mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
IfcGeomServer matrices in double precision
This commit is contained in:
@@ -221,13 +221,13 @@ public:
|
||||
|
||||
static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*);
|
||||
|
||||
template <typename P>
|
||||
IfcGeom::BRepElement<P>* create_brep_for_representation_and_product(
|
||||
template <typename P, typename PP>
|
||||
IfcGeom::BRepElement<P, PP>* create_brep_for_representation_and_product(
|
||||
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
|
||||
|
||||
template <typename P>
|
||||
IfcGeom::BRepElement<P>* create_brep_for_processed_representation(
|
||||
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P>*);
|
||||
template <typename P, typename PP>
|
||||
IfcGeom::BRepElement<P, PP>* create_brep_for_processed_representation(
|
||||
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P, PP>*);
|
||||
|
||||
const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct*);
|
||||
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
|
||||
IfcUtil::IfcBaseClass* product)
|
||||
{
|
||||
return create_brep_for_representation_and_product<double>(settings, (IfcSchema::IfcRepresentation*) representation, (IfcSchema::IfcProduct*) product);
|
||||
return create_brep_for_representation_and_product<double, double>(settings, (IfcSchema::IfcRepresentation*) representation, (IfcSchema::IfcProduct*) product);
|
||||
}
|
||||
|
||||
virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) {
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace IfcGeom {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
template <typename P = double, typename PP = P>
|
||||
class Element {
|
||||
private:
|
||||
int _id;
|
||||
@@ -89,17 +89,17 @@ namespace IfcGeom {
|
||||
std::string _guid;
|
||||
std::string _context;
|
||||
std::string _unique_id;
|
||||
Transformation<P> _transformation;
|
||||
Transformation<PP> _transformation;
|
||||
IfcUtil::IfcBaseEntity* product_;
|
||||
std::vector<const IfcGeom::Element<P>*> _parents;
|
||||
std::vector<const IfcGeom::Element<P, PP>*> _parents;
|
||||
public:
|
||||
|
||||
friend bool operator == (const Element<P> & element1, const Element<P> & element2) {
|
||||
friend bool operator == (const Element<P, PP> & element1, const Element<P, PP> & element2) {
|
||||
return element1.id() == element2.id();
|
||||
}
|
||||
|
||||
// Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set
|
||||
friend bool operator < (const Element<P> & element1, const Element<P> & element2) {
|
||||
friend bool operator < (const Element<P, PP> & element1, const Element<P, PP> & element2) {
|
||||
if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") {
|
||||
size_t attr_index = element1.product()->declaration().attribute_index("Elevation");
|
||||
Argument* elev_attr1 = element1.product()->data().getArgument(attr_index);
|
||||
@@ -123,10 +123,10 @@ namespace IfcGeom {
|
||||
const std::string& guid() const { return _guid; }
|
||||
const std::string& context() const { return _context; }
|
||||
const std::string& unique_id() const { return _unique_id; }
|
||||
const Transformation<P>& transformation() const { return _transformation; }
|
||||
const Transformation<PP>& transformation() const { return _transformation; }
|
||||
IfcUtil::IfcBaseEntity* product() const { return product_; }
|
||||
const std::vector<const IfcGeom::Element<P>*> parents() const { return _parents; }
|
||||
void SetParents(std::vector<const IfcGeom::Element<P>*> newparents) { _parents = newparents; }
|
||||
const std::vector<const IfcGeom::Element<P, PP>*> parents() const { return _parents; }
|
||||
void SetParents(std::vector<const IfcGeom::Element<P, PP>*> newparents) { _parents = newparents; }
|
||||
|
||||
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)
|
||||
@@ -158,8 +158,8 @@ namespace IfcGeom {
|
||||
virtual ~Element() {}
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
class BRepElement : public Element<P> {
|
||||
template <typename P = double, typename PP = P>
|
||||
class BRepElement : public Element<P, PP> {
|
||||
private:
|
||||
boost::shared_ptr<Representation::BRep> _geometry;
|
||||
public:
|
||||
@@ -168,7 +168,7 @@ namespace IfcGeom {
|
||||
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,
|
||||
IfcUtil::IfcBaseEntity* product)
|
||||
: Element<P>(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product)
|
||||
: Element<P, PP>(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product)
|
||||
, _geometry(geometry)
|
||||
{}
|
||||
private:
|
||||
@@ -176,19 +176,19 @@ namespace IfcGeom {
|
||||
BRepElement& operator=(const BRepElement& other);
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
class TriangulationElement : public Element<P> {
|
||||
template <typename P = double, typename PP = P>
|
||||
class TriangulationElement : public Element<P, PP> {
|
||||
private:
|
||||
boost::shared_ptr< Representation::Triangulation<P> > _geometry;
|
||||
public:
|
||||
const Representation::Triangulation<P>& geometry() const { return *_geometry; }
|
||||
const boost::shared_ptr< Representation::Triangulation<P> >& geometry_pointer() const { return _geometry; }
|
||||
TriangulationElement(const BRepElement<P>& shape_model)
|
||||
: Element<P>(shape_model)
|
||||
TriangulationElement(const BRepElement<P, PP>& shape_model)
|
||||
: Element<P, PP>(shape_model)
|
||||
, _geometry(boost::shared_ptr<Representation::Triangulation<P> >(new Representation::Triangulation<P>(shape_model.geometry())))
|
||||
{}
|
||||
TriangulationElement(const Element<P>& element, const boost::shared_ptr<Representation::Triangulation<P> >& geometry)
|
||||
: Element<P>(element)
|
||||
TriangulationElement(const Element<P, PP>& element, const boost::shared_ptr<Representation::Triangulation<P> >& geometry)
|
||||
: Element<P, PP>(element)
|
||||
, _geometry(geometry)
|
||||
{}
|
||||
private:
|
||||
@@ -196,14 +196,14 @@ namespace IfcGeom {
|
||||
TriangulationElement& operator=(const TriangulationElement& other);
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
class SerializedElement : public Element<P> {
|
||||
template <typename P = double, typename PP = P>
|
||||
class SerializedElement : public Element<P, PP> {
|
||||
private:
|
||||
Representation::Serialization* _geometry;
|
||||
public:
|
||||
const Representation::Serialization& geometry() const { return *_geometry; }
|
||||
SerializedElement(const BRepElement<P>& shape_model)
|
||||
: Element<P>(shape_model)
|
||||
SerializedElement(const BRepElement<P, PP>& shape_model)
|
||||
: Element<P, PP>(shape_model)
|
||||
, _geometry(new Representation::Serialization(shape_model.geometry()))
|
||||
{}
|
||||
virtual ~SerializedElement() {
|
||||
|
||||
@@ -1242,8 +1242,8 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c
|
||||
return single_material;
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_product(
|
||||
template <typename P, typename PP>
|
||||
IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_representation_and_product(
|
||||
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
|
||||
{
|
||||
std::stringstream representation_id_builder;
|
||||
@@ -1392,7 +1392,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
|
||||
context_string = representation->ContextOfItems()->ContextType();
|
||||
}
|
||||
|
||||
return new BRepElement<P>(
|
||||
return new BRepElement<P, PP>(
|
||||
product->data().id(),
|
||||
parent_id,
|
||||
name,
|
||||
@@ -1470,10 +1470,10 @@ IfcSchema::IfcProduct::list::ptr IfcGeom::Kernel::products_represented_by(const
|
||||
return products;
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representation(
|
||||
template <typename P, typename PP>
|
||||
IfcGeom::BRepElement<P, PP>* IfcGeom::Kernel::create_brep_for_processed_representation(
|
||||
const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
|
||||
IfcGeom::BRepElement<P>* brep)
|
||||
IfcGeom::BRepElement<P, PP>* brep)
|
||||
{
|
||||
int parent_id = -1;
|
||||
try {
|
||||
@@ -1506,7 +1506,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representati
|
||||
|
||||
const std::string product_type = product->declaration().name();
|
||||
|
||||
return new BRepElement<P>(
|
||||
return new BRepElement<P, PP>(
|
||||
product->data().id(),
|
||||
parent_id,
|
||||
name,
|
||||
@@ -1574,15 +1574,19 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
|
||||
return parent;
|
||||
}
|
||||
|
||||
template IFC_GEOM_API IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float>(
|
||||
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<double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double>(
|
||||
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>* IfcGeom::Kernel::create_brep_for_processed_representation<float>(
|
||||
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float>* brep);
|
||||
template IFC_GEOM_API IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_processed_representation<double>(
|
||||
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<double>* brep);
|
||||
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) {
|
||||
// Set default units, set length to meters, angles to undefined
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include "../ifcgeom_schema_agnostic/IteratorImplementation.h"
|
||||
|
||||
namespace IfcGeom {
|
||||
template class MAKE_TYPE_NAME(IteratorImplementation_)<float>;
|
||||
template class MAKE_TYPE_NAME(IteratorImplementation_)<double>;
|
||||
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
|
||||
@@ -11,20 +12,21 @@ namespace IfcGeom {
|
||||
#define MAKE_INIT_FN(t) MAKE_INIT_FN_(t, IfcSchema)
|
||||
|
||||
namespace {
|
||||
template <typename P>
|
||||
template <typename P, typename PP>
|
||||
struct factory_t {
|
||||
IfcGeom::IteratorImplementation<P>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) const {
|
||||
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<P>(settings, file);
|
||||
IfcGeom::IteratorImplementation<P, PP>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) const {
|
||||
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<P, PP>(settings, file);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void MAKE_INIT_FN(IteratorImplementation_)(IteratorFactoryImplementation<P>* mapping) {
|
||||
template <typename P, typename PP>
|
||||
void MAKE_INIT_FN(IteratorImplementation_)(IteratorFactoryImplementation<P, PP>* mapping) {
|
||||
static const std::string schema_name = STRINGIFY(IfcSchema);
|
||||
factory_t<P> factory;
|
||||
factory_t<P, PP> factory;
|
||||
mapping->bind(schema_name, factory);
|
||||
}
|
||||
|
||||
template void MAKE_INIT_FN(IteratorImplementation_)<float>(IteratorFactoryImplementation<float>*);
|
||||
template void MAKE_INIT_FN(IteratorImplementation_)<double>(IteratorFactoryImplementation<double>*);
|
||||
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>*);
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
|
||||
namespace IfcGeom {
|
||||
|
||||
template <typename P>
|
||||
class MAKE_TYPE_NAME(IteratorImplementation_) : public IteratorImplementation<P> {
|
||||
template <typename P, typename PP>
|
||||
class MAKE_TYPE_NAME(IteratorImplementation_) : public IteratorImplementation<P, PP> {
|
||||
private:
|
||||
|
||||
MAKE_TYPE_NAME(IteratorImplementation_)(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I
|
||||
@@ -111,9 +111,9 @@ namespace IfcGeom {
|
||||
IfcSchema::IfcRepresentation::list::it representation_iterator;
|
||||
|
||||
// The object is fetched beforehand to be sure that get() returns a valid element
|
||||
TriangulationElement<P>* current_triangulation;
|
||||
BRepElement<P>* current_shape_model;
|
||||
SerializedElement<P>* current_serialization;
|
||||
TriangulationElement<P, PP>* current_triangulation;
|
||||
BRepElement<P, PP>* current_shape_model;
|
||||
SerializedElement<P, PP>* current_serialization;
|
||||
|
||||
// A container and iterator for IfcBuildingElements for the current IfcRepresentation referenced by *representation_iterator
|
||||
IfcSchema::IfcProduct::list::ptr ifcproducts;
|
||||
@@ -154,6 +154,7 @@ namespace IfcGeom {
|
||||
/// @todo public/private sections all over the place: move all public to the beginning of the class
|
||||
public:
|
||||
typedef P Precision;
|
||||
typedef PP PlacementPrecision;
|
||||
|
||||
MAKE_TYPE_NAME(IteratorImplementation_)(const IteratorSettings& settings, IfcParse::IfcFile* file, std::vector<IfcGeom::filter_t>& filters)
|
||||
: settings(settings)
|
||||
@@ -399,7 +400,7 @@ namespace IfcGeom {
|
||||
return associated_single_materials.size() == 1;
|
||||
}
|
||||
|
||||
BRepElement<P>* create_shape_model_for_next_entity() {
|
||||
BRepElement<P, PP>* create_shape_model_for_next_entity() {
|
||||
for (;;) {
|
||||
IfcSchema::IfcRepresentation* representation;
|
||||
|
||||
@@ -468,9 +469,9 @@ namespace IfcGeom {
|
||||
IfcSchema::IfcProduct* product = *ifcproduct_iterator;
|
||||
Logger::SetProduct(product);
|
||||
|
||||
BRepElement<P>* element;
|
||||
BRepElement<P, PP>* element;
|
||||
if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) {
|
||||
element = kernel.create_brep_for_representation_and_product<P>(settings, representation, product);
|
||||
element = kernel.create_brep_for_representation_and_product<P, PP>(settings, representation, product);
|
||||
} else {
|
||||
element = kernel.create_brep_for_processed_representation(settings, representation, product, current_shape_model);
|
||||
}
|
||||
@@ -524,10 +525,10 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
/// Gets the representation of the current geometrical entity.
|
||||
Element<P>* get()
|
||||
Element<P, PP>* get()
|
||||
{
|
||||
// TODO: Test settings and throw
|
||||
Element<P>* ret = 0;
|
||||
Element<P, PP>* ret = 0;
|
||||
if (current_triangulation) { ret = current_triangulation; }
|
||||
else if (current_serialization) { ret = current_serialization; }
|
||||
else if (current_shape_model) { ret = current_shape_model; }
|
||||
@@ -537,12 +538,12 @@ namespace IfcGeom {
|
||||
{
|
||||
// We are going to build a vector with the element parents.
|
||||
// First, create the parent vector
|
||||
std::vector<const IfcGeom::Element<P>*> parents;
|
||||
std::vector<const IfcGeom::Element<P, PP>*> parents;
|
||||
|
||||
// if the element has a parent
|
||||
if (ret->parent_id() != -1)
|
||||
{
|
||||
const IfcGeom::Element<P>* parent_object = NULL;
|
||||
const IfcGeom::Element<P, PP>* parent_object = NULL;
|
||||
bool hasParent = true;
|
||||
|
||||
// get the parent
|
||||
@@ -582,13 +583,13 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
/// Gets the native (Open Cascade) representation of the current geometrical entity.
|
||||
BRepElement<P>* get_native()
|
||||
BRepElement<P, PP>* get_native()
|
||||
{
|
||||
// TODO: Test settings and throw
|
||||
return current_shape_model;
|
||||
}
|
||||
|
||||
const Element<P>* get_object(int id) {
|
||||
const Element<P, PP>* get_object(int id) {
|
||||
gp_Trsf trsf;
|
||||
int parent_id = -1;
|
||||
std::string instance_type, product_name, product_guid;
|
||||
@@ -640,14 +641,14 @@ namespace IfcGeom {
|
||||
|
||||
ElementSettings element_settings(settings, unit_magnitude, instance_type);
|
||||
|
||||
Element<P>* ifc_object = new Element<P>(element_settings, id, parent_id, product_name, instance_type, product_guid, "", trsf, ifc_product);
|
||||
Element<P, PP>* ifc_object = new Element<P, PP>(element_settings, id, parent_id, product_name, instance_type, product_guid, "", trsf, ifc_product);
|
||||
return ifc_object;
|
||||
}
|
||||
|
||||
IfcUtil::IfcBaseClass* create() {
|
||||
IfcGeom::BRepElement<P>* next_shape_model = 0;
|
||||
IfcGeom::SerializedElement<P>* next_serialization = 0;
|
||||
IfcGeom::TriangulationElement<P>* next_triangulation = 0;
|
||||
IfcGeom::BRepElement<P, PP>* next_shape_model = 0;
|
||||
IfcGeom::SerializedElement<P, PP>* next_serialization = 0;
|
||||
IfcGeom::TriangulationElement<P, PP>* next_triangulation = 0;
|
||||
|
||||
try {
|
||||
next_shape_model = create_shape_model_for_next_entity();
|
||||
@@ -666,16 +667,16 @@ namespace IfcGeom {
|
||||
if (next_shape_model) {
|
||||
if (settings.get(IteratorSettings::USE_BREP_DATA)) {
|
||||
try {
|
||||
next_serialization = new SerializedElement<P>(*next_shape_model);
|
||||
next_serialization = new SerializedElement<P, PP>(*next_shape_model);
|
||||
} catch (...) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Getting a serialized element from model failed.");
|
||||
}
|
||||
} else if (!settings.get(IteratorSettings::DISABLE_TRIANGULATION)) {
|
||||
try {
|
||||
if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) {
|
||||
next_triangulation = new TriangulationElement<P>(*next_shape_model);
|
||||
next_triangulation = new TriangulationElement<P, PP>(*next_shape_model);
|
||||
} else {
|
||||
next_triangulation = new TriangulationElement<P>(*next_shape_model, current_triangulation->geometry_pointer());
|
||||
next_triangulation = new TriangulationElement<P, PP>(*next_shape_model, current_triangulation->geometry_pointer());
|
||||
}
|
||||
} catch (...) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Getting a triangulation element from model failed.");
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ protected:
|
||||
}
|
||||
public:
|
||||
const std::string& string() { return str; }
|
||||
Hello() : Command(HELLO), str("IfcOpenShell-" IFCOPENSHELL_VERSION "-2") {}
|
||||
Hello() : Command(HELLO), str("IfcOpenShell-" IFCOPENSHELL_VERSION "-0") {}
|
||||
};
|
||||
|
||||
class More : public Command {
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
|
||||
class Entity : public Command {
|
||||
private:
|
||||
const IfcGeom::TriangulationElement<float>* geom;
|
||||
const IfcGeom::TriangulationElement<float, double>* geom;
|
||||
bool append_line_data;
|
||||
EntityExtension* eext_;
|
||||
protected:
|
||||
@@ -235,14 +235,14 @@ protected:
|
||||
swrite(s, geom->name());
|
||||
swrite(s, geom->type());
|
||||
swrite<int32_t>(s, geom->parent_id());
|
||||
const std::vector<float>& m = geom->transformation().matrix().data();
|
||||
const float matrix_array[16] = {
|
||||
const std::vector<double>& m = geom->transformation().matrix().data();
|
||||
const double matrix_array[16] = {
|
||||
m[0], m[3], m[6], m[ 9],
|
||||
m[1], m[4], m[7], m[10],
|
||||
m[2], m[5], m[8], m[11],
|
||||
0, 0, 0, 1
|
||||
};
|
||||
swrite(s, std::string((char*)matrix_array, 16 * sizeof(float)));
|
||||
swrite(s, std::string((char*)matrix_array, 16 * sizeof(double)));
|
||||
|
||||
// The first bit of the string is always the instance name of the representation.
|
||||
const std::string& representation_id = geom->geometry().id();
|
||||
@@ -310,7 +310,7 @@ protected:
|
||||
}
|
||||
}
|
||||
public:
|
||||
Entity(const IfcGeom::TriangulationElement<float>* geom, EntityExtension* eext = 0) : Command(ENTITY), geom(geom), append_line_data(false), eext_(eext) {};
|
||||
Entity(const IfcGeom::TriangulationElement<float, double>* geom, EntityExtension* eext = 0) : Command(ENTITY), geom(geom), append_line_data(false), eext_(eext) {};
|
||||
};
|
||||
|
||||
class Next : public Command {
|
||||
@@ -370,9 +370,9 @@ static const double MAX_WALKABLE_SURFACE_ANGLE_DEGREES = 15.;
|
||||
|
||||
class QuantityWriter : public EntityExtension {
|
||||
private:
|
||||
const IfcGeom::BRepElement<float>* elem_;
|
||||
const IfcGeom::BRepElement<float, double>* elem_;
|
||||
public:
|
||||
QuantityWriter(const IfcGeom::BRepElement<float>* elem) :
|
||||
QuantityWriter(const IfcGeom::BRepElement<float, double>* elem) :
|
||||
elem_(elem)
|
||||
{}
|
||||
void write_contents(std::ostream& s) {
|
||||
@@ -471,7 +471,7 @@ int main () {
|
||||
double deflection = 1.e-3;
|
||||
bool has_more = false;
|
||||
|
||||
IfcGeom::Iterator<float>* iterator = 0;
|
||||
IfcGeom::Iterator<float, double>* iterator = 0;
|
||||
IfcParse::IfcFile* file = 0;
|
||||
std::vector< std::pair<uint32_t, uint32_t> > setting_pairs;
|
||||
|
||||
@@ -501,7 +501,7 @@ int main () {
|
||||
settings.set_deflection_tolerance(deflection);
|
||||
|
||||
file = new IfcParse::IfcFile(data, (int)len);
|
||||
iterator = new IfcGeom::Iterator<float>(settings, file);
|
||||
iterator = new IfcGeom::Iterator<float, double>(settings, file);
|
||||
has_more = iterator->initialize();
|
||||
|
||||
More(has_more).write(std::cout);
|
||||
@@ -513,7 +513,7 @@ int main () {
|
||||
exit_code = 1;
|
||||
break;
|
||||
}
|
||||
const IfcGeom::TriangulationElement<float>* geom = static_cast<const IfcGeom::TriangulationElement<float>*>(iterator->get());
|
||||
const IfcGeom::TriangulationElement<float, double>* geom = static_cast<const IfcGeom::TriangulationElement<float, double>*>(iterator->get());
|
||||
QuantityWriter eext(iterator->get_native());
|
||||
Entity(geom, &eext).write(std::cout);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user