Salome HOME
0021018: EDF 1592 GEOM: Problems with the radius input field in the Fillet 1D dialog box
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PrismDriver.cxx
index 11bb15ad6418bd5ee07977c8e4f49020c33e556a..1757f9690c8ff93b8e67ff8056e89a75b191f4e2 100644 (file)
@@ -1,21 +1,23 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  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/ or email : webmaster.salome@opencascade.com
 //
 
 #include <Standard_Stream.hxx>
@@ -92,13 +94,13 @@ 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 );
-         }
+          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();
         }
       }
@@ -117,19 +119,33 @@ 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;
-           }
+          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;
@@ -160,10 +176,10 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PrismDriver_Type_()
 
   static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
   static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PrismDriver",
-                                                        sizeof(GEOMImpl_PrismDriver),
-                                                        1,
-                                                        (Standard_Address)_Ancestors,
-                                                        (Standard_Address)NULL);
+                                                         sizeof(GEOMImpl_PrismDriver),
+                                                         1,
+                                                         (Standard_Address)_Ancestors,
+                                                         (Standard_Address)NULL);
 
   return _aType;
 }