OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Voronoi::Internal Namespace Reference

Typedefs

using VD = Geometry::VoronoiDiagram
typedef double coordinate_type
typedef boost::polygon::point_data< coordinate_type > point_type
typedef boost::polygon::segment_data< coordinate_type > segment_type
typedef boost::polygon::rectangle_data< coordinate_type > rect_type
typedef VD::cell_type cell_type
typedef VD::cell_type::source_index_type source_index_type
typedef VD::cell_type::source_category_type source_category_type
typedef VD::edge_type edge_type
typedef VD::cell_container_type cell_container_type
typedef VD::cell_container_type vertex_container_type
typedef VD::edge_container_type edge_container_type
typedef VD::const_cell_iterator const_cell_iterator
typedef VD::const_vertex_iterator const_vertex_iterator
typedef VD::const_edge_iterator const_edge_iterator

Functions

void color_exterior (const VD::edge_type *edge)
point_type retrieve_point (const Points &points, const std::vector< segment_type > &segments, const cell_type &cell)
void clip_infinite_edge (const Points &points, const std::vector< segment_type > &segments, const edge_type &edge, coordinate_type bbox_max_size, std::vector< point_type > *clipped_edge)
void sample_curved_edge (const Points &points, const std::vector< segment_type > &segments, const edge_type &edge, std::vector< point_type > &sampled_edge, coordinate_type max_dist)

Variables

static const std::size_t EXTERNAL_COLOR = 1

Typedef Documentation

◆ cell_container_type

◆ cell_type

◆ const_cell_iterator

◆ const_edge_iterator

◆ const_vertex_iterator

◆ coordinate_type

◆ edge_container_type

◆ edge_type

◆ point_type

◆ rect_type

typedef boost::polygon::rectangle_data<coordinate_type> Slic3r::Voronoi::Internal::rect_type

◆ segment_type

typedef boost::polygon::segment_data<coordinate_type> Slic3r::Voronoi::Internal::segment_type

◆ source_category_type

typedef VD::cell_type::source_category_type Slic3r::Voronoi::Internal::source_category_type

◆ source_index_type

typedef VD::cell_type::source_index_type Slic3r::Voronoi::Internal::source_index_type

◆ VD

◆ vertex_container_type

Function Documentation

◆ clip_infinite_edge()

void Slic3r::Voronoi::Internal::clip_infinite_edge ( const Points & points,
const std::vector< segment_type > & segments,
const edge_type & edge,
coordinate_type bbox_max_size,
std::vector< point_type > * clipped_edge )
inline
259 {
260 assert(edge.is_infinite());
261 assert((edge.vertex0() == nullptr) != (edge.vertex1() == nullptr));
262
263 const cell_type& cell1 = *edge.cell();
264 const cell_type& cell2 = *edge.twin()->cell();
265 // Infinite edges could not be created by two segment sites.
266 assert(cell1.contains_point() || cell2.contains_point());
267 if (! cell1.contains_point() && ! cell2.contains_point()) {
268 printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n");
269 return;
270 }
271 point_type direction;
272 if (cell1.contains_point() && cell2.contains_point()) {
273 assert(! edge.is_secondary());
274 point_type p1 = retrieve_point(points, segments, cell1);
275 point_type p2 = retrieve_point(points, segments, cell2);
276 if (edge.vertex0() == nullptr)
277 std::swap(p1, p2);
278 direction.x(p1.y() - p2.y());
279 direction.y(p2.x() - p1.x());
280 } else {
281 assert(edge.is_secondary());
282 segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
283 direction.x(high(segment).y() - low(segment).y());
284 direction.y(low(segment).x() - high(segment).x());
285 }
286 coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
287 if (edge.vertex0() == nullptr) {
288 clipped_edge->push_back(point_type(edge.vertex1()->x() + direction.x() * koef, edge.vertex1()->y() + direction.y() * koef));
289 clipped_edge->push_back(point_type(edge.vertex1()->x(), edge.vertex1()->y()));
290 } else {
291 clipped_edge->push_back(point_type(edge.vertex0()->x(), edge.vertex0()->y()));
292 clipped_edge->push_back(point_type(edge.vertex0()->x() + direction.x() * koef, edge.vertex0()->y() + direction.y() * koef));
293 }
294 }
VD::cell_type cell_type
Definition VoronoiVisualUtils.hpp:218
point_type retrieve_point(const Points &points, const std::vector< segment_type > &segments, const cell_type &cell)
Definition VoronoiVisualUtils.hpp:248
double coordinate_type
Definition VoronoiVisualUtils.hpp:214
boost::polygon::segment_data< coordinate_type > segment_type
Definition VoronoiVisualUtils.hpp:216
boost::polygon::point_data< coordinate_type > point_type
Definition VoronoiVisualUtils.hpp:215

References retrieve_point().

Referenced by Slic3r::build_graph(), and Slic3r::dump_voronoi_to_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ color_exterior()

void Slic3r::Voronoi::Internal::color_exterior ( const VD::edge_type * edge)
inline
232 {
233 if (edge->color() == EXTERNAL_COLOR)
234 return;
235 edge->color(EXTERNAL_COLOR);
236 edge->twin()->color(EXTERNAL_COLOR);
237 const VD::vertex_type* v = edge->vertex1();
238 if (v == NULL || !edge->is_primary())
239 return;
240 v->color(EXTERNAL_COLOR);
241 const VD::edge_type* e = v->incident_edge();
242 do {
244 e = e->rot_next();
245 } while (e != v->incident_edge());
246 }
voronoi_diagram_type::vertex_type vertex_type
Definition Voronoi.hpp:40
voronoi_diagram_type::edge_type edge_type
Definition Voronoi.hpp:41
static const std::size_t EXTERNAL_COLOR
Definition VoronoiVisualUtils.hpp:229
void color_exterior(const VD::edge_type *edge)
Definition VoronoiVisualUtils.hpp:231

References color_exterior(), and EXTERNAL_COLOR.

Referenced by color_exterior(), and Slic3r::dump_voronoi_to_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ retrieve_point()

point_type Slic3r::Voronoi::Internal::retrieve_point ( const Points & points,
const std::vector< segment_type > & segments,
const cell_type & cell )
inline
249 {
250 assert(cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT || cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT ||
251 cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT);
252 return cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT ?
253 Voronoi::Internal::point_type(double(points[cell.source_index()].x()), double(points[cell.source_index()].y())) :
254 (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ?
255 low(segments[cell.source_index()]) : high(segments[cell.source_index()]);
256 }
Definition PolygonsSegmentIndex.hpp:33

Referenced by clip_infinite_edge(), and sample_curved_edge().

Here is the caller graph for this function:

◆ sample_curved_edge()

void Slic3r::Voronoi::Internal::sample_curved_edge ( const Points & points,
const std::vector< segment_type > & segments,
const edge_type & edge,
std::vector< point_type > & sampled_edge,
coordinate_type max_dist )
inline
297 {
298 point_type point = edge.cell()->contains_point() ?
299 retrieve_point(points, segments, *edge.cell()) :
300 retrieve_point(points, segments, *edge.twin()->cell());
301 segment_type segment = edge.cell()->contains_point() ?
302 segments[edge.twin()->cell()->source_index()] :
303 segments[edge.cell()->source_index()];
304 ::boost::polygon::voronoi_visual_utils<coordinate_type>::discretize(point, segment, max_dist, &sampled_edge);
305 }
static enable_if< typenamegtl_and< typenamegtl_if< typenameis_point_concept< typenamegeometry_concept< Point< InCT1 > >::type >::type >::type, typenamegtl_if< typenameis_segment_concept< typenamegeometry_concept< Segment< InCT2 > >::type >::type >::type >::type, void >::type discretize(const Point< InCT1 > &point, const Segment< InCT2 > &segment, const CT max_dist, std::vector< Point< CT > > *discretization)
Definition VoronoiVisualUtils.hpp:72

References boost::polygon::voronoi_visual_utils< CT >::discretize(), and retrieve_point().

Referenced by Slic3r::dump_voronoi_to_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ EXTERNAL_COLOR

const std::size_t Slic3r::Voronoi::Internal::EXTERNAL_COLOR = 1
static