mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Ported some ModelObject methods from Perl to C++.
Added some utility functions to TriangleMesh, thanks to @alexrj Some porting to C++ based on work by @alexrj.
This commit is contained in:
parent
777023c7a8
commit
31085fb1d7
7 changed files with 191 additions and 81 deletions
|
@ -215,6 +215,47 @@ TriangleMesh::repair() {
|
|||
BOOST_LOG_TRIVIAL(debug) << "TriangleMesh::repair() finished";
|
||||
}
|
||||
|
||||
|
||||
float TriangleMesh::volume()
|
||||
{
|
||||
if (this->stl.stats.volume == -1)
|
||||
stl_calculate_volume(&this->stl);
|
||||
return this->stl.stats.volume;
|
||||
}
|
||||
|
||||
void TriangleMesh::check_topology()
|
||||
{
|
||||
// checking exact
|
||||
stl_check_facets_exact(&stl);
|
||||
stl.stats.facets_w_1_bad_edge = (stl.stats.connected_facets_2_edge - stl.stats.connected_facets_3_edge);
|
||||
stl.stats.facets_w_2_bad_edge = (stl.stats.connected_facets_1_edge - stl.stats.connected_facets_2_edge);
|
||||
stl.stats.facets_w_3_bad_edge = (stl.stats.number_of_facets - stl.stats.connected_facets_1_edge);
|
||||
|
||||
// checking nearby
|
||||
//int last_edges_fixed = 0;
|
||||
float tolerance = stl.stats.shortest_edge;
|
||||
float increment = stl.stats.bounding_diameter / 10000.0;
|
||||
int iterations = 2;
|
||||
if (stl.stats.connected_facets_3_edge < stl.stats.number_of_facets) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
if (stl.stats.connected_facets_3_edge < stl.stats.number_of_facets) {
|
||||
//printf("Checking nearby. Tolerance= %f Iteration=%d of %d...", tolerance, i + 1, iterations);
|
||||
stl_check_facets_nearby(&stl, tolerance);
|
||||
//printf(" Fixed %d edges.\n", stl.stats.edges_fixed - last_edges_fixed);
|
||||
//last_edges_fixed = stl.stats.edges_fixed;
|
||||
tolerance += increment;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TriangleMesh::is_manifold() const
|
||||
{
|
||||
return this->stl.stats.connected_facets_3_edge == this->stl.stats.number_of_facets;
|
||||
}
|
||||
|
||||
void
|
||||
TriangleMesh::reset_repair_stats() {
|
||||
this->stl.stats.degenerate_facets = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue