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

Functions

bool verify_twin_halfedges_successive (const VD &vd, const Lines &lines)
bool verify_inside_outside_annotations (const VD &vd)
bool verify_vertices_on_contour (const VD &vd, const Lines &lines)
bool verify_signed_distances (const VD &vd, const Lines &lines, const std::vector< double > &signed_distances)
bool verify_offset_intersection_points (const VD &vd, const Lines &lines, const double offset_distance, const std::vector< Vec2d > &offset_intersection_points)

Function Documentation

◆ verify_inside_outside_annotations()

bool Slic3r::Voronoi::debug::verify_inside_outside_annotations ( const VD & vd)
480 {
481 // Verify that "Colors" are set at all Voronoi entities.
482 for (const VD::vertex_type &v : vd.vertices()) {
483 assert(! v.is_degenerate());
485 }
486 for (const VD::edge_type &e : vd.edges())
488 for (const VD::cell_type &c : vd.cells()) {
489 // Unfortunately denegerate cells could be created, which reference a null edge.
490 // https://github.com/boostorg/polygon/issues/47
491 assert(c.is_degenerate() || cell_category(c) != CellCategory::Unknown);
492 }
493
494 // Verify consistency between markings of Voronoi cells, edges and verticies.
495 for (const VD::cell_type &cell : vd.cells()) {
496 if (cell.is_degenerate()) {
497 // Unfortunately denegerate cells could be created, which reference a null edge.
498 // https://github.com/boostorg/polygon/issues/47
499 continue;
500 }
501 const VD::edge_type *first_edge = cell.incident_edge();
502 const VD::edge_type *edge = first_edge;
503 CellCategory cc = cell_category(cell);
504 size_t num_vertices_on_contour = 0;
505 size_t num_vertices_inside = 0;
506 size_t num_vertices_outside = 0;
507 size_t num_edges_point_to_contour = 0;
508 size_t num_edges_point_inside = 0;
509 size_t num_edges_point_outside = 0;
510 do {
511 {
512 EdgeCategory ec = edge_category(edge);
513 switch (ec) {
515 assert(edge->vertex0() != nullptr && edge->vertex1() != nullptr);
516 ++ num_edges_point_inside; break;
518// assert(edge->vertex0() != nullptr);
519 ++ num_edges_point_outside; break;
521 assert(edge->vertex1() != nullptr);
522 ++ num_edges_point_to_contour; break;
523 default:
524 assert(false);
525 }
526 }
527 {
528 VertexCategory vc = (edge->vertex1() == nullptr) ? VertexCategory::Outside : vertex_category(edge->vertex1());
529 switch (vc) {
531 ++ num_vertices_inside; break;
533 ++ num_vertices_outside; break;
535 ++ num_vertices_on_contour; break;
536 default:
537 assert(false);
538 }
539 }
540 {
541 const VD::cell_type *cell_other = edge->twin()->cell();
542 const CellCategory cc_other = cell_category(cell_other);
543 assert(cc_other != CellCategory::Unknown);
544 switch (cc) {
546 assert(cc_other != CellCategory::Boundary || cell_other->contains_segment());
547 break;
549 assert(cc_other == CellCategory::Inside || cc_other ==CellCategory::Boundary);
550 break;
552 assert(cc_other == CellCategory::Outside || cc_other == CellCategory::Boundary);
553 break;
554 default:
555 assert(false);
556 break;
557 }
558 }
559 edge = edge->next();
560 } while (edge != first_edge);
561
562 switch (cc) {
564 assert(cell.contains_segment());
565 assert(num_edges_point_to_contour == 2);
566 assert(num_vertices_on_contour == 2);
567 assert(num_vertices_inside > 0);
568 assert(num_vertices_outside > 0);
569 assert(num_edges_point_inside > 0);
570 assert(num_edges_point_outside > 0);
571 break;
573 assert(num_vertices_on_contour <= 1);
574 assert(num_edges_point_to_contour <= 1);
575 assert(num_vertices_inside > 0);
576 assert(num_vertices_outside == 0);
577 assert(num_edges_point_inside > 0);
578 assert(num_edges_point_outside == 0);
579 break;
581 assert(num_vertices_on_contour <= 1);
582 assert(num_edges_point_to_contour <= 1);
583 assert(num_vertices_inside == 0);
584 assert(num_vertices_outside > 0);
585 assert(num_edges_point_inside == 0);
586 assert(num_edges_point_outside > 0);
587 break;
588 default:
589 assert(false);
590 break;
591 }
592 }
593
594 return true;
595 }
const vertex_container_type & vertices() const
Definition Voronoi.hpp:81
voronoi_diagram_type::cell_type cell_type
Definition Voronoi.hpp:42
voronoi_diagram_type::vertex_type vertex_type
Definition Voronoi.hpp:40
voronoi_diagram_type::edge_type edge_type
Definition Voronoi.hpp:41
const edge_container_type & edges() const
Definition Voronoi.hpp:83
const cell_container_type & cells() const
Definition Voronoi.hpp:85
EdgeCategory
Definition VoronoiOffset.hpp:53
@ PointsOutside
Definition VoronoiOffset.hpp:59
@ Unknown
Definition VoronoiOffset.hpp:61
@ PointsToContour
Definition VoronoiOffset.hpp:55
@ PointsInside
Definition VoronoiOffset.hpp:57
CellCategory
Definition VoronoiOffset.hpp:66
@ Outside
Definition VoronoiOffset.hpp:72
@ Unknown
Definition VoronoiOffset.hpp:74
@ Inside
Definition VoronoiOffset.hpp:70
@ Boundary
Definition VoronoiOffset.hpp:68
CellCategory cell_category(const VD::cell_type &v)
Definition VoronoiOffset.hpp:95
VertexCategory vertex_category(const VD::vertex_type &v)
Definition VoronoiOffset.hpp:77
VertexCategory
Definition VoronoiOffset.hpp:36
@ OnContour
Definition VoronoiOffset.hpp:40
@ Outside
Definition VoronoiOffset.hpp:44
@ Unknown
Definition VoronoiOffset.hpp:46
@ Inside
Definition VoronoiOffset.hpp:42
EdgeCategory edge_category(const VD::edge_type &e)
Definition VoronoiOffset.hpp:86

References Slic3r::Voronoi::Boundary, Slic3r::Voronoi::cell_category(), Slic3r::Geometry::VoronoiDiagram::cells(), Slic3r::Voronoi::edge_category(), Slic3r::Geometry::VoronoiDiagram::edges(), Slic3r::Voronoi::Inside, Slic3r::Voronoi::OnContour, Slic3r::Voronoi::Outside, Slic3r::Voronoi::PointsInside, Slic3r::Voronoi::PointsOutside, Slic3r::Voronoi::PointsToContour, Slic3r::Voronoi::Unknown, Slic3r::Voronoi::vertex_category(), and Slic3r::Geometry::VoronoiDiagram::vertices().

Referenced by Slic3r::Voronoi::annotate_inside_outside(), Slic3r::Voronoi::edge_offset_contour_intersections(), Slic3r::Voronoi::signed_vertex_distances(), and Slic3r::Voronoi::skeleton_edges_rough().

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

◆ verify_offset_intersection_points()

bool Slic3r::Voronoi::debug::verify_offset_intersection_points ( const VD & vd,
const Lines & lines,
const double offset_distance,
const std::vector< Vec2d > & offset_intersection_points )
632 {
633 const VD::edge_type *front_edge = &vd.edges().front();
634 const double d = std::abs(offset_distance);
635 for (const VD::edge_type &edge : vd.edges()) {
636 const Vec2d &p = offset_intersection_points[&edge - front_edge];
638 double err = std::abs(detail::dist_to_site(lines, *edge.cell(), p) - d);
639 double err2 = std::abs(detail::dist_to_site(lines, *edge.twin()->cell(), p) - d);
640 assert(err < SCALED_EPSILON);
641 assert(err2 < SCALED_EPSILON);
642 }
643 }
644 return true;
645 }
#define SCALED_EPSILON
Definition libslic3r.h:109
double dist_to_site(const Lines &lines, const VD::cell_type &cell, const Vec2d &point)
Definition VoronoiOffset.cpp:238
static bool edge_offset_has_intersection(const Vec2d &intersection_point)
Definition VoronoiOffset.hpp:117
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::Voronoi::detail::dist_to_site(), Slic3r::Voronoi::edge_offset_has_intersection(), Slic3r::Geometry::VoronoiDiagram::edges(), and SCALED_EPSILON.

Referenced by Slic3r::Voronoi::edge_offset_contour_intersections().

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

◆ verify_signed_distances()

bool Slic3r::Voronoi::debug::verify_signed_distances ( const VD & vd,
const Lines & lines,
const std::vector< double > & signed_distances )
611 {
612 for (const VD::edge_type &edge : vd.edges()) {
613 const VD::vertex_type *v = edge.vertex0();
614 double d = (v == nullptr) ? std::numeric_limits<double>::max() : signed_distances[v - &vd.vertices().front()];
615 if (v == nullptr || vertex_category(v) == VertexCategory::Outside)
616 assert(d > 0.);
618 assert(d == 0.);
619 else
620 assert(d < 0.);
621 if (v != nullptr) {
622 double err = std::abs(detail::dist_to_site(lines, *edge.cell(), vertex_point(v)) - std::abs(d));
623 double err2 = std::abs(detail::dist_to_site(lines, *edge.twin()->cell(), vertex_point(v)) - std::abs(d));
624 assert(err < SCALED_EPSILON);
625 assert(err2 < SCALED_EPSILON);
626 }
627 }
628 return true;
629 }
Vec2d vertex_point(const VD::vertex_type &v)
Definition VoronoiOffset.hpp:31

References Slic3r::Voronoi::detail::dist_to_site(), Slic3r::Geometry::VoronoiDiagram::edges(), Slic3r::Voronoi::OnContour, Slic3r::Voronoi::Outside, SCALED_EPSILON, Slic3r::Voronoi::vertex_category(), Slic3r::Voronoi::vertex_point(), and Slic3r::Geometry::VoronoiDiagram::vertices().

Referenced by Slic3r::Voronoi::signed_vertex_distances().

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

◆ verify_twin_halfedges_successive()

bool Slic3r::Voronoi::debug::verify_twin_halfedges_successive ( const VD & vd,
const Lines & lines )
458 {
459 for (size_t i = 0; i < vd.num_edges(); i += 2) {
460 const VD::edge_type &e = vd.edges()[i];
461 const VD::edge_type &e2 = vd.edges()[i + 1];
462 assert(e.twin() == &e2);
463 assert(e2.twin() == &e);
464 assert(e.is_secondary() == e2.is_secondary());
465 if (e.is_secondary()) {
466 assert(e.cell()->contains_point() != e2.cell()->contains_point());
467 const VD::edge_type &ex = (e.cell()->contains_point() ? e : e2);
468 // Verify that the Point defining the cell left of ex is an end point of a segment
469 // defining the cell right of ex.
470 const Line &line0 = lines[ex.cell()->source_index()];
471 const Line &line1 = lines[ex.twin()->cell()->source_index()];
472 const Point &pt = (ex.cell()->source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line0.a : line0.b;
473 assert(pt == line1.a || pt == line1.b);
474 }
475 }
476 return true;
477 }
std::size_t num_edges() const
Definition Voronoi.hpp:89
Definition Line.hpp:156
Point b
Definition Line.hpp:199
Point a
Definition Line.hpp:198
Definition Point.hpp:199

References Slic3r::Line::a, Slic3r::Line::b, Slic3r::Geometry::VoronoiDiagram::edges(), and Slic3r::Geometry::VoronoiDiagram::num_edges().

Referenced by Slic3r::Voronoi::annotate_inside_outside().

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

◆ verify_vertices_on_contour()

bool Slic3r::Voronoi::debug::verify_vertices_on_contour ( const VD & vd,
const Lines & lines )
598 {
599 for (const VD::edge_type &edge : vd.edges()) {
600 const VD::vertex_type *v = edge.vertex0();
601 if (v != nullptr) {
602 bool on_contour = vertex_category(v) == VertexCategory::OnContour;
603 assert(detail::on_site(lines, *edge.cell(), vertex_point(v)) == on_contour);
604 assert(detail::on_site(lines, *edge.twin()->cell(), vertex_point(v)) == on_contour);
605 }
606 }
607 return true;
608 }
bool on_site(const Lines &lines, const VD::cell_type &cell, const Vec2d &pt)
Definition VoronoiOffset.cpp:246

References Slic3r::Geometry::VoronoiDiagram::edges(), Slic3r::Voronoi::detail::on_site(), Slic3r::Voronoi::OnContour, Slic3r::Voronoi::vertex_category(), and Slic3r::Voronoi::vertex_point().

Referenced by Slic3r::Voronoi::annotate_inside_outside().

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