Salome HOME
PAL12608: Add possibility to check geometry of a shape.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_RevolutionDriver.cxx
index 60222bcdf097e609fcfcb76f6bd7bcced7de45cd..beec64f3c3387041c585ace91401777cc74d91f3 100644 (file)
@@ -1,9 +1,29 @@
-
-using namespace std;
-#include "GEOMImpl_RevolutionDriver.hxx"
-#include "GEOMImpl_IRevolution.hxx"
-#include "GEOMImpl_Types.hxx"
-#include "GEOM_Function.hxx"
+// 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.
+//
+// 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>
+
+#include <GEOMImpl_RevolutionDriver.hxx>
+#include <GEOMImpl_IRevolution.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOM_Function.hxx>
 
 #include <BRepPrimAPI_MakeRevol.hxx>
 #include <BRep_Tool.hxx>
@@ -15,6 +35,8 @@ using namespace std;
 #include <TopExp.hxx>
 
 #include <gp_Pnt.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Dir.hxx>
 #include <Precision.hxx>
 #include <StdFail_NotDone.hxx>
 #include <Standard_TypeMismatch.hxx>
@@ -75,6 +97,14 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons
         ("End vertices of edge, defining the Revolution Axis, are too close");
     }
 
+    if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
+      gp_Lin aL(BRep_Tool::Pnt(V1), gp_Dir(aV));
+      Standard_Real d = aL.Distance(BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase)));
+      if (d < Precision::Confusion()) {
+       Standard_ConstructionError::Raise("Vertex to be rotated is too close to Revolution Axis");
+      }
+    }
+
     gp_Ax1 anAxis (BRep_Tool::Pnt(V1), aV);
     BRepPrimAPI_MakeRevol MR (aShapeBase, anAxis, aCI.GetAngle(), Standard_False);
     if (!MR.IsDone()) MR.Build();