Skip to content

Commit

Permalink
Fully successful manifold cleanup of Generic_Twin
Browse files Browse the repository at this point in the history
Adding a preprocessing step used by the geobox mesh repair feature in
geogram, we can also process the four components in Generic_Twin.g that
previously couldn't be handled.  With this change, we appear to be
successfully producing manifold outputs for ALL non-plate-mode BoT
objects in Generic_Twin that initially report as non-manifold per the
Manifold library's test.

Of course if enough of the original shape is missing, the results of
hole filling can't recover the original shape - but for a lot of "almost
closed" cases this looks as if it could be quite helpful.
  • Loading branch information
starseeker committed Jan 26, 2024
1 parent 9939b5d commit 82fddf5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/libged/bot/manifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <geogram/basic/command_line_args.h>
#include "geogram/mesh/mesh.h"
#include "geogram/mesh/mesh_geometry.h"
#include "geogram/mesh/mesh_preprocessing.h"
#include "geogram/mesh/mesh_repair.h"
#include "geogram/mesh/mesh_fill_holes.h"

Expand Down Expand Up @@ -144,6 +145,7 @@ geogram_mesh_repair(struct rt_bot_internal *bot)

// Use the default hole filling algorithm
GEO::CmdLine::set_arg("algo:hole_filling", "loop_split");
GEO::CmdLine::set_arg("algo:nn_search", "BNN");

GEO::Mesh gm;
gm.vertices.assign_points((double *)bot->vertices, 3, bot->num_vertices);
Expand All @@ -156,7 +158,25 @@ geogram_mesh_repair(struct rt_bot_internal *bot)

// After the initial raw load, do a repair pass to set up
// Geogram's internal mesh data
GEO::mesh_repair(gm, GEO::MeshRepairMode(GEO::MESH_REPAIR_DEFAULT));
double epsilon = 1e-6 * (0.01 * GEO::bbox_diagonal(gm));

GEO::mesh_repair(gm, GEO::MeshRepairMode(GEO::MESH_REPAIR_DEFAULT), epsilon);

// Per the geobox "mesh repair" function, we need to do some
// small connected component removal ahead of the fill_holes
// call - that was the behavior difference observed between
// the raw bot manifold run and exporting the mesh into geobox
// for processing
double area = GEO::Geom::mesh_area(gm,3);
double min_comp_area = 0.03 * area;
if (min_comp_area > 0.0) {
double nb_f_removed = gm.facets.nb();
GEO::remove_small_connected_components(gm, min_comp_area);
nb_f_removed -= gm.facets.nb();
if(nb_f_removed > 0 || nb_f_removed < 0) {
GEO::mesh_repair(gm, GEO::MESH_REPAIR_DEFAULT, epsilon);
}
}

// Do the hole filling, trying to fill all holes (1e30 is
// a value used in the Geogram code for a large hole size -
Expand Down

0 comments on commit 82fddf5

Please sign in to comment.