After-merge clean-ups

This commit is contained in:
Thomas Krijnen
2026-07-09 13:30:48 +02:00
parent 7fc2d9a998
commit 561a23cfbc
164 changed files with 1373 additions and 1406 deletions
-14
View File
@@ -81,22 +81,8 @@ macro(build_schema_example exe_name schema)
endif()
endmacro()
if("4" IN_LIST SCHEMA_VERSIONS)
build_schema_example(arbitrary_open_profile_def 4)
build_schema_example(triangulated_faceset 4)
endif()
if("2x3" IN_LIST SCHEMA_VERSIONS)
build_schema_example(composite_profile_def 2x3)
build_schema_example(csg_primitive 2x3)
build_schema_example(ellipse_pies 2x3)
build_schema_example(faces 2x3)
build_schema_example(ifc_curve_rebar 2x3)
build_schema_example(profiles 2x3)
build_schema_example(IfcParseExamples 2x3 helpers)
if(WITH_OPENCASCADE)
build_schema_example(IfcOpenHouse 2x3 geometry_serializer)
build_schema_example(IfcAdvancedHouse 2x3 geometry_serializer)
endif()
endif()
+3 -4
View File
@@ -44,11 +44,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcBaseClass.h"
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
#include "../ifcgeom/Serialization/Serialization.h"
+3 -4
View File
@@ -41,11 +41,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcBaseClass.h"
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
#include "../ifcgeom/Serialization/Serialization.h"
+52 -99
View File
@@ -23,50 +23,16 @@
#define IfcSchema Ifc2x3
#endif
#include "ifcparse/IfcFile.h"
#include "ifcparse/IfcLogger.h"
#include "ifcparse/file.h"
#include "ifcparse/logger.h"
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/seq/pop_back.hpp>
#include <boost/preprocessor/comparison/greater.hpp>
#include <boost/preprocessor/selection/min.hpp>
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
#ifndef SCHEMA_SEQ
static_assert(false, "A boost preprocessor sequence of schema identifiers is needed for this file to compile.");
#endif
// A macro cannot expand to an include directive, so unroll enough includes for
// the maximum number of schemas supported by the build configuration.
#define INCLUDE_SCHEMA_N(n) \
BOOST_PP_IIF(BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(SCHEMA_SEQ), n), \
BOOST_PP_STRINGIZE(ifcparse/BOOST_PP_CAT(Ifc, BOOST_PP_SEQ_ELEM(BOOST_PP_MIN(n, BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_POP_BACK(SCHEMA_SEQ))), SCHEMA_SEQ)).h), \
"ifcgeom/empty.h")
#include INCLUDE_SCHEMA_N(0)
#include INCLUDE_SCHEMA_N(1)
#include INCLUDE_SCHEMA_N(2)
#include INCLUDE_SCHEMA_N(3)
#include INCLUDE_SCHEMA_N(4)
#include INCLUDE_SCHEMA_N(5)
#include INCLUDE_SCHEMA_N(6)
#include INCLUDE_SCHEMA_N(7)
#include INCLUDE_SCHEMA_N(8)
#include INCLUDE_SCHEMA_N(9)
#include INCLUDE_SCHEMA_N(10)
#include INCLUDE_SCHEMA_N(11)
#include INCLUDE_SCHEMA_N(12)
#include INCLUDE_SCHEMA_N(13)
#include INCLUDE_SCHEMA_N(14)
#include INCLUDE_SCHEMA_N(15)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/, IfcSchema)
#include <iomanip>
#if USE_VLD
@@ -121,117 +87,104 @@ std::string format_string(const AttributeValue& argument) {
}
template <typename Schema, typename T>
void process_pset(element_properties& props, const T* inst) {
void process_pset(element_properties& props, const T& inst) {
// Process an individual Property or Quantity set.
if (auto pset = inst->template as<typename Schema::IfcPropertySet>()) {
if (!pset->Name()) {
if (auto pset = inst.template as<typename Schema::IfcPropertySet>()) {
if (!pset.Name()) {
return;
}
auto ps = pset->HasProperties();
for (auto it = ps->begin(); it != ps->end(); ++it) {
auto& p = *it;
if (auto singleval = p->template as<typename Schema::IfcPropertySingleValue>()) {
auto ps = pset.HasProperties();
for (const auto& p : ps) {
if (auto singleval = p.template as<typename Schema::IfcPropertySingleValue>()) {
std::string propname, propvalue;
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (!singleval->Name()) {
if (!singleval.Name()) {
continue;
}
propname = *singleval->Name();
propname = *singleval.Name();
}
if constexpr (!is_ifc4_or_higher<Schema>::value) {
propname = singleval->Name();
propname = *singleval.Name();
}
if (!singleval->NominalValue()) {
auto nominal_value = singleval.NominalValue();
if (!nominal_value) {
propvalue = "-";
} else {
props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as<IfcUtil::IfcBaseClass>()->get_attribute_value(0));
props[*pset.Name()][propname] = format_string(nominal_value.get_attribute_value(0));
}
}
}
}
if (auto qset = inst->template as<typename Schema::IfcElementQuantity>()) {
if (!qset->Name()) {
if (auto qset = inst.template as<typename Schema::IfcElementQuantity>()) {
if (!qset.Name()) {
return;
}
auto qs = qset->Quantities();
for (auto it = qs->begin(); it != qs->end(); ++it) {
auto& q = *it;
if (q->template as<typename Schema::IfcPhysicalSimpleQuantity>() && q->get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) {
double v = q->get_attribute_value(3);
props[*qset->Name()][q->Name()] = std::to_string(v);
auto qs = qset.Quantities();
for (const auto& q : qs) {
if (q.template as<typename Schema::IfcPhysicalSimpleQuantity>() && q.get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) {
double v = q.get_attribute_value(3);
props[*qset.Name()][q.Name()] = std::to_string(v);
}
}
}
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (auto extprops = inst->template as<typename Schema::IfcExtendedProperties>()) {
if (auto extprops = inst.template as<typename Schema::IfcExtendedProperties>()) {
// @todo
}
}
}
template <typename Schema>
void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefinition* inst) {
void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefinition& inst) {
// Extracts the property definitions for an IFC instance.
if (auto tyob = inst->template as<typename Schema::IfcTypeObject>()) {
if (tyob->HasPropertySets()) {
auto defs = *tyob->HasPropertySets();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
if (auto tyob = inst.template as<typename Schema::IfcTypeObject>()) {
if (tyob.HasPropertySets()) {
auto defs = *tyob.HasPropertySets();
for (const auto& def : defs) {
process_pset<Schema>(props, def);
}
}
}
if constexpr (is_ifc4_or_higher<Schema>::value) {
if (auto mdef = inst->template as<typename Schema::IfcMaterialDefinition>()) {
auto defs = mdef->HasProperties();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
if (auto mdef = inst.template as<typename Schema::IfcMaterialDefinition>()) {
auto defs = mdef.HasProperties();
for (const auto& def : defs) {
process_pset<Schema>(props, def);
}
}
if (auto pdef = inst->template as<typename Schema::IfcProfileDef>()) {
auto defs = pdef->HasProperties();
for (auto it = defs->begin(); it != defs->end(); ++it) {
auto& def = *it;
if (auto pdef = inst.template as<typename Schema::IfcProfileDef>()) {
auto defs = pdef.HasProperties();
for (const auto& def : defs) {
process_pset<Schema>(props, def);
}
}
}
if (auto ob = inst->template as<typename Schema::IfcObject>()) {
if (auto ob = inst.template as<typename Schema::IfcObject>()) {
if constexpr (is_ifc4_or_higher<Schema>::value) {
auto rels = ob->IsTypedBy();
for (auto it = rels->begin(); it != rels->end(); ++it) {
auto& rel = *it;
get_psets_s<Schema>(props, rel->RelatingType());
auto rels = ob.IsTypedBy();
for (const auto& rel : rels) {
get_psets_s<Schema>(props, rel.RelatingType());
}
}
{
auto rels = ob->IsDefinedBy();
for (auto it = rels->begin(); it != rels->end(); ++it) {
auto& rel = *it;
if (auto bytype = rel->template as<typename Schema::IfcRelDefinesByType>()) {
get_psets_s<Schema>(props, bytype->RelatingType());
} else if (auto byprops = rel->template as<typename Schema::IfcRelDefinesByProperties>()) {
process_pset<Schema>(props, byprops->RelatingPropertyDefinition());
auto rels = ob.IsDefinedBy();
for (const auto& rel : rels) {
if (auto bytype = rel.template as<typename Schema::IfcRelDefinesByType>()) {
get_psets_s<Schema>(props, bytype.RelatingType());
} else if (auto byprops = rel.template as<typename Schema::IfcRelDefinesByProperties>()) {
process_pset<Schema>(props, byprops.RelatingPropertyDefinition());
}
}
}
}
}
// What follows is machinery to create a preprocessor-based dispatch mechanism to dispatch to the
// correct get_psets_s<Schema>() based on inst->declaration().schema()->name().
#define EXPAND_AND_CONCATENATE(elem) Ifc##elem
#define GENERATE_LITERAL_STRING(elem) "Ifc" # elem
#define TEST_AND_DISPATCH(r, data, elem) \
if (strcasecmp(schema_name, GENERATE_LITERAL_STRING(elem)) == 0) { get_psets_s<EXPAND_AND_CONCATENATE(elem)>(props, inst->as<EXPAND_AND_CONCATENATE(elem)::IfcObjectDefinition>()); }
void get_psets(element_properties& props, const IfcUtil::IfcBaseClass* inst) {
auto schema_name = inst->declaration().schema()->name().c_str();
BOOST_PP_SEQ_FOR_EACH(TEST_AND_DISPATCH, , SCHEMA_SEQ)
element_properties get_psets(const express::Base& inst) {
element_properties props;
if (auto object_definition = inst.as<IfcSchema::IfcObjectDefinition>()) {
get_psets_s<IfcSchema>(props, object_definition);
}
return props;
}
int main(int argc, char** argv) {
@@ -241,7 +194,7 @@ int main(int argc, char** argv) {
}
// Redirect the output (both progress and log) to stdout
Logger::Root().SetOutput(&std::cout, &std::cout);
::logger::root().set_output(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1]
ifcopenshell::file file(argv[1]);
+3 -3
View File
@@ -34,10 +34,10 @@
#define IfcSchema Ifc4
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+3 -3
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+3 -3
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+3 -3
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+3 -3
View File
@@ -29,10 +29,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef ifcopenshell::global_id guid;
+4 -4
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
#include <boost/math/constants/constants.hpp>
const static double PI = boost::math::constants::pi<double>();
@@ -57,7 +57,7 @@ typedef IfcSchema::IfcCompositeCurveSegment curve_segment_t;
#define IFC_REINFORCING_BAR_TYPE IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE
#endif
void create_curve_rebar(IfcHierarchyHelper<IfcSchema>& file)
void create_curve_rebar(hierarchy_helper<IfcSchema>& file)
{
int dia = 24;
int R = 3 * dia;
+3 -3
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc2x3
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
typedef std::string S;
typedef IfcWrite::IfcGuidHelper guid;
+3 -3
View File
@@ -33,10 +33,10 @@
#define IfcSchema Ifc4
#endif
#include INCLUDE_SCHEMA(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema)
#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema)
#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema)
#include "ifcparse/IfcHierarchyHelper.h"
#include "ifcparse/hierarchy_helper.h"
#include "suzanne_geometry.h"