Continue work on plug-in and tests

This commit is contained in:
Thomas Krijnen
2026-05-06 21:17:25 +02:00
parent 4670715ef3
commit 98ff457fd6
61 changed files with 16000 additions and 16377 deletions
+45 -6
View File
@@ -11,16 +11,17 @@ foreach(file ${IFCPARSE_CPP_FILES_ALL})
list(APPEND IFCPARSE_CPP_FILES "${file}")
endforeach()
list(REMOVE_ITEM IFCPARSE_CPP_FILES
${CMAKE_CURRENT_SOURCE_DIR}/schema_plugin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/alignment_helper.cpp
)
message(STATUS "SCHEMA_VERSIONS from ifcparse: ${SCHEMA_VERSIONS}")
foreach(schema ${SCHEMA_VERSIONS})
list(APPEND IFCPARSE_H_FILES
schemas/Ifc${schema}.h
schemas/Ifc${schema}-definitions.h
)
list(APPEND IFCPARSE_CPP_FILES
schemas/Ifc${schema}.cpp
schemas/Ifc${schema}-schema.cpp
)
endforeach()
list(APPEND IFCPARSE_H_FILES
@@ -34,7 +35,9 @@ list(APPEND IFCPARSE_CPP_FILES
set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES})
add_library(IfcParse ${IFCPARSE_FILES})
add_library(parse ALIAS IfcParse)
set_target_properties(IfcParse PROPERTIES
OUTPUT_NAME "ifcopenshell.parse"
)
target_compile_definitions(IfcParse PUBLIC ${SCHEMA_DEFINITIONS})
if(USE_MMAP)
target_compile_definitions(IfcParse PUBLIC USE_MMAP)
@@ -60,9 +63,45 @@ if(WITH_ROCKSDB)
endif()
endif()
if (NOT WASM_BUILD)
set(plugin_when_not_wasm plugin)
endif()
foreach(schema ${SCHEMA_VERSIONS})
set(SCHEMA_PLUGIN_TARGET parse_schema_ifc${schema})
set(SCHEMA_PLUGIN_SOURCES
schema_plugin.cpp
hierarchy_helper.i
schemas/Ifc${schema}.cpp
schemas/Ifc${schema}-schema.cpp
)
if(schema STREQUAL "4x3_add2")
list(APPEND SCHEMA_PLUGIN_SOURCES alignment_helper.cpp)
endif()
add_library(${SCHEMA_PLUGIN_TARGET} SHARED ${SCHEMA_PLUGIN_SOURCES})
target_compile_definitions(${SCHEMA_PLUGIN_TARGET} PRIVATE
IFC_SCHEMA_EXPORTS
BOOST_DLL_USE_STD_FS
IfcSchema=Ifc${schema}
)
target_link_libraries(${SCHEMA_PLUGIN_TARGET} PRIVATE ${plugin_when_not_wasm} IfcParse)
set_target_properties(${SCHEMA_PLUGIN_TARGET} PROPERTIES
OUTPUT_NAME "ifcopenshell.parse.schema.ifc${schema}"
)
if(WASM_BUILD)
target_link_options(${SCHEMA_PLUGIN_TARGET} PRIVATE "SHELL:-s SIDE_MODULE=1")
endif()
list(APPEND schema_libraries ${SCHEMA_PLUGIN_TARGET})
endforeach()
# CMake installation targets
install(FILES ${IFCPARSE_H_FILES}
DESTINATION ${INCLUDEDIR}/ifcparse
)
install(TARGETS IfcParse)
install(TARGETS IfcParse ${schema_libraries})
set(schema_libraries ${schema_libraries} PARENT_SCOPE)
-3
View File
@@ -32,8 +32,6 @@ static const double PI = boost::math::constants::pi<double>();
#include <boost/math/quadrature/trapezoidal.hpp>
#ifdef HAS_SCHEMA_4x3_add2
// sets the segment name like ("H1" for horizontal, "V1" for vertical, "C1" for cant)
void _name_segments(const char* prefix, std::vector<Ifc4x3_add2::IfcObjectDefinition>& segments) {
unsigned idx = 1;
@@ -886,4 +884,3 @@ std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignme
}
return result;
}
#endif
+7 -12
View File
@@ -29,31 +29,26 @@
#include "ifc_parse_api.h"
#include "logger.h"
#ifdef HAS_SCHEMA_4x3_add2
#include "schemas/Ifc4x3_add2.h"
#endif
#include "hierarchy_helper.h"
#include "schemas/Ifc4x3_add2.h"
#ifdef HAS_SCHEMA_4x3_add2
//
// alignment helper methods
//
// creates a horizontal alignment from a list of PI points and curve radii. if include_geometry is true, the geometric representations are created, otherwise only business logic is created
IFC_PARSE_API Ifc4x3_add2::IfcAlignment addHorizontalAlignment(hierarchy_helper<Ifc4x3_add2>& model, const std::string& alignment_name, const std::vector<std::pair<double, double>>& points, const std::vector<double>& radii, bool include_geometry = true);
IFC_SCHEMA_API Ifc4x3_add2::IfcAlignment addHorizontalAlignment(hierarchy_helper<Ifc4x3_add2>& model, const std::string& alignment_name, const std::vector<std::pair<double, double>>& points, const std::vector<double>& radii, bool include_geometry = true);
// creates a horizontal and vertical alignment from a list of PI points, curve radii, and VPI points and vertical curve lengths. if include_geometry is true, the geometric representations are created, otherwise only business logic is created
IFC_PARSE_API Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_add2>& model, const std::string& alignment_name, const std::vector<std::pair<double, double>>& points, const std::vector<double>& radii, const std::vector<std::pair<double, double>>& vertical_points, const std::vector<double>& vertical_curve_lengths, bool include_geometry = true);
IFC_SCHEMA_API Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_add2>& model, const std::string& alignment_name, const std::vector<std::pair<double, double>>& points, const std::vector<double>& radii, const std::vector<std::pair<double, double>>& vertical_points, const std::vector<double>& vertical_curve_lengths, bool include_geometry = true);
// Maps horizontal alignment business logic to geometry.
// Bloss curves have two geometry elements for one horizontal alignment segment. That is the reason for returning a pair.
// Typically the first element of the pair will have the geometry and the second element will be nullptr
IFC_PARSE_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment);
IFC_PARSE_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment);
IFC_PARSE_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment);
IFC_PARSE_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment);
#endif
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment);
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment);
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment);
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment);
#endif
+72 -407
View File
@@ -32,334 +32,62 @@
#include "logger.h"
#include <map>
#ifdef HAS_SCHEMA_2x3
#include "schemas/Ifc2x3.h"
#endif
#ifdef HAS_SCHEMA_4
#include "schemas/Ifc4.h"
#endif
#ifdef HAS_SCHEMA_4x1
#include "schemas/Ifc4x1.h"
#endif
#ifdef HAS_SCHEMA_4x2
#include "schemas/Ifc4x2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc1
#include "schemas/Ifc4x3_rc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc2
#include "schemas/Ifc4x3_rc2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc3
#include "schemas/Ifc4x3_rc3.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc4
#include "schemas/Ifc4x3_rc4.h"
#endif
#ifdef HAS_SCHEMA_4x3
#include "schemas/Ifc4x3.h"
#endif
#ifdef HAS_SCHEMA_4x3_tc1
#include "schemas/Ifc4x3_tc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add1
#include "schemas/Ifc4x3_add1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add2
#include "schemas/Ifc4x3_add2.h"
#endif
#include <type_traits>
#include <vector>
#include "file.h"
#include "global_id.h"
namespace {
#ifdef HAS_SCHEMA_2x3
Ifc2x3::IfcObjectDefinition get_parent_of_relation(const Ifc2x3::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
namespace ifcopenshell::hierarchy_detail {
inline const char* parent_attribute_name(const ifcopenshell::declaration& declaration) {
return declaration.name() == "IfcRelContainedInSpatialStructure" ? "RelatingStructure" : "RelatingObject";
}
std::vector<express::Base> get_children_of_relation(const Ifc2x3::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
inline const char* children_attribute_name(const ifcopenshell::declaration& declaration) {
return declaration.name() == "IfcRelContainedInSpatialStructure" ? "RelatedElements" : "RelatedObjects";
}
std::vector<express::Base> get_children_of_relation(const Ifc2x3::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
template <typename Relation>
express::Base get_parent_of_relation(const Relation& relation) {
return relation.template as<express::Entity>().get(parent_attribute_name(relation.declaration()));
}
void set_children_of_relation(Ifc2x3::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc2x3::IfcProduct>(children));
template <typename Relation>
std::vector<express::Base> get_children_of_relation(const Relation& relation) {
return relation.template as<express::Entity>().get(children_attribute_name(relation.declaration()));
}
void set_children_of_relation(Ifc2x3::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc2x3::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4
Ifc4::IfcObjectDefinition get_parent_of_relation(const Ifc4::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
template <typename Relation>
void set_children_of_relation(Relation& relation, std::vector<express::Base>& children) {
relation.set_attribute_value(children_attribute_name(relation.declaration()), children);
}
std::vector<express::Base> get_children_of_relation(const Ifc4::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
template <typename Schema, typename = void>
struct styled_item_accepts_presentation_style : std::false_type {};
std::vector<express::Base> get_children_of_relation(const Ifc4::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4::IfcProduct>(children));
}
void set_children_of_relation(Ifc4::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x1
Ifc4x1::IfcObjectDefinition get_parent_of_relation(const Ifc4x1::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x1::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x1::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x1::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x1::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x1::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x1::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x2
Ifc4x2::IfcObjectDefinition get_parent_of_relation(const Ifc4x2::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x2::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x2::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x2::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x2::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x2::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_rc1
Ifc4x3_rc1::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_rc1::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc1::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc1::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_rc1::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_rc1::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_rc1::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_rc2
Ifc4x3_rc2::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_rc2::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc2::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc2::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_rc2::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_rc2::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_rc2::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_rc2::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_rc3
Ifc4x3_rc3::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_rc3::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc3::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc3::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_rc3::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_rc3::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_rc3::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_rc3::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_rc4
Ifc4x3_rc4::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_rc4::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc4::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_rc4::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_rc4::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_rc4::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_rc4::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_rc4::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3
Ifc4x3::IfcObjectDefinition get_parent_of_relation(const Ifc4x3::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_tc1
Ifc4x3_tc1::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_tc1::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_tc1::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_tc1::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_tc1::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_tc1::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_tc1::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_tc1::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_add1
Ifc4x3_add1::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_add1::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_add1::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_add1::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_add1::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_add1::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_add1::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_add1::IfcObjectDefinition>(children));
}
#endif
#ifdef HAS_SCHEMA_4x3_add2
Ifc4x3_add2::IfcObjectDefinition get_parent_of_relation(const Ifc4x3_add2::IfcRelContainedInSpatialStructure& relation) {
return relation.RelatingStructure();
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_add2::IfcRelContainedInSpatialStructure& relation) {
return cast_vector<express::Base>(relation.RelatedElements());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_add2::IfcRelAggregates& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
std::vector<express::Base> get_children_of_relation(const Ifc4x3_add2::IfcRelNests& relation) {
return cast_vector<express::Base>(relation.RelatedObjects());
}
void set_children_of_relation(Ifc4x3_add2::IfcRelContainedInSpatialStructure& relation, std::vector<express::Base>& children) {
relation.setRelatedElements(cast_vector<Ifc4x3_add2::IfcProduct>(children));
}
void set_children_of_relation(Ifc4x3_add2::IfcRelAggregates& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_add2::IfcObjectDefinition>(children));
}
void set_children_of_relation(Ifc4x3_add2::IfcRelNests& relation, std::vector<express::Base>& children) {
relation.setRelatedObjects(cast_vector<Ifc4x3_add2::IfcObjectDefinition>(children));
}
#endif
express::Base get_parent_of_relation(const express::Base& relation) {
return relation.as<express::Entity>().get("RelatingObject");
}
std::vector<express::Base> get_children_of_relation(const express::Base& relation) {
return relation.as<express::Entity>().get("RelatedElements");
}
void set_children_of_relation(express::Base& relation, std::vector<express::Base>& children) {
return relation.set_attribute_value("RelatedElements", children);
}
} // namespace
template <typename Schema>
class IFC_PARSE_API hierarchy_helper : public ifcopenshell::file {
struct styled_item_accepts_presentation_style<Schema,
std::void_t<decltype(std::declval<typename Schema::IfcStyledItem&>().setStyles(
std::declval<std::vector<typename Schema::IfcPresentationStyle>>()))>> : std::true_type {};
template <typename Schema, bool DirectStyle = styled_item_accepts_presentation_style<Schema>::value>
struct surface_style_type_selector {
using type = typename Schema::IfcPresentationStyleAssignment;
};
template <typename Schema>
struct surface_style_type_selector<Schema, true> {
using type = typename Schema::IfcPresentationStyle;
};
template <typename Schema>
using surface_style_type = typename surface_style_type_selector<Schema>::type;
} // namespace ifcopenshell::hierarchy_detail
template <typename Schema>
class IFC_SCHEMA_API hierarchy_helper : public ifcopenshell::file {
public:
hierarchy_helper() : ifcopenshell::file(&Schema::get_schema()) {}
@@ -444,10 +172,10 @@ class IFC_PARSE_API hierarchy_helper : public ifcopenshell::file {
bool found = false;
for (auto& rel : li) {
try {
if (get_parent_of_relation(rel) == relating_object) {
auto products = get_children_of_relation(rel);
if (ifcopenshell::hierarchy_detail::get_parent_of_relation(rel) == relating_object) {
auto products = ifcopenshell::hierarchy_detail::get_children_of_relation(rel);
products.push_back(add_entity(related_object));
set_children_of_relation(rel, products);
ifcopenshell::hierarchy_detail::set_children_of_relation(rel, products);
found = true;
break;
}
@@ -533,101 +261,38 @@ class IFC_PARSE_API hierarchy_helper : public ifcopenshell::file {
std::map<std::string, typename Schema::IfcGeometricRepresentationContext> contexts_;
};
#ifdef HAS_SCHEMA_2x3
IFC_PARSE_API Ifc2x3::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc2x3>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc2x3::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc2x3>& model, const Ifc2x3::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc2x3::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc2x3>& model, const Ifc2x3::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc2x3>& model, const Ifc2x3::IfcProductRepresentation& shape, const Ifc2x3::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc2x3>& model, const Ifc2x3::IfcRepresentation& shape, const Ifc2x3::IfcPresentationStyleAssignment& style_assignment);
#endif
template <typename Schema>
IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<Schema>
addStyleAssignment(hierarchy_helper<Schema>& model, double red, double green, double blue, double alpha = 1.0);
#ifdef HAS_SCHEMA_4
IFC_PARSE_API Ifc4::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4>& model, const Ifc4::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4>& model, const Ifc4::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4>& model, const Ifc4::IfcProductRepresentation& shape, const Ifc4::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4>& model, const Ifc4::IfcRepresentation& shape, const Ifc4::IfcPresentationStyleAssignment& style_assignment);
#endif
template <typename Schema>
IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<Schema>
setSurfaceColour(hierarchy_helper<Schema>& model,
const typename Schema::IfcProductRepresentation& shape,
double red,
double green,
double blue,
double alpha = 1.0);
#ifdef HAS_SCHEMA_4x1
IFC_PARSE_API Ifc4x1::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x1>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x1>& model, const Ifc4x1::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x1>& model, const Ifc4x1::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x1>& model, const Ifc4x1::IfcProductRepresentation& shape, const Ifc4x1::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x1>& model, const Ifc4x1::IfcRepresentation& shape, const Ifc4x1::IfcPresentationStyleAssignment& style_assignment);
#endif
template <typename Schema>
IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<Schema>
setSurfaceColour(hierarchy_helper<Schema>& model,
const typename Schema::IfcRepresentation& shape,
double red,
double green,
double blue,
double alpha = 1.0);
#ifdef HAS_SCHEMA_4x2
IFC_PARSE_API Ifc4x2::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x2>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x2>& model, const Ifc4x2::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x2>& model, const Ifc4x2::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x2>& model, const Ifc4x2::IfcProductRepresentation& shape, const Ifc4x2::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x2>& model, const Ifc4x2::IfcRepresentation& shape, const Ifc4x2::IfcPresentationStyleAssignment& style_assignment);
#endif
template <typename Schema>
IFC_SCHEMA_API void setSurfaceColour(
hierarchy_helper<Schema>& model,
const typename Schema::IfcProductRepresentation& shape,
const ifcopenshell::hierarchy_detail::surface_style_type<Schema>& style);
#ifdef HAS_SCHEMA_4x3_rc1
IFC_PARSE_API Ifc4x3_rc1::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x3_rc1>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& model, const Ifc4x3_rc1::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& model, const Ifc4x3_rc1::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& model, const Ifc4x3_rc1::IfcProductRepresentation& shape, const Ifc4x3_rc1::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& model, const Ifc4x3_rc1::IfcRepresentation& shape, const Ifc4x3_rc1::IfcPresentationStyleAssignment& style_assignment);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
IFC_PARSE_API Ifc4x3_rc2::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x3_rc2>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& model, const Ifc4x3_rc2::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& model, const Ifc4x3_rc2::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& model, const Ifc4x3_rc2::IfcProductRepresentation& shape, const Ifc4x3_rc2::IfcPresentationStyleAssignment& style_assignment);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& model, const Ifc4x3_rc2::IfcRepresentation& shape, const Ifc4x3_rc2::IfcPresentationStyleAssignment& style_assignment);
#endif
#ifdef HAS_SCHEMA_4x3_rc3
IFC_PARSE_API Ifc4x3_rc3::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_rc3>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& model, const Ifc4x3_rc3::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& model, const Ifc4x3_rc3::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& model, const Ifc4x3_rc3::IfcProductRepresentation& shape, const Ifc4x3_rc3::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& model, const Ifc4x3_rc3::IfcRepresentation& shape, const Ifc4x3_rc3::IfcPresentationStyle& style);
#endif
#ifdef HAS_SCHEMA_4x3_rc4
IFC_PARSE_API Ifc4x3_rc4::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_rc4>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc4::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& model, const Ifc4x3_rc4::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_rc4::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& model, const Ifc4x3_rc4::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& model, const Ifc4x3_rc4::IfcProductRepresentation& shape, const Ifc4x3_rc4::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& model, const Ifc4x3_rc4::IfcRepresentation& shape, const Ifc4x3_rc4::IfcPresentationStyle& style);
#endif
#ifdef HAS_SCHEMA_4x3
IFC_PARSE_API Ifc4x3::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3>& model, const Ifc4x3::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3>& model, const Ifc4x3::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3>& model, const Ifc4x3::IfcProductRepresentation& shape, const Ifc4x3::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3>& model, const Ifc4x3::IfcRepresentation& shape, const Ifc4x3::IfcPresentationStyle& style);
#endif
#ifdef HAS_SCHEMA_4x3_tc1
IFC_PARSE_API Ifc4x3_tc1::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_tc1>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_tc1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& model, const Ifc4x3_tc1::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_tc1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& model, const Ifc4x3_tc1::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& model, const Ifc4x3_tc1::IfcProductRepresentation& shape, const Ifc4x3_tc1::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& model, const Ifc4x3_tc1::IfcRepresentation& shape, const Ifc4x3_tc1::IfcPresentationStyle& style);
#endif
#ifdef HAS_SCHEMA_4x3_add1
IFC_PARSE_API Ifc4x3_add1::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_add1>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_add1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& model, const Ifc4x3_add1::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_add1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& model, const Ifc4x3_add1::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& model, const Ifc4x3_add1::IfcProductRepresentation& shape, const Ifc4x3_add1::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& model, const Ifc4x3_add1::IfcRepresentation& shape, const Ifc4x3_add1::IfcPresentationStyle& style);
#endif
#ifdef HAS_SCHEMA_4x3_add2
IFC_PARSE_API Ifc4x3_add2::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_add2>& model, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_add2::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcProductRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API Ifc4x3_add2::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcRepresentation& shape, double red, double green, double blue, double alpha = 1.0);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcProductRepresentation& shape, const Ifc4x3_add2::IfcPresentationStyle& style);
IFC_PARSE_API void setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcRepresentation& shape, const Ifc4x3_add2::IfcPresentationStyle& style);
#endif
template <typename Schema>
IFC_SCHEMA_API void setSurfaceColour(
hierarchy_helper<Schema>& model,
const typename Schema::IfcRepresentation& shape,
const ifcopenshell::hierarchy_detail::surface_style_type<Schema>& style);
#endif
@@ -31,6 +31,19 @@
using namespace std::string_literals;
namespace {
template <typename Person>
auto set_person_identification(Person& person, const std::string& value, int)
-> decltype(person.setIdentification(value), void()) {
person.setIdentification(value);
}
template <typename Person>
void set_person_identification(Person& person, const std::string& value, ...) {
person.setId(value);
}
} // namespace
template <typename Schema>
typename Schema::IfcAxis2Placement3D hierarchy_helper<Schema>::addPlacement3d(
double ox, double oy, double oz, double zx, double zy, double zz, double xx, double xy, double xz) {
@@ -77,14 +90,7 @@ typename Schema::IfcLocalPlacement hierarchy_helper<Schema>::addLocalPlacement(t
template <typename Schema>
typename Schema::IfcOwnerHistory hierarchy_helper<Schema>::addOwnerHistory() {
typename Schema::IfcPerson person = create<typename Schema::IfcPerson>();
#ifdef HAS_SCHEMA_2x3
if constexpr (std::is_same_v<Schema, Ifc2x3>) {
person.setId("");
} else
#endif
{
person.setIdentification("");
}
set_person_identification(person, "", 0);
auto organization = create<typename Schema::IfcOrganization>();
organization.setName("IfcOpenShell");
@@ -486,451 +492,92 @@ typename Schema::IfcSurfaceStyle getSurfaceStyle(hierarchy_helper<Schema>& file,
}
template <typename Schema>
typename Schema::IfcPresentationStyleAssignment addStyleAssignment_2x3(hierarchy_helper<Schema>& file, double r, double g, double b, double a = 1.0) {
ifcopenshell::hierarchy_detail::surface_style_type<Schema>
addStyleAssignment(hierarchy_helper<Schema>& file, double r, double g, double b, double a) {
auto surface_style = getSurfaceStyle<Schema>(file, r, g, b, a);
auto style_assignment = file.template create<typename Schema::IfcPresentationStyleAssignment>();
style_assignment.setStyles(std::vector<typename Schema::IfcPresentationStyleSelect>{surface_style});
return style_assignment;
if constexpr (ifcopenshell::hierarchy_detail::styled_item_accepts_presentation_style<Schema>::value) {
return surface_style;
} else {
auto style_assignment = file.template create<typename Schema::IfcPresentationStyleAssignment>();
style_assignment.setStyles(std::vector<typename Schema::IfcPresentationStyleSelect>{surface_style});
return style_assignment;
}
}
namespace {
template <typename Schema, typename = void>
struct styled_item_accepts_style_assignment_select : std::false_type {};
template <typename Schema>
struct styled_item_accepts_style_assignment_select<Schema,
std::void_t<typename Schema::IfcStyleAssignmentSelect>> : std::true_type {};
template <typename Schema>
typename Schema::IfcStyledItem create_styled_item(
ifcopenshell::file* file,
const typename Schema::IfcRepresentationItem& item,
const ifcopenshell::hierarchy_detail::surface_style_type<Schema>& style) {
auto sitem = file->template create<typename Schema::IfcStyledItem>();
sitem.setItem(item);
if constexpr (ifcopenshell::hierarchy_detail::styled_item_accepts_presentation_style<Schema>::value) {
sitem.setStyles(std::vector<typename Schema::IfcPresentationStyle>{style});
} else if constexpr (styled_item_accepts_style_assignment_select<Schema>::value) {
sitem.setStyles(std::vector<typename Schema::IfcStyleAssignmentSelect>{style});
} else {
sitem.setStyles(std::vector<typename Schema::IfcPresentationStyleAssignment>{style});
}
return sitem;
}
} // namespace
template <typename Schema>
ifcopenshell::hierarchy_detail::surface_style_type<Schema>
setSurfaceColour(hierarchy_helper<Schema>& file,
const typename Schema::IfcProductRepresentation& shape,
double r,
double g,
double b,
double a) {
auto style = addStyleAssignment<Schema>(file, r, g, b, a);
setSurfaceColour(file, shape, style);
return style;
}
template <typename Schema>
typename Schema::IfcPresentationStyle addStyleAssignment_4x3(hierarchy_helper<Schema>& file, double r, double g, double b, double a = 1.0) {
return getSurfaceStyle<Schema>(file, r, g, b, a);
ifcopenshell::hierarchy_detail::surface_style_type<Schema>
setSurfaceColour(hierarchy_helper<Schema>& file,
const typename Schema::IfcRepresentation& shape,
double r,
double g,
double b,
double a) {
auto style = addStyleAssignment<Schema>(file, r, g, b, a);
setSurfaceColour(file, shape, style);
return style;
}
template <typename Schema>
typename Schema::IfcPresentationStyleAssignment setSurfaceColour_2x3(hierarchy_helper<Schema>& file, typename Schema::IfcProductRepresentation shape, double r, double g, double b, double a) {
typename Schema::IfcPresentationStyleAssignment style_assignment = addStyleAssignment_2x3(file, r, g, b, a);
setSurfaceColour_2x3(file, shape, style_assignment);
return style_assignment;
}
template <typename Schema>
typename Schema::IfcPresentationStyle setSurfaceColour_4x3(hierarchy_helper<Schema>& file, typename Schema::IfcProductRepresentation shape, double r, double g, double b, double a) {
typename Schema::IfcPresentationStyle style_assignment = addStyleAssignment_4x3(file, r, g, b, a);
setSurfaceColour_4x3(file, shape, style_assignment);
return style_assignment;
}
template <typename Schema>
typename Schema::IfcPresentationStyleAssignment setSurfaceColour_2x3(hierarchy_helper<Schema>& file, typename Schema::IfcRepresentation shape, double r, double g, double b, double a) {
typename Schema::IfcPresentationStyleAssignment style_assignment = addStyleAssignment_2x3(file, r, g, b, a);
setSurfaceColour_2x3(file, shape, style_assignment);
return style_assignment;
}
template <typename Schema>
typename Schema::IfcPresentationStyle setSurfaceColour_4x3(hierarchy_helper<Schema>& file, typename Schema::IfcRepresentation shape, double r, double g, double b, double a) {
typename Schema::IfcPresentationStyle style_assignment = addStyleAssignment_4x3(file, r, g, b, a);
setSurfaceColour_4x3(file, shape, style_assignment);
return style_assignment;
}
template <typename Schema>
void setSurfaceColour_2x3(hierarchy_helper<Schema>& file, typename Schema::IfcProductRepresentation shape, typename Schema::IfcPresentationStyleAssignment style_assignment) {
void setSurfaceColour(
hierarchy_helper<Schema>& file,
const typename Schema::IfcProductRepresentation& shape,
const ifcopenshell::hierarchy_detail::surface_style_type<Schema>& style) {
auto reps = shape.Representations();
for (auto& rep : reps) {
setSurfaceColour_2x3(file, rep, style_assignment);
setSurfaceColour(file, rep, style);
}
}
template <typename Schema>
void setSurfaceColour_4x3(hierarchy_helper<Schema>& file, typename Schema::IfcProductRepresentation shape, typename Schema::IfcPresentationStyle style) {
auto reps = shape.Representations();
for (auto& rep : reps) {
setSurfaceColour_4x3(file, rep, style);
}
}
#ifdef HAS_SCHEMA_2x3
Ifc2x3::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc2x3::IfcRepresentationItem& item, const Ifc2x3::IfcPresentationStyleAssignment& style_assignment) {
auto sitem = file->create<Ifc2x3::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc2x3::IfcPresentationStyleAssignment>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4
Ifc4::IfcStyledItem create_styled_item(ifcopenshell::file* file, Ifc4::IfcRepresentationItem item, Ifc4::IfcPresentationStyleAssignment style_assignment) {
auto sitem = file->create<Ifc4::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4::IfcStyleAssignmentSelect>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x1
Ifc4x1::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x1::IfcRepresentationItem& item, const Ifc4x1::IfcPresentationStyleAssignment& style_assignment) {
auto sitem = file->create<Ifc4x1::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x1::IfcStyleAssignmentSelect>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x2
Ifc4x2::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x2::IfcRepresentationItem& item, const Ifc4x2::IfcPresentationStyleAssignment& style_assignment) {
auto sitem = file->create<Ifc4x2::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x2::IfcStyleAssignmentSelect>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_rc1
Ifc4x3_rc1::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_rc1::IfcRepresentationItem& item, const Ifc4x3_rc1::IfcPresentationStyleAssignment& style_assignment) {
auto sitem = file->create<Ifc4x3_rc1::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_rc1::IfcStyleAssignmentSelect>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_rc2
Ifc4x3_rc2::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_rc2::IfcRepresentationItem& item, const Ifc4x3_rc2::IfcPresentationStyleAssignment& style_assignment) {
auto sitem = file->create<Ifc4x3_rc2::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_rc2::IfcStyleAssignmentSelect>{style_assignment});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_rc3
Ifc4x3_rc3::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_rc3::IfcRepresentationItem& item, const Ifc4x3_rc3::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3_rc3::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_rc3::IfcPresentationStyle>{style});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_rc4
Ifc4x3_rc4::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_rc4::IfcRepresentationItem& item, const Ifc4x3_rc4::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3_rc4::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_rc4::IfcPresentationStyle>{style});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3
Ifc4x3::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3::IfcRepresentationItem& item, const Ifc4x3::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3::IfcPresentationStyle>{style});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_tc1
Ifc4x3_tc1::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_tc1::IfcRepresentationItem& item, const Ifc4x3_tc1::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3_tc1::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_tc1::IfcPresentationStyle>{style});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_add1
Ifc4x3_add1::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_add1::IfcRepresentationItem& item, const Ifc4x3_add1::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3_add1::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_add1::IfcPresentationStyle>{style});
return sitem;
}
#endif
#ifdef HAS_SCHEMA_4x3_add2
Ifc4x3_add2::IfcStyledItem create_styled_item(ifcopenshell::file* file, const Ifc4x3_add2::IfcRepresentationItem& item, const Ifc4x3_add2::IfcPresentationStyle& style) {
auto sitem = file->create<Ifc4x3_add2::IfcStyledItem>();
sitem.setItem(item);
sitem.setStyles(std::vector<Ifc4x3_add2::IfcPresentationStyle>{style});
return sitem;
}
#endif
template <typename Schema>
void setSurfaceColour_2x3(hierarchy_helper<Schema>& file, typename Schema::IfcRepresentation rep, typename Schema::IfcPresentationStyleAssignment style_assignment) {
void setSurfaceColour(
hierarchy_helper<Schema>& file,
const typename Schema::IfcRepresentation& rep,
const ifcopenshell::hierarchy_detail::surface_style_type<Schema>& style) {
auto items = rep.Items();
for (auto& item : items) {
create_styled_item(&file, item, style_assignment);
create_styled_item<Schema>(&file, item, style);
}
}
template <typename Schema>
void setSurfaceColour_4x3(hierarchy_helper<Schema>& file, typename Schema::IfcRepresentation rep, typename Schema::IfcPresentationStyle style) {
// @todo is there still a difference here?
auto items = rep.Items();
for (auto& item : items) {
create_styled_item(&file, item, style);
}
}
#ifdef HAS_SCHEMA_2x3
Ifc2x3::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc2x3>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc2x3::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc2x3>& file, const Ifc2x3::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc2x3::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc2x3>& file, const Ifc2x3::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc2x3>& file, const Ifc2x3::IfcProductRepresentation& shape, const Ifc2x3::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc2x3>& file, const Ifc2x3::IfcRepresentation& shape, const Ifc2x3::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4
Ifc4::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc4::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4>& file, Ifc4::IfcProductRepresentation shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc4::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4>& file, Ifc4::IfcRepresentation shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4>& file, Ifc4::IfcProductRepresentation shape, Ifc4::IfcPresentationStyleAssignment style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc4>& file, Ifc4::IfcRepresentation shape, Ifc4::IfcPresentationStyleAssignment style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4x1
Ifc4x1::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x1>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc4x1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x1>& file, const Ifc4x1::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc4x1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x1>& file, const Ifc4x1::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x1>& file, const Ifc4x1::IfcProductRepresentation& shape, const Ifc4x1::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc4x1>& file, const Ifc4x1::IfcRepresentation& shape, const Ifc4x1::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4x2
Ifc4x2::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x2>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc4x2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x2>& file, const Ifc4x2::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc4x2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x2>& file, const Ifc4x2::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x2>& file, const Ifc4x2::IfcProductRepresentation& shape, const Ifc4x2::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc4x2>& file, const Ifc4x2::IfcRepresentation& shape, const Ifc4x2::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc1
Ifc4x3_rc1::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x3_rc1>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc4x3_rc1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& file, const Ifc4x3_rc1::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc4x3_rc1::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& file, const Ifc4x3_rc1::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& file, const Ifc4x3_rc1::IfcProductRepresentation& shape, const Ifc4x3_rc1::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc1>& file, const Ifc4x3_rc1::IfcRepresentation& shape, const Ifc4x3_rc1::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc2
Ifc4x3_rc2::IfcPresentationStyleAssignment addStyleAssignment(hierarchy_helper<Ifc4x3_rc2>& file, double r, double g, double b, double a) {
return addStyleAssignment_2x3(file, r, g, b, a);
}
Ifc4x3_rc2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& file, const Ifc4x3_rc2::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
Ifc4x3_rc2::IfcPresentationStyleAssignment setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& file, const Ifc4x3_rc2::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_2x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& file, const Ifc4x3_rc2::IfcProductRepresentation& shape, const Ifc4x3_rc2::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc2>& file, const Ifc4x3_rc2::IfcRepresentation& shape, const Ifc4x3_rc2::IfcPresentationStyleAssignment& style_assignment) {
setSurfaceColour_2x3(file, shape, style_assignment);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc3
Ifc4x3_rc3::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_rc3>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3_rc3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& file, const Ifc4x3_rc3::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3_rc3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& file, const Ifc4x3_rc3::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& file, const Ifc4x3_rc3::IfcProductRepresentation& shape, const Ifc4x3_rc3::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc3>& file, const Ifc4x3_rc3::IfcRepresentation& shape, const Ifc4x3_rc3::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
#ifdef HAS_SCHEMA_4x3_rc4
Ifc4x3_rc4::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_rc4>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3_rc4::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& file, const Ifc4x3_rc4::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3_rc4::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& file, const Ifc4x3_rc4::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& file, const Ifc4x3_rc4::IfcProductRepresentation& shape, const Ifc4x3_rc4::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_rc4>& file, const Ifc4x3_rc4::IfcRepresentation& shape, const Ifc4x3_rc4::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
#ifdef HAS_SCHEMA_4x3
Ifc4x3::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3>& file, const Ifc4x3::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3>& file, const Ifc4x3::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3>& file, const Ifc4x3::IfcProductRepresentation& shape, const Ifc4x3::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3>& file, const Ifc4x3::IfcRepresentation& shape, const Ifc4x3::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
#ifdef HAS_SCHEMA_4x3_tc1
Ifc4x3_tc1::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_tc1>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3_tc1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& file, const Ifc4x3_tc1::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3_tc1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& file, const Ifc4x3_tc1::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& file, const Ifc4x3_tc1::IfcProductRepresentation& shape, const Ifc4x3_tc1::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_tc1>& file, const Ifc4x3_tc1::IfcRepresentation& shape, const Ifc4x3_tc1::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
#ifdef HAS_SCHEMA_4x3_add1
Ifc4x3_add1::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_add1>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3_add1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& file, const Ifc4x3_add1::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3_add1::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& file, const Ifc4x3_add1::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& file, const Ifc4x3_add1::IfcProductRepresentation& shape, const Ifc4x3_add1::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_add1>& file, const Ifc4x3_add1::IfcRepresentation& shape, const Ifc4x3_add1::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
#ifdef HAS_SCHEMA_4x3_add2
Ifc4x3_add2::IfcPresentationStyle addStyleAssignment(hierarchy_helper<Ifc4x3_add2>& file, double r, double g, double b, double a) {
return addStyleAssignment_4x3(file, r, g, b, a);
}
Ifc4x3_add2::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcProductRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
Ifc4x3_add2::IfcPresentationStyle setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcRepresentation& shape, double r, double g, double b, double a) {
return setSurfaceColour_4x3(file, shape, r, g, b, a);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcProductRepresentation& shape, const Ifc4x3_add2::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
void setSurfaceColour(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcRepresentation& shape, const Ifc4x3_add2::IfcPresentationStyle& style) {
setSurfaceColour_4x3(file, shape, style);
}
#endif
template <typename Schema>
typename Schema::IfcProductDefinitionShape hierarchy_helper<Schema>::addMappedItem(
typename Schema::IfcShapeRepresentation rep,
@@ -1071,39 +718,35 @@ typename Schema::IfcGeometricRepresentationSubContext hierarchy_helper<Schema>::
return rep_subcontext;
}
#ifdef HAS_SCHEMA_2x3
template IFC_PARSE_API class hierarchy_helper<Ifc2x3>;
#endif
#ifdef HAS_SCHEMA_4
template IFC_PARSE_API class hierarchy_helper<Ifc4>;
#endif
#ifdef HAS_SCHEMA_4x1
template IFC_PARSE_API class hierarchy_helper<Ifc4x1>;
#endif
#ifdef HAS_SCHEMA_4x2
template IFC_PARSE_API class hierarchy_helper<Ifc4x2>;
#endif
#ifdef HAS_SCHEMA_4x3_rc1
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_rc1>;
#endif
#ifdef HAS_SCHEMA_4x3_rc2
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_rc2>;
#endif
#ifdef HAS_SCHEMA_4x3_rc3
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_rc3>;
#endif
#ifdef HAS_SCHEMA_4x3_rc4
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_rc4>;
#endif
#ifdef HAS_SCHEMA_4x3
template IFC_PARSE_API class hierarchy_helper<Ifc4x3>;
#endif
#ifdef HAS_SCHEMA_4x3_tc1
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_tc1>;
#endif
#ifdef HAS_SCHEMA_4x3_add1
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_add1>;
#endif
#ifdef HAS_SCHEMA_4x3_add2
template IFC_PARSE_API class hierarchy_helper<Ifc4x3_add2>;
#endif
template IFC_SCHEMA_API class hierarchy_helper<IfcSchema>;
template IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<IfcSchema>
addStyleAssignment<IfcSchema>(hierarchy_helper<IfcSchema>&, double, double, double, double);
template IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<IfcSchema>
setSurfaceColour<IfcSchema>(
hierarchy_helper<IfcSchema>&,
const IfcSchema::IfcProductRepresentation&,
double,
double,
double,
double);
template IFC_SCHEMA_API ifcopenshell::hierarchy_detail::surface_style_type<IfcSchema>
setSurfaceColour<IfcSchema>(
hierarchy_helper<IfcSchema>&,
const IfcSchema::IfcRepresentation&,
double,
double,
double,
double);
template IFC_SCHEMA_API void setSurfaceColour<IfcSchema>(
hierarchy_helper<IfcSchema>&,
const IfcSchema::IfcProductRepresentation&,
const ifcopenshell::hierarchy_detail::surface_style_type<IfcSchema>&);
template IFC_SCHEMA_API void setSurfaceColour<IfcSchema>(
hierarchy_helper<IfcSchema>&,
const IfcSchema::IfcRepresentation&,
const ifcopenshell::hierarchy_detail::surface_style_type<IfcSchema>&);
+7
View File
@@ -22,14 +22,21 @@
#ifdef SWIG
#define IFC_PARSE_API
#define IFC_SCHEMA_API
#elif defined(_WIN32)
#ifdef IFC_PARSE_EXPORTS
#define IFC_PARSE_API __declspec(dllexport)
#else
#define IFC_PARSE_API __declspec(dllimport)
#endif
#ifdef IFC_SCHEMA_EXPORTS
#define IFC_SCHEMA_API __declspec(dllexport)
#else
#define IFC_SCHEMA_API IFC_PARSE_API
#endif
#else // simply assume *nix + GCC-like compiler
#define IFC_PARSE_API __attribute__((visibility("default")))
#define IFC_SCHEMA_API __attribute__((visibility("default")))
#endif
#endif
+76 -76
View File
@@ -23,43 +23,8 @@
#include <map>
#include <mutex>
#include <set>
#ifdef HAS_SCHEMA_2x3
#include "schemas/Ifc2x3.h"
#endif
#ifdef HAS_SCHEMA_4
#include "schemas/Ifc4.h"
#endif
#ifdef HAS_SCHEMA_4x1
#include "schemas/Ifc4x1.h"
#endif
#ifdef HAS_SCHEMA_4x2
#include "schemas/Ifc4x2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc1
#include "schemas/Ifc4x3_rc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc2
#include "schemas/Ifc4x3_rc2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc3
#include "schemas/Ifc4x3_rc3.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc4
#include "schemas/Ifc4x3_rc4.h"
#endif
#ifdef HAS_SCHEMA_4x3
#include "schemas/Ifc4x3.h"
#endif
#ifdef HAS_SCHEMA_4x3_tc1
#include "schemas/Ifc4x3_tc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add1
#include "schemas/Ifc4x3_add1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add2
#include "schemas/Ifc4x3_add2.h"
#endif
#include "schemas/Header_section_schema.h"
bool ifcopenshell::declaration::is(const std::string& name) const {
@@ -130,6 +95,8 @@ ifcopenshell::entity::~entity() {
}
}
namespace {
constexpr const char* schema_plugin_prefix = "parse.schema.";
std::string schema_key(const std::string& schema_name) {
return boost::to_upper_copy(schema_name);
}
@@ -144,42 +111,28 @@ namespace {
void register_builtin_schemas(ifcopenshell::schema_registry& registry) {
registry.bind("HEADER_SECTION_SCHEMA", &Header_section_schema::get_schema, &Header_section_schema::clear_schema, builtin_schema_module("HEADER_SECTION_SCHEMA"));
#ifdef HAS_SCHEMA_2x3
registry.bind("IFC2X3", &Ifc2x3::get_schema, &Ifc2x3::clear_schema, builtin_schema_module("IFC2X3"));
#endif
#ifdef HAS_SCHEMA_4
registry.bind("IFC4", &Ifc4::get_schema, &Ifc4::clear_schema, builtin_schema_module("IFC4"));
#endif
#ifdef HAS_SCHEMA_4x1
registry.bind("IFC4X1", &Ifc4x1::get_schema, &Ifc4x1::clear_schema, builtin_schema_module("IFC4X1"));
#endif
#ifdef HAS_SCHEMA_4x2
registry.bind("IFC4X2", &Ifc4x2::get_schema, &Ifc4x2::clear_schema, builtin_schema_module("IFC4X2"));
#endif
#ifdef HAS_SCHEMA_4x3_rc1
registry.bind("IFC4X3_RC1", &Ifc4x3_rc1::get_schema, &Ifc4x3_rc1::clear_schema, builtin_schema_module("IFC4X3_RC1"));
#endif
#ifdef HAS_SCHEMA_4x3_rc2
registry.bind("IFC4X3_RC2", &Ifc4x3_rc2::get_schema, &Ifc4x3_rc2::clear_schema, builtin_schema_module("IFC4X3_RC2"));
#endif
#ifdef HAS_SCHEMA_4x3_rc3
registry.bind("IFC4X3_RC3", &Ifc4x3_rc3::get_schema, &Ifc4x3_rc3::clear_schema, builtin_schema_module("IFC4X3_RC3"));
#endif
#ifdef HAS_SCHEMA_4x3_rc4
registry.bind("IFC4X3_RC4", &Ifc4x3_rc4::get_schema, &Ifc4x3_rc4::clear_schema, builtin_schema_module("IFC4X3_RC4"));
#endif
#ifdef HAS_SCHEMA_4x3
registry.bind("IFC4X3", &Ifc4x3::get_schema, &Ifc4x3::clear_schema, builtin_schema_module("IFC4X3"));
#endif
#ifdef HAS_SCHEMA_4x3_tc1
registry.bind("IFC4X3_TC1", &Ifc4x3_tc1::get_schema, &Ifc4x3_tc1::clear_schema, builtin_schema_module("IFC4X3_TC1"));
#endif
#ifdef HAS_SCHEMA_4x3_add1
registry.bind("IFC4X3_ADD1", &Ifc4x3_add1::get_schema, &Ifc4x3_add1::clear_schema, builtin_schema_module("IFC4X3_ADD1"));
#endif
#ifdef HAS_SCHEMA_4x3_add2
registry.bind("IFC4X3_ADD2", &Ifc4x3_add2::get_schema, &Ifc4x3_add2::clear_schema, builtin_schema_module("IFC4X3_ADD2"));
#endif
}
bool load_schema_plugin(ifcopenshell::schema_registry& registry, const std::string& schema_name) {
ifcopenshell::plugin::manager manager;
manager.add_search_path(ifcopenshell::schema_plugin_directory());
const auto expected_key = schema_key(schema_name);
const auto basename = std::string(schema_plugin_prefix) + boost::to_lower_copy(schema_name);
for (const auto& path : manager.discover_exact(basename)) {
auto module = manager.load(path);
if (module.meta().kind_ != ifcopenshell::plugin::kind::parse_schema ||
schema_key(module.meta().schema) != expected_key) {
continue;
}
auto register_plugin = module.get_alias<ifcopenshell::schema_registry::register_schema_plugin_fn>(ifcopenshell::schema_plugin_registration_symbol());
register_plugin(registry, module);
return true;
}
return false;
}
}
@@ -225,6 +178,37 @@ ifcopenshell::schema_registry& ifcopenshell::schema_registry_instance() {
return registry;
}
const char* ifcopenshell::schema_plugin_registration_symbol() {
return "ifcopenshell_register_schema_plugin_v1";
}
ifcopenshell::plugin::metadata ifcopenshell::schema_plugin_metadata(const std::string& schema_name) {
plugin::metadata metadata;
metadata.kind_ = plugin::kind::parse_schema;
metadata.id = schema_plugin_prefix + boost::to_lower_copy(schema_name);
metadata.schema = boost::to_upper_copy(schema_name);
return metadata;
}
std::filesystem::path ifcopenshell::schema_plugin_directory() {
return plugin::module_directory(reinterpret_cast<const void*>(&ifcopenshell::load_schema_plugins));
}
void ifcopenshell::load_schema_plugins(schema_registry& registry) {
plugin::manager manager;
manager.add_search_path(schema_plugin_directory());
for (const auto& path : manager.discover(schema_plugin_prefix)) {
auto module = manager.load(path);
if (module.meta().kind_ != plugin::kind::parse_schema) {
continue;
}
auto register_plugin = module.get_alias<schema_registry::register_schema_plugin_fn>(schema_plugin_registration_symbol());
register_plugin(registry, module);
}
}
void ifcopenshell::schema_registry::bind(const std::string& schema_name, get_schema_fn get, clear_schema_fn clear, const plugin::module& module) {
auto& entry = entries_[schema_key(schema_name)];
entry.get_ = get;
@@ -238,7 +222,12 @@ void ifcopenshell::schema_registry::bind(schema_definition* schema) {
}
const ifcopenshell::schema_definition* ifcopenshell::schema_registry::get(const std::string& schema_name) {
auto iter = entries_.find(schema_key(schema_name));
const auto key = schema_key(schema_name);
auto iter = entries_.find(key);
if (iter == entries_.end()) {
load_schema_plugin(*this, schema_name);
iter = entries_.find(key);
}
if (iter == entries_.end()) {
throw ifcopenshell::exception("No schema named " + schema_name);
}
@@ -251,11 +240,22 @@ const ifcopenshell::schema_definition* ifcopenshell::schema_registry::get(const
return iter->second.schema_;
}
std::vector<std::string> ifcopenshell::schema_registry::names() const {
std::vector<std::string> names;
std::vector<std::string> ifcopenshell::schema_registry::names() {
std::set<std::string> seen;
for (const auto& pair : entries_) {
names.push_back(pair.first);
seen.insert(pair.first);
}
plugin::manager manager;
manager.add_search_path(schema_plugin_directory());
for (const auto& path : manager.discover(schema_plugin_prefix)) {
auto module = manager.load(path);
if (module.meta().kind_ == plugin::kind::parse_schema && !module.meta().schema.empty()) {
seen.insert(schema_key(module.meta().schema));
}
}
std::vector<std::string> names(seen.begin(), seen.end());
return names;
}
+10 -1
View File
@@ -504,11 +504,12 @@ class IFC_PARSE_API schema_registry {
public:
typedef const schema_definition& (*get_schema_fn)();
typedef void (*clear_schema_fn)();
typedef void register_schema_plugin_fn(schema_registry&, const ifcopenshell::plugin::module&);
void bind(const std::string& schema_name, get_schema_fn get, clear_schema_fn clear, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module());
void bind(schema_definition* schema);
const schema_definition* get(const std::string& schema_name);
std::vector<std::string> names() const;
std::vector<std::string> names();
void clear();
private:
@@ -524,6 +525,14 @@ class IFC_PARSE_API schema_registry {
IFC_PARSE_API schema_registry& schema_registry_instance();
IFC_PARSE_API const char* schema_plugin_registration_symbol();
IFC_PARSE_API ifcopenshell::plugin::metadata schema_plugin_metadata(const std::string& schema_name);
IFC_PARSE_API std::filesystem::path schema_plugin_directory();
IFC_PARSE_API void load_schema_plugins(schema_registry& registry);
IFC_PARSE_API const schema_definition* schema_by_name(const std::string& schema_name);
IFC_PARSE_API std::vector<std::string> schema_names();
+58
View File
@@ -0,0 +1,58 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
// This file was generated with the assistance of an AI coding tool.
#include "schema.h"
#include "hierarchy_helper.h"
#include "macros.h"
#include "si_prefix.h"
#define INCLUDE_SCHEMA(x) STRINGIFY(schemas/x.h)
#include INCLUDE_SCHEMA(IfcSchema)
#undef INCLUDE_SCHEMA
#include <boost/dll/alias.hpp>
namespace ifcopenshell {
namespace schema_plugin {
plugin::abi_info plugin_abi() {
return plugin::host_abi();
}
plugin::metadata plugin_metadata() {
return schema_plugin_metadata(IfcSchema::Identifier);
}
void register_plugin(schema_registry& registry, const plugin::module& module) {
registry.bind(IfcSchema::Identifier, &IfcSchema::get_schema, &IfcSchema::clear_schema, module);
}
}
}
template IFC_SCHEMA_API double ifcopenshell::get_SI_equivalent<IfcSchema>(const IfcSchema::IfcNamedUnit&);
#include "hierarchy_helper.i"
BOOST_DLL_ALIAS(ifcopenshell::schema_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::schema_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::schema_plugin::register_plugin, ifcopenshell_register_schema_plugin_v1)
File diff suppressed because it is too large Load Diff
+1175 -1175
View File
File diff suppressed because it is too large Load Diff
+1203 -1203
View File
File diff suppressed because it is too large Load Diff
+1225 -1225
View File
File diff suppressed because it is too large Load Diff
+1313 -1313
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-144
View File
@@ -18,44 +18,6 @@
********************************************************************************/
#include "si_prefix.h"
#include "instance_data.h"
#ifdef HAS_SCHEMA_2x3
#include "schemas/Ifc2x3.h"
#endif
#ifdef HAS_SCHEMA_4
#include "schemas/Ifc4.h"
#endif
#ifdef HAS_SCHEMA_4x1
#include "schemas/Ifc4x1.h"
#endif
#ifdef HAS_SCHEMA_4x2
#include "schemas/Ifc4x2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc1
#include "schemas/Ifc4x3_rc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc2
#include "schemas/Ifc4x3_rc2.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc3
#include "schemas/Ifc4x3_rc3.h"
#endif
#ifdef HAS_SCHEMA_4x3_rc4
#include "schemas/Ifc4x3_rc4.h"
#endif
#ifdef HAS_SCHEMA_4x3
#include "schemas/Ifc4x3.h"
#endif
#ifdef HAS_SCHEMA_4x3_tc1
#include "schemas/Ifc4x3_tc1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add1
#include "schemas/Ifc4x3_add1.h"
#endif
#ifdef HAS_SCHEMA_4x3_add2
#include "schemas/Ifc4x3_add2.h"
#endif
double ifcopenshell::si_prefix_to_value(const std::string& prefix) {
if (prefix == "EXA") {
@@ -108,109 +70,3 @@ double ifcopenshell::si_prefix_to_value(const std::string& prefix) {
}
return 1.;
}
template <typename Schema>
double ifcopenshell::get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) {
double scale = 1.;
typename Schema::IfcSIUnit si_unit;
if (auto conv_unit = named_unit.template as<typename Schema::IfcConversionBasedUnit>()) {
auto factor = conv_unit.ConversionFactor();
auto component = factor.UnitComponent();
if (si_unit = component.concrete().template as<typename Schema::IfcSIUnit>()) {
auto value = factor.ValueComponent();
scale = value.get_attribute_value(0);
}
} else {
si_unit = named_unit.template as<typename Schema::IfcSIUnit>();
}
if (si_unit) {
if (si_unit.Prefix()) {
scale *= si_prefix_to_value(Schema::IfcSIPrefix::ToString(*si_unit.Prefix()));
}
} else {
scale = 0.;
}
return scale;
}
#if defined(_MSC_VER) && _MSC_VER < 1900
#ifdef HAS_SCHEMA_2x3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc2x3>(const Ifc2x3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4>(const Ifc4::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x1>(const Ifc4x1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x2>(const Ifc4x2::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc1>(const Ifc4x3_rc1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc2>(const Ifc4x3_rc2::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc3>(const Ifc4x3_rc3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc4
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc4>(const Ifc4x3_rc4::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3>(const Ifc4x3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_tc1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_tc1>(const Ifc4x3_tc1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_add1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_add1>(const Ifc4x3_add1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_add2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_add2>(const Ifc4x3_add2::IfcNamedUnit& named_unit);
#endif
#else
#ifdef HAS_SCHEMA_2x3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc2x3>(const typename Ifc2x3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4>(const typename Ifc4::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x1>(const typename Ifc4x1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x2>(const typename Ifc4x2::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc1>(const typename Ifc4x3_rc1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc2>(const typename Ifc4x3_rc2::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc3>(const typename Ifc4x3_rc3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_rc4
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_rc4>(const typename Ifc4x3_rc4::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3>(const typename Ifc4x3::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_tc1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_tc1>(const typename Ifc4x3_tc1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_add1
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_add1>(const typename Ifc4x3_add1::IfcNamedUnit& named_unit);
#endif
#ifdef HAS_SCHEMA_4x3_add2
template double IFC_PARSE_API ifcopenshell::get_SI_equivalent<Ifc4x3_add2>(const typename Ifc4x3_add2::IfcNamedUnit& named_unit);
#endif
#endif
+24 -1
View File
@@ -28,7 +28,30 @@ namespace ifcopenshell {
IFC_PARSE_API double si_prefix_to_value(const std::string& prefix);
template <typename Schema>
IFC_PARSE_API double get_SI_equivalent(const typename Schema::IfcNamedUnit& unit);
double get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) {
double scale = 1.;
typename Schema::IfcSIUnit si_unit;
if (auto conv_unit = named_unit.template as<typename Schema::IfcConversionBasedUnit>()) {
auto factor = conv_unit.ConversionFactor();
auto component = factor.UnitComponent();
if (si_unit = component.concrete().template as<typename Schema::IfcSIUnit>()) {
auto value = factor.ValueComponent();
scale = value.get_attribute_value(0);
}
} else {
si_unit = named_unit.template as<typename Schema::IfcSIUnit>();
}
if (si_unit) {
if (si_unit.Prefix()) {
scale *= si_prefix_to_value(Schema::IfcSIPrefix::ToString(*si_unit.Prefix()));
}
} else {
scale = 0.;
}
return scale;
}
} // namespace ifcopenshell
#endif