Salome HOME
Mise à niveau python
[modules/smesh.git] / src / Tools / blocFissure / gmu / identifieElementsDebouchants_a.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 """Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
21
22 import logging
23 import math
24
25 from . import initLog
26
27 from .geomsmesh import geompy
28 from .geomsmesh import geomPublishInFather
29
30 from .produitMixte import produitMixte
31
32 def identifieElementsDebouchants_a(iedf,\
33                                    partitionPeauFissFond, edgesFondFiss, wireFondFiss, \
34                                    verticesPipePeau, rayonPipe, edge):
35   """Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
36
37   logging.info('start')
38
39   name = "edgeFondIn{}".format(iedf)
40   geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
41   dist = [ geompy.MinDistance(pt, edge) for pt in verticesPipePeau]
42   ptPeau = verticesPipePeau[dist.index(min(dist))] # le point de verticesPipePeau a distance minimale de l'edge
43   [parametre, PointOnEdge, EdgeInWireIndex]  = geompy.MakeProjectionOnWire(ptPeau, wireFondFiss)
44   logging.debug("parametre:%s, EdgeInWireIndex: %s, len(edgesFondFiss): %s", parametre, EdgeInWireIndex, len(edgesFondFiss))
45
46   localEdgeInFondFiss = edgesFondFiss[EdgeInWireIndex]
47   centre = PointOnEdge
48   centre2 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, parametre)
49   geomPublishInFather(initLog.debug, partitionPeauFissFond, centre2, "centre2_{}".format(iedf))
50   name = "verticeEdgesFondIn{}".format(iedf)
51   geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, name)
52   norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, parametre)
53   geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, "norm{}".format(iedf))
54   cercle = geompy.MakeCircle(centre, norm, rayonPipe)
55   geomPublishInFather(initLog.debug, partitionPeauFissFond, cercle, "cerclorig{}".format(iedf))
56   [vertex] = geompy.ExtractShapes(cercle, geompy.ShapeType["VERTEX"], False)
57   vec1 = geompy.MakeVector(centre, vertex)
58   vec2 = geompy.MakeVector(centre, ptPeau)
59   angle = geompy.GetAngleRadians(vec1, vec2)
60   # cas général : on reconstitue une portion de pipe, avec l'arête de couture qui coincide
61   #   avec la face de fissure, au niveau du débouché sur la face externe
62   # cas dégénéré : le pipe débouche perpendiculairement à une surface plane à l'origine.
63   #   La partition filling / pipe reconstruit échoue.
64   #   - Si on partitionne le filling avec un simple pipe obtenu par extrusion droite du cercle,
65   #     cela donne un point en trop sur le cercle.
66   #   - Si on prend une vraie surface plane (pas un filling), on peut faire la partition avec
67   #     les pipes reconstruits
68   logging.debug("angle=%s", angle)
69
70   #if abs(angle) > 1.e-7:
71   sommetAxe = geompy.MakeTranslationVector(centre, norm)
72   if ( produitMixte(centre, vertex, ptPeau, sommetAxe) > 0 ):  # ajout de pi a (-)angle pour éviter des points confondus (partition échoue) dans les cas dégénérés
73     cercle = geompy.MakeRotation(cercle, norm, angle + math.pi)
74   else:
75     cercle = geompy.MakeRotation(cercle, norm, -angle + math.pi)
76   name = "cercle{}".format(iedf)
77   geomPublishInFather(initLog.debug,partitionPeauFissFond, cercle, name)
78
79   return ptPeau, centre, norm, localEdgeInFondFiss, localEdgeInFondFiss, cercle