OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp} Namespace Reference

Classes

struct  Foot
struct  Witness
struct  BoxEntry

Functions

double box_distance (const Contour &c, const Vec2d &p)
Foot closest (const Contour &c, const Vec2d &p, double stop=-1.0, const std::vector< Vec2d > *source_normals=nullptr, double normal_cosine=0.0)
std::vector< Vec2d > normals (const Contour &c, const Vec2d &p)

Class Documentation

◆ Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::Foot

struct Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::Foot
Class Members
double distance = std::numeric_limits<double>::infinity()
Vec2d point = Vec2d::Zero()

◆ Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::Witness

struct Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::Witness
Class Members
double angle_degrees
size_t contour
double distance

Function Documentation

◆ box_distance()

double Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::box_distance ( const Contour & c,
const Vec2d & p )
32 {
33 return ((c.min - p).cwiseMax(Vec2d::Zero()) + (p - c.max).cwiseMax(Vec2d::Zero())).norm();
34}
Vec2d max
Definition SeamContour.hpp:21
Vec2d min
Definition SeamContour.hpp:20

References box_distance(), Slic3r::SeamContour::Contour::max, and Slic3r::SeamContour::Contour::min.

Referenced by box_distance().

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

◆ closest()

Foot Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::closest ( const Contour & c,
const Vec2d & p,
double stop = -1.0,
const std::vector< Vec2d > * source_normals = nullptr,
double normal_cosine = 0.0 )
37 {
38 Foot result;
39 if (stop >= 0.0 && !source_normals)
40 for (const Vec2d &vertex : c.points)
41 if ((vertex - p).norm() <= stop) return {vertex, (vertex - p).norm()};
42 for (size_t i = 0; i < c.points.size(); ++i) {
43 const Vec2d &a = c.points[i];
44 const Vec2d d = c.points[(i + 1) % c.points.size()] - a;
45 const double length2 = d.squaredNorm();
46 if (source_normals) {
47 if (length2 <= 1e-18) continue;
48 const Vec2d normal = (c.hole ? -1.0 : 1.0) * Vec2d(d.y(), -d.x()) / std::sqrt(length2);
49 // A thin contour's nearest opposite side must not hide its slightly farther facing side.
50 if (std::none_of(source_normals->begin(), source_normals->end(), [&](const Vec2d &n) {
51 return n.dot(normal) >= normal_cosine;
52 })) continue;
53 }
54 const double t = length2 > 0.0 ? std::clamp((p - a).dot(d) / length2, 0.0, 1.0) : 0.0;
55 const Vec2d q = a + t * d;
56 const double distance = (q - p).norm();
57 if (distance < result.distance) result = {q, distance};
58 if (result.distance <= stop) break; // A proximity certificate needs no exact closest point.
59 }
60 return result;
61}
std::vector< Vec2d > points
Definition SeamContour.hpp:15
bool hole
Definition SeamContour.hpp:16
Point normal(Point pt, double scale)
Definition TreeSupport.cpp:112
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
T dot(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:154

References closest(), Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::Foot::distance, Slic3r::dot(), Slic3r::SeamContour::Contour::hole, Slic3r::normal(), and Slic3r::SeamContour::Contour::points.

Referenced by closest().

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

◆ normals()

std::vector< Vec2d > Slic3r::SeamContour::anonymous_namespace{SeamContour.cpp}::normals ( const Contour & c,
const Vec2d & p )
63 {
64 std::vector<Vec2d> result;
65 for (size_t i = 0; i < c.points.size(); ++i) {
66 const Vec2d &a = c.points[i];
67 const Vec2d d = c.points[(i + 1) % c.points.size()] - a;
68 if (d.squaredNorm() <= 1e-18) continue;
69 const double t = std::clamp((p - a).dot(d) / d.squaredNorm(), 0.0, 1.0);
70 // Every caller supplies a vertex or closest foot on this boundary; avoid a second full search.
71 if ((a + t * d - p).norm() <= 1e-6) {
72 // Candidate polygons are CCW; a hole has material on their opposite side.
73 const Vec2d n(d.y(), -d.x());
74 result.push_back((c.hole ? -1.0 : 1.0) * n.normalized());
75 }
76 }
77 return result;
78}

References Slic3r::dot(), Slic3r::SeamContour::Contour::hole, normals(), and Slic3r::SeamContour::Contour::points.

Referenced by normals().

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