Skip to content

Commit

Permalink
Added flags for interpolating attributes, simplifying coplanar facets
Browse files Browse the repository at this point in the history
and verbosity
  • Loading branch information
BrunoLevy committed Sep 18, 2024
1 parent b654130 commit 4284f14
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/lib/geogram/mesh/mesh_surface_intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,8 +2438,10 @@ namespace GEO {

void mesh_boolean_operation(
Mesh& result, Mesh& A, Mesh& B,
const std::string& operation, bool verbose
const std::string& operation,
MeshBooleanOperationFlags flags
) {
bool verbose = ((flags & MESH_BOOL_OPS_VERBOSE) != 0);
if(&result == &A) {
Attribute<index_t> operand_bit(
result.facets.attributes(), "operand_bit"
Expand All @@ -2461,10 +2463,18 @@ namespace GEO {
}
MeshSurfaceIntersection I(result);
I.set_radial_sort(true);
I.set_verbose(verbose);
I.set_verbose(verbose);
if((flags & MESH_BOOL_OPS_ATTRIBS) != 0) {
I.set_interpolate_attributes(true);
}
I.intersect();
I.classify(operation);
I.simplify_coplanar_facets();
if(
(flags & MESH_BOOL_OPS_ATTRIBS) == 0 &&
(flags & MESH_BOOL_OPS_NO_SIMPLIFY) == 0
) {
I.simplify_coplanar_facets();
}
}

void mesh_union(Mesh& result, Mesh& A, Mesh& B, bool verbose) {
Expand Down
36 changes: 33 additions & 3 deletions src/lib/geogram/mesh/mesh_surface_intersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -1123,21 +1123,51 @@ namespace GEO {

/********************************************************************/

enum MeshBooleanOperationFlags {
MESH_BOOL_OPS_DEFAULT = 0,
MESH_BOOL_OPS_VERBOSE = 1,
MESH_BOOL_OPS_ATTRIBS = 2,
MESH_BOOL_OPS_NO_SIMPLIFY = 4
};

/**
* \brief Computes a boolean operation with two surface meshes.
* \details A and B need to be two closed surface
* mesh without intersections.
* \param[in] A , B the two operands.
* \param[out] result the computed mesh.
* \param[in] operation one of "A+B", "A*B", "A-B", "B-A"
* \param[in] verbose if set, display additional information
* during computation
* \param[in] flags MESH_BOOL_OPS_DEFAULT or an '|'-combination of:
* - MESH_BOOL_OPS_VERBOSE: displays additional information
* - MESH_BOOL_OPS_ATTRIBS: interpolates attributes
* (implies MESH_BOOL_OPS_NO_SIMPLIFY)
* - MESH_BOOL_OPS_NO_SIMPLIFY: do not simplify coplanar facets
*/
void GEOGRAM_API mesh_boolean_operation(
Mesh& result, Mesh& A, Mesh& B, const std::string& operation,
bool verbose=false
MeshBooleanOperationFlags flags = MESH_BOOL_OPS_DEFAULT
);

/**
* \brief Computes a boolean operation with two surface meshes.
* \details A and B need to be two closed surface
* mesh without intersections.
* \param[in] A , B the two operands.
* \param[out] result the computed mesh.
* \param[in] operation one of "A+B", "A*B", "A-B", "B-A"
* \param[in] verbose if set, display additional information
* during computation
*/
inline void GEOGRAM_API mesh_boolean_operation(
Mesh& result, Mesh& A, Mesh& B, const std::string& operation,
bool verbose
) {
mesh_boolean_operation(
result, A, B, operation,
verbose ? MESH_BOOL_OPS_VERBOSE : MESH_BOOL_OPS_DEFAULT
);
}

/**
* \brief Computes the union of two surface meshes.
* \details A and B need to be two closed surface
Expand Down

0 comments on commit 4284f14

Please sign in to comment.