Salome HOME
IMP 0016175: EDF455: Save GUIState don't redisplay the objects.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PrismDriver.cxx
index 6be39bc15dd8e65332aa5ab44c1fe9c09a0383e8..cc492ef143a7868afcfef89884e82b4e8723dbca 100644 (file)
 // License along with this library; if not, write to the Free Software 
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_PrismDriver.hxx>
+
+#include <GEOMImpl_IShapesOperations.hxx>
 #include <GEOMImpl_IPrism.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
 
 #include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
 #include <BRep_Tool.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
@@ -36,6 +39,8 @@
 
 #include <Precision.hxx>
 #include <gp_Pnt.hxx>
+#include <gp_Trsf.hxx>
+#include <gp_Vec.hxx>
 #include <Standard_ConstructionError.hxx>
 
 //=======================================================================
@@ -71,7 +76,7 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
 
   TopoDS_Shape aShape;
 
-  if (aType == PRISM_BASE_VEC_H) {
+  if (aType == PRISM_BASE_VEC_H || aType == PRISM_BASE_VEC_H_2WAYS) {
     Handle(GEOM_Function) aRefBase = aCI.GetBase();
     Handle(GEOM_Function) aRefVector = aCI.GetVector();
     TopoDS_Shape aShapeBase = aRefBase->GetValue();
@@ -87,11 +92,18 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
         }
         if (aV.Magnitude() > Precision::Confusion()) {
           aV.Normalize();
+         if (aType == PRISM_BASE_VEC_H_2WAYS) {
+           gp_Trsf aTrsf;
+           aTrsf.SetTranslation( (-aV) * aCI.GetH() );
+           BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False);
+           aShapeBase = aTransformation.Shape();
+           aCI.SetH( aCI.GetH()*2 );
+         }
           aShape = BRepPrimAPI_MakePrism(aShapeBase, aV * aCI.GetH(), Standard_False).Shape();
         }
       }
     }
-  } else if (aType == PRISM_BASE_TWO_PNT) {
+  } else if (aType == PRISM_BASE_TWO_PNT || aType == PRISM_BASE_TWO_PNT_2WAYS) {
     Handle(GEOM_Function) aRefBase = aCI.GetBase();
     Handle(GEOM_Function) aRefPnt1 = aCI.GetFirstPoint();
     Handle(GEOM_Function) aRefPnt2 = aCI.GetLastPoint();
@@ -105,16 +117,39 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
       if (!V1.IsNull() && !V2.IsNull()) {
         gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
         if (aV.Magnitude() > gp::Resolution()) {
+         if (aType == PRISM_BASE_TWO_PNT_2WAYS)
+           {
+             gp_Trsf aTrsf;
+             aTrsf.SetTranslation(-aV);
+             BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False);
+             aShapeBase = aTransformation.Shape();
+             aV = aV * 2;
+           }
           aShape = BRepPrimAPI_MakePrism(aShapeBase, aV, Standard_False).Shape();
         }
       }
     }
-  } else {
+  } else if (aType == PRISM_BASE_DXDYDZ || aType == PRISM_BASE_DXDYDZ_2WAYS) {
+    Handle(GEOM_Function) aRefBase = aCI.GetBase();
+    TopoDS_Shape aShapeBase = aRefBase->GetValue();
+    gp_Vec aV (aCI.GetDX(), aCI.GetDY(), aCI.GetDZ());
+    if (aV.Magnitude() > gp::Resolution()) {
+      if (aType == PRISM_BASE_DXDYDZ_2WAYS)
+       {
+         gp_Trsf aTrsf;
+         aTrsf.SetTranslation(-aV);
+         BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False);
+         aShapeBase = aTransformation.Shape();
+         aV = aV * 2;
+       }
+      aShape = BRepPrimAPI_MakePrism(aShapeBase, aV, Standard_False).Shape();
+    }
   }
 
   if (aShape.IsNull()) return 0;
 
-  aFunction->SetValue(aShape);
+  TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+  aFunction->SetValue(aRes);
 
   log.SetTouched(Label());