From b9c5b0e6c8740f3227f1b30909af0f9240a0ad0d Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Thu, 10 Mar 2016 17:00:06 +0200 Subject: [PATCH] Add IFCCONVERT_DOUBLE_PRECISION build option --- cmake/CMakeLists.txt | 6 ++- src/ifcconvert/GeometrySerializer.h | 6 ++- src/ifcconvert/OpenCascadeBasedSerializer.cpp | 2 +- src/ifcconvert/SvgSerializer.h | 47 +++++++++---------- src/ifcconvert/WavefrontObjSerializer.h | 4 +- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b956b97c28..35e67c42e0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -24,7 +24,7 @@ project (IfcOpenShell) OPTION(UNICODE_SUPPORT "Build IfcOpenShell with Unicode support (requires ICU)." ON) OPTION(COLLADA_SUPPORT "Build IfcConvert with COLLADA support (requires OpenCOLLADA)." ON) OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizations on RelWithDebInfo and Release builds." OFF) -#TODO OPTION(IFCCONVERT_DOUBLE_PRECISION "IfcConvert: Use double precision floating-point numbers." OFF) +OPTION(IFCCONVERT_DOUBLE_PRECISION "IfcConvert: Use double precision floating-point numbers." ON) OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON) @@ -397,6 +397,10 @@ if(NOT WIN32) LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64) endif() +# IfcConvert +if (IFCCONVERT_DOUBLE_PRECISION) + add_definitions(-DIFCCONVERT_DOUBLE_PRECISION) +endif() file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp) file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h) set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES}) diff --git a/src/ifcconvert/GeometrySerializer.h b/src/ifcconvert/GeometrySerializer.h index 1eb36e6b67..c2ee0f6416 100644 --- a/src/ifcconvert/GeometrySerializer.h +++ b/src/ifcconvert/GeometrySerializer.h @@ -20,7 +20,11 @@ #ifndef GEOMETRYSERIALIZER_H #define GEOMETRYSERIALIZER_H -typedef double real_t; /**< @todo Will be configurable */ +#ifdef IFCCONVERT_DOUBLE_PRECISION +typedef double real_t; +#else +typedef float real_t; +#endif #include "../ifcconvert/Serializer.h" #include "../ifcgeom/IfcGeomIterator.h" diff --git a/src/ifcconvert/OpenCascadeBasedSerializer.cpp b/src/ifcconvert/OpenCascadeBasedSerializer.cpp index 2f9ea54839..1400d7c400 100644 --- a/src/ifcconvert/OpenCascadeBasedSerializer.cpp +++ b/src/ifcconvert/OpenCascadeBasedSerializer.cpp @@ -36,7 +36,7 @@ bool OpenCascadeBasedSerializer::ready() { return succeeded; } -void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement* o) { +void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement* o) { for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->geometry().begin(); it != o->geometry().end(); ++ it) { gp_GTrsf gtrsf = it->Placement(); diff --git a/src/ifcconvert/SvgSerializer.h b/src/ifcconvert/SvgSerializer.h index 08ff97f692..ea4acb3aff 100644 --- a/src/ifcconvert/SvgSerializer.h +++ b/src/ifcconvert/SvgSerializer.h @@ -22,15 +22,13 @@ #ifndef SVGSERIALIZER_H #define SVGSERIALIZER_H +#include "../ifcconvert/GeometrySerializer.h" +#include "../ifcconvert/util.h" + #include #include #include -#include "../ifcgeom/IfcGeomIterator.h" - -#include "../ifcconvert/GeometrySerializer.h" -#include "../ifcconvert/util.h" - class SvgSerializer : public GeometrySerializer { public: typedef std::pair > path_object; @@ -45,7 +43,7 @@ protected: std::vector< boost::shared_ptr > radii; IfcParse::IfcFile* file; public: - explicit SvgSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings) + SvgSerializer(const std::string& out_filename, const IfcGeom::IteratorSettings &settings) : GeometrySerializer(settings) , svg_file(out_filename.c_str()) , xmin(+std::numeric_limits::infinity()) @@ -55,25 +53,24 @@ public: , rescale(false) , file(0) {} - virtual void addXCoordinate(const boost::shared_ptr& fi) { xcoords.push_back(fi); } - virtual void addYCoordinate(const boost::shared_ptr& fi) { ycoords.push_back(fi); } - virtual void addSizeComponent(const boost::shared_ptr& fi) { radii.push_back(fi); } - virtual void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; } - virtual ~SvgSerializer() {} - virtual void writeHeader(); - virtual bool ready(); - virtual void write(const IfcGeom::TriangulationElement* /*o*/) {} - virtual void write(const IfcGeom::BRepElement* o); - virtual void write(path_object& p, const TopoDS_Wire& wire); - virtual path_object& start_path(IfcSchema::IfcBuildingStorey* storey, const std::string& id); - virtual bool isTesselated() const { return false; } - virtual void finalize(); - virtual void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} - virtual void setFile(IfcParse::IfcFile* f) { file = f; } - virtual void setBoundingRectangle(double width, double height); - virtual void setSectionHeight(double h) { section_height = h; } - virtual std::string nameElement(const IfcGeom::Element* elem); - virtual std::string nameElement(const IfcSchema::IfcProduct* elem); + void addXCoordinate(const boost::shared_ptr& fi) { xcoords.push_back(fi); } + void addYCoordinate(const boost::shared_ptr& fi) { ycoords.push_back(fi); } + void addSizeComponent(const boost::shared_ptr& fi) { radii.push_back(fi); } + void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; } + void writeHeader(); + bool ready(); + void write(const IfcGeom::TriangulationElement* /*o*/) {} + void write(const IfcGeom::BRepElement* o); + void write(path_object& p, const TopoDS_Wire& wire); + path_object& start_path(IfcSchema::IfcBuildingStorey* storey, const std::string& id); + bool isTesselated() const { return false; } + void finalize(); + void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} + void setFile(IfcParse::IfcFile* f) { file = f; } + void setBoundingRectangle(double width, double height); + void setSectionHeight(double h) { section_height = h; } + std::string nameElement(const IfcGeom::Element* elem); + std::string nameElement(const IfcSchema::IfcProduct* elem); }; #endif diff --git a/src/ifcconvert/WavefrontObjSerializer.h b/src/ifcconvert/WavefrontObjSerializer.h index 582bffc6fc..c8e87f6cdd 100644 --- a/src/ifcconvert/WavefrontObjSerializer.h +++ b/src/ifcconvert/WavefrontObjSerializer.h @@ -45,8 +45,8 @@ public: bool ready(); void writeHeader(); void writeMaterial(const IfcGeom::Material& style); - void write(const IfcGeom::TriangulationElement* o); - void write(const IfcGeom::BRepElement* /*o*/) {} + void write(const IfcGeom::TriangulationElement* o); + void write(const IfcGeom::BRepElement* /*o*/) {} void finalize() {} bool isTesselated() const { return true; } void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}