Skip to content

Commit a2ec0a7

Browse files
committed
fix for IFC entities over several lines, or several entities in one line
1 parent 752a9a1 commit a2ec0a7

File tree

10 files changed

+260
-104
lines changed

10 files changed

+260
-104
lines changed

IfcPlusPlus/src/ifcpp/geometry/Carve/CSG_Adapter.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ namespace CSG_Adapter
282282
if( !result_meshset_ok )
283283
{
284284
#ifdef OCC_FOUND
285+
// include directory $(CSF_OPT_INC)
286+
285287
TopoDS_Shape operand1_shape;
286288
TopoDS_Shape operand2_shape;
287289
MeshUtils::convertCarve2OpenCascade(op1.get(), operand1_shape);
@@ -347,7 +349,7 @@ namespace CSG_Adapter
347349
if( volume2 < 0 ) { operand2_solid.Reverse(); }
348350

349351
ShapeFix_ShapeTolerance shapeTolerance;// = new ShapeFix_ShapeTolerance();
350-
double tolerance = 1e-7;
352+
double tolerance = eps;// 1e-7;
351353
shapeTolerance.SetTolerance(operand1_solid,tolerance);
352354
shapeTolerance.SetTolerance(operand2_solid,tolerance);
353355

@@ -368,11 +370,13 @@ namespace CSG_Adapter
368370

369371
MeshUtils::TopoDS_Shape2Meshset(cutResult, result);
370372
result_meshset_ok = MeshUtils::checkMeshSetValidAndClosed(result, infoResult, report_callback, entity.get());
371-
#ifdef _DEBUG
373+
372374
if( result_meshset_ok )
373375
{
374-
std::cout << "CSG no success with carve, success with OCC" << std::endl;
376+
std::cout << "===> CSG successful with OCC" << std::endl;
375377
}
378+
#ifdef _DEBUG
379+
376380

377381
if( !result_meshset_ok )
378382
{

IfcPlusPlus/src/ifcpp/geometry/Carve/GeometryInputData.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,6 @@ class RepresentationData
10921092
~RepresentationData(){}
10931093

10941094
weak_ptr<IFC4X3::IfcRepresentation> m_ifc_representation;
1095-
weak_ptr<IFC4X3::IfcRepresentationContext> m_ifc_representation_context;
10961095
std::vector<shared_ptr<ItemShapeData> > m_vec_item_data;
10971096
std::vector<shared_ptr<AppearanceData> > m_vec_representation_appearances;
10981097
std::string m_representation_identifier;
@@ -1103,7 +1102,6 @@ class RepresentationData
11031102
{
11041103
shared_ptr<RepresentationData> copy_representation( new RepresentationData() );
11051104
copy_representation->m_ifc_representation = m_ifc_representation;
1106-
copy_representation->m_ifc_representation_context = m_ifc_representation_context;
11071105
for( size_t ii = 0; ii < m_vec_item_data.size(); ++ii )
11081106
{
11091107
shared_ptr<ItemShapeData>& item_data = m_vec_item_data[ii];
@@ -1165,7 +1163,6 @@ class RepresentationData
11651163
{
11661164
m_vec_representation_appearances.clear();
11671165
m_ifc_representation.reset();
1168-
m_ifc_representation_context.reset();
11691166
m_vec_item_data.clear();
11701167
m_representation_identifier = "";
11711168
m_representation_type = "";
@@ -1266,6 +1263,34 @@ class ProductShapeData
12661263
m_vec_product_appearances.clear();
12671264
}
12681265

1266+
void clearMeshGeometry()
1267+
{
1268+
m_vec_product_appearances.clear();
1269+
1270+
//m_ifc_object_definition.reset();
1271+
m_object_placement.reset();
1272+
//m_vec_children.clear();
1273+
1274+
for( size_t item_i = 0; item_i < m_vec_representations.size(); ++item_i )
1275+
{
1276+
shared_ptr<RepresentationData>& representation_data = m_vec_representations[item_i];
1277+
1278+
representation_data->m_vec_item_data.clear();
1279+
//std::vector<shared_ptr<ItemShapeData> > & items = representation_data->m_vec_item_data;
1280+
//for( size_t jj = 0; jj < items.size(); ++jj )
1281+
//{
1282+
// shared_ptr<ItemShapeData>& item = items[item_i];
1283+
// item->m_meshsets.clear();
1284+
// item->m_meshsets.clear();
1285+
//}
1286+
1287+
}
1288+
1289+
//m_vec_representations.clear();
1290+
1291+
1292+
m_added_to_spatial_structure = false;
1293+
}
12691294
void clearAll()
12701295
{
12711296
m_vec_product_appearances.clear();

IfcPlusPlus/src/ifcpp/geometry/Carve/MeshUtils.h

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ namespace MeshUtils
399399
{
400400
return false;
401401
}
402-
402+
403403
if( !e->rev )
404404
{
405405
return false;
@@ -530,12 +530,12 @@ namespace MeshUtils
530530
{
531531
return false;
532532
}
533-
533+
534534
if( !checkEdgePointers(e->rev) )
535535
{
536536
return false;
537537
}
538-
538+
539539
// continue
540540
e = e->next;
541541
}
@@ -598,7 +598,7 @@ namespace MeshUtils
598598

599599
e = e->next;
600600
}
601-
601+
602602
return false;
603603
}
604604

@@ -1056,7 +1056,7 @@ namespace MeshUtils
10561056
const vec3 B = edge1->v2()->v;
10571057
const vec3 C = edge2->v1()->v;
10581058
const vec3 D = edge2->v2()->v;
1059-
1059+
10601060
vec3 u = B - A;
10611061
vec3 v = D - C;
10621062
vec3 w = A - C;
@@ -1786,7 +1786,7 @@ namespace MeshUtils
17861786
}
17871787
}
17881788
}
1789-
1789+
17901790
static void triangulateLoops( const std::vector<std::vector<vec2> >& profilePathsInput, std::vector<std::vector<vec2> >& faceLoopsUsedForTriangulation, std::vector<uint32_t>& face_indexes_out, BuildingEntity* ifc_entity )
17911791
{
17921792
// TODO: complete and test
@@ -1977,7 +1977,7 @@ namespace MeshUtils
19771977

19781978
GeomDebugDump::moveOffset(0.3);
19791979
GeomDebugDump::dumpPolyline(profilePathsInput, color, true );
1980-
1980+
19811981
#endif
19821982
return;
19831983
}
@@ -2057,12 +2057,12 @@ namespace MeshUtils
20572057
size_t idx2_poly = poly.addPoint(carve::geom::VECTOR(pt2.x, pt2.y, 0));
20582058
poly.m_poly_data->addFace(idx0_poly, idx1_poly, idx2_poly);
20592059
}
2060-
2060+
20612061
glm::dvec4 colorCurrentLabel(0.3, 0.4, 0.5, 1.0);
20622062
std::string labelStr = "carve_triangulation";
20632063
GeomDebugDump::dumpVertex(GeomDebugDump::labelPos, colorCurrentLabel, labelStr);
20642064
GeomDebugDump::dumpCountLabel(GeomDebugDump::countLabelPos);
2065-
2065+
20662066
glm::dvec4 color(0.3, 0.4, 0.5, 1.0);
20672067
shared_ptr<carve::mesh::MeshSet<3> > mesh_triangle(poly.m_poly_data->createMesh(carve::input::opts()));
20682068
GeomDebugDump::dumpMeshset(mesh_triangle, color, true );
@@ -2195,7 +2195,7 @@ namespace MeshUtils
21952195
vecResultLoop.push_back(startEdge->v2());
21962196
usedEdges.clear();
21972197
usedEdges.insert(startEdge);
2198-
2198+
21992199
#ifdef _DEBUG
22002200
bool blue = true;
22012201
glm::vec4 color1(1.0, 0.1, 1, 1);
@@ -2209,7 +2209,7 @@ namespace MeshUtils
22092209
#endif
22102210

22112211
std::set<carve::mesh::Edge<3>* > vecEdges = vecEdgesInput;
2212-
2212+
22132213
for( size_t ii = 0; ii < vecEdges.size(); ++ii )
22142214
{
22152215
bool connectionFound = false;
@@ -2227,7 +2227,7 @@ namespace MeshUtils
22272227
}
22282228

22292229
vec3& edgeP0 = edge->v1()->v;
2230-
2230+
22312231
vec3 delt0 = edgeP0 - currentEndPoint;
22322232
if( delt0.length2() < eps * eps )
22332233
{
@@ -2475,7 +2475,7 @@ namespace MeshUtils
24752475
PolyInputCache3D polyInput( eps );
24762476
polyhedronFromMeshSet(meshset, polyInput);
24772477
bool meshsetChanged = false;
2478-
2478+
24792479

24802480
for( size_t ii = 0; ii < allOpenEdges.size(); ++ii )
24812481
{
@@ -2956,7 +2956,7 @@ namespace MeshUtils
29562956
aTri.Set(id0, id1, id2);
29572957
//aMesh->SetTriangle(aTriIter, aTri);
29582958

2959-
2959+
29602960
vec3 point1_carve = carve::geom::VECTOR(triang_point1.X(), triang_point1.Y(), triang_point1.Z());
29612961
vec3 point2_carve = carve::geom::VECTOR(triang_point2.X(), triang_point2.Y(), triang_point2.Z());
29622962
vec3 point3_carve = carve::geom::VECTOR(triang_point3.X(), triang_point3.Y(), triang_point3.Z());
@@ -2966,7 +2966,7 @@ namespace MeshUtils
29662966

29672967
std::vector<vec3> trianglePoints = { point1_carve, point2_carve, point3_carve };
29682968
vec3 triangleNormal = GeomUtils::computePolygonNormal(trianglePoints);
2969-
2969+
29702970
poly.m_poly_data->addFace(point1Index, point2Index, point3Index);
29712971

29722972

@@ -3027,7 +3027,7 @@ namespace MeshUtils
30273027
{
30283028
addShapeToPolyInput(shape, poly);
30293029
}
3030-
3030+
30313031
meshset = shared_ptr<carve::mesh::MeshSet<3> >(poly.m_poly_data->createMesh(carve::input::opts()));
30323032
}
30333033

@@ -3137,7 +3137,7 @@ namespace MeshUtils
31373137

31383138
static void convertCarve2OpenCascade(carve::mesh::MeshSet<3>* meshset, TopoDS_Shape& result)
31393139
{
3140-
3140+
31413141
try
31423142
{
31433143
//BRepBuilderAPI_Sewing sewer;
@@ -3147,7 +3147,7 @@ namespace MeshUtils
31473147
TopoDS_Shell shell;
31483148
BRep_Builder builder;
31493149
builder.MakeShell(shell);
3150-
3150+
31513151
std::map<carve::mesh::Vertex<3>*, TopoDS_Vertex> mapVertices;
31523152
for( size_t ii = 0; ii < meshset->vertex_storage.size(); ++ii )
31533153
{
@@ -3168,10 +3168,10 @@ namespace MeshUtils
31683168
if( faceVertices.size() > 2 )
31693169
{
31703170
BRepBuilderAPI_MakeWire mk_wire;
3171-
3171+
31723172
size_t n = faceVertices.size();
31733173
carve::mesh::Vertex<3>* vertexFirst = faceVertices[0];
3174-
3174+
31753175
for( int i = 0; i < n; ++i )
31763176
{
31773177
carve::mesh::Vertex<3>* v0 = faceVertices[i];
@@ -3225,7 +3225,9 @@ namespace MeshUtils
32253225

32263226
if( wire.IsNull() )
32273227
{
3228+
#ifdef _DEBUG
32283229
std::cout << "wire isNull" << std::endl;
3230+
#endif
32293231
}
32303232
else
32313233
{
@@ -3235,7 +3237,9 @@ namespace MeshUtils
32353237

32363238
if( face.IsNull() )
32373239
{
3240+
#ifdef _DEBUG
32383241
std::cout << "face isNull" << std::endl;
3242+
#endif
32393243
}
32403244
else
32413245
{
@@ -3247,7 +3251,7 @@ namespace MeshUtils
32473251
}
32483252
}
32493253

3250-
3254+
32513255
//sewer.Perform();
32523256
//TopoDS_Shape sewedShape = sewer.SewedShape();
32533257
BRepBuilderAPI_MakeSolid mkSolid(shell);

0 commit comments

Comments
 (0)