Skip to content

Commit b1763a5

Browse files
committed
remove void addOpenPolyhedron( ...), use addPolyhedron instead
1 parent e9dbb8f commit b1763a5

File tree

8 files changed

+74
-110
lines changed

8 files changed

+74
-110
lines changed

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class FaceConverter : public StatusCallback
139139

140140
PolyInputCache3D poly_cache;
141141
Sweeper::createTriangulated3DFace( face_loops, outer_boundary.get(), poly_cache );
142-
item_data->addOpenPolyhedron( poly_cache.m_poly_data );
142+
bool isClosed = false;
143+
item_data->addPolyhedron( poly_cache.m_poly_data, isClosed );
143144
item_data->applyTransformToItem( curve_bounded_plane_matrix );
144145
}
145146
else if( dynamic_pointer_cast<IfcCurveBoundedSurface>( bounded_surface ) )
@@ -370,35 +371,32 @@ class FaceConverter : public StatusCallback
370371
}
371372

372373
// IfcFaceList can be a closed or open shell
373-
if( st == SHELL_TYPE_UNKONWN )
374-
{
375-
item_data->addOpenOrClosedPolyhedron( poly_cache.m_poly_data );
376-
}
377-
else if( st == OPEN_SHELL )
374+
bool isClosed = false;
375+
item_data->addPolyhedron(poly_cache.m_poly_data, isClosed);
376+
377+
#ifdef _DEBUG
378+
if( st == SHELL_TYPE_UNKONWN || st == OPEN_SHELL)
378379
{
379-
item_data->addOpenPolyhedron( poly_cache.m_poly_data );
380+
// ok
380381
}
381382
else if( st == CLOSED_SHELL )
382383
{
383-
try
384-
{
385-
item_data->addClosedPolyhedron( poly_cache.m_poly_data );
386-
}
387-
catch( BuildingException& e )
384+
if (!isClosed)
388385
{
389386
// not a fatal error, just mesh is not closed
390-
messageCallback( e.what(), StatusCallback::MESSAGE_TYPE_MINOR_WARNING, "", report_entity ); // calling function already in e.what()
387+
messageCallback("convertIfcFaceList: CLOSED_SHELL: mesh is not closed", StatusCallback::MESSAGE_TYPE_MINOR_WARNING, "", report_entity);
391388

392-
#ifdef _DEBUG
393-
if( item_data->m_meshsets_open.size() > 0 )
389+
if (item_data->m_meshsets_open.size() > 0)
394390
{
395-
shared_ptr<carve::mesh::MeshSet<3> > meshset = item_data->m_meshsets_open.back();
396-
carve::geom::vector<4> color = carve::geom::VECTOR(0.7, 0.7, 0.7, 1.0);
397-
//shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_cache.m_poly_data->createMesh(carve::input::opts()));
398-
GeomDebugDump::dumpMeshset(meshset, color, true);
391+
shared_ptr<carve::mesh::MeshSet<3> >& meshset = item_data->m_meshsets_open.back();
392+
if (!meshset->isClosed())
393+
{
394+
carve::geom::vector<4> color = carve::geom::VECTOR(0.7, 0.7, 0.7, 1.0);
395+
GeomDebugDump::dumpMeshset(meshset, color, true);
396+
}
399397
}
400-
#endif
401398
}
402399
}
400+
#endif
403401
}
404402
};

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ class ItemShapeData
123123
return true;
124124
}
125125

126-
void addOpenOrClosedPolyhedron( const shared_ptr<carve::input::PolyhedronData>& poly_data )
126+
void addPolyhedron( const shared_ptr<carve::input::PolyhedronData>& poly_data, bool& isClosed )
127127
{
128+
isClosed = false;
128129
if( !poly_data )
129130
{
130131
return;
@@ -139,6 +140,7 @@ class ItemShapeData
139140
shared_ptr<carve::mesh::MeshSet<3> > meshset( poly_data->createMesh( carve::input::opts() ) );
140141
if( meshset->isClosed() )
141142
{
143+
isClosed = true;
142144
m_meshsets.push_back( meshset );
143145
}
144146
else
@@ -147,38 +149,6 @@ class ItemShapeData
147149
}
148150
}
149151

150-
void addOpenPolyhedron( const shared_ptr<carve::input::PolyhedronData>& poly_data )
151-
{
152-
if( poly_data->getVertexCount() < 3 )
153-
{
154-
return;
155-
}
156-
157-
shared_ptr<carve::mesh::MeshSet<3> > meshset( poly_data->createMesh( carve::input::opts() ) );
158-
m_meshsets_open.push_back( meshset );
159-
}
160-
161-
void addClosedPolyhedron( const shared_ptr<carve::input::PolyhedronData>& poly_data )
162-
{
163-
if( poly_data->getVertexCount() < 3 )
164-
{
165-
return;
166-
}
167-
168-
std::map<std::string, std::string> mesh_input_options;
169-
//mesh_input_options["avoid_cavities"] = "true";
170-
shared_ptr<carve::mesh::MeshSet<3> > meshset( poly_data->createMesh( mesh_input_options ) );
171-
if( meshset->isClosed() )
172-
{
173-
m_meshsets.push_back( meshset );
174-
}
175-
else
176-
{
177-
m_meshsets_open.push_back(meshset); // still may be useful as open mesh
178-
//throw BuildingException("Meshset is not closed", __FUNC__);
179-
}
180-
}
181-
182152
void addPoint( const vec3& point )
183153
{
184154
shared_ptr<carve::input::VertexData> vertex_data;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ class RepresentationConverter : public StatusCallback
688688

689689
PolyInputCache3D poly_cache;
690690
Sweeper::createTriangulated3DFace( face_loops, outer_boundary.get(), poly_cache );
691-
item_data->addOpenPolyhedron( poly_cache.m_poly_data );
691+
bool isClosed = false;
692+
item_data->addPolyhedron( poly_cache.m_poly_data, isClosed );
692693

693694
return;
694695
}
@@ -834,7 +835,8 @@ class RepresentationConverter : public StatusCallback
834835
}
835836
if( poly_cache_top_face.m_poly_data )
836837
{
837-
topo_item_data->addOpenOrClosedPolyhedron( poly_cache_top_face.m_poly_data );
838+
bool isClosed = false;
839+
topo_item_data->addPolyhedron( poly_cache_top_face.m_poly_data, isClosed );
838840
}
839841
return;
840842
}
@@ -867,7 +869,8 @@ class RepresentationConverter : public StatusCallback
867869

868870
if( poly_cache_top_face.m_poly_data )
869871
{
870-
topo_item_data->addOpenOrClosedPolyhedron( poly_cache_top_face.m_poly_data );
872+
bool isClosed = false;
873+
topo_item_data->addPolyhedron( poly_cache_top_face.m_poly_data, isClosed );
871874
}
872875
}
873876
return;
@@ -926,7 +929,6 @@ class RepresentationConverter : public StatusCallback
926929
{
927930
return;
928931
}
929-
const double length_factor = m_unit_converter->getLengthInMeterFactor();
930932

931933
// convert opening representation
932934
for( auto& rel_voids_weak : vec_rel_voids )

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ class SolidModelConverter : public StatusCallback
735735
//}
736736
#endif
737737

738-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
738+
bool isClosed = false;
739+
item_data->addPolyhedron( polyhedron_data, isClosed );
739740
}
740741

741742
void convertIfcRevolvedAreaSolid( const shared_ptr<IfcRevolvedAreaSolid>& revolved_area, shared_ptr<ItemShapeData> item_data )
@@ -966,7 +967,8 @@ class SolidModelConverter : public StatusCallback
966967
polyhedron_data->addFace( 3, 7, 4 );
967968
polyhedron_data->addFace( 4, 0, 3 );
968969

969-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
970+
bool isClosed = false;
971+
item_data->addPolyhedron( polyhedron_data, isClosed );
970972
return;
971973
}
972974

@@ -1006,7 +1008,8 @@ class SolidModelConverter : public StatusCallback
10061008
polyhedron_data->addFace( 0, 4, 3 );
10071009
polyhedron_data->addFace( 0, 3, 2 );
10081010

1009-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
1011+
bool isClosed = false;
1012+
item_data->addPolyhedron( polyhedron_data, isClosed );
10101013
return;
10111014
}
10121015

@@ -1052,7 +1055,8 @@ class SolidModelConverter : public StatusCallback
10521055
}
10531056
polyhedron_data->addFace( 1, m_geom_settings->getNumVerticesPerCircleWithRadius(radius) + 1, 2 );
10541057

1055-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
1058+
bool isClosed = false;
1059+
item_data->addPolyhedron( polyhedron_data, isClosed );
10561060
return;
10571061
}
10581062

@@ -1101,7 +1105,8 @@ class SolidModelConverter : public StatusCallback
11011105
polyhedron_data->addFace( 1, i*2 + 5, i*2 + 3 ); // bottom cap: 1-5-3 1-7-5 1-9-7
11021106
}
11031107

1104-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
1108+
bool isClosed = false;
1109+
item_data->addPolyhedron( polyhedron_data, isClosed );
11051110
return;
11061111
}
11071112

@@ -1180,7 +1185,8 @@ class SolidModelConverter : public StatusCallback
11801185
polyhedron_data->addFace( last_index, last_index - ( i + 2 ), last_index - ( i + 1 ) );
11811186
}
11821187
polyhedron_data->addFace( last_index, last_index - 1, last_index - nvc );
1183-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
1188+
bool isClosed = false;
1189+
item_data->addPolyhedron( polyhedron_data, isClosed );
11841190
return;
11851191
}
11861192
messageCallback( "Unhandled IFC Representation", StatusCallback::MESSAGE_TYPE_WARNING, __FUNC__, csg_primitive.get() );
@@ -1300,7 +1306,8 @@ class SolidModelConverter : public StatusCallback
13001306
poly_point = box_position_matrix*poly_point;
13011307
}
13021308

1303-
item_data->addOpenOrClosedPolyhedron( polyhedron_data );
1309+
bool isClosed = false;
1310+
item_data->addPolyhedron( polyhedron_data, isClosed );
13041311
return;
13051312
}
13061313

@@ -1481,7 +1488,8 @@ class SolidModelConverter : public StatusCallback
14811488
vec3 half_space_extrusion_vector = half_space_extrusion_direction*HALF_SPACE_BOX_SIZE*m_point_converter->getUnitConverter()->getCustomLengthFactor();
14821489
shared_ptr<carve::input::PolyhedronData> half_space_box_data( new carve::input::PolyhedronData() );
14831490
extrudeBox( base_surface_points, half_space_extrusion_vector, half_space_box_data );
1484-
item_data->addOpenOrClosedPolyhedron( half_space_box_data );
1491+
bool isClosed = false;
1492+
item_data->addPolyhedron( half_space_box_data, isClosed );
14851493
}
14861494
}
14871495

@@ -1505,7 +1513,8 @@ class SolidModelConverter : public StatusCallback
15051513

15061514
shared_ptr<carve::input::PolyhedronData> half_space_box_data( new carve::input::PolyhedronData() );
15071515
extrudeBox( box_base_points, half_space_extrusion_vector, half_space_box_data );
1508-
item_data->addOpenOrClosedPolyhedron( half_space_box_data );
1516+
bool isClosed = false;
1517+
item_data->addPolyhedron( half_space_box_data, isClosed );
15091518
}
15101519

15111520
return;

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

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -182,32 +182,18 @@ class Sweeper : public StatusCallback
182182
}
183183
}
184184

185-
try
186-
{
187-
#ifdef _DEBUG
188-
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
189-
bool valid = CSG_Adapter::checkMeshSetValidAndClosed(meshset, this, ifc_entity);
190-
if (!valid)
191-
{
192-
carve::geom::vector<4> color = carve::geom::VECTOR(0.3, 0.4, 0.5, 1.0);
193-
GeomDebugDump::dumpMeshset(meshset, color, true);
194-
GeomDebugDump::clearMeshsetDump();
195-
}
196-
#endif
197-
198-
item_data->addClosedPolyhedron(poly_data);
185+
bool isClosed = false;
186+
item_data->addPolyhedron(poly_data, isClosed);
199187

200-
}
201-
catch (BuildingException& exception)
202-
{
203188
#ifdef _DEBUG
204-
std::cout << exception.what() << std::endl;
189+
if( !isClosed )
190+
{
205191
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
206192
carve::geom::vector<4> color = carve::geom::VECTOR(0.3, 0.4, 0.5, 1.0);
207193
GeomDebugDump::dumpMeshset(meshset, color, true);
208-
#endif
209-
messageCallback(exception.what(), StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
194+
messageCallback("extrude: meshset not closed", StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
210195
}
196+
#endif
211197
}
212198
}
213199

@@ -577,19 +563,19 @@ class Sweeper : public StatusCallback
577563
}
578564
}
579565

580-
try
581-
{
582-
item_data->addClosedPolyhedron(poly_data);
583-
}
584-
catch (BuildingException& exception)
585-
{
586-
messageCallback(exception.what(), StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
566+
bool isClosed = false;
567+
item_data->addPolyhedron(poly_data, isClosed);
568+
587569
#ifdef _DEBUG
570+
if( !isClosed )
571+
{
572+
messageCallback("sweepDisk: meshset not closed", StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
573+
588574
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
589575
carve::geom::vector<4> color = carve::geom::VECTOR(0.7, 0.7, 0.7, 1.0);
590576
GeomDebugDump::dumpMeshset(meshset, color, true);
591-
#endif
592577
}
578+
#endif
593579

594580
#ifdef _DEBUG
595581
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
@@ -909,23 +895,17 @@ class Sweeper : public StatusCallback
909895

910896
}
911897

912-
try
913-
{
914-
item_data->addClosedPolyhedron(poly_data);
915-
}
916-
catch (BuildingException& exception)
917-
{
918-
messageCallback(exception.what(), StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
898+
bool isClosed = false;
899+
item_data->addPolyhedron(poly_data, isClosed);
900+
919901
#ifdef _DEBUG
902+
if( !isClosed)
903+
{
904+
messageCallback("sweepArea: meshset not closed", StatusCallback::MESSAGE_TYPE_WARNING, "", ifc_entity); // calling function already in e.what()
920905
carve::geom::vector<4> color = carve::geom::VECTOR(0.7, 0.7, 0.7, 1.0);
921906
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
922907
GeomDebugDump::dumpMeshset(meshset, color, true);
923-
#endif
924908
}
925-
926-
#ifdef _DEBUG
927-
shared_ptr<carve::mesh::MeshSet<3> > meshset(poly_data->createMesh(carve::input::opts()));
928-
CSG_Adapter::checkMeshSetValidAndClosed(meshset, this, ifc_entity);
929909
#endif
930910
}
931911
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class TessellatedItemConverter : public StatusCallback {
8181
if(auto const tri_face_set = dynamic_pointer_cast<IfcTriangulatedFaceSet>(tessellated_item))
8282
convertTriangulatedFaceSet( tri_face_set, coordinate_count, carve_mesh_builder );
8383

84-
item_data->addOpenOrClosedPolyhedron( carve_mesh_builder );
84+
bool isClosed = false;
85+
item_data->addPolyhedron( carve_mesh_builder, isClosed );
8586
}
8687

8788
protected:

IfcPlusPlus/src/ifcpp/writer/WriterUtil.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ std::string encodeStepString( const std::wstring& str )
192192
while( *stream_pos != '\0' )
193193
{
194194
wchar_t append_char = *stream_pos;
195-
if( append_char == 10 )
195+
if (append_char == 9)
196+
{
197+
closeUnicodeBlockIfOpened();
198+
// encode tab
199+
result_str.append("\\X\\09");
200+
}
201+
else if( append_char == 10 )
196202
{
197203
closeUnicodeBlockIfOpened();
198204
// encode new line

examples/SimpleViewerExampleQt/src/gui/TabReadWrite.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ void TabReadWrite::loadIfcFile( QString& path_in )
293293
step_reader->loadModelFromFile(path_str, geometry_converter->getBuildingModel());
294294

295295
// convert IFC geometric representations into Carve geometry
296-
const double length_in_meter = geometry_converter->getBuildingModel()->getUnitConverter()->getLengthInMeterFactor();
297-
geometry_converter->setCsgEps(1.5e-08*length_in_meter);
298296
geometry_converter->convertGeometry();
299297

300298
// convert Carve geometry to OSG

0 commit comments

Comments
 (0)