2017-12-19 20:24:00 +01:00
|
|
|
#include "IteratorImplementation.h"
|
|
|
|
|
|
2022-07-17 21:13:46 +02:00
|
|
|
#include <boost/preprocessor/stringize.hpp>
|
|
|
|
|
#include <boost/preprocessor/seq/for_each.hpp>
|
2017-12-21 14:14:04 +01:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
|
|
2022-07-17 21:13:46 +02:00
|
|
|
// Declares the schema-based external iterator initialization routines:
|
|
|
|
|
// - extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation*);
|
|
|
|
|
// - ...
|
|
|
|
|
#define EXTERNAL_DEFS(r, data, elem) \
|
2022-07-18 10:08:46 +02:00
|
|
|
extern void BOOST_PP_CAT(init_IteratorImplementation_Ifc, elem)(IteratorFactoryImplementation*);
|
2022-07-17 21:13:46 +02:00
|
|
|
|
|
|
|
|
// Declares the schema-based external iterator initialization routines:
|
|
|
|
|
// - init_IteratorImplementation_Ifc2x3(this);
|
|
|
|
|
// - ...
|
|
|
|
|
#define CALL_DEFS(r, data, elem) \
|
2022-07-18 10:08:46 +02:00
|
|
|
BOOST_PP_CAT(init_IteratorImplementation_Ifc, elem)(this);
|
2022-07-17 21:13:46 +02:00
|
|
|
|
2021-08-10 14:30:07 +02:00
|
|
|
IFC_GEOM_API IteratorFactoryImplementation& iterator_implementations() {
|
2021-07-11 15:00:59 +02:00
|
|
|
static IteratorFactoryImplementation impl;
|
2017-12-19 20:24:00 +01:00
|
|
|
return impl;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-17 21:13:46 +02:00
|
|
|
BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS, , SCHEMA_SEQ)
|
2021-02-14 12:43:27 +01:00
|
|
|
|
2021-07-11 15:00:59 +02:00
|
|
|
IteratorFactoryImplementation::IteratorFactoryImplementation() {
|
2022-07-17 21:13:46 +02:00
|
|
|
BOOST_PP_SEQ_FOR_EACH(CALL_DEFS, , SCHEMA_SEQ)
|
2017-12-19 20:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-11 15:00:59 +02:00
|
|
|
void IteratorFactoryImplementation::bind(const std::string& schema_name, iterator_fn fn) {
|
2017-12-21 14:14:04 +01:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
|
|
|
|
this->insert(std::make_pair(schema_name_lower, fn));
|
2017-12-19 20:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-11 15:00:59 +02:00
|
|
|
IfcGeom::IteratorImplementation* IteratorFactoryImplementation::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads) {
|
2017-12-21 14:14:04 +01:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
2021-07-11 15:00:59 +02:00
|
|
|
typename std::map<std::string, iterator_fn>::const_iterator it;
|
2017-12-21 14:14:04 +01:00
|
|
|
it = this->find(schema_name_lower);
|
2017-12-29 12:09:07 +01:00
|
|
|
if (it == this->end()) {
|
2017-12-20 11:10:27 +01:00
|
|
|
throw IfcParse::IfcException("No geometry iterator registered for " + schema_name);
|
|
|
|
|
}
|
2019-07-03 12:10:27 +02:00
|
|
|
return it->second(settings, file, filters, num_threads);
|
2017-12-20 11:10:27 +01:00
|
|
|
}
|