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() mailleur = self.mailleur2d3d()
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \ maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \ maillageFissureParams, elementsDefaut, \
step, mailleur) step, mailleur, self.numeroCas)
return maillageFissure return maillageFissure
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Ajustement precis des points sur edgesPipeFissureExterneC"""
import logging import logging
@ -25,13 +26,11 @@ from .findWireIntermediateVertices import findWireIntermediateVertices
from .projettePointSurCourbe import projettePointSurCourbe from .projettePointSurCourbe import projettePointSurCourbe
def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne, gptsdisks, idisklim): def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne, gptsdisks, idisklim):
""" """Ajustement precis des points sur edgesPipeFissureExterneC"""
ajustement precis des points sur edgesPipeFissureExterneC
"""
logging.info('start') logging.info('start')
edgesPFE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False) 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é 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é idiskmax = idisklim[1] # on ne prend pas le disque sur la peau, déjà ajusté
idiskint = [] idiskint = []
@ -39,8 +38,8 @@ def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne
distPtVt = [] distPtVt = []
for idisk in range(idiskmin, idiskmax): for idisk in range(idiskmin, idiskmax):
gptdsk = gptsdisks[idisk] gptdsk = gptsdisks[idisk]
pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe point = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe
distPtVt.append((geompy.MinDistance(pt, vtx), idisk)) distPtVt.append((geompy.MinDistance(point, vtx), idisk))
distPtVt.sort() distPtVt.sort()
idiskint.append(distPtVt[0][1]) idiskint.append(distPtVt[0][1])
gptsdisks[idiskint[-1]][0][-1] = vtx gptsdisks[idiskint[-1]][0][-1] = vtx
@ -50,12 +49,12 @@ def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne
break break
logging.debug("ajustement point sur edgePipeFissureExterne: %s", idisk) logging.debug("ajustement point sur edgePipeFissureExterne: %s", idisk)
gptdsk = gptsdisks[idisk] gptdsk = gptsdisks[idisk]
pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe point = 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)] distPtEd = [(geompy.MinDistance(point, edgePFE), k, edgePFE) for k, edgePFE in enumerate(edgesPFE)]
distPtEd.sort() distPtEd.sort()
edgePFE = distPtEd[0][2] edgePFE = distPtEd[0][2]
u = projettePointSurCourbe(pt, edgePFE) point_bis = projettePointSurCourbe(point, edgePFE)
ptproj = geompy.MakeVertexOnCurve(edgePFE, u) ptproj = geompy.MakeVertexOnCurve(edgePFE, point_bis)
gptsdisks[idisk][0][-1] = ptproj 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""bloc defaut"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- bloc defaut
def blocDefaut(blocDim): 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 @param blocdim : demi arete
@return cube (geomObject) @return cube (geomObject)
""" """
logging.info("start") logging.info("start")
geomObj_1 = geompy.MakeVertex(-blocDim, -blocDim, -blocDim) point_1 = geompy.MakeVertex(-blocDim, -blocDim, -blocDim)
geomObj_2 = geompy.MakeVertex( blocDim, blocDim, blocDim) point_2 = geompy.MakeVertex( blocDim, blocDim, blocDim)
Box = geompy.MakeBoxTwoPnt(geomObj_1, geomObj_2) le_cube = geompy.MakeBoxTwoPnt(point_1, point_2)
#geompy.addToStudy( Box_1, 'Box_1' )
return Box return le_cube

View File

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

View File

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

View File

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

View File

@ -17,25 +17,25 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""subShapes communes à deux listes"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- subShapes communes à deux listes
def commonSubShapes(obj, sub1, sub2): def commonSubShapes(obj, sub1, sub2):
""" """liste de subshapes communes"""
liste de subshapes communes
"""
logging.info("start") logging.info("start")
idsub1 = {}
subList = [] idsub1 = dict()
for s in sub1: for subshape in sub1:
idsub1[geompy.GetSubShapeID(obj, s)] = s idsub1[geompy.GetSubShapeID(obj, subshape)] = subshape
for s in sub2:
idsub = geompy.GetSubShapeID(obj, s) l_subshapes = list()
if idsub in list(idsub1.keys()): for subshape in sub2:
subList.append(s) idsub = geompy.GetSubShapeID(obj, subshape)
logging.debug("subList=%s", subList) if idsub in idsub1:
return subList 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""compoundFromList"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
def compoundFromList(elements, nom=None): def compoundFromList(elements, nom=None):
"""compoundFromList""" """compoundFromList"""
logging.debug('start') logging.debug('start')
shapeList = list() l_shapes = list()
for a in elements: for elem in elements:
if not isinstance(a, list): if not isinstance(elem, list):
shapeList.append(a) l_shapes.append(elem)
else: else:
if a[0] is not None: if elem[0] is not None:
shapeList.append(a[0]) l_shapes.append(elem[0])
if nom is not None: if nom is not None:
for i,a in enumerate(shapeList): for indice, elem in enumerate(l_shapes):
nomi = nom +"%d"%i nomi = nom +"%d"%indice
logging.debug('nom: %s',nomi) logging.debug('nom: %s',nomi)
geomPublish(initLog.debug, a, nomi) geomPublish(initLog.debug, elem, nomi)
shapeCompound = None shapeCompound = None
if len(shapeList) > 0: if l_shapes:
shapeCompound =geompy.MakeCompound(shapeList) shapeCompound = geompy.MakeCompound(l_shapes)
nomc = "compound_%s"%nom nomc = "compound_%s"%nom
geomPublish(initLog.debug, shapeCompound, nomc) geomPublish(initLog.debug, shapeCompound, nomc)
return shapeCompound return shapeCompound

View File

@ -20,13 +20,13 @@
"""Construit les arêtes débouchantes""" """Construit les arêtes débouchantes"""
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
#from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM 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, def construitEdgesRadialesDebouchantes(idisklim, idiskout, gptsdisks, raydisks,
facesPipePeau, edgeRadFacePipePeau, nbsegCercle): facesPipePeau, edgeRadFacePipePeau, nbsegCercle):
@ -35,112 +35,13 @@ def construitEdgesRadialesDebouchantes(idisklim, idiskout, gptsdisks, raydisks,
# --- listes de nappes radiales en filling à chaque extrémité débouchante # --- listes de nappes radiales en filling à chaque extrémité débouchante
facesDebouchantes = [False, False] facesDebouchantes, listNappes = construitEdgesRadialesDebouchantes_a(idisklim, idiskout, gptsdisks, raydisks, nbsegCercle)
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)
# --- mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau) # --- mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau)
for i, nappes in enumerate(listNappes): idFacesDebouchantes = construitEdgesRadialesDebouchantes_b(facesPipePeau, facesDebouchantes, 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)
# --- construction des listes d'edges radiales sur chaque extrémité débouchante # --- construction des listes d'edges radiales sur chaque extrémité débouchante
listEdges = [] listEdges = construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
for i, nappes in enumerate(listNappes): listNappes, idFacesDebouchantes)
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)
return (listEdges, 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""" """procédure complète de construction d'une fissure générale"""
import logging import logging
from . import initLog
import salome import salome
from salome.smesh import smeshBuilder
import GEOM
import SMESH
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM
from .geomsmesh import smesh from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from .orderEdgesFromWire import orderEdgesFromWire from .orderEdgesFromWire import orderEdgesFromWire
from .restreintFaceFissure import restreintFaceFissure from .restreintFaceFissure import restreintFaceFissure
@ -53,10 +56,11 @@ from .construitFissureGenerale_c import construitFissureGenerale_c
def construitFissureGenerale(shapesFissure, shapeFissureParams, \ def construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \ maillageFissureParams, elementsDefaut, \
step=-1, mailleur="MeshGems"): step=-1, mailleur="MeshGems", nro_cas=-1):
"""procédure complète fissure générale""" """procédure complète fissure générale"""
logging.info('start') logging.info('start')
logging.info("Usage du mailleur %s", mailleur) logging.info("Usage du mailleur %s", mailleur)
logging.info("pour le cas %d", nro_cas)
shapeDefaut = shapesFissure[0] # faces de fissure, débordant shapeDefaut = shapesFissure[0] # faces de fissure, débordant
@ -195,7 +199,7 @@ def construitFissureGenerale(shapesFissure, shapeFissureParams, \
facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \ facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \ bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \ edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
mailleur) mailleur, nro_cas)
# --- regroupement des maillages du défaut # --- regroupement des maillages du défaut

View File

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

View File

@ -21,10 +21,15 @@
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
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): def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
"""maillage effectif du pipe""" """maillage effectif du pipe"""
logging.info('start') logging.info('start')
@ -38,139 +43,56 @@ def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
faceCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe0") faceCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe0")
faceCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe1") faceCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe1")
mptdsk = list() # vertices de chaque disque au fur et à mesure
mptsdisks = list() # vertices maillage de tous les disques mptsdisks = list() # vertices maillage de tous les disques
mEdges = list() # identifiants edges maillage fond de fissure mEdges = list() # identifiants edges maillage fond de fissure
mEdgeFaces = list() # identifiants edges maillage edge face de fissure externe mEdgeFaces = list() # identifiants edges maillage edge face de fissure externe
mFaces = list() # identifiants faces maillage fissure mFaces = list() # identifiants faces maillage fissure
mVols = list() # identifiants volumes maillage pipe mVols = list() # identifiants volumes maillage pipe
mptdsk = list()
for idisk in range(idisklim[0], idisklim[1]+1): # boucle sur les disques internes for idisk in range(idisklim[0], idisklim[1]+1): # boucle sur les disques internes
#print ("\nidisk = {}".format(idisk))
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# --- points # --- Les points
gptdsk = gptsdisks[idisk] oldmpts = mptdsk
if idisk > idisklim[0]: mptdsk = construitMaillagePipe_a(idisk, \
oldmpts = mptdsk gptsdisks, idisklim, nbsegCercle, \
mptdsk = list() # vertices maillage d'un disque meshPipe, mptsdisks)
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)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# --- groupes edges cercles debouchants # --- Les groupes des edges des cercles débouchants
if idisk == idisklim[0]: if idisk in (idisklim[0],idisklim[1]):
pts = list() construitMaillagePipe_b(idisk, \
for k in range(nbsegCercle): idisklim, nbsegCercle, \
pts.append(mptdsk[k][-1]) meshPipe, mptdsk, \
edges = list() edgeCircPipe0Group, edgeCircPipe1Group)
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)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# --- groupes faces debouchantes # --- Les groupes des faces débouchantes
if idisk == idisklim[0]: if idisk in (idisklim[0],idisklim[1]):
faces = list() construitMaillagePipe_c(idisk, \
for j in range(nbsegRad): idisklim, nbsegCercle, \
for k in range(nbsegCercle): meshPipe, mptdsk, nbsegRad, \
k1 = k+1 faceCircPipe0Group, faceCircPipe1Group)
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)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# --- mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure # --- mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure
if idisk == idisklim[0]: construitMaillagePipe_d(idisk, \
mEdges.append(0) idisklim, nbsegCercle, nbsegRad, \
mEdgeFaces.append(0) meshPipe, mptdsk, oldmpts, \
mFaces.append([0]) fondFissGroup, edgeFaceFissGroup, faceFissGroup, \
mVols.append([[0]]) mEdges, mEdgeFaces, mFaces, mVols, nodesFondFissGroup)
nodesFondFissGroup.Add([mptdsk[0][0]]) # Bilan
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)
pipeFissGroup = meshPipe.CreateEmptyGroup( SMESH.VOLUME, 'PIPEFISS' ) 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] edgesCircPipeGroup = [edgeCircPipe0Group, edgeCircPipe1Group]
meshPipeGroups = dict(fondFissGroup = fondFissGroup, \ meshPipeGroups = dict(fondFissGroup = fondFissGroup, \
@ -189,4 +111,5 @@ def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
#text = "Arrêt rapide.\n" #text = "Arrêt rapide.\n"
#logging.info(text) #logging.info(text)
#raise Exception(text) #raise Exception(text)
return (meshPipe, meshPipeGroups, edgesCircPipeGroup) 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 # Copyright (C) 2014-2021 EDF R&D
# #
# This library is free software; you can redistribute it and/or # 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Les groupes des edges des cercles débouchants"""
from blocFissure import gmu import logging
from .initEtude import initEtude
initEtude()
from .triedreBase import triedreBase
O, OX, OY, OZ = triedreBase()
from .distance2 import distance2 def construitMaillagePipe_b(idisk, \
a=[10, 20, 30] idisklim, nbsegCercle, \
b=[5, 7, 3] meshPipe, mptdsk, \
c=distance2(a,b) edgeCircPipe0Group, edgeCircPipe1Group):
"""Les groupes des edges des cercles débouchants"""
#logging.info('start')
import unittest pts = list()
from blocFissure.gmu import initLog for n_cercle in range(nbsegCercle):
initLog.setUnitTests() pts.append(mptdsk[n_cercle][-1])
edges = list()
from blocFissure.gmu import distance2 nb_pts = len(pts)
for n_cercle in range(nb_pts):
suite = unittest.TestLoader().loadTestsFromTestCase(distance2.Test_distance2) n_cercle_1 = (n_cercle+1)%nb_pts
unittest.TextTestRunner(verbosity=2).run(suite) 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 # 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 import logging
from . import initLog
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog
from .checkDecoupePartition import checkDecoupePartition
# ----------------------------------------------------------------------------- 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)
def construitPartitionsPeauFissure(facesDefaut, fissPipe): def construitPartitionsPeauFissure(facesDefaut, fissPipe):
"""partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée. """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 ipart = 0
for filling in facesDefaut: for filling in facesDefaut:
part = geompy.MakePartition([fissPipe, filling], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0) part = geompy.MakePartition([fissPipe, filling], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
isPart = checkDecoupePartition([fissPipe, filling], part) # on recrée la partition avec toutes les faces filling en outil pour avoir une face de fissure correcte
if isPart: # 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] otherFD = [fd for fd in facesDefaut if fd != filling]
if otherFD: if otherFD:
fissPipePart = geompy.MakePartition([fissPipe], otherFD, list(), list(), geompy.ShapeType["FACE"], 0, list(), 0) 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 # 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 import logging
from . import initLog
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog
from .projettePointSurCourbe import projettePointSurCourbe from .projettePointSurCourbe import projettePointSurCourbe
def creePointsPipePeau(listEdges, idFacesDebouchantes, idFillingFromBout, def creePointsPipePeau(listEdges, idFacesDebouchantes, idFillingFromBout,
ptEdgeFond, ptFisExtPi, edCircPeau, gptsdisks, idisklim, nbsegRad): 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') logging.info('start')
for i, edges in enumerate(listEdges): for n_edges, edges in enumerate(listEdges):
idf = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau) idf = idFacesDebouchantes[n_edges] # indice de face débouchante (facesPipePeau)
if idf >= 0: if idf >= 0:
gptdsk = [] gptdsk = list()
if idf > 0: # idf vaut 0 ou 1 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) 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 name = "centre%d"%idf
geomPublish(initLog.debug, centre, name) geomPublish(initLog.debug, centre, name)
vertPipePeau = ptFisExtPi[idFillingFromBout[i]][idf] vertPipePeau = ptFisExtPi[idFillingFromBout[n_edges]][idf]
geomPublishInFather(initLog.debug, centre, vertPipePeau, "vertPipePeau") geomPublishInFather(initLog.debug, centre, vertPipePeau, "vertPipePeau")
grpsEdgesCirc = edCircPeau[idFillingFromBout[i]] # liste de groupes grpsEdgesCirc = edCircPeau[idFillingFromBout[n_edges]] # liste de groupes
edgesCirc = [] edgesCirc = list()
for grpEdgesCirc in grpsEdgesCirc: for grpEdgesCirc in grpsEdgesCirc:
edgesCirc += geompy.ExtractShapes(grpEdgesCirc, geompy.ShapeType["EDGE"], False) edgesCirc += geompy.ExtractShapes(grpEdgesCirc, geompy.ShapeType["EDGE"], False)
for k, edge in enumerate(edges): 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 = [(geompy.MinDistance(bout, edgeCirc), k2, edgeCirc) for k2, edgeCirc in enumerate(edgesCirc)]
distEdgeCirc.sort() distEdgeCirc.sort()
logging.debug("distEdgeCirc: %s", distEdgeCirc) logging.debug("distEdgeCirc: %s", distEdgeCirc)
u = projettePointSurCourbe(bout, distEdgeCirc[0][2]) dist = 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. 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) extrCircs = geompy.ExtractShapes(distEdgeCirc[0][2], geompy.ShapeType["VERTEX"], True)
if geompy.MinDistance(bout, extrCircs[0]) < geompy.MinDistance(bout, extrCircs[1]): if geompy.MinDistance(bout, extrCircs[0]) < geompy.MinDistance(bout, extrCircs[1]):
bout = extrCircs[0] bout = extrCircs[0]
else: else:
bout = extrCircs[1] bout = extrCircs[1]
else: else:
bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], u) bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], dist)
name ="bout%d"%k name ="bout%d"%k
geomPublishInFather(initLog.debug, centre, bout, name) geomPublishInFather(initLog.debug, centre, bout, name)
# enregistrement des points dans la structure # enregistrement des points dans la structure
points = [] points = list()
for j in range(nbsegRad +1): for n_seg in range(nbsegRad +1):
u = j/float(nbsegRad) points.append(geompy.MakeVertexOnCurve(edge, float(n_seg)/float(nbsegRad)))
points.append(geompy.MakeVertexOnCurve(edge, u))
if geompy.MinDistance(bout, points[0]) < geompy.MinDistance(centre, points[0]): if geompy.MinDistance(bout, points[0]) < geompy.MinDistance(centre, points[0]):
points.reverse() points.reverse()
points[0] = centre points[0] = centre
points[-1] = bout points[-1] = bout
gptdsk.append(points) gptdsk.append(points)
if i == 0: if n_edges == 0:
gptsdisks[idisklim[0] -1] = gptdsk gptsdisks[idisklim[0] -1] = gptdsk
idisklim[0] = idisklim[0] -1 idisklim[0] = idisklim[0] -1
else: else:
gptsdisks[idisklim[1] +1] = gptdsk gptsdisks[idisklim[1] +1] = gptdsk
idisklim[1] = idisklim[1] +1 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""TODO: a compléter"""
import os import os
import logging import logging
from .geomsmesh import smesh
import SMESH import SMESH
import SALOMEDS import SALOMEDS
from .geomsmesh import smesh
from .creeZoneDefautMaillage import creeZoneDefautMaillage from .creeZoneDefautMaillage import creeZoneDefautMaillage
from .peauInterne import peauInterne from .peauInterne import peauInterne
from .quadranglesToShapeNoCorner import quadranglesToShapeNoCorner from .quadranglesToShapeNoCorner import quadranglesToShapeNoCorner
@ -32,10 +34,7 @@ from .creeZoneDefautFilling import creeZoneDefautFilling
from .creeZoneDefautGeom import creeZoneDefautGeom from .creeZoneDefautGeom import creeZoneDefautGeom
from .getCentreFondFiss import getCentreFondFiss from .getCentreFondFiss import getCentreFondFiss
# ----------------------------------------------------------------------------- def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, \
# ---
def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
shapeFissureParams, maillageFissureParams): shapeFissureParams, maillageFissureParams):
""" """
#TODO: a compléter #TODO: a compléter
@ -65,11 +64,10 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
nomFicSain = maillageFissureParams['nomFicSain'] nomFicSain = maillageFissureParams['nomFicSain']
fichierMaillageSain = os.path.join (nomRep , '{}.med'.format(nomFicSain)) fichierMaillageSain = os.path.join (nomRep , '{}.med'.format(nomFicSain))
# --- centre de fond de fissure et tangente # --- centre de fond de fissure et tangente
edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure) edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure)
# --- zone de défaut # --- zone de défaut
nomZones = "zoneDefaut" nomZones = "zoneDefaut"
@ -89,9 +87,9 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
isPlane = False isPlane = False
if isHexa and not isPlane: if isHexa and not isPlane:
meshQuad = smesh.CopyMesh( zoneDefaut_skin, 'meshQuad', 0, 0) 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: for filling in fillings:
[faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \ [faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion) creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion)
@ -101,14 +99,15 @@ def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
extrusionsDefaut.append(extrusionDefaut) extrusionsDefaut.append(extrusionDefaut)
else: else:
[facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \ [facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion) creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, lgExtrusion)
bordsPartages = list() bordsPartages = list()
for face in facesDefaut: for _ in facesDefaut:
bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ? bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ?
fillconts = facesDefaut fillconts = facesDefaut
idFilToCont = list(range(len(facesDefaut))) idFilToCont = list(range(len(facesDefaut)))
return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, dmoyen, bordsPartages, fillconts, idFilToCont, return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, \
maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, dmoyen, bordsPartages, fillconts, idFilToCont, \
maillageSain, internalBoundary, \
zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, \
edgeFondExt, centreFondFiss, tgtCentre] edgeFondExt, centreFondFiss, tgtCentre]

View File

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

View File

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

View File

@ -17,38 +17,40 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""calcul du carré de la distance entre deux points"""
import logging import logging
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- calcul de distance carree entre deux points, jeux de coordonnees x,y,z # ---
def distance2(xyz1, xyz2): def distance2(xyz1, xyz2):
""" """
carré de la distance entre deux points donnés par des triplets [x,y,z] carré de la distance entre deux points donnés par des triplets [x,y,z]
""" """
#logging.info("start") #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
# ----------------------------------------------------------------------------- dcarre = 0
# --- test unitaire for ijk in range(3):
dcarre += (xyz1[ijk]-xyz2[ijk])*(xyz1[ijk]-xyz2[ijk])
logging.debug('dcarre=%s', dcarre)
import unittest return dcarre
class Test_distance2(unittest.TestCase):
def setUp(self): ## -----------------------------------------------------------------------------
self.a=[0, 0, 0] ## --- test unitaire
self.b=[3, 4, 5]
self.c=[-5,-4,-3] #import unittest
#class Test_distance2(unittest.TestCase):
def test_calcul(self): #"""test de la fonction"""
self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a))
self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c)) #def setUp(self):
self.assertEqual(distance2(self.b, self.b), 0) #self.a=[0, 0, 0]
self.assertEqual(distance2(self.a, self.b), 50) #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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""éliminer les doublons d'une liste de subshapes"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- éliminer les doublons d'une liste de subshapes # ---
def eliminateDoubles(obj, subshapes): def eliminateDoubles(obj, subshapes):
""" """éliminer les doublons d'une liste de subshapes"""
éliminer les doublons d'une liste de subshapes
""" idsubs = dict()
idsubs = {}
for sub in subshapes: for sub in subshapes:
subid = geompy.GetSubShapeID(obj, sub) subid = geompy.GetSubShapeID(obj, sub)
if subid in list(idsubs.keys()): if subid in idsubs:
idsubs[subid].append(sub) idsubs[subid].append(sub)
else: else:
idsubs[subid] = [sub] idsubs[subid] = [sub]
shortList = []
for k, v in idsubs.items(): shortList = list()
shortList.append(v[0]) for l_sub in idsubs.items():
shortList.append(l_sub[0])
logging.debug("shortList=%s", shortList) logging.debug("shortList=%s", shortList)
return shortList return shortList

View File

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

View File

@ -17,26 +17,29 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""maillage sain sans la zone de défaut"""
import logging import logging
# -----------------------------------------------------------------------------
# --- maillage sain sans la zone defaut
def enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges): def enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges):
""" """Maillage sain sans la zone de défaut
Maillage sain sans la zone de defaut
TODO: a completer TODO: a completer
""" """
logging.info('start') logging.info('start')
maillageSain.RemoveGroupWithContents(zoneDefaut) maillageSain.RemoveGroupWithContents(zoneDefaut)
if zoneDefaut_skin is not None: if zoneDefaut_skin is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_skin) maillageSain.RemoveGroupWithContents(zoneDefaut_skin)
if zoneDefaut_internalFaces is not None: if zoneDefaut_internalFaces is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_internalFaces) maillageSain.RemoveGroupWithContents(zoneDefaut_internalFaces)
if zoneDefaut_internalEdges is not None: if zoneDefaut_internalEdges is not None:
maillageSain.RemoveGroupWithContents(zoneDefaut_internalEdges) 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 # 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 import logging
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .whichSide import whichSide from .whichSide import whichSide
from .extractionOrientee_a import extractionOrientee_a
# -----------------------------------------------------------------------------
# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""): def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
""" """
@ -37,36 +34,22 @@ def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
""" """
logging.info('start') logging.info('start')
trace = True trace = True
sideRef = whichSide(face, ref) side_ref = whichSide(face, ref)
logging.debug("ref side %s", sideRef) logging.debug("ref side %s", side_ref)
shapesInside = [] shapesInside = list()
shapesOutside = [] shapesOutside = list()
shapesOnside = [] shapesOnside = list()
shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False) shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
i=0
j=0 i_aux = 0
k=0 j_aux = 0
k_aux = 0
prefix = prefix + shapeType prefix = prefix + shapeType
for shape in shapes: for shape in shapes:
side = whichSide(face, shape, tol) side = whichSide(face, shape, tol)
if side == sideRef: i_aux, j_aux, k_aux = extractionOrientee_a(obj, shape, side, side_ref, \
shapesInside.append(shape) shapesInside, shapesOutside, shapesOnside, \
if trace: i_aux, j_aux, k_aux, \
name = prefix + "_Inside%d"%i trace, prefix)
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]
return [shapesInside, shapesOutside, shapesOnside]

View File

@ -17,17 +17,14 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # 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 import logging
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
from .whichSideMulti import whichSideMulti from .whichSideMulti import whichSideMulti
from .extractionOrientee_a import extractionOrientee_a
# -----------------------------------------------------------------------------
# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
def extractionOrienteeMulti(faces, ifil, obj, centre, shapeType, tol, prefix=""): 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') logging.info('start')
trace = True trace = True
shapesInside = [] shapesInside = list()
shapesOutside = [] shapesOutside = list()
shapesOnside = [] shapesOnside = list()
shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False) shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
i=0
j=0 i_aux = 0
k=0 j_aux = 0
k_aux = 0
prefix = prefix + shapeType prefix = prefix + shapeType
for shape in shapes: for shape in shapes:
side = whichSideMulti(faces, ifil, shape, centre, tol) side = whichSideMulti(faces, ifil, shape, centre, tol)
if side == 1: i_aux, j_aux, k_aux = extractionOrientee_a(obj, shape, side, 1, \
shapesInside.append(shape) shapesInside, shapesOutside, shapesOnside, \
if trace: i_aux, j_aux, k_aux, \
name = prefix + "_Inside%d"%i trace, prefix)
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]
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 # 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 import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
# ----------------------------------------------------------------------------- from .geomsmesh import geompy
# --- TORE from .geomsmesh import geomPublishInFather
## --- faces 1/2 circulaires et leur centre, edges de ces faces dans le plan de fissure
def facesCirculaires(bloc, tore): def facesCirculaires(bloc, tore):
""" """
@ -41,59 +39,42 @@ def facesCirculaires(bloc, tore):
faces = geompy.GetShapesOnShape(bloc, tore, geompy.ShapeType["FACE"], GEOM.ST_ON) faces = geompy.GetShapesOnShape(bloc, tore, geompy.ShapeType["FACE"], GEOM.ST_ON)
geomPublishInFather(initLog.debug, tore, faces[0], 'face0' ) centres = list()
geomPublishInFather(initLog.debug, tore, faces[1], 'face1' ) alledges = list()
geomPublishInFather(initLog.debug, tore, faces[2], 'face2' ) for i_aux in range(4):
geomPublishInFather(initLog.debug, tore, faces[3], 'face3' ) 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] dicoedge = dict()
[v1,centres[0],v3] = geompy.ExtractShapes(faces[0], geompy.ShapeType["VERTEX"], True) edges = list()
[v1,centres[1],v3] = geompy.ExtractShapes(faces[1], geompy.ShapeType["VERTEX"], True) reverses = list()
[v1,centres[2],v3] = geompy.ExtractShapes(faces[2], geompy.ShapeType["VERTEX"], True)
[v1,centres[3],v3] = geompy.ExtractShapes(faces[3], geompy.ShapeType["VERTEX"], True)
geomPublishInFather(initLog.debug, faces[0], centres[0], 'centre0' ) for i_aux, edgesface in enumerate(alledges):
geomPublishInFather(initLog.debug, faces[1], centres[1], 'centre1' )
geomPublishInFather(initLog.debug, faces[2], centres[2], 'centre2' )
geomPublishInFather(initLog.debug, faces[3], centres[3], 'centre3' )
alledges = [None, None, None, None] lenef = list()
alledges[0] = geompy.ExtractShapes(faces[0], geompy.ShapeType["EDGE"], True) for edge in edgesface:
alledges[1] = geompy.ExtractShapes(faces[1], geompy.ShapeType["EDGE"], True) props = geompy.BasicProperties(edge)
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.append(props[0]) lenef.append(props[0])
pass
maxlen = max(lenef) maxlen = max(lenef)
for j in range(len(edgesface)): for j_aux, edge in enumerate(edgesface):
if lenef[j] < maxlen: if lenef[j_aux] < maxlen:
edgid = geompy.GetSubShapeID(tore, edgesface[j]) edgid = geompy.GetSubShapeID(tore, edge)
if not (edgid in dicoedge): if not (edgid in dicoedge):
dicoedge[edgid] = edgesface[j] dicoedge[edgid] = edge
edges.append(edgesface[j]) edges.append(edge)
named = 'edge_' + str(i) + '_' +str(j) named = 'edge_{}_{}'.format(i_aux,j_aux)
geomPublishInFather(initLog.debug, faces[i], edgesface[j], named) geomPublishInFather(initLog.debug, faces[i_aux], edge, named)
vertices = geompy.ExtractShapes(edgesface[j], geompy.ShapeType["VERTEX"], False) vertices = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
#firstVertex = geompy.GetFirstVertex(edgesface[j]) #firstVertex = geompy.GetFirstVertex(edge)
if geompy.GetSubShapeID(tore, vertices[0]) != geompy.GetSubShapeID(tore, centres[i]): if geompy.GetSubShapeID(tore, vertices[0]) != geompy.GetSubShapeID(tore, centres[i_aux]):
reverses.append(1) reverses.append(1)
#print 'reversed ' + str(edgid) #print 'reversed ' + str(edgid)
else: else:
reverses.append(0) reverses.append(0)
#print 'normal' + str(edgid) #print 'normal' + str(edgid)
pass
pass
pass
pass
return faces, centres, edges, reverses return faces, centres, edges, reverses

View File

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

View File

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

View File

@ -17,19 +17,18 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Tore : aces toriques et volumes du tore"""
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .extractionOrientee import extractionOrientee from .extractionOrientee import extractionOrientee
from .getSubshapeIds import getSubshapeIds from .getSubshapeIds import getSubshapeIds
# -----------------------------------------------------------------------------
# --- TORE
# --- faces toriques et volumes du tore
def facesVolumesToriques(tore, plan, facesDefaut): def facesVolumesToriques(tore, plan, facesDefaut):
""" """
Extraction des deux faces et volumes du tore partitionné, qui suivent la génératrice elliptique. 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) normal = geompy.GetNormal(plan, centre)
reference = geompy.MakeTranslationVector(centre, normal) reference = geompy.MakeTranslationVector(centre, normal)
[facesInPlan, facesOutPlan, facesOnPlan] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_") [facesInPlan, facesOutPlan, _] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_")
[facesInSide, facesOutSide, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
facesIdInPlan = getSubshapeIds(tore, facesInPlan) facesIdInPlan = getSubshapeIds(tore, facesInPlan)
facesIdOutPlan = getSubshapeIds(tore, facesOutPlan) facesIdOutPlan = getSubshapeIds(tore, facesOutPlan)
[_, _, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_")
facesIdOnSide = getSubshapeIds(tore, facesOnSide) facesIdOnSide = getSubshapeIds(tore, facesOnSide)
facesIdInSide = getSubshapeIds(tore, facesInSide)
facesIdOutSide = getSubshapeIds(tore, facesOutSide)
#facesIdInOutSide = facesIdInSide + facesIdOutSide
facetore1 = None facetore1 = None
faceTore2 = None for i_aux, faceId in enumerate(facesIdInPlan):
for i, faceId in enumerate(facesIdInPlan):
if faceId not in facesIdOnSide: if faceId not in facesIdOnSide:
facetore1 = facesInPlan[i] facetore1 = facesInPlan[i_aux]
break 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' ) 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' ) geomPublishInFather(initLog.debug, tore, facetore2, 'facetore2' )
[volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True) [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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Trouver les vertices aux extrémites d'un wire"""
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
# ----------------------------------------------------------------------------- from .geomsmesh import geompy
# --- trouver les vertices extremites d'un wire
from .findWireVertices import findWireVertices
def findWireEndVertices(aWire, getNormals=False): def findWireEndVertices(aWire, getNormals=False):
""" """Trouver les vertices aux extrémites d'un wire
trouver les vertices extremites d'un wire
calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001) Calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
""" """
logging.info("start") logging.info("start")
if geompy.NumberOfEdges(aWire) > 1: if geompy.NumberOfEdges(aWire) > 1:
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False)
else: else:
edges = [aWire] 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Trouver les vertices intermédiaires d'un wire"""
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
from .geomsmesh import geompy
from .findWireVertices import findWireVertices
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- trouver les vertices intermediaires d'un wire # --- trouver les vertices intermediaires d'un wire
def findWireIntermediateVertices(aWire, getNormals=False): def findWireIntermediateVertices(aWire, getNormals=False):
""" """Trouver les vertices d'un wire qui ne sont pas aux extremités
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) Calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001)
""" """
logging.info("start") logging.info("start")
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Message d'erreur"""
class fissError(Exception): class fissError(Exception):
""" """ Usage:
usage:
try: try:
instructions() instructions()
except: except:
raise fissError(traceback.extract_stack(),"mon message") raise fissError(traceback.extract_stack(),"mon message")
""" """
def __init__(self, pile, msg): def __init__(self, pile, msg):
self.pile = pile self.pile = pile
self.msg = msg self.msg = msg
def __str__(self): 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Fissure dans un coude"""
import os import os
from .geomsmesh import geompy, smesh import logging
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import math import math
import GEOM import GEOM
import SALOMEDS import SALOMEDS
import SMESH import SMESH
import logging
from . import initLog
from .geomsmesh import geompy, smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from .fissureGenerique import fissureGenerique from .fissureGenerique import fissureGenerique
@ -42,12 +44,12 @@ from .sortEdges import sortEdges
O, OX, OY, OZ = triedreBase() O, OX, OY, OZ = triedreBase()
class fissureCoude(fissureGenerique): 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" nomProbleme = "fissureCoude"
longitudinale = None
circonferentielle = None
elliptique = None
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def setParamGeometrieSaine(self): def setParamGeometrieSaine(self):
@ -347,10 +349,8 @@ class fissureCoude(fissureGenerique):
logging.info("genereShapeFissure %s", self.nomCas) logging.info("genereShapeFissure %s", self.nomCas)
logging.info("shapeFissureParams %s", shapeFissureParams) logging.info("shapeFissureParams %s", shapeFissureParams)
angleCoude = geomParams['angleCoude']
r_cintr = geomParams['r_cintr'] r_cintr = geomParams['r_cintr']
l_tube_p1 = geomParams['l_tube_p1'] l_tube_p1 = geomParams['l_tube_p1']
l_tube_p2 = geomParams['l_tube_p2']
epais = geomParams['epais'] epais = geomParams['epais']
de = geomParams['de'] de = geomParams['de']
@ -365,8 +365,6 @@ class fissureCoude(fissureGenerique):
if 'elliptique' in shapeFissureParams: if 'elliptique' in shapeFissureParams:
self.elliptique = shapeFissureParams['elliptique'] self.elliptique = shapeFissureParams['elliptique']
azimut = -azimut # axe inverse / ASCOUF azimut = -azimut # axe inverse / ASCOUF
axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1) axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1)
geomPublish(initLog.debug, axe,"axe") geomPublish(initLog.debug, axe,"axe")
@ -383,10 +381,8 @@ class fissureCoude(fissureGenerique):
self.circonferentielle = False self.circonferentielle = False
self.longitudinale = False self.longitudinale = False
if self.fissureLongue and not self.elliptique: if self.fissureLongue and not self.elliptique:
if abs(orientation) < 45 : self.longitudinale = bool(abs(orientation) < 45)
self.longitudinale = True self.circonferentielle = not bool(abs(orientation) < 45)
else:
self.circonferentielle = True
nbp1 = 10 nbp1 = 10
if self.circonferentielle: if self.circonferentielle:
@ -400,8 +396,8 @@ class fissureCoude(fissureGenerique):
raybor = de/2. - epais raybor = de/2. - epais
rayint = raybor + profondeur rayint = raybor + profondeur
rayext = raybor - profondeur/5.0 rayext = raybor - profondeur/5.0
lgfond = longueur -2*profondeur lgfond = longueur -2.*profondeur
angle = lgfond/(2*raybor) angle = lgfond/(2.*raybor)
pb = geompy.MakeVertex(raybor, 0, 0) pb = geompy.MakeVertex(raybor, 0, 0)
pi = geompy.MakeVertex(rayint, 0, 0) pi = geompy.MakeVertex(rayint, 0, 0)
pbl = geompy.MakeRotation(pb, OZ, angle) pbl = geompy.MakeRotation(pb, OZ, angle)
@ -592,7 +588,7 @@ class fissureCoude(fissureGenerique):
geomPublish(initLog.debug, centre, 'centrefissPlace' ) geomPublish(initLog.debug, centre, 'centrefissPlace' )
edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True) 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 edges = edgesTriees[:-1] # la plus grande correspond à arce, on l'elimine
wiretube = geompy.MakeWire(edges) wiretube = geompy.MakeWire(edges)
#wiretube = edgesTriees[-1] #wiretube = edgesTriees[-1]
@ -643,7 +639,7 @@ class fissureCoude(fissureGenerique):
facefiss = geompy.MakeFaceWires([arce, arci], 0) facefiss = geompy.MakeFaceWires([arce, arci], 0)
geomPublish(initLog.debug, facefiss, 'facefissPlace' ) geomPublish(initLog.debug, facefiss, 'facefissPlace' )
edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True) edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True)
edgesTriees, minl, maxl = sortEdges(edges) edgesTriees, _, _ = sortEdges(edges)
edgetube = edgesTriees[-1] # la plus grande correspond à arci edgetube = edgesTriees[-1] # la plus grande correspond à arci
wiretube = edgetube wiretube = edgetube
@ -684,7 +680,7 @@ class fissureCoude(fissureGenerique):
mailleur="MeshGems"): mailleur="MeshGems"):
maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \ maillageFissure = construitFissureGenerale(shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, \ maillageFissureParams, elementsDefaut, \
step, mailleur) step, mailleur, self.numeroCas)
return maillageFissure return maillageFissure
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -17,93 +17,85 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
""" """Groupe de quadrangles de face transformé en face géométrique par filling
Created on Tue Jun 24 09:14:13 2014
Created on Tue Jun 24 09:14:13 2014
@author: I48174 (Olivier HOAREAU) @author: I48174 (Olivier HOAREAU)
""" """
import logging import logging
from .geomsmesh import geompy
from .geomsmesh import smesh
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog
import GEOM import GEOM
import SMESH import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .listOfExtraFunctions import createNewMeshesFromCorner from .listOfExtraFunctions import createNewMeshesFromCorner
from .listOfExtraFunctions import createLinesFromMesh 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): def fusionMaillageDefaut(maillageSain, maillageDefautCible, maillageInterneCible, zoneDefaut_skin, shapeDefaut, listOfCorners):
""" """ """Groupe de quadrangles de face transformé en face géométrique par filling"""
# TODO: rédiger la docstring
logging.info("start")
logging.info("start")
facesNonCoupees = list()
facesNonCoupees = [] facesCoupees = list()
facesCoupees = [] maillagesNonCoupes = list()
maillagesNonCoupes = [] maillagesCoupes = list()
maillagesCoupes = []
# On crée une liste contenant le maillage de chaque face.
# On crée une liste contenant le maillage de chaque face. listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
i_aux = 0
i = 0 while i_aux < len(listOfNewMeshes):
while i < len(listOfNewMeshes): lines = createLinesFromMesh(listOfNewMeshes[i_aux])
lines = createLinesFromMesh(listOfNewMeshes[i]) setOfLines = list()
setOfLines = [] for line in lines:
for line in lines: # On possède l'information 'ID' de chaque noeud composant chaque
# 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
# 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
# ensemble de vertices constitue une ligne. Un ensemble de lignes # constitue la face.
# constitue la face. tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line] tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords] line = geompy.MakeInterpol(tmpPoints, False, False)
line = geompy.MakeInterpol(tmpPoints, False, False) setOfLines.append(line)
setOfLines.append(line)
# A partir des lignes de la face,
# A partir des lignes de la face, # on recrée un objet GEOM temporaire par filling.
# 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)
filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True) #logging.debug("face de filling")
#logging.debug("face de filling") #geomPublish(initLog.debug, filling, 'filling_{0}'.format(i_aux+1))
#geomPublish(initLog.debug, filling, 'filling_{0}'.format(i + 1))
tmpPartition = geompy.MakePartition([filling], [shapeDefaut], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
tmpPartition = geompy.MakePartition([filling], [shapeDefaut], [], [], geompy.ShapeType["FACE"], 0, [], 0) tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True) tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True) if len(tmpExplodeRef) == len(tmpExplodeNum):
if len(tmpExplodeRef) == len(tmpExplodeNum): logging.debug("face de filling non coupee")
logging.debug("face de filling non coupee") geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i_aux+1)) # doit etre publie pour critere OK plus bas
geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i + 1)) # doit etre publie pour critere OK plus bas facesNonCoupees.append(filling)
facesNonCoupees.append(filling) maillagesNonCoupes.append(listOfNewMeshes[i_aux])
maillagesNonCoupes.append(listOfNewMeshes[i]) else:
else: logging.debug("face de filling coupee")
logging.debug("face de filling coupee") geompy.addToStudy( filling, "faceCoupee_{0}".format(i_aux+1))
geompy.addToStudy( filling, "faceCoupee_{0}".format(i + 1)) facesCoupees.append(filling)
facesCoupees.append(filling) maillagesCoupes.append(listOfNewMeshes[i_aux])
maillagesCoupes.append(listOfNewMeshes[i]) i_aux += 1
i += 1 listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes] newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
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]
facesEnTrop = [] filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
for i_aux, filtre in enumerate(filtres):
criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees] filtre.SetMesh(maillageSain.GetMesh())
filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres] faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i_aux+1), filtre)
for i, filtre in enumerate(filtres): facesEnTrop.append(faceEnTrop)
filtre.SetMesh(maillageSain.GetMesh())
faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i + 1), filtre) newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
facesEnTrop.append(faceEnTrop)
smesh.SetName(newMaillageInterne, 'newInternalBoundary')
newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
return newZoneDefaut_skin, newMaillageInterne
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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Création élements géométriques fissure elliptique"""
import logging import logging
from . import initLog
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog
from .toreFissure import toreFissure from .toreFissure import toreFissure
from .ellipsoideDefaut import ellipsoideDefaut from .ellipsoideDefaut import ellipsoideDefaut
from .rotTrans import rotTrans from .rotTrans import rotTrans
from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut from .genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
# -----------------------------------------------------------------------------
# --- création élements géométriques fissure elliptique
def genereElemsFissureElliptique(shapeFissureParams, \ def genereElemsFissureElliptique(shapeFissureParams, \
mailleur="MeshGems"): mailleur="MeshGems"):
""" """Création élements géométriques fissure elliptique"""
TODO: a completer
"""
logging.info('start') logging.info('start')
centreDefaut = shapeFissureParams['centreDefaut'] centreDefaut = shapeFissureParams['centreDefaut']
@ -51,7 +49,7 @@ def genereElemsFissureElliptique(shapeFissureParams, \
allonge = demiGrandAxe/demiPetitAxe allonge = demiGrandAxe/demiPetitAxe
rayonTore = demiPetitAxe/5.0 rayonTore = demiPetitAxe/5.0
generatrice, _, Pipe_1, FaceFissure, Plane_1, Pipe1Part = toreFissure(demiPetitAxe, allonge, rayonTore) 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 # --- 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Maillage face de fissure pour identification zone de défaut"""
import logging import logging
from .geomsmesh import smesh
from salome.smesh import smeshBuilder from salome.smesh import smeshBuilder
# ----------------------------------------------------------------------------- from .geomsmesh import smesh
# --- maillage face de fissure pour identification zone de defaut
def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \ def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
mailleur="MeshGems"): mailleur="MeshGems"):
@ -46,7 +46,8 @@ def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
-SetQuadAllowed = permission quadrangle dans maillage triangle -SetQuadAllowed = permission quadrangle dans maillage triangle
-On récupère les coordonnées de chaque noeud de la fissure qu'on stocke -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') logging.info('start')

View File

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

View File

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

View File

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

View File

@ -17,161 +17,41 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # 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 import logging
from .geomsmesh import geompy from .identifieEdgesPeau_a import identifieEdgesPeau_a
from .geomsmesh import geomPublish from .identifieEdgesPeau_b import identifieEdgesPeau_b
from .geomsmesh import geomPublishInFather from .identifieEdgesPeau_c import identifieEdgesPeau_c
from . import initLog
from .substractSubShapes import substractSubShapes def identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, \
def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSorted,
edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees): 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') logging.info('start')
facesPipePeau = [None for i in range(len(edgesFissExtPipe))] facesPipePeau = [None for _ in range(len(edgesFissExtPipe))]
endsEdgeFond = [None for i in range(len(edgesFissExtPipe))] endsEdgeFond = [None for _ in range(len(edgesFissExtPipe))]
edgeRadFacePipePeau = [None for i in range(len(edgesFissExtPipe))] edgeRadFacePipePeau = [None for _ in range(len(edgesFissExtPipe))]
edgesListees = [] edgesListees = list()
edgesCircPeau = []
verticesCircPeau = []
if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau 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 edgesCircPeau, verticesCircPeau = identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauFondIn, \
logging.debug("examen face debouchante circulaire") endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesListees)
for i,efep in enumerate(edgesFissExtPipe): else:
dist = geompy.MinDistance(face, efep) edgesCircPeau = list()
logging.debug(" distance face circulaire edge %s", dist) verticesCircPeau = list()
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
# --- 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 # --- edges de bord de la face de peau
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False) groupEdgesBordPeau, bordsVifs = identifieEdgesPeau_b(facePeau, edgesListees, \
edgesBords = [] fillingFaceExterne, aretesVivesC, aretesVivesCoupees)
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")
# --- edges de la face de peau partagées avec la face de fissure # --- edges de la face de peau partagées avec la face de fissure
edgesPeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False) edgesFissurePeau = identifieEdgesPeau_c(verticesPipePeau, facePeau, edgesListees, verticesCircPeau)
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)
return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau,
edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, 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 # 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 logging
import math
from .geomsmesh import geompy from .identifieElementsDebouchants_a import identifieElementsDebouchants_a
from .geomsmesh import geomPublish from .identifieElementsDebouchants_b import identifieElementsDebouchants_b
from .geomsmesh import geomPublishInFather from .identifieElementsDebouchants_c import identifieElementsDebouchants_c
from . import initLog from .identifieElementsDebouchants_d import identifieElementsDebouchants_d
import traceback
from .fissError import fissError
from .produitMixte import produitMixte
from .whichSide import whichSide
def identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \ def identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
edgesFondIn, edgesFondFiss, wireFondFiss, \ edgesFondIn, edgesFondFiss, wireFondFiss, \
aretesVivesC, fillingFaceExterne, \ aretesVivesC, fillingFaceExterne, \
edgesPipeIn, verticesPipePeau, rayonPipe, \ edgesPipeIn, verticesPipePeau, rayonPipe, \
facesInside, facesOnside): 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') logging.info('start')
@ -49,127 +44,28 @@ def identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
#logging.debug("edgesFondIn %s", edgesFondIn) #logging.debug("edgesFondIn %s", edgesFondIn)
for iedf, edge in enumerate(edgesFondIn): for iedf, edge in enumerate(edgesFondIn):
name = "edgeFondIn%d"%iedf
geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name) ptPeau, centre, norm, localEdgeInFondFiss, localEdgeInFondFiss, cercle = \
dist = [ geompy.MinDistance(pt, edge) for pt in verticesPipePeau] identifieElementsDebouchants_a(iedf, \
ptPeau = verticesPipePeau[dist.index(min(dist))] # le point de verticesPipePeau a distance minimale de l'edge partitionPeauFissFond, edgesFondFiss, wireFondFiss, \
[u, PointOnEdge, EdgeInWireIndex] = geompy.MakeProjectionOnWire(ptPeau, wireFondFiss) verticesPipePeau, rayonPipe, edge,)
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)
verticesEdgesFondIn.append(centre) 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) cercles.append(cercle)
# --- estimation de la longueur du pipe necessaire de part et d'autre du point de sortie # --- estimation de la longueur du pipe necessaire de part et d'autre du point de sortie
if aretesVivesC is None: loc_pt0, lgp = identifieElementsDebouchants_b(ifil, \
faceTestPeau = fillingFaceExterne facesDefaut,aretesVivesC, fillingFaceExterne, rayonPipe, \
else: ptPeau, centre, norm, localEdgeInFondFiss)
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)
# --- position des points extremite du pipe sur l'edge debouchante # --- 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 identifieElementsDebouchants_c(iedf,\
locEdgePart = geompy.MakePartition([localEdgeInFondFiss],[centre], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0) partitionPeauFissFond, wireFondFiss, \
edgesLoc = geompy.ExtractShapes(locEdgePart, geompy.ShapeType["EDGE"], False) centre, localEdgeInFondFiss, cercle, loc_pt0, lgp, pipexts)
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)
edgePart = geompy.MakePartition([localEdgeInFondFiss], [p1,p2], list(), list(), geompy.ShapeType["EDGE"], 0, list(), 0) # --- Recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)
edps = geompy.ExtractShapes(edgePart, geompy.ShapeType["EDGE"], True) identifieElementsDebouchants_d(iedf,\
for edp in edps: partitionPeauFissFond, edgesFondIn, edgesPipeIn, \
if geompy.MinDistance(centre, edp) < 1.e-3: facesInside, facesOnside, \
pipext = geompy.MakePipe(cercle, edp) ptPeau, facesFissExt, edgesFissExtPeau, edgesFissExtPipe)
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
return (verticesEdgesFondIn, pipexts, cercles, 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 # 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 import logging
from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .extractionOrientee import extractionOrientee from .extractionOrientee import extractionOrientee
from .extractionOrienteeMulti import extractionOrienteeMulti from .extractionOrienteeMulti import extractionOrienteeMulti
def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond, def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
edgesPipeFiss, edgesFondFiss, aretesVivesC, edgesPipeFiss, edgesFondFiss, aretesVivesC,
fillingFaceExterne, centreFondFiss): fillingFaceExterne, centreFondFiss):
@ -44,34 +48,32 @@ def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesPipeC, "edgesPipeFiss") geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesPipeC, "edgesPipeFiss")
edgesFondC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesFondFiss)) edgesFondC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesFondFiss))
geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesFondC, "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: try:
vertices = geompy.GetSharedShapesMulti([edge, geompy.MakeCompound(facesOnside)], geompy.ShapeType["VERTEX"]) vertices = geompy.GetSharedShapesMulti([edge, geompy.MakeCompound(facesOnside)], geompy.ShapeType["VERTEX"])
verticesPipePeau.append(vertices[0]) verticesPipePeau.append(vertices[0])
name = "edgePipeIn%d"%i name = "edgePipeIn{}".format(i_aux)
geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name) geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
name = "verticePipePeau%d"%i name = "verticePipePeau{}".format(i_aux)
geomPublishInFather(initLog.debug, partitionPeauFissFond, vertices[0], name) 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: 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 =[] edgesFondIn = list()
if len(verticesPipePeau) > 0: # au moins une extrémité du pipe sur cette face de peau if verticesPipePeau: # 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]
tmp = geompy.GetSharedShapesMulti([edgesFondC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"]) 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] 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 # 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 import logging
@ -30,8 +31,7 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
edgesFondFiss, wireFondFiss, aretesVivesC, \ edgesFondFiss, wireFondFiss, aretesVivesC, \
facesDefaut, centreFondFiss, rayonPipe, \ facesDefaut, centreFondFiss, rayonPipe, \
aretesVivesCoupees): aretesVivesCoupees):
""" """Identification des éléments géométriques de la face de peau"""
"""
logging.info('start') logging.info('start')
fillingFaceExterne = facesDefaut[ifil] 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 # --- 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 # edges internes communes pipe et fissure, points communs edges fissure peau et edges circulaires
(edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside) = identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond, (edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside) = \
edgesPipeFiss, edgesFondFiss, aretesVivesC, identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond, \
fillingFaceExterne, centreFondFiss) edgesPipeFiss, edgesFondFiss, aretesVivesC, \
fillingFaceExterne, centreFondFiss)
# --- elements débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn) # --- elements débouchants (intersection pipe et peau), indexés selon les edges du fond de fissure (edgesFondIn)
(verticesEdgesFondIn, pipexts, cercles, (verticesEdgesFondIn, pipexts, cercles,
facesFissExt, edgesFissExtPeau, edgesFissExtPipe) = identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, facesFissExt, edgesFissExtPeau, edgesFissExtPipe) = identifieElementsDebouchants(ifil, facesDefaut, partitionPeauFissFond, \
edgesFondIn, edgesFondFiss, wireFondFiss, edgesFondIn, edgesFondFiss, wireFondFiss, \
aretesVivesC, fillingFaceExterne, aretesVivesC, fillingFaceExterne, \
edgesPipeIn, verticesPipePeau, rayonPipe, edgesPipeIn, verticesPipePeau, rayonPipe, \
facesInside, facesOnside) 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 # --- 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 # --- 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, (facePeau, facesPeauSorted, edgesPeauFondIn) = identifieFacesPeau(ifil, verticesPipePeau, facesOnside, wireFondFiss, \
verticesEdgesFondIn, pipexts, cercles, verticesEdgesFondIn, pipexts, cercles, \
fillingFaceExterne, centreFondFiss) fillingFaceExterne, centreFondFiss)
# --- 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
(endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, \
edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, bordsVifs, edgesFissurePeau, aretesVivesCoupees) = \
bordsVifs, edgesFissurePeau, aretesVivesCoupees) = identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, \
edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees) edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees)
dataPPFF = dict(endsEdgeFond = endsEdgeFond, # pour chaque face [points edge fond de fissure aux débouchés du pipe] 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] facesPipePeau = facesPipePeau, # pour chaque face [faces du pipe débouchantes]
@ -87,4 +88,3 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss
) )
return dataPPFF, aretesVivesCoupees return dataPPFF, aretesVivesCoupees

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,35 +22,20 @@
import os import os
import logging 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 import salome
from .sortFaces import sortFaces
from .sortEdges import sortEdges from .geomsmesh import geomPublish
from .eliminateDoubles import eliminateDoubles
from .substractSubShapes import substractSubShapes from . import initLog
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
from .insereFissureLongue_a import insereFissureLongue_a from .insereFissureLongue_a import insereFissureLongue_a
from .insereFissureLongue_b import insereFissureLongue_b from .insereFissureLongue_b import insereFissureLongue_b
from .insereFissureLongue_c import insereFissureLongue_c from .insereFissureLongue_c import insereFissureLongue_c
from .insereFissureLongue_d import insereFissureLongue_d 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] fillingFaceExterne = facesDefaut[0]
logging.debug("fillingFaceExterne %s", fillingFaceExterne) logging.debug("fillingFaceExterne %s", fillingFaceExterne)
geomPublish(initLog.debug, fillingFaceExterne, "fillingFaceExterne") geomPublish(initLog.debug, fillingFaceExterne, "fillingFaceExterne")
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
O, OX, OY, OZ = triedreBase()
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- peau et face de fissure # --- peau et face de fissure
edgesInside, centreFondFiss, tangentFondFiss, \
# --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée planBord1, planBord2 , \
partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0) facePeau, faceFiss, verticesOutCercles, verticesEdgePeauFiss, \
geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond' ) edgePeauFiss, demiCerclesPeau, \
groupEdgesBordPeau, groupsDemiCerclesPeau, groupEdgesFaceFissPipe = \
edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False) insereFissureLongue_a (facePorteFissure, WirePorteFondFissure, \
fillingFaceExterne, \
lgmax = 0 pipefiss, rayonPipe, \
imax = 0 mailleur )
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")
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- pipe de fond de fissure # --- pipe de fond de fissure
pipeFondFiss, disques, rayons, \
wireFondFiss = geompy.MakeWire(edgesInside, 1e-07) demiCercles, generatrices, \
VerticesEndPipeFiss, bordsLibres, \
disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe) groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss = \
[vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False) insereFissureLongue_b (edgesInside, centreFondFiss, tangentFondFiss, \
vertproj = geompy.MakeProjection(vertex, planfiss) planfiss, planBord1, planBord2, \
vec1 = geompy.MakeVector(centreFondFiss, vertex) facePeau, verticesOutCercles, verticesEdgePeauFiss, \
try: fillingFaceExterne, rayonPipe, \
# si centreFondFiss et vertproj sont proches: exception. Angle = +- 90° internalBoundary)
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() )
# --- maillage pipe fond fissure # --- maillage pipe fond fissure
meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout = \ 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, \ VerticesEndPipeFiss, verticesEdgePeauFiss, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \ groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
profondeur, rayonPipe, distance2) profondeur, rayonPipe)
# --- maillage face de peau # --- maillage face de peau
meshFacePeau, groupEdgesPeauFiss = \ meshFacePeau, groupEdgesPeauFiss = \
insereFissureLongue_b ( facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \ insereFissureLongue_d ( facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \ groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
nbSegGenLong, nbSegGenBout, profondeur, \ nbSegGenLong, nbSegGenBout, profondeur, \
mailleur ) mailleur )
@ -430,68 +135,24 @@ def insereFissureLongue(geometriesSaines, \
# --- maillage face de fissure # --- maillage face de fissure
meshFaceFiss = \ meshFaceFiss = \
insereFissureLongue_c ( faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \ insereFissureLongue_e ( faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
profondeur, rayonPipe, \ profondeur, rayonPipe, \
mailleur ) mailleur )
# --- maillage meshBoiteDefaut # --- maillage meshBoiteDefaut
meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe = \ meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe = \
insereFissureLongue_d ( internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \ insereFissureLongue_f ( internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
mailleur ) mailleur )
groups = maillageSain.GetGroups() # --- maillage complet
grps1 = [ grp for grp in groups if grp.GetName() == 'P1'] maillageComplet = \
grps2 = [ grp for grp in groups if grp.GetName() == 'P2'] insereFissureLongue_g (nomFicFissure, fichierMaillageFissure, nomFicSain, maillageSain, \
coords1 = maillageSain.GetNodeXYZ(grps1[0].GetID(1)) meshBoiteDefaut, facePorteFissure, \
coords2 = maillageSain.GetNodeXYZ(grps2[0].GetID(1)) group_faceFissInPipe, group_faceFissOutPipe, \
logging.info("coords1 %s, coords2 %s",coords1, coords2) 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(): if salome.sg.hasDesktop():
salome.sg.updateObjBrowser() salome.sg.updateObjBrowser()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # 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 # 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 logging
import salome import salome
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import smesh from .geomsmesh import geomPublish
from salome.smesh import smeshBuilder from .geomsmesh import geomPublishInFather
import SMESH
from . import initLog
from .extractionOrientee import extractionOrientee
from .sortFaces import sortFaces
from .sortEdges import sortEdges 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, \ def insereFissureLongue_a(facePorteFissure, WirePorteFondFissure, \
VerticesEndPipeFiss, verticesEdgePeauFiss, \ fillingFaceExterne, \
groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \ pipefiss, rayonPipe, \
profondeur, rayonPipe, distance2): mailleur="MeshGems"):
"""maillage pipe fond fissure""" """procedure complete fissure longue"""
logging.info('start') 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) # --- peau et face de fissure
putName(algo2d.GetSubMesh(), "disque", i)
putName(algo2d, "algo2d_disque", i)
for i, edge in enumerate(rayons): # --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée
algo1d = meshFondFiss.Segment(geom=edge) partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
hypo1d = algo1d.NumberOfSegments(4) geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond' )
putName(algo1d.GetSubMesh(), "rayon", i)
putName(algo1d, "algo1d_rayon", i)
putName(hypo1d, "hypo1d_rayon", i)
for i, edge in enumerate(demiCercles): edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False)
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) lgmax = 0
nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face imax = 0
nbSegGenBout = 6 for i_aux, edge in enumerate(edges):
logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted)) props = geompy.BasicProperties(edge)
for i, edge in enumerate(generSorted): longueur = props[0]
algo1d = meshFondFiss.Segment(geom=edge) if ( longueur > lgmax ):
if i < 6: lgmax = longueur
hypo1d = algo1d.NumberOfSegments(nbSegGenBout) imax = i_aux
else: edgemax = edges[imax]
hypo1d = algo1d.NumberOfSegments(nbSegGenLong) geomPublish(initLog.debug, edgemax, 'edgemax')
putName(algo1d.GetSubMesh(), "generatrice", i) centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5)
putName(algo1d, "algo1d_generatrice", i) geomPublish(initLog.debug, centreFondFiss, 'centreFondFiss')
putName(hypo1d, "hypo1d_generatrice", i) tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5)
geomPublish(initLog.debug, tangentFondFiss, 'tangentFondFiss')
disks = list() bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0)
for i, face in enumerate(disques[:4]): geomPublish(initLog.debug, bord1FondFiss, 'bord1FondFiss')
name = "disk%d"%i tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0)
disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE)) geomPublish(initLog.debug, tangentBord1FondFiss, 'tangentBord1FondFiss')
_ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE) bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0)
_ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE) geomPublish(initLog.debug, bord2FondFiss, 'bord2FondFiss')
tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0)
geomPublish(initLog.debug, tangentBord2FondFiss, 'tangentBord2FondFiss')
_ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE) planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE) planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe)
_ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE) geomPublish(initLog.debug, planBord1, 'planBord1')
geomPublish(initLog.debug, planBord2, 'planBord2')
groups_demiCercles = list() [edgesInside, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
groupnodes_demiCercles = list() [facesInside, _, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
for i, group in enumerate(groupsDemiCerclesPipe):
# --- 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 name = "Cercle%d"%i
groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE)) geomPublishInFather(initLog.debug,facePeau, group , name)
name = "nCercle%d"%i groupsDemiCerclesPeau.append(group)
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() # --- identification edges commune pipe face fissure externe au pipe
text = "meshFondFiss.Compute" edgePeauFissId = geompy.GetSubShapeID(partitionPeauFissByPipe, edgePeauFiss)
if is_done: edgesFaceFiss = geompy.ExtractShapes(faceFiss, geompy.ShapeType["EDGE"], False)
logging.info(text+" OK") edgesFaceFissPipe = list()
else: for edge in edgesFaceFiss:
text = "Erreur au calcul du maillage.\n" + text if geompy.GetSubShapeID(partitionPeauFissByPipe, edge) != edgePeauFissId:
logging.info(text) edgesFaceFissPipe.append(edge)
raise Exception(text) 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") return edgesInside, centreFondFiss, tangentFondFiss, \
grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1") planBord1, planBord2, \
idNode0 = grpNode0.GetID(1) facePeau, faceFiss, verticesOutCercles, verticesEdgePeauFiss, \
idNode1 = grpNode1.GetID(1) edgePeauFiss, demiCerclesPeau, \
coordsMesh = list() groupEdgesBordPeau, groupsDemiCerclesPeau, groupEdgesFaceFissPipe
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

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # 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 # 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 logging
import salome import salome
from .geomsmesh import geompy
from .geomsmesh import smesh
from salome.smesh import smeshBuilder from salome.smesh import smeshBuilder
import SMESH 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, \ from . import initLog
groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
nbSegGenLong, nbSegGenBout, profondeur, \ from .extractionOrientee import extractionOrientee
mailleur="MeshGems"): from .sortEdges import sortEdges
"""maillage face de peau""" 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') logging.info('start')
meshFacePeau = smesh.Mesh(facePeau) # -----------------------------------------------------------------------------
logging.info("Maillage avec %s", mailleur) # --- pipe de fond de fissure
if ( mailleur == "MeshGems"):
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf) wireFondFiss = geompy.MakeWire(edgesInside, 1e-07)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( 1000 ) disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe)
hypo2d.SetMinSize( 100 ) [vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
hypo2d.SetMaxSize( 3000. ) vertproj = geompy.MakeProjection(vertex, planfiss)
hypo2d.SetChordalError( 250. ) vec1 = geompy.MakeVector(centreFondFiss, vertex)
hypo2d.SetVerbosity( 0 ) 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: else:
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D) disque = geompy.MakeRotation(disque, tangentFondFiss, -angle)
hypo2d = algo2d.Parameters() [vertexReference] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False)
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)
algo1d = meshFacePeau.Segment(geom=edgePeauFiss) pipeFondFiss = geompy.MakePipe(disque, wireFondFiss)
hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ]) pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
hypo1d.SetDistrType( 2 ) #pipe = geompy.MakePipe(disque, WirePorteFondFissure)
hypo1d.SetConversionMode( 1 ) #pipe = geompy.MakePartition([pipe],[fillingFaceExterne], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] ) #pipes = geompy.ExtractShapes(pipe, geompy.ShapeType["SOLID"], False)
putName(algo1d.GetSubMesh(), "edgePeauFiss") #pipesSorted, volmin, volmax = sortSolids(pipes)
putName(algo1d, "algo1d_edgePeauFiss") #pipeFondFiss = pipesSorted[-1]
putName(hypo1d, "hypo1d_edgePeauFiss") #pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], list(), list(), geompy.ShapeType["SOLID"], 0, list(), 0)
#
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) geomPublish(initLog.debug, disque, 'disque')
_ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE) 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() geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[0], "PFOR")
text = "meshFacePeau.Compute" geomPublishInFather(initLog.debug,pipeFondFiss, VerticesEndPipeFiss[1], "PFEX")
if is_done: if ( geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[0]) > geompy.MinDistance(VerticesEndPipeFiss[0], verticesOutCercles[1]) ):
logging.info(text+" OK") aux = verticesOutCercles[0]
else: verticesOutCercles[0] = verticesOutCercles[1]
text = "Erreur au calcul du maillage.\n" + text verticesOutCercles[1] = aux
logging.info(text) geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[0], "THOR")
raise Exception(text) geomPublishInFather(initLog.debug,facePeau, verticesOutCercles[1], "THEX")
peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' ) [_, _, facesPipeOnside] = extractionOrientee(fillingFaceExterne, pipeFondFiss, centreFondFiss, "FACE", 0.1, "pipe_bord_")
_ = peauext_face.AddFrom( meshFacePeau.GetMesh() ) [_, _, 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 # 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 logging
import math
import salome import salome
from .geomsmesh import smesh
from salome.smesh import smeshBuilder from salome.smesh import smeshBuilder
import SMESH import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .sortEdges import sortEdges
from .putName import putName from .putName import putName
from .distance2 import distance2
import math def insereFissureLongue_c (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
VerticesEndPipeFiss, verticesEdgePeauFiss, \
def insereFissureLongue_c (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \ groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
profondeur, rayonPipe, \ profondeur, rayonPipe):
mailleur="MeshGems"): """maillage pipe fond fissure"""
"""maillage face de fissure"""
logging.info('start') logging.info('start')
meshFaceFiss = smesh.Mesh(faceFiss) meshFondFiss = smesh.Mesh(pipeFondFiss)
mesh_size = (profondeur - rayonPipe)/math.sqrt(3.0) # pour avoir deux couches de triangles equilateraux partout sur la fissure algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
logging.info("Maillage avec %s", mailleur) algo3d = meshFondFiss.Prism()
if ( mailleur == "MeshGems"): putName(algo3d.GetSubMesh(), "pipe")
algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.MG_CADSurf) putName(algo3d, "algo3d_pipe")
hypo2d = algo2d.Parameters() putName(algo2d, "algo2d_pipe")
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) 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() for i, edge in enumerate(rayons):
text = "meshFaceFiss.Compute" 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: if is_done:
logging.info(text+" OK") logging.info(text+" OK")
else: else:
@ -81,4 +112,36 @@ def insereFissureLongue_c (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_gen
logging.info(text) logging.info(text)
raise Exception(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 # 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 logging
import salome import salome
from .geomsmesh import smesh
from salome.smesh import smeshBuilder from salome.smesh import smeshBuilder
import SMESH import SMESH
from .geomsmesh import geompy
from .geomsmesh import smesh
from .putName import putName 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"): mailleur="MeshGems"):
"""maillage meshBoiteDefaut""" """maillage face de peau"""
logging.info('start') logging.info('start')
logging.info("insereFissureLongue_d (%s)", mailleur)
meshBoiteDefaut = smesh.Concatenate( [internalBoundary.GetMesh(), \ meshFacePeau = smesh.Mesh(facePeau)
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) logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"): 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: else:
algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN) algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
hypo3d = algo3d.MaxElementVolume(1000.0) hypo2d = algo2d.Parameters()
hypo3d.SetVerboseLevel( 0 ) hypo2d.SetMaxSize( 1000 )
hypo3d.SetStandardOutputLog( 0 ) hypo2d.SetOptimize( 1 )
hypo3d.SetRemoveLogOnSuccess( 1 ) hypo2d.SetFineness( 2 )
putName(algo3d.GetSubMesh(), "boiteDefaut") hypo2d.SetMinSize( 2 )
putName(algo3d, "algo3d_boiteDefaut") hypo2d.SetQuadAllowed( 0 )
putName(meshBoiteDefaut, "boiteDefaut") 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() algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
text = "meshBoiteDefaut.Compute" 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: if is_done:
logging.info(text+" OK") logging.info(text+" OK")
else: else:
@ -76,4 +101,7 @@ def insereFissureLongue_d (internalBoundary, meshFondFiss, meshFacePeau, meshFac
logging.info(text) logging.info(text)
raise Exception(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 # 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 Created on Mon Jun 23 14:49:36 2014
@author: I48174 (Olivier HOAREAU) @author: I48174 (Olivier HOAREAU)
""" """
@ -29,189 +28,193 @@ import SMESH
from .geomsmesh import smesh from .geomsmesh import smesh
def lookForCorner(maillageAScanner): def lookForCorner(maillageAScanner):
""" Cette fonction permet de scanner la liste de noeuds qui composent le """ Cette fonction permet de scanner la liste de noeuds qui composent le
maillage passé en paramètre. On recherche un ou plusieurs coins, ce maillage passé en paramètre. On recherche un ou plusieurs coins, ce
qui implique les caractéristiques suivantes: qui implique les caractéristiques suivantes:
- le noeud doit appartenir au moins à trois éléments distincts - le noeud doit appartenir au moins à trois éléments distincts
- chaque élément doit appartenir à un ensemble distinct - chaque élément doit appartenir à un ensemble distinct
La fonction renvoie une liste de coins par l'intermédiaire de l'IDs 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. chaque noeud. La liste contient en général au maximum deux coins.
""" """
logging.info("start") logging.info("start")
allNodeIds = maillageAScanner.GetNodesId() # On stocke tout les noeuds allNodeIds = maillageAScanner.GetNodesId() # On stocke tout les noeuds
listOfCorners = [] listOfCorners = list()
for ND in allNodeIds: for noeud in allNodeIds:
# On parcours la liste de noeuds # On parcours la liste de noeuds
listOfElements = maillageAScanner.GetNodeInverseElements(ND) listOfElements = maillageAScanner.GetNodeInverseElements(noeud)
if len(listOfElements) >=3: if len(listOfElements) >=3:
# On teste le nombre d'éléments qui partagent le même noeud # On teste le nombre d'éléments qui partagent le même noeud
# --- Filtre selon le critère 'coplanar' --- # # --- Filtre selon le critère 'coplanar' --- #
listOfCriterion = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \ listOfCriterion = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30) \ SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30) \
for elem in listOfElements] for elem in listOfElements]
listOfFilters = [smesh.GetFilterFromCriteria([criteria]) for criteria in listOfCriterion] listOfFilters = [smesh.GetFilterFromCriteria([criteria]) for criteria in listOfCriterion]
listOfSets = [maillageAScanner.GetIdsFromFilter(filter) for filter in listOfFilters] listOfSets = [maillageAScanner.GetIdsFromFilter(filtre) for filtre in listOfFilters]
if listOfSets.count(listOfSets[0]) == len(listOfSets): if listOfSets.count(listOfSets[0]) == len(listOfSets):
# Si toutes les listes d'éléments sont similaires, on retourne # Si toutes les listes d'éléments sont similaires, on retourne
# au début pour éviter de travailler sur des éléments inutiles. # au début pour éviter de travailler sur des éléments inutiles.
# Exemple : un noeud appartenant à 4 éléments sur la même face. # Exemple : un noeud appartenant à 4 éléments sur la même face.
continue continue
for s in listOfSets: for l_aux in listOfSets:
while listOfSets.count(s) > 1: while listOfSets.count(l_aux) > 1:
# On supprime tant que la liste d'éléments n'est pas unique. # On supprime tant que la liste d'éléments n'est pas unique.
listOfSets.remove(s) listOfSets.remove(l_aux)
if len(listOfSets) >= 3: if len(listOfSets) >= 3:
# Si on a au moins 3 listes d'élements différentes, on considère # Si on a au moins 3 listes d'élements différentes, on considère
# qu'il y a présence d'un coin. # qu'il y a présence d'un coin.
listOfCorners.append(ND) listOfCorners.append(noeud)
return listOfCorners
return listOfCorners
def createLinesFromMesh(maillageSupport): def createLinesFromMesh(maillageSupport):
""" Cette fonction permet de générer une liste de lignes à partir du """ 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 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 simple et on parcourt tout les noeuds pour former une ligne. Soit la
figure ci-dessous : figure ci-dessous :
1_____4_____7 On part du coin N1, et on cherche les noeuds 1_____4_____7 On part du coin N1, et on cherche les noeuds
| | | successifs tels que [1, 2, 3]. Lorsqu'on arrive | | | successifs tels que [1, 2, 3]. Lorsqu'on arrive
| 1 | 3 | arrive sur le noeud de fin de ligne N3, on repart | 1 | 3 | arrive sur le noeud de fin de ligne N3, on repart
| | | du noeud précédent du premier élément (E1), à | | | du noeud précédent du premier élément (E1), à
2_____5_____8 savoir le noeud N4. On suit les noeuds succesifs 2_____5_____8 savoir le noeud N4. On suit les noeuds succesifs
| | | [4, 5, 6] comme précédemment et ainsi de suite. | | | [4, 5, 6] comme précédemment et ainsi de suite.
| 2 | 4 | Lorsqu'on arrive sur le dernier noeud de la | 2 | 4 | Lorsqu'on arrive sur le dernier noeud de la
| | | dernière ligne, à savoir le noeud N9, on considère | | | dernière ligne, à savoir le noeud N9, on considère
3_____6_____9 que toutes les lignes sont créées. 3_____6_____9 que toutes les lignes sont créées.
La fonction retourne une liste de lignes utilisées par la suite. La fonction retourne une liste de lignes utilisées par la suite.
""" """
logging.info("start") logging.info("start")
allNodeIds = maillageSupport.GetNodesId() allNodeIds = maillageSupport.GetNodesId()
while len(allNodeIds): while len(allNodeIds):
nodeIds = allNodeIds nodeIds = allNodeIds
for idNode in nodeIds: # rechercher un coin for idNode in nodeIds: # rechercher un coin
elems = maillageSupport.GetNodeInverseElements(idNode) elems = maillageSupport.GetNodeInverseElements(idNode)
if len(elems) == 1: if len(elems) == 1:
# un coin: un noeud, un element quadrangle # un coin: un noeud, un element quadrangle
elem = elems[0] elem = elems[0]
break; idNode_c = idNode
idStart = idNode # le noeud de coin break
elemStart = elem # l'élément quadrangle au coin idStart = idNode_c # le noeud de coin
xyz = maillageSupport.GetNodeXYZ(idStart) elemStart = elem # l'élément quadrangle au coin
logging.debug("idStart %s, coords %s", idStart, str(xyz)) 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 nodelines = list() # on va constituer une liste de lignes de points
ligneFinale = False nextLine = True
while nextLine: ligneFinale = False
logging.debug("--- une ligne") while nextLine:
idNode = idStart logging.debug("--- une ligne")
elem = elemStart idNode = idStart
if ligneFinale: elem = elemStart
agauche = False # sens de parcours des 4 noeuds d'un quadrangle if ligneFinale:
nextLine = False 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: else:
agauche = True iprec = nodes[3]
ligneIncomplete = True # on commence une ligne de points idStart = iprec
debutLigne = True elems3 = maillageSupport.GetNodeInverseElements(iprec)
nodeline = [] if len(elems3) == 1: # autre coin
elemline = [] ligneFinale = True
while ligneIncomplete: # compléter la ligne de points else:
nodeline.append(idNode) for elem3 in elems3:
allNodeIds.remove(idNode) if elem3 != elem:
elemline.append(elem) elemStart = elem3
nodes = maillageSupport.GetElemNodes(elem) break
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 #print nodes, idNode, isuiv, iapres
if i < 3: elems1 = maillageSupport.GetNodeInverseElements(isuiv)
j = i+1 elems2 = maillageSupport.GetNodeInverseElements(iapres)
else: ligneIncomplete = False
j = 0 for elem2 in elems2:
if j < 3: if elems1.count(elem2) and elem2 != elem:
k = j+1 ligneIncomplete = True
else: idNode = isuiv
k = 0 elem = elem2
else: break
if i > 0: if not ligneIncomplete:
j = i -1 nodeline.append(isuiv)
else: allNodeIds.remove(isuiv)
j = 3 logging.debug("nodeline %s", nodeline)
if j > 0: logging.debug("elemline %s", elemline)
k = j -1 nodelines.append(nodeline)
else:
k = 3 # on a constitué une liste de lignes de points connexes
isuiv = nodes[j] # noeud suivant logging.debug("dimensions [%s, %s]", len(nodelines), len(nodeline))
iapres = nodes[k] # noeud opposé
if debutLigne: return nodelines
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
def createNewMeshesFromCorner(maillageSupport, listOfCorners): def createNewMeshesFromCorner(maillageSupport, listOfCorners):
""" Cette fonction permet de générer un nouveau maillage plus facile à """ 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 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 auquel le noeud appartient. Grâce à un filtre 'coplanar' sur les trois
éléments, on peut générer des faces distinctes. éléments, on peut générer des faces distinctes.
""" """
logging.info("start") logging.info("start")
tmp = [] tmp = list()
listOfNewMeshes = [] listOfNewMeshes = list()
for corner in listOfCorners: for corner in listOfCorners:
elems = maillageSupport.GetNodeInverseElements(corner) elems = maillageSupport.GetNodeInverseElements(corner)
for i, elem in enumerate(elems): for i_aux, elem in enumerate(elems):
# --- Filtre selon le critère 'coplanar' --- # # --- Filtre selon le critère 'coplanar' --- #
critere = smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \ critere = smesh.GetCriterion(SMESH.FACE, SMESH.FT_CoplanarFaces, \
SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30) SMESH.FT_Undefined, elem, SMESH.FT_Undefined, SMESH.FT_Undefined, 30)
filtre = smesh.GetFilterFromCriteria([critere]) filtre = smesh.GetFilterFromCriteria([critere])
grp = maillageSupport.GroupOnFilter(SMESH.FACE, 'grp', filtre) grp = maillageSupport.GroupOnFilter(SMESH.FACE, 'grp', filtre)
# On copie le maillage en fonction du filtre # On copie le maillage en fonction du filtre
msh = smesh.CopyMesh(grp, 'new_{0}'.format(i + 1), False, True) msh = smesh.CopyMesh(grp, 'new_{0}'.format(i_aux+1), False, True)
# On stocke l'ensemble des noeuds du maillage dans tmp # On stocke l'ensemble des noeuds du maillage dans tmp
# On ajoute le maillage à la liste des nouveaux maillages # On ajoute le maillage à la liste des nouveaux maillages
# seulement s'il n'y est pas déjà # seulement s'il n'y est pas déjà
tmp.append(msh.GetNodesId()) tmp.append(msh.GetNodesId())
if tmp.count(msh.GetNodesId()) <= 1: if ( tmp.count(msh.GetNodesId()) <= 1 ):
listOfNewMeshes.append(msh) listOfNewMeshes.append(msh)
return listOfNewMeshes
return listOfNewMeshes

View File

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

View File

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

View File

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

View File

@ -17,33 +17,33 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Maillage du bloc partitionné"""
import logging import logging
import SMESH
from salome.smesh import smeshBuilder
from salome.StdMeshers import StdMeshersBuilder
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import smesh from .geomsmesh import smesh
from salome.smesh import smeshBuilder
import SMESH
from salome.StdMeshers import StdMeshersBuilder
from .putName import putName from .putName import putName
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# --- maillage du bloc partitionne
def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, \ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, \
gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, \ gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, \
aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, \ aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, \
nbsegExt, nbsegGen, nbsegRad, scaleRad, reverses, reverext, nbsegCercle, nbsegFis, dmoyen, lensegEllipsoide, \ nbsegExt, nbsegGen, nbsegRad, scaleRad, reverses, reverext, nbsegCercle, nbsegFis, dmoyen, lensegEllipsoide, \
mailleur="MeshGems"): mailleur="MeshGems"):
"""Maillage du bloc partitionné """Maillage du bloc partitionné"""
TODO: a completer
"""
logging.info('start') logging.info('start')
# --- edges de bord à respecter # --- edges de bord à respecter
aFilterManager = smesh.CreateFilterManager() _ = smesh.CreateFilterManager()
nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ]) _, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ])
criteres = list() criteres = list()
unCritere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0) unCritere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0)
criteres.append(unCritere) criteres.append(unCritere)
@ -55,22 +55,22 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
bloc1 = smesh.Mesh(blocPartition) 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) algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN, geom=sharedFaces_i)
hypo2d = algo2d.Parameters(which=smesh.SIMPLE) hypo2d = algo2d.Parameters(which=smesh.SIMPLE)
hypo2d.SetLocalLength(lensegEllipsoide) hypo2d.SetLocalLength(lensegEllipsoide)
hypo2d.LengthFromEdges() hypo2d.LengthFromEdges()
hypo2d.SetAllowQuadrangles(0) hypo2d.SetAllowQuadrangles(0)
putName(algo2d.GetSubMesh(), "sharedFaces", i) putName(algo2d.GetSubMesh(), "sharedFaces", i_aux)
putName(algo2d, "algo2d_sharedFaces", i) putName(algo2d, "algo2d_sharedFaces", i_aux)
putName(hypo2d, "hypo2d_sharedFaces", i) 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) algo1d = bloc1.Segment(geom=sharedEdges_i)
hypo1d = algo1d.LocalLength(lensegEllipsoide) hypo1d = algo1d.LocalLength(lensegEllipsoide)
putName(algo1d.GetSubMesh(), "sharedEdges", i) putName(algo1d.GetSubMesh(), "sharedEdges", i_aux)
putName(algo1d, "algo1d_sharedEdges", i) putName(algo1d, "algo1d_sharedEdges", i_aux)
putName(hypo1d, "hypo1d_sharedEdges", i) putName(hypo1d, "hypo1d_sharedEdges", i_aux)
declareAlgoEllipsoideFirst = False declareAlgoEllipsoideFirst = False
if declareAlgoEllipsoideFirst: if declareAlgoEllipsoideFirst:
@ -90,32 +90,32 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
putName(algo1d, "algo1d_tore") putName(algo1d, "algo1d_tore")
putName(hypo1d, "hypo1d_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) algo2d = bloc1.Quadrangle(geom=faces_i)
hypo2d = smesh.CreateHypothesis('QuadrangleParams') hypo2d = smesh.CreateHypothesis('QuadrangleParams')
hypo2d.SetTriaVertex( geompy.GetSubShapeID(blocPartition,centres[i]) ) hypo2d.SetTriaVertex( geompy.GetSubShapeID(blocPartition,centres[i_aux]) )
hypo2d.SetQuadType( StdMeshersBuilder.QUAD_STANDARD ) hypo2d.SetQuadType( StdMeshersBuilder.QUAD_STANDARD )
status = bloc1.AddHypothesis(hypo2d,faces_i) _ = bloc1.AddHypothesis(hypo2d,faces_i)
putName(algo2d.GetSubMesh(), "faces", i) putName(algo2d.GetSubMesh(), "faces", i_aux)
putName(algo2d, "algo2d_faces", i) putName(algo2d, "algo2d_faces", i_aux)
putName(hypo2d, "hypo2d_faces", i) 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) 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) ]) hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ geompy.GetSubShapeID(blocPartition,edges_i) ])
else: else:
hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ ]) hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ ])
putName(algo1d.GetSubMesh(), "edges", i) putName(algo1d.GetSubMesh(), "edges", i_aux)
putName(algo1d, "algo1d_edges", i) putName(algo1d, "algo1d_edges", i_aux)
putName(hypo1d, "hypo1d_edges", i) 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) algo1d = bloc1.Segment(geom=circles_i)
hypo1d = algo1d.NumberOfSegments(nbsegCercle) hypo1d = algo1d.NumberOfSegments(nbsegCercle)
putName(algo1d.GetSubMesh(), "circles", i) putName(algo1d.GetSubMesh(), "circles", i_aux)
putName(algo1d, "algo1d_circles", i) putName(algo1d, "algo1d_circles", i_aux)
putName(hypo1d, "hypo1d_circles", i) putName(hypo1d, "hypo1d_circles", i_aux)
if len(edgeext) == 1: if len(edgeext) == 1:
densite = int(round(nbsegFis/2)) densite = int(round(nbsegFis/2))
@ -130,24 +130,23 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
else: else:
longTotal = 0 longTotal = 0
longEdgeExts = list() longEdgeExts = list()
for i, edgeext_i in enumerate(edgeext): for edgeext_i in edgeext:
props = geompy.BasicProperties(edgeext_i) props = geompy.BasicProperties(edgeext_i)
longEdgeExts.append(props[0]) longEdgeExts.append(props[0])
longTotal += props[0] longTotal += props[0]
for i, edgeext_i in enumerate(edgeext): for i_aux, edgeext_i in enumerate(edgeext):
local = longTotal/nbsegFis nbLocal = int(round(nbsegFis*longEdgeExts[i_aux]/longTotal))
nbLocal = int(round(nbsegFis*longEdgeExts[i]/longTotal))
densite = int(round(nbLocal/2)) densite = int(round(nbLocal/2))
algo1d = bloc1.Segment(geom=edgeext_i) algo1d = bloc1.Segment(geom=edgeext_i)
hypo1d = algo1d.NumberOfSegments(nbLocal) hypo1d = algo1d.NumberOfSegments(nbLocal)
hypo1d.SetDistrType( 2 ) hypo1d.SetDistrType( 2 )
hypo1d.SetConversionMode( 1 ) hypo1d.SetConversionMode( 1 )
hypo1d.SetTableFunction( [ 0, densite, 0.8, 1, 1, 1 ] ) hypo1d.SetTableFunction( [ 0, densite, 0.8, 1, 1, 1 ] )
if reverext[i]: if reverext[i_aux]:
hypo1d.SetReversedEdges([ geompy.GetSubShapeID(blocPartition, edgeext_i) ]) hypo1d.SetReversedEdges([ geompy.GetSubShapeID(blocPartition, edgeext_i) ])
putName(algo1d.GetSubMesh(), "edgeext", i) putName(algo1d.GetSubMesh(), "edgeext", i_aux)
putName(algo1d, "algo1d_edgeext", i) putName(algo1d, "algo1d_edgeext", i_aux)
putName(hypo1d, "hypo1d_edgeext", i) putName(hypo1d, "hypo1d_edgeext", i_aux)
algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facefissoutore) algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facefissoutore)
hypo2d = algo2d.LengthFromEdges() hypo2d = algo2d.LengthFromEdges()
@ -159,25 +158,25 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
maxElemArea = 0.5*dmoyen*dmoyen maxElemArea = 0.5*dmoyen*dmoyen
logging.debug("dmoyen %s, maxElemArea %s", dmoyen, maxElemArea) 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) algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facesExternes_i)
hypo2d = algo2d.MaxElementArea(maxElemArea) hypo2d = algo2d.MaxElementArea(maxElemArea)
if edgesBords is None: if edgesBords is None:
algo1d = bloc1.Segment(geom=facesExternes_i) algo1d = bloc1.Segment(geom=facesExternes_i)
hypo1d = algo1d.NumberOfSegments(1) hypo1d = algo1d.NumberOfSegments(1)
putName(algo2d.GetSubMesh(), "facesExternes", i) putName(algo2d.GetSubMesh(), "facesExternes", i_aux)
putName(algo2d, "algo2d_facesExternes", i) putName(algo2d, "algo2d_facesExternes", i_aux)
putName(hypo2d, "hypo2d_facesExternes", i) putName(hypo2d, "hypo2d_facesExternes", i_aux)
if edgesBords is None: if edgesBords is None:
putName(algo1d, "algo1d_facesExternes", i) putName(algo1d, "algo1d_facesExternes", i_aux)
putName(hypo1d, "hypo1d_facesExternes", i) 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) algo1d = bloc1.Segment(geom=aretesInternes_i)
hypo1d = algo1d.NumberOfSegments(nbsegExt) hypo1d = algo1d.NumberOfSegments(nbsegExt)
putName(algo1d.GetSubMesh(), "aretesInternes", i) putName(algo1d.GetSubMesh(), "aretesInternes", i_aux)
putName(algo1d, "algo1d_aretesInternes", i) putName(algo1d, "algo1d_aretesInternes", i_aux)
putName(hypo1d, "hypo1d_aretesInternes", i) putName(hypo1d, "hypo1d_aretesInternes", i_aux)
if edgesBords is not None: if edgesBords is not None:
algo1d = bloc1.UseExisting1DElements(geom=edgesBords) algo1d = bloc1.UseExisting1DElements(geom=edgesBords)
@ -193,16 +192,16 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
putName(algo3d, "algo3d_ellipsoide") putName(algo3d, "algo3d_ellipsoide")
putName(hypo3d, "hypo3d_ellipsoide") putName(hypo3d, "hypo3d_ellipsoide")
faceFissure1 = bloc1.GroupOnGeom(faceFissure,'FACE1',SMESH.FACE) _ = bloc1.GroupOnGeom(faceFissure,'FACE1',SMESH.FACE)
noeudsFondFissure = bloc1.GroupOnGeom(gencnt,'nfondfis',SMESH.NODE) _ = bloc1.GroupOnGeom(gencnt,'nfondfis',SMESH.NODE)
groups_faceCommuneEllipsoideBloc = list() groups_faceCommuneEllipsoideBloc = list()
for i, sharedFaces_i in enumerate(sharedFaces): for i_aux, sharedFaces_i in enumerate(sharedFaces):
name = "faceCommuneEllipsoideBloc_%d"%i name = "faceCommuneEllipsoideBloc_{}".format(i_aux)
groups_faceCommuneEllipsoideBloc.append(bloc1.GroupOnGeom(sharedFaces_i, name, SMESH.FACE)) groups_faceCommuneEllipsoideBloc.append(bloc1.GroupOnGeom(sharedFaces_i, name, SMESH.FACE))
groups_faceExterneBloc = list() groups_faceExterneBloc = list()
for i, facesExtBloc_i in enumerate(facesExtBloc): for i_aux, facesExtBloc_i in enumerate(facesExtBloc):
name = "faceExterneBloc_%d"%i name = "faceExterneBloc_{}".format(i_aux)
groups_faceExterneBloc.append(bloc1.GroupOnGeom(facesExtBloc_i, name, SMESH.FACE)) groups_faceExterneBloc.append(bloc1.GroupOnGeom(facesExtBloc_i, name, SMESH.FACE))
is_done = bloc1.Compute() is_done = bloc1.Compute()
@ -214,18 +213,18 @@ def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circle
logging.info(text) logging.info(text)
raise Exception(text) raise Exception(text)
nbRemoved = bloc1.RemoveOrphanNodes() _ = bloc1.RemoveOrphanNodes()
skinBlocMeshes = list() skinBlocMeshes = list()
for i, groups_faceCommuneEllipsoideBloc_i in enumerate(groups_faceCommuneEllipsoideBloc): for i_aux, groups_faceCommuneEllipsoideBloc_i in enumerate(groups_faceCommuneEllipsoideBloc):
name = "faceCommuneEllipsoideBloc_%d"%i name = "faceCommuneEllipsoideBloc_{}".format(i_aux)
skinBlocMeshes.append(smesh.CopyMesh(groups_faceCommuneEllipsoideBloc_i, name, 0, 0)) skinBlocMeshes.append(smesh.CopyMesh(groups_faceCommuneEllipsoideBloc_i, name, 0, 0))
for i, groups_faceExterneBloc_i in enumerate(groups_faceExterneBloc): for i_aux, groups_faceExterneBloc_i in enumerate(groups_faceExterneBloc):
name = "faceExterneBloc_%d"%i name = "faceExterneBloc_{}".format(i_aux)
skinBlocMeshes.append(smesh.CopyMesh(groups_faceExterneBloc_i, name, 0, 0)) skinBlocMeshes.append(smesh.CopyMesh(groups_faceExterneBloc_i, name, 0, 0))
meshesBloc = [internalBoundary.GetMesh()] meshesBloc = [internalBoundary.GetMesh()]
for i, skinBlocMeshes_i in enumerate(skinBlocMeshes): for skinBlocMeshes_i in skinBlocMeshes:
meshesBloc.append(skinBlocMeshes_i.GetMesh()) meshesBloc.append(skinBlocMeshes_i.GetMesh())
blocMesh = smesh.Concatenate(meshesBloc, 1, 1, 1e-05,False) 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Trouver les vertices intermédiaires d'un wire"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
# -----------------------------------------------------------------------------
# --- trouver les vertices intermediaires d'un wire
def orderEdgesFromWire(aWire): 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) et l'ordre des edges selon le sens de parcours (ordre des indices de la liste d'edges)
""" """
logging.info("start") logging.info("start")
edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False)
idverts = dict() idverts = dict()
for i, edge in enumerate(edges): for i_aux, edge in enumerate(edges):
verts = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True) verts = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True)
# idverts[(i,0)] = verts[0] vertex_a = geompy.MakeVertexOnCurve(edge, 0.0)
# idverts[(i,1)] = verts[1] dist = geompy.MinDistance(vertex_a, verts[0])
v0 = geompy.MakeVertexOnCurve(edge, 0.0)
dist = geompy.MinDistance(v0, verts[0])
if dist < 1.e-4: if dist < 1.e-4:
idverts[(i,0)] = verts[0] idverts[(i_aux,0)] = verts[0]
idverts[(i,1)] = verts[1] idverts[(i_aux,1)] = verts[1]
else: else:
idverts[(i,0)] = verts[1] idverts[(i_aux,0)] = verts[1]
idverts[(i,1)] = verts[0] idverts[(i_aux,1)] = verts[0]
idsubs = dict() idsubs = dict()
for kv, sub in idverts.items(): for i_aux, sub in idverts.items():
subid = geompy.GetSubShapeID(aWire, sub) subid = geompy.GetSubShapeID(aWire, sub)
if subid in list(idsubs.keys()): if ( subid in idsubs ):
idsubs[subid].append(kv) idsubs[subid].append(i_aux)
else: else:
idsubs[subid] = [kv] idsubs[subid] = [i_aux]
debut = -1 debut = -1
fin = -1 fin = -1
for k, kvs in idsubs.items(): for _, kvs in idsubs.items():
if len(kvs) == 1: # une extremité if len(kvs) == 1: # une extremité
kv = kvs[0] kv0 = kvs[0]
if kv[1] == 0: if kv0[1] == 0:
debut = kv[0] debut = kv0[0]
else: else:
fin = kv[0] fin = kv0[0]
logging.debug("nombre d'edges: {}, indice edge début: {}, fin: {}".format(len(edges), debut, fin)) texte = "nombre d'edges: {}, indice edge début: {}, fin: {}".format(len(edges), debut, fin)
logging.debug(texte)
if debut < 0: if debut < 0:
logging.critical("les edges du wire ne sont pas orientées dans le même sens: pas de début trouvé") 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))) return edges, list(range(len(edges)))
orderedList = [debut] orderedList = [debut]
while len(orderedList) < len(edges): while len(orderedList) < len(edges):
bout = orderedList[-1] bout = orderedList[-1]
vertex = idverts[(bout,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 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: if k[1] == 0:
orderedList.append(k[0]) orderedList.append(k[0])
break 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") 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))) 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))) accessList = list(range(len(orderedList)))
for i,k in enumerate(orderedList): for i_aux,k_aux in enumerate(orderedList):
accessList[k] = i accessList[k_aux] = i_aux
logging.info("position ordonnée des edges selon le sens de parcours : {}".format(accessList)) texte = "position ordonnée des edges selon le sens de parcours : {}".format(accessList)
logging.info(texte)
return edges, accessList return edges, accessList

View File

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

View File

@ -17,16 +17,19 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # 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 logging
import math
import traceback
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
from .findWireEndVertices import findWireEndVertices from .findWireEndVertices import findWireEndVertices
from .prolongeWire import prolongeWire from .prolongeWire import prolongeWire
import traceback
from .fissError import fissError from .fissError import fissError
def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe): def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
@ -46,7 +49,7 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
#fondFissCoupe = geompy.GetInPlaceByHistory(shapeDefaut, fondFiss) #= inutile #fondFissCoupe = geompy.GetInPlaceByHistory(shapeDefaut, fondFiss) #= inutile
geomPublish(initLog.debug, shapeDefaut, 'shapeDefaut_coupe') geomPublish(initLog.debug, shapeDefaut, 'shapeDefaut_coupe')
#geomPublishInFather(initLog.debug,shapeDefaut, fondFissCoupe, 'fondFiss_coupe') #geomPublishInFather(initLog.debug,shapeDefaut, fondFissCoupe, 'fondFiss_coupe')
extrem, norms = findWireEndVertices(fondFiss, True) extrem, norms = findWireEndVertices(fondFiss, True)
logging.debug("extrem: %s, norm: %s",extrem, norms) logging.debug("extrem: %s, norm: %s",extrem, norms)
cercle = geompy.MakeCircle(extrem[0], norms[0], rayonPipe) cercle = geompy.MakeCircle(extrem[0], norms[0], rayonPipe)
@ -66,10 +69,10 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
geomPublish(initLog.debug, fissPipe, 'fissPipe') geomPublish(initLog.debug, fissPipe, 'fissPipe')
partPipe = geompy.GetInPlaceByHistory(partFissPipe, pipeFiss) partPipe = geompy.GetInPlaceByHistory(partFissPipe, pipeFiss)
geomPublish(initLog.debug, partPipe, 'partPipe') geomPublish(initLog.debug, partPipe, 'partPipe')
edgesPipeFiss = geompy.GetSharedShapesMulti([fissPipe, partPipe], geompy.ShapeType["EDGE"]) edgesPipeFiss = geompy.GetSharedShapesMulti([fissPipe, partPipe], geompy.ShapeType["EDGE"])
for i, edge in enumerate(edgesPipeFiss): for i_aux, edge in enumerate(edgesPipeFiss):
name = "edgePipe%d"%i name = "edgePipe{}".format(i_aux)
geomPublishInFather(initLog.debug,fissPipe, edge, name) geomPublishInFather(initLog.debug,fissPipe, edge, name)
try: try:
wirePipeFiss = geompy.MakeWire(edgesPipeFiss) wirePipeFiss = geompy.MakeWire(edgesPipeFiss)
@ -77,13 +80,13 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
wirePipeFiss = geompy.MakeCompound(edgesPipeFiss) wirePipeFiss = geompy.MakeCompound(edgesPipeFiss)
logging.debug("wirePipeFiss construit sous forme de compound") logging.debug("wirePipeFiss construit sous forme de compound")
geomPublish(initLog.debug, wirePipeFiss, "wirePipeFiss") geomPublish(initLog.debug, wirePipeFiss, "wirePipeFiss")
wireFondFiss = geompy.GetInPlace(partFissPipe,fondFiss) wireFondFiss = geompy.GetInPlace(partFissPipe,fondFiss)
edgesFondFiss = geompy.GetSharedShapesMulti([fissPipe, wireFondFiss], geompy.ShapeType["EDGE"]) edgesFondFiss = geompy.GetSharedShapesMulti([fissPipe, wireFondFiss], geompy.ShapeType["EDGE"])
for i, edge in enumerate(edgesFondFiss): for i_aux, edge in enumerate(edgesFondFiss):
name = "edgeFondFiss%d"%i name = "edgeFondFiss{}".format(i_aux)
geomPublishInFather(initLog.debug,fissPipe, edge, name) geomPublishInFather(initLog.debug,fissPipe, edge, name)
wireFondFiss = geompy.MakeWire(edgesFondFiss) 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Peau interne du defaut dans le maillage sain"""
import logging import logging
from .geomsmesh import smesh
import SMESH
import traceback import traceback
from .fissError import fissError
import SMESH
from .geomsmesh import smesh
from .fissError import fissError
from .listOfExtraFunctions import lookForCorner from .listOfExtraFunctions import lookForCorner
from .fusionMaillageAttributionDefaut import fusionMaillageDefaut from .fusionMaillageAttributionDefaut import fusionMaillageDefaut
# -----------------------------------------------------------------------------
# --- peau interne du defaut dans le maillage sain
def peauInterne(fichierMaillage, shapeDefaut, nomZones): def peauInterne(fichierMaillage, shapeDefaut, nomZones):
"""Retrouve les groupes de défaut dans le maillage sain modifié par CreateHoleSkin (CreeZoneDefautMaillage) """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 ? Remarque : intérêt du passage par fichierMaillage plutôt que par maillageSain ?
""" """
logging.info("start") logging.info("start")
([maillageSain], status) = smesh.CreateMeshesFromMED(fichierMaillage) ([maillageSain], _) = smesh.CreateMeshesFromMED(fichierMaillage)
groups = maillageSain.GetGroups() groups = maillageSain.GetGroups()
#print ("groupes :") #print ("groupes :")
@ -78,7 +78,7 @@ def peauInterne(fichierMaillage, shapeDefaut, nomZones):
for entity_type in info: for entity_type in info:
#print (". {} : {})".format(entity_type, info[entity_type])) #print (". {} : {})".format(entity_type, info[entity_type]))
nbelem += 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]
nbhexa += info[entity_type] nbhexa += info[entity_type]
#print ("==> nbelem = {}, nbhexa = {}".format(nbelem,nbhexa)) #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>" 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) 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' ) internal = maillageSain.GetMesh().CutListOfGroups( [ DefautBoundary ], [ zoneDefaut_skin ], 'internal' )
internalBoundary = smesh.CopyMesh( internal, 'internalBoundary', 0, 0) internalBoundary = smesh.CopyMesh( internal, 'internalBoundary', 0, 0)
maillageDefautCible = smesh.CopyMesh(zoneDefaut_skin, 'maillageCible', 0, 0) maillageDefautCible = smesh.CopyMesh(zoneDefaut_skin, 'maillageCible', 0, 0)
listOfCorner = lookForCorner(maillageDefautCible) listOfCorner = lookForCorner(maillageDefautCible)
logging.debug("listOfCorner = {}".format(listOfCorner)) texte = "listOfCorner = {}".format(listOfCorner)
logging.debug(texte)
if listOfCorner: if listOfCorner:
logging.info("présence de coins à la surface externe de la zone à reconstruire") logging.info("présence de coins à la surface externe de la zone à reconstruire")
zoneDefaut_skin, internalBoundary = fusionMaillageDefaut(maillageSain, maillageDefautCible, internalBoundary, zoneDefaut_skin, shapeDefaut, listOfCorner) zoneDefaut_skin, internalBoundary = fusionMaillageDefaut(maillageSain, maillageDefautCible, internalBoundary, zoneDefaut_skin, shapeDefaut, listOfCorner)
return maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Calcul de produit mixte pour orientation"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
# ----------------------------------------------------------------------------- def produitMixte(origine, point_1, point_2, point_3):
# --- calcul de produit mixte pour orientation """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): 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]]
produit mixte de 3 vecteurs a partir d'une origine et 3 points o_3 = [coord_3[0] - coordo[0], coord_3[1] - coordo[1], coord_3[2] - coordo[2]]
"""
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
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 # 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 from .geomsmesh import geompy
import logging
import math
# ----------------------------------------------------------------------------- def projettePointSurCourbe(point, edge):
# --- projection d'un point sur une courbe.
def projettePointSurCourbe(pt, edge):
""" """
projection d'un point p sur une courbe c 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 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") #logging.debug("start")
dist = [] dist = list()
nbSlices = 50 nb_slices = 50
du = 1.0/nbSlices delta = 1.0/float(nb_slices)
for i in range(nbSlices + 1): for i_aux in range(nb_slices + 1):
p = geompy.MakeVertexOnCurve(edge, du*i) pti = geompy.MakeVertexOnCurve(edge, delta*float(i_aux))
d = geompy.MinDistance(p,pt) dpti = geompy.MinDistance(pti,point)
dist.append((d,i)) dist.append((dpti,i_aux))
dist.sort() dist.sort()
#logging.debug("dist %s", dist) #logging.debug("dist %s", dist)
umin = du*dist[0][1] umin = delta*dist[0][1]
umax = du*dist[1][1] umax = delta*dist[1][1]
#umin = 0.0 #umin = 0.0
#umax = 1.0 #umax = 1.0
tol = 1.e-8 tol = 1.e-8
pmin = geompy.MakeVertexOnCurve(edge, umin) pmin = geompy.MakeVertexOnCurve(edge, umin)
pmax = geompy.MakeVertexOnCurve(edge, umax) pmax = geompy.MakeVertexOnCurve(edge, umax)
dmin = geompy.MinDistance(pmin,pt) dmin = geompy.MinDistance(pmin,point)
dmax = geompy.MinDistance(pmax,pt) dmax = geompy.MinDistance(pmax,point)
dext = geompy.MinDistance(pmin,pmax) dext = geompy.MinDistance(pmin,pmax)
i=0 i_aux = 0
while dext > tol and i < 100 : while ( ( dext > tol ) and ( i_aux < 100 ) ):
i = i+1 i_aux += 1
utest = (umax + umin) / 2.0 utest = (umax + umin) / 2.0
ptest = geompy.MakeVertexOnCurve(edge, utest) ptest = geompy.MakeVertexOnCurve(edge, utest)
dtest = geompy.MinDistance(ptest,pt) dtest = geompy.MinDistance(ptest,point)
if dmin < dmax: if dmin < dmax:
umax = utest umax = utest
pmax = ptest pmax = ptest
@ -68,10 +67,11 @@ def projettePointSurCourbe(pt, edge):
dmin = dtest dmin = dtest
dext = geompy.MinDistance(pmin,pmax) 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) #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 utest = 0.0
if abs(1.0-utest) < 1.e-7: elif ( abs(1.0-utest) < 1.e-7 ):
utest = 1.0 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 return utest

View File

@ -17,30 +17,29 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # 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 import logging
from .geomsmesh import geompy
# ----------------------------------------------------------------------------- from .geomsmesh import geompy
# --- prolongation des segments extremité des polylines, pour la découpe
def prolongeVertices(vertices): def prolongeVertices(vertices):
""" """
Prolongation des segments extremité d'une polyline définie par un vecteur de points. 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é 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 extremes sont doublés. (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 @param vertices : liste ordonnée des points (geomObject) de la polyline
@return vertices : liste avec les deux extremités modifiées @return vertices : liste avec les deux extremités modifiées
""" """
logging.info("start") logging.info("start")
if len(vertices) < 2: if len(vertices) < 2:
return vertices return vertices
v0 = vertices[0]
v1 = vertices[1] m_0 = geompy.MakeMirrorByPoint(vertices[1], vertices[0])
m0 = geompy.MakeMirrorByPoint(v1, v0)
ve = vertices[-1] m_1 = geompy.MakeMirrorByPoint(vertices[-2], vertices[-1])
vd = vertices[-2]
m1 = geompy.MakeMirrorByPoint(vd, ve) vertices[0] = m_0
vertices[0] = m0 vertices[-1] = m_1
vertices[-1] = m1
return vertices return vertices

View File

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

View File

@ -17,44 +17,45 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Recherche et classement des edges du tore par propagate"""
import logging import logging
from .geomsmesh import geompy from .geomsmesh import geompy
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather from .geomsmesh import geomPublishInFather
from . import initLog from . import initLog
# -----------------------------------------------------------------------------
# --- recherche et classement des edges du tore par propagate
def propagateTore(tore): 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é @param tore partionné et coupé
@return (diams, circles, geners) edges dans le plan de fissure, edges demi circulaires, @return (diams, circles, geners) edges dans le plan de fissure, edges demi circulaires,
edges selon la generatrice (liste de compounds) edges selon la generatrice (liste de compounds)
""" """
logging.info("start") logging.info("start")
lencomp = [] lencomp = list()
compounds = geompy.Propagate(tore) compounds = geompy.Propagate(tore)
for i in range(len(compounds)): for objet in compounds:
#geomPublishInFather(initLog.debug, tore, compounds[i], 'edges' ) #geomPublishInFather(initLog.debug, tore, objet, 'edges' )
props = geompy.BasicProperties(compounds[i]) props = geompy.BasicProperties(objet)
lencomp.append(props[0]) 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) minlen = min(lencomp)
maxlen = max(lencomp) maxlen = max(lencomp)
diams = []
geners = [] diams = list()
circles = [] geners = list()
for i in range(len(lencomp)): circles = list()
if (lencomp[i]- minlen)/minlen < 0.01 : for i_aux, longueur in enumerate(lencomp):
diams.append(compounds[i]) if ( (longueur- minlen)/minlen < 0.01 ):
elif (maxlen - lencomp[i])/lencomp[i] < 0.2 : diams.append(compounds[i_aux])
geners.append(compounds[i]) elif ( (maxlen - longueur)/longueur < 0.2 ):
geners.append(compounds[i_aux])
else: else:
circles.append(compounds[i]) circles.append(compounds[i_aux])
geomPublishInFather(initLog.debug, tore, diams[0], 'diams0' ) geomPublishInFather(initLog.debug, tore, diams[0], 'diams0' )
geomPublishInFather(initLog.debug, tore, diams[1], 'diams1' ) 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 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
"""Nommage des objets mesh (algorithme, hypothèse, subMesh)"""
from .geomsmesh import smesh from .geomsmesh import smesh
# ----------------------------------------------------------------------------- def putName (objmesh, name, i_suff=-1, i_pref=-1):
# --- nommage des objets mesh (algorithme, hypothèse, subMesh) """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) smesh.SetName(objmesh, name)

View File

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

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