Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Voronoi::Internal Namespace Reference

Typedefs

using VD = Geometry::VoronoiDiagram
 
typedef double coordinate_type
 
typedef boost::polygon::point_data< coordinate_typepoint_type
 
typedef boost::polygon::segment_data< coordinate_typesegment_type
 
typedef boost::polygon::rectangle_data< coordinate_typerect_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

typedef VD::cell_container_type Slic3r::Voronoi::Internal::cell_container_type

◆ cell_type

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

◆ const_cell_iterator

typedef VD::const_cell_iterator Slic3r::Voronoi::Internal::const_cell_iterator

◆ const_edge_iterator

typedef VD::const_edge_iterator Slic3r::Voronoi::Internal::const_edge_iterator

◆ const_vertex_iterator

typedef VD::const_vertex_iterator Slic3r::Voronoi::Internal::const_vertex_iterator

◆ coordinate_type

◆ edge_container_type

typedef VD::edge_container_type Slic3r::Voronoi::Internal::edge_container_type

◆ edge_type

typedef VD::edge_type Slic3r::Voronoi::Internal::edge_type

◆ point_type

typedef boost::polygon::point_data<coordinate_type> Slic3r::Voronoi::Internal::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

typedef VD::cell_container_type Slic3r::Voronoi::Internal::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
244 {
245 assert(edge.is_infinite());
246 assert((edge.vertex0() == nullptr) != (edge.vertex1() == nullptr));
247
248 const cell_type& cell1 = *edge.cell();
249 const cell_type& cell2 = *edge.twin()->cell();
250 // Infinite edges could not be created by two segment sites.
251 assert(cell1.contains_point() || cell2.contains_point());
252 if (! cell1.contains_point() && ! cell2.contains_point()) {
253 printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n");
254 return;
255 }
256 point_type direction;
257 if (cell1.contains_point() && cell2.contains_point()) {
258 assert(! edge.is_secondary());
259 point_type p1 = retrieve_point(points, segments, cell1);
260 point_type p2 = retrieve_point(points, segments, cell2);
261 if (edge.vertex0() == nullptr)
262 std::swap(p1, p2);
263 direction.x(p1.y() - p2.y());
264 direction.y(p2.x() - p1.x());
265 } else {
266 assert(edge.is_secondary());
267 segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
268 direction.x(high(segment).y() - low(segment).y());
269 direction.y(low(segment).x() - high(segment).x());
270 }
271 coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
272 if (edge.vertex0() == nullptr) {
273 clipped_edge->push_back(point_type(edge.vertex1()->x() + direction.x() * koef, edge.vertex1()->y() + direction.y() * koef));
274 clipped_edge->push_back(point_type(edge.vertex1()->x(), edge.vertex1()->y()));
275 } else {
276 clipped_edge->push_back(point_type(edge.vertex0()->x(), edge.vertex0()->y()));
277 clipped_edge->push_back(point_type(edge.vertex0()->x() + direction.x() * koef, edge.vertex0()->y() + direction.y() * koef));
278 }
279 }
EIGEN_DEVICE_FUNC SegmentReturnType segment(Index start, Index n)
This is the const version of segment(Index,Index).
Definition BlockMethods.h:888
VD::cell_type cell_type
Definition VoronoiVisualUtils.hpp:203
boost::polygon::point_data< coordinate_type > point_type
Definition VoronoiVisualUtils.hpp:200

References retrieve_point(), and segment().

Referenced by 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
217 {
218 if (edge->color() == EXTERNAL_COLOR)
219 return;
220 edge->color(EXTERNAL_COLOR);
221 edge->twin()->color(EXTERNAL_COLOR);
222 const VD::vertex_type* v = edge->vertex1();
223 if (v == NULL || !edge->is_primary())
224 return;
225 v->color(EXTERNAL_COLOR);
226 const VD::edge_type* e = v->incident_edge();
227 do {
229 e = e->rot_next();
230 } while (e != v->incident_edge());
231 }
void color_exterior(const VD::edge_type *edge)
Definition VoronoiVisualUtils.hpp:216

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
234 {
235 assert(cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT || cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT ||
236 cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT);
237 return cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT ?
238 Voronoi::Internal::point_type(double(points[cell.source_index()].x()), double(points[cell.source_index()].y())) :
239 (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ?
240 low(segments[cell.source_index()]) : high(segments[cell.source_index()]);
241 }
Definition args.hpp:18

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
282 {
283 point_type point = edge.cell()->contains_point() ?
284 retrieve_point(points, segments, *edge.cell()) :
285 retrieve_point(points, segments, *edge.twin()->cell());
286 segment_type segment = edge.cell()->contains_point() ?
287 segments[edge.twin()->cell()->source_index()] :
288 segments[edge.cell()->source_index()];
290 }
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:57
point_type retrieve_point(const Points &points, const std::vector< segment_type > &segments, const cell_type &cell)
Definition VoronoiVisualUtils.hpp:233
boost::polygon::segment_data< coordinate_type > segment_type
Definition VoronoiVisualUtils.hpp:201

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

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