Skip to content

Commit

Permalink
mesh_surface_intersection.h: removed remove_fins() (will see later)
Browse files Browse the repository at this point in the history
mesh_CSG.cpp: group() now computes intersections.
              CSG operations throw an exception when called in 2D
	      (instead of assertion fail)
  • Loading branch information
BrunoLevy committed Nov 5, 2023
1 parent ed8d45a commit 73b1681
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/lib/geogram/mesh/mesh_CSG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ namespace GEO {
/****** Instructions ****/

CSGMesh_var CSGBuilder::multmatrix(const mat4& M, const CSGScope& scope) {
CSGMesh_var result = group(scope);
CSGMesh_var result = union_instr(scope);
for(index_t v: result->vertices) {
vec3 p(result->vertices.point_ptr(v));
p = transform_point(M,p);
Expand All @@ -406,6 +406,9 @@ namespace GEO {
return scope[0];
}
CSGMesh_var result = group(scope);
if(result->vertices.dimension() != 3) {
throw(std::logic_error("2D CSG operations not implemented yet"));
}
MeshSurfaceIntersection I(*result);
I.intersect();
I.remove_internal_shells();
Expand All @@ -416,6 +419,11 @@ namespace GEO {
if(scope.size() == 1) {
return scope[0];
}

if(scope[0]->vertices.dimension() != 3) {
throw(std::logic_error("2D CSG operations not implemented yet"));
}

if(scope.size() == 2) {
CSGMesh_var result = new CSGMesh;
mesh_intersection(*result, *scope[0], *scope[1]);
Expand All @@ -435,6 +443,11 @@ namespace GEO {
if(scope.size() == 1) {
return scope[0];
}

if(scope[0]->vertices.dimension() != 3) {
throw(std::logic_error("2D CSG operations not implemented yet"));
}

if(scope.size() == 2) {
CSGMesh_var result = new CSGMesh;
mesh_difference(*result, *scope[0], *scope[1]);
Expand Down Expand Up @@ -679,7 +692,7 @@ namespace GEO {
}

ArgList args;
result = group(args, scope);
result = union_instr(args, scope);
} catch(const std::logic_error& e) {
Logger::err("CSG") << "Error while parsing file:"
<< e.what()
Expand Down Expand Up @@ -821,7 +834,7 @@ namespace GEO {

CSGMesh_var CSGCompiler::group(const ArgList& args, const CSGScope& scope) {
geo_argused(args);
return builder_.group(scope);
return builder_.union_instr(scope);
}

CSGMesh_var CSGCompiler::color(const ArgList& args, const CSGScope& scope) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/geogram/mesh/mesh_surface_intersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace GEO {
void remove_external_shell();

void remove_internal_shells();

/**
* \brief Display information while computing the intersection.
* Default is unset.
Expand Down

0 comments on commit 73b1681

Please sign in to comment.