Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / Tools / blocFissure / gmu / calculePointsAxiauxPipe_b.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2022  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 """Préparation maillage du pipe"""
21
22 import logging
23
24 from .geomsmesh import geompy
25 from .geomsmesh import geomPublishInFather
26
27 from . import initLog
28
29 def calculePointsAxiauxPipe_b(meshFondFiss, \
30                               edgesFondFiss, edgesIdByOrientation, \
31                               wireFondFiss, wirePipeFiss, \
32                               rayonPipe):
33   """Préparation maillage du pipe :
34
35   - détections des points a respecter : jonction des edges/faces constituant la face de fissure externe au pipe
36   - points sur les edges de fond de fissure et edges pipe/face fissure,
37   - vecteurs tangents au fond de fissure (normal au disque maillé)
38   """
39
40   logging.info('start')
41
42   ptGSdic = dict() # dictionnaire [paramètre sur la courbe] --> point géométrique
43   allNodeIds = meshFondFiss.GetNodesId()
44   for nodeId in allNodeIds:
45     xyz = meshFondFiss.GetNodeXYZ(nodeId)
46     #logging.debug("nodeId %s, coords %s", nodeId, str(xyz))
47     point = geompy.MakeVertex(xyz[0], xyz[1], xyz[2])
48     parametre, _, EdgeInWireIndex = geompy.MakeProjectionOnWire(point, wireFondFiss) # parametre compris entre 0 et 1
49     edgeOrder = edgesIdByOrientation[EdgeInWireIndex]
50     ptGSdic[(edgeOrder, EdgeInWireIndex, parametre)] = point
51     #logging.debug("nodeId %s, parametre %s", nodeId, str(parametre))
52   usort = sorted(ptGSdic)
53   logging.debug("nombre de points obtenus par deflexion : %s",len(usort))
54
55   centres = list()
56   origins = list()
57   normals = list()
58   for i_aux, edu in enumerate(usort):
59     vertcx = ptGSdic[edu]
60     geomPublishInFather(initLog.debug, wireFondFiss, vertcx, "vertcx_{}".format(i_aux))
61     norm = geompy.MakeTangentOnCurve(edgesFondFiss[edu[1]], edu[2])
62     plan = geompy.MakePlane(vertcx, norm, 3.*rayonPipe)
63     part = geompy.MakePartition([plan], [wirePipeFiss], list(), list(), geompy.ShapeType["VERTEX"], 0, list(), 0)
64     liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True)
65     if ( len(liste) == 5 ): # 4 coins du plan plus intersection recherchée
66       for point in liste:
67         if geompy.MinDistance(point, vertcx) < 1.1*rayonPipe: # les quatre coins sont plus loin
68           vertpx = point
69           geomPublishInFather(initLog.debug, wireFondFiss, vertpx, "vertpx_{}".format(i_aux))
70           break
71       centres.append(vertcx)
72       origins.append(vertpx)
73       normals.append(norm)
74
75   return centres, origins, normals