Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2020-02-05 19:39:56 +0300
committertamasmeszaros <meszaros.q@gmail.com>2020-02-05 19:40:05 +0300
commitbd76c345f22d8232fd8e524fbc35bda295d32424 (patch)
treea14feafe0cc0a9450f780bdd4873c80b066c36d9 /sandboxes
parent6f777264a1db61f2354e540ad566f73162c4fbac (diff)
Handle CGAL exceptions and add tests for mesh boolean operations
Add conversion to exact predicates exact construction kernel format for consecutive booleans (experiments)
Diffstat (limited to 'sandboxes')
-rw-r--r--sandboxes/meshboolean/MeshBoolean.cpp68
1 files changed, 18 insertions, 50 deletions
diff --git a/sandboxes/meshboolean/MeshBoolean.cpp b/sandboxes/meshboolean/MeshBoolean.cpp
index d339ef5c3..392d90707 100644
--- a/sandboxes/meshboolean/MeshBoolean.cpp
+++ b/sandboxes/meshboolean/MeshBoolean.cpp
@@ -11,66 +11,34 @@
#include <boost/log/trivial.hpp>
-namespace Slic3r {
-
-} // namespace Slic3r
-
int main(const int argc, const char * argv[])
{
using namespace Slic3r;
- if (argc <= 1) return EXIT_FAILURE;
-
- DynamicPrintConfig cfg;
- auto model = Model::read_from_file(argv[1], &cfg);
+ if (argc <= 1) {
+ std::cout << "Usage: meshboolean <input_file.3mf>" << std::endl;
+ return EXIT_FAILURE;
+ }
- if (model.objects.empty()) return EXIT_SUCCESS;
- SLAPrint print;
- print.apply(model, cfg);
- PrintBase::TaskParams task;
- task.to_object_step = slaposHollowing;
+ TriangleMesh input;
- print.set_task(task);
- print.process();
+ input.ReadSTLFile(argv[1]);
+ input.repair();
Benchmark bench;
- for (SLAPrintObject *po : print.objects()) {
- TriangleMesh holes;
- sla::DrainHoles holepts = po->transformed_drainhole_points();
-
- for (auto &hole: holepts)
- holes.merge(sla::to_triangle_mesh(hole.to_mesh()));
-
- TriangleMesh hollowed_mesh = po->transformed_mesh();
- hollowed_mesh.merge(po->hollowed_interior_mesh());
-
- hollowed_mesh.require_shared_vertices();
- holes.require_shared_vertices();
-
- TriangleMesh drilled_mesh_igl = hollowed_mesh;
- bench.start();
- MeshBoolean::minus(drilled_mesh_igl, holes);
- bench.stop();
-
- std::cout << "Mesh boolean duration with IGL: " << bench.getElapsedSec() << std::endl;
-
- TriangleMesh drilled_mesh_cgal = hollowed_mesh;
- bench.start();
- MeshBoolean::cgal::self_union(drilled_mesh_cgal);
- MeshBoolean::cgal::minus(drilled_mesh_cgal, holes);
- bench.stop();
-
- std::cout << "Mesh boolean duration with CGAL: " << bench.getElapsedSec() << std::endl;
-
- std::string name("obj"), outf;
- outf = name + "igl" + std::to_string(po->model_object()->id().id) + ".obj";
- drilled_mesh_igl.WriteOBJFile(outf.c_str());
-
- outf = name + "cgal" + std::to_string(po->model_object()->id().id) + ".obj";
- drilled_mesh_cgal.WriteOBJFile(outf.c_str());
- }
+ bench.start();
+ bool fckd = MeshBoolean::cgal::does_self_intersect(input);
+ bench.stop();
+
+ std::cout << "Self intersect test: " << fckd << " duration: " << bench.getElapsedSec() << std::endl;
+
+ bench.start();
+ MeshBoolean::self_union(input);
+ bench.stop();
+
+ std::cout << "Self union duration: " << bench.getElapsedSec() << std::endl;
return 0;
}