Skip to content

Commit 3d47f5c

Browse files
committed
small bug fixes
1 parent bdc42bb commit 3d47f5c

20 files changed

+421
-535
lines changed

IfcPlusPlus/src/ifcpp/geometry/CSG_Adapter.h

+23-35
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
2626

2727
#include "IncludeCarveHeaders.h"
2828
#include "MeshOps.h"
29-
#include "MeshOpsDebug.h"
3029
#include "GeometryInputData.h"
3130

32-
//#define _USE_MANIFOLD_CSG
33-
#ifdef _USE_MANIFOLD_CSG
34-
#include "CSG_Manifold.h"
35-
#endif
36-
3731
#ifdef _DEBUG
3832
static int csg_compute_count = 0;
3933
#endif
@@ -97,19 +91,19 @@ namespace CSG_Adapter
9791
CarveMeshNormalizer normMesh(bbox1, bbox2, normalizeCoords);
9892
normMesh.m_disableNormalizeAll = false;
9993

94+
int tag = entity->m_tag;
10095
GeomProcessingParams paramsUnscaled(geomSettingsDefault, false);
10196
shared_ptr<GeometrySettings> geomSettings(new GeometrySettings(geomSettingsDefault));
10297
double scale = normMesh.getScale();
10398
if (!normalizeCoords)
10499
{
105100
scale = 1.0;
106101
}
107-
double epsDefault = geomSettings->getEpsilonCoplanarDistance();
102+
double epsDefault = geomSettings->getEpsilonMergePoints();
108103
double epsMinFaceAreaDefault = geomSettings->getMinTriangleArea();
109-
double CARVE_EPSILON = epsDefault;// 10.0 * epsDefault * scale;
110104
double epsMinFaceArea = epsMinFaceAreaDefault * ( scale * scale );
111105
double epsCoplanarAngle = geomSettings->getEpsilonCoplanarAngle() * scale;
112-
geomSettings->setEpsilonCoplanarDistance(CARVE_EPSILON);
106+
geomSettings->setEpsilonMergePoints(epsDefault);
113107
geomSettings->setEpsilonCoplanarAngle(epsCoplanarAngle);
114108
geomSettings->setMinTriangleArea(epsMinFaceArea);
115109
GeomProcessingParams paramsScaled(geomSettings, false);
@@ -118,7 +112,7 @@ namespace CSG_Adapter
118112
paramsUnscaled.ifc_entity = entity.get();
119113
paramsUnscaled.callbackFunc = report_callback;
120114

121-
bool intersecting = checkBoundinbBoxIntersection(bbox1, bbox2, operation, CARVE_EPSILON);
115+
bool intersecting = checkBoundinbBoxIntersection(bbox1, bbox2, operation, epsDefault);
122116
if (!intersecting)
123117
{
124118
assignResultOnFail(op1Orig, op2Orig, operation, result);
@@ -152,18 +146,22 @@ namespace CSG_Adapter
152146
try
153147
{
154148
// 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+
}
157156

158157
bool op1_dumped = false;
159158
bool op2_dumped = false;
160-
int tag = entity->m_tag;
161159
MeshOps::flattenFacePlanes(op1, op2, paramsScaled);
162160

163161
#ifdef _DEBUG
164162
++csg_compute_count;
165-
DumpSettingsStruct dumpColorSettings;
166-
dumpColorSettings.eps = CARVE_EPSILON;
163+
GeomDebugDump::DumpSettingsStruct dumpColorSettings;
164+
dumpColorSettings.eps = epsDefault;
167165
CarveMeshNormalizer normMesh_scaleMeshDump(normMesh);
168166
if (!normalizeCoords)
169167
{
@@ -172,9 +170,9 @@ namespace CSG_Adapter
172170
paramsUnscaled.normalizer = &normMesh_scaleMeshDump;
173171
}
174172

175-
if (csg_compute_count == 24 || tag == 99427)
173+
if (csg_compute_count == 24 || tag == 5598)
176174
{
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);
178176
}
179177

180178
if (infoMesh1orig.zeroAreaFaces.size() > 0)
@@ -228,7 +226,7 @@ namespace CSG_Adapter
228226
shared_ptr<carve::mesh::MeshSet<3> > op1Clone(op1Orig->clone());
229227
MeshSetInfo infoMesh1copy(report_callback, entity.get());
230228
MeshOps::checkMeshSetValidAndClosed(op1Clone, infoMesh1copy, paramsScaled);
231-
normMesh.normalizeMesh(op1Clone, "op1Clone", CARVE_EPSILON);
229+
normMesh.normalizeMesh(op1Clone, "op1Clone", epsDefault);
232230

233231
MeshOps::simplifyMeshSet(op1Clone, paramsScaled, triangulateOperands, shouldBeClosedManifold);
234232

@@ -246,7 +244,7 @@ namespace CSG_Adapter
246244
MeshSetInfo infoMesh1copy(report_callback, entity.get());
247245
MeshOps::checkMeshSetValidAndClosed(op1, infoMesh1copy, paramsUnscaled);
248246

249-
normMesh.normalizeMesh(op1, "op1orig", CARVE_EPSILON);
247+
normMesh.normalizeMesh(op1, "op1orig", epsDefault);
250248
operand1valid = MeshOps::checkMeshSetValidAndClosed(op1, infoMesh1, paramsScaled);
251249
if (!operand1valid && operand1origvalid)
252250
{
@@ -264,7 +262,7 @@ namespace CSG_Adapter
264262
MeshSetInfo infoMesh2copy(report_callback, entity.get());
265263
bool operand2copy_valid = MeshOps::checkMeshSetValidAndClosed(op2, infoMesh2copy, paramsUnscaled);
266264

267-
normMesh.normalizeMesh(op2, "op2orig", CARVE_EPSILON);
265+
normMesh.normalizeMesh(op2, "op2orig", epsDefault);
268266
operand2valid = MeshOps::checkMeshSetValidAndClosed(op2, infoMesh2, paramsScaled);
269267
if (!operand2valid && operand2origvalid)
270268
{
@@ -307,7 +305,7 @@ namespace CSG_Adapter
307305
if (infoMesh2.degenerateEdges.size() > 0) { paramsScaled.allowDegenerateEdges = true; }
308306

309307
////////////////////// compute carve csg operation /////////////////////////////////////////////
310-
carve::csg::CSG csg(CARVE_EPSILON);
308+
carve::csg::CSG csg(epsDefault);
311309
result = shared_ptr<carve::mesh::MeshSet<3> >(csg.compute(op1.get(), op2.get(), operation, nullptr, carve::csg::CSG::CLASSIFY_EDGE));
312310

313311
MeshSetInfo infoResult( report_callback, entity.get() );
@@ -344,7 +342,7 @@ namespace CSG_Adapter
344342
// TODO: check for fail with closed mesh, but not fully sliced through.
345343
if (!result_meshset_ok)
346344
{
347-
carve::csg::CSG csg(CARVE_EPSILON);
345+
carve::csg::CSG csg(epsDefault);
348346
result = shared_ptr<carve::mesh::MeshSet<3> >(csg.compute(op1.get(), op2.get(), operation, nullptr, carve::csg::CSG::CLASSIFY_NORMAL));
349347
result_meshset_ok = MeshOps::checkMeshSetValidAndClosed(result, infoResult, paramsScaled);
350348

@@ -368,16 +366,6 @@ namespace CSG_Adapter
368366
}
369367
#endif
370368

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-
381369
if( !result_meshset_ok )
382370
{
383371
strs_err << "csg operation failed" << std::endl;
@@ -421,7 +409,7 @@ namespace CSG_Adapter
421409
bool result_meshset_ok_beforeDeNormalize = MeshOps::checkMeshSetValidAndClosed(result, infoMesh_beforeDeNormalize, paramsScaled);
422410
#endif
423411

424-
normMesh.deNormalizeMesh(result, "", CARVE_EPSILON);
412+
normMesh.deNormalizeMesh(result, "", epsDefault);
425413

426414
#ifdef _DEBUG
427415
{
@@ -497,8 +485,8 @@ namespace CSG_Adapter
497485
if (!operand1valid_2)
498486
{
499487
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);
502490
}
503491
#endif
504492
continue;

IfcPlusPlus/src/ifcpp/geometry/ConverterOSG.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ class ConverterOSG : public StatusCallback
721721
void convertMeshSets(std::vector<shared_ptr<carve::mesh::MeshSet<3> > >& vecMeshSets, osg::Geode* geode, size_t ii_item, bool disableBackfaceCulling)
722722
{
723723
double min_triangle_area = m_geom_settings->getMinTriangleArea();
724-
double eps = m_geom_settings->getEpsilonCoplanarDistance();
724+
double eps = m_geom_settings->getEpsilonMergePoints();
725725
double crease_angle = m_faces_crease_angle;
726726
for (size_t ii = 0; ii < vecMeshSets.size(); ++ii)
727727
{

IfcPlusPlus/src/ifcpp/geometry/CurveConverter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class CurveConverter : public StatusCallback
125125
std::vector<shared_ptr<IfcTrimmingSelect> >& trim1_vec, std::vector<shared_ptr<IfcTrimmingSelect> >& trim2_vec, bool senseAgreement) const
126126
{
127127
double lengthFactor = m_point_converter->getUnitConverter()->getLengthInMeterFactor();
128-
double CARVE_EPSILON = m_geom_settings->getEpsilonCoplanarDistance();
128+
double CARVE_EPSILON = m_geom_settings->getEpsilonMergePoints();
129129

130130
// ENTITY IfcCurve ABSTRACT SUPERTYPE OF (ONEOF(IfcBoundedCurve, IfcConic, IfcLine, IfcOffsetCurve2D, IfcOffsetCurve3D, IfcPCurve))
131131
shared_ptr<IfcBoundedCurve> bounded_curve = dynamic_pointer_cast<IfcBoundedCurve>(ifc_curve);

IfcPlusPlus/src/ifcpp/geometry/FaceConverter.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class FaceConverter : public StatusCallback
138138
m_curve_converter->convertIfcCurve( inner_boundary, inner_boundary_loop, segment_start_points, true );
139139
}
140140

141-
double CARVE_EPSILON = m_geom_settings->getEpsilonCoplanarDistance();
141+
double CARVE_EPSILON = m_geom_settings->getEpsilonMergePoints();
142142
PolyInputCache3D poly_cache(CARVE_EPSILON);
143143
bool mergeAlignedEdges = true;
144144
GeomProcessingParams params( m_geom_settings, outer_boundary.get(), this );
@@ -328,7 +328,7 @@ class FaceConverter : public StatusCallback
328328
{
329329
return;
330330
}
331-
double CARVE_EPSILON = m_geom_settings->getEpsilonCoplanarDistance();
331+
double CARVE_EPSILON = m_geom_settings->getEpsilonMergePoints();
332332
PolyInputCache3D poly_cache(CARVE_EPSILON);
333333
GeomProcessingParams params( m_geom_settings, nullptr, this );
334334

0 commit comments

Comments
 (0)