Remove templates on iterator and element

This commit is contained in:
Thomas Krijnen
2021-07-11 15:00:59 +02:00
parent ff73f82798
commit eeaf04c6ea
25 changed files with 203 additions and 293 deletions
+7 -7
View File
@@ -920,7 +920,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
IfcGeom::Iterator<double> tmp_context_iterator(settings, ifc_file, filter_funcs, num_threads); IfcGeom::Iterator tmp_context_iterator(settings, ifc_file, filter_funcs, num_threads);
time_t start, end; time_t start, end;
time(&start); time(&start);
@@ -961,7 +961,7 @@ int main(int argc, char** argv) {
Logger::Notice(msg.str()); Logger::Notice(msg.str());
} }
IfcGeom::Iterator<double> context_iterator(settings, ifc_file, filter_funcs, num_threads); IfcGeom::Iterator context_iterator(settings, ifc_file, filter_funcs, num_threads);
if (!context_iterator.initialize()) { if (!context_iterator.initialize()) {
/// @todo It would be nice to know and print separate error prints for a case where we found no entities /// @todo It would be nice to know and print separate error prints for a case where we found no entities
/// and for a case we found no entities that satisfy our filtering criteria. /// and for a case we found no entities that satisfy our filtering criteria.
@@ -1074,15 +1074,15 @@ int main(int argc, char** argv) {
do { do {
IfcGeom::Element<double> *geom_object = context_iterator.get(); IfcGeom::Element* geom_object = context_iterator.get();
if (is_tesselated) if (is_tesselated)
{ {
serializer->write(static_cast<const IfcGeom::TriangulationElement<double>*>(geom_object)); serializer->write(static_cast<const IfcGeom::TriangulationElement*>(geom_object));
} }
else else
{ {
serializer->write(static_cast<const IfcGeom::BRepElement<double>*>(geom_object)); serializer->write(static_cast<const IfcGeom::BRepElement*>(geom_object));
} }
if (!no_progress) { if (!no_progress) {
@@ -1485,7 +1485,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true); settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true);
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
IfcGeom::Iterator<double> context_iterator(settings, &f); IfcGeom::Iterator context_iterator(settings, &f);
if (!context_iterator.initialize()) { if (!context_iterator.initialize()) {
return; return;
@@ -1526,7 +1526,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
if (num_created) { if (num_created) {
has_more = context_iterator.next(); has_more = context_iterator.next();
} }
IfcGeom::BRepElement<double>* geom_object = nullptr; IfcGeom::BRepElement* geom_object = nullptr;
if (has_more) { if (has_more) {
geom_object = context_iterator.get_native(); geom_object = context_iterator.get_native();
} }
+5 -7
View File
@@ -434,13 +434,11 @@ public:
std::pair<std::string, double> initializeUnits(IfcSchema::IfcUnitAssignment*); std::pair<std::string, double> initializeUnits(IfcSchema::IfcUnitAssignment*);
template <typename P, typename PP> IfcGeom::BRepElement* create_brep_for_representation_and_product(
IfcGeom::BRepElement<P, PP>* create_brep_for_representation_and_product(
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*); const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
template <typename P, typename PP> IfcGeom::BRepElement* create_brep_for_processed_representation(
IfcGeom::BRepElement<P, PP>* create_brep_for_processed_representation( const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement*);
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P, PP>*);
const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct*); const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct*);
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation); IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
@@ -543,11 +541,11 @@ public:
virtual void setValue(GeomValue var, double value); virtual void setValue(GeomValue var, double value);
virtual double getValue(GeomValue var) const; virtual double getValue(GeomValue var) const;
virtual IfcGeom::BRepElement<double>* convert( virtual IfcGeom::BRepElement* convert(
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation, const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
IfcUtil::IfcBaseClass* product) IfcUtil::IfcBaseClass* product)
{ {
return create_brep_for_representation_and_product<double, double>(settings, (IfcSchema::IfcRepresentation*) representation, (IfcSchema::IfcProduct*) product); return create_brep_for_representation_and_product(settings, (IfcSchema::IfcRepresentation*) representation, (IfcSchema::IfcProduct*) product);
} }
virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) { virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) {
+33 -39
View File
@@ -32,10 +32,9 @@
namespace IfcGeom { namespace IfcGeom {
template <typename P>
class Matrix { class Matrix {
private: private:
std::vector<P> _data; std::vector<double> _data;
public: public:
Matrix(const ElementSettings& settings, const gp_Trsf& trsf) { Matrix(const ElementSettings& settings, const gp_Trsf& trsf) {
// Convert the gp_Trsf into a 4x3 Matrix // Convert the gp_Trsf into a 4x3 Matrix
@@ -49,19 +48,18 @@ namespace IfcGeom {
const double matrix_value = i == 4 && settings.get(IteratorSettings::CONVERT_BACK_UNITS) const double matrix_value = i == 4 && settings.get(IteratorSettings::CONVERT_BACK_UNITS)
? trsf_value / settings.unit_magnitude() ? trsf_value / settings.unit_magnitude()
: trsf_value; : trsf_value;
_data.push_back(static_cast<P>(matrix_value)); _data.push_back(static_cast<double>(matrix_value));
} }
} }
} }
const std::vector<P>& data() const { return _data; } const std::vector<double>& data() const { return _data; }
}; };
template <typename P>
class Transformation { class Transformation {
private: private:
ElementSettings settings_; ElementSettings settings_;
gp_Trsf trsf_; gp_Trsf trsf_;
Matrix<P> matrix_; Matrix matrix_;
public: public:
Transformation(const ElementSettings& settings, const gp_Trsf& trsf) Transformation(const ElementSettings& settings, const gp_Trsf& trsf)
: settings_(settings) : settings_(settings)
@@ -69,7 +67,7 @@ namespace IfcGeom {
, matrix_(settings, trsf) , matrix_(settings, trsf)
{} {}
const gp_Trsf& data() const { return trsf_; } const gp_Trsf& data() const { return trsf_; }
const Matrix<P>& matrix() const { return matrix_; } const Matrix& matrix() const { return matrix_; }
Transformation inverted() const { Transformation inverted() const {
return Transformation(settings_, trsf_.Inverted()); return Transformation(settings_, trsf_.Inverted());
@@ -80,7 +78,6 @@ namespace IfcGeom {
} }
}; };
template <typename P = double, typename PP = P>
class Element { class Element {
private: private:
int _id; int _id;
@@ -90,17 +87,17 @@ namespace IfcGeom {
std::string _guid; std::string _guid;
std::string _context; std::string _context;
std::string _unique_id; std::string _unique_id;
Transformation<PP> _transformation; Transformation _transformation;
IfcUtil::IfcBaseEntity* product_; IfcUtil::IfcBaseEntity* product_;
std::vector<const IfcGeom::Element<P, PP>*> _parents; std::vector<const IfcGeom::Element*> _parents;
public: public:
friend bool operator == (const Element<P, PP> & element1, const Element<P, PP> & element2) { friend bool operator == (const Element& element1, const Element& element2) {
return element1.id() == element2.id(); return element1.id() == element2.id();
} }
// Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set // Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set
friend bool operator < (const Element<P, PP> & element1, const Element<P, PP> & element2) { friend bool operator < (const Element& element1, const Element& element2) {
if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") { if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") {
size_t attr_index = element1.product()->declaration().attribute_index("Elevation"); size_t attr_index = element1.product()->declaration().attribute_index("Elevation");
Argument* elev_attr1 = element1.product()->data().getArgument(attr_index); Argument* elev_attr1 = element1.product()->data().getArgument(attr_index);
@@ -124,10 +121,10 @@ namespace IfcGeom {
const std::string& guid() const { return _guid; } const std::string& guid() const { return _guid; }
const std::string& context() const { return _context; } const std::string& context() const { return _context; }
const std::string& unique_id() const { return _unique_id; } const std::string& unique_id() const { return _unique_id; }
const Transformation<PP>& transformation() const { return _transformation; } const Transformation& transformation() const { return _transformation; }
IfcUtil::IfcBaseEntity* product() const { return product_; } IfcUtil::IfcBaseEntity* product() const { return product_; }
const std::vector<const IfcGeom::Element<P, PP>*> parents() const { return _parents; } const std::vector<const IfcGeom::Element*> parents() const { return _parents; }
void SetParents(std::vector<const IfcGeom::Element<P, PP>*> newparents) { _parents = newparents; } void SetParents(std::vector<const IfcGeom::Element*> newparents) { _parents = newparents; }
Element(const ElementSettings& settings, int id, int parent_id, const std::string& name, const std::string& type, Element(const ElementSettings& settings, int id, int parent_id, const std::string& name, const std::string& type,
const std::string& guid, const std::string& context, const gp_Trsf& trsf, IfcUtil::IfcBaseEntity* product) const std::string& guid, const std::string& context, const gp_Trsf& trsf, IfcUtil::IfcBaseEntity* product)
@@ -159,17 +156,16 @@ namespace IfcGeom {
virtual ~Element() {} virtual ~Element() {}
}; };
template <typename P = double, typename PP = P> class BRepElement : public Element {
class BRepElement : public Element<P, PP> {
private: private:
boost::shared_ptr<Representation::BRep> _geometry; boost::shared_ptr<IfcGeom::Representation::BRep> _geometry;
public: public:
const boost::shared_ptr<Representation::BRep>& geometry_pointer() const { return _geometry; } const boost::shared_ptr<IfcGeom::Representation::BRep>& geometry_pointer() const { return _geometry; }
const Representation::BRep& geometry() const { return *_geometry; } const IfcGeom::Representation::BRep& geometry() const { return *_geometry; }
BRepElement(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid, BRepElement(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid,
const std::string& context, const gp_Trsf& trsf, const boost::shared_ptr<Representation::BRep>& geometry, const std::string& context, const gp_Trsf& trsf, const boost::shared_ptr<IfcGeom::Representation::BRep>& geometry,
IfcUtil::IfcBaseEntity* product) IfcUtil::IfcBaseEntity* product)
: Element<P, PP>(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product) : Element(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product)
, _geometry(geometry) , _geometry(geometry)
{} {}
@@ -184,19 +180,18 @@ namespace IfcGeom {
BRepElement& operator=(const BRepElement& other); BRepElement& operator=(const BRepElement& other);
}; };
template <typename P = double, typename PP = P> class TriangulationElement : public Element {
class TriangulationElement : public Element<P, PP> {
private: private:
boost::shared_ptr< Representation::Triangulation<P> > _geometry; boost::shared_ptr< IfcGeom::Representation::Triangulation > _geometry;
public: public:
const Representation::Triangulation<P>& geometry() const { return *_geometry; } const IfcGeom::Representation::Triangulation& geometry() const { return *_geometry; }
const boost::shared_ptr< Representation::Triangulation<P> >& geometry_pointer() const { return _geometry; } const boost::shared_ptr< IfcGeom::Representation::Triangulation>& geometry_pointer() const { return _geometry; }
TriangulationElement(const BRepElement<P, PP>& shape_model) TriangulationElement(const IfcGeom::BRepElement& shape_model)
: Element<P, PP>(shape_model) : Element(shape_model)
, _geometry(boost::shared_ptr<Representation::Triangulation<P> >(new Representation::Triangulation<P>(shape_model.geometry()))) , _geometry(boost::shared_ptr<IfcGeom::Representation::Triangulation>(new IfcGeom::Representation::Triangulation(shape_model.geometry())))
{} {}
TriangulationElement(const Element<P, PP>& element, const boost::shared_ptr<Representation::Triangulation<P> >& geometry) TriangulationElement(const IfcGeom::Element& element, const boost::shared_ptr<IfcGeom::Representation::Triangulation>& geometry)
: Element<P, PP>(element) : Element(element)
, _geometry(geometry) , _geometry(geometry)
{} {}
private: private:
@@ -204,15 +199,14 @@ namespace IfcGeom {
TriangulationElement& operator=(const TriangulationElement& other); TriangulationElement& operator=(const TriangulationElement& other);
}; };
template <typename P = double, typename PP = P> class SerializedElement : public Element {
class SerializedElement : public Element<P, PP> {
private: private:
Representation::Serialization* _geometry; IfcGeom::Representation::Serialization* _geometry;
public: public:
const Representation::Serialization& geometry() const { return *_geometry; } const IfcGeom::Representation::Serialization& geometry() const { return *_geometry; }
SerializedElement(const BRepElement<P, PP>& shape_model) SerializedElement(const BRepElement& shape_model)
: Element<P, PP>(shape_model) : Element(shape_model)
, _geometry(new Representation::Serialization(shape_model.geometry())) , _geometry(new IfcGeom::Representation::Serialization(shape_model.geometry()))
{} {}
virtual ~SerializedElement() { virtual ~SerializedElement() {
delete _geometry; delete _geometry;
+5 -21
View File
@@ -1828,8 +1828,7 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c
return single_material; return single_material;
} }
template <typename P, typename PP> IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_product(
IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_representation_and_product(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product) const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
{ {
std::stringstream representation_id_builder; std::stringstream representation_id_builder;
@@ -2020,7 +2019,7 @@ IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_representation_and
context_string = representation->ContextOfItems()->ContextType(); context_string = representation->ContextOfItems()->ContextType();
} }
auto elem = new BRepElement<P, PP>( auto elem = new BRepElement(
product->data().id(), product->data().id(),
parent_id, parent_id,
name, name,
@@ -2187,10 +2186,9 @@ IfcSchema::IfcProduct::list::ptr IfcGeom::Kernel::products_represented_by(const
return products; return products;
} }
template <typename P, typename PP> IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_processed_representation(
IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_processed_representation(
const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
IfcGeom::BRepElement<P, PP>* brep) IfcGeom::BRepElement* brep)
{ {
int parent_id = -1; int parent_id = -1;
try { try {
@@ -2223,7 +2221,7 @@ IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_processed_represen
const std::string product_type = product->declaration().name(); const std::string product_type = product->declaration().name();
return new BRepElement<P, PP>( return new BRepElement(
product->data().id(), product->data().id(),
parent_id, parent_id,
name, name,
@@ -2236,20 +2234,6 @@ IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_processed_represen
); );
} }
template IFC_GEOM_API IfcGeom::BRepElement<float, float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float, float>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
template IFC_GEOM_API IfcGeom::BRepElement<float, double>* IfcGeom::Kernel::create_brep_for_representation_and_product<float, double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
template IFC_GEOM_API IfcGeom::BRepElement<double, double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double, double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
template IFC_GEOM_API IfcGeom::BRepElement<float, float>* IfcGeom::Kernel::create_brep_for_processed_representation<float, float>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float, float>* brep);
template IFC_GEOM_API IfcGeom::BRepElement<float, double>* IfcGeom::Kernel::create_brep_for_processed_representation<float, double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float, double>* brep);
template IFC_GEOM_API IfcGeom::BRepElement<double, double>* IfcGeom::Kernel::create_brep_for_processed_representation<double, double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<double, double>* brep);
std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUnitAssignment* unit_assignment) { std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUnitAssignment* unit_assignment) {
// Set default units, set length to meters, angles to undefined // Set default units, set length to meters, angles to undefined
setValue(IfcGeom::Kernel::GV_LENGTH_UNIT, 1.0); setValue(IfcGeom::Kernel::GV_LENGTH_UNIT, 1.0);
+4 -16
View File
@@ -1,32 +1,20 @@
#include "IfcGeomIteratorImplementation.h" #include "IfcGeomIteratorImplementation.h"
#include "../ifcgeom_schema_agnostic/IteratorImplementation.h" #include "../ifcgeom_schema_agnostic/IteratorImplementation.h"
namespace IfcGeom {
template class MAKE_TYPE_NAME(IteratorImplementation_)<float, float>;
template class MAKE_TYPE_NAME(IteratorImplementation_)<float, double>;
template class MAKE_TYPE_NAME(IteratorImplementation_)<double, double>;
}
#define MAKE_INIT_FN__(a, b) init_ ## a ## b #define MAKE_INIT_FN__(a, b) init_ ## a ## b
#define MAKE_INIT_FN_(a, b) MAKE_INIT_FN__(a, b) #define MAKE_INIT_FN_(a, b) MAKE_INIT_FN__(a, b)
#define MAKE_INIT_FN(t) MAKE_INIT_FN_(t, IfcSchema) #define MAKE_INIT_FN(t) MAKE_INIT_FN_(t, IfcSchema)
namespace { namespace {
template <typename P, typename PP>
struct MAKE_TYPE_NAME(factory_t) { struct MAKE_TYPE_NAME(factory_t) {
IfcGeom::IteratorImplementation<P, PP>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads) const { IfcGeom::IteratorImplementation* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads) const {
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<P, PP>(settings, file, filters, num_threads); return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)(settings, file, filters, num_threads);
} }
}; };
} }
template <typename P, typename PP> void MAKE_INIT_FN(IteratorImplementation_)(IteratorFactoryImplementation* mapping) {
void MAKE_INIT_FN(IteratorImplementation_)(IteratorFactoryImplementation<P, PP>* mapping) {
static const std::string schema_name = STRINGIFY(IfcSchema); static const std::string schema_name = STRINGIFY(IfcSchema);
MAKE_TYPE_NAME(factory_t)<P, PP> factory; MAKE_TYPE_NAME(factory_t) factory;
mapping->bind(schema_name, factory); mapping->bind(schema_name, factory);
} }
template void MAKE_INIT_FN(IteratorImplementation_)<float, float>(IteratorFactoryImplementation<float, float>*);
template void MAKE_INIT_FN(IteratorImplementation_)<float, double>(IteratorFactoryImplementation<float, double>*);
template void MAKE_INIT_FN(IteratorImplementation_)<double, double>(IteratorFactoryImplementation<double, double>*);
+46 -52
View File
@@ -100,24 +100,22 @@
#endif #endif
namespace { namespace {
template <typename P, typename PP=P>
struct geometry_conversion_task { struct geometry_conversion_task {
int index; int index;
IfcSchema::IfcRepresentation *representation; IfcSchema::IfcRepresentation *representation;
IfcSchema::IfcProduct::list::ptr products; IfcSchema::IfcProduct::list::ptr products;
std::vector<IfcGeom::BRepElement<P, PP>*> breps; std::vector<IfcGeom::BRepElement*> breps;
std::vector<IfcGeom::Element<P, PP>*> elements; std::vector<IfcGeom::Element*> elements;
}; };
template <typename P, typename PP=P> IfcGeom::Element* process_based_on_settings(
IfcGeom::Element<P, PP>* process_based_on_settings(
const IfcGeom::IteratorSettings& settings, const IfcGeom::IteratorSettings& settings,
IfcGeom::BRepElement<P, PP>* elem, IfcGeom::BRepElement* elem,
IfcGeom::TriangulationElement<P, PP>* previous=nullptr) IfcGeom::TriangulationElement* previous=nullptr)
{ {
if (settings.get(IfcGeom::IteratorSettings::USE_BREP_DATA)) { if (settings.get(IfcGeom::IteratorSettings::USE_BREP_DATA)) {
try { try {
return new IfcGeom::SerializedElement<P, PP>(*elem); return new IfcGeom::SerializedElement(*elem);
} catch (...) { } catch (...) {
Logger::Message(Logger::LOG_ERROR, "Getting a serialized element from model failed."); Logger::Message(Logger::LOG_ERROR, "Getting a serialized element from model failed.");
return nullptr; return nullptr;
@@ -125,9 +123,9 @@ namespace {
} else if (!settings.get(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION)) { } else if (!settings.get(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION)) {
try { try {
if (!previous) { if (!previous) {
return new IfcGeom::TriangulationElement<P, PP>(*elem); return new IfcGeom::TriangulationElement(*elem);
} else { } else {
return new IfcGeom::TriangulationElement<P, PP>(*elem, previous->geometry_pointer()); return new IfcGeom::TriangulationElement(*elem, previous->geometry_pointer());
} }
} catch (...) { } catch (...) {
Logger::Message(Logger::LOG_ERROR, "Getting a triangulation element from model failed."); Logger::Message(Logger::LOG_ERROR, "Getting a triangulation element from model failed.");
@@ -138,15 +136,14 @@ namespace {
} }
} }
template <typename P, typename PP = P>
void create_element( void create_element(
IfcGeom::MAKE_TYPE_NAME(Kernel)* kernel, IfcGeom::MAKE_TYPE_NAME(Kernel)* kernel,
const IfcGeom::IteratorSettings& settings, const IfcGeom::IteratorSettings& settings,
geometry_conversion_task<P, PP>* rep) geometry_conversion_task* rep)
{ {
IfcSchema::IfcRepresentation *representation = rep->representation; IfcSchema::IfcRepresentation *representation = rep->representation;
IfcSchema::IfcProduct *product = *rep->products->begin(); IfcSchema::IfcProduct *product = *rep->products->begin();
auto brep = kernel->create_brep_for_representation_and_product<P, PP>(settings, representation, product); auto brep = kernel->create_brep_for_representation_and_product(settings, representation, product);
if (!brep) { if (!brep) {
return; return;
} }
@@ -160,9 +157,9 @@ namespace {
rep->elements = { elem }; rep->elements = { elem };
for (auto it = rep->products->begin() + 1; it != rep->products->end(); ++it) { for (auto it = rep->products->begin() + 1; it != rep->products->end(); ++it) {
auto brep2 = kernel->create_brep_for_processed_representation<P, PP>(settings, representation, *it, brep); auto brep2 = kernel->create_brep_for_processed_representation(settings, representation, *it, brep);
if (brep2) { if (brep2) {
auto elem2 = process_based_on_settings(settings, brep2, dynamic_cast<IfcGeom::TriangulationElement<P, PP>*>(elem)); auto elem2 = process_based_on_settings(settings, brep2, dynamic_cast<IfcGeom::TriangulationElement*>(elem));
if (elem2) { if (elem2) {
rep->breps.push_back(brep2); rep->breps.push_back(brep2);
rep->elements.push_back(elem2); rep->elements.push_back(elem2);
@@ -174,16 +171,15 @@ namespace {
namespace IfcGeom { namespace IfcGeom {
template <typename P, typename PP> class MAKE_TYPE_NAME(IteratorImplementation_) : public IteratorImplementation {
class MAKE_TYPE_NAME(IteratorImplementation_) : public IteratorImplementation<P, PP> {
private: private:
std::atomic<int> progress_; std::atomic<int> progress_;
std::vector<geometry_conversion_task<P, PP>> tasks_; std::vector<geometry_conversion_task> tasks_;
std::vector<IfcGeom::Element<P, PP>*> all_processed_elements_; std::vector<IfcGeom::Element*> all_processed_elements_;
std::vector<IfcGeom::BRepElement<P, PP>*> all_processed_native_elements_; std::vector<IfcGeom::BRepElement*> all_processed_native_elements_;
typename std::vector<IfcGeom::Element<P, PP>*>::const_iterator task_result_iterator_; typename std::vector<IfcGeom::Element*>::const_iterator task_result_iterator_;
typename std::vector<IfcGeom::BRepElement<P, PP>*>::const_iterator native_task_result_iterator_; typename std::vector<IfcGeom::BRepElement*>::const_iterator native_task_result_iterator_;
MAKE_TYPE_NAME(IteratorImplementation_)(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I MAKE_TYPE_NAME(IteratorImplementation_)(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I
MAKE_TYPE_NAME(IteratorImplementation_)& operator=(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I MAKE_TYPE_NAME(IteratorImplementation_)& operator=(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I
@@ -201,9 +197,9 @@ namespace IfcGeom {
IfcSchema::IfcRepresentation::list::it representation_iterator; IfcSchema::IfcRepresentation::list::it representation_iterator;
// The object is fetched beforehand to be sure that get() returns a valid element // The object is fetched beforehand to be sure that get() returns a valid element
TriangulationElement<P, PP>* current_triangulation; TriangulationElement* current_triangulation;
BRepElement<P, PP>* current_shape_model; BRepElement* current_shape_model;
SerializedElement<P, PP>* current_serialization; SerializedElement* current_serialization;
// A container and iterator for IfcBuildingElements for the current IfcRepresentation referenced by *representation_iterator // A container and iterator for IfcBuildingElements for the current IfcRepresentation referenced by *representation_iterator
IfcSchema::IfcProduct::list::ptr ifcproducts; IfcSchema::IfcProduct::list::ptr ifcproducts;
@@ -243,8 +239,6 @@ namespace IfcGeom {
/// @todo public/private sections all over the place: move all public to the beginning of the class /// @todo public/private sections all over the place: move all public to the beginning of the class
public: public:
typedef P Precision;
typedef PP PlacementPrecision;
boost::optional<bool> initialization_outcome_; boost::optional<bool> initialization_outcome_;
@@ -402,7 +396,7 @@ namespace IfcGeom {
if (ifcproducts.get() != previous) { if (ifcproducts.get() != previous) {
previous = ifcproducts.get(); previous = ifcproducts.get();
if (ifcproducts->size()) { if (ifcproducts->size()) {
geometry_conversion_task<P, PP> t; geometry_conversion_task t;
t.index = i++; t.index = i++;
t.representation = *representation_iterator; t.representation = *representation_iterator;
t.products = ifcproducts; t.products = ifcproducts;
@@ -467,7 +461,7 @@ namespace IfcGeom {
} // for } // for
} // while } // while
std::future<void> fu = std::async(std::launch::async, create_element<P, PP>, K, std::ref(settings), &rep); std::future<void> fu = std::async(std::launch::async, create_element, K, std::ref(settings), &rep);
threadpool.emplace_back(std::move(fu)); threadpool.emplace_back(std::move(fu));
} }
@@ -506,15 +500,15 @@ namespace IfcGeom {
if (with_geometry) { if (with_geometry) {
size_t num_created = 0; size_t num_created = 0;
do { do {
IfcGeom::Element<P, PP>* geom_object = get(); IfcGeom::Element* geom_object = get();
const IfcGeom::TriangulationElement<P, PP>* o = static_cast<const IfcGeom::TriangulationElement<P, PP>*>(geom_object); const IfcGeom::TriangulationElement* o = static_cast<const IfcGeom::TriangulationElement*>(geom_object);
const IfcGeom::Representation::Triangulation<P>& mesh = o->geometry(); const IfcGeom::Representation::Triangulation& mesh = o->geometry();
const gp_XYZ& pos = o->transformation().data().TranslationPart(); const gp_XYZ& pos = o->transformation().data().TranslationPart();
for (typename std::vector<P>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end();) { for (typename std::vector<double>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end();) {
const P x = *(it++); const double& x = *(it++);
const P y = *(it++); const double& y = *(it++);
const P z = *(it++); const double& z = *(it++);
bounds_min_.SetX(std::min(bounds_min_.X(), pos.X() + x)); bounds_min_.SetX(std::min(bounds_min_.X(), pos.X() + x));
bounds_min_.SetY(std::min(bounds_min_.Y(), pos.Y() + y)); bounds_min_.SetY(std::min(bounds_min_.Y(), pos.Y() + y));
@@ -729,7 +723,7 @@ namespace IfcGeom {
} }
} }
BRepElement<P, PP>* create_shape_model_for_next_entity() { BRepElement* create_shape_model_for_next_entity() {
for (;;) { for (;;) {
auto rp = get_next_task(); auto rp = get_next_task();
if (!rp) { if (!rp) {
@@ -740,9 +734,9 @@ namespace IfcGeom {
Logger::SetProduct(product); Logger::SetProduct(product);
BRepElement<P, PP>* element; BRepElement* element;
if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) { if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) {
element = kernel.create_brep_for_representation_and_product<P, PP>(settings, representation, product); element = kernel.create_brep_for_representation_and_product(settings, representation, product);
} else { } else {
element = kernel.create_brep_for_processed_representation(settings, representation, product, current_shape_model); element = kernel.create_brep_for_processed_representation(settings, representation, product, current_shape_model);
} }
@@ -806,10 +800,10 @@ namespace IfcGeom {
} }
/// Gets the representation of the current geometrical entity. /// Gets the representation of the current geometrical entity.
Element<P, PP>* get() Element* get()
{ {
// TODO: Test settings and throw // TODO: Test settings and throw
Element<P, PP>* ret = 0; Element* ret = 0;
if (num_threads_ != 1) { if (num_threads_ != 1) {
ret = *task_result_iterator_; ret = *task_result_iterator_;
@@ -828,12 +822,12 @@ namespace IfcGeom {
{ {
// We are going to build a vector with the element parents. // We are going to build a vector with the element parents.
// First, create the parent vector // First, create the parent vector
std::vector<const IfcGeom::Element<P, PP>*> parents; std::vector<const IfcGeom::Element*> parents;
// if the element has a parent // if the element has a parent
if (ret->parent_id() != -1) if (ret->parent_id() != -1)
{ {
const IfcGeom::Element<P, PP>* parent_object = NULL; const IfcGeom::Element* parent_object = NULL;
bool hasParent = true; bool hasParent = true;
// get the parent // get the parent
@@ -873,7 +867,7 @@ namespace IfcGeom {
} }
/// Gets the native (Open Cascade) representation of the current geometrical entity. /// Gets the native (Open Cascade) representation of the current geometrical entity.
BRepElement<P, PP>* get_native() BRepElement* get_native()
{ {
// TODO: Test settings and throw // TODO: Test settings and throw
if (num_threads_ != 1) { if (num_threads_ != 1) {
@@ -883,7 +877,7 @@ namespace IfcGeom {
} }
} }
const Element<P, PP>* get_object(int id) { const Element* get_object(int id) {
gp_Trsf trsf; gp_Trsf trsf;
int parent_id = -1; int parent_id = -1;
std::string instance_type, product_name, product_guid; std::string instance_type, product_name, product_guid;
@@ -935,14 +929,14 @@ namespace IfcGeom {
ElementSettings element_settings(settings, unit_magnitude, instance_type); ElementSettings element_settings(settings, unit_magnitude, instance_type);
Element<P, PP>* ifc_object = new Element<P, PP>(element_settings, id, parent_id, product_name, instance_type, product_guid, "", trsf, ifc_product); Element* ifc_object = new Element(element_settings, id, parent_id, product_name, instance_type, product_guid, "", trsf, ifc_product);
return ifc_object; return ifc_object;
} }
IfcUtil::IfcBaseClass* create() { IfcUtil::IfcBaseClass* create() {
IfcGeom::BRepElement<P, PP>* next_shape_model = 0; IfcGeom::BRepElement* next_shape_model = 0;
IfcGeom::SerializedElement<P, PP>* next_serialization = 0; IfcGeom::SerializedElement* next_serialization = 0;
IfcGeom::TriangulationElement<P, PP>* next_triangulation = 0; IfcGeom::TriangulationElement* next_triangulation = 0;
try { try {
next_shape_model = create_shape_model_for_next_entity(); next_shape_model = create_shape_model_for_next_entity();
@@ -961,16 +955,16 @@ namespace IfcGeom {
if (next_shape_model) { if (next_shape_model) {
if (settings.get(IteratorSettings::USE_BREP_DATA)) { if (settings.get(IteratorSettings::USE_BREP_DATA)) {
try { try {
next_serialization = new SerializedElement<P, PP>(*next_shape_model); next_serialization = new SerializedElement(*next_shape_model);
} catch (...) { } catch (...) {
Logger::Message(Logger::LOG_ERROR, "Getting a serialized element from model failed."); Logger::Message(Logger::LOG_ERROR, "Getting a serialized element from model failed.");
} }
} else if (!settings.get(IteratorSettings::DISABLE_TRIANGULATION)) { } else if (!settings.get(IteratorSettings::DISABLE_TRIANGULATION)) {
try { try {
if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) { if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) {
next_triangulation = new TriangulationElement<P, PP>(*next_shape_model); next_triangulation = new TriangulationElement(*next_shape_model);
} else { } else {
next_triangulation = new TriangulationElement<P, PP>(*next_shape_model, current_triangulation->geometry_pointer()); next_triangulation = new TriangulationElement(*next_shape_model, current_triangulation->geometry_pointer());
} }
} catch (...) { } catch (...) {
Logger::Message(Logger::LOG_ERROR, "Getting a triangulation element from model failed."); Logger::Message(Logger::LOG_ERROR, "Getting a triangulation element from model failed.");
+21 -22
View File
@@ -101,22 +101,21 @@ namespace IfcGeom {
Serialization& operator=(const Serialization&); Serialization& operator=(const Serialization&);
}; };
template <typename P>
class Triangulation : public Representation { class Triangulation : public Representation {
private: private:
// A nested pair of floats and a material index to be able to store an XYZ coordinate in a map. // A nested pair of floats and a material index to be able to store an XYZ coordinate in a map.
// TODO: Make this a std::tuple when compilers add support for that. // TODO: Make this a std::tuple when compilers add support for that.
typedef typename std::pair<P, std::pair<P, P> > Coordinate; typedef typename std::pair<double, std::pair<double, double> > Coordinate;
typedef typename std::pair<int, Coordinate> VertexKey; typedef typename std::pair<int, Coordinate> VertexKey;
typedef std::map<VertexKey, int> VertexKeyMap; typedef std::map<VertexKey, int> VertexKeyMap;
typedef std::pair<int, int> Edge; typedef std::pair<int, int> Edge;
std::string id_; std::string id_;
std::vector<P> _verts; std::vector<double> _verts;
std::vector<int> _faces; std::vector<int> _faces;
std::vector<int> _edges; std::vector<int> _edges;
std::vector<P> _normals; std::vector<double> _normals;
std::vector<P> uvs_; std::vector<double> uvs_;
std::vector<int> _material_ids; std::vector<int> _material_ids;
std::vector<Material> _materials; std::vector<Material> _materials;
size_t weld_offset_; size_t weld_offset_;
@@ -124,11 +123,11 @@ namespace IfcGeom {
public: public:
const std::string& id() const { return id_; } const std::string& id() const { return id_; }
const std::vector<P>& verts() const { return _verts; } const std::vector<double>& verts() const { return _verts; }
const std::vector<int>& faces() const { return _faces; } const std::vector<int>& faces() const { return _faces; }
const std::vector<int>& edges() const { return _edges; } const std::vector<int>& edges() const { return _edges; }
const std::vector<P>& normals() const { return _normals; } const std::vector<double>& normals() const { return _normals; }
const std::vector<P>& uvs() const { return uvs_; } const std::vector<double>& uvs() const { return uvs_; }
const std::vector<int>& material_ids() const { return _material_ids; } const std::vector<int>& material_ids() const { return _material_ids; }
const std::vector<Material>& materials() const { return _materials; } const std::vector<Material>& materials() const { return _materials; }
@@ -232,9 +231,9 @@ namespace IfcGeom {
} }
// TODO: Do the same for conical surfaces, but they are rare in IFC. // TODO: Do the same for conical surfaces, but they are rare in IFC.
} }
_normals.push_back(static_cast<P>(normal.X())); _normals.push_back(normal.X());
_normals.push_back(static_cast<P>(normal.Y())); _normals.push_back(normal.Y());
_normals.push_back(static_cast<P>(normal.Z())); _normals.push_back(normal.Z());
} }
} }
@@ -336,9 +335,9 @@ namespace IfcGeom {
segments.push_back(std::make_pair(right, current)); segments.push_back(std::make_pair(right, current));
} }
for (auto& s : segments) { for (auto& sgmt : segments) {
_edges.push_back(s.first); _edges.push_back(sgmt.first);
_edges.push_back(s.second); _edges.push_back(sgmt.second);
_material_ids.push_back(surface_style_id); _material_ids.push_back(surface_style_id);
} }
@@ -354,16 +353,16 @@ namespace IfcGeom {
/// Generates UVs for a single mesh using box projection. /// Generates UVs for a single mesh using box projection.
/// @todo Very simple impl. Assumes that input vertices and normals match 1:1. /// @todo Very simple impl. Assumes that input vertices and normals match 1:1.
static std::vector<P> box_project_uvs(const std::vector<P> &vertices, const std::vector<P> &normals) static std::vector<double> box_project_uvs(const std::vector<double> &vertices, const std::vector<double> &normals)
{ {
std::vector<P> uvs; std::vector<double> uvs;
uvs.resize(vertices.size() / 3 * 2); uvs.resize(vertices.size() / 3 * 2);
for (size_t uv_idx = 0, v_idx = 0; for (size_t uv_idx = 0, v_idx = 0;
uv_idx < uvs.size() && v_idx < vertices.size() && v_idx < normals.size(); uv_idx < uvs.size() && v_idx < vertices.size() && v_idx < normals.size();
uv_idx += 2, v_idx += 3) { uv_idx += 2, v_idx += 3) {
P n_x = normals[v_idx], n_y = normals[v_idx + 1], n_z = normals[v_idx + 2]; double n_x = normals[v_idx], n_y = normals[v_idx + 1], n_z = normals[v_idx + 2];
P v_x = vertices[v_idx], v_y = vertices[v_idx + 1], v_z = vertices[v_idx + 2]; double v_x = vertices[v_idx], v_y = vertices[v_idx + 1], v_z = vertices[v_idx + 2];
if (std::abs(n_x) > std::abs(n_y) && std::abs(n_x) > std::abs(n_z)) { if (std::abs(n_x) > std::abs(n_y) && std::abs(n_x) > std::abs(n_z)) {
uvs[uv_idx] = v_z; uvs[uv_idx] = v_z;
@@ -386,15 +385,15 @@ namespace IfcGeom {
// Welds vertices that belong to different faces // Welds vertices that belong to different faces
int addVertex(int material_index, const gp_XYZ& p) { int addVertex(int material_index, const gp_XYZ& p) {
const bool convert = settings().get(IteratorSettings::CONVERT_BACK_UNITS); const bool convert = settings().get(IteratorSettings::CONVERT_BACK_UNITS);
const P X = static_cast<P>(convert ? (p.X() / settings().unit_magnitude()) : p.X()); const double X = convert ? (p.X() / settings().unit_magnitude()) : p.X();
const P Y = static_cast<P>(convert ? (p.Y() / settings().unit_magnitude()) : p.Y()); const double Y = convert ? (p.Y() / settings().unit_magnitude()) : p.Y();
const P Z = static_cast<P>(convert ? (p.Z() / settings().unit_magnitude()) : p.Z()); const double Z = convert ? (p.Z() / settings().unit_magnitude()) : p.Z();
int i = (int) _verts.size() / 3; int i = (int) _verts.size() / 3;
if (settings().get(IteratorSettings::WELD_VERTICES)) { if (settings().get(IteratorSettings::WELD_VERTICES)) {
const VertexKey key = std::make_pair(material_index, std::make_pair(X, std::make_pair(Y, Z))); const VertexKey key = std::make_pair(material_index, std::make_pair(X, std::make_pair(Y, Z)));
typename VertexKeyMap::const_iterator it = welds.find(key); typename VertexKeyMap::const_iterator it = welds.find(key);
if ( it != welds.end() ) return it->second; if ( it != welds.end() ) return it->second;
i = (int) welds.size() + weld_offset_; i = (int) (welds.size() + weld_offset_);
welds[key] = i; welds[key] = i;
} }
_verts.push_back(X); _verts.push_back(X);
+4 -4
View File
@@ -287,7 +287,7 @@ namespace IfcGeom {
add_file(f, settings); add_file(f, settings);
} }
tree(IfcGeom::Iterator<double>& it) { tree(IfcGeom::Iterator& it) {
add_file(it); add_file(it);
} }
@@ -297,15 +297,15 @@ namespace IfcGeom {
settings_.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true); settings_.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
settings_.set(IfcGeom::IteratorSettings::SEW_SHELLS, true); settings_.set(IfcGeom::IteratorSettings::SEW_SHELLS, true);
IfcGeom::Iterator<double> it(settings_, &f); IfcGeom::Iterator it(settings_, &f);
add_file(it); add_file(it);
} }
void add_file(IfcGeom::Iterator<double>& it) { void add_file(IfcGeom::Iterator& it) {
if (it.initialize()) { if (it.initialize()) {
do { do {
IfcGeom::BRepElement<double>* elem = (IfcGeom::BRepElement<double>*)it.get(); IfcGeom::BRepElement* elem = (IfcGeom::BRepElement*)it.get();
auto compound = elem->geometry().as_compound(); auto compound = elem->geometry().as_compound();
compound.Move(elem->transformation().data()); compound.Move(elem->transformation().data());
add((IfcUtil::IfcBaseEntity*)it.file()->instance_by_id(elem->id()), compound); add((IfcUtil::IfcBaseEntity*)it.file()->instance_by_id(elem->id()), compound);
@@ -70,7 +70,6 @@
namespace IfcGeom { namespace IfcGeom {
template <typename P = double, typename PP = P>
class Iterator { class Iterator {
private: private:
Iterator(const Iterator&); // N/I Iterator(const Iterator&); // N/I
@@ -80,7 +79,7 @@ namespace IfcGeom {
IfcGeom::IteratorSettings settings_; IfcGeom::IteratorSettings settings_;
std::vector<IfcGeom::filter_t> filters_; std::vector<IfcGeom::filter_t> filters_;
IteratorImplementation<P, PP>* implementation_; IteratorImplementation* implementation_;
public: public:
Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, int num_threads = 1) Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, int num_threads = 1)
@@ -88,20 +87,20 @@ namespace IfcGeom {
, settings_(settings) , settings_(settings)
{ {
try { try {
implementation_ = iterator_implementations<P, PP>().construct(file_->schema()->name(), settings, file, filters_, num_threads); implementation_ = iterator_implementations().construct(file_->schema()->name(), settings, file, filters_, num_threads);
} catch (const std::exception& e) { } catch (const std::exception& e) {
Logger::Error(e); Logger::Error(e);
implementation_ = nullptr; implementation_ = nullptr;
} }
} }
Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, size_t num_threads = 1) Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads = 1)
: file_(file) : file_(file)
, settings_(settings) , settings_(settings)
, filters_(filters) , filters_(filters)
{ {
try { try {
implementation_ = iterator_implementations<P, PP>().construct(file_->schema()->name(), settings, file, filters_, num_threads); implementation_ = iterator_implementations().construct(file_->schema()->name(), settings, file, filters_, num_threads);
} catch (const std::exception& e) { } catch (const std::exception& e) {
Logger::Error(e); Logger::Error(e);
implementation_ = nullptr; implementation_ = nullptr;
@@ -131,11 +130,11 @@ namespace IfcGeom {
IfcUtil::IfcBaseClass* next() const { return implementation_->next(); } IfcUtil::IfcBaseClass* next() const { return implementation_->next(); }
Element<P, PP>* get() { return implementation_->get(); } Element* get() { return implementation_->get(); }
BRepElement<P, PP>* get_native() { return implementation_->get_native(); } BRepElement* get_native() { return implementation_->get_native(); }
const Element<P, PP>* get_object(int id) { return implementation_->get_object(id); } const Element* get_object(int id) { return implementation_->get_object(id); }
IfcUtil::IfcBaseClass* create() { return implementation_->create(); } IfcUtil::IfcBaseClass* create() { return implementation_->create(); }
}; };
@@ -2,48 +2,36 @@
#include <boost/algorithm/string/case_conv.hpp> #include <boost/algorithm/string/case_conv.hpp>
template <typename P, typename PP> IteratorFactoryImplementation& iterator_implementations() {
IteratorFactoryImplementation<P, PP>& iterator_implementations() { static IteratorFactoryImplementation impl;
static IteratorFactoryImplementation<P, PP> impl;
return impl; return impl;
} }
template IteratorFactoryImplementation<float, float>& iterator_implementations<float, float>();
template IteratorFactoryImplementation<float, double>& iterator_implementations<float, double>();
template IteratorFactoryImplementation<double, double>& iterator_implementations<double, double>();
#ifdef HAS_SCHEMA_2x3 #ifdef HAS_SCHEMA_2x3
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P, PP>*);
#endif #endif
#ifdef HAS_SCHEMA_4 #ifdef HAS_SCHEMA_4
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P, PP>*);
#endif #endif
#ifdef HAS_SCHEMA_4x1 #ifdef HAS_SCHEMA_4x1
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc4x1(IteratorFactoryImplementation<P, PP>*);
#endif #endif
#ifdef HAS_SCHEMA_4x2 #ifdef HAS_SCHEMA_4x2
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc4x2(IteratorFactoryImplementation<P, PP>*);
#endif #endif
#ifdef HAS_SCHEMA_4x3_rc1 #ifdef HAS_SCHEMA_4x3_rc1
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc4x3_rc1(IteratorFactoryImplementation<P, PP>*);
#endif #endif
#ifdef HAS_SCHEMA_4x3_rc2 #ifdef HAS_SCHEMA_4x3_rc2
template <typename P, typename PP> extern void init_IteratorImplementation_Ifc4x3_rc2(IteratorFactoryImplementation*);
extern void init_IteratorImplementation_Ifc4x3_rc2(IteratorFactoryImplementation<P, PP>*);
#endif #endif
template <typename P, typename PP> IteratorFactoryImplementation::IteratorFactoryImplementation() {
IteratorFactoryImplementation<P, PP>::IteratorFactoryImplementation() {
#ifdef HAS_SCHEMA_2x3 #ifdef HAS_SCHEMA_2x3
init_IteratorImplementation_Ifc2x3(this); init_IteratorImplementation_Ifc2x3(this);
#endif #endif
@@ -64,24 +52,17 @@ IteratorFactoryImplementation<P, PP>::IteratorFactoryImplementation() {
#endif #endif
} }
template <typename P, typename PP> void IteratorFactoryImplementation::bind(const std::string& schema_name, iterator_fn fn) {
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); const std::string schema_name_lower = boost::to_lower_copy(schema_name);
this->insert(std::make_pair(schema_name_lower, fn)); this->insert(std::make_pair(schema_name_lower, fn));
} }
template <typename P, typename PP> 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) {
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) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name); const std::string schema_name_lower = boost::to_lower_copy(schema_name);
typename std::map<std::string, typename get_factory_type<P, PP>::type>::const_iterator it; typename std::map<std::string, iterator_fn>::const_iterator it;
it = this->find(schema_name_lower); it = this->find(schema_name_lower);
if (it == this->end()) { if (it == this->end()) {
throw IfcParse::IfcException("No geometry iterator registered for " + schema_name); throw IfcParse::IfcException("No geometry iterator registered for " + schema_name);
} }
return it->second(settings, file, filters, num_threads); return it->second(settings, file, filters, num_threads);
} }
template class IteratorFactoryImplementation<float, float>;
template class IteratorFactoryImplementation<float, double>;
template class IteratorFactoryImplementation<double, double>;
@@ -13,52 +13,26 @@
#include <string> #include <string>
namespace IfcGeom { namespace IfcGeom {
template <typename P, typename PP>
class IteratorImplementation; class IteratorImplementation;
template <typename P, typename PP>
class Element; class Element;
template <typename P, typename PP>
class BRepElement; class BRepElement;
} }
typedef boost::function4<IfcGeom::IteratorImplementation<float, float>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int> iterator_float_float_fn; typedef boost::function4<IfcGeom::IteratorImplementation*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int> iterator_fn;
typedef boost::function4<IfcGeom::IteratorImplementation<float, double>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int> iterator_float_double_fn;
typedef boost::function4<IfcGeom::IteratorImplementation<double, double>*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int> iterator_double_double_fn;
template <typename P, typename PP> class IteratorFactoryImplementation : public std::map<std::string, iterator_fn> {
struct get_factory_type {};
template <>
struct get_factory_type<float, float> {
typedef iterator_float_float_fn type;
};
template <>
struct get_factory_type<float, double> {
typedef iterator_float_double_fn 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: public:
IteratorFactoryImplementation(); IteratorFactoryImplementation();
void bind(const std::string& schema_name, typename get_factory_type<P, PP>::type fn); void bind(const std::string& schema_name, iterator_fn fn);
IfcGeom::IteratorImplementation<P, PP>* construct(const std::string& schema_name, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int); IfcGeom::IteratorImplementation* construct(const std::string& schema_name, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector<IfcGeom::filter_t>&, int);
}; };
template <typename P, typename PP> IteratorFactoryImplementation& iterator_implementations();
IteratorFactoryImplementation<P, PP>& iterator_implementations();
namespace IfcGeom { namespace IfcGeom {
template <typename P, typename PP>
class IteratorImplementation { class IteratorImplementation {
public: public:
virtual bool initialize() = 0; virtual bool initialize() = 0;
@@ -70,9 +44,9 @@ namespace IfcGeom {
virtual double getUnitMagnitude() const = 0; virtual double getUnitMagnitude() const = 0;
virtual IfcParse::IfcFile* file() const = 0; virtual IfcParse::IfcFile* file() const = 0;
virtual IfcUtil::IfcBaseClass* next() = 0; virtual IfcUtil::IfcBaseClass* next() = 0;
virtual Element<P, PP>* get() = 0; virtual Element* get() = 0;
virtual BRepElement<P, PP>* get_native() = 0; virtual BRepElement* get_native() = 0;
virtual const Element<P, PP>* get_object(int id) = 0; virtual const Element* get_object(int id) = 0;
virtual IfcUtil::IfcBaseClass* create() = 0; virtual IfcUtil::IfcBaseClass* create() = 0;
}; };
+1 -2
View File
@@ -36,7 +36,6 @@
namespace IfcGeom { namespace IfcGeom {
template <typename P, typename PP>
class BRepElement; class BRepElement;
class Kernel { class Kernel {
@@ -91,7 +90,7 @@ namespace IfcGeom {
return implementation_->getValue(var); return implementation_->getValue(var);
} }
virtual BRepElement<double, double>* convert( virtual BRepElement* convert(
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation, const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
IfcUtil::IfcBaseClass* product) IfcUtil::IfcBaseClass* product)
{ {
+13 -13
View File
@@ -179,7 +179,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::close() {
void ColladaSerializer::ColladaExporter::ColladaScene::add( void ColladaSerializer::ColladaExporter::ColladaScene::add(
const std::string& node_id, const std::string& node_name, const std::string& geom_name, const std::string& node_id, const std::string& node_name, const std::string& geom_name,
const std::vector<std::string>& material_ids, const IfcGeom::Transformation<double>& transformation) const std::vector<std::string>& material_ids, const IfcGeom::Transformation& transformation)
{ {
if (!scene_opened) { if (!scene_opened) {
openVisualScene(scene_id); openVisualScene(scene_id);
@@ -194,13 +194,13 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
// The matrix attribute of an entity is basically a 4x3 representation of its ObjectPlacement. // The matrix attribute of an entity is basically a 4x3 representation of its ObjectPlacement.
// Note that this placement is absolute, ie it is multiplied with all parent placements. // Note that this placement is absolute, ie it is multiplied with all parent placements.
IfcGeom::Transformation<double>* relative_trsf = 0; IfcGeom::Transformation* relative_trsf = 0;
const IfcGeom::Transformation<double>* transformation_towrite = &transformation; const IfcGeom::Transformation* transformation_towrite = &transformation;
// If this is not the first parent, get the relative placement // If this is not the first parent, get the relative placement
if (parentNodes.size() > 0) if (parentNodes.size() > 0)
{ {
relative_trsf = new IfcGeom::Transformation<double>(matrixStack.top().multiplied(transformation)); relative_trsf = new IfcGeom::Transformation(matrixStack.top().multiplied(transformation));
transformation_towrite = relative_trsf; transformation_towrite = relative_trsf;
} }
@@ -231,22 +231,22 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
node.end(); node.end();
} }
void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::Element<double>& parent){ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::Element& parent){
//we open the visual scene tag if it's not. //we open the visual scene tag if it's not.
if (!scene_opened) { if (!scene_opened) {
openVisualScene(scene_id); openVisualScene(scene_id);
scene_opened = true; scene_opened = true;
} }
const IfcGeom::Transformation<double>& parent_trsf = parent.transformation(); const IfcGeom::Transformation& parent_trsf = parent.transformation();
IfcGeom::Transformation<double>* relative_trsf = 0; IfcGeom::Transformation* relative_trsf = 0;
const IfcGeom::Transformation<double>* transformation_towrite = &parent_trsf; const IfcGeom::Transformation* transformation_towrite = &parent_trsf;
// If this is not the first parent, get the relative placement // If this is not the first parent, get the relative placement
if (parentNodes.size() > 0) if (parentNodes.size() > 0)
{ {
relative_trsf = new IfcGeom::Transformation<double>(matrixStack.top().multiplied(parent_trsf)); relative_trsf = new IfcGeom::Transformation(matrixStack.top().multiplied(parent_trsf));
transformation_towrite = relative_trsf; transformation_towrite = relative_trsf;
} }
@@ -390,9 +390,9 @@ void ColladaSerializer::ColladaExporter::startDocument(const std::string& unit_n
asset.add(); asset.add();
} }
void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationElement<double>* o) void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationElement* o)
{ {
const IfcGeom::Representation::Triangulation<double>& mesh = o->geometry(); const IfcGeom::Representation::Triangulation& mesh = o->geometry();
std::string name = serializer->object_id(o); std::string name = serializer->object_id(o);
collada_id(name); collada_id(name);
@@ -451,7 +451,7 @@ std::string ColladaSerializer::differentiateSlabTypes(const IfcUtil::IfcBaseEnti
return result; return result;
} }
std::string ColladaSerializer::object_id(const IfcGeom::Element<double>* o) /*override*/ std::string ColladaSerializer::object_id(const IfcGeom::Element* o) /*override*/
{ {
if (settings_.get(SerializerSettings::USE_ELEMENT_TYPES)) { if (settings_.get(SerializerSettings::USE_ELEMENT_TYPES)) {
const std::string slabSuffix = (o->product() && o->product()->declaration().name() == "IfcSlab") const std::string slabSuffix = (o->product() && o->product()->declaration().name() == "IfcSlab")
@@ -544,7 +544,7 @@ void ColladaSerializer::writeHeader() {
exporter.startDocument(unit_name, unit_magnitude); exporter.startDocument(unit_name, unit_magnitude);
} }
void ColladaSerializer::write(const IfcGeom::TriangulationElement<double>* o) { void ColladaSerializer::write(const IfcGeom::TriangulationElement* o) {
exporter.write(o); exporter.write(o);
} }
+12 -12
View File
@@ -88,7 +88,7 @@ private:
const std::string scene_id; const std::string scene_id;
bool scene_opened; bool scene_opened;
std::stack<COLLADASW::Node*> parentNodes; std::stack<COLLADASW::Node*> parentNodes;
std::stack<IfcGeom::Transformation<double> > matrixStack; std::stack<IfcGeom::Transformation> matrixStack;
public: public:
ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer) ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer)
: COLLADASW::LibraryVisualScenes(&stream) : COLLADASW::LibraryVisualScenes(&stream)
@@ -97,8 +97,8 @@ private:
, serializer(_serializer) , serializer(_serializer)
{} {}
void add(const std::string& node_id, const std::string& node_name, const std::string& geom_name, void add(const std::string& node_id, const std::string& node_name, const std::string& geom_name,
const std::vector<std::string>& material_ids, const IfcGeom::Transformation<double>& matrix); const std::vector<std::string>& material_ids, const IfcGeom::Transformation& matrix);
void addParent(const IfcGeom::Element<double>& parent); void addParent(const IfcGeom::Element& parent);
void closeParent(); void closeParent();
COLLADASW::Node* GetDirectParent(); COLLADASW::Node* GetDirectParent();
void write(); void write();
@@ -158,7 +158,7 @@ private:
public: public:
std::string unique_id, representation_id, type; std::string unique_id, representation_id, type;
IfcGeom::Transformation<double> transformation; IfcGeom::Transformation transformation;
std::vector<double> vertices; std::vector<double> vertices;
std::vector<double> normals; std::vector<double> normals;
std::vector<int> faces; std::vector<int> faces;
@@ -167,9 +167,9 @@ private:
std::vector<IfcGeom::Material> materials; std::vector<IfcGeom::Material> materials;
std::vector<std::string> material_references; std::vector<std::string> material_references;
std::vector<double> uvs; std::vector<double> uvs;
std::vector<const IfcGeom::Element<double>*> parents_; std::vector<const IfcGeom::Element*> parents_;
DeferredObject(const std::string& unique_id, const std::string& representation_id, const std::string& type, const IfcGeom::Transformation<double>& transformation, DeferredObject(const std::string& unique_id, const std::string& representation_id, const std::string& type, const IfcGeom::Transformation& transformation,
const std::vector<double>& vertices, const std::vector<double>& normals, const std::vector<int>& faces, const std::vector<double>& vertices, const std::vector<double>& normals, const std::vector<int>& faces,
const std::vector<int>& edges, const std::vector<int>& material_ids, const std::vector<IfcGeom::Material>& materials, const std::vector<int>& edges, const std::vector<int>& material_ids, const std::vector<IfcGeom::Material>& materials,
const std::vector<std::string>& material_references, const std::vector<double>& uvs) const std::vector<std::string>& material_references, const std::vector<double>& uvs)
@@ -187,8 +187,8 @@ private:
, uvs(uvs) , uvs(uvs)
{} {}
std::vector<const IfcGeom::Element<double>*>& parents() { return parents_; } std::vector<const IfcGeom::Element*>& parents() { return parents_; }
const std::vector<const IfcGeom::Element<double>*>& parents() const { return parents_; } const std::vector<const IfcGeom::Element*>& parents() const { return parents_; }
}; };
COLLADABU::NativeString filename; COLLADABU::NativeString filename;
COLLADASW::StreamWriter stream; COLLADASW::StreamWriter stream;
@@ -211,7 +211,7 @@ private:
std::vector<DeferredObject> deferreds; std::vector<DeferredObject> deferreds;
virtual ~ColladaExporter() {} virtual ~ColladaExporter() {}
void startDocument(const std::string& unit_name, float unit_magnitude); void startDocument(const std::string& unit_name, float unit_magnitude);
void write(const IfcGeom::TriangulationElement<double>* o); void write(const IfcGeom::TriangulationElement* o);
void endDocument(); void endDocument();
}; };
ColladaExporter exporter; ColladaExporter exporter;
@@ -229,8 +229,8 @@ public:
} }
bool ready(); bool ready();
void writeHeader(); void writeHeader();
void write(const IfcGeom::TriangulationElement<double>* o); void write(const IfcGeom::TriangulationElement* o);
void write(const IfcGeom::BRepElement<double>* /*o*/) {} void write(const IfcGeom::BRepElement* /*o*/) {}
void finalize(); void finalize();
bool isTesselated() const { return true; } bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& name, float magnitude) { void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
@@ -239,7 +239,7 @@ public:
} }
void setFile(IfcParse::IfcFile*) {} void setFile(IfcParse::IfcFile*) {}
std::string object_id(const IfcGeom::Element<double>* o) /*override*/; std::string object_id(const IfcGeom::Element* o) /*override*/;
private: private:
static std::string differentiateSlabTypes(const IfcUtil::IfcBaseEntity* slab); static std::string differentiateSlabTypes(const IfcUtil::IfcBaseEntity* slab);
+3 -3
View File
@@ -70,15 +70,15 @@ public:
virtual ~GeometrySerializer() {} virtual ~GeometrySerializer() {}
virtual bool isTesselated() const = 0; virtual bool isTesselated() const = 0;
virtual void write(const IfcGeom::TriangulationElement<double>* o) = 0; virtual void write(const IfcGeom::TriangulationElement* o) = 0;
virtual void write(const IfcGeom::BRepElement<double>* o) = 0; virtual void write(const IfcGeom::BRepElement* o) = 0;
virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0; virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0;
const SerializerSettings& settings() const { return settings_; } const SerializerSettings& settings() const { return settings_; }
SerializerSettings& settings() { return settings_; } SerializerSettings& settings() { return settings_; }
/// Returns ID for the object depending on the used setting. /// Returns ID for the object depending on the used setting.
virtual std::string object_id(const IfcGeom::Element<double>* o) virtual std::string object_id(const IfcGeom::Element* o)
{ {
if (settings_.get(SerializerSettings::USE_ELEMENT_GUIDS)) return o->guid(); if (settings_.get(SerializerSettings::USE_ELEMENT_GUIDS)) return o->guid();
if (settings_.get(SerializerSettings::USE_ELEMENT_NAMES)) return o->name(); if (settings_.get(SerializerSettings::USE_ELEMENT_NAMES)) return o->name();
+1 -1
View File
@@ -157,7 +157,7 @@ size_t write_accessor(json& j, std::ofstream& ofs, It begin, It end) {
return j["accessors"].size() - 1; return j["accessors"].size() - 1;
} }
void GltfSerializer::write(const IfcGeom::TriangulationElement<double>* o) { void GltfSerializer::write(const IfcGeom::TriangulationElement* o) {
if (o->geometry().material_ids().empty()) { if (o->geometry().material_ids().empty()) {
return; return;
} }
+2 -2
View File
@@ -42,8 +42,8 @@ public:
virtual ~GltfSerializer(); virtual ~GltfSerializer();
bool ready(); bool ready();
void writeHeader(); void writeHeader();
void write(const IfcGeom::TriangulationElement<double>* o); void write(const IfcGeom::TriangulationElement* o);
void write(const IfcGeom::BRepElement<double>* /*o*/) {} void write(const IfcGeom::BRepElement* /*o*/) {}
void finalize(); void finalize();
bool isTesselated() const { return true; } bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
+3 -3
View File
@@ -54,7 +54,7 @@ void HdfSerializer::writeHeader() {
} }
void HdfSerializer::write(const IfcGeom::BRepElement<double>* o) { void HdfSerializer::write(const IfcGeom::BRepElement* o) {
std::string guid = o->guid(); std::string guid = o->guid();
@@ -72,8 +72,8 @@ void HdfSerializer::write(const IfcGeom::BRepElement<double>* o) {
const IfcGeom::Representation::Serialization serialization(brepmesh); const IfcGeom::Representation::Serialization serialization(brepmesh);
std::string brep_data = serialization.brep_data(); std::string brep_data = serialization.brep_data();
const IfcGeom::TriangulationElement<double>triangular_element(*o); const IfcGeom::TriangulationElement triangular_element(*o);
const IfcGeom::Representation::Triangulation<double>& mesh = triangular_element.geometry(); const IfcGeom::Representation::Triangulation& mesh = triangular_element.geometry();
const int vcount = (int)mesh.verts().size() / 3; const int vcount = (int)mesh.verts().size() / 3;
const int fcount = (int)mesh.faces().size() / 3; const int fcount = (int)mesh.faces().size() / 3;
const bool isyup = settings().get(SerializerSettings::USE_Y_UP); const bool isyup = settings().get(SerializerSettings::USE_Y_UP);
+2 -2
View File
@@ -46,8 +46,8 @@ public:
virtual ~HdfSerializer() {} virtual ~HdfSerializer() {}
bool ready(); bool ready();
void writeHeader(); void writeHeader();
void write(const IfcGeom::BRepElement<double>* o); void write(const IfcGeom::BRepElement* o);
void write(const IfcGeom::TriangulationElement<double>* /*o*/) {} void write(const IfcGeom::TriangulationElement* /*o*/) {}
void finalize() {} void finalize() {}
bool isTesselated() const { return false; } bool isTesselated() const { return false; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
@@ -36,7 +36,7 @@ bool OpenCascadeBasedSerializer::ready() {
return succeeded; return succeeded;
} }
void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement<double>* o) { void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement* o) {
TopoDS_Shape compound = o->geometry().as_compound(); TopoDS_Shape compound = o->geometry().as_compound();
gp_Trsf trsf = o->transformation().data(); gp_Trsf trsf = o->transformation().data();
const IfcGeom::ElementSettings& settings = o->geometry().settings(); const IfcGeom::ElementSettings& settings = o->geometry().settings();
+2 -2
View File
@@ -39,8 +39,8 @@ public:
void writeHeader() {} void writeHeader() {}
bool ready(); bool ready();
virtual void writeShape(const std::string& name, const TopoDS_Shape& shape) = 0; virtual void writeShape(const std::string& name, const TopoDS_Shape& shape) = 0;
void write(const IfcGeom::TriangulationElement<double>* /*o*/) {} void write(const IfcGeom::TriangulationElement* /*o*/) {}
void write(const IfcGeom::BRepElement<double>* o); void write(const IfcGeom::BRepElement* o);
bool isTesselated() const { return false; } bool isTesselated() const { return false; }
void setFile(IfcParse::IfcFile*) {} void setFile(IfcParse::IfcFile*) {}
}; };
+4 -4
View File
@@ -339,7 +339,7 @@ SvgSerializer::path_object& SvgSerializer::start_path(const gp_Pln& pln, const s
} }
namespace { namespace {
boost::optional<std::pair<IfcUtil::IfcBaseEntity*, double>> storey_elevation_from_element(const IfcGeom::BRepElement<double>* o) { boost::optional<std::pair<IfcUtil::IfcBaseEntity*, double>> storey_elevation_from_element(const IfcGeom::BRepElement* o) {
for (const auto& p : o->parents()) { for (const auto& p : o->parents()) {
if (p->type() == "IfcBuildingStorey") { if (p->type() == "IfcBuildingStorey") {
try { try {
@@ -503,7 +503,7 @@ namespace {
} }
} }
void SvgSerializer::write(const IfcGeom::BRepElement<double>* brep_obj) { void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
boost::optional<std::string> object_type; boost::optional<std::string> object_type;
if (!brep_obj->product()->get("ObjectType")->isNull()) { if (!brep_obj->product()->get("ObjectType")->isNull()) {
@@ -2052,7 +2052,7 @@ return oss.str();
} }
} }
std::string SvgSerializer::nameElement(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element<double>* elem) { std::string SvgSerializer::nameElement(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element* elem) {
auto n = elem->name(); auto n = elem->name();
IfcUtil::escape_xml(n); IfcUtil::escape_xml(n);
@@ -2178,7 +2178,7 @@ namespace {
std::string SvgSerializer::writeMetadata(const drawing_meta& m) { std::string SvgSerializer::writeMetadata(const drawing_meta& m) {
gp_Trsf trsf; gp_Trsf trsf;
trsf.SetTransformation(m.pln_3d.Position(), gp::XOY()); trsf.SetTransformation(m.pln_3d.Position(), gp::XOY());
auto m43 = IfcGeom::Matrix<double>(IfcGeom::ElementSettings(IfcGeom::IteratorSettings(), 1., ""), trsf).data(); auto m43 = IfcGeom::Matrix(IfcGeom::ElementSettings(IfcGeom::IteratorSettings(), 1., ""), trsf).data();
std::array<std::array<double, 4>, 4> m4 = {{ std::array<std::array<double, 4>, 4> m4 = {{
{{ (double)m43[0], (double)m43[3], (double)m43[6], (double)m43[9] }}, {{ (double)m43[0], (double)m43[3], (double)m43[6], (double)m43[9] }},
{{ (double)m43[1], (double)m43[4], (double)m43[7], (double)m43[10] }}, {{ (double)m43[1], (double)m43[4], (double)m43[7], (double)m43[10] }},
+4 -4
View File
@@ -215,8 +215,8 @@ public:
void writeHeader(); void writeHeader();
void doWriteHeader(); void doWriteHeader();
bool ready(); bool ready();
void write(const IfcGeom::TriangulationElement<double>* /*o*/) {} void write(const IfcGeom::TriangulationElement* /*o*/) {}
void write(const IfcGeom::BRepElement<double>* o); void write(const IfcGeom::BRepElement* o);
void write(path_object& p, const TopoDS_Wire& wire, boost::optional<std::vector<double>> dash_array=boost::none); void write(path_object& p, const TopoDS_Wire& wire, boost::optional<std::vector<double>> dash_array=boost::none);
void write(const geometry_data& data); void write(const geometry_data& data);
path_object& start_path(const gp_Pln& p, IfcUtil::IfcBaseEntity* storey, const std::string& id); path_object& start_path(const gp_Pln& p, IfcUtil::IfcBaseEntity* storey, const std::string& id);
@@ -279,10 +279,10 @@ public:
void setDrawingCenter(double x, double y) { void setDrawingCenter(double x, double y) {
center_x_ = x; center_y_ = y; center_x_ = x; center_y_ = y;
} }
std::string nameElement(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element<double>* elem); std::string nameElement(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element* elem);
std::string nameElement(const IfcUtil::IfcBaseEntity* elem); std::string nameElement(const IfcUtil::IfcBaseEntity* elem);
std::string idElement(const IfcUtil::IfcBaseEntity* elem); std::string idElement(const IfcUtil::IfcBaseEntity* elem);
std::string object_id(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element<double>* o) { std::string object_id(const IfcUtil::IfcBaseEntity* storey, const IfcGeom::Element* o) {
if (storey) { if (storey) {
return idElement(storey) + "-" + GeometrySerializer::object_id(o); return idElement(storey) + "-" + GeometrySerializer::object_id(o);
} else { } else {
+1 -1
View File
@@ -84,7 +84,7 @@ void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::Material& style)
} }
} }
void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement<double>* o) void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
{ {
obj_stream << "g " << object_id(o) << "\n"; obj_stream << "g " << object_id(o) << "\n";
obj_stream << "s 1" << "\n"; obj_stream << "s 1" << "\n";
+2 -2
View File
@@ -40,8 +40,8 @@ public:
bool ready(); bool ready();
void writeHeader(); void writeHeader();
void writeMaterial(const IfcGeom::Material& style); void writeMaterial(const IfcGeom::Material& style);
void write(const IfcGeom::TriangulationElement<double>* o); void write(const IfcGeom::TriangulationElement* o);
void write(const IfcGeom::BRepElement<double>* /*o*/) {} void write(const IfcGeom::BRepElement* /*o*/) {}
void finalize() {} void finalize() {}
bool isTesselated() const { return true; } bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}