Prusa Slicer 2.6.0
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)
470 {
471 // Verify that "Colors" are set at all Voronoi entities.
472 for (const VD::vertex_type &v : vd.vertices()) {
473 assert(! v.is_degenerate());
474 assert(vertex_category(v) != VertexCategory::Unknown);
475 }
476 for (const VD::edge_type &e : vd.edges())
477 assert(edge_category(e) != EdgeCategory::Unknown);
478 for (const VD::cell_type &c : vd.cells()) {
479 // Unfortunately denegerate cells could be created, which reference a null edge.
480 // https://github.com/boostorg/polygon/issues/47
481 assert(c.is_degenerate() || cell_category(c) != CellCategory::Unknown);
482 }
483
484 // Verify consistency between markings of Voronoi cells, edges and verticies.
485 for (const VD::cell_type &cell : vd.cells()) {
486 if (cell.is_degenerate()) {
487 // Unfortunately denegerate cells could be created, which reference a null edge.
488 // https://github.com/boostorg/polygon/issues/47
489 continue;
490 }
491 const VD::edge_type *first_edge = cell.incident_edge();
492 const VD::edge_type *edge = first_edge;
493 CellCategory cc = cell_category(cell);
494 size_t num_vertices_on_contour = 0;
495 size_t num_vertices_inside = 0;
496 size_t num_vertices_outside = 0;
497 size_t num_edges_point_to_contour = 0;
498 size_t num_edges_point_inside = 0;
499 size_t num_edges_point_outside = 0;
500 do {
501 {
502 EdgeCategory ec = edge_category(edge);
503 switch (ec) {
504 case EdgeCategory::PointsInside:
505 assert(edge->vertex0() != nullptr && edge->vertex1() != nullptr);
506 ++ num_edges_point_inside; break;
507 case EdgeCategory::PointsOutside:
508// assert(edge->vertex0() != nullptr);
509 ++ num_edges_point_outside; break;
510 case EdgeCategory::PointsToContour:
511 assert(edge->vertex1() != nullptr);
512 ++ num_edges_point_to_contour; break;
513 default:
514 assert(false);
515 }
516 }
517 {
518 VertexCategory vc = (edge->vertex1() == nullptr) ? VertexCategory::Outside : vertex_category(edge->vertex1());
519 switch (vc) {
520 case VertexCategory::Inside:
521 ++ num_vertices_inside; break;
522 case VertexCategory::Outside:
523 ++ num_vertices_outside; break;
524 case VertexCategory::OnContour:
525 ++ num_vertices_on_contour; break;
526 default:
527 assert(false);
528 }
529 }
530 {
531 const VD::cell_type *cell_other = edge->twin()->cell();
532 const CellCategory cc_other = cell_category(cell_other);
533 assert(cc_other != CellCategory::Unknown);
534 switch (cc) {
535 case CellCategory::Boundary:
536 assert(cc_other != CellCategory::Boundary || cell_other->contains_segment());
537 break;
538 case CellCategory::Inside:
539 assert(cc_other == CellCategory::Inside || cc_other ==CellCategory::Boundary);
540 break;
541 case CellCategory::Outside:
542 assert(cc_other == CellCategory::Outside || cc_other == CellCategory::Boundary);
543 break;
544 default:
545 assert(false);
546 break;
547 }
548 }
549 edge = edge->next();
550 } while (edge != first_edge);
551
552 switch (cc) {
553 case CellCategory::Boundary:
554 assert(cell.contains_segment());
555 assert(num_edges_point_to_contour == 2);
556 assert(num_vertices_on_contour == 2);
557 assert(num_vertices_inside > 0);
558 assert(num_vertices_outside > 0);
559 assert(num_edges_point_inside > 0);
560 assert(num_edges_point_outside > 0);
561 break;
562 case CellCategory::Inside:
563 assert(num_vertices_on_contour <= 1);
564 assert(num_edges_point_to_contour <= 1);
565 assert(num_vertices_inside > 0);
566 assert(num_vertices_outside == 0);
567 assert(num_edges_point_inside > 0);
568 assert(num_edges_point_outside == 0);
569 break;
570 case CellCategory::Outside:
571 assert(num_vertices_on_contour <= 1);
572 assert(num_edges_point_to_contour <= 1);
573 assert(num_vertices_inside == 0);
574 assert(num_vertices_outside > 0);
575 assert(num_edges_point_inside == 0);
576 assert(num_edges_point_outside > 0);
577 break;
578 default:
579 assert(false);
580 break;
581 }
582 }
583
584 return true;
585 }
EdgeCategory
Definition VoronoiOffset.hpp:48
CellCategory
Definition VoronoiOffset.hpp:61
CellCategory cell_category(const VD::cell_type &v)
Definition VoronoiOffset.hpp:90
VertexCategory vertex_category(const VD::vertex_type &v)
Definition VoronoiOffset.hpp:72
VertexCategory
Definition VoronoiOffset.hpp:31
EdgeCategory edge_category(const VD::edge_type &e)
Definition VoronoiOffset.hpp:81

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

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 
)
622 {
623 const VD::edge_type *front_edge = &vd.edges().front();
624 const double d = std::abs(offset_distance);
625 for (const VD::edge_type &edge : vd.edges()) {
626 const Vec2d &p = offset_intersection_points[&edge - front_edge];
627 if (edge_offset_has_intersection(p)) {
628 double err = std::abs(detail::dist_to_site(lines, *edge.cell(), p) - d);
629 double err2 = std::abs(detail::dist_to_site(lines, *edge.twin()->cell(), p) - d);
630 assert(err < SCALED_EPSILON);
631 assert(err2 < SCALED_EPSILON);
632 }
633 }
634 return true;
635 }
#define SCALED_EPSILON
Definition libslic3r.h:71

References Slic3r::Voronoi::detail::dist_to_site(), Slic3r::Voronoi::edge_offset_has_intersection(), 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 
)
601 {
602 for (const VD::edge_type &edge : vd.edges()) {
603 const VD::vertex_type *v = edge.vertex0();
604 double d = (v == nullptr) ? std::numeric_limits<double>::max() : signed_distances[v - &vd.vertices().front()];
605 if (v == nullptr || vertex_category(v) == VertexCategory::Outside)
606 assert(d > 0.);
607 else if (vertex_category(v) == VertexCategory::OnContour)
608 assert(d == 0.);
609 else
610 assert(d < 0.);
611 if (v != nullptr) {
612 double err = std::abs(detail::dist_to_site(lines, *edge.cell(), vertex_point(v)) - std::abs(d));
613 double err2 = std::abs(detail::dist_to_site(lines, *edge.twin()->cell(), vertex_point(v)) - std::abs(d));
614 assert(err < SCALED_EPSILON);
615 assert(err2 < SCALED_EPSILON);
616 }
617 }
618 return true;
619 }
Vec2d vertex_point(const VD::vertex_type &v)
Definition VoronoiOffset.hpp:26

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

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 
)
448 {
449 for (size_t i = 0; i < vd.num_edges(); i += 2) {
450 const VD::edge_type &e = vd.edges()[i];
451 const VD::edge_type &e2 = vd.edges()[i + 1];
452 assert(e.twin() == &e2);
453 assert(e2.twin() == &e);
454 assert(e.is_secondary() == e2.is_secondary());
455 if (e.is_secondary()) {
456 assert(e.cell()->contains_point() != e2.cell()->contains_point());
457 const VD::edge_type &ex = (e.cell()->contains_point() ? e : e2);
458 // Verify that the Point defining the cell left of ex is an end point of a segment
459 // defining the cell right of ex.
460 const Line &line0 = lines[ex.cell()->source_index()];
461 const Line &line1 = lines[ex.twin()->cell()->source_index()];
462 const Point &pt = (ex.cell()->source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line0.a : line0.b;
463 assert(pt == line1.a || pt == line1.b);
464 }
465 }
466 return true;
467 }
Definition Line.hpp:155
Point b
Definition Line.hpp:198
Point a
Definition Line.hpp:197
Definition Point.hpp:158

References Slic3r::Line::a, and Slic3r::Line::b.

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

+ 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 
)
588 {
589 for (const VD::edge_type &edge : vd.edges()) {
590 const VD::vertex_type *v = edge.vertex0();
591 if (v != nullptr) {
592 bool on_contour = vertex_category(v) == VertexCategory::OnContour;
593 assert(detail::on_site(lines, *edge.cell(), vertex_point(v)) == on_contour);
594 assert(detail::on_site(lines, *edge.twin()->cell(), vertex_point(v)) == on_contour);
595 }
596 }
597 return true;
598 }

References 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: