Skip to content

Commit 9d88d75

Browse files
committed
Fixes #3452363 Fail to create meshes of parametric curves when no angular unit information is present in the IFC file
1 parent bc56aa3 commit 9d88d75

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/ifcgeom/IfcGeomWires.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,28 @@
8080
#include "../ifcgeom/IfcGeom.h"
8181

8282
bool IfcGeom::convert(const Ifc2x3::IfcCompositeCurve::ptr l, TopoDS_Wire& wire) {
83+
if ( ! Ifc::hasPlaneAngleUnit ) {
84+
Ifc::LogMessage("Warning","Creating a composite curve without unit information:",l->entity);
85+
Ifc::hasPlaneAngleUnit = true;
86+
// First try radians
87+
Ifc::PlaneAngleUnit = 1.0f;
88+
bool succes_radians = IfcGeom::convert(l,wire);
89+
bool succes_degrees;
90+
if ( succes_radians ) {
91+
Ifc::LogMessage("Notice","Used radians to create composite curve");
92+
} else {
93+
// Now try degrees
94+
Ifc::PlaneAngleUnit = 0.0174532925199433f;
95+
succes_degrees = IfcGeom::convert(l,wire);
96+
if ( succes_degrees ) {
97+
Ifc::LogMessage("Notice","Used degrees to create composite curve");
98+
}
99+
// Restore to radians
100+
Ifc::PlaneAngleUnit = 1.0f;
101+
}
102+
Ifc::hasPlaneAngleUnit = false;
103+
return succes_radians || succes_degrees;
104+
}
83105
Ifc2x3::IfcCompositeCurveSegment::list segments = l->Segments();
84106
BRepBuilderAPI_MakeWire w;
85107
//TopoDS_Vertex last_vertex;

src/ifcparse/IfcParse.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ bool Ifc::Init(IfcParse::File* f) {
672672
Ifc::LengthUnit = value;
673673
} else if ( type == Ifc2x3::IfcUnitEnum::PLANEANGLEUNIT ) {
674674
Ifc::PlaneAngleUnit = value;
675+
Ifc::hasPlaneAngleUnit = true;
675676
}
676677
}
677678
}
@@ -765,6 +766,7 @@ unsigned int Ifc::lastId = 0;
765766
Tokens* Ifc::tokens = 0;
766767
float Ifc::LengthUnit = 1.0f;
767768
float Ifc::PlaneAngleUnit = 1.0f;
769+
bool Ifc::hasPlaneAngleUnit = false;
768770
int Ifc::CircleSegments = 32;
769771
MapEntitiesByType Ifc::bytype;
770772
MapEntityById Ifc::byid;

src/ifcparse/IfcParse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class Ifc {
247247
static bool Init(IfcParse::File* f);
248248
static std::string GetLog();
249249
static void Dispose();
250+
static bool hasPlaneAngleUnit;
250251
static float LengthUnit;
251252
static float PlaneAngleUnit;
252253
static int CircleSegments;

0 commit comments

Comments
 (0)