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.

60 lines
2.6 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>
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>& iterator_implementations() {
static IteratorFactoryImplementation<P, PP> impl;
2017-12-19 20:24:00 +01:00
return impl;
}
2018-07-07 21:14:27 +02:00
template IteratorFactoryImplementation<float, float>& iterator_implementations<float, float>();
template IteratorFactoryImplementation<float, double>& iterator_implementations<float, double>();
template IteratorFactoryImplementation<double, double>& iterator_implementations<double, double>();
2017-12-19 20:24:00 +01:00
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P, PP>*);
2017-12-21 14:14:04 +01:00
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P, PP>*);
2017-12-19 20:24:00 +01:00
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>*);
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>::IteratorFactoryImplementation() {
2017-12-21 14:14:04 +01:00
init_IteratorImplementation_Ifc2x3(this);
init_IteratorImplementation_Ifc4(this);
init_IteratorImplementation_Ifc4x1(this);
init_IteratorImplementation_Ifc4x2(this);
init_IteratorImplementation_Ifc4x3_rc1(this);
2017-12-19 20:24:00 +01:00
}
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
void IteratorFactoryImplementation<P, PP>::bind(const std::string& schema_name, typename get_factory_type<P, PP>::type 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
}
2018-07-07 21:14:27 +02:00
template <typename P, typename PP>
2019-07-19 15:55:22 +02:00
IfcGeom::IteratorImplementation<P, PP>* IteratorFactoryImplementation<P, PP>::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);
2018-07-07 21:14:27 +02:00
typename std::map<std::string, typename get_factory_type<P, PP>::type>::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
}
2018-07-07 21:14:27 +02:00
template class IteratorFactoryImplementation<float, float>;
template class IteratorFactoryImplementation<float, double>;
template class IteratorFactoryImplementation<double, double>;