From e9e7af000e6d84b90aaa62d06f8c28ab093b0745 Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 8 Jan 2014 14:29:32 +0000 Subject: [PATCH] PR: add blocFissure plugin --- src/Tools/CMakeLists.txt | 1 + src/Tools/blocFissure/CMakeLists.txt | 40 + src/Tools/blocFissure/CasTests/CMakeLists.txt | 55 + src/Tools/blocFissure/CasTests/__init__.py | 0 src/Tools/blocFissure/CasTests/cubeAngle.py | 103 ++ src/Tools/blocFissure/CasTests/cubeAngle2.py | 42 + src/Tools/blocFissure/CasTests/cylindre.py | 107 ++ src/Tools/blocFissure/CasTests/cylindre_2.py | 56 + src/Tools/blocFissure/CasTests/disquePerce.py | 28 + src/Tools/blocFissure/CasTests/ellipse_1.py | 111 ++ src/Tools/blocFissure/CasTests/ellipse_2.py | 59 + .../blocFissure/CasTests/eprouvetteCourbe.py | 105 ++ .../blocFissure/CasTests/eprouvetteDroite.py | 107 ++ .../CasTests/eprouvetteDroite_2.py | 60 + .../blocFissure/CasTests/execution_Cas.py | 127 ++ src/Tools/blocFissure/CasTests/faceGauche.py | 105 ++ .../blocFissure/CasTests/faceGauche_2.py | 106 ++ .../blocFissure/CasTests/fissureCoude_1.py | 92 ++ .../blocFissure/CasTests/fissureCoude_10.py | 92 ++ .../blocFissure/CasTests/fissureCoude_2.py | 92 ++ .../blocFissure/CasTests/fissureCoude_3.py | 92 ++ .../blocFissure/CasTests/fissureCoude_4.py | 92 ++ .../blocFissure/CasTests/fissureCoude_5.py | 92 ++ .../blocFissure/CasTests/fissureCoude_6.py | 91 ++ .../blocFissure/CasTests/fissureCoude_7.py | 91 ++ .../blocFissure/CasTests/fissureCoude_8.py | 92 ++ .../blocFissure/CasTests/fissureCoude_9.py | 90 ++ .../blocFissure/CasTests/fissure_Coude.py | 496 ++++++ .../blocFissure/CasTests/fissure_Coude_4.py | 73 + src/Tools/blocFissure/CasTests/vis_1.py | 105 ++ src/Tools/blocFissure/__init__.py | 0 src/Tools/blocFissure/casStandard.py | 145 ++ src/Tools/blocFissure/exemple.py | 23 + src/Tools/blocFissure/exemple2.py | 93 ++ src/Tools/blocFissure/gmu/CMakeLists.txt | 88 ++ src/Tools/blocFissure/gmu/__init__.py | 18 + src/Tools/blocFissure/gmu/blocDefaut.py | 20 + .../blocFissure/gmu/checkDecoupePartition.py | 41 + src/Tools/blocFissure/gmu/commonSubShapes.py | 23 + .../gmu/creeZoneDefautDansObjetSain.py | 94 ++ .../blocFissure/gmu/creeZoneDefautFilling.py | 35 + .../blocFissure/gmu/creeZoneDefautGeom.py | 207 +++ .../blocFissure/gmu/creeZoneDefautMaillage.py | 64 + src/Tools/blocFissure/gmu/distance2.py | 36 + src/Tools/blocFissure/gmu/eliminateDoubles.py | 24 + src/Tools/blocFissure/gmu/ellipsoideDefaut.py | 32 + src/Tools/blocFissure/gmu/enleveDefaut.py | 24 + .../blocFissure/gmu/extractionOrientee.py | 51 + .../gmu/extractionOrienteeMulti.py | 49 + src/Tools/blocFissure/gmu/facesCirculaires.py | 78 + src/Tools/blocFissure/gmu/facesFissure.py | 51 + src/Tools/blocFissure/gmu/facesToreInBloc.py | 29 + .../blocFissure/gmu/facesVolumesToriques.py | 53 + .../blocFissure/gmu/findWireEndVertices.py | 62 + .../gmu/findWireIntermediateVertices.py | 58 + src/Tools/blocFissure/gmu/fissureCoude.py | 669 ++++++++ src/Tools/blocFissure/gmu/fissureGenerique.py | 98 ++ .../gmu/genereElemsFissureElliptique.py | 54 + .../gmu/genereMeshCalculZoneDefaut.py | 36 + src/Tools/blocFissure/gmu/geomsmesh.py | 15 + .../blocFissure/gmu/getCentreFondFiss.py | 77 + .../gmu/getStatsMaillageFissure.py | 58 + src/Tools/blocFissure/gmu/getSubshapeIds.py | 18 + src/Tools/blocFissure/gmu/initEtude.py | 10 + src/Tools/blocFissure/gmu/initLog.py | 28 + .../gmu/insereFissureElliptique.py | 196 +++ .../blocFissure/gmu/insereFissureGenerale.py | 1371 +++++++++++++++++ .../blocFissure/gmu/insereFissureLongue.py | 656 ++++++++ src/Tools/blocFissure/gmu/meshBlocPart.py | 218 +++ .../blocFissure/gmu/orderEdgesFromWire.py | 72 + .../blocFissure/gmu/partitionBlocDefaut.py | 160 ++ .../blocFissure/gmu/partitionVolumeSain.py | 33 + src/Tools/blocFissure/gmu/peauInterne.py | 46 + src/Tools/blocFissure/gmu/produitMixte.py | 23 + .../blocFissure/gmu/projettePointSurCourbe.py | 59 + src/Tools/blocFissure/gmu/prolongeVertices.py | 28 + src/Tools/blocFissure/gmu/prolongeWire.py | 29 + src/Tools/blocFissure/gmu/propagateTore.py | 44 + src/Tools/blocFissure/gmu/putName.py | 13 + .../blocFissure/gmu/quadranglesToShape.py | 323 ++++ .../blocFissure/gmu/regroupeSainEtDefaut.py | 85 + src/Tools/blocFissure/gmu/rotTrans.py | 57 + src/Tools/blocFissure/gmu/shapeSurFissure.py | 35 + src/Tools/blocFissure/gmu/shapesSurFissure.py | 40 + src/Tools/blocFissure/gmu/sortEdges.py | 19 + src/Tools/blocFissure/gmu/sortFaces.py | 19 + src/Tools/blocFissure/gmu/sortGeneratrices.py | 43 + src/Tools/blocFissure/gmu/sortSolids.py | 19 + .../blocFissure/gmu/substractSubShapes.py | 23 + src/Tools/blocFissure/gmu/testgmu.py | 22 + src/Tools/blocFissure/gmu/toreFissure.py | 69 + src/Tools/blocFissure/gmu/triedreBase.py | 32 + src/Tools/blocFissure/gmu/whichSide.py | 60 + src/Tools/blocFissure/gmu/whichSideMulti.py | 71 + src/Tools/blocFissure/gmu/whichSideVertex.py | 30 + src/Tools/blocFissure/ihm/CMakeLists.txt | 46 + src/Tools/blocFissure/ihm/__init__.py | 0 src/Tools/blocFissure/ihm/fissureCoude.ui | 1071 +++++++++++++ src/Tools/blocFissure/ihm/fissureCoude_ihm.py | 96 ++ .../blocFissure/ihm/fissureCoude_plugin.py | 393 +++++ src/Tools/blocFissure/ihm/fissureGenerale.ui | 448 ++++++ .../materielCasTests/CMakeLists.txt | 41 + .../blocFissure/materielCasTests/__init__.py | 0 .../blocFissure/materielCasTests/cubeAngle.py | 78 + .../materielCasTests/decoupeCylindre.py | 167 ++ .../materielCasTests/disque_perce.py | 89 ++ .../blocFissure/materielCasTests/ellipse.py | 61 + .../materielCasTests/ellipse_disque.py | 53 + .../materielCasTests/ellipse_probleme.py | 59 + .../materielCasTests/eprouvetteCourbe.py | 107 ++ .../materielCasTests/eprouvetteDroite.py | 142 ++ .../materielCasTests/fissureGauche.py | 136 ++ .../materielCasTests/fissureGauche2.py | 98 ++ .../materielCasTests/genereMateriel.py | 13 + src/Tools/blocFissure/materielCasTests/vis.py | 273 ++++ src/Tools/smesh_plugins.py | 4 + 116 files changed, 12533 insertions(+) create mode 100644 src/Tools/blocFissure/CMakeLists.txt create mode 100644 src/Tools/blocFissure/CasTests/CMakeLists.txt create mode 100644 src/Tools/blocFissure/CasTests/__init__.py create mode 100644 src/Tools/blocFissure/CasTests/cubeAngle.py create mode 100644 src/Tools/blocFissure/CasTests/cubeAngle2.py create mode 100644 src/Tools/blocFissure/CasTests/cylindre.py create mode 100644 src/Tools/blocFissure/CasTests/cylindre_2.py create mode 100644 src/Tools/blocFissure/CasTests/disquePerce.py create mode 100644 src/Tools/blocFissure/CasTests/ellipse_1.py create mode 100644 src/Tools/blocFissure/CasTests/ellipse_2.py create mode 100644 src/Tools/blocFissure/CasTests/eprouvetteCourbe.py create mode 100644 src/Tools/blocFissure/CasTests/eprouvetteDroite.py create mode 100644 src/Tools/blocFissure/CasTests/eprouvetteDroite_2.py create mode 100644 src/Tools/blocFissure/CasTests/execution_Cas.py create mode 100644 src/Tools/blocFissure/CasTests/faceGauche.py create mode 100644 src/Tools/blocFissure/CasTests/faceGauche_2.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_1.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_10.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_2.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_3.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_4.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_5.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_6.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_7.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_8.py create mode 100644 src/Tools/blocFissure/CasTests/fissureCoude_9.py create mode 100644 src/Tools/blocFissure/CasTests/fissure_Coude.py create mode 100644 src/Tools/blocFissure/CasTests/fissure_Coude_4.py create mode 100644 src/Tools/blocFissure/CasTests/vis_1.py create mode 100644 src/Tools/blocFissure/__init__.py create mode 100644 src/Tools/blocFissure/casStandard.py create mode 100644 src/Tools/blocFissure/exemple.py create mode 100644 src/Tools/blocFissure/exemple2.py create mode 100644 src/Tools/blocFissure/gmu/CMakeLists.txt create mode 100644 src/Tools/blocFissure/gmu/__init__.py create mode 100644 src/Tools/blocFissure/gmu/blocDefaut.py create mode 100644 src/Tools/blocFissure/gmu/checkDecoupePartition.py create mode 100644 src/Tools/blocFissure/gmu/commonSubShapes.py create mode 100644 src/Tools/blocFissure/gmu/creeZoneDefautDansObjetSain.py create mode 100644 src/Tools/blocFissure/gmu/creeZoneDefautFilling.py create mode 100644 src/Tools/blocFissure/gmu/creeZoneDefautGeom.py create mode 100644 src/Tools/blocFissure/gmu/creeZoneDefautMaillage.py create mode 100644 src/Tools/blocFissure/gmu/distance2.py create mode 100644 src/Tools/blocFissure/gmu/eliminateDoubles.py create mode 100644 src/Tools/blocFissure/gmu/ellipsoideDefaut.py create mode 100644 src/Tools/blocFissure/gmu/enleveDefaut.py create mode 100644 src/Tools/blocFissure/gmu/extractionOrientee.py create mode 100644 src/Tools/blocFissure/gmu/extractionOrienteeMulti.py create mode 100644 src/Tools/blocFissure/gmu/facesCirculaires.py create mode 100644 src/Tools/blocFissure/gmu/facesFissure.py create mode 100644 src/Tools/blocFissure/gmu/facesToreInBloc.py create mode 100644 src/Tools/blocFissure/gmu/facesVolumesToriques.py create mode 100644 src/Tools/blocFissure/gmu/findWireEndVertices.py create mode 100644 src/Tools/blocFissure/gmu/findWireIntermediateVertices.py create mode 100644 src/Tools/blocFissure/gmu/fissureCoude.py create mode 100644 src/Tools/blocFissure/gmu/fissureGenerique.py create mode 100644 src/Tools/blocFissure/gmu/genereElemsFissureElliptique.py create mode 100644 src/Tools/blocFissure/gmu/genereMeshCalculZoneDefaut.py create mode 100644 src/Tools/blocFissure/gmu/geomsmesh.py create mode 100644 src/Tools/blocFissure/gmu/getCentreFondFiss.py create mode 100644 src/Tools/blocFissure/gmu/getStatsMaillageFissure.py create mode 100644 src/Tools/blocFissure/gmu/getSubshapeIds.py create mode 100644 src/Tools/blocFissure/gmu/initEtude.py create mode 100644 src/Tools/blocFissure/gmu/initLog.py create mode 100644 src/Tools/blocFissure/gmu/insereFissureElliptique.py create mode 100644 src/Tools/blocFissure/gmu/insereFissureGenerale.py create mode 100644 src/Tools/blocFissure/gmu/insereFissureLongue.py create mode 100644 src/Tools/blocFissure/gmu/meshBlocPart.py create mode 100644 src/Tools/blocFissure/gmu/orderEdgesFromWire.py create mode 100644 src/Tools/blocFissure/gmu/partitionBlocDefaut.py create mode 100644 src/Tools/blocFissure/gmu/partitionVolumeSain.py create mode 100644 src/Tools/blocFissure/gmu/peauInterne.py create mode 100644 src/Tools/blocFissure/gmu/produitMixte.py create mode 100644 src/Tools/blocFissure/gmu/projettePointSurCourbe.py create mode 100644 src/Tools/blocFissure/gmu/prolongeVertices.py create mode 100644 src/Tools/blocFissure/gmu/prolongeWire.py create mode 100644 src/Tools/blocFissure/gmu/propagateTore.py create mode 100644 src/Tools/blocFissure/gmu/putName.py create mode 100644 src/Tools/blocFissure/gmu/quadranglesToShape.py create mode 100644 src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py create mode 100644 src/Tools/blocFissure/gmu/rotTrans.py create mode 100644 src/Tools/blocFissure/gmu/shapeSurFissure.py create mode 100644 src/Tools/blocFissure/gmu/shapesSurFissure.py create mode 100644 src/Tools/blocFissure/gmu/sortEdges.py create mode 100644 src/Tools/blocFissure/gmu/sortFaces.py create mode 100644 src/Tools/blocFissure/gmu/sortGeneratrices.py create mode 100644 src/Tools/blocFissure/gmu/sortSolids.py create mode 100644 src/Tools/blocFissure/gmu/substractSubShapes.py create mode 100644 src/Tools/blocFissure/gmu/testgmu.py create mode 100644 src/Tools/blocFissure/gmu/toreFissure.py create mode 100644 src/Tools/blocFissure/gmu/triedreBase.py create mode 100644 src/Tools/blocFissure/gmu/whichSide.py create mode 100644 src/Tools/blocFissure/gmu/whichSideMulti.py create mode 100644 src/Tools/blocFissure/gmu/whichSideVertex.py create mode 100644 src/Tools/blocFissure/ihm/CMakeLists.txt create mode 100644 src/Tools/blocFissure/ihm/__init__.py create mode 100644 src/Tools/blocFissure/ihm/fissureCoude.ui create mode 100644 src/Tools/blocFissure/ihm/fissureCoude_ihm.py create mode 100644 src/Tools/blocFissure/ihm/fissureCoude_plugin.py create mode 100644 src/Tools/blocFissure/ihm/fissureGenerale.ui create mode 100644 src/Tools/blocFissure/materielCasTests/CMakeLists.txt create mode 100644 src/Tools/blocFissure/materielCasTests/__init__.py create mode 100644 src/Tools/blocFissure/materielCasTests/cubeAngle.py create mode 100644 src/Tools/blocFissure/materielCasTests/decoupeCylindre.py create mode 100644 src/Tools/blocFissure/materielCasTests/disque_perce.py create mode 100644 src/Tools/blocFissure/materielCasTests/ellipse.py create mode 100644 src/Tools/blocFissure/materielCasTests/ellipse_disque.py create mode 100644 src/Tools/blocFissure/materielCasTests/ellipse_probleme.py create mode 100644 src/Tools/blocFissure/materielCasTests/eprouvetteCourbe.py create mode 100644 src/Tools/blocFissure/materielCasTests/eprouvetteDroite.py create mode 100644 src/Tools/blocFissure/materielCasTests/fissureGauche.py create mode 100644 src/Tools/blocFissure/materielCasTests/fissureGauche2.py create mode 100644 src/Tools/blocFissure/materielCasTests/genereMateriel.py create mode 100644 src/Tools/blocFissure/materielCasTests/vis.py diff --git a/src/Tools/CMakeLists.txt b/src/Tools/CMakeLists.txt index a2abf7d49..2736c5d72 100644 --- a/src/Tools/CMakeLists.txt +++ b/src/Tools/CMakeLists.txt @@ -20,6 +20,7 @@ ADD_SUBDIRECTORY(MeshCut) ADD_SUBDIRECTORY(padder) ADD_SUBDIRECTORY(Verima) +ADD_SUBDIRECTORY(blocFissure) IF(SALOME_BUILD_GUI) ADD_SUBDIRECTORY(MGCleanerPlug) diff --git a/src/Tools/blocFissure/CMakeLists.txt b/src/Tools/blocFissure/CMakeLists.txt new file mode 100644 index 000000000..22e69a9b8 --- /dev/null +++ b/src/Tools/blocFissure/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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. +# +# 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 +# + +ADD_SUBDIRECTORY(CasTests) +ADD_SUBDIRECTORY(gmu) +ADD_SUBDIRECTORY(materielCasTests) + +IF(SALOME_BUILD_GUI) + ADD_SUBDIRECTORY(ihm) +ENDIF(SALOME_BUILD_GUI) + +# --- scripts --- + +# scripts / static +SET(plugin_SCRIPTS + __init__.py + casStandard.py + exemple.py + exemple2.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure) diff --git a/src/Tools/blocFissure/CasTests/CMakeLists.txt b/src/Tools/blocFissure/CasTests/CMakeLists.txt new file mode 100644 index 000000000..67f57db90 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/CMakeLists.txt @@ -0,0 +1,55 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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. +# +# 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 +# + +# --- scripts --- + +# scripts / static +SET(plugin_SCRIPTS + __init__.py + cubeAngle2.py + cubeAngle.py + cylindre_2.py + cylindre.py + disquePerce.py + ellipse_1.py + ellipse_2.py + eprouvetteCourbe.py + eprouvetteDroite_2.py + eprouvetteDroite.py + execution_Cas.py + faceGauche_2.py + faceGauche.py + fissureCoude_10.py + fissureCoude_1.py + fissureCoude_2.py + fissureCoude_3.py + fissure_Coude_4.py + fissureCoude_4.py + fissureCoude_5.py + fissureCoude_6.py + fissureCoude_7.py + fissureCoude_8.py + fissureCoude_9.py + fissure_Coude.py + vis_1.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure/CasTests) diff --git a/src/Tools/blocFissure/CasTests/__init__.py b/src/Tools/blocFissure/CasTests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/Tools/blocFissure/CasTests/cubeAngle.py b/src/Tools/blocFissure/CasTests/cubeAngle.py new file mode 100644 index 000000000..579d24140 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/cubeAngle.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class cubeAngle(fissureGenerique): + """ + problème de fissure plane coupant 2 faces (angle), débouches normaux, objet plan + """ + + nomProbleme = "cubeAngle" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, 'materielCasTests/CubeAngle.med')) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 20, + rayonPipe = 10) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [4]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,10) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 10) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 204, + Entity_Quad_Triangle = 336, + Entity_Quad_Edge = 278, + Entity_Quad_Penta = 96, + Entity_Quad_Hexa = 3651, + Entity_Node = 20490, + Entity_Quad_Tetra = 1877, + Entity_Quad_Quadrangle = 1702) + diff --git a/src/Tools/blocFissure/CasTests/cubeAngle2.py b/src/Tools/blocFissure/CasTests/cubeAngle2.py new file mode 100644 index 000000000..a33fc2acc --- /dev/null +++ b/src/Tools/blocFissure/CasTests/cubeAngle2.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +from cubeAngle import cubeAngle + +class cubeAngle2(cubeAngle): + """ + problème de fissure plane coupant 2 faces (angle), débouches normaux, objet plan + detection d'un probleme de tolerance sur les edges de jonction pipe et face fissure externe + """ + + nomProbleme = "cubeAngle2" + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + """ + self.shapeFissureParams = dict(lgInfluence = 20, + rayonPipe = 5) + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 32, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 748, + Entity_Quad_Triangle = 1228, + Entity_Quad_Edge = 351, + Entity_Quad_Penta = 640, + Entity_Quad_Hexa = 5827, + Entity_Node = 42865, + Entity_Quad_Tetra = 9216, + Entity_Quad_Quadrangle = 2518) + diff --git a/src/Tools/blocFissure/CasTests/cylindre.py b/src/Tools/blocFissure/CasTests/cylindre.py new file mode 100644 index 000000000..87657a1e6 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/cylindre.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class cylindre(fissureGenerique): + """ + problème de fissure plane sur cylindre, grand fond de fissure en arc de cercle + """ + + nomProbleme = "cylindre" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + """ + génère le maillage de l'objet sain, par chargement d'un fichier med + ici, les paramètres de géométrie et de maillage ne sont pas utiles + """ + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/CylindreSain.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 20, + rayonPipe = 5) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre2.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [7]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,15) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 20) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 1270, + Entity_Quad_Triangle = 1260, + Entity_Quad_Edge = 758, + Entity_Quad_Penta = 496, + Entity_Quad_Hexa = 18814, + Entity_Node = 113313, + Entity_Quad_Tetra = 20469, + Entity_Quad_Quadrangle = 7280) + diff --git a/src/Tools/blocFissure/CasTests/cylindre_2.py b/src/Tools/blocFissure/CasTests/cylindre_2.py new file mode 100644 index 000000000..e2023fe67 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/cylindre_2.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +import logging + +from cylindre import cylindre + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class cylindre_2(cylindre): + """ + problème de fissure plane sur cylindre hexa, fond de fissure complexe : polyline + """ + nomProbleme = "cylindre2" + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [3]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,15) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 1334, + Entity_Quad_Triangle = 1432, + Entity_Quad_Edge = 785, + Entity_Quad_Penta = 560, + Entity_Quad_Hexa = 19070, + Entity_Node = 114290, + Entity_Quad_Tetra = 19978, + Entity_Quad_Quadrangle = 7424) + diff --git a/src/Tools/blocFissure/CasTests/disquePerce.py b/src/Tools/blocFissure/CasTests/disquePerce.py new file mode 100644 index 000000000..5c4b63f3d --- /dev/null +++ b/src/Tools/blocFissure/CasTests/disquePerce.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu + +dicoParams = dict(nomCas = 'disque', + maillageSain = os.path.join(gmu.pathBloc, 'materielCasTests/disque.med'), + brepFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests/ellipse_disque.brep"), + edgeFissIds = [4], + lgInfluence = 10, + meshBrep = (0.5,2.5), + rayonPipe = 1.0, + lenSegPipe = 1.5, + nbSegRad = 6, + nbSegCercle = 16, + areteFaceFissure = 2.5) + + # --------------------------------------------------------------------------- + +referencesMaillageFissure = dict(Entity_Quad_Pyramid = 610, + Entity_Quad_Triangle = 1284, + Entity_Quad_Edge = 393, + Entity_Quad_Penta = 592, + Entity_Quad_Hexa = 6952, + Entity_Node = 51119, + Entity_Quad_Tetra = 11672, + Entity_Quad_Quadrangle = 3000) + diff --git a/src/Tools/blocFissure/CasTests/ellipse_1.py b/src/Tools/blocFissure/CasTests/ellipse_1.py new file mode 100644 index 000000000..00eef0df6 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/ellipse_1.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class ellipse_1(fissureGenerique): + """ + problème de fissure non plane, débouchante non normale + """ + + nomProbleme = "ellipse1" + +# # --------------------------------------------------------------------------- +# def genereGeometrieSaine(self, geomParams): +# logging.info("genereGeometrieSaine %s", self.nomCas) +# box = geompy.MakeBox(0, -500, 0, 400, 500, 800, "boiteSaine") +# return [box] + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/boiteSaine.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel, True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel, coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 50, + rayonPipe = 20) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/ellipse1.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [4]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,25) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 1000) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 175, + Entity_Quad_Triangle = 298, + Entity_Quad_Edge = 248, + Entity_Quad_Penta = 96, + Entity_Quad_Hexa = 3699, + Entity_Node = 20741, + Entity_Quad_Tetra = 1979, + Entity_Quad_Quadrangle = 1694) + diff --git a/src/Tools/blocFissure/CasTests/ellipse_2.py b/src/Tools/blocFissure/CasTests/ellipse_2.py new file mode 100644 index 000000000..15e0c1b60 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/ellipse_2.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from ellipse_1 import ellipse_1 + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class ellipse_2(ellipse_1): + """ + problème de fissure non plane, débouchante non normale + """ + + nomProbleme = "ellipse2" + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/ellipse1_pb.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [4]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,25) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 159, + Entity_Quad_Triangle = 438, + Entity_Quad_Edge = 249, + Entity_Quad_Penta = 80, + Entity_Quad_Hexa = 3635, + Entity_Node = 20519, + Entity_Quad_Tetra = 1973, + Entity_Quad_Quadrangle = 1658) diff --git a/src/Tools/blocFissure/CasTests/eprouvetteCourbe.py b/src/Tools/blocFissure/CasTests/eprouvetteCourbe.py new file mode 100644 index 000000000..66f9774bf --- /dev/null +++ b/src/Tools/blocFissure/CasTests/eprouvetteCourbe.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class eprouvetteCourbe(fissureGenerique): + """ + problème de fissure plane coupant 3 faces (éprouvette), faces au débouché non planes, incidence presque normale + """ + + nomProbleme = "eprouvetteCourbe" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbe.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 30, + rayonPipe = 10) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbeFiss.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [8]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,10) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 15) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 618, + Entity_Quad_Triangle = 1224, + Entity_Quad_Edge = 578, + Entity_Quad_Penta = 168, + Entity_Quad_Hexa = 18342, + Entity_Node = 98170, + Entity_Quad_Tetra = 10809, + Entity_Quad_Quadrangle = 5408) + diff --git a/src/Tools/blocFissure/CasTests/eprouvetteDroite.py b/src/Tools/blocFissure/CasTests/eprouvetteDroite.py new file mode 100644 index 000000000..8e08dd8e5 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/eprouvetteDroite.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import os +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class eprouvetteDroite(fissureGenerique): + """ + problème de fissure plane coupant 3 faces (éprouvette), débouches normaux, objet plan + """ + + nomProbleme = "eprouvetteDroite" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/eprouvetteDroite.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 30, + rayonPipe = 10, + lenSegPipe = 6) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_1.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [8]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,10) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 15) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 368, + Entity_Quad_Triangle = 798, + Entity_Quad_Edge = 491, + Entity_Quad_Penta = 88, + Entity_Quad_Hexa = 9692, + Entity_Node = 52652, + Entity_Quad_Tetra = 5093, + Entity_Quad_Quadrangle = 3750) + diff --git a/src/Tools/blocFissure/CasTests/eprouvetteDroite_2.py b/src/Tools/blocFissure/CasTests/eprouvetteDroite_2.py new file mode 100644 index 000000000..de55fd25f --- /dev/null +++ b/src/Tools/blocFissure/CasTests/eprouvetteDroite_2.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from eprouvetteDroite import eprouvetteDroite + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class eprouvetteDroite_2(eprouvetteDroite): + """ + problème de fissure plane coupant 3 faces (éprouvette), débouches non normaux, objet plan + """ + + nomProbleme = "eprouvetteDroite2" + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_2.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [10]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,10) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 396, + Entity_Quad_Triangle = 1084, + Entity_Quad_Edge = 510, + Entity_Quad_Penta = 96, + Entity_Quad_Hexa = 9504, + Entity_Node = 55482, + Entity_Quad_Tetra = 7545, + Entity_Quad_Quadrangle = 3724) + diff --git a/src/Tools/blocFissure/CasTests/execution_Cas.py b/src/Tools/blocFissure/CasTests/execution_Cas.py new file mode 100644 index 000000000..2d7b80dbe --- /dev/null +++ b/src/Tools/blocFissure/CasTests/execution_Cas.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- + +import sys, traceback +from blocFissure import gmu +from blocFissure.gmu import initLog +#initLog.setDebug() +initLog.setVerbose() + +from blocFissure.gmu import geomsmesh +from blocFissure.casStandard import casStandard + +problemes = [] + +cas=0 +from blocFissure.CasTests.fissure_Coude import fissure_Coude +problemes.append(fissure_Coude(cas)) + +cas=1 +from blocFissure.CasTests.faceGauche import faceGauche +problemes.append(faceGauche(cas)) + +cas=2 +from blocFissure.CasTests.faceGauche_2 import faceGauche_2 +problemes.append(faceGauche_2(cas)) + +cas=3 +from blocFissure.CasTests.ellipse_1 import ellipse_1 +problemes.append(ellipse_1(cas)) + +cas=4 +from blocFissure.CasTests.fissure_Coude_4 import fissure_Coude_4 +problemes.append(fissure_Coude_4(cas)) + +cas=5 +from blocFissure.CasTests.cylindre import cylindre +problemes.append(cylindre(cas)) + +cas=6 +from blocFissure.CasTests.cylindre_2 import cylindre_2 +problemes.append(cylindre_2(cas)) + +cas=7 +from blocFissure.CasTests.eprouvetteCourbe import eprouvetteCourbe +problemes.append(eprouvetteCourbe(cas)) + +cas=8 +from blocFissure.CasTests.eprouvetteDroite import eprouvetteDroite +problemes.append(eprouvetteDroite(cas)) + +cas=9 +from blocFissure.CasTests.eprouvetteDroite_2 import eprouvetteDroite_2 +problemes.append(eprouvetteDroite_2(cas)) + +cas=10 +from blocFissure.CasTests.cubeAngle import cubeAngle +problemes.append(cubeAngle(cas)) + +cas=11 +from blocFissure.CasTests.fissureCoude_1 import fissureCoude_1 +problemes.append(fissureCoude_1(cas)) + +cas=12 +from blocFissure.CasTests.fissureCoude_2 import fissureCoude_2 +problemes.append(fissureCoude_2(cas)) + +cas=13 +from blocFissure.CasTests.fissureCoude_3 import fissureCoude_3 +problemes.append(fissureCoude_3(cas)) + +cas=14 +from blocFissure.CasTests.fissureCoude_4 import fissureCoude_4 +problemes.append(fissureCoude_4(cas)) + +cas=15 +from blocFissure.CasTests.fissureCoude_5 import fissureCoude_5 +problemes.append(fissureCoude_5(cas)) + +cas=16 +from blocFissure.CasTests.ellipse_2 import ellipse_2 +problemes.append(ellipse_2(cas)) + +cas=17 +from blocFissure.CasTests.cubeAngle2 import cubeAngle2 +problemes.append(cubeAngle2(cas)) + +cas=18 +from blocFissure.CasTests import disquePerce +problemes.append(casStandard(disquePerce.dicoParams, disquePerce.referencesMaillageFissure, cas)) + +cas=19 +from blocFissure.CasTests.fissureCoude_6 import fissureCoude_6 +problemes.append(fissureCoude_6(cas)) + +cas=20 +from blocFissure.CasTests.fissureCoude_7 import fissureCoude_7 +problemes.append(fissureCoude_7(cas)) + +cas=21 +from blocFissure.CasTests.fissureCoude_8 import fissureCoude_8 +problemes.append(fissureCoude_8(cas)) + +cas=22 +from blocFissure.CasTests.fissureCoude_9 import fissureCoude_9 +problemes.append(fissureCoude_9(cas)) + +cas=23 +from blocFissure.CasTests.fissureCoude_10 import fissureCoude_10 +problemes.append(fissureCoude_10(cas)) + +cas=24 +from blocFissure.CasTests.vis_1 import vis_1 +problemes.append(vis_1(cas)) + +# ---tous les cas en sequence, ou les cas selectionnés ... +runall = True +if runall: + torun = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,] +else: #prob 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 + torun = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] + +for i in range(len(problemes)): + if torun[i]: + try: + problemes[i].executeProbleme() + except: + traceback.print_exc() + print "---------------------------------------------------------------------" diff --git a/src/Tools/blocFissure/CasTests/faceGauche.py b/src/Tools/blocFissure/CasTests/faceGauche.py new file mode 100644 index 000000000..dfb251cc0 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/faceGauche.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class faceGauche(fissureGenerique): + """ + problème de fissure non plane, débouchante non normale + """ + + nomProbleme = "faceGauche" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheSain.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 300, + rayonPipe = 20) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheFiss.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [6]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,50) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 1000) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 1284, + Entity_Quad_Triangle = 2336, + Entity_Quad_Edge = 758, + Entity_Quad_Penta = 984, + Entity_Quad_Hexa = 6416, + Entity_Node = 85673, + Entity_Quad_Tetra = 35990, + Entity_Quad_Quadrangle = 4285) + diff --git a/src/Tools/blocFissure/CasTests/faceGauche_2.py b/src/Tools/blocFissure/CasTests/faceGauche_2.py new file mode 100644 index 000000000..cc8a03db8 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/faceGauche_2.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class faceGauche_2(fissureGenerique): + """ + problème de fissure non plane, débouchante non normale + """ + + nomProbleme = "faceGauche2" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/boiteSaine.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 100, + rayonPipe = 20) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/faceGauche2FissCoupe.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [12, 4]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,25) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 8, + areteFaceFissure = 1000) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 859, + Entity_Quad_Triangle = 634, + Entity_Quad_Edge = 323, + Entity_Quad_Penta = 288, + Entity_Quad_Hexa = 3435, + Entity_Node = 44095, + Entity_Quad_Tetra = 18400, + Entity_Quad_Quadrangle = 2542) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_1.py b/src/Tools/blocFissure/CasTests/fissureCoude_1.py new file mode 100644 index 000000000..9e7636599 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_1.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_1(fissureCoude): + """ + problème de fissure du Coude : + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 60, + r_cintr = 1200, + l_tube_p1 = 1600, + l_tube_p2 = 1200, + epais = 40, + de = 760) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 15, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe = 2.5, + azimut = 160, + alpha = 20, + longueur = 400, + orientation = 90, + lgInfluence = 50, + elliptique = False, + externe = True) + +# --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 77917, + Entity_Quad_Edge = 975, + Entity_Quad_Triangle = 2182, + Entity_Quad_Quadrangle = 6842, + Entity_Quad_Tetra = 20135, + Entity_Quad_Hexa = 8994, + Entity_Quad_Penta = 972, + Entity_Quad_Pyramid = 1038) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_10.py b/src/Tools/blocFissure/CasTests/fissureCoude_10.py new file mode 100644 index 000000000..33ab3e012 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_10.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_10(fissureCoude): + # cas test ASCOU17 + + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 90, + r_cintr = 1143, + l_tube_p1 = 3200, + l_tube_p2 = 3200, + epais = 35, + de = 762) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 13, + n_ep = 2, + n_long_coude = 20, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 13) + + # --------------------------------------------------------------------------- + + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ +# logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(profondeur = 2.5, + rayonPipe = 1.5, + lenSegPipe = 6, + azimut = 180, + alpha = 45, + longueur = 1196, + orientation = 0, + lgInfluence = 30, + elliptique = False, + externe = False) + + # --------------------------------------------------------------------------- + + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 3, + nbsegCercle = 8, + areteFaceFissure = 2.5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 93352, + Entity_Quad_Edge = 1456, + Entity_Quad_Triangle = 8934, + Entity_Quad_Quadrangle = 6978, + Entity_Quad_Tetra = 31147, + Entity_Quad_Hexa = 6972, + Entity_Quad_Penta = 1600, + Entity_Quad_Pyramid = 1696) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_2.py b/src/Tools/blocFissure/CasTests/fissureCoude_2.py new file mode 100644 index 000000000..0690c01d6 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_2.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_2(fissureCoude): + """ + problème de fissure du Coude : + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 90, + r_cintr = 1200, + l_tube_p1 = 1600, + l_tube_p2 = 1200, + epais = 40, + de = 760) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 15, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe = 2.5, + azimut = 200, + alpha = 40, + longueur = 800, + orientation = 0, + lgInfluence = 50, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 132120, + Entity_Quad_Edge = 1411, + Entity_Quad_Triangle = 5342, + Entity_Quad_Quadrangle = 9524, + Entity_Quad_Tetra = 40902, + Entity_Quad_Hexa = 12981, + Entity_Quad_Penta = 1980, + Entity_Quad_Pyramid = 2064) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_3.py b/src/Tools/blocFissure/CasTests/fissureCoude_3.py new file mode 100644 index 000000000..653192d5b --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_3.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_3(fissureCoude): + """ + problème de fissure du Coude + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 40, + r_cintr = 654, + l_tube_p1 = 1700, + l_tube_p2 = 1700, + epais = 62.5, + de = 912.4) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 30, + n_circ_g = 50, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe = 2.5, + azimut = 90, + alpha = 20, + longueur = 240, + orientation = 90, + lgInfluence = 30, + elliptique = False, + externe = False) + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 98643, + Entity_Quad_Edge = 1130, + Entity_Quad_Triangle = 1476, + Entity_Quad_Quadrangle = 11100, + Entity_Quad_Tetra = 15993, + Entity_Quad_Hexa = 14508, + Entity_Quad_Penta = 624, + Entity_Quad_Pyramid = 788) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_4.py b/src/Tools/blocFissure/CasTests/fissureCoude_4.py new file mode 100644 index 000000000..8d43dcc41 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_4.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_4(fissureCoude): + """ + problème de fissure du Coude : ASCOU09A + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 40, + r_cintr = 654, + l_tube_p1 = 1700, + l_tube_p2 = 1700, + epais = 62.5, + de = 912.4) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 5, + n_long_coude = 30, + n_circ_g = 50, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe =2.5, + azimut = 90, + alpha = 20, + longueur = 240, + orientation = 90, + lgInfluence = 30, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 133832, + Entity_Quad_Edge = 1133, + Entity_Quad_Triangle = 1498, + Entity_Quad_Quadrangle = 11892, + Entity_Quad_Tetra = 18401, + Entity_Quad_Hexa = 22412, + Entity_Quad_Penta = 600, + Entity_Quad_Pyramid = 816) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_5.py b/src/Tools/blocFissure/CasTests/fissureCoude_5.py new file mode 100644 index 000000000..23477e134 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_5.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_5(fissureCoude): + """ + problème de fissure du Coude : + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 90, + r_cintr = 1200, + l_tube_p1 = 1600, + l_tube_p2 = 1200, + epais = 40, + de = 760) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 15, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe = 2.5, + azimut = 180, + alpha = 40, + longueur = 200, + orientation = 0, + lgInfluence = 50, + elliptique = False, + externe = False) + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 55217, + Entity_Quad_Edge = 762, + Entity_Quad_Triangle = 1586, + Entity_Quad_Quadrangle = 5610, + Entity_Quad_Tetra = 11468, + Entity_Quad_Hexa = 7200, + Entity_Quad_Penta = 516, + Entity_Quad_Pyramid = 552) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_6.py b/src/Tools/blocFissure/CasTests/fissureCoude_6.py new file mode 100644 index 000000000..0952579a8 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_6.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_6(fissureCoude): +# --- cas ASCOU08 + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 40, + r_cintr = 854, + l_tube_p1 = 1700, + l_tube_p2 = 1700, + epais = 62.5, + de = 912.4) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 15, + n_ep = 3, + n_long_coude = 16, + n_circ_g = 30, + n_circ_d = 30, + n_long_p2 = 15) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 4, + lenSegPipe = 4, + azimut = 90, + alpha = 20, + longueur = 133, + orientation = 0, + lgInfluence = 30, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 12, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 63783, + Entity_Quad_Edge = 831, + Entity_Quad_Triangle = 742, + Entity_Quad_Quadrangle = 7480, + Entity_Quad_Tetra = 8084, + Entity_Quad_Hexa = 10080, + Entity_Quad_Penta = 456, + Entity_Quad_Pyramid = 500) + + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_7.py b/src/Tools/blocFissure/CasTests/fissureCoude_7.py new file mode 100644 index 000000000..d19a4b14c --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_7.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_7(fissureCoude): + + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 40, + r_cintr = 654, + l_tube_p1 = 1700, + l_tube_p2 = 1700, + epais = 62.5, + de = 912.4) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 15, + n_ep = 3, + n_long_coude = 16, + n_circ_g = 30, + n_circ_d = 30, + n_long_p2 = 15) + + # --------------------------------------------------------------------------- + + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ +# logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 4, + lenSegPipe = 4, + azimut = 0, + alpha = 20, + longueur = 240, + orientation = 0, + lgInfluence = 30, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 12, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 75580, + Entity_Quad_Edge = 899, + Entity_Quad_Triangle = 1158, + Entity_Quad_Quadrangle = 8022, + Entity_Quad_Tetra = 13162, + Entity_Quad_Hexa = 11272, + Entity_Quad_Penta = 756, + Entity_Quad_Pyramid = 812) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_8.py b/src/Tools/blocFissure/CasTests/fissureCoude_8.py new file mode 100644 index 000000000..49439b6ec --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_8.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_8(fissureCoude): + # cas test ASCOU15 + + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 90, + r_cintr = 2290, + l_tube_p1 = 3200, + l_tube_p2 = 3200, + epais = 30.5, + de = 762) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 8, + n_ep = 2, + n_long_coude = 20, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 8) + + # --------------------------------------------------------------------------- + + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ +# logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(profondeur = 8, + rayonPipe = 1, + lenSegPipe = 1.5, + azimut = 180, + alpha = 45, + longueur = 48, + orientation = 0, + lgInfluence = 30, + elliptique = True, + externe = False) + + # --------------------------------------------------------------------------- + + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 4, + nbsegCercle = 16, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 50627, + Entity_Quad_Edge = 666, + Entity_Quad_Triangle = 1498, + Entity_Quad_Quadrangle = 4747, + Entity_Quad_Tetra = 13225, + Entity_Quad_Hexa = 5464, + Entity_Quad_Penta = 864, + Entity_Quad_Pyramid = 880) + diff --git a/src/Tools/blocFissure/CasTests/fissureCoude_9.py b/src/Tools/blocFissure/CasTests/fissureCoude_9.py new file mode 100644 index 000000000..d7370d1ed --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissureCoude_9.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_9(fissureCoude): + # cas test ASCOU19 + + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 90, + r_cintr = 1144, + l_tube_p1 = 1651, + l_tube_p2 = 1651, + epais = 39, + de = 762) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 4, + n_long_coude = 40, + n_circ_g = 40, + n_circ_d = 40, + n_long_p2 = 16) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2, + lenSegPipe = 6, + azimut = 0, + alpha = 30.8456, + longueur = 240, + orientation = 90, + lgInfluence = 50, + elliptique = False, + externe = False) + +# --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 6, + nbsegCercle = 20, + areteFaceFissure = 2.5) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 162936, + Entity_Quad_Edge = 1254, + Entity_Quad_Triangle = 3238, + Entity_Quad_Quadrangle = 15088, + Entity_Quad_Tetra = 19305, + Entity_Quad_Hexa = 27472, + Entity_Quad_Penta = 920, + Entity_Quad_Pyramid = 1056) + diff --git a/src/Tools/blocFissure/CasTests/fissure_Coude.py b/src/Tools/blocFissure/CasTests/fissure_Coude.py new file mode 100644 index 000000000..6f87ec6b4 --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissure_Coude.py @@ -0,0 +1,496 @@ +# -*- coding: utf-8 -*- + +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureLongue import insereFissureLongue + +O, OX, OY, OZ = triedreBase() + +class fissure_Coude(fissureGenerique): + """ + problème de fissure du Coude : version de base + maillage hexa + """ + + nomProbleme = "tuyau_Coude" + + # --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 60, + r_cintr = 1200, + l_tube_p1 = 1600, + l_tube_p2 = 1200, + epais = 40, + de = 760) + + # --------------------------------------------------------------------------- + def genereGeometrieSaine(self, geomParams): + logging.info("genereGeometrieSaine %s", self.nomCas) + + angleCoude = geomParams['angleCoude'] + r_cintr = geomParams['r_cintr'] + l_tube_p1 = geomParams['l_tube_p1'] + l_tube_p2 = geomParams['l_tube_p2'] + epais = geomParams['epais'] + de = geomParams['de'] + + centre = geompy.MakeVertex(0, 0, -l_tube_p1) + Disk_1 = geompy.MakeDiskPntVecR(centre, OZ, de/2.) + Disk_2 = geompy.MakeDiskPntVecR(centre, OZ, de/2. -epais) + Cut_1 = geompy.MakeCut(Disk_1, Disk_2) + Extrusion_1 = geompy.MakePrismVecH(Cut_1, OZ, l_tube_p1) + axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1) + Revolution_1 = geompy.MakeRevolution(Cut_1, axe, angleCoude*math.pi/180.0) + Rotation_1 = geompy.MakeRotation(Cut_1, axe, angleCoude*math.pi/180.0) + Rotation_2 = geompy.MakeRotation(OZ, OY, angleCoude*math.pi/180.0) + Extrusion_2 = geompy.MakePrismVecH(Rotation_1, Rotation_2, -l_tube_p2) + Plane_1 = geompy.MakePlaneLCS(None, 100000, 3) + geompy.addToStudy( Plane_1, "Plane_1" ) + geompy.addToStudy( Extrusion_1, "Extrusion_1" ) + geompy.addToStudy( Revolution_1, "Revolution_1" ) + geompy.addToStudy( Extrusion_2, "Extrusion_2" ) + + P1 = O + geompy.addToStudy( P1, "P1" ) + op2 = geompy.MakeVertex(0, 0, -l_tube_p1) + P2 = geompy.MakeRotation(op2, axe, angleCoude*math.pi/180.0) + P2 = geompy.MakeTranslationVectorDistance(P2, Rotation_2, -l_tube_p2) + geompy.addToStudy( P2, "P2" ) + + # --- tube coude sain + + geometrieSaine = geompy.MakePartition([Extrusion_1, Revolution_1, Extrusion_2, P1, P2], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + geompy.addToStudy( geometrieSaine, self.nomCas ) + [P1, P2] = geompy.RestoreGivenSubShapes(geometrieSaine, [P1, P2], GEOM.FSM_GetInPlaceByHistory, False, True) + + [ep, circ_g, circ_d, long_p2, long_coude, long_p1] = geompy.Propagate(geometrieSaine) + geompy.addToStudyInFather( geometrieSaine, long_p1, 'long_p1' ) + geompy.addToStudyInFather( geometrieSaine, ep, 'ep' ) + geompy.addToStudyInFather( geometrieSaine, long_coude, 'long_coude' ) + geompy.addToStudyInFather( geometrieSaine, circ_g, 'circ_g' ) + geompy.addToStudyInFather( geometrieSaine, circ_d, 'circ_d' ) + geompy.addToStudyInFather( geometrieSaine, long_p2, 'long_p2' ) + + # --- face extremite tube (EXTUBE) + + facesIds = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["FACE"], OZ, GEOM.ST_ON) + EXTUBE = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(EXTUBE, facesIds) + geompy.addToStudyInFather( geometrieSaine, EXTUBE, 'EXTUBE' ) + + # --- edge bord extremite tube (BORDTU) + + edge1Ids = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["EDGE"], OZ, GEOM.ST_ON) + edge2Ids = geompy.GetShapesOnCylinderIDs(geometrieSaine, geompy.ShapeType["EDGE"], OZ, de/2., GEOM.ST_ON) + edgesIds = [] + for edge in edge1Ids: + if edge in edge2Ids: + edgesIds.append(edge) + BORDTU = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(BORDTU, edgesIds) + geompy.addToStudyInFather( geometrieSaine, BORDTU, 'BORDTU' ) + + # --- face origine tube (CLGV) + + pp2 = geompy.MakeTranslationVectorDistance(P2, Rotation_2, 10) + vec2 = geompy.MakeVector(P2, pp2) + #geompy.addToStudy(vec2, 'vec2') + facesIds = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["FACE"], vec2, GEOM.ST_ON) + CLGV = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(CLGV, facesIds) + geompy.addToStudyInFather( geometrieSaine, CLGV, 'CLGV' ) + + # --- peau tube interieur (PEAUINT) + + extru1 = geompy.MakePrismVecH(Disk_2, OZ, l_tube_p1) + revol1 = geompy.MakeRevolution(Disk_2, axe, angleCoude*math.pi/180.0) + rot1 = geompy.MakeRotation(Disk_2, axe, angleCoude*math.pi/180.0) + extru2 = geompy.MakePrismVecH(rot1, Rotation_2, -l_tube_p2) + interne = geompy.MakeFuse(extru1, revol1) + interne = geompy.MakeFuse(extru2, interne) + geompy.addToStudy(interne, 'interne') + facesIds = geompy.GetShapesOnShapeIDs(interne, geometrieSaine, geompy.ShapeType["FACE"], GEOM.ST_ONIN) + PEAUINT = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(PEAUINT, facesIds) + geompy.addToStudyInFather( geometrieSaine, PEAUINT, 'PEAUINT' ) + + # --- peau tube exterieur (PEAUEXT) + + cercle1 = geompy.MakeCircle(centre, OZ, de/2.) + extru1 = geompy.MakePrismVecH(cercle1, OZ, l_tube_p1) + revol1 = geompy.MakeRevolution(cercle1, axe, angleCoude*math.pi/180.0) + rot1 = geompy.MakeRotation(cercle1, axe, angleCoude*math.pi/180.0) + extru2 = geompy.MakePrismVecH(rot1, Rotation_2, -l_tube_p2) + externe = geompy.MakeFuse(extru1, revol1) + externe = geompy.MakeFuse(extru2, externe) + geompy.addToStudy(externe, 'externe') + facesIds = geompy.GetShapesOnShapeIDs(externe, geometrieSaine, geompy.ShapeType["FACE"], GEOM.ST_ON) + PEAUEXT = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(PEAUEXT, facesIds) + geompy.addToStudyInFather( geometrieSaine, PEAUEXT, 'PEAUEXT' ) + + # --- solide sain + + volIds = geompy.SubShapeAllIDs(geometrieSaine, geompy.ShapeType["SOLID"]) + COUDE = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["SOLID"]) + geompy.UnionIDs(COUDE, volIds) + geompy.addToStudyInFather( geometrieSaine, COUDE, 'COUDSAIN' ) + + geometriesSaines = [geometrieSaine, long_p1, ep, long_coude, circ_g, circ_d, long_p2, P1, P2, EXTUBE, BORDTU, CLGV, PEAUINT, PEAUEXT, COUDE] + + return geometriesSaines + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 15, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 12) + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + geometrieSaine = geometriesSaines[0] + long_p1 = geometriesSaines[1] + ep = geometriesSaines[2] + long_coude = geometriesSaines[3] + circ_g = geometriesSaines[4] + circ_d = geometriesSaines[5] + long_p2 = geometriesSaines[6] + P1 = geometriesSaines[7] + P2 = geometriesSaines[8] + EXTUBE = geometriesSaines[9] + BORDTU = geometriesSaines[10] + CLGV = geometriesSaines[11] + PEAUINT = geometriesSaines[12] + PEAUEXT = geometriesSaines[13] + COUDE = geometriesSaines[14] + + n_long_p1 = meshParams['n_long_p1'] + n_ep = meshParams['n_ep'] + n_long_coude = meshParams['n_long_coude'] + n_circ_g = meshParams['n_circ_g'] + n_circ_d = meshParams['n_circ_d'] + n_long_p2 = meshParams['n_long_p2'] + + maillageSain = smesh.Mesh(geometrieSaine) + + algo3d = maillageSain.Hexahedron() + algo2d = maillageSain.Quadrangle() + smesh.SetName(algo3d, "algo3d_maillageSain") + smesh.SetName(algo2d, "algo2d_maillageSain") + + algo1d_long_p1 = maillageSain.Segment(geom=long_p1) + hypo1d_long_p1 = algo1d_long_p1.NumberOfSegments(n_long_p1) + smesh.SetName(algo1d_long_p1, "algo1d_long_p1") + smesh.SetName(hypo1d_long_p1, "hypo1d_long_p1") + + algo1d_ep = maillageSain.Segment(geom=ep) + hypo1d_ep = algo1d_ep.NumberOfSegments(n_ep) + smesh.SetName(algo1d_ep, "algo1d_ep") + smesh.SetName(hypo1d_ep, "hypo1d_ep") + + algo1d_long_coude = maillageSain.Segment(geom=long_coude) + hypo1d_long_coude = algo1d_long_coude.NumberOfSegments(n_long_coude) + smesh.SetName(algo1d_long_coude, "algo1d_long_coude") + smesh.SetName(hypo1d_long_coude, "hypo1d_long_coude") + + algo1d_circ_g = maillageSain.Segment(geom=circ_g) + hypo1d_circ_g = algo1d_circ_g.NumberOfSegments(n_circ_g) + smesh.SetName(algo1d_circ_g, "algo1d_circ_g") + smesh.SetName(hypo1d_circ_g, "hypo1d_circ_g") + + algo1d_circ_d = maillageSain.Segment(geom=circ_d) + hypo1d_circ_d = algo1d_circ_d.NumberOfSegments(n_circ_d) + smesh.SetName(algo1d_circ_d, "algo1d_circ_d") + smesh.SetName(hypo1d_circ_d, "hypo1d_circ_d") + + algo1d_long_p2 = maillageSain.Segment(geom=long_p2) + hypo1d_long_p2 = algo1d_long_p2.NumberOfSegments(n_long_p2) + smesh.SetName(algo1d_long_p2, "algo1d_long_p2") + smesh.SetName(hypo1d_long_p2, "hypo1d_long_p2") + + isDone = maillageSain.Compute() + + mp1 = maillageSain.GroupOnGeom(P1,'P1',SMESH.NODE) + mp2 = maillageSain.GroupOnGeom(P2,'P2',SMESH.NODE) + ext = maillageSain.GroupOnGeom(EXTUBE,'EXTUBE',SMESH.FACE) + btu = maillageSain.GroupOnGeom(BORDTU,'BORDTU',SMESH.EDGE) + clg = maillageSain.GroupOnGeom(CLGV,'CLGV',SMESH.FACE) + pei = maillageSain.GroupOnGeom(PEAUINT,'PEAUINT',SMESH.FACE) + pex = maillageSain.GroupOnGeom(PEAUEXT,'PEAUEXT',SMESH.FACE) + cou = maillageSain.GroupOnGeom(COUDE,'COUDSAIN',SMESH.VOLUME) + + return [maillageSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure + profondeur : 0 < profondeur <= épaisseur + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> ellipse, >2*profondeur = fissure longue + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + externe : True : fissure face externe, False : fissure face interne + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(profondeur = 10, + azimut = 160, + alpha = 20, + longueur = 400, + orientation = 90, + lgInfluence = 0, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + logging.info("shapeFissureParams %s", shapeFissureParams) + + angleCoude = geomParams['angleCoude'] + r_cintr = geomParams['r_cintr'] + l_tube_p1 = geomParams['l_tube_p1'] + l_tube_p2 = geomParams['l_tube_p2'] + epais = geomParams['epais'] + de = geomParams['de'] + + profondeur = shapeFissureParams['profondeur'] + azimut = shapeFissureParams['azimut'] + alpha = shapeFissureParams['alpha'] + longueur = shapeFissureParams['longueur'] + orientation = shapeFissureParams['orientation'] + externe = shapeFissureParams['externe'] + lgInfluence = shapeFissureParams['lgInfluence'] + + azimut = -azimut # axe inverse / ASCOUF + axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1) + + if not lgInfluence: + lgInfluence = profondeur + + if longueur > 2*profondeur: + self.fissureLongue=True + else: + self.fissureLongue=False + + self.circonferentielle = False + self.longitudinale = False + if self.fissureLongue and (abs(orientation) < 45) : + self.longitudinale = True + elif self.fissureLongue: + self.circonferentielle = True + + if self.circonferentielle: + if externe: + raybor = de/2. + rayint = raybor - profondeur + rayext = raybor + profondeur + else: + rayext = de/2. - epais + rayint = raybor + profondeur + rayext = raybor - profondeur + lgfond = longueur -2*profondeur + angle = lgfond/(2*raybor) + pb = geompy.MakeVertex(raybor, 0, 0) + pi = geompy.MakeVertex(rayint, 0, 0) + pe = geompy.MakeVertex(rayext, 0, 0) + pl = geompy.MakeVertex(raybor, profondeur, 0) + pr = geompy.MakeVertex(raybor, -profondeur, 0) + pil = geompy.MakeRotation(pi, OZ, angle) + pll = geompy.MakeRotation(pl, OZ, angle) + pel = geompy.MakeRotation(pe, OZ, angle) + pir = geompy.MakeRotation(pi, OZ, -angle) + prr = geompy.MakeRotation(pr, OZ, -angle) + per = geompy.MakeRotation(pe, OZ, -angle) + arcl = geompy.MakeArc(pil, pll, pel) + arcr = geompy.MakeArc(pir, prr, per) + arci = geompy.MakeArc(pil, pi, pir) + arce = geompy.MakeArc(pel, pe, per) + wire0 = geompy.MakeWire([arcr, arci, arcl]) + cercle0 = geompy.MakeCircle(O, OY, profondeur/4.0) + cercle0 = geompy.MakeRotation(cercle0, OY, math.pi/2.0) + cercle0 = geompy.MakeTranslationTwoPoints(cercle0, O, pi) + facetube0 = geompy.MakeFaceWires([cercle0], 1) + facetubel = geompy.MakeRotation(facetube0, OZ, angle) + facetuber = geompy.MakeRotation(facetube0, OZ, -angle) + face0 = geompy.MakeFaceWires([arcl,arci, arce, arcr], 1) + plan0 = geompy.MakePlane(O, OZ, 10000) + geompy.addToStudy( face0, 'facefissOrig' ) + face1 = geompy.MakeRotation(face0, OZ, azimut*math.pi/180.) + face2 = geompy.MakeTranslation(face1, 0, 0, -l_tube_p1) + facefiss = geompy.MakeRotation(face2, axe, alpha*math.pi/180.) + geompy.addToStudy( facefiss, 'facefissPlace' ) + centre = geompy.MakeRotation(pb, OZ, azimut*math.pi/180.) + centre = geompy.MakeTranslation(centre, 0, 0, -l_tube_p1) + centre = geompy.MakeRotation(centre, axe, alpha*math.pi/180.) + geompy.addToStudy( centre, 'centrefissPlace' ) + arcr = geompy.MakeRotation(arcr, OZ, azimut*math.pi/180.) + arcr = geompy.MakeTranslation(arcr, 0, 0, -l_tube_p1) + arcr = geompy.MakeRotation(arcr, axe, alpha*math.pi/180.) + arci = geompy.MakeRotation(arci, OZ, azimut*math.pi/180.) + arci = geompy.MakeTranslation(arci, 0, 0, -l_tube_p1) + arci = geompy.MakeRotation(arci, axe, alpha*math.pi/180.) + arcl = geompy.MakeRotation(arcl, OZ, azimut*math.pi/180.) + arcl = geompy.MakeTranslation(arcl, 0, 0, -l_tube_p1) + arcl = geompy.MakeRotation(arcl, axe, alpha*math.pi/180.) + wiretube = geompy.MakeRotation(wire0, OZ, azimut*math.pi/180.) + wiretube = geompy.MakeTranslation(wiretube, 0, 0, -l_tube_p1) + wiretube = geompy.MakeRotation(wiretube, axe, alpha*math.pi/180.) + geompy.addToStudy(wiretube, 'wiretubePlace' ) + facetubel = geompy.MakeRotation(facetubel, OZ, azimut*math.pi/180.) + facetubel = geompy.MakeTranslation(facetubel, 0, 0, -l_tube_p1) + facetubel = geompy.MakeRotation(facetubel, axe, alpha*math.pi/180.) + geompy.addToStudy(facetubel, 'facetubeGauche' ) + facetuber = geompy.MakeRotation(facetuber, OZ, azimut*math.pi/180.) + facetuber = geompy.MakeTranslation(facetuber, 0, 0, -l_tube_p1) + facetuber = geompy.MakeRotation(facetuber, axe, alpha*math.pi/180.) + geompy.addToStudy(facetuber, 'facetubeDroit' ) + planfiss = geompy.MakeRotation(plan0, OZ, azimut*math.pi/180.) + planfiss = geompy.MakeTranslation(planfiss, 0, 0, -l_tube_p1) + planfiss = geompy.MakeRotation(planfiss, axe, alpha*math.pi/180.) + geompy.addToStudy(planfiss, 'planfissPlace' ) + pipefissl = geompy.MakePipe(facetubel, arcl) + pipefissi = geompy.MakePipe(facetubel, arci) + pipefissr = geompy.MakePipe(facetuber, arcr) + pipefiss = geompy.MakePartition([pipefissl, pipefissi, pipefissr], [planfiss, wiretube], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + geompy.addToStudy(pipefiss, 'pipefissPlace' ) + + + elif self.longitudinale: + if externe: + raybor = r_cintr + de/2. + rayint = raybor - profondeur + rayext = raybor + profondeur + else: + rayext = r_cintr + de/2. - epais + rayint = raybor + profondeur + rayext = raybor - profondeur + lgfond = longueur -2*profondeur + angle = lgfond/(2*raybor) + pb = geompy.MakeVertex(-raybor, 0, 0) + pi = geompy.MakeVertex(-rayint, 0, 0) + pe = geompy.MakeVertex(-rayext, 0, 0) + pl = geompy.MakeVertex(-raybor, 0, -profondeur) + pr = geompy.MakeVertex(-raybor, 0, profondeur) + pil = geompy.MakeRotation(pi, OY, -angle) + pll = geompy.MakeRotation(pl, OY, -angle) + pel = geompy.MakeRotation(pe, OY, -angle) + pir = geompy.MakeRotation(pi, OY, angle) + prr = geompy.MakeRotation(pr, OY, angle) + per = geompy.MakeRotation(pe, OY, angle) + arcl = geompy.MakeArc(pil, pll, pel) + arcr = geompy.MakeArc(pir, prr, per) + arci = geompy.MakeArc(pil, pi, pir) + arce = geompy.MakeArc(pel, pe, per) + geompy.addToStudy( arcl, 'arcl' ) + geompy.addToStudy( arcr, 'arcr' ) + geompy.addToStudy( arci, 'arci' ) + geompy.addToStudy( arce, 'arce' ) + wire0 = geompy.MakeWire([arcr, arci, arcl]) + cercle0 = geompy.MakeCircle(O, OZ, profondeur/4.0) + #cercle0 = geompy.MakeRotation(cercle0, OZ, math.pi/2.0) + cercle0 = geompy.MakeTranslationTwoPoints(cercle0, O, pi) + geompy.addToStudy( cercle0, 'cercle0' ) + facetube0 = geompy.MakeFaceWires([cercle0], 1) + facetubel = geompy.MakeRotation(facetube0, OY, -angle) + facetuber = geompy.MakeRotation(facetube0, OY, angle) + geompy.addToStudy(facetubel , 'facetubel' ) + geompy.addToStudy( facetuber, 'facetuber' ) + face0 = geompy.MakeFaceWires([arcl,arci, arce, arcr], 1) + plan0 = geompy.MakePlane(O, OY, 10000) + geompy.addToStudy( face0, 'facefissOrig' ) + facefiss = geompy.MakeRotation(face0, OY, alpha*math.pi/180.) + geompy.addToStudy( facefiss, 'facefissPlace' ) + centre = geompy.MakeRotation(pb, OY, alpha*math.pi/180.) + geompy.addToStudy( centre, 'centrefissPlace' ) + arcr = geompy.MakeRotation(arcr, OY, alpha*math.pi/180.) + arci = geompy.MakeRotation(arci, OY, alpha*math.pi/180.) + arcl = geompy.MakeRotation(arcl, OY, alpha*math.pi/180.) + wiretube = geompy.MakeRotation(wire0, OY, alpha*math.pi/180.) + geompy.addToStudy(wiretube, 'wiretubePlace' ) + facetubel = geompy.MakeRotation(facetubel, OY, alpha*math.pi/180.) + geompy.addToStudy(facetubel, 'facetubeGauche' ) + facetuber = geompy.MakeRotation(facetuber, OY, alpha*math.pi/180.) + geompy.addToStudy(facetubel, 'facetubeDroit' ) + planfiss = geompy.MakeRotation(plan0, OY, alpha*math.pi/180.) + geompy.addToStudy(planfiss, 'planfissPlace' ) + pipefissl = geompy.MakePipe(facetubel, arcl) + pipefissi = geompy.MakePipe(facetubel, arci) + pipefissr = geompy.MakePipe(facetuber, arcr) + pipefiss = geompy.MakePartition([pipefissl, pipefissi, pipefissr], [planfiss, wiretube], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + geompy.addToStudy(pipefiss, 'pipefissPlace' ) + else: + pass + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(facefiss, 5 ,10) + + return [facefiss, centre, lgInfluence, coordsNoeudsFissure, wiretube, facetubel, facetuber, planfiss, pipefiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegExt = 5, + nbsegGen = 25, + nbsegRad = 5, + scaleRad = 4, + nbsegCercle = 6, + nbsegFis = 20, + lensegEllipso = 1.0) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureLongue(geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 77491, + Entity_Quad_Edge = 1006, + Entity_Quad_Triangle = 2412, + Entity_Quad_Quadrangle = 6710, + Entity_Quad_Tetra = 20853, + Entity_Quad_Hexa = 8656, + Entity_Quad_Penta = 1176, + Entity_Quad_Pyramid = 1232) + diff --git a/src/Tools/blocFissure/CasTests/fissure_Coude_4.py b/src/Tools/blocFissure/CasTests/fissure_Coude_4.py new file mode 100644 index 000000000..55a8b090d --- /dev/null +++ b/src/Tools/blocFissure/CasTests/fissure_Coude_4.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +from fissure_Coude import fissure_Coude + +class fissure_Coude_4(fissure_Coude): + """ + probleme de fissure du Coude : ASCOU09A + adaptation maillage + """ + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 40, + r_cintr = 654, + l_tube_p1 = 1700, + l_tube_p2 = 1700, + epais = 62.5, + de = 912.4) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 5, + n_long_coude = 30, + n_circ_g = 50, + n_circ_d = 20, + n_long_p2 = 12) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure + profondeur : 0 < profondeur <= épaisseur + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> ellipse, >2*profondeur = fissure longue + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + profondeur = 10, + azimut = 90, + alpha = 20, + longueur = 240, + orientation = 90, + lgInfluence = 30, + elliptique = False, + convexe = True, + externe = True) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 948, + Entity_Quad_Triangle = 1562, + Entity_Quad_Edge = 1192, + Entity_Quad_Penta = 732, + Entity_Quad_Hexa = 22208, + Entity_Node = 133418, + Entity_Quad_Tetra = 18759, + Entity_Quad_Quadrangle = 11852) + diff --git a/src/Tools/blocFissure/CasTests/vis_1.py b/src/Tools/blocFissure/CasTests/vis_1.py new file mode 100644 index 000000000..fdcb5c94f --- /dev/null +++ b/src/Tools/blocFissure/CasTests/vis_1.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class vis_1(fissureGenerique): + """ + problème de fissure non plane, débouchante non normale + """ + + nomProbleme = "vis_1" + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/visSain.med")) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : optionnel True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel coordonnée x d'un point dans le solide sain (pour orienter la face) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(lgInfluence = 0.6, + rayonPipe = 0.1) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/visFiss.brep"), "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, [4, 7, 9]) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 0.1 ,0.2) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 32, + areteFaceFissure = 0.1) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 1284, + Entity_Quad_Triangle = 2336, + Entity_Quad_Edge = 758, + Entity_Quad_Penta = 984, + Entity_Quad_Hexa = 6416, + Entity_Node = 85673, + Entity_Quad_Tetra = 35990, + Entity_Quad_Quadrangle = 4285) + diff --git a/src/Tools/blocFissure/__init__.py b/src/Tools/blocFissure/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/Tools/blocFissure/casStandard.py b/src/Tools/blocFissure/casStandard.py new file mode 100644 index 000000000..9c1ac5505 --- /dev/null +++ b/src/Tools/blocFissure/casStandard.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from blocFissure.gmu.fissureGenerique import fissureGenerique + +from blocFissure.gmu.initEtude import initEtude +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from blocFissure.gmu.insereFissureGenerale import insereFissureGenerale + +O, OX, OY, OZ = triedreBase() + +class casStandard(fissureGenerique): + """ + problème de fissure standard, défini par : + - un maillage sain (hexaèdres), + - une face géométrique de fissure, qui doit légèrement dépasser hors du volume maillé + - les numéros d'arêtes (edges géométriques) correspondant au fond de fissure + - les paramètres de maillage de la fissure + """ + + # --------------------------------------------------------------------------- + def __init__ (self, dicoParams, references = None, numeroCas = 0): + initEtude() + self.references = references + self.dicoParams = dicoParams + if self.dicoParams.has_key('nomCas'): + self.nomCas = self.dicoParams['nomCas'] + else: + self.nomCas = 'casStandard' + self.numeroCas = numeroCas + if self.numeroCas != 0: + self.nomCas = self.nomProbleme +"_%d"%(self.numeroCas) + else: + self.nomProbleme = self.nomCas + if self.dicoParams.has_key('lenSegPipe'): + self.lenSegPipe = self.dicoParams['lenSegPipe'] + else: + self.lenSegPipe =self.dicoParams['rayonPipe'] + if self.dicoParams.has_key('step'): + step = self.dicoParams['step'] + else: + step = -1 # exécuter toutes les étapes + if self.numeroCas == 0: # valeur par défaut : exécution immédiate, sinon execution différée dans le cas d'une liste de problèmes + self.executeProbleme(step) + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + ([objetSain], status) = smesh.CreateMeshesFromMED(self.dicoParams['maillageSain']) + smesh.SetName(objetSain.GetMesh(), 'objetSain') + + return [objetSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour méthode insereFissureGenerale + lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage) + rayonPipe : le rayon du pile maillé en hexa autour du fond de fissure + convexe : True : la face est convexe (vue de l'exterieur) sert si on ne donne pas de point interne + pointIn_x : optionnel : coordonnée x d'un point dans le solide sain (pour orienter la face - idem avec y,z) + """ + logging.info("setParamShapeFissure %s", self.nomCas) + if self.dicoParams.has_key('pointInterieur'): + self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'], + rayonPipe = self.dicoParams['rayonPipe'], + lenSegPipe = self.lenSegPipe, + pointIn_x = self.dicoParams['pointInterieur'][0], + pointIn_y = self.dicoParams['pointInterieur'][1], + pointIn_z = self.dicoParams['pointInterieur'][2]) + else: + self.shapeFissureParams = dict(lgInfluence = self.dicoParams['lgInfluence'], + rayonPipe = self.dicoParams['rayonPipe'], + lenSegPipe = self.lenSegPipe) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + + lgInfluence = shapeFissureParams['lgInfluence'] + + shellFiss = geompy.ImportFile( self.dicoParams['brepFaceFissure'], "BREP") + fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(fondFiss, self.dicoParams['edgeFissIds'] ) + geompy.addToStudy( shellFiss, 'shellFiss' ) + geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' ) + + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, self.dicoParams['meshBrep'][0] ,self.dicoParams['meshBrep'][1]) + + centre = None + return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = self.dicoParams['nbSegRad'], + nbsegCercle = self.dicoParams['nbSegCercle'], + areteFaceFissure = self.dicoParams['areteFaceFissure']) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + if self.references is not None: + self.referencesMaillageFissure = self.references + else: + self.referencesMaillageFissure = dict(Entity_Quad_Pyramid = 0, + Entity_Quad_Triangle = 0, + Entity_Quad_Edge = 0, + Entity_Quad_Penta = 0, + Entity_Quad_Hexa = 0, + Entity_Node = 0, + Entity_Quad_Tetra = 0, + Entity_Quad_Quadrangle = 0) + diff --git a/src/Tools/blocFissure/exemple.py b/src/Tools/blocFissure/exemple.py new file mode 100644 index 000000000..f351d59c9 --- /dev/null +++ b/src/Tools/blocFissure/exemple.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import os +from blocFissure import gmu +from blocFissure.gmu import initLog +initLog.setDebug() +#initLog.setVerbose() + +from blocFissure.casStandard import casStandard + +dicoParams = dict(nomCas = 'angleCube', + maillageSain = os.path.join(gmu.pathBloc, 'materielCasTests/CubeAngle.med'), + brepFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"), + edgeFissIds = [4], + lgInfluence = 20, + meshBrep = (5,10), + rayonPipe = 5, + lenSegPipe = 2.5, + nbSegRad = 5, + nbSegCercle = 32, + areteFaceFissure = 10) + +execInstance = casStandard(dicoParams) diff --git a/src/Tools/blocFissure/exemple2.py b/src/Tools/blocFissure/exemple2.py new file mode 100644 index 000000000..c6d20eb27 --- /dev/null +++ b/src/Tools/blocFissure/exemple2.py @@ -0,0 +1,93 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.NoteBook(theStudy) + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Vertex_1 = geompy.MakeVertex(0, 0, 100) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 50) +Rotation_1 = geompy.MakeRotation(Box_1, OZ, 45*math.pi/180.0) +geompy.TranslateDXDYDZ(Rotation_1, -50, -250, 0) +Cut_1 = geompy.MakeCut(Disk_1, Rotation_1) +geompy.Export(Cut_1, "disk.brep", "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Cut_1, 'Cut_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +boite = smesh.Mesh(Box_1) +Regular_1D = boite.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(15) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = boite.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = boite.Hexahedron(algo=smeshBuilder.Hexa) +isDone = boite.Compute() +smesh.SetName(boite, 'boite') +boite.ExportMED( r'boite.med', 0, SMESH.MED_V2_2, 1 ) + +## set object names +smesh.SetName(boite.GetMesh(), 'boite') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') + +import os +from blocFissure import gmu +from blocFissure.gmu import initLog +#initLog.setDebug() +initLog.setVerbose() + +from blocFissure.casStandard import casStandard + +dicoParams = dict(nomCas = 'angleCube2', + maillageSain = 'boite.med', + brepFaceFissure = "disk.brep", + edgeFissIds = [4], + lgInfluence = 20, + meshBrep = (5,10), + rayonPipe = 10, + nbSegRad = 5, + nbSegCercle = 8, + areteFaceFissure = 10) + +execInstance = casStandard(dicoParams) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/gmu/CMakeLists.txt b/src/Tools/blocFissure/gmu/CMakeLists.txt new file mode 100644 index 000000000..6ab0809fe --- /dev/null +++ b/src/Tools/blocFissure/gmu/CMakeLists.txt @@ -0,0 +1,88 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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. +# +# 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 +# + +# --- scripts --- + +# scripts / static +SET(plugin_SCRIPTS + __init__.py + blocDefaut.py + checkDecoupePartition.py + commonSubShapes.py + creeZoneDefautDansObjetSain.py + creeZoneDefautFilling.py + creeZoneDefautGeom.py + creeZoneDefautMaillage.py + distance2.py + eliminateDoubles.py + ellipsoideDefaut.py + enleveDefaut.py + extractionOrienteeMulti.py + extractionOrientee.py + facesCirculaires.py + facesFissure.py + facesToreInBloc.py + facesVolumesToriques.py + findWireEndVertices.py + findWireIntermediateVertices.py + fissureCoude.py + fissureGenerique.py + genereElemsFissureElliptique.py + genereMeshCalculZoneDefaut.py + geomsmesh.py + getCentreFondFiss.py + getStatsMaillageFissure.py + getSubshapeIds.py + initEtude.py + initLog.py + insereFissureElliptique.py + insereFissureGenerale.py + insereFissureLongue.py + meshBlocPart.py + orderEdgesFromWire.py + partitionBlocDefaut.py + partitionVolumeSain.py + peauInterne.py + produitMixte.py + projettePointSurCourbe.py + prolongeVertices.py + prolongeWire.py + propagateTore.py + putName.py + quadranglesToShape.py + regroupeSainEtDefaut.py + rotTrans.py + shapesSurFissure.py + shapeSurFissure.py + sortEdges.py + sortFaces.py + sortGeneratrices.py + sortSolids.py + substractSubShapes.py + testgmu.py + toreFissure.py + triedreBase.py + whichSideMulti.py + whichSide.py + whichSideVertex.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure/gmu) diff --git a/src/Tools/blocFissure/gmu/__init__.py b/src/Tools/blocFissure/gmu/__init__.py new file mode 100644 index 000000000..728082fb2 --- /dev/null +++ b/src/Tools/blocFissure/gmu/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +import os +import initLog +#initLog.setDebug() +#initLog.setVerbose() +#initLog.setRelease() + +# --- calcul path blocFissure + +apath = initLog.__file__ +isabs = os.path.isabs(apath) +pathGmu = os.path.split(apath)[0] +if isabs: + pathBloc = os.path.join(pathGmu, '..') +else: + pathBloc = os.path.join(os.getcwd(), pathGmu, '..') +pathBloc = os.path.normpath(pathBloc) diff --git a/src/Tools/blocFissure/gmu/blocDefaut.py b/src/Tools/blocFissure/gmu/blocDefaut.py new file mode 100644 index 000000000..0e6875777 --- /dev/null +++ b/src/Tools/blocFissure/gmu/blocDefaut.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- bloc defaut + +def blocDefaut(blocDim): + """ + Le bloc contenant la fissure est un cube construit centre a l'origine, dont on donne la demi arete. + @param blocdim : demi arete + @return cube (geomObject) + """ + logging.info("start") + geomObj_1 = geompy.MakeVertex(-blocDim, -blocDim, -blocDim) + geomObj_2 = geompy.MakeVertex( blocDim, blocDim, blocDim) + Box = geompy.MakeBoxTwoPnt(geomObj_1, geomObj_2) + #geompy.addToStudy( Box_1, 'Box_1' ) + return Box diff --git a/src/Tools/blocFissure/gmu/checkDecoupePartition.py b/src/Tools/blocFissure/gmu/checkDecoupePartition.py new file mode 100644 index 000000000..e1fcf2be1 --- /dev/null +++ b/src/Tools/blocFissure/gmu/checkDecoupePartition.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- teste si l'opération de partition a produit une modification + +def checkDecoupePartition(shapes, part): + """ + Teste si l'opération de partition a produit une découpe + (plus de shapes dans la partition). + Résultat non garanti si recouvrement des shapes d'origine. + @param shapes : liste des shapes d'origine + @param part : résultat de la partition + @return True si la partition a découpé les shapes d'origine + """ + logging.info('start') + # TODO: ShapeInfo donne des résultats faux (deux faces au lieu de une) + + isPart = False + orig = {} + for shape in shapes: + info = geompy.ShapeInfo(shape) + logging.debug("shape info %s", info) + for k in ['VERTEX', 'EDGE', 'FACE', 'SOLID']: + if k in orig.keys(): + orig[k] += info[k] + else: + orig[k] = info[k] + logging.debug("original shapes info %s", orig) + info = geompy.ShapeInfo(part) + logging.debug("partition info %s", info) + for k in ['VERTEX', 'EDGE', 'FACE', 'SOLID']: + if orig[k] < info[k]: + isPart = True + break + logging.debug("partition modifie l'original %s", isPart) + + return isPart + diff --git a/src/Tools/blocFissure/gmu/commonSubShapes.py b/src/Tools/blocFissure/gmu/commonSubShapes.py new file mode 100644 index 000000000..1777ae89c --- /dev/null +++ b/src/Tools/blocFissure/gmu/commonSubShapes.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- subShapes communes à deux listes + +def commonSubShapes(obj, sub1, sub2): + """ + liste de subshapes communes + """ + logging.info("start") + idsub1 = {} + subList = [] + for s in sub1: + idsub1[geompy.GetSubShapeID(obj, s)] = s + for s in sub2: + idsub = geompy.GetSubShapeID(obj, s) + if idsub in idsub1.keys(): + subList.append(s) + logging.debug("subList=%s", subList) + return subList diff --git a/src/Tools/blocFissure/gmu/creeZoneDefautDansObjetSain.py b/src/Tools/blocFissure/gmu/creeZoneDefautDansObjetSain.py new file mode 100644 index 000000000..edd6855db --- /dev/null +++ b/src/Tools/blocFissure/gmu/creeZoneDefautDansObjetSain.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import smesh +import SMESH +import SALOMEDS + +from creeZoneDefautMaillage import creeZoneDefautMaillage +from peauInterne import peauInterne +from quadranglesToShape import quadranglesToShape +from creeZoneDefautFilling import creeZoneDefautFilling +from creeZoneDefautGeom import creeZoneDefautGeom +from getCentreFondFiss import getCentreFondFiss + +# ----------------------------------------------------------------------------- +# --- + +def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, + shapeFissureParams, maillageFissureParams): + """ + TODO: a compléter + """ + logging.info('start') + + #smesh.SetCurrentStudy(salome.myStudy) + + geometrieSaine = geometriesSaines[0] + maillageSain = maillagesSains[0] + isHexa = maillagesSains[1] + shapeDefaut = shapesFissure[0] + tailleDefaut = shapesFissure[2] + coordsNoeudsFissure = shapesFissure[3] + + isElliptique = False + if shapeFissureParams.has_key('elliptique'): + isElliptique = shapeFissureParams['elliptique'] + if isElliptique: + if shapeFissureParams.has_key('demiGrandAxe'): + demiGrandAxe = shapeFissureParams['demiGrandAxe'] + else: + demiGrandAxe = shapeFissureParams['longueur'] + lgExtrusion = 2.0*demiGrandAxe + else: + lgExtrusion = 50. + + nomRep = maillageFissureParams['nomRep'] + nomFicSain = maillageFissureParams['nomFicSain'] + + fichierMaillageSain = nomRep + '/' + nomFicSain + '.med' + + # --- centre de fond de fissure et tangente + + edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure) + + + # --- zone de défaut + nomZones = "zoneDefaut" + + [origShapes, verticesShapes, dmoyen] = \ + creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut, nomZones, coordsNoeudsFissure) + + maillageSain.ExportMED( fichierMaillageSain, 0, SMESH.MED_V2_2, 1 ) + logging.debug("fichier maillage sain %s", fichierMaillageSain) + [maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges] = \ + peauInterne(fichierMaillageSain, nomZones) + + facesDefaut = [] + centresDefaut = [] + normalsDefaut =[] + extrusionsDefaut = [] + isPlane = False + if isHexa and not isPlane: + meshQuad = smesh.CopyMesh( zoneDefaut_skin, 'meshQuad', 0, 0) + fillings, noeuds_bords, bordsPartages, fillconts, idFilToCont = quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss) + for filling in fillings: + [faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \ + creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion) + facesDefaut.append(faceDefaut) + centresDefaut.append(centreDefaut) + normalsDefaut.append(normalDefaut) + extrusionsDefaut.append(extrusionDefaut) + else: + [facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \ + creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion) + bordsPartages =[] + for face in facesDefaut: + bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ? + fillconts = facesDefaut + idFilToCont = range(len(facesDefaut)) + + return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, dmoyen, bordsPartages, fillconts, idFilToCont, + maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, + edgeFondExt, centreFondFiss, tgtCentre] + diff --git a/src/Tools/blocFissure/gmu/creeZoneDefautFilling.py b/src/Tools/blocFissure/gmu/creeZoneDefautFilling.py new file mode 100644 index 000000000..ed3229eb8 --- /dev/null +++ b/src/Tools/blocFissure/gmu/creeZoneDefautFilling.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- crée zone géométrique défaut a partir d'un filling + +def creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion=50): + """ + Construction CAO de la zone à remailler, quand on utilise un filling, + après appel creeZoneDefautMaillage et quadranglesToShape + @param filling : la CAO de la peau du défaut reconstituée + @param shapeDefaut : objet géométrique représentant la fissure + (selon les cas, un point central, ou une shape plus complexe, + dont on ne garde que les vertices) + @return (facesDefaut = filling, centreDefaut, normalDefaut, extrusionDefaut) + """ + logging.info("start") + + trace = True + facesDefaut = filling + centreSphere = geompy.MakeCDG(shapeDefaut) + geompy.addToStudy(centreSphere, "cdg_defaut") + centreDefaut = geompy.MakeProjection(centreSphere, filling) + if trace: + geompy.addToStudy(centreDefaut, "centreDefaut") + normalDefaut = geompy.GetNormal(filling, centreDefaut) + if trace: + geompy.addToStudy(normalDefaut, "normalDefaut") + extrusionDefaut = geompy.MakePrismVecH(filling, normalDefaut, -lgExtrusion) + if trace: + geompy.addToStudy(extrusionDefaut, "extrusionDefaut") + + return facesDefaut, centreDefaut, normalDefaut, extrusionDefaut diff --git a/src/Tools/blocFissure/gmu/creeZoneDefautGeom.py b/src/Tools/blocFissure/gmu/creeZoneDefautGeom.py new file mode 100644 index 000000000..9969c8d8c --- /dev/null +++ b/src/Tools/blocFissure/gmu/creeZoneDefautGeom.py @@ -0,0 +1,207 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +from prolongeVertices import prolongeVertices + +# ----------------------------------------------------------------------------- +# --- zone de defaut, constructions geometrique avec CAO d'origine + +def creeZoneDefautGeom(objetSain, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion=50): + """ + Construction CAO de la zone à remailler, quand on utilise la CAO d'origine, + apres appel creeZoneDefautMaillage + @param objetSain : la géometrie de l'objet initial + @param shapeDefaut : objet géometrique représentant la fissure + (selon les cas, un point central, ou une shape plus complexe, + dont on ne garde que les vertices) + @param origShapes : liste id subShapes + @param verticesShapes : listes noeuds de bord + @param dmoyen : longueur arete moyenne bord + @lgExtrusion : distance d'extrusion de la face du defaut + (ne vaut que pour des fissures courtes) + @return (facesDefaut, centreDefaut, normalDefaut, extrusionDefaut) + """ + logging.info("start") + + trace = True + faces = [] + curves = [] + cdgs = [] + projs = [] + normals = [] + extrusions = [] + partitions = [] + decoupes = [] + + for ishape, vertices in enumerate(verticesShapes): + aShape = origShapes[ishape] + [face] = geompy.SubShapes(objetSain, [aShape]) + faces.append(face) + curve = geompy.MakePolyline(vertices, False) + curves.append(curve) + if trace: + name="poly_%d"%aShape + geompy.addToStudy(curve, name) + # + cdg = geompy.MakeCDG(curve) + cdgs.append(cdg) + if trace: + name="cdgpoly_%d"%aShape + geompy.addToStudy(cdg, name) + # + projCdg = geompy.MakeProjection(cdg, face) + projs.append(projCdg) + if trace: + name="projCdg_%d"%aShape + geompy.addToStudy(projCdg, name) + # + normal = geompy.GetNormal(face, projCdg) + normals.append(normal) + if trace: + name="normal_%d"%aShape + geompy.addToStudy(normal, name) + # + extrusion = geompy.MakePrismVecH2Ways(curve, normal, 10) + extrusions.append(extrusion) + if trace: + name="extrusion_%d"%aShape + geompy.addToStudy(extrusion, name) + # + verticesProlongees = prolongeVertices(vertices) + # + curveprol = geompy.MakePolyline(verticesProlongees, False) + if trace: + name="polyProl_%d"%aShape + geompy.addToStudy(curveprol, name) + # + extruprol = geompy.MakePrismVecH2Ways(curveprol, normal, 10) + if trace: + name="extruProl_%d"%aShape + geompy.addToStudy(extruprol, name) + # + partition = geompy.MakePartition([face], [extruprol], [], [], geompy.ShapeType["FACE"], 0, [], 0) + partitions.append(partition) + if trace: + name="partition_%d"%aShape + geompy.addToStudy(partition, name) + pass + # + + centreSphere = geompy.MakeCDG(shapeDefaut) + geompy.addToStudy(centreSphere, "cdg_defaut") + ccurves = geompy.MakeCompound(curves) + gravCenter = geompy.MakeCDG(ccurves) + geompy.addToStudy(gravCenter, "cdg_curves") + for i in range(len(partitions)): + if trace: + logging.debug(" --- original shape %s", origShapes[i]) + dists = [] + facesToSort = [] + subFaces = geompy.ExtractShapes(partitions[i], geompy.ShapeType["FACE"], True) + for aFace in subFaces: + cdg = geompy.MakeCDG(aFace) + distance = geompy.MinDistance(cdg, centreSphere) + dists.append(distance) + facesToSort.append(aFace) + if trace: + logging.debug("distance = %s", distance) + pass + pass + if len(dists) > 0: + minDist = min(dists) + for j,d in enumerate(dists): + if d == minDist: + aFace = facesToSort[j] + name="decoupe_%d"%origShapes[i] + geompy.addToStudy(aFace, name) + decoupes.append(aFace) + break + pass + pass + + facesDefaut = decoupes[0] + if len(decoupes) > 1: + facesDefaut = geompy.MakePartition(decoupes, [], [], [], geompy.ShapeType["FACE"], 0, [], 0) + geompy.addToStudy(facesDefaut, "facesDefaut") + + shells=[] + if len(decoupes) > 1: # plusieurs faces de defaut + subFaces = geompy.ExtractShapes(facesDefaut, geompy.ShapeType["FACE"], True) + # --- regroupe les subFaces en shells connectes + theFaces = list(subFaces) # copy + while len(theFaces) > 0: + logging.debug("------- len(theFaces) %s" , len(theFaces)) + theFace = theFaces[0] + logging.debug(" start with face %s",theFaces[0]) + theFaces[0:1] = [] + aShell = [theFace] + toAdd =[theFace] + while len(toAdd) > 0: + toAdd = [] + toRemove = [] + for i in range(len(theFaces)): + logging.debug(" try %s", theFaces[i]) + for aFace in aShell: + logging.debug(" with %s", aFace) + try: + edge = geompy.GetSharedShapesMulti([aFace, theFaces[i]], geompy.ShapeType["EDGE"]) + edgeShared = True + except: + edgeShared = False + if edgeShared: + if theFaces[i] not in toAdd: + toAdd.append(theFaces[i]) + toRemove.append(i) + logging.debug(" --- add %s", theFaces[i]) + aShell += toAdd + for k in sorted(toRemove, reverse=True): + theFaces[k:k+1] = [] + theShell = geompy.MakeShell(aShell) + name = "theShell%d"%len(shells) + geompy.addToStudy(theShell,name) + shells.append(theShell) + # + distances = [] + for aShell in shells: # --- trouver le shell en contact avec la fissure + distances.append(geompy.MinDistance(aShell, shapeDefaut)) + minDist = min(distances) + for index in range(len(distances)): + if distances[index] == minDist: + break + theShellDefaut = shells[index] + # + else: # --- une seule face de defaut + subFaces = [facesDefaut] + theShellDefaut = geompy.MakeShell(subFaces) + if trace: + geompy.addToStudy(theShellDefaut,"theShellDefaut") + + theFaces = geompy.ExtractShapes(theShellDefaut, geompy.ShapeType["FACE"], True) + distances = [] + for aFace in theFaces: + distances.append(geompy.MinDistance(aFace, centreSphere)) + minDist = min(distances) + for index in range(len(distances)): + if distances[index] == minDist: + break + + centreDefaut = geompy.MakeProjection(centreSphere, theFaces[index]) + if trace: + geompy.addToStudy(centreDefaut, "centreDefaut") + normalDefaut = geompy.GetNormal(subFaces[index], centreDefaut) + if trace: + geompy.addToStudy(normalDefaut, "normalDefaut") + extrusionDefaut = geompy.MakePrismVecH(theShellDefaut, normalDefaut, -lgExtrusion) + info = geompy.ShapeInfo(extrusionDefaut) + logging.debug("shape info %s", info) + if (info['SOLID'] > 1) or (info['COMPOUND'] > 0) : + solids = geompy.ExtractShapes(extrusionDefaut, geompy.ShapeType["SOLID"], True) + solid0 = solids[0] + for i in range(1,len(solids)): + solid0 = geompy.MakeFuse(solid0, solids[i]) + extrusionDefaut = solid0 + if trace: + geompy.addToStudy(extrusionDefaut, "extrusionDefaut") + + return facesDefaut, centreDefaut, normalDefaut, extrusionDefaut diff --git a/src/Tools/blocFissure/gmu/creeZoneDefautMaillage.py b/src/Tools/blocFissure/gmu/creeZoneDefautMaillage.py new file mode 100644 index 000000000..9fcb7d58e --- /dev/null +++ b/src/Tools/blocFissure/gmu/creeZoneDefautMaillage.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +import math +from distance2 import distance2 + +# ----------------------------------------------------------------------------- +# --- zone de defaut extraite du maillage + +def creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut, + nomZones, coordsNoeudsFissure): + """ + Identification de la zone à remailler, opérations sur le maillage + de l'objet sain + La zone à remailler est définie à partir d'un objet géométrique + ou à partir d'un jeu de points et d'une distance d'influence. + @param maillagesSains : (le maillage de l'objet initial, booleen isHexa) + @param shapeDefaut : objet géométrique représentant la fissure + (selon les cas, un point central, ou une shape plus complexe, + dont on ne garde que les vertices) + @param tailleDefaut : distance d'influence définissant la zone à remailler: + tous les éléments du maillage initial qui pénètrent dans cette zone + sont détectés + @param nomZones : préfixe des noms de groupes créés dans le maillage initial. S'il y a un groupe de noeuds + @coordsNoeudsFissure : jeu de points donné par une liste (x1,y1,z1, x2,y2,z2, ...) + @return (origShapes, verticesShapes, dmoyen) liste id subShapes, + listes noeuds de bord, longueur arête moyenne bord + """ + logging.info("start") + + maillageSain = maillagesSains[0] + isHexa = maillagesSains[1] + lists = maillageSain.CreateHoleSkin(tailleDefaut, shapeDefaut, nomZones, coordsNoeudsFissure) + + logging.debug("lists=%s", lists) + + trace = True + origShapes = [] + verticesShapes = [] + + cumul = 0 # somme des distances carrées entre point ordonnés (taille des arêtes) + nb = 0 # nombre d'arêtes évaluées + + for aList in lists: + aShape = aList[0] + origShapes.append(aShape) + logging.debug(" shapeId %s", aShape) + vertices = [] + xyz0 = None + for inode in range(1, len(aList)): + xyz = maillageSain.GetNodeXYZ(aList[inode]) + if xyz0 is not None: + cumul += distance2(xyz, xyz0) + nb += 1 + xyz0 = xyz + #logging.debug(" node %s %s", aList[inode], xyz) + vertices.append(geompy.MakeVertex(xyz[0], xyz[1], xyz[2])) + pass + verticesShapes.append(vertices) + pass + + dmoyen = math.sqrt(cumul/nb) # ~ taille de l'arête moyenne du maillage global + return origShapes, verticesShapes, dmoyen diff --git a/src/Tools/blocFissure/gmu/distance2.py b/src/Tools/blocFissure/gmu/distance2.py new file mode 100644 index 000000000..acdbbdcea --- /dev/null +++ b/src/Tools/blocFissure/gmu/distance2.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +import logging + +# ----------------------------------------------------------------------------- +# --- calcul de distance carree entre deux points, jeux de coordonnees x,y,z + +def distance2(xyz1, xyz2): + """ + carré de la distance entre deux points donnés par des triplets [x,y,z] + """ + #logging.info("start") + + d2 = 0 + for i in range(3): + d2 += (xyz1[i]-xyz2[i])*(xyz1[i]-xyz2[i]) + logging.debug('d2=%s', d2) + return d2 + +# ----------------------------------------------------------------------------- +# --- test unitaire + +import unittest +class Test_distance2(unittest.TestCase): + + def setUp(self): + self.a=[0, 0, 0] + self.b=[3, 4, 5] + self.c=[-5,-4,-3] + + def test_calcul(self): + self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a)) + self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c)) + self.assertEqual(distance2(self.b, self.b), 0) + self.assertEqual(distance2(self.a, self.b), 50) + \ No newline at end of file diff --git a/src/Tools/blocFissure/gmu/eliminateDoubles.py b/src/Tools/blocFissure/gmu/eliminateDoubles.py new file mode 100644 index 000000000..b9e2e6c1d --- /dev/null +++ b/src/Tools/blocFissure/gmu/eliminateDoubles.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- éliminer les doublons d'une liste de subshapes + +def eliminateDoubles(obj, subshapes): + """ + éliminer les doublons d'une liste de subshapes + """ + idsubs = {} + for sub in subshapes: + subid = geompy.GetSubShapeID(obj, sub) + if subid in idsubs.keys(): + idsubs[subid].append(sub) + else: + idsubs[subid] = [sub] + shortList = [] + for k, v in idsubs.iteritems(): + shortList.append(v[0]) + logging.debug("shortList=%s", shortList) + return shortList diff --git a/src/Tools/blocFissure/gmu/ellipsoideDefaut.py b/src/Tools/blocFissure/gmu/ellipsoideDefaut.py new file mode 100644 index 000000000..3940d57ca --- /dev/null +++ b/src/Tools/blocFissure/gmu/ellipsoideDefaut.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import logging +import math +from geomsmesh import geompy +from triedreBase import triedreBase +O, OX, OY, OZ = triedreBase() + +# ----------------------------------------------------------------------------- +# --- ellipsoide defaut + +def ellipsoideDefaut(minRad,allonge,rayTore): + """ + Le bloc contenant la fissure est un ellipsoide construit centre a l'origine, + contenant le tore elliptique de fissure + @param minRad :petit rayon + @param allonge :rapport grand rayon / petit rayon + @param rayTore :rayon du tore construit autour de la generatrice de l'ellipse + @return ellipsoide (geomObject) + """ + logging.info("start") + boule = geompy.MakeSphereR(2) + bouler = geompy.MakeRotation(boule, OY, math.pi/2.0) + face = geompy.MakeFaceHW(100, 100, 3) + boulepart = geompy.MakePartition([bouler], [face], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + solids = geompy.ExtractShapes(boulepart, geompy.ShapeType["SOLID"], True) + solid0 = solids[0] + for i in range(1,len(solids)): + solid0 = geompy.MakeFuse(solid0, solids[i]) + ellipsoide = geompy.MakeScaleAlongAxes(solid0, O, minRad, minRad*(allonge+2.0)/2.0, minRad) # on limite l'allongement de l'ellipsoide + #geompy.addToStudy( ellipsoide, 'ellipsoide' ) + return ellipsoide diff --git a/src/Tools/blocFissure/gmu/enleveDefaut.py b/src/Tools/blocFissure/gmu/enleveDefaut.py new file mode 100644 index 000000000..011c76485 --- /dev/null +++ b/src/Tools/blocFissure/gmu/enleveDefaut.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +import logging + +# ----------------------------------------------------------------------------- +# --- maillage sain sans la zone defaut + +def enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges): + """ + Maillage sain sans la zone de defaut + TODO: a completer + """ + logging.info('start') + + maillageSain.RemoveGroupWithContents(zoneDefaut) + if zoneDefaut_skin is not None: + maillageSain.RemoveGroupWithContents(zoneDefaut_skin) + if zoneDefaut_internalFaces is not None: + maillageSain.RemoveGroupWithContents(zoneDefaut_internalFaces) + if zoneDefaut_internalEdges is not None: + maillageSain.RemoveGroupWithContents(zoneDefaut_internalEdges) + nbRemoved = maillageSain.RemoveOrphanNodes() + return maillageSain + diff --git a/src/Tools/blocFissure/gmu/extractionOrientee.py b/src/Tools/blocFissure/gmu/extractionOrientee.py new file mode 100644 index 000000000..2ea9e52f9 --- /dev/null +++ b/src/Tools/blocFissure/gmu/extractionOrientee.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +from whichSide import whichSide + +# ----------------------------------------------------------------------------- +# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face. + +def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""): + """ + renvoie l'extraction des shapes d'un objet selon leur position + par rapport à la face. + shapeType in ["VERTEX", "EDGE", "FACE",...] + """ + logging.info('start') + trace = True + sideRef = whichSide(face, ref) + logging.debug("ref side %s", sideRef) + shapesInside = [] + shapesOutside = [] + shapesOnside = [] + shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False) + i=0 + j=0 + k=0 + prefix = prefix + shapeType + for shape in shapes: + side = whichSide(face, shape, tol) + if side == sideRef: + shapesInside.append(shape) + if trace: + name = prefix + "_Inside%d"%i + geompy.addToStudyInFather(obj, shape, name) + i+=1 + elif side == -sideRef: + shapesOutside.append(shape) + if trace: + name = prefix + "_Outside%d"%j + geompy.addToStudyInFather(obj, shape, name) + j+=1 + elif side == 0: + shapesOnside.append(shape) + if trace: + name = prefix + "_Onside%d"%k + geompy.addToStudyInFather(obj, shape, name) + k+=1 + logging.debug("--- shape was %s", name) + return [shapesInside, shapesOutside, shapesOnside] + diff --git a/src/Tools/blocFissure/gmu/extractionOrienteeMulti.py b/src/Tools/blocFissure/gmu/extractionOrienteeMulti.py new file mode 100644 index 000000000..86faec83d --- /dev/null +++ b/src/Tools/blocFissure/gmu/extractionOrienteeMulti.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +from whichSideMulti import whichSideMulti + +# ----------------------------------------------------------------------------- +# --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face. + +def extractionOrienteeMulti(faces, ifil, obj, centre, shapeType, tol, prefix=""): + """ + renvoie l'extraction des shapes d'un objet selon leur position + par rapport aux faces. + shapeType in ["VERTEX", "EDGE", "FACE",...] + """ + logging.info('start') + trace = True + shapesInside = [] + shapesOutside = [] + shapesOnside = [] + shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False) + i=0 + j=0 + k=0 + prefix = prefix + shapeType + for shape in shapes: + side = whichSideMulti(faces, ifil, shape, centre, tol) + if side == 1: + shapesInside.append(shape) + if trace: + name = prefix + "_Inside%d"%i + geompy.addToStudyInFather(obj, shape, name) + i+=1 + elif side == -1: + shapesOutside.append(shape) + if trace: + name = prefix + "_Outside%d"%j + geompy.addToStudyInFather(obj, shape, name) + j+=1 + elif side == 0: + shapesOnside.append(shape) + if trace: + name = prefix + "_Onside%d"%k + geompy.addToStudyInFather(obj, shape, name) + k+=1 + logging.debug("--- shape was %s", name) + return [shapesInside, shapesOutside, shapesOnside] + diff --git a/src/Tools/blocFissure/gmu/facesCirculaires.py b/src/Tools/blocFissure/gmu/facesCirculaires.py new file mode 100644 index 000000000..daca717f2 --- /dev/null +++ b/src/Tools/blocFissure/gmu/facesCirculaires.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- TORE +## --- faces 1/2 circulaires et leur centre, edges de ces faces dans le plan de fissure + +def facesCirculaires(bloc, tore): + """ + Extraction des faces demi circulaires à l'intersection du tore partitionné et de la paroi, + de leur centre, les edges de ces faces situees dans le plan de fissure et un booleen par edge, + indiquant son sens (normal / reversed). + @param bloc : bloc defaut + @param tore : le tore partitionné et coupé + @return (faces, centres, edges, reverses) + """ + logging.info("start") + + faces = geompy.GetShapesOnShape(bloc, tore, geompy.ShapeType["FACE"], GEOM.ST_ON) + + geompy.addToStudyInFather( tore, faces[0], 'face0' ) + geompy.addToStudyInFather( tore, faces[1], 'face1' ) + geompy.addToStudyInFather( tore, faces[2], 'face2' ) + geompy.addToStudyInFather( tore, faces[3], 'face3' ) + + centres = [None, None, None, None] + [v1,centres[0],v3] = geompy.ExtractShapes(faces[0], geompy.ShapeType["VERTEX"], True) + [v1,centres[1],v3] = geompy.ExtractShapes(faces[1], geompy.ShapeType["VERTEX"], True) + [v1,centres[2],v3] = geompy.ExtractShapes(faces[2], geompy.ShapeType["VERTEX"], True) + [v1,centres[3],v3] = geompy.ExtractShapes(faces[3], geompy.ShapeType["VERTEX"], True) + + geompy.addToStudyInFather( faces[0], centres[0], 'centre0' ) + geompy.addToStudyInFather( faces[1], centres[1], 'centre1' ) + geompy.addToStudyInFather( faces[2], centres[2], 'centre2' ) + geompy.addToStudyInFather( faces[3], centres[3], 'centre3' ) + + alledges = [None, None, None, None] + alledges[0] = geompy.ExtractShapes(faces[0], geompy.ShapeType["EDGE"], True) + alledges[1] = geompy.ExtractShapes(faces[1], geompy.ShapeType["EDGE"], True) + alledges[2] = geompy.ExtractShapes(faces[2], geompy.ShapeType["EDGE"], True) + alledges[3] = geompy.ExtractShapes(faces[3], geompy.ShapeType["EDGE"], True) + + dicoedge = {} + edges = [] + reverses = [] + for i in range(len(alledges)): + edgesface = alledges[i] + lenef = [] + for j in range(len(edgesface)): + props = geompy.BasicProperties(edgesface[j]) + lenef.append(props[0]) + pass + maxlen = max(lenef) + for j in range(len(edgesface)): + if lenef[j] < maxlen: + edgid = geompy.GetSubShapeID(tore, edgesface[j]) + if not (edgid in dicoedge): + dicoedge[edgid] = edgesface[j] + edges.append(edgesface[j]) + named = 'edge_' + str(i) + '_' +str(j) + geompy.addToStudyInFather( faces[i], edgesface[j], named) + vertices = geompy.ExtractShapes(edgesface[j], geompy.ShapeType["VERTEX"], False) + #firstVertex = geompy.GetFirstVertex(edgesface[j]) + if geompy.GetSubShapeID(tore, vertices[0]) != geompy.GetSubShapeID(tore, centres[i]): + reverses.append(1) + #print 'reversed ' + str(edgid) + else: + reverses.append(0) + #print 'normal' + str(edgid) + pass + pass + pass + pass + + return faces, centres, edges, reverses + diff --git a/src/Tools/blocFissure/gmu/facesFissure.py b/src/Tools/blocFissure/gmu/facesFissure.py new file mode 100644 index 000000000..1cbf8cea4 --- /dev/null +++ b/src/Tools/blocFissure/gmu/facesFissure.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- faces fissure dans et hors tore, et edges face hors tore + +def facesFissure(blocp, faceFissure, extrusionDefaut, genint): + """ + extraction des faces de fissure dans et hors tore, des edges le long du tore et en paroi + @param faceFissure : la face de fissure avec la partie dans le tore elliptique et la partie externe + @return (facefissintore, facefissoutore, edgeint, edgeext) + """ + logging.info('start') + + [f0,f1] = geompy.ExtractShapes(faceFissure, geompy.ShapeType["FACE"], True) + ed0 = geompy.ExtractShapes(f0, geompy.ShapeType["EDGE"], True) + ed1 = geompy.ExtractShapes(f1, geompy.ShapeType["EDGE"], True) + if len(ed0) > len(ed1): + facefissintore = f0 + facefissoutore = f1 + else: + facefissintore = f1 + facefissoutore = f0 + + geompy.addToStudyInFather(faceFissure, facefissintore,'facefissintore') + geompy.addToStudyInFather(faceFissure, facefissoutore,'facefissoutore') + + edgeint = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_IN) + edgeext = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_ON) + + for i in range(len(edgeint)): + name = "edgeint_%d"%i + geompy.addToStudyInFather(facefissoutore, edgeint[i],name) + for i in range(len(edgeext)): + name = "edgeext_%d"%i + geompy.addToStudyInFather(facefissoutore, edgeext[i],name) + + reverext = [] + if len(edgeext) > 1: + vertices = geompy.ExtractShapes(genint, geompy.ShapeType["VERTEX"], False) + for i in range(len(edgeext)): + vertedge = geompy.ExtractShapes(edgeext[i], geompy.ShapeType["VERTEX"], False) + if ((geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[0])) or + (geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[1]))): + reverext.append(0) + else: + reverext.append(1) + + return facefissintore, facefissoutore, edgeint, edgeext, reverext diff --git a/src/Tools/blocFissure/gmu/facesToreInBloc.py b/src/Tools/blocFissure/gmu/facesToreInBloc.py new file mode 100644 index 000000000..043155426 --- /dev/null +++ b/src/Tools/blocFissure/gmu/facesToreInBloc.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- identification des faces tore et fissure dans le solide hors tore du bloc partitionné + +def facesToreInBloc(blocp, facefissoutore, facetore1, facetore2): + """ + identification des faces tore et fissure dans le bloc partitionné : sous shapes du bloc + @param blocp : bloc partitionné + @param facefissoutore : la face de fissure externe au tore + @param facetore1 : face du tore selon la génératrice + @param facetore2 : face du tore selon la génératrice + @return (blocFaceFiss, blocFaceTore1, blocFaceTore2) sous shapes reperées + """ + logging.info('start') + + blocFaceFiss = geompy.GetInPlaceByHistory(blocp, facefissoutore) + blocFaceTore1 = geompy.GetInPlaceByHistory(blocp, facetore1) + blocFaceTore2 = geompy.GetInPlaceByHistory(blocp, facetore2) + + geompy.addToStudyInFather(blocp, blocFaceFiss,'blocFaceFiss') + geompy.addToStudyInFather(blocp, blocFaceTore1,'blocFaceTore1') + geompy.addToStudyInFather(blocp, blocFaceTore2,'blocFaceTore2') + + return blocFaceFiss, blocFaceTore1, blocFaceTore2 + diff --git a/src/Tools/blocFissure/gmu/facesVolumesToriques.py b/src/Tools/blocFissure/gmu/facesVolumesToriques.py new file mode 100644 index 000000000..2ad4dc6e7 --- /dev/null +++ b/src/Tools/blocFissure/gmu/facesVolumesToriques.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +from extractionOrientee import extractionOrientee +from getSubshapeIds import getSubshapeIds + +# ----------------------------------------------------------------------------- +# --- TORE +# --- faces toriques et volumes du tore + +def facesVolumesToriques(tore, plan, facesDefaut): + """ + Extraction des deux faces et volumes du tore partitionné, qui suivent la génératrice elliptique. + @param tore : le tore partitionné et coupé. + @param plan : le plan de coupe + @return (facetore1,facetore2) les 2 faces selon la génératrice + """ + logging.info("start") + + centre = geompy.MakeVertexOnSurface(plan, 0.5, 0.5) + normal = geompy.GetNormal(plan, centre) + reference = geompy.MakeTranslationVector(centre, normal) + + [facesInPlan, facesOutPlan, facesOnPlan] = extractionOrientee(plan, tore, reference, "FACE", 1.e-2, "faceTorePlan_") + [facesInSide, facesOutSide, facesOnSide] = extractionOrientee(facesDefaut, tore, reference, "FACE", 1.e-2, "faceTorePeau_") + facesIdInPlan = getSubshapeIds(tore, facesInPlan) + facesIdOutPlan = getSubshapeIds(tore, facesOutPlan) + facesIdOnSide = getSubshapeIds(tore, facesOnSide) + facesIdInSide = getSubshapeIds(tore, facesInSide) + facesIdOutSide = getSubshapeIds(tore, facesOutSide) + #facesIdInOutSide = facesIdInSide + facesIdOutSide + facetore1 = None + faceTore2 = None + for i, faceId in enumerate(facesIdInPlan): + if faceId not in facesIdOnSide: + facetore1 = facesInPlan[i] + 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) + + geompy.addToStudyInFather( tore, facetore1, 'facetore1' ) + geompy.addToStudyInFather( tore, facetore2, 'facetore2' ) + + [volumeTore1, volumeTore2] = geompy.ExtractShapes(tore, geompy.ShapeType["SOLID"], True) + geompy.addToStudyInFather( tore, volumeTore1, 'volumeTore1' ) + geompy.addToStudyInFather( tore, volumeTore2, 'volumeTore2' ) + + return facetore1, facetore2, volumeTore1, volumeTore2 diff --git a/src/Tools/blocFissure/gmu/findWireEndVertices.py b/src/Tools/blocFissure/gmu/findWireEndVertices.py new file mode 100644 index 000000000..1196e28bd --- /dev/null +++ b/src/Tools/blocFissure/gmu/findWireEndVertices.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- trouver les vertices extremites d'un wire + +def findWireEndVertices(aWire, getNormals=False): + """ + trouver les vertices extremites d'un wire + calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001) + """ + logging.info("start") + if geompy.NumberOfEdges(aWire) > 1: + edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) + else: + edges = [aWire] + vertices = [] + idsubs = {} + shortList = [] + if getNormals: + normals = [] + idnorm = {} + shortNorm = [] + for edge in edges: + vert = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False) + vertices += vert + if getNormals: + v0 = geompy.MakeVertexOnCurve(edge, 0.0) + n0 = geompy.MakeTangentOnCurve(edge, 0.0) + v1 = geompy.MakeVertexOnCurve(edge, 1.0) + n1 = geompy.MakeTangentOnCurve(edge, 1.0) + dist = geompy.MinDistance(v0, vert[0]) + logging.debug("distance %s", dist) + if dist < 1.e-2: + normals += [n0, n1] + else: + normals += [n1, n0] + for i, sub in enumerate(vertices): + subid = geompy.GetSubShapeID(aWire, sub) + if subid in idsubs.keys(): + idsubs[subid].append(sub) + else: + idsubs[subid] = [sub] + name='vertex%d'%i + geompy.addToStudyInFather(aWire, sub, name) + if getNormals: + idnorm[subid] = normals[i] + name='norm%d'%i + geompy.addToStudyInFather(aWire, normals[i], name) + logging.debug("idsubs: %s", idsubs) + for k, v in idsubs.iteritems(): + if len(v) == 1: + shortList.append(v[0]) + if getNormals: + shortNorm.append(idnorm[k]) + if getNormals: + return shortList, shortNorm + else: + return shortList + diff --git a/src/Tools/blocFissure/gmu/findWireIntermediateVertices.py b/src/Tools/blocFissure/gmu/findWireIntermediateVertices.py new file mode 100644 index 000000000..3b8b40591 --- /dev/null +++ b/src/Tools/blocFissure/gmu/findWireIntermediateVertices.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- trouver les vertices intermediaires d'un wire + +def findWireIntermediateVertices(aWire, getNormals=False): + """ + trouver les vertices d'un wire qui ne sont pas aux extremités + calcul optionnel des tangentes. Attention à la tolérance qui peut être élevée (> 0.001) + """ + logging.info("start") + edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) + vertices = [] + idsubs = {} + shortList = [] + if getNormals: + normals = [] + idnorm = {} + shortNorm = [] + for edge in edges: + vert = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False) + vertices += vert + if getNormals: + v0 = geompy.MakeVertexOnCurve(edge, 0.0) + n0 = geompy.MakeTangentOnCurve(edge, 0.0) + v1 = geompy.MakeVertexOnCurve(edge, 1.0) + n1 = geompy.MakeTangentOnCurve(edge, 1.0) + dist = geompy.MinDistance(v0, vert[0]) + logging.debug("distance %s", dist) + if dist < 1.e-2: + normals += [n0, n1] + else: + normals += [n1, n0] + for i, sub in enumerate(vertices): + subid = geompy.GetSubShapeID(aWire, sub) + if subid in idsubs.keys(): + idsubs[subid].append(sub) + else: + idsubs[subid] = [sub] + name='vertex%d'%i + geompy.addToStudyInFather(aWire, sub, name) + if getNormals: + idnorm[subid] = normals[i] + name='norm%d'%i + geompy.addToStudyInFather(aWire, normals[i], name) + for k, v in idsubs.iteritems(): + if len(v) > 1: + shortList.append(v[0]) + if getNormals: + shortNorm.append(idnorm[k]) + if getNormals: + return shortList, shortNorm + else: + return shortList + diff --git a/src/Tools/blocFissure/gmu/fissureCoude.py b/src/Tools/blocFissure/gmu/fissureCoude.py new file mode 100644 index 000000000..0490611aa --- /dev/null +++ b/src/Tools/blocFissure/gmu/fissureCoude.py @@ -0,0 +1,669 @@ +# -*- coding: utf-8 -*- + +from geomsmesh import geompy, smesh + +import math +import GEOM +import SALOMEDS +import SMESH +#import StdMeshers +#import GHS3DPlugin +#import NETGENPlugin +import logging + +from fissureGenerique import fissureGenerique + +from triedreBase import triedreBase +from genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut +from creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain +from insereFissureGenerale import insereFissureGenerale +from sortEdges import sortEdges + +O, OX, OY, OZ = triedreBase() + +class fissureCoude(fissureGenerique): + """ + problème de fissure du Coude : version de base + maillage hexa + """ + + nomProbleme = "tuyau_Coude" + + # --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = 60, + r_cintr = 1200, + l_tube_p1 = 1600, + l_tube_p2 = 1200, + epais = 40, + de = 760) + + # --------------------------------------------------------------------------- + def genereGeometrieSaine(self, geomParams): + logging.info("genereGeometrieSaine %s", self.nomCas) + + angleCoude = geomParams['angleCoude'] + r_cintr = geomParams['r_cintr'] + l_tube_p1 = geomParams['l_tube_p1'] + l_tube_p2 = geomParams['l_tube_p2'] + epais = geomParams['epais'] + de = geomParams['de'] + + centre = geompy.MakeVertex(0, 0, -l_tube_p1) + diskext = geompy.MakeDiskPntVecR(centre, OZ, de/2.) + diskint = geompy.MakeDiskPntVecR(centre, OZ, de/2. -epais) + couronne = geompy.MakeCut(diskext, diskint) + tube_1 = geompy.MakePrismVecH(couronne, OZ, l_tube_p1) + axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1) + coude = geompy.MakeRevolution(couronne, axe, angleCoude*math.pi/180.0) + Rotation_1 = geompy.MakeRotation(couronne, axe, angleCoude*math.pi/180.0) + Rotation_2 = geompy.MakeRotation(OZ, OY, angleCoude*math.pi/180.0) + tube_2 = geompy.MakePrismVecH(Rotation_1, Rotation_2, -l_tube_p2) + plan_y = geompy.MakePlaneLCS(None, 100000, 3) + geompy.addToStudy( plan_y, "plan_y" ) + geompy.addToStudy( tube_1, "tube_1" ) + geompy.addToStudy( coude, "coude" ) + geompy.addToStudy( tube_2, "tube_2" ) + + P1 = O + geompy.addToStudy( P1, "P1" ) + op2 = geompy.MakeVertex(0, 0, -l_tube_p1) + P2 = geompy.MakeRotation(op2, axe, angleCoude*math.pi/180.0) + P2 = geompy.MakeTranslationVectorDistance(P2, Rotation_2, -l_tube_p2) + geompy.addToStudy( P2, "P2" ) + + # --- tube coude sain + + geometrieSaine = geompy.MakePartition([tube_1, coude, tube_2, P1, P2], [plan_y], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + geompy.addToStudy( geometrieSaine, self.nomCas ) + [P1, P2] = geompy.RestoreGivenSubShapes(geometrieSaine, [P1, P2], GEOM.FSM_GetInPlaceByHistory, False, True) + + xmin = -de -r_cintr -l_tube_p2 + zmin = -l_tube_p1 -r_cintr -l_tube_p2 -de + ymax = de +100. + boxypos = geompy.MakeBox(xmin, 0, zmin, ymax, ymax, 100, "boxypos") + boxyneg = geompy.MakeBox(xmin, 0, zmin, ymax, -ymax, 100, "boxyneg") + edgesypos = geompy.GetShapesOnShape(boxypos, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_IN) + edgesyneg = geompy.GetShapesOnShape(boxyneg, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_IN) + circ_g = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(circ_g, edgesyneg) + circ_d = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(circ_d, edgesypos) + edgesy0pos = geompy.GetShapesOnShape(boxypos, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_ONIN) + grpedpos = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(grpedpos, edgesy0pos) + grpedy0 = geompy.CutGroups(grpedpos, circ_d, "edges_y0") + boxtub1 = geompy.MakeBox(-de/2.0 -1, -1, -l_tube_p1, de, de, 0, "boxtub1") + edgestub1 = geompy.GetShapesOnShape(boxtub1, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_IN) + grped = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(grped, edgestub1) + long_p1 = geompy.IntersectGroups(grped, grpedy0) + boxtub = geompy.MakeBox(-de/2.0 -1, -1, -l_tube_p1 -l_tube_p2, de, de, -l_tube_p1) + boxtub2 = geompy.MakeRotation(boxtub, axe, angleCoude*math.pi/180.0, "boxttub2") + edgestub2 = geompy.GetShapesOnShape(boxtub2, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_IN) + grped = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(grped, edgestub2) + long_p2 = geompy.IntersectGroups(grped, grpedy0) + boxtub1t = geompy.MakeTranslationVectorDistance(boxtub1, OZ, -l_tube_p1) + facer = geompy.GetShapesOnShape(boxtub1t, boxtub1, geompy.ShapeType["FACE"], GEOM.ST_ONIN, "facer") + boxcoud = geompy.MakeRevolution(facer[0], axe, angleCoude*math.pi/180.0, "boxcoud") + edgescoud = geompy.GetShapesOnShape(boxcoud, geometrieSaine, geompy.ShapeType["EDGE"], GEOM.ST_IN) + grped = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionList(grped, edgescoud) + long_coude = geompy.IntersectGroups(grped, grpedy0) + grped = geompy.CutGroups(grpedy0, long_p1) + grped = geompy.CutGroups(grped, long_p2) + ep = geompy.CutGroups(grped, long_coude) + geompy.addToStudyInFather( geometrieSaine, long_p1, 'long_p1' ) + geompy.addToStudyInFather( geometrieSaine, ep, 'ep' ) + geompy.addToStudyInFather( geometrieSaine, long_coude, 'long_coude' ) + geompy.addToStudyInFather( geometrieSaine, circ_g, 'circ_g' ) + geompy.addToStudyInFather( geometrieSaine, circ_d, 'circ_d' ) + geompy.addToStudyInFather( geometrieSaine, long_p2, 'long_p2' ) + + # --- face extremite tube (EXTUBE) + + facesIds = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["FACE"], OZ, GEOM.ST_ON) + EXTUBE = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(EXTUBE, facesIds) + geompy.addToStudyInFather( geometrieSaine, EXTUBE, 'EXTUBE' ) + + # --- edge bord extremite tube (BORDTU) + + edge1Ids = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["EDGE"], OZ, GEOM.ST_ON) + edge2Ids = geompy.GetShapesOnCylinderIDs(geometrieSaine, geompy.ShapeType["EDGE"], OZ, de/2. -epais, GEOM.ST_ON) + edgesIds = [] + for edge in edge1Ids: + if edge in edge2Ids: + edgesIds.append(edge) + BORDTU = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(BORDTU, edgesIds) + geompy.addToStudyInFather( geometrieSaine, BORDTU, 'BORDTU' ) + + # --- face origine tube (CLGV) + + pp2 = geompy.MakeTranslationVectorDistance(P2, Rotation_2, 10) + vec2 = geompy.MakeVector(P2, pp2) + #geompy.addToStudy(vec2, 'vec2') + facesIds = geompy.GetShapesOnPlaneIDs(geometrieSaine, geompy.ShapeType["FACE"], vec2, GEOM.ST_ON) + CLGV = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(CLGV, facesIds) + geompy.addToStudyInFather( geometrieSaine, CLGV, 'CLGV' ) + + # --- peau tube interieur (PEAUINT) + + extru1 = geompy.MakePrismVecH(diskint, OZ, l_tube_p1) + revol1 = geompy.MakeRevolution(diskint, axe, angleCoude*math.pi/180.0) + rot1 = geompy.MakeRotation(diskint, axe, angleCoude*math.pi/180.0) + extru2 = geompy.MakePrismVecH(rot1, Rotation_2, -l_tube_p2) + interne = geompy.MakeFuse(extru1, revol1) + interne = geompy.MakeFuse(extru2, interne) + geompy.addToStudy(interne, 'interne') + facesIds = geompy.GetShapesOnShapeIDs(interne, geometrieSaine, geompy.ShapeType["FACE"], GEOM.ST_ONIN) + PEAUINT = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(PEAUINT, facesIds) + geompy.addToStudyInFather( geometrieSaine, PEAUINT, 'PEAUINT' ) + + # --- peau tube exterieur (PEAUEXT) + + cercle1 = geompy.MakeCircle(centre, OZ, de/2.) + extru1 = geompy.MakePrismVecH(cercle1, OZ, l_tube_p1) + revol1 = geompy.MakeRevolution(cercle1, axe, angleCoude*math.pi/180.0) + rot1 = geompy.MakeRotation(cercle1, axe, angleCoude*math.pi/180.0) + extru2 = geompy.MakePrismVecH(rot1, Rotation_2, -l_tube_p2) + externe = geompy.MakeFuse(extru1, revol1) + externe = geompy.MakeFuse(extru2, externe) + geompy.addToStudy(externe, 'externe') + facesIds = geompy.GetShapesOnShapeIDs(externe, geometrieSaine, geompy.ShapeType["FACE"], GEOM.ST_ON) + PEAUEXT = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["FACE"]) + geompy.UnionIDs(PEAUEXT, facesIds) + geompy.addToStudyInFather( geometrieSaine, PEAUEXT, 'PEAUEXT' ) + + # --- solide sain + + volIds = geompy.SubShapeAllIDs(geometrieSaine, geompy.ShapeType["SOLID"]) + COUDE = geompy.CreateGroup(geometrieSaine, geompy.ShapeType["SOLID"]) + geompy.UnionIDs(COUDE, volIds) + geompy.addToStudyInFather( geometrieSaine, COUDE, 'COUDSAIN' ) + + geometriesSaines = [geometrieSaine, long_p1, ep, long_coude, circ_g, circ_d, long_p2, P1, P2, EXTUBE, BORDTU, CLGV, PEAUINT, PEAUEXT, COUDE] + + return geometriesSaines + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = 16, + n_ep = 3, + n_long_coude = 15, + n_circ_g = 20, + n_circ_d = 20, + n_long_p2 = 12) + + # --------------------------------------------------------------------------- + def genereMaillageSain(self, geometriesSaines, meshParams): + logging.info("genereMaillageSain %s", self.nomCas) + + geometrieSaine = geometriesSaines[0] + long_p1 = geometriesSaines[1] + ep = geometriesSaines[2] + long_coude = geometriesSaines[3] + circ_g = geometriesSaines[4] + circ_d = geometriesSaines[5] + long_p2 = geometriesSaines[6] + P1 = geometriesSaines[7] + P2 = geometriesSaines[8] + EXTUBE = geometriesSaines[9] + BORDTU = geometriesSaines[10] + CLGV = geometriesSaines[11] + PEAUINT = geometriesSaines[12] + PEAUEXT = geometriesSaines[13] + COUDE = geometriesSaines[14] + + n_long_p1 = meshParams['n_long_p1'] + n_ep = meshParams['n_ep'] + n_long_coude = meshParams['n_long_coude'] + n_circ_g = meshParams['n_circ_g'] + n_circ_d = meshParams['n_circ_d'] + n_long_p2 = meshParams['n_long_p2'] + + maillageSain = smesh.Mesh(geometrieSaine) + + algo3d = maillageSain.Hexahedron() + algo2d = maillageSain.Quadrangle() + smesh.SetName(algo3d, "algo3d_maillageSain") + smesh.SetName(algo2d, "algo2d_maillageSain") + + algo1d_long_p1 = maillageSain.Segment(geom=long_p1) + hypo1d_long_p1 = algo1d_long_p1.NumberOfSegments(n_long_p1) + smesh.SetName(algo1d_long_p1, "algo1d_long_p1") + smesh.SetName(hypo1d_long_p1, "hypo1d_long_p1") + + algo1d_ep = maillageSain.Segment(geom=ep) + hypo1d_ep = algo1d_ep.NumberOfSegments(n_ep) + smesh.SetName(algo1d_ep, "algo1d_ep") + smesh.SetName(hypo1d_ep, "hypo1d_ep") + + algo1d_long_coude = maillageSain.Segment(geom=long_coude) + hypo1d_long_coude = algo1d_long_coude.NumberOfSegments(n_long_coude) + smesh.SetName(algo1d_long_coude, "algo1d_long_coude") + smesh.SetName(hypo1d_long_coude, "hypo1d_long_coude") + + algo1d_circ_g = maillageSain.Segment(geom=circ_g) + hypo1d_circ_g = algo1d_circ_g.NumberOfSegments(n_circ_g) + smesh.SetName(algo1d_circ_g, "algo1d_circ_g") + smesh.SetName(hypo1d_circ_g, "hypo1d_circ_g") + + algo1d_circ_d = maillageSain.Segment(geom=circ_d) + hypo1d_circ_d = algo1d_circ_d.NumberOfSegments(n_circ_d) + smesh.SetName(algo1d_circ_d, "algo1d_circ_d") + smesh.SetName(hypo1d_circ_d, "hypo1d_circ_d") + + algo1d_long_p2 = maillageSain.Segment(geom=long_p2) + hypo1d_long_p2 = algo1d_long_p2.NumberOfSegments(n_long_p2) + smesh.SetName(algo1d_long_p2, "algo1d_long_p2") + smesh.SetName(hypo1d_long_p2, "hypo1d_long_p2") + + isDone = maillageSain.Compute() + + mp1 = maillageSain.GroupOnGeom(P1,'P1',SMESH.NODE) + mp2 = maillageSain.GroupOnGeom(P2,'P2',SMESH.NODE) + ext = maillageSain.GroupOnGeom(EXTUBE,'EXTUBE',SMESH.FACE) + btu = maillageSain.GroupOnGeom(BORDTU,'BORDTU',SMESH.EDGE) + clg = maillageSain.GroupOnGeom(CLGV,'CLGV',SMESH.FACE) + pei = maillageSain.GroupOnGeom(PEAUINT,'PEAUINT',SMESH.FACE) + pex = maillageSain.GroupOnGeom(PEAUEXT,'PEAUEXT',SMESH.FACE) + cou = maillageSain.GroupOnGeom(COUDE,'COUDSAIN',SMESH.VOLUME) + + return [maillageSain, True] # True : maillage hexa + + # --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + logging.info("setParamShapeFissure %s", self.nomCas) + self.shapeFissureParams = dict(profondeur = 10, + rayonPipe = 2.5, + lenSegPipe = 2.5, + azimut = 160, + alpha = 20, + longueur = 400, + orientation = 90, + lgInfluence = 50, + elliptique = False, + externe = True) + + # --------------------------------------------------------------------------- + def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams): + logging.info("genereShapeFissure %s", self.nomCas) + logging.info("shapeFissureParams %s", shapeFissureParams) + + angleCoude = geomParams['angleCoude'] + r_cintr = geomParams['r_cintr'] + l_tube_p1 = geomParams['l_tube_p1'] + l_tube_p2 = geomParams['l_tube_p2'] + epais = geomParams['epais'] + de = geomParams['de'] + + profondeur = shapeFissureParams['profondeur'] + azimut = shapeFissureParams['azimut'] + alpha = shapeFissureParams['alpha'] + longueur = shapeFissureParams['longueur'] + orientation = shapeFissureParams['orientation'] + externe = shapeFissureParams['externe'] + lgInfluence = shapeFissureParams['lgInfluence'] + self.elliptique = False + if shapeFissureParams.has_key('elliptique'): + self.elliptique = shapeFissureParams['elliptique'] + + + + azimut = -azimut # axe inverse / ASCOUF + axe = geompy.MakeTranslation(OY, -r_cintr, 0, -l_tube_p1) + geompy.addToStudy(axe,"axe") + + if not lgInfluence: + lgInfluence = profondeur + + if longueur > 2*profondeur: + self.fissureLongue=True + else: + self.fissureLongue=False + self.elliptique = True + + self.circonferentielle = False + self.longitudinale = False + if self.fissureLongue and not self.elliptique: + if abs(orientation) < 45 : + self.longitudinale = True + else: + self.circonferentielle = True + + nbp1 = 10 + if self.circonferentielle: + if externe: + dp = -1.0 + raybor = de/2. + rayint = raybor - profondeur + rayext = raybor + profondeur/5.0 + else: + dp = 1.0 + raybor = de/2. - epais + rayint = raybor + profondeur + rayext = raybor - profondeur/5.0 + lgfond = longueur -2*profondeur + angle = lgfond/(2*raybor) + pb = geompy.MakeVertex(raybor, 0, 0) + pi = geompy.MakeVertex(rayint, 0, 0) + pbl = geompy.MakeRotation(pb, OZ, angle) + pbr = geompy.MakeRotation(pb, OZ, -angle) + geompy.addToStudy(pbl,"pbl") + geompy.addToStudy(pbr,"pbr") + pal = geompy.MakeTranslationVector(pbl, OZ) + par = geompy.MakeTranslationVector(pbr, OZ) + axl = geompy.MakeVector(pbl,pal) + axr = geompy.MakeVector(pbr,par) + pil = geompy.MakeRotation(pi, OZ, angle) + pir = geompy.MakeRotation(pi, OZ, -angle) + points = [] + nbp = 3*nbp1 + for i in range(nbp): + angi = dp*(nbp -i)*(2.0*math.pi/3.0)/nbp + pt = geompy.MakeRotation(pil, axl, angi) + points.append(pt) + for i in range(nbp): + angi = angle -2.0*i*angle/nbp + pt = geompy.MakeRotation(pi, OZ, angi) + points.append(pt) + for i in range(nbp+1): + angi = -dp*i*(2.0*math.pi/3.0)/nbp + pt = geompy.MakeRotation(pir, axr, angi) + points.append(pt) + for i, pt in enumerate(points): + pt = geompy.MakeRotation(pt, OZ, azimut*math.pi/180.) + pt = geompy.MakeTranslation(pt, 0, 0, -l_tube_p1) + pt = geompy.MakeRotation(pt, axe, alpha*math.pi/180.) + points[i] = pt + wire0 = geompy.MakeInterpol(points[0:nbp+1]) + wire1 = geompy.MakeInterpol(points[nbp:2*nbp+1]) + wire2 = geompy.MakeInterpol(points[2*nbp:3*nbp+1]) + #wiretube = geompy.MakeInterpol(points) + wiretube=geompy.MakeWire([wire0,wire1,wire2]) + geompy.addToStudy(wiretube,"wiretube") + + pe = geompy.MakeVertex(rayext, 0, 0) + pe = geompy.MakeRotation(pe, OZ, azimut*math.pi/180.) + pe = geompy.MakeTranslation(pe, 0, 0, -l_tube_p1) + pe = geompy.MakeRotation(pe, axe, alpha*math.pi/180.) + + arce = geompy.MakeArc(points[0], pe, points[-1]) + geompy.addToStudy(arce,"arce") + + facefiss = geompy.MakeFaceWires([arce, wiretube], 1) + geompy.addToStudy( facefiss, 'facefissPlace' ) + + pc = geompy.MakeVertex((raybor + rayint)/2.0, 0, 0) + centre = geompy.MakeRotation(pc, OZ, azimut*math.pi/180.) + centre = geompy.MakeTranslation(centre, 0, 0, -l_tube_p1) + centre = geompy.MakeRotation(centre, axe, alpha*math.pi/180.) + geompy.addToStudy( centre, 'centrefissPlace' ) + + wiretube = geompy.GetInPlace(facefiss, wiretube) + geompy.addToStudy(wiretube, 'wiretubePlace' ) + try: + edgetube = geompy.MakeEdgeWire(wiretube) + geompy.addToStudy(edgetube,"edgetube") + except: + logging.debug("erreur MakeEdgeWire sur fond de fissure, on fait sans") + edgetube = None + + # --------------------------------------------------------- + + elif self.longitudinale: + if externe: + raybor = de/2. + dp = -1.0 + else: + raybor = de/2. - epais + dp = +1.0 + prof = dp * profondeur + lgfond = longueur -2*profondeur + cosaz = math.cos(azimut*math.pi/180.) + sinaz = math.sin(azimut*math.pi/180.) + alfrd = alpha*math.pi/180. + rayxy = r_cintr + raybor*cosaz + angle = lgfond/(2.*rayxy) + logging.debug("longueur: %s, angle: %s, rayon: %s",lgfond, angle, rayxy) + pb = geompy.MakeVertex(raybor*cosaz, raybor*sinaz, -l_tube_p1, "pb") + pi = geompy.MakeTranslation(pb, prof*cosaz, prof*sinaz, 0., "pi") + pbv = geompy.MakeTranslation(pb, -sinaz, cosaz, 0., "pbv") + axb = geompy.MakeVector(pb,pbv, "axb") + pbl = geompy.MakeRotation(pb, axe, alfrd -angle, "pbl") + pbr = geompy.MakeRotation(pb, axe, alfrd +angle, "pbr") + axl = geompy.MakeRotation(axb, axe, alfrd -angle, "axl") + axr = geompy.MakeRotation(axb, axe, alfrd +angle, "axr") + pil = geompy.MakeRotation(pi, axe, alfrd -angle, "pil") + pir = geompy.MakeRotation(pi, axe, alfrd +angle, "pir") + + curves = [] + + points = [] + nbp = 3*nbp1 + xs = [] + totx = 0 + for i in range(nbp+2): + x = math.sin(i*math.pi/(nbp+1)) # fonction de répartition des points : distance relative + x2 = x*x + totx += x2 + xs.append(totx) + logging.debug("x2: %s, totx: %s", x2, totx) + for i in range(nbp+1): + #posi = nbp -i # répartition équidistante des points sur la courbe + posi = nbp*(1 -xs[i]/totx) # points plus resserrés aux extrémités de la courbe + angi = -dp*posi*(5.0*math.pi/8.0)/nbp + pt = geompy.MakeRotation(pil, axl, angi) + points.append(pt) + curves.append(geompy.MakeInterpol(points)) + point0 = points[0] + geompy.addToStudy(curves[-1],"curve0") +# for i, pt in enumerate(points): +# name = "point%d"%i +# geompy.addToStudyInFather(curves[-1], pt, name) + + points = [] + nbp = 3*nbp1 + xs =[] + totx = 0 + for i in range(nbp+1): + x = math.sin(i*math.pi/nbp) + #x = 1.0 # répartition équidistante des points sur la courbe + x2 = x*x # points plus resserrés aux extrémités de la courbe + totx += x2 + xs.append(totx) + logging.debug("x2: %s, totx: %s", x2, totx) + for i in range(nbp): + angi = alfrd -angle +2.0*angle*xs[i]/totx + pt = geompy.MakeRotation(pi, axe, angi) + points.append(pt) + curves.append(geompy.MakeInterpol(points)) + geompy.addToStudy(curves[-1],"curve1") +# for i, pt in enumerate(points): +# name = "point%d"%i +# geompy.addToStudyInFather(curves[-1], pt, name) + + points = [] + nbp = 3*nbp1 + xs = [] + totx = 0 + for i in range(nbp+2): + x = math.sin(i*math.pi/(nbp+1)) + x2 = x*x + totx += x2 + xs.append(totx) + logging.debug("x2: %s, totx: %s", x2, totx) + for i in range(nbp+1): + #posi = nbp -i # répartition équidistante des points sur la courbe + posi = nbp*xs[i]/totx # points plus resserrés aux extrémités de la courbe + angi = dp*posi*(5.0*math.pi/8.0)/nbp + pt = geompy.MakeRotation(pir, axr, angi) + points.append(pt) + curves.append(geompy.MakeInterpol(points)) + point1 = points[-1] + geompy.addToStudy(curves[-1],"curve2") +# for i, pt in enumerate(points): +# name = "point%d"%i +# geompy.addToStudyInFather(curves[-1], pt, name) + + wiretube = geompy.MakeWire(curves) + geompy.addToStudy(wiretube,"wiretube") + try: + edgetube = geompy.MakeEdgeWire(wiretube) + geompy.addToStudy(edgetube,"edgetube") + except: + logging.debug("erreur MakeEdgeWire sur fond de fissure, on fait sans") + edgetube = None + + pts = [] + pts.append(point0) + dpr = prof*math.cos(5.0*math.pi/8.0) + pe = geompy.MakeTranslation(pb, dpr*cosaz, dpr*sinaz, 0., "pe") + for i in range(nbp): + angi = alfrd -angle +2.0*i*angle/nbp + pt = geompy.MakeRotation(pe, axe, angi) + pts.append(pt) + pts.append(point1) + arce = geompy.MakeInterpol(pts) + geompy.addToStudy(arce,"arce") + + facefiss = geompy.MakeFaceWires([arce, wiretube], 0) + geompy.addToStudy( facefiss, 'facefissPlace' ) + + pc = geompy.MakeTranslation(pb, 0.5*prof*cosaz, 0.5*prof*sinaz, 0.) + centre = geompy.MakeRotation(pc, axe, alfrd) + geompy.addToStudy( centre, 'centrefissPlace' ) + + edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True) + edgesTriees, minl, maxl = sortEdges(edges) + edges = edgesTriees[:-1] # la plus grande correspond à arce, on l'elimine + wiretube = geompy.MakeWire(edges) + #wiretube = edgesTriees[-1] + geompy.addToStudy(wiretube, 'wiretubePlace' ) + + # --------------------------------------------------------- + + else: # fissure elliptique, longue ou courte + if externe: + raybor = de/2. + dp = -1.0 + else: + raybor = de/2. - epais + dp = +1.0 + prof = dp * profondeur + cosaz = math.cos(azimut*math.pi/180.) + sinaz = math.sin(azimut*math.pi/180.) + alfrd = alpha*math.pi/180. + pb = geompy.MakeVertex(raybor*cosaz, raybor*sinaz, -l_tube_p1, "pb") + pi = geompy.MakeTranslation(pb, prof*cosaz, prof*sinaz, 0., "pi") + pbv = geompy.MakeTranslation(pb, -profondeur*sinaz, profondeur*cosaz, 0., "pbv") + ayb = geompy.MakeVector(pb,pbv, "ayb") + pb0 = geompy.MakeRotation(pb, axe, alfrd, "pb0") + ay0 = geompy.MakeRotation(ayb, axe, alfrd, "ay0") + pi0 = geompy.MakeRotation(pi, axe, alfrd, "pi0") + az_ = geompy.MakeVector(pi0, pb0, "az_") + az0 = geompy.MakeTranslationVector(az_, az_, "az0") #normale sortante + ax0 = geompy.MakeRotation(ay0, az0, -math.pi/2.0, "ax0") + ax1 = geompy.MakeRotation(ax0, az0, orientation*math.pi/180., "ax1") + ay1 = geompy.MakeRotation(ay0, az0, orientation*math.pi/180., "ay1") + originLCS = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0, "originLCS") + coo = geompy.PointCoordinates(pb0) + cox = geompy.VectorCoordinates(ax1) + coy = geompy.VectorCoordinates(ay1) + localLCS = geompy.MakeMarker(coo[0], coo[1], coo[2], cox[0], cox[1], cox[2], coy[0], coy[1], coy[2], "localLCS") + + pco = geompy.MakeVertex(0, 0, -profondeur, "pco") + pao = geompy.MakeRotation(pco, OY, 0.6*math.pi, "pao") + pbo = geompy.MakeRotation(pco, OY, -0.6*math.pi, "pbo") + pce = geompy.MakeVertex(0, 0, 0.1*profondeur,"pce") + arcoo = geompy.MakeArc(pao, pco, pbo, "arcoo") + linoo = geompy.MakeArc(pao, pce, pbo, "linoo") + scalex = longueur/profondeur + arco =geompy.MakeScaleAlongAxes(arcoo, O, scalex, 1., 1., "arco") + lino =geompy.MakeScaleAlongAxes(linoo, O, scalex, 1., 1., "lino") + arci = geompy.MakePosition(arco, originLCS, localLCS, "arci") + arce = geompy.MakePosition(lino, originLCS, localLCS, "arce") + facefiss = geompy.MakeFaceWires([arce, arci], 0) + geompy.addToStudy( facefiss, 'facefissPlace' ) + edges = geompy.ExtractShapes(facefiss, geompy.ShapeType["EDGE"], True) + edgesTriees, minl, maxl = sortEdges(edges) + edgetube = edgesTriees[-1] # la plus grande correspond à arci + wiretube = edgetube + + pc = geompy.MakeTranslation(pb, 0.5*prof*cosaz, 0.5*prof*sinaz, 0.) + centre = geompy.MakeRotation(pc, axe, alfrd) + geompy.addToStudy( centre, 'centrefissPlace' ) + + coordsNoeudsFissure = genereMeshCalculZoneDefaut(facefiss, profondeur/2. ,profondeur) + + return [facefiss, centre, lgInfluence, coordsNoeudsFissure, wiretube, edgetube] + + # --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = 5, + nbsegCercle = 6, + areteFaceFissure = 5) + + # --------------------------------------------------------------------------- + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams): + elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams) + return elementsDefaut + + # --------------------------------------------------------------------------- + def genereMaillageFissure(self, geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step): + maillageFissure = insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step) + return maillageFissure + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 77917, + Entity_Quad_Edge = 975, + Entity_Quad_Triangle = 2182, + Entity_Quad_Quadrangle = 6842, + Entity_Quad_Tetra = 20135, + Entity_Quad_Hexa = 8994, + Entity_Quad_Penta = 972, + Entity_Quad_Pyramid = 1038) + diff --git a/src/Tools/blocFissure/gmu/fissureGenerique.py b/src/Tools/blocFissure/gmu/fissureGenerique.py new file mode 100644 index 000000000..17518e871 --- /dev/null +++ b/src/Tools/blocFissure/gmu/fissureGenerique.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- + +from blocFissure import gmu +from blocFissure.gmu.initEtude import initEtude +from blocFissure.gmu.getStatsMaillageFissure import getStatsMaillageFissure + +class fissureGenerique(): + """ + classe générique problème fissure: + génération géométrie et maillage sain + définition et positionnement d'une fissure + génération d'un bloc défaut inséré dans le maillage sain + """ + + nomProbleme = "generique" + + def __init__(self, numeroCas): + initEtude() + self.numeroCas = numeroCas + self.nomCas = self.nomProbleme +"_%d"%(self.numeroCas) + self.fissureLongue = False + + def setParamGeometrieSaine(self): + self.geomParams = {} + + def genereGeometrieSaine(self, geomParams): + geometriesSaines = [None] + return geometriesSaines + + def setParamMaillageSain(self): + self.meshParams = {} + + def genereMaillageSain(self, geometriesSaines, meshParams): + maillagesSains = [None] + return maillagesSains + + def setParamShapeFissure(self): + self.shapeFissureParams = {} + + def genereShapeFissure(self, geometriesSaines, geomParams, shapeFissureParams): + shapesFissure = [None] + return shapesFissure + + def setParamMaillageFissure(self): + self.maillageFissureParams = {} + + def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, maillageFissureParams): + elementsDefaut = [None] + return elementsDefaut + + def genereMaillageFissure(self, geometriesSaines, maillagesSains, shapesFissure, + maillageFissureParams, elementsDefaut, step): + maillageFissure = None + return maillageFissure + + def setReferencesMaillageFissure(self): + referencesMaillageFissure = {} + return referencesMaillageFissure + +# --------------------------------------------------------------------------- + + def executeProbleme(self, step=-1): + print "executeProbleme", self.nomCas + if step == 0: + return + + self.setParamGeometrieSaine() + geometriesSaines = self.genereGeometrieSaine(self.geomParams) + if step == 1: + return + + self.setParamMaillageSain() + maillagesSains = self.genereMaillageSain(geometriesSaines, self.meshParams) + if step == 2: + return + + self.setParamShapeFissure() + shapesFissure = self.genereShapeFissure(geometriesSaines, self.geomParams, self.shapeFissureParams) + if step == 3: + return + + self.setParamMaillageFissure() + elementsDefaut = self.genereZoneDefaut(geometriesSaines, maillagesSains, shapesFissure, self.shapeFissureParams, self.maillageFissureParams) + if step == 4: + return + + maillageFissure = self.genereMaillageFissure(geometriesSaines, maillagesSains, + shapesFissure, self.shapeFissureParams, + self.maillageFissureParams, elementsDefaut, step) + + self.setReferencesMaillageFissure() + mesures = getStatsMaillageFissure(maillageFissure, self.referencesMaillageFissure, self.maillageFissureParams) + + + + + + diff --git a/src/Tools/blocFissure/gmu/genereElemsFissureElliptique.py b/src/Tools/blocFissure/gmu/genereElemsFissureElliptique.py new file mode 100644 index 000000000..bbf939417 --- /dev/null +++ b/src/Tools/blocFissure/gmu/genereElemsFissureElliptique.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +from toreFissure import toreFissure +from ellipsoideDefaut import ellipsoideDefaut +from rotTrans import rotTrans +from genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut + +# ----------------------------------------------------------------------------- +# --- création élements géométriques fissure elliptique + +def genereElemsFissureElliptique(shapeFissureParams): + """ + TODO: a completer + """ + logging.info('start') + + centreDefaut = shapeFissureParams['centreDefaut'] + vecteurDefaut = shapeFissureParams['vecteurDefaut'] + demiGrandAxe = shapeFissureParams['demiGrandAxe'] + demiPetitAxe = shapeFissureParams['demiPetitAxe'] + orientation = shapeFissureParams['orientation'] + tailleDefaut = shapeFissureParams['taille'] + + # --- ellipse incomplete : generatrice + + allonge = demiGrandAxe/demiPetitAxe + rayonTore = demiPetitAxe/5.0 + generatrice, FaceGenFiss, Pipe_1, FaceFissure, Plane_1, Pipe1Part = toreFissure(demiPetitAxe, allonge, rayonTore) + ellipsoide = ellipsoideDefaut(demiPetitAxe, allonge, rayonTore) + + # --- positionnement sur le bloc defaut de generatrice, tore et plan fissure + + pipe0 = rotTrans(Pipe_1, orientation, centreDefaut, vecteurDefaut) + gener1 = rotTrans(generatrice, orientation, centreDefaut, vecteurDefaut) + pipe1 = rotTrans(Pipe1Part, orientation, centreDefaut, vecteurDefaut) + facefis1 = rotTrans(FaceFissure, orientation, centreDefaut, vecteurDefaut) + plane1 = rotTrans(Plane_1, orientation, centreDefaut, vecteurDefaut) + ellipsoide1 = rotTrans(ellipsoide, orientation, centreDefaut, vecteurDefaut) + + geompy.addToStudy( pipe0, 'pipe0' ) + geompy.addToStudy( gener1, 'gener1' ) + geompy.addToStudy( pipe1, 'pipe1' ) + geompy.addToStudy( facefis1, 'facefis1' ) + geompy.addToStudy( plane1, 'plane1' ) + geompy.addToStudy( ellipsoide1, 'ellipsoide1' ) + + shapeDefaut = facefis1 + xyz_defaut = geompy.PointCoordinates(centreDefaut) + coordsNoeudsFissure = genereMeshCalculZoneDefaut(facefis1, demiPetitAxe/10.0, demiPetitAxe/5.0) + + return shapeDefaut, xyz_defaut, tailleDefaut, coordsNoeudsFissure, pipe0, gener1, pipe1, facefis1, plane1, ellipsoide1 diff --git a/src/Tools/blocFissure/gmu/genereMeshCalculZoneDefaut.py b/src/Tools/blocFissure/gmu/genereMeshCalculZoneDefaut.py new file mode 100644 index 000000000..a08664bad --- /dev/null +++ b/src/Tools/blocFissure/gmu/genereMeshCalculZoneDefaut.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import smesh +from salome.smesh import smeshBuilder + +# ----------------------------------------------------------------------------- +# --- maillage face de fissure pour identification zone de defaut + +def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize): + """ + TODO: a completer + """ + logging.info('start') + + meshFissure = smesh.Mesh(facefiss) + algo2d = meshFissure.Triangle(algo=smeshBuilder.NETGEN_1D2D) + hypo2d = algo2d.Parameters() + hypo2d.SetMaxSize( maxSize ) + hypo2d.SetSecondOrder( 0 ) + hypo2d.SetOptimize( 1 ) + hypo2d.SetFineness( 2 ) + hypo2d.SetMinSize( minSize ) + hypo2d.SetQuadAllowed( 0 ) + isDone = meshFissure.Compute() + smesh.SetName(algo2d, "algo2d_zoneFiss") + smesh.SetName(hypo2d, "hypo1d_zoneFiss") + + coordsNoeudsFissure = [] + nodeIds = meshFissure.GetNodesId() + for id in nodeIds: + coords = meshFissure.GetNodeXYZ(id) + coordsNoeudsFissure.append(coords[0]) + coordsNoeudsFissure.append(coords[1]) + coordsNoeudsFissure.append(coords[2]) + return coordsNoeudsFissure diff --git a/src/Tools/blocFissure/gmu/geomsmesh.py b/src/Tools/blocFissure/gmu/geomsmesh.py new file mode 100644 index 000000000..889d35ba3 --- /dev/null +++ b/src/Tools/blocFissure/gmu/geomsmesh.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +import logging +logging.info('start') + +import salome +salome.salome_init() + +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +logging.debug("initialisation de geompy et smesh OK") diff --git a/src/Tools/blocFissure/gmu/getCentreFondFiss.py b/src/Tools/blocFissure/gmu/getCentreFondFiss.py new file mode 100644 index 000000000..6c04d3627 --- /dev/null +++ b/src/Tools/blocFissure/gmu/getCentreFondFiss.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +import bisect + +publie = False + +def getCentreFondFiss(shapesFissure): + """ + identification du centre de fond de fissure, + transformation fond de fissure en edge unique (seulement pour la procédure insereFissureGenerale). + On distingue le cas d'utilisation de la procédure insereFissureLongue par le nombre d'éléments de shapesFissure. + """ + global publie + logging.debug("start") + + fondFiss = shapesFissure[4] # groupe d'edges de fond de fissure + if len(shapesFissure) == 6: # procédure insereFissureGenerale, et edge fond de fissure fournie explicitement + edgeFondExt = shapesFissure[5] + else: + edgeFondExt = None + + if len(shapesFissure) > 6: # procédure insereFissureLongue (fissure plane, plusieurs edges sur le fond de fissure) + centreFondFiss = shapesFissure[1] + tgtCentre = None + else: # procédure insereFissureGenerale, détermination edge unique et milieu de l'edge + if geompy.NumberOfEdges(fondFiss) > 1: + if geompy.NbShapes(fondFiss, geompy.ShapeType["WIRE"]) > 0: # wire + aWire = fondFiss + else: # compound + edges = geompy.ExtractShapes(fondFiss, geompy.ShapeType["EDGE"], False) + aWire = geompy.MakeWire(edges, 1e-07) + else: + edgeFondExt = fondFiss + aWire = geompy.MakeWire([fondFiss], 1e-07) + if not publie: + geompy.addToStudy(aWire, "wireFondFissExt") + + lgWire = geompy.BasicProperties(aWire)[0] + edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], True) + lgEdges = [geompy.BasicProperties(ed)[0] for ed in edges] + lgSumEd =[sum(lgEdges[0:i+1]) for i in range(len(lgEdges))] + iedr = bisect.bisect_left(lgSumEd, lgWire/2.0) + iedg = iedr -1 + if iedg < 0: + lgOnEdge = lgWire/2.0 + else: + lgOnEdge = lgWire/2.0 - lgSumEd[iedg] + logging.debug("lgsumEdges %s", lgSumEd) + logging.debug("id edge: %s, lgOnEdge: %s, lgEdge: %s",iedr, lgOnEdge, lgEdges[iedr]) + if iedr > 0: # il y a une edge avant celle du milieu + if geompy.MinDistance(edges[iedr-1], geompy.MakeVertexOnCurve(edges[iedr], 0.0 )) < 1.e-3: # edge orientée croissante + centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], lgOnEdge/lgEdges[iedr]) + else: + centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], 1.0 - lgOnEdge/lgEdges[iedr]) + elif iedr < len(edges)-1: # il y a une edge après celle du milieu + if geompy.MinDistance(edges[iedr+1], geompy.MakeVertexOnCurve(edges[iedr], 1.0 )) < 1.e-3: # edge orientée croissante + centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], lgOnEdge/lgEdges[iedr]) + else: + centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], 1.0 - lgOnEdge/lgEdges[iedr]) + else: # on ne sait pas comment est orientée l'edge unique, mais ça n'a pas d'importance + centreFondFiss = geompy.MakeVertexOnCurve(edges[iedr], lgOnEdge/lgEdges[iedr]) + geompy.addToStudyInFather(aWire, centreFondFiss, "centreFondFiss") + tgtCentre = geompy.MakeTangentOnCurve(edges[iedr], lgOnEdge/ lgEdges[iedr]) + + if edgeFondExt is None: # fond de fissure non fourni explicitement sous forme d'edge + try: + edgeFondExt = geompy.MakeEdgeWire(aWire, 0.0005, 1e-07) + except: + logging.debug("erreur MakeEdgeWire sur fond de fissure, on fait sans") + edgeFondExt = None + if not publie and edgeFondExt is not None: + geompy.addToStudy(edgeFondExt, "edgeFondExt") + + publie = True + return edgeFondExt, centreFondFiss, tgtCentre diff --git a/src/Tools/blocFissure/gmu/getStatsMaillageFissure.py b/src/Tools/blocFissure/gmu/getStatsMaillageFissure.py new file mode 100644 index 000000000..453b6b904 --- /dev/null +++ b/src/Tools/blocFissure/gmu/getStatsMaillageFissure.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +import logging +import SMESH + +# ----------------------------------------------------------------------------- +# --- statistiques maillage + +def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissureParams): + """ + TODO: a completer + """ + logging.debug('start') + + nomRep = '.' + if maillageFissureParams.has_key('nomRep'): + nomRep = maillageFissureParams['nomRep'] + + nomFicFissure = maillageFissureParams['nomFicFissure'] + fichierStatMaillageFissure = nomRep + '/' + nomFicFissure + '.res' + fichierNewRef = nomRep + '/' + nomFicFissure + '.new' + logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure) + + OK = False + if maillage is not None: + mesures = maillage.GetMeshInfo() + d= {} + for key, value in mesures.iteritems(): + logging.debug( "key: %s value: %s", key, value) + d[str(key)] = value + logging.debug("dico mesures %s", d) + + f = open(fichierStatMaillageFissure, 'w') + f2 = open(fichierNewRef, 'w') + OK = True + for key in ('Entity_Quad_Pyramid', 'Entity_Quad_Hexa', 'Entity_Quad_Quadrangle'): + if d[key] != referencesMaillageFissure[key]: + logging.info("Ecart: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key]) + f.write("Ecart: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n') + OK = False + else: + logging.info("Valeur_OK: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key]) + f.write("Valeur_OK: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n') + f2.write(key + " = " + str(d[key]) + ",\n") + tolerance = 0.05 + for key in ('Entity_Quad_Penta', 'Entity_Quad_Tetra', 'Entity_Quad_Triangle', 'Entity_Quad_Edge', 'Entity_Node'): + if (d[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \ + or (d[key] > (1.0 + tolerance)*referencesMaillageFissure[key]): + logging.info("Ecart: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key]) + f.write("Ecart: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n') + OK = False + else: + logging.info("Valeur_OK: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key]) + f.write("Valeur_OK: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n') + f2.write(key + " = " + str(d[key]) + ",\n") + f.close() + f2.close() + return OK diff --git a/src/Tools/blocFissure/gmu/getSubshapeIds.py b/src/Tools/blocFissure/gmu/getSubshapeIds.py new file mode 100644 index 000000000..778359646 --- /dev/null +++ b/src/Tools/blocFissure/gmu/getSubshapeIds.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- transformation d'une liste de subshapes en une liste d'Id + +def getSubshapeIds(obj, subshapes): + """ + transformation d'une liste de subshapes en une liste d'Id + """ + logging.debug("start") + subshapesId = [] + for sub in subshapes: + subshapesId.append(geompy.GetSubShapeID(obj, sub)) + logging.debug("subshapesId=%s", subshapesId) + return subshapesId diff --git a/src/Tools/blocFissure/gmu/initEtude.py b/src/Tools/blocFissure/gmu/initEtude.py new file mode 100644 index 000000000..1e73886b6 --- /dev/null +++ b/src/Tools/blocFissure/gmu/initEtude.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + +import logging +myStudy = None + +def initEtude(): + """ + creation nouvelle etude salome + """ + import geomsmesh diff --git a/src/Tools/blocFissure/gmu/initLog.py b/src/Tools/blocFissure/gmu/initLog.py new file mode 100644 index 000000000..63908c1d0 --- /dev/null +++ b/src/Tools/blocFissure/gmu/initLog.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +import logging + +def setDebug(): + logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s', + level=logging.DEBUG) + logging.info('start Debug') + +def setVerbose(): + logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s', + level=logging.INFO) + logging.info('start Verbose') + +def setRelease(): + logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', + level=logging.WARNING) + logging.warning('start Release') + +def setUnitTests(): + logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', + level=logging.CRITICAL) + logging.critical('start UnitTests') + + #logging.basicConfig(filename='myapp.log', + # format='%(asctime)s %(message)s', + # datefmt='%m/%d/%Y %I:%M:%S %p', + # level=logging.DEBUG) diff --git a/src/Tools/blocFissure/gmu/insereFissureElliptique.py b/src/Tools/blocFissure/gmu/insereFissureElliptique.py new file mode 100644 index 000000000..95d4a6279 --- /dev/null +++ b/src/Tools/blocFissure/gmu/insereFissureElliptique.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- + +import logging +import salome +from geomsmesh import geompy +from geomsmesh import smesh +import SMESH +import math + +from partitionBlocDefaut import partitionBlocDefaut +from facesVolumesToriques import facesVolumesToriques +from facesCirculaires import facesCirculaires +from propagateTore import propagateTore +from sortGeneratrices import sortGeneratrices +from facesFissure import facesFissure +from facesToreInBloc import facesToreInBloc +from shapeSurFissure import shapeSurFissure +from meshBlocPart import meshBlocPart +from enleveDefaut import enleveDefaut +from regroupeSainEtDefaut import RegroupeSainEtDefaut +from putName import putName + +# ----------------------------------------------------------------------------- +# --- procedure complete fissure elliptique + +def insereFissureElliptique(geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step=-1): + """ + TODO: a completer + """ + logging.info('start') + + geometrieSaine = geometriesSaines[0] + maillageSain = maillagesSains[0] + isHexa = maillagesSains[1] + shapeDefaut = shapesFissure[0] + tailleDefaut = shapesFissure[2] + pipe0 = shapesFissure[4] + gener1 = shapesFissure[5] + pipe1 = shapesFissure[6] + facefis1 = shapesFissure[7] + plane1 = shapesFissure[8] + ellipsoide1 = shapesFissure[9] + + + demiGrandAxe = shapeFissureParams['demiGrandAxe'] + demiPetitAxe = shapeFissureParams['demiPetitAxe'] + orientation = shapeFissureParams['orientation'] + + nomRep = maillageFissureParams['nomRep'] + nomFicSain = maillageFissureParams['nomFicSain'] + nomFicFissure = maillageFissureParams['nomFicFissure'] + + nbsegExt = maillageFissureParams['nbsegExt'] # 5 + nbsegGen = maillageFissureParams['nbsegGen'] # 25 + nbsegRad = maillageFissureParams['nbsegRad'] # 5 + scaleRad = maillageFissureParams['scaleRad'] # 4 + nbsegCercle = maillageFissureParams['nbsegCercle'] # 6 + nbsegFis = maillageFissureParams['nbsegFis'] # 20 + lensegEllipsoide = maillageFissureParams['lensegEllipso'] # 1.0 + + fichierMaillageSain = nomRep + '/' + nomFicSain + '.med' + fichierMaillageFissure = nomRep + '/' + nomFicFissure + '.med' + + facesDefaut = elementsDefaut[0] + centreDefaut = elementsDefaut[1] + normalDefaut = elementsDefaut[2] + extrusionDefaut = elementsDefaut[3] + dmoyen = elementsDefaut[4] + bordsPartages = elementsDefaut[5] + fillconts = elementsDefaut[6] + idFilToCont = elementsDefaut[7] + maillageSain = elementsDefaut[8] + internalBoundary = elementsDefaut[9] + zoneDefaut = elementsDefaut[10] + zoneDefaut_skin = elementsDefaut[11] + zoneDefaut_internalFaces = elementsDefaut[12] + zoneDefaut_internalEdges = elementsDefaut[13] + + ## --- ellipse incomplete : generatrice + #if step == 5: + #return None + + #allonge = demiGrandAxe/demiPetitAxe + #rayonTore = demiPetitAxe/5.0 + #generatrice, FaceGenFiss, Pipe_1, FaceFissure, Plane_1, Pipe1Part = self.toreFissure(demiPetitAxe, allonge, rayonTore) + #ellipsoide = self.ellipsoideDefaut(demiPetitAxe, allonge, rayonTore) + + ## --- positionnement sur le bloc defaut de generatrice, tore et plan fissure + #if step == 6: + #return None + + #pipe0 = self.rotTrans(Pipe_1, orientation, centreDefaut, normalDefaut) + #gener1 = self.rotTrans(generatrice, orientation, centreDefaut, normalDefaut) + #pipe1 = self.rotTrans(Pipe1Part, orientation, centreDefaut, normalDefaut) + #facefis1 = self.rotTrans(FaceFissure, orientation, centreDefaut, normalDefaut) + #plane1 = self.rotTrans(Plane_1, orientation, centreDefaut, normalDefaut) + #ellipsoide1 = self.rotTrans(ellipsoide, orientation, centreDefaut, normalDefaut) + + #geompy.addToStudy( pipe0, 'pipe0' ) + #geompy.addToStudy( gener1, 'gener1' ) + #geompy.addToStudy( pipe1, 'pipe1' ) + #geompy.addToStudy( facefis1, 'facefis1' ) + #geompy.addToStudy( plane1, 'plane1' ) + #geompy.addToStudy( ellipsoide1, 'ellipsoide1' ) + + # --- partition du bloc défaut par génératrice, tore et plan fissure + if step == 7: + return None + + [blocPartition, blocp, tore, + faceFissure, facesExternes, facesExtBloc, facesExtElli, + aretesInternes, ellipsoidep, sharedFaces, sharedEdges, edgesBords] = \ + partitionBlocDefaut(extrusionDefaut, facesDefaut, gener1, pipe1, + facefis1, ellipsoide1) + if not isHexa: + edgesBords = None # maillage sain hexa ==> filling, et maillage edges Bords imposés du maillage sain + + # --- TORE + # --- faces toriques du tore + if step == 8: + return None + + [facetore1, facetore2, volumeTore1, volumeTore2] = facesVolumesToriques(tore, plane1, facesDefaut) + + # --- faces 1/2 circulaires et edges dans le plan de fissure + if step == 9: + return None + + [faces, centres, edges, reverses] = facesCirculaires(extrusionDefaut, tore) + + # --- recherche et classement des edges du tore par propagate + if step == 10: + return None + + [diams, circles, geners] = propagateTore(tore) + + # --- tri par longueur des 3 génératrices + if step == 11: + return None + + [genext, genint, gencnt] = sortGeneratrices(tore, geners) + + # --- faces fissure dans et hors tore, et edges face hors tore + if step == 12: + return None + + [facefissintore, facefissoutore, edgeint, edgeext, reverext] = \ + facesFissure(ellipsoidep, faceFissure, extrusionDefaut, genint) + + # --- identification des faces tore et fissure dans le solide hors tore + if step == 13: + return None + + [blocFaceFiss, blocFaceTore1, blocFaceTore2] = \ + facesToreInBloc(ellipsoidep, facefissoutore, facetore1, facetore2) + + # --- identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face) + + #shapesAModifier = self.shapesSurFissure(blocPartition, plane1 faceFissure, gencnt) + if step == 14: + return None + + extrusionFaceFissure, normfiss = shapeSurFissure(plane1) + + # --- maillage du bloc partitionne + + if step == 15: + return None + + [bloc1, blocComplet] = \ + meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, + gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, + aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, + nbsegExt, nbsegGen, nbsegRad, scaleRad, reverses, reverext, nbsegCercle, + nbsegFis, dmoyen, lensegEllipsoide) + + if step == 16: + return None + maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges) + + if step == 17: + return None + maillageComplet = RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceFissure, 'VOLUMES') + + if step == 18: + return None + maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 ) + putName(maillageComplet, nomFicFissure) + logging.info("fichier maillage fissure : %s", fichierMaillageFissure) + + if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + + return maillageComplet diff --git a/src/Tools/blocFissure/gmu/insereFissureGenerale.py b/src/Tools/blocFissure/gmu/insereFissureGenerale.py new file mode 100644 index 000000000..3204084a5 --- /dev/null +++ b/src/Tools/blocFissure/gmu/insereFissureGenerale.py @@ -0,0 +1,1371 @@ +# -*- coding: utf-8 -*- + +import logging +import salome +from geomsmesh import geompy +import GEOM +from geomsmesh import smesh +from salome.smesh import smeshBuilder +import SMESH +import math +import bisect + +from extractionOrientee import extractionOrientee +from extractionOrienteeMulti import extractionOrienteeMulti +from sortFaces import sortFaces +from sortEdges import sortEdges +from eliminateDoubles import eliminateDoubles +from substractSubShapes import substractSubShapes +from produitMixte import produitMixte +from findWireEndVertices import findWireEndVertices +from findWireIntermediateVertices import findWireIntermediateVertices +from orderEdgesFromWire import orderEdgesFromWire +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 checkDecoupePartition import checkDecoupePartition +from whichSide import whichSide +from whichSideMulti import whichSideMulti +from whichSideVertex import whichSideVertex +from projettePointSurCourbe import projettePointSurCourbe +from prolongeWire import prolongeWire +#from getCentreFondFiss import getCentreFondFiss + +# ----------------------------------------------------------------------------- +# --- procédure complète fissure générale + +def insereFissureGenerale(maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step=-1): + """ + TODO: a completer + """ + logging.info('start') + + shapeDefaut = shapesFissure[0] # faces de fissure, débordant + fondFiss = shapesFissure[4] # groupe d'edges de fond de fissure + + rayonPipe = shapeFissureParams['rayonPipe'] + if shapeFissureParams.has_key('lenSegPipe'): + lenSegPipe = shapeFissureParams['lenSegPipe'] + else: + lenSegPipe = rayonPipe + + nomRep = maillageFissureParams['nomRep'] + nomFicSain = maillageFissureParams['nomFicSain'] + nomFicFissure = maillageFissureParams['nomFicFissure'] + + nbsegRad = maillageFissureParams['nbsegRad'] # nombre de couches selon un rayon du pipe + nbsegCercle = maillageFissureParams['nbsegCercle'] # nombre de secteur dans un cercle du pipe + areteFaceFissure = maillageFissureParams['areteFaceFissure'] + + pointIn_x = 0.0 + pointIn_y = 0.0 + pointIn_z = 0.0 + isPointInterne = False + if shapeFissureParams.has_key('pointIn_x'): + pointIn_x = shapeFissureParams['pointIn_x'] + isPointInterne = True + if shapeFissureParams.has_key('pointIn_y'): + pointIn_y = shapeFissureParams['pointIn_y'] + isPointInterne = True + if shapeFissureParams.has_key('pointIn_z'): + pointIn_z = shapeFissureParams['pointIn_z'] + isPointInterne = True + if isPointInterne: + pointInterne = geompy.MakeVertex(pointIn_x, pointIn_y, pointIn_z) + + #fichierMaillageSain = nomRep + '/' + nomFicSain + '.med' + fichierMaillageFissure = nomRep + '/' + nomFicFissure + '.med' + + facesDefaut = elementsDefaut[0] # fillings des faces en peau + #centresDefaut = elementsDefaut[1] + #normalsDefaut = elementsDefaut[2] + #extrusionsDefaut = elementsDefaut[3] + dmoyen = elementsDefaut[4] + bordsPartages = elementsDefaut[5] + fillconts = elementsDefaut[6] + idFilToCont = elementsDefaut[7] + maillageSain = elementsDefaut[8] + internalBoundary = elementsDefaut[9] + zoneDefaut = elementsDefaut[10] + zoneDefaut_skin = elementsDefaut[11] + zoneDefaut_internalFaces = elementsDefaut[12] + zoneDefaut_internalEdges = elementsDefaut[13] + edgeFondExt = elementsDefaut[14] + centreFondFiss = elementsDefaut[15] + tgtCentre = elementsDefaut[16] + + # --- restriction de la face de fissure au domaine solide : + # partition face fissure étendue par fillings, on garde la plus grande face + + partShapeDefaut = geompy.MakePartition([shapeDefaut], facesDefaut, [], [], geompy.ShapeType["FACE"], 0, [], 0) + geompy.addToStudy(partShapeDefaut, 'partShapeDefaut') + facesPartShapeDefaut = geompy.ExtractShapes(partShapeDefaut, geompy.ShapeType["FACE"], False) + if isPointInterne: + distfaces = [(geompy.MinDistance(face,pointInterne), i, face) for i, face in enumerate(facesPartShapeDefaut)] + distfaces.sort() + logging.debug("selection de la face la plus proche du point interne, distance=%s",distfaces[0][0]) + facesPortFissure = distfaces[0][2] + else: + facesPartShapeDefautSorted, minSurf, maxSurf = sortFaces(facesPartShapeDefaut) # la face de fissure dans le volume doit être la plus grande + logging.debug("surfaces faces fissure étendue, min %s, max %s", minSurf, maxSurf) + facesPortFissure = facesPartShapeDefautSorted[-1] + + geompy.addToStudy(facesPortFissure, "facesPortFissure") + + O, OX, OY, OZ = triedreBase() + + # ----------------------------------------------------------------------------- + # --- pipe de fond de fissure, prolongé, partition face fissure par pipe + # identification des edges communes pipe et face fissure + + if geompy.NumberOfFaces(shapeDefaut) == 1: + plan = geompy.MakePlane(centreFondFiss, tgtCentre, 10000) + shapeDefaut = geompy.MakePartition([shapeDefaut], [plan], [], [], geompy.ShapeType["FACE"], 0, [], 0) + fondFissCoupe = geompy.GetInPlaceByHistory(shapeDefaut, fondFiss) + geompy.addToStudy(shapeDefaut, 'shapeDefaut_coupe') + geompy.addToStudyInFather(shapeDefaut, fondFissCoupe, 'fondFiss_coupe') + + extrem, norms = findWireEndVertices(fondFiss, True) + logging.debug("extrem: %s, norm: %s",extrem, norms) + cercle = geompy.MakeCircle(extrem[0], norms[0], rayonPipe) + cercle = geompy.MakeRotation(cercle, norms[0], math.pi/3.0 ) # éviter d'avoir l'arête de couture du pipe presque confondue avec la face fissure + geompy.addToStudy(cercle, 'cercle') + fondFissProlonge = prolongeWire(fondFiss, extrem, norms, 2*rayonPipe) + pipeFiss = geompy.MakePipe(cercle, fondFissProlonge) + geompy.addToStudy(pipeFiss, 'pipeFiss') + partFissPipe = geompy.MakePartition([shapeDefaut, pipeFiss], [], [], [], geompy.ShapeType["FACE"], 0, [], 1) + geompy.addToStudy(partFissPipe, 'partFissPipe') + fissPipe = geompy.GetInPlaceByHistory(partFissPipe, shapeDefaut) + geompy.addToStudy(fissPipe, 'fissPipe') + partPipe = geompy.GetInPlaceByHistory(partFissPipe, pipeFiss) + geompy.addToStudy(partPipe, 'partPipe') + + edgesPipeFiss = geompy.GetSharedShapesMulti([fissPipe, partPipe], geompy.ShapeType["EDGE"]) + for i, edge in enumerate(edgesPipeFiss): + name = "edgePipe%d"%i + geompy.addToStudyInFather(fissPipe, edge, name) + try: + wirePipeFiss = geompy.MakeWire(edgesPipeFiss) + except: + wirePipeFiss = geompy.MakeCompound(edgesPipeFiss) + logging.debug("wirePipeFiss construit sous forme de compound") + geompy.addToStudy(wirePipeFiss, "wirePipeFiss") + + wireFondFiss = geompy.GetInPlace(partFissPipe,fondFiss) + edgesFondFiss = geompy.GetSharedShapesMulti([fissPipe, wireFondFiss], geompy.ShapeType["EDGE"]) + for i, edge in enumerate(edgesFondFiss): + name = "edgeFondFiss%d"%i + geompy.addToStudyInFather(fissPipe, edge, name) + wireFondFiss = geompy.MakeWire(edgesFondFiss) + geompy.addToStudy(wireFondFiss,"wireFondFiss") + + # ----------------------------------------------------------------------------- + # --- 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) + + partitionsPeauFissFond = [] + ipart = 0 + for filling in facesDefaut: + part = geompy.MakePartition([fissPipe, filling], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) + isPart = checkDecoupePartition([fissPipe, filling], part) + if isPart: # on recrée la partition avec toutes les faces filling en outil pour avoir une face de fissure correcte + otherFD = [fd for fd in facesDefaut if fd != filling] + if len(otherFD) > 0: + fissPipePart = geompy.MakePartition([fissPipe], otherFD, [], [], geompy.ShapeType["FACE"], 0, [], 0) + else: + fissPipePart = fissPipe + part = geompy.MakePartition([fissPipePart, filling], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) + partitionsPeauFissFond.append(part) + geompy.addToStudy( part, 'partitionPeauFissFond%d'%ipart ) + else: + partitionsPeauFissFond.append(None) + ipart = ipart +1 + + # --- arêtes vives détectées (dans quadranglesToShape) + + aretesVives = [] + aretesVivesCoupees = [] + ia = 0 + for a in bordsPartages: + if a[0] is not None: + aretesVives.append(a[0]) + name = "areteVive%d"%ia + geompy.addToStudy(a[0], name) + ia += 1 + aretesVivesC = None + if len(aretesVives) > 0: + aretesVivesC =geompy.MakeCompound(aretesVives) + + # ------------------------------------------------------- + # --- inventaire des faces de peau coupées par la fissure + # pour chaque face de peau : 0, 1 ou 2 faces débouchante du fond de fissure + # 0, 1 ou plus edges de la face de fissure externe au pipe + + nbFacesFilling = len(partitionsPeauFissFond) + ptEdgeFond = [ [] for i in range(nbFacesFilling)] # pour chaque face [points edge fond de fissure aux débouchés du pipe] + fsPipePeau = [ [] for i in range(nbFacesFilling)] # pour chaque face [faces du pipe débouchantes] + edRadFPiPo = [ [] for i in range(nbFacesFilling)] # pour chaque face [edge radiale des faces du pipe débouchantes ] + fsFissuExt = [ [] for i in range(nbFacesFilling)] # pour chaque face [faces de fissure externes au pipe] + edFisExtPe = [ [] for i in range(nbFacesFilling)] # pour chaque face [edge en peau des faces de fissure externes (pas subshape facePeau)] + edFisExtPi = [ [] for i in range(nbFacesFilling)] # pour chaque face [edge commun au pipe des faces de fissure externes] + facesPeaux = [None for i in range(nbFacesFilling)] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes) + edCircPeau = [ [] for i in range(nbFacesFilling)] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe] + ptCircPeau = [ [] for i in range(nbFacesFilling)] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe] + gpedgeBord = [None for i in range(nbFacesFilling)] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine + gpedgeVifs = [None for i in range(nbFacesFilling)] # pour chaque face de peau : groupes subshape des edges aux arêtes vives entre fillings + edFissPeau = [ [] for i in range(nbFacesFilling)] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] + ptFisExtPi = [ [] for i in range(nbFacesFilling)] # pour chaque face de peau : [point commun edFissPeau edCircPeau] + + for ifil, partitionPeauFissFond in enumerate(partitionsPeauFissFond): + fillingFaceExterne = facesDefaut[ifil] + fillingSansDecoupe = fillconts[idFilToCont[ifil]] + if partitionPeauFissFond is not None: + logging.debug("traitement partitionPeauFissFond %s", ifil) + # ----------------------------------------------------------------------- + # --- identification edges fond de fissure, edges pipe sur la face de fissure, + # edges prolongées + + edgesPipeC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesPipeFiss)) + geompy.addToStudyInFather(partitionPeauFissFond, edgesPipeC, "edgesPipeFiss") + edgesFondC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesFondFiss)) + geompy.addToStudyInFather(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): + try: + vertices = geompy.GetSharedShapesMulti([edge, geompy.MakeCompound(facesOnside)], geompy.ShapeType["VERTEX"]) + verticesPipePeau.append(vertices[0]) + name = "edgePipeIn%d"%i + geompy.addToStudyInFather(partitionPeauFissFond, edge, name) + name = "verticePipePeau%d"%i + geompy.addToStudyInFather(partitionPeauFissFond, vertices[0], name) + logging.debug("edgePipeIn%s coupe les faces OnSide", i) + except: + logging.debug("edgePipeIn%s ne coupe pas les faces OnSide", i) + edgesFondOut = [] + edgesFondIn =[] + if len(verticesPipePeau) > 0: # au moins une extrémité du pipe sur cette face de peau + tmp = geompy.GetSharedShapesMulti([edgesFondC, geompy.MakeCompound(edgesOutside)], geompy.ShapeType["EDGE"]) + edgesFondOut = [ ed for ed in tmp if geompy.MinDistance(ed, geompy.MakeCompound(facesOnside)) < 1.e-3] + 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] + verticesEdgesFondIn = [] # les points du fond de fissure au débouché du pipe sur la peau (indice de edgesFondIn) + pipexts = [] # les segments de pipe associés au points de fond de fissure débouchants (même indice) + cercles = [] # les cercles de generation des pipes débouchant (même indice) + facesFissExt = [] # les faces de la fissure externe associés au points de fond de fissure débouchants (même indice) + edgesFissExtPeau = [] # edges des faces de fissure externe sur la peau (même indice) + edgesFissExtPipe = [] # edges des faces de fissure externe sur le pipe (même indice) + #logging.debug("edgesFondIn %s", edgesFondIn) + + edgesFondFiss, edgesIdByOrientation = orderEdgesFromWire(wireFondFiss) + for i,edge in enumerate(edgesFondFiss): + geompy.addToStudyInFather(wireFondFiss, edge, "edgeFondFiss%d"%i) + + for iedf, edge in enumerate(edgesFondIn): + name = "edgeFondIn%d"%iedf + geompy.addToStudyInFather(partitionPeauFissFond, edge, name) + dist = [ geompy.MinDistance(pt, edge) for pt in verticesPipePeau] + ptPeau = verticesPipePeau[dist.index(min(dist))] # le point de verticesPipePeau a distance minimale de l'edge + [u, PointOnEdge, EdgeInWireIndex] = geompy.MakeProjectionOnWire(ptPeau, wireFondFiss) + logging.debug("u:%s, EdgeInWireIndex: %s, len(edgesFondFiss): %s", u, EdgeInWireIndex, len(edgesFondFiss)) + localEdgeInFondFiss = edgesFondFiss[EdgeInWireIndex] + centre = PointOnEdge + centre2 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, u) + geompy.addToStudyInFather(partitionPeauFissFond, centre2, "centre2_%d"%iedf) + verticesEdgesFondIn.append(centre) + name = "verticeEdgesFondIn%d"%iedf + geompy.addToStudyInFather(partitionPeauFissFond, centre, name) + norm = geompy.MakeTangentOnCurve(localEdgeInFondFiss, u) + geompy.addToStudyInFather(partitionPeauFissFond, centre, "norm%d"%iedf) + cercle = geompy.MakeCircle(centre, norm, rayonPipe) + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(partitionPeauFissFond, cercle, name) + cercles.append(cercle) + + # --- estimation de la longueur du pipe necessaire de part et d'autre du point de sortie + if aretesVivesC is None: + faceTestPeau = fillingFaceExterne + else: + faceTestPeau = facesDefaut[ifil] + sideCentre = whichSide(faceTestPeau, centre) + locPt0 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 0.0) + locPt1 = geompy.MakeVertexOnCurve(localEdgeInFondFiss, 1.0) + sidePt0 = whichSide(faceTestPeau, locPt0) + sidePt1 = whichSide(faceTestPeau, locPt1) + logging.debug("position centre cercle: %s, extremité edge u0: %s, u1: %s", sideCentre, sidePt0, sidePt1) + normFace = geompy.GetNormal(faceTestPeau, ptPeau) + inclPipe = abs(geompy.GetAngleRadians(norm, normFace)) + lgp = max(rayonPipe/2., abs(3*rayonPipe*math.tan(inclPipe))) + logging.debug("angle inclinaison Pipe en sortie: %s degres, lgp: %s", inclPipe*180/math.pi, lgp) + + # --- position des points extremite du pipe sur l'edge debouchante + # il faut la distance curviligne ofp du point central par rapport à une extrémité de l'edge débouchante + locEdgePart = geompy.MakePartition([localEdgeInFondFiss],[centre], [], [], geompy.ShapeType["EDGE"], 0, [], 0) + edgesLoc = geompy.ExtractShapes(locEdgePart, geompy.ShapeType["EDGE"], False) + edgesLocSorted =[(geompy.MinDistance(edge, locPt0), kk, edge) for kk, edge in enumerate(edgesLoc)] + edgesLocSorted.sort() + ofp = geompy.BasicProperties(edgesLocSorted[0][2])[0] # distance curviligne centre locPt0 + logging.debug("distance curviligne centre extremite0: %s", ofp) + p1 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp +lgp, locPt0) + p2 = geompy.MakeVertexOnCurveByLength(localEdgeInFondFiss, ofp -lgp, locPt0) + geompy.addToStudyInFather(wireFondFiss, p1, "p1_%d"%iedf) + geompy.addToStudyInFather(wireFondFiss, p2, "p2_%d"%iedf) + + edgePart = geompy.MakePartition([localEdgeInFondFiss], [p1,p2], [], [], geompy.ShapeType["EDGE"], 0, [], 0) + edps = geompy.ExtractShapes(edgePart, geompy.ShapeType["EDGE"], True) + for edp in edps: + if geompy.MinDistance(centre, edp) < 1.e-3: + pipext = geompy.MakePipe(cercle, edp) + name = "pipeExt%d"%iedf + geompy.addToStudyInFather(partitionPeauFissFond, pipext, name) + pipexts.append(pipext) + + for face in facesInside: + logging.debug("recherche edges communes entre une face inside et (faces onside, edges pipe et fond débouchante)") + edgesPeauFis = [] + edgesPipeFis = [] + edgesPipeFnd = [] + 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", i) + facesFissExt.append(face) + name="faceFissExt%d"%iedf + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(partitionPeauFissFond, edpe, name) + edgesFissExtPipe.append(edpi) + name="edgesFissExtPipe%d"%iedf + geompy.addToStudyInFather(partitionPeauFissFond, edpi, name) + break + if dist < 1.e-3: + break + + if len(verticesPipePeau) == 0: # aucune extrémité du pipe sur cette face de peau + # il faut recenser les edges de fissure sur la face de peau + j = 0 + for face in facesInside: + edgesPeauFis = [] + edgesPipeFis = [] + edgesPipeFnd = [] + try: + edgesPeauFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(facesOnside), face], geompy.ShapeType["EDGE"]) + edgesPipeFis = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesPipeIn), face], geompy.ShapeType["EDGE"]) + edgesPipeFnd = geompy.GetSharedShapesMulti([geompy.MakeCompound(edgesFondIn), face], geompy.ShapeType["EDGE"]) + except: + pass + if (len(edgesPeauFis) > 0) and (len(edgesPipeFis) > 0) and (len(edgesPipeFnd) == 0): + edgesFissExtPeau.append(edgesPeauFis[0]) + name="edgesFissExtPeau%d"%j + geompy.addToStudyInFather(partitionPeauFissFond, edgesPeauFis[0], name) + j += 1 + + # ----------------------------------------------------------------------- + # --- identification faces de peau : face de peau percée du pipe, extrémités du pipe + # La partition avec le pipe peut créer un vertex (et un edge) de trop sur le cercle projeté, + # quand le cercle est très proche de la face. + # dans ce cas, la projection du cercle sur la face suivie d'une partition permet + # d'éviter le point en trop + + facesAndFond = facesOnside + facesAndFond.append(wireFondFiss) + try: + partitionPeauByPipe = geompy.MakePartition(facesAndFond, pipexts, [], [], geompy.ShapeType["FACE"], 0, [], 1) + except: + logging.debug("probleme partition face pipe, contournement avec MakeSection") + sections = [] + for pipext in pipexts: + sections.append(geompy.MakeSection(facesOnside[0], pipext)) + partitionPeauByPipe = geompy.MakePartition(facesAndFond, sections, [], [], geompy.ShapeType["FACE"], 0, [], 1) + + # contrôle edge en trop sur edges circulaires + if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau + edgeEnTrop = [] + outilPart = pipexts + facesPeau = geompy.ExtractShapes(partitionPeauByPipe, geompy.ShapeType["FACE"], False) + facesPeauSorted, minsur, maxsurf = sortFaces(facesPeau) + for i, face in enumerate(facesPeauSorted[:-1]): # on ne teste que la ou les petites faces "circulaires" + nbv = geompy.NumberOfEdges(face) + logging.debug("nombre d'edges sur face circulaire: %s", nbv) + if nbv > 3: + edgeEnTrop.append(True) # TODO : distinguer les cas avec deux faces circulaires dont l'une est correcte + else: + edgeEnTrop.append(False) + refaire = sum(edgeEnTrop) + if refaire > 0: + dc = [(geompy.MinDistance(verticesEdgesFondIn[0], fac), i) for i, fac in enumerate(facesPeauSorted[:-1])] + dc.sort() + logging.debug("dc sorted: %s", dc) + i0 = dc[0][1] # indice de facesPeauSorted qui correspond à verticesEdgesFondIn[0], donc 0 pour cercles + direct = (i0 == 0) + for i, bad in enumerate(edgeEnTrop): + if direct: + j = i + else: + j = 1-i + if bad: + outilPart[j] = geompy.MakeProjection(cercles[j],facesOnside[0]) + pass + partitionPeauByPipe = geompy.MakePartition(facesAndFond, outilPart, [], [], geompy.ShapeType["FACE"], 0, [], 1) + pass + + name="partitionPeauByPipe%d"%ifil + geompy.addToStudy(partitionPeauByPipe, name) + [edgesPeauFondIn, edgesPeauFondOut, edgesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3) + [facesPeauFondIn, facesPeauFondOut, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3) + + if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau + facesPeauSorted, minsur, maxsurf = sortFaces(facesPeauFondOn) + facePeau = facesPeauSorted[-1] # la plus grande face + else: + facePeau =geompy.MakePartition(facesPeauFondOn, [], [], [], geompy.ShapeType["FACE"], 0, [], 1) + name="facePeau%d"%ifil + geompy.addToStudy(facePeau, name) + + facesPipePeau = [None for i in range(len(edgesFissExtPipe))] + endsEdgeFond = [None for i in range(len(edgesFissExtPipe))] + edgeRadFacePipePeau = [None for i in range(len(edgesFissExtPipe))] + + edgesListees = [] + edgesCircPeau = [] + verticesCircPeau = [] + if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau + + for face in facesPeauSorted[:-1]: # la ou les faces débouchantes, pas la grande face de peau + logging.debug("examen face debouchante circulaire") + for i,efep in enumerate(edgesFissExtPipe): + dist = geompy.MinDistance(face, efep) + logging.debug(" distance face circulaire edge %s", dist) + if dist < 1e-3: + for ik, edpfi in enumerate(edgesPeauFondIn): + if geompy.MinDistance(face, edpfi) < 1e-3: + break + sharedVertices = geompy.GetSharedShapesMulti([face, edgesPeauFondIn[ik]], geompy.ShapeType["VERTEX"]) + nameFace = "facePipePeau%d"%i + nameVert = "endEdgeFond%d"%i + nameEdge = "edgeRadFacePipePeau%d"%i + facesPipePeau[i] = face + endsEdgeFond[i] = sharedVertices[0] + geompy.addToStudy(face, nameFace) + geompy.addToStudy(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 + geompy.addToStudy(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 + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(facePeau, grpVertCircPeau, name) + pass + pass # --- au moins une extrémité du pipe sur cette face de peau + + # --- edges de bord de la face de peau + + edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False) + edgesBords = [] + for i, edge in enumerate(edgesFilling): + edgepeau = geompy.GetInPlace(facePeau, edge) + name = "edgepeau%d"%i + geompy.addToStudyInFather(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: + bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC) + if bordsVifs is not None: + geompy.addToStudyInFather(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) + geompy.addToStudyInFather(facePeau, groupEdgesBordPeau , "EdgesBords") + + # --- edges de la face de peau partagées avec la face de fissure + + edgesPeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False) + edges = substractSubShapes(facePeau, edgesPeau, edgesListees) + edgesFissurePeau = [] + if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau + edgesFissurePeau = [None for i in range(len(verticesCircPeau))] # edges associés aux extrémités du pipe, en premier + for edge in edges: + for i, grpVert in enumerate(verticesCircPeau): + if (geompy.MinDistance(grpVert, edge) < 1.e-3) and (edge not in edgesFissurePeau): + edgesFissurePeau[i] = edge + name = "edgeFissurePeau%d"%i + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(facePeau, edge, name) + + + ptEdgeFond[ifil] = endsEdgeFond # pour chaque face [points edge fond de fissure aux débouchés du pipe] + fsPipePeau[ifil] = facesPipePeau # pour chaque face [faces du pipe débouchantes] + edRadFPiPo[ifil] = edgeRadFacePipePeau # pour chaque face [edge radiale des faces du pipe débouchantes ] + fsFissuExt[ifil] = facesFissExt # pour chaque face [faces de fissure externes au pipe] + edFisExtPe[ifil] = edgesFissExtPeau # pour chaque face [edge en peau des faces de fissure externes (pas subshape facePeau)] + edFisExtPi[ifil] = edgesFissExtPipe # pour chaque face [edge commun au pipe des faces de fissure externes] + facesPeaux[ifil] = facePeau # pour chaque face : la face de peau finale a mailler (percee des faces débouchantes) + edCircPeau[ifil] = edgesCircPeau # pour chaque face de peau : [groupe subshapes edges circulaires aux débouchés du pipe] + ptCircPeau[ifil] = verticesCircPeau # pour chaque face de peau : [groupe subshapes points sur edges circulaires aux débouchés du pipe] + gpedgeBord[ifil] = groupEdgesBordPeau # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine + gpedgeVifs[ifil] = bordsVifs # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives + edFissPeau[ifil] = edgesFissurePeau # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] + ptFisExtPi[ifil] = verticesPipePeau # pour chaque face de peau : [point commun edFissPeau edCircPeau] + + # ----------------------------------------------------------------------- + # fin de la boucle sur les faces de filling + # ----------------------------------------------------------------------- + + for i, avc in enumerate(aretesVivesCoupees): + name = "areteViveCoupee%d"%i + geompy.addToStudy(avc, name) + + # --- identification des faces et edges de fissure externe pour maillage + + facesFissExt = [] + edgesFissExtPeau = [] + edgesFissExtPipe = [] + for ifil in range(nbFacesFilling): # TODO: éliminer les doublons (comparer tous les vertices triés, avec mesure de distance ?) + facesFissExt += fsFissuExt[ifil] + edgesFissExtPeau += edFisExtPe[ifil] + edgesFissExtPipe += edFisExtPi[ifil] + logging.debug("---------------------------- identification faces de fissure externes au pipe :%s ", len(facesFissExt)) + # regroupement des faces de fissure externes au pipe. + + if len(facesFissExt) > 1: + faceFissureExterne = geompy.MakePartition(facesFissExt, [], [], [], geompy.ShapeType["FACE"], 0, [], 0) + edgesPipeFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesPipeFiss)) # edgesFissExtPipe peut ne pas couvrir toute la longueur + # edgesPeauFissureExterneC = geompy.GetInPlace(faceFissureExterne, geompy.MakeCompound(edgesFissExtPeau)) + # il peut manquer des edges de faceFissureExterne en contact avec la peau dans edgesFissExtPeau + (isDone, closedFreeBoundaries, openFreeBoundaries) = geompy.GetFreeBoundary(faceFissureExterne) + edgesBordFFE = [] + for bound in closedFreeBoundaries: + edgesBordFFE += geompy.ExtractShapes(bound, geompy.ShapeType["EDGE"], False) + edgesBordFFEid = [ (ed,geompy.GetSubShapeID(faceFissureExterne, ed)) for ed in edgesBordFFE] + logging.debug("edgesBordFFEid %s", edgesBordFFEid) + edgesPPE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False) + edgesPPEid = [ geompy.GetSubShapeID(faceFissureExterne, ed) for ed in edgesPPE] + logging.debug("edgesPPEid %s", edgesPPEid) + 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 %s", edgesPFE) + edgesPeauFissureExterneC = geompy.MakeCompound(edgesPFE) + else: + faceFissureExterne = facesFissExt[0] + edgesPeauFissureExterneC = geompy.MakeCompound(edgesFissExtPeau) + edgesPipeFissureExterneC = geompy.MakeCompound(edgesFissExtPipe) + wirePipeFissureExterne = geompy.MakeWire(geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False)) + geompy.addToStudy(faceFissureExterne, "faceFissureExterne") + geompy.addToStudyInFather(faceFissureExterne, edgesPeauFissureExterneC, "edgesPeauFissureExterne") + geompy.addToStudyInFather(faceFissureExterne, edgesPipeFissureExterneC, "edgesPipeFissureExterne") + + logging.debug("---------------------------- Preparation Maillage du Pipe --------------") + # ----------------------------------------------------------------------- + # --- preparation maillage du pipe : + # - détections des points a respecter : jonction des edges/faces constituant + # la face de fissure externe au pipe + # - points sur les edges de fond de fissure et edges pipe/face fissure, + # - vecteurs tangents au fond de fissure (normal au disque maillé) + + # --- option de maillage selon le rayon de courbure du fond de fissure + lenEdgeFondExt = 0 + for edff in edgesFondFiss: + lenEdgeFondExt += geompy.BasicProperties(edff)[0] + + disfond = [] + for filling in facesDefaut: + disfond.append(geompy.MinDistance(centreFondFiss, filling)) + disfond.sort() + rcourb = disfond[0] + nbSegQuart = 5 # on veut 5 segments min sur un quart de cercle + alpha = math.pi/(4*nbSegQuart) + deflexion = rcourb*(1.0 -math.cos(alpha)) + lgmin = lenSegPipe*0.25 + lgmax = lenSegPipe*1.5 + logging.debug("rcourb: %s, lenFond:%s, deflexion: %s, lgmin: %s, lgmax: %s", rcourb, lenEdgeFondExt, deflexion, lgmin, lgmax) + + meshFondExt = smesh.Mesh(wireFondFiss) + algo1d = meshFondExt.Segment() + hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure + isDone = meshFondExt.Compute() + + ptGSdic = {} # dictionnaire [paramètre sur la courbe] --> point géométrique + allNodeIds = meshFondExt.GetNodesId() + for nodeId in allNodeIds: + xyz = meshFondExt.GetNodeXYZ(nodeId) + #logging.debug("nodeId %s, coords %s", nodeId, str(xyz)) + pt = geompy.MakeVertex(xyz[0], xyz[1], xyz[2]) + u, PointOnEdge, EdgeInWireIndex = geompy.MakeProjectionOnWire(pt, wireFondFiss) # u compris entre 0 et 1 + edgeOrder = edgesIdByOrientation[EdgeInWireIndex] + ptGSdic[(edgeOrder, EdgeInWireIndex, u)] = pt + #logging.debug("nodeId %s, u %s", nodeId, str(u)) + usort = sorted(ptGSdic) + logging.debug("nombre de points obtenus par deflexion %s",len(usort)) + + centres = [] + origins = [] + normals = [] + for edu in usort: + ied = edu[1] + u = edu[2] + vertcx = ptGSdic[edu] + norm = geompy.MakeTangentOnCurve(edgesFondFiss[ied], u) + plan = geompy.MakePlane(vertcx, norm, 3*rayonPipe) + part = geompy.MakePartition([plan], [wirePipeFiss], [], [], geompy.ShapeType["VERTEX"], 0, [], 0) + liste = geompy.ExtractShapes(part, geompy.ShapeType["VERTEX"], True) + if len(liste) == 5: # 4 coins du plan plus intersection recherchée + for point in liste: + if geompy.MinDistance(point, vertcx) < 1.1*rayonPipe: # les quatre coins sont plus loin + vertpx = point + break + centres.append(vertcx) + origins.append(vertpx) + normals.append(norm) +# name = "vertcx%d"%i +# geompy.addToStudyInFather(wireFondFiss, vertcx, name) +# name = "vertpx%d"%i +# geompy.addToStudyInFather(wireFondFiss, vertpx, name) +# name = "plan%d"%i +# geompy.addToStudyInFather(wireFondFiss, plan, name) + + # --- maillage du pipe étendu, sans tenir compte de l'intersection avec la face de peau + + logging.debug("nbsegCercle %s", nbsegCercle) + + # ----------------------------------------------------------------------- + # --- points géométriques + + gptsdisks = [] # vertices géométrie de tous les disques + raydisks = [[] for i in range(nbsegCercle)] + for i in range(len(centres)): # boucle sur les disques + gptdsk = [] # vertices géométrie d'un disque + vertcx = centres[i] + vertpx = origins[i] + normal = normals[i] + vec1 = geompy.MakeVector(vertcx, vertpx) + + points = [vertcx] # les points du rayon de référence + for j in range(nbsegRad): + pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, (j+1)*float(rayonPipe)/nbsegRad) + points.append(pt) + gptdsk.append(points) + pt = geompy.MakeTranslationVectorDistance(vertcx, vec1, 1.5*rayonPipe) + rayon = geompy.MakeLineTwoPnt(vertcx, pt) + raydisks[0].append(rayon) + + for k in range(nbsegCercle-1): + angle = (k+1)*2*math.pi/nbsegCercle + pts = [vertcx] # les points d'un rayon obtenu par rotation + for j in range(nbsegRad): + pt = geompy.MakeRotation(points[j+1], normal, angle) + pts.append(pt) + gptdsk.append(pts) + ray = geompy.MakeRotation(rayon, normal, angle) + raydisks[k+1].append(ray) + + gptsdisks.append(gptdsk) + + # ----------------------------------------------------------------------- + # --- recherche des points en trop (externes au volume à remailler) + # - on associe chaque extrémité du pipe à une face filling + # - on part des disques aux extrémités du pipe + # - pour chaque disque, on prend les vertices de géométrie, + # on marque leur position relative à la face. + # - on s'arrete quand tous les noeuds sont dedans + + logging.debug("---------------------------- recherche des points du pipe a éliminer --------------") + + pt0 = centres[0] + pt1 = centres[-1] + idFillingFromBout = [None, None] # contiendra l'index du filling pour les extrémités 0 et 1 + for ifil in range(nbFacesFilling): + for ipt, pt in enumerate(ptEdgeFond[ifil]): # il y a un ou deux points débouchant sur cette face + if geompy.MinDistance(pt,pt0) < geompy.MinDistance(pt,pt1): # TODO: trouver plus fiable pour les cas tordus... + idFillingFromBout[0] = ifil + else: + idFillingFromBout[1] = ifil + logging.debug("association bouts du pipe - faces de filling: %s", idFillingFromBout) + + facesPipePeau = [] + edgeRadFacePipePeau = [] + for ifil in range(nbFacesFilling): + facesPipePeau += fsPipePeau[ifil] + edgeRadFacePipePeau += edRadFPiPo[ifil] + + logging.debug("recherche des disques de noeuds complètement internes") + idisklim = [] # indices des premier et dernier disques internes + idiskout = [] # indices des premier et dernier disques externes + for bout in range(2): + if bout == 0: + idisk = -1 + inc = 1 + numout = -1 + else: + idisk = len(gptsdisks) + inc = -1 + numout = len(gptsdisks) + inside = False + outside = True + while not inside: + idisk = idisk + inc + logging.debug("examen disque %s", idisk) + gptdsk = gptsdisks[idisk] + inside = True + for k in range(nbsegCercle): + points = gptdsk[k] + for j, pt in enumerate(points): + side = whichSideVertex(facesDefaut[idFillingFromBout[bout]], pt) + if side < 0: + if outside: # premier point detecté dedans + outside = False + numout = idisk -inc # le disque précédent était dehors + else: + inside = False # ce point est dehors + if not inside and not outside: + break + idisklim.append(idisk) # premier et dernier disques internes + idiskout.append(numout) # premier et dernier disques externes + + # --- listes de nappes radiales en filling à chaque extrémité débouchante + facesDebouchantes = [False, False] + idFacesDebouchantes = [-1, -1] # contiendra les indices des faces disque débouchantes (facesPipePeau) + listNappes =[] + for i, idisk in enumerate(idisklim): + numout = idiskout[i] + logging.debug("extremité %s, indices disques interne %s, externe %s",i, idisk, numout) + nappes = [] + if (idisk != 0) and (idisk != len(gptsdisks)-1): # si extrémité débouchante + for k in range(nbsegCercle): + if i == 0: + iddeb = max(0, numout) + idfin = max(iddeb+3,idisk+1) # il faut 3 rayons pour faire un filling qui suive le fond de fissure + #logging.debug("extremité %s, indices retenus interne %s, externe %s",i, idfin, iddeb) + comp = geompy.MakeCompound(raydisks[k][iddeb:idfin]) + name='compoundRay%d'%k + geompy.addToStudy(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 + geompy.addToStudy(comp, name) + nappe = geompy.MakeFilling(comp, 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default) + nappes.append(nappe) + name='nappe%d'%k + geompy.addToStudy(nappe, name) + facesDebouchantes[i] = True + listNappes.append(nappes) + + # --- 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): + 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): + id = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau) + if id < 0: + listEdges.append([]) + else: + face = facesPipePeau[id] + edges = [edgeRadFacePipePeau[id]] + 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, minl,maxl] = sortEdges(eds) + edge = edsorted[-1] + else: + maxl = geompy.BasicProperties(edge)[0] + if maxl < 0.01: # problème MakeSection + logging.debug("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): + 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) + logging.debug(" dmax %s",dmax) + if dmax < 0.01: + ednouv.append(ed) + logging.debug(" edges issues de la partition: %s", ednouv) + for ii, ed in enumerate(ednouv): + geompy.addToStudy(ed, "ednouv%d"%ii) + [edsorted, minl,maxl] = sortEdges(ednouv) + logging.debug(" longueur edge trouvée: %s", maxl) + edge = edsorted[-1] + edges.append(edge) + name = 'edgeEndPipe%d'%k + geompy.addToStudy(edge, name) + listEdges.append(edges) + + # --- création des points du maillage du pipe sur la face de peau + for i, edges in enumerate(listEdges): + id = idFacesDebouchantes[i] # indice de face débouchante (facesPipePeau) + if id >= 0: + gptdsk = [] + if id > 0: # id vaut 0 ou 1 + id = -1 # si id 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]][id] + name = "centre%d"%id + geompy.addToStudy(centre, name) + vertPipePeau = ptFisExtPi[idFillingFromBout[i]][id] + geompy.addToStudyInFather(centre, vertPipePeau, "vertPipePeau") + grpsEdgesCirc = edCircPeau[idFillingFromBout[i]] # liste de groupes + edgesCirc = [] + for grpEdgesCirc in grpsEdgesCirc: + edgesCirc += geompy.ExtractShapes(grpEdgesCirc, geompy.ShapeType["EDGE"], False) + for k, edge in enumerate(edges): + extrems = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True) + if geompy.MinDistance(centre, extrems[0]) < geompy.MinDistance(centre, extrems[1]): + bout = extrems[1] + else: + bout = extrems[0] + # ajustement du point extrémité (bout) sur l'edge circulaire en face de peau + logging.debug("edgesCirc: %s", edgesCirc) + distEdgeCirc = [(geompy.MinDistance(bout, edgeCirc), k2, edgeCirc) for k2, edgeCirc in enumerate(edgesCirc)] + distEdgeCirc.sort() + logging.debug("distEdgeCirc: %s", distEdgeCirc) + u = projettePointSurCourbe(bout, distEdgeCirc[0][2]) + if (abs(u) < 0.02) or (abs(1-u) < 0.02): # les points très proches d'une extrémité doivent y être mis précisément. + extrCircs = geompy.ExtractShapes(distEdgeCirc[0][2], geompy.ShapeType["VERTEX"], True) + if geompy.MinDistance(bout, extrCircs[0]) < geompy.MinDistance(bout, extrCircs[1]): + bout = extrCircs[0] + else: + bout = extrCircs[1] + pass + else: + bout = geompy.MakeVertexOnCurve(distEdgeCirc[0][2], u) + name ="bout%d"%k + geompy.addToStudyInFather(centre, bout, name) + # enregistrement des points dans la structure + points = [] + for j in range(nbsegRad +1): + u = j/float(nbsegRad) + points.append(geompy.MakeVertexOnCurve(edge, u)) + if geompy.MinDistance(bout, points[0]) < geompy.MinDistance(centre, points[0]): + points.reverse() + points[0] = centre + points[-1] = bout + gptdsk.append(points) + if i == 0: + gptsdisks[idisklim[0] -1] = gptdsk + idisklim[0] = idisklim[0] -1 + else: + gptsdisks[idisklim[1] +1] = gptdsk + idisklim[1] = idisklim[1] +1 + + # --- ajustement precis des points sur edgesPipeFissureExterneC + + edgesPFE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False) + verticesPFE = findWireIntermediateVertices(wirePipeFissureExterne) # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe) + idiskmin = idisklim[0] + 1 # on ne prend pas le disque sur la peau, déjà ajusté + idiskmax = idisklim[1] # on ne prend pas le disque sur la peau, déjà ajusté + idiskint = [] + for vtx in verticesPFE: + distPtVt = [] + for idisk in range(idiskmin, idiskmax): + gptdsk = gptsdisks[idisk] + pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe + distPtVt.append((geompy.MinDistance(pt, vtx), idisk)) + distPtVt.sort() + idiskint.append(distPtVt[0][1]) + gptsdisks[idiskint[-1]][0][-1] = vtx + logging.debug("ajustement point sur edgePipeFissureExterne, vertex: %s %s", idiskint[-1], distPtVt[0][0]) + for idisk in range(idiskmin, idiskmax): + if idisk in idiskint: + break + logging.debug("ajustement point sur edgePipeFissureExterne: %s", idisk) + gptdsk = gptsdisks[idisk] + pt = gptdsk[0][-1] # le point sur l'edge de la fissure externe au pipe + distPtEd = [(geompy.MinDistance(pt, edgePFE), k, edgePFE) for k, edgePFE in enumerate(edgesPFE)] + distPtEd.sort() + edgePFE = distPtEd[0][2] + u = projettePointSurCourbe(pt, edgePFE) + ptproj = geompy.MakeVertexOnCurve(edgePFE, u) + gptsdisks[idisk][0][-1] = ptproj + + # ----------------------------------------------------------------------- + # --- maillage effectif du pipe + + logging.debug("---------------------------- maillage effectif du pipe --------------") + meshPipe = smesh.Mesh(None, "meshPipe") + fondFissGroup = meshPipe.CreateEmptyGroup(SMESH.EDGE, "FONDFISS") + nodesFondFissGroup = meshPipe.CreateEmptyGroup(SMESH.NODE, "nfondfis") + faceFissGroup = meshPipe.CreateEmptyGroup(SMESH.FACE, "fisInPi") + edgeFaceFissGroup = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeFaceFiss") + edgeCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeCircPipe0") + edgeCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeCircPipe1") + faceCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe0") + faceCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe1") + mptsdisks = [] # vertices maillage de tous les disques + mEdges = [] # identifiants edges maillage fond de fissure + mEdgeFaces = [] # identifiants edges maillage edge face de fissure externe + mFaces = [] # identifiants faces maillage fissure + mVols = [] # identifiants volumes maillage pipe + + mptdsk = None + for idisk in range(idisklim[0], idisklim[1]+1): # boucle sur les disques internes + + # ----------------------------------------------------------------------- + # --- points + + gptdsk = gptsdisks[idisk] + if idisk > idisklim[0]: + oldmpts = mptdsk + mptdsk = [] # vertices maillage d'un disque + for k in range(nbsegCercle): + points = gptdsk[k] + mptids = [] + 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 + + if idisk == idisklim[0]: + pts = [] + for k in range(nbsegCercle): + pts.append(mptdsk[k][-1]) + edges = [] + for k in range(len(pts)): + k1 = (k+1)%len(pts) + idEdge = meshPipe.AddEdge([pts[k], pts[k1]]) + edges.append(idEdge) + edgeCircPipe0Group.Add(edges) + + if idisk == idisklim[1]: + pts = [] + for k in range(nbsegCercle): + pts.append(mptdsk[k][-1]) + edges = [] + for k in range(len(pts)): + k1 = (k+1)%len(pts) + idEdge = meshPipe.AddEdge([pts[k], pts[k1]]) + edges.append(idEdge) + edgeCircPipe1Group.Add(edges) + + # ----------------------------------------------------------------------- + # --- groupes faces debouchantes + + if idisk == idisklim[0]: + faces = [] + for j in range(nbsegRad): + for k in range(nbsegCercle): + k1 = k+1 + if k == nbsegCercle-1: + k1 = 0 + if j == 0: + idf = meshPipe.AddFace([mptdsk[k][0], mptdsk[k][1], mptdsk[k1][1]]) # triangle + else: + idf = meshPipe.AddFace([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j]]) # quadrangle + faces.append(idf) + faceCircPipe0Group.Add(faces) + + if idisk == idisklim[1]: + faces = [] + 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 + + if idisk == idisklim[0]: + mEdges.append(0) + mEdgeFaces.append(0) + mFaces.append([0]) + mVols.append([[0]]) + nodesFondFissGroup.Add([mptdsk[0][0]]) + else: + ide = meshPipe.AddEdge([oldmpts[0][0], mptdsk[0][0]]) + mEdges.append(ide) + fondFissGroup.Add([ide]) + nodesFondFissGroup.Add([mptdsk[0][0]]) + ide2 = meshPipe.AddEdge([oldmpts[0][-1], mptdsk[0][-1]]) + mEdgeFaces.append(ide2) + edgeFaceFissGroup.Add([ide2]) + idFaces = [] + idVols = [] + + 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 = [] + 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' ) + nbAdd = pipeFissGroup.AddFrom( meshPipe.GetMesh() ) + + nb, new_mesh, new_group = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries") + edgesCircPipeGroup = [edgeCircPipe0Group, edgeCircPipe1Group] + + # --- fin du maillage du pipe + # ----------------------------------------------------------------------- + # --- edges de bord, faces défaut à respecter + + aFilterManager = smesh.CreateFilterManager() + nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ]) + criteres = [] + 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 à ne pas mettre de pyramides à l'exterieur des volumes repliés sur eux-mêmes + # on désigne les faces de peau en quadrangles par le groupe "skinFaces" + + skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' ) + nbAdd = skinFaces.AddFrom( internalBoundary.GetMesh() ) + + # --- maillage des éventuelles arêtes vives entre faces reconstruites + + if len(aretesVivesCoupees) > 0: + aretesVivesC = geompy.MakeCompound(aretesVivesCoupees) + meshAretesVives = smesh.Mesh(aretesVivesC) + algo1d = meshAretesVives.Segment() + hypo1d = algo1d.LocalLength(dmoyen/3.0,[],1e-07) + putName(algo1d.GetSubMesh(), "aretesVives") + putName(algo1d, "algo1d_aretesVives") + putName(hypo1d, "hypo1d_aretesVives") + isDone = meshAretesVives.Compute() + logging.info("aretesVives fini") + grpAretesVives = meshAretesVives.CreateEmptyGroup( SMESH.EDGE, 'grpAretesVives' ) + nbAdd = grpAretesVives.AddFrom( meshAretesVives.GetMesh() ) + + # ----------------------------------------------------------------------- + # --- maillage faces de fissure + + logging.debug("---------------------------- maillage faces de fissure externes au pipe :%s --------------", len(facesFissExt)) + + meshFaceFiss = smesh.Mesh(faceFissureExterne) + algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_1D2D) + hypo2d = algo2d.Parameters() + hypo2d.SetMaxSize( areteFaceFissure ) + hypo2d.SetSecondOrder( 0 ) + hypo2d.SetOptimize( 1 ) + hypo2d.SetFineness( 2 ) + hypo2d.SetMinSize( rayonPipe/float(nbsegRad) ) + hypo2d.SetQuadAllowed( 0 ) + putName(algo2d.GetSubMesh(), "faceFiss") + putName(algo2d, "algo2d_faceFiss") + putName(hypo2d, "hypo2d_faceFiss") + + algo1d = meshFaceFiss.UseExisting1DElements(geom=edgesPipeFissureExterneC) + hypo1d = algo1d.SourceEdges([ edgeFaceFissGroup ],0,0) + putName(algo1d.GetSubMesh(), "edgeFissPeau") + putName(algo1d, "algo1d_edgeFissPeau") + putName(hypo1d, "hypo1d_edgeFissPeau") + + isDone = meshFaceFiss.Compute() + logging.info("meshFaceFiss fini") + + grpFaceFissureExterne = meshFaceFiss.GroupOnGeom(faceFissureExterne, "fisOutPi", SMESH.FACE) + grpEdgesPeauFissureExterne = meshFaceFiss.GroupOnGeom(edgesPeauFissureExterneC,'edgesPeauFissureExterne',SMESH.EDGE) + grpEdgesPipeFissureExterne = meshFaceFiss.GroupOnGeom(edgesPipeFissureExterneC,'edgesPipeFissureExterne',SMESH.EDGE) + + # --- maillage faces de peau + + boutFromIfil = [None for i in range(nbFacesFilling)] + if idFillingFromBout[0] != idFillingFromBout[1]: # repérage des extremites du pipe quand elles débouchent sur des faces différentes + boutFromIfil[idFillingFromBout[0]] = 0 + boutFromIfil[idFillingFromBout[1]] = 1 + + logging.debug("---------------------------- maillage faces de peau --------------") + meshesFacesPeau = [] + for ifil in range(nbFacesFilling): + meshFacePeau = None + if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte + + # --- edges de bord de la face de filling + filling = facesDefaut[ifil] + edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False) + groupEdgesBordPeau = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"]) + geompy.UnionList(groupEdgesBordPeau, edgesFilling) + geompy.addToStudyInFather(filling, groupEdgesBordPeau , "EdgesBords") + + meshFacePeau = smesh.Mesh(facesDefaut[ifil]) + + algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau) + hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0) + putName(algo1d.GetSubMesh(), "bordsLibres", ifil) + putName(algo1d, "algo1d_bordsLibres", ifil) + putName(hypo1d, "hypo1d_bordsLibres", ifil) + + else: + + facePeau = facesPeaux[ifil] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes) + edgesCircPeau = edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe] + verticesCircPeau = ptCircPeau[ifil] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe] + groupEdgesBordPeau = gpedgeBord[ifil] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine + bordsVifs = gpedgeVifs[ifil] # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives + edgesFissurePeau = edFissPeau[ifil] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] + + meshFacePeau = smesh.Mesh(facePeau) + + algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau) + hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0) + putName(algo1d.GetSubMesh(), "bordsLibres", ifil) + putName(algo1d, "algo1d_bordsLibres", ifil) + putName(hypo1d, "hypo1d_bordsLibres", ifil) + + algo1d = meshFacePeau.UseExisting1DElements(geom=geompy.MakeCompound(edgesFissurePeau)) + hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0) + putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil) + putName(algo1d, "algo1d_edgePeauFiss", ifil) + putName(hypo1d, "hypo1d_edgePeauFiss", ifil) + + if bordsVifs is not None: + algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs) + hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0) + putName(algo1d.GetSubMesh(), "bordsVifs", ifil) + putName(algo1d, "algo1d_bordsVifs", ifil) + putName(hypo1d, "hypo1d_bordsVifs", ifil) + + for i, edgeCirc in enumerate(edgesCircPeau): + if edgeCirc is not None: + algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc) + if boutFromIfil[ifil] is None: + hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i] ],0,0) + else: + hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0) + name = "cercle%d"%i + putName(algo1d.GetSubMesh(), name, ifil) + putName(algo1d, "algo1d_" + name, ifil) + putName(hypo1d, "hypo1d_" + name, ifil) + + algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_1D2D) + hypo2d = algo2d.Parameters() + hypo2d.SetMaxSize( dmoyen ) + hypo2d.SetOptimize( 1 ) + hypo2d.SetFineness( 2 ) + hypo2d.SetMinSize( rayonPipe/float(nbsegRad) ) + hypo2d.SetQuadAllowed( 0 ) + putName(algo2d.GetSubMesh(), "facePeau", ifil) + putName(algo2d, "algo2d_facePeau", ifil) + putName(hypo2d, "hypo2d_facePeau", ifil) + + isDone = meshFacePeau.Compute() + logging.info("meshFacePeau %d fini", ifil) + GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil ) + nbAdd = GroupFaces.AddFrom( meshFacePeau.GetMesh() ) + meshesFacesPeau.append(meshFacePeau) + + # --- regroupement des maillages du défaut + + listMeshes = [internalBoundary.GetMesh(), + meshPipe.GetMesh(), + meshFaceFiss.GetMesh()] + for mp in meshesFacesPeau: + listMeshes.append(mp.GetMesh()) + + meshBoiteDefaut = smesh.Concatenate(listMeshes, 1, 1, 1e-05,False) + # pour aider l'algo hexa-tetra à ne pas mettre de pyramides à l'exterieur des volumes repliés sur eux-mêmes + # on désigne 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 ==> utiliser GHS3D + distene=True + if distene: + algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.GHS3D) + else: + algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN) + hypo3d = algo3d.MaxElementVolume(1000.0) + putName(algo3d.GetSubMesh(), "boiteDefaut") + putName(algo3d, "algo3d_boiteDefaut") + isDone = meshBoiteDefaut.Compute() + putName(meshBoiteDefaut, "boiteDefaut") + logging.info("meshBoiteDefaut fini") + + 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(facesPortFissure) + maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut, + None, None, 'COMPLET', normfiss) + + logging.info("conversion quadratique") + maillageComplet.ConvertToQuadratic( 1 ) + logging.info("groupes") + groups = maillageComplet.GetGroups() + grps = [ grp for grp in groups if grp.GetName() == 'FONDFISS'] + fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FONDFISS' ) + + logging.info("réorientation face de fissure FACE1") + grps = [ grp for grp in groups if grp.GetName() == 'FACE1'] + nb = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1)) + + logging.info("réorientation face de fissure FACE2") + plansim = geompy.MakePlane(O, normfiss, 10000) + fissnorm = geompy.MakeMirrorByPlane(normfiss, plansim) + grps = [ grp for grp in groups if grp.GetName() == 'FACE2'] + nb = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1)) + fond = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' ) + + logging.info("export maillage fini") + maillageComplet.ExportMED( fichierMaillageFissure, 0, SMESH.MED_V2_2, 1 ) + putName(maillageComplet, nomFicFissure) + logging.info("fichier maillage fissure %s", fichierMaillageFissure) + + if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + + logging.info("maillage fissure fini") + + return maillageComplet diff --git a/src/Tools/blocFissure/gmu/insereFissureLongue.py b/src/Tools/blocFissure/gmu/insereFissureLongue.py new file mode 100644 index 000000000..ec8307c9d --- /dev/null +++ b/src/Tools/blocFissure/gmu/insereFissureLongue.py @@ -0,0 +1,656 @@ +# -*- coding: utf-8 -*- + +import logging +import salome +from geomsmesh import geompy +from geomsmesh import smesh +from salome.smesh import smeshBuilder +import SMESH +import math + +from extractionOrientee import extractionOrientee +from sortFaces import sortFaces +from sortEdges import sortEdges +from eliminateDoubles import eliminateDoubles +from substractSubShapes import substractSubShapes +from produitMixte import produitMixte +from findWireEndVertices import findWireEndVertices +from getSubshapeIds import getSubshapeIds +from putName import putName +from distance2 import distance2 +from enleveDefaut import enleveDefaut +from shapeSurFissure import shapeSurFissure +from regroupeSainEtDefaut import RegroupeSainEtDefaut +from triedreBase import triedreBase + +# ----------------------------------------------------------------------------- +# --- procedure complete fissure longue + +def insereFissureLongue(geometriesSaines, maillagesSains, + shapesFissure, shapeFissureParams, + maillageFissureParams, elementsDefaut, step=-1): + """ + TODO: a completer + """ + logging.info('start') + + #geometrieSaine = geometriesSaines[0] + #maillageSain = maillagesSains[0] + #isHexa = maillagesSains[1] + shapeDefaut = shapesFissure[0] # face de fissure, debordant + #tailleDefaut = shapesFissure[2] + wiretube = shapesFissure[4] # wire fond de fissure, debordant + planfiss = shapesFissure[7] # plan de fissure + pipefiss = shapesFissure[8] # pipe, debordant + + profondeur = shapeFissureParams['profondeur'] + rayonPipe = profondeur/4.0 + + nomRep = maillageFissureParams['nomRep'] + nomFicSain = maillageFissureParams['nomFicSain'] + nomFicFissure = maillageFissureParams['nomFicFissure'] + + #nbsegExt = maillageFissureParams['nbsegExt'] # 5 + #nbsegGen = maillageFissureParams['nbsegGen'] # 25 + #nbsegRad = maillageFissureParams['nbsegRad'] # 5 + #scaleRad = maillageFissureParams['scaleRad'] # 4 + #nbsegCercle = maillageFissureParams['nbsegCercle'] # 6 + #nbsegFis = maillageFissureParams['nbsegFis'] # 20 + #lensegEllipsoide = maillageFissureParams['lensegEllipso'] # 1.0 + + #fichierMaillageSain = nomRep + '/' + nomFicSain + '.med' + fichierMaillageFissure = nomRep + '/' + nomFicFissure + '.med' + + facesDefaut = elementsDefaut[0] + #centreDefaut = elementsDefaut[1] + #normalDefaut = elementsDefaut[2] + #extrusionDefaut = elementsDefaut[3] + #dmoyen = elementsDefaut[4] + #bordsPartages = elementsDefaut[5] + #fillconts = elementsDefaut[6] + #idFilToCont = elementsDefaut[7] + maillageSain = elementsDefaut[8] + internalBoundary = elementsDefaut[9] + zoneDefaut = elementsDefaut[10] + zoneDefaut_skin = elementsDefaut[11] + zoneDefaut_internalFaces = elementsDefaut[12] + zoneDefaut_internalEdges = elementsDefaut[13] + + facePorteFissure = shapeDefaut + WirePorteFondFissure = wiretube + fillingFaceExterne = facesDefaut[0] + print fillingFaceExterne + geompy.addToStudy(fillingFaceExterne, "fillingFaceExterne") + edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False) + + O, OX, OY, OZ = triedreBase() + + # ----------------------------------------------------------------------------- + # --- peau et face de fissure + + # --- partition peau defaut - face de fissure prolongee - wire de fond de fissure prolongée + partitionPeauFissFond = geompy.MakePartition([facePorteFissure, WirePorteFondFissure, fillingFaceExterne], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) + geompy.addToStudy( partitionPeauFissFond, 'partitionPeauFissFond' ) + + edges = geompy.ExtractShapes(WirePorteFondFissure, geompy.ShapeType["EDGE"], False) + + lgmax = 0 + imax = 0 + for i, edge in enumerate(edges): + props = geompy.BasicProperties(edge) + lg = props[0] + if lg > lgmax: + lgmax = lg + imax = i + edgemax = edges[imax] + geompy.addToStudy(edgemax, 'edgemax') + centreFondFiss = geompy.MakeVertexOnCurve(edgemax, 0.5) + geompy.addToStudy(centreFondFiss, 'centreFondFiss') + tangentFondFiss = geompy.MakeTangentOnCurve(edgemax, 0.5) + geompy.addToStudy(tangentFondFiss, 'tangentFondFiss') + + bord1FondFiss = geompy.MakeVertexOnCurve(edgemax, 0.0) + geompy.addToStudy(bord1FondFiss, 'bord1FondFiss') + tangentBord1FondFiss = geompy.MakeTangentOnCurve(edgemax, 0.0) + geompy.addToStudy(tangentBord1FondFiss, 'tangentBord1FondFiss') + + bord2FondFiss = geompy.MakeVertexOnCurve(edgemax, 1.0) + geompy.addToStudy(bord2FondFiss, 'bord2FondFiss') + tangentBord2FondFiss = geompy.MakeTangentOnCurve(edgemax, 1.0) + geompy.addToStudy(tangentBord2FondFiss, 'tangentBord2FondFiss') + + planBord1 = geompy.MakePlane(bord1FondFiss, tangentBord1FondFiss, 3*rayonPipe) + planBord2 = geompy.MakePlane(bord2FondFiss, tangentBord2FondFiss, 3*rayonPipe) + geompy.addToStudy(planBord1, 'planBord1') + geompy.addToStudy(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], [], [], geompy.ShapeType["FACE"], 0, [], 0) + geompy.addToStudy( 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 + geompy.addToStudyInFather(partitionPeauFissByPipe, facePeau, "facePeau") + + # --- identification edges de bord face peau + edgesBords = [] + 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) + geompy.addToStudyInFather(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] + geompy.addToStudyInFather(partitionPeauFissByPipe, faceFiss, "faceFiss") + geompy.addToStudyInFather(faceFiss, edgePeauFiss, "edgePeauFiss") + geompy.addToStudyInFather(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 = [] + for i, edge in enumerate(demiCerclesPeau): + name = "demiCerclePeau_%d"%i + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(facePeau, vertex, name) + verticesOutCercles = substractSubShapes(facePeau, verticesDemiCerclesPeau, verticesEdgePeauFiss) + for i, vertex in enumerate(verticesOutCercles): + name = "verticesOutCercles_%d"%i + geompy.addToStudyInFather(facePeau, vertex, name) + + # --- demi cercles regroupés + groupsDemiCerclesPeau = [] + for i, vertex in enumerate(verticesEdgePeauFiss): + demis = [] + 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 + geompy.addToStudyInFather(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 = [] + for edge in edgesFaceFiss: + if geompy.GetSubShapeID(partitionPeauFissByPipe, edge) != edgePeauFissId: + edgesFaceFissPipe.append(edge) + name = "edgeFaceFissPipe_%d"%len(edgesFaceFissPipe) + geompy.addToStudyInFather(faceFiss, edge, name) + groupEdgesFaceFissPipe = geompy.CreateGroup(faceFiss, geompy.ShapeType["EDGE"]) + geompy.UnionList(groupEdgesFaceFissPipe, edgesFaceFissPipe) + geompy.addToStudyInFather(faceFiss, groupEdgesFaceFissPipe, "edgesFaceFissPipe") + + # ----------------------------------------------------------------------------- + # --- pipe de fond de fissure + + wireFondFiss = geompy.MakeWire(edgesInside, 1e-07) + + disque = geompy.MakeDiskPntVecR(centreFondFiss, tangentFondFiss, rayonPipe) + [vertex] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False) + vertproj = geompy.MakeProjection(vertex, planfiss) + vec1 = geompy.MakeVector(centreFondFiss, vertex) + try: + # si centreFondFiss et vertproj sont proches: exception. Angle = +- 90° + vec2 = geompy.MakeVector(centreFondFiss, vertproj) + angle = geompy.GetAngleRadians(vec1, vec2) + except: + # on utilise la projection du centre sur la peau pour avoir un vecteur non nul + vertproj = geompy.MakeProjection(centreFondFiss, facePeau) + vec2 = geompy.MakeVector(centreFondFiss, vertproj) + angle = geompy.GetAngleRadians(vec1, vec2) + sommetAxe = geompy.MakeTranslationVector(centreFondFiss, tangentFondFiss) + pm = produitMixte(centreFondFiss, vertex, vertproj, sommetAxe) + if pm > 0: + disque = geompy.MakeRotation(disque, tangentFondFiss, angle) + else: + disque = geompy.MakeRotation(disque, tangentFondFiss, -angle) + [vertexReference] = geompy.ExtractShapes(disque, geompy.ShapeType["VERTEX"], False) + + pipeFondFiss = geompy.MakePipe(disque, wireFondFiss) + pipeFondFiss = geompy.MakePartition([pipeFondFiss], [planfiss, wireFondFiss, planBord1, planBord2], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + #pipe = geompy.MakePipe(disque, WirePorteFondFissure) + #pipe = geompy.MakePartition([pipe],[fillingFaceExterne], [], [], geompy.ShapeType["SOLID"], 0, [], 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], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + + geompy.addToStudy( disque, 'disque') + geompy.addToStudy( wireFondFiss, 'wireFondFiss') + geompy.addToStudy( pipeFondFiss, 'pipeFondFiss') + + VerticesEndFondFiss = findWireEndVertices(wireFondFiss) + for i, v in enumerate(VerticesEndFondFiss): + name = "vertexEndFondFiss_%d"%i + geompy.addToStudyInFather(wireFondFiss, v, name) + VerticesEndPipeFiss = [] + for v in VerticesEndFondFiss: + VerticesEndPipeFiss.append(geompy.GetInPlace(pipeFondFiss, v)) + for i, v in enumerate(VerticesEndPipeFiss): + name = "vertexEndPipeFiss_%d"%i + geompy.addToStudyInFather(pipeFondFiss, v, name) + + geompy.addToStudyInFather(pipeFondFiss, VerticesEndPipeFiss[0], "PFOR") + geompy.addToStudyInFather(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 + geompy.addToStudyInFather(facePeau, verticesOutCercles[0], "THOR") + geompy.addToStudyInFather(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)) + geompy.addToStudy(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 = [] + demiCercles = [] + 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 = [] + 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 = [] + 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) + geompy.addToStudyInFather(pipeFondFiss, groupGenerFiss, "GenFiss") + + # --- demi cercles externes regroupés + groupsDemiCerclesPipe = [] + for i, vertex in enumerate(verticesEdgePeauFiss): + demis = [] + 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 + geompy.addToStudyInFather(pipeFondFiss, group , name) + groupsDemiCerclesPipe.append(group) + + # --- faces fissure dans le pipe + + facesFissinPipe = [] + 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 + geompy.addToStudyInFather(pipeFondFiss, face, name) + break + groupFaceFissInPipe = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["FACE"]) + geompy.UnionList(groupFaceFissInPipe, facesFissinPipe) + name = "FaceFissInPipe" + geompy.addToStudyInFather(pipeFondFiss, groupFaceFissInPipe , name) + + # --- edges de fond de fissure + + edgesFondFiss = [] + for i, edge in enumerate(edgesInside): + anEdge = geompy.GetInPlace(pipeFondFiss, edge) + logging.debug(" edge %s ", anEdge) + edgesFondFiss.append(anEdge) + name ="edgeFondFissure_%d"%i + geompy.addToStudyInFather(pipeFondFiss, anEdge, name) + groupEdgeFondFiss = geompy.CreateGroup(pipeFondFiss, geompy.ShapeType["EDGE"]) + geompy.UnionList(groupEdgeFondFiss, edgesFondFiss) + name = "FONDFISS" + geompy.addToStudyInFather(pipeFondFiss, groupEdgeFondFiss , name) + + # ------------------------------------------------------------------------- + # --- maillage + + # --- edges de bord face defaut à respecter + + aFilterManager = smesh.CreateFilterManager() + nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ]) + criteres = [] + 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 + + meshFondFiss = smesh.Mesh(pipeFondFiss) + algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE) + algo3d = meshFondFiss.Prism() + putName(algo3d.GetSubMesh(), "pipe") + putName(algo3d, "algo3d_pipe") + putName(algo2d, "algo2d_pipe") + + for i, face in enumerate(disques): + algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face) + putName(algo2d.GetSubMesh(), "disque", i) + putName(algo2d, "algo2d_disque", i) + + for i, edge in enumerate(rayons): + algo1d = meshFondFiss.Segment(geom=edge) + hypo1d = algo1d.NumberOfSegments(4) + putName(algo1d.GetSubMesh(), "rayon", i) + putName(algo1d, "algo1d_rayon", i) + putName(hypo1d, "hypo1d_rayon", i) + + for i, edge in enumerate(demiCercles): + algo1d = meshFondFiss.Segment(geom=edge) + hypo1d = algo1d.NumberOfSegments(6) + putName(algo1d.GetSubMesh(), "demiCercle", i) + putName(algo1d, "algo1d_demiCercle", i) + putName(hypo1d, "hypo1d_demiCercle", i) + + generSorted, minlg, maxlg = sortEdges(generatrices) + nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face + nbSegGenBout = 6 + logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted)) + for i, edge in enumerate(generSorted): + algo1d = meshFondFiss.Segment(geom=edge) + if i < 6: + hypo1d = algo1d.NumberOfSegments(nbSegGenBout) + else: + hypo1d = algo1d.NumberOfSegments(nbSegGenLong) + putName(algo1d.GetSubMesh(), "generatrice", i) + putName(algo1d, "algo1d_generatrice", i) + putName(hypo1d, "hypo1d_generatrice", i) + isDone = meshFondFiss.Compute() + logging.info("meshFondFiss computed") + + disks = [] + for i, face in enumerate(disques[:4]): + name = "disk%d"%i + disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE)) + peauext_pipe = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' ) + + grpPFOR = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE) + grpPFEX = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE) + + grp = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE) + group_edgeFondFiss = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE) + noeudsFondFissure = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE) + groups_demiCercles = [] + groupnodes_demiCercles = [] + 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) + 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 = [] + coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0)) + coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1)) + coordsGeom = [] + 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] = 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]) + + + # --- maillage face de peau + + meshFacePeau = smesh.Mesh(facePeau) + algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D) + hypo2d = algo2d.Parameters() + hypo2d.SetMaxSize( 1000 ) + hypo2d.SetOptimize( 1 ) + hypo2d.SetFineness( 2 ) + hypo2d.SetMinSize( 2 ) + hypo2d.SetQuadAllowed( 0 ) + putName(algo2d.GetSubMesh(), "facePeau") + putName(algo2d, "algo2d_facePeau") + putName(hypo2d, "hypo2d_facePeau") + # + lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0] + frac = profondeur/lenEdgePeauFiss + nbSeg = nbSegGenLong +2*nbSegGenBout + ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss) + logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio) + algo1d = meshFacePeau.Segment(geom=edgePeauFiss) + hypo1d = algo1d.NumberOfSegments(nbSeg,[],[ ]) + 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) + # + isDone = meshFacePeau.Compute() + logging.info("meshFacePeau computed") + grpTHOR = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE) + grpTHEX = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE) + + groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE) + + peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' ) + nbAdd = peauext_face.AddFrom( meshFacePeau.GetMesh() ) + + + # --- maillage face de fissure + + meshFaceFiss = smesh.Mesh(faceFiss) + algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D) + hypo2d = algo2d.Parameters() + hypo2d.SetMaxSize( (profondeur - rayonPipe)/math.sqrt(3.0) ) # pour avoir deux couches de triangles equilateraux partout sur la fissure + 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") + # + isDone = meshFaceFiss.Compute() + logging.info("meshFaceFiss computed") + + grp = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE) + + 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 ==> utiliser GHS3D + distene=True + if distene: + algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.GHS3D) + else: + algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN) + hypo3d = algo3d.MaxElementVolume(1000.0) + putName(algo3d.GetSubMesh(), "boiteDefaut") + putName(algo3d, "algo3d_boiteDefaut") + isDone = meshBoiteDefaut.Compute() + logging.info("meshBoiteDefaut computed") + putName(meshBoiteDefaut, "boiteDefaut") + + 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) + + 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, 0, SMESH.MED_V2_2, 1 ) + putName(maillageComplet, nomFicFissure) + logging.info("fichier maillage fissure %s", fichierMaillageFissure) + + if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + + return maillageComplet \ No newline at end of file diff --git a/src/Tools/blocFissure/gmu/meshBlocPart.py b/src/Tools/blocFissure/gmu/meshBlocPart.py new file mode 100644 index 000000000..c868ed139 --- /dev/null +++ b/src/Tools/blocFissure/gmu/meshBlocPart.py @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +from geomsmesh import smesh +from salome.smesh import smeshBuilder +import SMESH +from salome.StdMeshers import StdMeshersBuilder +from putName import putName + +# ----------------------------------------------------------------------------- +# --- maillage du bloc partitionne + +def meshBlocPart(blocPartition, faceFissure, tore, centres, edges, diams, circles, faces, + gencnt, facefissoutore, edgeext, facesExternes, facesExtBloc, facesExtElli, + aretesInternes, internalBoundary, ellipsoidep, sharedFaces, sharedEdges, edgesBords, + nbsegExt, nbsegGen, nbsegRad, scaleRad, reverses, reverext, nbsegCercle, nbsegFis, dmoyen, lensegEllipsoide): + """ + Maillage du bloc partitionné + TODO: a completer + """ + logging.info('start') + + # --- edges de bord à respecter + + aFilterManager = smesh.CreateFilterManager() + nbAdded, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [ ]) + criteres = [] + 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') + + # --- maillage bloc + + bloc1 = smesh.Mesh(blocPartition) + + for i in range(len(sharedFaces)): + algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN, geom=sharedFaces[i]) + hypo2d = algo2d.Parameters(which=smesh.SIMPLE) + hypo2d.SetLocalLength(lensegEllipsoide) + hypo2d.LengthFromEdges() + hypo2d.SetAllowQuadrangles(0) + putName(algo2d.GetSubMesh(), "sharedFaces", i) + putName(algo2d, "algo2d_sharedFaces", i) + putName(hypo2d, "hypo2d_sharedFaces", i) + + for i in range(len(sharedEdges)): + algo1d = bloc1.Segment(geom=sharedEdges[i]) + hypo1d = algo1d.LocalLength(lensegEllipsoide) + putName(algo1d.GetSubMesh(), "sharedEdges", i) + putName(algo1d, "algo1d_sharedEdges", i) + putName(hypo1d, "hypo1d_sharedEdges", i) + + declareAlgoEllipsoideFirst = False + if declareAlgoEllipsoideFirst: + algo3d = bloc1.Tetrahedron(algo=smeshBuilder.NETGEN,geom=ellipsoidep) + hypo3d = algo3d.MaxElementVolume(1000.0) + putName(algo3d.GetSubMesh(), "ellipsoide") + putName(algo3d, "algo3d_ellipsoide") + putName(hypo3d, "hypo3d_ellipsoide") + + algo3d = bloc1.Prism(geom=tore) + algo2d = bloc1.Quadrangle(geom=tore) + algo1d = bloc1.Segment(geom=tore) + hypo1d = algo1d.NumberOfSegments(nbsegGen) + putName(algo3d.GetSubMesh(), "tore") + putName(algo3d, "algo3d_tore") + putName(algo2d, "algo2d_tore") + putName(algo1d, "algo1d_tore") + putName(hypo1d, "hypo1d_tore") + + for i in range(len(faces)): + algo2d = bloc1.Quadrangle(geom=faces[i]) + hypo2d = smesh.CreateHypothesis('QuadrangleParams') + hypo2d.SetTriaVertex( geompy.GetSubShapeID(blocPartition,centres[i]) ) + hypo2d.SetQuadType( StdMeshersBuilder.QUAD_STANDARD ) + status = bloc1.AddHypothesis(hypo2d,faces[i]) + putName(algo2d.GetSubMesh(), "faces", i) + putName(algo2d, "algo2d_faces", i) + putName(hypo2d, "hypo2d_faces", i) + + for i in range(len(edges)): + algo1d = bloc1.Segment(geom=edges[i]) + if reverses[i] > 0: + hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ geompy.GetSubShapeID(blocPartition,edges[i]) ]) + else: + hypo1d = algo1d.NumberOfSegments(nbsegRad, scaleRad,[ ]) + putName(algo1d.GetSubMesh(), "edges", i) + putName(algo1d, "algo1d_edges", i) + putName(hypo1d, "hypo1d_edges", i) + + for i in range(len(circles)): + algo1d = bloc1.Segment(geom=circles[i]) + hypo1d = algo1d.NumberOfSegments(nbsegCercle) + putName(algo1d.GetSubMesh(), "circles", i) + putName(algo1d, "algo1d_circles", i) + putName(hypo1d, "hypo1d_circles", i) + + if len(edgeext) == 1: + densite = int(round(nbsegFis/2)) + algo1d = bloc1.Segment(geom=edgeext[0]) + hypo1d = algo1d.NumberOfSegments(nbsegFis) + hypo1d.SetDistrType( 2 ) + hypo1d.SetConversionMode( 1 ) + hypo1d.SetTableFunction( [ 0, densite, 0.4, 1, 0.6, 1, 1, densite ] ) + putName(algo1d.GetSubMesh(), "edgeext") + putName(algo1d, "algo1d_edgeext") + putName(hypo1d, "hypo1d_edgeext") + else: + longTotal = 0 + longEdgeExts = [] + for i in range(len(edgeext)): + props = geompy.BasicProperties(edgeext[i]) + longEdgeExts.append(props[0]) + longTotal += props[0] + for i in range(len(edgeext)): + local = longTotal/nbsegFis + nbLocal = int(round(nbsegFis*longEdgeExts[i]/longTotal)) + densite = int(round(nbLocal/2)) + algo1d = bloc1.Segment(geom=edgeext[i]) + hypo1d = algo1d.NumberOfSegments(nbLocal) + hypo1d.SetDistrType( 2 ) + hypo1d.SetConversionMode( 1 ) + hypo1d.SetTableFunction( [ 0, densite, 0.8, 1, 1, 1 ] ) + if reverext[i]: + hypo1d.SetReversedEdges([ geompy.GetSubShapeID(blocPartition, edgeext[i]) ]) + putName(algo1d.GetSubMesh(), "edgeext", i) + putName(algo1d, "algo1d_edgeext", i) + putName(hypo1d, "hypo1d_edgeext", i) + + algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facefissoutore) + hypo2d = algo2d.LengthFromEdges() + putName(algo2d.GetSubMesh(), "facefissoutore") + putName(algo2d, "algo2d_facefissoutore") + putName(hypo2d, "hypo2d_facefissoutore") + + + maxElemArea = 0.5*dmoyen*dmoyen + logging.debug("dmoyen %s, maxElemArea %s", dmoyen, maxElemArea) + + for i in range(len(facesExternes)): + algo2d = bloc1.Triangle(algo=smeshBuilder.NETGEN_2D, geom=facesExternes[i]) + hypo2d = algo2d.MaxElementArea(maxElemArea) + if edgesBords is None: + algo1d = bloc1.Segment(geom=facesExternes[i]) + hypo1d = algo1d.NumberOfSegments(1) + putName(algo2d.GetSubMesh(), "facesExternes", i) + putName(algo2d, "algo2d_facesExternes", i) + putName(hypo2d, "hypo2d_facesExternes", i) + if edgesBords is None: + putName(algo1d, "algo1d_facesExternes", i) + putName(hypo1d, "hypo1d_facesExternes", i) + + for i in range(len(aretesInternes)): + algo1d = bloc1.Segment(geom=aretesInternes[i]) + hypo1d = algo1d.NumberOfSegments(nbsegExt) + putName(algo1d.GetSubMesh(), "aretesInternes", i) + putName(algo1d, "algo1d_aretesInternes", i) + putName(hypo1d, "hypo1d_aretesInternes", i) + + if edgesBords is not None: + algo1d = bloc1.UseExisting1DElements(geom=edgesBords) + hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0) + putName(algo1d.GetSubMesh(), "bordsLibres") + putName(algo1d, "algo1d_bordsLibres") + putName(hypo1d, "hypo1d_bordsLibres") + + #isDone = bloc1.Compute() + + if not declareAlgoEllipsoideFirst: + algo3d = bloc1.Tetrahedron(algo=smeshBuilder.NETGEN,geom=ellipsoidep) + hypo3d = algo3d.MaxElementVolume(1000.0) + putName(algo3d.GetSubMesh(), "ellipsoide") + putName(algo3d, "algo3d_ellipsoide") + putName(hypo3d, "hypo3d_ellipsoide") + + isDone = bloc1.Compute() + + nbRemoved = bloc1.RemoveOrphanNodes() + + faceFissure1 = bloc1.GroupOnGeom(faceFissure,'FACE1',SMESH.FACE) + noeudsFondFissure = bloc1.GroupOnGeom(gencnt,'nfondfis',SMESH.NODE) + + groups_faceCommuneEllipsoideBloc = [] + for i in range(len(sharedFaces)): + name = "faceCommuneEllipsoideBloc_%d"%i + groups_faceCommuneEllipsoideBloc.append(bloc1.GroupOnGeom(sharedFaces[i], name, SMESH.FACE)) + groups_faceExterneBloc = [] + for i in range(len(facesExtBloc)): + name = "faceExterneBloc_%d"%i + groups_faceExterneBloc.append(bloc1.GroupOnGeom(facesExtBloc[i], name, SMESH.FACE)) + + skinBlocMeshes = [] + for i in range(len(groups_faceCommuneEllipsoideBloc)): + name = "faceCommuneEllipsoideBloc_%d"%i + skinBlocMeshes.append(smesh.CopyMesh(groups_faceCommuneEllipsoideBloc[i], name, 0, 0)) + for i in range(len(groups_faceExterneBloc)): + name = "faceExterneBloc_%d"%i + skinBlocMeshes.append(smesh.CopyMesh(groups_faceExterneBloc[i], name, 0, 0)) + + meshesBloc = [internalBoundary.GetMesh()] + for i in range(len(skinBlocMeshes)): + meshesBloc.append(skinBlocMeshes[i].GetMesh()) + blocMesh = smesh.Concatenate(meshesBloc, 1, 1, 1e-05,False) + + algo3d = blocMesh.Tetrahedron(algo=smeshBuilder.NETGEN) + hypo3d = algo3d.MaxElementVolume(1000.0) + putName(algo3d.GetSubMesh(), "bloc") + putName(algo3d, "algo3d_bloc") + putName(hypo3d, "hypo3d_bloc") + + is_done = blocMesh.Compute() + + blocComplet = smesh.Concatenate([bloc1.GetMesh(), blocMesh.GetMesh()], 1, 1, 1e-05,False) + + return bloc1, blocComplet \ No newline at end of file diff --git a/src/Tools/blocFissure/gmu/orderEdgesFromWire.py b/src/Tools/blocFissure/gmu/orderEdgesFromWire.py new file mode 100644 index 000000000..0a092e26c --- /dev/null +++ b/src/Tools/blocFissure/gmu/orderEdgesFromWire.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- trouver les vertices intermediaires d'un wire + +def orderEdgesFromWire(aWire): + """ + fournit les edges ordonnées d'un wire selon ExtractShapes(,,False), + et l'ordre des edges selon le sens de parcours (ordre des indices de la liste d'edges) + """ + logging.info("start") + edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"], False) + + idverts = {} + for i, edge in enumerate(edges): + verts = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True) +# idverts[(i,0)] = verts[0] +# idverts[(i,1)] = verts[1] + v0 = geompy.MakeVertexOnCurve(edge, 0.0) + dist = geompy.MinDistance(v0, verts[0]) + if dist < 1.e-4: + idverts[(i,0)] = verts[0] + idverts[(i,1)] = verts[1] + else: + idverts[(i,0)] = verts[1] + idverts[(i,1)] = verts[0] + + idsubs = {} + for kv, sub in idverts.iteritems(): + subid = geompy.GetSubShapeID(aWire, sub) + if subid in idsubs.keys(): + idsubs[subid].append(kv) + else: + idsubs[subid] = [kv] + + debut = -1 + fin = -1 + for k, kvs in idsubs.iteritems(): + if len(kvs) == 1: # une extremité + kv = kvs[0] + if kv[1] == 0: + debut = kv[0] + else: + fin = kv[0] + logging.debug("nombre d'edges: %s, indice edge début: %s, fin: %s",len(edges), debut, fin) + if debut < 0: + logging.critical("les edges du wire ne sont pas orientées dans le même sens: pas de début trouvé") + return edges, range(len(edges)) + + orderedList = [debut] + while len(orderedList) < len(edges): + bout = orderedList[-1] + vertex = idverts[(bout,1)] + for k, v in idverts.iteritems(): + if k[0] not in orderedList: + if geompy.MinDistance(vertex, v) < 1.e-4: + if k[1] == 0: + orderedList.append(k[0]) + break + else: + logging.critical("les edges du wire ne sont pas orientées dans le même sens: une edge à l'envers") + return edges, range(len(edges)) + + logging.debug("liste des edges ordonnées selon le sens de parcours: %s", orderedList) + accessList = range(len(orderedList)) + for i,k in enumerate(orderedList): + accessList[k] = i + logging.info("position ordonnée des edges selon le sens de parcours: %s", accessList) + return edges, accessList diff --git a/src/Tools/blocFissure/gmu/partitionBlocDefaut.py b/src/Tools/blocFissure/gmu/partitionBlocDefaut.py new file mode 100644 index 000000000..4016c9a5b --- /dev/null +++ b/src/Tools/blocFissure/gmu/partitionBlocDefaut.py @@ -0,0 +1,160 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- partition du bloc defaut par generatrice, tore et plan fissure + +def partitionBlocDefaut(volDefaut, facesDefaut, gener, pipe, + facefis, ellipsoide): + """ + Partition du bloc defaut par la generatrice de l'ellipse, + le tore elliptique, la face plane de fissure + @param volDefaut : le bloc defaut + @param gener : la generatrice de l'ellipse, positionnée dans l'espace + @param pipe : le tore partitionné par le plan de fissure, positionné + dans l'espace + @param facefis : la face plane de la fissure, positionnée dans l'espace + @return (volDefautPart, blocp, tore, faceFissure), le bloc partitionné, + les sous shapes issues de la partition + (le bloc moins le tore, la generatrice, le tore, la face de fissure) + """ + logging.info("start") + + volDefautPart = geompy.MakePartition([volDefaut], [pipe, facefis, ellipsoide], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + blocp = geompy.GetInPlaceByHistory(volDefautPart, volDefaut) + #gencnt = geompy.GetInPlaceByHistory(volDefautPart, gener) + tore = geompy.GetInPlaceByHistory(volDefautPart, pipe) + faceFissure = geompy.GetInPlaceByHistory(volDefautPart, facefis) + #ellipsoidep =geompy.GetInPlaceByHistory(volDefautPart, ellipsoide) + + geompy.addToStudy( volDefautPart, 'volDefautPart' ) + geompy.addToStudyInFather( volDefautPart, tore, 'tore' ) + geompy.addToStudyInFather( volDefautPart, faceFissure, 'FACE1' ) + #geompy.addToStudyInFather( volDefautPart, gencnt, 'generatrice' ) + + solids = geompy.ExtractShapes(blocp, geompy.ShapeType["SOLID"], True) + vols = [] + for i in range(len(solids)): + props = geompy.BasicProperties(solids[i]) + vols.append(props[2]) + maxvol = max(vols) + imaxvol = vols.index(maxvol) + blocp = solids[imaxvol] + vols[imaxvol] = 0 + maxvol = max(vols) + imaxvol = vols.index(maxvol) + ellipsoidep = solids[imaxvol] + + geompy.addToStudyInFather( volDefautPart, blocp, 'bloc' ) + geompy.addToStudyInFather( volDefautPart, ellipsoidep, 'ellipsoide' ) + + sharedFaces = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["FACE"]) + for i in range(len(sharedFaces)): + name = "faceCommuneEllipsoideBloc_%d"%i + geompy.addToStudyInFather(blocp, sharedFaces[i], name) + + #sharedEdges = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["EDGE"]) + allSharedEdges = geompy.GetSharedShapesMulti([blocp, ellipsoidep], geompy.ShapeType["EDGE"]) + sharedEdges = [] + for i in range(len(allSharedEdges)): + if geompy.NbShapes(allSharedEdges[i], geompy.ShapeType["VERTEX"]) > 1: # edge non degeneree + sharedEdges.append(allSharedEdges[i]) + for i in range(len(sharedEdges)): + name = "edgeCommuneEllipsoideBloc_%d"%i + geompy.addToStudyInFather(blocp, sharedEdges[i], name) + + facesExternes = [] + facesExtBloc = [] + facesExtElli = [] + faces = geompy.ExtractShapes(facesDefaut, geompy.ShapeType["FACE"], True) + if len(faces) == 0: + faces = [facesDefaut] + for i in range(len(faces)): + faceExt = geompy.GetInPlace(ellipsoidep, faces[i]) + if faceExt is not None: + name = "faceExterne_e%d"%i + geompy.addToStudyInFather(ellipsoidep, faceExt, name) + facesExternes.append(faceExt) + facesExtElli.append(faceExt) + + faceExt = geompy.GetInPlace(blocp, faces[i]) + if faceExt is not None: + name = "faceExterne_b%d"%i + geompy.addToStudyInFather(blocp, faceExt, name) + facesExternes.append(faceExt) + facesExtBloc.append(faceExt) + else: + logging.info(" recherche faces externes par GetShapesOnShape") + vertex = geompy.MakeVertexOnSurface(faces[i], 0.5, 0.5) + normal = geompy.GetNormal(faces[i], vertex) + extrusionFace = geompy.MakePrismVecH(faces[i], normal, 1) + #extrusionFace = geompy.MakePrismVecH2Ways(faces[i], normal, 0.1) + #extrusionFace = geompy.MakeScaleTransform(extrusionFace, vertex, 1.01) + name = "extrusionFace_b%d"%i + geompy.addToStudyInFather(blocp, extrusionFace, name) + #facesExt = geompy.GetShapesOnShape(extrusionFace, blocp, geompy.ShapeType["FACE"], GEOM.ST_ONIN) + facesExt = geompy.GetShapesOnShape(extrusionFace, blocp, geompy.ShapeType["FACE"], GEOM.ST_ON) + for j in range(len(facesExt)): + name = "faceExterne_b%d_%d"%(i,j) + geompy.addToStudyInFather(blocp, facesExt[j], name) + facesExternes.append(facesExt[j]) + facesExtBloc.append(facesExt[j]) + + if len(facesExtBloc) < len(faces): # toutes les faces externes du bloc n'ont pas été trouvées. TODO eliminer les detections multiples + logging.info(" recherche faces externes par aretes partagees avec faces externes ellipsoide") + facesBloc = geompy.ExtractShapes(blocp, geompy.ShapeType["FACE"], True) + for i in range(len(facesBloc)): + notOnEllipsoide = True + for j in range(len(sharedFaces)): # eliminer les faces communes avec l'ellipsoide + if facesBloc[i].IsSame(sharedFaces[j]): + notOnEllipsoide = False + break + if notOnEllipsoide: + for j in range(len(facesExtElli)): # les faces recherchees ont une ou plusieurs edge communes avec la ou les faces externes de l'ellipsoide + allSharedEdges = [] + try: + allSharedEdges += geompy.GetSharedShapesMulti([facesBloc[i], facesExtElli[j]], geompy.ShapeType["EDGE"]) + except: + pass + if len(allSharedEdges) > 0: + name = "faceExterne_b%d_%d"%(i,j) + geompy.addToStudyInFather(blocp, facesBloc[i], name) + facesExternes.append(facesBloc[i]) + facesExtBloc.append(facesBloc[i]) + + aretesInternes = [] + for i in range(len(facesExternes)): + for j in range(i+1,len(facesExternes)): + shared = [] + try: + shared += geompy.GetSharedShapesMulti([facesExternes[i], facesExternes[j]], geompy.ShapeType["EDGE"]) + except: + logging.info("no shared edges in %s,%s",i,j) + else: + aretesInternes += shared + for i in range(len(aretesInternes)): + name = "aretesInternes_%d"%i + geompy.addToStudyInFather(blocp, aretesInternes[i], name) + + edgesBords = [] + for faceExtB in facesExtBloc: + edges = geompy.ExtractShapes(faceExtB, geompy.ShapeType["EDGE"], True) + for i in range(len(edges)): + isInterne = False + for j in range(len(aretesInternes)): + if edges[i].IsSame(aretesInternes[j]): + isInterne = True + break + if not isInterne: + edgesBords.append(edges[i]) + name = "edgeBord%d"%i + geompy.addToStudyInFather(blocp,edges[i] , name) + group = None + if len(edgesBords) > 0: + group = geompy.CreateGroup(blocp, geompy.ShapeType["EDGE"]) + geompy.UnionList(group, edgesBords) + edgesBords = group + + return volDefautPart, blocp, tore, faceFissure, facesExternes, facesExtBloc, facesExtElli, aretesInternes, ellipsoidep, sharedFaces, sharedEdges, edgesBords diff --git a/src/Tools/blocFissure/gmu/partitionVolumeSain.py b/src/Tools/blocFissure/gmu/partitionVolumeSain.py new file mode 100644 index 000000000..a23fa591a --- /dev/null +++ b/src/Tools/blocFissure/gmu/partitionVolumeSain.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- partition volume sain et bloc, face du bloc recevant la fissure + +def partitionVolumeSain(volumeSain,boiteDefaut): + """ + Partition du volume complet sur lequel porte le calcul par le cube qui contiendra le defaut + @param volumeSain : volume complet (geomObject) + @param boiteDefaut : cube qui contiendra le defaut, positionné dans l'espace (son centre doit être au voisinage + immediat de la peau de l'objet sain: le tore elliptique debouche de paroi) + @return (volumeSainPart, partieSaine, volDefaut, faceBloc) : volume complet partionné par le cube, partie saine, + bloc du defaut (solide commun au cube et au volume complet), face du bloc defaut correspondant à la paroi. + """ + logging.info("start") + + volumeSainPart = geompy.MakePartition([volumeSain], [boiteDefaut], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + [a,b] = geompy.ExtractShapes(volumeSainPart, geompy.ShapeType["SOLID"], True) + volDefaut = geompy.GetInPlaceByHistory(volumeSainPart, boiteDefaut) + if geompy.GetSubShapeID(volumeSainPart,b) == geompy.GetSubShapeID(volumeSainPart,volDefaut): + partieSaine = a + else: + partieSaine = b + faceBloc = geompy.GetShapesOnShapeAsCompound(volumeSain, volDefaut, geompy.ShapeType["FACE"], GEOM.ST_ON) + + geompy.addToStudy( volumeSainPart, 'volumeSainPart' ) + geompy.addToStudyInFather( volumeSainPart, partieSaine, 'partieSaine' ) + geompy.addToStudyInFather( volumeSainPart, volDefaut, 'volDefaut' ) + geompy.addToStudyInFather( volDefaut, faceBloc, 'faceBloc' ) + return volumeSainPart, partieSaine, volDefaut, faceBloc diff --git a/src/Tools/blocFissure/gmu/peauInterne.py b/src/Tools/blocFissure/gmu/peauInterne.py new file mode 100644 index 000000000..6790061b9 --- /dev/null +++ b/src/Tools/blocFissure/gmu/peauInterne.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import smesh +import SMESH + +# ----------------------------------------------------------------------------- +# --- peau interne du defaut dans le maillage sain + +def peauInterne(fichierMaillage, nomZones): + """ + Retrouve les groupes de défaut dans le maillage sain modifié par CreateHoleSkin (CreeZoneDefautMaillage) + On récupère le volume et la peau de la zone de défaut, les éventuelles faces et arêtes internes de cette zone. + """ + logging.info("start") + ([maillageSain], status) = smesh.CreateMeshesFromMED(fichierMaillage) + + groups = maillageSain.GetGroups() + zoneDefaut = None + for grp in groups: + #print " ",grp.GetName() + if grp.GetName() == nomZones + "_vol": + zoneDefaut = grp + break + zoneDefaut_skin = None + for grp in groups: + if grp.GetName() == nomZones + "_skin": + zoneDefaut_skin = grp + break + zoneDefaut_internalFaces = None + for grp in groups: + if grp.GetName() == nomZones + "_internalFaces": + zoneDefaut_internalFaces = grp + break + zoneDefaut_internalEdges = None + for grp in groups: + if grp.GetName() == nomZones + "_internalEdges": + zoneDefaut_internalEdges = grp + break + + nbAdded, maillageSain, DefautBoundary = maillageSain.MakeBoundaryElements( SMESH.BND_2DFROM3D, 'DefBound', '', 0, [ zoneDefaut ]) + internal = maillageSain.GetMesh().CutListOfGroups( [ DefautBoundary ], [ zoneDefaut_skin ], 'internal' ) + internalBoundary = smesh.CopyMesh( internal, 'internalBoundary', 0, 0) + + return maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges + diff --git a/src/Tools/blocFissure/gmu/produitMixte.py b/src/Tools/blocFissure/gmu/produitMixte.py new file mode 100644 index 000000000..509a75889 --- /dev/null +++ b/src/Tools/blocFissure/gmu/produitMixte.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- calcul de produit mixte pour orientation + +def produitMixte(o, p1, p2, p3): + """ + produit mixte de 3 vecteurs a partir d'une origine et 3 points + """ + coordo = geompy.PointCoordinates(o) + coordp1 = geompy.PointCoordinates(p1) + coordp2 = geompy.PointCoordinates(p2) + coordp3 = geompy.PointCoordinates(p3) + u = [coordp1[0] - coordo[0], coordp1[1] - coordo[1], coordp1[2] - coordo[2]] + v = [coordp2[0] - coordo[0], coordp2[1] - coordo[1], coordp2[2] - coordo[2]] + w = [coordp3[0] - coordo[0], coordp3[1] - coordo[1], coordp3[2] - coordo[2]] + pm = (u[0]*v[1]*w[2] + v[0]*w[1]*u[2] + w[0]*u[1]*v[2]) - (u[0]*w[1]*v[2] + v[0]*u[1]*w[2] + w[0]*v[1]*u[2]) + logging.debug('pm=%s', pm) + return pm + diff --git a/src/Tools/blocFissure/gmu/projettePointSurCourbe.py b/src/Tools/blocFissure/gmu/projettePointSurCourbe.py new file mode 100644 index 000000000..fa43d3926 --- /dev/null +++ b/src/Tools/blocFissure/gmu/projettePointSurCourbe.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +from geomsmesh import geompy +import logging +import math + +# ----------------------------------------------------------------------------- +# --- projection d'un point sur une courbe. + +def projettePointSurCourbe(pt, edge): + """ + projection d'un point p sur une courbe c + on suppose que la distance (c(u), p) passe par un minimum quand u varie entre 0 et 1 + et qu'elle presente pas de minimum local + """ + #logging.debug("start") + + dist = [] + nbSlices = 50 + du = 1.0/nbSlices + for i in range(nbSlices + 1): + p = geompy.MakeVertexOnCurve(edge, du*i) + d = geompy.MinDistance(p,pt) + dist.append((d,i)) + dist.sort() + #logging.debug("dist %s", dist) + umin = du*dist[0][1] + umax = du*dist[1][1] + #umin = 0.0 + #umax = 1.0 + tol = 1.e-8 + pmin = geompy.MakeVertexOnCurve(edge, umin) + pmax = geompy.MakeVertexOnCurve(edge, umax) + dmin = geompy.MinDistance(pmin,pt) + dmax = geompy.MinDistance(pmax,pt) + dext = geompy.MinDistance(pmin,pmax) + i=0 + while dext > tol and i < 100 : + i = i+1 + utest = (umax + umin) / 2.0 + ptest = geompy.MakeVertexOnCurve(edge, utest) + dtest = geompy.MinDistance(ptest,pt) + if dmin < dmax: + umax = utest + pmax = ptest + dmax = dtest + else: + umin = utest + pmin = ptest + dmin = dtest + dext = geompy.MinDistance(pmin,pmax) + #logging.debug('umin=%s umax=%s dmin=%s dmax=%s dtest=%s dext=%s', umin,umax,dmin,dmax,dtest,dext) + if abs(utest) < 1.e-7: + utest = 0.0 + if abs(1.0-utest) < 1.e-7: + utest = 1.0 + logging.debug('u=%s, nbiter=%s dtest=%s dext=%s',utest,i,dtest,dext) + return utest + \ No newline at end of file diff --git a/src/Tools/blocFissure/gmu/prolongeVertices.py b/src/Tools/blocFissure/gmu/prolongeVertices.py new file mode 100644 index 000000000..e6e6f038a --- /dev/null +++ b/src/Tools/blocFissure/gmu/prolongeVertices.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- prolongation des segments extremité des polylines, pour la découpe + +def prolongeVertices(vertices): + """ + Prolongation des segments extremité d'une polyline définie par un vecteur de points. + Chaque nouvelle extremité est obtenue par symétrie point du voisin de cette ancienne extrémité + (symétrie de centre l'ancienne extrémite) : les segments extremes sont doublés. + @param vertices : liste ordonnée des points (geomObject) de la polyline + @return vertices : liste avec les deux extremités modifiées + """ + logging.info("start") + if len(vertices) < 2: + return vertices + v0 = vertices[0] + v1 = vertices[1] + m0 = geompy.MakeMirrorByPoint(v1, v0) + ve = vertices[-1] + vd = vertices[-2] + m1 = geompy.MakeMirrorByPoint(vd, ve) + vertices[0] = m0 + vertices[-1] = m1 + return vertices diff --git a/src/Tools/blocFissure/gmu/prolongeWire.py b/src/Tools/blocFissure/gmu/prolongeWire.py new file mode 100644 index 000000000..72e766dff --- /dev/null +++ b/src/Tools/blocFissure/gmu/prolongeWire.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- prolongation d'un wire par deux segments tangents + +def prolongeWire(aWire, extrem, norms, long): + """ + """ + logging.info("start") + if geompy.NumberOfEdges(aWire) > 1: + edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"]) + else: + edges = [aWire] + for i, v1 in enumerate(extrem): + exts = [geompy.MakeTranslationVectorDistance(v1, norms[i], l) for l in (-long, long)] + dists = [(geompy.MinDistance(v, aWire), i , v) for i, v in enumerate(exts)] + dists.sort() + v2 = dists[-1][-1] + #v2 = geompy.MakeTranslationVectorDistance(v1, norms[i], long) + edge = geompy.MakeEdge(v1, v2) + edges.append(edge) + name = "extrem%d"%i + #geompy.addToStudy(edge,name) + wireProlonge = geompy.MakeWire(edges) + geompy.addToStudy(wireProlonge, "wireProlonge") + return wireProlonge diff --git a/src/Tools/blocFissure/gmu/propagateTore.py b/src/Tools/blocFissure/gmu/propagateTore.py new file mode 100644 index 000000000..70678a420 --- /dev/null +++ b/src/Tools/blocFissure/gmu/propagateTore.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- recherche et classement des edges du tore par propagate + +def propagateTore(tore): + """ + Classement des edges du tore par une operation 'propagate' + @param tore partionné et coupé + @return (diams, circles, geners) edges dans le plan de fissure, edges demi circulaires, + edges selon la generatrice (liste de compounds) + """ + logging.info("start") + + lencomp = [] + compounds = geompy.Propagate(tore) + for i in range(len(compounds)): + #geompy.addToStudyInFather( tore, compounds[i], 'edges' ) + props = geompy.BasicProperties(compounds[i]) + lencomp.append(props[0]) + pass + minlen = min(lencomp) + maxlen = max(lencomp) + diams = [] + geners = [] + circles = [] + for i in range(len(lencomp)): + if (lencomp[i]- minlen)/minlen < 0.01 : + diams.append(compounds[i]) + elif (maxlen - lencomp[i])/lencomp[i] < 0.2 : + geners.append(compounds[i]) + else: + circles.append(compounds[i]) + + geompy.addToStudyInFather( tore, diams[0], 'diams0' ) + geompy.addToStudyInFather( tore, diams[1], 'diams1' ) + geompy.addToStudyInFather( tore, circles[0], 'circles0' ) + geompy.addToStudyInFather( tore, circles[1], 'circles1' ) + geompy.addToStudyInFather( tore, geners[0], 'geners' ) + + return diams, circles, geners diff --git a/src/Tools/blocFissure/gmu/putName.py b/src/Tools/blocFissure/gmu/putName.py new file mode 100644 index 000000000..b8d4cbfa3 --- /dev/null +++ b/src/Tools/blocFissure/gmu/putName.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +from geomsmesh import smesh + +# ----------------------------------------------------------------------------- +# --- nommage des objets mesh (algorithme, hypothèse, subMesh) + +def putName(objmesh,name, i=-1): + if i >= 0: + suffix = "_%d"%i + name += suffix + smesh.SetName(objmesh, name) + diff --git a/src/Tools/blocFissure/gmu/quadranglesToShape.py b/src/Tools/blocFissure/gmu/quadranglesToShape.py new file mode 100644 index 000000000..faa9478f7 --- /dev/null +++ b/src/Tools/blocFissure/gmu/quadranglesToShape.py @@ -0,0 +1,323 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +import GEOM +import math +import numpy as np + +def mydot(a): + return np.dot(a,a) + +# ----------------------------------------------------------------------------- +# --- groupe de quadrangles de face transformé en face géométrique par filling + +def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): + """ + groupe de quadrangles de face transformée en faces géométriques par filling + on part de quadrangles définissant une zone a 4 cotés (convexe), et on reconstitue n lignes de p points. + Ces n lignes de p points sont transformées en n courbes géométriques, + à partir desquelles on reconstitue une surface géométrique. + Il peut y avoir plusieurs faces géométriques reconstituées, si on fournit des groupes de quadrangles non connexes. + On détecte les angles vifs, pour conserver des arêtes vives délimitant des faces connexes. + @param meshQuad : maillages constitué de quadrangles constituant une ou plusieurs zones convexes + @return (fillings, noeuds_Bords) : liste de geomObject, listes des bords (bord = liste ordonnée de noeuds (geomObject)) + """ + logging.info("start") + + isVecteurDefaut = False + if shapeFissureParams.has_key('vecteurDefaut'): + isVecteurDefaut = True + vecteurDefaut = shapeFissureParams['vecteurDefaut'] + + fillings = [] # les faces reconstituées, découpées selon les arêtes vives + noeuds_bords = [] # + bords_Partages = [] # contient a la fin les courbes correspondant aux arêtes vives + fillconts = [] # les faces reconstituées, sans découpage selon les arêtes vives + idFilToCont = [] # index face découpée vers face sans découpe + iface = 0 # index face découpée + icont = 0 # index face continue + + allNodeIds = meshQuad.GetNodesId() + while len(allNodeIds): + nodeIds = allNodeIds + for idNode in nodeIds: # rechercher un coin + elems = meshQuad.GetNodeInverseElements(idNode) + if len(elems) == 1: + # un coin: un noeud, un element quadrangle + elem = elems[0] + break; + idStart = idNode # le noeud de coin + elemStart = elem # l'élément quadrangle au coin + xyz = meshQuad.GetNodeXYZ(idStart) + logging.debug("idStart %s, coords %s", idStart, str(xyz)) + + nodelines =[] # on va constituer une liste de lignes de points + nextLine = True + ligneFinale = False + while nextLine: + logging.debug("--- une ligne") + idNode = idStart + elem = elemStart + if ligneFinale: + agauche = False # sens de parcours des 4 noeuds d'un quadrangle + nextLine = False + else: + agauche = True + ligneIncomplete = True # on commence une ligne de points + debutLigne = True + nodeline = [] + elemline = [] + while ligneIncomplete: # compléter la ligne de points + nodeline.append(idNode) + allNodeIds.remove(idNode) + elemline.append(elem) + nodes = meshQuad.GetElemNodes(elem) + i = nodes.index(idNode) # repérer l'index du noeud courant (i) dans l'élément quadrangle (0 a 3) + if agauche: # déterminer le noeud suivant (j) et celui opposé (k) dans le quadrangle + if i < 3: + j = i+1 + else: + j = 0 + if j < 3: + k = j+1 + else: + k = 0 + else: + if i > 0: + j = i -1 + else: + j = 3 + if j > 0: + k = j -1 + else: + k = 3 + isuiv = nodes[j] #noeud suivant + iapres = nodes[k] #noeud opposé + if debutLigne: + debutLigne = False + # précédent a trouver, dernière ligne : précédent au lieu de suivant + if agauche: + if i > 0: + iprec = nodes[i -1] + else: + iprec = nodes[3] + idStart = iprec + elems3 = meshQuad.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 = meshQuad.GetNodeInverseElements(isuiv) + elems2 = meshQuad.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)) + + # stockage des coordonnées dans un tableau numpy + mat = np.zeros((len(nodelines), len(nodeline), 3)) + for i, ligne in enumerate(nodelines): + for j, nodeId in enumerate(ligne): + mat[i,j] = meshQuad.GetNodeXYZ(nodeId) + logging.debug("matrice de coordonnées: \n%s",mat) + logging.debug("dimensions %s", mat.shape) + + # recherche d'angles supérieurs a un seuil sur une ligne : angle entre deux vecteurs successifs + cosmin = math.cos(math.pi/4.) # TODO: angle reference en paramètre + vecx = mat[:, 1:, :] - mat[:, :-1, :] # vecteurs selon direction "x" + vx0 = vecx[:, :-1, :] # vecteurs amont + vx1 = vecx[:, 1:, :] # vecteurs aval + e = np.einsum('ijk,ijk->ij', vx0, vx1) # produit scalaire des vecteurs + f = np.apply_along_axis(mydot, 2, vx0) # normes carrées vecteurs amont + g = np.apply_along_axis(mydot, 2, vx1) # normes carrées vecteurs aval + h = e/(np.sqrt(f*g)) # cosinus + ruptureX = h < cosmin # True si angle > reference + logging.debug("matrice de rupture X: \n%s",ruptureX) + rupX = filter(lambda x: np.prod(ruptureX[:,x]), range(len(nodeline)-2)) + logging.debug("colonnes de rupture: %s",rupX) + # recherche d'angles supérieurs a un seuil sur une colonne : angle entre deux vecteurs successifs + vecy = mat[ 1:, :, :] - mat[:-1, :, :] # vecteurs selon direction "y" + vy0 = vecy[:-1, :, :] # vecteurs amont + vy1 = vecy[ 1:, :, :] # vecteurs aval + e = np.einsum('ijk,ijk->ij', vy0, vy1) # produit scalaire des vecteurs + f = np.apply_along_axis(mydot, 2, vy0) # normes carrées vecteurs amont + g = np.apply_along_axis(mydot, 2, vy1) # normes carrées vecteurs aval + h = e/(np.sqrt(f*g)) # cosinus + ruptureY = h < cosmin # True si angle > reference + logging.debug("matrice de rupture Y: \n%s",ruptureY) + rupY = filter(lambda x: np.prod(ruptureY[x, :]), range(len(nodelines)-2)) + logging.debug("lignes de rupture: %s",rupY) + if (len(rupX)*len(rupY)) > 0: + logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions, + lors de la reconstitution des faces géométriques dans la zone remaillée""") + + mats = [] + bordsPartages = [] + if (len(rupX)> 0): + rupX.append(mat.shape[1]-1) + for i, index in enumerate(rupX): + imax = index+2 + imin = 0 + if i > 0: + imin = rupX[i-1] + 1 + mats.append(mat[:, imin:imax, :]) + if imax == mat.shape[1] + 1: + ifin = 0 + else: + ifin = imax + bordsPartages.append([imin,ifin]) # les indices différents de 0 correspondent à des bords partagés + elif (len(rupY)> 0): + rupY.append(mat.shape[0]-1) + for i, index in enumerate(rupY): + imax = index+2 + imin = 0 + if i > 0: + imin = rupY[i-1] + 1 + mats.append(mat[imin:imax, :, :]) + if imax == mat.shape[0] + 1: + ifin = 0 + else: + ifin = imax + bordsPartages.append([imin,ifin]) # les indices différents de 0 correspondent à des bords partagés + else: + mats.append(mat) + bordsPartages.append([0,0]) # les indices différents de 0 correspondent à des bords partagés + + curvconts = [] + for nmat, amat in enumerate(mats): + logging.debug("dimensions matrice %s: %s", nmat, amat.shape) + nbLignes = amat.shape[1] # pas de rupture, ou rupture selon des colonnes: on transpose + nbCols = amat.shape[0] + if len(rupY) > 0 : # rupture selon des lignes: pas de transposition + nbLignes = amat.shape[0] + nbCols = amat.shape[1] + curves = [] + noeudsBords = [] + for i in range(4): + noeudsBords.append([]) + k = 0 + for i in range(nbLignes): + nodeList = [] + for j in range(nbCols): + #logging.debug("point[%s,%s] = (%s, %s, %s)",i,j,amat[i,j,0], amat[i,j,1], amat[i,j,2]) + if len(rupY) > 0 : # pas de transposition + node = geompy.MakeVertex(amat[i,j,0], amat[i,j,1], amat[i,j,2]) + else: # transposition + node = geompy.MakeVertex(amat[j,i,0], amat[j,i,1], amat[j,i,2]) + nodeList.append(node) + if i == 0: + noeudsBords[0].append(node) + #name = "bord0_%d"%k + #geompy.addToStudy( node, name ) + if i == (nbLignes -1): + noeudsBords[2].append(node) + #name = "bord2_%d"%k + #geompy.addToStudy( node, name ) + if j == 0: + noeudsBords[1].append(node) + #name = "bord1_%d"%k + #geompy.addToStudy( node, name ) + if j == (nbCols -1): + noeudsBords[3].append(node) + #name = "bord3_%d"%k + #geompy.addToStudy( node, name ) + k += 1 + curve = geompy.MakeInterpol(nodeList, False, False) + #name = "curve_%d"%i + #geompy.addToStudy( curve, name ) + if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe + curvconts.append(nodeList) + curves.append(curve) + if bordsPartages[nmat][0] : + bordsPartages[nmat][0] = curves[0] # la première ligne est un bord partagé + else: + bordsPartages[nmat][0] = None + if bordsPartages[nmat][1] : + bordsPartages[nmat][1] = curves[-1] # la dernière ligne est un bord partagé + else: + bordsPartages[nmat][1] = None + filling = geompy.MakeFilling(geompy.MakeCompound(curves), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True) + # --- test orientation filling + vertex = geompy.MakeVertexOnSurface(filling, 0.5, 0.5) + normal = geompy.GetNormal(filling, vertex) + + if centreFondFiss is not None: + logging.debug("orientation filling a l'aide du centre de fond de fissure") + vecteurDefaut = geompy.MakeVector(centreFondFiss, vertex) + + if not isVecteurDefaut: + pointIn_x = 0.0 + pointIn_y = 0.0 + pointIn_z = 0.0 + pointExplicite = False + if shapeFissureParams.has_key('pointIn_x'): + pointExplicite = True + pointIn_x = shapeFissureParams['pointIn_x'] + if shapeFissureParams.has_key('pointIn_y'): + pointExplicite = True + pointIn_y = shapeFissureParams['pointIn_y'] + if shapeFissureParams.has_key('pointIn_z'): + pointExplicite = True + pointIn_z = shapeFissureParams['pointIn_z'] + if pointExplicite: + cdg = geompy.MakeVertex(pointIn_x, pointIn_y, pointIn_z) + logging.debug("orientation filling par point intérieur %s", (pointIn_x, pointIn_y, pointIn_z)) + vecteurDefaut = geompy.MakeVector(cdg, vertex) + + if shapeFissureParams.has_key('convexe'): + isConvexe = shapeFissureParams['convexe'] + logging.debug("orientation filling par indication de convexité %s", isConvexe) + cdg = geompy.MakeCDG(filling) + if isConvexe: + vecteurDefaut = geompy.MakeVector(cdg, vertex) + else: + vecteurDefaut = geompy.MakeVector(vertex, cdg) + + if vecteurDefaut is not None: + geompy.addToStudy(normal, "normFillOrig%d"%iface) + geompy.addToStudy(vecteurDefaut, "fromInterieur%d"%iface) + if geompy.GetAngleRadians(vecteurDefaut, normal) > math.pi/2.0: + filling = geompy.ChangeOrientation(filling) + geompy.addToStudy( filling, "filling%d"%iface ) + #geompy.ExportBREP(filling, "filling.brep") + iface = iface+1 + fillings.append(filling) + noeuds_bords.append(noeudsBords) + idFilToCont.append(icont) + bords_Partages += bordsPartages + pass # --- loop on mats + # --- reconstruction des faces continues à partir des listes de noeuds + # les courbes doivent suivre la courbure pour éviter les oscillations + if icont == iface - 1: # pas de découpe, on garde la même face + fillcont = fillings[-1] + else: + nbLignes = len(curvconts[0]) + curves = [] + for i in range(nbLignes): + nodes = [curvconts[j][i] for j in range(len(curvconts))] + curve = geompy.MakeInterpol(nodes, False, False) + curves.append(curve) + fillcont = geompy.MakeFilling(geompy.MakeCompound(curves), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True) + geompy.addToStudy( fillcont, "filcont%d"%icont ) + fillconts.append(fillcont) + icont = icont+1 + pass # --- loop while there are remaining nodes + + return fillings, noeuds_bords, bords_Partages, fillconts, idFilToCont diff --git a/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py b/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py new file mode 100644 index 000000000..7acbe4c77 --- /dev/null +++ b/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import smesh +import SMESH +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- maillage complet et fissure + +def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None): + """ + Maillage sain sans la zone de defaut + TODO: a completer + """ + logging.info('Concatenation') + + maillageComplet = smesh.Concatenate([maillageSain.GetMesh(), blocComplet.GetMesh()], 1, 1, 1e-05,False) + + groups = maillageComplet.GetGroups() + grps = [ grp for grp in groups if grp.GetName() == 'FACE1'] + faceFissure = grps[0] + grps = [ grp for grp in groups if grp.GetName() == 'nfondfis'] + noeudsFondFissure = grps[0] + grps = [ grp for grp in groups if grp.GetName() == 'fisInPi'] + fisInPi = grps[0] + grps = [ grp for grp in groups if grp.GetName() == 'fisOutPi'] + fisOutPi = grps[0] + + # --- TODO: fiabiliser l'orientation dans le cas general + if normal is None: + normal = smesh.MakeDirStruct( 0, 0, 1 ) + maillageComplet.Reorient2D( fisInPi, normal, [0,0,0]) + maillageComplet.Reorient2D( fisOutPi, normal, [0,0,0]) + + shapes = [] + if extrusionFaceFissure is not None: + subIds = geompy.SubShapeAllIDs(extrusionFaceFissure, geompy.ShapeType["SOLID"]) + if len(subIds) > 1: + shapes = geompy.ExtractShapes(extrusionFaceFissure, geompy.ShapeType["SOLID"], False) + else: + shapes = [extrusionFaceFissure] +# else: +# subIds = geompy.SubShapeAllIDs(faceGeomFissure, geompy.ShapeType["FACE"]) +# if len(subIds) > 1: +# shapes = geompy.ExtractShapes(faceGeomFissure, geompy.ShapeType["FACE"], False) +# else: +# shapes = [faceGeomFissure] + + grpEdges = [] + grpFaces = [] + grpVolumes = [] + if len(shapes) == 0: + shapes = [None] # calcul uniquement avec les normales des faces mailles de la fissure + for i, aShape in enumerate(shapes): + logging.info('Detection elements affectes par le dedoublement de la face %d'%i) + affectedGroups = maillageComplet.AffectedElemGroupsInRegion([faceFissure], [noeudsFondFissure], aShape) + grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedEdges'] + affectedEdges = grps[0] + affectedEdges.SetName('affEd%d'%i) + grpEdges.append(affectedEdges) + grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedFaces'] + affectedFaces = grps[0] + affectedFaces.SetName('affFa%d'%i) + grpFaces.append(affectedFaces) + grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedVolumes'] + affectedVolumes = grps[0] + affectedVolumes.SetName('affVo%d'%i) + grpVolumes.append(affectedVolumes) + logging.info("union des groupes d'edges") + affectedEdges = maillageComplet.UnionListOfGroups(grpEdges, 'affEdges') + logging.info("union des groupes de faces") + affectedFaces = maillageComplet.UnionListOfGroups(grpFaces, 'affFaces') + logging.info("union des groupes de volumes") + affectedVolumes = maillageComplet.UnionListOfGroups(grpVolumes, 'affVols') + for grp in affectedGroups: + logging.debug("nom groupe %s",grp.GetName()) + [ FACE2, FACE2_nodes ] = maillageComplet.DoubleNodeElemGroups([faceFissure], [noeudsFondFissure], affectedGroups, True, True) + FACE2.SetName( 'FACE2' ) + + GroupVol = maillageComplet.CreateEmptyGroup( SMESH.VOLUME, nomVolume ) + nbAdd = GroupVol.AddFrom( maillageComplet.GetMesh() ) + + return maillageComplet + diff --git a/src/Tools/blocFissure/gmu/rotTrans.py b/src/Tools/blocFissure/gmu/rotTrans.py new file mode 100644 index 000000000..7b8ff6e47 --- /dev/null +++ b/src/Tools/blocFissure/gmu/rotTrans.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +import math +from triedreBase import triedreBase +O, OX, OY, OZ = triedreBase() + +# ----------------------------------------------------------------------------- +# --- operateur de rotation translation d'un objet centré à l'origine + +def rotTrans(objet, orientation, point, normal, trace = False): + """ + Déplacement par rotation translation d'un objet centré à l'origine, vers un point de la surface de la pièce saine + dans laquelle on insère le défaut. + @param objet : objet original centré à l'origine (geomObject) + @param orientation : rotation selon OX de l'objet original (degrés) + @param point : le point qui sera le centre de l'objet déplacé (geomObject), en général sur la surface de la pièce saine + @param normal : la normale à la surface de la pièce saine au point central (geomObject) + @return trans : objet transformé (geomObject) + """ + logging.info("start") + planXY = geompy.MakePlaneLCS(None, 2000, 1) + projXY = geompy.MakeProjection(normal, planXY) + [v1,v2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False) + xyz1 = geompy.PointCoordinates(v1) + xyz2 = geompy.PointCoordinates(v2) + x = xyz2[0] - xyz1[0] + y = xyz2[1] - xyz1[1] + sinalpha = y / math.sqrt(x*x + y*y) + cosalpha = x / math.sqrt(x*x + y*y) + alpha = math.asin(sinalpha) + if cosalpha < 0: + alpha = math.pi -alpha + + beta = geompy.GetAngleRadians(OZ, normal) + [v1,v2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False) + xyz1 = geompy.PointCoordinates(v1) + xyz2 = geompy.PointCoordinates(v2) + z = xyz2[2] - xyz1[2] + if z < 0: + beta = math.pi -beta + + rot0 = geompy.MakeRotation(objet, OX, orientation*math.pi/180.0) + rot1 = geompy.MakeRotation(rot0, OZ, alpha) + axe2 = geompy.MakeRotation(OY, OZ, alpha) + rot2 = geompy.MakeRotation(rot1, axe2, beta -math.pi/2.) + logging.debug("alpha",alpha) + logging.debug("beta",beta) + if trace: + geompy.addToStudy( rot1, 'rot1' ) + geompy.addToStudy( axe2, 'axe2' ) + geompy.addToStudy( rot2, 'rot2' ) + + xyz = geompy.PointCoordinates(point) + trans = geompy.MakeTranslation(rot2, xyz[0], xyz[1], xyz[2]) + return trans diff --git a/src/Tools/blocFissure/gmu/shapeSurFissure.py b/src/Tools/blocFissure/gmu/shapeSurFissure.py new file mode 100644 index 000000000..10b125ff7 --- /dev/null +++ b/src/Tools/blocFissure/gmu/shapeSurFissure.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- construction d'une shape de dectection des éléments à modifier suite à la la duplication des noeuds de la face fissure (d'un coté de la face) + +def shapeSurFissure(facesFissure): + """ + TODO: a completer, Normaliser les vecteurs et ponderer par les surfaces... + """ + logging.info('start') + normal = None + subIds = geompy.SubShapeAllIDs(facesFissure, geompy.ShapeType["FACE"]) + if len(subIds) > 1: + logging.debug("plusieurs faces de fissure") + faces = geompy.ExtractShapes(facesFissure, geompy.ShapeType["FACE"], False) + extrusions = [] + for n,face in enumerate(faces): + vertex = geompy.MakeVertexOnSurface(face, 0.5, 0.5) + normal = geompy.GetNormal(face, vertex) + extrusion = geompy.MakePrismVecH(face, normal, 100) + extrusions.append(extrusion) + extrusionFaceFissure = geompy.MakeCompound(extrusions) + else: + logging.debug("une seule face de fissure") + face = facesFissure + vertex = geompy.MakeVertexOnSurface(face, 0.5, 0.5) + normal = geompy.GetNormal(face, vertex) + extrusionFaceFissure = geompy.MakePrismVecH(facesFissure, normal, 100) + + geompy.addToStudy(extrusionFaceFissure, "extrusionFaceFissure") + return extrusionFaceFissure, normal + diff --git a/src/Tools/blocFissure/gmu/shapesSurFissure.py b/src/Tools/blocFissure/gmu/shapesSurFissure.py new file mode 100644 index 000000000..a8a98a1a1 --- /dev/null +++ b/src/Tools/blocFissure/gmu/shapesSurFissure.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- identification des shapes modifiées par la duplication des noeuds de la face fissure (d'un coté de la face) + +def shapesSurFissure(blocPartition, plane1, faceFissure, gencnt): + """ + TODO: a completer + """ + logging.info('start') + + shapesAModifier = [] + vertex = geompy.MakeVertexOnSurface(plane1, 0.5, 0.5) + normal = geompy.GetNormal(plane1, vertex) + extrusion = geompy.MakePrismVecH(plane1, normal, 100) + + sharedSolids = [] + solids= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("SOLID"), GEOM.ST_ONIN ) + for solid in solids: + sharedSolids += geompy.GetSharedShapes(faceFissure, solid, geompy.ShapeType["SOLID"]) + logging.debug("sharedSolids %s",sharedSolids) + + sharedFaces = [] + faces= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("FACE"), GEOM.ST_ONIN ) + for face in faces: + sharedFaces += geompy.GetSharedShapes(faceFissure, face, geompy.ShapeType["FACE"]) + logging.debug("sharedFaces %s",sharedFaces) + + sharedEdges = [] + edges= geompy.GetShapesOnBox ( extrusion, blocPartition, geompy.ShapeType("EDGE"), GEOM.ST_ONIN ) + for edge in edges: + if not edge.IsSame(gencnt): + sharedEdges += geompy.GetSharedShapes(faceFissure, edge, geompy.ShapeType["EDGE"]) + logging.debug("sharedEdges %s",sharedEdges) + + shapesAModifier = [ sharedSolids, sharedFaces, sharedEdges] + return shapesAModifier diff --git a/src/Tools/blocFissure/gmu/sortEdges.py b/src/Tools/blocFissure/gmu/sortEdges.py new file mode 100644 index 000000000..6d633f7d8 --- /dev/null +++ b/src/Tools/blocFissure/gmu/sortEdges.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- tri par longueur d'edges + +def sortEdges(edgesToSort): + """ + tri des edges par longueur + """ + logging.info('start') + + lenEdges = [(geompy.BasicProperties(edge)[0], i, edge) for i, edge in enumerate(edgesToSort)] + lenEdges.sort() + edgesSorted = [edge for length, i, edge in lenEdges] + return edgesSorted, lenEdges[0][0], lenEdges[-1][0] + diff --git a/src/Tools/blocFissure/gmu/sortFaces.py b/src/Tools/blocFissure/gmu/sortFaces.py new file mode 100644 index 000000000..0fe962e6d --- /dev/null +++ b/src/Tools/blocFissure/gmu/sortFaces.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- tri par surface de faces + +def sortFaces(facesToSort): + """ + tri des faces par surface + """ + logging.info('start') + + surFaces = [(geompy.BasicProperties(face)[1], i, face) for i, face in enumerate(facesToSort)] + surFaces.sort() + facesSorted = [face for surf, i, face in surFaces] + return facesSorted, surFaces[0][0], surFaces[-1][0] + diff --git a/src/Tools/blocFissure/gmu/sortGeneratrices.py b/src/Tools/blocFissure/gmu/sortGeneratrices.py new file mode 100644 index 000000000..956a8bcb8 --- /dev/null +++ b/src/Tools/blocFissure/gmu/sortGeneratrices.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- tri par longueur des 3 generatrices + +def sortGeneratrices(tore, geners): + """ + tri des 3 edges 'génératrices' selon leur longueur. + @param tore + @param les edges 'generatrices' + @return (genext, genint, gencnt) les 3 edges, de la plus grande à la plus petite + """ + logging.info("start") + + genx = geompy.ExtractShapes(geners[0], geompy.ShapeType["EDGE"], True) + + lenx = [] + for i in range(len(genx)): + props = geompy.BasicProperties(genx[i]) + lenx.append(props[0]) + pass + minlen = min(lenx) + maxlen = max(lenx) + genext=None + gencnt=None + genint=None + for i in range(len(genx)): + if lenx[i] == minlen: + genint = genx[i] + elif lenx[i] == maxlen: + genext = genx[i] + else: + gencnt= genx[i] + pass + + geompy.addToStudyInFather( tore, genext, 'genext' ) + geompy.addToStudyInFather( tore, genint, 'genint' ) + geompy.addToStudyInFather( tore, gencnt, 'gencnt' ) + + return genext, genint, gencnt diff --git a/src/Tools/blocFissure/gmu/sortSolids.py b/src/Tools/blocFissure/gmu/sortSolids.py new file mode 100644 index 000000000..c51bca539 --- /dev/null +++ b/src/Tools/blocFissure/gmu/sortSolids.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- tri par volume de solides + +def sortSolids(solidsToSort): + """ + tri des solides par volume + """ + logging.info('start') + + volSolids = [(geompy.BasicProperties(solid)[2], i, solid) for i, solid in enumerate(solidsToSort)] + volSolids.sort() + solidsSorted = [solid for vol, i, solid in volSolids] + return solidsSorted, volSolids[0][0], volSolids[-1][0] + diff --git a/src/Tools/blocFissure/gmu/substractSubShapes.py b/src/Tools/blocFissure/gmu/substractSubShapes.py new file mode 100644 index 000000000..3f819d7f4 --- /dev/null +++ b/src/Tools/blocFissure/gmu/substractSubShapes.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- substract a list of subShapes from another + +def substractSubShapes(obj, subs, toRemove): + """ + liste de subshapes par difference + """ + logging.info("start") + idToremove = {} + subList = [] + for s in toRemove: + idToremove[geompy.GetSubShapeID(obj, s)] = s + for s in subs: + idsub = geompy.GetSubShapeID(obj, s) + if idsub not in idToremove.keys(): + subList.append(s) + logging.debug("subList=%s", subList) + return subList diff --git a/src/Tools/blocFissure/gmu/testgmu.py b/src/Tools/blocFissure/gmu/testgmu.py new file mode 100644 index 000000000..219e3a98b --- /dev/null +++ b/src/Tools/blocFissure/gmu/testgmu.py @@ -0,0 +1,22 @@ + +from blocFissure import gmu +from blocFissure.gmu.initEtude import initEtude +initEtude() +from blocFissure.gmu.triedreBase import triedreBase +O, OX, OY, OZ = triedreBase() + +from blocFissure.gmu.distance2 import distance2 +a=[10, 20, 30] +b=[5, 7, 3] +c=distance2(a,b) + +import unittest +from blocFissure.gmu import initLog +initLog.setUnitTests() + +from blocFissure.gmu import distance2 + +suite = unittest.TestLoader().loadTestsFromTestCase(distance2.Test_distance2) +unittest.TextTestRunner(verbosity=2).run(suite) + + diff --git a/src/Tools/blocFissure/gmu/toreFissure.py b/src/Tools/blocFissure/gmu/toreFissure.py new file mode 100644 index 000000000..899ef5e0c --- /dev/null +++ b/src/Tools/blocFissure/gmu/toreFissure.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy +import math +from triedreBase import triedreBase + +O, OX, OY, OZ = triedreBase() + +# ----------------------------------------------------------------------------- +# --- tore et plan de fissure + +def toreFissure(minRad,allonge,rayTore): + """ + Construction de la geometrie du tore elliptique autour du front de fissure. + L'ellipse est construite dans le plan xoy, axe oy. + @param minRad :petit rayon + @param allonge :rapport grand rayon / petit rayon + @param rayTore :rayon du tore construit autour de la generatrice de l'ellipse + @return (generatrice, FaceGenFiss, Pipe_1, FaceFissure, Plane_1, Pipe1Part) : ellipse, section du tore, + tore plein, face plane de le fissure, plan de la fissure, tore partitioné par le plan de fissure. + """ + logging.info("start ", minRad, allonge, rayTore) + + Vertex_1 = geompy.MakeVertex( minRad, 0, 0) + Vertex_2 = geompy.MakeVertex(-minRad, 0, 0) + Vertex_3 = geompy.MakeRotation(Vertex_1, OZ, 45*math.pi/180.0) + Arc_1 = geompy.MakeArc(Vertex_1, Vertex_2, Vertex_3) + generatrice = geompy.MakeScaleAlongAxes(Arc_1, O, 1, allonge, 1) + + #geompy.addToStudy( Vertex_1, 'Vertex_1' ) + #geompy.addToStudy( Vertex_2, 'Vertex_2' ) + #geompy.addToStudy( Vertex_3, 'Vertex_3' ) + #geompy.addToStudy( Arc_1, 'Arc_1' ) + #geompy.addToStudy( generatrice, 'generatrice' ) + + # --- face circulaire sur la generatrice, pour extrusion + + Circle_1 = geompy.MakeCircle(O, OY, rayTore) + Rotation_1 = geompy.MakeRotation(Circle_1, OY, -90*math.pi/180.0) + Translation_1 = geompy.MakeTranslation(Rotation_1, minRad, 0, 0) + FaceGenFiss = geompy.MakeFaceWires([Translation_1], 1) + + #geompy.addToStudy( Circle_1, 'Circle_1' ) + #geompy.addToStudy( Rotation_1, 'Rotation_1' ) + #geompy.addToStudy( Translation_1, 'Translation_1' ) + #geompy.addToStudy( FaceGenFiss, 'FaceGenFiss' ) + + # --- tore extrude + + Pipe_1 = geompy.MakePipe(FaceGenFiss, generatrice) + + # --- plan fissure, delimite par la generatrice + + Scale_1_vertex_3 = geompy.GetSubShape(generatrice, [3]) + Line_1 = geompy.MakeLineTwoPnt(Vertex_1, Scale_1_vertex_3) + FaceFissure = geompy.MakeFaceWires([generatrice, Line_1], 1) + + #geompy.addToStudyInFather( generatrice, Scale_1_vertex_3, 'Scale_1:vertex_3' ) + #geompy.addToStudy( Line_1, 'Line_1' ) + #geompy.addToStudy( FaceFissure, 'FaceFissure' ) + + # --- tore coupe en 2 demi tore de section 1/2 disque + + Plane_1 = geompy.MakePlane(O, OZ, 2000) + Pipe1Part = geompy.MakePartition([Pipe_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + geompy.addToStudy(Pipe1Part , 'Pipe1Part' ) + + return generatrice, FaceGenFiss, Pipe_1, FaceFissure, Plane_1, Pipe1Part diff --git a/src/Tools/blocFissure/gmu/triedreBase.py b/src/Tools/blocFissure/gmu/triedreBase.py new file mode 100644 index 000000000..53135633e --- /dev/null +++ b/src/Tools/blocFissure/gmu/triedreBase.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# --- origine et vecteurs de base + +O = None +OX = None +OY = None +OZ = None + +def triedreBase(): + """ + definitions globales du triedre de reference, + objets partages par plusieurs methodes + """ + global O, OX, OY, OZ + + if O == None: + logging.info("start") + O = geompy.MakeVertex(0, 0, 0) + OX = geompy.MakeVectorDXDYDZ(1, 0, 0) + OY = geompy.MakeVectorDXDYDZ(0, 1, 0) + OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) + + geompy.addToStudy( O, 'O' ) + geompy.addToStudy( OX, 'OX' ) + geompy.addToStudy( OY, 'OY' ) + geompy.addToStudy( OZ, 'OZ' ) + + return O, OX, OY, OZ diff --git a/src/Tools/blocFissure/gmu/whichSide.py b/src/Tools/blocFissure/gmu/whichSide.py new file mode 100644 index 000000000..d31fad2dd --- /dev/null +++ b/src/Tools/blocFissure/gmu/whichSide.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- calcul de la position d'une shape par rapport à une face (dessus, dessous, sur la surface même) + +def whichSide(face, obj, tol = 1.e-3): + """ + Position d'un objet par rapport a une face (non nécessairement plane). + L'objet est supposé situé entierement d'un coté de la face, + ou lui appartenant totalement (objets traversants non pris en compte) + renvoie 1 si 'objet est du coté de la normale à la face, + -1 de l'autre coté, 0 si il est sur la face + """ + logging.debug('start') + side = 0 + logging.debug("shape info %s", geompy.ShapeInfo(obj)) + nbEdges = geompy.NbShapes(obj, geompy.ShapeType["EDGE"]) # --- attention ! pour une seule edge presente, renvoie 2 + logging.debug(" nbEdges %s", nbEdges) + nbFaces = geompy.NbShapes(obj, geompy.ShapeType["FACE"]) # --- attention ! pour une seule face presente, renvoie 2 + logging.debug(" nbFaces %s", nbFaces) + vertices = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False) + if nbEdges > 0 and nbFaces == 0: # --- edges + if nbEdges <= 2: + point = geompy.MakeVertexOnCurve(obj, 0.5) + vertices.append(point) + else: + edges = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False) + for anEdge in edges: + point = geompy.MakeVertexOnCurve(anEdge, 0.5) + vertices.append(point) + elif nbFaces >0: # --- faces + if nbFaces <=2: + point = geompy.MakeVertexOnSurface(obj, 0.5, 0.5) + vertices.append(point) + if nbFaces > 2: + faces = geompy.ExtractShapes(obj, geompy.ShapeType["FACE"], False) + for aFace in faces: + point = geompy.MakeVertexOnSurface(aFace, 0.5, 0.5) + vertices.append(point) + else: # --- vertices + vertices = [obj] + for vertex in vertices: + distance = geompy.MinDistance(vertex, face) + logging.debug(" distance %s", distance) + if distance > tol: + projection = geompy.MakeProjection(vertex, face) + normal = geompy.GetNormal(face, projection) + vect = geompy.MakeVector(projection, vertex) + angle = geompy.GetAngle(normal, vect) + logging.debug(" angle %s", angle) + side = 1 + if abs(angle) > 10: + side = -1 + break + logging.debug(" side %s", side) + return side + diff --git a/src/Tools/blocFissure/gmu/whichSideMulti.py b/src/Tools/blocFissure/gmu/whichSideMulti.py new file mode 100644 index 000000000..248e6cf2c --- /dev/null +++ b/src/Tools/blocFissure/gmu/whichSideMulti.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- calcul de la position d'une shape par rapport à une face (dessus, dessous, sur la surface même) + +def whichSideMulti(facerefs, ifil, obj, centre, tol = 1.e-3): + """ + Position d'un objet par rapport a un ensemble de faces (non nécessairement planes). + Ces faces délimitent partiellement un volume, le point "centre" est supposé dans le volume + L'objet est supposé situé entierement d'un coté des faces, + ou appartenant totalement à une face (objets traversants non pris en compte) + renvoie 1 si 'objet est dedans (inside), + -1 dehors (outside), 0 si il est sur une face d'index ifil + """ + logging.debug('start') + side = 0 + logging.debug("shape info %s", geompy.ShapeInfo(obj)) + nbEdges = geompy.NbShapes(obj, geompy.ShapeType["EDGE"]) # --- attention ! pour une seule edge presente, renvoie 2 + logging.debug(" nbEdges %s", nbEdges) + vertices = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False) + if nbEdges > 0 : # --- edges + if nbEdges <= 2: + point = geompy.MakeVertexOnCurve(obj, 0.5) + vertices.append(point) + else: + edges = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False) + for anEdge in edges: + point = geompy.MakeVertexOnCurve(anEdge, 0.5) + vertices.append(point) + else: # --- vertices + vertices = [obj] + nbOnRef = 0 + nbOnOther = 0 + for vertex in vertices: + nbMiss = 0 + for i, face in enumerate(facerefs): + distance = geompy.MinDistance(vertex, face) + logging.debug(" distance %s", distance) + if distance > tol: + if geompy.MinDistance(vertex, centre) > tol: + line = geompy.MakeLineTwoPnt(vertex, centre) + else : + side = 1 # le centre est inside... + break + part = geompy.MakePartition([line], [face], [], [], geompy.ShapeType["EDGE"], 0, [], 0) + nbpts = geompy.NbShapes(part,geompy.ShapeType["VERTEX"]) + if nbpts > 2: + side = -1 # outside + break + else: + nbMiss += 1 + pass # peut-être inside, tester les autres faces + else: + if i == ifil: + nbOnRef +=1 # le point est sur la face de référence, on continue avec les autres points + break + else: + nbOnOther += 1 # le point est sur une autre face, mais il peut aussi être sur la face de référence... + pass # on peut tester les autres faces + if nbMiss == len(facerefs): + side = 1 # inside + if side != 0: + break + if side == 0 and nbOnRef < len(vertices): + side = 1 # inside + logging.debug(" side %s", side) + return side + diff --git a/src/Tools/blocFissure/gmu/whichSideVertex.py b/src/Tools/blocFissure/gmu/whichSideVertex.py new file mode 100644 index 000000000..13a29c4fa --- /dev/null +++ b/src/Tools/blocFissure/gmu/whichSideVertex.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import logging +from geomsmesh import geompy + +# ----------------------------------------------------------------------------- +# --- calcul de la position d'une shape par rapport à une face (dessus, dessous, sur la surface même) + +def whichSideVertex(face, vertex, tol = 1.e-3): + """ + Position d'un vertex par rapport a une face (non nécessairement plane). + renvoie 1 si le vertex est du coté de la normale à la face, + -1 de l'autre coté, 0 si il est sur la face + """ + #logging.info('start') + side = 0 + distance = geompy.MinDistance(vertex, face) + #logging.debug(" distance %s", distance) + if distance > tol: + projection = geompy.MakeProjection(vertex, face) + normal = geompy.GetNormal(face, projection) + vect = geompy.MakeVector(projection, vertex) + angle = geompy.GetAngle(normal, vect) + #logging.debug(" angle %s", angle) + side = 1 + if abs(angle) > 10: + side = -1 + logging.debug("side %s distance %s", side, distance) + return side + diff --git a/src/Tools/blocFissure/ihm/CMakeLists.txt b/src/Tools/blocFissure/ihm/CMakeLists.txt new file mode 100644 index 000000000..7b8c7406c --- /dev/null +++ b/src/Tools/blocFissure/ihm/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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. +# +# 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 +# + +INCLUDE(UsePyQt4) + +# --- scripts --- + +# scripts / static +SET(plugin_SCRIPTS + __init__.py + fissureCoude_ihm.py + fissureCoude_plugin.py +) + +# --- resources --- + +# uic files / to be processed by pyuic +SET(_pyuic_files + fissureCoude.ui + fissureGenerale.ui +) + +# scripts / pyuic wrappings +PYQT4_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_files}) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure/ihm) + +SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure/ihm) \ No newline at end of file diff --git a/src/Tools/blocFissure/ihm/__init__.py b/src/Tools/blocFissure/ihm/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/Tools/blocFissure/ihm/fissureCoude.ui b/src/Tools/blocFissure/ihm/fissureCoude.ui new file mode 100644 index 000000000..16284e989 --- /dev/null +++ b/src/Tools/blocFissure/ihm/fissureCoude.ui @@ -0,0 +1,1071 @@ + + + Dialog + + + + 0 + 0 + 1061 + 600 + + + + Dialog + + + + + + + + + + Coude Sain + + + + + + Géométrie + + + + + + + + L_TUBE_P1 + + + + + + + Valeur de l'angle du coude en degrés + + + 5 + + + -181.000000000000000 + + + 180.000000000000000 + + + -181.000000000000000 + + + + + + + R_CINTR + + + + + + + EPAIS + + + + + + + Valeur de l’épaisseur du coude et des embouts + + + 5 + + + 1000000.000000000000000 + + + + + + + L_TUBE_P2 + + + + + + + Valeur de la longueur de l’embout P2 à l’extrémité duquel seront appliqués les chargements + + + 5 + + + 1000000.000000000000000 + + + + + + + DEXT + + + + + + + ANGLE + + + + + + + Valeur du diamètre externe du coude et des embouts droits + + + 5 + + + 1000000.000000000000000 + + + + + + + Valeur de la longueur de l’embout P1 à l’extrémité duquel seront appliqués les chargements + + + 5 + + + 1000000.000000000000000 + + + + + + + Valeur du rayon de cintrage du coude + + + 5 + + + 1000000.000000000000000 + + + + + + + + + + + + + + + Paramètres optionnels de discretisation + + + Options de discretisation + + + + + + + Maillage + + + + + + + + Nombres de segments + + + + + + + + + NB_AXE_TUBE_P1 + + + + + + + Nombre d’éléments le long de l’embout P1 + + + 10000 + + + 15 + + + + + + + NB_AXE_TUBE_P2 + + + + + + + Nombre d’éléments le long de l’embout P2 + + + 10000 + + + 15 + + + + + + + NB_AXE_COUDE + + + + + + + Nombre d’éléments le long de l’axe du coude + + + 10000 + + + 10 + + + + + + + NB_CIRCONF + + + + + + + <html><head/><body><p>Nombre d’éléments le long de la circonférence</p><p>(nombre pair)</p></body></html> + + + 10000 + + + 20 + + + + + + + NB_EPAISSEUR + + + + + + + Nombre d'éléments dans l'épaisseur + + + 10000 + + + 3 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Fissure + + + + + + + + Géométrie fissure + + + + + + + + position + + + + + + <html><head/><body><p>Fissure positionnée sur la face interne</p></body></html> + + + fissure interne + + + + + + + <html><head/><body><p>Fissure positionnée sur la face externe</p></body></html> + + + fissure externe + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>Forcer une fissure de forme elliptique, même si elle est longue</p></body></html> + + + + + + forcer elliptique + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Valeur de la position circonférentielle du centre de la fissure comptée positivement en degrés à partir de l’extrados jusqu’à l’intrados en passant par le flanc gauche + + + 5 + + + -181.000000000000000 + + + 180.000000000000000 + + + -181.000000000000000 + + + + + + + PROFONDEUR + + + + + + + <html><head/><body><p>Profondeur de la fissure :</p><p>distance maximale entre le fond de fissure et la peau interne ou externe sur laquelle débouche la fissure</p></body></html> + + + 5 + + + 1000000.000000000000000 + + + + + + + LONGUEUR + + + + + + + AZIMUT + + + + + + + ORIEN + + + + + + + Valeur de l’angle en degrés formé par le grand axe de la fissure et la génératrice du coude donnant ainsi l’orientation du défaut + + + 5 + + + -1.000000000000000 + + + 90.000000000000000 + + + -1.000000000000000 + + + + + + + Longueur du grand axe de la fissure mesurée sur le coude en peau interne ou externe, suivant la peau sur laquelle se trouve la fissure + + + 5 + + + 1000000.000000000000000 + + + + + + + + + position longitudinale + + + + + + Définition de la position longitudinale par une abscisse curiviligne + + + ABS_CURV + + + + + + + Définition de la position longitudinale par un angle + + + POSI_ANGUL + + + + + + + <html><head/><body><p>Valeur de la position longitudinale du centre de la fissure définie par rapport à l'interface de l'embout P1 :</p><p>Abcisse curviligne le long de l'axe du coude, sur la peau interne ou externe, selon la position de la fissure.</p><p><br/></p></body></html> + + + 5 + + + 1000000.000000000000000 + + + + + + + <html><head/><body><p>Valeur de la position longitudinale du centre de la fissure définie par rapport à l'interface de l'embout P1 :</p><p>Angle en degrés formé par la section contenant le centre de la fissure et l'interface de l'embout P1.</p><p><br/></p></body></html> + + + 5 + + + -181.000000000000000 + + + 180.000000000000000 + + + -181.000000000000000 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Maillage fissure + + + + + + maillage zone de fissure + + + + + + pipe rayonnant + + + + + + + + NB_TRANCHES + + + + + + + NB_COURONNE + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>nombre de couronnes du maillage rayonnant autour de la ligne de fond de fissure, y compris la couronne centrale formée de prismes.</p></body></html> + + + 1 + + + 10000 + + + 1 + + + + + + + NB_SECTEUR + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>nombre de secteurs selon un cercle normal au fond de fissure.</p></body></html> + + + 3 + + + 10000 + + + 3 + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>Nombre de mailles (approximatif) le long de la ligne de fond de fissure.</p></body></html> + + + 7 + + + 100000 + + + 7 + + + + + + + RAYON_TORE + + + + + + + false + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>Rayon du pipe.</p></body></html> + + + 5 + + + 1000000.000000000000000 + + + 2.000000000000000 + + + + + + + + + Qt::Horizontal + + + + 6 + 20 + + + + + + + + + + + Paramètres optionnels de discrétisation + + + Options de discretisation + + + + + + + true + + + faces externes + + + + + + aretes face fissure + + + + + + + <html><head/><body><p>Faces externes de la zone à remailler.</p><p>Mailage en triangles : valeur cible des arêtes.</p></body></html> + + + 5 + + + 1000000.000000000000000 + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + + + + + true + + + identification zone à remailler + + + + + + + + <html><head/><body><p>La zone remaillée contiendra toutes les mailles du maillage sain à une distance de la face de fissure inférieure à cette valeur.</p></body></html> + + + 5 + + + 1000000.000000000000000 + + + + + + + distance influence + + + + + + + + + Qt::Horizontal + + + + 47 + 20 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 4 + + + + + + + + + + réinitialisation de tous les paramètres à leur valeur par défaut + + + Reset + + + + + + + réinitialisation de tous les paramètres à leur valeur de la précédente éxécution + + + Précédent + + + + + + + réinitialisation des paramètres à partir d'un fichier préalablement sauvegardé + + + Recharger + + + + + + + sauvegarde des paramètres dans un fichier à choisir + + + Sauver + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + verticalSpacer_2 + + + + + buttonBox + accepted() + Dialog + accept() + + + 1055 + 594 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 1055 + 594 + + + 286 + 274 + + + + + cb_optDiscrSain + clicked(bool) + gb_discrSain + setShown(bool) + + + 69 + 312 + + + 70 + 549 + + + + + cb_optDiscrFiss + clicked(bool) + gb_discrFacesExternes + setShown(bool) + + + 1033 + 311 + + + 1033 + 387 + + + + + cb_optDiscrFiss + clicked(bool) + gb_zoneRemail + setShown(bool) + + + 1033 + 311 + + + 1036 + 472 + + + + + cb_optDiscrFiss + clicked(bool) + dsb_rayonTore + setEnabled(bool) + + + 1033 + 311 + + + 1005 + 278 + + + + + rb_absCurv + toggled(bool) + dsb_absCurv + setEnabled(bool) + + + 477 + 392 + + + 649 + 396 + + + + + rb_posiAngul + toggled(bool) + dsb_posiAngul + setEnabled(bool) + + + 477 + 425 + + + 649 + 429 + + + + + diff --git a/src/Tools/blocFissure/ihm/fissureCoude_ihm.py b/src/Tools/blocFissure/ihm/fissureCoude_ihm.py new file mode 100644 index 000000000..1167c55fa --- /dev/null +++ b/src/Tools/blocFissure/ihm/fissureCoude_ihm.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +from blocFissure.gmu.fissureCoude import fissureCoude + +class fissureCoude_ihm(fissureCoude): + """ + problème de fissure du Coude : + pour version IHM graphique + """ + +# --------------------------------------------------------------------------- + def setDicoParams(self,dico): + self.dico = dico + +# --------------------------------------------------------------------------- + def setParamGeometrieSaine(self): + """ + Paramètres géométriques du tuyau coudé sain: + angleCoude + r_cintr + l_tube_p1 + l_tube_p2 + epais + de + """ + self.geomParams = dict(angleCoude = self.dico['angle'], + r_cintr = self.dico['rCintr'], + l_tube_p1 = self.dico['lTubeP1'], + l_tube_p2 = self.dico['lTubeP2'], + epais = self.dico['epais'], + de = self.dico['dext']) + + # --------------------------------------------------------------------------- + def setParamMaillageSain(self): + self.meshParams = dict(n_long_p1 = self.dico['nbAxeTubeP1'], + n_ep = self.dico['nbEpaisseur'], + n_long_coude = self.dico['nbAxeCoude'], + n_circ_g = self.dico['nbCirconf'], + n_circ_d = self.dico['nbCirconf'], + n_long_p2 = self.dico['nbAxeTubeP2']) + +# --------------------------------------------------------------------------- + def setParamShapeFissure(self): + """ + paramètres de la fissure pour le tuyau coude + profondeur : 0 < profondeur <= épaisseur + rayonPipe : rayon du pipe correspondant au maillage rayonnant + lenSegPipe : longueur des mailles rayonnantes le long du fond de fissure (= rayonPipe par défaut) + azimut : entre 0 et 360° + alpha : 0 < alpha < angleCoude + longueur : <=2*profondeur ==> force une fissure elliptique (longueur/profondeur = grand axe/petit axe). + orientation : 0° : longitudinale, 90° : circonférentielle, autre : uniquement fissures elliptiques + lgInfluence : distance autour de la shape de fissure a remailler (si 0, pris égal à profondeur. A ajuster selon le maillage) + elliptique : True : fissure elliptique (longueur/profondeur = grand axe/petit axe); False : fissure longue (fond de fissure de profondeur constante, demi-cercles aux extrémites) + pointIn_x : optionnel coordonnées x d'un point dans le solide, pas trop loin du centre du fond de fissure (idem y,z) + externe : True : fissure face externe, False : fissure face interne + """ + print "setParamShapeFissure", self.nomCas + self.shapeFissureParams = dict(profondeur = self.dico['profondeur'], + rayonPipe = self.dico['rayonTore'], + lenSegPipe = self.dico['lenSegPipe'], + azimut = self.dico['azimut'], + alpha = self.dico['posiAngul'], + longueur = self.dico['longueur'], + orientation = self.dico['orientation'], + lgInfluence = self.dico['influence'], + elliptique = self.dico['cbForceEllipse'], + externe = self.dico['rbFissExt']) + +# --------------------------------------------------------------------------- + def setParamMaillageFissure(self): + """ + Paramètres du maillage de la fissure pour le tuyau coudé + Voir également setParamShapeFissure, paramètres rayonPipe et lenSegPipe. + nbSegRad = nombre de couronnes + nbSegCercle = nombre de secteurs + areteFaceFissure = taille cible de l'arête des triangles en face de fissure. + """ + self.maillageFissureParams = dict(nomRep = '.', + nomFicSain = self.nomCas, + nomFicFissure = 'fissure_' + self.nomCas, + nbsegRad = self.dico['nbCouronnes'], + nbsegCercle = self.dico['nbSecteurs'], + areteFaceFissure = self.dico['aretesFaceFissure']) + + # --------------------------------------------------------------------------- + def setReferencesMaillageFissure(self): + self.referencesMaillageFissure = dict(Entity_Node = 0, + Entity_Quad_Edge = 0, + Entity_Quad_Triangle = 0, + Entity_Quad_Quadrangle = 0, + Entity_Quad_Tetra = 0, + Entity_Quad_Hexa = 0, + Entity_Quad_Penta = 0, + Entity_Quad_Pyramid = 0) + diff --git a/src/Tools/blocFissure/ihm/fissureCoude_plugin.py b/src/Tools/blocFissure/ihm/fissureCoude_plugin.py new file mode 100644 index 000000000..67e4cd855 --- /dev/null +++ b/src/Tools/blocFissure/ihm/fissureCoude_plugin.py @@ -0,0 +1,393 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2006-2013 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. +# +# 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 +# + +# if you already have plugins defined in a salome_plugins.py file, add this file at the end. +# if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py + +import sys, traceback +from blocFissure import gmu +from blocFissure.gmu import initLog +#initLog.setDebug() +initLog.setVerbose() + +from blocFissure.gmu import geomsmesh +from blocFissure.casStandard import casStandard + +from blocFissure.ihm.fissureCoude_ihm import fissureCoude_ihm + +def fissureCoudeDlg(context): + # get context study, studyId, salomeGui + study = context.study + studyId = context.studyId + sg = context.sg + + import os + #import subprocess + #import tempfile + from PyQt4 import QtCore + from PyQt4 import QtGui + from PyQt4.QtGui import QFileDialog + from PyQt4.QtGui import QMessageBox + from PyQt4.QtGui import QPalette + from PyQt4.QtGui import QColor + from fissureCoude_ui import Ui_Dialog + + class fissureCoudeDialog(QtGui.QDialog): + + def __init__(self): + QtGui.QDialog.__init__(self) + # Set up the user interface from Designer. + self.ui = Ui_Dialog() + self.ui.setupUi(self) + + self.blackPalette = self.ui.dsb_angle.palette() + self.redPalette = QPalette() + self.redPalette.setColor(QPalette.Text, QColor(255,0,0)) + self.NOK = False + + self.initDefaut() + self.initDialog(self.defaut) + self.ui.dsb_angle.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_rCintr.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_lTubeP1.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_lTubeP2.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_epais.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_dext.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_profondeur.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_longueur.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_azimut.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_orientation.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_posiAngul.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_absCurv.setSpecialValueText("saisie_obligatoire") + self.ui.sb_nbTranches.setSpecialValueText("saisie_obligatoire") + self.ui.sb_nbCouronne.setSpecialValueText("saisie_obligatoire") + self.ui.sb_nbSecteur.setSpecialValueText("saisie_obligatoire") + self.ui.dsb_aretesFaceFissure.setSpecialValueText("automatique") + self.ui.dsb_influence.setSpecialValueText("automatique") + + # Connect up the buttons. + self.connect(self.ui.pb_valPrec, QtCore.SIGNAL("clicked()"), + self.readValPrec) + self.connect(self.ui.pb_reset, QtCore.SIGNAL("clicked()"), + self.resetVal) + self.connect(self.ui.pb_recharger, QtCore.SIGNAL("clicked()"), + self.recharger) + self.connect(self.ui.pb_sauver, QtCore.SIGNAL("clicked()"), + self.sauver) + self.disconnect(self.ui.buttonBox, QtCore.SIGNAL("accepted()"), self.accept) + self.connect(self.ui.buttonBox, QtCore.SIGNAL("accepted()"), + self.execute) + + def initDefaut(self): + self.defaut = dict( + angle = -181.0, + rCintr = 0.0, + lTubeP1 = 0.0, + lTubeP2 = 0.0, + epais = 0.0, + dext = 0.0, + profondeur = 0.0, + longueur = 0.0, + azimut = -181.0, + orientation = -1.0, + posiAngul = -181.0, + absCurv = 0.0, + nbTranches = 7, + nbCouronnes = 1, + nbSecteurs = 3, + cbOptDiscrSain = False, + cbOptDiscrFiss = False, + rbPosiAngul = True, + rbFissExt = True, + cbForceEllipse = False, + nbAxeTubeP1 = 15, + nbAxeTubeP2 = 15, + nbAxeCoude = 10, + nbCirconf = 20, + nbEpaisseur = 3, + rayonTore = 2.0, + aretesFaceFissure = 0.0, + influence = 0.0, + ) + + def initDialog(self, dico): + self.ui.dsb_angle.setValue(dico['angle']) + self.ui.dsb_rCintr.setValue(dico['rCintr']) + self.ui.dsb_lTubeP1.setValue(dico['lTubeP1']) + self.ui.dsb_lTubeP2.setValue(dico['lTubeP2']) + self.ui.dsb_epais.setValue(dico['epais']) + self.ui.dsb_dext.setValue(dico['dext']) + self.ui.dsb_profondeur.setValue(dico['profondeur']) + self.ui.dsb_longueur.setValue(dico['longueur']) + self.ui.dsb_azimut.setValue(dico['azimut']) + self.ui.dsb_orientation.setValue(dico['orientation']) + self.ui.dsb_posiAngul.setValue(dico['posiAngul']) + self.ui.dsb_absCurv.setValue(dico['absCurv']) + self.ui.sb_nbTranches.setValue(dico['nbTranches']) + self.ui.sb_nbCouronne.setValue(dico['nbCouronnes']) + self.ui.sb_nbSecteur.setValue(dico['nbSecteurs']) + self.ui.dsb_aretesFaceFissure.setValue(dico['aretesFaceFissure']) + self.ui.dsb_influence.setValue(dico['influence']) + self.ui.sb_nbAxeTubeP1.setValue(dico['nbAxeTubeP1']) + self.ui.sb_nbAxeTubeP2.setValue(dico['nbAxeTubeP2']) + self.ui.sb_nbAxeCoude.setValue(dico['nbAxeCoude']) + self.ui.sb_nbCirconf.setValue(dico['nbCirconf']) + self.ui.sb_nbEpaisseur.setValue(dico['nbEpaisseur']) + self.ui.dsb_rayonTore.setValue(dico['rayonTore']) + #self.ui.cb_optDiscrSain.setChecked(False) + #self.ui.gb_discrSain.setShown(False) + self.ui.cb_optDiscrSain.setChecked(not(dico['cbOptDiscrSain'])) + self.ui.cb_optDiscrSain.click() + self.ui.cb_optDiscrFiss.setChecked(not(dico['cbOptDiscrFiss'])) + self.ui.cb_optDiscrFiss.click() + if dico['rbPosiAngul']: + self.ui.dsb_absCurv.setEnabled(False) + self.ui.dsb_posiAngul.setEnabled(True) + self.ui.rb_posiAngul.setChecked(True) + #self.ui.rb_posiAngul.click() + else: + self.ui.dsb_absCurv.setEnabled(True) + self.ui.dsb_posiAngul.setEnabled(False) + self.ui.rb_absCurv.setChecked(True) + #self.ui.rb_absCurv.click() + self.ui.rb_fissExt.setChecked(dico['rbFissExt']) + self.ui.cb_forceEllipse.setChecked(dico['cbForceEllipse']) + incomplet = self.testval(dico) + pass + + def testval(self, dico): + incomplet = False + if dico['angle'] < -180.0: + self.ui.dsb_angle.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_angle.setPalette(self.blackPalette) + + if dico['rCintr'] == 0.0: + self.ui.dsb_rCintr.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_rCintr.setPalette(self.blackPalette) + + if dico['lTubeP1'] == 0.0: + self.ui.dsb_lTubeP1.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_lTubeP1.setPalette(self.blackPalette) + + if dico['lTubeP2'] == 0.0: + self.ui.dsb_lTubeP2.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_lTubeP2.setPalette(self.blackPalette) + + if dico['epais'] == 0.0: + self.ui.dsb_epais.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_epais.setPalette(self.blackPalette) + + if dico['dext'] == 0.0: + self.ui.dsb_dext.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_dext.setPalette(self.blackPalette) + + if dico['profondeur'] == 0.0: + self.ui.dsb_profondeur.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_profondeur.setPalette(self.blackPalette) + + if dico['longueur'] == 0.0: + self.ui.dsb_longueur.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_longueur.setPalette(self.blackPalette) + + if dico['azimut'] < -180.0: + self.ui.dsb_azimut.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_azimut.setPalette(self.blackPalette) + + if dico['orientation'] < 0.0: + self.ui.dsb_orientation.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_orientation.setPalette(self.blackPalette) + + if dico['posiAngul'] < -180.0 and dico['rbPosiAngul'] == True: + self.ui.dsb_posiAngul.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_posiAngul.setPalette(self.blackPalette) + + if dico['absCurv'] == 0.0 and dico['rbPosiAngul'] == False: + self.ui.dsb_absCurv.setPalette(self.redPalette) + incomplet = True + else: + self.ui.dsb_absCurv.setPalette(self.blackPalette) + + if dico['nbTranches'] == 7: + self.ui.sb_nbTranches.setPalette(self.redPalette) + incomplet = True + else: + self.ui.sb_nbTranches.setPalette(self.blackPalette) + + if dico['nbCouronnes'] == 1: + self.ui.sb_nbCouronne.setPalette(self.redPalette) + incomplet = True + else: + self.ui.sb_nbCouronne.setPalette(self.blackPalette) + + if dico['nbSecteurs'] == 3: + self.ui.sb_nbSecteur.setPalette(self.redPalette) + incomplet = True + else: + self.ui.sb_nbSecteur.setPalette(self.blackPalette) + + print "incomplet: ", incomplet + return incomplet + + def fileDefault(self): + filedef = os.path.expanduser("~/.config/salome/dialogFissureCoude.dic") + print filedef + return filedef + + def writeDefault(self, dico): + filedef = self.fileDefault() + f = open(filedef, 'w') + f.write(str(dico)) + f.close() + + def readValPrec(self): + filedef = self.fileDefault() + if os.path.exists(filedef): + f = open(filedef, 'r') + txt = f.read() + dico = eval(txt) + print dico + self.initDialog(dico) + + def resetVal(self): + #self.initDefaut() + self.initDialog(self.defaut) + + def sauver(self): + print "sauver" + fileDiag = QFileDialog(self) + fileDiag.setFileMode(QFileDialog.AnyFile) + fileDiag.setNameFilter("Parametres *.dic (*.dic)") + fileDiag.setViewMode(QFileDialog.List) + if fileDiag.exec_() : + fileNames = fileDiag.selectedFiles() + filedef = fileNames[0] + dico = self.creeDico() + f = open(filedef, 'w') + f.write(str(dico)) + f.close() + + def recharger(self): + print "recharger" + fileDiag = QFileDialog(self) + fileDiag.setFileMode(QFileDialog.ExistingFile) + fileDiag.setNameFilter("Parametres *.dic (*.dic)") + fileDiag.setViewMode(QFileDialog.Detail) + if fileDiag.exec_() : + fileNames = fileDiag.selectedFiles() + filedef = fileNames[0] + print filedef + if os.path.exists(filedef): + f = open(filedef, 'r') + txt = f.read() + dico = eval(txt) + print dico + self.initDialog(dico) + + def creeDico(self): + dico = dict( + angle = self.ui.dsb_angle.value(), + rCintr = self.ui.dsb_rCintr.value(), + lTubeP1 = self.ui.dsb_lTubeP1.value(), + lTubeP2 = self.ui.dsb_lTubeP2.value(), + epais = self.ui.dsb_epais.value(), + dext = self.ui.dsb_dext.value(), + profondeur = self.ui.dsb_profondeur.value(), + longueur = self.ui.dsb_longueur.value(), + azimut = self.ui.dsb_azimut.value(), + orientation = self.ui.dsb_orientation.value(), + posiAngul = self.ui.dsb_posiAngul.value(), + absCurv = self.ui.dsb_absCurv.value(), + nbTranches = self.ui.sb_nbTranches.value(), + nbCouronnes = self.ui.sb_nbCouronne.value(), + nbSecteurs = self.ui.sb_nbSecteur.value(), + cbOptDiscrSain = self.ui.cb_optDiscrSain.isChecked(), + cbOptDiscrFiss = self.ui.cb_optDiscrFiss.isChecked(), + rbPosiAngul = self.ui.rb_posiAngul.isChecked(), + rbFissExt = self.ui.rb_fissExt.isChecked(), + cbForceEllipse = self.ui.cb_forceEllipse.isChecked(), + nbAxeTubeP1 = self.ui.sb_nbAxeTubeP1.value(), + nbAxeTubeP2 = self.ui.sb_nbAxeTubeP2.value(), + nbAxeCoude = self.ui.sb_nbAxeCoude.value(), + nbCirconf = self.ui.sb_nbCirconf.value(), + nbEpaisseur = self.ui.sb_nbEpaisseur.value(), + rayonTore = self.ui.dsb_rayonTore.value(), + aretesFaceFissure = self.ui.dsb_aretesFaceFissure.value(), + influence = self.ui.dsb_influence.value(), + ) + print dico + return dico + + def checkValues(self): + return self.NOK + + def execute(self): + dico = self.creeDico() + NOK = self.testval(dico) + if not(NOK): + dico['lenSegPipe'] = (dico['longueur'] + 3.14*dico['profondeur'])/dico['nbTranches'] + self.writeDefault(dico) + probleme = fissureCoude_ihm(0) + probleme.setDicoParams(dico) + probleme.executeProbleme() + self.NOK = NOK + self.accept() + + pass + +# ---------------------------------------------------------------------------- + + window = fissureCoudeDialog() +# window.ui.dsb_tolerance.setValue(0.01) + retry = True + while(retry): + retry = False + window.exec_() + result = window.result() + if result: + # dialog accepted + print "dialog accepted, check" + retry = window.checkValues() + else: + print "dialog rejected, exit" + pass + diff --git a/src/Tools/blocFissure/ihm/fissureGenerale.ui b/src/Tools/blocFissure/ihm/fissureGenerale.ui new file mode 100644 index 000000000..c18b3c18d --- /dev/null +++ b/src/Tools/blocFissure/ihm/fissureGenerale.ui @@ -0,0 +1,448 @@ + + + Dialog + + + + 0 + 0 + 631 + 490 + + + + Dialog + + + <html><head/><body><p>Insertion d'un maillage de fissure dans un maillage hexaédrique sain.</p><p>Le maillage sain est fourni sous forme de fichier Med.</p><p>La face de fissure est décrite par une géométrie dans un fichier brep.</p><p>La ou les arêtes de fond de fissure sont données par leurs index dans la face de fissure.</p><p>La procédure identfie des mailles saines à enlever et remailler, construit un maillage régulier rayonnant autour de la ligne de fond de fissure, reconstitue les faces externes en triangles, complète la zone à remailler en tétraèdres.</p></body></html> + + + + + + maillage sain et géometries de fissure + + + + + + + + <html><head/><body><p>sélection du fichier med du maillage sain (hexaèdres)</p></body></html> + + + maillage sain + + + + + + + <html><head/><body><p>fichier med du maillage sain (hexaèdres)</p></body></html> + + + + + + + <html><head/><body><p>sélection du fichier brep (géométrie) décrivant la face de fissure.</p></body></html> + + + face fissure + + + + + + + <html><head/><body><p>fichier brep (géométrie) décrivant la face de fissure.</p></body></html> + + + + + + + + + + + index edges fond fissure + + + + + + + <html><head/><body><p>Index des edges décrivant le fond de fissure, dans la face de fissure.</p><p>Sous forme d'une liste Python.</p><p>Exemples :<span style=" color:#00ffff;"/><span style=" font-style:italic; color:#00ffff;">[5,9]</span> ou <span style=" font-style:italic; color:#00ffff;">[3]</span></p><p>(on peut récupérer ces valeurs à l'aide du dialogue de création de groupes d'edges, dans GEOM)</p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + identification zone à remailler + + + + + + + + distance influence + + + + + + + <html><head/><body><p>La zone remaillée contiendra toutes les mailles du maillage sain à une distance de la face de fissure inférieure à cette valeur.</p></body></html> + + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + prémaillage face fissure + + + + + + + + min + + + + + + + <html><head/><body><p>Pour faciliter la détermination de la zone à remailler, il faut des points sur la face de fissure, suffisament resserrés, en relation avec la taille des mailles du maillage sain.</p><p>Ces points sont obtenus par pré maillage de la face de fissure, en triangles. On donne la taille min et max des triangles.</p></body></html> + + + 1000000.000000000000000 + + + + + + + max + + + + + + + <html><head/><body><p>Pour faciliter la détermination de la zone à remailler, il faut des points sur la face de fissure, suffisament resserrés, en relation avec la taille des mailles du maillage sain.</p><p>Ces points sont obtenus par pré maillage de la face de fissure, en triangles. On donne la taille min et max des triangles.</p></body></html> + + + 1000000.000000000000000 + + + + + + + + + Qt::Horizontal + + + + 34 + 20 + + + + + + + + + + + + + + maillage zone de fissure + + + + + + pipe rayonnant + + + + + + + + rayon pipe + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>Rayon du pipe.</p></body></html> + + + 1000000.000000000000000 + + + + + + + longueur mailles + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>Longueur des mailles le long de la ligne de fond de fissure.</p></body></html> + + + 1000000.000000000000000 + + + + + + + couronnes + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>nombre de couronnes de mailles autour de la ligne de fond de fissure.</p></body></html> + + + 2 + + + 10000 + + + 4 + + + + + + + secteurs + + + + + + + <html><head/><body><p>Pipe rayonnant construit sur le fond de fissure :</p><p>nombre de secteurs selon un cercle normal au fond de fissure.</p></body></html> + + + 4 + + + 10000 + + + 8 + + + + + + + + + Qt::Horizontal + + + + 6 + 20 + + + + + + + + + + + faces externes + + + + + + aretes face fissure + + + + + + + <html><head/><body><p>Faces externes de la zone à remailler.</p><p>Mailage en triangles : valeur cible des arêtes.</p></body></html> + + + 1000000.000000000000000 + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 112 + + + + + + + + + + Qt::Vertical + + + + 20 + 13 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + bb_OkCancel + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_OkCancel + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/Tools/blocFissure/materielCasTests/CMakeLists.txt b/src/Tools/blocFissure/materielCasTests/CMakeLists.txt new file mode 100644 index 000000000..108cb1549 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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. +# +# 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 +# + +# --- scripts --- + +# scripts / static +SET(plugin_SCRIPTS + __init__.py + cubeAngle.py + decoupeCylindre.py + disque_perce.py + ellipse_disque.py + ellipse_probleme.py + ellipse.py + eprouvetteCourbe.py + eprouvetteDroite.py + fissureGauche2.py + fissureGauche.py + genereMateriel.py + vis.py +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}/blocFissure/materielCasTests) diff --git a/src/Tools/blocFissure/materielCasTests/__init__.py b/src/Tools/blocFissure/materielCasTests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/Tools/blocFissure/materielCasTests/cubeAngle.py b/src/Tools/blocFissure/materielCasTests/cubeAngle.py new file mode 100644 index 000000000..e596663ca --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/cubeAngle.py @@ -0,0 +1,78 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.NoteBook(theStudy) + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Vertex_1 = geompy.MakeVertex(0, 0, 100) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 60) +Vertex_2 = geompy.MakeVertex(-5, -5, 90) +Vertex_3 = geompy.MakeVertex(65, 65, 110) +Box_2 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2) +Common_1 = geompy.MakeCommon(Disk_1, Box_2) +geompy.Export(Common_1, os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Box_2, 'Box_2' ) +geompy.addToStudy( Common_1, 'Common_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +Mesh_1 = smesh.Mesh(Box_1) +Regular_1D = Mesh_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(15) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa) +isDone = Mesh_1.Compute() +smesh.SetName(Mesh_1, 'Mesh_1') +Mesh_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/CubeAngle.med"), 0, SMESH.MED_V2_2, 1 ) + +## set object names +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py b/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py new file mode 100644 index 000000000..b650fb2e9 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py @@ -0,0 +1,167 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +O_1 = geompy.MakeVertex(0, 0, 0) +OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Vertex_1 = geompy.MakeVertex(0, 0, 500) +Vertex_2 = geompy.MakeVertex(100, 0, 500) +Vertex_3 = geompy.MakeVertex(110, 0, 500) +Vertex_4 = geompy.MakeVertex(117.071068, -2.928932, 500) +Vertex_5 = geompy.MakeVertex(120, -10, 500) +Vertex_6 = geompy.MakeVertex(120, -30, 500) +Vertex_7 = geompy.MakeVertex(122.928932, -37.071068, 500) +Vertex_8 = geompy.MakeVertex(130, -40, 500) +Vertex_9 = geompy.MakeVertex(135, -40, 500) +Vertex_10 = geompy.MakeVertex(160, -40, 500) +Plane_1 = geompy.MakePlaneLCS(None, 2000, 2) +Mirror_1_1 = geompy.MakeMirrorByPlane(Vertex_2, Plane_1) +Mirror_1_2 = geompy.MakeMirrorByPlane(Vertex_3, Plane_1) +Mirror_1_3 = geompy.MakeMirrorByPlane(Vertex_4, Plane_1) +Mirror_1_4 = geompy.MakeMirrorByPlane(Vertex_5, Plane_1) +Mirror_1_5 = geompy.MakeMirrorByPlane(Vertex_6, Plane_1) +Mirror_1_6 = geompy.MakeMirrorByPlane(Vertex_7, Plane_1) +Mirror_1_7 = geompy.MakeMirrorByPlane(Vertex_8, Plane_1) +Mirror_1_8 = geompy.MakeMirrorByPlane(Vertex_9, Plane_1) +Mirror_1_9 = geompy.MakeMirrorByPlane(Vertex_10, Plane_1) +Curve_2 = geompy.MakeInterpol([Mirror_1_9, Mirror_1_8, Mirror_1_7, Mirror_1_6, Mirror_1_5, Mirror_1_4, Mirror_1_3, Mirror_1_2, Mirror_1_1, Vertex_1, Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, False) +Circle_1 = geompy.MakeCircle(Vertex_1, None, 145) +Vertex_11 = geompy.MakeVertex(0, -165, 500) +Curve_2_vertex_2 = geompy.GetSubShape(Curve_2, [2]) +Curve_2_vertex_3 = geompy.GetSubShape(Curve_2, [3]) +Arc_1 = geompy.MakeArc(Curve_2_vertex_2, Vertex_11, Curve_2_vertex_3) +FissInCylindre = geompy.MakeFaceWires([Curve_2, Arc_1], 1) +Divided_Cylinder_1 = geompy.MakeDividedCylinder(145, 800, GEOM.SQUARE) +CylindreSain = geompy.MakeRotation(Divided_Cylinder_1, OZ, 45*math.pi/180.0) +[Compound_1, vertical, radial, Compound_4] = geompy.Propagate(CylindreSain) +geompy.Export(FissInCylindre, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre.brep"), "BREP") +Vertex_12 = geompy.MakeVertex(0, -145, 500) +Circle_2 = geompy.MakeCircle(Vertex_12, None, 145) +Face_1 = geompy.MakeFaceWires([Circle_2], 1) +Vertex_13 = geompy.MakeVertex(0, 0, 500) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_13, OZ_1, 170) +FissInCylindre2 = geompy.MakeCommon(Face_1, Disk_1) +geompy.Export(FissInCylindre2, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre2.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( O_1, 'O' ) +geompy.addToStudy( OX_1, 'OX' ) +geompy.addToStudy( OY_1, 'OY' ) +geompy.addToStudy( OZ_1, 'OZ' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Vertex_5, 'Vertex_5' ) +geompy.addToStudy( Vertex_6, 'Vertex_6' ) +geompy.addToStudy( Vertex_7, 'Vertex_7' ) +geompy.addToStudy( Vertex_8, 'Vertex_8' ) +geompy.addToStudy( Vertex_9, 'Vertex_9' ) +geompy.addToStudy( Vertex_10, 'Vertex_10' ) +geompy.addToStudy( Plane_1, 'Plane_1' ) +geompy.addToStudy( Mirror_1_1, 'Mirror_1_1' ) +geompy.addToStudy( Mirror_1_2, 'Mirror_1_2' ) +geompy.addToStudy( Mirror_1_3, 'Mirror_1_3' ) +geompy.addToStudy( Mirror_1_4, 'Mirror_1_4' ) +geompy.addToStudy( Mirror_1_5, 'Mirror_1_5' ) +geompy.addToStudy( Mirror_1_6, 'Mirror_1_6' ) +geompy.addToStudy( Mirror_1_7, 'Mirror_1_7' ) +geompy.addToStudy( Mirror_1_8, 'Mirror_1_8' ) +geompy.addToStudy( Mirror_1_9, 'Mirror_1_9' ) +geompy.addToStudy( Curve_2, 'Curve_2' ) +geompy.addToStudy( Circle_1, 'Circle_1' ) +geompy.addToStudy( Vertex_11, 'Vertex_11' ) +geompy.addToStudyInFather( Curve_2, Curve_2_vertex_2, 'Curve_2:vertex_2' ) +geompy.addToStudyInFather( Curve_2, Curve_2_vertex_3, 'Curve_2:vertex_3' ) +geompy.addToStudy( Arc_1, 'Arc_1' ) +geompy.addToStudy( FissInCylindre, 'FissInCylindre' ) +geompy.addToStudy( Divided_Cylinder_1, 'Divided Cylinder_1' ) +geompy.addToStudy( CylindreSain, 'CylindreSain' ) +geompy.addToStudyInFather( CylindreSain, Compound_1, 'Compound_1' ) +geompy.addToStudyInFather( CylindreSain, vertical, 'vertical' ) +geompy.addToStudyInFather( CylindreSain, radial, 'radial' ) +geompy.addToStudyInFather( CylindreSain, Compound_4, 'Compound_4' ) +geompy.addToStudy( Vertex_12, 'Vertex_12' ) +geompy.addToStudy( Circle_2, 'Circle_2' ) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Vertex_13, 'Vertex_13' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( FissInCylindre2, 'FissInCylindre2' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +smeshObj_1 = smesh.CreateHypothesis('NumberOfSegments') +smeshObj_1.SetNumberOfSegments( 5 ) +smeshObj_1.SetDistrType( 0 ) +CylindreSain_1 = smesh.Mesh(CylindreSain) +Regular_1D = CylindreSain_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[ ]) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = CylindreSain_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = CylindreSain_1.Hexahedron(algo=smeshBuilder.Hexa) +Regular_1D_1 = CylindreSain_1.Segment(geom=vertical) +Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30,[],[ ]) +Nb_Segments_2.SetDistrType( 0 ) +Regular_1D_2 = CylindreSain_1.Segment(geom=radial) +Nb_Segments_3 = Regular_1D_2.NumberOfSegments(6,[],[ ]) +Nb_Segments_3.SetDistrType( 0 ) +isDone = CylindreSain_1.Compute() +smesh.SetName(CylindreSain_1, 'CylindreSain') +CylindreSain_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"), 0, SMESH.MED_V2_2, 1 ) +SubMesh_1 = Regular_1D_1.GetSubMesh() +SubMesh_2 = Regular_1D_2.GetSubMesh() + +## some objects were removed +aStudyBuilder = theStudy.NewBuilder() +SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(smeshObj_1)) +if SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO) +## set object names +smesh.SetName(CylindreSain_1.GetMesh(), 'CylindreSain') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(Nb_Segments_3, 'Nb. Segments_3') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(SubMesh_2, 'SubMesh_2') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/disque_perce.py b/src/Tools/blocFissure/materielCasTests/disque_perce.py new file mode 100644 index 000000000..2f2730d3d --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/disque_perce.py @@ -0,0 +1,89 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(100, 300) +Cylinder_2 = geompy.MakeCylinderRH(600, 200) +Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1) +Face_1 = geompy.MakeFaceHW(500, 1500, 3) +Disque = geompy.MakePartition([Cut_1], [Face_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) +[Compound_1, Compound_2, Compound_3, Compound_4] = geompy.Propagate(Disque) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Cut_1, 'Cut_1' ) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Disque, 'Disque' ) +geompy.addToStudyInFather( Disque, Compound_1, 'Compound_1' ) +geompy.addToStudyInFather( Disque, Compound_2, 'Compound_2' ) +geompy.addToStudyInFather( Disque, Compound_3, 'Compound_3' ) +geompy.addToStudyInFather( Disque, Compound_4, 'Compound_4' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +Disque_1 = smesh.Mesh(Disque) +Regular_1D = Disque_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(10) +Nb_Segments_1.SetDistrType( 0 ) +Hexa_3D = Disque_1.Hexahedron(algo=smeshBuilder.Hexa) +Regular_1D_1 = Disque_1.Segment(geom=Compound_3) +Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20) +Nb_Segments_2.SetDistrType( 0 ) +Regular_1D_2 = Disque_1.Segment(geom=Compound_4) +status = Disque_1.AddHypothesis(Nb_Segments_2,Compound_4) +Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +isDone = Disque_1.Compute() +smesh.SetName(Disque_1, 'Disque') +Disque_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/disque.med"), 0, SMESH.MED_V2_2, 1 ) +SubMesh_1 = Regular_1D_1.GetSubMesh() +SubMesh_2 = Regular_1D_2.GetSubMesh() + +## set object names +smesh.SetName(Disque_1.GetMesh(), 'Disque') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(SubMesh_2, 'SubMesh_2') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/ellipse.py b/src/Tools/blocFissure/materielCasTests/ellipse.py new file mode 100644 index 000000000..8cf26ab68 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/ellipse.py @@ -0,0 +1,61 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Vertex_1 = geompy.MakeVertex(400, 0, 400) +Vertex_2 = geompy.MakeVertex(400, 0, 500) +Vector_1 = geompy.MakeVector(Vertex_1, Vertex_2) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, Vector_1, 50) +Rotation_1 = geompy.MakeRotation(Disk_1, Vector_1, 180*math.pi/180.0) +Scale_1 = geompy.MakeScaleAlongAxes(Rotation_1, Vertex_1, 1, 1.5, 1) +Vertex_3 = geompy.MakeVertex(420, -400, 300) +Vertex_4 = geompy.MakeVertex(500, 400, 500) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_4, Vertex_3) +ellipse1 = geompy.MakeCut(Scale_1, Box_1) +[fondFiss] = geompy.SubShapes(ellipse1, [4]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vector_1, 'Vector_1' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Scale_1, 'Scale_1' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( ellipse1, 'ellipse1' ) +geompy.addToStudyInFather( ellipse1, fondFiss, 'fondFiss' ) +geompy.Export(ellipse1, os.path.join(gmu.pathBloc, "materielCasTests/ellipse1.brep"), "BREP") + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/ellipse_disque.py b/src/Tools/blocFissure/materielCasTests/ellipse_disque.py new file mode 100644 index 000000000..9e74ff06f --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/ellipse_disque.py @@ -0,0 +1,53 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.NoteBook(theStudy) + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Vertex_1 = geompy.MakeVertex(100, 0, 0) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OY, 12.5) +Scale_1 = geompy.MakeScaleAlongAxes(Disk_1, Vertex_1, 1, 1, 4.1) +Vertex_2 = geompy.MakeVertex(98, -2, -2) +Vertex_3 = geompy.MakeVertex(120, 2, 60) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2) +Ellipse_disque = geompy.MakeCommon(Box_1, Scale_1) +geompy.Export(Ellipse_disque, os.path.join(gmu.pathBloc, "materielCasTests/ellipse_disque.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Scale_1, 'Scale_1' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Ellipse_disque, 'Ellipse_disque' ) + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py b/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py new file mode 100644 index 000000000..742197ede --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py @@ -0,0 +1,59 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +geompy = geomBuilder.New(theStudy) + +Disk_1 = geompy.MakeDiskR(100, 1) +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Scale_1 = geompy.MakeScaleAlongAxes(Disk_1, None, 0.4, 0.75, 1) +[Vertex_1] = geompy.ExtractShapes(Scale_1, geompy.ShapeType["VERTEX"], True) +Rotation_1 = geompy.MakeRotation(Scale_1, OY, 190*math.pi/180.0) +Rotation_2 = geompy.MakeRotation(Rotation_1, OZ, 10*math.pi/180.0) +Vertex_2 = geompy.MakeVertex(20, -100, -50) +Vertex_4 = geompy.MakeVertex(100, 100, 50) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_4) +Cut_1 = geompy.MakeCut(Rotation_1, Box_1) +ellipse1 = geompy.MakeTranslation(Cut_1, 400, 0, 400) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Scale_1, 'Scale_1' ) +geompy.addToStudyInFather( Scale_1, Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Rotation_2, 'Rotation_2' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Cut_1, 'Cut_1' ) +geompy.addToStudy( ellipse1, 'ellipse1_pb' ) +geompy.Export(ellipse1, os.path.join(gmu.pathBloc, "materielCasTests/ellipse1_pb.brep"), "BREP") + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/eprouvetteCourbe.py b/src/Tools/blocFissure/materielCasTests/eprouvetteCourbe.py new file mode 100644 index 000000000..7cbff0698 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/eprouvetteCourbe.py @@ -0,0 +1,107 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Vertex_1 = geompy.MakeVertex(-2000, 0, 0) +Cylinder_1 = geompy.MakeCylinder(Vertex_1, OY, 1900, 300) +Cylinder_2 = geompy.MakeCylinder(Vertex_1, OY, 2100, 300) +Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1) +Vertex_2 = geompy.MakeVertex(-500, -100, -300) +Vertex_3 = geompy.MakeVertex(500, 400, 300) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2) +Common_1 = geompy.MakeCommon(Box_1, Cut_1) +Vertex_4 = geompy.MakeVertex(-300, -1000, 0) +Cylinder_3 = geompy.MakeCylinder(Vertex_4, OX, 1100, 600) +EprouvetteCourbe = geompy.MakeCut(Common_1, Cylinder_3) +[Compound_y, Compound_z, Compound_x] = geompy.Propagate(EprouvetteCourbe) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -110.000000 85.000000:T 220.000000 0.000000:T 0.000000 75.000000:T -220.000000 0.000000:WW", geomObj_1 ) +SectionDroite = geompy.MakeFaceWires([Sketch_1], 1) +geompy.Export(SectionDroite, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbeFiss.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Cut_1, 'Cut_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Common_1, 'Common_1' ) +geompy.addToStudy( Cylinder_3, 'Cylinder_3' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( EprouvetteCourbe, 'EprouvetteCourbe' ) +geompy.addToStudy( Sketch_1, 'Sketch_1' ) +geompy.addToStudy( SectionDroite, 'SectionDroite' ) +geompy.addToStudyInFather( EprouvetteCourbe, Compound_y, 'Compound_y' ) +geompy.addToStudyInFather( EprouvetteCourbe, Compound_z, 'Compound_z' ) +geompy.addToStudyInFather( EprouvetteCourbe, Compound_x, 'Compound_x' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +EprouvetteCourbe_1 = smesh.Mesh(EprouvetteCourbe) +Regular_1D = EprouvetteCourbe_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(50) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = EprouvetteCourbe_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = EprouvetteCourbe_1.Hexahedron(algo=smeshBuilder.Hexa) +Regular_1D_1 = EprouvetteCourbe_1.Segment(geom=Compound_x) +Nb_Segments_2 = Regular_1D_1.NumberOfSegments(15) +Nb_Segments_2.SetDistrType( 0 ) +Regular_1D_2 = EprouvetteCourbe_1.Segment(geom=Compound_y) +Nb_Segments_3 = Regular_1D_2.NumberOfSegments(25) +Nb_Segments_3.SetDistrType( 0 ) +isDone = EprouvetteCourbe_1.Compute() +smesh.SetName(EprouvetteCourbe_1, 'EprouvetteCourbe') +EprouvetteCourbe_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteCourbe.med"), 0, SMESH.MED_V2_2, 1 ) +SubMesh_1 = Regular_1D_1.GetSubMesh() +SubMesh_2 = Regular_1D_2.GetSubMesh() + +## set object names +smesh.SetName(EprouvetteCourbe_1.GetMesh(), 'EprouvetteCourbe') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(Nb_Segments_3, 'Nb. Segments_3') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(SubMesh_2, 'SubMesh_2') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/eprouvetteDroite.py b/src/Tools/blocFissure/materielCasTests/eprouvetteDroite.py new file mode 100644 index 000000000..0a70a2685 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/eprouvetteDroite.py @@ -0,0 +1,142 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.NoteBook(theStudy) + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +eprouvetteDroite = geompy.MakeBoxDXDYDZ(100, 200, 500) +[Compound_z, Compound_y, Compound_x] = geompy.Propagate(eprouvetteDroite) + +Vertex_1 = geompy.MakeVertex(-10, -10, 200) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Plane_1 = geompy.MakePlane(Vertex_1, OZ, 2000) +geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F 0.000000 0.000000:TT 120.000000 0.000000:T 0.000000 100.000000:T -120.000000 0.000000:WW", Plane_1 ) +sectionDroite = geompy.MakeFaceWires([Sketch_1], 1) +Box_1_vertex_7 = geompy.GetSubShape(eprouvetteDroite, [7]) +Box_1_vertex_16 = geompy.GetSubShape(eprouvetteDroite, [16]) +Line_1 = geompy.MakeLineTwoPnt(Box_1_vertex_7, Box_1_vertex_16) +geomObj_3 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Plane_2 = geompy.MakePlane(Vertex_1, Line_1, 2000) +geomObj_4 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_2 = geompy.MakeSketcherOnPlane("Sketcher:F 0.000000 0.000000:T 120.000000 0.000000:T 0.000000 100.000000:T -120.000000 20.000000:WW", Plane_2 ) +SectionInclinee = geompy.MakeFaceWires([Sketch_2], 1) +geompy.Export(sectionDroite, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFissPb1.brep"), "BREP") +geompy.Export(SectionInclinee, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss2.brep"), "BREP") +Vertex_2 = geompy.MakeVertex(110, -10, 200) +Vertex_3 = geompy.MakeVertex(110, 80, 200) +Vertex_4 = geompy.MakeVertex(-10, 80, 200) +Line_2 = geompy.MakeLineTwoPnt(Vertex_1, Vertex_2) +Line_3 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3) +Line_4 = geompy.MakeLineTwoPnt(Vertex_3, Vertex_4) +Line_5 = geompy.MakeLineTwoPnt(Vertex_4, Vertex_1) +Face_1 = geompy.MakeFaceWires([Line_2, Line_3, Line_4, Line_5], 1) +Vertex_5 = geompy.MakeVertex(110, -10, 180) +Vertex_6 = geompy.MakeVertex(110, 70, 180) +Face_1_vertex_4 = geompy.GetSubShape(Face_1, [4]) +Line_6 = geompy.MakeLineTwoPnt(Face_1_vertex_4, Vertex_5) +Line_7 = geompy.MakeLineTwoPnt(Vertex_5, Vertex_6) +Face_1_vertex_9 = geompy.GetSubShape(Face_1, [9]) +Line_8 = geompy.MakeLineTwoPnt(Vertex_6, Face_1_vertex_9) +Face_2 = geompy.MakeFaceWires([Line_5, Line_6, Line_7, Line_8], 1) +geompy.Export(Face_1, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_1.brep"), "BREP") +geompy.Export(Face_2, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_2.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( eprouvetteDroite, 'eprouvetteDroite' ) +geompy.addToStudyInFather( eprouvetteDroite, Compound_z, 'Compound_z' ) +geompy.addToStudyInFather( eprouvetteDroite, Compound_y, 'Compound_y' ) +geompy.addToStudyInFather( eprouvetteDroite, Compound_x, 'Compound_x' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Plane_1, 'Plane_1' ) +geompy.addToStudy( Sketch_1, 'Sketch_1' ) +geompy.addToStudy( sectionDroite, 'sectionDroite' ) +geompy.addToStudyInFather( eprouvetteDroite, Box_1_vertex_7, 'Box_1:vertex_7' ) +geompy.addToStudyInFather( eprouvetteDroite, Box_1_vertex_16, 'Box_1:vertex_16' ) +geompy.addToStudy( Line_1, 'Line_1' ) +geompy.addToStudy( Plane_2, 'Plane_2' ) +geompy.addToStudy( Sketch_2, 'Sketch_2' ) +geompy.addToStudy( SectionInclinee, 'SectionInclinee' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Line_2, 'Line_2' ) +geompy.addToStudy( Line_3, 'Line_3' ) +geompy.addToStudy( Line_4, 'Line_4' ) +geompy.addToStudy( Line_5, 'Line_5' ) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Vertex_5, 'Vertex_5' ) +geompy.addToStudy( Vertex_6, 'Vertex_6' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_4, 'Face_1:vertex_4' ) +geompy.addToStudy( Line_6, 'Line_6' ) +geompy.addToStudy( Line_7, 'Line_7' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_9, 'Face_1:vertex_9' ) +geompy.addToStudy( Line_8, 'Line_8' ) +geompy.addToStudy( Face_2, 'Face_2' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +eprouvetteDroite_1 = smesh.Mesh(eprouvetteDroite) +Regular_1D = eprouvetteDroite_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(50,[],[ ]) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = eprouvetteDroite_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = eprouvetteDroite_1.Hexahedron(algo=smeshBuilder.Hexa) +Regular_1D_1 = eprouvetteDroite_1.Segment(geom=Compound_y) +Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20,[],[ ]) +Nb_Segments_2.SetDistrType( 0 ) +Regular_1D_2 = eprouvetteDroite_1.Segment(geom=Compound_x) +Nb_Segments_3 = Regular_1D_2.NumberOfSegments(10,[],[ ]) +Nb_Segments_3.SetDistrType( 0 ) +isDone = eprouvetteDroite_1.Compute() +smesh.SetName(eprouvetteDroite_1, 'eprouvetteDroite') +eprouvetteDroite_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/eprouvetteDroite.med"), 0, SMESH.MED_V2_2, 1 ) +SubMesh_1 = Regular_1D_1.GetSubMesh() +SubMesh_2 = Regular_1D_2.GetSubMesh() + +## set object names +smesh.SetName(eprouvetteDroite_1.GetMesh(), 'eprouvetteDroite') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(Nb_Segments_3, 'Nb. Segments_3') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(SubMesh_2, 'SubMesh_2') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/fissureGauche.py b/src/Tools/blocFissure/materielCasTests/fissureGauche.py new file mode 100644 index 000000000..b378fa587 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/fissureGauche.py @@ -0,0 +1,136 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +geomObj_1 = geompy.MakeCylinderRH(1000, 3000) +Cylinder_1 = geompy.MakeRotation(geomObj_1, OZ, 180*math.pi/180.0) +geomObj_2 = geompy.MakeCylinder(O, OX, 2000, 5000) +Cylinder_2 = geompy.MakeRotation(geomObj_2, OX, 180*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Cylinder_2, -2000, 0, 0) +Fuse_1 = geompy.MakeFuse(Cylinder_1, Translation_1) +Fillet_1 = geompy.MakeFillet(Fuse_1, 800, geompy.ShapeType["EDGE"], [11]) +Vertex_1 = geompy.MakeVertex(0, -3000, -3000) +Vertex_2 = geompy.MakeVertex(2500, 3000, 3000) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_1) +Partition_1 = geompy.MakePartition([Box_1], [Fillet_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) +geomObj_3 = geompy.MakeCylinderRH(1450, 8000) +Cylinder_3 = geompy.MakeRotation(geomObj_3, OZ, 180*math.pi/180.0) +Cut_1 = geompy.MakeCut(Partition_1, Cylinder_3) +[faceFiss1] = geompy.SubShapes(Cut_1, [61]) +[Vertex_3,geomObj_4] = geompy.SubShapes(faceFiss1, [4, 5]) +Cylinder_4 = geompy.MakeCylinderRH(2000, 4000) +Cylinder_5 = geompy.MakeCylinderRH(1500, 4000) +Cut_2 = geompy.MakeCut(Cylinder_4, Cylinder_5) +Plane_1 = geompy.MakePlaneLCS(None, 10000, 3) +Vertex_5 = geompy.MakeVertex(0, 0, 100) +Plane_2 = geompy.MakePlaneThreePnt(O, Vertex_5, Vertex_3, 10000) +Plane_3 = geompy.MakePlaneThreePnt(O, Vertex_5, geomObj_4, 10000) +Vertex_6 = geompy.MakeVertex(0, -5000, -5000) +Vertex_7 = geompy.MakeVertex(5000, 5000, 5000) +Box_2 = geompy.MakeBoxTwoPnt(Vertex_7, Vertex_6) +Common_1 = geompy.MakeCommon(Box_2, Cut_2) +objetSain = geompy.MakePartition([Common_1], [Plane_1, Plane_2, Plane_3], [], [], geompy.ShapeType["SOLID"], 0, [], 0) +[hauteurs, epaisseurs, Compound_3, Compound_4, Compound_5, Compound_6] = geompy.Propagate(objetSain) +geompy.Export(faceFiss1, os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheFiss.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( Fuse_1, 'Fuse_1' ) +geompy.addToStudy( Fillet_1, 'Fillet_1' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) +geompy.addToStudy( Cylinder_3, 'Cylinder_3' ) +geompy.addToStudy( Cut_1, 'Cut_1' ) +geompy.addToStudyInFather( Cut_1, faceFiss1, 'faceFiss1' ) +geompy.addToStudyInFather( faceFiss1, Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Cylinder_4, 'Cylinder_4' ) +geompy.addToStudy( Cylinder_5, 'Cylinder_5' ) +geompy.addToStudy( Cut_2, 'Cut_2' ) +geompy.addToStudy( Plane_1, 'Plane_1' ) +geompy.addToStudy( Vertex_5, 'Vertex_5' ) +geompy.addToStudy( Plane_2, 'Plane_2' ) +geompy.addToStudy( Plane_3, 'Plane_3' ) +geompy.addToStudy( Vertex_6, 'Vertex_6' ) +geompy.addToStudy( Vertex_7, 'Vertex_7' ) +geompy.addToStudy( Box_2, 'Box_2' ) +geompy.addToStudy( Common_1, 'Common_1' ) +geompy.addToStudy( objetSain, 'objetSain' ) +geompy.addToStudyInFather( objetSain, hauteurs, 'hauteurs' ) +geompy.addToStudyInFather( objetSain, epaisseurs, 'epaisseurs' ) +geompy.addToStudyInFather( objetSain, Compound_3, 'Compound_3' ) +geompy.addToStudyInFather( objetSain, Compound_4, 'Compound_4' ) +geompy.addToStudyInFather( objetSain, Compound_5, 'Compound_5' ) +geompy.addToStudyInFather( objetSain, Compound_6, 'Compound_6' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +objetSain_1 = smesh.Mesh(objetSain) +Regular_1D = objetSain_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(10,[],[ ]) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = objetSain_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = objetSain_1.Hexahedron(algo=smeshBuilder.Hexa) +Regular_1D_1 = objetSain_1.Segment(geom=hauteurs) +Nb_Segments_2 = Regular_1D_1.NumberOfSegments(15,[],[ ]) +Nb_Segments_2.SetDistrType( 0 ) +Regular_1D_2 = objetSain_1.Segment(geom=epaisseurs) +Nb_Segments_3 = Regular_1D_2.NumberOfSegments(5,[],[ ]) +Nb_Segments_3.SetDistrType( 0 ) +isDone = objetSain_1.Compute() +smesh.SetName(objetSain_1, 'objetSain') +objetSain_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/faceGaucheSain.med"), 0, SMESH.MED_V2_2, 1 ) +SubMesh_1 = Regular_1D_1.GetSubMesh() +SubMesh_2 = Regular_1D_2.GetSubMesh() + +## set object names +smesh.SetName(objetSain_1.GetMesh(), 'objetSain') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(Nb_Segments_3, 'Nb. Segments_3') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(SubMesh_2, 'SubMesh_2') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/fissureGauche2.py b/src/Tools/blocFissure/materielCasTests/fissureGauche2.py new file mode 100644 index 000000000..431668130 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/fissureGauche2.py @@ -0,0 +1,98 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Circle_1 = geompy.MakeCircle(O, OX, 500) +Extrusion_1 = geompy.MakePrismVecH2Ways(Circle_1, OX, 500) +Vertex_1 = geompy.MakeVertex(500, 0, 0) +Circle_3 = geompy.MakeCircle(Vertex_1, OZ, 300) +Extrusion_2 = geompy.MakePrismVecH(Circle_3, OZ, 1000) +Partition_1 = geompy.MakePartition([Extrusion_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0) +[Face_1,Face_2] = geompy.SubShapes(Partition_1, [18, 13]) +FaceFissExt = geompy.MakeFuse(Face_2, Face_1) +geompy.Export(FaceFissExt, os.path.join(gmu.pathBloc, "materielCasTests/faceGauche2Fiss.brep"), "BREP") +Vertex_2 = geompy.MakeVertex(0, -500, 0) +Vertex_3 = geompy.MakeVertex(400, 500, 800) +objetSain = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2) +Rotation_1 = geompy.MakeRotation(Extrusion_1, OX, 180*math.pi/180.0) +Partition_2 = geompy.MakePartition([Rotation_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0) +[FaceFissExtSimple] = geompy.SubShapes(Partition_2, [13]) +Plane_1 = geompy.MakePlaneLCS(None, 2000, 3) +FaceFissExtCoupe = geompy.MakePartition([FaceFissExtSimple], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0) +geompy.Export(FaceFissExtCoupe, os.path.join(gmu.pathBloc, "materielCasTests/faceGauche2FissCoupe.brep"), "BREP") +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Circle_1, 'Circle_1' ) +geompy.addToStudy( Extrusion_1, 'Extrusion_1' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Circle_3, 'Circle_3' ) +geompy.addToStudy( Extrusion_2, 'Extrusion_2' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) +geompy.addToStudyInFather( Partition_1, Face_1, 'Face_1' ) +geompy.addToStudyInFather( Partition_1, Face_2, 'Face_2' ) +geompy.addToStudy( FaceFissExt, 'FaceFissExt' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( objetSain, 'objetSain' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Partition_2, 'Partition_2' ) +geompy.addToStudyInFather( Partition_2, FaceFissExtSimple, 'FaceFissExtSimple' ) +geompy.addToStudy( Plane_1, 'Plane_1' ) +geompy.addToStudy( FaceFissExtCoupe, 'FaceFissExtCoupe' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +from salome.StdMeshers import StdMeshersBuilder +Mesh_1 = smesh.Mesh(objetSain) +Regular_1D = Mesh_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[ ]) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa) +isDone = Mesh_1.Compute() +smesh.SetName(Mesh_1, 'Mesh_1') +Mesh_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/boiteSaine.med"), 0, SMESH.MED_V2_2, 1 ) + +## set object names +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/blocFissure/materielCasTests/genereMateriel.py b/src/Tools/blocFissure/materielCasTests/genereMateriel.py new file mode 100644 index 000000000..919b2a16a --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/genereMateriel.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +from blocFissure.materielCasTests import cubeAngle +from blocFissure.materielCasTests import decoupeCylindre +from blocFissure.materielCasTests import eprouvetteCourbe +from blocFissure.materielCasTests import eprouvetteDroite +from blocFissure.materielCasTests import fissureGauche +from blocFissure.materielCasTests import fissureGauche2 +from blocFissure.materielCasTests import ellipse +from blocFissure.materielCasTests import ellipse_probleme +from blocFissure.materielCasTests import disque_perce +from blocFissure.materielCasTests import ellipse_disque +from blocFissure.materielCasTests import vis diff --git a/src/Tools/blocFissure/materielCasTests/vis.py b/src/Tools/blocFissure/materielCasTests/vis.py new file mode 100644 index 000000000..1819a56f7 --- /dev/null +++ b/src/Tools/blocFissure/materielCasTests/vis.py @@ -0,0 +1,273 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook + +import os +from blocFissure import gmu + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +sk = geompy.Sketcher2D() +sk.addPoint(0.000000, 0.000000) +sk.addSegmentAbsolute(10.000000, 0.000000) +sk.addSegmentAbsolute(10.000000, 98.750000) +sk.addArcAngleRadiusLength(0, -1.250000, 90.000000) +sk.addSegmentAbsolute(15.000000, 100.000000) +sk.addSegmentAbsolute(15.000000, 120.000000) +sk.addSegmentAbsolute(9.945000, 120.000000) +sk.addSegmentAbsolute(9.945000, 108.000000) +sk.addSegmentAbsolute(0.000000, 105.000000) +sk.close() +Sketch_1 = sk.wire(geomObj_2) +Face_1 = geompy.MakeFaceWires([Sketch_1], 1) +Vertex_1 = geompy.MakeVertex(15, 108, 0) +Vertex_2 = geompy.MakeVertex(0, 94, 0) +Vertex_3 = geompy.MakeVertex(10, 94, 0) +Face_1_vertex_17 = geompy.GetSubShape(Face_1, [17]) +Line_1 = geompy.MakeLineTwoPnt(Vertex_1, Face_1_vertex_17) +Face_1_vertex_9 = geompy.GetSubShape(Face_1, [9]) +Line_2 = geompy.MakeLineTwoPnt(Face_1_vertex_17, Face_1_vertex_9) +Face_1_vertex_19 = geompy.GetSubShape(Face_1, [19]) +Face_1_vertex_7 = geompy.GetSubShape(Face_1, [7]) +Line_3 = geompy.MakeLineTwoPnt(Face_1_vertex_19, Face_1_vertex_7) +Line_4 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3) +coupe_vis = geompy.MakePartition([Face_1], [Line_1, Line_2, Line_3, Line_4], [], [], geompy.ShapeType["FACE"], 0, [], 0) +[tige, section, tige_haute, rond, tete, section_tete] = geompy.Propagate(coupe_vis) +conge = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(conge, [21]) +appui = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(appui, [37]) +p_imp = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(p_imp, [4]) + +Vertex_4 = geompy.MakeVertex(11.25, 98.75, 0) +Vertex_5 = geompy.MakeVertexWithRef(Vertex_4, -0.5, 0.5, 0) +Vertex_6 = geompy.MakeVertexWithRef(Vertex_4, -5, 5, 0) +Line_5 = geompy.MakeLineTwoPnt(Vertex_5, Vertex_6) +Partition_1 = geompy.MakePartition([Line_5], [conge], [], [], geompy.ShapeType["EDGE"], 0, [], 1) +[Vertex_7] = geompy.SubShapes(Partition_1, [4]) +Vertex_8 = geompy.MakeVertexWithRef(Vertex_7, -1.1, 1.1, 0) +generatrice = geompy.MakeLineTwoPnt(Vertex_5, Vertex_8) +Revolution_1 = geompy.MakeRevolution2Ways(generatrice, OY, 60*math.pi/180.0) +Partition_2 = geompy.MakePartition([Revolution_1], [conge], [], [], geompy.ShapeType["FACE"], 0, [], 1) +Partition_2_vertex_11 = geompy.GetSubShape(Partition_2, [11]) +Plane_1 = geompy.MakePlane(Partition_2_vertex_11, OY, 2000) +Partition_3 = geompy.MakePartition([Revolution_1], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0) +Vertex_9 = geompy.MakeVertex(0, 99.633883, 8.977320000000001) +Vertex_10 = geompy.MakeVertex(0, 99.633883, -8.977320000000001) +Vertex_11 = geompy.MakeVertexWithRef(Vertex_9, 0, 0, -1) +Vertex11x = geompy.MakeVertexWithRef(Vertex_11, 1, 0, 0) +Line_11x = geompy.MakeLineTwoPnt(Vertex_11, Vertex11x) +Vertex_12 = geompy.MakeVertexWithRef(Vertex_10, 0, 0, 1) +Vertex12x = geompy.MakeVertexWithRef(Vertex_12, 1, 0, 0) +Line_12x = geompy.MakeLineTwoPnt(Vertex_12, Vertex12x) +Vertex_13 = geompy.MakeVertexWithRef(Vertex_11, 0, 1, 0) +Vertex_14 = geompy.MakeVertexWithRef(Vertex_12, 0, 1, 0) +Vertex_15 = geompy.MakeRotation(Vertex_9, Line_11x, 30*math.pi/180.0) +Vertex_16 = geompy.MakeRotation(Vertex_10, Line_12x, -30*math.pi/180.0) +Arc_1 = geompy.MakeArc(Vertex_15, Vertex_9, Vertex_13,False) +Arc_2 = geompy.MakeArc(Vertex_14, Vertex_10, Vertex_16,False) +Line_6 = geompy.MakeLineTwoPnt(Vertex_13, Vertex_14) +Line_8 = geompy.MakeLineTwoPnt(Vertex_16, Vertex_15) +Wire_1 = geompy.MakeWire([Arc_1, Arc_2, Line_6, Line_8], 1e-07) +Face_2 = geompy.MakeFaceWires([Wire_1], 1) +Extrusion_1 = geompy.MakePrismVecH(Face_2, OX, 15) +Revolution_2 = geompy.MakeRevolution2Ways(generatrice, OY, 65*math.pi/180.0) +Fissure = geompy.MakeCommonList([Extrusion_1, Revolution_2], True) +fondFiss = geompy.CreateGroup(Fissure, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(fondFiss, [9, 7, 4]) +geompy.Export(Fissure, os.path.join(gmu.pathBloc, "materielCasTests/visFiss.brep"), "BREP") + +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Sketch_1, 'Sketch_1' ) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_17, 'Face_1:vertex_17' ) +geompy.addToStudy( Line_1, 'Line_1' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_9, 'Face_1:vertex_9' ) +geompy.addToStudy( Line_2, 'Line_2' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_19, 'Face_1:vertex_19' ) +geompy.addToStudyInFather( Face_1, Face_1_vertex_7, 'Face_1:vertex_7' ) +geompy.addToStudy( Line_3, 'Line_3' ) +geompy.addToStudy( Line_4, 'Line_4' ) +geompy.addToStudy( coupe_vis, 'coupe_vis' ) +geompy.addToStudyInFather( coupe_vis, tige, 'tige' ) +geompy.addToStudyInFather( coupe_vis, section, 'section' ) +geompy.addToStudyInFather( coupe_vis, tige_haute, 'tige_haute' ) +geompy.addToStudyInFather( coupe_vis, rond, 'rond' ) +geompy.addToStudyInFather( coupe_vis, tete, 'tete' ) +geompy.addToStudyInFather( coupe_vis, section_tete, 'section_tete' ) +geompy.addToStudyInFather( coupe_vis, conge, 'conge' ) +geompy.addToStudyInFather( coupe_vis, appui, 'appui' ) +geompy.addToStudyInFather( coupe_vis, p_imp, 'p_imp' ) + +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Vertex_6, 'Vertex_6' ) +geompy.addToStudy( Vertex_5, 'Vertex_5' ) +geompy.addToStudy( Line_5, 'Line_5' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) +geompy.addToStudyInFather( Partition_1, Vertex_7, 'Vertex_7' ) +geompy.addToStudy( Vertex_8, 'Vertex_8' ) +geompy.addToStudy( generatrice, 'generatrice' ) +geompy.addToStudy( Revolution_1, 'Revolution_1' ) +geompy.addToStudy( Partition_2, 'Partition_2' ) +geompy.addToStudyInFather( Partition_2, Partition_2_vertex_11, 'Partition_2:vertex_11' ) +geompy.addToStudy( Plane_1, 'Plane_1' ) +geompy.addToStudy( Partition_3, 'Partition_3' ) +geompy.addToStudy( Vertex_9, 'Vertex_9' ) +geompy.addToStudy( Vertex_10, 'Vertex_10' ) +geompy.addToStudy( Vertex_11, 'Vertex_11' ) +geompy.addToStudy( Vertex_12, 'Vertex_12' ) +geompy.addToStudy( Vertex_13, 'Vertex_13' ) +geompy.addToStudy( Vertex_14, 'Vertex_14' ) +geompy.addToStudy( Vertex_15, 'Vertex_15' ) +geompy.addToStudy( Vertex_16, 'Vertex_16' ) +geompy.addToStudy( Arc_1, 'Arc_1' ) +geompy.addToStudy( Arc_2, 'Arc_2' ) +geompy.addToStudy( Line_6, 'Line_6' ) +geompy.addToStudy( Line_8, 'Line_8' ) +geompy.addToStudy( Wire_1, 'Wire_1' ) +geompy.addToStudy( Face_2, 'Face_2' ) +geompy.addToStudy( Extrusion_1, 'Extrusion_1' ) +geompy.addToStudy( Revolution_2, 'Revolution_2' ) +geompy.addToStudy( Fissure, 'Fissure' ) +geompy.addToStudyInFather( Fissure, fondFiss, 'fondFiss' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +coupe_vis_1 = smesh.Mesh(coupe_vis) +Regular_1D = coupe_vis_1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(10) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = coupe_vis_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) +isDone = coupe_vis_1.Compute() +Nb_Segments_2 = smesh.CreateHypothesis('NumberOfSegments') +Nb_Segments_2.SetNumberOfSegments( 30 ) +Nb_Segments_2.SetDistrType( 0 ) +status = coupe_vis_1.AddHypothesis(Regular_1D,tige) +status = coupe_vis_1.AddHypothesis(Nb_Segments_2,tige) +isDone = coupe_vis_1.Compute() +Nb_Segments_3 = smesh.CreateHypothesis('NumberOfSegments') +Nb_Segments_3.SetNumberOfSegments( 10 ) +Nb_Segments_3.SetScaleFactor( 3 ) +Nb_Segments_3.SetReversedEdges( [ ] ) +Nb_Segments_3.SetObjectEntry( "0:1:1:14" ) +status = coupe_vis_1.AddHypothesis(Regular_1D,section) +status = coupe_vis_1.AddHypothesis(Nb_Segments_3,section) +coupe_vis_1.Clear() +isDone = coupe_vis_1.Compute() +coupe_vis_1.Clear() +Nb_Segments_3.SetNumberOfSegments( 10 ) +Nb_Segments_3.SetDistrType( 1 ) +Nb_Segments_3.SetScaleFactor( 3 ) +Nb_Segments_3.SetReversedEdges( [ 23, 4, 9, 16 ] ) +Nb_Segments_3.SetObjectEntry( "0:1:1:14" ) +isDone = coupe_vis_1.Compute() +tige_1 = coupe_vis_1.GroupOnGeom(tige,'tige',SMESH.EDGE) +section_1 = coupe_vis_1.GroupOnGeom(section,'section',SMESH.EDGE) +tige_haute_1 = coupe_vis_1.GroupOnGeom(tige_haute,'tige_haute',SMESH.EDGE) +rond_1 = coupe_vis_1.GroupOnGeom(rond,'rond',SMESH.EDGE) +tete_1 = coupe_vis_1.GroupOnGeom(tete,'tete',SMESH.EDGE) +section_tete_1 = coupe_vis_1.GroupOnGeom(section_tete,'section_tete',SMESH.EDGE) +conge_1 = coupe_vis_1.GroupOnGeom(conge,'conge',SMESH.EDGE) +appui_1 = coupe_vis_1.GroupOnGeom(appui,'appui',SMESH.EDGE) +p_imp_1 = coupe_vis_1.GroupOnGeom(p_imp,'p_imp',SMESH.EDGE) +isDone = coupe_vis_1.SplitQuad( [ 691 ], 1 ) +visHex80 = smesh.CopyMesh( coupe_vis_1, 'visHex80', 1, 0) +[ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2 ] = visHex80.GetGroups() +[ tige_rotated, section_rotated, tige_haute_rotated, rond_rotated, tete_rotated, section_tete_rotated, conge_rotated, appui_rotated, p_imp_rotated, tige_top, section_top, tige_haute_top, rond_top, tete_top, section_tete_top, conge_top, appui_top, p_imp_top ] = visHex80.RotationSweepObject2D( visHex80, SMESH.AxisStruct( 0, 0, 0, 0, 10, 0 ), math.pi/40, 40, 1e-05 ,True) +[ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2, tige_rotated, tige_top, section_rotated, section_top, tige_haute_rotated, tige_haute_top, rond_rotated, rond_top, tete_rotated, tete_top, section_tete_rotated, section_tete_top, conge_rotated, conge_top, appui_rotated, appui_top, p_imp_rotated, p_imp_top ] = visHex80.GetGroups() +[ tige_mirrored, section_mirrored, tige_haute_mirrored, rond_mirrored, tete_mirrored, section_tete_mirrored, conge_mirrored, appui_mirrored, p_imp_mirrored, tige_rotated_mirrored, tige_top_mirrored, section_rotated_mirrored, section_top_mirrored, tige_haute_rotated_mirrored, tige_haute_top_mirrored, rond_rotated_mirrored, rond_top_mirrored, tete_rotated_mirrored, tete_top_mirrored, section_tete_rotated_mirrored, section_tete_top_mirrored, conge_rotated_mirrored, conge_top_mirrored, appui_rotated_mirrored, appui_top_mirrored, p_imp_rotated_mirrored, p_imp_top_mirrored ] = visHex80.MirrorObject( visHex80, SMESH.AxisStruct( 0, 0, 0, 0, 0, 10 ), SMESH.SMESH_MeshEditor.PLANE ,True,True) +[ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2, tige_rotated, tige_top, section_rotated, section_top, tige_haute_rotated, tige_haute_top, rond_rotated, rond_top, tete_rotated, tete_top, section_tete_rotated, section_tete_top, conge_rotated, conge_top, appui_rotated, appui_top, p_imp_rotated, p_imp_top, tige_mirrored, section_mirrored, tige_haute_mirrored, rond_mirrored, tete_mirrored, section_tete_mirrored, conge_mirrored, appui_mirrored, p_imp_mirrored, tige_rotated_mirrored, tige_top_mirrored, section_rotated_mirrored, section_top_mirrored, tige_haute_rotated_mirrored, tige_haute_top_mirrored, rond_rotated_mirrored, rond_top_mirrored, tete_rotated_mirrored, tete_top_mirrored, section_tete_rotated_mirrored, section_tete_top_mirrored, conge_rotated_mirrored, conge_top_mirrored, appui_rotated_mirrored, appui_top_mirrored, p_imp_rotated_mirrored, p_imp_top_mirrored ] = visHex80.GetGroups() +coincident_nodes_on_part = visHex80.FindCoincidentNodesOnPart( visHex80, 1e-05, [ ] ) +visHex80.MergeNodes(coincident_nodes_on_part) +equal_elements = visHex80.FindEqualElements( visHex80 ) +visHex80.MergeElements(equal_elements) +[ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2, tige_rotated, tige_top, section_rotated, section_top, tige_haute_rotated, tige_haute_top, rond_rotated, rond_top, tete_rotated, tete_top, section_tete_rotated, section_tete_top, conge_rotated, conge_top, appui_rotated, appui_top, p_imp_rotated, p_imp_top, tige_mirrored, section_mirrored, tige_haute_mirrored, rond_mirrored, tete_mirrored, section_tete_mirrored, conge_mirrored, appui_mirrored, p_imp_mirrored, tige_rotated_mirrored, tige_top_mirrored, section_rotated_mirrored, section_top_mirrored, tige_haute_rotated_mirrored, tige_haute_top_mirrored, rond_rotated_mirrored, rond_top_mirrored, tete_rotated_mirrored, tete_top_mirrored, section_tete_rotated_mirrored, section_tete_top_mirrored, conge_rotated_mirrored, conge_top_mirrored, appui_rotated_mirrored, appui_top_mirrored, p_imp_rotated_mirrored, p_imp_top_mirrored ] = visHex80.GetGroups() +SubMesh_1 = coupe_vis_1.GetSubMesh( tige, 'SubMesh_1' ) +SubMesh_2 = coupe_vis_1.GetSubMesh( section, 'SubMesh_2' ) +visHex80.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"), 0, SMESH.MED_V2_2, 1 ) + + +## Set names of Mesh objects +smesh.SetName(appui_rotated, 'appui_rotated') +smesh.SetName(p_imp_rotated, 'p_imp_rotated') +smesh.SetName(section_tete_rotated, 'section_tete_rotated') +smesh.SetName(conge_rotated, 'conge_rotated') +smesh.SetName(rond_rotated, 'rond_rotated') +smesh.SetName(tete_rotated, 'tete_rotated') +smesh.SetName(section_rotated, 'section_rotated') +smesh.SetName(tige_haute_rotated, 'tige_haute_rotated') +smesh.SetName(tige_rotated, 'tige_rotated') +smesh.SetName(SubMesh_2, 'SubMesh_2') +smesh.SetName(SubMesh_1, 'SubMesh_1') +smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +smesh.SetName(appui_1, 'appui') +smesh.SetName(p_imp_1, 'p_imp') +smesh.SetName(coupe_vis_1.GetMesh(), 'coupe_vis') +smesh.SetName(visHex80.GetMesh(), 'visHex80') +smesh.SetName(tige_1, 'tige') +smesh.SetName(p_imp_2, 'p_imp') +smesh.SetName(section_1, 'section') +smesh.SetName(appui_2, 'appui') +smesh.SetName(tige_haute_1, 'tige_haute') +smesh.SetName(conge_2, 'conge') +smesh.SetName(rond_1, 'rond') +smesh.SetName(section_tete_2, 'section_tete') +smesh.SetName(tete_1, 'tete') +smesh.SetName(tete_2, 'tete') +smesh.SetName(section_tete_1, 'section_tete') +smesh.SetName(rond_2, 'rond') +smesh.SetName(conge_1, 'conge') +smesh.SetName(tige_haute_2, 'tige_haute') +smesh.SetName(section_2, 'section') +smesh.SetName(tige_2, 'tige') +smesh.SetName(p_imp_top, 'p_imp_top') +smesh.SetName(Nb_Segments_3, 'Nb. Segments_3') +smesh.SetName(conge_top, 'conge_top') +smesh.SetName(Nb_Segments_2, 'Nb. Segments_2') +smesh.SetName(appui_top, 'appui_top') +smesh.SetName(Nb_Segments_1, 'Nb. Segments_1') +smesh.SetName(tete_top, 'tete_top') +smesh.SetName(section_tete_top, 'section_tete_top') +smesh.SetName(tige_haute_top, 'tige_haute_top') +smesh.SetName(rond_top, 'rond_top') +smesh.SetName(tige_top, 'tige_top') +smesh.SetName(section_top, 'section_top') + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/src/Tools/smesh_plugins.py b/src/Tools/smesh_plugins.py index f7ac148f4..5dd763cf3 100644 --- a/src/Tools/smesh_plugins.py +++ b/src/Tools/smesh_plugins.py @@ -25,6 +25,7 @@ from spadderPlugin import runSpadderPlugin from meshcut_plugin import MeshCut from yamsplug_plugin import YamsLct from MGCleanerplug_plugin import MGCleanerLct +from blocFissure.ihm.fissureCoude_plugin import fissureCoudeDlg salome_pluginsmanager.AddFunction('PADDER mesher', 'Create a mesh with PADDER', @@ -42,3 +43,6 @@ salome_pluginsmanager.AddFunction('ReMesh with MGCleaner', 'Run MGCleaner', MGCleanerLct) +salome_pluginsmanager.AddFunction('Meshed Pipe with a crack', + 'Create a mesh with blocFissure tool', + fissureCoudeDlg) -- 2.39.2