2014-09-14 21:38:46 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-03-23 17:44:27 +03:00
|
|
|
# Copyright (C) 2014-2021 EDF R&D
|
2019-02-14 14:55:47 +03:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2021-01-26 16:00:53 +01:00
|
|
|
"""Construit les arêtes débouchantes"""
|
2014-09-14 21:38:46 +02:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2017-03-20 13:27:30 +01:00
|
|
|
from .geomsmesh import geompy
|
|
|
|
from .geomsmesh import geomPublish
|
2021-01-26 16:00:53 +01:00
|
|
|
#from .geomsmesh import geomPublishInFather
|
2017-03-20 13:27:30 +01:00
|
|
|
from . import initLog
|
2014-09-21 21:49:53 +02:00
|
|
|
import GEOM
|
2017-03-20 13:27:30 +01:00
|
|
|
from .sortEdges import sortEdges
|
2014-09-14 21:38:46 +02:00
|
|
|
|
|
|
|
def construitEdgesRadialesDebouchantes(idisklim, idiskout, gptsdisks, raydisks,
|
|
|
|
facesPipePeau, edgeRadFacePipePeau, nbsegCercle):
|
2021-01-26 16:00:53 +01:00
|
|
|
"""construction des listes d'edges radiales sur chaque extrémité débouchante"""
|
2014-09-14 21:38:46 +02:00
|
|
|
logging.info('start')
|
2016-12-05 17:54:39 +01:00
|
|
|
|
2014-09-14 21:38:46 +02:00
|
|
|
# --- listes de nappes radiales en filling à chaque extrémité débouchante
|
2016-12-05 17:54:39 +01:00
|
|
|
|
2014-09-14 21:38:46 +02:00
|
|
|
facesDebouchantes = [False, False]
|
|
|
|
idFacesDebouchantes = [-1, -1] # contiendra les indices des faces disque débouchantes (facesPipePeau)
|
|
|
|
listNappes =[]
|
|
|
|
for i, idisk in enumerate(idisklim):
|
|
|
|
numout = idiskout[i]
|
|
|
|
logging.debug("extremité %s, indices disques interne %s, externe %s",i, idisk, numout)
|
|
|
|
nappes = []
|
|
|
|
if (idisk != 0) and (idisk != len(gptsdisks)-1): # si extrémité débouchante
|
|
|
|
for k in range(nbsegCercle):
|
|
|
|
if i == 0:
|
|
|
|
iddeb = max(0, numout)
|
|
|
|
idfin = max(iddeb+3,idisk+1) # il faut 3 rayons pour faire un filling qui suive le fond de fissure
|
|
|
|
#logging.debug("extremité %s, indices retenus interne %s, externe %s",i, idfin, iddeb)
|
|
|
|
comp = geompy.MakeCompound(raydisks[k][iddeb:idfin])
|
|
|
|
name='compoundRay%d'%k
|
2014-12-11 15:45:06 +01:00
|
|
|
geomPublish(initLog.debug, comp, name)
|
2014-09-14 21:38:46 +02:00
|
|
|
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
|
2014-12-11 15:45:06 +01:00
|
|
|
geomPublish(initLog.debug, comp, name)
|
2014-09-14 21:38:46 +02:00
|
|
|
nappe = geompy.MakeFilling(comp, 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default)
|
|
|
|
nappes.append(nappe)
|
|
|
|
name='nappe%d'%k
|
2014-12-11 15:45:06 +01:00
|
|
|
geomPublish(initLog.debug, nappe, name)
|
2014-09-14 21:38:46 +02:00
|
|
|
facesDebouchantes[i] = True
|
|
|
|
listNappes.append(nappes)
|
2016-12-05 17:54:39 +01:00
|
|
|
|
2014-09-14 21:38:46 +02:00
|
|
|
# --- mise en correspondance avec les indices des faces disque débouchantes (facesPipePeau)
|
|
|
|
for i, nappes in enumerate(listNappes):
|
|
|
|
if facesDebouchantes[i]:
|
|
|
|
for k, face in enumerate(facesPipePeau):
|
2014-09-21 21:49:53 +02:00
|
|
|
#logging.debug('i, k, face, nappes[0] %s %s %s %s', i, k, face, nappes[0])
|
2014-12-11 15:45:06 +01:00
|
|
|
#geomPublish(initLog.debug, nappes[0], 'lanappe')
|
|
|
|
#geomPublish(initLog.debug, face, 'laface')
|
2014-09-14 21:38:46 +02:00
|
|
|
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
|
|
|
|
listEdges = []
|
|
|
|
for i, nappes in enumerate(listNappes):
|
|
|
|
ifd = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau)
|
|
|
|
if ifd < 0:
|
|
|
|
listEdges.append([])
|
|
|
|
else:
|
|
|
|
face = facesPipePeau[ifd]
|
|
|
|
edges = [edgeRadFacePipePeau[ifd]]
|
|
|
|
for k, nappe in enumerate(nappes):
|
|
|
|
if k > 0:
|
|
|
|
obj = geompy.MakeSection(face, nappes[k]) # normalement une edge, parfois un compound d'edges dont un tout petit
|
|
|
|
edge = obj
|
|
|
|
vs = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
|
|
|
|
if len(vs) > 2:
|
|
|
|
eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
|
2021-01-26 16:00:53 +01:00
|
|
|
[edsorted, _, maxl] = sortEdges(eds)
|
2014-09-14 21:38:46 +02:00
|
|
|
edge = edsorted[-1]
|
|
|
|
else:
|
|
|
|
maxl = geompy.BasicProperties(edge)[0]
|
|
|
|
if maxl < 0.01: # problème MakeSection
|
2016-12-05 17:54:39 +01:00
|
|
|
logging.info("problème MakeSection recherche edge radiale %s, longueur trop faible: %s, utilisation partition", k, maxl)
|
2014-09-14 21:38:46 +02:00
|
|
|
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):
|
2016-12-05 17:54:39 +01:00
|
|
|
dmax=100.
|
2014-09-14 21:38:46 +02:00
|
|
|
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)
|
2016-12-05 17:54:39 +01:00
|
|
|
lgedge = geompy.BasicProperties(ed)[0]
|
|
|
|
logging.debug(" dmax %s, longueur edge %s",dmax, lgedge)
|
|
|
|
if dmax < 0.01 and lgedge > 0.01:
|
2014-09-14 21:38:46 +02:00
|
|
|
ednouv.append(ed)
|
2016-12-05 17:54:39 +01:00
|
|
|
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)
|
2021-01-26 16:00:53 +01:00
|
|
|
[edsorted, _, maxl] = sortEdges(ednouv)
|
2016-12-05 17:54:39 +01:00
|
|
|
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))]
|
2021-01-26 16:00:53 +01:00
|
|
|
[edsorted2, _, maxl] = sortEdges(eds)
|
2016-12-05 17:54:39 +01:00
|
|
|
edge = edsorted2[-1]
|
|
|
|
logging.debug("lg edge: %s", maxl)
|
|
|
|
else:
|
|
|
|
logging.debug("problème recherche edge radiale %s non résolu", k)
|
2014-09-14 21:38:46 +02:00
|
|
|
edges.append(edge)
|
|
|
|
name = 'edgeEndPipe%d'%k
|
2014-12-11 15:45:06 +01:00
|
|
|
geomPublish(initLog.debug, edge, name)
|
2014-09-14 21:38:46 +02:00
|
|
|
listEdges.append(edges)
|
2016-12-05 17:54:39 +01:00
|
|
|
|
2021-01-26 16:00:53 +01:00
|
|
|
return (listEdges, idFacesDebouchantes)
|