From 43a465f006a78c3ef791bdf9c1a9482841fbd5bb Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Jun 2013 11:44:23 +0200 Subject: [PATCH] Fix in returning correct surface from face --- src/Mod/Part/App/TopoShapeFacePyImp.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index 00e86fddd1..6a872b1620 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -37,6 +37,7 @@ # include # include # include +# include # include # include # include @@ -563,28 +564,49 @@ Py::Object TopoShapeFacePy::getSurface() const { Handle_Geom_Surface s = BRep_Tool::Surface(f); Handle_Geom_SurfaceOfRevolution rev = Handle_Geom_SurfaceOfRevolution::DownCast(s); + if (rev.IsNull()) { + Handle_Geom_RectangularTrimmedSurface rect = Handle_Geom_RectangularTrimmedSurface::DownCast(s); + rev = Handle_Geom_SurfaceOfRevolution::DownCast(rect->BasisSurface()); + } if (!rev.IsNull()) { GeomSurfaceOfRevolution* surf = new GeomSurfaceOfRevolution(rev); return Py::Object(new SurfaceOfRevolutionPy(surf),true); } + else { + throw Py::RuntimeError("Failed to convert to surface of revolution"); + } } case GeomAbs_SurfaceOfExtrusion: { Handle_Geom_Surface s = BRep_Tool::Surface(f); Handle_Geom_SurfaceOfLinearExtrusion ext = Handle_Geom_SurfaceOfLinearExtrusion::DownCast(s); + if (ext.IsNull()) { + Handle_Geom_RectangularTrimmedSurface rect = Handle_Geom_RectangularTrimmedSurface::DownCast(s); + ext = Handle_Geom_SurfaceOfLinearExtrusion::DownCast(rect->BasisSurface()); + } if (!ext.IsNull()) { GeomSurfaceOfExtrusion* surf = new GeomSurfaceOfExtrusion(ext); return Py::Object(new SurfaceOfExtrusionPy(surf),true); } + else { + throw Py::RuntimeError("Failed to convert to surface of extrusion"); + } } case GeomAbs_OffsetSurface: { Handle_Geom_Surface s = BRep_Tool::Surface(f); Handle_Geom_OffsetSurface off = Handle_Geom_OffsetSurface::DownCast(s); + if (off.IsNull()) { + Handle_Geom_RectangularTrimmedSurface rect = Handle_Geom_RectangularTrimmedSurface::DownCast(s); + off = Handle_Geom_OffsetSurface::DownCast(rect->BasisSurface()); + } if (!off.IsNull()) { GeomOffsetSurface* surf = new GeomOffsetSurface(off); return Py::Object(new OffsetSurfacePy(surf),true); } + else { + throw Py::RuntimeError("Failed to convert to offset surface"); + } } case GeomAbs_OtherSurface: break;