Skip to content

Commit 2312188

Browse files
committed
Added extra way to catch glass panels in ifc2x3
1 parent 0905685 commit 2312188

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

inc/helper.cpp

Lines changed: 81 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,12 +3134,12 @@ bool helperFunctions::hasGlassMaterial(const IfcSchema::IfcProduct* ifcProduct)
31343134
IfcSchema::IfcMaterial* ifcMaterial = relMaterial->as<IfcSchema::IfcMaterial>();
31353135
std::string materialName = boost::to_upper_copy(ifcMaterial->Name());
31363136

3137-
if (materialName.find("GLASS") != std::string::npos ||
3137+
if (materialName.find("GLASS") != std::string::npos ||
31383138
materialName.find("GLAZED") != std::string::npos)
31393139
{
31403140
return true;
31413141
}
3142-
//TODO: implement ifc4x3
3142+
//TODO: implement ifc4x3
31433143
#if defined(USE_IFC4x3)
31443144
return false;
31453145
#elif defined(USE_IFC2x3) || defined(USE_IFC4)
@@ -3170,7 +3170,6 @@ bool helperFunctions::hasGlassMaterial(const IfcSchema::IfcProduct* ifcProduct)
31703170

31713171
// find via object material
31723172
if (currentStyleRep != nullptr) {
3173-
31743173
IfcSchema::IfcRepresentationItem::list::ptr representationList = currentStyleRep->Items();
31753174
for (auto propertyIt = representationList->begin(); propertyIt != representationList->end(); ++propertyIt)
31763175
{
@@ -3202,93 +3201,118 @@ bool helperFunctions::hasGlassMaterial(const IfcSchema::IfcProduct* ifcProduct)
32023201
IfcSchema::IfcSurfaceStyle* currentStyle = currentStyleSelect->as<IfcSchema::IfcSurfaceStyle>();
32033202
IfcSchema::IfcSurfaceStyleElementSelect::list::ptr elementSurfList = currentStyle->Styles();
32043203

3204+
bool hasRenderingStyle = false;
32053205
for (auto styleElementIt = elementSurfList->begin(); styleElementIt != elementSurfList->end(); ++styleElementIt)
32063206
{
32073207
IfcSchema::IfcSurfaceStyleElementSelect* currentElemStyle = *styleElementIt;
32083208
if (currentElemStyle->data().type()->name() != "IfcSurfaceStyleRendering") { continue; }
32093209
IfcSchema::IfcSurfaceStyleRendering* currentRenderStyle = currentElemStyle->as< IfcSchema::IfcSurfaceStyleRendering>();
3210-
if (currentRenderStyle->Transparency() > 0.25) { return true; }
3210+
if (currentRenderStyle->Transparency() > 0.2) { return true; }
3211+
hasRenderingStyle = true;
32113212
}
3213+
if (hasRenderingStyle) { return false; }
32123214
}
32133215
}
32143216
}
32153217
}
3218+
}
32163219

3217-
// find via geometry material
3218-
if (currentStyleRep == nullptr) {
3219-
IfcSchema::IfcProductRepresentation* currentProductRep = ifcProduct->Representation();
3220-
IfcSchema::IfcRepresentation::list::ptr currentRepList = currentProductRep->Representations();
3221-
3222-
std::vector< IfcSchema::IfcRepresentation*> representationList;
3223-
for (auto repIt = currentRepList->begin(); repIt != currentRepList->end(); ++repIt)
3224-
{
3225-
IfcSchema::IfcRepresentation* currentRep = *repIt;
3226-
if (!currentRep->RepresentationIdentifier()) { continue; }
3227-
if (currentRep->RepresentationIdentifier().get() != "Body") { continue; }
3228-
if (currentRep->RepresentationType().get() == "MappedRepresentation") // repesentation is used as container
3229-
{
3230-
IfcSchema::IfcRepresentationItem::list::ptr representationSubItemList = currentRep->Items();
3220+
// find via geometry material
3221+
IfcSchema::IfcProductRepresentation* currentProductRep = ifcProduct->Representation();
3222+
IfcSchema::IfcRepresentation::list::ptr currentRepList = currentProductRep->Representations();
3223+
3224+
std::vector< IfcSchema::IfcRepresentation*> representationList;
3225+
for (auto repIt = currentRepList->begin(); repIt != currentRepList->end(); ++repIt)
3226+
{
3227+
IfcSchema::IfcRepresentation* currentRep = *repIt;
3228+
if (!currentRep->RepresentationIdentifier()) { continue; }
3229+
if (currentRep->RepresentationIdentifier().get() != "Body") { continue; }
3230+
if (currentRep->RepresentationType().get() == "MappedRepresentation") // repesentation is used as container
3231+
{
3232+
IfcSchema::IfcRepresentationItem::list::ptr representationSubItemList = currentRep->Items();
32313233

3232-
for (auto represenetationSubIt = representationSubItemList->begin(); represenetationSubIt != representationSubItemList->end(); ++represenetationSubIt)
3233-
{
3234-
IfcSchema::IfcRepresentationItem* subRepresentationItem = *represenetationSubIt;
3235-
if (subRepresentationItem->data().type()->name() != "IfcMappedItem") { continue; }
3236-
IfcSchema::IfcMappedItem* currentMappedItem = subRepresentationItem->as<IfcSchema::IfcMappedItem>();
3237-
IfcSchema::IfcRepresentationMap* currentRepMap = currentMappedItem->MappingSource();
3238-
IfcSchema::IfcRepresentation* subRep = currentRepMap->MappedRepresentation();
3239-
representationList.emplace_back(subRep);
3240-
}
3241-
continue;
3242-
}
3243-
representationList.emplace_back(currentRep);
3244-
}
32453234

32463235

3247-
for (IfcSchema::IfcRepresentation* currentRep : representationList)
3236+
for (auto represenetationSubIt = representationSubItemList->begin(); represenetationSubIt != representationSubItemList->end(); ++represenetationSubIt)
32483237
{
3249-
IfcSchema::IfcRepresentationItem::list::ptr representationSubItemList = currentRep->Items();
3238+
IfcSchema::IfcRepresentationItem* subRepresentationItem = *represenetationSubIt;
3239+
if (subRepresentationItem->data().type()->name() != "IfcMappedItem") { continue; }
3240+
IfcSchema::IfcMappedItem* currentMappedItem = subRepresentationItem->as<IfcSchema::IfcMappedItem>();
3241+
IfcSchema::IfcRepresentationMap* currentRepMap = currentMappedItem->MappingSource();
3242+
IfcSchema::IfcRepresentation* subRep = currentRepMap->MappedRepresentation();
3243+
representationList.emplace_back(subRep);
3244+
}
3245+
continue;
3246+
}
3247+
representationList.emplace_back(currentRep);
3248+
}
32503249

3251-
for (auto RepresentationSubItemIt = representationSubItemList->begin(); RepresentationSubItemIt != representationSubItemList->end(); ++RepresentationSubItemIt)
3252-
{
3253-
IfcSchema::IfcRepresentationItem* RepresentationSubItem = *RepresentationSubItemIt;
3254-
IfcSchema::IfcStyledItem::list::ptr StyledItemList = RepresentationSubItem->StyledByItem();
3250+
for (IfcSchema::IfcRepresentation* currentRep : representationList)
3251+
{
3252+
IfcSchema::IfcRepresentationItem::list::ptr representationSubItemList = currentRep->Items();
32553253

3256-
for (auto styledItemIt = StyledItemList->begin(); styledItemIt != StyledItemList->end(); ++styledItemIt)
3257-
{
3258-
IfcSchema::IfcStyledItem* styledItem = *styledItemIt;
3254+
for (auto RepresentationSubItemIt = representationSubItemList->begin(); RepresentationSubItemIt != representationSubItemList->end(); ++RepresentationSubItemIt)
3255+
{
3256+
IfcSchema::IfcRepresentationItem* RepresentationSubItem = *RepresentationSubItemIt;
3257+
IfcSchema::IfcStyledItem::list::ptr StyledItemList = RepresentationSubItem->StyledByItem();
3258+
3259+
for (auto styledItemIt = StyledItemList->begin(); styledItemIt != StyledItemList->end(); ++styledItemIt)
3260+
{
3261+
3262+
IfcSchema::IfcStyledItem* styledItem = *styledItemIt;
32593263

32603264
#if defined(USE_IFC2x3)
3261-
IfcSchema::IfcPresentationStyleAssignment::list::ptr currenStyleAssList = styledItem->Styles();
3265+
IfcSchema::IfcPresentationStyleAssignment::list::ptr currenStyleAssList = styledItem->Styles();
32623266
#elif defined(USE_IFC4)
3263-
IfcSchema::IfcStyleAssignmentSelect::list::ptr currenStyleAssList = styledItem->Styles();
3267+
IfcSchema::IfcStyleAssignmentSelect::list::ptr currenStyleAssList = styledItem->Styles();
32643268
#endif
3265-
3266-
for (auto currenStyleAssIt = currenStyleAssList->begin(); currenStyleAssIt != currenStyleAssList->end(); ++currenStyleAssIt)
3267-
{
3269+
for (auto currenStyleAssIt = currenStyleAssList->begin(); currenStyleAssIt != currenStyleAssList->end(); ++currenStyleAssIt)
3270+
{
32683271
#if defined(USE_IFC2x3)
3269-
IfcSchema::IfcPresentationStyleAssignment* currentStyleAss = *currenStyleAssIt;
3272+
IfcSchema::IfcPresentationStyleAssignment* currentStyleAss = *currenStyleAssIt;
32703273
#elif defined(USE_IFC4)
3271-
IfcSchema::IfcStyleAssignmentSelect* currentStyleAss = *currenStyleAssIt;
3274+
IfcSchema::IfcStyleAssignmentSelect* currentStyleAss = *currenStyleAssIt;
32723275
#endif
3273-
if (currentStyleAss->data().type()->name() != "IfcSurfaceStyle") { continue; }
3276+
if (currentStyleAss->data().type()->name() == "IfcSurfaceStyle") {
32743277

3275-
IfcSchema::IfcSurfaceStyle* currentStyle = currentStyleAss->as<IfcSchema::IfcSurfaceStyle>();
3276-
IfcSchema::IfcSurfaceStyleElementSelect::list::ptr elementSurfList = currentStyle->Styles();
3278+
IfcSchema::IfcSurfaceStyle* currentStyle = currentStyleAss->as<IfcSchema::IfcSurfaceStyle>();
3279+
IfcSchema::IfcSurfaceStyleElementSelect::list::ptr elementSurfList = currentStyle->Styles();
32773280

3278-
for (auto styleElementIt = elementSurfList->begin(); styleElementIt != elementSurfList->end(); ++styleElementIt)
3279-
{
3280-
IfcSchema::IfcSurfaceStyleElementSelect* currentElemStyle = *styleElementIt;
3281-
if (currentElemStyle->data().type()->name() != "IfcSurfaceStyleRendering") { continue; }
3282-
IfcSchema::IfcSurfaceStyleRendering* currentRenderStyle = currentElemStyle->as< IfcSchema::IfcSurfaceStyleRendering>();
3283-
if (currentRenderStyle->Transparency() > 0.25) { return true; }
3281+
for (auto styleElementIt = elementSurfList->begin(); styleElementIt != elementSurfList->end(); ++styleElementIt)
3282+
{
3283+
IfcSchema::IfcSurfaceStyleElementSelect* currentElemStyle = *styleElementIt;
3284+
if (currentElemStyle->data().type()->name() != "IfcSurfaceStyleRendering") { continue; }
3285+
IfcSchema::IfcSurfaceStyleRendering* currentRenderStyle = currentElemStyle->as< IfcSchema::IfcSurfaceStyleRendering>();
3286+
if (currentRenderStyle->Transparency() > 0.1) { return true; }
3287+
}
3288+
}
3289+
#if defined(USE_IFC2x3)
3290+
if (currentStyleAss->data().type()->name() == "IfcPresentationStyleAssignment") {
3291+
IfcSchema::IfcPresentationStyleSelect::list::ptr presentationStyles = currentStyleAss->Styles();
3292+
for (auto styleElementIt = presentationStyles->begin(); styleElementIt != presentationStyles->end(); ++styleElementIt)
3293+
{
3294+
IfcSchema::IfcPresentationStyleSelect* presentationStyleSelect = *styleElementIt;
3295+
if (presentationStyleSelect->data().type()->name() == "IfcSurfaceStyle") {
3296+
3297+
IfcSchema::IfcSurfaceStyle* currentStyle = presentationStyleSelect->as<IfcSchema::IfcSurfaceStyle>();
3298+
IfcSchema::IfcSurfaceStyleElementSelect::list::ptr elementSurfList = currentStyle->Styles();
3299+
3300+
for (auto styleElementIt = elementSurfList->begin(); styleElementIt != elementSurfList->end(); ++styleElementIt)
3301+
{
3302+
IfcSchema::IfcSurfaceStyleElementSelect* currentElemStyle = *styleElementIt;
3303+
if (currentElemStyle->data().type()->name() != "IfcSurfaceStyleRendering") { continue; }
3304+
IfcSchema::IfcSurfaceStyleRendering* currentRenderStyle = currentElemStyle->as< IfcSchema::IfcSurfaceStyleRendering>();
3305+
if (currentRenderStyle->Transparency() > 0.2) { return true; }
3306+
}
32843307
}
32853308
}
32863309
}
3310+
#endif
32873311
}
32883312
}
32893313
}
3290-
#endif
32913314
}
3315+
#endif
32923316
return false;
32933317
}
32943318

inc/helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define USE_IFC4
1+
#define USE_IFC4x3
22
#define iterationVersion "0.3.0"
33

44
#ifdef USE_IFC2x3

0 commit comments

Comments
 (0)