Files
IfcOpenShell/src/ifcgeom_schema_agnostic/IteratorImplementation.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.2 KiB
C++
Raw Normal View History

2017-12-19 20:24:00 +01:00
#include "IteratorImplementation.h"
2017-12-21 14:14:04 +01:00
#include <boost/algorithm/string/case_conv.hpp>
2021-07-11 15:00:59 +02:00
IteratorFactoryImplementation& iterator_implementations() {
static IteratorFactoryImplementation impl;
2017-12-19 20:24:00 +01:00
return impl;
}
#ifdef HAS_SCHEMA_2x3
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation*);
#endif
2017-12-21 14:14:04 +01:00
#ifdef HAS_SCHEMA_4
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation*);
#endif
2017-12-19 20:24:00 +01:00
#ifdef HAS_SCHEMA_4x1
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation*);
#endif
#ifdef HAS_SCHEMA_4x2
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation*);
#endif
#ifdef HAS_SCHEMA_4x3_rc1
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation*);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
2021-07-11 15:00:59 +02:00
extern void init_IteratorImplementation_Ifc4x3_rc2(IteratorFactoryImplementation*);
#endif
2021-02-14 12:43:27 +01:00
2021-07-11 15:00:59 +02:00
IteratorFactoryImplementation::IteratorFactoryImplementation() {
#ifdef HAS_SCHEMA_2x3
2017-12-21 14:14:04 +01:00
init_IteratorImplementation_Ifc2x3(this);
#endif
#ifdef HAS_SCHEMA_4
2017-12-21 14:14:04 +01:00
init_IteratorImplementation_Ifc4(this);
#endif
#ifdef HAS_SCHEMA_4x1
init_IteratorImplementation_Ifc4x1(this);
#endif
#ifdef HAS_SCHEMA_4x2
init_IteratorImplementation_Ifc4x2(this);
#endif
#ifdef HAS_SCHEMA_4x3_rc1
init_IteratorImplementation_Ifc4x3_rc1(this);
#endif
#ifdef HAS_SCHEMA_4x3_rc2
2021-02-14 12:43:27 +01:00
init_IteratorImplementation_Ifc4x3_rc2(this);
#endif
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);
}
return it->second(settings, file, filters, num_threads);
2017-12-20 11:10:27 +01:00
}