From c441817b4194b24e4cf97cd7c23f88ba56498e52 Mon Sep 17 00:00:00 2001 From: akk Date: Wed, 9 Mar 2005 15:09:14 +0000 Subject: [PATCH] PAL8375 improvement solving. --- src/SMESH_SWIG/Makefile.in | 5 +- src/SMESH_SWIG/PAL-MESH-041_mesh.py | 103 +++++++++++++++++++++++++++ src/SMESH_SWIG/PAL-MESH-043_2D.py | 102 +++++++++++++++++++++++++++ src/SMESH_SWIG/PAL-MESH-043_3D.py | 104 ++++++++++++++++++++++++++++ 4 files changed, 313 insertions(+), 1 deletion(-) create mode 100755 src/SMESH_SWIG/PAL-MESH-041_mesh.py create mode 100755 src/SMESH_SWIG/PAL-MESH-043_2D.py create mode 100755 src/SMESH_SWIG/PAL-MESH-043_3D.py diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index e474c3b7a..35e7f2139 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -84,7 +84,10 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \ SMESH_Sphere.py \ SMESH_GroupFromGeom.py \ SMESH_Nut.py \ - SMESH_GroupLyingOnGeom.py + SMESH_GroupLyingOnGeom.py \ + PAL-MESH-041_mesh.py \ + PAL-MESH-043_2D.py \ + PAL-MESH-043_3D.py LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl \ diff --git a/src/SMESH_SWIG/PAL-MESH-041_mesh.py b/src/SMESH_SWIG/PAL-MESH-041_mesh.py new file mode 100755 index 000000000..8585c9f6f --- /dev/null +++ b/src/SMESH_SWIG/PAL-MESH-041_mesh.py @@ -0,0 +1,103 @@ +import geompy +import salome + +import StdMeshers + +#-----------------------------GEOM---------------------------------------- + +#----------Vertexes------------ +p1 = geompy.MakeVertex(20.0,30.0,40.0) +p2 = geompy.MakeVertex(90.0,80.0,0.0) +p3 = geompy.MakeVertex(30.0,80.0,200.0) + +#----------Edges--------------- +e1 = geompy.MakeEdge(p1,p2) +e2 = geompy.MakeEdge(p2,p3) +e3 = geompy.MakeEdge(p3,p1) + +#----------Wire---------------- +ListOfEdges = [] +ListOfEdges.append(e3) +ListOfEdges.append(e2) +ListOfEdges.append(e1) +wire1 = geompy.MakeWire(ListOfEdges) + + +#----------Face---------------- +WantPlanarFace = 1 +face1 = geompy.MakeFace(wire1,WantPlanarFace) + +Id_face1 = geompy.addToStudy(face1,"Face1") + + + +#-----------------------------SMESH------------------------------------------- +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + +# -- Init -- +plane_mesh = salome.IDToObject( Id_face1) +smesh.SetCurrentStudy(salome.myStudy) + +mesh = smesh.CreateMesh(plane_mesh) + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +id_mesh = salome.ObjectToID(mesh) +smeshgui.SetName( id_mesh, "Mesh_1") + + +print"---------------------Hypothesis" + + +#---------------- NumberOfSegments +numberOfSegment = 9 + +hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" ) +hypNbSeg.SetNumberOfSegments( numberOfSegment ) + +print hypNbSeg.GetName() +print hypNbSeg.GetNumberOfSegments() +smeshgui.SetName(salome.ObjectToID(hypNbSeg), "Nb. Segments") + + +#--------------------------Max. Element Area +maxElementArea = 200 + +hypArea200 = smesh.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so") +hypArea200.SetMaxElementArea( maxElementArea ) +print hypArea200.GetName() +print hypArea200.GetMaxElementArea() + +smeshgui.SetName(salome.ObjectToID(hypArea200), "Max. Element Area") + +print"---------------------Algorithms" + +#----------------------------Wire discretisation +algoWireDes = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" ) +listHyp = algoWireDes.GetCompatibleHypothesis() + +print algoWireDes.GetName() +smeshgui.SetName(salome.ObjectToID(algoWireDes), "Ware descritisation") + +#----------------------------Triangle (Mefisto) +algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" ) +listHyp = algoMef.GetCompatibleHypothesis() + +print algoMef.GetName() + +#----------------------------Add hipothesis to the plane +mesh.AddHypothesis( plane_mesh, hypNbSeg ) # nb segments +mesh.AddHypothesis( plane_mesh, hypArea200 ) # max area + +mesh.AddHypothesis( plane_mesh, algoWireDes ) # Regular 1D/wire discretisation +mesh.AddHypothesis( plane_mesh, algoMef ) # MEFISTO 2D + +smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)") + +print "---------------------Compute the mesh" + +smesh.Compute(mesh, plane_mesh) + +salome.sg.updateObjBrowser(1) + diff --git a/src/SMESH_SWIG/PAL-MESH-043_2D.py b/src/SMESH_SWIG/PAL-MESH-043_2D.py new file mode 100755 index 000000000..76ab25924 --- /dev/null +++ b/src/SMESH_SWIG/PAL-MESH-043_2D.py @@ -0,0 +1,102 @@ +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_testExtrusion2D.py +# Module : SMESH +# Description : Create meshes to test extrusion of mesh elements along path + +import salome +import geompy +import SMESH +import StdMeshers + +#----------------------------------GEOM + +# create points +p1 = geompy.MakeVertex(100, 0, 0) +p2 = geompy.MakeVertex(100, 0, 100) +p3 = geompy.MakeVertex(0, 0, 0) +p4 = geompy.MakeVertex(0, 100, 0) + + +# create two vectors +vector1 = geompy.MakeVector(p1,p2) +vector2 = geompy.MakeVector(p3,p4) + +# make two ellipses +ellipse1 = geompy.MakeEllipse(p1,vector1,50,25) +ellipse2 = geompy.MakeEllipse(p3,vector2,300,50) + +# publish circular face and second circle +id_ellipse1 = geompy.addToStudy(ellipse1, "Ellips 1") +id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2") + + +#---------------------------------SMESH +# get smesh engine +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) + +# get SMESH GUI +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +# create hypoteses +hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg1.SetNumberOfSegments(18) +id_hypNbSeg1 = salome.ObjectToID(hypNbSeg1) +smeshgui.SetName(id_hypNbSeg1, "NumberOfSegments 1"); + +hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg2.SetNumberOfSegments(34) +id_hypNbSeg2 = salome.ObjectToID(hypNbSeg2) +smeshgui.SetName(id_hypNbSeg2, "NumberOfSegments 2"); + +# create algorithmes +algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +id_algoReg = salome.ObjectToID(algoReg) +smeshgui.SetName(id_algoReg, "Regular_1D"); + +# create the path mesh +mesh1 = smesh.CreateMesh(ellipse1) +id_mesh1 = salome.ObjectToID(mesh1) +smeshgui.SetName(id_mesh1, "Path Mesh"); + +# set hypotheses and algos +mesh1.AddHypothesis(ellipse1,algoReg) +mesh1.AddHypothesis(ellipse1,hypNbSeg1) + +# create the tool mesh +mesh2 = smesh.CreateMesh(ellipse2) +id_mesh2 = salome.ObjectToID(mesh2) +smeshgui.SetName(id_mesh2, "Tool Mesh"); + +# set hypotheses and algos +mesh2.AddHypothesis(ellipse2,algoReg) +mesh2.AddHypothesis(ellipse2,hypNbSeg2) + +# compute meshes +smesh.Compute(mesh1,ellipse1) +smesh.Compute(mesh2,ellipse2) + + +# ---- udate object browser +salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/PAL-MESH-043_3D.py b/src/SMESH_SWIG/PAL-MESH-043_3D.py new file mode 100755 index 000000000..cfd0f45c4 --- /dev/null +++ b/src/SMESH_SWIG/PAL-MESH-043_3D.py @@ -0,0 +1,104 @@ +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_testExtrusion3D.py +# Module : SMESH +# Description : Create meshes to test extrusion of mesh elements along path + +import salome +import geompy +import SMESH +import StdMeshers + +# get smesh engine +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) + +# create points to build two circles +p1 = geompy.MakeVertex(0, 100, 0) +p2 = geompy.MakeVertex(100, 0, 0) +p3 = geompy.MakeVertex(0, -100, 0) +p4 = geompy.MakeVertex(0, 70, 0) +p5 = geompy.MakeVertex(0, 100, 30) +p6 = geompy.MakeVertex(0, 130, 0) + +# create two circles +circle = geompy.MakeCircleThreePnt(p1, p2, p3) +cf = geompy.MakeCircleThreePnt(p4, p5, p6) + +# make circular face +wire = geompy.MakeWire([cf]) +face = geompy.MakeFace(wire, 1) + +# publish circular face and second circle +idcircle = geompy.addToStudy(circle, "Circle") +idface = geompy.addToStudy(face, "Circular face") + +# get SMESH GUI +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +# create hypoteses +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg.SetNumberOfSegments(12) +idseg = salome.ObjectToID(hypNbSeg) +smeshgui.SetName(idseg, "NumberOfSegments_10"); + +hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hypArea.SetMaxElementArea(30) +idarea = salome.ObjectToID(hypArea) +smeshgui.SetName(idarea, "MaxElementArea_20"); + +# create algorithmes +algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +idreg = salome.ObjectToID(algoReg) +smeshgui.SetName(idreg, "Regular_1D"); + +algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +idmef = salome.ObjectToID(algoMef) +smeshgui.SetName(idmef, "MEFISTO_2D"); + +# init a Mesh with the circular face +mesh1 = smesh.CreateMesh(face) +idmesh1 = salome.ObjectToID(mesh1) +smeshgui.SetName(idmesh1, "Mesh on circular face"); + +# set hypotheses and algos +mesh1.AddHypothesis(face,algoReg) +mesh1.AddHypothesis(face,hypNbSeg) +mesh1.AddHypothesis(face,algoMef) +mesh1.AddHypothesis(face,hypArea) + +# init a Mesh with the second circle +mesh2 = smesh.CreateMesh(circle) +idmesh2 = salome.ObjectToID(mesh2) +smeshgui.SetName(idmesh2, "Mesh on circular edge"); + +# set hypotheses and algos +mesh2.AddHypothesis(circle,algoReg) +mesh2.AddHypothesis(circle,hypNbSeg) + +# compute meshes +smesh.Compute(mesh1,face) +smesh.Compute(mesh2,circle) + +# ---- udate object browser +salome.sg.updateObjBrowser(1); -- 2.39.2