X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FblocFissure%2FmaterielCasTests%2Fvis.py;h=6fdc61ffd6ece3085194a3ebf4a2b150d7f59348;hp=8956aaf358d1df9f2132348100d5e5cf255fa383;hb=b3c9d09a8a81c0ad6cd5a1513d6b890d31f5fd9a;hpb=f8923c57965084c2260bfd4cee3d0d5266ae0c9f diff --git a/src/Tools/blocFissure/materielCasTests/vis.py b/src/Tools/blocFissure/materielCasTests/vis.py index 8956aaf35..6fdc61ffd 100644 --- a/src/Tools/blocFissure/materielCasTests/vis.py +++ b/src/Tools/blocFissure/materielCasTests/vis.py @@ -1,10 +1,29 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2014-2020 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 logging import sys import salome salome.salome_init() -theStudy = salome.myStudy import salome_notebook notebook = salome_notebook.notebook @@ -12,6 +31,8 @@ notebook = salome_notebook.notebook import os from blocFissure import gmu +logging.info('start') + ### ### GEOM component ### @@ -22,7 +43,7 @@ import math import SALOMEDS -geompy = geomBuilder.New(theStudy) +geompy = geomBuilder.New() O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) @@ -75,7 +96,7 @@ Partition_2 = geompy.MakePartition([Revolution_1], [conge], [], [], geompy.Shape 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_9 = geompy.MakeVertex(0, 99.633883, 1.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) @@ -98,7 +119,7 @@ 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.ExportBREP(Fissure, os.path.join(gmu.pathBloc, "materielCasTests/visFiss.brep")) +geompy.ExportBREP(Fissure, os.path.join(gmu.pathBloc, "materielCasTests", "visFiss.brep")) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) @@ -164,10 +185,13 @@ geompy.addToStudyInFather( Fissure, fondFiss, 'fondFiss' ) ### SMESH component ### +logging.info("Maillage de {}".format(coupe_vis.GetName())) + import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(theStudy) +smesh = smeshBuilder.New() + coupe_vis_1 = smesh.Mesh(coupe_vis) Regular_1D = coupe_vis_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(10) @@ -176,8 +200,7 @@ Regular_1D_1 = coupe_vis_1.Segment(geom=tige) Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30) Regular_1D_2 = coupe_vis_1.Segment(geom=section) Nb_Segments_3 = Regular_1D_2.NumberOfSegments(10,1,[ 7, 11, 16, 23 ]) -isDone = coupe_vis_1.Compute() -isDone = coupe_vis_1.SplitQuad( [ 691 ], 1 ) + 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) @@ -187,14 +210,44 @@ 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.Compute() +text = "Maillage de {}".format(coupe_vis.GetName()) +if isDone: + logging.debug(text+" : OK") +else: + text = "Erreur au calcul du maillage.\n" + text + logging.info(text) + raise Exception(text) + +# Découpage en 2 triangles du quadrangle dans l'angle +cg_x=0.972772 +cg_y=104.835 +cg_z=0. +l_ids = coupe_vis_1.FindElementsByPoint( cg_x,cg_y,cg_z, SMESH.FACE ) +if ( len(l_ids) != 1 ): + text = "Maillage {}.\nImpossible de trouver l'élément proche de ({},{},{}).".format(coupe_vis.GetName(),cg_x,cg_y,cg_z) + raise Exception(text) +isDone = coupe_vis_1.SplitQuad( l_ids, 1 ) +text = "SplitQuad de l'élément n° {} du maillage de {}".format(l_ids[0],coupe_vis.GetName()) +if isDone: + logging.debug(text+" : OK") +else: + text = "Erreur.\n" + text + logging.info(text) + raise Exception(text) + 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.RotationSweepObjects( [ visHex80 ], [ visHex80 ], [ visHex80 ], SMESH.AxisStruct( 0, 0, 0, 0, 10, 0 ), 0.0785398, 40, 1e-05, 1 ) -[ 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() + +_ = visHex80.RotationSweepObjects( [ visHex80 ], [ visHex80 ], [ visHex80 ], SMESH.AxisStruct( 0, 0, 0, 0, 10, 0 ), 0.0785398, 40, 1e-05, 1 ) + +[ 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() Sub_mesh_1 = Regular_1D_1.GetSubMesh() Sub_mesh_2 = Regular_1D_2.GetSubMesh() -visHex80.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"), 0, SMESH.MED_V2_2, 1 ) - +visHex80.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "visSain.med")) ## Set names of Mesh objects smesh.SetName(tige_2, 'tige') @@ -245,4 +298,4 @@ smesh.SetName(tige_haute_2, 'tige_haute') if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) + salome.sg.updateObjBrowser()