Guess units if none are present and convert back if needed

This commit is contained in:
Thomas Krijnen
2011-11-02 12:52:35 +00:00
parent d6d3333f9d
commit 4dc0bdbe02
4 changed files with 26 additions and 4 deletions
+8 -2
View File
@@ -47,9 +47,12 @@
// Welds vertices that belong to different faces
bool weld_vertices = true;
bool convert_back_units = false;
int IfcGeomObjects::IfcMesh::addvert(const gp_XYZ& p) {
const float X = (float)p.X();const float Y = (float)p.Y();const float Z = (float)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<float,float>(Y,Z));
@@ -277,7 +280,7 @@ IfcGeomObjects::IfcGeomObject* _get() {
int parent_id = -1;
const std::string name = ifc_product->hasName() ? ifc_product->Name() : "";
const std::string guid = ifc_product->GlobalId();
gp_Trsf trsf;
try {
IfcGeom::convert(ifc_product->ObjectPlacement(),trsf);
@@ -469,6 +472,9 @@ void IfcGeomObjects::Settings(int setting, bool value) {
case WELD_VERTICES:
weld_vertices = value;
break;
case CONVERT_BACK_UNITS:
convert_back_units = value;
break;
}
}
int IfcGeomObjects::Progress() {