mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
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:
@@ -80,6 +80,28 @@
|
|||||||
#include "../ifcgeom/IfcGeom.h"
|
#include "../ifcgeom/IfcGeom.h"
|
||||||
|
|
||||||
bool IfcGeom::convert(const Ifc2x3::IfcCompositeCurve::ptr l, TopoDS_Wire& wire) {
|
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();
|
Ifc2x3::IfcCompositeCurveSegment::list segments = l->Segments();
|
||||||
BRepBuilderAPI_MakeWire w;
|
BRepBuilderAPI_MakeWire w;
|
||||||
//TopoDS_Vertex last_vertex;
|
//TopoDS_Vertex last_vertex;
|
||||||
|
|||||||
@@ -672,6 +672,7 @@ bool Ifc::Init(IfcParse::File* f) {
|
|||||||
Ifc::LengthUnit = value;
|
Ifc::LengthUnit = value;
|
||||||
} else if ( type == Ifc2x3::IfcUnitEnum::PLANEANGLEUNIT ) {
|
} else if ( type == Ifc2x3::IfcUnitEnum::PLANEANGLEUNIT ) {
|
||||||
Ifc::PlaneAngleUnit = value;
|
Ifc::PlaneAngleUnit = value;
|
||||||
|
Ifc::hasPlaneAngleUnit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -765,6 +766,7 @@ unsigned int Ifc::lastId = 0;
|
|||||||
Tokens* Ifc::tokens = 0;
|
Tokens* Ifc::tokens = 0;
|
||||||
float Ifc::LengthUnit = 1.0f;
|
float Ifc::LengthUnit = 1.0f;
|
||||||
float Ifc::PlaneAngleUnit = 1.0f;
|
float Ifc::PlaneAngleUnit = 1.0f;
|
||||||
|
bool Ifc::hasPlaneAngleUnit = false;
|
||||||
int Ifc::CircleSegments = 32;
|
int Ifc::CircleSegments = 32;
|
||||||
MapEntitiesByType Ifc::bytype;
|
MapEntitiesByType Ifc::bytype;
|
||||||
MapEntityById Ifc::byid;
|
MapEntityById Ifc::byid;
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ public:
|
|||||||
static bool Init(IfcParse::File* f);
|
static bool Init(IfcParse::File* f);
|
||||||
static std::string GetLog();
|
static std::string GetLog();
|
||||||
static void Dispose();
|
static void Dispose();
|
||||||
|
static bool hasPlaneAngleUnit;
|
||||||
static float LengthUnit;
|
static float LengthUnit;
|
||||||
static float PlaneAngleUnit;
|
static float PlaneAngleUnit;
|
||||||
static int CircleSegments;
|
static int CircleSegments;
|
||||||
|
|||||||
Reference in New Issue
Block a user