67
67
68
68
#include < geogram/third_party/PoissonRecon/poisson_geogram.h>
69
69
70
+ #include < geogram/basic/stopwatch.h>
70
71
#include < geogram/basic/command_line.h>
71
72
#include < geogram/basic/command_line_args.h>
72
73
#include < geogram/basic/file_system.h>
@@ -272,8 +273,6 @@ namespace {
272
273
texture_ = 0 ;
273
274
checker_texture_ = 0 ;
274
275
texture_mode_ = NO_TEXTURE;
275
- add_key_func (" F5" , autorepair);
276
- locked_ = false ;
277
276
}
278
277
279
278
void geogram_initialize (int argc, char ** argv) override {
@@ -474,6 +473,20 @@ namespace {
474
473
);
475
474
}
476
475
476
+ if (ImGui::MenuItem (" intersect" )) {
477
+ GEO::Command::set_current (
478
+ " void intersect("
479
+ " bool neighbors = true"
480
+ " [test neighboring triangles for intersections],"
481
+ " bool union = true"
482
+ " [removes internal shells],"
483
+ " bool coplanar = true"
484
+ " [re-triangulate sets of coplanar facets]"
485
+ " ) [removes surface mesh intersections]" ,
486
+ this , &GeoBoxApplication::intersect
487
+ );
488
+ }
489
+
477
490
if (ImGui::MenuItem (" keep largest part" )) {
478
491
GEO::Command::set_current (
479
492
" void keep_largest_component( "
@@ -706,9 +719,11 @@ namespace {
706
719
texture_filename_ = " " ;
707
720
bool result = SimpleMeshApplication::load (filename);
708
721
if (result && FileSystem::extension (filename) == " stl" ) {
722
+ locked_ = true ;
709
723
begin ();
710
724
mesh_repair (mesh_);
711
- end ();
725
+ end ();
726
+ locked_ = false ;
712
727
}
713
728
714
729
std::string tex_file_name =
@@ -1043,7 +1058,29 @@ namespace {
1043
1058
end ();
1044
1059
}
1045
1060
1046
-
1061
+ void intersect (
1062
+ bool detect_intersecting_neighbors = true ,
1063
+ bool remove_internal_shells = true ,
1064
+ bool simplify_coplanar_facets = true
1065
+ ) {
1066
+ begin ();
1067
+ MeshSurfaceIntersection intersection (mesh_);
1068
+ intersection.set_delaunay (true );
1069
+ intersection.set_detect_intersecting_neighbors (
1070
+ detect_intersecting_neighbors
1071
+ );
1072
+ intersection.set_verbose (false );
1073
+ intersection.set_radial_sort (remove_internal_shells);
1074
+ intersection.intersect ();
1075
+ if (remove_internal_shells) {
1076
+ intersection.remove_internal_shells ();
1077
+ }
1078
+ if (simplify_coplanar_facets) {
1079
+ intersection.simplify_coplanar_facets ();
1080
+ }
1081
+ end ();
1082
+ }
1083
+
1047
1084
void remesh_smooth (
1048
1085
index_t nb_points = 30000 ,
1049
1086
double tri_shape_adapt = 1.0 ,
@@ -1644,7 +1681,6 @@ namespace {
1644
1681
* for all geometry processing functions.
1645
1682
*/
1646
1683
void begin () {
1647
- locked_ = true ;
1648
1684
mesh ()->vertices .set_double_precision ();
1649
1685
}
1650
1686
@@ -1671,7 +1707,6 @@ namespace {
1671
1707
if (mesh ()->facets .nb () == 0 && mesh ()->cells .nb () == 0 ) {
1672
1708
show_vertices ();
1673
1709
}
1674
- locked_ = false ;
1675
1710
}
1676
1711
1677
1712
/* *
@@ -1852,30 +1887,12 @@ namespace {
1852
1887
glupDisable (GLUP_NORMAL_MAPPING);
1853
1888
}
1854
1889
1855
- protected:
1856
- static void autorepair () {
1857
- GeoBoxApplication* app =
1858
- static_cast <GeoBoxApplication*>(instance ());
1859
- app->begin ();
1860
- MeshSurfaceIntersection intersection (app->mesh_ );
1861
- intersection.set_delaunay (true );
1862
- intersection.set_detect_intersecting_neighbors (true );
1863
- intersection.set_verbose (false );
1864
- intersection.set_radial_sort (true );
1865
- intersection.intersect ();
1866
- intersection.remove_internal_shells ();
1867
- intersection.simplify_coplanar_facets ();
1868
- app->end ();
1869
- }
1870
-
1871
1890
protected:
1872
1891
std::string texture_filename_;
1873
1892
Image_var texture_image_;
1874
1893
GLuint texture_;
1875
1894
GLuint checker_texture_;
1876
1895
TextureMode texture_mode_;
1877
- bool locked_; // to avoid weird behavior when pressing up/down while
1878
- // command or mesh repair is running.
1879
1896
};
1880
1897
}
1881
1898
0 commit comments