Hacky solution to disable schemas to speedup compilation

This commit is contained in:
Thomas Krijnen
2021-05-11 22:29:16 +02:00
parent ce76d27acc
commit 34386ea27c
12 changed files with 582 additions and 166 deletions
@@ -12,32 +12,56 @@ template IteratorFactoryImplementation<float, float>& iterator_implementations<f
template IteratorFactoryImplementation<float, double>& iterator_implementations<float, double>();
template IteratorFactoryImplementation<double, double>& iterator_implementations<double, double>();
#ifdef HAS_SCHEMA_2x3
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P, PP>*);
#endif
#ifdef HAS_SCHEMA_4
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P, PP>*);
#endif
#ifdef HAS_SCHEMA_4x1
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation<P, PP>*);
#endif
#ifdef HAS_SCHEMA_4x2
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation<P, PP>*);
#endif
#ifdef HAS_SCHEMA_4x3_rc1
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation<P, PP>*);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4x3_rc2(IteratorFactoryImplementation<P, PP>*);
#endif
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>::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
}
template <typename P, typename PP>
+111 -39
View File
@@ -48,20 +48,44 @@ 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
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
}
void IfcGeom::impl::KernelFactoryImplementation::bind(const std::string& schema_name, IfcGeom::impl::kernel_fn fn) {
@@ -132,6 +156,15 @@ IfcSchema::IfcObjectDefinition* get_decomposing_entity_impl(IfcSchema::IfcProduc
}
namespace {
#ifdef HAS_SCHEMA_2x3
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc2x3::IfcRelDecomposes* decompose) {
return decompose->RelatingObject();
}
CREATE_GET_DECOMPOSING_ENTITY(Ifc2x3);
#endif
#ifdef HAS_SCHEMA_4
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4::IfcRelDecomposes* decompose) {
Ifc4::IfcRelAggregates* aggr = decompose->as<Ifc4::IfcRelAggregates>();
if (aggr != nullptr) {
@@ -139,7 +172,10 @@ namespace {
}
return nullptr;
}
CREATE_GET_DECOMPOSING_ENTITY(Ifc4);
#endif
#ifdef HAS_SCHEMA_4x1
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x1::IfcRelDecomposes* decompose) {
Ifc4x1::IfcRelAggregates* aggr = decompose->as<Ifc4x1::IfcRelAggregates>();
if (aggr != nullptr) {
@@ -147,7 +183,10 @@ namespace {
}
return nullptr;
}
CREATE_GET_DECOMPOSING_ENTITY(Ifc4x1);
#endif
#ifdef HAS_SCHEMA_4x2
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc4x2::IfcRelDecomposes* decompose) {
Ifc4x2::IfcRelAggregates* aggr = decompose->as<Ifc4x2::IfcRelAggregates>();
if (aggr != nullptr) {
@@ -155,7 +194,10 @@ namespace {
}
return nullptr;
}
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<Ifc4x3_rc1::IfcRelAggregates>();
if (aggr != nullptr) {
@@ -163,7 +205,10 @@ namespace {
}
return nullptr;
}
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<Ifc4x3_rc2::IfcRelAggregates>();
if (aggr != nullptr) {
@@ -171,37 +216,47 @@ namespace {
}
return nullptr;
}
IfcUtil::IfcBaseEntity* get_RelatingObject(Ifc2x3::IfcRelDecomposes* decompose) {
return decompose->RelatingObject();
}
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);
CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc2);
#endif
}
IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBaseEntity* inst, bool include_openings) {
#ifdef HAS_SCHEMA_2x3
if (inst->as<Ifc2x3::IfcProduct>()) {
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->as<Ifc4x3_rc2::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x3_rc2::IfcProduct>(), include_openings);
} else if (inst->declaration().name() == "IfcProject") {
return nullptr;
} else {
throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
}
#endif
#ifdef HAS_SCHEMA_4
if (inst->as<Ifc4::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4::IfcProduct>(), include_openings);
}
#endif
#ifdef HAS_SCHEMA_4x1
if (inst->as<Ifc4x1::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x1::IfcProduct>(), include_openings);
}
#endif
#ifdef HAS_SCHEMA_4x2
if (inst->as<Ifc4x2::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x2::IfcProduct>(), include_openings);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc1
if (inst->as<Ifc4x3_rc1::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x3_rc1::IfcProduct>(), include_openings);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc2
if (inst->as<Ifc4x3_rc2::IfcProduct>()) {
return get_decomposing_entity_impl(inst->as<Ifc4x3_rc2::IfcProduct>(), include_openings);
}
#endif
if (inst->declaration().name() == "IfcProject") {
return nullptr;
}
throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
}
namespace {
@@ -223,21 +278,38 @@ namespace {
}
std::map<std::string, IfcUtil::IfcBaseEntity*> IfcGeom::Kernel::get_layers(IfcUtil::IfcBaseEntity* inst) {
#ifdef HAS_SCHEMA_2x3
if (inst->as<Ifc2x3::IfcProduct>()) {
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 if (inst->as<Ifc4x3_rc2::IfcProduct>()) {
return get_layers_impl<Ifc4x3_rc2>(inst->as<Ifc4x3_rc2::IfcProduct>());
} else {
throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
}
#endif
#ifdef HAS_SCHEMA_4
if (inst->as<Ifc4::IfcProduct>()) {
return get_layers_impl<Ifc4>(inst->as<Ifc4::IfcProduct>());
}
#endif
#ifdef HAS_SCHEMA_4x1
if (inst->as<Ifc4x1::IfcProduct>()) {
return get_layers_impl<Ifc4x1>(inst->as<Ifc4x1::IfcProduct>());
}
#endif
#ifdef HAS_SCHEMA_4x2
if (inst->as<Ifc4x2::IfcProduct>()) {
return get_layers_impl<Ifc4x2>(inst->as<Ifc4x2::IfcProduct>());
}
#endif
#ifdef HAS_SCHEMA_4x3_rc1
if (inst->as<Ifc4x3_rc1::IfcProduct>()) {
return get_layers_impl<Ifc4x3_rc1>(inst->as<Ifc4x3_rc1::IfcProduct>());
}
#endif
#ifdef HAS_SCHEMA_4x3_rc2
if (inst->as<Ifc4x3_rc2::IfcProduct>()) {
return get_layers_impl<Ifc4x3_rc2>(inst->as<Ifc4x3_rc2::IfcProduct>());
}
#endif
throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
}
bool IfcGeom::Kernel::is_manifold(const TopoDS_Shape& a) {
+12
View File
@@ -5,12 +5,24 @@
#include "../ifcgeom/IfcGeomIteratorSettings.h"
#include "../ifcgeom/IfcRepresentationShapeItem.h"
#ifdef HAS_SCHEMA_2x3
#include "../ifcparse/Ifc2x3.h"
#endif
#ifdef HAS_SCHEMA_4
#include "../ifcparse/Ifc4.h"
#endif
#ifdef HAS_SCHEMA_4x1
#include "../ifcparse/Ifc4x1.h"
#endif
#ifdef HAS_SCHEMA_4x2
#include "../ifcparse/Ifc4x2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc1
#include "../ifcparse/Ifc4x3_rc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc2
#include "../ifcparse/Ifc4x3_rc2.h"
#endif
#include <boost/function.hpp>
+106 -29
View File
@@ -3,23 +3,59 @@
#include <boost/algorithm/string/case_conv.hpp>
namespace IfcGeom {
#ifdef HAS_SCHEMA_2x3
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* tesselate_Ifc4x3_rc2(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
}
template <typename Fn, typename T>
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn_2x3, Fn fn_4, Fn fn_4x1, Fn fn_4x2, Fn fn_4x3_rc1, Fn fn_4x3_rc2, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
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)
{
// @todo an ugly hack to guarantee schemas are initialised.
try {
IfcParse::schema_by_name("IFC2X3");
@@ -27,41 +63,82 @@ IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn_2x3, Fn fn_4, Fn fn_4x1, Fn
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
#ifdef HAS_SCHEMA_2x3
if (schema_name_lower == "ifc2x3") {
return fn_2x3(shape, t);
} else if (schema_name_lower == "ifc4") {
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 if (schema_name_lower == "ifc4x3_rc2") {
return fn_4x3_rc2(shape, t);
} else {
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
}
#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_rx2
if (schema_name_lower == "ifc4x3_rc2") {
return fn_4x3_rc2(shape, t);
}
#endif
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,
IfcGeom::tesselate_Ifc4x1,
IfcGeom::tesselate_Ifc4x2,
IfcGeom::tesselate_Ifc4x3_rc1,
#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);
}
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,
IfcGeom::serialise_Ifc4x1,
IfcGeom::serialise_Ifc4x2,
IfcGeom::serialise_Ifc4x3_rc1,
#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);
}