X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FblocFissure%2FmaterielCasTests%2FdecoupeCylindre.py;h=c81d91c4d9f18bcffd2205e3f32f14c7882e6e8e;hb=HEAD;hp=b5fe06e21606a0b9e6eb5369e4a0629d098997aa;hpb=d3e1cabf77f67408ac401e2d387e721605cb3b10;p=modules%2Fsmesh.git diff --git a/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py b/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py index b5fe06e21..25e9563eb 100644 --- a/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py +++ b/src/Tools/blocFissure/materielCasTests/decoupeCylindre.py @@ -1,37 +1,53 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2014-2024 CEA, EDF +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +"""Géométries et maillages de base nécessaires aux cas-tests : +. cylindre +. cylindre_2 +""" -import sys -import salome +import os +import math -salome.salome_init() -theStudy = salome.myStudy +import logging -import salome_notebook -notebook = salome_notebook.notebook +import salome +from salome.smesh import smeshBuilder +import GEOM +import SMESH +import SALOMEDS -import os from blocFissure import gmu +from blocFissure.gmu.geomsmesh import geompy +from blocFissure.gmu.geomsmesh import geomPublish +from blocFissure.gmu.geomsmesh import geomPublishInFather + +from blocFissure.gmu.triedreBase import triedreBase +from blocFissure.gmu.putName import putName +from blocFissure.gmu import initLog ### ### GEOM component ### -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - +O, OX, OY, OZ = triedreBase() -geompy = geomBuilder.New() - -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) @@ -53,84 +69,78 @@ 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) +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.addToStudy( CylindreSain, 'CylindreSain' ) +geomPublishInFather(initLog.debug,CylindreSain, Compound_1, 'Compound_1' ) +geompy.addToStudyInFather(CylindreSain, vertical, 'vertical' ) +geompy.addToStudyInFather(CylindreSain, radial, 'radial' ) +geompy.addToStudyInFather(CylindreSain, Compound_4, 'Compound_4' ) + 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.ExportBREP(FissInCylindre, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre.brep")) +geompy.addToStudy( FissInCylindre, 'cylindre_fissure' ) + +geompy.ExportBREP(FissInCylindre, os.path.join(gmu.pathBloc, "materielCasTests", "FissInCylindre.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) +Disk_1 = geompy.MakeDiskPntVecR(Vertex_13, OZ, 170) FissInCylindre2 = geompy.MakeCommon(Face_1, Disk_1) -geompy.ExportBREP(FissInCylindre2, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre2.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' ) +geompy.addToStudy( FissInCylindre2, 'cylindre_2_fissure' ) + +geompy.ExportBREP(FissInCylindre2, os.path.join(gmu.pathBloc, "materielCasTests", "FissInCylindre2.brep")) + +geomPublish(initLog.debug, Vertex_1, 'Vertex_1' ) +geomPublish(initLog.debug, Vertex_2, 'Vertex_2' ) +geomPublish(initLog.debug, Vertex_3, 'Vertex_3' ) +geomPublish(initLog.debug, Vertex_4, 'Vertex_4' ) +geomPublish(initLog.debug, Vertex_5, 'Vertex_5' ) +geomPublish(initLog.debug, Vertex_6, 'Vertex_6' ) +geomPublish(initLog.debug, Vertex_7, 'Vertex_7' ) +geomPublish(initLog.debug, Vertex_8, 'Vertex_8' ) +geomPublish(initLog.debug, Vertex_9, 'Vertex_9' ) +geomPublish(initLog.debug, Vertex_10, 'Vertex_10' ) +geomPublish(initLog.debug, Plane_1, 'Plane_1' ) +geomPublish(initLog.debug, Mirror_1_1, 'Mirror_1_1' ) +geomPublish(initLog.debug, Mirror_1_2, 'Mirror_1_2' ) +geomPublish(initLog.debug, Mirror_1_3, 'Mirror_1_3' ) +geomPublish(initLog.debug, Mirror_1_4, 'Mirror_1_4' ) +geomPublish(initLog.debug, Mirror_1_5, 'Mirror_1_5' ) +geomPublish(initLog.debug, Mirror_1_6, 'Mirror_1_6' ) +geomPublish(initLog.debug, Mirror_1_7, 'Mirror_1_7' ) +geomPublish(initLog.debug, Mirror_1_8, 'Mirror_1_8' ) +geomPublish(initLog.debug, Mirror_1_9, 'Mirror_1_9' ) +geomPublish(initLog.debug, Curve_2, 'Curve_2' ) +geomPublish(initLog.debug, Circle_1, 'Circle_1' ) +geomPublish(initLog.debug, Vertex_11, 'Vertex_11' ) +geomPublishInFather(initLog.debug, Curve_2, Curve_2_vertex_2, 'Curve_2:vertex_2' ) +geomPublishInFather(initLog.debug, Curve_2, Curve_2_vertex_3, 'Curve_2:vertex_3' ) +geomPublish(initLog.debug, Arc_1, 'Arc_1' ) +geomPublish(initLog.debug, FissInCylindre, 'FissInCylindre' ) +geomPublish(initLog.debug, Divided_Cylinder_1, 'Divided Cylinder_1' ) +geomPublish(initLog.debug, Vertex_12, 'Vertex_12' ) +geomPublish(initLog.debug, Circle_2, 'Circle_2' ) +geomPublish(initLog.debug, Face_1, 'Face_1' ) +geomPublish(initLog.debug, Vertex_13, 'Vertex_13' ) +geomPublish(initLog.debug, Disk_1, 'Disk_1' ) +geomPublish(initLog.debug, FissInCylindre2, 'FissInCylindre2' ) ### ### SMESH component ### -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - smesh = smeshBuilder.New() -from salome.StdMeshers import StdMeshersBuilder -smeshObj_1 = smesh.CreateHypothesis('NumberOfSegments') -smeshObj_1.SetNumberOfSegments( 5 ) -smeshObj_1.SetDistrType( 0 ) CylindreSain_1 = smesh.Mesh(CylindreSain) +putName(CylindreSain_1.GetMesh(), 'CylindreSain') + Regular_1D = CylindreSain_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[ ]) Nb_Segments_1.SetDistrType( 0 ) @@ -142,26 +152,25 @@ 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")) -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') +#smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') +#smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') +#smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') +putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='cylindre') +putName(Nb_Segments_2, 'Nb. Segments_2', i_pref='cylindre') +putName(Nb_Segments_3, 'Nb. Segments_3', i_pref='cylindre') + +is_done = CylindreSain_1.Compute() +text = "CylindreSain_1.Compute" +if is_done: + logging.info(text+" OK") +else: + text = "Erreur au calcul du maillage.\n" + text + logging.info(text) + raise Exception(text) + +CylindreSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "CylindreSain.med")) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser()