Fixes #3452363 Fail to create meshes of parametric curves when no angular unit information is present in the IFC file

This commit is contained in:
Thomas Krijnen
2011-12-07 14:07:22 +00:00
parent bc56aa3397
commit 9d88d75b3b
3 changed files with 25 additions and 0 deletions
+22
View File
@@ -80,6 +80,28 @@
#include "../ifcgeom/IfcGeom.h"
bool IfcGeom::convert(const Ifc2x3::IfcCompositeCurve::ptr l, TopoDS_Wire& wire) {
if ( ! Ifc::hasPlaneAngleUnit ) {
Ifc::LogMessage("Warning","Creating a composite curve without unit information:",l->entity);
Ifc::hasPlaneAngleUnit = true;
// First try radians
Ifc::PlaneAngleUnit = 1.0f;
bool succes_radians = IfcGeom::convert(l,wire);
bool succes_degrees;
if ( succes_radians ) {
Ifc::LogMessage("Notice","Used radians to create composite curve");
} else {
// Now try degrees
Ifc::PlaneAngleUnit = 0.0174532925199433f;
succes_degrees = IfcGeom::convert(l,wire);
if ( succes_degrees ) {
Ifc::LogMessage("Notice","Used degrees to create composite curve");
}
// Restore to radians
Ifc::PlaneAngleUnit = 1.0f;
}
Ifc::hasPlaneAngleUnit = false;
return succes_radians || succes_degrees;
}
Ifc2x3::IfcCompositeCurveSegment::list segments = l->Segments();
BRepBuilderAPI_MakeWire w;
//TopoDS_Vertex last_vertex;
+2
View File
@@ -672,6 +672,7 @@ bool Ifc::Init(IfcParse::File* f) {
Ifc::LengthUnit = value;
} else if ( type == Ifc2x3::IfcUnitEnum::PLANEANGLEUNIT ) {
Ifc::PlaneAngleUnit = value;
Ifc::hasPlaneAngleUnit = true;
}
}
}
@@ -765,6 +766,7 @@ unsigned int Ifc::lastId = 0;
Tokens* Ifc::tokens = 0;
float Ifc::LengthUnit = 1.0f;
float Ifc::PlaneAngleUnit = 1.0f;
bool Ifc::hasPlaneAngleUnit = false;
int Ifc::CircleSegments = 32;
MapEntitiesByType Ifc::bytype;
MapEntityById Ifc::byid;
+1
View File
@@ -247,6 +247,7 @@ public:
static bool Init(IfcParse::File* f);
static std::string GetLog();
static void Dispose();
static bool hasPlaneAngleUnit;
static float LengthUnit;
static float PlaneAngleUnit;
static int CircleSegments;