Salome HOME
Correcion de programmation - fichiers en python
[modules/smesh.git] / src / Tools / blocFissure / gmu / partitionneFissureParPipe.py
index 7d6289797d00843eac503d3ba6d55c3c77646098..d0a4e4f406207cba7ebb6e5278e305339034975b 100644 (file)
@@ -1,13 +1,33 @@
 # -*- coding: utf-8 -*-
+# Copyright (C) 2014-2020  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 math
 import logging
-from geomsmesh import geompy
-from geomsmesh import geomPublish
-from geomsmesh import geomPublishInFather
-import initLog
-from findWireEndVertices import findWireEndVertices
-from prolongeWire import prolongeWire
+from .geomsmesh import geompy
+from .geomsmesh import geomPublish
+from .geomsmesh import geomPublishInFather
+from . import initLog
+from .findWireEndVertices import findWireEndVertices
+from .prolongeWire import prolongeWire
+import traceback
+from .fissError import fissError
 
 def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
   """
@@ -33,7 +53,12 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
   cercle = geompy.MakeRotation(cercle, norms[0], math.pi/3.0 ) # éviter d'avoir l'arête de couture du pipe presque confondue avec la face fissure
   geomPublish(initLog.debug, cercle, 'cercle')
   fondFissProlonge = prolongeWire(fondFiss, extrem, norms, 2*rayonPipe)
-  pipeFiss = geompy.MakePipe(cercle, fondFissProlonge)
+  try:
+    pipeFiss = geompy.MakePipe(cercle, fondFissProlonge)
+  except:
+    texte = "génération du pipe le long de la ligne de fond de fissure prolongée impossible. "
+    texte += "Cause possible : la ligne s'autointersecte lorsqu'on la prolonge."
+    raise fissError(traceback.extract_stack(),texte)
   geomPublish(initLog.debug, pipeFiss, 'pipeFiss')
   partFissPipe = geompy.MakePartition([shapeDefaut, pipeFiss], [], [], [], geompy.ShapeType["FACE"], 0, [], 1)
   geomPublish(initLog.debug, partFissPipe, 'partFissPipe')