mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
#842 IFC4X3 schema and some other schema init cruft
This commit is contained in:
@@ -459,7 +459,7 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
set(SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2")
|
||||
set(SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" "4x3_rc1")
|
||||
|
||||
if(COMPILE_SCHEMA)
|
||||
# @todo, this appears to be untested at the moment
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -477,6 +477,13 @@ Ifc4x2::IfcStyledItem* create_styled_item(Ifc4x2::IfcRepresentationItem* item, I
|
||||
style_assignments->push(style_assignment);
|
||||
return new Ifc4x2::IfcStyledItem(item, style_assignments, boost::none);
|
||||
}
|
||||
|
||||
Ifc4x3_rc1::IfcStyledItem* create_styled_item(Ifc4x3_rc1::IfcRepresentationItem* item, Ifc4x3_rc1::IfcPresentationStyleAssignment* style_assignment) {
|
||||
IfcEntityList::ptr style_assignments(new IfcEntityList);
|
||||
style_assignments->push(style_assignment);
|
||||
return new Ifc4x3_rc1::IfcStyledItem(item, style_assignments, boost::none);
|
||||
}
|
||||
|
||||
template <typename Schema>
|
||||
void IfcHierarchyHelper<Schema>::setSurfaceColour(typename Schema::IfcRepresentation* rep,
|
||||
typename Schema::IfcPresentationStyleAssignment* style_assignment)
|
||||
@@ -573,3 +580,4 @@ template IFC_PARSE_API class IfcHierarchyHelper<Ifc2x3>;
|
||||
template IFC_PARSE_API class IfcHierarchyHelper<Ifc4>;
|
||||
template IFC_PARSE_API class IfcHierarchyHelper<Ifc4x1>;
|
||||
template IFC_PARSE_API class IfcHierarchyHelper<Ifc4x2>;
|
||||
template IFC_PARSE_API class IfcHierarchyHelper<Ifc4x3_rc1>;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
#include "../ifcparse/Ifc4x1.h"
|
||||
#include "../ifcparse/Ifc4x2.h"
|
||||
#include "../ifcparse/Ifc4x3_rc1.h"
|
||||
|
||||
|
||||
#include "../ifcparse/IfcFile.h"
|
||||
@@ -65,6 +66,10 @@ namespace {
|
||||
return t->RelatingStructure();
|
||||
}
|
||||
|
||||
Ifc4x3_rc1::IfcObjectDefinition* get_parent_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t) {
|
||||
return t->RelatingStructure();
|
||||
}
|
||||
|
||||
IfcEntityList::ptr get_children_of_relation(IfcUtil::IfcBaseClass* t) {
|
||||
return *t->data().getArgument(
|
||||
t->declaration().as_entity()->attribute_index("RelatedElements")
|
||||
@@ -86,6 +91,11 @@ namespace {
|
||||
IfcEntityList::ptr get_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t) {
|
||||
return t->RelatedElements()->generalize();
|
||||
}
|
||||
|
||||
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t) {
|
||||
return t->RelatedElements()->generalize();
|
||||
}
|
||||
|
||||
void set_children_of_relation(IfcUtil::IfcBaseClass* t, IfcEntityList::ptr& cs) {
|
||||
IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument;
|
||||
attr->set(cs);
|
||||
@@ -110,6 +120,10 @@ namespace {
|
||||
void set_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
|
||||
t->setRelatedElements(cs->as<Ifc4x2::IfcProduct>());
|
||||
}
|
||||
|
||||
void set_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
|
||||
t->setRelatedElements(cs->as<Ifc4x3_rc1::IfcProduct>());
|
||||
}
|
||||
}
|
||||
template <typename Schema>
|
||||
class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
#include "../ifcparse/Ifc4x1.h"
|
||||
#include "../ifcparse/Ifc4x2.h"
|
||||
#include "../ifcparse/Ifc4x3_rc1.h"
|
||||
|
||||
double IfcParse::IfcSIPrefixToValue(const std::string& v) {
|
||||
if ( v == "EXA" ) return 1.e18;
|
||||
@@ -76,3 +77,4 @@ template double IfcParse::get_SI_equivalent<Ifc2x3>(typename Ifc2x3::IfcNamedUni
|
||||
template double IfcParse::get_SI_equivalent<Ifc4>(typename Ifc4::IfcNamedUnit* named_unit);
|
||||
template double IfcParse::get_SI_equivalent<Ifc4x1>(typename Ifc4x1::IfcNamedUnit* named_unit);
|
||||
template double IfcParse::get_SI_equivalent<Ifc4x2>(typename Ifc4x2::IfcNamedUnit* named_unit);
|
||||
template double IfcParse::get_SI_equivalent<Ifc4x3_rc1>(typename Ifc4x3_rc1::IfcNamedUnit* named_unit);
|
||||
|
||||
@@ -66,6 +66,7 @@ IfcParse::schema_definition::~schema_definition() {
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
#include "../ifcparse/Ifc4x1.h"
|
||||
#include "../ifcparse/Ifc4x2.h"
|
||||
#include "../ifcparse/Ifc4x3_rc1.h"
|
||||
|
||||
const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) {
|
||||
// TODO: initialize automatically somehow
|
||||
@@ -73,6 +74,7 @@ const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& n
|
||||
Ifc4::get_schema();
|
||||
Ifc4x1::get_schema();
|
||||
Ifc4x2::get_schema();
|
||||
Ifc4x3_rc1::get_schema();
|
||||
|
||||
std::map<std::string, const IfcParse::schema_definition*>::const_iterator it = schemas.find(name);
|
||||
if (it == schemas.end()) {
|
||||
|
||||
@@ -456,6 +456,12 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
||||
return helper_fn_create_shape<Ifc2x3>(settings, instance, representation);
|
||||
} else if (schema_name == "IFC4") {
|
||||
return helper_fn_create_shape<Ifc4>(settings, instance, representation);
|
||||
} else if (schema_name == "IFC4X1") {
|
||||
return helper_fn_create_shape<Ifc4x1>(settings, instance, representation);
|
||||
} else if (schema_name == "IFC4X2") {
|
||||
return helper_fn_create_shape<Ifc4x2>(settings, instance, representation);
|
||||
} else if (schema_name == "IFC4X3_RC1") {
|
||||
return helper_fn_create_shape<Ifc4x3_rc1>(settings, instance, representation);
|
||||
} else {
|
||||
throw IfcParse::IfcException("No geometry support for " + schema_name);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
|
||||
#include "../ifcparse/Ifc2x3.h"
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
#include "../ifcparse/Ifc4x1.h"
|
||||
#include "../ifcparse/Ifc4x2.h"
|
||||
#include "../ifcparse/Ifc4x3_rc1.h"
|
||||
#include "../ifcparse/IfcBaseClass.h"
|
||||
#include "../ifcparse/IfcFile.h"
|
||||
#include "../ifcparse/IfcSchema.h"
|
||||
|
||||
@@ -4,12 +4,14 @@ extern void init_XmlSerializerIfc2x3(XmlSerializerFactory::Factory*);
|
||||
extern void init_XmlSerializerIfc4(XmlSerializerFactory::Factory*);
|
||||
extern void init_XmlSerializerIfc4x1(XmlSerializerFactory::Factory*);
|
||||
extern void init_XmlSerializerIfc4x2(XmlSerializerFactory::Factory*);
|
||||
extern void init_XmlSerializerIfc4x3_rc1(XmlSerializerFactory::Factory*);
|
||||
|
||||
XmlSerializerFactory::Factory::Factory() {
|
||||
init_XmlSerializerIfc2x3(this);
|
||||
init_XmlSerializerIfc4(this);
|
||||
init_XmlSerializerIfc4x1(this);
|
||||
init_XmlSerializerIfc4x2(this);
|
||||
init_XmlSerializerIfc4x3_rc1(this);
|
||||
}
|
||||
|
||||
void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) {
|
||||
|
||||
Reference in New Issue
Block a user