2019-08-16 17:40:13 +02:00
|
|
|
#include "abstract_mapping.h"
|
|
|
|
|
|
|
|
|
|
#include "../ifcparse/IfcFile.h"
|
|
|
|
|
|
2023-03-21 20:15:01 +01:00
|
|
|
#include <boost/preprocessor/stringize.hpp>
|
|
|
|
|
#include <boost/preprocessor/seq/for_each.hpp>
|
|
|
|
|
|
2023-06-15 21:27:42 +02:00
|
|
|
#ifndef SCHEMA_SEQ
|
|
|
|
|
static_assert(false, "A boost preprocessor sequence of schema identifiers is needed for this file to compile.");
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
ifcopenshell::geometry::impl::MappingFactoryImplementation& ifcopenshell::geometry::impl::mapping_implementations() {
|
|
|
|
|
static MappingFactoryImplementation impl;
|
|
|
|
|
return impl;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 20:15:01 +01:00
|
|
|
// Declares the schema-based external kernel initialization routines:
|
|
|
|
|
// - extern void init_MappingImplementation_Ifc2x3(IfcGeom::impl::MappingFactoryImplementation*);
|
|
|
|
|
// - ...
|
|
|
|
|
#define EXTERNAL_DEFS(r, data, elem) \
|
|
|
|
|
extern void BOOST_PP_CAT(init_MappingImplementation_Ifc, elem)(ifcopenshell::geometry::impl::MappingFactoryImplementation*);
|
|
|
|
|
|
|
|
|
|
// Declares the schema-based external iterator initialization routines:
|
|
|
|
|
// - init_MappingImplementation_Ifc2x3(this);
|
|
|
|
|
// - ...
|
|
|
|
|
#define CALL_DEFS(r, data, elem) \
|
|
|
|
|
BOOST_PP_CAT(init_MappingImplementation_Ifc, elem)(this);
|
|
|
|
|
|
|
|
|
|
BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS, , SCHEMA_SEQ)
|
2019-08-16 17:40:13 +02:00
|
|
|
|
|
|
|
|
ifcopenshell::geometry::impl::MappingFactoryImplementation::MappingFactoryImplementation() {
|
2023-03-21 20:15:01 +01:00
|
|
|
BOOST_PP_SEQ_FOR_EACH(CALL_DEFS, , SCHEMA_SEQ)
|
2019-08-16 17:40:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std::string& schema_name, ifcopenshell::geometry::impl::mapping_fn fn) {
|
|
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
|
|
|
|
this->insert(std::make_pair(schema_name_lower, fn));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-10 18:30:54 +02:00
|
|
|
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, Settings& s, Logger& logger) {
|
2019-08-16 17:40:13 +02:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name());
|
|
|
|
|
std::map<std::string, ifcopenshell::geometry::impl::mapping_fn>::const_iterator it;
|
|
|
|
|
it = this->find(schema_name_lower);
|
|
|
|
|
if (it == end()) {
|
|
|
|
|
throw IfcParse::IfcException("No geometry mapping registered for " + schema_name_lower);
|
|
|
|
|
}
|
2026-06-10 18:30:54 +02:00
|
|
|
auto new_mapping = it->second(file, s, logger);
|
2026-06-17 18:23:19 +02:00
|
|
|
try {
|
|
|
|
|
new_mapping->initialize_settings();
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
logger.Error("GEO", 400, e);
|
|
|
|
|
logger.Error("GEO", 401, "Unable to initialize conversion settings");
|
|
|
|
|
}
|
2023-03-21 20:15:01 +01:00
|
|
|
return new_mapping;
|
2019-08-16 17:40:13 +02:00
|
|
|
}
|