@@ -59,6 +59,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
59
59
#include < ifcpp/IFC4/include/IfcUnitAssignment.h>
60
60
#include < ifcpp/IFC4/include/IfcUnitEnum.h>
61
61
#include < ifcpp/IFC4/include/IfcWall.h>
62
+ #include < ifcpp/geometry/Carve/GeometryInputData.h>
62
63
#include " IncludeCarveHeaders.h"
63
64
64
65
inline void convertPlacement (double local_x[3 ], double local_z[3 ], double location[3 ], shared_ptr<IfcAxis2Placement3D>& axis2placement3d, std::vector<shared_ptr<BuildingEntity> >& vec_new_entities)
@@ -203,7 +204,7 @@ namespace GeomDebugDump
203
204
return -1 ;
204
205
}
205
206
206
- inline void MeshSet2Stream (const carve::mesh::MeshSet<3 >* meshset, const vec3& offset, const carve::geom::vector<4 >& color, std::stringstream& strs_out)
207
+ inline void MeshSet2Stream (const carve::mesh::MeshSet<3 >* meshset, const carve::math::Matrix& transform, const vec3& offset, const carve::geom::vector<4 >& color, std::stringstream& strs_out)
207
208
{
208
209
strs_out << " Polyhedron{" << std::endl;
209
210
strs_out << " color{" << color.x << " , " << color.y << " , " << color.z << " , " << color.w << " }" << std::endl;
@@ -225,9 +226,10 @@ namespace GeomDebugDump
225
226
{
226
227
strs_vertices << " , " ;
227
228
}
228
- double x = (vertex.v .x + offset.x )*scale_length_factor;
229
- double y = (vertex.v .y + offset.y )*scale_length_factor;
230
- double z = (vertex.v .z + offset.z )*scale_length_factor;
229
+ vec3 vertex_transformed = transform * vertex.v ;
230
+ double x = (vertex_transformed.x + offset.x )*scale_length_factor;
231
+ double y = (vertex_transformed.y + offset.y )*scale_length_factor;
232
+ double z = (vertex_transformed.z + offset.z )*scale_length_factor;
231
233
232
234
strs_vertices << " {" << x << " ," << y << " ," << z << " }" << std::endl;
233
235
++vertex_count;
@@ -350,6 +352,7 @@ namespace GeomDebugDump
350
352
inline void dumpMeshsets ( const std::vector<carve::mesh::MeshSet<3 >* >& vec_meshsets, const vec3& offset, const std::vector<carve::geom::vector<4 > >& vec_colors, bool append )
351
353
{
352
354
std::stringstream strs_out;
355
+ carve::math::Matrix ident = carve::math::Matrix::IDENT ();
353
356
for ( size_t i = 0 ; i < vec_meshsets.size (); ++i )
354
357
{
355
358
carve::mesh::MeshSet<3 >* meshset = vec_meshsets[i];
@@ -358,7 +361,7 @@ namespace GeomDebugDump
358
361
{
359
362
color = vec_colors[i];
360
363
}
361
- MeshSet2Stream (meshset, offset, color, strs_out);
364
+ MeshSet2Stream (meshset, ident, offset, color, strs_out);
362
365
}
363
366
364
367
if ( !append )
@@ -370,7 +373,7 @@ namespace GeomDebugDump
370
373
dump_ofstream.close ();
371
374
}
372
375
373
- inline void dumpPolyhedron ( const carve::poly::Polyhedron* poly, const vec3& offset, const carve::geom::vector<4 >& color, bool append )
376
+ inline void dumpPolyhedron ( const carve::poly::Polyhedron* poly, const vec3& offset, const carve::geom::vector<4 >& color, bool append)
374
377
{
375
378
std::stringstream strs_out;
376
379
Polyhedron2Stream ( poly, offset, color, strs_out );
@@ -384,10 +387,10 @@ namespace GeomDebugDump
384
387
dump_ofstream << strs_out.str ().c_str ();
385
388
dump_ofstream.close ();
386
389
}
387
- inline void dumpMeshSet (const carve::mesh::MeshSet<3 >* poly , const vec3& offset, const carve::geom::vector<4 >& color, bool append)
390
+ inline void dumpMeshSetWithTransform (const carve::mesh::MeshSet<3 >* meshset , const carve::math::Matrix& transform, const vec3& offset, const carve::geom::vector<4 >& color, bool append, bool move_offset = true )
388
391
{
389
392
std::stringstream strs_out;
390
- MeshSet2Stream (poly , offset, color, strs_out);
393
+ MeshSet2Stream (meshset, transform , offset, color, strs_out);
391
394
392
395
if ( !append )
393
396
{
@@ -397,25 +400,66 @@ namespace GeomDebugDump
397
400
std::ofstream dump_ofstream (" dump_mesh_debug.txt" , std::ofstream::app);
398
401
dump_ofstream << strs_out.str ().c_str ();
399
402
dump_ofstream.close ();
403
+
404
+ if ( move_offset )
405
+ {
406
+ dump_y_pos_geom += meshset->getAABB ().extent .y * 2.2 ;
407
+ }
400
408
}
401
409
402
- inline void dumpPolyhedronInput ( const carve::input::PolyhedronData& poly_input, const vec3& offset, const carve::geom::vector<4 >& color, bool append )
410
+ inline void dumpPolyhedronInput ( const carve::input::PolyhedronData& poly_input, const vec3& offset, const carve::geom::vector<4 >& color, bool append)
403
411
{
404
412
dumpPolyhedron ( poly_input.create ( carve::input::opts () ), offset, color, append );
405
413
}
406
414
407
- inline void dumpMeshset ( const shared_ptr<carve::mesh::MeshSet<3 > >& meshset, const carve::geom::vector<4 >& color, bool append, bool move_offset = true )
415
+ // inline void dumpMeshset( const shared_ptr<carve::mesh::MeshSet<3> >& meshset, const carve::math::Matrix& transform, const carve::geom::vector<4>& color, bool append, bool move_offset = true )
416
+ // {
417
+ // if( meshset->meshes.size() == 0 )
418
+ // {
419
+ // return;
420
+ // }
421
+ // vec3 offset = carve::geom::VECTOR( 0, dump_y_pos_geom, 0 );
422
+ // dumpMeshSet( meshset.get(), transform, offset, color, append );
423
+
424
+ // if( move_offset )
425
+ // {
426
+ // dump_y_pos_geom += meshset->getAABB().extent.y*2.2;
427
+ // }
428
+ // }
429
+
430
+ inline void dumpMeshset (const shared_ptr<carve::mesh::MeshSet<3 > >& meshset, const carve::geom::vector<4 >& color, bool append, bool move_offset = true )
408
431
{
409
- if ( meshset->meshes .size () == 0 )
410
- {
411
- return ;
432
+ carve::math::Matrix ident = carve::math::Matrix::IDENT ();
433
+ vec3 offset = carve::geom::VECTOR (0 , dump_y_pos_geom, 0 );
434
+ dumpMeshSetWithTransform (meshset.get (), ident, offset, color, append, move_offset);
435
+ }
436
+
437
+ inline void dumpItemData (const shared_ptr<ItemShapeData >& itemData, const carve::math::Matrix& transform, const carve::geom::vector<4 >& color, bool append, bool move_offset = true )
438
+ {
439
+ vec3 offset = carve::geom::VECTOR (0 , dump_y_pos_geom, 0 );
440
+ for ( const shared_ptr<carve::mesh::MeshSet<3 > >& meshset : itemData->m_meshsets ) {
441
+ dumpMeshSetWithTransform (meshset.get (), transform, offset, color, append, move_offset);
412
442
}
413
- vec3 offset = carve::geom::VECTOR ( 0 , dump_y_pos_geom, 0 );
414
- dumpMeshSet ( meshset.get (), offset, color, append );
415
443
416
- if ( move_offset )
417
- {
418
- dump_y_pos_geom += meshset->getAABB ().extent .y *2.2 ;
444
+ for ( auto meshset : itemData->m_meshsets_open ) {
445
+ dumpMeshSetWithTransform (meshset.get (), transform, offset, color, append, move_offset);
446
+ }
447
+ }
448
+
449
+ inline void dumpProductData (const shared_ptr<ProductShapeData >& productData, const carve::geom::vector<4 >& color, bool append, bool move_offset = true , bool includeChildren = false )
450
+ {
451
+ carve::math::Matrix transform = productData->getTransform ();
452
+ for ( const shared_ptr<RepresentationData >& rep : productData->m_vec_representations ) {
453
+
454
+ for ( const shared_ptr<ItemShapeData >& itemData : rep->m_vec_item_data ) {
455
+ dumpItemData (itemData, transform, color, append, move_offset);
456
+ }
457
+ }
458
+
459
+ if ( includeChildren ) {
460
+ for ( const shared_ptr<ProductShapeData >& child : productData->m_vec_children ) {
461
+ dumpProductData (child, color, append, move_offset, includeChildren);
462
+ }
419
463
}
420
464
}
421
465
0 commit comments