IfcGeomServer matrices in double precision

This commit is contained in:
Thomas Krijnen
2018-07-07 21:14:27 +02:00
parent d105292817
commit 7a7aab01bb
10 changed files with 143 additions and 128 deletions
@@ -70,7 +70,7 @@
namespace IfcGeom {
template <typename P>
template <typename P = double, typename PP = P>
class Iterator {
private:
Iterator(const Iterator&); // N/I
@@ -78,14 +78,14 @@ namespace IfcGeom {
IfcParse::IfcFile* file_;
IfcGeom::IteratorSettings settings_;
IteratorImplementation<P>* implementation_;
IteratorImplementation<P, PP>* implementation_;
public:
Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file)
: file_(file)
, settings_(settings)
{
implementation_ = iterator_implementations<P>().construct(file_->schema()->name(), settings, file);
implementation_ = iterator_implementations<P, PP>().construct(file_->schema()->name(), settings, file);
}
bool initialize() {
@@ -102,11 +102,11 @@ namespace IfcGeom {
IfcUtil::IfcBaseClass* next() const { return implementation_->next(); }
Element<P>* get() { return implementation_->get(); }
Element<P, PP>* get() { return implementation_->get(); }
BRepElement<P>* get_native() { return implementation_->get_native(); }
BRepElement<P, PP>* get_native() { return implementation_->get_native(); }
const Element<P>* get_object(int id) { return implementation_->get_object(id); }
const Element<P, PP>* get_object(int id) { return implementation_->get_object(id); }
IfcUtil::IfcBaseClass* create() { return implementation_->create(); }
};
@@ -2,37 +2,38 @@
#include <boost/algorithm/string/case_conv.hpp>
template <typename P>
IteratorFactoryImplementation<P>& iterator_implementations() {
static IteratorFactoryImplementation<P> impl;
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>& iterator_implementations() {
static IteratorFactoryImplementation<P, PP> impl;
return impl;
}
template IteratorFactoryImplementation<float>& iterator_implementations<float>();
template IteratorFactoryImplementation<double>& iterator_implementations<double>();
template IteratorFactoryImplementation<float, float>& iterator_implementations<float, float>();
template IteratorFactoryImplementation<float, double>& iterator_implementations<float, double>();
template IteratorFactoryImplementation<double, double>& iterator_implementations<double, double>();
template <typename P>
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P>*);
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P, PP>*);
template <typename P>
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P>*);
template <typename P, typename PP>
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P, PP>*);
template <typename P>
IteratorFactoryImplementation<P>::IteratorFactoryImplementation() {
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>::IteratorFactoryImplementation() {
init_IteratorImplementation_Ifc2x3(this);
init_IteratorImplementation_Ifc4(this);
}
template <class P>
void IteratorFactoryImplementation<P>::bind(const std::string& schema_name, typename get_factory_type<P>::type fn) {
template <typename P, typename PP>
void IteratorFactoryImplementation<P, PP>::bind(const std::string& schema_name, typename get_factory_type<P, PP>::type fn) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
this->insert(std::make_pair(schema_name_lower, fn));
}
template <class P>
IfcGeom::IteratorImplementation<P>* IteratorFactoryImplementation<P>::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) {
template <typename P, typename PP>
IfcGeom::IteratorImplementation<P, PP>* IteratorFactoryImplementation<P, PP>::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
typename std::map<std::string, typename get_factory_type<P>::type>::const_iterator it;
typename std::map<std::string, typename get_factory_type<P, PP>::type>::const_iterator it;
it = this->find(schema_name_lower);
if (it == this->end()) {
throw IfcParse::IfcException("No geometry iterator registered for " + schema_name);
@@ -41,5 +42,6 @@ IfcGeom::IteratorImplementation<P>* IteratorFactoryImplementation<P>::construct(
}
template class IteratorFactoryImplementation<float>;
template class IteratorFactoryImplementation<double>;
template class IteratorFactoryImplementation<float, float>;
template class IteratorFactoryImplementation<float, double>;
template class IteratorFactoryImplementation<double, double>;
@@ -10,46 +10,52 @@
#include <string>
namespace IfcGeom {
template <typename P>
template <typename P, typename PP>
class IteratorImplementation;
template <typename P>
template <typename P, typename PP>
class Element;
template <typename P>
template <typename P, typename PP>
class BRepElement;
}
typedef boost::function2<IfcGeom::IteratorImplementation<float>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*> iterator_float_fn;
typedef boost::function2<IfcGeom::IteratorImplementation<double>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*> iterator_double_fn;
typedef boost::function2<IfcGeom::IteratorImplementation<float, float>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*> iterator_float_float_fn;
typedef boost::function2<IfcGeom::IteratorImplementation<float, double>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*> iterator_float_double_fn;
typedef boost::function2<IfcGeom::IteratorImplementation<double, double>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*> iterator_double_double_fn;
template <typename P>
template <typename P, typename PP>
struct get_factory_type {};
template <>
struct get_factory_type<float> {
typedef iterator_float_fn type;
struct get_factory_type<float, float> {
typedef iterator_float_float_fn type;
};
template <>
struct get_factory_type<double> {
typedef iterator_double_fn type;
struct get_factory_type<float, double> {
typedef iterator_float_double_fn type;
};
template <typename P>
class IteratorFactoryImplementation : public std::map<std::string, typename get_factory_type<P>::type> {
template <>
struct get_factory_type<double, double> {
typedef iterator_double_double_fn type;
};
template <typename P, typename PP>
class IteratorFactoryImplementation : public std::map<std::string, typename get_factory_type<P, PP>::type> {
public:
IteratorFactoryImplementation();
void bind(const std::string& schema_name, typename get_factory_type<P>::type fn);
IfcGeom::IteratorImplementation<P>* construct(const std::string& schema_name, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
void bind(const std::string& schema_name, typename get_factory_type<P, PP>::type fn);
IfcGeom::IteratorImplementation<P, PP>* construct(const std::string& schema_name, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
};
template <typename P>
IteratorFactoryImplementation<P>& iterator_implementations();
template <typename P, typename PP>
IteratorFactoryImplementation<P, PP>& iterator_implementations();
namespace IfcGeom {
template <typename P>
template <typename P, typename PP>
class IteratorImplementation {
public:
virtual bool initialize() = 0;
@@ -58,9 +64,9 @@ namespace IfcGeom {
virtual double getUnitMagnitude() const = 0;
virtual IfcParse::IfcFile* file() const = 0;
virtual IfcUtil::IfcBaseClass* next() = 0;
virtual Element<P>* get() = 0;
virtual BRepElement<P>* get_native() = 0;
virtual const Element<P>* get_object(int id) = 0;
virtual Element<P, PP>* get() = 0;
virtual BRepElement<P, PP>* get_native() = 0;
virtual const Element<P, PP>* get_object(int id) = 0;
virtual IfcUtil::IfcBaseClass* create() = 0;
};
+2 -2
View File
@@ -24,7 +24,7 @@ namespace {
namespace IfcGeom {
template <typename T>
template <typename P, typename PP>
class BRepElement;
class Kernel {
@@ -78,7 +78,7 @@ namespace IfcGeom {
return implementation_->getValue(var);
}
virtual BRepElement<double>* convert(
virtual BRepElement<double, double>* convert(
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
IfcUtil::IfcBaseClass* product)
{