Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / identifieElementsDebouchants_c.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """Position des points extremite du pipe sur l'edge debouchante"""
21
22 import logging
23
24 import traceback
25
26 from . import initLog
27
28 from .geomsmesh import geompy
29 from .geomsmesh import geomPublishInFather
30
31 from .fissError import fissError
32
33 def identifieElementsDebouchants_c(iedf,\
34                                    partitionPeauFissFond, wireFondFiss, \
35                                    centre, localEdgeInFondFiss, cercle, loc_pt0, lgp, pipexts):
36   """Position des points extremite du pipe sur l'edge debouchante"""
37
38   logging.info('start')
39
40   # ---
41   #     il faut la distance curviligne ofp du point central par rapport à une extrémité de l'edge débouchante
42   locEdgePart = geompy.MakePartition([localEdgeInFondFiss],[centre], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
43   edgesLoc = geompy.ExtractShapes(locEdgePart, geompy.ShapeType["EDGE"], False)
44   edgesLocSorted =[(geompy.MinDistance(edge, loc_pt0), kk, edge) for kk, edge in enumerate(edgesLoc)]
45   edgesLocSorted.sort()
46   try:
47     ofp = geompy.BasicProperties(edgesLocSorted[0][2])[0] # distance curviligne centre loc_pt0
48   except:
49     texte = "Identification des éléments au débouché du pipe sur la face externe impossible. "
50     texte += "Cause possible : la ligne de fond de fissure comprend un point géométrique coincidant avec la face externe. "
51     texte += "La ligne de fond de fissure doit déboucher franchement de la face externe, et ne doit pas être coupée au niveau de la face."
52     raise fissError(traceback.extract_stack(),texte)
53   logging.debug("distance curviligne centre extremite0: %s", ofp)
54   point_1 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp +lgp, loc_pt0)
55   point_2 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp -lgp, loc_pt0)
56   geomPublishInFather(initLog.debug, wireFondFiss, point_1, "point_1_{}".format(iedf))
57   geomPublishInFather(initLog.debug, wireFondFiss, point_2, "point_2_{}".format(iedf))
58
59   edgePart = geompy.MakePartition([localEdgeInFondFiss], [point_1,point_2], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
60   edps = geompy.ExtractShapes(edgePart, geompy.ShapeType["EDGE"], True)
61   for edp in edps:
62     if geompy.MinDistance(centre, edp) < 1.e-3:
63       pipext = geompy.MakePipe(cercle, edp)
64       name = "pipeExt{}".format(iedf)
65       geomPublishInFather(initLog.debug, partitionPeauFissFond, pipext, name)
66       pipexts.append(pipext)
67
68   return