smesh/src/Tools/blocFissure/gmu/insereFissureLongue_a.py

175 lines
8.3 KiB
Python
Raw Normal View History

2021-01-27 11:50:20 +01:00
# -*- coding: utf-8 -*-
2021-04-02 13:17:18 +02:00
# Copyright (C) 2014-2021 EDF R&D
2021-01-27 11:50:20 +01: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-04-02 13:17:18 +02:00
"""procédure complète de construction d'une fissure longue"""
2021-01-27 11:50:20 +01:00
import logging
2021-04-02 13:17:18 +02:00
2021-01-27 11:50:20 +01:00
import salome
2021-04-02 13:17:18 +02:00
2021-01-27 11:50:20 +01:00
from .geomsmesh import geompy
2021-04-02 13:17:18 +02:00
from .geomsmesh import geomPublish
from .geomsmesh import geomPublishInFather
2021-01-27 11:50:20 +01:00
2021-04-02 13:17:18 +02:00
from . import initLog
from .extractionOrientee import extractionOrientee
from .sortFaces import sortFaces
2021-01-27 11:50:20 +01:00
from .sortEdges import sortEdges
2021-04-02 13:17:18 +02:00
from .eliminateDoubles import eliminateDoubles
from .substractSubShapes import substractSubShapes
2021-01-27 11:50:20 +01:00
2021-04-02 13:17:18 +02:00
# -----------------------------------------------------------------------------
2021-01-27 11:50:20 +01:00
2021-04-02 13:17:18 +02:00
def insereFissureLongue_a(facePorteFissure, WirePorteFondFissure, \
fillingFaceExterne, \
pipefiss, rayonPipe, \
2021-04-06 17:59:21 +02:00
mailleur="MeshGems", nro_cas=None):
2021-04-02 13:17:18 +02:00
"""procedure complete fissure longue"""
2021-01-27 11:50:20 +01:00
logging.info('start')
2021-04-02 13:17:18 +02:00
logging.info("Usage du mailleur %s", mailleur)
# -----------------------------------------------------------------------------
# --- peau et face de fissure
# --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée
partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, partitionPeauFissFond, 'partitionPeauFissFond', nro_cas )
2021-04-02 13:17:18 +02:00
edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False)
lgmax = 0
imax = 0
for i_aux, edge in enumerate(edges):
props = geompy.BasicProperties(edge)
longueur = props[0]
if ( longueur > lgmax ):
lgmax = longueur
imax = i_aux
edgemax = edges[imax]
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, edgemax, 'edgemax', nro_cas)
2021-04-02 13:17:18 +02:00
centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, centreFondFiss, 'centreFondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, tangentFondFiss, 'tangentFondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, bord1FondFiss, 'bord1FondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, tangentBord1FondFiss, 'tangentBord1FondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, bord2FondFiss, 'bord2FondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, tangentBord2FondFiss, 'tangentBord2FondFiss', nro_cas)
2021-04-02 13:17:18 +02:00
planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe)
planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, planBord1, 'planBord1', nro_cas)
geomPublish(initLog.debug, planBord2, 'planBord2', nro_cas)
2021-04-02 13:17:18 +02:00
[edgesInside, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
[facesInside, _, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
# --- partition peau -face fissure - pipe fond de fissure prolongé
partitionPeauFissByPipe = geompy.MakePartition([facesInside[0], facesOnside[0]], [pipefiss], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
2021-04-06 17:59:21 +02:00
geomPublish(initLog.debug, partitionPeauFissByPipe, 'partitionPeauFissByPipe', nro_cas )
2021-04-02 13:17:18 +02:00
# --- 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
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, facePeau, "facePeau", nro_cas)
2021-04-02 13:17:18 +02:00
# --- identification edges de bord face peau
edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
edgesBords = list()
2021-04-06 17:59:21 +02:00
for edge in edgesFilling:
2021-04-02 13:17:18 +02:00
edgepeau = geompy.GetInPlace(facePeau, edge)
edgesBords.append(edgepeau)
groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesBords)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,facePeau, groupEdgesBordPeau , "EdgesBords", nro_cas)
2021-04-02 13:17:18 +02:00
# --- 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]
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,partitionPeauFissByPipe, faceFiss, "faceFiss", nro_cas)
geomPublishInFather(initLog.debug,faceFiss, edgePeauFiss, "edgePeauFiss", nro_cas)
geomPublishInFather(initLog.debug,facePeau, edgePeauFiss, "edgePeauFiss", nro_cas)
2021-04-02 13:17:18 +02:00
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_aux, edge in enumerate(demiCerclesPeau):
name = "demiCerclePeau_{}".format(i_aux)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,facePeau, edge, name, nro_cas)
2021-04-02 13:17:18 +02:00
verticesDemiCerclesPeau += geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
verticesDemiCerclesPeau = eliminateDoubles(facePeau, verticesDemiCerclesPeau)
for i_aux, vertex in enumerate(verticesDemiCerclesPeau):
name = "verticesDemiCerclesPeau_{}".format(i_aux)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,facePeau, vertex, name, nro_cas)
2021-04-02 13:17:18 +02:00
verticesOutCercles = substractSubShapes(facePeau, verticesDemiCerclesPeau, verticesEdgePeauFiss)
for i_aux, vertex in enumerate(verticesOutCercles):
name = "verticesOutCercles_{}".format(i_aux)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,facePeau, vertex, name, nro_cas)
2021-04-02 13:17:18 +02:00
# --- demi cercles regroupés
groupsDemiCerclesPeau = list()
for i_aux, vertex in enumerate(verticesEdgePeauFiss):
2021-04-02 13:17:18 +02:00
demis = list()
for edge in demiCerclesPeau:
if ( geompy.MinDistance(vertex, edge) < 1.e-5 ):
2021-04-02 13:17:18 +02:00
demis.append(edge)
group = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
geompy.UnionList(group, demis)
name = "Cercle{}".format(i_aux)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,facePeau, group , name, nro_cas)
2021-04-02 13:17:18 +02:00
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)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,faceFiss, edge, name, nro_cas)
2021-04-02 13:17:18 +02:00
groupEdgesFaceFissPipe = geompy.CreateGroup(faceFiss, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesFaceFissPipe, edgesFaceFissPipe)
2021-04-06 17:59:21 +02:00
geomPublishInFather(initLog.debug,faceFiss, groupEdgesFaceFissPipe, "edgesFaceFissPipe", nro_cas)
2021-04-02 13:17:18 +02:00
return edgesInside, centreFondFiss, tangentFondFiss, \
planBord1, planBord2, \
facePeau, faceFiss, verticesOutCercles, verticesEdgePeauFiss, \
edgePeauFiss, demiCerclesPeau, \
groupEdgesBordPeau, groupsDemiCerclesPeau, groupEdgesFaceFissPipe