OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SurfaceMesh Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/SurfaceMesh.hpp>

Collaboration diagram for Slic3r::SurfaceMesh:

Public Member Functions

 SurfaceMesh (const indexed_triangle_set &its)
 SurfaceMesh (const SurfaceMesh &)=delete
SurfaceMesh & operator= (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_vertex & point (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
Vec3i32 get_face_neighbors (Face_index face_id) const

Private Attributes

const std::vector< Vec3i32 > m_face_neighbors
const indexed_triangle_set & m_its

Detailed Description

Constructor & Destructor Documentation

◆ SurfaceMesh() [1/2]

Slic3r::SurfaceMesh::SurfaceMesh ( const indexed_triangle_set & its)
inlineexplicit
62 : m_its(its),
64 {}
const std::vector< Vec3i32 > m_face_neighbors
Definition SurfaceMesh.hpp:162
const indexed_triangle_set & m_its
Definition SurfaceMesh.hpp:163
std::vector< Vec3i32 > its_face_neighbors_par(const indexed_triangle_set &its)
Definition TriangleMesh.cpp:1620

References Slic3r::its_face_neighbors_par(), m_face_neighbors, and m_its.

Referenced by SurfaceMesh(), and operator=().

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

◆ SurfaceMesh() [2/2]

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

References SurfaceMesh().

Here is the call graph for this function:

Member Function Documentation

◆ degree() [1/2]

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

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

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
70{ assert(! h.is_invalid()); return h.m_face; }

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

Here is the call graph for this function:

◆ get_face_neighbors()

Vec3i32 Slic3r::SurfaceMesh::get_face_neighbors ( Face_index face_id) const
inline
157{ 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
75{ 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
102 {
103 Halfedge_index hi(source.m_face, source.m_vertex_idx);
104 assert(! hi.is_invalid());
105
106 const Vertex_index orig_target = this->target(hi);
107 Vertex_index current_target = orig_target;
108
109 while (! is_same_vertex(current_target, target)) {
110 hi = next_around_source(hi);
111 if (hi.is_invalid())
112 break;
113 current_target = this->target(hi);
114 if (is_same_vertex(current_target, orig_target))
115 return Halfedge_index(); // invalid
116 }
117
118 return hi;
119 }
Vertex_index source(Halfedge_index h) const
Definition SurfaceMesh.hpp:68
Halfedge_index next_around_source(Halfedge_index h) const
Definition SurfaceMesh.hpp:99
Vertex_index target(Halfedge_index h) const
Definition SurfaceMesh.hpp:69
bool is_same_vertex(const Vertex_index &a, const Vertex_index &b) const
Definition SurfaceMesh.hpp:156

References Slic3r::Halfedge_index::is_invalid(), is_same_vertex(), 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
74{ 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(), and opposite().

Here is the caller graph for this function:

◆ is_border()

bool Slic3r::SurfaceMesh::is_border ( Halfedge_index h) const
inline
154{ 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
156{ return m_its.indices[a.m_face][a.m_vertex_idx] == m_its.indices[b.m_face][b.m_vertex_idx]; }

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

Referenced by halfedge(), and opposite().

Here is the caller graph for this function:

◆ next()

Halfedge_index Slic3r::SurfaceMesh::next ( Halfedge_index h) const
inline
72{ 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(), and opposite().

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
99{ Halfedge_index op = opposite(h); return (op.is_invalid() ? Halfedge_index() : next(op)); }
Halfedge_index opposite(Halfedge_index h) const
Definition SurfaceMesh.hpp:76
Halfedge_index next(Halfedge_index h) const
Definition SurfaceMesh.hpp:72

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
97{ return opposite(next(h)); }

References next(), and opposite().

Referenced by degree().

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

◆ operator=()

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

References SurfaceMesh().

Here is the call graph for this function:

◆ opposite()

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

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(), and prev_around_target().

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
121{ return m_its.vertices[m_its.indices[v.m_face][v.m_vertex_idx]]; }

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

◆ prev()

Halfedge_index Slic3r::SurfaceMesh::prev ( Halfedge_index h) const
inline
73{ 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
100{ return opposite(prev(h)); }
Halfedge_index prev(Halfedge_index h) const
Definition SurfaceMesh.hpp:73

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
98{ 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
68{ 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(), and opposite().

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
69{ 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<Vec3i32> Slic3r::SurfaceMesh::m_face_neighbors
private

◆ m_its

const indexed_triangle_set& Slic3r::SurfaceMesh::m_its
private

Referenced by SurfaceMesh(), is_same_vertex(), and point().


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