]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Extrusion direction fix.
authordbv <dbv@opencascade.com>
Fri, 15 Apr 2016 16:23:45 +0000 (19:23 +0300)
committerdbv <dbv@opencascade.com>
Mon, 18 Apr 2016 08:00:54 +0000 (11:00 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp

index 510668afa144cbe66e3ea04d4212292953a8149f..2829bff0a6fffd7984eb489f3744da2176f57514 100644 (file)
@@ -27,6 +27,7 @@
 #include <BRepLib_CheckCurveOnSurface.hxx>
 #include <BRepPrimAPI_MakePrism.hxx>
 #include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
 #include <gp_Pln.hxx>
 #include <IntAna_IntConicQuad.hxx>
 #include <IntAna_Quadric.hxx>
@@ -119,16 +120,34 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr&                theBaseShape,
   if(theDirection.get()) {
     aBaseDir = theDirection;
     aDirVec = theDirection->impl<gp_Dir>();
-  } 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;