Skip to content

Commit

Permalink
- Small optimization in Tadd_edge_cnstr_with_neighbor(): constraint
Browse files Browse the repository at this point in the history
list is shared by both edges.
- mesh_CSG: added post_process() function (placeholder for snaprounding)
  • Loading branch information
BrunoLevy committed Nov 7, 2023
1 parent ff3f8ca commit 8f64059
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/geogram/delaunay/CDT_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,17 @@ namespace GEO {
) {
geo_debug_assert(t < nT());
geo_debug_assert(le < 3);
#ifdef GEO_DEBUG
index_t t_e_cnstr_first = Tedge_cnstr_first(t,le);
#endif
Tadd_edge_cnstr(t, le, cnstr_id);
index_t t2 = Tadj(t,le);
if(t2 != index_t(-1)) {
index_t le2 = Tadj_find(t2,t);
Tadd_edge_cnstr(t2,le2,cnstr_id);
// Sanity check: make sure the two edges always share the
// same constraint list.
geo_debug_assert(Tedge_cnstr_first(t2,le2) == t_e_cnstr_first);
Tset_edge_cnstr_first(t2,le2,Tedge_cnstr_first(t,le));
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/lib/geogram/mesh/mesh_CSG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <geogram/mesh/mesh.h>
#include <geogram/mesh/mesh_surface_intersection.h>
#include <geogram/mesh/mesh_fill_holes.h>
#include <geogram/mesh/mesh_repair.h>
#include <geogram/delaunay/delaunay.h>
#include <geogram/basic/command_line.h>

Expand Down Expand Up @@ -495,6 +496,7 @@ namespace GEO {
MeshSurfaceIntersection I(*result);
I.intersect();
I.remove_internal_shells();
post_process(result);
}
result->update_bbox();
return result;
Expand All @@ -512,6 +514,7 @@ namespace GEO {
if(scope.size() == 2) {
CSGMesh_var result = new CSGMesh;
mesh_intersection(*result, *scope[0], *scope[1]);
post_process(result);
result->update_bbox();
return result;
}
Expand All @@ -522,6 +525,7 @@ namespace GEO {
CSGMesh_var M2 = intersection(scope2);
CSGMesh_var result = new CSGMesh;
mesh_intersection(*result, *M1, *M2);
post_process(result);
result->update_bbox();
return result;
}
Expand All @@ -538,6 +542,7 @@ namespace GEO {
if(scope.size() == 2) {
CSGMesh_var result = new CSGMesh;
mesh_difference(*result, *scope[0], *scope[1]);
post_process(result);
result->update_bbox();
return result;
}
Expand All @@ -549,6 +554,7 @@ namespace GEO {
CSGMesh_var op2 = group(scope2);
CSGMesh_var result = new CSGMesh;
mesh_difference(*result, *scope[0], *op2);
post_process(result);
result->update_bbox();
return result;
}
Expand Down Expand Up @@ -704,6 +710,16 @@ namespace GEO {
}

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

void CSGBuilder::post_process(CSGMesh_var mesh) {
geo_argused(mesh);
/*
mesh_repair(*mesh, MESH_REPAIR_DEFAULT, 1e-6);
MeshSurfaceIntersection I(*mesh);
I.intersect();
I.remove_internal_shells();
*/
}

index_t CSGBuilder::get_fragments_from_r(double r) {
if (fn_ > 0.0) {
Expand Down
10 changes: 10 additions & 0 deletions src/lib/geogram/mesh/mesh_CSG.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ namespace GEO {
}

protected:

/**
* \brief Post-processes the result of a previous intersection
* \details After converting exact coordinates to doubles, some
* problems may occur. This function tentatively fixes this
* problems. TODO: correct snap-rounding.
* \param[in] mesh the mesh to be processed
*/
void post_process(CSGMesh_var mesh);

/**
* \brief Computes the number of fragments, that is, edges
* in a polygonal approximation of a circle.
Expand Down

0 comments on commit 8f64059

Please sign in to comment.