From 9b64c6f4b9150982d40f07eba018d74ba12917c0 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 21 May 2015 13:01:01 +0000 Subject: [PATCH] Check for orientation of wires when creating outer boundary of face --- src/ifcgeom/IfcGeomFaces.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp index 6d9a66d24e..fdafbbfec8 100644 --- a/src/ifcgeom/IfcGeomFaces.cpp +++ b/src/ifcgeom/IfcGeomFaces.cpp @@ -85,6 +85,7 @@ #include #include +#include #include #ifdef USE_IFC4 @@ -92,8 +93,6 @@ #include #include #include - -#include #endif #include "../ifcgeom/IfcGeom.h" @@ -155,7 +154,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) { IfcSchema::IfcFaceBound* bound = *it; IfcSchema::IfcLoop* loop = bound->Bound(); - const bool same_sense = bound->Orientation(); + bool same_sense = bound->Orientation(); const bool is_interior = !bound->is(IfcSchema::Type::IfcFaceOuterBound) && (num_bounds > 1) && @@ -216,6 +215,21 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) { if (mf->IsDone()) { TopoDS_Face outer_face_bound = mf->Face(); + if (BRepCheck_Face(outer_face_bound).OrientationOfWires() == BRepCheck_BadOrientationOfSubshape) { + wire.Reverse(); + same_sense = !same_sense; + delete mf; + if (face_surface.IsNull()) { + mf = new BRepBuilderAPI_MakeFace(wire); + } else { + mf = new BRepBuilderAPI_MakeFace(face_surface, wire); + } + ShapeFix_Face fix(mf->Face()); + fix.FixOrientation(); + fix.Perform(); + outer_face_bound = fix.Face(); + } + // If the wires are reversed the face needs to be reversed as well in order // to maintain the counter-clock-wise ordering of the bounding wire's vertices. bool all_reversed = true;