@@ -18,16 +18,17 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
18
18
#include < ifcpp/model/BasicTypes.h>
19
19
#include < ifcpp/model/BuildingObject.h>
20
20
#include < ifcpp/model/BuildingModel.h>
21
- #include < ifcpp/IFC4/include/IfcObjectDefinition.h>
22
- #include < ifcpp/IFC4/include/IfcSpatialStructureElement.h>
23
- #include < ifcpp/IFC4/include/IfcRelContainedInSpatialStructure.h>
24
- #include < ifcpp/IFC4/include/IfcRelAggregates.h>
25
21
#include < ifcpp/IFC4/include/IfcAxis2Placement.h>
26
22
#include < ifcpp/IFC4/include/IfcAxis2Placement3D.h>
27
- #include < ifcpp/IFC4/include/IfcGeometricRepresentationContext.h>
28
23
#include < ifcpp/IFC4/include/IfcDirection.h>
29
- #include < ifcpp/IFC4/include/IfcProject .h>
24
+ #include < ifcpp/IFC4/include/IfcGeometricRepresentationContext .h>
30
25
#include < ifcpp/IFC4/include/IfcLabel.h>
26
+ #include < ifcpp/IFC4/include/IfcObjectDefinition.h>
27
+ #include < ifcpp/IFC4/include/IfcProject.h>
28
+ #include < ifcpp/IFC4/include/IfcRelAggregates.h>
29
+ #include < ifcpp/IFC4/include/IfcRelContainedInSpatialStructure.h>
30
+ #include < ifcpp/IFC4/include/IfcSpatialStructureElement.h>
31
+ #include < ifcpp/IFC4/include/IfcTypeProduct.h>
31
32
32
33
#include " IncludeGeometryHeaders.h"
33
34
#include " IfcPlusPlusSystem.h"
@@ -196,6 +197,55 @@ void IfcTreeWidget::slotModelLoadingStart()
196
197
slotModelCleared ();
197
198
}
198
199
200
+ bool hasParentInBuildingStructure (shared_ptr<BuildingObject> obj)
201
+ {
202
+ shared_ptr<IfcObjectDefinition> obj_def = dynamic_pointer_cast<IfcObjectDefinition>(obj);
203
+ if (!obj_def)
204
+ {
205
+ return true ;
206
+ }
207
+
208
+ shared_ptr<IfcTypeProduct> typeProduct = dynamic_pointer_cast<IfcTypeProduct>(obj);
209
+ if (typeProduct)
210
+ {
211
+ return true ;
212
+ }
213
+
214
+ if (obj_def->m_Decomposes_inverse .size () > 0 )
215
+ {
216
+ return true ;
217
+ }
218
+
219
+ shared_ptr<IfcSpatialStructureElement> spatial_ele = dynamic_pointer_cast<IfcSpatialStructureElement>(obj_def);
220
+ if (spatial_ele)
221
+ {
222
+ std::vector<weak_ptr<IfcRelContainedInSpatialStructure> >& vec_contained = spatial_ele->m_ContainsElements_inverse ;
223
+ if (vec_contained.size () > 0 )
224
+ {
225
+
226
+ for (auto it_rel_contained = vec_contained.begin (); it_rel_contained!=vec_contained.end (); ++it_rel_contained)
227
+ {
228
+ shared_ptr<IfcRelContainedInSpatialStructure> rel_contained (*it_rel_contained);
229
+
230
+ // std::vector<shared_ptr<IfcProduct> > m_RelatedElements;
231
+ // shared_ptr<IfcSpatialElement> m_RelatingStructure;
232
+
233
+ std::vector<shared_ptr<IfcProduct> >& vec_related_elements = rel_contained->m_RelatedElements ;
234
+
235
+ if (rel_contained->m_RelatingStructure == spatial_ele)
236
+ {
237
+ if (vec_related_elements.size () > 0 )
238
+ {
239
+ return true ;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+
246
+ return false ;
247
+ }
248
+
199
249
QTreeWidgetItem* resolveTreeItems ( shared_ptr<BuildingObject> obj, std::unordered_set<int >& set_visited )
200
250
{
201
251
QTreeWidgetItem* item = nullptr ;
@@ -229,8 +279,7 @@ QTreeWidgetItem* resolveTreeItems( shared_ptr<BuildingObject> obj, std::unordere
229
279
if ( obj_def->m_IsDecomposedBy_inverse .size () > 0 )
230
280
{
231
281
std::vector<weak_ptr<IfcRelAggregates> >& vec_IsDecomposedBy = obj_def->m_IsDecomposedBy_inverse ;
232
- std::vector<weak_ptr<IfcRelAggregates> >::iterator it;
233
- for ( it=vec_IsDecomposedBy.begin (); it!=vec_IsDecomposedBy.end (); ++it )
282
+ for ( auto it=vec_IsDecomposedBy.begin (); it!=vec_IsDecomposedBy.end (); ++it )
234
283
{
235
284
shared_ptr<IfcRelAggregates> rel_agg ( *it );
236
285
std::vector<shared_ptr<IfcObjectDefinition> >& vec = rel_agg->m_RelatedObjects ;
@@ -307,6 +356,12 @@ void IfcTreeWidget::slotModelLoadingDone()
307
356
for ( auto it = map_outside.begin (); it != map_outside.end (); ++it )
308
357
{
309
358
shared_ptr<BuildingObject>& ifc_object = it->second ;
359
+
360
+ if (hasParentInBuildingStructure (ifc_object))
361
+ {
362
+ continue ;
363
+ }
364
+
310
365
QTreeWidgetItem* object_item = resolveTreeItems ( ifc_object, set_visited );
311
366
if ( object_item != NULL )
312
367
{
0 commit comments