diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 563db5dd14..d600baa5b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 \ -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so \ -DCOLLADA_SUPPORT=Off \ - "-DSCHEMA_VERSIONS=2x3;4" \ + "-DSCHEMA_VERSIONS=2x3;4;4x3" \ -DGLTF_SUPPORT=On \ -DJSON_INCLUDE_DIR=/usr/include \ -DCGAL_INCLUDE_DIR=/usr/include \ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 514c3acdb6..b51c04bff9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -590,13 +590,16 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME) endfunction() if(NOT SCHEMA_VERSIONS) - set(SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" "4x3_rc1" "4x3_rc2" "4x3_rc3" "4x3_rc4") + set(SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" "4x3_rc1" "4x3_rc2" "4x3_rc3" "4x3_rc4", "4x3") endif() foreach(s ${SCHEMA_VERSIONS}) add_definitions(-DHAS_SCHEMA_${s}) endforeach() +string(REPLACE ";" ")(" schema_version_seq "(${SCHEMA_VERSIONS})") +ADD_DEFINITIONS(-DSCHEMA_SEQ=${schema_version_seq}) + if(COMPILE_SCHEMA) # @todo, this appears to be untested at the moment diff --git a/src/ifcgeom_schema_agnostic/IteratorImplementation.cpp b/src/ifcgeom_schema_agnostic/IteratorImplementation.cpp index 1bea4fc73d..2333ade00f 100644 --- a/src/ifcgeom_schema_agnostic/IteratorImplementation.cpp +++ b/src/ifcgeom_schema_agnostic/IteratorImplementation.cpp @@ -1,55 +1,30 @@ #include "IteratorImplementation.h" +#include +#include #include +// Declares the schema-based external iterator initialization routines: +// - extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation*); +// - ... +#define EXTERNAL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(extern void init_IteratorImplementation_, elem), (IteratorFactoryImplementation*);) + +// Declares the schema-based external iterator initialization routines: +// - init_IteratorImplementation_Ifc2x3(this); +// - ... +#define CALL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(init_IteratorImplementation_, elem), (this);) + IFC_GEOM_API IteratorFactoryImplementation& iterator_implementations() { static IteratorFactoryImplementation impl; return impl; } -#ifdef HAS_SCHEMA_2x3 -extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation*); -#endif - -#ifdef HAS_SCHEMA_4 -extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation*); -#endif - -#ifdef HAS_SCHEMA_4x1 -extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation*); -#endif - -#ifdef HAS_SCHEMA_4x2 -extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation*); -#endif - -#ifdef HAS_SCHEMA_4x3_rc1 -extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation*); -#endif - -#ifdef HAS_SCHEMA_4x3_rc2 -extern void init_IteratorImplementation_Ifc4x3_rc2(IteratorFactoryImplementation*); -#endif +BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS, , SCHEMA_SEQ) IteratorFactoryImplementation::IteratorFactoryImplementation() { -#ifdef HAS_SCHEMA_2x3 - init_IteratorImplementation_Ifc2x3(this); -#endif -#ifdef HAS_SCHEMA_4 - init_IteratorImplementation_Ifc4(this); -#endif -#ifdef HAS_SCHEMA_4x1 - init_IteratorImplementation_Ifc4x1(this); -#endif -#ifdef HAS_SCHEMA_4x2 - init_IteratorImplementation_Ifc4x2(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - init_IteratorImplementation_Ifc4x3_rc1(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - init_IteratorImplementation_Ifc4x3_rc2(this); -#endif + BOOST_PP_SEQ_FOR_EACH(CALL_DEFS, , SCHEMA_SEQ) } void IteratorFactoryImplementation::bind(const std::string& schema_name, iterator_fn fn) { diff --git a/src/ifcgeom_schema_agnostic/Kernel.cpp b/src/ifcgeom_schema_agnostic/Kernel.cpp index 385979c555..fdea7a5d75 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.cpp +++ b/src/ifcgeom_schema_agnostic/Kernel.cpp @@ -5,6 +5,9 @@ #include #include +#include +#include + IfcGeom::Kernel::Kernel(IfcParse::IfcFile* file) { if (file != 0) { if (file->schema() == 0) { @@ -48,44 +51,22 @@ IfcGeom::impl::KernelFactoryImplementation& IfcGeom::impl::kernel_implementation return impl; } -#ifdef HAS_SCHEMA_2x3 -extern void init_KernelImplementation_Ifc2x3(IfcGeom::impl::KernelFactoryImplementation*); -#endif -#ifdef HAS_SCHEMA_4 -extern void init_KernelImplementation_Ifc4(IfcGeom::impl::KernelFactoryImplementation*); -#endif -#ifdef HAS_SCHEMA_4x1 -extern void init_KernelImplementation_Ifc4x1(IfcGeom::impl::KernelFactoryImplementation*); -#endif -#ifdef HAS_SCHEMA_4x2 -extern void init_KernelImplementation_Ifc4x2(IfcGeom::impl::KernelFactoryImplementation*); -#endif -#ifdef HAS_SCHEMA_4x3_rc1 -extern void init_KernelImplementation_Ifc4x3_rc1(IfcGeom::impl::KernelFactoryImplementation*); -#endif -#ifdef HAS_SCHEMA_4x3_rc2 -extern void init_KernelImplementation_Ifc4x3_rc2(IfcGeom::impl::KernelFactoryImplementation*); -#endif +// Declares the schema-based external kernel initialization routines: +// - extern void init_KernelImplementation_Ifc2x3(IfcGeom::impl::KernelFactoryImplementation*); +// - ... +#define EXTERNAL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(extern void init_KernelImplementation_, elem), (IfcGeom::impl::KernelFactoryImplementation*);) + +// Declares the schema-based external iterator initialization routines: +// - init_IteratorImplementation_Ifc2x3(this); +// - ... +#define CALL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(init_KernelImplementation_, elem), (this);) + +BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS, , SCHEMA_SEQ) IfcGeom::impl::KernelFactoryImplementation::KernelFactoryImplementation() { -#ifdef HAS_SCHEMA_2x3 - init_KernelImplementation_Ifc2x3(this); -#endif -#ifdef HAS_SCHEMA_4 - init_KernelImplementation_Ifc4(this); -#endif -#ifdef HAS_SCHEMA_4x1 - init_KernelImplementation_Ifc4x1(this); -#endif -#ifdef HAS_SCHEMA_4x2 - init_KernelImplementation_Ifc4x2(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - init_KernelImplementation_Ifc4x3_rc1(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - init_KernelImplementation_Ifc4x3_rc2(this); -#endif + BOOST_PP_SEQ_FOR_EACH(CALL_DEFS, , SCHEMA_SEQ) } void IfcGeom::impl::KernelFactoryImplementation::bind(const std::string& schema_name, IfcGeom::impl::kernel_fn fn) { @@ -155,6 +136,20 @@ IfcSchema::IfcObjectDefinition* get_decomposing_entity_impl(IfcSchema::IfcProduc return parent; \ } +#define GET_RELATINGOBJECT_IFC4_VARIANT(IfcSchema) \ + \ +IfcUtil::IfcBaseEntity* get_RelatingObject(IfcSchema::IfcRelDecomposes* decompose) { \ + IfcSchema::IfcRelAggregates* aggr = decompose->as(); \ + if (aggr != nullptr) { \ + return aggr->RelatingObject(); \ + } \ + IfcSchema::IfcRelNests* nest = decompose->as(); \ + if (nest != nullptr) { \ + return nest->RelatingObject(); \ + } \ + return nullptr; \ +} + namespace { #ifdef HAS_SCHEMA_2x3 @@ -165,113 +160,59 @@ namespace { #endif #ifdef HAS_SCHEMA_4 - IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4::IfcRelDecomposes* decompose) { - Ifc4::IfcRelAggregates* aggr = decompose->as(); - if (aggr != nullptr) { - return aggr->RelatingObject(); - } - Ifc4::IfcRelNests* nest = decompose->as(); - if (nest != nullptr) { - return nest->RelatingObject(); - } - return nullptr; - } + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4); CREATE_GET_DECOMPOSING_ENTITY(Ifc4); #endif #ifdef HAS_SCHEMA_4x1 - IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x1::IfcRelDecomposes* decompose) { - Ifc4x1::IfcRelAggregates* aggr = decompose->as(); - if (aggr != nullptr) { - return aggr->RelatingObject(); - } - Ifc4x1::IfcRelNests* nest = decompose->as(); - if (nest != nullptr) { - return nest->RelatingObject(); - } - return nullptr; - } + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x1); CREATE_GET_DECOMPOSING_ENTITY(Ifc4x1); #endif #ifdef HAS_SCHEMA_4x2 - IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x2::IfcRelDecomposes* decompose) { - Ifc4x2::IfcRelAggregates* aggr = decompose->as(); - if (aggr != nullptr) { - return aggr->RelatingObject(); - } - Ifc4x2::IfcRelNests* nest = decompose->as(); - if (nest != nullptr) { - return nest->RelatingObject(); - } - return nullptr; - } + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x2); CREATE_GET_DECOMPOSING_ENTITY(Ifc4x2); #endif #ifdef HAS_SCHEMA_4x3_rc1 - IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x3_rc1::IfcRelDecomposes* decompose) { - Ifc4x3_rc1::IfcRelAggregates* aggr = decompose->as(); - if (aggr != nullptr) { - return aggr->RelatingObject(); - } - Ifc4x3_rc1::IfcRelNests* nest = decompose->as(); - if (nest != nullptr) { - return nest->RelatingObject(); - } - return nullptr; - } + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x3_rc1); CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc1); #endif #ifdef HAS_SCHEMA_4x3_rc2 - IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x3_rc2::IfcRelDecomposes* decompose) { - Ifc4x3_rc2::IfcRelAggregates* aggr = decompose->as(); - if (aggr != nullptr) { - return aggr->RelatingObject(); - } - Ifc4x3_rc2::IfcRelNests* nest = decompose->as(); - if (nest != nullptr) { - return nest->RelatingObject(); - } - return nullptr; - } + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x3_rc2); CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc2); #endif +#ifdef HAS_SCHEMA_4x3_rc3 + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x3_rc3); + CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc3); +#endif + +#ifdef HAS_SCHEMA_4x3_rc4 + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x3_rc4); + CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc4); +#endif + +#ifdef HAS_SCHEMA_4x3 + GET_RELATINGOBJECT_IFC4_VARIANT(Ifc4x3); + CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3); +#endif } +// Declares the schema-based IfcProduct check: +// - if (inst->as()) { ... } +// - ... +#define IFCPROCUCT_CHECK(r, data, elem) \ + if (inst->as()) { return get_decomposing_entity_impl(inst->as(), include_openings); } + +#define GET_LAYERS(r, data, elem) \ + if (inst->as()) { return get_layers_impl(inst->as()); } + + IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBaseEntity* inst, bool include_openings) { -#ifdef HAS_SCHEMA_2x3 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif -#ifdef HAS_SCHEMA_4 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif -#ifdef HAS_SCHEMA_4x1 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif -#ifdef HAS_SCHEMA_4x2 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - if (inst->as()) { - return get_decomposing_entity_impl(inst->as(), include_openings); - } -#endif + BOOST_PP_SEQ_FOR_EACH(IFCPROCUCT_CHECK, , SCHEMA_SEQ) + if (inst->declaration().name() == "IfcProject") { return nullptr; } @@ -298,36 +239,7 @@ namespace { } std::map IfcGeom::Kernel::get_layers(IfcUtil::IfcBaseEntity* inst) { -#ifdef HAS_SCHEMA_2x3 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif -#ifdef HAS_SCHEMA_4 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif -#ifdef HAS_SCHEMA_4x1 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif -#ifdef HAS_SCHEMA_4x2 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - if (inst->as()) { - return get_layers_impl(inst->as()); - } -#endif + BOOST_PP_SEQ_FOR_EACH(GET_LAYERS, , SCHEMA_SEQ) throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name()); } diff --git a/src/ifcgeom_schema_agnostic/Kernel.h b/src/ifcgeom_schema_agnostic/Kernel.h index 4d961cded0..930255c768 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.h +++ b/src/ifcgeom_schema_agnostic/Kernel.h @@ -29,6 +29,9 @@ #ifdef HAS_SCHEMA_4x3_rc4 #include "../ifcparse/Ifc4x3_rc4.h" #endif +#ifdef HAS_SCHEMA_4x3 +#include "../ifcparse/Ifc4x3.h" +#endif #include diff --git a/src/ifcgeom_schema_agnostic/Serialization.cpp b/src/ifcgeom_schema_agnostic/Serialization.cpp index 11efb997f1..522b3eace8 100644 --- a/src/ifcgeom_schema_agnostic/Serialization.cpp +++ b/src/ifcgeom_schema_agnostic/Serialization.cpp @@ -2,143 +2,53 @@ #include +#include +#include +#include + +#define EXTERNAL_DEFS_1(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(IfcUtil::IfcBaseClass* tesselate_, elem), (const TopoDS_Shape& shape, double deflection);) + +#define EXTERNAL_DEFS_2(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(IfcUtil::IfcBaseClass* serialise_, elem), (const TopoDS_Shape& shape, bool advanced);) + +#define CONDITIONAL_CALL(r, data, elem) \ + if (schema_name_lower == BOOST_PP_STRINGIZE(BOOST_PP_CAT(elem,))) { \ + return BOOST_PP_CAT(METHOD_NAME, elem)(shape, arg_2); \ + } + namespace IfcGeom { -#ifdef HAS_SCHEMA_2x3 - extern IfcUtil::IfcBaseClass* tesselate_Ifc2x3(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc2x3(const TopoDS_Shape& shape, bool advanced); -#endif - -#ifdef HAS_SCHEMA_4 - extern IfcUtil::IfcBaseClass* tesselate_Ifc4(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc4(const TopoDS_Shape& shape, bool advanced); -#endif - -#ifdef HAS_SCHEMA_4x1 - extern IfcUtil::IfcBaseClass* tesselate_Ifc4x1(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc4x1(const TopoDS_Shape& shape, bool advanced); -#endif - -#ifdef HAS_SCHEMA_4x2 - extern IfcUtil::IfcBaseClass* tesselate_Ifc4x2(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc4x2(const TopoDS_Shape& shape, bool advanced); -#endif - -#ifdef HAS_SCHEMA_4x3_rc1 - extern IfcUtil::IfcBaseClass* tesselate_Ifc4x3_rc1(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc4x3_rc1(const TopoDS_Shape& shape, bool advanced); -#endif - -#ifdef HAS_SCHEMA_4x3_rc2 - extern IfcUtil::IfcBaseClass* tesselate_Ifc4x3_rc2(const TopoDS_Shape& shape, double deflection); - extern IfcUtil::IfcBaseClass* serialise_Ifc4x3_rc2(const TopoDS_Shape& shape, bool advanced); -#endif + BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS_1, , SCHEMA_SEQ); + BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS_2, , SCHEMA_SEQ); } -template -IfcUtil::IfcBaseClass* execute_based_on_schema( -#ifdef HAS_SCHEMA_2x3 - Fn fn_2x3, -#endif -#ifdef HAS_SCHEMA_4 - Fn fn_4, -#endif -#ifdef HAS_SCHEMA_4x1 - Fn fn_4x1, -#endif -#ifdef HAS_SCHEMA_4x2 - Fn fn_4x2, -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - Fn fn_4x3_rc1, -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - Fn fn_4x3_rc2, -#endif - const std::string& schema_name, const TopoDS_Shape& shape, T t) -{ +#define METHOD_NAME tesselate_ + +IfcUtil::IfcBaseClass* IfcGeom::tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double arg_2) { // @todo an ugly hack to guarantee schemas are initialised. try { IfcParse::schema_by_name("IFC2X3"); } catch (IfcParse::IfcException&) {} - const std::string schema_name_lower = boost::to_lower_copy(schema_name); + const std::string schema_name_lower = boost::to_lower_copy(schema_name.substr(3)); -#ifdef HAS_SCHEMA_2x3 - if (schema_name_lower == "ifc2x3") { - return fn_2x3(shape, t); - } -#endif -#ifdef HAS_SCHEMA_4 - if (schema_name_lower == "ifc4") { - return fn_4(shape, t); - } -#endif -#ifdef HAS_SCHEMA_4x1 - if (schema_name_lower == "ifc4x1") { - return fn_4x1(shape, t); - } -#endif -#ifdef HAS_SCHEMA_4x2 - if (schema_name_lower == "ifc4x2") { - return fn_4x2(shape, t); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - if (schema_name_lower == "ifc4x3_rc1") { - return fn_4x3_rc1(shape, t); - } -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - if (schema_name_lower == "ifc4x3_rc2") { - return fn_4x3_rc2(shape, t); - } -#endif + BOOST_PP_SEQ_FOR_EACH(CONDITIONAL_CALL, , SCHEMA_SEQ); throw IfcParse::IfcException("No geometry serialization available for " + schema_name); } -IfcUtil::IfcBaseClass* IfcGeom::tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double deflection) { - return execute_based_on_schema( -#ifdef HAS_SCHEMA_2x3 - IfcGeom::tesselate_Ifc2x3, -#endif -#ifdef HAS_SCHEMA_4 - IfcGeom::tesselate_Ifc4, -#endif -#ifdef HAS_SCHEMA_4x1 - IfcGeom::tesselate_Ifc4x1, -#endif -#ifdef HAS_SCHEMA_4x2 - IfcGeom::tesselate_Ifc4x2, -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - IfcGeom::tesselate_Ifc4x3_rc1, -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - IfcGeom::tesselate_Ifc4x3_rc2, -#endif - schema_name, shape, deflection); -} +#undef METHOD_NAME +#define METHOD_NAME serialise_ -IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool advanced) { - return execute_based_on_schema( -#ifdef HAS_SCHEMA_2x3 - IfcGeom::serialise_Ifc2x3, -#endif -#ifdef HAS_SCHEMA_4 - IfcGeom::serialise_Ifc4, -#endif -#ifdef HAS_SCHEMA_4x1 - IfcGeom::serialise_Ifc4x1, -#endif -#ifdef HAS_SCHEMA_4x2 - IfcGeom::serialise_Ifc4x2, -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - IfcGeom::serialise_Ifc4x3_rc1, -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - IfcGeom::serialise_Ifc4x3_rc2, -#endif - schema_name, shape, advanced); +IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool arg_2) { + // @todo an ugly hack to guarantee schemas are initialised. + try { + IfcParse::schema_by_name("IFC2X3"); + } catch (IfcParse::IfcException&) {} + + const std::string schema_name_lower = boost::to_lower_copy(schema_name.substr(3)); + + BOOST_PP_SEQ_FOR_EACH(CONDITIONAL_CALL, , SCHEMA_SEQ); + + throw IfcParse::IfcException("No geometry serialization available for " + schema_name); } \ No newline at end of file diff --git a/src/ifcparse/IfcHierarchyHelper.cpp b/src/ifcparse/IfcHierarchyHelper.cpp index d00a67590f..b0109ac7ce 100644 --- a/src/ifcparse/IfcHierarchyHelper.cpp +++ b/src/ifcparse/IfcHierarchyHelper.cpp @@ -560,6 +560,14 @@ Ifc4x3_rc4::IfcStyledItem* create_styled_item(Ifc4x3_rc4::IfcRepresentationItem* } #endif +#ifdef HAS_SCHEMA_4x3 +Ifc4x3::IfcStyledItem* create_styled_item(Ifc4x3::IfcRepresentationItem* item, Ifc4x3::IfcPresentationStyle* style) { + boost::shared_ptr> styles(new aggregate_of()); + styles->push(style); + return new Ifc4x3::IfcStyledItem(item, styles, boost::none); +} +#endif + template void setSurfaceColour_2x3(IfcHierarchyHelper& file, typename Schema::IfcRepresentation* rep, typename Schema::IfcPresentationStyleAssignment* style_assignment) { @@ -800,7 +808,32 @@ void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3_rc4::IfcRepre } #endif +#ifdef HAS_SCHEMA_4x3 +Ifc4x3::IfcPresentationStyle* addStyleAssignment(IfcHierarchyHelper& file, double r, double g, double b, double a) +{ + return addStyleAssignment_4x3(file, r, g, b, a); +} +Ifc4x3::IfcPresentationStyle* setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcProductRepresentation* shape, double r, double g, double b, double a) +{ + return setSurfaceColour_4x3(file, shape, r, g, b, a); +} + +Ifc4x3::IfcPresentationStyle* setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcRepresentation* shape, double r, double g, double b, double a) +{ + return setSurfaceColour_4x3(file, shape, r, g, b, a); +} + +void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcProductRepresentation* shape, Ifc4x3::IfcPresentationStyle* style) +{ + setSurfaceColour_4x3(file, shape, style); +} + +void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcRepresentation* shape, Ifc4x3::IfcPresentationStyle* style) +{ + setSurfaceColour_4x3(file, shape, style); +} +#endif template typename Schema::IfcProductDefinitionShape* IfcHierarchyHelper::addMappedItem( @@ -923,4 +956,7 @@ template IFC_PARSE_API class IfcHierarchyHelper; #endif #ifdef HAS_SCHEMA_4x3_rc4 template IFC_PARSE_API class IfcHierarchyHelper; +#endif +#ifdef HAS_SCHEMA_4x3 +template IFC_PARSE_API class IfcHierarchyHelper; #endif \ No newline at end of file diff --git a/src/ifcparse/IfcHierarchyHelper.h b/src/ifcparse/IfcHierarchyHelper.h index 3c462ba92f..84e29d842a 100644 --- a/src/ifcparse/IfcHierarchyHelper.h +++ b/src/ifcparse/IfcHierarchyHelper.h @@ -56,6 +56,9 @@ #ifdef HAS_SCHEMA_4x3_rc4 #include "../ifcparse/Ifc4x3_rc4.h" #endif +#ifdef HAS_SCHEMA_4x3 +#include "../ifcparse/Ifc4x3.h" +#endif #include "../ifcparse/IfcFile.h" #include "../ifcparse/IfcWrite.h" @@ -238,6 +241,28 @@ namespace { } #endif +#ifdef HAS_SCHEMA_4x3 + Ifc4x3::IfcObjectDefinition* get_parent_of_relation(Ifc4x3::IfcRelContainedInSpatialStructure* t) { + return t->RelatingStructure(); + } + + aggregate_of_instance::ptr get_children_of_relation(Ifc4x3::IfcRelContainedInSpatialStructure* t) { + return t->RelatedElements()->generalize(); + } + + aggregate_of_instance::ptr get_children_of_relation(Ifc4x3::IfcRelAggregates* t) { + return t->RelatedObjects()->generalize(); + } + + void set_children_of_relation(Ifc4x3::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) { + t->setRelatedElements(cs->as()); + } + + void set_children_of_relation(Ifc4x3::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) { + t->setRelatedObjects(cs->as()); + } +#endif + IfcUtil::IfcBaseClass* get_parent_of_relation(IfcUtil::IfcBaseClass* t) { return *t->data().getArgument( t->declaration().as_entity()->attribute_index("RelatingObject") @@ -464,6 +489,14 @@ IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3 IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3_rc4::IfcRepresentation* shape, Ifc4x3_rc4::IfcPresentationStyle* style); #endif +#ifdef HAS_SCHEMA_4x3 +IFC_PARSE_API Ifc4x3::IfcPresentationStyle* addStyleAssignment(IfcHierarchyHelper& file, double r, double g, double b, double a = 1.0); +IFC_PARSE_API Ifc4x3::IfcPresentationStyle* setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcProductRepresentation* shape, double r, double g, double b, double a = 1.0); +IFC_PARSE_API Ifc4x3::IfcPresentationStyle* setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcRepresentation* shape, double r, double g, double b, double a = 1.0); +IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcProductRepresentation* shape, Ifc4x3::IfcPresentationStyle* style); +IFC_PARSE_API void setSurfaceColour(IfcHierarchyHelper& file, Ifc4x3::IfcRepresentation* shape, Ifc4x3::IfcPresentationStyle* style); +#endif + /* template <> inline void IfcHierarchyHelper::addRelatedObject (typename Schema::IfcObjectDefinition* relating_structure, diff --git a/src/ifcparse/IfcSIPrefix.cpp b/src/ifcparse/IfcSIPrefix.cpp index e851785ecb..4d53ec99ac 100644 --- a/src/ifcparse/IfcSIPrefix.cpp +++ b/src/ifcparse/IfcSIPrefix.cpp @@ -43,6 +43,9 @@ #ifdef HAS_SCHEMA_4x3_rc4 #include "../ifcparse/Ifc4x3_rc4.h" #endif +#ifdef HAS_SCHEMA_4x3 +#include "../ifcparse/Ifc4x3.h" +#endif double IfcParse::IfcSIPrefixToValue(const std::string& v) { if ( v == "EXA" ) return 1.e18; @@ -119,6 +122,9 @@ template double IFC_PARSE_API IfcParse::get_SI_equivalent(Ifc4x3_rc3 #ifdef HAS_SCHEMA_4x3_rc4 template double IFC_PARSE_API IfcParse::get_SI_equivalent(Ifc4x3_rc4::IfcNamedUnit* named_unit); #endif +#ifdef HAS_SCHEMA_4x3 +template double IFC_PARSE_API IfcParse::get_SI_equivalent(Ifc4x3_rc4::IfcNamedUnit* named_unit); +#endif #else @@ -146,5 +152,8 @@ template double IFC_PARSE_API IfcParse::get_SI_equivalent(typename I #ifdef HAS_SCHEMA_4x3_rc4 template double IFC_PARSE_API IfcParse::get_SI_equivalent(typename Ifc4x3_rc4::IfcNamedUnit* named_unit); #endif +#ifdef HAS_SCHEMA_4x3 +template double IFC_PARSE_API IfcParse::get_SI_equivalent(typename Ifc4x3::IfcNamedUnit* named_unit); +#endif #endif diff --git a/src/ifcparse/IfcSchema.cpp b/src/ifcparse/IfcSchema.cpp index 6c7bee5b0c..817c9082e7 100644 --- a/src/ifcparse/IfcSchema.cpp +++ b/src/ifcparse/IfcSchema.cpp @@ -116,6 +116,9 @@ void IfcParse::register_schema(schema_definition* s) { #ifdef HAS_SCHEMA_4x3_rc4 #include "../ifcparse/Ifc4x3_rc4.h" #endif +#ifdef HAS_SCHEMA_4x3 +#include "../ifcparse/Ifc4x3.h" +#endif const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) { // TODO: initialize automatically somehow @@ -143,6 +146,9 @@ const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& n #ifdef HAS_SCHEMA_4x3_rc4 Ifc4x3_rc4::get_schema(); #endif +#ifdef HAS_SCHEMA_4x3 + Ifc4x3::get_schema(); +#endif std::map::const_iterator it = schemas.find(boost::to_upper_copy(name)); if (it == schemas.end()) { @@ -191,6 +197,9 @@ void IfcParse::clear_schemas() { #ifdef HAS_SCHEMA_4x3_rc4 Ifc4x3_rc4::clear_schema(); #endif +#ifdef HAS_SCHEMA_4x3 + Ifc4x3::clear_schema(); +#endif // clear any remaining registered schemas // we pop schemas until map is empty, because map iteration is invalidated after each erasure diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 4f7f08ca9d..45b2bb761a 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -586,6 +586,21 @@ struct ShapeRTTI : public boost::static_visitor return helper_fn_create_shape(settings, instance, representation); } #endif + #ifdef HAS_SCHEMA_4x3_rc3 + if (schema_name == "IFC4X3_RC3") { + return helper_fn_create_shape(settings, instance, representation); + } + #endif + #ifdef HAS_SCHEMA_4x3_rc4 + if (schema_name == "IFC4X3_RC4") { + return helper_fn_create_shape(settings, instance, representation); + } + #endif + #ifdef HAS_SCHEMA_4x3 + if (schema_name == "IFC4X3") { + return helper_fn_create_shape(settings, instance, representation); + } + #endif throw IfcParse::IfcException("No geometry support for " + schema_name); } diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index dd1517c998..e795245049 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -109,6 +109,9 @@ #endif #ifdef HAS_SCHEMA_4x3_rc4 #include "../ifcparse/Ifc4x3_rc4.h" +#endif +#ifdef HAS_SCHEMA_4x3 +#include "../ifcparse/Ifc4x3.h" #endif #include "../ifcparse/IfcBaseClass.h" @@ -159,6 +162,15 @@ #ifdef HAS_SCHEMA_4x3_rc2 #include "../ifcparse/Ifc4x3_rc2.h" #endif +#ifdef HAS_SCHEMA_4x3_rc3 + #include "../ifcparse/Ifc4x3_rc3.h" +#endif +#ifdef HAS_SCHEMA_4x3_rc4 + #include "../ifcparse/Ifc4x3_rc4.h" +#endif +#ifdef HAS_SCHEMA_4x3 + #include "../ifcparse/Ifc4x3.h" +#endif #include "../ifcparse/IfcBaseClass.h" #include "../ifcparse/IfcFile.h" diff --git a/src/serializers/XmlSerializer.cpp b/src/serializers/XmlSerializer.cpp index dea89823f5..81386fb33e 100644 --- a/src/serializers/XmlSerializer.cpp +++ b/src/serializers/XmlSerializer.cpp @@ -1,43 +1,19 @@ #include "XmlSerializer.h" -#ifdef HAS_SCHEMA_2x3 -extern void init_XmlSerializerIfc2x3(XmlSerializerFactory::Factory*); -#endif -#ifdef HAS_SCHEMA_4 -extern void init_XmlSerializerIfc4(XmlSerializerFactory::Factory*); -#endif -#ifdef HAS_SCHEMA_4x1 -extern void init_XmlSerializerIfc4x1(XmlSerializerFactory::Factory*); -#endif -#ifdef HAS_SCHEMA_4x2 -extern void init_XmlSerializerIfc4x2(XmlSerializerFactory::Factory*); -#endif -#ifdef HAS_SCHEMA_4x3_rc1 -extern void init_XmlSerializerIfc4x3_rc1(XmlSerializerFactory::Factory*); -#endif -#ifdef HAS_SCHEMA_4x3_rc2 -extern void init_XmlSerializerIfc4x3_rc2(XmlSerializerFactory::Factory*); -#endif +#include +#include +#include + +#define EXTERNAL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(extern void init_XmlSerializer, elem), (XmlSerializerFactory::Factory*);) + +#define CALL_DEFS(r, data, elem) \ + BOOST_PP_CAT(BOOST_PP_CAT(init_XmlSerializer, elem), (this);) + +BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS, , SCHEMA_SEQ) XmlSerializerFactory::Factory::Factory() { -#ifdef HAS_SCHEMA_2x3 - init_XmlSerializerIfc2x3(this); -#endif -#ifdef HAS_SCHEMA_4 - init_XmlSerializerIfc4(this); -#endif -#ifdef HAS_SCHEMA_4x1 - init_XmlSerializerIfc4x1(this); -#endif -#ifdef HAS_SCHEMA_4x2 - init_XmlSerializerIfc4x2(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - init_XmlSerializerIfc4x3_rc1(this); -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - init_XmlSerializerIfc4x3_rc2(this); -#endif + BOOST_PP_SEQ_FOR_EACH(CALL_DEFS, , SCHEMA_SEQ) } void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) {