X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FblocFissure%2Fgmu%2FpartitionneFissureParPipe.py;h=d0a4e4f406207cba7ebb6e5278e305339034975b;hb=0fc0831670e27a5611b941c52dc152fd63964515;hp=8f770fa512b6cfda7dd0b33e52aea03702690eca;hpb=cfa45d551fd47dd3648dea6e50ac74329b0d9e5d;p=modules%2Fsmesh.git diff --git a/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py b/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py index 8f770fa51..d0a4e4f40 100644 --- a/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py +++ b/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py @@ -1,10 +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 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): """ @@ -21,41 +44,46 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe): plan = geompy.MakePlane(centreFondFiss, tgtCentre, 10000) shapeDefaut = geompy.MakePartition([shapeDefaut], [plan], [], [], geompy.ShapeType["FACE"], 0, [], 0) #fondFissCoupe = geompy.GetInPlaceByHistory(shapeDefaut, fondFiss) #= inutile - geompy.addToStudy(shapeDefaut, 'shapeDefaut_coupe') - #geompy.addToStudyInFather(shapeDefaut, fondFissCoupe, 'fondFiss_coupe') + geomPublish(initLog.debug, shapeDefaut, 'shapeDefaut_coupe') + #geomPublishInFather(initLog.debug,shapeDefaut, fondFissCoupe, 'fondFiss_coupe') extrem, norms = findWireEndVertices(fondFiss, True) logging.debug("extrem: %s, norm: %s",extrem, norms) cercle = geompy.MakeCircle(extrem[0], norms[0], 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 - geompy.addToStudy(cercle, 'cercle') + geomPublish(initLog.debug, cercle, 'cercle') fondFissProlonge = prolongeWire(fondFiss, extrem, norms, 2*rayonPipe) - pipeFiss = geompy.MakePipe(cercle, fondFissProlonge) - geompy.addToStudy(pipeFiss, 'pipeFiss') + 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) - geompy.addToStudy(partFissPipe, 'partFissPipe') + geomPublish(initLog.debug, partFissPipe, 'partFissPipe') fissPipe = geompy.GetInPlaceByHistory(partFissPipe, shapeDefaut) - geompy.addToStudy(fissPipe, 'fissPipe') + geomPublish(initLog.debug, fissPipe, 'fissPipe') partPipe = geompy.GetInPlaceByHistory(partFissPipe, pipeFiss) - geompy.addToStudy(partPipe, 'partPipe') + geomPublish(initLog.debug, partPipe, 'partPipe') edgesPipeFiss = geompy.GetSharedShapesMulti([fissPipe, partPipe], geompy.ShapeType["EDGE"]) for i, edge in enumerate(edgesPipeFiss): name = "edgePipe%d"%i - geompy.addToStudyInFather(fissPipe, edge, name) + geomPublishInFather(initLog.debug,fissPipe, edge, name) try: wirePipeFiss = geompy.MakeWire(edgesPipeFiss) except: wirePipeFiss = geompy.MakeCompound(edgesPipeFiss) logging.debug("wirePipeFiss construit sous forme de compound") - geompy.addToStudy(wirePipeFiss, "wirePipeFiss") + geomPublish(initLog.debug, wirePipeFiss, "wirePipeFiss") wireFondFiss = geompy.GetInPlace(partFissPipe,fondFiss) edgesFondFiss = geompy.GetSharedShapesMulti([fissPipe, wireFondFiss], geompy.ShapeType["EDGE"]) for i, edge in enumerate(edgesFondFiss): name = "edgeFondFiss%d"%i - geompy.addToStudyInFather(fissPipe, edge, name) + geomPublishInFather(initLog.debug,fissPipe, edge, name) wireFondFiss = geompy.MakeWire(edgesFondFiss) - geompy.addToStudy(wireFondFiss,"wireFondFiss") + geomPublish(initLog.debug, wireFondFiss,"wireFondFiss") return (fissPipe, edgesPipeFiss, edgesFondFiss, wirePipeFiss, wireFondFiss) \ No newline at end of file