From cb2002d18822479b5cce3222d5c7980b86a92313 Mon Sep 17 00:00:00 2001 From: blobfish Date: Fri, 15 May 2015 18:06:33 +0200 Subject: [PATCH] Part: ModelRefine: fix for bug# 2097 --- src/Mod/Part/App/modelRefine.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/modelRefine.cpp b/src/Mod/Part/App/modelRefine.cpp index 0e2468aef..ac6f5f98b 100644 --- a/src/Mod/Part/App/modelRefine.cpp +++ b/src/Mod/Part/App/modelRefine.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -343,12 +344,31 @@ FaceTypedPlane::FaceTypedPlane() : FaceTypedBase(GeomAbs_Plane) { } +static Handle(Geom_Plane) getGeomPlane(const TopoDS_Face &faceIn) +{ + Handle_Geom_Plane planeSurfaceOut; + Handle_Geom_Surface surface = BRep_Tool::Surface(faceIn); + if (!surface.IsNull()) + { + planeSurfaceOut = Handle(Geom_Plane)::DownCast(surface); + if (planeSurfaceOut.IsNull()) + { + Handle_Geom_RectangularTrimmedSurface trimmedSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); + if (!trimmedSurface.IsNull()) + planeSurfaceOut = Handle(Geom_Plane)::DownCast(trimmedSurface->BasisSurface()); + } + } + + return planeSurfaceOut; +} + bool FaceTypedPlane::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const { - Handle(Geom_Plane) planeSurfaceOne = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(faceOne)); - Handle(Geom_Plane) planeSurfaceTwo = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(faceTwo)); - if (planeSurfaceOne.IsNull() || planeSurfaceTwo.IsNull()) - return false;//error? + Handle(Geom_Plane) planeSurfaceOne = getGeomPlane(faceOne); + Handle(Geom_Plane) planeSurfaceTwo = getGeomPlane(faceTwo); + if (planeSurfaceOne.IsNull() || planeSurfaceTwo.IsNull()) + return false;//error? + gp_Pln planeOne(planeSurfaceOne->Pln()); gp_Pln planeTwo(planeSurfaceTwo->Pln()); return (planeOne.Position().Direction().IsParallel(planeTwo.Position().Direction(), Precision::Confusion()) &&