From ce2fca906ad55e4ec6554dc2fcffba6374fc5b1e Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 15 Apr 2016 19:23:45 +0300 Subject: [PATCH] Extrusion direction fix. --- src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp | 31 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 510668afa..2829bff0a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -119,16 +120,34 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, if(theDirection.get()) { aBaseDir = theDirection; aDirVec = theDirection->impl(); - } else if(aBaseShape.ShapeType() != TopAbs_VERTEX && - aBaseShape.ShapeType() != TopAbs_EDGE && - aFindPlane.Found() == Standard_True){ - Handle(Geom_Plane) aPlane = aFindPlane.Plane(); + } else { + if(aBaseShape.ShapeType() == TopAbs_VERTEX + || aBaseShape.ShapeType() == TopAbs_EDGE + || aFindPlane.Found() == Standard_False) { + return; + } + + Handle(Geom_Plane) aPlane; + if(aBaseShape.ShapeType() == TopAbs_FACE || aBaseShape.ShapeType() == TopAbs_SHELL) { + TopExp_Explorer anExp(aBaseShape, TopAbs_FACE); + const TopoDS_Shape& aFace = anExp.Current(); + Handle(Geom_Surface) aSurface = BRep_Tool::Surface(TopoDS::Face(aFace)); + if(aSurface->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { + Handle(Geom_RectangularTrimmedSurface) aTrimSurface = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); + aSurface = aTrimSurface->BasisSurface(); + } + if(aSurface->DynamicType() != STANDARD_TYPE(Geom_Plane)) { + return; + } + aPlane = Handle(Geom_Plane)::DownCast(aSurface); + } else { + aPlane = aFindPlane.Plane(); + } gp_Pnt aLoc = aPlane->Axis().Location(); aDirVec = aPlane->Axis().Direction(); aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z())); aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z())); - } else { - return; } if(!aBaseLoc.get()) { gp_Pnt aLoc; -- 2.39.2