Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::sla::FaceHash Struct Reference
+ Collaboration diagram for Slic3r::sla::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 Vec3i &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::sla::FaceHash::FaceHash ( const indexed_triangle_set its)
inline
613 : facehash(its.indices.size())
614 {
615 for (Vec3i face : its.indices) {
616 std::swap(face(0), face(2));
617 facehash.insert(facekey(face, its.vertices));
618 }
619 }
Eigen::Matrix< int, 3, 1, Eigen::DontAlign > Vec3i
Definition Point.hpp:40
std::unordered_set< std::string > facehash
Definition Hollowing.cpp:561
static std::string facekey(const Vec3i &face, const std::vector< Vec3f > &vertices)
Definition Hollowing.cpp:594
std::vector< stl_vertex > vertices
Definition stl.h:165
std::vector< stl_triangle_vertex_indices > indices
Definition stl.h:164

References indexed_triangle_set::indices, and indexed_triangle_set::vertices.

Member Function Documentation

◆ facekey()

static std::string Slic3r::sla::FaceHash::facekey ( const Vec3i face,
const std::vector< Vec3f > &  vertices 
)
inlinestatic
595 {
596 // Scale to integer to avoid floating points
597 std::array<Vec<3, int64_t>, 3> pts = {
598 scaled<int64_t>(vertices[face(0)]),
599 scaled<int64_t>(vertices[face(1)]),
600 scaled<int64_t>(vertices[face(2)])
601 };
602
603 // Get the first two sides of the triangle, do a cross product and move
604 // that vector to the center of the triangle. This encodes all
605 // information to identify an identical triangle at the same position.
606 Vec<3, int64_t> a = pts[0] - pts[2], b = pts[1] - pts[2];
607 Vec<3, int64_t> c = a.cross(b) + (pts[0] + pts[1] + pts[2]) / 3;
608
609 // Return a concatenated string representation of the coordinates
610 return hash(c);
611 }
static std::string hash(const Vec< 3, int64_t > &v)
Definition Hollowing.cpp:583

◆ find()

bool Slic3r::sla::FaceHash::find ( const std::string &  key)
inline
622 {
623 auto it = facehash.find(key);
624 return it != facehash.end();
625 }

◆ hash()

static std::string Slic3r::sla::FaceHash::hash ( const Vec< 3, int64_t > &  v)
inlinestatic
584 {
585 std::string ret;
586 ret.reserve(3 * MAX_NUM_CHARS);
587
588 for (auto val : v)
589 ret += to_chars(val).data();
590
591 return ret;
592 }
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195
static constexpr size_t MAX_NUM_CHARS
Definition Hollowing.cpp:557
static std::array< char, MAX_NUM_CHARS+1 > to_chars(int64_t val)
Definition Hollowing.cpp:564

◆ to_chars()

static std::array< char, MAX_NUM_CHARS+1 > Slic3r::sla::FaceHash::to_chars ( int64_t  val)
inlinestatic
565 {
566 std::array<char, MAX_NUM_CHARS + 1> ret;
567
568 static const constexpr char * Conv = "0123456789abcdef";
569
570 auto ptr = ret.begin();
571 auto uval = static_cast<uint64_t>(std::abs(val));
572 while (uval) {
573 *ptr = Conv[uval & 0xf];
574 ++ptr;
575 uval = uval >> 4;
576 }
577 if (val < 0) { *ptr = '-'; ++ptr; }
578 *ptr = '\0'; // C style string ending
579
580 return ret;
581 }
unsigned __int64 uint64_t
Definition unistd.h:80

Member Data Documentation

◆ facehash

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

◆ MAX_NUM_CHARS

constexpr size_t Slic3r::sla::FaceHash::MAX_NUM_CHARS = 16
staticconstexpr

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