From: GERALD NICOLAS Date: Thu, 15 Apr 2021 13:40:06 +0000 (+0200) Subject: Découpage de claculePointsAxiauxPipe X-Git-Tag: V9_7_0a1~3^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb7885b577e8b570a49ff7e755b8a11302d8571e;p=modules%2Fsmesh.git Découpage de claculePointsAxiauxPipe --- diff --git a/src/Tools/blocFissure/gmu/CMakeLists.txt b/src/Tools/blocFissure/gmu/CMakeLists.txt index 8fdcb3a6d..dfd9fc247 100644 --- a/src/Tools/blocFissure/gmu/CMakeLists.txt +++ b/src/Tools/blocFissure/gmu/CMakeLists.txt @@ -25,6 +25,9 @@ SET(plugin_SCRIPTS ajustePointsEdgePipeFissure.py blocDefaut.py calculePointsAxiauxPipe.py + calculePointsAxiauxPipe_a.py + calculePointsAxiauxPipe_b.py + calculePointsAxiauxPipe_c.py casStandard.py checkDecoupePartition.py commonSubShapes.py diff --git a/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe.py b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe.py index f67262afc..5fdc48fb1 100644 --- a/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe.py +++ b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe.py @@ -20,21 +20,18 @@ """Préparation maillage du pipe""" import logging -import math -from .geomsmesh import geompy -from .geomsmesh import smesh +from .calculePointsAxiauxPipe_a import calculePointsAxiauxPipe_a +from .calculePointsAxiauxPipe_b import calculePointsAxiauxPipe_b +from .calculePointsAxiauxPipe_c import calculePointsAxiauxPipe_c -from .putName import putName - -def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut, - centreFondFiss, wireFondFiss, wirePipeFiss, +def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut, \ + centreFondFiss, wireFondFiss, wirePipeFiss, \ lenSegPipe, rayonPipe, nbsegCercle, nbsegRad, \ nro_cas=None): """Préparation maillage du pipe : - - détections des points a respecter : jonction des edges/faces constituant - la face de fissure externe au pipe + - détections des points a respecter : jonction des edges/faces constituant la face de fissure externe au pipe - points sur les edges de fond de fissure et edges pipe/face fissure, - vecteurs tangents au fond de fissure (normal au disque maillé) """ @@ -42,117 +39,19 @@ def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut, logging.info('start') logging.info("Pour le cas n°%s", nro_cas) - # --- option de maillage selon le rayon de courbure du fond de fissure - lenEdgeFondExt = 0 - for edff in edgesFondFiss: - lenEdgeFondExt += geompy.BasicProperties(edff)[0] - - disfond = list() - for filling in facesDefaut: - disfond.append(geompy.MinDistance(centreFondFiss, filling)) - disfond.sort() - rcourb = disfond[0] - texte = "rcourb: {}, lenEdgeFondExt: {}, lenSegPipe: {}".format(rcourb, lenEdgeFondExt, lenSegPipe) - logging.info(texte) - nbSegQuart = 5 # on veut 5 segments min sur un quart de cercle - alpha = math.pi/(4*nbSegQuart) - deflexion = rcourb*(1.0 -math.cos(alpha)) - lgmin = lenSegPipe*0.25 - lgmax = lenSegPipe*1.5 - texte = "==> deflexion: {}, lgmin: {}, lgmax: {}".format(deflexion, lgmin, lgmax) - logging.info(texte) - - meshFondExt = smesh.Mesh(wireFondFiss) - putName(meshFondExt, "wireFondFiss", i_pref=nro_cas) - algo1d = meshFondExt.Segment() - hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure - putName(algo1d.GetSubMesh(), "wireFondFiss", i_pref=nro_cas) - putName(algo1d, "algo1d_wireFondFiss", i_pref=nro_cas) - putName(hypo1d, "hypo1d_wireFondFiss", i_pref=nro_cas) - - is_done = meshFondExt.Compute() - text = "calculePointsAxiauxPipe meshFondExt.Compute" - if is_done: - logging.info(text) - else: - text = "Erreur au calcul du maillage.\n" + text - logging.info(text) - raise Exception(text) - - ptGSdic = dict() # dictionnaire [paramètre sur la courbe] --> point géométrique - allNodeIds = meshFondExt.GetNodesId() - for nodeId in allNodeIds: - xyz = meshFondExt.GetNodeXYZ(nodeId) - #logging.debug("nodeId %s, coords %s", nodeId, str(xyz)) - point = geompy.MakeVertex(xyz[0], xyz[1], xyz[2]) - parametre, _, EdgeInWireIndex = geompy.MakeProjectionOnWire(point, wireFondFiss) # parametre compris entre 0 et 1 - edgeOrder = edgesIdByOrientation[EdgeInWireIndex] - ptGSdic[(edgeOrder, EdgeInWireIndex, parametre)] = point - #logging.debug("nodeId %s, parametre %s", nodeId, str(parametre)) - usort = sorted(ptGSdic) - logging.debug("nombre de points obtenus par deflexion %s",len(usort)) + # --- Maillage selon le rayon de courbure du fond de fissure - centres = list() - origins = list() - normals = list() - for edu in usort: - vertcx = ptGSdic[edu] - norm = geompy.MakeTangentOnCurve(edgesFondFiss[edu[1]], edu[2]) - plan = geompy.MakePlane(vertcx, norm, 3.*rayonPipe) - part = geompy.MakePartition([plan], [wirePipeFiss], list(), list(), geompy.ShapeType["VERTEX"], 0, list(), 0) - liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True) - if ( len(liste) == 5 ): # 4 coins du plan plus intersection recherchée - for point in liste: - if geompy.MinDistance(point, vertcx) < 1.1*rayonPipe: # les quatre coins sont plus loin - vertpx = point - break - centres.append(vertcx) - origins.append(vertpx) - normals.append(norm) -# name = "vertcx%d"%i -# geompy.addToStudyInFather(wireFondFiss, vertcx, name) -# name = "vertpx%d"%i -# geompy.addToStudyInFather(wireFondFiss, vertpx, name) -# name = "plan%d"%i -# geompy.addToStudyInFather(wireFondFiss, plan, name) - - # --- maillage du pipe étendu, sans tenir compte de l'intersection avec la face de peau - - logging.debug("nbsegCercle %s", nbsegCercle) - - # ----------------------------------------------------------------------- + meshFondFiss = calculePointsAxiauxPipe_a(facesDefaut, centreFondFiss, wireFondFiss, \ + lenSegPipe, \ + nro_cas) # --- points géométriques - gptsdisks = list() # vertices géométrie de tous les disques - raydisks = [list() for _ in range(nbsegCercle)] - for indice, centres_i in enumerate(centres): # boucle sur les disques - gptdsk = list() # vertices géométrie d'un disque - vertcx = centres_i - vertpx = origins[indice] - normal = normals[indice] - vec1 = geompy.MakeVector(vertcx, vertpx) - - points = [vertcx] # les points du rayon de référence - dist_0 = rayonPipe/float(nbsegRad) - for j_aux in range(nbsegRad): - point = geompy.MakeTranslationVectorDistance(vertcx, vec1, float(j_aux+1)*dist_0) - points.append(point) - gptdsk.append(points) - point = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe) - rayon = geompy.MakeLineTwoPnt(vertcx, point) - raydisks[0].append(rayon) - - angle_0 = 2.*math.pi/float(nbsegCercle) - for k_aux in range(nbsegCercle-1): - angle = float(k_aux+1)*angle_0 - pts = [vertcx] # les points d'un rayon obtenu par rotation - for j_aux in range(nbsegRad): - point = geompy.MakeRotation(points[j_aux+1], normal, angle) - pts.append(point) - gptdsk.append(pts) - ray = geompy.MakeRotation(rayon, normal, angle) - raydisks[k_aux+1].append(ray) + centres, origins, normals = calculePointsAxiauxPipe_b(meshFondFiss, \ + edgesFondFiss, edgesIdByOrientation, \ + wireFondFiss, wirePipeFiss, \ + rayonPipe) - gptsdisks.append(gptdsk) + gptsdisks, raydisks = calculePointsAxiauxPipe_c(centres, origins, normals, \ + rayonPipe, nbsegCercle, nbsegRad) return (centres, gptsdisks, raydisks) diff --git a/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_a.py b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_a.py new file mode 100644 index 000000000..a0e07a1ef --- /dev/null +++ b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_a.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-2021 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 +# +"""Maillage selon le rayon de courbure du fond de fissure""" + +import logging +import math + +from .geomsmesh import geompy +from .geomsmesh import smesh + +from .putName import putName + +def calculePointsAxiauxPipe_a(facesDefaut, centreFondFiss, wireFondFiss, \ + lenSegPipe, \ + nro_cas=None): + """Maillage selon le rayon de courbure du fond de fissure""" + + logging.info('start') + + # Rayon de courbure maximal + disfond = list() + for filling in facesDefaut: + disfond.append(geompy.MinDistance(centreFondFiss, filling)) + disfond.sort() + + texte = "rcourb: {}, lenSegPipe: {}".format(disfond[0], lenSegPipe) + logging.info(texte) + + # Maillage 1D + lgmin = lenSegPipe*0.25 + lgmax = lenSegPipe*1.5 + # la déflexion ets la distance maximale entre une arête du maillage et la courbe support + nbSegQuart = 5 # on veut 5 segments min sur un quart de cercle + alpha = math.pi/(4*nbSegQuart) + deflexion = disfond[0]*(1.0 -math.cos(alpha)) + texte = "==> lgmin: {}, lgmax: {}, deflexion: {}".format(deflexion, lgmin, lgmax) + logging.info(texte) + + meshFondFiss = smesh.Mesh(wireFondFiss) + putName(meshFondFiss, "wireFondFiss", i_pref=nro_cas) + algo1d = meshFondFiss.Segment() + hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure + putName(algo1d.GetSubMesh(), "wireFondFiss", i_pref=nro_cas) + putName(algo1d, "algo1d_wireFondFiss", i_pref=nro_cas) + putName(hypo1d, "hypo1d_wireFondFiss", i_pref=nro_cas) + + is_done = meshFondFiss.Compute() + text = "calculePointsAxiauxPipe meshFondFiss.Compute" + if is_done: + logging.info(text) + else: + text = "Erreur au calcul du maillage.\n" + text + logging.info(text) + raise Exception(text) + + return meshFondFiss diff --git a/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_b.py b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_b.py new file mode 100644 index 000000000..3aa8c08ef --- /dev/null +++ b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_b.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-2021 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 +# +"""Préparation maillage du pipe""" + +import logging + +from .geomsmesh import geompy +from .geomsmesh import geomPublishInFather + +from . import initLog + +def calculePointsAxiauxPipe_b(meshFondFiss, \ + edgesFondFiss, edgesIdByOrientation, \ + wireFondFiss, wirePipeFiss, \ + rayonPipe): + """Préparation maillage du pipe : + + - détections des points a respecter : jonction des edges/faces constituant la face de fissure externe au pipe + - points sur les edges de fond de fissure et edges pipe/face fissure, + - vecteurs tangents au fond de fissure (normal au disque maillé) + """ + + logging.info('start') + + ptGSdic = dict() # dictionnaire [paramètre sur la courbe] --> point géométrique + allNodeIds = meshFondFiss.GetNodesId() + for nodeId in allNodeIds: + xyz = meshFondFiss.GetNodeXYZ(nodeId) + #logging.debug("nodeId %s, coords %s", nodeId, str(xyz)) + point = geompy.MakeVertex(xyz[0], xyz[1], xyz[2]) + parametre, _, EdgeInWireIndex = geompy.MakeProjectionOnWire(point, wireFondFiss) # parametre compris entre 0 et 1 + edgeOrder = edgesIdByOrientation[EdgeInWireIndex] + ptGSdic[(edgeOrder, EdgeInWireIndex, parametre)] = point + #logging.debug("nodeId %s, parametre %s", nodeId, str(parametre)) + usort = sorted(ptGSdic) + logging.debug("nombre de points obtenus par deflexion : %s",len(usort)) + + centres = list() + origins = list() + normals = list() + for i_aux, edu in enumerate(usort): + vertcx = ptGSdic[edu] + geomPublishInFather(initLog.debug, wireFondFiss, vertcx, "vertcx_{}".format(i_aux)) + norm = geompy.MakeTangentOnCurve(edgesFondFiss[edu[1]], edu[2]) + plan = geompy.MakePlane(vertcx, norm, 3.*rayonPipe) + part = geompy.MakePartition([plan], [wirePipeFiss], list(), list(), geompy.ShapeType["VERTEX"], 0, list(), 0) + liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True) + if ( len(liste) == 5 ): # 4 coins du plan plus intersection recherchée + for point in liste: + if geompy.MinDistance(point, vertcx) < 1.1*rayonPipe: # les quatre coins sont plus loin + vertpx = point + geomPublishInFather(initLog.debug, wireFondFiss, vertpx, "vertpx_{}".format(i_aux)) + break + centres.append(vertcx) + origins.append(vertpx) + normals.append(norm) + + return centres, origins, normals diff --git a/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_c.py b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_c.py new file mode 100644 index 000000000..182898999 --- /dev/null +++ b/src/Tools/blocFissure/gmu/calculePointsAxiauxPipe_c.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014-2021 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 +# +"""Préparation maillage du pipe""" + +import logging +import math + +from .geomsmesh import geompy + +def calculePointsAxiauxPipe_c(centres, origins, normals, \ + rayonPipe, nbsegCercle, nbsegRad): + """Préparation maillage du pipe : + + - détections des points a respecter : jonction des edges/faces constituant la face de fissure externe au pipe + - points sur les edges de fond de fissure et edges pipe/face fissure, + - vecteurs tangents au fond de fissure (normal au disque maillé) + """ + + logging.info('start') + logging.debug("nbsegCercle = %d, nbsegRad = %d", nbsegCercle, nbsegRad) + + # ----------------------------------------------------------------------- + # --- points géométriques + + gptsdisks = list() # vertices géométrie de tous les disques + raydisks = [list() for _ in range(nbsegCercle)] + +# boucle sur les disques + for indice, centres_i in enumerate(centres): + gptdsk = list() # vertices géométrie d'un disque + vertcx = centres_i + vertpx = origins[indice] + normal = normals[indice] + vec1 = geompy.MakeVector(vertcx, vertpx) + + points = [vertcx] # les points du rayon de référence + dist_0 = rayonPipe/float(nbsegRad) + for j_aux in range(nbsegRad): + point = geompy.MakeTranslationVectorDistance(vertcx, vec1, float(j_aux+1)*dist_0) + points.append(point) + gptdsk.append(points) + point = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe) + rayon = geompy.MakeLineTwoPnt(vertcx, point) + raydisks[0].append(rayon) + + angle_0 = 2.*math.pi/float(nbsegCercle) + for k_aux in range(nbsegCercle-1): + angle = float(k_aux+1)*angle_0 + pts = [vertcx] # les points d'un rayon obtenu par rotation + for j_aux in range(nbsegRad): + point = geompy.MakeRotation(points[j_aux+1], normal, angle) + pts.append(point) + gptdsk.append(pts) + ray = geompy.MakeRotation(rayon, normal, angle) + raydisks[k_aux+1].append(ray) + + gptsdisks.append(gptdsk) + + return gptsdisks, raydisks diff --git a/src/Tools/blocFissure/gmu/creePointsPipePeau.py b/src/Tools/blocFissure/gmu/creePointsPipePeau.py index 7936be3c7..5d967dffb 100644 --- a/src/Tools/blocFissure/gmu/creePointsPipePeau.py +++ b/src/Tools/blocFissure/gmu/creePointsPipePeau.py @@ -72,7 +72,7 @@ def creePointsPipePeau(listEdges, idFacesDebouchantes, idFillingFromBout, bout = extrCircs[1] else: bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], dist) - name = "bout_{}";format(i_aux) + name = "bout_{}".format(i_aux) geomPublishInFather(initLog.debug, centre, bout, name) # enregistrement des points dans la structure points = list()