X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FblocFissure%2FmaterielCasTests%2FcubeAngle.py;h=43928fab3048b5676d119cf0264c03042c36f324;hp=9b4f4481cb205547e3b906891b4cfc5909021134;hb=b24a2d1b7692bdb21cf037b026e0273ba547cef4;hpb=264eeb2edd6977ccf2d2bd88cbb210353f63f7c9 diff --git a/src/Tools/blocFissure/materielCasTests/cubeAngle.py b/src/Tools/blocFissure/materielCasTests/cubeAngle.py index 9b4f4481c..43928fab3 100644 --- a/src/Tools/blocFissure/materielCasTests/cubeAngle.py +++ b/src/Tools/blocFissure/materielCasTests/cubeAngle.py @@ -1,30 +1,49 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2014-2021 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -import sys -import salome - -salome.salome_init() - -import salome_notebook +"""Cas-test de blocFissure pour un cube""" +import logging import os -from blocFissure import gmu -### -### GEOM component -### +from blocFissure import gmu +import salome import GEOM from salome.geom import geomBuilder -import math -import SALOMEDS +import SMESH +from salome.smesh import smeshBuilder +#=============== Options ==================== +# 1. NOM_OBJET = nom de l'objet +NOM_OBJET = "CubeAngle" +#============================================ + +salome.salome_init() + +### +### GEOM component +### 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) Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) Vertex_1 = geompy.MakeVertex(0, 0, 100) @@ -33,10 +52,7 @@ 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.ExportBREP(Common_1, os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.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' ) @@ -44,29 +60,42 @@ 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' ) +geompy.addToStudy( Common_1, NOM_OBJET ) + +ficcao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.brep".format(NOM_OBJET)) +text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficcao) +logging.info(text) +geompy.ExportBREP(Common_1, ficcao) ### ### SMESH component ### -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder smesh = smeshBuilder.New() -from salome.StdMeshers import StdMeshersBuilder Mesh_1 = smesh.Mesh(Box_1) +smesh.SetName(Mesh_1, NOM_OBJET) 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 ) + +is_done = Mesh_1.Compute() +text = "Mesh_1.Compute" +if is_done: + logging.info(text+" OK") +else: + text = "Erreur au calcul du maillage.\n" + text + logging.info(text) + raise Exception(text) + +ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET)) +text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed) +logging.info(text) +Mesh_1.ExportMED(ficmed) ## 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')