Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::SurfaceMesh Class Reference

#include <src/libslic3r/SurfaceMesh.hpp>

+ Collaboration diagram for Slic3r::SurfaceMesh:

Public Member Functions

 SurfaceMesh (const indexed_triangle_set &its)
 
 SurfaceMesh (const SurfaceMesh &)=delete
 
SurfaceMeshoperator= (const SurfaceMesh &)=delete
 
Vertex_index source (Halfedge_index h) const
 
Vertex_index target (Halfedge_index h) const
 
Face_index face (Halfedge_index h) const
 
Halfedge_index next (Halfedge_index h) const
 
Halfedge_index prev (Halfedge_index h) const
 
Halfedge_index halfedge (Vertex_index v) const
 
Halfedge_index halfedge (Face_index f) const
 
Halfedge_index opposite (Halfedge_index h) const
 
Halfedge_index next_around_target (Halfedge_index h) const
 
Halfedge_index prev_around_target (Halfedge_index h) const
 
Halfedge_index next_around_source (Halfedge_index h) const
 
Halfedge_index prev_around_source (Halfedge_index h) const
 
Halfedge_index halfedge (Vertex_index source, Vertex_index target) const
 
const stl_vertexpoint (Vertex_index v) const
 
size_t degree (Vertex_index v) const
 
size_t degree (Face_index f) const
 
bool is_border (Halfedge_index h) const
 
bool is_same_vertex (const Vertex_index &a, const Vertex_index &b) const
 
Vec3i get_face_neighbors (Face_index face_id) const
 

Private Attributes

const std::vector< Vec3im_face_neighbors
 
const indexed_triangle_setm_its
 

Detailed Description

Constructor & Destructor Documentation

◆ SurfaceMesh() [1/2]

Slic3r::SurfaceMesh::SurfaceMesh ( const indexed_triangle_set its)
inlineexplicit
57 : m_its(its),
59 {}
const indexed_triangle_set & m_its
Definition SurfaceMesh.hpp:158
const std::vector< Vec3i > m_face_neighbors
Definition SurfaceMesh.hpp:157
std::vector< Vec3i > its_face_neighbors_par(const indexed_triangle_set &its)
Definition TriangleMesh.cpp:1525

◆ SurfaceMesh() [2/2]

Slic3r::SurfaceMesh::SurfaceMesh ( const SurfaceMesh )
delete

Member Function Documentation

◆ degree() [1/2]

size_t Slic3r::SurfaceMesh::degree ( Face_index  f) const
inline
137 {
138 size_t total = 0;
139 for (unsigned char i=0; i<3; ++i) {
140 size_t d = degree(Vertex_index(f, i));
141 if (d == 0)
142 return 0;
143 total += d;
144 }
145 assert(total - 6 >= 0);
146 return total - 6; // we counted 3 halfedges from f, and one more for each neighbor
147 }
size_t degree(Vertex_index v) const
Definition SurfaceMesh.hpp:118
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:12

References degree(), and Slic3r::f().

+ Here is the call graph for this function:

◆ degree() [2/2]

size_t Slic3r::SurfaceMesh::degree ( Vertex_index  v) const
inline
119 {
120 // In case the mesh is broken badly, the loop might end up to be infinite,
121 // never getting back to the first halfedge. Remember list of all half-edges
122 // and trip if any is encountered for the second time.
123 Halfedge_index h_first = halfedge(v);
124 boost::container::small_vector<Halfedge_index, 10> he_visited;
125 Halfedge_index h = next_around_target(h_first);
126 size_t degree = 2;
127 while (! h.is_invalid() && h != h_first) {
128 he_visited.emplace_back(h);
129 h = next_around_target(h);
130 if (std::find(he_visited.begin(), he_visited.end(), h) == he_visited.end())
131 return 0;
132 ++degree;
133 }
134 return h.is_invalid() ? 0 : degree - 1;
135 }
Halfedge_index halfedge(Vertex_index v) const
Definition SurfaceMesh.hpp:69
Halfedge_index next_around_target(Halfedge_index h) const
Definition SurfaceMesh.hpp:92

References degree(), halfedge(), Slic3r::Halfedge_index::is_invalid(), and next_around_target().

Referenced by degree(), and degree().

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

◆ face()

Face_index Slic3r::SurfaceMesh::face ( Halfedge_index  h) const
inline
65{ assert(! h.is_invalid()); return h.m_face; }

References Slic3r::Halfedge_index::is_invalid(), and Slic3r::Halfedge_index::m_face.

Referenced by Slic3r::Measure::MeasuringImpl::update_planes().

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

◆ get_face_neighbors()

Vec3i Slic3r::SurfaceMesh::get_face_neighbors ( Face_index  face_id) const
inline
152{ assert(int(face_id) < int(m_face_neighbors.size())); return m_face_neighbors[face_id]; }

References m_face_neighbors.

◆ halfedge() [1/3]

Halfedge_index Slic3r::SurfaceMesh::halfedge ( Face_index  f) const
inline
70{ return Halfedge_index(f, 0); }

References Slic3r::f().

+ Here is the call graph for this function:

◆ halfedge() [2/3]

Halfedge_index Slic3r::SurfaceMesh::halfedge ( Vertex_index  source,
Vertex_index  target 
) const
inline
97 {
98 Halfedge_index hi(source.m_face, source.m_vertex_idx);
99 assert(! hi.is_invalid());
100
101 const Vertex_index orig_target = this->target(hi);
102 Vertex_index current_target = orig_target;
103
104 while (! is_same_vertex(current_target, target)) {
105 hi = next_around_source(hi);
106 if (hi.is_invalid())
107 break;
108 current_target = this->target(hi);
109 if (is_same_vertex(current_target, orig_target))
110 return Halfedge_index(); // invalid
111 }
112
113 return hi;
114 }
Vertex_index source(Halfedge_index h) const
Definition SurfaceMesh.hpp:63
Halfedge_index next_around_source(Halfedge_index h) const
Definition SurfaceMesh.hpp:94
Vertex_index target(Halfedge_index h) const
Definition SurfaceMesh.hpp:64
bool is_same_vertex(const Vertex_index &a, const Vertex_index &b) const
Definition SurfaceMesh.hpp:151
unsigned char m_vertex_idx
Definition SurfaceMesh.hpp:49
Face_index m_face
Definition SurfaceMesh.hpp:48

References Slic3r::Halfedge_index::is_invalid(), is_same_vertex(), Slic3r::Vertex_index::m_face, Slic3r::Vertex_index::m_vertex_idx, next_around_source(), source(), and target().

+ Here is the call graph for this function:

◆ halfedge() [3/3]

Halfedge_index Slic3r::SurfaceMesh::halfedge ( Vertex_index  v) const
inline
69{ return Halfedge_index(v.m_face, (v.m_vertex_idx == 0 ? 2 : v.m_vertex_idx - 1)); }

References Slic3r::Vertex_index::m_face, and Slic3r::Vertex_index::m_vertex_idx.

Referenced by degree(), opposite(), and Slic3r::Measure::MeasuringImpl::update_planes().

+ Here is the caller graph for this function:

◆ is_border()

bool Slic3r::SurfaceMesh::is_border ( Halfedge_index  h) const
inline
149{ return m_face_neighbors[h.m_face][h.m_side] == -1; }

References Slic3r::Halfedge_index::m_face, m_face_neighbors, and Slic3r::Halfedge_index::m_side.

◆ is_same_vertex()

bool Slic3r::SurfaceMesh::is_same_vertex ( const Vertex_index a,
const Vertex_index b 
) const
inline
151{ return m_its.indices[a.m_face][a.m_vertex_idx] == m_its.indices[b.m_face][b.m_vertex_idx]; }
std::vector< stl_triangle_vertex_indices > indices
Definition stl.h:164

References indexed_triangle_set::indices, and m_its.

Referenced by halfedge(), and opposite().

+ Here is the caller graph for this function:

◆ next()

Halfedge_index Slic3r::SurfaceMesh::next ( Halfedge_index  h) const
inline
67{ assert(! h.is_invalid()); h.m_side = (h.m_side + 1) % 3; return h; }

References Slic3r::Halfedge_index::is_invalid(), and Slic3r::Halfedge_index::m_side.

Referenced by next_around_source(), next_around_target(), opposite(), and Slic3r::Measure::MeasuringImpl::update_planes().

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

◆ next_around_source()

Halfedge_index Slic3r::SurfaceMesh::next_around_source ( Halfedge_index  h) const
inline
94{ Halfedge_index op = opposite(h); return (op.is_invalid() ? Halfedge_index() : next(op)); }
Halfedge_index opposite(Halfedge_index h) const
Definition SurfaceMesh.hpp:71
Halfedge_index next(Halfedge_index h) const
Definition SurfaceMesh.hpp:67

References Slic3r::Halfedge_index::is_invalid(), next(), and opposite().

Referenced by halfedge().

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

◆ next_around_target()

Halfedge_index Slic3r::SurfaceMesh::next_around_target ( Halfedge_index  h) const
inline
92{ return opposite(next(h)); }

References next(), and opposite().

Referenced by degree(), and Slic3r::Measure::MeasuringImpl::update_planes().

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

◆ operator=()

SurfaceMesh & Slic3r::SurfaceMesh::operator= ( const SurfaceMesh )
delete

◆ opposite()

Halfedge_index Slic3r::SurfaceMesh::opposite ( Halfedge_index  h) const
inline
71 {
72 if (h.is_invalid())
73 return h;
74
75 int face_idx = m_face_neighbors[h.m_face][h.m_side];
76 Halfedge_index h_candidate = halfedge(Face_index(face_idx));
77
78 if (h_candidate.is_invalid())
79 return Halfedge_index(); // invalid
80
81 for (int i=0; i<3; ++i) {
82 if (is_same_vertex(source(h_candidate), target(h))) {
83 // Meshes in PrusaSlicer should be fixed enough for the following not to happen.
84 assert(is_same_vertex(target(h_candidate), source(h)));
85 return h_candidate;
86 }
87 h_candidate = next(h_candidate);
88 }
89 return Halfedge_index(); // invalid
90 }

References halfedge(), Slic3r::Halfedge_index::is_invalid(), is_same_vertex(), Slic3r::Halfedge_index::m_face, m_face_neighbors, Slic3r::Halfedge_index::m_side, next(), source(), and target().

Referenced by next_around_source(), next_around_target(), prev_around_source(), prev_around_target(), and Slic3r::Measure::MeasuringImpl::update_planes().

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

◆ point()

const stl_vertex & Slic3r::SurfaceMesh::point ( Vertex_index  v) const
inline
116{ return m_its.vertices[m_its.indices[v.m_face][v.m_vertex_idx]]; }
std::vector< stl_vertex > vertices
Definition stl.h:165

References indexed_triangle_set::indices, Slic3r::Vertex_index::m_face, m_its, Slic3r::Vertex_index::m_vertex_idx, and indexed_triangle_set::vertices.

Referenced by Slic3r::Measure::MeasuringImpl::update_planes().

+ Here is the caller graph for this function:

◆ prev()

Halfedge_index Slic3r::SurfaceMesh::prev ( Halfedge_index  h) const
inline
68{ assert(! h.is_invalid()); h.m_side = (h.m_side == 0 ? 2 : h.m_side - 1); return h; }

References Slic3r::Halfedge_index::is_invalid(), and Slic3r::Halfedge_index::m_side.

Referenced by prev_around_source(), and prev_around_target().

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

◆ prev_around_source()

Halfedge_index Slic3r::SurfaceMesh::prev_around_source ( Halfedge_index  h) const
inline
95{ return opposite(prev(h)); }
Halfedge_index prev(Halfedge_index h) const
Definition SurfaceMesh.hpp:68

References opposite(), and prev().

+ Here is the call graph for this function:

◆ prev_around_target()

Halfedge_index Slic3r::SurfaceMesh::prev_around_target ( Halfedge_index  h) const
inline
93{ Halfedge_index op = opposite(h); return (op.is_invalid() ? Halfedge_index() : prev(op)); }

References Slic3r::Halfedge_index::is_invalid(), opposite(), and prev().

+ Here is the call graph for this function:

◆ source()

Vertex_index Slic3r::SurfaceMesh::source ( Halfedge_index  h) const
inline
63{ assert(! h.is_invalid()); return Vertex_index(h.m_face, h.m_side); }

References Slic3r::Halfedge_index::is_invalid(), Slic3r::Halfedge_index::m_face, and Slic3r::Halfedge_index::m_side.

Referenced by halfedge(), opposite(), and Slic3r::Measure::MeasuringImpl::update_planes().

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

◆ target()

Vertex_index Slic3r::SurfaceMesh::target ( Halfedge_index  h) const
inline
64{ assert(! h.is_invalid()); return Vertex_index(h.m_face, h.m_side == 2 ? 0 : h.m_side + 1); }

References Slic3r::Halfedge_index::is_invalid(), Slic3r::Halfedge_index::m_face, and Slic3r::Halfedge_index::m_side.

Referenced by halfedge(), and opposite().

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

Member Data Documentation

◆ m_face_neighbors

const std::vector<Vec3i> Slic3r::SurfaceMesh::m_face_neighbors
private

◆ m_its

const indexed_triangle_set& Slic3r::SurfaceMesh::m_its
private

Referenced by is_same_vertex(), and point().


The documentation for this class was generated from the following file: