Salome HOME
EDF 1337 : Take into account the new dimension presentations in the undo / redo mechanism
[modules/geom.git] / src / GEOM_SWIG / GEOM_TestHealing.py
index 70934fc7993a8ae61502a6a69596867e818ca798..abe4a9810495f4343caee8535d33ee6dad880c6d 100644 (file)
@@ -1,32 +1,30 @@
 #  -*- coding: iso-8859-1 -*-
-#  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2012  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
+# Copyright (C) 2003-2007  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 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.
+# 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
+# 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
 
-#  GEOM GEOM_SWIG : binding of C++ implementaion with Python
+#  GEOM_SWIG : binding of C++ implementaion with Python
 #  File   : GEOM_TestHealing.py
 #  Author : Julia DOROVSKIKH
 #  Module : GEOM
-#  $Header$
-#
+
 def TestProcessShape (geompy):
 
   ##Load shape from BREP file
@@ -324,6 +322,51 @@ def TestDivideEdge (geompy):
   Id_Box    = geompy.addToStudy(Box, "Box")
   Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge")
 
+def TestFuseEdges (geompy):
+
+  # create vertices
+  p1 = geompy.MakeVertex(0, 0, 0)
+  p2 = geompy.MakeVertex(70, 0, 0)
+  p3 = geompy.MakeVertex(70, 50, 0)
+  p4 = geompy.MakeVertex(70, 80, 0)
+  p5 = geompy.MakeVertex(50, 80, 0)
+  p6 = geompy.MakeVertex(20, 80, 0)
+  p7 = geompy.MakeVertex(0, 80, 0)
+  p8 = geompy.MakeVertex(0, 30, 0)
+
+  points = [p1, p2, p3, p4, p5, p6, p7, p8]
+
+  # make a wire
+  wire_1 = geompy.MakePolyline(points, True)
+
+  # suppress some vertices in the wire
+  wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3])
+  wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6])
+
+  # suppress all suitable vertices in the wire
+  wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, [])
+
+  wires = [wire_1, wire_2, wire_3, wire_4]
+
+  # add objects in the study
+  ii = 1
+  for point in points:
+    geompy.addToStudy(point, "p%d"%ii)
+    ii = ii + 1
+    pass
+
+  ii = 1
+  for wire in wires:
+    geompy.addToStudy(wire, "wire_%d"%ii)
+    wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType["VERTEX"])
+    jj = 1
+    for point in wire_points:
+      geompy.addToStudyInFather(wire, point, "point_%d"%jj)
+      jj = jj + 1
+      pass
+    ii = ii + 1
+    pass
+
 def TestHealingOperations (geompy, math):
 
   TestMakeSewing(geompy, math)
@@ -333,3 +376,4 @@ def TestHealingOperations (geompy, math):
   TestCloseContour(geompy)
   TestSuppressFaces(geompy)
   TestProcessShape(geompy)
+  TestFuseEdges(geompy)