Merge branch 'gni/evolution'

Conventions python3
This commit is contained in:
GERALD NICOLAS 2021-04-02 13:50:12 +02:00
commit 4e6f2284a4
118 changed files with 3535 additions and 2811 deletions

View File

@ -113,7 +113,7 @@ class cubeAngle(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -108,7 +108,7 @@ class cylindre(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -122,7 +122,7 @@ class ellipse_1(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -116,7 +116,7 @@ class eprouvetteCourbe(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -113,7 +113,7 @@ class eprouvetteDroite(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -111,7 +111,7 @@ class faceGauche(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -113,7 +113,7 @@ class faceGauche_2(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -118,7 +118,7 @@ class tube(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -119,7 +119,7 @@ class vis_1(fissureGenerique):
mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

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
@ -108,7 +127,6 @@ SET(plugin_SCRIPTS
sortGeneratrices.py
sortSolids.py
substractSubShapes.py
testgmu.py
toreFissure.py
triedreBase.py
trouveEdgesFissPeau.py

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""init de la classe"""
import os
from . import initLog

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Ajustement precis des points sur edgesPipeFissureExterneC"""
import logging
@ -25,13 +26,11 @@ from .findWireIntermediateVertices import findWireIntermediateVertices
from .projettePointSurCourbe import projettePointSurCourbe
def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne, gptsdisks, idisklim):
"""
ajustement precis des points sur edgesPipeFissureExterneC
"""
"""Ajustement precis des points sur edgesPipeFissureExterneC"""
logging.info('start')
edgesPFE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False)
verticesPFE = findWireIntermediateVertices(wirePipeFissureExterne) # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe)
verticesPFE, _ = findWireIntermediateVertices(wirePipeFissureExterne) # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe)
idiskmin = idisklim[0] + 1 # on ne prend pas le disque sur la peau, déjà ajusté
idiskmax = idisklim[1] # on ne prend pas le disque sur la peau, déjà ajusté
idiskint = []
@ -39,8 +38,8 @@ def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne
distPtVt = []
for idisk in range(idiskmin, idiskmax):
gptdsk = gptsdisks[idisk]
pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe
distPtVt.append((geompy.MinDistance(pt, vtx), idisk))
point = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe
distPtVt.append((geompy.MinDistance(point, vtx), idisk))
distPtVt.sort()
idiskint.append(distPtVt[0][1])
gptsdisks[idiskint[-1]][0][-1] = vtx
@ -50,12 +49,12 @@ def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne
break
logging.debug("ajustement point sur edgePipeFissureExterne: %s", idisk)
gptdsk = gptsdisks[idisk]
pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe
distPtEd = [(geompy.MinDistance(pt, edgePFE), k, edgePFE) for k, edgePFE in enumerate(edgesPFE)]
point = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe
distPtEd = [(geompy.MinDistance(point, edgePFE), k, edgePFE) for k, edgePFE in enumerate(edgesPFE)]
distPtEd.sort()
edgePFE = distPtEd[0][2]
u = projettePointSurCourbe(pt, edgePFE)
ptproj = geompy.MakeVertexOnCurve(edgePFE, u)
point_bis = projettePointSurCourbe(point, edgePFE)
ptproj = geompy.MakeVertexOnCurve(edgePFE, point_bis)
gptsdisks[idisk][0][-1] = ptproj
return gptsdisks
return gptsdisks

View File

@ -17,22 +17,20 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""bloc defaut"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- bloc defaut
def blocDefaut(blocDim):
"""
Le bloc contenant la fissure est un cube construit centre a l'origine, dont on donne la demi arete.
""" Le bloc contenant la fissure est un cube construit centre a l'origine, dont on donne la demi arete.
@param blocdim : demi arete
@return cube (geomObject)
"""
logging.info("start")
geomObj_1 = geompy.MakeVertex(-blocDim, -blocDim, -blocDim)
geomObj_2 = geompy.MakeVertex( blocDim, blocDim, blocDim)
Box = geompy.MakeBoxTwoPnt(geomObj_1, geomObj_2)
#geompy.addToStudy( Box_1, 'Box_1' )
return Box
point_1 = geompy.MakeVertex(-blocDim, -blocDim, -blocDim)
point_2 = geompy.MakeVertex( blocDim, blocDim, blocDim)
le_cube = geompy.MakeBoxTwoPnt(point_1, point_2)
return le_cube

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Préparation maillage du pipe"""
import logging
import math
@ -27,7 +28,7 @@ from .geomsmesh import smesh
def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
centreFondFiss, wireFondFiss, wirePipeFiss,
lenSegPipe, rayonPipe, nbsegCercle, nbsegRad):
"""preparation maillage du pipe :
"""Préparation maillage du pipe :
- détections des points a respecter : jonction des edges/faces constituant
la face de fissure externe au pipe
@ -59,7 +60,7 @@ def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
meshFondExt = smesh.Mesh(wireFondFiss)
algo1d = meshFondExt.Segment()
hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure
_ = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure
is_done = meshFondExt.Compute()
text = "calculePointsAxiauxPipe meshFondExt.Compute"
@ -75,11 +76,11 @@ def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
for nodeId in allNodeIds:
xyz = meshFondExt.GetNodeXYZ(nodeId)
#logging.debug("nodeId %s, coords %s", nodeId, str(xyz))
pt = geompy.MakeVertex(xyz[0], xyz[1], xyz[2])
u, PointOnEdge, EdgeInWireIndex = geompy.MakeProjectionOnWire(pt, wireFondFiss) # u compris entre 0 et 1
point = geompy.MakeVertex(xyz[0], xyz[1], xyz[2])
parametre, _, EdgeInWireIndex = geompy.MakeProjectionOnWire(point, wireFondFiss) # parametre compris entre 0 et 1
edgeOrder = edgesIdByOrientation[EdgeInWireIndex]
ptGSdic[(edgeOrder, EdgeInWireIndex, u)] = pt
#logging.debug("nodeId %s, u %s", nodeId, str(u))
ptGSdic[(edgeOrder, EdgeInWireIndex, parametre)] = point
#logging.debug("nodeId %s, parametre %s", nodeId, str(parametre))
usort = sorted(ptGSdic)
logging.debug("nombre de points obtenus par deflexion %s",len(usort))
@ -88,10 +89,10 @@ def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
normals = list()
for edu in usort:
ied = edu[1]
u = edu[2]
parametre = edu[2]
vertcx = ptGSdic[edu]
norm = geompy.MakeTangentOnCurve(edgesFondFiss[ied], u)
plan = geompy.MakePlane(vertcx, norm, 3*rayonPipe)
norm = geompy.MakeTangentOnCurve(edgesFondFiss[ied], parametre)
plan = geompy.MakePlane(vertcx, norm, 3.*rayonPipe)
part = geompy.MakePartition([plan], [wirePipeFiss], list(), list(), geompy.ShapeType["VERTEX"], 0, list(), 0)
liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True)
if len(liste) == 5: # 4 coins du plan plus intersection recherchée
@ -117,29 +118,31 @@ def calculePointsAxiauxPipe(edgesFondFiss, edgesIdByOrientation, facesDefaut,
# --- points géométriques
gptsdisks = list() # vertices géométrie de tous les disques
raydisks = [list() for i in range(nbsegCercle)]
for i, centres_i in enumerate(centres): # boucle sur les disques
raydisks = [list() for _ in range(nbsegCercle)]
for indice, centres_i in enumerate(centres): # boucle sur les disques
gptdsk = list() # vertices géométrie d'un disque
vertcx = centres_i
vertpx = origins[i]
normal = normals[i]
vertpx = origins[indice]
normal = normals[indice]
vec1 = geompy.MakeVector(vertcx, vertpx)
points = [vertcx] # les points du rayon de référence
dist_0 = rayonPipe/float(nbsegRad)
for j in range(nbsegRad):
pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, (j+1)*float(rayonPipe)/nbsegRad)
points.append(pt)
point = geompy.MakeTranslationVectorDistance(vertcx, vec1, (j+1)*dist_0)
points.append(point)
gptdsk.append(points)
pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe)
rayon = geompy.MakeLineTwoPnt(vertcx, pt)
point = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe)
rayon = geompy.MakeLineTwoPnt(vertcx, point)
raydisks[0].append(rayon)
angle_0 = 2.*math.pi/float(nbsegCercle)
for k in range(nbsegCercle-1):
angle = (k+1)*2*math.pi/nbsegCercle
angle = float(k+1)*angle_0
pts = [vertcx] # les points d'un rayon obtenu par rotation
for j in range(nbsegRad):
pt = geompy.MakeRotation(points[j+1], normal, angle)
pts.append(pt)
point = geompy.MakeRotation(points[j+1], normal, angle)
pts.append(point)
gptdsk.append(pts)
ray = geompy.MakeRotation(rayon, normal, angle)
raydisks[k+1].append(ray)

View File

@ -20,16 +20,17 @@
"""Cas standard"""
import os
from .geomsmesh import geompy, smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import logging
import math
import GEOM
import SALOMEDS
import SMESH
import logging
from .geomsmesh import geompy, smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .fissureGenerique import fissureGenerique
@ -88,7 +89,7 @@ class casStandard(fissureGenerique):
def genereMaillageSain(self, geometriesSaines, meshParams):
logging.info("genereMaillageSain %s", self.nomCas)
([objetSain], status) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain'])
([objetSain], _) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain'])
smesh.SetName(objetSain.GetMesh(), 'objetSain')
return [objetSain, True] # True : maillage hexa
@ -175,7 +176,7 @@ class casStandard(fissureGenerique):
mailleur="MeshGems"):
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -17,17 +17,15 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Teste si l'opération de partition a produit une modification"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- teste si l'opération de partition a produit une modification
def checkDecoupePartition(shapes, part):
"""
Teste si l'opération de partition a produit une découpe
(plus de shapes dans la partition).
"""Teste si l'opération de partition a produit une découpe (plus de shapes dans la partition).
Résultat non garanti si recouvrement des shapes d'origine.
@param shapes : liste des shapes d'origine
@param part : résultat de la partition
@ -35,25 +33,25 @@ def checkDecoupePartition(shapes, part):
"""
logging.info('start')
# TODO: ShapeInfo donne des résultats faux (deux faces au lieu de une)
isPart = False
orig = {}
orig = dict()
for shape in shapes:
info = geompy.ShapeInfo(shape)
logging.debug("shape info %s", info)
for k in ['VERTEX', 'EDGE', 'FACE', 'SOLID']:
if k in list(orig.keys()):
orig[k] += info[k]
for type_shape in ['VERTEX', 'EDGE', 'FACE', 'SOLID']:
if type_shape in orig:
orig[type_shape] += info[type_shape]
else:
orig[k] = info[k]
orig[type_shape] = info[type_shape]
logging.debug("original shapes info %s", orig)
info = geompy.ShapeInfo(part)
logging.debug("partition info %s", info)
for k in ['VERTEX', 'EDGE', 'FACE', 'SOLID']:
if orig[k] < info[k]:
isPart = True
decoupe = False
for type_shape in ['VERTEX', 'EDGE', 'FACE', 'SOLID']:
if orig[type_shape] < info[type_shape]:
decoupe = True
break
logging.debug("partition modifie l'original %s", isPart)
return isPart
logging.debug("partition modifie l'original %s", decoupe)
return decoupe

View File

@ -17,25 +17,25 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""subShapes communes à deux listes"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- subShapes communes à deux listes
def commonSubShapes(obj, sub1, sub2):
"""
liste de subshapes communes
"""
"""liste de subshapes communes"""
logging.info("start")
idsub1 = {}
subList = []
for s in sub1:
idsub1[geompy.GetSubShapeID(obj, s)] = s
for s in sub2:
idsub = geompy.GetSubShapeID(obj, s)
if idsub in list(idsub1.keys()):
subList.append(s)
logging.debug("subList=%s", subList)
return subList
idsub1 = dict()
for subshape in sub1:
idsub1[geompy.GetSubShapeID(obj, subshape)] = subshape
l_subshapes = list()
for subshape in sub2:
idsub = geompy.GetSubShapeID(obj, subshape)
if idsub in idsub1:
l_subshapes.append(subshape)
logging.debug("l_subshapes=%s", l_subshapes)
return l_subshapes

View File

@ -17,36 +17,36 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""compoundFromList"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
def compoundFromList(elements, nom=None):
"""compoundFromList"""
logging.debug('start')
shapeList = list()
for a in elements:
if not isinstance(a, list):
shapeList.append(a)
l_shapes = list()
for elem in elements:
if not isinstance(elem, list):
l_shapes.append(elem)
else:
if a[0] is not None:
shapeList.append(a[0])
if elem[0] is not None:
l_shapes.append(elem[0])
if nom is not None:
for i,a in enumerate(shapeList):
nomi = nom +"%d"%i
for indice, elem in enumerate(l_shapes):
nomi = nom +"%d"%indice
logging.debug('nom: %s',nomi)
geomPublish(initLog.debug, a, nomi)
geomPublish(initLog.debug, elem, nomi)
shapeCompound = None
if len(shapeList) > 0:
shapeCompound =geompy.MakeCompound(shapeList)
if l_shapes:
shapeCompound = geompy.MakeCompound(l_shapes)
nomc = "compound_%s"%nom
geomPublish(initLog.debug, shapeCompound, nomc)
return shapeCompound

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

@ -20,14 +20,17 @@
"""procédure complète de construction d'une fissure générale"""
import logging
from . import initLog
import salome
from salome.smesh import smeshBuilder
import GEOM
import SMESH
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .orderEdgesFromWire import orderEdgesFromWire
from .restreintFaceFissure import restreintFaceFissure
@ -53,10 +56,11 @@ from .construitFissureGenerale_c import construitFissureGenerale_c
def construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step=-1, mailleur="MeshGems"):
step=-1, mailleur="MeshGems", nro_cas=-1):
"""procédure complète fissure générale"""
logging.info('start')
logging.info("Usage du mailleur %s", mailleur)
logging.info("pour le cas %d", nro_cas)
shapeDefaut = shapesFissure[0] # faces de fissure, débordant
@ -195,7 +199,7 @@ def construitFissureGenerale(shapesFissure, shapeFissureParams, \
facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
mailleur)
mailleur, nro_cas)
# --- regroupement des maillages du défaut

View File

@ -22,13 +22,15 @@
import os
import logging
import salome
from .geomsmesh import geompy
import GEOM
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import GEOM
import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .putName import putName
from .enleveDefaut import enleveDefaut
from .shapeSurFissure import shapeSurFissure

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

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2021 EDF R&D
#
# This library is free software; you can redistribute it and/or
@ -16,25 +17,30 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Les groupes des edges des cercles débouchants"""
from blocFissure import gmu
from .initEtude import initEtude
initEtude()
from .triedreBase import triedreBase
O, OX, OY, OZ = triedreBase()
import logging
from .distance2 import distance2
a=[10, 20, 30]
b=[5, 7, 3]
c=distance2(a,b)
def construitMaillagePipe_b(idisk, \
idisklim, nbsegCercle, \
meshPipe, mptdsk, \
edgeCircPipe0Group, edgeCircPipe1Group):
"""Les groupes des edges des cercles débouchants"""
#logging.info('start')
import unittest
from blocFissure.gmu import initLog
initLog.setUnitTests()
from blocFissure.gmu import distance2
suite = unittest.TestLoader().loadTestsFromTestCase(distance2.Test_distance2)
unittest.TextTestRunner(verbosity=2).run(suite)
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,21 +17,23 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""peau et face de fissure
partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée
il peut y avoir plusieurs faces externes, dont certaines sont découpées par la fissure
liste de faces externes : facesDefaut
liste de partitions face externe - fissure : partitionPeauFissFond (None quand pas d'intersection)
"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .checkDecoupePartition import checkDecoupePartition
# -----------------------------------------------------------------------------
# --- peau et face de fissure
#
# --- partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée
# il peut y avoir plusieurs faces externes, dont certaines sont découpées par la fissure
# liste de faces externes : facesDefaut
# liste de partitions face externe - fissure : partitionPeauFissFond (None quand pas d'intersection)
from .checkDecoupePartition import checkDecoupePartition
def construitPartitionsPeauFissure(facesDefaut, fissPipe):
"""partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée.
@ -47,8 +49,8 @@ def construitPartitionsPeauFissure(facesDefaut, fissPipe):
ipart = 0
for filling in facesDefaut:
part = geompy.MakePartition([fissPipe, filling], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
isPart = checkDecoupePartition([fissPipe, filling], part)
if isPart: # on recrée la partition avec toutes les faces filling en outil pour avoir une face de fissure correcte
# on recrée la partition avec toutes les faces filling en outil pour avoir une face de fissure correcte
if checkDecoupePartition([fissPipe, filling], part):
otherFD = [fd for fd in facesDefaut if fd != filling]
if otherFD:
fissPipePart = geompy.MakePartition([fissPipe], otherFD, list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)

View File

@ -17,35 +17,34 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""création des points du maillage du pipe sur la face de peau"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .projettePointSurCourbe import projettePointSurCourbe
def creePointsPipePeau(listEdges, idFacesDebouchantes, idFillingFromBout,
ptEdgeFond, ptFisExtPi, edCircPeau, gptsdisks, idisklim, nbsegRad):
"""
création des points du maillage du pipe sur la face de peau
"""
"""création des points du maillage du pipe sur la face de peau"""
logging.info('start')
for i, edges in enumerate(listEdges):
idf = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau)
for n_edges, edges in enumerate(listEdges):
idf = idFacesDebouchantes[n_edges] # indice de face débouchante (facesPipePeau)
if idf >= 0:
gptdsk = []
gptdsk = list()
if idf > 0: # idf vaut 0 ou 1
idf = -1 # si idf vaut 1, on prend le dernier élément de la liste (1 ou 2 extrémités débouchent sur la face)
centre = ptEdgeFond[idFillingFromBout[i]][idf]
centre = ptEdgeFond[idFillingFromBout[n_edges]][idf]
name = "centre%d"%idf
geomPublish(initLog.debug, centre, name)
vertPipePeau = ptFisExtPi[idFillingFromBout[i]][idf]
vertPipePeau = ptFisExtPi[idFillingFromBout[n_edges]][idf]
geomPublishInFather(initLog.debug, centre, vertPipePeau, "vertPipePeau")
grpsEdgesCirc = edCircPeau[idFillingFromBout[i]] # liste de groupes
edgesCirc = []
grpsEdgesCirc = edCircPeau[idFillingFromBout[n_edges]] # liste de groupes
edgesCirc = list()
for grpEdgesCirc in grpsEdgesCirc:
edgesCirc += geompy.ExtractShapes(grpEdgesCirc, geompy.ShapeType["EDGE"], False)
for k, edge in enumerate(edges):
@ -59,32 +58,31 @@ def creePointsPipePeau(listEdges, idFacesDebouchantes, idFillingFromBout,
distEdgeCirc = [(geompy.MinDistance(bout, edgeCirc), k2, edgeCirc) for k2, edgeCirc in enumerate(edgesCirc)]
distEdgeCirc.sort()
logging.debug("distEdgeCirc: %s", distEdgeCirc)
u = projettePointSurCourbe(bout, distEdgeCirc[0][2])
if (abs(u) < 0.02) or (abs(1-u) < 0.02): # les points très proches d'une extrémité doivent y être mis précisément.
dist = projettePointSurCourbe(bout, distEdgeCirc[0][2])
if (abs(dist) < 0.02) or (abs(1.-dist) < 0.02): # les points très proches d'une extrémité doivent y être mis précisément.
extrCircs = geompy.ExtractShapes(distEdgeCirc[0][2], geompy.ShapeType["VERTEX"], True)
if geompy.MinDistance(bout, extrCircs[0]) < geompy.MinDistance(bout, extrCircs[1]):
bout = extrCircs[0]
else:
bout = extrCircs[1]
else:
bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], u)
bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], dist)
name ="bout%d"%k
geomPublishInFather(initLog.debug, centre, bout, name)
# enregistrement des points dans la structure
points = []
for j in range(nbsegRad +1):
u = j/float(nbsegRad)
points.append(geompy.MakeVertexOnCurve(edge, u))
points = list()
for n_seg in range(nbsegRad +1):
points.append(geompy.MakeVertexOnCurve(edge, float(n_seg)/float(nbsegRad)))
if geompy.MinDistance(bout, points[0]) < geompy.MinDistance(centre, points[0]):
points.reverse()
points[0] = centre
points[-1] = bout
gptdsk.append(points)
if i == 0:
if n_edges == 0:
gptsdisks[idisklim[0] -1] = gptdsk
idisklim[0] = idisklim[0] -1
else:
gptsdisks[idisklim[1] +1] = gptdsk
idisklim[1] = idisklim[1] +1
return (gptsdisks, idisklim)
return (gptsdisks, idisklim)

View File

@ -17,14 +17,16 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""TODO: a compléter"""
import os
import logging
from .geomsmesh import smesh
import SMESH
import SALOMEDS
from .geomsmesh import smesh
from .creeZoneDefautMaillage import creeZoneDefautMaillage
from .peauInterne import peauInterne
from .quadranglesToShapeNoCorner import quadranglesToShapeNoCorner
@ -32,10 +34,7 @@ from .creeZoneDefautFilling import creeZoneDefautFilling
from .creeZoneDefautGeom import creeZoneDefautGeom
from .getCentreFondFiss import getCentreFondFiss
# -----------------------------------------------------------------------------
# ---
def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, \
shapeFissureParams, maillageFissureParams):
"""
#TODO: a compléter
@ -65,11 +64,10 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
nomFicSain = maillageFissureParams['nomFicSain']
fichierMaillageSain = os.path.join (nomRep , '{}.med'.format(nomFicSain))
# --- centre de fond de fissure et tangente
edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure)
# --- zone de défaut
nomZones = "zoneDefaut"
@ -89,9 +87,9 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
isPlane = False
if isHexa and not isPlane:
meshQuad = smesh.CopyMesh( zoneDefaut_skin, 'meshQuad', 0, 0)
fillings, noeuds_bords, bordsPartages, fillconts, idFilToCont = quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss)
fillings, _, bordsPartages, fillconts, idFilToCont = quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss)
for filling in fillings:
[faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion)
@ -101,14 +99,15 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
extrusionsDefaut.append(extrusionDefaut)
else:
[facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion)
creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, lgExtrusion)
bordsPartages = list()
for face in facesDefaut:
for _ in facesDefaut:
bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ?
fillconts = facesDefaut
idFilToCont = list(range(len(facesDefaut)))
return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, dmoyen, bordsPartages, fillconts, idFilToCont,
maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges,
return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, \
dmoyen, bordsPartages, fillconts, idFilToCont, \
maillageSain, internalBoundary, \
zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, \
edgeFondExt, centreFondFiss, tgtCentre]

View File

@ -17,20 +17,20 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Crée zone géométrique défaut a partir d'un filling"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- crée zone géométrique défaut a partir d'un filling
def creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion=50):
"""
Construction CAO de la zone à remailler, quand on utilise un filling,
"""Construction CAO de la zone à remailler, quand on utilise un filling,
après appel creeZoneDefautMaillage et quadranglesToShapeNoCorner
@param filling : la CAO de la peau du défaut reconstituée
@param shapeDefaut : objet géométrique représentant la fissure
(selon les cas, un point central, ou une shape plus complexe,

View File

@ -17,28 +17,24 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Zone de défaut, constructions géométrique avec CAO d'origine"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .prolongeVertices import prolongeVertices
# -----------------------------------------------------------------------------
# --- zone de defaut, constructions geometrique avec CAO d'origine
def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, lgExtrusion=50):
"""Construction CAO de la zone à remailler, quand on utilise la CAO d'origine,apres appel creeZoneDefautMaillage
def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion=50):
"""
Construction CAO de la zone à remailler, quand on utilise la CAO d'origine,
apres appel creeZoneDefautMaillage
@param objetSain : la géometrie de l'objet initial
@param shapeDefaut : objet géometrique représentant la fissure
(selon les cas, un point central, ou une shape plus complexe,
dont on ne garde que les vertices)
@param origShapes : liste id subShapes
@param verticesShapes : listes noeuds de bord
@param dmoyen : longueur arete moyenne bord
@lgExtrusion : distance d'extrusion de la face du defaut
(ne vaut que pour des fissures courtes)
@return (facesDefaut, centreDefaut, normalDefaut, extrusionDefaut)
@ -46,14 +42,14 @@ def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoye
logging.info("start")
trace = True
faces = []
curves = []
cdgs = []
projs = []
normals = []
extrusions = []
partitions = []
decoupes = []
faces = list()
curves = list()
cdgs = list()
projs = list()
normals = list()
extrusions = list()
partitions = list()
decoupes = list()
for ishape, vertices in enumerate(verticesShapes):
aShape = origShapes[ishape]
@ -106,7 +102,6 @@ def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoye
if trace:
name="partition_%d"%aShape
geomPublish(initLog.debug, partition, name)
pass
#
centreSphere = geompy.MakeCDG(shapeDefaut)
@ -114,12 +109,12 @@ def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoye
ccurves = geompy.MakeCompound(curves)
gravCenter = geompy.MakeCDG(ccurves)
geomPublish(initLog.debug, gravCenter, "cdg_curves")
for i in range(len(partitions)):
for indice, part in enumerate(partitions):
if trace:
logging.debug(" --- original shape %s", origShapes[i])
dists = []
facesToSort = []
subFaces = geompy.ExtractShapes(partitions[i], geompy.ShapeType["FACE"], True)
logging.debug(" --- original shape %s", origShapes[indice])
dists = list()
facesToSort = list()
subFaces = geompy.ExtractShapes(part, geompy.ShapeType["FACE"], True)
for aFace in subFaces:
cdg = geompy.MakeCDG(aFace)
distance = geompy.MinDistance(cdg, centreSphere)
@ -127,70 +122,66 @@ def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoye
facesToSort.append(aFace)
if trace:
logging.debug("distance = %s", distance)
pass
pass
if len(dists) > 0:
minDist = min(dists)
for j,d in enumerate(dists):
if d == minDist:
aFace = facesToSort[j]
name="decoupe_%d"%origShapes[i]
name="decoupe_%d"%origShapes[indice]
geomPublish(initLog.debug, aFace, name)
decoupes.append(aFace)
break
pass
pass
facesDefaut = decoupes[0]
if len(decoupes) > 1:
facesDefaut = geompy.MakePartition(decoupes, [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
geomPublish(initLog.debug, facesDefaut, "facesDefaut")
shells=[]
shells = list()
if len(decoupes) > 1: # plusieurs faces de defaut
subFaces = geompy.ExtractShapes(facesDefaut, geompy.ShapeType["FACE"], True)
# --- regroupe les subFaces en shells connectes
theFaces = list(subFaces) # copy
while len(theFaces) > 0:
while theFaces:
logging.debug("------- len(theFaces) %s" , len(theFaces))
theFace = theFaces[0]
logging.debug(" start with face %s",theFaces[0])
theFaces[0:1] = []
theFaces[0:1] = list()
aShell = [theFace]
toAdd =[theFace]
while len(toAdd) > 0:
toAdd = []
toRemove = []
for i in range(len(theFaces)):
logging.debug(" try %s", theFaces[i])
while toAdd:
toAdd = list()
toRemove = list()
for indice, la_face in enumerate(theFaces):
logging.debug(" try %s", la_face)
for aFace in aShell:
logging.debug(" with %s", aFace)
try:
edge = geompy.GetSharedShapesMulti([aFace, theFaces[i]], geompy.ShapeType["EDGE"])
_ = geompy.GetSharedShapesMulti([aFace, la_face], geompy.ShapeType["EDGE"])
edgeShared = True
except:
edgeShared = False
if edgeShared:
if theFaces[i] not in toAdd:
toAdd.append(theFaces[i])
toRemove.append(i)
logging.debug(" --- add %s", theFaces[i])
if la_face not in toAdd:
toAdd.append(la_face)
toRemove.append(indice)
logging.debug(" --- add %s", la_face)
aShell += toAdd
for k in sorted(toRemove, reverse=True):
theFaces[k:k+1] = []
theFaces[k:k+1] = list()
theShell = geompy.MakeShell(aShell)
name = "theShell%d"%len(shells)
geomPublish(initLog.debug, theShell,name)
shells.append(theShell)
#
distances = []
distances = list()
for aShell in shells: # --- trouver le shell en contact avec la fissure
distances.append(geompy.MinDistance(aShell, shapeDefaut))
minDist = min(distances)
for index in range(len(distances)):
if distances[index] == minDist:
for indice, dist in enumerate(distances):
if dist == minDist:
theShellDefaut = shells[indice]
break
theShellDefaut = shells[index]
#
else: # --- une seule face de defaut
subFaces = [facesDefaut]
@ -199,18 +190,19 @@ def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoye
geomPublish(initLog.debug, theShellDefaut,"theShellDefaut")
theFaces = geompy.ExtractShapes(theShellDefaut, geompy.ShapeType["FACE"], True)
distances = []
distances = list()
for aFace in theFaces:
distances.append(geompy.MinDistance(aFace, centreSphere))
minDist = min(distances)
for index in range(len(distances)):
if distances[index] == minDist:
for indice, dist in enumerate(distances):
if dist == minDist:
indice0 = indice
break
centreDefaut = geompy.MakeProjection(centreSphere, theFaces[index])
centreDefaut = geompy.MakeProjection(centreSphere, theFaces[indice0])
if trace:
geomPublish(initLog.debug, centreDefaut, "centreDefaut")
normalDefaut = geompy.GetNormal(subFaces[index], centreDefaut)
normalDefaut = geompy.GetNormal(subFaces[indice0], centreDefaut)
if trace:
geomPublish(initLog.debug, normalDefaut, "normalDefaut")
extrusionDefaut = geompy.MakePrismVecH(theShellDefaut, normalDefaut, -lgExtrusion)

View File

@ -17,16 +17,17 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Zone de defaut extraite du maillage"""
import logging
from .geomsmesh import geompy
import math
from .distance2 import distance2
import traceback
from .geomsmesh import geompy
from .distance2 import distance2
from .fissError import fissError
# -----------------------------------------------------------------------------
# --- zone de defaut extraite du maillage
def creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut,
nomZones, coordsNoeudsFissure):
@ -45,12 +46,13 @@ def creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut,
@return (origShapes, verticesShapes, dmoyen) liste id subShapes, listes noeuds de bord, longueur arête moyenne bord
"""
logging.info("start")
logging.debug("distance d'influence (tailleDefaut) = %f" % tailleDefaut)
texte = "distance d'influence (tailleDefaut) = {}".format(tailleDefaut)
logging.debug(texte)
#print (" shapeDefaut : {}".format(shapeDefaut))
#print (" nomZones : {}".format(nomZones))
maillageSain = maillagesSains[0]
isHexa = maillagesSains[1]
#isHexa = maillagesSains[1]
lists = maillageSain.CreateHoleSkin(tailleDefaut, shapeDefaut, nomZones, coordsNoeudsFissure)
#print("lists = {}".format(lists))
@ -59,8 +61,8 @@ def creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut,
origShapes = list()
verticesShapes = list()
cumul = 0. # somme des distances carrées entre point ordonnés (taille des arêtes)
nb = 0 # nombre d'arêtes évaluées
cumul = 0. # somme des distances carrées entre points ordonnés (taille des arêtes)
nbar = 0 # nombre d'arêtes évaluées
for aList in lists:
aShape = aList[0]
@ -77,17 +79,18 @@ def creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut,
xyz0 = xyz
#logging.debug(" node %s %s", node, xyz)
vertices.append(geompy.MakeVertex(xyz[0], xyz[1], xyz[2]))
nb += len(aList) - 2
nbar += len(aList) - 2
verticesShapes.append(vertices)
#print ("nb = {}".format(nb))
#print ("nbar = {}".format(nbar))
#print ("cumul = {}".format(cumul))
if (nb == 0):
if (nbar == 0):
texte = "La zone à remailler n'est pas détectée correctement.<br>"
texte += "Cause possible :<ul>"
texte += "<li>La distance d'influence est trop petite. "
texte += "L'ordre de grandeur minimal correspond à la taille des mailles du maillage sain dans la zone à remailler.</li></ul>"
raise fissError(traceback.extract_stack(),texte)
dmoyen = math.sqrt(cumul/float(nb)) # ~ taille de l'arête moyenne du maillage global
dmoyen = math.sqrt(cumul/float(nbar)) # ~ taille de l'arête moyenne du maillage global
return origShapes, verticesShapes, dmoyen

View File

@ -17,38 +17,40 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""calcul du carré de la distance entre deux points"""
import logging
# -----------------------------------------------------------------------------
# --- calcul de distance carree entre deux points, jeux de coordonnees x,y,z
# ---
def distance2(xyz1, xyz2):
"""
carré de la distance entre deux points donnés par des triplets [x,y,z]
"""
#logging.info("start")
d2 = 0
for i in range(3):
d2 += (xyz1[i]-xyz2[i])*(xyz1[i]-xyz2[i])
logging.debug('d2=%s', d2)
return d2
# -----------------------------------------------------------------------------
# --- test unitaire
dcarre = 0
for ijk in range(3):
dcarre += (xyz1[ijk]-xyz2[ijk])*(xyz1[ijk]-xyz2[ijk])
logging.debug('dcarre=%s', dcarre)
import unittest
class Test_distance2(unittest.TestCase):
return dcarre
def setUp(self):
self.a=[0, 0, 0]
self.b=[3, 4, 5]
self.c=[-5,-4,-3]
def test_calcul(self):
self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a))
self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c))
self.assertEqual(distance2(self.b, self.b), 0)
self.assertEqual(distance2(self.a, self.b), 50)
## -----------------------------------------------------------------------------
## --- test unitaire
#import unittest
#class Test_distance2(unittest.TestCase):
#"""test de la fonction"""
#def setUp(self):
#self.a=[0, 0, 0]
#self.b=[3, 4, 5]
#self.c=[-5,-4,-3]
#def test_calcul(self):
#self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a))
#self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c))
#self.assertEqual(distance2(self.b, self.b), 0)
#self.assertEqual(distance2(self.a, self.b), 50)

View File

@ -17,26 +17,28 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""éliminer les doublons d'une liste de subshapes"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- éliminer les doublons d'une liste de subshapes
# ---
def eliminateDoubles(obj, subshapes):
"""
éliminer les doublons d'une liste de subshapes
"""
idsubs = {}
"""éliminer les doublons d'une liste de subshapes"""
idsubs = dict()
for sub in subshapes:
subid = geompy.GetSubShapeID(obj, sub)
if subid in list(idsubs.keys()):
if subid in idsubs:
idsubs[subid].append(sub)
else:
idsubs[subid] = [sub]
shortList = []
for k, v in idsubs.items():
shortList.append(v[0])
shortList = list()
for l_sub in idsubs.items():
shortList.append(l_sub[0])
logging.debug("shortList=%s", shortList)
return shortList

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Recherche des points en trop (externes au volume à remailler)"""
import logging
@ -24,33 +25,34 @@ from .geomsmesh import geompy
from .whichSideVertex import whichSideVertex
def elimineExtremitesPipe(ptEdgeFond, facesDefaut, centres, gptsdisks, nbsegCercle):
"""
recherche des points en trop (externes au volume à remailler)
- on associe chaque extrémité du pipe à une face filling
"""Recherche des points en trop (externes au volume à remailler)
- on associe chaque extrémité du pipe à une face filling
- on part des disques aux extrémités du pipe
- pour chaque disque, on prend les vertices de géométrie,
on marque leur position relative à la face.
- on s'arrete quand tous les noeuds sont dedans
"""
logging.info('start')
pt0 = centres[0]
pt1 = centres[-1]
point_0 = centres[0]
point_1 = centres[-1]
idFillingFromBout = [None, None] # contiendra l'index du filling pour les extrémités 0 et 1
nbFacesFilling = len(ptEdgeFond)
for ifil in range(nbFacesFilling):
for ipt, pt in enumerate(ptEdgeFond[ifil]): # il y a un ou deux points débouchant sur cette face
if geompy.MinDistance(pt,pt0) < geompy.MinDistance(pt,pt1): # TODO: trouver plus fiable pour les cas tordus...
for point in ptEdgeFond[ifil]: # il y a un ou deux points débouchant sur cette face
if geompy.MinDistance(point,point_0) < geompy.MinDistance(point,point_1): # TODO: trouver plus fiable pour les cas tordus...
idFillingFromBout[0] = ifil
else:
else:
idFillingFromBout[1] = ifil
logging.debug("association bouts du pipe - faces de filling: %s", idFillingFromBout)
logging.debug("recherche des disques de noeuds complètement internes")
idisklim = [] # indices des premier et dernier disques internes
idiskout = [] # indices des premier et dernier disques externes
idisklim = list() # indices des premier et dernier disques internes
idiskout = list() # indices des premier et dernier disques externes
for bout in range(2):
if bout == 0:
idisk = -1
inc = 1
@ -59,26 +61,28 @@ def elimineExtremitesPipe(ptEdgeFond, facesDefaut, centres, gptsdisks, nbsegCerc
idisk = len(gptsdisks)
inc = -1
numout = len(gptsdisks)
inside = False
outside = True
while not inside:
idisk = idisk + inc
idisk += inc
logging.debug("examen disque %s", idisk)
gptdsk = gptsdisks[idisk]
inside = True
for k in range(nbsegCercle):
points = gptdsk[k]
for j, pt in enumerate(points):
side = whichSideVertex(facesDefaut[idFillingFromBout[bout]], pt)
for n_seg in range(nbsegCercle):
points = gptdsk[n_seg]
for point in points:
side = whichSideVertex(facesDefaut[idFillingFromBout[bout]], point)
if side < 0:
if outside: # premier point detecté dedans
outside = False
numout = idisk -inc # le disque précédent était dehors
else:
inside = False # ce point est dehors
inside = False # ce point est dehors
if not inside and not outside:
break
idisklim.append(idisk) # premier et dernier disques internes
idiskout.append(numout) # premier et dernier disques externes
return (idFillingFromBout, idisklim, idiskout)
return (idFillingFromBout, idisklim, idiskout)

View File

@ -17,26 +17,25 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""ellipsoide defaut"""
import logging
import math
from .geomsmesh import geompy
from .triedreBase import triedreBase
O, OX, OY, OZ = triedreBase()
# -----------------------------------------------------------------------------
# --- ellipsoide defaut
def ellipsoideDefaut(minRad,allonge,rayTore):
"""
Le bloc contenant la fissure est un ellipsoide construit centre a l'origine,
def ellipsoideDefaut(minRad,allonge):
"""Le bloc contenant la fissure est un ellipsoide construit centre a l'origine,
contenant le tore elliptique de fissure
@param minRad :petit rayon
@param allonge :rapport grand rayon / petit rayon
@param rayTore :rayon du tore construit autour de la generatrice de l'ellipse
@return ellipsoide (geomObject)
"""
logging.info("start")
logging.info("start")
boule = geompy.MakeSphereR(2)
bouler = geompy.MakeRotation(boule, OY, math.pi/2.0)
face = geompy.MakeFaceHW(100, 100, 3)

View File

@ -17,26 +17,29 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""maillage sain sans la zone de défaut"""
import logging
# -----------------------------------------------------------------------------
# --- maillage sain sans la zone defaut
def enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges):
"""
Maillage sain sans la zone de defaut
"""Maillage sain sans la zone de défaut
TODO: a completer
"""
logging.info('start')
maillageSain.RemoveGroupWithContents(zoneDefaut)
if zoneDefaut_skin is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_skin)
if zoneDefaut_internalFaces is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_internalFaces)
if zoneDefaut_internalEdges is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_internalEdges)
nbRemoved = maillageSain.RemoveOrphanNodes()
return maillageSain
_ = maillageSain.RemoveOrphanNodes()
return maillageSain

View File

@ -17,17 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .whichSide import whichSide
# -----------------------------------------------------------------------------
# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
from .extractionOrientee_a import extractionOrientee_a
def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
"""
@ -37,36 +34,22 @@ def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
"""
logging.info('start')
trace = True
sideRef = whichSide(face, ref)
logging.debug("ref side %s", sideRef)
shapesInside = []
shapesOutside = []
shapesOnside = []
side_ref = whichSide(face, ref)
logging.debug("ref side %s", side_ref)
shapesInside = list()
shapesOutside = list()
shapesOnside = list()
shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
i=0
j=0
k=0
i_aux = 0
j_aux = 0
k_aux = 0
prefix = prefix + shapeType
for shape in shapes:
side = whichSide(face, shape, tol)
if side == sideRef:
shapesInside.append(shape)
if trace:
name = prefix + "_Inside%d"%i
geomPublishInFather(initLog.debug, obj, shape, name)
i+=1
elif side == -sideRef:
shapesOutside.append(shape)
if trace:
name = prefix + "_Outside%d"%j
geomPublishInFather(initLog.debug, obj, shape, name)
j+=1
elif side == 0:
shapesOnside.append(shape)
if trace:
name = prefix + "_Onside%d"%k
geomPublishInFather(initLog.debug, obj, shape, name)
k+=1
logging.debug("--- shape was %s", name)
return [shapesInside, shapesOutside, shapesOnside]
i_aux, j_aux, k_aux = extractionOrientee_a(obj, shape, side, side_ref, \
shapesInside, shapesOutside, shapesOnside, \
i_aux, j_aux, k_aux, \
trace, prefix)
return [shapesInside, shapesOutside, shapesOnside]

View File

@ -17,17 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Renvoie l'extraction des shapes d'un objet selon leur position par rapport à la fac"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .whichSideMulti import whichSideMulti
# -----------------------------------------------------------------------------
# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
from .extractionOrientee_a import extractionOrientee_a
def extractionOrienteeMulti(faces, ifil, obj, centre, shapeType, tol, prefix=""):
"""
@ -37,34 +34,20 @@ def extractionOrienteeMulti(faces, ifil, obj, centre, shapeType, tol, prefix="")
"""
logging.info('start')
trace = True
shapesInside = []
shapesOutside = []
shapesOnside = []
shapesInside = list()
shapesOutside = list()
shapesOnside = list()
shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
i=0
j=0
k=0
i_aux = 0
j_aux = 0
k_aux = 0
prefix = prefix + shapeType
for shape in shapes:
side = whichSideMulti(faces, ifil, shape, centre, tol)
if side == 1:
shapesInside.append(shape)
if trace:
name = prefix + "_Inside%d"%i
geomPublishInFather(initLog.debug, obj, shape, name)
i+=1
elif side == -1:
shapesOutside.append(shape)
if trace:
name = prefix + "_Outside%d"%j
geomPublishInFather(initLog.debug, obj, shape, name)
j+=1
elif side == 0:
shapesOnside.append(shape)
if trace:
name = prefix + "_Onside%d"%k
geomPublishInFather(initLog.debug, obj, shape, name)
k+=1
logging.debug("--- shape was %s", name)
return [shapesInside, shapesOutside, shapesOnside]
i_aux, j_aux, k_aux = extractionOrientee_a(obj, shape, side, 1, \
shapesInside, shapesOutside, shapesOnside, \
i_aux, j_aux, k_aux, \
trace, prefix)
return [shapesInside, shapesOutside, shapesOnside]

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
#
"""Détermine le bon côté"""
import logging
from . import initLog
from .geomsmesh import geomPublishInFather
def extractionOrientee_a(obj, shape, side, side_ref, \
shapesInside, shapesOutside, shapesOnside, \
i_aux, j_aux, k_aux, \
trace=True, prefix=""):
"""Détermine le bon côté"""
#logging.info('start')
if side == side_ref:
shapesInside.append(shape)
if trace:
name = prefix + "_Inside%d"%i_aux
geomPublishInFather(initLog.debug, obj, shape, name)
i_aux += 1
elif side == -side_ref:
shapesOutside.append(shape)
if trace:
name = prefix + "_Outside%d"%j_aux
geomPublishInFather(initLog.debug, obj, shape, name)
j_aux += 1
elif side == 0:
shapesOnside.append(shape)
if trace:
name = prefix + "_Onside%d"%k_aux
geomPublishInFather(initLog.debug, obj, shape, name)
k_aux += 1
logging.debug("--- shape was %s", name)
return i_aux, j_aux, k_aux

View File

@ -17,16 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Tore : faces 1/2 circulaires et leur centre, edges de ces faces dans le plan de fissure"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- TORE
## --- faces 1/2 circulaires et leur centre, edges de ces faces dans le plan de fissure
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def facesCirculaires(bloc, tore):
"""
@ -41,59 +39,42 @@ def facesCirculaires(bloc, tore):
faces = geompy.GetShapesOnShape(bloc, tore, geompy.ShapeType["FACE"], GEOM.ST_ON)
geomPublishInFather(initLog.debug, tore, faces[0], 'face0' )
geomPublishInFather(initLog.debug, tore, faces[1], 'face1' )
geomPublishInFather(initLog.debug, tore, faces[2], 'face2' )
geomPublishInFather(initLog.debug, tore, faces[3], 'face3' )
centres = list()
alledges = list()
for i_aux in range(4):
geomPublishInFather(initLog.debug, tore, faces[i_aux], 'face{}'.format(i_aux))
[_,centre,_] = geompy.ExtractShapes(faces[i_aux], geompy.ShapeType["VERTEX"], True)
centres.append(centre)
geomPublishInFather(initLog.debug, faces[i_aux], centre, 'centre{}'.format(i_aux))
alledges.append(geompy.ExtractShapes(faces[i_aux], geompy.ShapeType["EDGE"], True))
centres = [None, None, None, None]
[v1,centres[0],v3] = geompy.ExtractShapes(faces[0], geompy.ShapeType["VERTEX"], True)
[v1,centres[1],v3] = geompy.ExtractShapes(faces[1], geompy.ShapeType["VERTEX"], True)
[v1,centres[2],v3] = geompy.ExtractShapes(faces[2], geompy.ShapeType["VERTEX"], True)
[v1,centres[3],v3] = geompy.ExtractShapes(faces[3], geompy.ShapeType["VERTEX"], True)
dicoedge = dict()
edges = list()
reverses = list()
geomPublishInFather(initLog.debug, faces[0], centres[0], 'centre0' )
geomPublishInFather(initLog.debug, faces[1], centres[1], 'centre1' )
geomPublishInFather(initLog.debug, faces[2], centres[2], 'centre2' )
geomPublishInFather(initLog.debug, faces[3], centres[3], 'centre3' )
for i_aux, edgesface in enumerate(alledges):
alledges = [None, None, None, None]
alledges[0] = geompy.ExtractShapes(faces[0], geompy.ShapeType["EDGE"], True)
alledges[1] = geompy.ExtractShapes(faces[1], geompy.ShapeType["EDGE"], True)
alledges[2] = geompy.ExtractShapes(faces[2], geompy.ShapeType["EDGE"], True)
alledges[3] = geompy.ExtractShapes(faces[3], geompy.ShapeType["EDGE"], True)
dicoedge = {}
edges = []
reverses = []
for i in range(len(alledges)):
edgesface = alledges[i]
lenef = []
for j in range(len(edgesface)):
props = geompy.BasicProperties(edgesface[j])
lenef = list()
for edge in edgesface:
props = geompy.BasicProperties(edge)
lenef.append(props[0])
pass
maxlen = max(lenef)
for j in range(len(edgesface)):
if lenef[j] < maxlen:
edgid = geompy.GetSubShapeID(tore, edgesface[j])
for j_aux, edge in enumerate(edgesface):
if lenef[j_aux] < maxlen:
edgid = geompy.GetSubShapeID(tore, edge)
if not (edgid in dicoedge):
dicoedge[edgid] = edgesface[j]
edges.append(edgesface[j])
named = 'edge_' + str(i) + '_' +str(j)
geomPublishInFather(initLog.debug, faces[i], edgesface[j], named)
vertices = geompy.ExtractShapes(edgesface[j], geompy.ShapeType["VERTEX"], False)
#firstVertex = geompy.GetFirstVertex(edgesface[j])
if geompy.GetSubShapeID(tore, vertices[0]) != geompy.GetSubShapeID(tore, centres[i]):
dicoedge[edgid] = edge
edges.append(edge)
named = 'edge_{}_{}'.format(i_aux,j_aux)
geomPublishInFather(initLog.debug, faces[i_aux], edge, named)
vertices = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
#firstVertex = geompy.GetFirstVertex(edge)
if geompy.GetSubShapeID(tore, vertices[0]) != geompy.GetSubShapeID(tore, centres[i_aux]):
reverses.append(1)
#print 'reversed ' + str(edgid)
else:
reverses.append(0)
#print 'normal' + str(edgid)
pass
pass
pass
pass
return faces, centres, edges, reverses

View File

@ -17,33 +17,34 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Faces fissure dans et hors tore, et edges face hors tore"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
import GEOM
from . import initLog
# -----------------------------------------------------------------------------
# --- faces fissure dans et hors tore, et edges face hors tore
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def facesFissure(blocp, faceFissure, extrusionDefaut, genint):
"""
extraction des faces de fissure dans et hors tore, des edges le long du tore et en paroi
"""Extraction des faces de fissure dans et hors tore, des edges le long du tore et en paroi
@param faceFissure : la face de fissure avec la partie dans le tore elliptique et la partie externe
@return (facefissintore, facefissoutore, edgeint, edgeext)
"""
logging.info('start')
[f0,f1] = geompy.ExtractShapes(faceFissure, geompy.ShapeType["FACE"], True)
ed0 = geompy.ExtractShapes(f0, geompy.ShapeType["EDGE"], True)
ed1 = geompy.ExtractShapes(f1, geompy.ShapeType["EDGE"], True)
[face_0,face_1] = geompy.ExtractShapes(faceFissure, geompy.ShapeType["FACE"], True)
ed0 = geompy.ExtractShapes(face_0, geompy.ShapeType["EDGE"], True)
ed1 = geompy.ExtractShapes(face_1, geompy.ShapeType["EDGE"], True)
if len(ed0) > len(ed1):
facefissintore = f0
facefissoutore = f1
facefissintore = face_0
facefissoutore = face_1
else:
facefissintore = f1
facefissoutore = f0
facefissintore = face_1
facefissoutore = face_0
geomPublishInFather(initLog.debug, faceFissure, facefissintore,'facefissintore')
geomPublishInFather(initLog.debug, faceFissure, facefissoutore,'facefissoutore')
@ -51,18 +52,18 @@ def facesFissure(blocp, faceFissure, extrusionDefaut, genint):
edgeint = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_IN)
edgeext = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_ON)
for i in range(len(edgeint)):
name = "edgeint_%d"%i
geomPublishInFather(initLog.debug, facefissoutore, edgeint[i],name)
for i in range(len(edgeext)):
name = "edgeext_%d"%i
geomPublishInFather(initLog.debug, facefissoutore, edgeext[i],name)
for i_aux, edge in enumerate(edgeint):
name = "edgeint_{}".format(i_aux)
geomPublishInFather(initLog.debug, facefissoutore, edge,name)
for i_aux, edge in enumerate(edgeext):
name = "edgeext_{}".format(i_aux)
geomPublishInFather(initLog.debug, facefissoutore, edge,name)
reverext = []
reverext = list()
if len(edgeext) > 1:
vertices = geompy.ExtractShapes(genint, geompy.ShapeType["VERTEX"], False)
for i in range(len(edgeext)):
vertedge = geompy.ExtractShapes(edgeext[i], geompy.ShapeType["VERTEX"], False)
for edge in edgeext:
vertedge = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
if ((geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[0])) or
(geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[1]))):
reverext.append(0)

View File

@ -17,19 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification des faces tore et fissure dans le solide hors tore du bloc partitionné"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- identification des faces tore et fissure dans le solide hors tore du bloc partitionné
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def facesToreInBloc(blocp, facefissoutore, facetore1, facetore2):
"""
identification des faces tore et fissure dans le bloc partitionné : sous shapes du bloc
"""Identification des faces tore et fissure dans le bloc partitionné : sous shapes du bloc
@param blocp : bloc partitionné
@param facefissoutore : la face de fissure externe au tore
@param facetore1 : face du tore selon la génératrice
@ -47,4 +46,3 @@ def facesToreInBloc(blocp, facefissoutore, facetore1, facetore2):
geomPublishInFather(initLog.debug, blocp, blocFaceTore2,'blocFaceTore2')
return blocFaceFiss, blocFaceTore1, blocFaceTore2

View File

@ -17,19 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Tore : aces toriques et volumes du tore"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .extractionOrientee import extractionOrientee
from .getSubshapeIds import getSubshapeIds
# -----------------------------------------------------------------------------
# --- TORE
# --- faces toriques et volumes du tore
def facesVolumesToriques(tore, plan, facesDefaut):
"""
Extraction des deux faces et volumes du tore partitionné, qui suivent la génératrice elliptique.
@ -43,28 +42,25 @@ def facesVolumesToriques(tore, plan, facesDefaut):
normal = geompy.GetNormal(plan, centre)
reference = geompy.MakeTranslationVector(centre, normal)
[facesInPlan, facesOutPlan, facesOnPlan] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
[facesInSide, facesOutSide, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
[facesInPlan, facesOutPlan, _] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
facesIdInPlan = getSubshapeIds(tore, facesInPlan)
facesIdOutPlan = getSubshapeIds(tore, facesOutPlan)
[_, _, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
facesIdOnSide = getSubshapeIds(tore, facesOnSide)
facesIdInSide = getSubshapeIds(tore, facesInSide)
facesIdOutSide = getSubshapeIds(tore, facesOutSide)
#facesIdInOutSide = facesIdInSide + facesIdOutSide
facetore1 = None
faceTore2 = None
for i, faceId in enumerate(facesIdInPlan):
for i_aux, faceId in enumerate(facesIdInPlan):
if faceId not in facesIdOnSide:
facetore1 = facesInPlan[i]
facetore1 = facesInPlan[i_aux]
break
for i, faceId in enumerate(facesIdOutPlan):
if faceId not in facesIdOnSide:
facetore2 = facesOutPlan[i]
break
#[facetore1,facetore2] = geompy.GetShapesOnShape(pipe0, tore, geompy.ShapeType["FACE"], GEOM.ST_ON)
geomPublishInFather(initLog.debug, tore, facetore1, 'facetore1' )
facetore2 = None
for i_aux, faceId in enumerate(facesIdOutPlan):
if faceId not in facesIdOnSide:
facetore2 = facesOutPlan[i_aux]
break
geomPublishInFather(initLog.debug, tore, facetore2, 'facetore2' )
[volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True)

View File

@ -17,67 +17,35 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Trouver les vertices aux extrémites d'un wire"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- trouver les vertices extremites d'un wire
from .geomsmesh import geompy
from .findWireVertices import findWireVertices
def findWireEndVertices(aWire, getNormals=False):
"""
trouver les vertices extremites d'un wire
calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
"""Trouver les vertices aux extrémites d'un wire
Calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
"""
logging.info("start")
if geompy.NumberOfEdges(aWire) > 1:
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False)
else:
edges = [aWire]
vertices = []
idsubs = {}
shortList = []
if getNormals:
normals = []
idnorm = {}
shortNorm = []
for edge in edges:
vert = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
vertices += vert
if getNormals:
v0 = geompy.MakeVertexOnCurve(edge, 0.0)
n0 = geompy.MakeTangentOnCurve(edge, 0.0)
v1 = geompy.MakeVertexOnCurve(edge, 1.0)
n1 = geompy.MakeTangentOnCurve(edge, 1.0)
dist = geompy.MinDistance(v0, vert[0])
logging.debug("distance %s", dist)
if dist < 1.e-2:
normals += [n0, n1]
else:
normals += [n1, n0]
for i, sub in enumerate(vertices):
subid = geompy.GetSubShapeID(aWire, sub)
if subid in list(idsubs.keys()):
idsubs[subid].append(sub)
else:
idsubs[subid] = [sub]
name='vertex%d'%i
geomPublishInFather(initLog.debug, aWire, sub, name)
if getNormals:
idnorm[subid] = normals[i]
name='norm%d'%i
geomPublishInFather(initLog.debug, aWire, normals[i], name)
logging.debug("idsubs: %s", idsubs)
for k, v in idsubs.items():
if len(v) == 1:
shortList.append(v[0])
if getNormals:
shortNorm.append(idnorm[k])
if getNormals:
return shortList, shortNorm
else:
return shortList
idsubs, idnorm = findWireVertices(aWire, edges, getNormals)
shortList = list()
shortNorm = list()
for k_aux, sub in idsubs.items():
if ( len(sub) == 1 ):
shortList.append(sub[0])
if getNormals:
shortNorm.append(idnorm[k_aux])
return shortList, shortNorm

View File

@ -17,63 +17,35 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Trouver les vertices intermédiaires d'un wire"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .geomsmesh import geompy
from .findWireVertices import findWireVertices
# -----------------------------------------------------------------------------
# --- trouver les vertices intermediaires d'un wire
def findWireIntermediateVertices(aWire, getNormals=False):
"""
trouver les vertices d'un wire qui ne sont pas aux extremités
calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
"""Trouver les vertices d'un wire qui ne sont pas aux extremités
Calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
"""
logging.info("start")
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False)
vertices = []
idsubs = {}
shortList = []
if getNormals:
normals = []
idnorm = {}
shortNorm = []
for edge in edges:
vert = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
vertices += vert
if getNormals:
v0 = geompy.MakeVertexOnCurve(edge, 0.0)
n0 = geompy.MakeTangentOnCurve(edge, 0.0)
v1 = geompy.MakeVertexOnCurve(edge, 1.0)
n1 = geompy.MakeTangentOnCurve(edge, 1.0)
dist = geompy.MinDistance(v0, vert[0])
logging.debug("distance %s", dist)
if dist < 1.e-2:
normals += [n0, n1]
else:
normals += [n1, n0]
for i, sub in enumerate(vertices):
subid = geompy.GetSubShapeID(aWire, sub)
if subid in list(idsubs.keys()):
idsubs[subid].append(sub)
else:
idsubs[subid] = [sub]
name='vertex%d'%i
geomPublishInFather(initLog.debug, aWire, sub, name)
if getNormals:
idnorm[subid] = normals[i]
name='norm%d'%i
geomPublishInFather(initLog.debug, aWire, normals[i], name)
for k, v in idsubs.items():
if len(v) > 1:
shortList.append(v[0])
if getNormals:
shortNorm.append(idnorm[k])
if getNormals:
return shortList, shortNorm
else:
return shortList
idsubs, idnorm = findWireVertices(aWire, edges, getNormals)
shortList = list()
shortNorm = list()
for k_aux, sub in idsubs.items():
if ( len(sub) > 1 ):
shortList.append(sub[0])
if getNormals:
shortNorm.append(idnorm[k_aux])
return shortList, shortNorm

View File

@ -0,0 +1,69 @@
# -*- 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
#
"""Trouver les vertices d'un wire"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
def findWireVertices(aWire, edges, getNormals=False):
"""Trouver les vertices d'un wire
Calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
"""
logging.info("start")
vertices = list()
idsubs = dict()
idnorm = dict()
if getNormals:
normals = list()
for edge in edges:
vert = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
vertices += vert
if getNormals:
vertex_0 = geompy.MakeVertexOnCurve(edge, 0.0)
tangente_0 = geompy.MakeTangentOnCurve(edge, 0.0)
tangente_1 = geompy.MakeTangentOnCurve(edge, 1.0)
dist = geompy.MinDistance(vertex_0, vert[0])
logging.debug("distance %s", dist)
if dist < 1.e-2:
normals += [tangente_0, tangente_1]
else:
normals += [tangente_1, tangente_0]
for nro, sub in enumerate(vertices):
subid = geompy.GetSubShapeID(aWire, sub)
if subid in list(idsubs.keys()):
idsubs[subid].append(sub)
else:
idsubs[subid] = [sub]
name='vertex{}'.format(nro)
geomPublishInFather(initLog.debug, aWire, sub, name)
if getNormals:
idnorm[subid] = normals[nro]
name='norm{}'.format(nro)
geomPublishInFather(initLog.debug, aWire, normals[nro], name)
logging.debug("idsubs: %s", idsubs)
return idsubs, idnorm

View File

@ -17,19 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Message d'erreur"""
class fissError(Exception):
"""
usage:
""" Usage:
try:
instructions()
except:
raise fissError(traceback.extract_stack(),"mon message")
raise fissError(traceback.extract_stack(),"mon message")
"""
def __init__(self, pile, msg):
self.pile = pile
self.pile = pile
self.msg = msg
def __str__(self):
return 'msg=%s\npile=%s\n'%(self.msg, repr(self.pile))
return 'msg={}\npile={}\n'.format(self.msg, repr(self.pile))

View File

@ -17,19 +17,21 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Fissure dans un coude"""
import os
from .geomsmesh import geompy, smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import logging
import math
import GEOM
import SALOMEDS
import SMESH
import logging
from . import initLog
from .geomsmesh import geompy, smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from .fissureGenerique import fissureGenerique
@ -42,12 +44,12 @@ from .sortEdges import sortEdges
O, OX, OY, OZ = triedreBase()
class fissureCoude(fissureGenerique):
"""
problème de fissure du Coude : version de base
maillage hexa
"""
"""Problème de fissure du Coude : version de base - maillage hexa"""
nomProbleme = "fissureCoude"
longitudinale = None
circonferentielle = None
elliptique = None
# ---------------------------------------------------------------------------
def setParamGeometrieSaine(self):
@ -347,10 +349,8 @@ class fissureCoude(fissureGenerique):
logging.info("genereShapeFissure %s", self.nomCas)
logging.info("shapeFissureParams %s", shapeFissureParams)
angleCoude = geomParams['angleCoude']
r_cintr = geomParams['r_cintr']
l_tube_p1 = geomParams['l_tube_p1']
l_tube_p2 = geomParams['l_tube_p2']
epais = geomParams['epais']
de = geomParams['de']
@ -365,8 +365,6 @@ class fissureCoude(fissureGenerique):
if 'elliptique' in shapeFissureParams:
self.elliptique = shapeFissureParams['elliptique']
azimut = -azimut # axe inverse / ASCOUF
axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1)
geomPublish(initLog.debug, axe,"axe")
@ -383,10 +381,8 @@ class fissureCoude(fissureGenerique):
self.circonferentielle = False
self.longitudinale = False
if self.fissureLongue and not self.elliptique:
if abs(orientation) < 45 :
self.longitudinale = True
else:
self.circonferentielle = True
self.longitudinale = bool(abs(orientation) < 45)
self.circonferentielle = not bool(abs(orientation) < 45)
nbp1 = 10
if self.circonferentielle:
@ -400,8 +396,8 @@ class fissureCoude(fissureGenerique):
raybor = de/2. - epais
rayint = raybor + profondeur
rayext = raybor - profondeur/5.0
lgfond = longueur -2*profondeur
angle = lgfond/(2*raybor)
lgfond = longueur -2.*profondeur
angle = lgfond/(2.*raybor)
pb = geompy.MakeVertex(raybor, 0, 0)
pi = geompy.MakeVertex(rayint, 0, 0)
pbl = geompy.MakeRotation(pb, OZ, angle)
@ -592,7 +588,7 @@ class fissureCoude(fissureGenerique):
geomPublish(initLog.debug, centre, 'centrefissPlace' )
edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True)
edgesTriees, minl, maxl = sortEdges(edges)
edgesTriees, _, _ = sortEdges(edges)
edges = edgesTriees[:-1] # la plus grande correspond à arce, on l'elimine
wiretube = geompy.MakeWire(edges)
#wiretube = edgesTriees[-1]
@ -643,7 +639,7 @@ class fissureCoude(fissureGenerique):
facefiss = geompy.MakeFaceWires([arce, arci], 0)
geomPublish(initLog.debug, facefiss, 'facefissPlace' )
edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True)
edgesTriees, minl, maxl = sortEdges(edges)
edgesTriees, _, _ = sortEdges(edges)
edgetube = edgesTriees[-1] # la plus grande correspond à arci
wiretube = edgetube
@ -684,7 +680,7 @@ class fissureCoude(fissureGenerique):
mailleur="MeshGems"):
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \
step, mailleur)
step, mailleur, self.numeroCas)
return maillageFissure
# ---------------------------------------------------------------------------

View File

@ -17,93 +17,85 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""
Created on Tue Jun 24 09:14:13 2014
"""Groupe de quadrangles de face transformé en face géométrique par filling
Created on Tue Jun 24 09:14:13 2014
@author: I48174 (Olivier HOAREAU)
"""
import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .listOfExtraFunctions import createNewMeshesFromCorner
from .listOfExtraFunctions import createLinesFromMesh
# -----------------------------------------------------------------------------
# --- groupe de quadrangles de face transformé en face géométrique par filling
def fusionMaillageDefaut(maillageSain, maillageDefautCible, maillageInterneCible, zoneDefaut_skin, shapeDefaut, listOfCorners):
""" """
# TODO: rédiger la docstring
logging.info("start")
facesNonCoupees = []
facesCoupees = []
maillagesNonCoupes = []
maillagesCoupes = []
# On crée une liste contenant le maillage de chaque face.
listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
i = 0
while i < len(listOfNewMeshes):
lines = createLinesFromMesh(listOfNewMeshes[i])
setOfLines = []
for line in lines:
# On possède l'information 'ID' de chaque noeud composant chaque
# ligne de la face. A partir de l'ID, on crée un vertex. Un
# ensemble de vertices constitue une ligne. Un ensemble de lignes
# constitue la face.
tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
line = geompy.MakeInterpol(tmpPoints, False, False)
setOfLines.append(line)
# A partir des lignes de la face,
# on recrée un objet GEOM temporaire par filling.
filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
#logging.debug("face de filling")
#geomPublish(initLog.debug, filling, 'filling_{0}'.format(i + 1))
tmpPartition = geompy.MakePartition([filling], [shapeDefaut], [], [], geompy.ShapeType["FACE"], 0, [], 0)
tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
if len(tmpExplodeRef) == len(tmpExplodeNum):
logging.debug("face de filling non coupee")
geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i + 1)) # doit etre publie pour critere OK plus bas
facesNonCoupees.append(filling)
maillagesNonCoupes.append(listOfNewMeshes[i])
else:
logging.debug("face de filling coupee")
geompy.addToStudy( filling, "faceCoupee_{0}".format(i + 1))
facesCoupees.append(filling)
maillagesCoupes.append(listOfNewMeshes[i])
i += 1
listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
facesEnTrop = []
criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees]
filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
for i, filtre in enumerate(filtres):
filtre.SetMesh(maillageSain.GetMesh())
faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i + 1), filtre)
facesEnTrop.append(faceEnTrop)
newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
smesh.SetName(newMaillageInterne, 'newInternalBoundary')
return newZoneDefaut_skin, newMaillageInterne
"""Groupe de quadrangles de face transformé en face géométrique par filling"""
logging.info("start")
facesNonCoupees = list()
facesCoupees = list()
maillagesNonCoupes = list()
maillagesCoupes = list()
# On crée une liste contenant le maillage de chaque face.
listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
i_aux = 0
while i_aux < len(listOfNewMeshes):
lines = createLinesFromMesh(listOfNewMeshes[i_aux])
setOfLines = list()
for line in lines:
# On possède l'information 'ID' de chaque noeud composant chaque
# ligne de la face. A partir de l'ID, on crée un vertex. Un
# ensemble de vertices constitue une ligne. Un ensemble de lignes
# constitue la face.
tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
line = geompy.MakeInterpol(tmpPoints, False, False)
setOfLines.append(line)
# A partir des lignes de la face,
# on recrée un objet GEOM temporaire par filling.
filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
#logging.debug("face de filling")
#geomPublish(initLog.debug, filling, 'filling_{0}'.format(i_aux+1))
tmpPartition = geompy.MakePartition([filling], [shapeDefaut], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
if len(tmpExplodeRef) == len(tmpExplodeNum):
logging.debug("face de filling non coupee")
geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i_aux+1)) # doit etre publie pour critere OK plus bas
facesNonCoupees.append(filling)
maillagesNonCoupes.append(listOfNewMeshes[i_aux])
else:
logging.debug("face de filling coupee")
geompy.addToStudy( filling, "faceCoupee_{0}".format(i_aux+1))
facesCoupees.append(filling)
maillagesCoupes.append(listOfNewMeshes[i_aux])
i_aux += 1
listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
facesEnTrop = list()
criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees]
filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
for i_aux, filtre in enumerate(filtres):
filtre.SetMesh(maillageSain.GetMesh())
faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i_aux+1), filtre)
facesEnTrop.append(faceEnTrop)
newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
smesh.SetName(newMaillageInterne, 'newInternalBoundary')
return newZoneDefaut_skin, newMaillageInterne

View File

@ -17,26 +17,24 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Création élements géométriques fissure elliptique"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .toreFissure import toreFissure
from .ellipsoideDefaut import ellipsoideDefaut
from .rotTrans import rotTrans
from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
# -----------------------------------------------------------------------------
# --- création élements géométriques fissure elliptique
def genereElemsFissureElliptique(shapeFissureParams, \
mailleur="MeshGems"):
"""
TODO: a completer
"""
"""Création élements géométriques fissure elliptique"""
logging.info('start')
centreDefaut = shapeFissureParams['centreDefaut']
@ -51,7 +49,7 @@ def genereElemsFissureElliptique(shapeFissureParams, \
allonge = demiGrandAxe/demiPetitAxe
rayonTore = demiPetitAxe/5.0
generatrice, _, Pipe_1, FaceFissure, Plane_1, Pipe1Part = toreFissure(demiPetitAxe, allonge, rayonTore)
ellipsoide = ellipsoideDefaut(demiPetitAxe, allonge, rayonTore)
ellipsoide = ellipsoideDefaut(demiPetitAxe, allonge)
# --- positionnement sur le bloc defaut de generatrice, tore et plan fissure

View File

@ -17,13 +17,13 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Maillage face de fissure pour identification zone de défaut"""
import logging
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
# -----------------------------------------------------------------------------
# --- maillage face de fissure pour identification zone de defaut
from .geomsmesh import smesh
def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
mailleur="MeshGems"):
@ -46,7 +46,8 @@ def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
-SetQuadAllowed = permission quadrangle dans maillage triangle
-On récupère les coordonnées de chaque noeud de la fissure qu'on stocke
dans une liste sous la forme : [X0, Y0, Z0, ..., Xn, Yn, Zn]"""
dans une liste sous la forme : [X0, Y0, Z0, ..., Xn, Yn, Zn]
"""
logging.info('start')

View File

@ -17,10 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import logging
#logging.info('start')
from . import initLog
"""Publications dans salome"""
import salome
salome.salome_init()
@ -31,13 +28,14 @@ geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New()
# logging.debug("initialisation de geompy et smesh OK")
from . import initLog
def geomPublish(level,aShape, aName):
"""Publication d'un objet"""
if initLog.getLogLevel() <= level:
geompy.addToStudy(aShape, aName)
def geomPublishInFather(level, aFather, aShape, aName):
"""Publication d'un objet sous son ascendant"""
if initLog.getLogLevel() <= level:
geompy.addToStudyInFather(aFather, aShape, aName)

View File

@ -17,31 +17,34 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification du centre de fond de fissure,"""
import logging
import bisect
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import bisect
publie = False
def getCentreFondFiss(shapesFissure):
"""
identification du centre de fond de fissure,
"""Identification du centre de fond de fissure,
transformation fond de fissure en edge unique (seulement pour la procédure construitFissureGenerale).
On distingue le cas d'utilisation de la procédure insereFissureLongue par le nombre d'éléments de shapesFissure.
"""
global publie
logging.debug("start")
fondFiss = shapesFissure[4] # groupe d'edges de fond de fissure
if len(shapesFissure) == 6: # procédure construitFissureGenerale, et edge fond de fissure fournie explicitement
edgeFondExt = shapesFissure[5]
else:
edgeFondExt = None
if len(shapesFissure) > 6: # procédure insereFissureLongue (fissure plane, plusieurs edges sur le fond de fissure)
centreFondFiss = shapesFissure[1]
tgtCentre = None
@ -57,7 +60,7 @@ def getCentreFondFiss(shapesFissure):
aWire = geompy.MakeWire([fondFiss], 1e-07)
if not publie:
geomPublish(initLog.debug, aWire, "wireFondFissExt")
lgWire = geompy.BasicProperties(aWire)[0]
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], True)
lgEdges = [geompy.BasicProperties(ed)[0] for ed in edges]
@ -71,7 +74,7 @@ def getCentreFondFiss(shapesFissure):
logging.debug("lgsumEdges %s", lgSumEd)
logging.debug("id edge: %s, lgOnEdge: %s, lgEdge: %s",iedr, lgOnEdge, lgEdges[iedr])
if iedr > 0: # il y a une edge avant celle du milieu
if geompy.MinDistance(edges[iedr-1], geompy.MakeVertexOnCurve(edges[iedr], 0.0 )) < 1.e-3: # edge orientée croissante
if geompy.MinDistance(edges[iedr-1], geompy.MakeVertexOnCurve(edges[iedr], 0.0 )) < 1.e-3: # edge orientée croissante
centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], lgOnEdge/lgEdges[iedr])
else:
centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], 1.0 - lgOnEdge/lgEdges[iedr])
@ -84,7 +87,7 @@ def getCentreFondFiss(shapesFissure):
centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], lgOnEdge/lgEdges[iedr])
geomPublishInFather(initLog.debug,aWire, centreFondFiss, "centreFondFiss")
tgtCentre = geompy.MakeTangentOnCurve(edges[iedr], lgOnEdge/ lgEdges[iedr])
if edgeFondExt is None: # fond de fissure non fourni explicitement sous forme d'edge
try:
edgeFondExt = geompy.MakeEdgeWire(aWire, 0.0005, 1e-07)
@ -93,6 +96,7 @@ def getCentreFondFiss(shapesFissure):
edgeFondExt = None
if not publie and edgeFondExt is not None:
geomPublish(initLog.debug, edgeFondExt, "edgeFondExt")
publie = True
return edgeFondExt, centreFondFiss, tgtCentre

View File

@ -17,20 +17,18 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Transformation d'une liste de subshapes en une liste d'Id"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- transformation d'une liste de subshapes en une liste d'Id
def getSubshapeIds(obj, subshapes):
"""
transformation d'une liste de subshapes en une liste d'Id
"""
"""Transformation d'une liste de subshapes en une liste d'Id"""
logging.debug("start")
subshapesId = []
subshapesId = list()
for sub in subshapes:
subshapesId.append(geompy.GetSubShapeID(obj, sub))
logging.debug("subshapesId=%s", subshapesId)
return subshapesId

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

@ -17,17 +17,21 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification edges fond de fissure, edges pipe sur la face de fissure,
edges prolongées
edges internes communes pipe et fissure, points communs edges fissure peau et edges circulaires
"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .extractionOrientee import extractionOrientee
from .extractionOrienteeMulti import extractionOrienteeMulti
def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
edgesPipeFiss, edgesFondFiss, aretesVivesC,
fillingFaceExterne, centreFondFiss):
@ -44,34 +48,32 @@ def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesPipeC, "edgesPipeFiss")
edgesFondC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesFondFiss))
geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesFondC, "edgesFondFiss")
if aretesVivesC is None:
[edgesInside, edgesOutside, edgesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, facesOutside, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
else:
[edgesInside, edgesOutside, edgesOnside] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, facesOutside, facesOnside] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
edgesPipeIn = geompy.GetSharedShapesMulti([edgesPipeC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"])
verticesPipePeau = []
for i, edge in enumerate(edgesPipeIn):
if aretesVivesC is None:
[edgesInside, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, _, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
else:
[edgesInside, _, _] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, _, facesOnside] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
edgesPipeIn = geompy.GetSharedShapesMulti([edgesPipeC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"])
verticesPipePeau = list()
for i_aux, edge in enumerate(edgesPipeIn):
try:
vertices = geompy.GetSharedShapesMulti([edge, geompy.MakeCompound(facesOnside)], geompy.ShapeType["VERTEX"])
verticesPipePeau.append(vertices[0])
name = "edgePipeIn%d"%i
name = "edgePipeIn{}".format(i_aux)
geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
name = "verticePipePeau%d"%i
name = "verticePipePeau{}".format(i_aux)
geomPublishInFather(initLog.debug, partitionPeauFissFond, vertices[0], name)
logging.debug("edgePipeIn%s coupe les faces OnSide", i)
logging.debug("edgePipeIn%s coupe les faces OnSide", i_aux)
except:
logging.debug("edgePipeIn%s ne coupe pas les faces OnSide", i)
logging.debug("edgePipeIn%s ne coupe pas les faces OnSide", i_aux)
edgesFondIn =[]
if len(verticesPipePeau) > 0: # au moins une extrémité du pipe sur cette face de peau
#tmp = geompy.GetSharedShapesMulti([edgesFondC, geompy.MakeCompound(edgesOutside)], geompy.ShapeType["EDGE"])
#edgesFondOut = [ ed for ed in tmp if geompy.MinDistance(ed, geompy.MakeCompound(facesOnside)) < 1.e-3]
edgesFondIn = list()
if verticesPipePeau: # au moins une extrémité du pipe sur cette face de peau
tmp = geompy.GetSharedShapesMulti([edgesFondC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"])
edgesFondIn = [ ed for ed in tmp if geompy.MinDistance(ed, geompy.MakeCompound(facesOnside)) < 1.e-3]
return (edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside)
return (edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside)

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification des éléments géométriques de la face de peau"""
import logging
@ -30,8 +31,7 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
edgesFondFiss, wireFondFiss, aretesVivesC, \
facesDefaut, centreFondFiss, rayonPipe, \
aretesVivesCoupees):
"""
"""
"""Identification des éléments géométriques de la face de peau"""
logging.info('start')
fillingFaceExterne = facesDefaut[ifil]
@ -40,17 +40,18 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
# --- identification edges fond de fissure, edges pipe sur la face de fissure, edges prolongées
# edges internes communes pipe et fissure, points communs edges fissure peau et edges circulaires
(edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside) = identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
edgesPipeFiss, edgesFondFiss, aretesVivesC,
fillingFaceExterne, centreFondFiss)
(edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside) = \
identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond, \
edgesPipeFiss, edgesFondFiss, aretesVivesC, \
fillingFaceExterne, centreFondFiss)
# --- elements débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)
(verticesEdgesFondIn, pipexts, cercles,
facesFissExt, edgesFissExtPeau, edgesFissExtPipe) = identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond,
edgesFondIn, edgesFondFiss, wireFondFiss,
aretesVivesC, fillingFaceExterne,
edgesPipeIn, verticesPipePeau, rayonPipe,
facesFissExt, edgesFissExtPeau, edgesFissExtPipe) = identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
edgesFondIn, edgesFondFiss, wireFondFiss, \
aretesVivesC, fillingFaceExterne, \
edgesPipeIn, verticesPipePeau, rayonPipe, \
facesInside, facesOnside)
# --- pour les faces de peau sans extremité débouchante de fissure, il faut recenser les edges de fissure sur la face de peau
@ -60,16 +61,16 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
# --- inventaire des faces de peau : face de peau percée du pipe, extrémités du pipe
(facePeau, facesPeauSorted, edgesPeauFondIn) = identifieFacesPeau(ifil, verticesPipePeau, facesOnside, wireFondFiss,
verticesEdgesFondIn, pipexts, cercles,
(facePeau, facesPeauSorted, edgesPeauFondIn) = identifieFacesPeau(ifil, verticesPipePeau, facesOnside, wireFondFiss, \
verticesEdgesFondIn, pipexts, cercles, \
fillingFaceExterne, centreFondFiss)
# --- identification précise des edges et disques des faces de peau selon index extremité fissure
(endsEdgeFond, facesPipePeau, edgeRadFacePipePeau,
edgesCircPeau, verticesCircPeau, groupEdgesBordPeau,
bordsVifs, edgesFissurePeau, aretesVivesCoupees) = identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted,
edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees)
(endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, \
bordsVifs, edgesFissurePeau, aretesVivesCoupees) = \
identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, \
edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees)
dataPPFF = dict(endsEdgeFond = endsEdgeFond, # pour chaque face [points edge fond de fissure aux débouchés du pipe]
facesPipePeau = facesPipePeau, # pour chaque face [faces du pipe débouchantes]
@ -87,4 +88,3 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
)
return dataPPFF, aretesVivesCoupees

View File

@ -17,31 +17,36 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Identification des faces et edges de fissure externe pour maillage"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
def identifieFacesEdgesFissureExterne(fsFissuExt, edFisExtPe, edFisExtPi, edgesPipeFiss):
"""identification des faces et edges de fissure externe pour maillage"""
"""Identification des faces et edges de fissure externe pour maillage"""
logging.info('start')
logging.debug("---------------------------- fsFissuExt : {} ".format(fsFissuExt))
texte = "---------------------------- fsFissuExt : {} ".format(fsFissuExt)
logging.debug(texte)
facesFissExt = list()
edgesFissExtPeau = list()
edgesFissExtPipe = list()
for ifil in range(len(fsFissuExt)): # TODO: éliminer les doublons (comparer tous les vertices triés, avec mesure de distance ?)
facesFissExt += fsFissuExt[ifil]
for ifil, face in enumerate(fsFissuExt): # éliminer les doublons (comparer tous les vertices triés, avec mesure de distance ?)
facesFissExt += face
edgesFissExtPeau += edFisExtPe[ifil]
edgesFissExtPipe += edFisExtPi[ifil]
logging.debug("---------------------------- identification faces de fissure externes au pipe : {}".format(len(facesFissExt)))
texte = "---------------------------- identification faces de fissure externes au pipe : {}".format(len(facesFissExt))
logging.debug(texte)
# regroupement des faces de fissure externes au pipe.
if not facesFissExt:
logging.info("---------------------------- fsFissuExt : {} ".format(fsFissuExt))
texte = "---------------------------- fsFissuExt : {} ".format(fsFissuExt)
logging.info(texte)
raise Exception("stop identifieFacesEdgesFissureExterne ; aucune face de fissure externe au pipe n'a été trouvée.")
elif len(facesFissExt) > 1:
@ -49,17 +54,20 @@ def identifieFacesEdgesFissureExterne(fsFissuExt, edFisExtPe, edFisExtPi, edgesP
edgesPipeFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesPipeFiss)) # edgesFissExtPipe peut ne pas couvrir toute la longueur
# edgesPeauFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesFissExtPeau))
# il peut manquer des edges de faceFissureExterne en contact avec la peau dans edgesFissExtPeau
(isDone, closedFreeBoundaries, openFreeBoundaries) = geompy.GetFreeBoundary(faceFissureExterne)
(_, closedFreeBoundaries, _) = geompy.GetFreeBoundary(faceFissureExterne)
edgesBordFFE = list()
for bound in closedFreeBoundaries:
edgesBordFFE += geompy.ExtractShapes(bound, geompy.ShapeType["EDGE"], False)
edgesBordFFEid = [ (ed,geompy.GetSubShapeID(faceFissureExterne, ed)) for ed in edgesBordFFE]
logging.debug("edgesBordFFEid {}".format(edgesBordFFEid))
texte = "edgesBordFFEid {}".format(edgesBordFFEid)
logging.debug(texte)
edgesPPE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False)
edgesPPEid = [ geompy.GetSubShapeID(faceFissureExterne, ed) for ed in edgesPPE]
logging.debug("edgesPPEid {}".format(edgesPPEid))
texte = "edgesPPEid {}".format(edgesPPEid)
logging.debug(texte)
edgesPFE = [ edid[0] for edid in edgesBordFFEid if edid[1] not in edgesPPEid] # on garde toutes les edges de bord non en contact avec le pipe
logging.debug("edgesPFE {}".format(edgesPFE))
texte = "edgesPFE {}".format(edgesPFE)
logging.debug(texte)
edgesPeauFissureExterneC = geompy.MakeCompound(edgesPFE)
else:

View File

@ -17,13 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Inventaire des faces de peau"""
import logging
from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .sortFaces import sortFaces
from .extractionOrientee import extractionOrientee
@ -31,69 +32,64 @@ from .extractionOrientee import extractionOrientee
def identifieFacesPeau(ifil, verticesPipePeau, facesOnside, wireFondFiss,
verticesEdgesFondIn, pipexts, cercles,
fillingFaceExterne, centreFondFiss):
"""
inventaire des faces de peau : face de peau percée du pipe, extrémités du pipe
"""Inventaire des faces de peau : face de peau percée du pipe, extrémités du pipe
La partition avec le pipe peut créer un vertex (et un edge) de trop sur le cercle projeté,
quand le cercle est très proche de la face.
dans ce cas, la projection du cercle sur la face suivie d'une partition permet
d'éviter le point en trop
"""
logging.info('start')
facesAndFond = facesOnside
facesAndFond.append(wireFondFiss)
try:
partitionPeauByPipe = geompy.MakePartition(facesAndFond, pipexts, [], [], geompy.ShapeType["FACE"], 0, [], 1)
except:
logging.debug("probleme partition face pipe, contournement avec MakeSection")
sections = []
sections = list()
for pipext in pipexts:
sections.append(geompy.MakeSection(facesOnside[0], pipext))
partitionPeauByPipe = geompy.MakePartition(facesAndFond, sections, [], [], geompy.ShapeType["FACE"], 0, [], 1)
# contrôle edge en trop sur edges circulaires
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
edgeEnTrop = []
edgeEnTrop = list()
outilPart = pipexts
facesPeau = geompy.ExtractShapes(partitionPeauByPipe, geompy.ShapeType["FACE"], False)
facesPeauSorted, minsur, maxsurf = sortFaces(facesPeau)
for i, face in enumerate(facesPeauSorted[:-1]): # on ne teste que la ou les petites faces "circulaires"
facesPeauSorted, _, _ = sortFaces(facesPeau)
for face in facesPeauSorted[:-1]: # on ne teste que la ou les petites faces "circulaires"
nbv = geompy.NumberOfEdges(face)
logging.debug("nombre d'edges sur face circulaire: %s", nbv)
if nbv > 3:
edgeEnTrop.append(True) # TODO : distinguer les cas avec deux faces circulaires dont l'une est correcte
else:
edgeEnTrop.append(False)
edgeEnTrop.append(bool(nbv > 3)) # TODO : distinguer les cas avec deux faces circulaires dont l'une est correcte
refaire = sum(edgeEnTrop)
if refaire > 0:
dc = [(geompy.MinDistance(verticesEdgesFondIn[0], fac), i) for i, fac in enumerate(facesPeauSorted[:-1])]
dc.sort()
logging.debug("dc sorted: %s", dc)
i0 = dc[0][1] # indice de facesPeauSorted qui correspond à verticesEdgesFondIn[0], donc 0 pour cercles
direct = (i0 == 0)
for i, bad in enumerate(edgeEnTrop):
l_aux = [(geompy.MinDistance(verticesEdgesFondIn[0], fac), i_aux) for i_aux, fac in enumerate(facesPeauSorted[:-1])]
l_aux.sort()
logging.debug("l_aux sorted: %s", l_aux)
direct = bool(l_aux[0][1] == 0) # l_aux[0][1] = indice de facesPeauSorted qui correspond à verticesEdgesFondIn[0], donc 0 pour cercles
for i_aux, bad in enumerate(edgeEnTrop):
if direct:
j = i
j_aux = i_aux
else:
j = 1-i
j_aux = 1-i_aux
if bad:
outilPart[j] = geompy.MakeProjection(cercles[j],facesOnside[0])
pass
outilPart[j_aux] = geompy.MakeProjection(cercles[j_aux],facesOnside[0])
partitionPeauByPipe = geompy.MakePartition(facesAndFond, outilPart, [], [], geompy.ShapeType["FACE"], 0, [], 1)
pass
name="partitionPeauByPipe%d"%ifil
name="partitionPeauByPipe{}".format(ifil)
geomPublish(initLog.debug, partitionPeauByPipe, name)
[edgesPeauFondIn, edgesPeauFondOut, edgesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3)
[facesPeauFondIn, facesPeauFondOut, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3)
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
facesPeauSorted, minsur, maxsurf = sortFaces(facesPeauFondOn)
[edgesPeauFondIn, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3)
[_, _, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3)
if verticesPipePeau: # --- au moins une extrémité du pipe sur cette face de peau
facesPeauSorted, _, _ = sortFaces(facesPeauFondOn)
facePeau = facesPeauSorted[-1] # la plus grande face
else:
facePeau =geompy.MakePartition(facesPeauFondOn, [], [], [], geompy.ShapeType["FACE"], 0, [], 1)
facesPeauSorted = [facePeau]
name="facePeau%d"%ifil
name="facePeau{}".format(ifil)
geomPublish(initLog.debug, facePeau, name)
return (facePeau, facesPeauSorted, edgesPeauFondIn)
return (facePeau, facesPeauSorted, edgesPeauFondIn)

View File

@ -17,12 +17,10 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Création d'une nouvelle étude"""
import logging
myStudy = None
def initEtude():
"""
creation nouvelle etude salome
"""
"""Création nouvelle etude salome"""
from . import geomsmesh

View File

@ -17,6 +17,7 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Initialisations des impressions"""
import logging
import os
@ -34,6 +35,7 @@ ch = None
fh = None
def setLogger(logfile, level, formatter):
"""setLogger"""
global ch, fh
rootLogger = logging.getLogger('')
if fh is not None:
@ -53,9 +55,9 @@ def setLogger(logfile, level, formatter):
rootLogger.addHandler(ch)
ch.setFormatter(formatter)
rootLogger.setLevel(level)
def setDebug(logfile=None):
"""setDebug"""
global loglevel
loglevel = debug
level = logging.DEBUG
@ -64,6 +66,7 @@ def setDebug(logfile=None):
logging.info('start Debug %s', loglevel)
def setVerbose(logfile=None):
"""setVerbose"""
global loglevel
loglevel = info
level = logging.INFO
@ -72,28 +75,32 @@ def setVerbose(logfile=None):
logging.info('start Verbose %s', loglevel)
def setRelease(logfile=None):
"""setRelease"""
global loglevel
loglevel = warning
level = logging.WARNING
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
logging.warning('start Release %s', loglevel)
def setUnitTests(logfile=None):
"""setUnitTests"""
global loglevel
loglevel = critical
level = logging.CRITICAL
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
logging.critical('start UnitTests %s', loglevel)
def setPerfTests(logfile=None):
"""setPerfTests"""
global loglevel
loglevel = critical
level = logging.CRITICAL
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
logging.info('start PerfTests %s', loglevel)
def getLogLevel():
"""getLogLevel"""
return loglevel

View File

@ -22,14 +22,9 @@
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
import SMESH
import math
from .partitionBlocDefaut import partitionBlocDefaut
from .facesVolumesToriques import facesVolumesToriques
@ -50,17 +45,15 @@ from .putName import putName
def insereFissureElliptique(geometriesSaines, maillagesSains, \
shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, step=-1):
"""
TODO: a completer
"""
"""procedure complete fissure elliptique"""
logging.info('start')
geometrieSaine = geometriesSaines[0]
#geometrieSaine = geometriesSaines[0]
maillageSain = maillagesSains[0]
isHexa = maillagesSains[1]
shapeDefaut = shapesFissure[0]
tailleDefaut = shapesFissure[2]
pipe0 = shapesFissure[4]
#shapeDefaut = shapesFissure[0]
#tailleDefaut = shapesFissure[2]
#pipe0 = shapesFissure[4]
gener1 = shapesFissure[5]
pipe1 = shapesFissure[6]
facefis1 = shapesFissure[7]
@ -68,12 +61,12 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
ellipsoide1 = shapesFissure[9]
demiGrandAxe = shapeFissureParams['demiGrandAxe']
demiPetitAxe = shapeFissureParams['demiPetitAxe']
orientation = shapeFissureParams['orientation']
#demiGrandAxe = shapeFissureParams['demiGrandAxe']
#demiPetitAxe = shapeFissureParams['demiPetitAxe']
#orientation = shapeFissureParams['orientation']
nomRep = maillageFissureParams['nomRep']
nomFicSain = maillageFissureParams['nomFicSain']
#nomFicSain = maillageFissureParams['nomFicSain']
nomFicFissure = maillageFissureParams['nomFicFissure']
nbsegExt = maillageFissureParams['nbsegExt'] # 5
@ -84,18 +77,18 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
nbsegFis = maillageFissureParams['nbsegFis'] # 20
lensegEllipsoide = maillageFissureParams['lensegEllipso'] # 1.0
fichierMaillageSain = os.path.join(nomRep, '{}.med'.format(nomFicSain))
#fichierMaillageSain = os.path.join(nomRep, '{}.med'.format(nomFicSain))
fichierMaillageFissure = os.path.join(nomRep, '{}.med'.format(nomFicFissure))
facesDefaut = elementsDefaut[0]
centreDefaut = elementsDefaut[1]
normalDefaut = elementsDefaut[2]
#centreDefaut = elementsDefaut[1]
#normalDefaut = elementsDefaut[2]
extrusionDefaut = elementsDefaut[3]
dmoyen = elementsDefaut[4]
bordsPartages = elementsDefaut[5]
fillconts = elementsDefaut[6]
idFilToCont = elementsDefaut[7]
maillageSain = elementsDefaut[8]
#bordsPartages = elementsDefaut[5]
#fillconts = elementsDefaut[6]
#idFilToCont = elementsDefaut[7]
#maillageSain = elementsDefaut[8]
internalBoundary = elementsDefaut[9]
zoneDefaut = elementsDefaut[10]
zoneDefaut_skin = elementsDefaut[11]
@ -109,7 +102,7 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
#allonge = demiGrandAxe/demiPetitAxe
#rayonTore = demiPetitAxe/5.0
#generatrice, FaceGenFiss, Pipe_1, FaceFissure, Plane_1, Pipe1Part = self.toreFissure(demiPetitAxe, allonge, rayonTore)
#ellipsoide = self.ellipsoideDefaut(demiPetitAxe, allonge, rayonTore)
#ellipsoide = self.ellipsoideDefaut(demiPetitAxe, allonge)
## --- positionnement sur le bloc defaut de generatrice, tore et plan fissure
#if step == 6:
@ -133,7 +126,7 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
if step == 7:
return None
[ blocPartition, blocp, tore, \
[ blocPartition, _, tore, \
faceFissure, facesExternes, facesExtBloc, facesExtElli,
aretesInternes, ellipsoidep, sharedFaces, sharedEdges, edgesBords] = \
partitionBlocDefaut(extrusionDefaut, facesDefaut, gener1, pipe1, facefis1, ellipsoide1)
@ -145,7 +138,7 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
if step == 8:
return None
[facetore1, facetore2, volumeTore1, volumeTore2] = facesVolumesToriques(tore, plane1, facesDefaut)
[facetore1, facetore2, _, _] = facesVolumesToriques(tore, plane1, facesDefaut)
# --- faces 1/2 circulaires et edges dans le plan de fissure
if step == 9:
@ -163,20 +156,20 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
if step == 11:
return None
[genext, genint, gencnt] = sortGeneratrices(tore, geners)
[_, genint, gencnt] = sortGeneratrices(tore, geners)
# --- faces fissure dans et hors tore, et edges face hors tore
if step == 12:
return None
[facefissintore, facefissoutore, edgeint, edgeext, reverext] = \
[_, facefissoutore, _, edgeext, reverext] = \
facesFissure(ellipsoidep, faceFissure, extrusionDefaut, genint)
# --- identification des faces tore et fissure dans le solide hors tore
if step == 13:
return None
[blocFaceFiss, blocFaceTore1, blocFaceTore2] = \
[_, _, _] = \
facesToreInBloc(ellipsoidep, facefissoutore, facetore1, facetore2)
# --- identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face)
@ -185,14 +178,14 @@ def insereFissureElliptique(geometriesSaines, maillagesSains, \
if step == 14:
return None
extrusionFaceFissure, normfiss = shapeSurFissure(plane1)
extrusionFaceFissure, _ = shapeSurFissure(plane1)
# --- maillage du bloc partitionne
if step == 15:
return None
[bloc1, blocComplet] = \
[_, blocComplet] = \
meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, \
gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, \
aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, \

View File

@ -17,23 +17,23 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""procédure complète fissure générale"""
import os
import math
import logging
from . import initLog
import salome
from salome.smesh import smeshBuilder
import GEOM
import SMESH
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
import math
import bisect
from .extractionOrientee import extractionOrientee
from .extractionOrienteeMulti import extractionOrienteeMulti
@ -54,7 +54,6 @@ from .whichSide import whichSide
from .whichSideVertex import whichSideVertex
from .projettePointSurCourbe import projettePointSurCourbe
from .prolongeWire import prolongeWire
#from getCentreFondFiss import getCentreFondFiss
def insereFissureGenerale(maillagesSains,
shapesFissure, shapeFissureParams,
@ -106,15 +105,15 @@ def insereFissureGenerale(maillagesSains,
#extrusionsDefaut = elementsDefaut[3]
dmoyen = elementsDefaut[4]
bordsPartages = elementsDefaut[5]
fillconts = elementsDefaut[6]
idFilToCont = elementsDefaut[7]
#fillconts = elementsDefaut[6]
#idFilToCont = elementsDefaut[7]
maillageSain = elementsDefaut[8]
internalBoundary = elementsDefaut[9]
zoneDefaut = elementsDefaut[10]
zoneDefaut_skin = elementsDefaut[11]
zoneDefaut_internalFaces = elementsDefaut[12]
zoneDefaut_internalEdges = elementsDefaut[13]
edgeFondExt = elementsDefaut[14]
#edgeFondExt = elementsDefaut[14]
centreFondFiss = elementsDefaut[15]
tgtCentre = elementsDefaut[16]
@ -136,7 +135,7 @@ def insereFissureGenerale(maillagesSains,
geomPublish(initLog.debug, facesPortFissure, "facesPortFissure")
O, OX, OY, OZ = triedreBase()
O, _, _, _ = triedreBase()
# -----------------------------------------------------------------------------
# --- pipe de fond de fissure, prolongé, partition face fissure par pipe
@ -313,16 +312,16 @@ def insereFissureGenerale(maillagesSains,
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))
[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, u)
centre2 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, parametre)
geomPublishInFather(initLog.debug,partitionPeauFissFond, centre2, "centre2_%d"%iedf)
verticesEdgesFondIn.append(centre)
name = "verticeEdgesFondIn%d"%iedf
geomPublishInFather(initLog.debug,partitionPeauFissFond, centre, name)
norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, u)
norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, parametre)
geomPublishInFather(initLog.debug,partitionPeauFissFond, centre, "norm%d"%iedf)
cercle = geompy.MakeCircle(centre, norm, rayonPipe)
geomPublishInFather(initLog.debug,partitionPeauFissFond, cercle, "cerclorig%d"%iedf)
@ -493,8 +492,8 @@ def insereFissureGenerale(maillagesSains,
name="partitionPeauByPipe%d"%ifil
geomPublish(initLog.debug, partitionPeauByPipe, name)
[edgesPeauFondIn, edgesPeauFondOut, edgesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3)
[facesPeauFondIn, facesPeauFondOut, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3)
[edgesPeauFondIn, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3)
[_, _, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3)
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
facesPeauSorted, _, _ = sortFaces(facesPeauFondOn)
@ -659,7 +658,7 @@ def insereFissureGenerale(maillagesSains,
edgesPipeFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesPipeFiss)) # edgesFissExtPipe peut ne pas couvrir toute la longueur
# edgesPeauFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesFissExtPeau))
# il peut manquer des edges de faceFissureExterne en contact avec la peau dans edgesFissExtPeau
(isDone, closedFreeBoundaries, openFreeBoundaries) = geompy.GetFreeBoundary(faceFissureExterne)
(_, closedFreeBoundaries, _) = geompy.GetFreeBoundary(faceFissureExterne)
edgesBordFFE = list()
for bound in closedFreeBoundaries:
edgesBordFFE += geompy.ExtractShapes(bound, geompy.ShapeType["EDGE"], False)
@ -724,10 +723,10 @@ def insereFissureGenerale(maillagesSains,
xyz = meshFondExt.GetNodeXYZ(nodeId)
#logging.debug("nodeId %s, coords %s", nodeId, str(xyz))
pt = geompy.MakeVertex(xyz[0], xyz[1], xyz[2])
u, PointOnEdge, EdgeInWireIndex = geompy.MakeProjectionOnWire(pt, wireFondFiss) # u compris entre 0 et 1
parametre, PointOnEdge, EdgeInWireIndex = geompy.MakeProjectionOnWire(pt, wireFondFiss) # parametre compris entre 0 et 1
edgeOrder = edgesIdByOrientation[EdgeInWireIndex]
ptGSdic[(edgeOrder, EdgeInWireIndex, u)] = pt
#logging.debug("nodeId %s, u %s", nodeId, str(u))
ptGSdic[(edgeOrder, EdgeInWireIndex, parametre)] = pt
#logging.debug("nodeId %s, parametre %s", nodeId, str(parametre))
usort = sorted(ptGSdic)
logging.debug("nombre de points obtenus par deflexion %s",len(usort))
@ -735,10 +734,8 @@ def insereFissureGenerale(maillagesSains,
origins = list()
normals = list()
for edu in usort:
ied = edu[1]
u = edu[2]
vertcx = ptGSdic[edu]
norm = geompy.MakeTangentOnCurve(edgesFondFiss[ied], u)
norm = geompy.MakeTangentOnCurve(edgesFondFiss[edu[1]], edu[2])
plan = geompy.MakePlane(vertcx, norm, 3*rayonPipe)
part = geompy.MakePartition([plan], [wirePipeFiss], list(), list(), geompy.ShapeType["VERTEX"], 0, list(), 0)
liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True)
@ -912,7 +909,7 @@ def insereFissureGenerale(maillagesSains,
vs = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
if len(vs) > 2:
eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
[edsorted, minl,maxl] = sortEdges(eds)
[edsorted, _,maxl] = sortEdges(eds)
edge = edsorted[-1]
else:
maxl = geompy.BasicProperties(edge)[0]
@ -932,7 +929,7 @@ def insereFissureGenerale(maillagesSains,
logging.debug(" edges issues de la partition: %s", ednouv)
for ii, ed in enumerate(ednouv):
geomPublish(initLog.debug, ed, "ednouv%d"%ii)
[edsorted, minl,maxl] = sortEdges(ednouv)
[edsorted, _,maxl] = sortEdges(ednouv)
logging.debug(" longueur edge trouvée: %s", maxl)
edge = edsorted[-1]
edges.append(edge)
@ -998,7 +995,7 @@ def insereFissureGenerale(maillagesSains,
# --- ajustement precis des points sur edgesPipeFissureExterneC
edgesPFE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False)
verticesPFE = findWireIntermediateVertices(wirePipeFissureExterne) # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe)
verticesPFE, _ = findWireIntermediateVertices(wirePipeFissureExterne) # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe)
idiskmin = idisklim[0] + 1 # on ne prend pas le disque sur la peau, déjà ajusté
idiskmax = idisklim[1] # on ne prend pas le disque sur la peau, déjà ajusté
idiskint = list()
@ -1166,9 +1163,9 @@ def insereFissureGenerale(maillagesSains,
mVols.append(idVols)
pipeFissGroup = meshPipe.CreateEmptyGroup( SMESH.VOLUME, 'PIPEFISS' )
nbAdd = pipeFissGroup.AddFrom( meshPipe.GetMesh() )
_ = pipeFissGroup.AddFrom( meshPipe.GetMesh() )
nb, _, new_group = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries")
_, _, _ = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries")
edgesCircPipeGroup = [edgeCircPipe0Group, edgeCircPipe1Group]
# --- fin du maillage du pipe
@ -1176,7 +1173,7 @@ def insereFissureGenerale(maillagesSains,
# --- edges de bord, faces défaut à respecter
_ = smesh.CreateFilterManager()
nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
_, 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)
@ -1188,7 +1185,7 @@ def insereFissureGenerale(maillagesSains,
# on désigne les faces de peau en quadrangles par le groupe "skinFaces"
skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
nbAdd = skinFaces.AddFrom( internalBoundary.GetMesh() )
_ = skinFaces.AddFrom( internalBoundary.GetMesh() )
# --- maillage des éventuelles arêtes vives entre faces reconstruites
@ -1211,7 +1208,7 @@ def insereFissureGenerale(maillagesSains,
logging.info(text)
raise Exception(text)
grpAretesVives = meshAretesVives.CreateEmptyGroup( SMESH.EDGE, 'grpAretesVives' )
nbAdd = grpAretesVives.AddFrom( meshAretesVives.GetMesh() )
_ = grpAretesVives.AddFrom( meshAretesVives.GetMesh() )
# -----------------------------------------------------------------------
# --- maillage faces de fissure
@ -1247,9 +1244,9 @@ def insereFissureGenerale(maillagesSains,
putName(algo1d, "algo1d_edgeFissPeau")
putName(hypo1d, "hypo1d_edgeFissPeau")
grpFaceFissureExterne = meshFaceFiss.GroupOnGeom(faceFissureExterne, "fisOutPi", SMESH.FACE)
_ = meshFaceFiss.GroupOnGeom(faceFissureExterne, "fisOutPi", SMESH.FACE)
grpEdgesPeauFissureExterne = meshFaceFiss.GroupOnGeom(edgesPeauFissureExterneC,'edgesPeauFissureExterne',SMESH.EDGE)
grpEdgesPipeFissureExterne = meshFaceFiss.GroupOnGeom(edgesPipeFissureExterneC,'edgesPipeFissureExterne',SMESH.EDGE)
_ = meshFaceFiss.GroupOnGeom(edgesPipeFissureExterneC,'edgesPipeFissureExterne',SMESH.EDGE)
is_done = meshFaceFiss.Compute()
text = "meshFaceFiss.Compute"
@ -1361,7 +1358,7 @@ def insereFissureGenerale(maillagesSains,
raise Exception(text)
GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
nbAdd = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
_ = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
meshesFacesPeau.append(meshFacePeau)
# --- regroupement des maillages du défaut
@ -1415,7 +1412,7 @@ def insereFissureGenerale(maillagesSains,
maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin,
zoneDefaut_internalFaces, zoneDefaut_internalEdges)
putName(maillageSain, nomFicSain+"_coupe")
extrusionFaceFissure, normfiss = shapeSurFissure(facesPortFissure)
_, normfiss = shapeSurFissure(facesPortFissure)
maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut,
None, None, 'COMPLET', normfiss)
@ -1428,13 +1425,13 @@ def insereFissureGenerale(maillagesSains,
logging.info("réorientation face de fissure FACE1")
grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
nb = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
_ = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
logging.info("réorientation face de fissure FACE2")
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))
_ = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1))
_ = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
logging.info("export maillage fini")

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,10 +17,9 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Cette fonction permet de scanner la liste de noeuds qui composent le maillage passé en paramètre
"""
Created on Mon Jun 23 14:49:36 2014
@author: I48174 (Olivier HOAREAU)
"""
@ -29,189 +28,193 @@ import SMESH
from .geomsmesh import smesh
def lookForCorner(maillageAScanner):
""" Cette fonction permet de scanner la liste de noeuds qui composent le
maillage passé en paramètre. On recherche un ou plusieurs coins, ce
qui implique les caractéristiques suivantes:
- le noeud doit appartenir au moins à trois éléments distincts
- chaque élément doit appartenir à un ensemble distinct
La fonction renvoie une liste de coins par l'intermédiaire de l'IDs
chaque noeud. La liste contient en général au maximum deux coins.
"""
logging.info("start")
allNodeIds = maillageAScanner.GetNodesId() # On stocke tout les noeuds
listOfCorners = []
for ND in allNodeIds:
# On parcours la liste de noeuds
listOfElements = maillageAScanner.GetNodeInverseElements(ND)
if len(listOfElements) >=3:
# On teste le nombre d'éléments qui partagent le même noeud
# --- Filtre selon le critère 'coplanar' --- #
listOfCriterion = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30) \
for elem in listOfElements]
listOfFilters = [smesh.GetFilterFromCriteria([criteria]) for criteria in listOfCriterion]
listOfSets = [maillageAScanner.GetIdsFromFilter(filter) for filter in listOfFilters]
if listOfSets.count(listOfSets[0]) == len(listOfSets):
# Si toutes les listes d'éléments sont similaires, on retourne
# au début pour éviter de travailler sur des éléments inutiles.
# Exemple : un noeud appartenant à 4 éléments sur la même face.
continue
for s in listOfSets:
while listOfSets.count(s) > 1:
# On supprime tant que la liste d'éléments n'est pas unique.
listOfSets.remove(s)
if len(listOfSets) >= 3:
# Si on a au moins 3 listes d'élements différentes, on considère
# qu'il y a présence d'un coin.
listOfCorners.append(ND)
return listOfCorners
""" Cette fonction permet de scanner la liste de noeuds qui composent le
maillage passé en paramètre. On recherche un ou plusieurs coins, ce
qui implique les caractéristiques suivantes:
- le noeud doit appartenir au moins à trois éléments distincts
- chaque élément doit appartenir à un ensemble distinct
La fonction renvoie une liste de coins par l'intermédiaire de l'IDs
chaque noeud. La liste contient en général au maximum deux coins.
"""
logging.info("start")
allNodeIds = maillageAScanner.GetNodesId() # On stocke tout les noeuds
listOfCorners = list()
for noeud in allNodeIds:
# On parcours la liste de noeuds
listOfElements = maillageAScanner.GetNodeInverseElements(noeud)
if len(listOfElements) >=3:
# On teste le nombre d'éléments qui partagent le même noeud
# --- Filtre selon le critère 'coplanar' --- #
listOfCriterion = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30) \
for elem in listOfElements]
listOfFilters = [smesh.GetFilterFromCriteria([criteria]) for criteria in listOfCriterion]
listOfSets = [maillageAScanner.GetIdsFromFilter(filtre) for filtre in listOfFilters]
if listOfSets.count(listOfSets[0]) == len(listOfSets):
# Si toutes les listes d'éléments sont similaires, on retourne
# au début pour éviter de travailler sur des éléments inutiles.
# Exemple : un noeud appartenant à 4 éléments sur la même face.
continue
for l_aux in listOfSets:
while listOfSets.count(l_aux) > 1:
# On supprime tant que la liste d'éléments n'est pas unique.
listOfSets.remove(l_aux)
if len(listOfSets) >= 3:
# Si on a au moins 3 listes d'élements différentes, on considère
# qu'il y a présence d'un coin.
listOfCorners.append(noeud)
return listOfCorners
def createLinesFromMesh(maillageSupport):
""" Cette fonction permet de générer une liste de lignes à partir du
maillage support passé en paramètre. On démarre à partir d'un coin
simple et on parcourt tout les noeuds pour former une ligne. Soit la
figure ci-dessous :
1_____4_____7 On part du coin N1, et on cherche les noeuds
| | | successifs tels que [1, 2, 3]. Lorsqu'on arrive
| 1 | 3 | arrive sur le noeud de fin de ligne N3, on repart
| | | du noeud précédent du premier élément (E1), à
2_____5_____8 savoir le noeud N4. On suit les noeuds succesifs
| | | [4, 5, 6] comme précédemment et ainsi de suite.
| 2 | 4 | Lorsqu'on arrive sur le dernier noeud de la
| | | dernière ligne, à savoir le noeud N9, on considère
3_____6_____9 que toutes les lignes sont créées.
La fonction retourne une liste de lignes utilisées par la suite.
"""
logging.info("start")
allNodeIds = maillageSupport.GetNodesId()
while len(allNodeIds):
nodeIds = allNodeIds
for idNode in nodeIds: # rechercher un coin
elems = maillageSupport.GetNodeInverseElements(idNode)
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
xyz = maillageSupport.GetNodeXYZ(idStart)
logging.debug("idStart %s, coords %s", idStart, str(xyz))
nodelines =[] # on va constituer une liste de lignes de points
nextLine = True
ligneFinale = False
while nextLine:
logging.debug("--- une ligne")
idNode = idStart
elem = elemStart
if ligneFinale:
agauche = False # sens de parcours des 4 noeuds d'un quadrangle
nextLine = False
""" Cette fonction permet de générer une liste de lignes à partir du
maillage support passé en paramètre. On démarre à partir d'un coin
simple et on parcourt tout les noeuds pour former une ligne. Soit la
figure ci-dessous :
1_____4_____7 On part du coin N1, et on cherche les noeuds
| | | successifs tels que [1, 2, 3]. Lorsqu'on arrive
| 1 | 3 | arrive sur le noeud de fin de ligne N3, on repart
| | | du noeud précédent du premier élément (E1), à
2_____5_____8 savoir le noeud N4. On suit les noeuds succesifs
| | | [4, 5, 6] comme précédemment et ainsi de suite.
| 2 | 4 | Lorsqu'on arrive sur le dernier noeud de la
| | | dernière ligne, à savoir le noeud N9, on considère
3_____6_____9 que toutes les lignes sont créées.
La fonction retourne une liste de lignes utilisées par la suite.
"""
logging.info("start")
allNodeIds = maillageSupport.GetNodesId()
while len(allNodeIds):
nodeIds = allNodeIds
for idNode in nodeIds: # rechercher un coin
elems = maillageSupport.GetNodeInverseElements(idNode)
if len(elems) == 1:
# un coin: un noeud, un element quadrangle
elem = elems[0]
idNode_c = idNode
break
idStart = idNode_c # le noeud de coin
elemStart = elem # l'élément quadrangle au coin
xyz = maillageSupport.GetNodeXYZ(idStart)
logging.debug("idStart %s, coords %s", idStart, str(xyz))
nodelines = list() # on va constituer une liste de lignes de points
nextLine = True
ligneFinale = False
while nextLine:
logging.debug("--- une ligne")
idNode = idStart
elem = elemStart
if ligneFinale:
agauche = False # sens de parcours des 4 noeuds d'un quadrangle
nextLine = False
else:
agauche = True
ligneIncomplete = True # on commence une ligne de points
debutLigne = True
nodeline = list()
elemline = list()
while ligneIncomplete: # compléter la ligne de points
nodeline.append(idNode)
allNodeIds.remove(idNode)
elemline.append(elem)
nodes = maillageSupport.GetElemNodes(elem)
i_aux = nodes.index(idNode) # repérer l'index du noeud courant (i_aux) dans l'élément quadrangle (0 a 3)
if agauche: # déterminer le noeud suivant (j_aux) et celui opposé (k_aux) dans le quadrangle
if i_aux < 3:
j_aux = i_aux+1
else:
j_aux = 0
if j_aux < 3:
k_aux = j_aux+1
else:
k_aux = 0
else:
if i_aux > 0:
j_aux = i_aux -1
else:
j_aux = 3
if j_aux > 0:
k_aux = j_aux -1
else:
k_aux = 3
isuiv = nodes[j_aux] # noeud suivant
iapres = nodes[k_aux] # noeud opposé
if debutLigne:
debutLigne = False
# précédent a trouver, dernière ligne : précédent au lieu de suivant
if agauche:
if i_aux > 0:
iprec = nodes[i_aux -1]
else:
agauche = True
ligneIncomplete = True # on commence une ligne de points
debutLigne = True
nodeline = []
elemline = []
while ligneIncomplete: # compléter la ligne de points
nodeline.append(idNode)
allNodeIds.remove(idNode)
elemline.append(elem)
nodes = maillageSupport.GetElemNodes(elem)
i = nodes.index(idNode) # repérer l'index du noeud courant (i) dans l'élément quadrangle (0 a 3)
if agauche: # déterminer le noeud suivant (j) et celui opposé (k) dans le quadrangle
if i < 3:
j = i+1
else:
j = 0
if j < 3:
k = j+1
else:
k = 0
else:
if i > 0:
j = i -1
else:
j = 3
if j > 0:
k = j -1
else:
k = 3
isuiv = nodes[j] # noeud suivant
iapres = nodes[k] # noeud opposé
if debutLigne:
debutLigne = False
# précédent a trouver, dernière ligne : précédent au lieu de suivant
if agauche:
if i > 0:
iprec = nodes[i -1]
else:
iprec = nodes[3]
idStart = iprec
elems3 = maillageSupport.GetNodeInverseElements(iprec)
if len(elems3) == 1: # autre coin
ligneFinale = True
else:
for elem3 in elems3:
if elem3 != elem:
elemStart = elem3
break
#print nodes, idNode, isuiv, iapres
elems1 = maillageSupport.GetNodeInverseElements(isuiv)
elems2 = maillageSupport.GetNodeInverseElements(iapres)
ligneIncomplete = False
for elem2 in elems2:
if elems1.count(elem2) and elem2 != elem:
ligneIncomplete = True
idNode = isuiv
elem = elem2
break
if not ligneIncomplete:
nodeline.append(isuiv)
allNodeIds.remove(isuiv)
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))
return nodelines
iprec = nodes[3]
idStart = iprec
elems3 = maillageSupport.GetNodeInverseElements(iprec)
if len(elems3) == 1: # autre coin
ligneFinale = True
else:
for elem3 in elems3:
if elem3 != elem:
elemStart = elem3
break
#print nodes, idNode, isuiv, iapres
elems1 = maillageSupport.GetNodeInverseElements(isuiv)
elems2 = maillageSupport.GetNodeInverseElements(iapres)
ligneIncomplete = False
for elem2 in elems2:
if elems1.count(elem2) and elem2 != elem:
ligneIncomplete = True
idNode = isuiv
elem = elem2
break
if not ligneIncomplete:
nodeline.append(isuiv)
allNodeIds.remove(isuiv)
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))
return nodelines
def createNewMeshesFromCorner(maillageSupport, listOfCorners):
""" Cette fonction permet de générer un nouveau maillage plus facile à
utiliser. On démarre d'un coin et on récupère les trois éléments
auquel le noeud appartient. Grâce à un filtre 'coplanar' sur les trois
éléments, on peut générer des faces distinctes.
"""
logging.info("start")
tmp = []
listOfNewMeshes = []
for corner in listOfCorners:
elems = maillageSupport.GetNodeInverseElements(corner)
for i, elem in enumerate(elems):
# --- Filtre selon le critère 'coplanar' --- #
critere = smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30)
filtre = smesh.GetFilterFromCriteria([critere])
grp = maillageSupport.GroupOnFilter(SMESH.FACE, 'grp', filtre)
# On copie le maillage en fonction du filtre
msh = smesh.CopyMesh(grp, 'new_{0}'.format(i + 1), False, True)
# On stocke l'ensemble des noeuds du maillage dans tmp
# On ajoute le maillage à la liste des nouveaux maillages
# seulement s'il n'y est pas déjà
tmp.append(msh.GetNodesId())
if tmp.count(msh.GetNodesId()) <= 1:
listOfNewMeshes.append(msh)
return listOfNewMeshes
""" Cette fonction permet de générer un nouveau maillage plus facile à
utiliser. On démarre d'un coin et on récupère les trois éléments
auquel le noeud appartient. Grâce à un filtre 'coplanar' sur les trois
éléments, on peut générer des faces distinctes.
"""
logging.info("start")
tmp = list()
listOfNewMeshes = list()
for corner in listOfCorners:
elems = maillageSupport.GetNodeInverseElements(corner)
for i_aux, elem in enumerate(elems):
# --- Filtre selon le critère 'coplanar' --- #
critere = smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30)
filtre = smesh.GetFilterFromCriteria([critere])
grp = maillageSupport.GroupOnFilter(SMESH.FACE, 'grp', filtre)
# On copie le maillage en fonction du filtre
msh = smesh.CopyMesh(grp, 'new_{0}'.format(i_aux+1), False, True)
# On stocke l'ensemble des noeuds du maillage dans tmp
# On ajoute le maillage à la liste des nouveaux maillages
# seulement s'il n'y est pas déjà
tmp.append(msh.GetNodesId())
if ( tmp.count(msh.GetNodesId()) <= 1 ):
listOfNewMeshes.append(msh)
return listOfNewMeshes

View File

@ -17,24 +17,24 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""edges de bord, faces défaut à respecter"""
import logging
import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
import SMESH
from .putName import putName
def mailleAretesEtJonction(internalBoundary, aretesVivesCoupees, lgAretesVives):
"""
edges de bord, faces défaut à respecter
"""
"""edges de bord, faces défaut à respecter"""
logging.info('start')
aFilterManager = smesh.CreateFilterManager()
nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
criteres = []
_ = smesh.CreateFilterManager()
_, 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)
@ -45,7 +45,7 @@ def mailleAretesEtJonction(internalBoundary, aretesVivesCoupees, lgAretesVives):
# on désigne les faces de peau en quadrangles par le groupe "skinFaces"
skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
nbAdd = skinFaces.AddFrom( internalBoundary.GetMesh() )
_ = skinFaces.AddFrom( internalBoundary.GetMesh() )
# --- maillage des éventuelles arêtes vives entre faces reconstruites
@ -70,6 +70,6 @@ def mailleAretesEtJonction(internalBoundary, aretesVivesCoupees, lgAretesVives):
raise Exception(text)
grpAretesVives = meshAretesVives.CreateEmptyGroup( SMESH.EDGE, 'grpAretesVives' )
nbAdd = grpAretesVives.AddFrom( meshAretesVives.GetMesh() )
_ = grpAretesVives.AddFrom( meshAretesVives.GetMesh() )
return (internalBoundary, bordsLibres, grpAretesVives)

View File

@ -17,13 +17,14 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""maillage faces de fissure"""
import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from salome.smesh import smeshBuilder
from .geomsmesh import smesh
from .putName import putName

View File

@ -22,13 +22,14 @@
import logging
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
from salome.smesh import smeshBuilder
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .geomsmesh import smesh
from . import initLog
from .putName import putName
@ -36,12 +37,12 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
mailleur="MeshGems"):
mailleur="MeshGems", nro_cas=-1):
"""maillage faces de peau"""
logging.info('start')
logging.info(mailleur)
logging.info(mailleur+" pour le cas n° %d"%nro_cas)
nbFacesFilling = len(partitionsPeauFissFond)
boutFromIfil = [None for i in range(nbFacesFilling)]
boutFromIfil = [None for _ in range(nbFacesFilling)]
if idFillingFromBout[0] != idFillingFromBout[1]: # repérage des extremites du pipe quand elles débouchent sur des faces différentes
boutFromIfil[idFillingFromBout[0]] = 0
boutFromIfil[idFillingFromBout[1]] = 1
@ -65,9 +66,9 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
putName(algo1d, "algo1d_bordsLibres", ifil)
putName(hypo1d, "hypo1d_bordsLibres", ifil)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
putName(algo1d, "algo1d_bordsLibres", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsLibres", ifil, nro_cas)
else:
@ -84,36 +85,37 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil)
putName(algo1d, "algo1d_bordsLibres", ifil)
putName(hypo1d, "hypo1d_bordsLibres", ifil)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
putName(algo1d, "algo1d_bordsLibres", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsLibres", ifil, nro_cas)
logging.info("b")
algo1d = meshFacePeau.UseExisting1DElements(geom=geompy.MakeCompound(edgesFissurePeau))
hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0)
putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil)
putName(algo1d, "algo1d_edgePeauFiss", ifil)
putName(hypo1d, "hypo1d_edgePeauFiss", ifil)
putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil, nro_cas)
putName(algo1d, "algo1d_edgePeauFiss", ifil, nro_cas)
putName(hypo1d, "hypo1d_edgePeauFiss", ifil, nro_cas)
if bordsVifs is not None:
algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs)
hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0)
putName(algo1d.GetSubMesh(), "bordsVifs", ifil)
putName(algo1d, "algo1d_bordsVifs", ifil)
putName(hypo1d, "hypo1d_bordsVifs", ifil)
putName(algo1d.GetSubMesh(), "bordsVifs", ifil, nro_cas)
putName(algo1d, "algo1d_bordsVifs", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsVifs", ifil, nro_cas)
for i, edgeCirc in enumerate(edgesCircPeau):
logging.info("i = {}".format(i))
for i_aux, edgeCirc in enumerate(edgesCircPeau):
texte = "i_aux = {}".format(i_aux)
logging.info(texte)
if edgeCirc is not None:
algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc) # addToStudy() failed ?
if boutFromIfil[ifil] is None:
hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i] ],0,0)
hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i_aux] ],0,0)
else:
hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0)
name = "cercle%d"%i
putName(algo1d.GetSubMesh(), name, ifil)
putName(algo1d, "algo1d_" + name, ifil)
putName(hypo1d, "hypo1d_" + name, ifil)
name = "cercle{}".format(i_aux)
putName(algo1d.GetSubMesh(), name, ifil, nro_cas)
putName(algo1d, "algo1d_" + name, ifil, nro_cas)
putName(hypo1d, "hypo1d_" + name, ifil, nro_cas)
logging.info("c")
logging.info("Maillage avec %s", mailleur)
@ -134,9 +136,9 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
hypo2d.SetQuadAllowed( 0 )
logging.info("d")
putName(algo2d.GetSubMesh(), "facePeau", ifil)
putName(algo2d, "algo2d_facePeau", ifil)
putName(hypo2d, "hypo2d_facePeau", ifil)
putName(algo2d.GetSubMesh(), "facePeau", ifil, nro_cas)
putName(algo2d, "algo2d_facePeau", ifil, nro_cas)
putName(hypo2d, "hypo2d_facePeau", ifil, nro_cas)
is_done = meshFacePeau.Compute()
text = "meshFacePeau {} .Compute".format(ifil)

View File

@ -17,33 +17,33 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Maillage du bloc partitionné"""
import logging
import SMESH
from salome.smesh import smeshBuilder
from salome.StdMeshers import StdMeshersBuilder
from .geomsmesh import geompy
from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from salome.StdMeshers import StdMeshersBuilder
from .putName import putName
# -----------------------------------------------------------------------------
# --- maillage du bloc partitionne
def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, \
gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, \
aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, \
nbsegExt, nbsegGen, nbsegRad, scaleRad, reverses, reverext, nbsegCercle, nbsegFis, dmoyen, lensegEllipsoide, \
mailleur="MeshGems"):
"""Maillage du bloc partitionné
TODO: a completer
"""
"""Maillage du bloc partitionné"""
logging.info('start')
# --- edges de bord à respecter
aFilterManager = smesh.CreateFilterManager()
nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
_ = smesh.CreateFilterManager()
_, 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)
@ -55,22 +55,22 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
bloc1 = smesh.Mesh(blocPartition)
for i, sharedFaces_i in enumerate(sharedFaces):
for i_aux, sharedFaces_i in enumerate(sharedFaces):
algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN, geom=sharedFaces_i)
hypo2d = algo2d.Parameters(which=smesh.SIMPLE)
hypo2d.SetLocalLength(lensegEllipsoide)
hypo2d.LengthFromEdges()
hypo2d.SetAllowQuadrangles(0)
putName(algo2d.GetSubMesh(), "sharedFaces", i)
putName(algo2d, "algo2d_sharedFaces", i)
putName(hypo2d, "hypo2d_sharedFaces", i)
putName(algo2d.GetSubMesh(), "sharedFaces", i_aux)
putName(algo2d, "algo2d_sharedFaces", i_aux)
putName(hypo2d, "hypo2d_sharedFaces", i_aux)
for i, sharedEdges_i in enumerate(sharedEdges):
for i_aux, sharedEdges_i in enumerate(sharedEdges):
algo1d = bloc1.Segment(geom=sharedEdges_i)
hypo1d = algo1d.LocalLength(lensegEllipsoide)
putName(algo1d.GetSubMesh(), "sharedEdges", i)
putName(algo1d, "algo1d_sharedEdges", i)
putName(hypo1d, "hypo1d_sharedEdges", i)
putName(algo1d.GetSubMesh(), "sharedEdges", i_aux)
putName(algo1d, "algo1d_sharedEdges", i_aux)
putName(hypo1d, "hypo1d_sharedEdges", i_aux)
declareAlgoEllipsoideFirst = False
if declareAlgoEllipsoideFirst:
@ -90,32 +90,32 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
putName(algo1d, "algo1d_tore")
putName(hypo1d, "hypo1d_tore")
for i, faces_i in enumerate(faces):
for i_aux, faces_i in enumerate(faces):
algo2d = bloc1.Quadrangle(geom=faces_i)
hypo2d = smesh.CreateHypothesis('QuadrangleParams')
hypo2d.SetTriaVertex( geompy.GetSubShapeID(blocPartition,centres[i]) )
hypo2d.SetTriaVertex( geompy.GetSubShapeID(blocPartition,centres[i_aux]) )
hypo2d.SetQuadType( StdMeshersBuilder.QUAD_STANDARD )
status = bloc1.AddHypothesis(hypo2d,faces_i)
putName(algo2d.GetSubMesh(), "faces", i)
putName(algo2d, "algo2d_faces", i)
putName(hypo2d, "hypo2d_faces", i)
_ = bloc1.AddHypothesis(hypo2d,faces_i)
putName(algo2d.GetSubMesh(), "faces", i_aux)
putName(algo2d, "algo2d_faces", i_aux)
putName(hypo2d, "hypo2d_faces", i_aux)
for i, edges_i in enumerate(edges):
for i_aux, edges_i in enumerate(edges):
algo1d = bloc1.Segment(geom=edges_i)
if reverses[i] > 0:
if reverses[i_aux] > 0:
hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ geompy.GetSubShapeID(blocPartition,edges_i) ])
else:
hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ ])
putName(algo1d.GetSubMesh(), "edges", i)
putName(algo1d, "algo1d_edges", i)
putName(hypo1d, "hypo1d_edges", i)
hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ ])
putName(algo1d.GetSubMesh(), "edges", i_aux)
putName(algo1d, "algo1d_edges", i_aux)
putName(hypo1d, "hypo1d_edges", i_aux)
for i, circles_i in enumerate(circles):
for i_aux, circles_i in enumerate(circles):
algo1d = bloc1.Segment(geom=circles_i)
hypo1d = algo1d.NumberOfSegments(nbsegCercle)
putName(algo1d.GetSubMesh(), "circles", i)
putName(algo1d, "algo1d_circles", i)
putName(hypo1d, "hypo1d_circles", i)
putName(algo1d.GetSubMesh(), "circles", i_aux)
putName(algo1d, "algo1d_circles", i_aux)
putName(hypo1d, "hypo1d_circles", i_aux)
if len(edgeext) == 1:
densite = int(round(nbsegFis/2))
@ -130,24 +130,23 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
else:
longTotal = 0
longEdgeExts = list()
for i, edgeext_i in enumerate(edgeext):
for edgeext_i in edgeext:
props = geompy.BasicProperties(edgeext_i)
longEdgeExts.append(props[0])
longTotal += props[0]
for i, edgeext_i in enumerate(edgeext):
local = longTotal/nbsegFis
nbLocal = int(round(nbsegFis*longEdgeExts[i]/longTotal))
for i_aux, edgeext_i in enumerate(edgeext):
nbLocal = int(round(nbsegFis*longEdgeExts[i_aux]/longTotal))
densite = int(round(nbLocal/2))
algo1d = bloc1.Segment(geom=edgeext_i)
hypo1d = algo1d.NumberOfSegments(nbLocal)
hypo1d.SetDistrType( 2 )
hypo1d.SetConversionMode( 1 )
hypo1d.SetTableFunction( [ 0, densite, 0.8, 1, 1, 1 ] )
if reverext[i]:
if reverext[i_aux]:
hypo1d.SetReversedEdges([ geompy.GetSubShapeID(blocPartition, edgeext_i) ])
putName(algo1d.GetSubMesh(), "edgeext", i)
putName(algo1d, "algo1d_edgeext", i)
putName(hypo1d, "hypo1d_edgeext", i)
putName(algo1d.GetSubMesh(), "edgeext", i_aux)
putName(algo1d, "algo1d_edgeext", i_aux)
putName(hypo1d, "hypo1d_edgeext", i_aux)
algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facefissoutore)
hypo2d = algo2d.LengthFromEdges()
@ -159,25 +158,25 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
maxElemArea = 0.5*dmoyen*dmoyen
logging.debug("dmoyen %s, maxElemArea %s", dmoyen, maxElemArea)
for i, facesExternes_i in enumerate(facesExternes):
for i_aux, facesExternes_i in enumerate(facesExternes):
algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facesExternes_i)
hypo2d = algo2d.MaxElementArea(maxElemArea)
if edgesBords is None:
algo1d = bloc1.Segment(geom=facesExternes_i)
hypo1d = algo1d.NumberOfSegments(1)
putName(algo2d.GetSubMesh(), "facesExternes", i)
putName(algo2d, "algo2d_facesExternes", i)
putName(hypo2d, "hypo2d_facesExternes", i)
putName(algo2d.GetSubMesh(), "facesExternes", i_aux)
putName(algo2d, "algo2d_facesExternes", i_aux)
putName(hypo2d, "hypo2d_facesExternes", i_aux)
if edgesBords is None:
putName(algo1d, "algo1d_facesExternes", i)
putName(hypo1d, "hypo1d_facesExternes", i)
putName(algo1d, "algo1d_facesExternes", i_aux)
putName(hypo1d, "hypo1d_facesExternes", i_aux)
for i, aretesInternes_i in enumerate(aretesInternes):
for i_aux, aretesInternes_i in enumerate(aretesInternes):
algo1d = bloc1.Segment(geom=aretesInternes_i)
hypo1d = algo1d.NumberOfSegments(nbsegExt)
putName(algo1d.GetSubMesh(), "aretesInternes", i)
putName(algo1d, "algo1d_aretesInternes", i)
putName(hypo1d, "hypo1d_aretesInternes", i)
putName(algo1d.GetSubMesh(), "aretesInternes", i_aux)
putName(algo1d, "algo1d_aretesInternes", i_aux)
putName(hypo1d, "hypo1d_aretesInternes", i_aux)
if edgesBords is not None:
algo1d = bloc1.UseExisting1DElements(geom=edgesBords)
@ -193,16 +192,16 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
putName(algo3d, "algo3d_ellipsoide")
putName(hypo3d, "hypo3d_ellipsoide")
faceFissure1 = bloc1.GroupOnGeom(faceFissure,'FACE1',SMESH.FACE)
noeudsFondFissure = bloc1.GroupOnGeom(gencnt,'nfondfis',SMESH.NODE)
_ = bloc1.GroupOnGeom(faceFissure,'FACE1',SMESH.FACE)
_ = bloc1.GroupOnGeom(gencnt,'nfondfis',SMESH.NODE)
groups_faceCommuneEllipsoideBloc = list()
for i, sharedFaces_i in enumerate(sharedFaces):
name = "faceCommuneEllipsoideBloc_%d"%i
for i_aux, sharedFaces_i in enumerate(sharedFaces):
name = "faceCommuneEllipsoideBloc_{}".format(i_aux)
groups_faceCommuneEllipsoideBloc.append(bloc1.GroupOnGeom(sharedFaces_i, name, SMESH.FACE))
groups_faceExterneBloc = list()
for i, facesExtBloc_i in enumerate(facesExtBloc):
name = "faceExterneBloc_%d"%i
for i_aux, facesExtBloc_i in enumerate(facesExtBloc):
name = "faceExterneBloc_{}".format(i_aux)
groups_faceExterneBloc.append(bloc1.GroupOnGeom(facesExtBloc_i, name, SMESH.FACE))
is_done = bloc1.Compute()
@ -214,18 +213,18 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
logging.info(text)
raise Exception(text)
nbRemoved = bloc1.RemoveOrphanNodes()
_ = bloc1.RemoveOrphanNodes()
skinBlocMeshes = list()
for i, groups_faceCommuneEllipsoideBloc_i in enumerate(groups_faceCommuneEllipsoideBloc):
name = "faceCommuneEllipsoideBloc_%d"%i
for i_aux, groups_faceCommuneEllipsoideBloc_i in enumerate(groups_faceCommuneEllipsoideBloc):
name = "faceCommuneEllipsoideBloc_{}".format(i_aux)
skinBlocMeshes.append(smesh.CopyMesh(groups_faceCommuneEllipsoideBloc_i, name, 0, 0))
for i, groups_faceExterneBloc_i in enumerate(groups_faceExterneBloc):
name = "faceExterneBloc_%d"%i
for i_aux, groups_faceExterneBloc_i in enumerate(groups_faceExterneBloc):
name = "faceExterneBloc_{}".format(i_aux)
skinBlocMeshes.append(smesh.CopyMesh(groups_faceExterneBloc_i, name, 0, 0))
meshesBloc = [internalBoundary.GetMesh()]
for i, skinBlocMeshes_i in enumerate(skinBlocMeshes):
for skinBlocMeshes_i in skinBlocMeshes:
meshesBloc.append(skinBlocMeshes_i.GetMesh())
blocMesh = smesh.Concatenate(meshesBloc, 1, 1, 1e-05,False)

View File

@ -17,64 +17,61 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Trouver les vertices intermédiaires d'un wire"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- trouver les vertices intermediaires d'un wire
def orderEdgesFromWire(aWire):
"""
fournit les edges ordonnées d'un wire selon ExtractShapes(,,False),
"""Fournit les edges ordonnées d'un wire selon ExtractShapes(,,False),
et l'ordre des edges selon le sens de parcours (ordre des indices de la liste d'edges)
"""
logging.info("start")
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False)
idverts = dict()
for i, edge in enumerate(edges):
for i_aux, edge in enumerate(edges):
verts = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True)
# idverts[(i,0)] = verts[0]
# idverts[(i,1)] = verts[1]
v0 = geompy.MakeVertexOnCurve(edge, 0.0)
dist = geompy.MinDistance(v0, verts[0])
vertex_a = geompy.MakeVertexOnCurve(edge, 0.0)
dist = geompy.MinDistance(vertex_a, verts[0])
if dist < 1.e-4:
idverts[(i,0)] = verts[0]
idverts[(i,1)] = verts[1]
idverts[(i_aux,0)] = verts[0]
idverts[(i_aux,1)] = verts[1]
else:
idverts[(i,0)] = verts[1]
idverts[(i,1)] = verts[0]
idverts[(i_aux,0)] = verts[1]
idverts[(i_aux,1)] = verts[0]
idsubs = dict()
for kv, sub in idverts.items():
for i_aux, sub in idverts.items():
subid = geompy.GetSubShapeID(aWire, sub)
if subid in list(idsubs.keys()):
idsubs[subid].append(kv)
if ( subid in idsubs ):
idsubs[subid].append(i_aux)
else:
idsubs[subid] = [kv]
idsubs[subid] = [i_aux]
debut = -1
fin = -1
for k, kvs in idsubs.items():
fin = -1
for _, kvs in idsubs.items():
if len(kvs) == 1: # une extremité
kv = kvs[0]
if kv[1] == 0:
debut = kv[0]
kv0 = kvs[0]
if kv0[1] == 0:
debut = kv0[0]
else:
fin = kv[0]
logging.debug("nombre d'edges: {}, indice edge début: {}, fin: {}".format(len(edges), debut, fin))
fin = kv0[0]
texte = "nombre d'edges: {}, indice edge début: {}, fin: {}".format(len(edges), debut, fin)
logging.debug(texte)
if debut < 0:
logging.critical("les edges du wire ne sont pas orientées dans le même sens: pas de début trouvé")
return edges, list(range(len(edges)))
orderedList = [debut]
while len(orderedList) < len(edges):
bout = orderedList[-1]
vertex = idverts[(bout,1)]
for k, v in idverts.items():
for k, vertex_a in idverts.items():
if k[0] not in orderedList:
if geompy.MinDistance(vertex, v) < 1.e-4:
if geompy.MinDistance(vertex, vertex_a) < 1.e-4:
if k[1] == 0:
orderedList.append(k[0])
break
@ -82,9 +79,12 @@ def orderEdgesFromWire(aWire):
logging.critical("les edges du wire ne sont pas orientées dans le même sens: une edge à l'envers")
return edges, list(range(len(edges)))
logging.debug("liste des edges ordonnées selon le sens de parcours : {}".format(orderedList))
texte = "liste des edges ordonnées selon le sens de parcours : {}".format(orderedList)
logging.debug(texte)
accessList = list(range(len(orderedList)))
for i,k in enumerate(orderedList):
accessList[k] = i
logging.info("position ordonnée des edges selon le sens de parcours : {}".format(accessList))
for i_aux,k_aux in enumerate(orderedList):
accessList[k_aux] = i_aux
texte = "position ordonnée des edges selon le sens de parcours : {}".format(accessList)
logging.info(texte)
return edges, accessList

View File

@ -17,15 +17,17 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Partition du bloc defaut par generatrice, tore et plan fissure"""
import logging
import GEOM
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- partition du bloc defaut par generatrice, tore et plan fissure
from . import initLog
def partitionBlocDefaut(volDefaut, facesDefaut, gener, pipe,
facefis, ellipsoide):
@ -56,9 +58,9 @@ def partitionBlocDefaut(volDefaut, facesDefaut, gener, pipe,
#geomPublishInFather(initLog.debug, volDefautPart, gencnt, 'generatrice' )
solids = geompy.ExtractShapes(blocp, geompy.ShapeType["SOLID"], True)
vols = []
for i in range(len(solids)):
props = geompy.BasicProperties(solids[i])
vols = list()
for solid in solids:
props = geompy.BasicProperties(solid)
vols.append(props[2])
maxvol = max(vols)
imaxvol = vols.index(maxvol)
@ -72,110 +74,111 @@ def partitionBlocDefaut(volDefaut, facesDefaut, gener, pipe,
geomPublishInFather(initLog.debug, volDefautPart, ellipsoidep, 'ellipsoide' )
sharedFaces = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["FACE"])
for i in range(len(sharedFaces)):
name = "faceCommuneEllipsoideBloc_%d"%i
geomPublishInFather(initLog.debug,blocp, sharedFaces[i], name)
for i_aux, face in enumerate(sharedFaces):
name = "faceCommuneEllipsoideBloc_{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp, face, name)
#sharedEdges = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["EDGE"])
allSharedEdges = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["EDGE"])
sharedEdges = []
for i in range(len(allSharedEdges)):
if geompy.NbShapes(allSharedEdges[i], geompy.ShapeType["VERTEX"]) > 1: # edge non degeneree
sharedEdges.append(allSharedEdges[i])
for i in range(len(sharedEdges)):
name = "edgeCommuneEllipsoideBloc_%d"%i
geomPublishInFather(initLog.debug,blocp, sharedEdges[i], name)
sharedEdges = list()
for face in allSharedEdges:
if geompy.NbShapes(face, geompy.ShapeType["VERTEX"]) > 1: # edge non degeneree
sharedEdges.append(face)
for i_aux, edge in enumerate(sharedEdges):
name = "edgeCommuneEllipsoideBloc_{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp, edge, name)
facesExternes = []
facesExtBloc = []
facesExtElli = []
facesExternes = list()
facesExtBloc = list()
facesExtElli = list()
faces = geompy.ExtractShapes(facesDefaut, geompy.ShapeType["FACE"], True)
if len(faces) == 0:
if not faces:
faces = [facesDefaut]
for i in range(len(faces)):
faceExt = geompy.GetInPlace(ellipsoidep, faces[i])
for i_aux, face in enumerate(faces):
faceExt = geompy.GetInPlace(ellipsoidep, face)
if faceExt is not None:
name = "faceExterne_e%d"%i
name = "faceExterne_e{}".format(i_aux)
geomPublishInFather(initLog.debug,ellipsoidep, faceExt, name)
facesExternes.append(faceExt)
facesExtElli.append(faceExt)
faceExt = geompy.GetInPlace(blocp, faces[i])
faceExt = geompy.GetInPlace(blocp, face)
if faceExt is not None:
name = "faceExterne_b%d"%i
name = "faceExterne_b{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp, faceExt, name)
facesExternes.append(faceExt)
facesExtBloc.append(faceExt)
else:
logging.info(" recherche faces externes par GetShapesOnShape")
vertex = geompy.MakeVertexOnSurface(faces[i], 0.5, 0.5)
normal = geompy.GetNormal(faces[i], vertex)
extrusionFace = geompy.MakePrismVecH(faces[i], normal, 1)
#extrusionFace = geompy.MakePrismVecH2Ways(faces[i], normal, 0.1)
vertex = geompy.MakeVertexOnSurface(face, 0.5, 0.5)
normal = geompy.GetNormal(face, vertex)
extrusionFace = geompy.MakePrismVecH(face, normal, 1)
#extrusionFace = geompy.MakePrismVecH2Ways(face, normal, 0.1)
#extrusionFace = geompy.MakeScaleTransform(extrusionFace, vertex, 1.01)
name = "extrusionFace_b%d"%i
name = "extrusionFace_b{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp, extrusionFace, name)
#facesExt = geompy.GetShapesOnShape(extrusionFace, blocp, geompy.ShapeType["FACE"], GEOM.ST_ONIN)
facesExt = geompy.GetShapesOnShape(extrusionFace, blocp, geompy.ShapeType["FACE"], GEOM.ST_ON)
for j in range(len(facesExt)):
name = "faceExterne_b%d_%d"%(i,j)
geomPublishInFather(initLog.debug,blocp, facesExt[j], name)
facesExternes.append(facesExt[j])
facesExtBloc.append(facesExt[j])
for j_aux, face_ext in enumerate(facesExt):
name = "faceExterne_b{}_{}".format(i_aux,j_aux)
geomPublishInFather(initLog.debug,blocp, face_ext, name)
facesExternes.append(face_ext)
facesExtBloc.append(face_ext)
if len(facesExtBloc) < len(faces): # toutes les faces externes du bloc n'ont pas été trouvées. TODO eliminer les detections multiples
logging.info(" recherche faces externes par aretes partagees avec faces externes ellipsoide")
facesBloc = geompy.ExtractShapes(blocp, geompy.ShapeType["FACE"], True)
for i in range(len(facesBloc)):
for i_aux, face in enumerate(facesBloc):
notOnEllipsoide = True
for j in range(len(sharedFaces)): # eliminer les faces communes avec l'ellipsoide
if facesBloc[i].IsSame(sharedFaces[j]):
for j_aux, sharedface in enumerate(sharedFaces): # eliminer les faces communes avec l'ellipsoide
if face.IsSame(sharedface):
notOnEllipsoide = False
break
if notOnEllipsoide:
for j in range(len(facesExtElli)): # les faces recherchees ont une ou plusieurs edge communes avec la ou les faces externes de l'ellipsoide
allSharedEdges = []
for j_aux, face_ext_elli in enumerate(facesExtElli): # les faces recherchees ont une ou plusieurs edge communes avec la ou les faces externes de l'ellipsoide
allSharedEdges = list()
try:
allSharedEdges += geompy.GetSharedShapesMulti([facesBloc[i], facesExtElli[j]], geompy.ShapeType["EDGE"])
allSharedEdges += geompy.GetSharedShapesMulti([face, face_ext_elli], geompy.ShapeType["EDGE"])
except:
pass
if len(allSharedEdges) > 0:
name = "faceExterne_b%d_%d"%(i,j)
geomPublishInFather(initLog.debug,blocp, facesBloc[i], name)
facesExternes.append(facesBloc[i])
facesExtBloc.append(facesBloc[i])
if allSharedEdges:
name = "faceExterne_b{}_{}".format(i_aux,j_aux)
geomPublishInFather(initLog.debug,blocp, face, name)
facesExternes.append(face)
facesExtBloc.append(face)
aretesInternes = []
for i in range(len(facesExternes)):
for j in range(i+1,len(facesExternes)):
shared = []
aretesInternes = list()
for i_aux, face_ext_i in enumerate(facesExternes):
for j_aux, face_ext_j in enumerate(facesExternes[i_aux+1:]):
shared = list()
try:
shared += geompy.GetSharedShapesMulti([facesExternes[i], facesExternes[j]], geompy.ShapeType["EDGE"])
shared += geompy.GetSharedShapesMulti([face_ext_i, face_ext_j], geompy.ShapeType["EDGE"])
except:
logging.info("no shared edges in %s,%s",i,j)
texte = "no shared edges in {},{}".format(i_aux,j_aux)
logging.info(texte)
else:
aretesInternes += shared
for i in range(len(aretesInternes)):
name = "aretesInternes_%d"%i
geomPublishInFather(initLog.debug,blocp, aretesInternes[i], name)
for i_aux, edge in enumerate(aretesInternes):
name = "aretesInternes_{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp, edge, name)
edgesBords = []
l_edgesBords = list()
for faceExtB in facesExtBloc:
edges = geompy.ExtractShapes(faceExtB, geompy.ShapeType["EDGE"], True)
for i in range(len(edges)):
for i_aux, edge in enumerate(edges):
isInterne = False
for j in range(len(aretesInternes)):
if edges[i].IsSame(aretesInternes[j]):
for arete in aretesInternes:
if edge.IsSame(arete):
isInterne = True
break
if not isInterne:
edgesBords.append(edges[i])
name = "edgeBord%d"%i
geomPublishInFather(initLog.debug,blocp,edges[i] , name)
group = None
if len(edgesBords) > 0:
group = geompy.CreateGroup(blocp, geompy.ShapeType["EDGE"])
geompy.UnionList(group, edgesBords)
edgesBords = group
l_edgesBords.append(edge)
name = "edgeBord{}".format(i_aux)
geomPublishInFather(initLog.debug,blocp,edge , name)
if l_edgesBords:
edgesBords = geompy.CreateGroup(blocp, geompy.ShapeType["EDGE"])
geompy.UnionList(edgesBords, l_edgesBords)
else:
edgesBords = None
return volDefautPart, blocp, tore, faceFissure, facesExternes, facesExtBloc, facesExtElli, aretesInternes, ellipsoidep, sharedFaces, sharedEdges, edgesBords

View File

@ -17,15 +17,15 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Partition volume sain et bloc, face du bloc recevant la fissure"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
# -----------------------------------------------------------------------------
# --- partition volume sain et bloc, face du bloc recevant la fissure
from . import initLog
def partitionVolumeSain(volumeSain,boiteDefaut):
"""

View File

@ -17,16 +17,19 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Pipe de fond de fissure, prolongé, partition face fissure par pipe"""
import math
import logging
import math
import traceback
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .findWireEndVertices import findWireEndVertices
from .prolongeWire import prolongeWire
import traceback
from .fissError import fissError
def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
@ -46,7 +49,7 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
#fondFissCoupe = geompy.GetInPlaceByHistory(shapeDefaut, fondFiss) #= inutile
geomPublish(initLog.debug, shapeDefaut, 'shapeDefaut_coupe')
#geomPublishInFather(initLog.debug,shapeDefaut, fondFissCoupe, 'fondFiss_coupe')
extrem, norms = findWireEndVertices(fondFiss, True)
logging.debug("extrem: %s, norm: %s",extrem, norms)
cercle = geompy.MakeCircle(extrem[0], norms[0], rayonPipe)
@ -66,10 +69,10 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
geomPublish(initLog.debug, fissPipe, 'fissPipe')
partPipe = geompy.GetInPlaceByHistory(partFissPipe, pipeFiss)
geomPublish(initLog.debug, partPipe, 'partPipe')
edgesPipeFiss = geompy.GetSharedShapesMulti([fissPipe, partPipe], geompy.ShapeType["EDGE"])
for i, edge in enumerate(edgesPipeFiss):
name = "edgePipe%d"%i
for i_aux, edge in enumerate(edgesPipeFiss):
name = "edgePipe{}".format(i_aux)
geomPublishInFather(initLog.debug,fissPipe, edge, name)
try:
wirePipeFiss = geompy.MakeWire(edgesPipeFiss)
@ -77,13 +80,13 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
wirePipeFiss = geompy.MakeCompound(edgesPipeFiss)
logging.debug("wirePipeFiss construit sous forme de compound")
geomPublish(initLog.debug, wirePipeFiss, "wirePipeFiss")
wireFondFiss = geompy.GetInPlace(partFissPipe,fondFiss)
edgesFondFiss = geompy.GetSharedShapesMulti([fissPipe, wireFondFiss], geompy.ShapeType["EDGE"])
for i, edge in enumerate(edgesFondFiss):
name = "edgeFondFiss%d"%i
for i_aux, edge in enumerate(edgesFondFiss):
name = "edgeFondFiss{}".format(i_aux)
geomPublishInFather(initLog.debug,fissPipe, edge, name)
wireFondFiss = geompy.MakeWire(edgesFondFiss)
geomPublish(initLog.debug, wireFondFiss,"wireFondFiss")
geomPublish(initLog.debug, wireFondFiss,"wireFondFiss")
return (fissPipe, edgesPipeFiss, edgesFondFiss, wirePipeFiss, wireFondFiss)
return (fissPipe, edgesPipeFiss, edgesFondFiss, wirePipeFiss, wireFondFiss)

View File

@ -17,19 +17,19 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Peau interne du defaut dans le maillage sain"""
import logging
from .geomsmesh import smesh
import SMESH
import traceback
from .fissError import fissError
import SMESH
from .geomsmesh import smesh
from .fissError import fissError
from .listOfExtraFunctions import lookForCorner
from .fusionMaillageAttributionDefaut import fusionMaillageDefaut
# -----------------------------------------------------------------------------
# --- peau interne du defaut dans le maillage sain
def peauInterne(fichierMaillage, shapeDefaut, nomZones):
"""Retrouve les groupes de défaut dans le maillage sain modifié par CreateHoleSkin (CreeZoneDefautMaillage)
@ -37,7 +37,7 @@ def peauInterne(fichierMaillage, shapeDefaut, nomZones):
Remarque : intérêt du passage par fichierMaillage plutôt que par maillageSain ?
"""
logging.info("start")
([maillageSain], status) = smesh.CreateMeshesFromMED(fichierMaillage)
([maillageSain], _) = smesh.CreateMeshesFromMED(fichierMaillage)
groups = maillageSain.GetGroups()
#print ("groupes :")
@ -78,7 +78,7 @@ def peauInterne(fichierMaillage, shapeDefaut, nomZones):
for entity_type in info:
#print (". {} : {})".format(entity_type, info[entity_type]))
nbelem += info[entity_type]
if ("Entity_Hexa" == str(entity_type)):
if ( str(entity_type) == "Entity_Hexa" ):
nbhexa += info[entity_type]
nbhexa += info[entity_type]
#print ("==> nbelem = {}, nbhexa = {}".format(nbelem,nbhexa))
@ -92,16 +92,16 @@ def peauInterne(fichierMaillage, shapeDefaut, nomZones):
texte += "<li>Il n'y a pas que des hexaèdres réglés linéaires dans la zone à remailler (notamment mailles quadratiques, tetraèdres non traités)</li></ul>"
raise fissError(traceback.extract_stack(),texte)
nbAdded, maillageSain, DefautBoundary = maillageSain.MakeBoundaryElements( SMESH.BND_2DFROM3D, 'DefBound', '', 0, [ zoneDefaut ])
_, maillageSain, DefautBoundary = maillageSain.MakeBoundaryElements( SMESH.BND_2DFROM3D, 'DefBound', '', 0, [ zoneDefaut ])
internal = maillageSain.GetMesh().CutListOfGroups( [ DefautBoundary ], [ zoneDefaut_skin ], 'internal' )
internalBoundary = smesh.CopyMesh( internal, 'internalBoundary', 0, 0)
maillageDefautCible = smesh.CopyMesh(zoneDefaut_skin, 'maillageCible', 0, 0)
listOfCorner = lookForCorner(maillageDefautCible)
logging.debug("listOfCorner = {}".format(listOfCorner))
texte = "listOfCorner = {}".format(listOfCorner)
logging.debug(texte)
if listOfCorner:
logging.info("présence de coins à la surface externe de la zone à reconstruire")
zoneDefaut_skin, internalBoundary = fusionMaillageDefaut(maillageSain, maillageDefautCible, internalBoundary, zoneDefaut_skin, shapeDefaut, listOfCorner)
logging.info("présence de coins à la surface externe de la zone à reconstruire")
zoneDefaut_skin, internalBoundary = fusionMaillageDefaut(maillageSain, maillageDefautCible, internalBoundary, zoneDefaut_skin, shapeDefaut, listOfCorner)
return maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges

View File

@ -17,25 +17,26 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Calcul de produit mixte pour orientation"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- calcul de produit mixte pour orientation
def produitMixte(origine, point_1, point_2, point_3):
"""produit mixte de 3 vecteurs a partir d'une origine et 3 points"""
coordo = geompy.PointCoordinates(origine)
coord_1 = geompy.PointCoordinates(point_1)
coord_2 = geompy.PointCoordinates(point_2)
coord_3 = geompy.PointCoordinates(point_3)
def produitMixte(o, p1, p2, p3):
"""
produit mixte de 3 vecteurs a partir d'une origine et 3 points
"""
coordo = geompy.PointCoordinates(o)
coordp1 = geompy.PointCoordinates(p1)
coordp2 = geompy.PointCoordinates(p2)
coordp3 = geompy.PointCoordinates(p3)
u = [coordp1[0] - coordo[0], coordp1[1] - coordo[1], coordp1[2] - coordo[2]]
v = [coordp2[0] - coordo[0], coordp2[1] - coordo[1], coordp2[2] - coordo[2]]
w = [coordp3[0] - coordo[0], coordp3[1] - coordo[1], coordp3[2] - coordo[2]]
pm = (u[0]*v[1]*w[2] + v[0]*w[1]*u[2] + w[0]*u[1]*v[2]) - (u[0]*w[1]*v[2] + v[0]*u[1]*w[2] + w[0]*v[1]*u[2])
logging.debug('pm=%s', pm)
return pm
o_1 = [coord_1[0] - coordo[0], coord_1[1] - coordo[1], coord_1[2] - coordo[2]]
o_2 = [coord_2[0] - coordo[0], coord_2[1] - coordo[1], coord_2[2] - coordo[2]]
o_3 = [coord_3[0] - coordo[0], coord_3[1] - coordo[1], coord_3[2] - coordo[2]]
prmi = ( o_1[0]*o_2[1]*o_3[2] + o_2[0]*o_3[1]*o_1[2] + o_3[0]*o_1[1]*o_2[2] ) \
- ( o_1[0]*o_3[1]*o_2[2] + o_2[0]*o_1[1]*o_3[2] + o_3[0]*o_2[1]*o_1[2] )
logging.debug('prmi=%s', prmi)
return prmi

View File

@ -17,47 +17,46 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Projection d'un point sur une courbe."""
import logging
from .geomsmesh import geompy
import logging
import math
# -----------------------------------------------------------------------------
# --- projection d'un point sur une courbe.
def projettePointSurCourbe(pt, edge):
def projettePointSurCourbe(point, edge):
"""
projection d'un point p sur une courbe c
on suppose que la distance (c(u), p) passe par un minimum quand u varie entre 0 et 1
et qu'elle presente pas de minimum local
et qu'elle presente pas de minimum local
"""
#logging.debug("start")
dist = []
nbSlices = 50
du = 1.0/nbSlices
for i in range(nbSlices + 1):
p = geompy.MakeVertexOnCurve(edge, du*i)
d = geompy.MinDistance(p,pt)
dist.append((d,i))
dist = list()
nb_slices = 50
delta = 1.0/float(nb_slices)
for i_aux in range(nb_slices + 1):
pti = geompy.MakeVertexOnCurve(edge, delta*float(i_aux))
dpti = geompy.MinDistance(pti,point)
dist.append((dpti,i_aux))
dist.sort()
#logging.debug("dist %s", dist)
umin = du*dist[0][1]
umax = du*dist[1][1]
umin = delta*dist[0][1]
umax = delta*dist[1][1]
#umin = 0.0
#umax = 1.0
tol = 1.e-8
pmin = geompy.MakeVertexOnCurve(edge, umin)
pmax = geompy.MakeVertexOnCurve(edge, umax)
dmin = geompy.MinDistance(pmin,pt)
dmax = geompy.MinDistance(pmax,pt)
dmin = geompy.MinDistance(pmin,point)
dmax = geompy.MinDistance(pmax,point)
dext = geompy.MinDistance(pmin,pmax)
i=0
while dext > tol and i < 100 :
i = i+1
i_aux = 0
while ( ( dext > tol ) and ( i_aux < 100 ) ):
i_aux += 1
utest = (umax + umin) / 2.0
ptest = geompy.MakeVertexOnCurve(edge, utest)
dtest = geompy.MinDistance(ptest,pt)
ptest = geompy.MakeVertexOnCurve(edge, utest)
dtest = geompy.MinDistance(ptest,point)
if dmin < dmax:
umax = utest
pmax = ptest
@ -68,10 +67,11 @@ def projettePointSurCourbe(pt, edge):
dmin = dtest
dext = geompy.MinDistance(pmin,pmax)
#logging.debug('umin=%s umax=%s dmin=%s dmax=%s dtest=%s dext=%s', umin,umax,dmin,dmax,dtest,dext)
if abs(utest) < 1.e-7:
if ( abs(utest) < 1.e-7 ):
utest = 0.0
if abs(1.0-utest) < 1.e-7:
elif ( abs(1.0-utest) < 1.e-7 ):
utest = 1.0
logging.debug('u=%s, nbiter=%s dtest=%s dext=%s',utest,i,dtest,dext)
logging.debug('u=%s, nbiter=%s dtest=%s dext=%s',utest,i_aux,dtest,dext)
return utest

View File

@ -17,30 +17,29 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Prolongation des segments extrémités des polylines, pour la découpe"""
import logging
from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- prolongation des segments extremité des polylines, pour la découpe
from .geomsmesh import geompy
def prolongeVertices(vertices):
"""
Prolongation des segments extremité d'une polyline définie par un vecteur de points.
Chaque nouvelle extremité est obtenue par symétrie point du voisin de cette ancienne extrémité
(symétrie de centre l'ancienne extrémite) : les segments extremes sont doublés.
Chaque nouvelle extrémité est obtenue par symétrie point du voisin de cette ancienne extrémité
(symétrie de centre l'ancienne extrémite) : les segments extrêmes sont doublés.
@param vertices : liste ordonnée des points (geomObject) de la polyline
@return vertices : liste avec les deux extremités modifiées
"""
logging.info("start")
if len(vertices) < 2:
return vertices
v0 = vertices[0]
v1 = vertices[1]
m0 = geompy.MakeMirrorByPoint(v1, v0)
ve = vertices[-1]
vd = vertices[-2]
m1 = geompy.MakeMirrorByPoint(vd, ve)
vertices[0] = m0
vertices[-1] = m1
m_0 = geompy.MakeMirrorByPoint(vertices[1], vertices[0])
m_1 = geompy.MakeMirrorByPoint(vertices[-2], vertices[-1])
vertices[0] = m_0
vertices[-1] = m_1
return vertices

View File

@ -17,38 +17,40 @@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
"""Prolongation d'un wire par deux segments tangents"""
import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .orderEdgesFromWire import orderEdgesFromWire
# -----------------------------------------------------------------------------
# --- prolongation d'un wire par deux segments tangents
def prolongeWire(aWire, extrem, norms, lg):
"""
"""
def prolongeWire(aWire, extrem, norms, longueur):
"""Prolongation d'un wire par deux segments tangents"""
logging.info("start")
if geompy.NumberOfEdges(aWire) > 1:
if ( geompy.NumberOfEdges(aWire) > 1 ):
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"])
uneSeuleEdge = False
else:
edges = [aWire]
uneSeuleEdge = True
edgesBout = []
for i, v1 in enumerate(extrem):
exts = [geompy.MakeTranslationVectorDistance(v1, norms[i], l) for l in (-lg, lg)]
dists = [(geompy.MinDistance(v, aWire), i , v) for i, v in enumerate(exts)]
edgesBout = list()
for i_aux, v_1 in enumerate(extrem):
exts = [geompy.MakeTranslationVectorDistance(v_1, norms[i_aux], lg_aux) for lg_aux in (-longueur, longueur)]
dists = [(geompy.MinDistance(v, aWire), j_aux , v) for j_aux, v in enumerate(exts)]
dists.sort()
v2 = dists[-1][-1]
edge = geompy.MakeEdge(v1, v2)
v_2 = dists[-1][-1]
edge = geompy.MakeEdge(v_1, v_2)
edges.append(edge)
edgesBout.append(edge)
name = "extrem%d"%i
name = "extrem{}".format(i_aux)
geomPublish(initLog.debug, edge, name)
try:
wireProlonge = geompy.MakeWire(edges)
geomPublish(initLog.debug, wireProlonge, "wireProlonge")
@ -61,16 +63,19 @@ def prolongeWire(aWire, extrem, norms, lg):
edgelist, accessList = orderEdgesFromWire(aWire)
edge1 = edgelist[accessList[0]]
if geompy.MinDistance(edgesBout[0], edge1) < 1.e-4 :
i0 = 0
i1 = 1
i_0 = 0
i_1 = 1
else:
i0 = 1
i1 = 0
wireProlonge = edgesBout[i0]
for i in range(len(edgelist)):
wireProlonge = geompy.MakeWire([wireProlonge, edgelist[accessList[i]]])
geomPublish(initLog.debug, wireProlonge, "wireProlonge_%d"%i)
wireProlonge = geompy.MakeWire([wireProlonge,edgesBout[i1]])
i_0 = 1
i_1 = 0
wireProlonge = edgesBout[i_0]
for i_aux in range(len(edgelist)):
wireProlonge = geompy.MakeWire([wireProlonge, edgelist[accessList[i_aux]]])
geomPublish(initLog.debug, wireProlonge, "wireProlonge_{}".format(i_aux))
wireProlonge = geompy.MakeWire([wireProlonge,edgesBout[i_1]])
geomPublish(initLog.debug, wireProlonge, "wireProlonge")
logging.warning("prolongation wire pas a pas OK")
return wireProlonge

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,14 +18,27 @@
# 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:
suffixe = "_{}".format(i_suff)
name += suffixe
# préfixe éventuel :
if i_pref >= 0:
prefixe = "Cas{:02d}_".format(i_pref)
name = prefixe + name
def putName(objmesh,name, i=-1):
if i >= 0:
suffix = "_%d"%i
name += suffix
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

Some files were not shown because too many files have changed in this diff Show More