@@ -37,7 +37,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
37
37
#ifdef _DEBUG
38
38
static int csg_compute_count = 0 ;
39
39
#endif
40
- #define _USE_CLASSIFY_NORMAL
41
40
42
41
namespace CSG_Adapter
43
42
{
@@ -80,24 +79,22 @@ namespace CSG_Adapter
80
79
return false ;
81
80
}
82
81
83
- if ( op1Orig->vertex_storage .size () > 2000 )
82
+ if ( op1Orig->vertex_storage .size () > 4000 )
84
83
{
85
84
assignResultOnFail (op1Orig, op2Orig, operation, result);
86
85
return false ;
87
86
}
88
87
89
- if ( op2Orig->vertex_storage .size () > 2000 )
88
+ if ( op2Orig->vertex_storage .size () > 4000 )
90
89
{
91
90
assignResultOnFail (op1Orig, op2Orig, operation, result);
92
91
return false ;
93
92
}
94
93
95
-
96
94
carve::geom::aabb<3 > bbox1 = op1Orig->getAABB ();
97
95
carve::geom::aabb<3 > bbox2 = op2Orig->getAABB ();
98
96
bool result_meshset_ok = false ;
99
- bool normalizeCoordsInsteadOfEpsilon = normalizeCoords;
100
- CarveMeshNormalizer normMesh (bbox1, bbox2, normalizeCoordsInsteadOfEpsilon);
97
+ CarveMeshNormalizer normMesh (bbox1, bbox2, normalizeCoords);
101
98
normMesh.m_disableNormalizeAll = false ;
102
99
103
100
GeomProcessingParams paramsUnscaled (geomSettingsDefault, false );
@@ -109,10 +106,9 @@ namespace CSG_Adapter
109
106
}
110
107
double epsDefault = geomSettings->getEpsilonCoplanarDistance ();
111
108
double epsMinFaceAreaDefault = geomSettings->getMinTriangleArea ();
112
- double CARVE_EPSILON = 10.0 * epsDefault * scale;
109
+ double CARVE_EPSILON = epsDefault; // 10.0 * epsDefault * scale;
113
110
double epsMinFaceArea = epsMinFaceAreaDefault * ( scale * scale );
114
111
double epsCoplanarAngle = geomSettings->getEpsilonCoplanarAngle () * scale;
115
- double CARVE_EPSILON_restore = epsDefault;
116
112
geomSettings->setEpsilonCoplanarDistance (CARVE_EPSILON);
117
113
geomSettings->setEpsilonCoplanarAngle (epsCoplanarAngle);
118
114
geomSettings->setMinTriangleArea (epsMinFaceArea);
@@ -121,18 +117,10 @@ namespace CSG_Adapter
121
117
paramsScaled.callbackFunc = report_callback;
122
118
paramsUnscaled.ifc_entity = entity.get ();
123
119
paramsUnscaled.callbackFunc = report_callback;
124
-
120
+
125
121
bool intersecting = checkBoundinbBoxIntersection (bbox1, bbox2, operation, CARVE_EPSILON);
126
122
if (!intersecting)
127
123
{
128
- #ifdef _DEBUG
129
- shared_ptr<carve::mesh::MeshSet<3 > > op1 (op1Orig->clone ());
130
- shared_ptr<carve::mesh::MeshSet<3 > > op2 (op2Orig->clone ());
131
- int tag = 0 ;
132
- bool op1_dumped = false , op2_dumped = false ;
133
- DumpSettingsStruct dumpColorSettings;
134
- dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsUnscaled);
135
- #endif
136
124
assignResultOnFail (op1Orig, op2Orig, operation, result);
137
125
return true ;
138
126
}
@@ -159,7 +147,6 @@ namespace CSG_Adapter
159
147
160
148
shared_ptr<carve::mesh::MeshSet<3 > > op1 (op1Orig->clone ());
161
149
shared_ptr<carve::mesh::MeshSet<3 > > op2 (op2Orig->clone ());
162
-
163
150
164
151
std::stringstream strs_err;
165
152
try
@@ -177,25 +164,38 @@ namespace CSG_Adapter
177
164
++csg_compute_count;
178
165
DumpSettingsStruct dumpColorSettings;
179
166
dumpColorSettings.eps = CARVE_EPSILON;
167
+ CarveMeshNormalizer normMesh_scaleMeshDump (normMesh);
180
168
if (!normalizeCoords)
181
169
{
182
- dumpColorSettings.normalizer = &normMesh;
170
+ normMesh_scaleMeshDump.m_normalizeCoordsInsteadOfEpsilon = true ;
171
+ paramsScaled.normalizer = &normMesh_scaleMeshDump;
172
+ paramsUnscaled.normalizer = &normMesh_scaleMeshDump;
183
173
}
184
174
185
- if (csg_compute_count == 24 || tag == 20896 )
175
+ if (csg_compute_count == 24 || tag == 99427 )
176
+ {
177
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
178
+ }
179
+
180
+ if (infoMesh1orig.zeroAreaFaces .size () > 0 )
181
+ {
182
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
183
+ }
184
+
185
+ if (infoMesh1orig.finEdges .size () > 0 )
186
+ {
187
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
188
+ }
189
+ if (infoMesh2orig.finEdges .size () > 0 )
186
190
{
187
191
dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
188
- // dumpMeshes = true;
189
192
}
190
193
#endif
191
194
192
195
bool triangulateOperands = true ;
193
196
bool shouldBeClosedManifold = true ;
194
- MeshOps::simplifyMeshSet (op1, geomSettings, paramsScaled, triangulateOperands, shouldBeClosedManifold);
195
- MeshOps::simplifyMeshSet (op2, geomSettings, paramsScaled, triangulateOperands, shouldBeClosedManifold);
196
-
197
- MeshOps::retriangulateMeshSetSimple (op1, false , paramsScaled, 0 );
198
- MeshOps::retriangulateMeshSetSimple (op2, false , paramsScaled, 0 );
197
+ MeshOps::simplifyMeshSet (op1, paramsScaled, triangulateOperands, shouldBeClosedManifold);
198
+ MeshOps::simplifyMeshSet (op2, paramsScaled, triangulateOperands, shouldBeClosedManifold);
199
199
200
200
MeshSetInfo infoMesh1 (report_callback, entity.get ());
201
201
MeshSetInfo infoMesh2 (report_callback, entity.get ());
@@ -213,18 +213,63 @@ namespace CSG_Adapter
213
213
paramsUnscaled.allowFinEdges = true ;
214
214
}
215
215
216
+ if (infoMesh1orig.zeroAreaFaces .size () > 0 )
217
+ {
218
+ paramsScaled.allowZeroAreaFaces = true ; // temp
219
+ paramsUnscaled.allowZeroAreaFaces = true ; // temp
220
+ }
221
+
216
222
if (!operand1valid && operand1origvalid)
217
223
{
224
+ #ifdef _DEBUG
225
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
226
+ double vol1 = MeshOps::computeMeshsetVolume (op1.get ());
227
+ {
228
+ shared_ptr<carve::mesh::MeshSet<3 > > op1Clone (op1Orig->clone ());
229
+ MeshSetInfo infoMesh1copy (report_callback, entity.get ());
230
+ MeshOps::checkMeshSetValidAndClosed (op1Clone, infoMesh1copy, paramsScaled);
231
+ normMesh.normalizeMesh (op1Clone, " op1Clone" , CARVE_EPSILON);
232
+
233
+ MeshOps::simplifyMeshSet (op1Clone, paramsScaled, triangulateOperands, shouldBeClosedManifold);
234
+
235
+ MeshSetInfo infoMesh1AfterSimplify (report_callback, entity.get ());
236
+ bool operand1CloneValid = MeshOps::checkMeshSetValidAndClosed (op1Clone, infoMesh1AfterSimplify, paramsScaled);
237
+ if (operand1CloneValid)
238
+ {
239
+ int wait = 0 ;
240
+ }
241
+ }
242
+
243
+ #endif
244
+
218
245
op1 = shared_ptr<carve::mesh::MeshSet<3 > >(op1Orig->clone ());
219
246
MeshSetInfo infoMesh1copy (report_callback, entity.get ());
220
- bool operand1copy_valid = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1copy, paramsUnscaled);
247
+ MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1copy, paramsUnscaled);
221
248
222
249
normMesh.normalizeMesh (op1, " op1orig" , CARVE_EPSILON);
223
250
operand1valid = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1, paramsScaled);
224
251
if (!operand1valid && operand1origvalid)
225
252
{
226
253
// normalizing changed the validity, should not happen
227
254
#ifdef _DEBUG
255
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
256
+ double vol1 = MeshOps::computeMeshsetVolume (op1.get ());
257
+ #endif
258
+ }
259
+ }
260
+
261
+ if (!operand2valid && operand2origvalid)
262
+ {
263
+ op1 = shared_ptr<carve::mesh::MeshSet<3 > >(op2Orig->clone ());
264
+ MeshSetInfo infoMesh2copy (report_callback, entity.get ());
265
+ bool operand2copy_valid = MeshOps::checkMeshSetValidAndClosed (op2, infoMesh2copy, paramsUnscaled);
266
+
267
+ normMesh.normalizeMesh (op2, " op2orig" , CARVE_EPSILON);
268
+ operand2valid = MeshOps::checkMeshSetValidAndClosed (op2, infoMesh2, paramsScaled);
269
+ if (!operand2valid && operand2origvalid)
270
+ {
271
+ // normalizing changed the validity, should not happen
272
+ #ifdef _DEBUG
228
273
229
274
dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
230
275
double vol2 = MeshOps::computeMeshsetVolume (op2.get ());
@@ -234,6 +279,11 @@ namespace CSG_Adapter
234
279
235
280
if ( !operand1valid || !operand2valid )
236
281
{
282
+ #ifdef _DEBUG
283
+
284
+ dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
285
+ double vol2 = MeshOps::computeMeshsetVolume (op2.get ());
286
+ #endif
237
287
assignResultOnFail (op1Orig, op2Orig, operation, result);
238
288
return false ;
239
289
}
@@ -269,22 +319,29 @@ namespace CSG_Adapter
269
319
270
320
dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
271
321
double vol2 = MeshOps::computeMeshsetVolume (op2.get ());
322
+ double volume_result = MeshOps::computeMeshsetVolume (result.get ());
323
+
324
+ if (triangulateOperands)
325
+ {
326
+ if (infoMesh1.maxNumberOfEdgesPerFace != 3 || infoMesh2.maxNumberOfEdgesPerFace != 3 )
327
+ {
328
+ std::cout << " not triangulated" << std::endl;
329
+ }
330
+ }
272
331
#endif
273
- MeshOps::fixMeshset (result, geomSettings, paramsScaled. debugDump );
332
+ MeshOps::simplifyMeshSet (result, paramsScaled, triangulateOperands, shouldBeClosedManifold );
274
333
result_meshset_ok = MeshOps::checkMeshSetValidAndClosed (result, infoResult, paramsScaled);
275
334
}
276
335
277
336
#ifdef _DEBUG
278
- if (csg_compute_count > 15 )
337
+ if (!result_meshset_ok )
279
338
{
280
339
double vol2 = MeshOps::computeMeshsetVolume (op2.get ());
281
340
dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
282
341
}
283
342
#endif
284
343
285
344
// TODO: check for fail with closed mesh, but not fully sliced through.
286
-
287
- #ifdef _USE_CLASSIFY_NORMAL
288
345
if (!result_meshset_ok)
289
346
{
290
347
carve::csg::CSG csg (CARVE_EPSILON);
@@ -296,11 +353,11 @@ namespace CSG_Adapter
296
353
#ifdef _DEBUG
297
354
dumpOperands (op1, op2, result, tag, op1_dumped, op2_dumped, dumpColorSettings, paramsScaled);
298
355
#endif
299
- MeshOps::fixMeshset (result, geomSettings, paramsScaled.debugDump );
356
+
357
+ MeshOps::simplifyMeshSet (result, paramsScaled, triangulateOperands, shouldBeClosedManifold);
300
358
result_meshset_ok = MeshOps::checkMeshSetValidAndClosed (result, infoResult, paramsScaled);
301
359
}
302
360
}
303
- #endif
304
361
305
362
#ifdef _DEBUG
306
363
double vol = MeshOps::computeMeshsetVolume (result.get ());
@@ -366,7 +423,6 @@ namespace CSG_Adapter
366
423
367
424
normMesh.deNormalizeMesh (result, " " , CARVE_EPSILON);
368
425
369
-
370
426
#ifdef _DEBUG
371
427
{
372
428
// de-normalized:
@@ -411,6 +467,7 @@ namespace CSG_Adapter
411
467
MeshSetInfo infoMesh1 (report_callback, entity.get ());
412
468
bool allowFinEdges = false ;
413
469
GeomProcessingParams params (geomSettings, false );
470
+ params.allowZeroAreaFaces = true ; // will be removed later
414
471
bool operand1valid = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1, params);
415
472
416
473
if (!operand1valid)
@@ -432,14 +489,16 @@ namespace CSG_Adapter
432
489
433
490
#ifdef _DEBUG
434
491
435
- MeshSetInfo infoMesh1 (report_callback, entity.get ());
492
+ MeshSetInfo infoMesh1_2 (report_callback, entity.get ());
436
493
bool allowFinEdges = false ;
437
494
GeomProcessingParams params (geomSettings, false );
438
- bool operand1valid_2 = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1 , params);
495
+ bool operand1valid_2 = MeshOps::checkMeshSetValidAndClosed (op1, infoMesh1_2 , params);
439
496
440
497
if (!operand1valid_2)
441
498
{
442
- std::cout << " !operand1valid" << std::endl;
499
+ std::cout << " !operand1valid after computeCSG_Carve" << std::endl;
500
+ DumpSettingsStruct dumpSet;
501
+ dumpWithLabel (" computeCSG_Carve:result:op1 " , op1, dumpSet, params, true , true );
443
502
}
444
503
#endif
445
504
continue ;
@@ -463,7 +522,7 @@ namespace CSG_Adapter
463
522
464
523
if (!operand1valid_3)
465
524
{
466
- std::cout << " !operand1valid " << std::endl;
525
+ std::cout << " !operand1valid_3 computeCSG_Carve " << std::endl;
467
526
}
468
527
}
469
528
#endif
0 commit comments