@@ -26,14 +26,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
26
26
27
27
#include " IncludeCarveHeaders.h"
28
28
#include " MeshOps.h"
29
- #include " MeshOpsDebug.h"
30
29
#include " GeometryInputData.h"
31
30
32
- // #define _USE_MANIFOLD_CSG
33
- #ifdef _USE_MANIFOLD_CSG
34
- #include " CSG_Manifold.h"
35
- #endif
36
-
37
31
#ifdef _DEBUG
38
32
static int csg_compute_count = 0 ;
39
33
#endif
@@ -97,19 +91,19 @@ namespace CSG_Adapter
97
91
CarveMeshNormalizer normMesh (bbox1, bbox2, normalizeCoords);
98
92
normMesh.m_disableNormalizeAll = false ;
99
93
94
+ int tag = entity->m_tag ;
100
95
GeomProcessingParams paramsUnscaled (geomSettingsDefault, false );
101
96
shared_ptr<GeometrySettings> geomSettings (new GeometrySettings (geomSettingsDefault));
102
97
double scale = normMesh.getScale ();
103
98
if (!normalizeCoords)
104
99
{
105
100
scale = 1.0 ;
106
101
}
107
- double epsDefault = geomSettings->getEpsilonCoplanarDistance ();
102
+ double epsDefault = geomSettings->getEpsilonMergePoints ();
108
103
double epsMinFaceAreaDefault = geomSettings->getMinTriangleArea ();
109
- double CARVE_EPSILON = epsDefault;// 10.0 * epsDefault * scale;
110
104
double epsMinFaceArea = epsMinFaceAreaDefault * ( scale * scale );
111
105
double epsCoplanarAngle = geomSettings->getEpsilonCoplanarAngle () * scale;
112
- geomSettings->setEpsilonCoplanarDistance (CARVE_EPSILON );
106
+ geomSettings->setEpsilonMergePoints (epsDefault );
113
107
geomSettings->setEpsilonCoplanarAngle (epsCoplanarAngle);
114
108
geomSettings->setMinTriangleArea (epsMinFaceArea);
115
109
GeomProcessingParams paramsScaled (geomSettings, false );
@@ -118,7 +112,7 @@ namespace CSG_Adapter
118
112
paramsUnscaled.ifc_entity = entity.get ();
119
113
paramsUnscaled.callbackFunc = report_callback;
120
114
121
- bool intersecting = checkBoundinbBoxIntersection (bbox1, bbox2, operation, CARVE_EPSILON );
115
+ bool intersecting = checkBoundinbBoxIntersection (bbox1, bbox2, operation, epsDefault );
122
116
if (!intersecting)
123
117
{
124
118
assignResultOnFail (op1Orig, op2Orig, operation, result);
@@ -152,18 +146,22 @@ namespace CSG_Adapter
152
146
try
153
147
{
154
148
// normalize first, so that EPS values match the size of different meshes
155
- normMesh.normalizeMesh (op1, " op1" , CARVE_EPSILON);
156
- normMesh.normalizeMesh (op2, " op2" , CARVE_EPSILON);
149
+ normMesh.normalizeMesh (op1, " op1" , epsDefault);
150
+ normMesh.normalizeMesh (op2, " op2" , epsDefault);
151
+
152
+ if (tag == 5598 )
153
+ {
154
+ paramsScaled.debugDump = true ;
155
+ }
157
156
158
157
bool op1_dumped = false ;
159
158
bool op2_dumped = false ;
160
- int tag = entity->m_tag ;
161
159
MeshOps::flattenFacePlanes (op1, op2, paramsScaled);
162
160
163
161
#ifdef _DEBUG
164
162
++csg_compute_count;
165
- DumpSettingsStruct dumpColorSettings;
166
- dumpColorSettings.eps = CARVE_EPSILON ;
163
+ GeomDebugDump:: DumpSettingsStruct dumpColorSettings;
164
+ dumpColorSettings.eps = epsDefault ;
167
165
CarveMeshNormalizer normMesh_scaleMeshDump (normMesh);
168
166
if (!normalizeCoords)
169
167
{
@@ -172,9 +170,9 @@ namespace CSG_Adapter
172
170
paramsUnscaled.normalizer = &normMesh_scaleMeshDump;
173
171
}
174
172
175
- if (csg_compute_count == 24 || tag == 99427 )
173
+ if (csg_compute_count == 24 || tag == 5598 )
176
174
{
177
- dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
175
+ GeomDebugDump:: dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
178
176
}
179
177
180
178
if (infoMesh1orig.zeroAreaFaces .size () > 0 )
@@ -228,7 +226,7 @@ namespace CSG_Adapter
228
226
shared_ptr<carve::mesh::MeshSet<3 > > op1Clone (op1Orig->clone ());
229
227
MeshSetInfo infoMesh1copy (report_callback, entity.get ());
230
228
MeshOps::checkMeshSetValidAndClosed (op1Clone, infoMesh1copy, paramsScaled);
231
- normMesh.normalizeMesh (op1Clone, " op1Clone" , CARVE_EPSILON );
229
+ normMesh.normalizeMesh (op1Clone, " op1Clone" , epsDefault );
232
230
233
231
MeshOps::simplifyMeshSet (op1Clone, paramsScaled, triangulateOperands, shouldBeClosedManifold);
234
232
@@ -246,7 +244,7 @@ namespace CSG_Adapter
246
244
MeshSetInfo infoMesh1copy (report_callback, entity.get ());
247
245
MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1copy, paramsUnscaled);
248
246
249
- normMesh.normalizeMesh (op1, " op1orig" , CARVE_EPSILON );
247
+ normMesh.normalizeMesh (op1, " op1orig" , epsDefault );
250
248
operand1valid = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1, paramsScaled);
251
249
if (!operand1valid && operand1origvalid)
252
250
{
@@ -264,7 +262,7 @@ namespace CSG_Adapter
264
262
MeshSetInfo infoMesh2copy (report_callback, entity.get ());
265
263
bool operand2copy_valid = MeshOps::checkMeshSetValidAndClosed (op2, infoMesh2copy, paramsUnscaled);
266
264
267
- normMesh.normalizeMesh (op2, " op2orig" , CARVE_EPSILON );
265
+ normMesh.normalizeMesh (op2, " op2orig" , epsDefault );
268
266
operand2valid = MeshOps::checkMeshSetValidAndClosed (op2, infoMesh2, paramsScaled);
269
267
if (!operand2valid && operand2origvalid)
270
268
{
@@ -307,7 +305,7 @@ namespace CSG_Adapter
307
305
if (infoMesh2.degenerateEdges .size () > 0 ) { paramsScaled.allowDegenerateEdges = true ; }
308
306
309
307
// //////////////////// compute carve csg operation /////////////////////////////////////////////
310
- carve::csg::CSG csg (CARVE_EPSILON );
308
+ carve::csg::CSG csg (epsDefault );
311
309
result = shared_ptr<carve::mesh::MeshSet<3 > >(csg.compute (op1.get (), op2.get (), operation, nullptr , carve::csg::CSG::CLASSIFY_EDGE));
312
310
313
311
MeshSetInfo infoResult ( report_callback, entity.get () );
@@ -344,7 +342,7 @@ namespace CSG_Adapter
344
342
// TODO: check for fail with closed mesh, but not fully sliced through.
345
343
if (!result_meshset_ok)
346
344
{
347
- carve::csg::CSG csg (CARVE_EPSILON );
345
+ carve::csg::CSG csg (epsDefault );
348
346
result = shared_ptr<carve::mesh::MeshSet<3 > >(csg.compute (op1.get (), op2.get (), operation, nullptr , carve::csg::CSG::CLASSIFY_NORMAL));
349
347
result_meshset_ok = MeshOps::checkMeshSetValidAndClosed (result, infoResult, paramsScaled);
350
348
@@ -368,16 +366,6 @@ namespace CSG_Adapter
368
366
}
369
367
#endif
370
368
371
- if ( !result_meshset_ok )
372
- {
373
- // dumpMeshes = true;
374
-
375
- #ifdef _USE_MANIFOLD_CSG
376
- computeCSG_Manifold (op1, op2, operation, result, CARVE_EPSILON, report_callback, entity);
377
- result_meshset_ok = MeshOps::checkMeshSetValidAndClosed (result, infoResult, report_callback, entity.get ());
378
- #endif
379
- }
380
-
381
369
if ( !result_meshset_ok )
382
370
{
383
371
strs_err << " csg operation failed" << std::endl;
@@ -421,7 +409,7 @@ namespace CSG_Adapter
421
409
bool result_meshset_ok_beforeDeNormalize = MeshOps::checkMeshSetValidAndClosed (result, infoMesh_beforeDeNormalize, paramsScaled);
422
410
#endif
423
411
424
- normMesh.deNormalizeMesh (result, " " , CARVE_EPSILON );
412
+ normMesh.deNormalizeMesh (result, " " , epsDefault );
425
413
426
414
#ifdef _DEBUG
427
415
{
@@ -497,8 +485,8 @@ namespace CSG_Adapter
497
485
if (!operand1valid_2)
498
486
{
499
487
std::cout << " !operand1valid after computeCSG_Carve" << std::endl;
500
- DumpSettingsStruct dumpSet;
501
- dumpWithLabel (" computeCSG_Carve:result:op1 " , op1, dumpSet, params, true , true );
488
+ GeomDebugDump:: DumpSettingsStruct dumpSet;
489
+ GeomDebugDump:: dumpWithLabel (" computeCSG_Carve:result:op1 " , op1, dumpSet, params, true , true );
502
490
}
503
491
#endif
504
492
continue ;
0 commit comments