Fixes for gcc

This commit is contained in:
Thomas Krijnen
2026-01-06 13:23:48 +01:00
parent ccd91c0ff0
commit 572a5655cf
12 changed files with 86 additions and 104 deletions
@@ -845,7 +845,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
std::string debug_identifier; std::string debug_identifier;
if (debug) { if (debug) {
static my_thread_local size_t operation_counter_ = 0; static thread_local size_t operation_counter_ = 0;
std::stringstream ss; std::stringstream ss;
ss << "bool-" << std::this_thread::get_id() << "-" << (operation_counter_++); ss << "bool-" << std::this_thread::get_id() << "-" << (operation_counter_++);
debug_identifier = ss.str(); debug_identifier = ss.str();
+1 -1
View File
@@ -50,7 +50,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) {
relative_to = inst.PlacementRelTo(); relative_to = inst.PlacementRelTo();
#else #else
if (inst.as<IfcSchema::IfcLocalPlacement>()) { if (inst.as<IfcSchema::IfcLocalPlacement>()) {
relative_to = inst.as<IfcSchema::IfcLocalPlacement>()->PlacementRelTo(); relative_to = inst.as<IfcSchema::IfcLocalPlacement>().PlacementRelTo();
} }
#endif #endif
+17 -19
View File
@@ -325,30 +325,30 @@ const express::Base mapping::get_single_material_association(const express::Base
} }
} }
if (associated_materials.size() == 1) { if (associated_materials.size() == 1) {
IfcSchema::IfcMaterialSelect associated_material; express::Base associated_material;
try { try {
associated_material = associated_materials.front().RelatingMaterial(); associated_material = associated_materials.front().RelatingMaterial().concrete();
} catch(IfcParse::IfcException& e) { } catch(IfcParse::IfcException& e) {
Logger::Error(e.what()); Logger::Error(e.what());
} }
if (associated_material) { if (associated_material) {
// @todo make sure that chaining as() works in nullptrs single_material = associated_material.as<IfcSchema::IfcMaterial>();
single_material = associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterial>();
// NB: Single-layer layersets are also considered, regardless of --enable-layerset-slicing, this // NB: Single-layer layersets are also considered, regardless of --enable-layerset-slicing, this
// in accordance with other viewers. // in accordance with other viewers.
if (!single_material) { if (!single_material) {
if (associated_material.as<IfcSchema::IfcMaterialUsageDefinition>().as<IfcSchema::IfcMaterialLayerSetUsage>() || associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialLayerSet>()) { if (associated_material.as<IfcSchema::IfcMaterialLayerSetUsage>() || associated_material.as<IfcSchema::IfcMaterialLayerSet>()) {
IfcSchema::IfcMaterialLayerSet layerset; IfcSchema::IfcMaterialLayerSet layerset;
if (auto m = associated_material.as<IfcSchema::IfcMaterialUsageDefinition>().as<IfcSchema::IfcMaterialLayerSetUsage>()) { if (auto m = associated_material.as<IfcSchema::IfcMaterialLayerSetUsage>()) {
if (m.get("ForLayerSet").isNull()) { if (m.get("ForLayerSet").isNull()) {
Logger::Warning("Missing ForLayerSet for:", m); Logger::Warning("Missing ForLayerSet for:", m);
return express::Base{}; return express::Base{};
} }
layerset = m.ForLayerSet(); layerset = m.ForLayerSet();
} else { } else {
layerset = associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialLayerSet>(); layerset = associated_material.as<IfcSchema::IfcMaterialLayerSet>();
} }
if (settings_.get<settings::LayersetFirst>().value ? layerset.MaterialLayers().size() >= 1 : layerset.MaterialLayers().size() == 1) { if (settings_.get<settings::LayersetFirst>().value ? layerset.MaterialLayers().size() >= 1 : layerset.MaterialLayers().size() == 1) {
IfcSchema::IfcMaterialLayer layer = layerset.MaterialLayers().front(); IfcSchema::IfcMaterialLayer layer = layerset.MaterialLayers().front();
@@ -359,16 +359,16 @@ const express::Base mapping::get_single_material_association(const express::Base
} }
#ifdef SCHEMA_HAS_IfcMaterialProfileSet #ifdef SCHEMA_HAS_IfcMaterialProfileSet
if (associated_material.as<IfcSchema::IfcMaterialUsageDefinition>().as<IfcSchema::IfcMaterialProfileSetUsage>() || associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialProfileSet>()) { if (associated_material.as<IfcSchema::IfcMaterialProfileSetUsage>() || associated_material.as<IfcSchema::IfcMaterialProfileSet>()) {
IfcSchema::IfcMaterialProfileSet profileset; IfcSchema::IfcMaterialProfileSet profileset;
if (auto m = associated_material.as<IfcSchema::IfcMaterialUsageDefinition>().as<IfcSchema::IfcMaterialProfileSetUsage>()) { if (auto m = associated_material.as<IfcSchema::IfcMaterialProfileSetUsage>()) {
if (m.get("ForProfileSet").isNull()) { if (m.get("ForProfileSet").isNull()) {
Logger::Warning("Missing ForProfileSet for:", m); Logger::Warning("Missing ForProfileSet for:", m);
return express::Base{}; return express::Base{};
} }
profileset = m.ForProfileSet(); profileset = m.ForProfileSet();
} else { } else {
profileset = associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialProfileSet>(); profileset = associated_material.as<IfcSchema::IfcMaterialProfileSet>();
} }
if (settings_.get<settings::LayersetFirst>().value ? profileset.MaterialProfiles().size() >= 1 : profileset.MaterialProfiles().size() == 1) { if (settings_.get<settings::LayersetFirst>().value ? profileset.MaterialProfiles().size() >= 1 : profileset.MaterialProfiles().size() == 1) {
IfcSchema::IfcMaterialProfile profile = profileset.MaterialProfiles().front(); IfcSchema::IfcMaterialProfile profile = profileset.MaterialProfiles().front();
@@ -380,8 +380,8 @@ const express::Base mapping::get_single_material_association(const express::Base
#endif #endif
#ifdef SCHEMA_HAS_IfcMaterialConstituentSet #ifdef SCHEMA_HAS_IfcMaterialConstituentSet
if (associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialConstituentSet>() && associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialConstituentSet>().MaterialConstituents()) { if (associated_material.as<IfcSchema::IfcMaterialConstituentSet>() && associated_material.as<IfcSchema::IfcMaterialConstituentSet>().MaterialConstituents()) {
IfcSchema::IfcMaterialConstituentSet constituentset = associated_material.as<IfcSchema::IfcMaterialDefinition>().as<IfcSchema::IfcMaterialConstituentSet>(); IfcSchema::IfcMaterialConstituentSet constituentset = associated_material.as<IfcSchema::IfcMaterialConstituentSet>();
if (settings_.get<settings::LayersetFirst>().value ? constituentset.MaterialConstituents().value().size() >= 1 : constituentset.MaterialConstituents().value().size() == 1) { if (settings_.get<settings::LayersetFirst>().value ? constituentset.MaterialConstituents().value().size() >= 1 : constituentset.MaterialConstituents().value().size() == 1) {
IfcSchema::IfcMaterialConstituent constituent = constituentset.MaterialConstituents().value().front(); IfcSchema::IfcMaterialConstituent constituent = constituentset.MaterialConstituents().value().front();
if (auto m_ = constituent.Material()) { if (auto m_ = constituent.Material()) {
@@ -469,12 +469,10 @@ namespace {
// Only in case of 2x3 or old style IfcPresentationStyleAssignment // Only in case of 2x3 or old style IfcPresentationStyleAssignment
auto styles = style_assignment->Styles(); auto styles = style_assignment->Styles();
#elif defined(SCHEMA_HAS_IfcPresentationStyleAssignment) #elif defined(SCHEMA_HAS_IfcPresentationStyleAssignment)
std::vector<IfcSchema::IfcPresentationStyleAssignment> style_assignments = si->Styles(); std::vector<IfcSchema::IfcPresentationStyleAssignment> style_assignments = si.Styles();
for (IfcSchema::IfcPresentationStyleAssignment::list::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) { for (auto& style_assignment : style_assignments) {
IfcSchema::IfcPresentationStyleAssignment* style_assignment = *kt;
// Only in case of 2x3 or old style IfcPresentationStyleAssignment // Only in case of 2x3 or old style IfcPresentationStyleAssignment
auto styles = style_assignment->Styles(); auto styles = style_assignment.Styles();
#else #else
auto styles = si.Styles(); auto styles = si.Styles();
#endif #endif
@@ -735,7 +733,7 @@ taxonomy::ptr mapping::map(const express::Base& inst) {
namespace { namespace {
express::Base get_RelatingObject(IfcSchema::IfcRelDecomposes& decompose) { express::Base get_RelatingObject(IfcSchema::IfcRelDecomposes& decompose) {
#ifdef SCHEMA_IfcRelDecomposes_HAS_RelatingObject #ifdef SCHEMA_IfcRelDecomposes_HAS_RelatingObject
return decompose->RelatingObject(); return decompose.RelatingObject();
#else #else
IfcSchema::IfcRelAggregates aggr = decompose.as<IfcSchema::IfcRelAggregates>(); IfcSchema::IfcRelAggregates aggr = decompose.as<IfcSchema::IfcRelAggregates>();
if (aggr) { if (aggr) {
@@ -990,7 +988,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat
for (auto it = associations.begin(); it != associations.end(); ++it) { for (auto it = associations.begin(); it != associations.end(); ++it) {
IfcSchema::IfcRelAssociatesMaterial associates_material = (*it).as<IfcSchema::IfcRelAssociatesMaterial>(); IfcSchema::IfcRelAssociatesMaterial associates_material = (*it).as<IfcSchema::IfcRelAssociatesMaterial>();
if (associates_material) { if (associates_material) {
usage = associates_material.RelatingMaterial().as<IfcSchema::IfcMaterialUsageDefinition>().as<IfcSchema::IfcMaterialLayerSetUsage>(); usage = associates_material.RelatingMaterial().as<IfcSchema::IfcMaterialLayerSetUsage>();
break; break;
} }
} }
+1 -11
View File
@@ -433,17 +433,7 @@ namespace impl {
template <typename T> template <typename T>
T IfcParse::impl::in_memory_file_storage::create(int id) { T IfcParse::impl::in_memory_file_storage::create(int id) {
express::Base inst; return create(&T::declaration(), id).template as<T>();
// T::Class() yadaya, id or freshid() I though I changed this elsewhere already
if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::entity>) {
inst = new T(in_memory_attribute_storage(T::Class().attribute_count()));
} else if constexpr (std::is_same_v<std::decay_t<std::invoke_result_t<typename T::Class>>, IfcParse::type_declaration>) {
inst = new T(in_memory_attribute_storage(1));
} else {
static_assert(dependent_false_v<T>, "Requires and entity or type declaration");
}
inst->file_ = file;
return file->addEntity(inst)->as<T>();
} }
#ifdef IFOPSH_WITH_ROCKSDB #ifdef IFOPSH_WITH_ROCKSDB
+56 -49
View File
@@ -66,7 +66,7 @@ typename Schema::IfcLocalPlacement IfcHierarchyHelper<Schema>::addLocalPlacement
double xx, double xx,
double xy, double xy,
double xz) { double xz) {
auto local_placement = create<Schema::IfcLocalPlacement>(); auto local_placement = create<typename Schema::IfcLocalPlacement>();
if (parent) { if (parent) {
local_placement.setPlacementRelTo(parent); local_placement.setPlacementRelTo(parent);
} }
@@ -76,24 +76,31 @@ typename Schema::IfcLocalPlacement IfcHierarchyHelper<Schema>::addLocalPlacement
template <typename Schema> template <typename Schema>
typename Schema::IfcOwnerHistory IfcHierarchyHelper<Schema>::addOwnerHistory() { typename Schema::IfcOwnerHistory IfcHierarchyHelper<Schema>::addOwnerHistory() {
typename Schema::IfcPerson person = create<Schema::IfcPerson>(); typename Schema::IfcPerson person = create<typename Schema::IfcPerson>();
person.setIdentification(""); #ifdef HAS_SCHEMA_2x3
if constexpr (std::is_same_v<Schema, Ifc2x3>) {
person.setId("");
} else
#endif
{
person.setIdentification("");
}
auto organization = create<Schema::IfcOrganization>(); auto organization = create<typename Schema::IfcOrganization>();
organization.setName("IfcOpenShell"); organization.setName("IfcOpenShell");
auto person_and_org = create<Schema::IfcPersonAndOrganization>(); auto person_and_org = create<typename Schema::IfcPersonAndOrganization>();
person_and_org.setThePerson(person); person_and_org.setThePerson(person);
person_and_org.setTheOrganization(organization); person_and_org.setTheOrganization(organization);
auto application = create<Schema::IfcApplication>(); auto application = create<typename Schema::IfcApplication>();
application.setApplicationDeveloper(organization); application.setApplicationDeveloper(organization);
application.setVersion(IFCOPENSHELL_VERSION); application.setVersion(IFCOPENSHELL_VERSION);
application.setApplicationFullName("IfcOpenShell"); application.setApplicationFullName("IfcOpenShell");
application.setApplicationIdentifier("IfcOpenShell"); application.setApplicationIdentifier("IfcOpenShell");
int timestamp = (int)time(0); int timestamp = (int)time(0);
auto owner_hist = create<Schema::IfcOwnerHistory>(); auto owner_hist = create<typename Schema::IfcOwnerHistory>();
owner_hist.setOwningUser(person_and_org); owner_hist.setOwningUser(person_and_org);
owner_hist.setOwningApplication(application); owner_hist.setOwningApplication(application);
owner_hist.setChangeAction(Schema::IfcChangeActionEnum::IfcChangeAction_ADDED); owner_hist.setChangeAction(Schema::IfcChangeActionEnum::IfcChangeAction_ADDED);
@@ -109,7 +116,7 @@ template <typename Schema>
typename Schema::IfcProject IfcHierarchyHelper<Schema>::addProject(typename Schema::IfcOwnerHistory owner_hist) { typename Schema::IfcProject IfcHierarchyHelper<Schema>::addProject(typename Schema::IfcOwnerHistory owner_hist) {
std::vector<typename Schema::IfcRepresentationContext> rep_contexts; std::vector<typename Schema::IfcRepresentationContext> rep_contexts;
auto dimexp = create<Schema::IfcDimensionalExponents>(); auto dimexp = create<typename Schema::IfcDimensionalExponents>();
dimexp.setLengthExponent(0); dimexp.setLengthExponent(0);
dimexp.setMassExponent(0); dimexp.setMassExponent(0);
dimexp.setTimeExponent(0); dimexp.setTimeExponent(0);
@@ -118,32 +125,32 @@ typename Schema::IfcProject IfcHierarchyHelper<Schema>::addProject(typename Sche
dimexp.setAmountOfSubstanceExponent(0); dimexp.setAmountOfSubstanceExponent(0);
dimexp.setLuminousIntensityExponent(0); dimexp.setLuminousIntensityExponent(0);
auto unit1 = create<Schema::IfcSIUnit>(); auto unit1 = create<typename Schema::IfcSIUnit>();
unit1.setUnitType(Schema::IfcUnitEnum::IfcUnit_LENGTHUNIT); unit1.setUnitType(Schema::IfcUnitEnum::IfcUnit_LENGTHUNIT);
unit1.setPrefix(Schema::IfcSIPrefix::IfcSIPrefix_MILLI); unit1.setPrefix(Schema::IfcSIPrefix::IfcSIPrefix_MILLI);
unit1.setName(Schema::IfcSIUnitName::IfcSIUnitName_METRE); unit1.setName(Schema::IfcSIUnitName::IfcSIUnitName_METRE);
auto unit2a = create<Schema::IfcSIUnit>(); auto unit2a = create<typename Schema::IfcSIUnit>();
unit2a.setUnitType(Schema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT); unit2a.setUnitType(Schema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT);
unit2a.setName(Schema::IfcSIUnitName::IfcSIUnitName_RADIAN); unit2a.setName(Schema::IfcSIUnitName::IfcSIUnitName_RADIAN);
auto unit2b = create<Schema::IfcMeasureWithUnit>(); auto unit2b = create<typename Schema::IfcMeasureWithUnit>();
auto measure = create<Schema::IfcPlaneAngleMeasure>(); auto measure = create<typename Schema::IfcPlaneAngleMeasure>();
measure.set_attribute_value(0, 0.01745329251); measure.set_attribute_value(0, 0.01745329251);
unit2b.setValueComponent(measure); unit2b.setValueComponent(measure);
unit2b.setUnitComponent(unit2a); unit2b.setUnitComponent(unit2a);
auto unit2 = create<Schema::IfcConversionBasedUnit>(); auto unit2 = create<typename Schema::IfcConversionBasedUnit>();
unit2.setDimensions(dimexp); unit2.setDimensions(dimexp);
unit2.setUnitType(Schema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT); unit2.setUnitType(Schema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT);
unit2.setName("Degrees"); unit2.setName("Degrees");
unit2.setConversionFactor(unit2b); unit2.setConversionFactor(unit2b);
std::vector<typename Schema::IfcUnit> units = {unit1, unit2}; std::vector<typename Schema::IfcUnit> units = {unit1, unit2};
auto unit_assignment = create<Schema::IfcUnitAssignment>(); auto unit_assignment = create<typename Schema::IfcUnitAssignment>();
unit_assignment.setUnits(units); unit_assignment.setUnits(units);
auto project = create<Schema::IfcProject>(); auto project = create<typename Schema::IfcProject>();
project.setGlobalId(IfcParse::IfcGlobalId()); project.setGlobalId(IfcParse::IfcGlobalId());
project.setOwnerHistory(owner_hist ? owner_hist : addOwnerHistory()); project.setOwnerHistory(owner_hist ? owner_hist : addOwnerHistory());
project.setRepresentationContexts(rep_contexts); project.setRepresentationContexts(rep_contexts);
@@ -156,7 +163,7 @@ template <typename Schema>
void IfcHierarchyHelper<Schema>::relatePlacements(typename Schema::IfcProduct parent, typename Schema::IfcProduct product) { void IfcHierarchyHelper<Schema>::relatePlacements(typename Schema::IfcProduct parent, typename Schema::IfcProduct product) {
typename Schema::IfcObjectPlacement place = product.ObjectPlacement(); typename Schema::IfcObjectPlacement place = product.ObjectPlacement();
if (place) { if (place) {
if (auto local_place = place.as<typename Schema::IfcLocalPlacement>()) { if (auto local_place = place.template as<typename Schema::IfcLocalPlacement>()) {
if (parent.ObjectPlacement()) { if (parent.ObjectPlacement()) {
if (local_place != parent.ObjectPlacement()) { if (local_place != parent.ObjectPlacement()) {
local_place.setPlacementRelTo(parent.ObjectPlacement()); local_place.setPlacementRelTo(parent.ObjectPlacement());
@@ -183,7 +190,7 @@ typename Schema::IfcSite IfcHierarchyHelper<Schema>::addSite(typename Schema::If
proj = addProject(owner_hist); proj = addProject(owner_hist);
} }
auto site = create<Schema::IfcSite>(); auto site = create<typename Schema::IfcSite>();
site.setGlobalId(IfcParse::IfcGlobalId()); site.setGlobalId(IfcParse::IfcGlobalId());
site.setOwnerHistory(owner_hist); site.setOwnerHistory(owner_hist);
site.setObjectPlacement(addLocalPlacement()); site.setObjectPlacement(addLocalPlacement());
@@ -208,7 +215,7 @@ typename Schema::IfcBuilding IfcHierarchyHelper<Schema>::addBuilding(typename Sc
site = addSite(typename Schema::IfcProject{}, owner_hist); site = addSite(typename Schema::IfcProject{}, owner_hist);
} }
auto building = create<Schema::IfcBuilding>(); auto building = create<typename Schema::IfcBuilding>();
building.setGlobalId(IfcParse::IfcGlobalId()); building.setGlobalId(IfcParse::IfcGlobalId());
building.setOwnerHistory(owner_hist); building.setOwnerHistory(owner_hist);
building.setObjectPlacement(addLocalPlacement()); building.setObjectPlacement(addLocalPlacement());
@@ -236,7 +243,7 @@ typename Schema::IfcBuildingStorey IfcHierarchyHelper<Schema>::addBuildingStorey
building = addBuilding(typename Schema::IfcSite{}, owner_hist); building = addBuilding(typename Schema::IfcSite{}, owner_hist);
} }
auto storey = create<Schema::IfcBuildingStorey>(); auto storey = create<typename Schema::IfcBuildingStorey>();
storey.setGlobalId(IfcParse::IfcGlobalId()); storey.setGlobalId(IfcParse::IfcGlobalId());
storey.setOwnerHistory(owner_hist); storey.setOwnerHistory(owner_hist);
storey.setObjectPlacement(addLocalPlacement()); storey.setObjectPlacement(addLocalPlacement());
@@ -292,14 +299,14 @@ void IfcHierarchyHelper<Schema>::addExtrudedPolyline(typename Schema::IfcShapeRe
cartesian_points.push_back(cartesian_points.front()); cartesian_points.push_back(cartesian_points.front());
} }
auto line = create<Schema::IfcPolyline>(); auto line = create<typename Schema::IfcPolyline>();
line.setPoints(cartesian_points); line.setPoints(cartesian_points);
auto profile = create<Schema::IfcArbitraryClosedProfileDef>(); auto profile = create<typename Schema::IfcArbitraryClosedProfileDef>();
profile.setProfileType(Schema::IfcProfileTypeEnum::IfcProfileType_AREA); profile.setProfileType(Schema::IfcProfileTypeEnum::IfcProfileType_AREA);
profile.setOuterCurve(line); profile.setOuterCurve(line);
auto solid = create<Schema::IfcExtrudedAreaSolid>(); auto solid = create<typename Schema::IfcExtrudedAreaSolid>();
solid.setSweptArea(profile); solid.setSweptArea(profile);
solid.setPosition(place2 ? place2 : addPlacement3d()); solid.setPosition(place2 ? place2 : addPlacement3d());
solid.setExtrudedDirection(dir ? dir : addTriplet<typename Schema::IfcDirection>(0, 0, 1)); solid.setExtrudedDirection(dir ? dir : addTriplet<typename Schema::IfcDirection>(0, 0, 1));
@@ -315,13 +322,13 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addExtrud
typename Schema::IfcAxis2Placement3D place2, typename Schema::IfcAxis2Placement3D place2,
typename Schema::IfcDirection dir, typename Schema::IfcDirection dir,
typename Schema::IfcRepresentationContext context) { typename Schema::IfcRepresentationContext context) {
auto rep = create<Schema::IfcShapeRepresentation>(); auto rep = create<typename Schema::IfcShapeRepresentation>();
rep.setContextOfItems(context ? context : getRepresentationContext("Model")); rep.setContextOfItems(context ? context : getRepresentationContext("Model"));
rep.setRepresentationIdentifier(std::string("Body")); rep.setRepresentationIdentifier(std::string("Body"));
rep.setRepresentationType(std::string("SweptSolid")); rep.setRepresentationType(std::string("SweptSolid"));
rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{}); rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{});
auto shape = create<Schema::IfcProductDefinitionShape>(); auto shape = create<typename Schema::IfcProductDefinitionShape>();
shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{rep}); shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{rep});
addExtrudedPolyline(rep, points, h, place, place2, dir, context); addExtrudedPolyline(rep, points, h, place, place2, dir, context);
@@ -355,9 +362,9 @@ void IfcHierarchyHelper<Schema>::addAxis(
{ {
auto p1 = addDoublet<typename Schema::IfcCartesianPoint>(-l / 2., 0.); auto p1 = addDoublet<typename Schema::IfcCartesianPoint>(-l / 2., 0.);
auto p2 = addDoublet<typename Schema::IfcCartesianPoint>(+l / 2., 0.); auto p2 = addDoublet<typename Schema::IfcCartesianPoint>(+l / 2., 0.);
std::vector<Schema::IfcCartesianPoint> pts{p1, p2}; std::vector<typename Schema::IfcCartesianPoint> pts{p1, p2};
auto poly = create<Schema::IfcPolyline>(); auto poly = create<typename Schema::IfcPolyline>();
poly.setPoints(pts); poly.setPoints(pts);
auto items = rep.Items(); auto items = rep.Items();
@@ -373,13 +380,13 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addBox(do
typename Schema::IfcAxis2Placement3D place2, typename Schema::IfcAxis2Placement3D place2,
typename Schema::IfcDirection dir, typename Schema::IfcDirection dir,
typename Schema::IfcRepresentationContext context) { typename Schema::IfcRepresentationContext context) {
typename Schema::IfcShapeRepresentation rep = create<Schema::IfcShapeRepresentation>(); typename Schema::IfcShapeRepresentation rep = create<typename Schema::IfcShapeRepresentation>();
rep.setContextOfItems(context ? context : getRepresentationContext("Model")); rep.setContextOfItems(context ? context : getRepresentationContext("Model"));
rep.setRepresentationIdentifier(std::string("Body")); rep.setRepresentationIdentifier(std::string("Body"));
rep.setRepresentationType(std::string("SweptSolid")); rep.setRepresentationType(std::string("SweptSolid"));
rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{}); rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{});
auto shape = create<Schema::IfcProductDefinitionShape>(); auto shape = create<typename Schema::IfcProductDefinitionShape>();
shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{rep}); shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{rep});
addBox(rep, w, d, h, place, place2, dir, context); addBox(rep, w, d, h, place, place2, dir, context);
@@ -389,19 +396,19 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addBox(do
template <typename Schema> template <typename Schema>
typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addAxisBox( typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addAxisBox(
double w, double d, double h, typename Schema::IfcRepresentationContext context) { double w, double d, double h, typename Schema::IfcRepresentationContext context) {
auto body_rep = create<Schema::IfcShapeRepresentation>(); auto body_rep = create<typename Schema::IfcShapeRepresentation>();
body_rep.setContextOfItems(context ? context : getRepresentationContext("Model")); body_rep.setContextOfItems(context ? context : getRepresentationContext("Model"));
body_rep.setRepresentationIdentifier(std::string("Body")); body_rep.setRepresentationIdentifier(std::string("Body"));
body_rep.setRepresentationType(std::string("SweptSolid")); body_rep.setRepresentationType(std::string("SweptSolid"));
body_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{}); body_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{});
auto axis_rep = create<Schema::IfcShapeRepresentation>(); auto axis_rep = create<typename Schema::IfcShapeRepresentation>();
axis_rep.setContextOfItems(context ? context : getRepresentationContext("Plan")); axis_rep.setContextOfItems(context ? context : getRepresentationContext("Plan"));
axis_rep.setRepresentationIdentifier(std::string("Axis")); axis_rep.setRepresentationIdentifier(std::string("Axis"));
axis_rep.setRepresentationType(std::string("Curve2D")); axis_rep.setRepresentationType(std::string("Curve2D"));
axis_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{}); axis_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{});
auto shape = create<Schema::IfcProductDefinitionShape>(); auto shape = create<typename Schema::IfcProductDefinitionShape>();
shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{axis_rep, body_rep}); shape.setRepresentations(std::vector<typename Schema::IfcRepresentation>{axis_rep, body_rep});
addBox(body_rep, w, d, h, typename Schema::IfcAxis2Placement2D{}, typename Schema::IfcAxis2Placement3D{}, typename Schema::IfcDirection{}, context); addBox(body_rep, w, d, h, typename Schema::IfcAxis2Placement2D{}, typename Schema::IfcAxis2Placement3D{}, typename Schema::IfcDirection{}, context);
@@ -428,9 +435,9 @@ void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresen
return; return;
} }
auto plane = create<Schema::IfcPlane>(); auto plane = create<typename Schema::IfcPlane>();
plane.setPosition(place); plane.setPosition(place);
auto half_space = create<Schema::IfcHalfSpaceSolid>(); auto half_space = create<typename Schema::IfcHalfSpaceSolid>();
half_space.setBaseSurface(plane); half_space.setBaseSurface(plane);
half_space.setAgreementFlag(agree); half_space.setAgreementFlag(agree);
@@ -438,8 +445,8 @@ void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresen
auto items = rep.Items(); auto items = rep.Items();
decltype(items) new_items; decltype(items) new_items;
for (auto& item : items) { for (auto& item : items) {
if (auto bop = item.as<typename Schema::IfcBooleanOperand>()) { if (auto bop = item.template as<typename Schema::IfcBooleanOperand>()) {
auto clip = create<Schema::IfcBooleanClippingResult>(); auto clip = create<typename Schema::IfcBooleanClippingResult>();
clip.setOperator(Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE); clip.setOperator(Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE);
clip.setFirstOperand(bop); clip.setFirstOperand(bop);
clip.setSecondOperand(half_space); clip.setSecondOperand(half_space);
@@ -451,19 +458,19 @@ void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresen
template <typename Schema> template <typename Schema>
typename Schema::IfcSurfaceStyle getSurfaceStyle(IfcHierarchyHelper<Schema>& file, double r, double g, double b, double a = 1.0) { typename Schema::IfcSurfaceStyle getSurfaceStyle(IfcHierarchyHelper<Schema>& file, double r, double g, double b, double a = 1.0) {
auto colour = file.create<typename Schema::IfcColourRgb>(); auto colour = file.template create<typename Schema::IfcColourRgb>();
colour.setRed(r); colour.setRed(r);
colour.setGreen(g); colour.setGreen(g);
colour.setBlue(b); colour.setBlue(b);
auto rendering = file.create<typename Schema::IfcSurfaceStyleRendering>(); auto rendering = file.template create<typename Schema::IfcSurfaceStyleRendering>();
rendering.setSurfaceColour(colour); rendering.setSurfaceColour(colour);
if (a != 1.0) { if (a != 1.0) {
rendering.setTransparency(1.0 - a); rendering.setTransparency(1.0 - a);
} }
rendering.setReflectanceMethod(Schema::IfcReflectanceMethodEnum::IfcReflectanceMethod_FLAT); rendering.setReflectanceMethod(Schema::IfcReflectanceMethodEnum::IfcReflectanceMethod_FLAT);
auto surface_style = file.create<typename Schema::IfcSurfaceStyle>(); auto surface_style = file.template create<typename Schema::IfcSurfaceStyle>();
surface_style.setSide(Schema::IfcSurfaceSide::IfcSurfaceSide_BOTH); surface_style.setSide(Schema::IfcSurfaceSide::IfcSurfaceSide_BOTH);
surface_style.setStyles(std::vector<typename Schema::IfcSurfaceStyleElementSelect>{rendering}); surface_style.setStyles(std::vector<typename Schema::IfcSurfaceStyleElementSelect>{rendering});
@@ -473,7 +480,7 @@ typename Schema::IfcSurfaceStyle getSurfaceStyle(IfcHierarchyHelper<Schema>& fil
template <typename Schema> template <typename Schema>
typename Schema::IfcPresentationStyleAssignment addStyleAssignment_2x3(IfcHierarchyHelper<Schema>& file, double r, double g, double b, double a = 1.0) { typename Schema::IfcPresentationStyleAssignment addStyleAssignment_2x3(IfcHierarchyHelper<Schema>& file, double r, double g, double b, double a = 1.0) {
auto surface_style = getSurfaceStyle<Schema>(file, r, g, b, a); auto surface_style = getSurfaceStyle<Schema>(file, r, g, b, a);
auto style_assignment = file.create<typename Schema::IfcPresentationStyleAssignment>(); auto style_assignment = file.template create<typename Schema::IfcPresentationStyleAssignment>();
style_assignment.setStyles(std::vector<typename Schema::IfcPresentationStyleSelect>{surface_style}); style_assignment.setStyles(std::vector<typename Schema::IfcPresentationStyleSelect>{surface_style});
return style_assignment; return style_assignment;
} }
@@ -513,7 +520,7 @@ typename Schema::IfcPresentationStyle setSurfaceColour_4x3(IfcHierarchyHelper<Sc
template <typename Schema> template <typename Schema>
void setSurfaceColour_2x3(IfcHierarchyHelper<Schema>& file, typename Schema::IfcProductRepresentation shape, typename Schema::IfcPresentationStyleAssignment style_assignment) { void setSurfaceColour_2x3(IfcHierarchyHelper<Schema>& file, typename Schema::IfcProductRepresentation shape, typename Schema::IfcPresentationStyleAssignment style_assignment) {
auto reps = shape->Representations(); auto reps = shape.Representations();
for (auto& rep : reps) { for (auto& rep : reps) {
setSurfaceColour_2x3(file, rep, style_assignment); setSurfaceColour_2x3(file, rep, style_assignment);
} }
@@ -927,7 +934,7 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addMapped
if (maps.size() == 1) { if (maps.size() == 1) {
map = maps.front(); map = maps.front();
} else { } else {
map = create<Schema::IfcRepresentationMap>(); map = create<typename Schema::IfcRepresentationMap>();
map.setMappingOrigin(addPlacement3d()); map.setMappingOrigin(addPlacement3d());
map.setMappedRepresentation(rep); map.setMappedRepresentation(rep);
} }
@@ -938,14 +945,14 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addMapped
} }
if (!transform) { if (!transform) {
transform = create<Schema::IfcCartesianTransformationOperator3D>(); transform = create<typename Schema::IfcCartesianTransformationOperator3D>();
transform.setLocalOrigin(addTriplet<typename Schema::IfcCartesianPoint>(0, 0, 0)); transform.setLocalOrigin(addTriplet<typename Schema::IfcCartesianPoint>(0, 0, 0));
} }
auto item = create<Schema::IfcMappedItem>(); auto item = create<typename Schema::IfcMappedItem>();
item.setMappingSource(map); item.setMappingSource(map);
item.setMappingTarget(transform); item.setMappingTarget(transform);
auto new_rep = create<Schema::IfcShapeRepresentation>(); auto new_rep = create<typename Schema::IfcShapeRepresentation>();
new_rep.setContextOfItems(rep.ContextOfItems()); new_rep.setContextOfItems(rep.ContextOfItems());
new_rep.setRepresentationType(std::string("MappedRepresentation")); new_rep.setRepresentationType(std::string("MappedRepresentation"));
new_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{item}); new_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{item});
@@ -957,7 +964,7 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addMapped
representations.push_back(new_rep); representations.push_back(new_rep);
if (!def) { if (!def) {
def = create<Schema::IfcProductDefinitionShape>(); def = create<typename Schema::IfcProductDefinitionShape>();
def.setRepresentations(representations); def.setRepresentations(representations);
} else { } else {
def.setRepresentations(representations); def.setRepresentations(representations);
@@ -980,11 +987,11 @@ typename Schema::IfcProductDefinitionShape IfcHierarchyHelper<Schema>::addMapped
template <typename Schema> template <typename Schema>
typename Schema::IfcShapeRepresentation IfcHierarchyHelper<Schema>::addEmptyRepresentation(const std::string& repid, const std::string& reptype) { typename Schema::IfcShapeRepresentation IfcHierarchyHelper<Schema>::addEmptyRepresentation(const std::string& repid, const std::string& reptype) {
auto shape_rep = create<Schema::IfcShapeRepresentation>(); auto shape_rep = create<typename Schema::IfcShapeRepresentation>();
shape_rep.setContextOfItems(getRepresentationContext(reptype == "Curve2D" ? "Plan" : "Model")); shape_rep.setContextOfItems(getRepresentationContext(reptype == "Curve2D" ? "Plan" : "Model"));
shape_rep.setRepresentationIdentifier(repid); shape_rep.setRepresentationIdentifier(repid);
shape_rep.setRepresentationType(reptype); shape_rep.setRepresentationType(reptype);
shape_rep.setItems(std::vector<Schema::IfcRepresentationItem>{}); shape_rep.setItems(std::vector<typename Schema::IfcRepresentationItem>{});
addEntity(shape_rep); addEntity(shape_rep);
return shape_rep; return shape_rep;
} }
@@ -1017,7 +1024,7 @@ typename Schema::IfcGeometricRepresentationContext IfcHierarchyHelper<Schema>::g
project = addProject(); project = addProject();
} }
auto project_contexts = project.RepresentationContexts(); auto project_contexts = project.RepresentationContexts();
auto context = create<Schema::IfcGeometricRepresentationContext>(); auto context = create<typename Schema::IfcGeometricRepresentationContext>();
context.setContextIdentifier(s); context.setContextIdentifier(s);
context.setCoordinateSpaceDimension(3); context.setCoordinateSpaceDimension(3);
context.setPrecision(1.e-5); context.setPrecision(1.e-5);
@@ -1046,7 +1053,7 @@ typename Schema::IfcGeometricRepresentationSubContext IfcHierarchyHelper<Schema>
if (!rep_subcontext) { if (!rep_subcontext) {
// didn't find the subcontext, create it // didn't find the subcontext, create it
rep_subcontext = create<Schema::IfcGeometricRepresentationSubContext>(); rep_subcontext = create<typename Schema::IfcGeometricRepresentationSubContext>();
rep_subcontext.setContextIdentifier(ident); rep_subcontext.setContextIdentifier(ident);
rep_subcontext.setContextType(type); rep_subcontext.setContextType(type);
rep_subcontext.setParentContext(geometric_representation_context); rep_subcontext.setParentContext(geometric_representation_context);
+1 -1
View File
@@ -426,7 +426,7 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
if (!owner_hist) { if (!owner_hist) {
owner_hist = addOwnerHistory(); owner_hist = addOwnerHistory();
} }
std::vector<Schema::IfcObject> related_objects = {related_object.template as<typename Schema::IfcObject>()}; std::vector<typename Schema::IfcObject> related_objects = {related_object.template as<typename Schema::IfcObject>()};
auto t = create<Schema::IfcRelDefinesByType>(); auto t = create<Schema::IfcRelDefinesByType>();
t.setGlobalId(IfcParse::IfcGlobalId()); t.setGlobalId(IfcParse::IfcGlobalId());
t.setOwnerHistory(owner_hist); t.setOwnerHistory(owner_hist);
+1 -1
View File
@@ -34,7 +34,7 @@
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
static my_thread_local express::Base current_product_; static thread_local express::Base current_product_;
namespace { namespace {
+2 -2
View File
@@ -2447,14 +2447,14 @@ std::vector<express::Entity> IfcFile::getInverse(int instance_id, const IfcParse
for (auto it = lower; it != upper; ++it) { for (auto it = lower; it != upper; ++it) {
for (auto& i : it->second) { for (auto& i : it->second) {
return_value.push_back(instance_by_id(i).as<express::Entity>()); return_value.push_back(instance_by_id(i).template as<express::Entity>());
} }
} }
} else { } else {
auto it = x.byref_excl_.find({ instance_id, ent->index_in_schema(), attribute_index }); auto it = x.byref_excl_.find({ instance_id, ent->index_in_schema(), attribute_index });
if (it != x.byref_excl_.end()) { if (it != x.byref_excl_.end()) {
for (auto& i : it->second) { for (auto& i : it->second) {
return_value.push_back(instance_by_id(i).as<express::Entity>()); return_value.push_back(instance_by_id(i).template as<express::Entity>());
} }
} }
} }
+1 -1
View File
@@ -114,7 +114,7 @@ class IFC_PARSE_API IfcSpfLexer {
public: public:
std::string& GetTempString() const { std::string& GetTempString() const {
static my_thread_local std::string string; static thread_local std::string string;
return string; return string;
} }
FileReader* stream; FileReader* stream;
+2 -2
View File
@@ -141,7 +141,7 @@ class IFC_PARSE_API declaration {
mutable const schema_definition* schema_; mutable const schema_definition* schema_;
std::string& temp_string_() const { std::string& temp_string_() const {
static my_thread_local std::string string; static thread_local std::string string;
return string; return string;
} }
@@ -457,7 +457,7 @@ class IFC_PARSE_API schema_definition {
}; };
std::string& temp_string_() const { std::string& temp_string_() const {
static my_thread_local std::string string; static thread_local std::string string;
return string; return string;
} }
+3 -3
View File
@@ -113,7 +113,7 @@ class IFC_PARSE_API Base {
return T{}; return T{};
} }
} else if constexpr (std::is_same_v<Select, T>) { } else if constexpr (std::is_same_v<Select, T>) {
static_assert(false, "Select is abstract"); static_assert(std::is_same_v<Select, T>, "Select is abstract");
} else { } else {
if (declaration().is(T::Class())) { if (declaration().is(T::Class())) {
return T(data_weak()); return T(data_weak());
@@ -189,14 +189,14 @@ template <typename T, typename U>
std::vector<T> cast_vector(const std::vector<U>& vs) { std::vector<T> cast_vector(const std::vector<U>& vs) {
std::vector<T> result; std::vector<T> result;
for (const auto& v : vs) { for (const auto& v : vs) {
if constexpr (std::is_base_of_v<T, U> || std::is_same_v<T, U>) { if constexpr (std::is_base_of_v<T, U>) {
// For a base or identity transform we can just rely on static cast // For a base or identity transform we can just rely on static cast
result.push_back(v); result.push_back(v);
} else if constexpr (std::is_base_of_v<express::Select, U> && std::is_same_v<T, express::Base>) { } else if constexpr (std::is_base_of_v<express::Select, U> && std::is_same_v<T, express::Base>) {
// From a select to concrete we simply call the appropriate method // From a select to concrete we simply call the appropriate method
result.push_back(v.concrete()); result.push_back(v.concrete());
} else { } else {
if (auto u = v.as<T>()) { if (auto u = v.template as<T>()) {
result.push_back(u); result.push_back(u);
} }
} }
-13
View File
@@ -34,17 +34,4 @@
#define IFC_PARSE_API #define IFC_PARSE_API
#endif #endif
#if defined(__clang__)
#define my_thread_local thread_local
#elif defined(__GNUC__)
#define my_thread_local __thread
#elif __STDC_VERSION__ >= 201112L
#define my_thread_local _Thread_local
#elif defined(_MSC_VER)
#define my_thread_local __declspec(thread)
#elif defined(SWIG)
#else
#error Cannot define thread_local
#endif
#endif #endif