From 973dda6f8843f608fb3d6688510af025f2ec874b Mon Sep 17 00:00:00 2001 From: blobfish Date: Fri, 21 Aug 2015 13:17:09 -0400 Subject: [PATCH] Part: ModelRefine: adding basis surface to cylinder. --- src/Mod/Part/App/modelRefine.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/modelRefine.cpp b/src/Mod/Part/App/modelRefine.cpp index 7bcb0866b..05216d8ba 100644 --- a/src/Mod/Part/App/modelRefine.cpp +++ b/src/Mod/Part/App/modelRefine.cpp @@ -435,11 +435,28 @@ FaceTypedCylinder::FaceTypedCylinder() : FaceTypedBase(GeomAbs_Cylinder) { } +static Handle(Geom_CylindricalSurface) getGeomCylinder(const TopoDS_Face &faceIn) +{ + Handle_Geom_CylindricalSurface cylinderSurfaceOut; + Handle_Geom_Surface surface = BRep_Tool::Surface(faceIn); + if (!surface.IsNull()) + { + cylinderSurfaceOut = Handle(Geom_CylindricalSurface)::DownCast(surface); + if (cylinderSurfaceOut.IsNull()) + { + Handle_Geom_RectangularTrimmedSurface trimmedSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); + if (!trimmedSurface.IsNull()) + cylinderSurfaceOut = Handle(Geom_CylindricalSurface)::DownCast(trimmedSurface->BasisSurface()); + } + } + + return cylinderSurfaceOut; +} + bool FaceTypedCylinder::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const { - //check if these handles are valid? - Handle(Geom_CylindricalSurface) surfaceOne = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceOne)); - Handle(Geom_CylindricalSurface) surfaceTwo = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceTwo)); + Handle(Geom_CylindricalSurface) surfaceOne = getGeomCylinder(faceOne); + Handle(Geom_CylindricalSurface) surfaceTwo = getGeomCylinder(faceTwo); if (surfaceOne.IsNull() || surfaceTwo.IsNull()) return false;//probably need an error gp_Cylinder cylinderOne = surfaceOne->Cylinder(); @@ -623,7 +640,9 @@ TopoDS_Face FaceTypedCylinder::buildFace(const FaceVectorType &faces) const // Find outer boundary wires that cut the cylinder into segments. This will be the case f we // have removed the seam edges of a complete (360 degrees) cylindrical face - Handle(Geom_CylindricalSurface) surface = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faces.at(0))); + Handle(Geom_CylindricalSurface) surface = getGeomCylinder(faces.at(0)); + if (surface.IsNull()) + return dummy; std::vector innerWires, encirclingWires; std::vector::iterator wireIt; for (wireIt = allWires.begin(); wireIt != allWires.end(); ++wireIt) {