From 48669531195bde232166cc767a5c26cb717e6d30 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 8 Apr 2012 08:39:09 +0000 Subject: [PATCH] Revert the IfcGeomObjects API to float precision instead of double. Internally double precision is still used. --- src/ifcgeom/IfcGeomObjects.cpp | 22 +++++++++++----------- src/ifcgeom/IfcGeomObjects.h | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ifcgeom/IfcGeomObjects.cpp b/src/ifcgeom/IfcGeomObjects.cpp index 86cf1dde2a..bce59d1796 100644 --- a/src/ifcgeom/IfcGeomObjects.cpp +++ b/src/ifcgeom/IfcGeomObjects.cpp @@ -50,12 +50,12 @@ bool weld_vertices = true; bool convert_back_units = false; int IfcGeomObjects::IfcMesh::addvert(const gp_XYZ& p) { - const double X = convert_back_units ? (double)p.X() / Ifc::LengthUnit : (double)p.X(); - const double Y = convert_back_units ? (double)p.Y() / Ifc::LengthUnit : (double)p.Y(); - const double Z = convert_back_units ? (double)p.Z() / Ifc::LengthUnit : (double)p.Z(); + const float X = convert_back_units ? (float) (p.X() / Ifc::LengthUnit) : (float)p.X(); + const float Y = convert_back_units ? (float) (p.Y() / Ifc::LengthUnit) : (float)p.Y(); + const float Z = convert_back_units ? (float) (p.Z() / Ifc::LengthUnit) : (float)p.Z(); int i = (int) verts.size() / 3; if ( weld_vertices ) { - const VertKey key = VertKey(X,std::pair(Y,Z)); + const VertKey key = VertKey(X,std::pair(Y,Z)); VertKeyMap::const_iterator it = welds.find(key); if ( it != welds.end() ) return it->second; i = (int) welds.size(); @@ -145,9 +145,9 @@ IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) { gp_Vec normal_direction; prop.Normal(uv.X(),uv.Y(),p,normal_direction); gp_Dir normal = gp_Dir(normal_direction.XYZ() * rotation_matrix); - normals.push_back((double)normal.X()); - normals.push_back((double)normal.Y()); - normals.push_back((double)normal.Z()); + normals.push_back((float)normal.X()); + normals.push_back((float)normal.Y()); + normals.push_back((float)normal.Z()); } } @@ -167,9 +167,9 @@ IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) { const gp_XYZ v1 = pt2-pt1; const gp_XYZ v2 = pt3-pt2; gp_Dir normal = gp_Dir(v1^v2); - normals.push_back((double)normal.X()); - normals.push_back((double)normal.Y()); - normals.push_back((double)normal.Z()); + normals.push_back((float)normal.X()); + normals.push_back((float)normal.Y()); + normals.push_back((float)normal.Z()); */ faces.push_back(dict[n1]); @@ -198,7 +198,7 @@ IfcGeomObjects::IfcObject::IfcObject(int my_id, // Convert the gp_Trsf into a 4x3 Matrix for( int i = 1; i < 5; ++ i ) for ( int j = 1; j < 4; ++ j ) - matrix.push_back((double)trsf.Value(j,i)); + matrix.push_back((float)trsf.Value(j,i)); id = my_id; parent_id = p_id; diff --git a/src/ifcgeom/IfcGeomObjects.h b/src/ifcgeom/IfcGeomObjects.h index 611e9f1787..eff49be793 100644 --- a/src/ifcgeom/IfcGeomObjects.h +++ b/src/ifcgeom/IfcGeomObjects.h @@ -23,7 +23,7 @@ * and instances (SUBTYPE OF IfcBuildingElement e.g. IfcWindow). * * * * IfcMesh is a class that represents a triangulated IfcShapeRepresentation. * - * IfcMesh.verts is a 1 dimensional vector of double defining the cartesian * + * IfcMesh.verts is a 1 dimensional vector of float defining the cartesian * * coordinates of the vertices of the triangulated shape in the format of * * [x1,y1,z1,..,xn,yn,zn] * * IfcMesh.faces is a 1 dimensional vector of int containing the indices of * @@ -96,19 +96,19 @@ namespace IfcGeomObjects { // Some typedefs for convenience typedef std::vector::const_iterator IntIt; - typedef std::vector::const_iterator FltIt; + typedef std::vector::const_iterator FltIt; // A nested pair of doubles to be able to store an XYZ coordinate in a map. - typedef std::pair< double,std::pair > VertKey; + typedef std::pair< float,std::pair > VertKey; typedef std::map VertKeyMap; typedef std::pair Edge; class IfcMesh { public: int id; - std::vector verts; + std::vector verts; std::vector faces; std::vector edges; - std::vector normals; + std::vector normals; std::string brep_data; VertKeyMap welds; @@ -130,7 +130,7 @@ namespace IfcGeomObjects { std::string name; std::string type; std::string guid; - std::vector matrix; + std::vector matrix; IfcObject(int my_id, int p_id, const std::string& n, const std::string& t, const std::string& g, const gp_Trsf& trsf); };