#842 IFC4X3 schema and some other schema init cruft

This commit is contained in:
Thomas Krijnen
2020-06-15 12:48:30 +02:00
parent b8d0e22aa8
commit f01ae4a45b
16 changed files with 90239 additions and 6 deletions
@@ -18,10 +18,22 @@ extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P,
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P, PP>*);
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation<P, PP>*);
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation<P, PP>*);
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation<P, PP>*);
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>::IteratorFactoryImplementation() {
init_IteratorImplementation_Ifc2x3(this);
init_IteratorImplementation_Ifc4(this);
init_IteratorImplementation_Ifc4x1(this);
init_IteratorImplementation_Ifc4x2(this);
init_IteratorImplementation_Ifc4x3_rc1(this);
}
template <typename P, typename PP>
+45
View File
@@ -50,10 +50,16 @@ IfcGeom::impl::KernelFactoryImplementation& IfcGeom::impl::kernel_implementation
extern void init_KernelImplementation_Ifc2x3(IfcGeom::impl::KernelFactoryImplementation*);
extern void init_KernelImplementation_Ifc4(IfcGeom::impl::KernelFactoryImplementation*);
extern void init_KernelImplementation_Ifc4x1(IfcGeom::impl::KernelFactoryImplementation*);
extern void init_KernelImplementation_Ifc4x2(IfcGeom::impl::KernelFactoryImplementation*);
extern void init_KernelImplementation_Ifc4x3_rc1(IfcGeom::impl::KernelFactoryImplementation*);
IfcGeom::impl::KernelFactoryImplementation::KernelFactoryImplementation() {
init_KernelImplementation_Ifc2x3(this);
init_KernelImplementation_Ifc4(this);
init_KernelImplementation_Ifc4x1(this);
init_KernelImplementation_Ifc4x2(this);
init_KernelImplementation_Ifc4x3_rc1(this);
}
void IfcGeom::impl::KernelFactoryImplementation::bind(const std::string& schema_name, IfcGeom::impl::kernel_fn fn) {
@@ -131,6 +137,30 @@ namespace {
}
return nullptr;
}
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x1::IfcRelDecomposes* decompose) {
Ifc4x1::IfcRelAggregates* aggr = decompose->as<Ifc4x1::IfcRelAggregates>();
if (aggr != nullptr) {
return aggr->RelatingObject();
}
return nullptr;
}
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x2::IfcRelDecomposes* decompose) {
Ifc4x2::IfcRelAggregates* aggr = decompose->as<Ifc4x2::IfcRelAggregates>();
if (aggr != nullptr) {
return aggr->RelatingObject();
}
return nullptr;
}
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x3_rc1::IfcRelDecomposes* decompose) {
Ifc4x3_rc1::IfcRelAggregates* aggr = decompose->as<Ifc4x3_rc1::IfcRelAggregates>();
if (aggr != nullptr) {
return aggr->RelatingObject();
}
return nullptr;
}
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc2x3::IfcRelDecomposes* decompose) {
return decompose->RelatingObject();
@@ -138,6 +168,9 @@ namespace {
CREATE_GET_DECOMPOSING_ENTITY(Ifc2x3);
CREATE_GET_DECOMPOSING_ENTITY(Ifc4);
CREATE_GET_DECOMPOSING_ENTITY(Ifc4x1);
CREATE_GET_DECOMPOSING_ENTITY(Ifc4x2);
CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc1);
}
IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBaseEntity* inst, bool include_openings) {
@@ -145,6 +178,12 @@ IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBase
return get_decomposing_entity_impl(inst->as<Ifc2x3::IfcProduct>(), include_openings);
} else if (inst->as<Ifc4::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4::IfcProduct>(), include_openings);
} else if (inst->as<Ifc4x1::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x1::IfcProduct>(), include_openings);
} else if (inst->as<Ifc4x2::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x2::IfcProduct>(), include_openings);
} else if (inst->as<Ifc4x3_rc1::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x3_rc1::IfcProduct>(), include_openings);
} else if (inst->declaration().name() == "IfcProject") {
return nullptr;
} else {
@@ -175,6 +214,12 @@ std::map<std::string, IfcUtil::IfcBaseEntity*> IfcGeom::Kernel::get_layers(IfcUt
return get_layers_impl<Ifc2x3>(inst->as<Ifc2x3::IfcProduct>());
} else if (inst->as<Ifc4::IfcProduct>()) {
return get_layers_impl<Ifc4>(inst->as<Ifc4::IfcProduct>());
} else if (inst->as<Ifc4x1::IfcProduct>()) {
return get_layers_impl<Ifc4x1>(inst->as<Ifc4x1::IfcProduct>());
} else if (inst->as<Ifc4x2::IfcProduct>()) {
return get_layers_impl<Ifc4x2>(inst->as<Ifc4x2::IfcProduct>());
} else if (inst->as<Ifc4x3_rc1::IfcProduct>()) {
return get_layers_impl<Ifc4x3_rc1>(inst->as<Ifc4x3_rc1::IfcProduct>());
} else {
throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
}
+3
View File
@@ -7,6 +7,9 @@
#include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/Ifc4.h"
#include "../ifcparse/Ifc4x1.h"
#include "../ifcparse/Ifc4x2.h"
#include "../ifcparse/Ifc4x3_rc1.h"
#include <boost/function.hpp>
+30 -5
View File
@@ -5,12 +5,19 @@
namespace IfcGeom {
extern IfcUtil::IfcBaseClass* tesselate_Ifc2x3(const TopoDS_Shape& shape, double deflection);
extern IfcUtil::IfcBaseClass* tesselate_Ifc4(const TopoDS_Shape& shape, double deflection);
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x1(const TopoDS_Shape& shape, double deflection);
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x2(const TopoDS_Shape& shape, double deflection);
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x3_rc1(const TopoDS_Shape& shape, double deflection);
extern IfcUtil::IfcBaseClass* serialise_Ifc2x3(const TopoDS_Shape& shape, bool advanced);
extern IfcUtil::IfcBaseClass* serialise_Ifc4(const TopoDS_Shape& shape, bool advanced);
extern IfcUtil::IfcBaseClass* serialise_Ifc4x1(const TopoDS_Shape& shape, bool advanced);
extern IfcUtil::IfcBaseClass* serialise_Ifc4x2(const TopoDS_Shape& shape, bool advanced);
extern IfcUtil::IfcBaseClass* serialise_Ifc4x3_rc1(const TopoDS_Shape& shape, bool advanced);
}
template <typename Fn, typename T>
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn1, Fn fn2, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn_2x3, Fn fn_4, Fn fn_4x1, Fn fn_4x2, Fn fn_4x3_rc1, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
// @todo an ugly hack to guarantee schemas are initialised.
try {
IfcParse::schema_by_name("IFC2X3");
@@ -19,18 +26,36 @@ IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn1, Fn fn2, const std::string
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
if (schema_name_lower == "ifc2x3") {
return fn1(shape, t);
return fn_2x3(shape, t);
} else if (schema_name_lower == "ifc4") {
return fn2(shape, t);
return fn_4(shape, t);
} else if (schema_name_lower == "ifc4x1") {
return fn_4x1(shape, t);
} else if (schema_name_lower == "ifc4x2") {
return fn_4x2(shape, t);
} else if (schema_name_lower == "ifc4x3_rc1") {
return fn_4x3_rc1(shape, t);
} else {
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(IfcGeom::tesselate_Ifc2x3, IfcGeom::tesselate_Ifc4, schema_name, shape, deflection);
return execute_based_on_schema(
IfcGeom::tesselate_Ifc2x3,
IfcGeom::tesselate_Ifc4,
IfcGeom::tesselate_Ifc4x1,
IfcGeom::tesselate_Ifc4x2,
IfcGeom::tesselate_Ifc4x3_rc1,
schema_name, shape, deflection);
}
IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool advanced) {
return execute_based_on_schema(IfcGeom::serialise_Ifc2x3, IfcGeom::serialise_Ifc4, schema_name, shape, advanced);
return execute_based_on_schema(
IfcGeom::serialise_Ifc2x3,
IfcGeom::serialise_Ifc4,
IfcGeom::serialise_Ifc4x1,
IfcGeom::serialise_Ifc4x2,
IfcGeom::serialise_Ifc4x3_rc1,
schema_name, shape, advanced);
}