@@ -28,6 +28,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
28
28
#include < ifcpp/IFC4/include/IfcRelAggregates.h>
29
29
#include < ifcpp/IFC4/include/IfcRelContainedInSpatialStructure.h>
30
30
#include < ifcpp/IFC4/include/IfcRelDefinesByProperties.h>
31
+ #include < ifcpp/IFC4/include/IfcSite.h>
31
32
#include < ifcpp/IFC4/include/IfcSpace.h>
32
33
#include < ifcpp/IFC4/include/IfcWindow.h>
33
34
@@ -94,7 +95,7 @@ class GeometryConverter : public StatusCallback
94
95
{
95
96
m_product_shape_data.clear ();
96
97
m_map_outside_spatial_structure.clear ();
97
- m_representation_converter->clearCache (false );
98
+ m_representation_converter->clearCache ();
98
99
m_messages.clear ();
99
100
}
100
101
@@ -116,7 +117,7 @@ class GeometryConverter : public StatusCallback
116
117
}
117
118
clearInputCache ();
118
119
m_ifc_model = model;
119
- m_representation_converter->clearCache (false );
120
+ m_representation_converter->clearCache ();
120
121
m_representation_converter->setUnitConverter ( m_ifc_model->getUnitConverter () );
121
122
m_ifc_model->setMessageTarget ( this );
122
123
}
@@ -289,6 +290,66 @@ class GeometryConverter : public StatusCallback
289
290
}
290
291
}
291
292
293
+ void resetIfcSiteLargeCoords (shared_ptr<IfcSite>& ifc_site)
294
+ {
295
+ if (!ifc_site)
296
+ {
297
+ return ;
298
+ }
299
+
300
+ if (!ifc_site->m_ObjectPlacement )
301
+ {
302
+ return ;
303
+ }
304
+
305
+ shared_ptr<IfcLocalPlacement> local_placement = dynamic_pointer_cast<IfcLocalPlacement>(ifc_site->m_ObjectPlacement );
306
+ if (!local_placement)
307
+ {
308
+ return ;
309
+ }
310
+
311
+ if (local_placement->m_RelativePlacement )
312
+ {
313
+ shared_ptr<IfcAxis2Placement3D> axis_placement = dynamic_pointer_cast<IfcAxis2Placement3D>(local_placement->m_RelativePlacement );
314
+ if (axis_placement)
315
+ {
316
+ if (axis_placement->m_Location )
317
+ {
318
+ shared_ptr<IfcCartesianPoint> placement_location = dynamic_pointer_cast<IfcCartesianPoint>(axis_placement->m_Location );
319
+ if (placement_location)
320
+ {
321
+ if (placement_location->m_Coordinates .size () > 2 )
322
+ {
323
+ if (placement_location->m_Coordinates [0 ])
324
+ {
325
+ if (placement_location->m_Coordinates [0 ]->m_value > 1000 )
326
+ {
327
+ placement_location->m_Coordinates [0 ]->m_value = 0 ;
328
+ }
329
+ }
330
+
331
+ if (placement_location->m_Coordinates [1 ])
332
+ {
333
+ if (placement_location->m_Coordinates [1 ]->m_value > 1000 )
334
+ {
335
+ placement_location->m_Coordinates [1 ]->m_value = 0 ;
336
+ }
337
+ }
338
+
339
+ if (placement_location->m_Coordinates [2 ])
340
+ {
341
+ if (placement_location->m_Coordinates [2 ]->m_value > 1000 )
342
+ {
343
+ placement_location->m_Coordinates [2 ]->m_value = 0 ;
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+
292
353
/* \brief method convertGeometry: Creates geometry for Carve from previously loaded BuildingModel model.
293
354
**/
294
355
void convertGeometry ()
@@ -297,7 +358,7 @@ class GeometryConverter : public StatusCallback
297
358
progressValueCallback ( 0 , " geometry" );
298
359
m_product_shape_data.clear ();
299
360
m_map_outside_spatial_structure.clear ();
300
- m_representation_converter->clearCache (false );
361
+ m_representation_converter->clearCache ();
301
362
302
363
if ( !m_ifc_model )
303
364
{
@@ -325,6 +386,12 @@ class GeometryConverter : public StatusCallback
325
386
if (object_def)
326
387
{
327
388
vec_object_definitions.push_back (object_def);
389
+
390
+ shared_ptr<IfcSite> ifc_site = dynamic_pointer_cast<IfcSite>(object_def);
391
+ if (ifc_site)
392
+ {
393
+ resetIfcSiteLargeCoords (ifc_site);
394
+ }
328
395
}
329
396
}
330
397
}
@@ -520,6 +587,23 @@ class GeometryConverter : public StatusCallback
520
587
progressValueCallback ( 1.0 , " geometry" );
521
588
}
522
589
590
+ void addVector3D (const vec3& point, std::vector<float >& target_array)
591
+ {
592
+ bool m_roundCoords = false ;
593
+ if (m_roundCoords)
594
+ {
595
+ target_array.push_back (round (point.x *10000 )*0.0001 );
596
+ target_array.push_back (round (point.y *10000 )*0.0001 );
597
+ target_array.push_back (round (point.z *10000 )*0.0001 );
598
+ }
599
+ else
600
+ {
601
+ target_array.push_back (point.x );
602
+ target_array.push_back (point.y );
603
+ target_array.push_back (point.z );
604
+ }
605
+ }
606
+
523
607
// \brief method convertIfcProduct: Creates geometry objects (meshset with connected vertex-edge-face graph) from an IfcProduct object
524
608
// caution: when using OpenMP, this method runs in parallel threads, so every write access to member variables needs a write lock
525
609
void convertIfcProductShape ( shared_ptr<ProductShapeData>& product_shape )
@@ -535,21 +619,21 @@ class GeometryConverter : public StatusCallback
535
619
{
536
620
return ;
537
621
}
538
-
539
- if ( !ifc_product->m_Representation )
540
- {
541
- return ;
542
- }
543
-
622
+
544
623
double length_factor = 1.0 ;
545
- if ( m_ifc_model )
624
+ if ( m_ifc_model)
546
625
{
547
- if ( m_ifc_model->getUnitConverter () )
626
+ if ( m_ifc_model->getUnitConverter ())
548
627
{
549
628
length_factor = m_ifc_model->getUnitConverter ()->getLengthInMeterFactor ();
550
629
}
551
630
}
552
631
632
+ if ( !ifc_product->m_Representation )
633
+ {
634
+ return ;
635
+ }
636
+
553
637
// evaluate IFC geometry
554
638
shared_ptr<IfcProductRepresentation>& product_representation = ifc_product->m_Representation ;
555
639
std::vector<shared_ptr<IfcRepresentation> >& vec_representations = product_representation->m_Representations ;
@@ -591,12 +675,21 @@ class GeometryConverter : public StatusCallback
591
675
m_representation_converter->getPlacementConverter ()->convertIfcObjectPlacement ( ifc_product->m_ObjectPlacement , product_shape, placement_already_applied, false );
592
676
}
593
677
594
- // handle openings
678
+
595
679
std::vector<shared_ptr<ProductShapeData> > vec_opening_data;
596
680
const shared_ptr<IfcElement> ifc_element = dynamic_pointer_cast<IfcElement>(ifc_product);
597
681
if ( ifc_element )
598
682
{
683
+ // handle openings
599
684
m_representation_converter->subtractOpenings (ifc_element, product_shape);
685
+
686
+ // handle styles on IfcElement level
687
+ std::vector<shared_ptr<AppearanceData> > vec_apperances;
688
+ StylesConverter::convertElementStyle (ifc_element, vec_apperances);
689
+ for (auto appearance_data : vec_apperances)
690
+ {
691
+ product_shape->addAppearance (appearance_data);
692
+ }
600
693
}
601
694
602
695
// Fetch the IFCProduct relationships
@@ -645,6 +738,46 @@ class GeometryConverter : public StatusCallback
645
738
}
646
739
}
647
740
741
+ bool hasRelatedOpenings (shared_ptr<ProductShapeData>& product_shape)
742
+ {
743
+ if (product_shape->m_ifc_object_definition .expired ())
744
+ {
745
+ return false ;
746
+ }
747
+
748
+ shared_ptr<IfcObjectDefinition> ifc_object_def (product_shape->m_ifc_object_definition );
749
+ shared_ptr<IfcProduct> ifc_product = dynamic_pointer_cast<IfcProduct>(ifc_object_def);
750
+ if (!ifc_product)
751
+ {
752
+ return false ;
753
+ }
754
+
755
+ shared_ptr<IfcElement> ifc_element = dynamic_pointer_cast<IfcElement>(ifc_product);
756
+ if (!ifc_element)
757
+ {
758
+ return false ;
759
+ }
760
+
761
+ if (ifc_element->m_HasOpenings_inverse .size () == 0 )
762
+ {
763
+ return false ;
764
+ }
765
+
766
+ // collect aggregated objects
767
+ const std::vector<weak_ptr<IfcRelAggregates> >& vec_decomposed_by = ifc_object_def->m_IsDecomposedBy_inverse ;
768
+ if (vec_decomposed_by.size () > 0 )
769
+ {
770
+ return true ;
771
+ }
772
+
773
+ const std::vector<weak_ptr<IfcRelAggregates> >& vec_decomposes = ifc_object_def->m_Decomposes_inverse ;
774
+ if (vec_decomposes.size () > 0 )
775
+ {
776
+ return true ;
777
+ }
778
+ return false ;
779
+ }
780
+
648
781
void subtractOpeningsInRelatedObjects (shared_ptr<ProductShapeData>& product_shape)
649
782
{
650
783
if ( product_shape->m_ifc_object_definition .expired () )
0 commit comments