From 89d6b3d21a284f83a26a2bff33c910ab0bf4f10d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 14 Feb 2021 17:21:58 +0100 Subject: [PATCH] Fixes for RC2 changes re IfcPoint and IfcSegment --- src/ifcgeom/IfcGeomHelpers.cpp | 35 ++++++++++++++++++++++++++++++---- src/ifcgeom/IfcGeomWires.cpp | 17 +++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/ifcgeom/IfcGeomHelpers.cpp b/src/ifcgeom/IfcGeomHelpers.cpp index b7549908ca..573a978613 100644 --- a/src/ifcgeom/IfcGeomHelpers.cpp +++ b/src/ifcgeom/IfcGeomHelpers.cpp @@ -169,7 +169,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf& gp_Dir axis(0, 0, 1); gp_Dir refDirection; - IfcGeom::Kernel::convert(l->Location(), o); + if (!l->Location()->declaration().is("IfcCartesianPoint")) { + // only applicable to 4x3 rc2 + Logger::Error("Not implemented", l->Location()); + return false; + } + + IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(), o); const bool hasAxis = l->hasAxis(); const bool hasRef = l->hasRefDirection(); @@ -207,7 +213,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf& bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis1Placement* l, gp_Ax1& ax) { IN_CACHE(IfcAxis1Placement,l,gp_Ax1,ax) gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1); - IfcGeom::Kernel::convert(l->Location(),o); + + if (!l->Location()->declaration().is("IfcCartesianPoint")) { + // only applicable to 4x3 rc2 + Logger::Error("Not implemented", l->Location()); + return false; + } + + IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),o); if ( l->hasAxis() ) IfcGeom::Kernel::convert(l->Axis(), axis); ax = gp_Ax1(o, axis); CACHE(IfcAxis1Placement,l,ax) @@ -356,7 +369,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* pln, gp_Pln& plane) { IN_CACHE(IfcPlane,pln,gp_Pln,plane) IfcSchema::IfcAxis2Placement3D* l = pln->Position(); gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1);gp_Dir refDirection; - IfcGeom::Kernel::convert(l->Location(),o); + + if (!l->Location()->declaration().is("IfcCartesianPoint")) { + // only applicable to 4x3 rc2 + Logger::Error("Not implemented", l->Location()); + return false; + } + + IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),o); bool hasRef = l->hasRefDirection(); if ( l->hasAxis() ) IfcGeom::Kernel::convert(l->Axis(),axis); if ( hasRef ) IfcGeom::Kernel::convert(l->RefDirection(),refDirection); @@ -371,7 +391,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* pln, gp_Pln& plane) { bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d& trsf) { IN_CACHE(IfcAxis2Placement2D,l,gp_Trsf2d,trsf) gp_Pnt P; gp_Dir V (1,0,0); - IfcGeom::Kernel::convert(l->Location(),P); + + if (!l->Location()->declaration().is("IfcCartesianPoint")) { + // only applicable to 4x3 rc2 + Logger::Error("Not implemented", l->Location()); + return false; + } + + IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),P); if ( l->hasRefDirection() ) IfcGeom::Kernel::convert(l->RefDirection(),V); diff --git a/src/ifcgeom/IfcGeomWires.cpp b/src/ifcgeom/IfcGeomWires.cpp index 8e5c9b3730..2645af47b5 100644 --- a/src/ifcgeom/IfcGeomWires.cpp +++ b/src/ifcgeom/IfcGeomWires.cpp @@ -370,14 +370,23 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire return use_radians || use_degrees; } - +#ifdef SCHEMA_HAS_IfcSegment + // 4x3 + IfcSchema::IfcSegment::list::ptr segments = l->Segments(); +#else IfcSchema::IfcCompositeCurveSegment::list::ptr segments = l->Segments(); +#endif TopTools_ListOfShape converted_segments; - for (IfcSchema::IfcCompositeCurveSegment::list::it it = segments->begin(); it != segments->end(); ++it) { + for (auto it = segments->begin(); it != segments->end(); ++it) { - IfcSchema::IfcCurve* curve = (*it)->ParentCurve(); + if (!(*it)->declaration().is(IfcSchema::IfcCompositeCurveSegment::Class())) { + Logger::Error("Not implemented", *it); + return false; + } + + IfcSchema::IfcCurve* curve = ((IfcSchema::IfcCompositeCurveSegment*)(*it))->ParentCurve(); // The type of ParentCurve is IfcCurve, but the documentation says: // ParentCurve: The *bounded curve* which defines the geometry of the segment. @@ -406,7 +415,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire continue; } - if (!(*it)->SameSense()) { + if (!((IfcSchema::IfcCompositeCurveSegment*)(*it))->SameSense()) { segment.Reverse(); }