Mise à niveau python

This commit is contained in:
GERALD NICOLAS 2021-04-02 13:17:18 +02:00
parent 3f80bd1060
commit b4a070b88f
41 changed files with 2059 additions and 1329 deletions

View File

@ -30,10 +30,17 @@ SET(plugin_SCRIPTS
commonSubShapes.py
compoundFromList.py
construitEdgesRadialesDebouchantes.py
construitEdgesRadialesDebouchantes_a.py
construitEdgesRadialesDebouchantes_b.py
construitEdgesRadialesDebouchantes_c.py
construitFissureGenerale.py
construitFissureGenerale_a.py
construitFissureGenerale_b.py
construitFissureGenerale_c.py
construitMaillagePipe_a.py
construitMaillagePipe_b.py
construitMaillagePipe_c.py
construitMaillagePipe_d.py
construitMaillagePipe.py
construitPartitionsPeauFissure.py
creePointsPipePeau.py
@ -48,12 +55,14 @@ SET(plugin_SCRIPTS
enleveDefaut.py
extractionOrienteeMulti.py
extractionOrientee.py
extractionOrientee_a.py
facesCirculaires.py
facesFissure.py
facesToreInBloc.py
facesVolumesToriques.py
findWireEndVertices.py
findWireIntermediateVertices.py
findWireVertices.py
fissError.py
fissureCoude.py
fissureGenerique.py
@ -64,7 +73,14 @@ SET(plugin_SCRIPTS
getCentreFondFiss.py
getStatsMaillageFissure.py
getSubshapeIds.py
identifieEdgesPeau_a.py
identifieEdgesPeau_b.py
identifieEdgesPeau_c.py
identifieEdgesPeau.py
identifieElementsDebouchants_a.py
identifieElementsDebouchants_b.py
identifieElementsDebouchants_c.py
identifieElementsDebouchants_d.py
identifieElementsDebouchants.py
identifieElementsFissure.py
identifieElementsGeometriquesPeau.py
@ -74,11 +90,14 @@ SET(plugin_SCRIPTS
initLog.py
insereFissureElliptique.py
insereFissureGenerale.py
insereFissureLongue.py
insereFissureLongue_a.py
insereFissureLongue_b.py
insereFissureLongue_c.py
insereFissureLongue_d.py
insereFissureLongue_e.py
insereFissureLongue_f.py
insereFissureLongue_g.py
insereFissureLongue.py
listOfExtraFunctions.py
mailleAretesEtJonction.py
mailleFacesFissure.py

View File

@ -20,13 +20,13 @@
"""Construit les arêtes débouchantes"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
#from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
from .sortEdges import sortEdges
from . import initLog
from .construitEdgesRadialesDebouchantes_a import construitEdgesRadialesDebouchantes_a
from .construitEdgesRadialesDebouchantes_b import construitEdgesRadialesDebouchantes_b
from .construitEdgesRadialesDebouchantes_c import construitEdgesRadialesDebouchantes_c
def construitEdgesRadialesDebouchantes(idisklim, idiskout, gptsdisks, raydisks,
facesPipePeau, edgeRadFacePipePeau, nbsegCercle):
@ -35,112 +35,13 @@ def construitEdgesRadialesDebouchantes(idisklim, idiskout, gptsdisks, raydisks,
# --- listes de nappes radiales en filling à chaque extrémité débouchante
facesDebouchantes = [False, False]
idFacesDebouchantes = [-1, -1] # contiendra les indices des faces disque débouchantes (facesPipePeau)
listNappes =[]
for i, idisk in enumerate(idisklim):
numout = idiskout[i]
logging.debug("extremité %s, indices disques interne %s, externe %s",i, idisk, numout)
nappes = []
if (idisk != 0) and (idisk != len(gptsdisks)-1): # si extrémité débouchante
for k in range(nbsegCercle):
if i == 0:
iddeb = max(0, numout)
idfin = max(iddeb+3,idisk+1) # il faut 3 rayons pour faire un filling qui suive le fond de fissure
#logging.debug("extremité %s, indices retenus interne %s, externe %s",i, idfin, iddeb)
comp = geompy.MakeCompound(raydisks[k][iddeb:idfin])
name='compoundRay%d'%k
geomPublish(initLog.debug, comp, name)
else:
idfin = min(len(gptsdisks), numout+1)
iddeb = min(idfin-3, idisk) # il faut 3 rayons pour faire un filling qui suive le fond de fissure
#logging.debug("extremité %s, indices retenus interne %s, externe %s",i, idfin, iddeb)
comp = geompy.MakeCompound(raydisks[k][iddeb:idfin])
name='compoundRay%d'%k
geomPublish(initLog.debug, comp, name)
nappe = geompy.MakeFilling(comp, 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default)
nappes.append(nappe)
name='nappe%d'%k
geomPublish(initLog.debug, nappe, name)
facesDebouchantes[i] = True
listNappes.append(nappes)
facesDebouchantes, listNappes = construitEdgesRadialesDebouchantes_a(idisklim, idiskout, gptsdisks, raydisks, nbsegCercle)
# --- mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau)
for i, nappes in enumerate(listNappes):
if facesDebouchantes[i]:
for k, face in enumerate(facesPipePeau):
#logging.debug('i, k, face, nappes[0] %s %s %s %s', i, k, face, nappes[0])
#geomPublish(initLog.debug, nappes[0], 'lanappe')
#geomPublish(initLog.debug, face, 'laface')
edge = geompy.MakeSection(face, nappes[0])
if geompy.NbShapes(edge, geompy.ShapeType["EDGE"]) > 0:
idFacesDebouchantes[i] = k
break
logging.debug("idFacesDebouchantes: %s", idFacesDebouchantes)
idFacesDebouchantes = construitEdgesRadialesDebouchantes_b(facesPipePeau, facesDebouchantes, listNappes)
# --- construction des listes d'edges radiales sur chaque extrémité débouchante
listEdges = []
for i, nappes in enumerate(listNappes):
ifd = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau)
if ifd < 0:
listEdges.append([])
else:
face = facesPipePeau[ifd]
edges = [edgeRadFacePipePeau[ifd]]
for k, nappe in enumerate(nappes):
if k > 0:
obj = geompy.MakeSection(face, nappes[k]) # normalement une edge, parfois un compound d'edges dont un tout petit
edge = obj
vs = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
if len(vs) > 2:
eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
[edsorted, _, maxl] = sortEdges(eds)
edge = edsorted[-1]
else:
maxl = geompy.BasicProperties(edge)[0]
if maxl < 0.01: # problème MakeSection
logging.info("problème MakeSection recherche edge radiale %s, longueur trop faible: %s, utilisation partition", k, maxl)
partNappeFace = geompy.MakePartition([face, nappes[k]], [] , [], [], geompy.ShapeType["FACE"], 0, [], 0)
edps= geompy.ExtractShapes(partNappeFace, geompy.ShapeType["EDGE"], False)
ednouv = []
for ii, ed in enumerate(edps):
dmax=100.
vxs = geompy.ExtractShapes(ed, geompy.ShapeType["VERTEX"], False)
distx = [geompy.MinDistance(vx, face) for vx in vxs]
distx += [geompy.MinDistance(vx, nappes[k]) for vx in vxs]
dmax = max(distx)
lgedge = geompy.BasicProperties(ed)[0]
logging.debug(" dmax %s, longueur edge %s",dmax, lgedge)
if dmax < 0.01 and lgedge > 0.01:
ednouv.append(ed)
if (len(ednouv) > 0):
logging.debug(" edges issues de la partition: %s", ednouv)
for ii, ed in enumerate(ednouv):
geomPublish(initLog.debug, ed, "ednouv%d"%ii)
[edsorted, _, maxl] = sortEdges(ednouv)
logging.debug(" longueur edge trouvée: %s", maxl)
edge = edsorted[-1]
else:
logging.info("problème partition recherche edge radiale %s", k)
vxs = geompy.ExtractShapes(partNappeFace, geompy.ShapeType["VERTEX"], False)
vxnouv=[]
for ii,vx in enumerate(vxs):
distx = geompy.MinDistance(vx, face)
distx += geompy.MinDistance(vx, nappes[k])
logging.debug("vertex distance: %s", distx)
if distx < 0.005:
vxnouv.append(vx)
logging.debug("nombre vertex candidats %s", len(vxnouv))
if len(vxnouv) >= 2:
eds = [geompy.MakeEdge(vxnouv[j],vxnouv[(j+1)%len(vxnouv)]) for j in range(len(vxnouv))]
[edsorted2, _, maxl] = sortEdges(eds)
edge = edsorted2[-1]
logging.debug("lg edge: %s", maxl)
else:
logging.debug("problème recherche edge radiale %s non résolu", k)
edges.append(edge)
name = 'edgeEndPipe%d'%k
geomPublish(initLog.debug, edge, name)
listEdges.append(edges)
listEdges = construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
listNappes, idFacesDebouchantes)
return (listEdges, idFacesDebouchantes)

View File

@ -0,0 +1,62 @@
# -*- 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
#
"""listes de nappes radiales en filling à chaque extrémité débouchante"""
import logging
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from . import initLog
def construitEdgesRadialesDebouchantes_a(idisklim, idiskout, gptsdisks, raydisks, nbsegCercle):
"""listes de nappes radiales en filling à chaque extrémité débouchante"""
logging.info('start')
facesDebouchantes = [False, False]
listNappes = list()
for n_extr, idisk in enumerate(idisklim):
numout = idiskout[n_extr]
logging.debug("extremité %s, indices disques interne %s, externe %s",n_extr, idisk, numout)
nappes = list()
if (idisk != 0) and (idisk != len(gptsdisks)-1): # si extrémité débouchante
for n_ray in range(nbsegCercle):
if n_extr == 0:
iddeb = max(0, numout)
idfin = max(iddeb+3,idisk+1) # il faut 3 rayons pour faire un filling qui suive le fond de fissure
#logging.debug("extremité %s, indices retenus interne %s, externe %s",n_extr, idfin, iddeb)
comp = geompy.MakeCompound(raydisks[n_ray][iddeb:idfin])
name='compoundRay%d'%n_ray
geomPublish(initLog.debug, comp, name)
else:
idfin = min(len(gptsdisks), numout+1)
iddeb = min(idfin-3, idisk) # il faut 3 rayons pour faire un filling qui suive le fond de fissure
#logging.debug("extremité %s, indices retenus interne %s, externe %s",n_extr, idfin, iddeb)
comp = geompy.MakeCompound(raydisks[n_ray][iddeb:idfin])
name='compoundRay%d'%n_ray
geomPublish(initLog.debug, comp, name)
nappe = geompy.MakeFilling(comp, 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default)
nappes.append(nappe)
name='nappe%d'%n_ray
geomPublish(initLog.debug, nappe, name)
facesDebouchantes[n_extr] = True
listNappes.append(nappes)
return facesDebouchantes, listNappes

View File

@ -0,0 +1,45 @@
# -*- 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
#
"""Mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau)"""
import logging
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from . import initLog
def construitEdgesRadialesDebouchantes_b(facesPipePeau, facesDebouchantes, listNappes):
"""Mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau)"""
idFacesDebouchantes = [-1, -1] # contiendra les indices des faces disque débouchantes (facesPipePeau)
for n_nappe, nappes in enumerate(listNappes):
if facesDebouchantes[n_nappe]:
for n_face, face in enumerate(facesPipePeau):
#logging.debug('n_nappe, n_face, face, nappes[0] %s %s %s %s', n_nappe, n_face, face, nappes[0])
#geomPublish(initLog.debug, nappes[0], 'lanappe')
#geomPublish(initLog.debug, face, 'laface')
edge = geompy.MakeSection(face, nappes[0])
if geompy.NbShapes(edge, geompy.ShapeType["EDGE"]) > 0:
idFacesDebouchantes[n_nappe] = n_face
break
logging.debug("idFacesDebouchantes: %s", idFacesDebouchantes)
return idFacesDebouchantes

View File

@ -0,0 +1,101 @@
# -*- 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
#
"""Construction des listes d'edges radiales sur chaque extrémité débouchante"""
import logging
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from . import initLog
from .sortEdges import sortEdges
def construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
listNappes, idFacesDebouchantes):
"""Construction des listes d'edges radiales sur chaque extrémité débouchante"""
logging.info('start')
listEdges = list()
for n_nappe, nappes in enumerate(listNappes):
ifd = idFacesDebouchantes[n_nappe] # indice de face débouchante (facesPipePeau)
if ifd < 0:
listEdges.append([])
else:
face = facesPipePeau[ifd]
edges = [edgeRadFacePipePeau[ifd]]
for n_nappe, nappe in enumerate(nappes):
if n_nappe > 0:
obj = geompy.MakeSection(face, nappe) # normalement une edge, parfois un compound d'edges dont un tout petit
edge = obj
l_shapes = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
if len(l_shapes) > 2:
eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
[edsorted, _, maxl] = sortEdges(eds)
edge = edsorted[-1]
else:
maxl = geompy.BasicProperties(edge)[0]
if maxl < 0.01: # problème MakeSection
logging.info("problème MakeSection recherche edge radiale %s, longueur trop faible: %s, utilisation partition", n_nappe, maxl)
partNappeFace = geompy.MakePartition([face, nappe], [] , [], [], geompy.ShapeType["FACE"], 0, [], 0)
l_shapes= geompy.ExtractShapes(partNappeFace, geompy.ShapeType["EDGE"], False)
l_nouv_edges = list()
for shape in l_shapes:
dmax=100.
l_vertex = geompy.ExtractShapes(shape, geompy.ShapeType["VERTEX"], False)
distx = [geompy.MinDistance(vertex, face) for vertex in l_vertex]
distx += [geompy.MinDistance(vertex, nappe) for vertex in l_vertex]
dmax = max(distx)
lgedge = geompy.BasicProperties(shape)[0]
logging.debug(" dmax %s, longueur edge %s",dmax, lgedge)
if dmax < 0.01 and lgedge > 0.01:
l_nouv_edges.append(shape)
if l_nouv_edges:
logging.debug(" edges issues de la partition: %s", l_nouv_edges)
for num, edge in enumerate(l_nouv_edges):
geomPublish(initLog.debug, edge, "l_nouv_edges%d"%num)
[edsorted, _, maxl] = sortEdges(l_nouv_edges)
logging.debug(" longueur edge trouvée: %s", maxl)
edge = edsorted[-1]
else:
logging.info("problème partition recherche edge radiale %s", n_nappe)
l_vertex = geompy.ExtractShapes(partNappeFace, geompy.ShapeType["VERTEX"], False)
l_vertexnouv= list()
for vertex in l_vertex:
distx = geompy.MinDistance(vertex, face)
distx += geompy.MinDistance(vertex, nappe)
logging.debug("vertex distance: %s", distx)
if distx < 0.005:
l_vertexnouv.append(vertex)
logging.debug("nombre vertex candidats %s", len(l_vertexnouv))
if len(l_vertexnouv) >= 2:
l_edges = [geompy.MakeEdge(l_vertexnouv[j],l_vertexnouv[(j+1)%len(l_vertexnouv)]) for j in range(len(l_vertexnouv))]
[edsorted2, _, maxl] = sortEdges(l_edges)
edge = edsorted2[-1]
logging.debug("lg edge: %s", maxl)
else:
logging.debug("problème recherche edge radiale %s non résolu", n_nappe)
edges.append(edge)
name = 'edgeEndPipe%d'%n_nappe
geomPublish(initLog.debug, edge, name)
listEdges.append(edges)
return listEdges

View File

@ -21,10 +21,15 @@
import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
import SMESH
from .geomsmesh import smesh
from .construitMaillagePipe_a import construitMaillagePipe_a
from .construitMaillagePipe_b import construitMaillagePipe_b
from .construitMaillagePipe_c import construitMaillagePipe_c
from .construitMaillagePipe_d import construitMaillagePipe_d
def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
"""maillage effectif du pipe"""
logging.info('start')
@ -38,139 +43,56 @@ def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
faceCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe0")
faceCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe1")
mptdsk = list() # vertices de chaque disque au fur et à mesure
mptsdisks = list() # vertices maillage de tous les disques
mEdges = list() # identifiants edges maillage fond de fissure
mEdgeFaces = list() # identifiants edges maillage edge face de fissure externe
mFaces = list() # identifiants faces maillage fissure
mVols = list() # identifiants volumes maillage pipe
mptdsk = list()
for idisk in range(idisklim[0], idisklim[1]+1): # boucle sur les disques internes
#print ("\nidisk = {}".format(idisk))
# -----------------------------------------------------------------------
# --- points
# --- Les points
gptdsk = gptsdisks[idisk]
if idisk > idisklim[0]:
oldmpts = mptdsk
mptdsk = list() # vertices maillage d'un disque
for k in range(nbsegCercle):
points = gptdsk[k]
mptids = list()
for j, pt in enumerate(points):
if j == 0 and k > 0:
id = mptdsk[0][0]
else:
coords = geompy.PointCoordinates(pt)
id = meshPipe.AddNode(coords[0], coords[1], coords[2])
mptids.append(id)
mptdsk.append(mptids)
mptsdisks.append(mptdsk)
oldmpts = mptdsk
mptdsk = construitMaillagePipe_a(idisk, \
gptsdisks, idisklim, nbsegCercle, \
meshPipe, mptsdisks)
# -----------------------------------------------------------------------
# --- groupes edges cercles debouchants
# --- Les groupes des edges des cercles débouchants
if idisk == idisklim[0]:
pts = list()
for k in range(nbsegCercle):
pts.append(mptdsk[k][-1])
edges = list()
nb_pts = len(pts)
for k in range(nb_pts):
k1 = (k+1)%nb_pts
idEdge = meshPipe.AddEdge([pts[k], pts[k1]])
edges.append(idEdge)
edgeCircPipe0Group.Add(edges)
if idisk == idisklim[1]:
pts = list()
for k in range(nbsegCercle):
pts.append(mptdsk[k][-1])
edges = list()
nb_pts = len(pts)
for k in range(nb_pts):
k1 = (k+1)%nb_pts
idEdge = meshPipe.AddEdge([pts[k], pts[k1]])
edges.append(idEdge)
edgeCircPipe1Group.Add(edges)
if idisk in (idisklim[0],idisklim[1]):
construitMaillagePipe_b(idisk, \
idisklim, nbsegCercle, \
meshPipe, mptdsk, \
edgeCircPipe0Group, edgeCircPipe1Group)
# -----------------------------------------------------------------------
# --- groupes faces debouchantes
# --- Les groupes des faces débouchantes
if idisk == idisklim[0]:
faces = list()
for j in range(nbsegRad):
for k in range(nbsegCercle):
k1 = k+1
if k == nbsegCercle-1:
k1 = 0
if j == 0:
idf = meshPipe.AddFace([mptdsk[k][0], mptdsk[k][1], mptdsk[k1][1]]) # triangle
else:
idf = meshPipe.AddFace([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j]]) # quadrangle
faces.append(idf)
faceCircPipe0Group.Add(faces)
if idisk == idisklim[1]:
faces = list()
for j in range(nbsegRad):
for k in range(nbsegCercle):
k1 = k+1
if k == nbsegCercle-1:
k1 = 0
if j == 0:
idf = meshPipe.AddFace([mptdsk[k][0], mptdsk[k][1], mptdsk[k1][1]]) # triangle
else:
idf = meshPipe.AddFace([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j]]) # quadrangle
faces.append(idf)
faceCircPipe1Group.Add(faces)
if idisk in (idisklim[0],idisklim[1]):
construitMaillagePipe_c(idisk, \
idisklim, nbsegCercle, \
meshPipe, mptdsk, nbsegRad, \
faceCircPipe0Group, faceCircPipe1Group)
# -----------------------------------------------------------------------
# --- mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure
if idisk == idisklim[0]:
mEdges.append(0)
mEdgeFaces.append(0)
mFaces.append([0])
mVols.append([[0]])
nodesFondFissGroup.Add([mptdsk[0][0]])
else:
ide = meshPipe.AddEdge([oldmpts[0][0], mptdsk[0][0]])
mEdges.append(ide)
fondFissGroup.Add([ide])
nodesFondFissGroup.Add([mptdsk[0][0]])
ide2 = meshPipe.AddEdge([oldmpts[0][-1], mptdsk[0][-1]])
mEdgeFaces.append(ide2)
edgeFaceFissGroup.Add([ide2])
idFaces = list()
idVols = list()
for j in range(nbsegRad):
idf = meshPipe.AddFace([oldmpts[0][j], mptdsk[0][j], mptdsk[0][j+1], oldmpts[0][j+1]])
faceFissGroup.Add([idf])
idFaces.append(idf)
idVolCercle = list()
for k in range(nbsegCercle):
k1 = k+1
if k == nbsegCercle-1:
k1 = 0
if j == 0:
idv = meshPipe.AddVolume([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], \
oldmpts[k][j], oldmpts[k][j+1], oldmpts[k1][j+1]])
else:
idv = meshPipe.AddVolume([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j], \
oldmpts[k][j], oldmpts[k][j+1], oldmpts[k1][j+1], oldmpts[k1][j]])
idVolCercle.append(idv)
idVols.append(idVolCercle)
mFaces.append(idFaces)
mVols.append(idVols)
construitMaillagePipe_d(idisk, \
idisklim, nbsegCercle, nbsegRad, \
meshPipe, mptdsk, oldmpts, \
fondFissGroup, edgeFaceFissGroup, faceFissGroup, \
mEdges, mEdgeFaces, mFaces, mVols, nodesFondFissGroup)
# Bilan
pipeFissGroup = meshPipe.CreateEmptyGroup( SMESH.VOLUME, 'PIPEFISS' )
nbAdd = pipeFissGroup.AddFrom( meshPipe.GetMesh() )
_ = pipeFissGroup.AddFrom( meshPipe.GetMesh() )
nb, new_mesh, new_group = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries")
_, _, _ = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries")
edgesCircPipeGroup = [edgeCircPipe0Group, edgeCircPipe1Group]
meshPipeGroups = dict(fondFissGroup = fondFissGroup, \
@ -189,4 +111,5 @@ def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
#text = "Arrêt rapide.\n"
#logging.info(text)
#raise Exception(text)
return (meshPipe, meshPipeGroups, edgesCircPipeGroup)

View File

@ -0,0 +1,50 @@
# -*- 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
#
"""Les points"""
import logging
from .geomsmesh import geompy
def construitMaillagePipe_a(idisk, \
gptsdisks, idisklim, nbsegCercle, \
meshPipe, mptsdisks):
"""Les points"""
#logging.info('start')
gptdsk = gptsdisks[idisk]
mptdsk = list() # vertices maillage d'un disque
for n_seg in range(nbsegCercle):
points = gptdsk[n_seg]
mptids = list()
for n_point, point in enumerate(points):
if n_point == 0 and n_seg > 0:
n_noeud = mptdsk[0][0]
else:
coords = geompy.PointCoordinates(point)
n_noeud = meshPipe.AddNode(coords[0], coords[1], coords[2])
mptids.append(n_noeud)
mptdsk.append(mptids)
mptsdisks.append(mptdsk)
return mptdsk

View File

@ -0,0 +1,46 @@
# -*- 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
#
"""Les groupes des edges des cercles débouchants"""
import logging
def construitMaillagePipe_b(idisk, \
idisklim, nbsegCercle, \
meshPipe, mptdsk, \
edgeCircPipe0Group, edgeCircPipe1Group):
"""Les groupes des edges des cercles débouchants"""
#logging.info('start')
pts = list()
for n_cercle in range(nbsegCercle):
pts.append(mptdsk[n_cercle][-1])
edges = list()
nb_pts = len(pts)
for n_cercle in range(nb_pts):
n_cercle_1 = (n_cercle+1)%nb_pts
id_edge = meshPipe.AddEdge([pts[n_cercle], pts[n_cercle_1]])
edges.append(id_edge)
if idisk == idisklim[0]:
edgeCircPipe0Group.Add(edges)
else:
edgeCircPipe1Group.Add(edges)
return

View File

@ -0,0 +1,48 @@
# -*- 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
#
"""Les groupes des faces débouchantes"""
import logging
def construitMaillagePipe_c(idisk, \
idisklim, nbsegCercle, \
meshPipe, mptdsk, nbsegRad, \
faceCircPipe0Group, faceCircPipe1Group):
"""Les groupes des faces débouchantes"""
#logging.info('start')
faces = list()
for n_seg in range(nbsegRad):
for n_cercle in range(nbsegCercle):
n_cercle_1 = n_cercle+1
if n_cercle == nbsegCercle-1:
n_cercle_1 = 0
if n_seg == 0:
id_face = meshPipe.AddFace([mptdsk[n_cercle][0], mptdsk[n_cercle][1], mptdsk[n_cercle_1][1]]) # triangle
else:
id_face = meshPipe.AddFace([mptdsk[n_cercle][n_seg], mptdsk[n_cercle][n_seg+1], mptdsk[n_cercle_1][n_seg+1], mptdsk[n_cercle_1][n_seg]]) # quadrangle
faces.append(id_face)
if idisk == idisklim[0]:
faceCircPipe0Group.Add(faces)
else:
faceCircPipe1Group.Add(faces)
return

View File

@ -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
#
"""Mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure"""
import logging
import SMESH
def construitMaillagePipe_d(idisk, \
idisklim, nbsegCercle, nbsegRad, \
meshPipe, mptdsk, oldmpts, \
fondFissGroup, edgeFaceFissGroup, faceFissGroup, \
mEdges, mEdgeFaces, mFaces, mVols, nodesFondFissGroup):
"""Mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure"""
#logging.info('start')
if idisk == idisklim[0]:
mEdges.append(0)
mEdgeFaces.append(0)
mFaces.append([0])
mVols.append([[0]])
nodesFondFissGroup.Add([mptdsk[0][0]])
else:
ide = meshPipe.AddEdge([oldmpts[0][0], mptdsk[0][0]])
mEdges.append(ide)
fondFissGroup.Add([ide])
nodesFondFissGroup.Add([mptdsk[0][0]])
ide2 = meshPipe.AddEdge([oldmpts[0][-1], mptdsk[0][-1]])
mEdgeFaces.append(ide2)
edgeFaceFissGroup.Add([ide2])
id_faces = list()
id_volumes = list()
for n_srad in range(nbsegRad):
idf = meshPipe.AddFace([oldmpts[0][n_srad], mptdsk[0][n_srad], mptdsk[0][n_srad+1], oldmpts[0][n_srad+1]])
faceFissGroup.Add([idf])
id_faces.append(idf)
id_vol_cercle = list()
for n_cercle in range(nbsegCercle):
n_cercle_1 = n_cercle+1
if n_cercle == nbsegCercle-1:
n_cercle_1 = 0
if n_srad == 0:
idv = meshPipe.AddVolume([mptdsk[n_cercle][n_srad], mptdsk[n_cercle][n_srad+1], mptdsk[n_cercle_1][n_srad+1], \
oldmpts[n_cercle][n_srad], oldmpts[n_cercle][n_srad+1], oldmpts[n_cercle_1][n_srad+1]])
else:
idv = meshPipe.AddVolume([mptdsk[n_cercle][n_srad], mptdsk[n_cercle][n_srad+1], mptdsk[n_cercle_1][n_srad+1], mptdsk[n_cercle_1][n_srad], \
oldmpts[n_cercle][n_srad], oldmpts[n_cercle][n_srad+1], oldmpts[n_cercle_1][n_srad+1], oldmpts[n_cercle_1][n_srad]])
id_vol_cercle.append(idv)
id_volumes.append(id_vol_cercle)
mFaces.append(id_faces)
mVols.append(id_volumes)
return

View File

@ -17,161 +17,41 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification précise des edges et disques des faces de peau selon index extremité fissure"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .identifieEdgesPeau_a import identifieEdgesPeau_a
from .identifieEdgesPeau_b import identifieEdgesPeau_b
from .identifieEdgesPeau_c import identifieEdgesPeau_c
from .substractSubShapes import substractSubShapes
def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSorted,
def identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, \
edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees):
"""
identification précise des edges et disques des faces de peau selon index extremité fissure
"""
"""Identification précise des edges et disques des faces de peau selon index extremité fissure"""
logging.info('start')
facesPipePeau = [None for i in range(len(edgesFissExtPipe))]
endsEdgeFond = [None for i in range(len(edgesFissExtPipe))]
edgeRadFacePipePeau = [None for i in range(len(edgesFissExtPipe))]
facesPipePeau = [None for _ in range(len(edgesFissExtPipe))]
endsEdgeFond = [None for _ in range(len(edgesFissExtPipe))]
edgeRadFacePipePeau = [None for _ in range(len(edgesFissExtPipe))]
edgesListees = []
edgesCircPeau = []
verticesCircPeau = []
edgesListees = list()
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
for face in facesPeauSorted[:-1]: # la ou les faces débouchantes, pas la grande face de peau
logging.debug("examen face debouchante circulaire")
for i,efep in enumerate(edgesFissExtPipe):
dist = geompy.MinDistance(face, efep)
logging.debug(" distance face circulaire edge %s", dist)
if dist < 1e-3:
for ik, edpfi in enumerate(edgesPeauFondIn):
if geompy.MinDistance(face, edpfi) < 1e-3:
break
sharedVertices = geompy.GetSharedShapesMulti([face, edgesPeauFondIn[ik]], geompy.ShapeType["VERTEX"])
nameFace = "facePipePeau%d"%i
nameVert = "endEdgeFond%d"%i
nameEdge = "edgeRadFacePipePeau%d"%i
facesPipePeau[i] = face
endsEdgeFond[i] = sharedVertices[0]
geomPublish(initLog.debug, face, nameFace)
geomPublish(initLog.debug, sharedVertices[0], nameVert)
edgesFace = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
for edge in edgesFace:
if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3:
edgeRadFacePipePeau[i] = edge
geomPublish(initLog.debug, edge, nameEdge)
break
pass
pass
pass
pass
edgesCircPeau, verticesCircPeau = identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauFondIn, \
endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesListees)
else:
edgesCircPeau = list()
verticesCircPeau = list()
# --- edges circulaires de la face de peau et points de jonction de la face externe de fissure
logging.debug("facesPipePeau: %s", facesPipePeau)
edgesCircPeau = [None for i in range(len(facesPipePeau))]
verticesCircPeau = [None for i in range(len(facesPipePeau))]
for i,fcirc in enumerate(facesPipePeau):
edges = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["EDGE"])
grpEdgesCirc = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(grpEdgesCirc, edges)
edgesCircPeau[i] = grpEdgesCirc
name = "edgeCirc%d"%i
geomPublishInFather(initLog.debug, facePeau, grpEdgesCirc, name)
edgesListees = edgesListees + edges
vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"])
grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"])
geompy.UnionList(grpVertCircPeau, vertices)
verticesCircPeau[i] = grpVertCircPeau
name = "pointEdgeCirc%d"%i
geomPublishInFather(initLog.debug, facePeau, grpVertCircPeau, name)
pass
pass # --- au moins une extrémité du pipe sur cette face de peau
# --- edges de bord de la face de peau
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
edgesBords = []
for i, edge in enumerate(edgesFilling):
edgepeau = geompy.GetInPlace(facePeau, edge)
name = "edgepeau%d"%i
geomPublishInFather(initLog.debug, facePeau,edgepeau, name)
logging.debug("edgepeau %s", geompy.ShapeInfo(edgepeau))
if geompy.ShapeInfo(edgepeau)['EDGE'] > 1:
logging.debug(" EDGES multiples")
edgs = geompy.ExtractShapes(edgepeau, geompy.ShapeType["EDGE"], False)
edgesBords += edgs
edgesListees += edgs
else:
logging.debug(" EDGE")
edgesBords.append(edgepeau)
edgesListees.append(edgepeau)
groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesBords)
bordsVifs = None
if aretesVivesC is not None:
logging.debug("identification des bords vifs par GetInPlace")
bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC)
if bordsVifs is None:
logging.debug("pas d'identification des bords vifs par GetInPlace: test par distance")
edvifs = []
arvives = geompy.ExtractShapes(aretesVivesC, geompy.ShapeType["EDGE"], False)
edgs = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
for ed in edgs:
vxs = geompy.ExtractShapes(ed, geompy.ShapeType["VERTEX"], False)
for ar in arvives:
d = geompy.MinDistance(vxs[0], ar)
d += geompy.MinDistance(vxs[1], ar)
logging.debug("test distance bord face peau - arete vive: %s",d)
if d < 0.001:
edvifs.append(ed)
break
if len(edvifs) >0:
bordsVifs = geompy.CreateGroup(facePeau,geompy.ShapeType["EDGE"])
for ed in edvifs:
geompy.AddObject(bordsVifs, geompy.GetSubShapeID(facePeau, ed))
if bordsVifs is not None:
geomPublishInFather(initLog.debug, facePeau, bordsVifs, "bordsVifs")
groupEdgesBordPeau = geompy.CutGroups(groupEdgesBordPeau, bordsVifs)
grptmp = None
if len(aretesVivesCoupees) > 0:
grpC = geompy.MakeCompound(aretesVivesCoupees)
grptmp = geompy.GetInPlace(facePeau, grpC)
if grptmp is not None:
grpnew = geompy.CutGroups(bordsVifs, grptmp) # ce qui est nouveau dans bordsVifs
else:
grpnew = bordsVifs
if grpnew is not None:
edv = geompy.ExtractShapes(grpnew, geompy.ShapeType["EDGE"], False)
aretesVivesCoupees += edv
logging.debug("aretesVivesCoupees %s",aretesVivesCoupees)
geomPublishInFather(initLog.debug, facePeau, groupEdgesBordPeau , "EdgesBords")
groupEdgesBordPeau, bordsVifs = identifieEdgesPeau_b(facePeau, edgesListees, \
fillingFaceExterne, aretesVivesC, aretesVivesCoupees)
# --- edges de la face de peau partagées avec la face de fissure
edgesPeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
edges = substractSubShapes(facePeau, edgesPeau, edgesListees)
edgesFissurePeau = []
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
edgesFissurePeau = [None for i in range(len(verticesCircPeau))] # edges associés aux extrémités du pipe, en premier
for edge in edges:
for i, grpVert in enumerate(verticesCircPeau):
if (geompy.MinDistance(grpVert, edge) < 1.e-3) and (edge not in edgesFissurePeau):
edgesFissurePeau[i] = edge
name = "edgeFissurePeau%d"%i
geomPublishInFather(initLog.debug, facePeau, edge, name)
for edge in edges: # on ajoute après les edges manquantes
if edge not in edgesFissurePeau:
edgesFissurePeau.append(edge)
else:
for i, edge in enumerate(edges):
edgesFissurePeau.append(edge)
name = "edgeFissurePeau%d"%i
geomPublishInFather(initLog.debug, facePeau, edge, name)
edgesFissurePeau = identifieEdgesPeau_c(verticesPipePeau, facePeau, edgesListees, verticesCircPeau)
return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau,
edgesCircPeau, verticesCircPeau, groupEdgesBordPeau,

View File

@ -0,0 +1,79 @@
# -*- 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
#
"""Identification précise des edges et disques des faces de peau selon index extremité fissure"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
def identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauFondIn, \
endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesListees):
"""Identification précise des edges et disques des faces de peau selon index extremité fissure"""
logging.info('start')
for face in facesPeauSorted[:-1]: # la ou les faces débouchantes, pas la grande face de peau
logging.debug("examen face debouchante circulaire")
for i_aux,efep in enumerate(edgesFissExtPipe):
dist = geompy.MinDistance(face, efep)
logging.debug(" distance face circulaire edge %s", dist)
if dist < 1e-3:
for j_aux, edpfi in enumerate(edgesPeauFondIn):
if geompy.MinDistance(face, edpfi) < 1e-3:
j_aux_0 = j_aux
break
sharedVertices = geompy.GetSharedShapesMulti([face, edgesPeauFondIn[j_aux_0]], geompy.ShapeType["VERTEX"])
nameFace = "facePipePeau{}".format(i_aux)
nameVert = "endEdgeFond{}".format(i_aux)
nameEdge = "edgeRadFacePipePeau{}".format(i_aux)
facesPipePeau[i_aux] = face
endsEdgeFond[i_aux] = sharedVertices[0]
geomPublish(initLog.debug, face, nameFace)
geomPublish(initLog.debug, sharedVertices[0], nameVert)
edgesFace = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
for edge in edgesFace:
if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3:
edgeRadFacePipePeau[i_aux] = edge
geomPublish(initLog.debug, edge, nameEdge)
break
# --- edges circulaires de la face de peau et points de jonction de la face externe de fissure
logging.debug("facesPipePeau: %s", facesPipePeau)
edgesCircPeau = [None for _ in range(len(facesPipePeau))]
verticesCircPeau = [None for _ in range(len(facesPipePeau))]
for i_aux,fcirc in enumerate(facesPipePeau):
edges = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["EDGE"])
grpEdgesCirc = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(grpEdgesCirc, edges)
edgesCircPeau[i_aux] = grpEdgesCirc
name = "edgeCirc{}".format(i_aux)
geomPublishInFather(initLog.debug, facePeau, grpEdgesCirc, name)
edgesListees = edgesListees + edges
vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"])
grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"])
geompy.UnionList(grpVertCircPeau, vertices)
verticesCircPeau[i_aux] = grpVertCircPeau
name = "pointEdgeCirc{}".format(i_aux)
geomPublishInFather(initLog.debug, facePeau, grpVertCircPeau, name)
return edgesCircPeau, verticesCircPeau

View File

@ -0,0 +1,94 @@
# -*- 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
#
"""edges de bord de la face de peau"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def identifieEdgesPeau_b(facePeau, edgesListees, \
fillingFaceExterne, aretesVivesC, aretesVivesCoupees):
"""edges de bord de la face de peau"""
logging.info('start')
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
edgesBords = list()
for i, edge in enumerate(edgesFilling):
edgepeau = geompy.GetInPlace(facePeau, edge)
name = "edgepeau%d"%i
geomPublishInFather(initLog.debug, facePeau,edgepeau, name)
logging.debug("edgepeau %s", geompy.ShapeInfo(edgepeau))
if geompy.ShapeInfo(edgepeau)['EDGE'] > 1:
logging.debug(" EDGES multiples")
l_edges = geompy.ExtractShapes(edgepeau, geompy.ShapeType["EDGE"], False)
edgesBords += l_edges
edgesListees += l_edges
else:
logging.debug(" EDGE")
edgesBords.append(edgepeau)
edgesListees.append(edgepeau)
groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesBords)
bordsVifs = None
if aretesVivesC is not None:
logging.debug("identification des bords vifs par GetInPlace")
bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC)
if bordsVifs is None:
logging.debug("pas d'identification des bords vifs par GetInPlace: test par distance")
edvifs = list()
arvives = geompy.ExtractShapes(aretesVivesC, geompy.ShapeType["EDGE"], False)
l_edges = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
for edge in l_edges:
vxs = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
for arete in arvives:
dist = geompy.MinDistance(vxs[0], arete)
dist += geompy.MinDistance(vxs[1], arete)
logging.debug("test distance bord face peau - arete vive: %s",dist)
if ( dist < 0.001 ):
edvifs.append(edge)
break
if len(edvifs) >0:
bordsVifs = geompy.CreateGroup(facePeau,geompy.ShapeType["EDGE"])
for edge in edvifs:
geompy.AddObject(bordsVifs, geompy.GetSubShapeID(facePeau, edge))
if bordsVifs is not None:
geomPublishInFather(initLog.debug, facePeau, bordsVifs, "bordsVifs")
groupEdgesBordPeau = geompy.CutGroups(groupEdgesBordPeau, bordsVifs)
grptmp = None
if len(aretesVivesCoupees) > 0:
grpc = geompy.MakeCompound(aretesVivesCoupees)
grptmp = geompy.GetInPlace(facePeau, grpc)
if grptmp is not None:
grpnew = geompy.CutGroups(bordsVifs, grptmp) # ce qui est nouveau dans bordsVifs
else:
grpnew = bordsVifs
if grpnew is not None:
edv = geompy.ExtractShapes(grpnew, geompy.ShapeType["EDGE"], False)
aretesVivesCoupees += edv
logging.debug("aretesVivesCoupees %s",aretesVivesCoupees)
geomPublishInFather(initLog.debug, facePeau, groupEdgesBordPeau , "EdgesBords")
return groupEdgesBordPeau, bordsVifs

View File

@ -0,0 +1,57 @@
# -*- 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
#
"""edges de la face de peau partagées avec la face de fissure"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .substractSubShapes import substractSubShapes
def identifieEdgesPeau_c(verticesPipePeau, facePeau, edgesListees, verticesCircPeau):
"""edges de la face de peau partagées avec la face de fissure"""
logging.info('start')
edgesPeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
edges = substractSubShapes(facePeau, edgesPeau, edgesListees)
edgesFissurePeau = list()
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
edgesFissurePeau = [None for _ in range(len(verticesCircPeau))] # edges associés aux extrémités du pipe, en premier
for edge in edges:
for i_aux, grpVert in enumerate(verticesCircPeau):
if (geompy.MinDistance(grpVert, edge) < 1.e-3) and (edge not in edgesFissurePeau):
edgesFissurePeau[i_aux] = edge
name = "edgeFissurePeau{}".format(i_aux)
geomPublishInFather(initLog.debug, facePeau, edge, name)
for edge in edges: # on ajoute après les edges manquantes
if edge not in edgesFissurePeau:
edgesFissurePeau.append(edge)
else:
for i_aux, edge in enumerate(edges):
edgesFissurePeau.append(edge)
name = "edgeFissurePeau{}".format(i_aux)
geomPublishInFather(initLog.debug, facePeau, edge, name)
return edgesFissurePeau

View File

@ -17,26 +17,21 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
import logging
import math
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import traceback
from .fissError import fissError
from .produitMixte import produitMixte
from .whichSide import whichSide
from .identifieElementsDebouchants_a import identifieElementsDebouchants_a
from .identifieElementsDebouchants_b import identifieElementsDebouchants_b
from .identifieElementsDebouchants_c import identifieElementsDebouchants_c
from .identifieElementsDebouchants_d import identifieElementsDebouchants_d
def identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
edgesFondIn, edgesFondFiss, wireFondFiss, \
aretesVivesC, fillingFaceExterne, \
edgesPipeIn, verticesPipePeau, rayonPipe, \
facesInside, facesOnside):
"""elements débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
"""Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
logging.info('start')
@ -49,127 +44,28 @@ def identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
#logging.debug("edgesFondIn %s", edgesFondIn)
for iedf, edge in enumerate(edgesFondIn):
name = "edgeFondIn%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
dist = [ geompy.MinDistance(pt, edge) for pt in verticesPipePeau]
ptPeau = verticesPipePeau[dist.index(min(dist))] # le point de verticesPipePeau a distance minimale de l'edge
[u, PointOnEdge, EdgeInWireIndex] = geompy.MakeProjectionOnWire(ptPeau, wireFondFiss)
logging.debug("u:%s, EdgeInWireIndex: %s, len(edgesFondFiss): %s", u, EdgeInWireIndex, len(edgesFondFiss))
localEdgeInFondFiss = edgesFondFiss[EdgeInWireIndex]
centre = PointOnEdge
centre2 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, u)
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre2, "centre2_%d"%iedf)
ptPeau, centre, norm, localEdgeInFondFiss, localEdgeInFondFiss, cercle = \
identifieElementsDebouchants_a(iedf, \
partitionPeauFissFond, edgesFondFiss, wireFondFiss, \
verticesPipePeau, rayonPipe, edge,)
verticesEdgesFondIn.append(centre)
name = "verticeEdgesFondIn%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, name)
norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, u)
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, "norm%d"%iedf)
cercle = geompy.MakeCircle(centre, norm, rayonPipe)
geomPublishInFather(initLog.debug, partitionPeauFissFond, cercle, "cerclorig%d"%iedf)
[vertex] = geompy.ExtractShapes(cercle, geompy.ShapeType["VERTEX"], False)
vec1 = geompy.MakeVector(centre, vertex)
vec2 = geompy.MakeVector(centre, ptPeau)
angle = geompy.GetAngleRadians(vec1, vec2)
# cas général : on reconstitue une portion de pipe, avec l'arête de couture qui coincide
# avec la face de fissure, au niveau du débouché sur la face externe
# cas dégénéré : le pipe débouche perpendiculairement à une surface plane à l'origine.
# La partition filling / pipe reconstruit échoue.
# - Si on partitionne le filling avec un simple pipe obtenu par extrusion droite du cercle,
# cela donne un point en trop sur le cercle.
# - Si on prend une vraie surface plane (pas un filling), on peut faire la partition avec
# les pipes reconstruits
logging.debug("angle=%s", angle)
#if abs(angle) > 1.e-7:
sommetAxe = geompy.MakeTranslationVector(centre, norm)
pm = produitMixte(centre, vertex, ptPeau, sommetAxe)
if pm > 0: # ajout de pi a (-)angle pour éviter des points confondus (partition échoue) dans les cas dégénérés
cercle = geompy.MakeRotation(cercle, norm, angle + math.pi)
else:
cercle = geompy.MakeRotation(cercle, norm, -angle + math.pi)
name = "cercle%d"%iedf
geomPublishInFather(initLog.debug,partitionPeauFissFond, cercle, name)
cercles.append(cercle)
# --- estimation de la longueur du pipe necessaire de part et d'autre du point de sortie
if aretesVivesC is None:
faceTestPeau = fillingFaceExterne
else:
faceTestPeau = facesDefaut[ifil]
sideCentre = whichSide(faceTestPeau, centre)
locPt0 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 0.0)
locPt1 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 1.0)
sidePt0 = whichSide(faceTestPeau, locPt0)
sidePt1 = whichSide(faceTestPeau, locPt1)
logging.debug("position centre cercle: %s, extremité edge u0: %s, u1: %s", sideCentre, sidePt0, sidePt1)
normFace = geompy.GetNormal(faceTestPeau, ptPeau)
inclPipe = abs(geompy.GetAngleRadians(norm, normFace))
lgp = max(rayonPipe/2., abs(3*rayonPipe*math.tan(inclPipe)))
logging.debug("angle inclinaison Pipe en sortie: %s degres, lgp: %s", inclPipe*180/math.pi, lgp)
loc_pt0, lgp = identifieElementsDebouchants_b(ifil, \
facesDefaut,aretesVivesC, fillingFaceExterne, rayonPipe, \
ptPeau, centre, norm, localEdgeInFondFiss)
# --- position des points extremite du pipe sur l'edge debouchante
# il faut la distance curviligne ofp du point central par rapport à une extrémité de l'edge débouchante
locEdgePart = geompy.MakePartition([localEdgeInFondFiss],[centre], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
edgesLoc = geompy.ExtractShapes(locEdgePart, geompy.ShapeType["EDGE"], False)
edgesLocSorted =[(geompy.MinDistance(edge, locPt0), kk, edge) for kk, edge in enumerate(edgesLoc)]
edgesLocSorted.sort()
try:
ofp = geompy.BasicProperties(edgesLocSorted[0][2])[0] # distance curviligne centre locPt0
except:
texte = "Identification des éléments au débouché du pipe sur la face externe impossible. "
texte += "Cause possible : la ligne de fond de fissure comprend un point géométrique coincidant avec la face externe. "
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."
raise fissError(traceback.extract_stack(),texte)
logging.debug("distance curviligne centre extremite0: %s", ofp)
p1 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp +lgp, locPt0)
p2 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp -lgp, locPt0)
geomPublishInFather(initLog.debug, wireFondFiss, p1, "p1_%d"%iedf)
geomPublishInFather(initLog.debug, wireFondFiss, p2, "p2_%d"%iedf)
identifieElementsDebouchants_c(iedf,\
partitionPeauFissFond, wireFondFiss, \
centre, localEdgeInFondFiss, cercle, loc_pt0, lgp, pipexts)
edgePart = geompy.MakePartition([localEdgeInFondFiss], [p1,p2], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
edps = geompy.ExtractShapes(edgePart, geompy.ShapeType["EDGE"], True)
for edp in edps:
if geompy.MinDistance(centre, edp) < 1.e-3:
pipext = geompy.MakePipe(cercle, edp)
name = "pipeExt%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, pipext, name)
pipexts.append(pipext)
for ifa, face in enumerate(facesInside):
logging.debug("recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)")
edgesPeauFis = list()
edgesPipeFis = list()
edgesPipeFnd = list()
try:
edgesPeauFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(facesOnside), face], geompy.ShapeType["EDGE"])
logging.debug(" faces onside %s",edgesPeauFis)
edgesPipeFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesPipeIn), face], geompy.ShapeType["EDGE"])
logging.debug(" edgesPipeIn %s", edgesPipeFis)
edgesPipeFnd = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesFondIn), face], geompy.ShapeType["EDGE"])
logging.debug(" edgesFondIn %s ", edgesPipeFnd)
except:
logging.debug(" pb edges communes %s %s %s",edgesPeauFis, edgesPipeFis, edgesPipeFnd)
pass
if (len(edgesPeauFis) > 0) and (len(edgesPipeFis) > 0) and (len(edgesPipeFnd) == 0):
dist = geompy.MinDistance(geompy.MakeCompound(edgesPeauFis), ptPeau)
logging.debug(" test distance extrémité reference %s", dist)
if dist < 1.e-3: # c'est la face de fissure externe associée
logging.debug(" face %s inside ajoutée", ifa)
facesFissExt.append(face)
name="faceFissExt%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, face, name)
dist = 1.
for ipe, edpe in enumerate(edgesPeauFis):
for ipi, edpi in enumerate(edgesPipeFis):
dist = geompy.MinDistance(edpe, edpi)
if dist < 1.e-3:
edgesFissExtPeau.append(edpe)
name="edgesFissExtPeau%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edpe, name)
edgesFissExtPipe.append(edpi)
name="edgesFissExtPipe%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edpi, name)
break
if dist < 1.e-3:
break
# --- Recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)
identifieElementsDebouchants_d(iedf,\
partitionPeauFissFond, edgesFondIn, edgesPipeIn, \
facesInside, facesOnside, \
ptPeau, facesFissExt, edgesFissExtPeau, edgesFissExtPipe)
return (verticesEdgesFondIn, pipexts, cercles, facesFissExt, edgesFissExtPeau, edgesFissExtPipe)

View File

@ -0,0 +1,79 @@
# -*- 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
#
"""Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
import logging
import math
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .produitMixte import produitMixte
def identifieElementsDebouchants_a(iedf,\
partitionPeauFissFond, edgesFondFiss, wireFondFiss, \
verticesPipePeau, rayonPipe, edge):
"""Eléments débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)"""
logging.info('start')
name = "edgeFondIn{}".format(iedf)
geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
dist = [ geompy.MinDistance(pt, edge) for pt in verticesPipePeau]
ptPeau = verticesPipePeau[dist.index(min(dist))] # le point de verticesPipePeau a distance minimale de l'edge
[parametre, PointOnEdge, EdgeInWireIndex] = geompy.MakeProjectionOnWire(ptPeau, wireFondFiss)
logging.debug("parametre:%s, EdgeInWireIndex: %s, len(edgesFondFiss): %s", parametre, EdgeInWireIndex, len(edgesFondFiss))
localEdgeInFondFiss = edgesFondFiss[EdgeInWireIndex]
centre = PointOnEdge
centre2 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, parametre)
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre2, "centre2_{}".format(iedf))
name = "verticeEdgesFondIn{}".format(iedf)
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, name)
norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, parametre)
geomPublishInFather(initLog.debug, partitionPeauFissFond, centre, "norm{}".format(iedf))
cercle = geompy.MakeCircle(centre, norm, rayonPipe)
geomPublishInFather(initLog.debug, partitionPeauFissFond, cercle, "cerclorig{}".format(iedf))
[vertex] = geompy.ExtractShapes(cercle, geompy.ShapeType["VERTEX"], False)
vec1 = geompy.MakeVector(centre, vertex)
vec2 = geompy.MakeVector(centre, ptPeau)
angle = geompy.GetAngleRadians(vec1, vec2)
# cas général : on reconstitue une portion de pipe, avec l'arête de couture qui coincide
# avec la face de fissure, au niveau du débouché sur la face externe
# cas dégénéré : le pipe débouche perpendiculairement à une surface plane à l'origine.
# La partition filling / pipe reconstruit échoue.
# - Si on partitionne le filling avec un simple pipe obtenu par extrusion droite du cercle,
# cela donne un point en trop sur le cercle.
# - Si on prend une vraie surface plane (pas un filling), on peut faire la partition avec
# les pipes reconstruits
logging.debug("angle=%s", angle)
#if abs(angle) > 1.e-7:
sommetAxe = geompy.MakeTranslationVector(centre, norm)
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
cercle = geompy.MakeRotation(cercle, norm, angle + math.pi)
else:
cercle = geompy.MakeRotation(cercle, norm, -angle + math.pi)
name = "cercle{}".format(iedf)
geomPublishInFather(initLog.debug,partitionPeauFissFond, cercle, name)
return ptPeau, centre, norm, localEdgeInFondFiss, localEdgeInFondFiss, cercle

View File

@ -0,0 +1,52 @@
# -*- 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
#
"""Estimation de la longueur du pipe necessaire de part et d'autre du point de sortie"""
import logging
import math
from .geomsmesh import geompy
from .whichSide import whichSide
def identifieElementsDebouchants_b(ifil, \
facesDefaut,aretesVivesC, fillingFaceExterne, rayonPipe, \
ptPeau, centre, norm, localEdgeInFondFiss):
"""Estimation de la longueur du pipe necessaire de part et d'autre du point de sortie"""
logging.info('start')
# --- estimation de la longueur du pipe necessaire de part et d'autre du point de sortie
if aretesVivesC is None:
face_test_peau = fillingFaceExterne
else:
face_test_peau = facesDefaut[ifil]
side_centre = whichSide(face_test_peau, centre)
loc_pt0 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 0.0)
loc_pt1 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 1.0)
side_point_0 = whichSide(face_test_peau, loc_pt0)
side_point_1 = whichSide(face_test_peau, loc_pt1)
logging.debug("position centre cercle: %s, extremité edge u0: %s, u1: %s", side_centre, side_point_0, side_point_1)
norm_face = geompy.GetNormal(face_test_peau, ptPeau)
incl_pipe = abs(geompy.GetAngleRadians(norm, norm_face))
lgp = max(rayonPipe/2., abs(3*rayonPipe*math.tan(incl_pipe)))
logging.debug("angle inclinaison Pipe en sortie: %s degres, lgp: %s", incl_pipe*180/math.pi, lgp)
return loc_pt0, lgp

View File

@ -0,0 +1,68 @@
# -*- 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
#
"""Position des points extremite du pipe sur l'edge debouchante"""
import logging
import traceback
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .fissError import fissError
def identifieElementsDebouchants_c(iedf,\
partitionPeauFissFond, wireFondFiss, \
centre, localEdgeInFondFiss, cercle, loc_pt0, lgp, pipexts):
"""Position des points extremite du pipe sur l'edge debouchante"""
logging.info('start')
# ---
# il faut la distance curviligne ofp du point central par rapport à une extrémité de l'edge débouchante
locEdgePart = geompy.MakePartition([localEdgeInFondFiss],[centre], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
edgesLoc = geompy.ExtractShapes(locEdgePart, geompy.ShapeType["EDGE"], False)
edgesLocSorted =[(geompy.MinDistance(edge, loc_pt0), kk, edge) for kk, edge in enumerate(edgesLoc)]
edgesLocSorted.sort()
try:
ofp = geompy.BasicProperties(edgesLocSorted[0][2])[0] # distance curviligne centre loc_pt0
except:
texte = "Identification des éléments au débouché du pipe sur la face externe impossible. "
texte += "Cause possible : la ligne de fond de fissure comprend un point géométrique coincidant avec la face externe. "
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."
raise fissError(traceback.extract_stack(),texte)
logging.debug("distance curviligne centre extremite0: %s", ofp)
point_1 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp +lgp, loc_pt0)
point_2 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp -lgp, loc_pt0)
geomPublishInFather(initLog.debug, wireFondFiss, point_1, "point_1_{}".format(iedf))
geomPublishInFather(initLog.debug, wireFondFiss, point_2, "point_2_{}".format(iedf))
edgePart = geompy.MakePartition([localEdgeInFondFiss], [point_1,point_2], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0)
edps = geompy.ExtractShapes(edgePart, geompy.ShapeType["EDGE"], True)
for edp in edps:
if geompy.MinDistance(centre, edp) < 1.e-3:
pipext = geompy.MakePipe(cercle, edp)
name = "pipeExt{}".format(iedf)
geomPublishInFather(initLog.debug, partitionPeauFissFond, pipext, name)
pipexts.append(pipext)
return

View File

@ -0,0 +1,72 @@
# -*- 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
#
"""Recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def identifieElementsDebouchants_d(iedf,\
partitionPeauFissFond, edgesFondIn, edgesPipeIn, \
facesInside, facesOnside, \
ptPeau, facesFissExt, edgesFissExtPeau, edgesFissExtPipe):
"""Recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)"""
for ifa, face in enumerate(facesInside):
logging.debug("recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)")
edgesPeauFis = list()
edgesPipeFis = list()
edgesPipeFnd = list()
try:
edgesPeauFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(facesOnside), face], geompy.ShapeType["EDGE"])
logging.debug(" faces onside %s",edgesPeauFis)
edgesPipeFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesPipeIn), face], geompy.ShapeType["EDGE"])
logging.debug(" edgesPipeIn %s", edgesPipeFis)
edgesPipeFnd = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesFondIn), face], geompy.ShapeType["EDGE"])
logging.debug(" edgesFondIn %s ", edgesPipeFnd)
except:
logging.debug(" pb edges communes %s %s %s",edgesPeauFis, edgesPipeFis, edgesPipeFnd)
if (len(edgesPeauFis) > 0) and (len(edgesPipeFis) > 0) and (len(edgesPipeFnd) == 0):
dist = geompy.MinDistance(geompy.MakeCompound(edgesPeauFis), ptPeau)
logging.debug(" test distance extrémité reference %s", dist)
if dist < 1.e-3: # c'est la face de fissure externe associée
logging.debug(" face %s inside ajoutée", ifa)
facesFissExt.append(face)
name="faceFissExt%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, face, name)
dist = 1.
for edpe in edgesPeauFis:
for edpi in edgesPipeFis:
dist = geompy.MinDistance(edpe, edpi)
if dist < 1.e-3:
edgesFissExtPeau.append(edpe)
name="edgesFissExtPeau%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edpe, name)
edgesFissExtPipe.append(edpi)
name="edgesFissExtPipe%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edpi, name)
break
if dist < 1.e-3:
break
return

View File

@ -22,35 +22,20 @@
import os
import logging
import salome
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
import math
from .extractionOrientee import extractionOrientee
from .sortFaces import sortFaces
from .sortEdges import sortEdges
from .eliminateDoubles import eliminateDoubles
from .substractSubShapes import substractSubShapes
from .produitMixte import produitMixte
from .findWireEndVertices import findWireEndVertices
from .getSubshapeIds import getSubshapeIds
from .putName import putName
from .distance2 import distance2
from .enleveDefaut import enleveDefaut
from .shapeSurFissure import shapeSurFissure
from .regroupeSainEtDefaut import RegroupeSainEtDefaut
from .triedreBase import triedreBase
import salome
from .geomsmesh import geomPublish
from . import initLog
from .insereFissureLongue_a import insereFissureLongue_a
from .insereFissureLongue_b import insereFissureLongue_b
from .insereFissureLongue_c import insereFissureLongue_c
from .insereFissureLongue_d import insereFissureLongue_d
from .insereFissureLongue_e import insereFissureLongue_e
from .insereFissureLongue_f import insereFissureLongue_f
from .insereFissureLongue_g import insereFissureLongue_g
# -----------------------------------------------------------------------------
@ -107,322 +92,42 @@ def insereFissureLongue(geometriesSaines, \
fillingFaceExterne = facesDefaut[0]
logging.debug("fillingFaceExterne %s", fillingFaceExterne)
geomPublish(initLog.debug, fillingFaceExterne, "fillingFaceExterne")
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
O, OX, OY, OZ = triedreBase()
# -----------------------------------------------------------------------------
# --- peau et face de fissure
# --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée
partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond' )
edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False)
lgmax = 0
imax = 0
for i, edge in enumerate(edges):
props = geompy.BasicProperties(edge)
lg = props[0]
if lg > lgmax:
lgmax = lg
imax = i
edgemax = edges[imax]
geomPublish(initLog.debug, edgemax, 'edgemax')
centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5)
geomPublish(initLog.debug, centreFondFiss, 'centreFondFiss')
tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5)
geomPublish(initLog.debug, tangentFondFiss, 'tangentFondFiss')
bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0)
geomPublish(initLog.debug, bord1FondFiss, 'bord1FondFiss')
tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0)
geomPublish(initLog.debug, tangentBord1FondFiss, 'tangentBord1FondFiss')
bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0)
geomPublish(initLog.debug, bord2FondFiss, 'bord2FondFiss')
tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0)
geomPublish(initLog.debug, tangentBord2FondFiss, 'tangentBord2FondFiss')
planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe)
planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe)
geomPublish(initLog.debug, planBord1, 'planBord1')
geomPublish(initLog.debug, planBord2, 'planBord2')
[edgesInside, edgesOutside, edgesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, facesOutside, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
# --- partition peau -face fissure - pipe fond de fissure prolongé
partitionPeauFissByPipe = geompy.MakePartition([facesInside[0], facesOnside[0]], [pipefiss], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
geomPublish(initLog.debug, partitionPeauFissByPipe, 'partitionPeauFissByPipe' )
# --- identification face de peau
[facesPeauFissInside, facesPeauFissOutside, facesPeauFissOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissByPipe, centreFondFiss, "FACE", 0.1, "peauFiss_bord_")
facesPeauSorted, minsur, maxsurf = sortFaces(facesPeauFissOnside) # 4 demi disques, une grande face
facePeau = facesPeauSorted[-1] # la plus grande face
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, facePeau, "facePeau")
# --- identification edges de bord face peau
edgesBords = list()
for i, edge in enumerate(edgesFilling):
edgepeau = geompy.GetInPlace(facePeau, edge)
edgesBords.append(edgepeau)
groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesBords)
geomPublishInFather(initLog.debug,facePeau, groupEdgesBordPeau , "EdgesBords")
# --- identification face fissure externe au pipe et edge commune peau fissure
for face in facesPeauFissInside:
try:
sharedEdges = geompy.GetSharedShapesMulti([facePeau, face], geompy.ShapeType["EDGE"])
if sharedEdges is not None:
faceFiss = face
edgePeauFiss = sharedEdges[0]
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, faceFiss, "faceFiss")
geomPublishInFather(initLog.debug,faceFiss, edgePeauFiss, "edgePeauFiss")
geomPublishInFather(initLog.debug,facePeau, edgePeauFiss, "edgePeauFiss")
break
except:
pass
verticesEdgePeauFiss = geompy.ExtractShapes(edgePeauFiss, geompy.ShapeType["VERTEX"], False)
# --- identification edges demi cercle dans face de peau
edgesFacePeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
edgesFacePeauSorted, minlg, maxlg = sortEdges(edgesFacePeau)
demiCerclesPeau = edgesFacePeauSorted[0:4]
verticesDemiCerclesPeau = list()
for i, edge in enumerate(demiCerclesPeau):
name = "demiCerclePeau_%d"%i
geomPublishInFather(initLog.debug,facePeau, edge, name)
verticesDemiCerclesPeau += geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
verticesDemiCerclesPeau = eliminateDoubles(facePeau, verticesDemiCerclesPeau)
for i, vertex in enumerate(verticesDemiCerclesPeau):
name = "verticesDemiCerclesPeau_%d"%i
geomPublishInFather(initLog.debug,facePeau, vertex, name)
verticesOutCercles = substractSubShapes(facePeau, verticesDemiCerclesPeau, verticesEdgePeauFiss)
for i, vertex in enumerate(verticesOutCercles):
name = "verticesOutCercles_%d"%i
geomPublishInFather(initLog.debug,facePeau, vertex, name)
# --- demi cercles regroupés
groupsDemiCerclesPeau = list()
for i, vertex in enumerate(verticesEdgePeauFiss):
demis = list()
for edge in demiCerclesPeau:
if geompy.MinDistance(vertex, edge) < 1.e-5:
demis.append(edge)
group = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(group, demis)
name = "Cercle%d"%i
geomPublishInFather(initLog.debug,facePeau, group , name)
groupsDemiCerclesPeau.append(group)
# --- identification edges commune pipe face fissure externe au pipe
edgePeauFissId = geompy.GetSubShapeID(partitionPeauFissByPipe, edgePeauFiss)
edgesFaceFiss = geompy.ExtractShapes(faceFiss, geompy.ShapeType["EDGE"], False)
edgesFaceFissPipe = list()
for edge in edgesFaceFiss:
if geompy.GetSubShapeID(partitionPeauFissByPipe, edge) != edgePeauFissId:
edgesFaceFissPipe.append(edge)
name = "edgeFaceFissPipe_%d"%len(edgesFaceFissPipe)
geomPublishInFather(initLog.debug,faceFiss, edge, name)
groupEdgesFaceFissPipe = geompy.CreateGroup(faceFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesFaceFissPipe, edgesFaceFissPipe)
geomPublishInFather(initLog.debug,faceFiss, groupEdgesFaceFissPipe, "edgesFaceFissPipe")
edgesInside, centreFondFiss, tangentFondFiss, \
planBord1, planBord2 , \
facePeau, faceFiss, verticesOutCercles, verticesEdgePeauFiss, \
edgePeauFiss, demiCerclesPeau, \
groupEdgesBordPeau, groupsDemiCerclesPeau, groupEdgesFaceFissPipe = \
insereFissureLongue_a (facePorteFissure, WirePorteFondFissure, \
fillingFaceExterne, \
pipefiss, rayonPipe, \
mailleur )
# -----------------------------------------------------------------------------
# --- pipe de fond de fissure
wireFondFiss = geompy.MakeWire(edgesInside, 1e-07)
disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe)
[vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
vertproj = geompy.MakeProjection(vertex, planfiss)
vec1 = geompy.MakeVector(centreFondFiss, vertex)
try:
# si centreFondFiss et vertproj sont proches: exception. Angle = +- 90°
vec2 = geompy.MakeVector(centreFondFiss, vertproj)
angle = geompy.GetAngleRadians(vec1, vec2)
except:
# on utilise la projection du centre sur la peau pour avoir un vecteur non nul
vertproj = geompy.MakeProjection(centreFondFiss, facePeau)
vec2 = geompy.MakeVector(centreFondFiss, vertproj)
angle = geompy.GetAngleRadians(vec1, vec2)
sommetAxe = geompy.MakeTranslationVector(centreFondFiss, tangentFondFiss)
pm = produitMixte(centreFondFiss, vertex, vertproj, sommetAxe)
if pm > 0:
disque = geompy.MakeRotation(disque, tangentFondFiss, angle)
else:
disque = geompy.MakeRotation(disque, tangentFondFiss, -angle)
[vertexReference] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
pipeFondFiss = geompy.MakePipe(disque, wireFondFiss)
pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
#pipe = geompy.MakePipe(disque, WirePorteFondFissure)
#pipe = geompy.MakePartition([pipe],[fillingFaceExterne], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
#pipes = geompy.ExtractShapes(pipe, geompy.ShapeType["SOLID"], False)
#pipesSorted, volmin, volmax = sortSolids(pipes)
#pipeFondFiss = pipesSorted[-1]
#pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
geomPublish(initLog.debug, disque, 'disque')
geomPublish(initLog.debug, wireFondFiss, 'wireFondFiss')
geomPublish(initLog.debug, pipeFondFiss, 'pipeFondFiss')
VerticesEndFondFiss = findWireEndVertices(wireFondFiss)
for i, v in enumerate(VerticesEndFondFiss):
name = "vertexEndFondFiss_%d"%i
geomPublishInFather(initLog.debug,wireFondFiss, v, name)
VerticesEndPipeFiss = list()
for v in VerticesEndFondFiss:
VerticesEndPipeFiss.append(geompy.GetInPlace(pipeFondFiss, v))
for i, v in enumerate(VerticesEndPipeFiss):
name = "vertexEndPipeFiss_%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, v, name)
geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[0], "PFOR")
geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[1], "PFEX")
if geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[0]) > geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[1]):
a = verticesOutCercles[0]
verticesOutCercles[0] = verticesOutCercles[1]
verticesOutCercles[1] = a
geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[0], "THOR")
geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[1], "THEX")
[facesPipeInside, facesPipeOutside, facesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "FACE", 0.1, "pipe_bord_")
[edgesPipeInside, edgesPipeOutside, edgesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "EDGE", 0.1, "pipe_bord_")
disqueInt1 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord1)
disqueInt2 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord2)
disques = facesPipeOnside + [disqueInt1, disqueInt2]
edgesDiskInt = geompy.ExtractShapes(disqueInt1, geompy.ShapeType["EDGE"], False)
edgesDiskInt = edgesDiskInt +geompy.ExtractShapes(disqueInt2, geompy.ShapeType["EDGE"], False)
edgesSorted, minlg, maxlg = sortEdges(edgesDiskInt) # 4 rayons, 2 demi cercles
centre = geompy.MakeVertexOnSurface(planfiss, 0.5, 0.5)
refpoint = geompy.MakeTranslationVector(centre, geompy.GetNormal(planfiss,centre))
geomPublish(initLog.debug, refpoint, 'refpoint')
[facesPipeInplan, facesPipeOutplan, facesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "FACE", 0.1, "pipe_plan_")
[edgesPipeInplan, edgesPipeOutplan, edgesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "EDGE", 0.1, "pipe_plan_")
# --- rayon disques = (edgesPipeOnside inter edgesPipeOnplan) + rayons disque internes
# demi cercles = edgesPipeOnside moins edgesPipeOnplan + demi cercles disque internes
# generatrices = edgesPipeOnplan moins rayon disques (3 grandes et 6 petites)
edgesIdPipeOnside = getSubshapeIds(pipeFondFiss, edgesPipeOnside)
edgesIdPipeOnplan = getSubshapeIds(pipeFondFiss, edgesPipeOnplan)
rayons = list()
demiCercles = list()
for i, edgeId in enumerate(edgesIdPipeOnside):
if edgeId in edgesIdPipeOnplan:
rayons.append(edgesPipeOnside[i])
else:
demiCercles.append(edgesPipeOnside[i])
demiCerclesExternes = demiCercles
rayons = rayons + edgesSorted[:4] # les 4 plus petits sont les rayons
demiCercles = demiCercles + edgesSorted[4:] # les suivants sont les arcs de cercle
rayonsId = getSubshapeIds(pipeFondFiss, rayons)
generatrices = list()
for i, edgeId in enumerate(edgesIdPipeOnplan):
if edgeId not in rayonsId:
generatrices.append(edgesPipeOnplan[i])
# --- generatrices en contact avec la face fissure externe au pipe
generFiss = list()
for edge in generatrices:
distance = geompy.MinDistance(vertexReference, edge)
logging.debug("distance %s", distance)
if distance < 1.e-5:
generFiss.append(edge)
break
for edge in generatrices:
distance = geompy.MinDistance(generFiss[0], edge)
logging.debug("distance %s", distance)
if distance < 1.e-5:
generFiss.append(edge)
groupGenerFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupGenerFiss, generFiss)
geomPublishInFather(initLog.debug,pipeFondFiss, groupGenerFiss, "GenFiss")
# --- demi cercles externes regroupés
groupsDemiCerclesPipe = list()
for i, vertex in enumerate(verticesEdgePeauFiss):
demis = list()
for edge in demiCerclesExternes:
if geompy.MinDistance(vertex, edge) < 0.1:
demis.append(edge)
group = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(group, demis)
name = "Cercle%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, group , name)
groupsDemiCerclesPipe.append(group)
# --- faces fissure dans le pipe
facesFissinPipe = list()
generFissId = getSubshapeIds(pipeFondFiss, generFiss)
logging.debug("generatrice fissure %s", generFissId)
for face in facesPipeOnplan:
edges =geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], False)
edgesId = getSubshapeIds(pipeFondFiss, edges)
logging.debug(" edges %s", edgesId)
for i,edgeId in enumerate(edgesId):
if edgeId in generFissId:
logging.debug("face found")
facesFissinPipe.append(face)
name = "faceFissInPipe_%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, face, name)
break
groupFaceFissInPipe = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["FACE"])
geompy.UnionList(groupFaceFissInPipe, facesFissinPipe)
name = "FaceFissInPipe"
geomPublishInFather(initLog.debug,pipeFondFiss, groupFaceFissInPipe , name)
# --- edges de fond de fissure
edgesFondFiss = list()
for i, edge in enumerate(edgesInside):
anEdge = geompy.GetInPlace(pipeFondFiss, edge)
logging.debug(" edge %s ", anEdge)
edgesFondFiss.append(anEdge)
name ="edgeFondFissure_%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, anEdge, name)
groupEdgeFondFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgeFondFiss, edgesFondFiss)
name = "FONDFISS"
geomPublishInFather(initLog.debug,pipeFondFiss, groupEdgeFondFiss , name)
# -------------------------------------------------------------------------
# --- maillage
# --- edges de bord face defaut à respecter
aFilterManager = smesh.CreateFilterManager()
nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
criteres = list()
unCritere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0)
criteres.append(unCritere)
filtre = smesh.GetFilterFromCriteria(criteres)
bordsLibres = internalBoundary.MakeGroupByFilter( 'bords', filtre )
smesh.SetName(bordsLibres, 'bordsLibres')
# --- pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
# on designe les faces de peau en quadrangles par le groupe "skinFaces"
skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
nbAdd = skinFaces.AddFrom( internalBoundary.GetMesh() )
pipeFondFiss, disques, rayons, \
demiCercles, generatrices, \
VerticesEndPipeFiss, bordsLibres, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss = \
insereFissureLongue_b (edgesInside, centreFondFiss, tangentFondFiss, \
planfiss, planBord1, planBord2, \
facePeau, verticesOutCercles, verticesEdgePeauFiss, \
fillingFaceExterne, rayonPipe, \
internalBoundary)
# --- maillage pipe fond fissure
meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout = \
insereFissureLongue_a (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
insereFissureLongue_c (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
VerticesEndPipeFiss, verticesEdgePeauFiss, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
profondeur, rayonPipe, distance2)
profondeur, rayonPipe)
# --- maillage face de peau
meshFacePeau, groupEdgesPeauFiss = \
insereFissureLongue_b ( facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
insereFissureLongue_d ( facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
nbSegGenLong, nbSegGenBout, profondeur, \
mailleur )
@ -430,68 +135,24 @@ def insereFissureLongue(geometriesSaines, \
# --- maillage face de fissure
meshFaceFiss = \
insereFissureLongue_c ( faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
insereFissureLongue_e ( faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
profondeur, rayonPipe, \
mailleur )
# --- maillage meshBoiteDefaut
meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe = \
insereFissureLongue_d ( internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
insereFissureLongue_f ( internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
mailleur )
groups = maillageSain.GetGroups()
grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
coords1 = maillageSain.GetNodeXYZ(grps1[0].GetID(1))
coords2 = maillageSain.GetNodeXYZ(grps2[0].GetID(1))
logging.info("coords1 %s, coords2 %s",coords1, coords2)
# --- maillage complet
maillageComplet = \
insereFissureLongue_g (nomFicFissure, fichierMaillageFissure, nomFicSain, maillageSain, \
meshBoiteDefaut, facePorteFissure, \
group_faceFissInPipe, group_faceFissOutPipe, \
zoneDefaut, zoneDefaut_skin, zoneDefaut_internalEdges, zoneDefaut_internalFaces)
faceFissure = meshBoiteDefaut.GetMesh().UnionListOfGroups( [ group_faceFissOutPipe, group_faceFissInPipe ], 'FACE1' )
maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges)
putName(maillageSain, nomFicSain+"_coupe")
extrusionFaceFissure, normfiss = shapeSurFissure(facePorteFissure)
maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut, extrusionFaceFissure, facePorteFissure, 'COUDE')
groups = maillageComplet.GetGroups()
grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
nodeid1 = maillageComplet.AddNode(coords1[0], coords1[1], coords1[2])
nodeid2 = maillageComplet.AddNode(coords2[0], coords2[1], coords2[2])
grps1[0].Add([nodeid1])
grps2[0].Add([nodeid2])
ma0d1 = maillageComplet.Add0DElement(nodeid1)
ma0d2 = maillageComplet.Add0DElement(nodeid2)
grpma0d1 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P1' )
nbAdd = grpma0d1.Add( [ma0d1] )
grpma0d2 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P2' )
nbAdd = grpma0d2.Add( [ma0d2] )
# grps = [ grp for grp in groups if grp.GetName() == 'affectedEdges']
# grps[0].SetName('affEdges')
# grps = [ grp for grp in groups if grp.GetName() == 'affectedFaces']
# grps[0].SetName('affFaces')
# grps = [ grp for grp in groups if grp.GetName() == 'affectedVolumes']
# grps[0].SetName('affVols')
maillageComplet.ConvertToQuadratic( 1 )
grps = [ grp for grp in groups if grp.GetName() == 'FONDFISS']
fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FONDFISS' )
grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
nb = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
plansim = geompy.MakePlane(O, normfiss, 10000)
fissnorm = geompy.MakeMirrorByPlane(normfiss, plansim)
grps = [ grp for grp in groups if grp.GetName() == 'FACE2']
nb = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1))
#isDone = maillageComplet.ReorientObject( grps[0] )
fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure %s", fichierMaillageFissure)
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2020 EDF R&D
# 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
@ -17,129 +17,158 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Insertion de fissure longue - maillage pipe fond fissure"""
"""procédure complète de construction d'une fissure longue"""
import logging
import salome
from .geomsmesh import geompy
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .extractionOrientee import extractionOrientee
from .sortFaces import sortFaces
from .sortEdges import sortEdges
from .putName import putName
from .eliminateDoubles import eliminateDoubles
from .substractSubShapes import substractSubShapes
import math
# -----------------------------------------------------------------------------
def insereFissureLongue_a (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
VerticesEndPipeFiss, verticesEdgePeauFiss, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
profondeur, rayonPipe, distance2):
"""maillage pipe fond fissure"""
def insereFissureLongue_a(facePorteFissure, WirePorteFondFissure, \
fillingFaceExterne, \
pipefiss, rayonPipe, \
mailleur="MeshGems"):
"""procedure complete fissure longue"""
logging.info('start')
logging.info("Usage du mailleur %s", mailleur)
meshFondFiss = smesh.Mesh(pipeFondFiss)
algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
algo3d = meshFondFiss.Prism()
putName(algo3d.GetSubMesh(), "pipe")
putName(algo3d, "algo3d_pipe")
putName(algo2d, "algo2d_pipe")
for i, face in enumerate(disques):
algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
putName(algo2d.GetSubMesh(), "disque", i)
putName(algo2d, "algo2d_disque", i)
# -----------------------------------------------------------------------------
# --- peau et face de fissure
for i, edge in enumerate(rayons):
algo1d = meshFondFiss.Segment(geom=edge)
hypo1d = algo1d.NumberOfSegments(4)
putName(algo1d.GetSubMesh(), "rayon", i)
putName(algo1d, "algo1d_rayon", i)
putName(hypo1d, "hypo1d_rayon", i)
# --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée
partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond' )
for i, edge in enumerate(demiCercles):
algo1d = meshFondFiss.Segment(geom=edge)
hypo1d = algo1d.NumberOfSegments(6)
putName(algo1d.GetSubMesh(), "demiCercle", i)
putName(algo1d, "algo1d_demiCercle", i)
putName(hypo1d, "hypo1d_demiCercle", i)
edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False)
generSorted, minlg, maxlg = sortEdges(generatrices)
nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
nbSegGenBout = 6
logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
for i, edge in enumerate(generSorted):
algo1d = meshFondFiss.Segment(geom=edge)
if i < 6:
hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
else:
hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
putName(algo1d.GetSubMesh(), "generatrice", i)
putName(algo1d, "algo1d_generatrice", i)
putName(hypo1d, "hypo1d_generatrice", i)
lgmax = 0
imax = 0
for i_aux, edge in enumerate(edges):
props = geompy.BasicProperties(edge)
longueur = props[0]
if ( longueur > lgmax ):
lgmax = longueur
imax = i_aux
edgemax = edges[imax]
geomPublish(initLog.debug, edgemax, 'edgemax')
centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5)
geomPublish(initLog.debug, centreFondFiss, 'centreFondFiss')
tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5)
geomPublish(initLog.debug, tangentFondFiss, 'tangentFondFiss')
disks = list()
for i, face in enumerate(disques[:4]):
name = "disk%d"%i
disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
_ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0)
geomPublish(initLog.debug, bord1FondFiss, 'bord1FondFiss')
tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0)
geomPublish(initLog.debug, tangentBord1FondFiss, 'tangentBord1FondFiss')
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0)
geomPublish(initLog.debug, bord2FondFiss, 'bord2FondFiss')
tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0)
geomPublish(initLog.debug, tangentBord2FondFiss, 'tangentBord2FondFiss')
_ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe)
planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe)
geomPublish(initLog.debug, planBord1, 'planBord1')
geomPublish(initLog.debug, planBord2, 'planBord2')
groups_demiCercles = list()
groupnodes_demiCercles = list()
for i, group in enumerate(groupsDemiCerclesPipe):
[edgesInside, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, _, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
# --- partition peau -face fissure - pipe fond de fissure prolongé
partitionPeauFissByPipe = geompy.MakePartition([facesInside[0], facesOnside[0]], [pipefiss], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
geomPublish(initLog.debug, partitionPeauFissByPipe, 'partitionPeauFissByPipe' )
# --- identification face de peau
[facesPeauFissInside, _, facesPeauFissOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissByPipe, centreFondFiss, "FACE", 0.1, "peauFiss_bord_")
facesPeauSorted, _, _ = sortFaces(facesPeauFissOnside) # 4 demi disques, une grande face
facePeau = facesPeauSorted[-1] # la plus grande face
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, facePeau, "facePeau")
# --- identification edges de bord face peau
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
edgesBords = list()
for i, edge in enumerate(edgesFilling):
edgepeau = geompy.GetInPlace(facePeau, edge)
edgesBords.append(edgepeau)
groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesBords)
geomPublishInFather(initLog.debug,facePeau, groupEdgesBordPeau , "EdgesBords")
# --- identification face fissure externe au pipe et edge commune peau fissure
for face in facesPeauFissInside:
try:
sharedEdges = geompy.GetSharedShapesMulti([facePeau, face], geompy.ShapeType["EDGE"])
if sharedEdges is not None:
faceFiss = face
edgePeauFiss = sharedEdges[0]
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, faceFiss, "faceFiss")
geomPublishInFather(initLog.debug,faceFiss, edgePeauFiss, "edgePeauFiss")
geomPublishInFather(initLog.debug,facePeau, edgePeauFiss, "edgePeauFiss")
break
except:
pass
verticesEdgePeauFiss = geompy.ExtractShapes(edgePeauFiss, geompy.ShapeType["VERTEX"], False)
# --- identification edges demi cercle dans face de peau
edgesFacePeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
edgesFacePeauSorted, _, _ = sortEdges(edgesFacePeau)
demiCerclesPeau = edgesFacePeauSorted[0:4]
verticesDemiCerclesPeau = list()
for i, edge in enumerate(demiCerclesPeau):
name = "demiCerclePeau_%d"%i
geomPublishInFather(initLog.debug,facePeau, edge, name)
verticesDemiCerclesPeau += geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
verticesDemiCerclesPeau = eliminateDoubles(facePeau, verticesDemiCerclesPeau)
for i, vertex in enumerate(verticesDemiCerclesPeau):
name = "verticesDemiCerclesPeau_%d"%i
geomPublishInFather(initLog.debug,facePeau, vertex, name)
verticesOutCercles = substractSubShapes(facePeau, verticesDemiCerclesPeau, verticesEdgePeauFiss)
for i, vertex in enumerate(verticesOutCercles):
name = "verticesOutCercles_%d"%i
geomPublishInFather(initLog.debug,facePeau, vertex, name)
# --- demi cercles regroupés
groupsDemiCerclesPeau = list()
for i, vertex in enumerate(verticesEdgePeauFiss):
demis = list()
for edge in demiCerclesPeau:
if geompy.MinDistance(vertex, edge) < 1.e-5:
demis.append(edge)
group = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(group, demis)
name = "Cercle%d"%i
groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
name = "nCercle%d"%i
groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
geomPublishInFather(initLog.debug,facePeau, group , name)
groupsDemiCerclesPeau.append(group)
is_done = meshFondFiss.Compute()
text = "meshFondFiss.Compute"
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
# --- identification edges commune pipe face fissure externe au pipe
edgePeauFissId = geompy.GetSubShapeID(partitionPeauFissByPipe, edgePeauFiss)
edgesFaceFiss = geompy.ExtractShapes(faceFiss, geompy.ShapeType["EDGE"], False)
edgesFaceFissPipe = list()
for edge in edgesFaceFiss:
if geompy.GetSubShapeID(partitionPeauFissByPipe, edge) != edgePeauFissId:
edgesFaceFissPipe.append(edge)
name = "edgeFaceFissPipe_%d"%len(edgesFaceFissPipe)
geomPublishInFather(initLog.debug,faceFiss, edge, name)
groupEdgesFaceFissPipe = geompy.CreateGroup(faceFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesFaceFissPipe, edgesFaceFissPipe)
geomPublishInFather(initLog.debug,faceFiss, groupEdgesFaceFissPipe, "edgesFaceFissPipe")
grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
idNode0 = grpNode0.GetID(1)
idNode1 = grpNode1.GetID(1)
coordsMesh = list()
coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
for vertex in verticesEdgePeauFiss:
coord = geompy.PointCoordinates(vertex)
if distance2(coord, coordsMesh[0]) < 0.1:
meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
if distance2(coord, coordsMesh[1]) < 0.1:
meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
for groupNodes in groupnodes_demiCercles:
for idNode in groupNodes.GetListOfID():
coordMesh = meshFondFiss.GetNodeXYZ(idNode)
vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
minDist = 100000
minCoord = None
imin = -1
for i, edge in enumerate(demiCerclesPeau):
discoord = geompy.MinDistanceComponents(vertex, edge)
if discoord[0] <minDist:
minDist = discoord[0]
minCoord = discoord[1:]
imin = i
if imin >= 0 and minDist > 1.E-6:
logging.debug("node id moved : %s distance=%s", idNode, minDist)
meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
return meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout
return edgesInside, centreFondFiss, tangentFondFiss, \
planBord1, planBord2, \
facePeau, faceFiss, verticesOutCercles, verticesEdgePeauFiss, \
edgePeauFiss, demiCerclesPeau, \
groupEdgesBordPeau, groupsDemiCerclesPeau, groupEdgesFaceFissPipe

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2020 EDF R&D
# 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
@ -17,89 +17,219 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Insertion de fissure longue - maillage face de peau"""
"""procédure complète de construction d'une fissure longue"""
import logging
import salome
from .geomsmesh import geompy
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .putName import putName
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from .geomsmesh import smesh
def insereFissureLongue_b (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
nbSegGenLong, nbSegGenBout, profondeur, \
mailleur="MeshGems"):
"""maillage face de peau"""
from . import initLog
from .extractionOrientee import extractionOrientee
from .sortEdges import sortEdges
from .produitMixte import produitMixte
from .findWireEndVertices import findWireEndVertices
from .getSubshapeIds import getSubshapeIds
# -----------------------------------------------------------------------------
def insereFissureLongue_b(edgesInside, centreFondFiss, tangentFondFiss, \
planfiss, planBord1, planBord2, \
facePeau, verticesOutCercles, verticesEdgePeauFiss, \
fillingFaceExterne, rayonPipe, \
internalBoundary):
"""procedure complete fissure longue"""
logging.info('start')
meshFacePeau = smesh.Mesh(facePeau)
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( 1000 )
hypo2d.SetMinSize( 100 )
hypo2d.SetMaxSize( 3000. )
hypo2d.SetChordalError( 250. )
hypo2d.SetVerbosity( 0 )
# -----------------------------------------------------------------------------
# --- pipe de fond de fissure
wireFondFiss = geompy.MakeWire(edgesInside, 1e-07)
disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe)
[vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
vertproj = geompy.MakeProjection(vertex, planfiss)
vec1 = geompy.MakeVector(centreFondFiss, vertex)
try:
# si centreFondFiss et vertproj sont proches: exception. Angle = +- 90°
vec2 = geompy.MakeVector(centreFondFiss, vertproj)
angle = geompy.GetAngleRadians(vec1, vec2)
except:
# on utilise la projection du centre sur la peau pour avoir un vecteur non nul
vertproj = geompy.MakeProjection(centreFondFiss, facePeau)
vec2 = geompy.MakeVector(centreFondFiss, vertproj)
angle = geompy.GetAngleRadians(vec1, vec2)
sommetAxe = geompy.MakeTranslationVector(centreFondFiss, tangentFondFiss)
if ( produitMixte(centreFondFiss, vertex, vertproj, sommetAxe) > 0 ):
disque = geompy.MakeRotation(disque, tangentFondFiss, angle)
else:
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
hypo2d = algo2d.Parameters()
hypo2d.SetMaxSize( 1000 )
hypo2d.SetOptimize( 1 )
hypo2d.SetFineness( 2 )
hypo2d.SetMinSize( 2 )
hypo2d.SetQuadAllowed( 0 )
putName(algo2d.GetSubMesh(), "facePeau")
putName(algo2d, "algo2d_facePeau")
putName(hypo2d, "hypo2d_facePeau")
#
lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
frac = profondeur/lenEdgePeauFiss
nbSeg = nbSegGenLong +2*nbSegGenBout
ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
disque = geompy.MakeRotation(disque, tangentFondFiss, -angle)
[vertexReference] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
hypo1d.SetDistrType( 2 )
hypo1d.SetConversionMode( 1 )
hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
putName(algo1d.GetSubMesh(), "edgePeauFiss")
putName(algo1d, "algo1d_edgePeauFiss")
putName(hypo1d, "hypo1d_edgePeauFiss")
#
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres")
putName(algo1d, "algo1d_bordsLibres")
putName(hypo1d, "hypo1d_bordsLibres")
#
for i in range(2):
algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
putName(algo1d.GetSubMesh(), "DemiCercles", i)
putName(algo1d, "algo1d_groupDemiCercles", i)
putName(hypo1d, "hypo1d_groupDemiCercles", i)
pipeFondFiss = geompy.MakePipe(disque, wireFondFiss)
pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
#pipe = geompy.MakePipe(disque, WirePorteFondFissure)
#pipe = geompy.MakePartition([pipe],[fillingFaceExterne], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
#pipes = geompy.ExtractShapes(pipe, geompy.ShapeType["SOLID"], False)
#pipesSorted, volmin, volmax = sortSolids(pipes)
#pipeFondFiss = pipesSorted[-1]
#pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
_ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
_ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
geomPublish(initLog.debug, disque, 'disque')
geomPublish(initLog.debug, wireFondFiss, 'wireFondFiss')
geomPublish(initLog.debug, pipeFondFiss, 'pipeFondFiss')
groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
VerticesEndFondFiss, _ = findWireEndVertices(wireFondFiss)
for i_aux, vertex in enumerate(VerticesEndFondFiss):
name = "vertexEndFondFiss_{}".format(i_aux)
geomPublishInFather(initLog.debug,wireFondFiss, vertex, name)
VerticesEndPipeFiss = list()
for vertex in VerticesEndFondFiss:
VerticesEndPipeFiss.append(geompy.GetInPlace(pipeFondFiss, vertex))
for i_aux, vertex in enumerate(VerticesEndPipeFiss):
name = "vertexEndPipeFiss_{}".format(i_aux)
geomPublishInFather(initLog.debug,pipeFondFiss, vertex, name)
is_done = meshFacePeau.Compute()
text = "meshFacePeau.Compute"
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[0], "PFOR")
geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[1], "PFEX")
if ( geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[0]) > geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[1]) ):
aux = verticesOutCercles[0]
verticesOutCercles[0] = verticesOutCercles[1]
verticesOutCercles[1] = aux
geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[0], "THOR")
geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[1], "THEX")
peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
_ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
[_, _, facesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "FACE", 0.1, "pipe_bord_")
[_, _, edgesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "EDGE", 0.1, "pipe_bord_")
disqueInt1 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord1)
disqueInt2 = geompy.GetInPlaceByHistory(pipeFondFiss, planBord2)
disques = facesPipeOnside + [disqueInt1, disqueInt2]
edgesDiskInt = geompy.ExtractShapes(disqueInt1, geompy.ShapeType["EDGE"], False)
edgesDiskInt = edgesDiskInt +geompy.ExtractShapes(disqueInt2, geompy.ShapeType["EDGE"], False)
edgesSorted, _, _ = sortEdges(edgesDiskInt) # 4 rayons, 2 demi cercles
return meshFacePeau, groupEdgesPeauFiss
centre = geompy.MakeVertexOnSurface(planfiss, 0.5, 0.5)
refpoint = geompy.MakeTranslationVector(centre, geompy.GetNormal(planfiss,centre))
geomPublish(initLog.debug, refpoint, 'refpoint')
[_, _, facesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "FACE", 0.1, "pipe_plan_")
[_, _, edgesPipeOnplan] = extractionOrientee(planfiss, pipeFondFiss, refpoint, "EDGE", 0.1, "pipe_plan_")
# --- rayon disques = (edgesPipeOnside inter edgesPipeOnplan) + rayons disque internes
# demi cercles = edgesPipeOnside moins edgesPipeOnplan + demi cercles disque internes
# generatrices = edgesPipeOnplan moins rayon disques (3 grandes et 6 petites)
edgesIdPipeOnside = getSubshapeIds(pipeFondFiss, edgesPipeOnside)
edgesIdPipeOnplan = getSubshapeIds(pipeFondFiss, edgesPipeOnplan)
rayons = list()
demiCercles = list()
for i, edgeId in enumerate(edgesIdPipeOnside):
if edgeId in edgesIdPipeOnplan:
rayons.append(edgesPipeOnside[i])
else:
demiCercles.append(edgesPipeOnside[i])
demiCerclesExternes = demiCercles
rayons = rayons + edgesSorted[:4] # les 4 plus petits sont les rayons
demiCercles = demiCercles + edgesSorted[4:] # les suivants sont les arcs de cercle
rayonsId = getSubshapeIds(pipeFondFiss, rayons)
generatrices = list()
for i, edgeId in enumerate(edgesIdPipeOnplan):
if edgeId not in rayonsId:
generatrices.append(edgesPipeOnplan[i])
# --- generatrices en contact avec la face fissure externe au pipe
generFiss = list()
for edge in generatrices:
distance = geompy.MinDistance(vertexReference, edge)
logging.debug("distance %s", distance)
if distance < 1.e-5:
generFiss.append(edge)
break
for edge in generatrices:
distance = geompy.MinDistance(generFiss[0], edge)
logging.debug("distance %s", distance)
if distance < 1.e-5:
generFiss.append(edge)
groupGenerFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupGenerFiss, generFiss)
geomPublishInFather(initLog.debug,pipeFondFiss, groupGenerFiss, "GenFiss")
# --- demi cercles externes regroupés
groupsDemiCerclesPipe = list()
for i, vertex in enumerate(verticesEdgePeauFiss):
demis = list()
for edge in demiCerclesExternes:
if geompy.MinDistance(vertex, edge) < 0.1:
demis.append(edge)
group = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(group, demis)
name = "Cercle%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, group , name)
groupsDemiCerclesPipe.append(group)
# --- faces fissure dans le pipe
facesFissinPipe = list()
generFissId = getSubshapeIds(pipeFondFiss, generFiss)
logging.debug("generatrice fissure %s", generFissId)
for face in facesPipeOnplan:
edges =geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], False)
edgesId = getSubshapeIds(pipeFondFiss, edges)
logging.debug(" edges %s", edgesId)
for i,edgeId in enumerate(edgesId):
if edgeId in generFissId:
logging.debug("face found")
facesFissinPipe.append(face)
name = "faceFissInPipe_%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, face, name)
break
groupFaceFissInPipe = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["FACE"])
geompy.UnionList(groupFaceFissInPipe, facesFissinPipe)
name = "FaceFissInPipe"
geomPublishInFather(initLog.debug,pipeFondFiss, groupFaceFissInPipe , name)
# --- edges de fond de fissure
edgesFondFiss = list()
for i, edge in enumerate(edgesInside):
anEdge = geompy.GetInPlace(pipeFondFiss, edge)
logging.debug(" edge %s ", anEdge)
edgesFondFiss.append(anEdge)
name ="edgeFondFissure_%d"%i
geomPublishInFather(initLog.debug,pipeFondFiss, anEdge, name)
groupEdgeFondFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgeFondFiss, edgesFondFiss)
name = "FONDFISS"
geomPublishInFather(initLog.debug,pipeFondFiss, groupEdgeFondFiss , name)
# -------------------------------------------------------------------------
# --- maillage
# --- edges de bord face defaut à respecter
_ = smesh.CreateFilterManager()
_, internalBoundary, _ = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
criteres = list()
un_critere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0)
criteres.append(un_critere)
filtre = smesh.GetFilterFromCriteria(criteres)
bordsLibres = internalBoundary.MakeGroupByFilter( 'bords', filtre )
smesh.SetName(bordsLibres, 'bordsLibres')
# --- pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
# on designe les faces de peau en quadrangles par le groupe "skinFaces"
skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
_ = skinFaces.AddFrom( internalBoundary.GetMesh() )
# --- maillage pipe fond fissure
return pipeFondFiss, disques, rayons, \
demiCercles, generatrices, \
VerticesEndPipeFiss, bordsLibres, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss

View File

@ -17,63 +17,94 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Insertion de fissure longue - maillage face de fissure"""
"""Insertion de fissure longue - maillage pipe fond fissure"""
import logging
import math
import salome
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .sortEdges import sortEdges
from .putName import putName
from .distance2 import distance2
import math
def insereFissureLongue_c (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
profondeur, rayonPipe, \
mailleur="MeshGems"):
"""maillage face de fissure"""
def insereFissureLongue_c (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
VerticesEndPipeFiss, verticesEdgePeauFiss, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
profondeur, rayonPipe):
"""maillage pipe fond fissure"""
logging.info('start')
meshFaceFiss = smesh.Mesh(faceFiss)
mesh_size = (profondeur - rayonPipe)/math.sqrt(3.0) # pour avoir deux couches de triangles equilateraux partout sur la fissure
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.MG_CADSurf)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( mesh_size )
hypo2d.SetMinSize( mesh_size/10. )
hypo2d.SetMaxSize( mesh_size*3. )
hypo2d.SetChordalError( mesh_size*0.25 )
hypo2d.SetVerbosity( 0 )
else:
algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D)
hypo2d = algo2d.Parameters()
hypo2d.SetMaxSize( mesh_size )
hypo2d.SetOptimize( 1 )
hypo2d.SetFineness( 2 )
hypo2d.SetMinSize( 2 )
hypo2d.SetQuadAllowed( 0 )
putName(algo2d.GetSubMesh(), "faceFiss")
putName(algo2d, "algo2d_faceFiss")
putName(hypo2d, "hypo2d_faceFiss")
#
algo1d = meshFaceFiss.UseExisting1DElements(geom=edgePeauFiss)
hypo1d = algo1d.SourceEdges([ groupEdgesPeauFiss ],0,0)
putName(algo1d.GetSubMesh(), "edgeFissPeau")
putName(algo1d, "algo1d_edgeFissPeau")
putName(hypo1d, "hypo1d_edgeFissPeau")
#
algo1d = meshFaceFiss.UseExisting1DElements(geom=groupEdgesFaceFissPipe)
hypo1d = algo1d.SourceEdges([ group_generFiss ],0,0)
putName(algo1d.GetSubMesh(), "edgeFissPeau")
putName(algo1d, "algo1d_edgeFissPeau")
putName(hypo1d, "hypo1d_edgeFissPeau")
meshFondFiss = smesh.Mesh(pipeFondFiss)
algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
algo3d = meshFondFiss.Prism()
putName(algo3d.GetSubMesh(), "pipe")
putName(algo3d, "algo3d_pipe")
putName(algo2d, "algo2d_pipe")
_ = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE)
for i, face in enumerate(disques):
algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
putName(algo2d.GetSubMesh(), "disque", i)
putName(algo2d, "algo2d_disque", i)
is_done = meshFaceFiss.Compute()
text = "meshFaceFiss.Compute"
for i, edge in enumerate(rayons):
algo1d = meshFondFiss.Segment(geom=edge)
hypo1d = algo1d.NumberOfSegments(4)
putName(algo1d.GetSubMesh(), "rayon", i)
putName(algo1d, "algo1d_rayon", i)
putName(hypo1d, "hypo1d_rayon", i)
for i, edge in enumerate(demiCercles):
algo1d = meshFondFiss.Segment(geom=edge)
hypo1d = algo1d.NumberOfSegments(6)
putName(algo1d.GetSubMesh(), "demiCercle", i)
putName(algo1d, "algo1d_demiCercle", i)
putName(hypo1d, "hypo1d_demiCercle", i)
generSorted, minlg, maxlg = sortEdges(generatrices)
nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
nbSegGenBout = 6
logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
for i, edge in enumerate(generSorted):
algo1d = meshFondFiss.Segment(geom=edge)
if i < 6:
hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
else:
hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
putName(algo1d.GetSubMesh(), "generatrice", i)
putName(algo1d, "algo1d_generatrice", i)
putName(hypo1d, "hypo1d_generatrice", i)
disks = list()
for i, face in enumerate(disques[:4]):
name = "disk%d"%i
disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
_ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
_ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
groups_demiCercles = list()
groupnodes_demiCercles = list()
for i, group in enumerate(groupsDemiCerclesPipe):
name = "Cercle%d"%i
groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
name = "nCercle%d"%i
groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
is_done = meshFondFiss.Compute()
text = "meshFondFiss.Compute"
if is_done:
logging.info(text+" OK")
else:
@ -81,4 +112,36 @@ def insereFissureLongue_c (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_gen
logging.info(text)
raise Exception(text)
return meshFaceFiss
grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
idNode0 = grpNode0.GetID(1)
idNode1 = grpNode1.GetID(1)
coordsMesh = list()
coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
for vertex in verticesEdgePeauFiss:
coord = geompy.PointCoordinates(vertex)
if distance2(coord, coordsMesh[0]) < 0.1:
meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
if distance2(coord, coordsMesh[1]) < 0.1:
meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
for groupNodes in groupnodes_demiCercles:
for idNode in groupNodes.GetListOfID():
coordMesh = meshFondFiss.GetNodeXYZ(idNode)
vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
minDist = 100000
minCoord = None
imin = -1
for i, edge in enumerate(demiCerclesPeau):
discoord = geompy.MinDistanceComponents(vertex, edge)
if discoord[0] <minDist:
minDist = discoord[0]
minCoord = discoord[1:]
imin = i
if imin >= 0 and minDist > 1.E-6:
logging.debug("node id moved : %s distance=%s", idNode, minDist)
meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
return meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout

View File

@ -17,58 +17,83 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Insertion de fissure longue - maillage meshBoiteDefaut"""
"""Insertion de fissure longue - maillage face de peau"""
import logging
import salome
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .putName import putName
def insereFissureLongue_d (internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
def insereFissureLongue_d (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
nbSegGenLong, nbSegGenBout, profondeur, \
mailleur="MeshGems"):
"""maillage meshBoiteDefaut"""
"""maillage face de peau"""
logging.info('start')
logging.info("insereFissureLongue_d (%s)", mailleur)
meshBoiteDefaut = smesh.Concatenate( [internalBoundary.GetMesh(), \
meshFondFiss.GetMesh(), \
meshFacePeau.GetMesh(), \
meshFaceFiss.GetMesh()], \
1, 1, 1e-05,False)
# pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
# on designe les faces de peau en quadrangles par le groupe "skinFaces"
group_faceFissOutPipe = None
group_faceFissInPipe = None
groups = meshBoiteDefaut.GetGroups()
for grp in groups:
if grp.GetType() == SMESH.FACE:
#if "internalBoundary" in grp.GetName():
# grp.SetName("skinFaces")
if grp.GetName() == "fisOutPi":
group_faceFissOutPipe = grp
elif grp.GetName() == "fisInPi":
group_faceFissInPipe = grp
# le maillage NETGEN ne passe pas toujours ==> on force l'usage de MG_Tetra
mailleur = "MeshGems"
meshFacePeau = smesh.Mesh(facePeau)
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.MG_Tetra)
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( 1000 )
hypo2d.SetMinSize( 100 )
hypo2d.SetMaxSize( 3000. )
hypo2d.SetChordalError( 250. )
hypo2d.SetVerbosity( 0 )
else:
algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN)
hypo3d = algo3d.MaxElementVolume(1000.0)
hypo3d.SetVerboseLevel( 0 )
hypo3d.SetStandardOutputLog( 0 )
hypo3d.SetRemoveLogOnSuccess( 1 )
putName(algo3d.GetSubMesh(), "boiteDefaut")
putName(algo3d, "algo3d_boiteDefaut")
putName(meshBoiteDefaut, "boiteDefaut")
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
hypo2d = algo2d.Parameters()
hypo2d.SetMaxSize( 1000 )
hypo2d.SetOptimize( 1 )
hypo2d.SetFineness( 2 )
hypo2d.SetMinSize( 2 )
hypo2d.SetQuadAllowed( 0 )
putName(algo2d.GetSubMesh(), "facePeau")
putName(algo2d, "algo2d_facePeau")
putName(hypo2d, "hypo2d_facePeau")
#
lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
frac = profondeur/lenEdgePeauFiss
nbSeg = nbSegGenLong +2*nbSegGenBout
ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
is_done = meshBoiteDefaut.Compute()
text = "meshBoiteDefaut.Compute"
algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
hypo1d.SetDistrType( 2 )
hypo1d.SetConversionMode( 1 )
hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
putName(algo1d.GetSubMesh(), "edgePeauFiss")
putName(algo1d, "algo1d_edgePeauFiss")
putName(hypo1d, "hypo1d_edgePeauFiss")
#
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres")
putName(algo1d, "algo1d_bordsLibres")
putName(hypo1d, "hypo1d_bordsLibres")
#
for i in range(2):
algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
putName(algo1d.GetSubMesh(), "DemiCercles", i)
putName(algo1d, "algo1d_groupDemiCercles", i)
putName(hypo1d, "hypo1d_groupDemiCercles", i)
_ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
_ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
is_done = meshFacePeau.Compute()
text = "meshFacePeau.Compute"
if is_done:
logging.info(text+" OK")
else:
@ -76,4 +101,7 @@ def insereFissureLongue_d (internalBoundary, meshFondFiss, meshFacePeau, meshFac
logging.info(text)
raise Exception(text)
return meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe
peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
_ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
return meshFacePeau, groupEdgesPeauFiss

View File

@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2020 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
#
"""Insertion de fissure longue - maillage face de fissure"""
import logging
import math
import SMESH
from salome.smesh import smeshBuilder
import salome
from .geomsmesh import smesh
from .putName import putName
def insereFissureLongue_e (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
profondeur, rayonPipe, \
mailleur="MeshGems"):
"""maillage face de fissure"""
logging.info('start')
meshFaceFiss = smesh.Mesh(faceFiss)
mesh_size = (profondeur - rayonPipe)/math.sqrt(3.0) # pour avoir deux couches de triangles equilateraux partout sur la fissure
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.MG_CADSurf)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( mesh_size )
hypo2d.SetMinSize( mesh_size/10. )
hypo2d.SetMaxSize( mesh_size*3. )
hypo2d.SetChordalError( mesh_size*0.25 )
hypo2d.SetVerbosity( 0 )
else:
algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D)
hypo2d = algo2d.Parameters()
hypo2d.SetMaxSize( mesh_size )
hypo2d.SetOptimize( 1 )
hypo2d.SetFineness( 2 )
hypo2d.SetMinSize( 2 )
hypo2d.SetQuadAllowed( 0 )
putName(algo2d.GetSubMesh(), "faceFiss")
putName(algo2d, "algo2d_faceFiss")
putName(hypo2d, "hypo2d_faceFiss")
#
algo1d = meshFaceFiss.UseExisting1DElements(geom=edgePeauFiss)
hypo1d = algo1d.SourceEdges([ groupEdgesPeauFiss ],0,0)
putName(algo1d.GetSubMesh(), "edgeFissPeau")
putName(algo1d, "algo1d_edgeFissPeau")
putName(hypo1d, "hypo1d_edgeFissPeau")
#
algo1d = meshFaceFiss.UseExisting1DElements(geom=groupEdgesFaceFissPipe)
hypo1d = algo1d.SourceEdges([ group_generFiss ],0,0)
putName(algo1d.GetSubMesh(), "edgeFissPeau")
putName(algo1d, "algo1d_edgeFissPeau")
putName(hypo1d, "hypo1d_edgeFissPeau")
_ = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE)
is_done = meshFaceFiss.Compute()
text = "meshFaceFiss.Compute"
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
return meshFaceFiss

View File

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2020 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
#
"""Insertion de fissure longue - maillage meshBoiteDefaut"""
import logging
import salome
from salome.smesh import smeshBuilder
import SMESH
from .geomsmesh import smesh
from .putName import putName
def insereFissureLongue_f (internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
mailleur="MeshGems"):
"""maillage meshBoiteDefaut"""
logging.info('start')
logging.info("insereFissureLongue_f (%s)", mailleur)
meshBoiteDefaut = smesh.Concatenate( [internalBoundary.GetMesh(), \
meshFondFiss.GetMesh(), \
meshFacePeau.GetMesh(), \
meshFaceFiss.GetMesh()], \
1, 1, 1e-05,False)
# pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
# on designe les faces de peau en quadrangles par le groupe "skinFaces"
group_faceFissOutPipe = None
group_faceFissInPipe = None
groups = meshBoiteDefaut.GetGroups()
for grp in groups:
if grp.GetType() == SMESH.FACE:
#if "internalBoundary" in grp.GetName():
# grp.SetName("skinFaces")
if grp.GetName() == "fisOutPi":
group_faceFissOutPipe = grp
elif grp.GetName() == "fisInPi":
group_faceFissInPipe = grp
# le maillage NETGEN ne passe pas toujours ==> on force l'usage de MG_Tetra
mailleur = "MeshGems"
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.MG_Tetra)
else:
algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN)
hypo3d = algo3d.MaxElementVolume(1000.0)
hypo3d.SetVerboseLevel( 0 )
hypo3d.SetStandardOutputLog( 0 )
hypo3d.SetRemoveLogOnSuccess( 1 )
putName(algo3d.GetSubMesh(), "boiteDefaut")
putName(algo3d, "algo3d_boiteDefaut")
putName(meshBoiteDefaut, "boiteDefaut")
is_done = meshBoiteDefaut.Compute()
text = "meshBoiteDefaut.Compute"
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
return meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe

View File

@ -0,0 +1,98 @@
# -*- 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
#
"""Les groupes de la fissure longue"""
import logging
import salome
import SMESH
from .geomsmesh import geompy
from .putName import putName
from .enleveDefaut import enleveDefaut
from .shapeSurFissure import shapeSurFissure
from .regroupeSainEtDefaut import RegroupeSainEtDefaut
from .triedreBase import triedreBase
# -----------------------------------------------------------------------------
def insereFissureLongue_g(nomFicFissure, fichierMaillageFissure, nomFicSain, maillageSain, \
meshBoiteDefaut, facePorteFissure, \
group_faceFissInPipe, group_faceFissOutPipe, \
zoneDefaut, zoneDefaut_skin, zoneDefaut_internalEdges, zoneDefaut_internalFaces):
"""Les groupes de la fissure longue"""
logging.info('start')
O, _, _, _ = triedreBase()
groups = maillageSain.GetGroups()
grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
coords1 = maillageSain.GetNodeXYZ(grps1[0].GetID(1))
coords2 = maillageSain.GetNodeXYZ(grps2[0].GetID(1))
logging.info("coords1 %s, coords2 %s",coords1, coords2)
_ = meshBoiteDefaut.GetMesh().UnionListOfGroups( [ group_faceFissOutPipe, group_faceFissInPipe ], 'FACE1' )
maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges)
putName(maillageSain, nomFicSain+"_coupe")
extrusionFaceFissure, normfiss = shapeSurFissure(facePorteFissure)
maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut, extrusionFaceFissure, facePorteFissure, 'COUDE')
groups = maillageComplet.GetGroups()
grps1 = [ grp for grp in groups if grp.GetName() == 'P1']
grps2 = [ grp for grp in groups if grp.GetName() == 'P2']
nodeid1 = maillageComplet.AddNode(coords1[0], coords1[1], coords1[2])
nodeid2 = maillageComplet.AddNode(coords2[0], coords2[1], coords2[2])
grps1[0].Add([nodeid1])
grps2[0].Add([nodeid2])
ma0d1 = maillageComplet.Add0DElement(nodeid1)
ma0d2 = maillageComplet.Add0DElement(nodeid2)
grpma0d1 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P1' )
_ = grpma0d1.Add( [ma0d1] )
grpma0d2 = maillageComplet.CreateEmptyGroup( SMESH.ELEM0D, 'P2' )
_ = grpma0d2.Add( [ma0d2] )
# grps = [ grp for grp in groups if grp.GetName() == 'affectedEdges']
# grps[0].SetName('affEdges')
# grps = [ grp for grp in groups if grp.GetName() == 'affectedFaces']
# grps[0].SetName('affFaces')
# grps = [ grp for grp in groups if grp.GetName() == 'affectedVolumes']
# grps[0].SetName('affVols')
maillageComplet.ConvertToQuadratic( 1 )
grps = [ grp for grp in groups if grp.GetName() == 'FONDFISS']
_ = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FONDFISS' )
grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
_ = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
plansim = geompy.MakePlane(O, normfiss, 10000)
fissnorm = geompy.MakeMirrorByPlane(normfiss, plansim)
grps = [ grp for grp in groups if grp.GetName() == 'FACE2']
_ = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1))
#isDone = maillageComplet.ReorientObject( grps[0] )
_ = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
maillageComplet.ExportMED(fichierMaillageFissure)
putName(maillageComplet, nomFicFissure)
logging.info("fichier maillage fissure %s", fichierMaillageFissure)
return maillageComplet

View File

@ -17,44 +17,45 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Recherche et classement des edges du tore par propagate"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- recherche et classement des edges du tore par propagate
def propagateTore(tore):
"""
Classement des edges du tore par une operation 'propagate'
"""Classement des edges du tore par une operation 'propagate'
@param tore partionné et coupé
@return (diams, circles, geners) edges dans le plan de fissure, edges demi circulaires,
edges selon la generatrice (liste de compounds)
"""
logging.info("start")
lencomp = []
lencomp = list()
compounds = geompy.Propagate(tore)
for i in range(len(compounds)):
#geomPublishInFather(initLog.debug, tore, compounds[i], 'edges' )
props = geompy.BasicProperties(compounds[i])
for objet in compounds:
#geomPublishInFather(initLog.debug, tore, objet, 'edges' )
props = geompy.BasicProperties(objet)
lencomp.append(props[0])
pass
# Remarque : on passe par min et max plutôt que faire lencomp.sort() pour garder l'ordre dans le tri suivant
minlen = min(lencomp)
maxlen = max(lencomp)
diams = []
geners = []
circles = []
for i in range(len(lencomp)):
if (lencomp[i]- minlen)/minlen < 0.01 :
diams.append(compounds[i])
elif (maxlen - lencomp[i])/lencomp[i] < 0.2 :
geners.append(compounds[i])
diams = list()
geners = list()
circles = list()
for i_aux, longueur in enumerate(lencomp):
if ( (longueur- minlen)/minlen < 0.01 ):
diams.append(compounds[i_aux])
elif ( (maxlen - longueur)/longueur < 0.2 ):
geners.append(compounds[i_aux])
else:
circles.append(compounds[i])
circles.append(compounds[i_aux])
geomPublishInFather(initLog.debug, tore, diams[0], 'diams0' )
geomPublishInFather(initLog.debug, tore, diams[1], 'diams1' )

View File

@ -18,12 +18,18 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Nommage des objets mesh (algorithme, hypothèse, subMesh)"""
from .geomsmesh import smesh
# -----------------------------------------------------------------------------
# --- nommage des objets mesh (algorithme, hypothèse, subMesh)
def putName (objmesh, name, i_suff=-1, i_pref=-1):
"""Nommage des objets mesh
@objmesh objet à nommer
@name le nom brut
@i_suff un éventuel suffixe
@i_pref un éventuel préfixe
"""
# suffixe éventuel :
if i_suff >= 0:
@ -36,4 +42,3 @@ def putName (objmesh, name, i_suff=-1, i_pref=-1):
name = prefixe + name
smesh.SetName(objmesh, name)

View File

@ -17,21 +17,24 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Remarque : cette focntion n'est jamais appelée ????"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
import math
import numpy as np
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
def mydot(a):
"""produit scalaire"""
return np.dot(a,a)
# -----------------------------------------------------------------------------
# --- groupe de quadrangles de face transformé en face géométrique par filling
def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
"""
@ -51,14 +54,14 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
isVecteurDefaut = True
vecteurDefaut = shapeFissureParams['vecteurDefaut']
fillings = [] # les faces reconstituées, découpées selon les arêtes vives
noeuds_bords = [] #
bords_Partages = [] # contient a la fin les courbes correspondant aux arêtes vives
fillconts = [] # les faces reconstituées, sans découpage selon les arêtes vives
idFilToCont = [] # index face découpée vers face sans découpe
fillings = list() # les faces reconstituées, découpées selon les arêtes vives
noeuds_bords = list() #
bords_Partages = list() # contient a la fin les courbes correspondant aux arêtes vives
fillconts = list() # les faces reconstituées, sans découpage selon les arêtes vives
idFilToCont = list() # index face découpée vers face sans découpe
iface = 0 # index face découpée
icont = 0 # index face continue
allNodeIds = meshQuad.GetNodesId()
while len(allNodeIds):
nodeIds = allNodeIds
@ -67,13 +70,13 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
if len(elems) == 1:
# un coin: un noeud, un element quadrangle
elem = elems[0]
break;
break
idStart = idNode # le noeud de coin
elemStart = elem # l'élément quadrangle au coin
xyz = meshQuad.GetNodeXYZ(idStart)
logging.debug("idStart %s, coords %s", idStart, str(xyz))
nodelines =[] # on va constituer une liste de lignes de points
nodelines = list() # on va constituer une liste de lignes de points
nextLine = True
ligneFinale = False
while nextLine:
@ -87,8 +90,8 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
agauche = True
ligneIncomplete = True # on commence une ligne de points
debutLigne = True
nodeline = []
elemline = []
nodeline = list()
elemline = list()
while ligneIncomplete: # compléter la ligne de points
nodeline.append(idNode)
allNodeIds.remove(idNode)
@ -148,10 +151,10 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
logging.debug("nodeline %s", nodeline)
logging.debug("elemline %s", elemline)
nodelines.append(nodeline)
# on a constitué une liste de lignes de points connexes
logging.debug("dimensions [%s, %s]", len(nodelines), len(nodeline))
logging.debug("dimensions [%s, %s]", len(nodelines), len(nodeline))
# stockage des coordonnées dans un tableau numpy
mat = np.zeros((len(nodelines), len(nodeline), 3))
for i, ligne in enumerate(nodelines):
@ -159,7 +162,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
mat[i,j] = meshQuad.GetNodeXYZ(nodeId)
logging.debug("matrice de coordonnées: \n%s",mat)
logging.debug("dimensions %s", mat.shape)
# recherche d'angles supérieurs a un seuil sur une ligne : angle entre deux vecteurs successifs
cosmin = math.cos(math.pi/4.) # TODO: angle reference en paramètre
vecx = mat[:, 1:, :] - mat[:, :-1, :] # vecteurs selon direction "x"
@ -186,11 +189,11 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
rupY = [x for x in range(len(nodelines)-2) if np.prod(ruptureY[x, :])]
logging.debug("lignes de rupture: %s",rupY)
if (len(rupX)*len(rupY)) > 0:
logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions,
logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions,
lors de la reconstitution des faces géométriques dans la zone remaillée""")
mats = []
bordsPartages = []
mats = list()
bordsPartages = list()
if (len(rupX)> 0):
rupX.append(mat.shape[1]-1)
for i, index in enumerate(rupX):
@ -220,8 +223,8 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
else:
mats.append(mat)
bordsPartages.append([0,0]) # les indices différents de 0 correspondent à des bords partagés
curvconts = []
curvconts = list()
for nmat, amat in enumerate(mats):
logging.debug("dimensions matrice %s: %s", nmat, amat.shape)
nbLignes = amat.shape[1] # pas de rupture, ou rupture selon des colonnes: on transpose
@ -229,13 +232,13 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
if len(rupY) > 0 : # rupture selon des lignes: pas de transposition
nbLignes = amat.shape[0]
nbCols = amat.shape[1]
curves = []
noeudsBords = []
curves = list()
noeudsBords = list()
for i in range(4):
noeudsBords.append([])
k = 0
for i in range(nbLignes):
nodeList = []
nodeList = list()
for j in range(nbCols):
#logging.debug("point[%s,%s] = (%s, %s, %s)",i,j,amat[i,j,0], amat[i,j,1], amat[i,j,2])
if len(rupY) > 0 : # pas de transposition
@ -263,7 +266,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
curve = geompy.MakeInterpol(nodeList, False, False)
#name = "curve_%d"%i
#geomPublish(initLog.debug, curve, name )
if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe
if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe
curvconts.append(nodeList)
curves.append(curve)
if bordsPartages[nmat][0] :
@ -282,7 +285,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
if centreFondFiss is not None:
logging.debug("orientation filling a l'aide du centre de fond de fissure")
vecteurDefaut = geompy.MakeVector(centreFondFiss, vertex)
if not isVecteurDefaut:
pointIn_x = 0.0
pointIn_y = 0.0
@ -301,7 +304,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
cdg = geompy.MakeVertex(pointIn_x, pointIn_y, pointIn_z)
logging.debug("orientation filling par point intérieur %s", (pointIn_x, pointIn_y, pointIn_z))
vecteurDefaut = geompy.MakeVector(cdg, vertex)
if 'convexe' in shapeFissureParams:
isConvexe = shapeFissureParams['convexe']
logging.debug("orientation filling par indication de convexité %s", isConvexe)
@ -310,7 +313,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
vecteurDefaut = geompy.MakeVector(cdg, vertex)
else:
vecteurDefaut = geompy.MakeVector(vertex, cdg)
if vecteurDefaut is not None:
geomPublish(initLog.debug, normal, "normFillOrig%d"%iface)
geomPublish(initLog.debug, vecteurDefaut, "fromInterieur%d"%iface)
@ -323,14 +326,14 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
noeuds_bords.append(noeudsBords)
idFilToCont.append(icont)
bords_Partages += bordsPartages
pass # --- loop on mats
# --- loop on mats
# --- reconstruction des faces continues à partir des listes de noeuds
# les courbes doivent suivre la courbure pour éviter les oscillations
if icont == iface - 1: # pas de découpe, on garde la même face
fillcont = fillings[-1]
else:
nbLignes = len(curvconts[0])
curves = []
curves = list()
for i in range(nbLignes):
nodes = [curvconts[j][i] for j in range(len(curvconts))]
curve = geompy.MakeInterpol(nodes, False, False)
@ -338,7 +341,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss):
fillcont = geompy.MakeFilling(geompy.MakeCompound(curves), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
geomPublish(initLog.debug, fillcont, "filcont%d"%icont )
fillconts.append(fillcont)
icont = icont+1
pass # --- loop while there are remaining nodes
icont = icont+1
# --- loop while there are remaining nodes
return fillings, noeuds_bords, bords_Partages, fillconts, idFilToCont

View File

@ -17,21 +17,21 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Groupe de quadrangles de face transformé en face géométrique par filling"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
import math
import numpy as np
def mydot(a):
return np.dot(a,a)
import GEOM
# -----------------------------------------------------------------------------
# --- groupe de quadrangles de face transformé en face géométrique par filling
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from . import initLog
def mydot(a):
"""produit scalaire"""
return np.dot(a,a)
def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
"""
@ -51,30 +51,31 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
isVecteurDefaut = True
vecteurDefaut = shapeFissureParams['vecteurDefaut']
fillings = [] # les faces reconstituées, découpées selon les arêtes vives
noeuds_bords = [] #
bords_Partages = [] # contient a la fin les courbes correspondant aux arêtes vives
fillconts = [] # les faces reconstituées, sans découpage selon les arêtes vives
idFilToCont = [] # index face découpée vers face sans découpe
fillings = list() # les faces reconstituées, découpées selon les arêtes vives
noeuds_bords = list() #
bords_Partages = list() # contient a la fin les courbes correspondant aux arêtes vives
fillconts = list() # les faces reconstituées, sans découpage selon les arêtes vives
idFilToCont = list() # index face découpée vers face sans découpe
iface = 0 # index face découpée
icont = 0 # index face continue
pisur2 = np.pi/2.0
pisur4 = np.pi/4.0
allNodeIds = meshQuad.GetNodesId()
while len(allNodeIds):
logging.debug("len(allNodeIds): %s ", len(allNodeIds))
nodeIds = allNodeIds
for idNode in nodeIds: # rechercher un coin
elems = meshQuad.GetNodeInverseElements(idNode)
if len(elems) == 1:
if ( len(elems) == 1 ):
# un coin: un noeud, un element quadrangle
elem = elems[0]
break;
idStart = idNode # le noeud de coin
elemStart = elem # l'élément quadrangle au coin
idStart = idNode # le noeud de coin
elemStart = elems[0] # l'élément quadrangle au coin
break
xyz = meshQuad.GetNodeXYZ(idStart)
logging.debug("idStart %s, coords %s", idStart, str(xyz))
nodelines =[] # on va constituer une liste de lignes de points
nodelines = list() # on va constituer une liste de lignes de points
nextLine = True
ligneFinale = False
while nextLine:
@ -88,8 +89,8 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
agauche = True
ligneIncomplete = True # on commence une ligne de points
debutLigne = True
nodeline = []
elemline = []
nodeline = list()
elemline = list()
while ligneIncomplete: # compléter la ligne de points
nodeline.append(idNode)
allNodeIds.remove(idNode)
@ -153,8 +154,8 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
longueur = [len(val) for val in nodelines]
logging.debug("longueur = %s", longueur)
# on a constitué une liste de lignes de points connexes
logging.debug("dimensions [%s, %s]", len(nodelines), len(nodeline))
logging.debug("dimensions [%s, %s]", len(nodelines), len(nodeline))
# stockage des coordonnées dans un tableau numpy
mat = np.zeros((len(nodelines), len(nodeline), 3))
for i, ligne in enumerate(nodelines):
@ -162,9 +163,9 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
mat[i,j] = meshQuad.GetNodeXYZ(nodeId)
logging.debug("matrice de coordonnées: \n%s",mat)
logging.debug("dimensions %s", mat.shape)
# recherche d'angles supérieurs a un seuil sur une ligne : angle entre deux vecteurs successifs
cosmin = math.cos(math.pi/4.) # TODO: angle reference en paramètre
cosmin = np.cos(pisur4) # TODO: angle reference en paramètre
vecx = mat[:, 1:, :] - mat[:, :-1, :] # vecteurs selon direction "x"
vx0 = vecx[:, :-1, :] # vecteurs amont
vx1 = vecx[:, 1:, :] # vecteurs aval
@ -189,11 +190,11 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
rupY = [x for x in range(len(nodelines)-2) if np.prod(ruptureY[x, :])]
logging.debug("lignes de rupture: %s",rupY)
if (len(rupX)*len(rupY)) > 0:
logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions,
logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions,
lors de la reconstitution des faces géométriques dans la zone remaillée""")
mats = []
bordsPartages = []
mats = list()
bordsPartages = list()
if (len(rupX)> 0):
rupX.append(mat.shape[1]-1)
for i, index in enumerate(rupX):
@ -223,8 +224,8 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
else:
mats.append(mat)
bordsPartages.append([0,0]) # les indices différents de 0 correspondent à des bords partagés
curvconts = []
curvconts = list()
for nmat, amat in enumerate(mats):
logging.debug("dimensions matrice %s: %s", nmat, amat.shape)
nbLignes = amat.shape[1] # pas de rupture, ou rupture selon des colonnes: on transpose
@ -232,13 +233,13 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
if len(rupY) > 0 : # rupture selon des lignes: pas de transposition
nbLignes = amat.shape[0]
nbCols = amat.shape[1]
curves = []
noeudsBords = []
curves = list()
noeudsBords = list()
for i in range(4):
noeudsBords.append([])
k = 0
for i in range(nbLignes):
nodeList = []
nodeList = list()
for j in range(nbCols):
#logging.debug("point[%s,%s] = (%s, %s, %s)",i,j,amat[i,j,0], amat[i,j,1], amat[i,j,2])
if len(rupY) > 0 : # pas de transposition
@ -266,7 +267,7 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
curve = geompy.MakeInterpol(nodeList, False, False)
#name = "curve_%d"%i
#geomPublish(initLog.debug, curve, name )
if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe
if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe
curvconts.append(nodeList)
curves.append(curve)
if bordsPartages[nmat][0] :
@ -285,7 +286,7 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
if centreFondFiss is not None:
logging.debug("orientation filling a l'aide du centre de fond de fissure")
vecteurDefaut = geompy.MakeVector(centreFondFiss, vertex)
if not isVecteurDefaut:
pointIn_x = 0.0
pointIn_y = 0.0
@ -304,7 +305,7 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
cdg = geompy.MakeVertex(pointIn_x, pointIn_y, pointIn_z)
logging.debug("orientation filling par point intérieur %s", (pointIn_x, pointIn_y, pointIn_z))
vecteurDefaut = geompy.MakeVector(cdg, vertex)
if 'convexe' in shapeFissureParams:
isConvexe = shapeFissureParams['convexe']
logging.debug("orientation filling par indication de convexité %s", isConvexe)
@ -313,11 +314,11 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
vecteurDefaut = geompy.MakeVector(cdg, vertex)
else:
vecteurDefaut = geompy.MakeVector(vertex, cdg)
if vecteurDefaut is not None:
geomPublish(initLog.debug, normal, "normFillOrig%d"%iface)
geomPublish(initLog.debug, vecteurDefaut, "fromInterieur%d"%iface)
if geompy.GetAngleRadians(vecteurDefaut, normal) > math.pi/2.0:
if ( geompy.GetAngleRadians(vecteurDefaut, normal) > pisur2 ):
filling = geompy.ChangeOrientation(filling)
geomPublish(initLog.debug, filling, "filling%d"%iface )
#geompy.ExportBREP(filling, "filling.brep")
@ -327,14 +328,14 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
idFilToCont.append(icont)
bords_Partages += bordsPartages
logging.debug("bords_Partages = %s", bords_Partages)
pass # --- loop on mats
# --- loop on mats
# --- reconstruction des faces continues à partir des listes de noeuds
# les courbes doivent suivre la courbure pour éviter les oscillations
if icont == iface - 1: # pas de découpe, on garde la même face
fillcont = fillings[-1]
else:
nbLignes = len(curvconts[0])
curves = []
curves = list()
for i in range(nbLignes):
nodes = [curvconts[j][i] for j in range(len(curvconts))]
curve = geompy.MakeInterpol(nodes, False, False)
@ -342,7 +343,7 @@ def quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss):
fillcont = geompy.MakeFilling(geompy.MakeCompound(curves), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
geomPublish(initLog.debug, fillcont, "filcont%d"%icont )
fillconts.append(fillcont)
icont = icont+1
pass # --- loop while there are remaining nodes
icont = icont+1
# --- loop while there are remaining nodes
return fillings, noeuds_bords, bords_Partages, fillconts, idFilToCont

View File

@ -17,18 +17,17 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""
Created on Tue Jun 24 09:14:13 2014
@author: I48174
"""
"""Remarque : cette focntion n'est jamais appelée ????"""
import logging
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
from .listOfExtraFunctions import createNewMeshesFromCorner
from .listOfExtraFunctions import createLinesFromMesh
@ -37,8 +36,7 @@ from .listOfExtraFunctions import createLinesFromMesh
# --- groupe de quadrangles de face transformé en face géométrique par filling
def quadranglesToShapeWithCorner(meshQuad, shapeDefaut, listOfCorners):
""" """
# TODO: rédiger la docstring
"""TODO: rédiger la docstring"""
logging.info("start")

View File

@ -17,20 +17,17 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Maillage sain sans la zone de defaut"""
import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
import SMESH
def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None):
"""Maillage sain sans la zone de defaut
from .geomsmesh import geompy
from .geomsmesh import smesh
TODO: a completer
"""
def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None):
"""Maillage sain sans la zone de defaut"""
logging.info('Concatenation')
maillageComplet = smesh.Concatenate([maillageSain.GetMesh(), blocComplet.GetMesh()], 1, 1, 1e-05,False)
@ -50,7 +47,8 @@ def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGe
# --- TODO: fiabiliser l'orientation dans le cas general
if normal is None:
normal = smesh.MakeDirStruct( 0, 0, 1 )
logging.debug('après normal = {}'.format(normal))
texte = 'après normal = {}'.format(normal)
logging.debug(texte)
maillageComplet.Reorient2D( fisInPi, normal, [0,0,0])
logging.debug('après Reorient2D In')
maillageComplet.Reorient2D( fisOutPi, normal, [0,0,0])
@ -58,7 +56,7 @@ def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGe
shapes = list()
if extrusionFaceFissure is not None:
subIds = geompy.SubShapeAllIDs(extrusionFaceFissure, geompy.ShapeType["SOLID"])
if len(subIds) > 1:
if ( len(subIds) > 1 ):
shapes = geompy.ExtractShapes(extrusionFaceFissure, geompy.ShapeType["SOLID"], False)
else:
shapes = [extrusionFaceFissure]
@ -72,7 +70,7 @@ def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGe
grpEdges = list()
grpFaces = list()
grpVolumes = list()
if len(shapes) == 0:
if not shapes:
shapes = [None] # calcul uniquement avec les normales des faces mailles de la fissure
for i, aShape in enumerate(shapes):
texte = "Detection elements affectes par le dedoublement de la face n° {}".format(i)

View File

@ -17,14 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Restriction de la face de fissure au domaine solide"""
import logging
import traceback
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .sortFaces import sortFaces
import traceback
from .fissError import fissError
def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
@ -33,13 +37,16 @@ def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
partition face fissure étendue par fillings
"""
logging.info('start')
partShapeDefaut = geompy.MakePartition([shapeDefaut], facesDefaut, [], [], geompy.ShapeType["FACE"], 0, [], 0)
geomPublish(initLog.debug, partShapeDefaut, 'partShapeDefaut')
facesPartShapeDefaut = geompy.ExtractShapes(partShapeDefaut, geompy.ShapeType["FACE"], False)
if pointInterne is not None:
distfaces = [(geompy.MinDistance(face,pointInterne), i, face) for i, face in enumerate(facesPartShapeDefaut)]
distfaces.sort()
logging.debug("selection de la face la plus proche du point interne, distance={}".format(distfaces[0][0]))
texte = "selection de la face la plus proche du point interne, distance={}".format(distfaces[0][0])
logging.debug(texte)
facesPortFissure = distfaces[0][2]
else:
try:
@ -52,8 +59,10 @@ def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
texte += "<li>le prémaillage de la face de fissure est trop grossier, les mailles à enlever dans le maillage sain "
texte += "n'ont pas toutes été détectées.</li></ul>"
raise fissError(traceback.extract_stack(),texte)
logging.debug("surfaces faces fissure étendue, min {}, max {}".format(minSurf, maxSurf))
texte = "surfaces faces fissure étendue, min {}, max {}".format(minSurf, maxSurf)
logging.debug(texte)
facesPortFissure = facesPartShapeDefautSorted[-1]
geomPublish(initLog.debug, facesPortFissure, "facesPortFissure")
return facesPortFissure

View File

@ -17,18 +17,19 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Opérateur de rotation translation d'un objet centré à l'origine"""
import logging
import math
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import math
from .triedreBase import triedreBase
O, OX, OY, OZ = triedreBase()
# -----------------------------------------------------------------------------
# --- operateur de rotation translation d'un objet centré à l'origine
from . import initLog
from .triedreBase import triedreBase
O, OX, OY, OZ = triedreBase()
def rotTrans(objet, orientation, point, normal, trace = False):
"""
@ -41,33 +42,34 @@ def rotTrans(objet, orientation, point, normal, trace = False):
@return trans : objet transformé (geomObject)
"""
logging.info("start")
planXY = geompy.MakePlaneLCS(None, 2000, 1)
projXY = geompy.MakeProjection(normal, planXY)
[v1,v2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False)
xyz1 = geompy.PointCoordinates(v1)
xyz2 = geompy.PointCoordinates(v2)
[v_1,v_2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False)
xyz1 = geompy.PointCoordinates(v_1)
xyz2 = geompy.PointCoordinates(v_2)
x = xyz2[0] - xyz1[0]
y = xyz2[1] - xyz1[1]
sinalpha = y / math.sqrt(x*x + y*y)
cosalpha = x / math.sqrt(x*x + y*y)
alpha = math.asin(sinalpha)
if cosalpha < 0:
if ( cosalpha < 0. ):
alpha = math.pi -alpha
beta = geompy.GetAngleRadians(OZ, normal)
[v1,v2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False)
xyz1 = geompy.PointCoordinates(v1)
xyz2 = geompy.PointCoordinates(v2)
z = xyz2[2] - xyz1[2]
if z < 0:
[v_1,v_2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False)
xyz1 = geompy.PointCoordinates(v_1)
xyz2 = geompy.PointCoordinates(v_2)
if ( (xyz2[2] - xyz1[2]) < 0 ):
beta = math.pi -beta
rot0 = geompy.MakeRotation(objet, OX, orientation*math.pi/180.0)
rot1 = geompy.MakeRotation(rot0, OZ, alpha)
axe2 = geompy.MakeRotation(OY, OZ, alpha)
rot2 = geompy.MakeRotation(rot1, axe2, beta -math.pi/2.)
logging.debug("alpha",alpha)
logging.debug("beta",beta)
logging.debug("alpha %f",alpha)
logging.debug("beta %f",beta)
if trace:
geomPublish(initLog.debug, rot1, 'rot1' )
geomPublish(initLog.debug, axe2, 'axe2' )
@ -75,4 +77,5 @@ def rotTrans(objet, orientation, point, normal, trace = False):
xyz = geompy.PointCoordinates(point)
trans = geompy.MakeTranslation(rot2, xyz[0], xyz[1], xyz[2])
return trans

View File

@ -17,28 +17,26 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""construction d'une shape de dectection des éléments à modifier suite à la la duplication des noeuds de la face fissure (d'un coté de la face)"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- construction d'une shape de dectection des éléments à modifier suite à la la duplication des noeuds de la face fissure (d'un coté de la face)
def shapeSurFissure(facesFissure):
"""
TODO: a completer, Normaliser les vecteurs et ponderer par les surfaces...
"""
"""Normaliser les vecteurs et ponderer par les surfaces..."""
logging.info('start')
normal = None
subIds = geompy.SubShapeAllIDs(facesFissure, geompy.ShapeType["FACE"])
if len(subIds) > 1:
if ( len(subIds) > 1 ):
logging.debug("plusieurs faces de fissure")
faces = geompy.ExtractShapes(facesFissure, geompy.ShapeType["FACE"], False)
extrusions = []
for n,face in enumerate(faces):
extrusions = list()
for face in faces:
vertex = geompy.MakeVertexOnSurface(face, 0.5, 0.5)
normal = geompy.GetNormal(face, vertex)
extrusion = geompy.MakePrismVecH(face, normal, 100)
@ -50,7 +48,7 @@ def shapeSurFissure(facesFissure):
vertex = geompy.MakeVertexOnSurface(face, 0.5, 0.5)
normal = geompy.GetNormal(face, vertex)
extrusionFaceFissure = geompy.MakePrismVecH(facesFissure, normal, 100)
geomPublish(initLog.debug, extrusionFaceFissure, "extrusionFaceFissure")
return extrusionFaceFissure, normal
geomPublish(initLog.debug, extrusionFaceFissure, "extrusionFaceFissure")
return extrusionFaceFissure, normal

View File

@ -17,42 +17,40 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face)"""
import logging
import GEOM
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face)
def shapesSurFissure(blocPartition, plane1, faceFissure, gencnt):
"""
TODO: a completer
"""
"""Identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face)"""
logging.info('start')
shapesAModifier = []
vertex = geompy.MakeVertexOnSurface(plane1, 0.5, 0.5)
normal = geompy.GetNormal(plane1, vertex)
extrusion = geompy.MakePrismVecH(plane1, normal, 100)
sharedSolids = []
sharedSolids = list()
solids= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("SOLID"), GEOM.ST_ONIN )
for solid in solids:
sharedSolids += geompy.GetSharedShapes(faceFissure, solid, geompy.ShapeType["SOLID"])
logging.debug("sharedSolids %s",sharedSolids)
sharedFaces = []
sharedFaces = list()
faces= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("FACE"), GEOM.ST_ONIN )
for face in faces:
sharedFaces += geompy.GetSharedShapes(faceFissure, face, geompy.ShapeType["FACE"])
logging.debug("sharedFaces %s",sharedFaces)
sharedEdges = []
sharedEdges = list()
edges= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("EDGE"), GEOM.ST_ONIN )
for edge in edges:
if not edge.IsSame(gencnt):
sharedEdges += geompy.GetSharedShapes(faceFissure, edge, geompy.ShapeType["EDGE"])
logging.debug("sharedEdges %s",sharedEdges)
shapesAModifier = [ sharedSolids, sharedFaces, sharedEdges]
return shapesAModifier
return [ sharedSolids, sharedFaces, sharedEdges ]

View File

@ -17,10 +17,10 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""tri par longueur d'edges"""
import logging
from .geomsmesh import geompy
def sortEdges(edgesToSort):
@ -29,6 +29,6 @@ def sortEdges(edgesToSort):
l_length = [(geompy.BasicProperties(edge)[0], i, edge) for i, edge in enumerate(edgesToSort)]
l_length.sort()
edgesSorted = [edge for length, i, edge in l_length]
edgesSorted = [edge for _, i, edge in l_length]
return edgesSorted, l_length[0][0], l_length[-1][0]

View File

@ -17,7 +17,6 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""tri par surface de faces"""
import logging
@ -29,6 +28,6 @@ def sortFaces(facesToSort):
l_surfaces = [(geompy.BasicProperties(face)[1], i, face) for i, face in enumerate(facesToSort)]
l_surfaces.sort()
facesSorted = [face for surf, i, face in l_surfaces]
facesSorted = [face for _, i, face in l_surfaces]
return facesSorted, l_surfaces[0][0], l_surfaces[-1][0]

View File

@ -17,15 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""tri par longueur des 3 generatrices"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- tri par longueur des 3 generatrices
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from . import initLog
def sortGeneratrices(tore, geners):
"""
@ -38,24 +37,23 @@ def sortGeneratrices(tore, geners):
genx = geompy.ExtractShapes(geners[0], geompy.ShapeType["EDGE"], True)
lenx = []
for i in range(len(genx)):
props = geompy.BasicProperties(genx[i])
lenx = list()
for gene in genx:
props = geompy.BasicProperties(gene)
lenx.append(props[0])
pass
minlen = min(lenx)
maxlen = max(lenx)
genext=None
gencnt=None
genint=None
for i in range(len(genx)):
if lenx[i] == minlen:
genint = genx[i]
elif lenx[i] == maxlen:
genext = genx[i]
for i_aux, gene in enumerate(genx):
if lenx[i_aux] == minlen:
genint = gene
elif lenx[i_aux] == maxlen:
genext = gene
else:
gencnt= genx[i]
pass
gencnt= gene
geomPublishInFather(initLog.debug, tore, genext, 'genext' )
geomPublishInFather(initLog.debug, tore, genint, 'genint' )

View File

@ -17,21 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""tri par volume de solides"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- tri par volume de solides
def sortSolids(solidsToSort):
"""
tri des solides par volume
"""
"""tri des solides par volume"""
logging.info('start')
volSolids = [(geompy.BasicProperties(solid)[2], i, solid) for i, solid in enumerate(solidsToSort)]
volSolids.sort()
solidsSorted = [solid for vol, i, solid in volSolids]
return solidsSorted, volSolids[0][0], volSolids[-1][0]
solidsSorted = [solid for _, i, solid in volSolids]
return solidsSorted, volSolids[0][0], volSolids[-1][0]