Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
HashEdge Struct Reference
+ Collaboration diagram for HashEdge:

Public Member Functions

bool operator== (const HashEdge &rhs) const
 
bool operator!= (const HashEdge &rhs) const
 
int hash (int M) const
 
void load_exact (stl_file *stl, const stl_vertex *a, const stl_vertex *b)
 
bool load_nearby (const stl_file *stl, const stl_vertex &a, const stl_vertex &b, float tolerance)
 

Public Attributes

uint32_t key [6]
 
int facet_number
 
int which_edge
 
HashEdgenext
 

Private Member Functions

bool vertex_lower (const stl_vertex &a, const stl_vertex &b)
 

Detailed Description

Member Function Documentation

◆ hash()

int HashEdge::hash ( int  M) const
inline
45{ return ((key[0] / 11 + key[1] / 7 + key[2] / 3) ^ (key[3] / 11 + key[4] / 7 + key[5] / 3)) % M; }
uint32_t key[6]
Definition connect.cpp:41

References key.

Referenced by HashTableEdges::insert_edge().

+ Here is the caller graph for this function:

◆ load_exact()

void HashEdge::load_exact ( stl_file stl,
const stl_vertex a,
const stl_vertex b 
)
inline
55 {
56 {
57 stl_vertex diff = (*a - *b).cwiseAbs();
58 float max_diff = std::max(diff(0), std::max(diff(1), diff(2)));
59 stl->stats.shortest_edge = std::min(max_diff, stl->stats.shortest_edge);
60 }
61
62 // Ensure identical vertex ordering of equal edges.
63 // This method is numerically robust.
64 if (vertex_lower(*a, *b)) {
65 } else {
66 // This edge is loaded backwards.
67 std::swap(a, b);
68 this->which_edge += 3;
69 }
70 memcpy(&this->key[0], a->data(), sizeof(stl_vertex));
71 memcpy(&this->key[3], b->data(), sizeof(stl_vertex));
72 // Switch negative zeros to positive zeros, so memcmp will consider them to be equal.
73 for (size_t i = 0; i < 6; ++ i) {
74 unsigned char *p = (unsigned char*)(this->key + i);
75 #if BOOST_ENDIAN_LITTLE_BYTE
76 if (p[0] == 0 && p[1] == 0 && p[2] == 0 && p[3] == 0x80)
77 // Negative zero, switch to positive zero.
78 p[3] = 0;
79 #else /* BOOST_ENDIAN_LITTLE_BYTE */
80 if (p[0] == 0x80 && p[1] == 0 && p[2] == 0 && p[3] == 0)
81 // Negative zero, switch to positive zero.
82 p[0] = 0;
83 #endif /* BOOST_ENDIAN_LITTLE_BYTE */
84 }
85 }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbsReturnType cwiseAbs() const
Definition MatrixCwiseUnaryOps.h:32
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition PlainObjectBase.h:255
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:672
bool vertex_lower(const stl_vertex &a, const stl_vertex &b)
Definition connect.cpp:117
int which_edge
Definition connect.cpp:51
stl_stats stats
Definition stl.h:153
float shortest_edge
Definition stl.h:101

References cwiseAbs(), stl_stats::shortest_edge, stl_file::stats, and vertex_lower().

Referenced by stl_check_facets_exact(), and stl_fill_holes().

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

◆ load_nearby()

bool HashEdge::load_nearby ( const stl_file stl,
const stl_vertex a,
const stl_vertex b,
float  tolerance 
)
inline
88 {
89 // Index of a grid cell spaced by tolerance.
91 Vec3i vertex1 = ((a - stl->stats.min) / tolerance).cast<int32_t>();
92 Vec3i vertex2 = ((b - stl->stats.min) / tolerance).cast<int32_t>();
93 static_assert(sizeof(Vec3i) == 12, "size of Vec3i incorrect");
94
95 if (vertex1 == vertex2)
96 // Both vertices hash to the same value
97 return false;
98
99 // Ensure identical vertex ordering of edges, which vertices land into equal grid cells.
100 // This method is numerically robust.
101 if ((vertex1[0] != vertex2[0]) ?
102 (vertex1[0] < vertex2[0]) :
103 ((vertex1[1] != vertex2[1]) ?
104 (vertex1[1] < vertex2[1]) :
105 (vertex1[2] < vertex2[2]))) {
106 memcpy(&this->key[0], vertex1.data(), sizeof(stl_vertex));
107 memcpy(&this->key[3], vertex2.data(), sizeof(stl_vertex));
108 } else {
109 memcpy(&this->key[0], vertex2.data(), sizeof(stl_vertex));
110 memcpy(&this->key[3], vertex1.data(), sizeof(stl_vertex));
111 this->which_edge += 3; /* this edge is loaded backwards */
112 }
113 return true;
114 }
Eigen::Matrix< int, 3, 1, Eigen::DontAlign > Vec3i
Definition Point.hpp:40
stl_vertex min
Definition stl.h:98
__int32 int32_t
Definition unistd.h:75

References stl_stats::min, and stl_file::stats.

Referenced by stl_check_facets_nearby().

+ Here is the caller graph for this function:

◆ operator!=()

bool HashEdge::operator!= ( const HashEdge rhs) const
inline
44{ return ! (*this == rhs); }

◆ operator==()

bool HashEdge::operator== ( const HashEdge rhs) const
inline
43{ return memcmp(key, rhs.key, sizeof(key)) == 0; }

References key.

◆ vertex_lower()

bool HashEdge::vertex_lower ( const stl_vertex a,
const stl_vertex b 
)
inlineprivate
117 {
118 return (a(0) != b(0)) ? (a(0) < b(0)) :
119 ((a(1) != b(1)) ? (a(1) < b(1)) : (a(2) < b(2)));
120 }

Referenced by load_exact().

+ Here is the caller graph for this function:

Member Data Documentation

◆ facet_number

◆ key

uint32_t HashEdge::key[6]

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

◆ next

◆ which_edge


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