--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2022 CEA/DEN, EDF R&D
+#
+# 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, 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
+# 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
+#
+
+import unittest
+
+import salome
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New()
+
+class BasicGeomObjsEx11(unittest.TestCase):
+
+ def testNoRaiseOnMakeFaceWires(self):
+ """
+ Work in pair with testRaiseOnMakeFaceWires
+ """
+ pts = [(0,0,0),(1,0,0),(1,1,1e-6),(0,1,0)] # diff with testRaiseOnMakeFaceWires is 1e-6 instead of 1e-5
+ vertices = [ geompy.MakeVertex(*list(elt)) for elt in pts]
+ polyline0 = geompy.MakePolyline([ vertices[nodeidx] for nodeidx in range(len(pts)) ], True)
+ wire_0 = geompy.MakeFaceWires( [ polyline0 ] , isPlanarWanted = True, theName=None, raiseException=True) # isPlanarWanted and raiseException are expected to be True here !
+ self.assertTrue(wire_0) # wire_0 is expected to be not None because wire has been created and detected to be planar
+ wire_1 = geompy.MakeFace( polyline0 , isPlanarWanted = True, theName=None, raiseException=True) # isPlanarWanted and raiseException are expected to be True here !
+ self.assertTrue(wire_1)
+
+ def testRaiseOnMakeFaceWires(self):
+ """
+ Work in pair with testNoRaiseOnMakeFaceWires
+ """
+ pts = [(0,0,0),(1,0,0),(1,1,1e-5),(0,1,0)] # diff with testRaiseOnMakeFaceWires is 1e-5 instead of 1e-6
+ vertices = [ geompy.MakeVertex(*list(elt)) for elt in pts]
+ polyline0 = geompy.MakePolyline([ vertices[nodeidx] for nodeidx in range(len(pts)) ], True)
+ # MakeFaceWires is expected to fail here because third point is too far from Oxy plane
+ self.assertRaises( RuntimeError, geompy.MakeFaceWires, [ polyline0 ] , True, None, True )# isPlanarWanted and raiseException are expected to be True here !
+ wire_0 = geompy.MakeFaceWires( [ polyline0 ] , isPlanarWanted = True, theName=None, raiseException=False) # returns something bug wire_0 is incorrect
+ self.assertRaises( RuntimeError, geompy.MakeFace, polyline0 , True, None, True )# isPlanarWanted and raiseException are expected to be True here !
+ wire_1 = geompy.MakeFace( polyline0 , isPlanarWanted = True, theName=None, raiseException=False) # returns something bug wire_1 is incorrect
+
+if __name__ == '__main__':
+ unittest.main()
if not Operation.IsDone() and Operation.GetErrorCode() != "NOT_FOUND_ANY":
raise RuntimeError(Method_name + " : " + Operation.GetErrorCode())
+def PrintOrRaise(message, raiseException=False):
+ if raiseException:
+ raise RuntimeError(message)
+ else:
+ print(message)
+
## Return list of variables value from salome notebook
## @ingroup l1_geomBuilder_auxiliary
def ParseParameters(*parameters):
#
# @ref tui_creation_face "Example"
@ManageTransactions("ShapesOp")
- def MakeFace(self, theWire, isPlanarWanted, theName=None):
+ def MakeFace(self, theWire, isPlanarWanted, theName=None, raiseException=False):
"""
Create a face on the given wire.
# Example: see GEOM_TestAll.py
anObj = self.ShapesOp.MakeFace(theWire, isPlanarWanted)
if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
- print("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.")
+ PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
else:
RaiseIfFailed("MakeFace", self.ShapesOp)
self._autoPublish(anObj, theName, "face")
#
# @ref tui_creation_face "Example"
@ManageTransactions("ShapesOp")
- def MakeFaceWires(self, theWires, isPlanarWanted, theName=None):
+ def MakeFaceWires(self, theWires, isPlanarWanted, theName=None, raiseException=False):
"""
Create a face on the given wires set.
# Example: see GEOM_TestAll.py
anObj = self.ShapesOp.MakeFaceWires(ToList(theWires), isPlanarWanted)
if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
- print("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.")
+ PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
else:
RaiseIfFailed("MakeFaceWires", self.ShapesOp)
self._autoPublish(anObj, theName, "face")