diff --git a/src/ifcgeom/IfcGeomWires.cpp b/src/ifcgeom/IfcGeomWires.cpp index dfa359645e..01f1a00497 100644 --- a/src/ifcgeom/IfcGeomWires.cpp +++ b/src/ifcgeom/IfcGeomWires.cpp @@ -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; diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index cfe7b2bcbe..1dabe1f018 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -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; diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index 8370a976ae..37a1fde156 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -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;