1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 from .geomsmesh import geompy
25 from .geomsmesh import smesh
27 def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
28 centreFondFiss, wireFondFiss, wirePipeFiss,
29 lenSegPipe, rayonPipe, nbsegCercle, nbsegRad):
31 preparation maillage du pipe :
32 - détections des points a respecter : jonction des edges/faces constituant
33 la face de fissure externe au pipe
34 - points sur les edges de fond de fissure et edges pipe/face fissure,
35 - vecteurs tangents au fond de fissure (normal au disque maillé)
40 # --- option de maillage selon le rayon de courbure du fond de fissure
42 for edff in edgesFondFiss:
43 lenEdgeFondExt += geompy.BasicProperties(edff)[0]
46 for filling in facesDefaut:
47 disfond.append(geompy.MinDistance(centreFondFiss, filling))
50 nbSegQuart = 5 # on veut 5 segments min sur un quart de cercle
51 alpha = math.pi/(4*nbSegQuart)
52 deflexion = rcourb*(1.0 -math.cos(alpha))
53 lgmin = lenSegPipe*0.25
54 lgmax = lenSegPipe*1.5
55 logging.debug("rcourb: %s, lenFond:%s, deflexion: %s, lgmin: %s, lgmax: %s", rcourb, lenEdgeFondExt, deflexion, lgmin, lgmax)
57 meshFondExt = smesh.Mesh(wireFondFiss)
58 algo1d = meshFondExt.Segment()
59 hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure
60 isDone = meshFondExt.Compute()
62 ptGSdic = {} # dictionnaire [paramètre sur la courbe] --> point géométrique
63 allNodeIds = meshFondExt.GetNodesId()
64 for nodeId in allNodeIds:
65 xyz = meshFondExt.GetNodeXYZ(nodeId)
66 #logging.debug("nodeId %s, coords %s", nodeId, str(xyz))
67 pt = geompy.MakeVertex(xyz[0], xyz[1], xyz[2])
68 u, PointOnEdge, EdgeInWireIndex = geompy.MakeProjectionOnWire(pt, wireFondFiss) # u compris entre 0 et 1
69 edgeOrder = edgesIdByOrientation[EdgeInWireIndex]
70 ptGSdic[(edgeOrder, EdgeInWireIndex, u)] = pt
71 #logging.debug("nodeId %s, u %s", nodeId, str(u))
72 usort = sorted(ptGSdic)
73 logging.debug("nombre de points obtenus par deflexion %s",len(usort))
82 norm = geompy.MakeTangentOnCurve(edgesFondFiss[ied], u)
83 plan = geompy.MakePlane(vertcx, norm, 3*rayonPipe)
84 part = geompy.MakePartition([plan], [wirePipeFiss], [], [], geompy.ShapeType["VERTEX"], 0, [], 0)
85 liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True)
86 if len(liste) == 5: # 4 coins du plan plus intersection recherchée
88 if geompy.MinDistance(point, vertcx) < 1.1*rayonPipe: # les quatre coins sont plus loin
91 centres.append(vertcx)
92 origins.append(vertpx)
95 # geompy.addToStudyInFather(wireFondFiss, vertcx, name)
97 # geompy.addToStudyInFather(wireFondFiss, vertpx, name)
99 # geompy.addToStudyInFather(wireFondFiss, plan, name)
101 # --- maillage du pipe étendu, sans tenir compte de l'intersection avec la face de peau
103 logging.debug("nbsegCercle %s", nbsegCercle)
105 # -----------------------------------------------------------------------
106 # --- points géométriques
108 gptsdisks = [] # vertices géométrie de tous les disques
109 raydisks = [[] for i in range(nbsegCercle)]
110 for i in range(len(centres)): # boucle sur les disques
111 gptdsk = [] # vertices géométrie d'un disque
115 vec1 = geompy.MakeVector(vertcx, vertpx)
117 points = [vertcx] # les points du rayon de référence
118 for j in range(nbsegRad):
119 pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, (j+1)*float(rayonPipe)/nbsegRad)
121 gptdsk.append(points)
122 pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe)
123 rayon = geompy.MakeLineTwoPnt(vertcx, pt)
124 raydisks[0].append(rayon)
126 for k in range(nbsegCercle-1):
127 angle = (k+1)*2*math.pi/nbsegCercle
128 pts = [vertcx] # les points d'un rayon obtenu par rotation
129 for j in range(nbsegRad):
130 pt = geompy.MakeRotation(points[j+1], normal, angle)
133 ray = geompy.MakeRotation(rayon, normal, angle)
134 raydisks[k+1].append(ray)
136 gptsdisks.append(gptdsk)
138 return (centres, gptsdisks, raydisks)