OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::FaceHash Struct Reference
Collaboration diagram for Slic3r::FaceHash:

Public Member Functions

 FaceHash (const indexed_triangle_set &its)
bool find (const std::string &key)

Static Public Member Functions

static std::array< char, MAX_NUM_CHARS+1 > to_chars (int64_t val)
static std::string hash (const Vec< 3, int64_t > &v)
static std::string facekey (const Vec3i32 &face, const std::vector< Vec3f > &vertices)

Public Attributes

std::unordered_set< std::string > facehash

Static Public Attributes

static constexpr size_t MAX_NUM_CHARS = 16

Detailed Description

Constructor & Destructor Documentation

◆ FaceHash()

Slic3r::FaceHash::FaceHash ( const indexed_triangle_set & its)
inline
234 : facehash(its.indices.size())
235 {
236 for (const Vec3i32 &face : its.indices)
237 facehash.insert(facekey(face, its.vertices));
238 }
Eigen::Matrix< int32_t, 3, 1, Eigen::DontAlign > Vec3i32
Definition Point.hpp:59
static std::string facekey(const Vec3i32 &face, const std::vector< Vec3f > &vertices)
Definition SLAPrintSteps.cpp:215
std::unordered_set< std::string > facehash
Definition SLAPrintSteps.cpp:182

References facehash, and facekey().

Here is the call graph for this function:

Member Function Documentation

◆ facekey()

std::string Slic3r::FaceHash::facekey ( const Vec3i32 & face,
const std::vector< Vec3f > & vertices )
inlinestatic
216 {
217 // Scale to integer to avoid floating points
218 std::array<Vec<3, int64_t>, 3> pts = {
219 scaled<int64_t>(vertices[face(0)]),
220 scaled<int64_t>(vertices[face(1)]),
221 scaled<int64_t>(vertices[face(2)])
222 };
223
224 // Get the first two sides of the triangle, do a cross product and move
225 // that vector to the center of the triangle. This encodes all
226 // information to identify an identical triangle at the same position.
227 Vec<3, int64_t> a = pts[0] - pts[2], b = pts[1] - pts[2];
228 Vec<3, int64_t> c = a.cross(b) + (pts[0] + pts[1] + pts[2]) / 3;
229
230 // Return a concatenated string representation of the coordinates
231 return hash(c);
232 }
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
Mat< N, 1, T > Vec
Definition Point.hpp:48
static std::string hash(const Vec< 3, int64_t > &v)
Definition SLAPrintSteps.cpp:204

References hash(), and Slic3r::scaled().

Referenced by FaceHash(), and Slic3r::create_exclude_mask().

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

◆ find()

bool Slic3r::FaceHash::find ( const std::string & key)
inline
241 {
242 auto it = facehash.find(key);
243 return it != facehash.end();
244 }

References facehash.

Referenced by Slic3r::create_exclude_mask().

Here is the caller graph for this function:

◆ hash()

std::string Slic3r::FaceHash::hash ( const Vec< 3, int64_t > & v)
inlinestatic
205 {
206 std::string ret;
207 ret.reserve(3 * MAX_NUM_CHARS);
208
209 for (auto val : v)
210 ret += to_chars(val).data();
211
212 return ret;
213 }
static std::array< char, MAX_NUM_CHARS+1 > to_chars(int64_t val)
Definition SLAPrintSteps.cpp:185
static constexpr size_t MAX_NUM_CHARS
Definition SLAPrintSteps.cpp:178

References MAX_NUM_CHARS, and to_chars().

Referenced by facekey().

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

◆ to_chars()

std::array< char, MAX_NUM_CHARS+1 > Slic3r::FaceHash::to_chars ( int64_t val)
inlinestatic
186 {
187 std::array<char, MAX_NUM_CHARS + 1> ret;
188
189 static const constexpr char * Conv = "0123456789abcdef";
190
191 auto ptr = ret.begin();
192 auto uval = static_cast<uint64_t>(std::abs(val));
193 while (uval) {
194 *ptr = Conv[uval & 0xf];
195 ++ptr;
196 uval = uval >> 4;
197 }
198 if (val < 0) { *ptr = '-'; ++ptr; }
199 *ptr = '\0'; // C style string ending
200
201 return ret;
202 }

Referenced by hash().

Here is the caller graph for this function:

Member Data Documentation

◆ facehash

std::unordered_set<std::string> Slic3r::FaceHash::facehash

Referenced by FaceHash(), and find().

◆ MAX_NUM_CHARS

size_t Slic3r::FaceHash::MAX_NUM_CHARS = 16
staticconstexpr

Referenced by hash().


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