]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMImpl/GEOMImpl_TranslateDriver.cxx
Salome HOME
0022686: [CEA 1268] Explode a shape into edges sorted in a row from a starting point
[modules/geom.git] / src / GEOMImpl / GEOMImpl_TranslateDriver.cxx
index 69311116399b70c5e2682b16125c203c84eb368f..cb67a9ec09b3943309f4f968cd7da4059d66ff04 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Standard_Stream.hxx>
-
 #include <GEOMImpl_TranslateDriver.hxx>
 #include <GEOMImpl_ITranslate.hxx>
-#include <GEOMImpl_ITransformOperations.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
-
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
+#include <GEOMUtils.hxx>
 
 #include <BRep_Tool.hxx>
 #include <BRep_Builder.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRepBuilderAPI_Transform.hxx>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
@@ -42,8 +35,6 @@
 #include <TopoDS_Compound.hxx>
 #include <TopAbs.hxx>
 #include <TopExp.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
 
 #include <gp_Trsf.hxx>
 #include <gp_Pnt.hxx>
@@ -175,10 +166,7 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
     Handle(GEOM_Function) aVector = TI.GetVector();
     gp_Vec Vec = gp::DX();
     if (!aVector.IsNull()) {
-      TopoDS_Shape aV = aVector->GetValue();
-      if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0;
-      TopoDS_Edge anEdge = TopoDS::Edge(aV);
-      Vec = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge)));
+      Vec = GEOMUtils::GetVector( aVector->GetValue(), Standard_False );
       Vec.Normalize();
     }
 
@@ -199,7 +187,6 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
       B.Add(aCompound, anOriginal.Located(aLocRes));
     }
     aShape = aCompound;
-    //aShape = GEOMImpl_ITransformOperations::TranslateShape1D(anOriginal, &TI);
   }
   else if (aType == TRANSLATE_2D) {
     Standard_Integer nbtimes1 = TI.GetNbIter1(), nbtimes2 = TI.GetNbIter2();
@@ -211,18 +198,12 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
     gp_Vec Vec2 = gp::DY();
 
     if (!aVector.IsNull()) {
-      TopoDS_Shape aV = aVector->GetValue();
-      if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0;
-      TopoDS_Edge anEdge = TopoDS::Edge(aV);
-      Vec1 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge)));
+      Vec1 = GEOMUtils::GetVector( aVector->GetValue(), Standard_False );
       Vec1.Normalize();
     }
 
     if (!aVector2.IsNull()) {
-      TopoDS_Shape aV = aVector2->GetValue();
-      if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0;
-      TopoDS_Edge anEdge = TopoDS::Edge(aV);
-      Vec2 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge)));
+      Vec2 = GEOMUtils::GetVector( aVector2->GetValue(), Standard_False );
       Vec2.Normalize();
     }
 
@@ -250,25 +231,13 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
       }
     }
     aShape = aCompound;
-    //aShape = GEOMImpl_ITransformOperations::TranslateShape2D(anOriginal, &TI);
   }
   else return 0;
 
   if (aShape.IsNull()) return 0;
 
-  BRepCheck_Analyzer ana (aShape, Standard_True);
-  if (!ana.IsValid()) {
-    ShapeFix_ShapeTolerance aSFT;
-    aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
-    Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
-    aSfs->SetPrecision(Precision::Confusion());
-    aSfs->Perform();
-    aShape = aSfs->Shape();
-
-    ana.Init(aShape, Standard_False);
-    if (!ana.IsValid())
-      Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
-  }
+  if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+    Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
 
   aFunction->SetValue(aShape);