From: vsr Date: Tue, 12 Apr 2022 16:13:50 +0000 (+0300) Subject: 29171 Move examples to test folder X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=33cf7a01f2e029732ac9d0f3873860b4bd7ba0f0;p=modules%2Fsmesh.git 29171 Move examples to test folder --- diff --git a/src/SMESH_SWIG/CMakeLists.txt b/src/SMESH_SWIG/CMakeLists.txt index bd3a578d4..d40b4a17c 100644 --- a/src/SMESH_SWIG/CMakeLists.txt +++ b/src/SMESH_SWIG/CMakeLists.txt @@ -32,79 +32,11 @@ include_directories( ) # scripts / static -SET(_bin_SCRIPTS - ex00_all.py - ex01_cube2build.py - ex02_cube2primitive.py - ex03_cube2partition.py - ex04_cube5tetraHexa.py - ex05_hole1build.py - ex06_hole1boolean.py - ex07_hole1partition.py - ex08_hole2build.py - ex09_grid4build.py - ex10_grid4geometry.py - ex11_grid3partition.py - ex12_grid17partition.py - ex13_hole1partial.py - ex14_cyl1holed.py - ex15_cyl2geometry.py - ex16_cyl2complementary.py - ex17_dome1.py - ex18_dome2.py - ex19_sphereINcube.py - ex21_lamp.py - ex24_cylinder.py - ex29_refine.py - ex30_tepal.py - ex30_groupsOp.py - ex31_dimGroup.py - SMESH_test.py - SMESH_test0.py - SMESH_test1.py - SMESH_test1_AndDisplay.py - SMESH_test2.py - SMESH_test3.py - SMESH_test4.py - SMESH_test5.py - SMESH_mechanic.py - SMESH_mechanic_tetra.py - SMESH_mechanic_editor.py - SMESH_mechanic_netgen.py - SMESH_fixation.py - SMESH_fixation_hexa.py - SMESH_fixation_tetra.py - SMESH_fixation_netgen.py - SMESH_box_tetra.py - SMESH_box2_tetra.py - SMESH_box3_tetra.py - SMESH_flight_skin.py - SMESH_Partition1_tetra.py - SMESH_controls.py - SMESH_freebord.py - SMESH_blocks.py - SMESH_BelongToGeom.py - SMESH_GroupFromGeom2.py - SMESH_box.py - SMESH_demo_hexa2_upd.py - SMESH_hexaedre.py - SMESH_Sphere.py - SMESH_GroupFromGeom.py - SMESH_Nut.py - SMESH_GroupLyingOnGeom.py - SMESH_AdvancedEditor.py - SMESH_BuildCompound.py - PAL_MESH_041_mesh.py - PAL_MESH_043_2D.py - PAL_MESH_043_3D.py - SMESH_reg.py - smesh_selection.py - YACS_geomesh0.py -) SET(smesh_SCRIPTS smeshBuilder.py smesh_algorithm.py + smesh_selection.py ) SET(StdMeshers_SCRIPTS @@ -135,7 +67,5 @@ install(FILES ${SMeshHelper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_SMeshHelper_REAL_NAME}") # --- rules --- -SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS) SALOME_INSTALL_SCRIPTS("${smesh_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/smesh DEF_PERMS) SALOME_INSTALL_SCRIPTS("${StdMeshers_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/StdMeshers DEF_PERMS) -SALOME_INSTALL_SCRIPTS(SMESH_shared_modules.py ${SALOME_INSTALL_PYTHON}/shared_modules DEF_PERMS) diff --git a/src/SMESH_SWIG/PAL_MESH_041_mesh.py b/src/SMESH_SWIG/PAL_MESH_041_mesh.py deleted file mode 100644 index f0ec9bc47..000000000 --- a/src/SMESH_SWIG/PAL_MESH_041_mesh.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -#-----------------------------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------------------------------------------- - -# -- Init mesh -- -plane_mesh = salome.IDToObject( Id_face1) - -mesh = smesh.Mesh(plane_mesh, "Mesh_1") - -print("---------------------Hypothesis and Algorithms") - -#---------------- NumberOfSegments - -numberOfSegment = 9 - -algoWireDes = mesh.Segment() -listHyp = algoWireDes.GetCompatibleHypothesis() -print(algoWireDes.GetName()) -algoWireDes.SetName("Ware descritisation") - -hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "Nb. Segments") - - -#--------------------------Max. Element Area -maxElementArea = 200 - -algoMef = mesh.Triangle() -listHyp = algoMef.GetCompatibleHypothesis() -print(algoMef.GetName()) -algoMef.SetName("Triangle (Mefisto)") - -hypArea200 = algoMef.MaxElementArea(maxElementArea) -print(hypArea200.GetName()) -print(hypArea200.GetMaxElementArea()) -smesh.SetName(hypArea200, "Max. Element Area") - - -print("---------------------Compute the mesh") - -ret = mesh.Compute() -print(ret) - -salome.sg.updateObjBrowser() - diff --git a/src/SMESH_SWIG/PAL_MESH_043_2D.py b/src/SMESH_SWIG/PAL_MESH_043_2D.py deleted file mode 100644 index bc558ff67..000000000 --- a/src/SMESH_SWIG/PAL_MESH_043_2D.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_testExtrusion2D.py -# Module : SMESH -# Description : Create meshes to test extrusion of mesh elements along path -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -#----------------------------------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 - -# create the path mesh -mesh1 = smesh.Mesh(ellipse1, "Path Mesh") - -algoReg1 = mesh1.Segment() -algoReg1.SetName("Regular_1D") -hypNbSeg1 = algoReg1.NumberOfSegments(18) -smesh.SetName(hypNbSeg1, "NumberOfSegments 1") - -# create the tool mesh -mesh2 = smesh.Mesh(ellipse2, "Tool Mesh") -algoReg2 = mesh2.Segment() -algoReg2.SetName("Regular_1D") -hypNbSeg2 = algoReg2.NumberOfSegments(34) -smesh.SetName(hypNbSeg2, "NumberOfSegments 2") - -# compute meshes -mesh1.Compute() -mesh2.Compute() - - -# ---- udate object browser -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/PAL_MESH_043_3D.py b/src/SMESH_SWIG/PAL_MESH_043_3D.py deleted file mode 100644 index 21a7eebce..000000000 --- a/src/SMESH_SWIG/PAL_MESH_043_3D.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_testExtrusion3D.py -# Module : SMESH -# Description : Create meshes to test extrusion of mesh elements along path -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -# 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") - - -# init a Mesh with the circular face -mesh1 = smesh.Mesh(face, "Mesh on circular face") - -# set hypotheses and algos to the first mesh -numberOfSegments1 = 12 -algoReg1 = mesh1.Segment() -algoReg1.SetName("Regular_1D") -hypNbSeg1 = algoReg1.NumberOfSegments(numberOfSegments1) -smesh.SetName(hypNbSeg1, "NumberOfSegments_" + str(numberOfSegments1)) - -maxElementArea = 30 - -algoMef = mesh1.Triangle() -algoMef.SetName("MEFISTO_2D") -hypArea = algoMef.MaxElementArea(maxElementArea) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - - -# init a Mesh with the second circle -mesh2 = smesh.Mesh(circle, "Mesh on circular edge") - -numberOfSegments2 = 12 -algoReg2 = mesh2.Segment() -algoReg2.SetName("Regular_1D") -hypNbSeg2 = algoReg2.NumberOfSegments(numberOfSegments2) -smesh.SetName(hypNbSeg2, "NumberOfSegments_" + str(numberOfSegments2)) - - -# compute meshes -mesh1.Compute() -mesh2.Compute() - -# ---- update object browser -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_AdvancedEditor.py b/src/SMESH_SWIG/SMESH_AdvancedEditor.py deleted file mode 100644 index 77fd88b9a..000000000 --- a/src/SMESH_SWIG/SMESH_AdvancedEditor.py +++ /dev/null @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import math - -def GetNewNodes(mesh,Elems,OldNodes): - """ - Auxiliary function, which return list of nodes from - given Elems avoided nodes from OldNodes - """ - newnodes = [] - for i in Elems: - nbn = mesh.GetElemNbNodes(i) - for j in range(0,nbn): - nn = mesh.GetElemNode(i,j) - isold = 0 - for k in range(0,len(newnodes)): - if nn==newnodes[k]: - isold = 1 - break - pass - if isold: continue - for k in range(0,len(OldNodes)): - if nn==OldNodes[k]: - isold = 1 - break - pass - if isold: continue - newnodes.append(nn) - pass - pass - return newnodes - - -# create empty mesh -mesh = smesh.Mesh() - -tol = 0.001 - -# create a cross from quadrangle faces -# 1. create first edge and make extrusion along 0x -n1 = mesh.AddNode(55,-5,0) -n2 = mesh.AddNode(55,5,0) -e1 = mesh.AddEdge([n1,n2]) -dir1 = SMESH.DirStruct(SMESH.PointStruct(-10,0,0)) -mesh.ExtrusionSweep([e1],dir1,11) -# 2. create second edge and make extrusion along 0y -n3 = mesh.AddNode(-5,-55,0) -n4 = mesh.AddNode(5,-55,0) -e2 = mesh.AddEdge([n3,n4]) -dir2 = SMESH.DirStruct(SMESH.PointStruct(0,10,0)) -mesh.ExtrusionSweep([e2],dir2,11) - -# since result has coincident nodes and faces -# we have to make merge -nodes = mesh.FindCoincidentNodes(0.001) -mesh.MergeNodes(nodes) -mesh.MergeEqualElements() - -# make extrusion faces along 0z -faces = mesh.GetElementsByType(SMESH.FACE) -nbf = len(faces) -maxang = 2.0 -zstep = 5 -nbzsteps = 50 -dir3 = SMESH.DirStruct(SMESH.PointStruct(0,0,zstep)) -newfaces = [] # list for keeping created top faces - # during extrusion - -for i in range(0,nbzsteps): - mesh.ExtrusionSweep(faces,dir3,1) - # find top faces after each extrusion and keep them - res = mesh.GetLastCreatedElems() - nbr = len(res) - nfaces = [] - for j in res: - nbn = mesh.GetElemNbNodes(j) - if nbn!=4: continue - nn1 = mesh.GetElemNode(j,0) - xyz1 = mesh.GetNodeXYZ(nn1) - nn2 = mesh.GetElemNode(j,1) - xyz2 = mesh.GetNodeXYZ(nn2) - nn3 = mesh.GetElemNode(j,2) - xyz3 = mesh.GetNodeXYZ(nn3) - if abs(xyz1[2]-xyz2[2])2: faces1.append(i) - pass -nbf1 = len(faces1) - -# create other two edges and rotate them for creation -# other full circle -n8 = mesh.AddNode(-65,0,0) -n9 = mesh.AddNode(-67.5,0,0) -n10 = mesh.AddNode(-70,0,0) -e8 = mesh.AddEdge([n8,n9]) -e9 = mesh.AddEdge([n9,n10]) -axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0) -mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol) -res = mesh.GetLastCreatedElems() -faces2 = [] -for i in res: - nbn = mesh.GetElemNbNodes(i) - if nbn>2: faces2.append(i) - pass -nbf2 = len(faces2) - -# there are coincident nodes after rotation -# therefore we have to merge nodes -nodes = mesh.FindCoincidentNodes(0.001) -mesh.MergeNodes(nodes) - -nbcircs = 2 -nbrsteps = 24 -nbrs = nbcircs*nbrsteps -dz = nbzsteps*zstep/nbrs - -# create first spiral -oldnodes = [] -newnodes = GetNewNodes(mesh,faces1,oldnodes) -oldnodes = newnodes - -nodes = [] -mesh.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol) -res = mesh.GetLastCreatedElems() - -for i in range(0,nbrs): - volumes = [] - for j in range(0,nbf1): volumes.append(res[i+j*nbrs]) - newnodes = GetNewNodes(mesh,volumes,oldnodes) - for j in newnodes: - xyz = mesh.GetNodeXYZ(j) - mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1)) - pass - oldnodes = newnodes - pass - -# create second spiral -oldnodes = [] -newnodes = GetNewNodes(mesh,faces2,oldnodes) -oldnodes = newnodes - -nodes = [] -mesh.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol) -res = mesh.GetLastCreatedElems() - -for i in range(0,nbrs): - volumes = [] - for j in range(0,nbf2): volumes.append(res[i+j*nbrs]) - newnodes = GetNewNodes(mesh,volumes,oldnodes) - for j in newnodes: - xyz = mesh.GetNodeXYZ(j) - mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1)) - pass - oldnodes = newnodes - pass - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_BelongToGeom.py b/src/SMESH_SWIG/SMESH_BelongToGeom.py deleted file mode 100644 index 5aee14d00..000000000 --- a/src/SMESH_SWIG/SMESH_BelongToGeom.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -from SMESH_test1 import * - -## Old style -def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType): - if theShape != theSubShape: - aName = str(theSubShape) - geompy.addToStudyInFather(theShape,theSubShape,aName) - - theMeshGen.Compute(theMesh,theShape) - - aFilterMgr = theMeshGen.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - - aBelongToGeom = aFilterMgr.CreateBelongToGeom() - aBelongToGeom.SetGeom(theSubShape) - aBelongToGeom.SetElementType(theElemType) - - aFilter.SetPredicate(aBelongToGeom) - aFilterMgr.UnRegister() - return aFilter.GetElementsId(theMesh) - -## Current style -def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType): - if theShape != theSubShape: - aName = str(theSubShape) - geompy.addToStudyInFather(theShape,theSubShape,aName) - - theMesh.Compute() - aFilter = smesh.GetFilter(theElemType, SMESH.FT_BelongToGeom, theSubShape) - return aFilter.GetElementsId(theMesh.GetMesh()) - - -anElemType = SMESH.FACE; -print("anElemType =", anElemType) -#anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType) -anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType) -print("Number of ids = ", len(anIds)) -print("anIds = ", anIds) -## Check old version -#anIds = CheckBelongToGeomFilterOld(smesh,mesh.GetMesh(),box,box,anElemType) -#print "anIds = ", anIds - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_BuildCompound.py b/src/SMESH_SWIG/SMESH_BuildCompound.py deleted file mode 100644 index fcd721e06..000000000 --- a/src/SMESH_SWIG/SMESH_BuildCompound.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 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, 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 -# - -# File : SMESH_BuildCompound.py -# Author : Alexander KOVALEV -# Module : SMESH -# $Header$ -# ! Please, if you edit this example file, update also -# ! SMESH_SRC/doc/salome/gui/SMESH/input/tui_creating_meshes.doc -# ! as some sequences of symbols from this example are used during -# ! documentation generation to identify certain places of this file -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -## create a bottom box -Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.) - -# get a top face -Psup1=geompy.MakeVertex(100., 100., 50.) -Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1) -# get a bottom face -Pinf1=geompy.MakeVertex(100., 100., 0.) -Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1) - -## create a top box -Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.) - -# get a top face -Psup2=geompy.MakeVertex(150., 150., 100.) -Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2) -# get a bottom face -Pinf2=geompy.MakeVertex(150., 150., 50.) -Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2) - -## Publish in the study -geompy.addToStudy(Box_inf, "Box_inf") -geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup") -geompy.addToStudyInFather(Box_inf, Finf1, "Finf") - -geompy.addToStudy(Box_sup, "Box_sup") -geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup") -geompy.addToStudyInFather(Box_sup, Finf2, "Finf") - - -## create a bottom mesh -Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf") -algo1D_1=Mesh_inf.Segment() -algo1D_1.NumberOfSegments(10) -algo2D_1=Mesh_inf.Quadrangle() -algo3D_1=Mesh_inf.Hexahedron() -Mesh_inf.Compute() - -# create a group on the top face -Gsup1=Mesh_inf.Group(Fsup1, "Sup") -# create a group on the bottom face -Ginf1=Mesh_inf.Group(Finf1, "Inf") - -## create a top mesh -Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup") -algo1D_2=Mesh_sup.Segment() -algo1D_2.NumberOfSegments(5) -algo2D_2=Mesh_sup.Quadrangle() -algo3D_2=Mesh_sup.Hexahedron() -Mesh_sup.Compute() - -# create a group on the top face -Gsup2=Mesh_sup.Group(Fsup2, "Sup") -# create a group on the bottom face -Ginf2=Mesh_sup.Group(Finf2, "Inf") - -## create compounds -# create a compound of two meshes with renaming groups with the same names and -# merging of elements with the given tolerance -Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) -smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems') -# create a compound of two meshes with uniting groups with the same names and -# creating groups of all elements -Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) -smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems') -#end - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_GroupFromGeom.py b/src/SMESH_SWIG/SMESH_GroupFromGeom.py deleted file mode 100644 index c73cb7e1f..000000000 --- a/src/SMESH_SWIG/SMESH_GroupFromGeom.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_GroupFromGeom.py -# Module : SMESH -# -from SMESH_test1 import * - -# Compute the mesh created in SMESH_test1 - -mesh.Compute() - -# Create geometry groups on plane: -aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"]) -geompy.AddObject(aGeomGroup1, 1) - -aGeomGroup2 = geompy.CreateGroup(face , geompy.ShapeType["EDGE"]) - -geompy.AddObject(aGeomGroup2, 3) -geompy.AddObject(aGeomGroup2, 6) -geompy.AddObject(aGeomGroup2, 8) -geompy.AddObject(aGeomGroup2, 10) - -geompy.addToStudy(aGeomGroup1, "Group on Faces") -geompy.addToStudy(aGeomGroup2, "Group on Edges") - -aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) -aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_GroupFromGeom2.py b/src/SMESH_SWIG/SMESH_GroupFromGeom2.py deleted file mode 100644 index 2911d07a5..000000000 --- a/src/SMESH_SWIG/SMESH_GroupFromGeom2.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -#============================================================================== -# Info. -# Bug (from script, bug) : SMESH_GroupFromGeom.py, PAL6945 -# Modified : 25/11/2004 -# Author : Kovaltchuk Alexey -# Project : PAL/SALOME -#============================================================================== -# -from SMESH_test1 import * - - -# Compute the mesh created in SMESH_test1 - -mesh.Compute() - -# Create geometry groups on plane: -aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"]) -geompy.AddObject(aGeomGroup1, 1) - -aGeomGroup2 = geompy.CreateGroup(face , geompy.ShapeType["EDGE"]) - -geompy.AddObject(aGeomGroup2, 3) -geompy.AddObject(aGeomGroup2, 6) -geompy.AddObject(aGeomGroup2, 8) -geompy.AddObject(aGeomGroup2, 10) - -geompy.addToStudy(aGeomGroup1, "Group on Faces") -geompy.addToStudy(aGeomGroup2, "Group on Edges") - -aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) -aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) - -print("Create aGroupOnShell - a group linked to a shell") -aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", SMESH.EDGE) -print("aGroupOnShell type =", aGroupOnShell.GetType()) -print("aGroupOnShell size =", aGroupOnShell.Size()) -print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) - -print(" ") - -print("Modify hypothesis: 100 -> 50") -hypLen1.SetLength(50) -print("Contents of aGroupOnShell changes:") -print("aGroupOnShell size =", aGroupOnShell.Size()) -print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) - -print(" ") - -print("Re-compute mesh, contents of aGroupOnShell changes again:") -mesh.Compute() -print("aGroupOnShell size =", aGroupOnShell.Size()) -print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py b/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py deleted file mode 100644 index 67a060c99..000000000 --- a/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -def BuildGroupLyingOn(theMesh, theElemType, theName, theShape): - aFilterMgr = smesh.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - - aLyingOnGeom = aFilterMgr.CreateLyingOnGeom() - aLyingOnGeom.SetGeom(theShape) - aLyingOnGeom.SetElementType(theElemType) - - aFilter.SetPredicate(aLyingOnGeom) - anIds = aFilter.GetElementsId(theMesh) - aFilterMgr.UnRegister() - - aGroup = theMesh.CreateGroup(theElemType, theName) - aGroup.Add(anIds) - -#Example -from SMESH_test1 import * - -mesh.Compute() - -# First way -BuildGroupLyingOn(mesh.GetMesh(), SMESH.FACE, "Group of faces lying on edge #1", edge ) - -# Second way -mesh.MakeGroup("Group of faces lying on edge #2", SMESH.FACE, SMESH.FT_LyingOnGeom, edge) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_Nut.py b/src/SMESH_SWIG/SMESH_Nut.py deleted file mode 100644 index 1f45f16a8..000000000 --- a/src/SMESH_SWIG/SMESH_Nut.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -##################################################################### -#Created :17/02/2005 -#Author :MASLOV Eugeny, KOVALTCHUK Alexey -##################################################################### -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import os -import math - -#Sketcher_1 creation -print("Sketcher creation...") -Sketcher_1 = geompy.MakeSketcher("Sketcher:F 100 -57.7:TT 100 57.7:TT 0 115.47:TT -100 57.7:TT -100 -57.7:TT 0 -115.47:WW") -geompy.addToStudy(Sketcher_1, "Sketcher_1") -Face_1 = geompy.MakeFace(Sketcher_1, 1) -geompy.addToStudy(Face_1, "Face_1") - -#Line creation -print("Line creation...") -Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100)) -geompy.addToStudy(Line_1, "Line_1") - -#Prism creation -print("Prism creation...") -Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100) -geompy.addToStudy(Prism_1, "Prism_1") - -#Sketcher_2 creation -print("Sketcher creation...") -Sketcher_2 = geompy.MakeSketcher("Sketcher:F 50 0:TT 80 0:TT 112 13:TT 112 48:TT 80 63:TT 80 90:TT 50 90:WW", [0,0,0, 1,0,0, 0,1,0]) -geompy.addToStudy(Sketcher_2, "Sketcher_2") -Face_2 = geompy.MakeFace(Sketcher_2, 1) -geompy.addToStudy(Face_2, "Face_2") - -#Revolution creation -print("Revolution creation...") -Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi) -geompy.addToStudy(Revolution_1, "Revolution_1") - -#Common applying -print("Common of Revolution and Prism...") -Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1) -geompy.addToStudy(Common_1, "Common_1") - -#Explode Common_1 on edges -CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"]) -for i in range(0, len(CommonExplodedListEdges)): - name = "Edge_"+str(i+1) - geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name) - -#Fillet applying -print("Fillet creation...") -Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5]) -geompy.addToStudy(Fillet_1, "Fillet_1") - -#Chamfer applying -print("Chamfer creation...") -cyl_face = geompy.GetFaceNearPoint( Fillet_1, geompy.MakeVertex( 50, 0, 45 ), theName='cyl_face') -cyl_face_id = geompy.GetSubShapeID( Fillet_1, cyl_face ) -top_face = geompy.GetFaceNearPoint( Fillet_1, geompy.MakeVertex( 60, 0, 90 ), theName='top_face') -top_face_id = geompy.GetSubShapeID( Fillet_1, top_face ) -Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, cyl_face_id, top_face_id, theName='Chamfer_1' ) - -cyl_face = geompy.GetFaceNearPoint( Chamfer_1, geompy.MakeVertex( 80, 0, 85 ), theName='cyl_face') -cyl_face_id = geompy.GetSubShapeID( Chamfer_1, cyl_face ) -top_face = geompy.GetFaceNearPoint( Chamfer_1, geompy.MakeVertex( 65, 0, 90 ), theName='top_face') -top_face_id = geompy.GetSubShapeID( Chamfer_1, top_face ) -Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, cyl_face_id, top_face_id, theName='Chamfer_2' ) - -#Import of the shape from "slots.brep" -print("Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep") -thePath = os.getenv("DATA_DIR") -theFileName = os.path.join( thePath,"Shapes","Brep","slots.brep") -theShapeForCut = geompy.ImportBREP(theFileName) -geompy.addToStudy(theShapeForCut, "slot.brep_1") - -#Cut applying -print("Cut...") -Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2) -Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1") - -#Mesh creation - -# -- Init -- -shape_mesh = salome.IDToObject( Cut_1_ID ) - -mesh = smesh.Mesh(shape_mesh, "Nut") - -#HYPOTHESIS CREATION -print("-------------------------- Average length") -theAverageLength = 5 -algoReg1D = mesh.Segment() -hAvLength = algoReg1D.LocalLength(theAverageLength) -print(hAvLength.GetName()) -print(hAvLength.GetId()) -print(hAvLength.GetLength()) -smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength)) - -print("-------------------------- MaxElementArea") -theMaxElementArea = 20 -algoMef = mesh.Triangle(smeshBuilder.MEFISTO) -hArea = algoMef.MaxElementArea( theMaxElementArea ) -print(hArea.GetName()) -print(hArea.GetId()) -print(hArea.GetMaxElementArea()) -smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea)) - -print("-------------------------- MaxElementVolume") -theMaxElementVolume = 150 -algoNg = mesh.Tetrahedron(smeshBuilder.NETGEN) -hVolume = algoNg.MaxElementVolume( theMaxElementVolume ) -print(hVolume.GetName()) -print(hVolume.GetId()) -print(hVolume.GetMaxElementVolume()) -smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume)) - - -print("-------------------------- compute the mesh of the mechanic piece") -mesh.Compute() - -print("Information about the Nut:") -print("Number of nodes : ", mesh.NbNodes()) -print("Number of edges : ", mesh.NbEdges()) -print("Number of faces : ", mesh.NbFaces()) -print("Number of triangles : ", mesh.NbTriangles()) -print("Number of quadrangles : ", mesh.NbQuadrangles()) -print("Number of volumes : ", mesh.NbVolumes()) -print("Number of tetrahedrons: ", mesh.NbTetras()) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_Partition1_tetra.py b/src/SMESH_SWIG/SMESH_Partition1_tetra.py deleted file mode 100644 index 26ad2f73e..000000000 --- a/src/SMESH_SWIG/SMESH_Partition1_tetra.py +++ /dev/null @@ -1,187 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py -# Hypothesis and algorithms for the mesh generation are global -# -- Rayon de la bariere -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -from math import sqrt - - -#--------------------------------------------------------------- - -barier_height = 7.0 -barier_radius = 5.6 / 2 # Rayon de la bariere -colis_radius = 1.0 / 2 # Rayon du colis -colis_step = 2.0 # Distance s�parant deux colis -cc_width = 0.11 # Epaisseur du complement de colisage - -# -- - -cc_radius = colis_radius + cc_width -colis_center = sqrt(2.0)*colis_step/2 - -# -- - -boolean_common = 1 -boolean_cut = 2 -boolean_fuse = 3 -boolean_section = 4 - -# -- - -p0 = geompy.MakeVertex(0.,0.,0.) -vz = geompy.MakeVectorDXDYDZ(0.,0.,1.) - -# -- - -barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height) - -# -- - -colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height) -cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height) - -colis_cc = geompy.MakeCompound([colis, cc]) -colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0) - -colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4) - -# -- - -Compound1 = geompy.MakeCompound([colis_cc_multi, barier]) -SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"]) -alveole = geompy.MakePartition(SubShape_theShape) - -print("Analysis of the geometry to mesh (right after the Partition) :") - -subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) - -print("number of Shells in alveole : ", len(subShellList)) -print("number of Faces in alveole : ", len(subFaceList)) -print("number of Edges in alveole : ", len(subEdgeList)) - -subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"]) - -## there are 9 sub-shapes - -comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] ) -comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] ) -comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] ) -comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] ) - -compGOs = [] -compGOs.append( comp1 ) -compGOs.append( comp2 ) -compGOs.append( comp3 ) -compGOs.append( comp4 ) -comp = geompy.MakeCompound( compGOs ) - -alveole = geompy.MakeCompound( [ comp, subshapes[8] ]) - -idalveole = geompy.addToStudy(alveole, "alveole") - -print("Analysis of the geometry to mesh (right after the MakeCompound) :") - -subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) - -print("number of Shells in alveole : ", len(subShellList)) -print("number of Faces in alveole : ", len(subFaceList)) -print("number of Edges in alveole : ", len(subEdgeList)) - -status = geompy.CheckShape(alveole) -print(" check status ", status) - - -# ---- init a Mesh with the alveole -shape_mesh = salome.IDToObject( idalveole ) - -mesh = smesh.Mesh(shape_mesh, "MeshAlveole") - -print("-------------------------- create Hypothesis (In this case global hypothesis are used)") - -print("-------------------------- NumberOfSegments") - -numberOfSegments = 10 - -regular1D = mesh.Segment() -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -print("-------------------------- MaxElementArea") - -maxElementArea = 0.1 - -mefisto2D = mesh.Triangle() -hypArea = mefisto2D.MaxElementArea(maxElementArea) -print(hypArea.GetName()) -print(hypArea.GetId()) -print(hypArea.GetMaxElementArea()) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - -print("-------------------------- MaxElementVolume") - -maxElementVolume = 0.5 - -netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) -hypVolume = netgen3D.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) - -print("-------------------------- compute the mesh of alveole ") -ret = mesh.Compute() - -if ret != 0: - log=mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the Mesh_mechanic:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons: ", mesh.NbTetras()) -else: - print("problem when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_Sphere.py b/src/SMESH_SWIG/SMESH_Sphere.py deleted file mode 100644 index fdcb723cf..000000000 --- a/src/SMESH_SWIG/SMESH_Sphere.py +++ /dev/null @@ -1,121 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# GEOM GEOM_SWIG : binding of C++ implementation with Python -# File : GEOM_Sphere.py -# Author : Damien COQUERET, Open CASCADE -# Module : GEOM -# $Header: -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import math - -# It is an example of creating a hexahedrical mesh on a sphere. -# -# Used approach allows to avoid problems with degenerated and -# seam edges without special processing of geometrical shapes - -#----------------------------------------------------------------------- -#Variables -Radius = 100. -Dist = Radius / 2. -Factor = 2.5 -Angle90 = math.pi / 2. -NbSeg = 10 - -PointsList = [] -ShapesList = [] - -#Basic Elements -P0 = geompy.MakeVertex(0., 0., 0.) -P1 = geompy.MakeVertex(-Dist, -Dist, -Dist) -P2 = geompy.MakeVertex(-Dist, -Dist, Dist) -P3 = geompy.MakeVertex(-Dist, Dist, Dist) -P4 = geompy.MakeVertex(-Dist, Dist, -Dist) - -VZ = geompy.MakeVectorDXDYDZ(0., 0., 1.) - -#Construction Elements -PointsList.append(P1) -PointsList.append(P2) -PointsList.append(P3) -PointsList.append(P4) -PointsList.append(P1) - -PolyLine = geompy.MakePolyline(PointsList) - -Face1 = geompy.MakeFace(PolyLine, 1) -Face2 = geompy.MakeScaleTransform(Face1, P0, Factor) -Face3 = geompy.MakeScaleTransform(Face1, P0, -1.) - -#Models -Sphere = geompy.MakeSphereR(Radius) - -Block = geompy.MakeHexa2Faces(Face1, Face2) -Cube = geompy.MakeHexa2Faces(Face1, Face3) - -Common1 = geompy.MakeBoolean(Sphere, Block, 1) -Common2 = geompy.MakeRotation(Common1, VZ, Angle90) - -MultiBlock1 = geompy.MakeMultiTransformation1D(Common1, 20, -1, 3) -MultiBlock2 = geompy.MakeMultiTransformation1D(Common2, 30, -1, 3) - -#Reconstruct sphere from several blocks -ShapesList.append(Cube) -ShapesList.append(MultiBlock1) -ShapesList.append(MultiBlock2) -Compound = geompy.MakeCompound(ShapesList) - -Result = geompy.MakeGlueFaces(Compound, 0.1) - -#addToStudy -Id_Sphere = geompy.addToStudy(Sphere, "Sphere") -Id_Cube = geompy.addToStudy(Cube, "Cube") - -Id_Common1 = geompy.addToStudy(Common1, "Common1") -Id_Common2 = geompy.addToStudy(Common2, "Common2") - -Id_MultiBlock1 = geompy.addToStudy(MultiBlock1, "MultiBlock1") -Id_MultiBlock2 = geompy.addToStudy(MultiBlock2, "MultiBlock2") - -Id_Result = geompy.addToStudy(Result, "Result") - -#----------------------------------------------------------------------- -#Meshing -my_hexa = smesh.Mesh(Result, "Sphere_Mesh") -algo = my_hexa.Segment() -algo.NumberOfSegments(NbSeg) -my_hexa.Quadrangle() -my_hexa.Hexahedron() -my_hexa.Compute() - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_blocks.py b/src/SMESH_SWIG/SMESH_blocks.py deleted file mode 100644 index 9d1c47b1a..000000000 --- a/src/SMESH_SWIG/SMESH_blocks.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# SMESH SMESH_SWIG : binding of C++ implementation with Python -# File : SMESH_blocks.py -# Author : Julia DOROVSKIKH -# Module : SMESH -# $Header$ -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import math - -import GEOM_Spanner - -isBlocksTest = 0 # False -isMeshTest = 1 # True - -GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_box.py b/src/SMESH_SWIG/SMESH_box.py deleted file mode 100644 index 7d2e291a0..000000000 --- a/src/SMESH_SWIG/SMESH_box.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -#============================================================================== -# Info. -# Bug (from script, bug) : box.py, PAL5223 -# Modified : 25/11/2004 -# Author : Kovaltchuk Alexey -# Project : PAL/SALOME -#============================================================================== -# Salome geometry and meshing for a box -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -from salome import sg - -# Plate - -box = geompy.MakeBox(0.,0.,0.,1.,1.,1.) -boxId = geompy.addToStudy(box,"box") - -# ---- SMESH - -# ---- init a Mesh - -box_mesh=smesh.Mesh(box, "box_mesh") - -# set Hypothesis and Algorithm - -alg1D = box_mesh.Segment() -alg1D.SetName("algo1D") -hypL1 = alg1D.LocalLength(0.25) -smesh.SetName(hypL1, "LocalLength") - -alg2D = box_mesh.Quadrangle() -alg2D.SetName("algo2D") - -alg3D = box_mesh.Hexahedron() -alg3D.SetName("algo3D") - -# compute mesh - -box_mesh.Compute() - -sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_box2_tetra.py b/src/SMESH_SWIG/SMESH_box2_tetra.py deleted file mode 100644 index 3cf795ced..000000000 --- a/src/SMESH_SWIG/SMESH_box2_tetra.py +++ /dev/null @@ -1,141 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of the geometry union of 2 boxes having a face in common -# Hypothesis and algorithms for the mesh generation are global -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -# ---- define 2 boxes box1 and box2 - -box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) - -idbox1 = geompy.addToStudy(box1, "box1") - -print("Analysis of the geometry box1 :") -subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) - -print("number of Shells in box1 : ", len(subShellList)) -print("number of Faces in box1 : ", len(subFaceList)) -print("number of Edges in box1 : ", len(subEdgeList)) - -box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) - -idbox2 = geompy.addToStudy(box2, "box2") - -print("Analysis of the geometry box2 :") -subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) - -print("number of Shells in box2 : ", len(subShellList)) -print("number of Faces in box2 : ", len(subFaceList)) -print("number of Edges in box2 : ", len(subEdgeList)) - -# append the tow boxes to make ine shel, referrencing only once -# the internal interface - -shell = geompy.MakePartition([box1, box2]) -idshell = geompy.addToStudy(shell, "shell") - -print("Analysis of the geometry shell (union of box1 and box2) :") -subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) - -print("number of Shells in shell : ", len(subShellList)) -print("number of Faces in shell : ", len(subFaceList)) -print("number of Edges in shell : ", len(subEdgeList)) - - -### ---------------------------- SMESH -------------------------------------- - -# ---- init a Mesh with the shell - -mesh = smesh.Mesh(shell, "MeshBox2") - - -# ---- set Hypothesis and Algorithm - -print("-------------------------- NumberOfSegments") - -numberOfSegments = 10 - -regular1D = mesh.Segment() -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -print("-------------------------- MaxElementArea") - -maxElementArea = 500 - -mefisto2D = mesh.Triangle() -hypArea = mefisto2D.MaxElementArea(maxElementArea) -print(hypArea.GetName()) -print(hypArea.GetId()) -print(hypArea.GetMaxElementArea()) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - -print("-------------------------- MaxElementVolume") - -maxElementVolume = 500 - -netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) -hypVolume = netgen3D.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) - -print("-------------------------- compute shell") -ret = mesh.Compute() -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the MeshBox2:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons: ", mesh.NbTetras()) -else: - print("probleme when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_box3_tetra.py b/src/SMESH_SWIG/SMESH_box3_tetra.py deleted file mode 100644 index 38610c33f..000000000 --- a/src/SMESH_SWIG/SMESH_box3_tetra.py +++ /dev/null @@ -1,151 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of the geometry union of 3 boxes aligned where the middle -# one has a race in common with the two others. -# Hypothesis and algorithms for the mesh generation are global -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define 3 boxes box1, box2 and box3 - -box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) - -idbox1 = geompy.addToStudy(box1, "box1") - -print("Analysis of the geometry box1 :") -subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) - -print("number of Shells in box1 : ", len(subShellList)) -print("number of Faces in box1 : ", len(subFaceList)) -print("number of Edges in box1 : ", len(subEdgeList)) - -box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) - -idbox2 = geompy.addToStudy(box2, "box2") - -print("Analysis of the geometry box2 :") -subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) - -print("number of Shells in box2 : ", len(subShellList)) -print("number of Faces in box2 : ", len(subFaceList)) -print("number of Edges in box2 : ", len(subEdgeList)) - -box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.) - -idbox3 = geompy.addToStudy(box3, "box3") - -print("Analysis of the geometry box3 :") -subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"]) - -print("number of Shells in box3 : ", len(subShellList)) -print("number of Faces in box3 : ", len(subFaceList)) -print("number of Edges in box3 : ", len(subEdgeList)) - -shell = geompy.MakePartition([box1, box2, box3]) -idshell = geompy.addToStudy(shell,"shell") - -print("Analysis of the geometry shell (union of box1, box2 and box3) :") -subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) - -print("number of Shells in shell : ", len(subShellList)) -print("number of Faces in shell : ", len(subFaceList)) -print("number of Edges in shell : ", len(subEdgeList)) - - -### ---------------------------- SMESH -------------------------------------- - -# ---- init a Mesh with the shell - -mesh = smesh.Mesh(shell, "MeshBox3") - - -# ---- set Hypothesis and Algorithm - -print("-------------------------- NumberOfSegments") - -numberOfSegments = 10 - -regular1D = mesh.Segment() -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -print("-------------------------- MaxElementArea") - -maxElementArea = 500 - -mefisto2D = mesh.Triangle() -hypArea = mefisto2D.MaxElementArea(maxElementArea) -print(hypArea.GetName()) -print(hypArea.GetId()) -print(hypArea.GetMaxElementArea()) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - -print("-------------------------- MaxElementVolume") - -maxElementVolume = 500 - -netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) -hypVolume = netgen3D.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) - -print("-------------------------- compute shell") -ret = mesh.Compute() -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the MeshBox3:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons: ", mesh.NbTetras()) -else: - print("probleme when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_box_tetra.py b/src/SMESH_SWIG/SMESH_box_tetra.py deleted file mode 100644 index 52618addf..000000000 --- a/src/SMESH_SWIG/SMESH_box_tetra.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of a simple box. Hypothesis and algorithms for -# the mesh generation are global -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define a box - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) - -idbox = geompy.addToStudy(box, "box") - -print("Analysis of the geometry box :") -subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) - -print("number of Shells in box : ", len(subShellList)) -print("number of Faces in box : ", len(subFaceList)) -print("number of Edges in box : ", len(subEdgeList)) - - -### ---------------------------- SMESH -------------------------------------- - -# ---- init a Mesh with the box - -mesh = smesh.Mesh(box, "MeshBox") - -# ---- set Hypothesis and Algorithm - -print("-------------------------- NumberOfSegments") -numberOfSegments = 10 - -regular1D = mesh.Segment() -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -print("-------------------------- MaxElementArea") - -maxElementArea = 500 - -mefisto2D = mesh.Triangle() -hypArea = mefisto2D.MaxElementArea(maxElementArea) -print(hypArea.GetName()) -print(hypArea.GetId()) -print(hypArea.GetMaxElementArea()) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - -print("-------------------------- MaxElementVolume") - -maxElementVolume = 500 - -netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) -hypVolume = netgen3D.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) - -print("-------------------------- compute the mesh of the box") -ret = mesh.Compute() -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the MeshBox:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons: ", mesh.NbTetras()) -else: - print("probleme when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_controls.py b/src/SMESH_SWIG/SMESH_controls.py deleted file mode 100644 index d081611f9..000000000 --- a/src/SMESH_SWIG/SMESH_controls.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_control.py -# Author : Sergey LITONIN -# Module : SMESH -# -import salome -import SMESH_mechanic - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -mesh = SMESH_mechanic.mesh - -# ---- Criterion : AREA > 100 - -# create group -aGroup = mesh.MakeGroup("Area > 100", SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Area > 100 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# ---- Criterion : Taper > 3e-15 - -# create group -aGroup = mesh.MakeGroup("Taper > 3e-15", SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, 3e-15) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Taper > 3e-15 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# ---- Criterion : ASPECT RATIO > 1.3 - -# create group -aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.3) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# ---- Criterion : MINIMUM ANGLE < 30 - -# create group -aGroup = mesh.MakeGroup("Minimum Angle < 30", SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, 30) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Minimum Angle < 30 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# ---- Criterion : Warp > 2e-13 - -# create group -aGroup = mesh.MakeGroup("Warp > 2e-13", SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, 2e-13 ) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Warp > 2e-13 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# ---- Criterion : Skew > 18 - -# create group -aGroup = mesh.MakeGroup("Skew > 18", SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 18 ) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Skew > 18 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# Criterion : Length > 10 - -# create group -aGroup = mesh.MakeGroup("Length > 10", SMESH.FACE, SMESH.FT_Length, SMESH.FT_MoreThan, 10 ) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Length > 10 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# Criterion : Borders at multi-connections = 2 - -# create group -aGroup = mesh.MakeGroup("Borders at multi-connections = 2", SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, 2) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -# Criterion : Element Diameter 2D > 10 - -# create group -aGroup = mesh.MakeGroup("Element Diameter 2D > 10", SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10 ) - -# print result -anIds = aGroup.GetIDs() -print("Criterion: Element Diameter 2D > 10 Nb = ", len( anIds )) -#for i in range( len( anIds ) ): - #print anIds[ i ] - - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py b/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py deleted file mode 100644 index d6c3c4325..000000000 --- a/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py +++ /dev/null @@ -1,200 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -#============================================================================== -# Info. -# Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781 -# Modified : 25/11/2004 -# Author : Kovaltchuk Alexey -# Project : PAL/SALOME -#============================================================================== -# Tetrahedrization of a geometry (box minus a inner cylinder). -# Hypothesis and algorithms for the mesh generation are not global: -# the mesh of some edges is thinner -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import math - - -# ----------------------------------------------------------------------------- - -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - -a = math.sqrt(2.)/4. -ma = - a -zero = 0. -un = 1. -mun= - un -demi = 1./2. - -Orig = geompy.MakeVertex(zero,zero,zero) -P0 = geompy.MakeVertex(a,a,zero) -P1 = geompy.MakeVertex(zero,demi,zero) -P2 = geompy.MakeVertex(ma,a,zero) -P3 = geompy.MakeVertex(mun,un,zero) -P4 = geompy.MakeVertex(un,un,zero) -P5 = geompy.MakeVertex(zero,zero,un) - -arc = geompy.MakeArc(P0,P1,P2) -e1 = geompy.MakeEdge(P2,P3) -e2 = geompy.MakeEdge(P3,P4) -e3 = geompy.MakeEdge(P4,P0) - -list = [] -list.append(arc) -list.append(e1) -list.append(e2) -list.append(e3) - -wire = geompy.MakeWire(list) -face = geompy.MakeFace(wire,1) - -dir = geompy.MakeVector(Orig,P5) -vol1 = geompy.MakePipe(face,dir) - -angle = math.pi/2. -#dir = geom.MakeVector(Orig,P5) -vol2 = geompy.MakeRotation(vol1,dir,angle) - -vol3 = geompy.MakeRotation(vol2,dir,angle) - -vol4 = geompy.MakeRotation(vol3,dir,angle) - -list = [] -list.append(vol1) -list.append(vol2) -list.append(vol3) -list.append(vol4) - -volComp = geompy.MakeCompound(list) - -tol3d = 1.e-3 -vol = geompy.MakeGlueFaces(volComp,tol3d) -idVol = geompy.addToStudy(vol,"volume") - -print("Analysis of the final volume:") -subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell) -subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace) -subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge) - -print("number of Shells in the volume : ",len(subShellList)) -print("number of Faces in the volume : ",len(subFaceList)) -print("number of Edges in the volume : ",len(subEdgeList)) - -idSubEdge = [] -for k in range(len(subEdgeList)): - idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k))) - -edgeZ = [] -edgeZ.append(subEdgeList[0]) -edgeZ.append(subEdgeList[3]) -edgeZ.append(subEdgeList[10]) -edgeZ.append(subEdgeList[11]) -edgeZ.append(subEdgeList[20]) -edgeZ.append(subEdgeList[21]) -edgeZ.append(subEdgeList[28]) -edgeZ.append(subEdgeList[31]) - -idEdgeZ = [] -for i in range(8): - idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1))) - -### ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -# ---- init a Mesh with the volume - -mesh = smesh.Mesh(vol, "meshVolume") - -# ---- set Hypothesis and Algorithm to main shape - -print("-------------------------- NumberOfSegments the global one") - -numberOfSegments = 10 - -regular1D = mesh.Segment() -regular1D.SetName("Wire Discretisation") -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments") - - -print("-------------------------- Quadrangle_2D") - -quad2D=mesh.Quadrangle() -quad2D.SetName("Quadrangle_2D") - -print("-------------------------- Hexa_3D") - -hexa3D=mesh.Hexahedron() -hexa3D.SetName("Hexa_3D") - - -print("-------------------------- NumberOfSegments in the Z direction") - -numberOfSegmentsZ = 40 - -for i in range(8): - print("-------------------------- add hypothesis to edge in the Z directions", (i+1)) - - algo = mesh.Segment(edgeZ[i]) - hyp = algo.NumberOfSegments(numberOfSegmentsZ) - smesh.SetName(hyp, "NumberOfSegmentsZ") - smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1)) - - -salome.sg.updateObjBrowser() - -print("-------------------------- compute the mesh of the volume") - -ret=mesh.Compute() - -print(ret) -if ret != 0: -## log=mesh.GetLog(0) # no erase trace -## for linelog in log: -## print linelog - print("Information about the MeshBox :") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons: ", mesh.NbTetras()) -else: - print("problem when Computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_fixation.py b/src/SMESH_SWIG/SMESH_fixation.py deleted file mode 100644 index 87cec63b9..000000000 --- a/src/SMESH_SWIG/SMESH_fixation.py +++ /dev/null @@ -1,300 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_fix_volute.py -# Author : Paul RASCLE, EDF -# Module : SMESH -# $Header$ -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import math - -# ----------------------------------------------------------------------------- - -def MakeFace(lstEdges) : - """ - Create a planar face from 4 edges - """ - wire = geompy.MakeWire(lstEdges) - face = geompy.MakeFace(wire, 1) - return face - -# ----------------------------------------------------------------------------- - -# ---- dimensions - -##longueurPlq = 0.686 -##largeurPlq = 0.573 -##epaisseurPlq = 0.150 - -##hauteurFlanc = 0.380 -##epaisseurFlanc = 0.112 -##rayonConge = 0.150 - epaisseurFlanc - -##epaisseurFond = 0.162 -##rayonTrou = 0.075 -##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou) -##marge = 0.01 -##tol3d = 1.e-5 - -longueurPlq = 686 -largeurPlq = 573 -epaisseurPlq = 150 - -hauteurFlanc = 380 -epaisseurFlanc = 112 -rayonConge = 150 - epaisseurFlanc - -epaisseurFond = 162 -rayonTrou = 75 -posAxeTrou = hauteurFlanc - (180 + rayonTrou) -marge = 10 -tol3d = 1.e-3 - -# ---- points, directions de base - -p0 = geompy.MakeVertex(0., 0., 0.) - -vx = geompy.MakeVectorDXDYDZ(100., 0., 0.) -vy = geompy.MakeVectorDXDYDZ(0., 100., 0.) -vz = geompy.MakeVectorDXDYDZ(0., 0., 100.) - -# ---- ellipse du flanc - -he = hauteurFlanc - 2*rayonConge -re = 0.5*(largeurPlq - epaisseurFond) - rayonConge -sine = re/he -cose = math.sqrt(1. - sine*sine) - -ve = geompy.MakeVectorDXDYDZ(sine, 0., cose) -cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he) -cyl1 = geompy.MakeRotation(cyl0, ve, 0.5) -cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose) - -pbe = geompy.MakeVertex(3*he, -2*re, 3*he) -boxe = geompy.MakeBoxTwoPnt(p0, pbe) - -cylcoup = geompy.MakeBoolean(cyle, boxe, 2) - -aretes = [] -aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"]) - -shape = geompy.MakeCopy(aretes[0]) -aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge) - - -# ----------------------------------------------------------------------------- -# ---- decoupage de la piece en volumes a 6 faces de 4 cotes -# ----------------------------------------------------------------------------- - -# ---- cotes x - -x0 = 0. -x0h = rayonConge -x1 = rayonConge + epaisseurFlanc -xc = longueurPlq/2 -x2 = longueurPlq - rayonConge - epaisseurFlanc -x3h = longueurPlq - rayonConge -x3 = longueurPlq - -# ---- cotes y - -y0 = 0. -y0h = rayonConge -y1 = largeurPlq - epaisseurFond -y1m = y1 - marge -y2 = largeurPlq -y2p = largeurPlq + marge - -# ---- cotes z - -z0 = 0. -z1m = epaisseurPlq - marge -z1 = epaisseurPlq -z2 = epaisseurPlq + rayonConge -z3 = epaisseurPlq + 2*rayonConge -z4 = epaisseurPlq + hauteurFlanc -z4p = epaisseurPlq + hauteurFlanc + marge - -zc = epaisseurPlq + posAxeTrou -zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3 -zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3 - -# ---- decoupe du fond - -p11 = geompy.MakeVertex(x1, y1m, z1) -p12 = geompy.MakeVertex(x1, y1m, z2) -p13 = geompy.MakeVertex(x1, y1m, z3) -p14 = geompy.MakeVertex(x1, y1m, z4) -pc1 = geompy.MakeVertex(xc, y1m, z1) -pc2 = geompy.MakeVertex(xc, y1m, zc2) -pc3 = geompy.MakeVertex(xc, y1m, zc3) -pcc = geompy.MakeVertex(xc, y1m, zc) -pc4 = geompy.MakeVertex(xc, y1m, z4) -p21 = geompy.MakeVertex(x2, y1m, z1) -p22 = geompy.MakeVertex(x2, y1m, z2) -p23 = geompy.MakeVertex(x2, y1m, z3) -p24 = geompy.MakeVertex(x2, y1m, z4) -pcf = geompy.MakeVertex(xc, y2p, zc) - -arc2 = geompy.MakeArc(p12,pc2,p22) -arc3 = geompy.MakeArc(p13,pc3,p23) - -segz1 = geompy.MakeVector(p11,p21) -segz41 = geompy.MakeVector(p14,pc4) -segz42 = geompy.MakeVector(pc4,p24) -segx11 = geompy.MakeVector(p11,p12) -segx12 = geompy.MakeVector(p12,p13) -segx13 = geompy.MakeVector(p13,p14) -segxc2 = geompy.MakeVector(pc1,pc2) -segxc3 = geompy.MakeVector(pc2,pc3) -segxc4 = geompy.MakeVector(pcc,pc4) -segx21 = geompy.MakeVector(p21,p22) -segx22 = geompy.MakeVector(p22,p23) -segx23 = geompy.MakeVector(p23,p24) -segx1c1 = geompy.MakeVector(p13,pcc) -segx1c2 = geompy.MakeVector(p14,pcc) -segx2c1 = geompy.MakeVector(p23,pcc) -segx2c2 = geompy.MakeVector(p24,pcc) - -facef = [] -facef.append(MakeFace([segx13,segx1c2,segx1c1])) -facef.append(MakeFace([segx23,segx2c2,segx2c1])) -facef.append(MakeFace([segx2c2,segxc4,segz42])) -facef.append(MakeFace([segx1c2,segz41,segxc4])) -facef.append(MakeFace([segx1c1,arc3,segx2c1])) -facef.append(MakeFace([segx12,arc2,segx22,arc3])) -facef.append(MakeFace([segx11,segz1,segx21,arc2])) - -vcccf = geompy.MakeVector(pcc, pcf) -hcccf = y2p - y1m -decf = [] -for face in facef: - decf.append(geompy.MakePrismVecH(face,vcccf,hcccf)) - -pc = geompy.MakeVertex(xc, 0., zc) -py2 = geompy.MakeVertex(xc, y2, zc) -axeCyl = geompy.MakeVector(pc, py2) - -cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq) -cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi) - -fondec = [] -for id in (0,1,2,3): - fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2)) -fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2)) -for id in (5,6): - fondec.append(decf[id]) - -p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p) -p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p) -pxc = geompy.MakeVertex(xc,y0,z0) -bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p) -bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p) - -fondec2 = [] -for id in (0,1,2,3): - fondec2.append(fondec[id]) -for id in (4,5,6): - fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1)) - fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1)) - -# ----- autres blocs de decoupe - -bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2) -bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2) -bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2) -bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2) - -pcylx0 = geompy.MakeVertex(0., -marge, z2) -pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2) -pcyly0 = geompy.MakeVertex(-marge, 0., z2) - -cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge) -cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge) -cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge) - -bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2) -bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2) -bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2) -#NRI : inverse order of BOP -bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2) -bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2) -bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2) - -pf1 = geompy.MakeVertex(0., y0h, z3) -pf2 = geompy.MakeVertex(0., y1, z3) -pf3 = geompy.MakeVertex(0., y1, z4) -pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4) - -vf1 = geompy.MakeEdge(pf1, pf2) -vf2 = geompy.MakeEdge(pf2, pf3) -vf3 = geompy.MakeEdge(pf3, pf4) - -faceFlanc = MakeFace([vf1,vf2,vf3,aShape]) - -flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc) -flanc2 = geompy.MakeCopy(flanc1) -flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.) -flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.) - -# ---- constitution et decoupe des blocs -boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p) - -blocs = [] -for dec in fondec2: - blocs.append(geompy.MakeBoolean(boxfond2, dec, 1)) - -blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1)) -blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1)) -blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1)) -blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1)) -blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1)) -blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1)) -blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1)) -blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1)) -blocs.append(bcong2) -blocs.append(bcong4) -blocs.append(bcong1) -blocs.append(bcong3) -blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3)) -blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3)) -blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3)) -blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3)) -blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4)) -blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4)) -blocs.append(flanc1) -blocs.append(flanc2) - -compbloc = geompy.MakeCompound(blocs) -idcomp = geompy.addToStudy(compbloc, "compbloc") - -# ---- eliminer les faces en double, solid-->shell - -compshell = geompy.MakeGlueFaces(compbloc,tol3d) -idcomp = geompy.addToStudy(compshell, "compshell") diff --git a/src/SMESH_SWIG/SMESH_fixation_hexa.py b/src/SMESH_SWIG/SMESH_fixation_hexa.py deleted file mode 100644 index b93723979..000000000 --- a/src/SMESH_SWIG/SMESH_fixation_hexa.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Hexahedrization of the geometry generated by the Python script -# SMESH_fixation.py -# Hypothesis and algorithms for the mesh generation are global -# -import salome -import SMESH_fixation - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -compshell = SMESH_fixation.compshell -idcomp = SMESH_fixation.idcomp -geompy = SMESH_fixation.geompy -salome = SMESH_fixation.salome - -print("Analysis of the geometry to be meshed :") -subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) - -print("number of Shells in compshell : ", len(subShellList)) -print("number of Faces in compshell : ", len(subFaceList)) -print("number of Edges in compshell : ", len(subEdgeList)) - -status = geompy.CheckShape(compshell) -print(" check status ", status) - -### ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -# ---- init a Mesh with the compshell -shape_mesh = salome.IDToObject( idcomp ) - -mesh = smesh.Mesh(shape_mesh, "MeshCompShell") - - -# ---- set Hypothesis and Algorithm - -print("-------------------------- NumberOfSegments") - -numberOfSegments = 5 - -regular1D = mesh.Segment() -regular1D.SetName("Wire Discretisation") -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -print("-------------------------- Quadrangle_2D") - -quad2D = mesh.Quadrangle() -quad2D.SetName("Quadrangle_2D") - -print("-------------------------- Hexa_3D") - -hexa3D = mesh.Hexahedron() -hexa3D.SetName("Hexa_3D") - -print("-------------------------- compute compshell") -ret = mesh.Compute() -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the MeshcompShel:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of quadrangles : ", mesh.NbQuadrangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of hexahedrons : ", mesh.NbHexas()) -else: - print("problem when Computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_fixation_netgen.py b/src/SMESH_SWIG/SMESH_fixation_netgen.py deleted file mode 100644 index ea850a933..000000000 --- a/src/SMESH_SWIG/SMESH_fixation_netgen.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of the geometry generated by the Python script -# SMESH_fixation.py -# The new Netgen algorithm is used that discretizes baoundaries itself -# -import salome -import SMESH_fixation - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -compshell = SMESH_fixation.compshell -idcomp = SMESH_fixation.idcomp -geompy = SMESH_fixation.geompy -salome = SMESH_fixation.salome - -print("Analysis of the geometry to be meshed :") -subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) - -print("number of Shells in compshell : ", len(subShellList)) -print("number of Faces in compshell : ", len(subFaceList)) -print("number of Edges in compshell : ", len(subEdgeList)) - -status = geompy.CheckShape(compshell) -print(" check status ", status) - -### ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -print("-------------------------- create Mesh, algorithm, hypothesis") - -mesh = smesh.Mesh(compshell, "MeshcompShel"); -netgen = mesh.Tetrahedron(smeshBuilder.FULL_NETGEN) -netgen.SetMaxSize( 50 ) -#netgen.SetSecondOrder( 0 ) -netgen.SetFineness( smeshBuilder.Fine ) -#netgen.SetOptimize( 1 ) - -print("-------------------------- compute mesh") -ret = mesh.Compute() -print(ret) -if ret != 0: - print("Information about the MeshcompShel:") - print("Number of nodes : ", mesh.GetMesh().NbNodes()) - print("Number of edges : ", mesh.GetMesh().NbEdges()) - print("Number of faces : ", mesh.GetMesh().NbFaces()) - print("Number of triangles : ", mesh.GetMesh().NbTriangles()) - print("Number of volumes : ", mesh.GetMesh().NbVolumes()) - print("Number of tetrahedrons : ", mesh.GetMesh().NbTetras()) - -else: - print("problem when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_fixation_tetra.py b/src/SMESH_SWIG/SMESH_fixation_tetra.py deleted file mode 100644 index 32f8143a5..000000000 --- a/src/SMESH_SWIG/SMESH_fixation_tetra.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Tetrahedrization of the geometry generated by the Python script -# SMESH_fixation.py -# Hypothesis and algorithms for the mesh generation are global -# -import salome -import SMESH_fixation - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -compshell = SMESH_fixation.compshell -idcomp = SMESH_fixation.idcomp -geompy = SMESH_fixation.geompy -salome = SMESH_fixation.salome - -print("Analysis of the geometry to be meshed :") -subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) - -print("number of Shells in compshell : ", len(subShellList)) -print("number of Faces in compshell : ", len(subFaceList)) -print("number of Edges in compshell : ", len(subEdgeList)) - -status = geompy.CheckShape(compshell) -print(" check status ", status) - -### ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -# ---- init a Mesh with the compshell - -mesh = smesh.Mesh(compshell, "MeshcompShell") - - -# ---- set Hypothesis and Algorithm - -print("-------------------------- NumberOfSegments") - -numberOfSegments = 5 - -regular1D = mesh.Segment() -regular1D.SetName("Wire Discretisation") -hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) - -## print "-------------------------- MaxElementArea" - -## maxElementArea = 80 - -## mefisto2D = mesh.Triangle() -## mefisto2D.SetName("MEFISTO_2D") -## hypArea = mefisto2D.MaxElementArea(maxElementArea) -## print hypArea.GetName() -## print hypArea.GetId() -## print hypArea.GetMaxElementArea() -## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - -print("-------------------------- LengthFromEdges") - -mefisto2D = mesh.Triangle() -mefisto2D.SetName("MEFISTO_2D") -hypLengthFromEdges = mefisto2D.LengthFromEdges() -print(hypLengthFromEdges.GetName()) -print(hypLengthFromEdges.GetId()) -smesh.SetName(hypLengthFromEdges, "LengthFromEdges") - - -print("-------------------------- MaxElementVolume") - -maxElementVolume = 1000 - -netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) -netgen3D.SetName("NETGEN_3D") -hypVolume = netgen3D.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) - -print("-------------------------- compute compshell") -ret = mesh.Compute(mesh) -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the MeshcompShel:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons : ", mesh.NbTetras()) - -else: - print("problem when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_flight_skin.py b/src/SMESH_SWIG/SMESH_flight_skin.py deleted file mode 100644 index bfbd5d387..000000000 --- a/src/SMESH_SWIG/SMESH_flight_skin.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Triangulation of the skin of the geometry from a Brep representing a plane -# Hypothesis and algorithms for the mesh generation are global -# -import os -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -# ---------------------------- GEOM -------------------------------------- - -# import a BRep -#before running this script, please be sure about -#the path the file fileName - -filePath = os.environ["DATA_DIR"] -filePath = filePath + "/Shapes/Brep/" - -filename = "flight_solid.brep" -filename = filePath + filename - -shape = geompy.Import(filename, "BREP") -idShape = geompy.addToStudy(shape, "flight") - -print("Analysis of the geometry flight :") -subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"]) - -print("number of Shells in flight : ", len(subShellList)) -print("number of Faces in flight : ", len(subFaceList)) -print("number of Edges in flight : ", len(subEdgeList)) - - -### ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -# ---- init a Mesh with the shell -shape_mesh = salome.IDToObject( idShape ) - -mesh = smesh.Mesh(shape_mesh, "MeshFlight") - - -# ---- set Hypothesis and Algorithm - -print("-------------------------- LocalLength") - -lengthOfSegments = 0.3 - -regular1D = mesh.Segment() -hypLength = regular1D.LocalLength(lengthOfSegments) -print(hypLength.GetName()) -print(hypLength.GetId()) -print(hypLength.GetLength()) -smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments)) - -print("-------------------------- LengthFromEdges") - -mefisto2D = mesh.Triangle() -hypLengthFromEdge = mefisto2D.LengthFromEdges() -print(hypLengthFromEdge.GetName()) -print(hypLengthFromEdge.GetId()) -smesh.SetName(hypLengthFromEdge,"LengthFromEdge") - -print("-------------------------- compute the skin flight") -ret = mesh.Compute() -print(ret) -if ret != 0: - log = mesh.GetLog(0) # no erase trace - # for linelog in log: - # print(linelog) - print("Information about the Mesh_mechanic_tetra:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of volumes : ", mesh.NbVolumes()) -else: - print("probleme when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_freebord.py b/src/SMESH_SWIG/SMESH_freebord.py deleted file mode 100644 index 24a19df01..000000000 --- a/src/SMESH_SWIG/SMESH_freebord.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -# Create box without one plane - -box = geompy.MakeBox(0., 0., 0., 10., 20., 30.) -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) - -FaceList = [] -for i in range( 5 ): - FaceList.append( subShapeList[ i ] ) - -aComp = geompy.MakeCompound( FaceList ) -aBox = geompy.Sew( aComp, 1. ) -idbox = geompy.addToStudy( aBox, "box" ) - -aBox = salome.IDToObject( idbox ) - -# Create mesh -smesh.UpdateStudy() - -mesh = smesh.Mesh(aBox, "Mesh_freebord") - -algoReg = mesh.Segment() -hypNbSeg = algoReg.NumberOfSegments(5) - -algoMef = mesh.Triangle() -hypArea = algoMef.MaxElementArea(20) - - -mesh.Compute() - - -# Criterion : Free edges. Create group. - -aCriterion = smesh.GetCriterion(SMESH.EDGE, SMESH.FT_FreeEdges) - -aGroup = mesh.MakeGroupByCriterion("Free edges", aCriterion) - -anIds = aGroup.GetIDs() - -# print result -print("Criterion: Free edges Nb = ", len( anIds )) -for i in range( len( anIds ) ): - print(anIds[ i ]) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_hexaedre.py b/src/SMESH_SWIG/SMESH_hexaedre.py deleted file mode 100644 index 1eecb94a7..000000000 --- a/src/SMESH_SWIG/SMESH_hexaedre.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ----------------------------------------------------------------------------- - -p0 = geompy.MakeVertex(0., 0., 0.) -px = geompy.MakeVertex(100., 0., 0.) -py = geompy.MakeVertex(0., 100., 0.) -pz = geompy.MakeVertex(0., 0., 100.) -vx = geompy.MakeVector(p0, px) -vy = geompy.MakeVector(p0, py) -vz = geompy.MakeVector(p0, pz) - -sphereExt = geompy.MakeSphere( 0., 0., 0., 400.) -sphereInt = geompy.MakeSphere( 0.,-50., 0., 350.) -sphereA = geompy.MakeSphere( -400., 50., 50., 400.) -sphereB = geompy.MakeSphere( 350.,-50.,-50., 350.) -ptcyle = geompy.MakeVertex(0., -300., -450.) -cylindre = geompy.MakeCylinder(ptcyle,vz,500.,900.) - -vol1=geompy.MakeCut(sphereExt,sphereA) -vol2=geompy.MakeCut(vol1,sphereB) -vol3=geompy.MakeCut(vol2,cylindre) -blob=geompy.MakeCut(vol3,sphereInt) -blob=geompy.RemoveExtraEdges(blob) - -idblob = geompy.addToStudy(blob,"blob") - -edgeGroups = geompy.Propagate( blob ) -assert len( edgeGroups ) == 3 - -salome.sg.updateObjBrowser() - -# ----------------------------------------------------------------------------- - -print("-------------------------- mesh") -smesh.UpdateStudy() - -# ---- define a mesh on the geom shape 'blob' -mesh=smesh.Mesh(blob, "MeshBlob") - -# ---- assign global hypothesis and algorithms to mesh -print("-------------------------- add hypothesis to mesh") -algo1 = mesh.Segment() -algo2 = mesh.Quadrangle() -algo3 = mesh.Hexahedron() - -# ---- assign local hypothesis and algorithms to mesh -for edges in edgeGroups: # loop on groups of logically parallel edges - length = geompy.BasicProperties( edges )[0] - if length < 500: nbSeg = 4 - elif length < 2000: nbSeg = 10 - else: nbSeg = 15 - algo = mesh.Segment( edges ) - algo.NumberOfSegments( nbSeg ) - pass - -# ---- compute mesh -print("-------------------------- compute mesh") -ok = mesh.Compute() -if ok: - print("Information about the Mesh:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of quadrangles : ", mesh.NbQuadrangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of hexahedrons : ", mesh.NbHexas()) -else: - print("problem when Computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_mechanic.py b/src/SMESH_SWIG/SMESH_mechanic.py deleted file mode 100644 index 0b2974282..000000000 --- a/src/SMESH_SWIG/SMESH_mechanic.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_withHole.py -# Author : Lucien PIGNOLONI -# Module : SMESH -# $Header$ -#------------------------------------------------------------------------- -# -import salome -salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -from salome.StdMeshers import StdMeshersBuilder - -# ---------------------------- GEOM -------------------------------------- - -# ---- define contiguous arcs and segment to define a closed wire -p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) -p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) -p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) -arc1 = geompy.MakeArc( p1, p2, p3 ) - -p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) -seg1 = geompy.MakeVector( p3, p4 ) - -p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) -p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) -arc2 = geompy.MakeArc( p4, p5, p6 ) - -p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) -arc3 = geompy.MakeArc( p6, p7, p1 ) - -# ---- define a closed wire with arcs and segment -List1 = [] -List1.append( arc1 ) -List1.append( seg1 ) -List1.append( arc2 ) -List1.append( arc3 ) - -wire1 = geompy.MakeWire( List1 ) -Id_wire1 = geompy.addToStudy( wire1, "wire1" ) - -# ---- define a planar face with wire -WantPlanarFace = 1 #True -face1 = geompy.MakeFace( wire1, WantPlanarFace ) -Id_face1 = geompy.addToStudy( face1, "face1" ) - -# ---- create a shape by extrusion -pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) -pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) -vz = geompy.MakeVector( pO, pz ) - -prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) -Id_prism1 = geompy.addToStudy( prism1, "prism1" ) - -# ---- create two cylinders -pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) -pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) - -radius = 20.0 -height = 180.0 -cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) - -Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) -Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) - -# ---- cut with cyl1 -shape = geompy.MakeBoolean( prism1, cyl1, 2 ) - -# ---- fuse with cyl2 to obtain the final mechanic piece :) -mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) -Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) - -# ---- explode on faces -SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) - -# ---- add a face sub-shape in study to be meshed different -sub_face1 = SubFaceL[0] -name = geompy.SubShapeName( sub_face1, mechanic ) - -Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face2 = SubFaceL[4] -name = geompy.SubShapeName( sub_face2, mechanic ) - -Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face3 = SubFaceL[5] -name = geompy.SubShapeName( sub_face3, mechanic ) - -Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face4 = SubFaceL[10] -name = geompy.SubShapeName( sub_face4, mechanic ) - -Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) - -# ---------------------------- SMESH -------------------------------------- -smesh.UpdateStudy() - -# -- Init -- -shape_mesh = salome.IDToObject( Id_mechanic ) - -mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic") - -print("-------------------------- NumberOfSegments") - -numberOfSegment = 10 - -algo = mesh.Segment() -hypNbSeg = algo.NumberOfSegments(numberOfSegment) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_10") - -print("-------------------------- MaxElementArea") - -maxElementArea = 25 - -algo = mesh.Triangle() -hypArea25 = algo.MaxElementArea(maxElementArea) -print(hypArea25.GetName()) -print(hypArea25.GetId()) -print(hypArea25.GetMaxElementArea()) -smesh.SetName(hypArea25, "MaxElementArea_25") - -# Create submesh on sub_face1 - sub_face4 -# --------------------------------------- - -# Set 2D algorithm to submesh on sub_face1 -algo = mesh.Quadrangle(sub_face1) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace1") - -# Set 2D algorithm to submesh on sub_face2 -algo = mesh.Quadrangle(sub_face2) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace2") - -# Set 2D algorithm to submesh on sub_face3 -algo = mesh.Quadrangle(sub_face3) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace3") - -# Set 2D algorithm to submesh on sub_face4 -algo = mesh.Quadrangle(sub_face4) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace4") - -print("-------------------------- compute the mesh of the mechanic piece") - -mesh.Compute() - -print("Information about the Mesh_mechanic:") -print("Number of nodes : ", mesh.NbNodes()) -print("Number of edges : ", mesh.NbEdges()) -print("Number of faces : ", mesh.NbFaces()) -print("Number of triangles : ", mesh.NbTriangles()) -print("Number of quadrangles : ", mesh.NbQuadrangles()) -print("Number of volumes : ", mesh.NbVolumes()) -print("Number of tetrahedrons: ", mesh.NbTetras()) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_mechanic_editor.py b/src/SMESH_SWIG/SMESH_mechanic_editor.py deleted file mode 100644 index 5b20b16eb..000000000 --- a/src/SMESH_SWIG/SMESH_mechanic_editor.py +++ /dev/null @@ -1,237 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_withHole.py -# Author : Lucien PIGNOLONI -# Module : SMESH -# $Header$ -#------------------------------------------------------------------------- -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---------------------------- GEOM -------------------------------------- - -# ---- define contiguous arcs and segment to define a closed wire -p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) -p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) -p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) -arc1 = geompy.MakeArc( p1, p2, p3 ) - -p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) -seg1 = geompy.MakeVector( p3, p4 ) - -p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) -p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) -arc2 = geompy.MakeArc( p4, p5, p6 ) - -p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) -arc3 = geompy.MakeArc( p6, p7, p1 ) - -# ---- define a closed wire with arcs and segment -List1 = [] -List1.append( arc1 ) -List1.append( seg1 ) -List1.append( arc2 ) -List1.append( arc3 ) - -wire1 = geompy.MakeWire( List1 ) -Id_wire1 = geompy.addToStudy( wire1, "wire1" ) - -# ---- define a planar face with wire -WantPlanarFace = 1 #True -face1 = geompy.MakeFace( wire1, WantPlanarFace ) -Id_face1 = geompy.addToStudy( face1, "face1" ) - -# ---- create a shape by extrusion -pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) -pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) -vz = geompy.MakeVector( pO, pz ) - -prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) -Id_prism1 = geompy.addToStudy( prism1, "prism1" ) - -# ---- create two cylinders -pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) -pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) - -radius = 20.0 -height = 180.0 -cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) - -Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) -Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) - -# ---- cut with cyl1 -shape = geompy.MakeBoolean( prism1, cyl1, 2 ) - -# ---- fuse with cyl2 to obtain the final mechanic piece :) -mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) -Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) - -# ---- explode on faces -SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) - -# ---- add a face sub-shape in study to be meshed different -sub_face1 = SubFaceL[0] -name = geompy.SubShapeName( sub_face1, mechanic ) - -Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face2 = SubFaceL[4] -name = geompy.SubShapeName( sub_face2, mechanic ) - -Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face3 = SubFaceL[5] -name = geompy.SubShapeName( sub_face3, mechanic ) - -Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) - -# ---- add a face sub-shape in study to be meshed different -sub_face4 = SubFaceL[10] -name = geompy.SubShapeName( sub_face4, mechanic ) - -Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) - -# ---------------------------- SMESH -------------------------------------- - -# -- Init -- -shape_mesh = salome.IDToObject( Id_mechanic ) - -mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic") - -print("-------------------------- NumberOfSegments") - -numberOfSegment = 10 - -algo = mesh.Segment() -hypNbSeg = algo.NumberOfSegments(numberOfSegment) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) - - -print("-------------------------- MaxElementArea") - -maxElementArea = 25 - -algo = mesh.Triangle() -hypArea25 = algo.MaxElementArea(maxElementArea) -print(hypArea25.GetName()) -print(hypArea25.GetId()) -print(hypArea25.GetMaxElementArea()) -smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea)) - - -# Create submesh on sub_face1 - sub_face4 -# --------------------------------------- - -# Set 2D algorithm to submesh on sub_face1 -algo = mesh.Quadrangle(sub_face1) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace1") -submesh1 = algo.GetSubMesh() - -# Set 2D algorithm to submesh on sub_face2 -algo = mesh.Quadrangle(sub_face2) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace2") -submesh2 = algo.GetSubMesh() - -# Set 2D algorithm to submesh on sub_face3 -algo = mesh.Quadrangle(sub_face3) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace3") -submesh3 = algo.GetSubMesh() - -# Set 2D algorithm to submesh on sub_face4 -algo = mesh.Quadrangle(sub_face4) -smesh.SetName(algo.GetSubMesh(), "SubMeshFace4") -submesh4 = algo.GetSubMesh() - - -print("-------------------------- compute the mesh of the mechanic piece") - -mesh.Compute() - -print("Information about the Mesh_mechanic:") -print("Number of nodes : ", mesh.NbNodes()) -print("Number of edges : ", mesh.NbEdges()) -print("Number of faces : ", mesh.NbFaces()) -print("Number of triangles : ", mesh.NbTriangles()) -print("Number of quadrangles : ", mesh.NbQuadrangles()) -print("Number of volumes : ", mesh.NbVolumes()) -print("Number of tetrahedrons: ", mesh.NbTetras()) - - -#1 cutting of quadrangles of the 'SubMeshFace2' submesh -mesh.SplitQuadObject(submesh2, 1) - -#2 cutting of triangles of the group -FacesTriToQuad = [ 2391, 2824, 2825, 2826, 2827, 2828, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2841, 2844, 2845, 2847, 2854, 2861, 2863, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2946, 2951, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985 ] -GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", SMESH.FACE, FacesTriToQuad) -mesh.TriToQuadObject(GroupTriToQuad, SMESH.FT_AspectRatio , 1.57) - -#3 extrusion of the group -point = SMESH.PointStruct(0, 0, 5) -vector = SMESH.DirStruct(point) -mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5) - -#4 mirror object -mesh.Mirror([], SMESH.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0) - -#5 mesh translation -point = SMESH.PointStruct(10, 10, 10) -vector = SMESH.DirStruct(point) -mesh.Translate([], vector, 0) - -#6 mesh rotation -axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10) -angle180 = 180*3.141/180 -mesh.Rotate([], axisXYZ, angle180, 0) - -#7 group smoothing -FacesSmooth = [864, 933, 941, 950, 1005, 1013] -GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", SMESH.FACE, FacesSmooth) -mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH) - -#8 rotation sweep object -FacesRotate = [492, 493, 502, 503] -GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", SMESH.FACE, FacesRotate) -angle45 = 45*3.141/180 -axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632) -mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) - -#9 reorientation of the submesh1 -mesh.ReorientObject(submesh1) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_mechanic_netgen.py b/src/SMESH_SWIG/SMESH_mechanic_netgen.py deleted file mode 100644 index 786eec4ff..000000000 --- a/src/SMESH_SWIG/SMESH_mechanic_netgen.py +++ /dev/null @@ -1,138 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# Quadrangulation of the geometry generated by the Python script -# SMESH_mechanic.py -# The new Netgen algorithm is used that discretizes baoundaries itself -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---------------------------- GEOM -------------------------------------- - -# ---- define contiguous arcs and segment to define a closed wire -p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) -p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) -p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) -arc1 = geompy.MakeArc( p1, p2, p3 ) - -p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) -seg1 = geompy.MakeVector( p3, p4 ) - -p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) -p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) -arc2 = geompy.MakeArc( p4, p5, p6 ) - -p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) -arc3 = geompy.MakeArc( p6, p7, p1 ) - -# ---- define a closed wire with arcs and segment -List1 = [] -List1.append( arc1 ) -List1.append( seg1 ) -List1.append( arc2 ) -List1.append( arc3 ) - -wire1 = geompy.MakeWire( List1 ) -Id_wire1 = geompy.addToStudy( wire1, "wire1" ) - -# ---- define a planar face with wire -WantPlanarFace = 1 #True -face1 = geompy.MakeFace( wire1, WantPlanarFace ) -Id_face1 = geompy.addToStudy( face1, "face1" ) - -# ---- create a shape by extrusion -pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) -pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) -vz = geompy.MakeVector( pO, pz ) - -prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) -Id_prism1 = geompy.addToStudy( prism1, "prism1") - -# ---- create two cylinders - -pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) -pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) -radius = 20.0 -height = 180.0 -cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) - -Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) -Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) - -# ---- cut with cyl1 -shape = geompy.MakeBoolean( prism1, cyl1, 2 ) - -# ---- fuse with cyl2 to obtain the final mechanic piece :) -mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) -Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) - -# ---- Analysis of the geometry - -print("Analysis of the geometry mechanic :") - -subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) - -print("number of Shells in mechanic : ",len(subShellList)) -print("number of Faces in mechanic : ",len(subFaceList)) -print("number of Edges in mechanic : ",len(subEdgeList)) - -### ---------------------------- SMESH -------------------------------------- - -print("-------------------------- create Mesh, algorithm, hypothesis") - -mesh = smesh.Mesh(mechanic, "Mesh_mechanic"); -netgen = mesh.Triangle(smeshBuilder.NETGEN) -netgen.SetMaxSize( 50 ) -#netgen.SetSecondOrder( 0 ) -netgen.SetFineness( smeshBuilder.Fine ) -netgen.SetQuadAllowed( 1 ) -#netgen.SetOptimize( 1 ) - -print("-------------------------- compute mesh") -ret = mesh.Compute() -print(ret) -if ret != 0: - print("Information about the MeshcompShel:") - print("Number of nodes : ", mesh.NbNodes()) - print("Number of edges : ", mesh.NbEdges()) - print("Number of faces : ", mesh.NbFaces()) - print("Number of triangles : ", mesh.NbTriangles()) - print("Number of quadrangles : ", mesh.NbQuadrangles()) - print("Number of volumes : ", mesh.NbVolumes()) - print("Number of tetrahedrons : ", mesh.NbTetras()) - -else: - print("problem when computing the mesh") - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_mechanic_tetra.py b/src/SMESH_SWIG/SMESH_mechanic_tetra.py deleted file mode 100644 index 1e424cbdd..000000000 --- a/src/SMESH_SWIG/SMESH_mechanic_tetra.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_withHole.py -# Author : Lucien PIGNOLONI -# Module : SMESH -# $Header$ -# -import salome -salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---------------------------- GEOM -------------------------------------- - -# ---- define contiguous arcs and segment to define a closed wire -p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) -p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) -p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) -arc1 = geompy.MakeArc( p1, p2, p3 ) - -p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) -seg1 = geompy.MakeVector( p3, p4 ) - -p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) -p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) -arc2 = geompy.MakeArc( p4, p5, p6 ) - -p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) -arc3 = geompy.MakeArc( p6, p7, p1 ) - -# ---- define a closed wire with arcs and segment -List1 = [] -List1.append( arc1 ) -List1.append( seg1 ) -List1.append( arc2 ) -List1.append( arc3 ) - -wire1 = geompy.MakeWire( List1 ) -Id_wire1 = geompy.addToStudy( wire1, "wire1" ) - -# ---- define a planar face with wire -WantPlanarFace = 1 #True -face1 = geompy.MakeFace( wire1, WantPlanarFace ) -Id_face1 = geompy.addToStudy( face1, "face1" ) - -# ---- create a shape by extrusion -pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) -pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) -vz = geompy.MakeVector( pO, pz ) - -prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) -Id_prism1 = geompy.addToStudy( prism1, "prism1") - -# ---- create two cylinders - -pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) -pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) -radius = 20.0 -height = 180.0 -cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) - -Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) -Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) - -# ---- cut with cyl1 -shape = geompy.MakeBoolean( prism1, cyl1, 2 ) - -# ---- fuse with cyl2 to obtain the final mechanic piece :) -mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) -Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) - -# ---- Analysis of the geometry - -print("Analysis of the geometry mechanic :") - -subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) -subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) -subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) - -print("number of Shells in mechanic : ",len(subShellList)) -print("number of Faces in mechanic : ",len(subFaceList)) -print("number of Edges in mechanic : ",len(subEdgeList)) - -### ---------------------------- SMESH -------------------------------------- - -shape_mesh = salome.IDToObject( Id_mechanic ) - -mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic_tetra") - -print("-------------------------- add hypothesis to main mechanic") - -numberOfSegment = 10 - -algo1 = mesh.Segment() -hypNbSeg = algo1.NumberOfSegments(numberOfSegment) -print(hypNbSeg.GetName()) -print(hypNbSeg.GetId()) -print(hypNbSeg.GetNumberOfSegments()) -smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) - - -maxElementArea = 20 - -algo2 = mesh.Triangle(smeshBuilder.MEFISTO) -hypArea = algo2.MaxElementArea(maxElementArea) -print(hypArea.GetName()) -print(hypArea.GetId()) -print(hypArea.GetMaxElementArea()) -smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) - - -maxElementVolume = 20 - -algo3 = mesh.Tetrahedron(smeshBuilder.NETGEN) -hypVolume = algo3.MaxElementVolume(maxElementVolume) -print(hypVolume.GetName()) -print(hypVolume.GetId()) -print(hypVolume.GetMaxElementVolume()) -smesh.SetName(hypVolume, "maxElementVolume_" + str(maxElementVolume)) - - -print("-------------------------- compute the mesh of the mechanic piece") -mesh.Compute() - -print("Information about the Mesh_mechanic_tetra:") -print("Number of nodes : ", mesh.NbNodes()) -print("Number of edges : ", mesh.NbEdges()) -print("Number of faces : ", mesh.NbFaces()) -print("Number of triangles : ", mesh.NbTriangles()) -print("Number of quadrangles: ", mesh.NbQuadrangles()) -print("Number of volumes : ", mesh.NbVolumes()) -print("Number of tetrahedrons: ", mesh.NbTetras()) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_reg.py b/src/SMESH_SWIG/SMESH_reg.py deleted file mode 100644 index b1981f487..000000000 --- a/src/SMESH_SWIG/SMESH_reg.py +++ /dev/null @@ -1,119 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_reg.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -from salome.StdMeshers import StdMeshersBuilder - - -# ---- define a box -print("Define box") -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# ---- add faces of box to study -print("Add faces to study") -idface = [] -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -for f in subShapeList: - name = geompy.SubShapeName(f, box) - print(name) - idface.append( geompy.addToStudyInFather(box, f, name) ) - -# ---- add edges of box to study -print("Add edges to study") -idedge = [] -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) -for f in subShapeList: - name = geompy.SubShapeName(f, box) - print(name) - idedge.append( geompy.addToStudyInFather(box, f, name) ) - -salome.sg.updateObjBrowser() - -# ---- launch SMESH -smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init() -smesh.UpdateStudy() - -# ---- Creating meshes - -box = salome.IDToObject(idbox) -names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ] - - -print("-------------------------- Create ", names[0], " mesh") -mesh = smesh.Mesh(box, names[0]) -algo = mesh.Segment() -hyp = algo.NumberOfSegments(7) -hyp.SetDistrType(0) -smesh.SetName(hyp, "NumberOfSegmentsReg") -algo = mesh.Triangle() -algo.MaxElementArea(2500) - -print("-------------------------- Create ", names[1], " mesh") -mesh = smesh.Mesh(box, names[1]) -algo = mesh.Segment() -hyp = algo.NumberOfSegments(7) -hyp.SetDistrType(1) -hyp.SetScaleFactor(2) -smesh.SetName(hyp, "NumberOfSegmentsScale") -algo = mesh.Triangle() -algo.MaxElementArea(2500) - -print("-------------------------- Create ", names[2], " mesh") -mesh = smesh.Mesh(box,names[2]) -algo = mesh.Segment() -hyp = algo.NumberOfSegments(7) -hyp.SetDistrType(2) -hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] ) -hyp.SetConversionMode(0) -smesh.SetName(hyp, "NumberOfSegmentsTable") -algo = mesh.Triangle() -algo.MaxElementArea(2500) - -print("-------------------------- Create ", names[3], " mesh") -mesh = smesh.Mesh(box, names[3]) -algo = mesh.Segment() -hyp = algo.NumberOfSegments(10) -hyp.SetDistrType(3) -hyp.SetExpressionFunction("sin(3*t)") -hyp.SetConversionMode(1) -smesh.SetName(hyp, "NumberOfSegmentsExpr") -algo = mesh.Triangle() -algo.MaxElementArea(2500) - - -salome.sg.updateObjBrowser() - diff --git a/src/SMESH_SWIG/SMESH_shared_modules.py b/src/SMESH_SWIG/SMESH_shared_modules.py deleted file mode 100644 index c1f3cea99..000000000 --- a/src/SMESH_SWIG/SMESH_shared_modules.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -""" - -""" - -# force SMESH importation at interpreter initialization -# see salome_shared_modules.py -# (avoids incomplete import at run time) - -from launchConfigureParser import verbose - -if verbose(): print("============== import SMESH =======================") - -import SMESH - -# this function is required - -def init_shared_modules(): - """ - This function initializes shared modules that need to be - """ - pass diff --git a/src/SMESH_SWIG/SMESH_test.py b/src/SMESH_SWIG/SMESH_test.py deleted file mode 100644 index c6504e37a..000000000 --- a/src/SMESH_SWIG/SMESH_test.py +++ /dev/null @@ -1,150 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes -# File : SMESH_test.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define a box - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idb = geompy.addToStudy(box, "box") - -# ---- add first face of box in study - -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -idf = geompy.addToStudyInFather(box, face, name) - -# ---- add shell from box in study - -subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -ids = geompy.addToStudyInFather(box, shell, name) - -# ---- add first edge of face in study - -edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) -edge = edgeList[0]; -name = geompy.SubShapeName(edge, face) -ide = geompy.addToStudyInFather(face, edge, name) - -# ---- SMESH - -smesh.UpdateStudy() -box = salome.IDToObject(idb) -mesh = smesh.Mesh(box, "Meshbox") - -print("-------------------------- add hypothesis to box") - -algo_1 = mesh.Segment(box) -hyp = algo_1.LocalLength(100) -print(hyp.GetName()) -print(hyp.GetId()) -print(hyp.GetLength()) - -algo_2 = mesh.Triangle(smeshBuilder.MEFISTO, box) -hyp = algo_2.MaxElementArea(5000) -print(hyp.GetName()) -print(hyp.GetId()) -print(hyp.GetMaxElementArea()) - -smesh.SetName(algo_2.GetSubMesh(), "SubMeshBox") - - -print("-------------------------- add hypothesis to edge") - -edge = salome.IDToObject(ide) - -algo_3 = mesh.Segment(edge) -hyp = algo_3.LocalLength(100) -print(hyp.GetName()) -print(hyp.GetId()) -print(hyp.GetLength()) - -smesh.SetName(algo_3.GetSubMesh(), "SubMeshEdge") - - -print("-------------------------- compute face") - -face = salome.IDToObject(idf) - -ret = mesh.Compute(face) -print(ret) -log = [] #mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after -for a in log: - print("-------") - ii = 0 - ir = 0 - comType = a.commandType - if comType == 0: - for i in range(a.number): - ind = a.indexes[ii] - ii = ii+1 - r1 = a.coords[ir] - ir = ir+1 - r2 = a.coords[ir] - ir = ir+1 - r3 = a.coords[ir] - ir = ir+1 - print("AddNode %i - %g %g %g" % (ind, r1, r2, r3)) - elif comType == 1: - for i in range(a.number): - ind = a.indexes[ii] - ii = ii+1 - i1 = a.indexes[ii] - ii = ii+1 - i2 = a.indexes[ii] - ii = ii+1 - print("AddEdge %i - %i %i" % (ind, i1, i2)) - elif comType == 2: - for i in range(a.number): - ind = a.indexes[ii] - print(ind) - ii = ii+1 - print(ii) - i1 = a.indexes[ii] - ii = ii+1 - i2 = a.indexes[ii] - print(i2) - ii = ii+1 - print("ii", ii) - i3 = a.indexes[ii] - print(i3) - #ii = ii+1 - ii = ii+1 - print("AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_test0.py b/src/SMESH_SWIG/SMESH_test0.py deleted file mode 100644 index 60b05309f..000000000 --- a/src/SMESH_SWIG/SMESH_test0.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test0.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define a box - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# ---- add first face of box in study - -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -print(name) -idface = geompy.addToStudyInFather(box, face, name) - -# ---- add shell from box in study - -subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -print(name) -idshell = geompy.addToStudyInFather(box, shell, name) - -# ---- add first edge of face in study - -edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) -edge = edgeList[0] -name = geompy.SubShapeName(edge, face) -print(name) -idedge = geompy.addToStudyInFather(face, edge, name) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_test1.py b/src/SMESH_SWIG/SMESH_test1.py deleted file mode 100644 index 1f158a694..000000000 --- a/src/SMESH_SWIG/SMESH_test1.py +++ /dev/null @@ -1,113 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test1.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define a box - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# ---- add first face of box in study - -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -print(name) -idface = geompy.addToStudyInFather(box, face, name) - -# ---- add shell from box in study - -subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -print(name) -idshell = geompy.addToStudyInFather(box, shell, name) - -# ---- add first edge of face in study - -edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) -edge = edgeList[0] -name = geompy.SubShapeName(edge, face) -print(name) -idedge = geompy.addToStudyInFather(face, edge, name) - - -# ---- SMESH - -# ---- Init a Mesh with the box - -mesh = smesh.Mesh(box, "Meshbox") - -print("-------------------------- add hypothesis to box") -algoReg1 = mesh.Segment() -hypNbSeg1 = algoReg1.NumberOfSegments(7) -print(hypNbSeg1.GetName()) -print(hypNbSeg1.GetId()) -print(hypNbSeg1.GetNumberOfSegments()) -smesh.SetName(hypNbSeg1, "NumberOfSegments_7") - -algoMef1 = mesh.Triangle() -hypArea1 = algoMef1.MaxElementArea(2500) -print(hypArea1.GetName()) -print(hypArea1.GetId()) -print(hypArea1.GetMaxElementArea()) -smesh.SetName(hypArea1, "MaxElementArea_2500") - -# ---- add hypothesis to edge -print("-------------------------- add hypothesis to edge") -edge = salome.IDToObject(idedge) - -algoReg2 = mesh.Segment(edge) -hypLen1 = algoReg2.LocalLength(100) -smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge") -print(hypLen1.GetName()) -print(hypLen1.GetId()) -print(hypLen1.GetLength()) -smesh.SetName(hypLen1, "Local_Length_100") - -# ---- add hypothesis to face -print("-------------------------- add hypothesis to face") -face = salome.IDToObject(idface) - -algoMef2 = mesh.Triangle(face) -hypArea2 = algoMef2.MaxElementArea(500) -smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace") -print(hypArea2.GetName()) -print(hypArea2.GetId()) -print(hypArea2.GetMaxElementArea()) -smesh.SetName(hypArea2, "MaxElementArea_500") - - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_test1_AndDisplay.py b/src/SMESH_SWIG/SMESH_test1_AndDisplay.py deleted file mode 100644 index 6c53c0a8b..000000000 --- a/src/SMESH_SWIG/SMESH_test1_AndDisplay.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test1.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# ---- define a box - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# ---- add first face of box in study - -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -print(name) -idface = geompy.addToStudyInFather(box, face, name) - -# ---- add shell from box in study - -subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -print(name) -idshell = geompy.addToStudyInFather(box, shell, name) - -# ---- add first edge of face in study - -edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) -edge = edgeList[0] -name = geompy.SubShapeName(edge, face) -print(name) -idedge = geompy.addToStudyInFather(face, edge, name) - - -# ---- SMESH - -# ---- Init a Mesh with the box - -mesh = smesh.Mesh(box, "Meshbox") - -print("-------------------------- add hypothesis to box") -algoReg1 = mesh.Segment() -hypNbSeg1 = algoReg1.NumberOfSegments(7) -print(hypNbSeg1.GetName()) -print(hypNbSeg1.GetId()) -print(hypNbSeg1.GetNumberOfSegments()) -smesh.SetName(hypNbSeg1, "NumberOfSegments_7") - -algoMef1 = mesh.Triangle() -hypArea1 = algoMef1.MaxElementArea(2500) -print(hypArea1.GetName()) -print(hypArea1.GetId()) -print(hypArea1.GetMaxElementArea()) -smesh.SetName(hypArea1, "MaxElementArea_2500") - -# ---- add hypothesis to edge -print("-------------------------- add hypothesis to edge") -edge = salome.IDToObject(idedge) - -algoReg2 = mesh.Segment(edge) -hypLen1 = algoReg2.LocalLength(100) -smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge") -print(hypLen1.GetName()) -print(hypLen1.GetId()) -print(hypLen1.GetLength()) -smesh.SetName(hypLen1, "Local_Length_100") - -# ---- add hypothesis to face -print("-------------------------- add hypothesis to face") -face = salome.IDToObject(idface) - -algoMef2 = mesh.Triangle(face) -hypArea2 = algoMef2.MaxElementArea(500) -smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace") -print(hypArea2.GetName()) -print(hypArea2.GetId()) -print(hypArea2.GetMaxElementArea()) -smesh.SetName(hypArea2, "MaxElementArea_500") - -mesh.Compute() - -salome.sg.updateObjBrowser() - -sg = salome.ImportComponentGUI('SMESH') -if not isinstance(sg, type(salome.salome_ComponentGUI)): - sg.CreateAndDisplayActor('0:1:2:3') diff --git a/src/SMESH_SWIG/SMESH_test2.py b/src/SMESH_SWIG/SMESH_test2.py deleted file mode 100644 index 562519ca0..000000000 --- a/src/SMESH_SWIG/SMESH_test2.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test2.py -# Module : SMESH -# -from SMESH_test1 import * - -# ---- compute box - -print("-------------------------- compute box") -ret = mesh.Compute() -print(ret) -log = mesh.GetLog(0); # no erase trace -# for linelog in log: -# print(linelog) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_test3.py b/src/SMESH_SWIG/SMESH_test3.py deleted file mode 100644 index edfbe6ec0..000000000 --- a/src/SMESH_SWIG/SMESH_test3.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test3.py -# Module : SMESH -#import salome -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import math - -pi = math.pi - -# --------------------------------------------- -xa = math.sin(pi/12) -ya = 0 -za = math.cos(pi/12) - -xb = 0 -yb = math.sin(pi/18) -zb = math.cos(pi/18) - -xc = math.cos(-pi/18) -yc = 0 -zc = math.sin(-pi/18) - -rc1 = 150 -rc2 = 150 -rc3 = 150 -rc4 = 300 - -hc1 = 300 -hc2 = 2*hc1 -hc3 = 2*hc1 -hc4 = 2*hc1 - -# --------------------------------------------- -point_0 = geompy.MakeVertex(0, 0, 0) -point_z = geompy.MakeVertex(0, 0, 1) - -point_a = geompy.MakeVertex(xa, ya, za) -point_b = geompy.MakeVertex(xb, yb, zb) -point_c = geompy.MakeVertex(xc, yc, zc) - -dir_z = geompy.MakeVector(point_0, point_z) -dir_a = geompy.MakeVector(point_0, point_a) -dir_b = geompy.MakeVector(point_0, point_b) -dir_c = geompy.MakeVector(point_0, point_c) - -axe_z = dir_z -axe_a = dir_a -axe_b = dir_b -axe_c = dir_c - -cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1) - -cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2) -cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1) - -cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3) -cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1) - -cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4) -cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2) -cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0) -cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4) - -inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common - -blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut -blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2) - -blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common - -idblob = geompy.addToStudy(blob,"blob") -#idc = geompy.addToStudy(cyl_c,"cyl_c") -#idd = geompy.addToStudy(cyl_d,"cyl_d") diff --git a/src/SMESH_SWIG/SMESH_test4.py b/src/SMESH_SWIG/SMESH_test4.py deleted file mode 100644 index 1fd277308..000000000 --- a/src/SMESH_SWIG/SMESH_test4.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - - -# ---- GEOM - -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -name = geompy.SubShapeName(face, box) -idface = geompy.addToStudyInFather(box, face, name) - -box = salome.IDToObject(idbox) -face = salome.IDToObject(idface) - -# ---- SMESH - -smesh.UpdateStudy() -mesh = smesh.Mesh(box, "Meshbox") - -# Set 1D algorithm/hypotheses to mesh -algo1 = mesh.Segment() -algo1.NumberOfSegments(10) - -# Set 2D algorithm/hypotheses to mesh -algo2 = mesh.Triangle(smeshBuilder.MEFISTO) -algo2.MaxElementArea(10) - -# Create submesh on face -algo3 = mesh.Segment(face) -algo3.NumberOfSegments(10) -algo4 = mesh.Triangle(smeshBuilder.MEFISTO, face) -algo4.MaxElementArea(100) -submesh = algo4.GetSubMesh() -smesh.SetName(submesh, "SubMeshFace") - - -mesh.Compute() - -faces = submesh.GetElementsByType(SMESH.FACE) -if len(faces) > 1: - print(len(faces), len(faces)/2) - group1 = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces") - group2 = mesh.CreateEmptyGroup(SMESH.FACE,"Another group of faces") - group1.Add(faces[:int(len(faces)/2)]) - group2.Add(faces[int(len(faces)/2):]) - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/SMESH_test5.py b/src/SMESH_SWIG/SMESH_test5.py deleted file mode 100644 index ca49d2c64..000000000 --- a/src/SMESH_SWIG/SMESH_test5.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# File : SMESH_test5.py -# Module : SMESH -# -import salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import CORBA -import os -import os.path - -def SetSObjName(theSObj,theName) : - ok, anAttr = theSObj.FindAttribute("AttributeName") - if ok: - aName = anAttr._narrow(SALOMEDS.AttributeName) - #print aName.__dict__ - aName.SetValue(theName) - -def ConvertMED2UNV(thePath,theFile) : - anInitFileName = thePath + theFile - aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName) - print(aResult, aMeshes) - - for iMesh in range(len(aMeshes)) : - aMesh = aMeshes[iMesh] - print(aMesh.GetName(), end=' ') - aFileName = anInitFileName - aFileName = os.path.basename(aFileName) - aMesh.SetName(aFileName) - print(aMesh.GetName()) - - aOutPath = '/tmp/' - aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv" - aMesh.ExportUNV(aFileName) - aMesh = smesh.CreateMeshesFromUNV(aFileName) - print(aMesh.GetName(), end=' ') - os.remove(aFileName) - aFileName = os.path.basename(aFileName) - aMesh.SetName(aFileName) - print(aMesh.GetName()) - -aPath = os.getenv('DATA_DIR') + '/MedFiles/' -aListDir = os.listdir(aPath) -print(aListDir) - -for iFile in range(len(aListDir)) : - aFileName = aListDir[iFile] - aName,anExt = os.path.splitext(aFileName) - if anExt == ".med" : - aFileName = os.path.basename(aFileName) - print(aFileName) - ConvertMED2UNV(aPath,aFileName) - #break - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/YACS_geomesh0.py b/src/SMESH_SWIG/YACS_geomesh0.py deleted file mode 100644 index 05a235acb..000000000 --- a/src/SMESH_SWIG/YACS_geomesh0.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2018-2021 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, 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 -# - -# test used in YACS, ForEachLoop - -def geomesh(l0, r0, h0, d0, d1, my_container, direc): - print("Géometrie et maillage barre : (l0, r0, h0, d0, d1)=", (l0, r0, h0, d0, d1)) - - import sys - import salome - salome.salome_init() - import GEOM - from salome.geom import geomBuilder - import math - import os - import SALOMEDS - import SMESH - from salome.smesh import smeshBuilder - - my_container.load_component_Library("GEOM") - #engineGeom = my_container.create_component_instance("GEOM") - engineGeom = my_container.load_impl("GEOM","") - geompy = geomBuilder.New(engineGeom) - my_container.load_component_Library("SMESH") - #engineSmesh = my_container.create_component_instance("SMESH") - engineSmesh = my_container.load_impl("SMESH","") - smesh = smeshBuilder.New(engineSmesh,engineGeom) - print("instances Names:", engineGeom.instanceName, engineSmesh.instanceName) - print("instances:", engineGeom, engineSmesh) - print("builders:", geompy, smesh) - - volume = (2.*l0*r0 + 0.75*math.pi*r0*r0)*h0 - 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(-l0, -r0, 0) - Vertex_2 = geompy.MakeVertex(-l0-r0, 0, 0) - Vertex_3 = geompy.MakeVertex(-l0, r0, 0) - Vertex_4 = geompy.MakeVertex(l0, r0, 0) - Vertex_5 = geompy.MakeVertex(l0+r0, 0, 0) - Vertex_6 = geompy.MakeVertex(l0, -r0, 0) - Arc_1 = geompy.MakeArc(Vertex_1, Vertex_2, Vertex_3) - Arc_2 = geompy.MakeArc(Vertex_4, Vertex_5, Vertex_6) - Line_1 = geompy.MakeLineTwoPnt(Vertex_3, Vertex_4) - Line_2 = geompy.MakeLineTwoPnt(Vertex_6, Vertex_1) - Face_1 = geompy.MakeFaceWires([Arc_1, Arc_2, Line_1, Line_2], 1) - barre0 = geompy.MakePrismVecH(Face_1, OZ, h0) - Vertex_1a = geompy.MakeVertex(-l0, -r0/2, 0) - Vertex_2a = geompy.MakeVertex(-l0-r0/2, 0, 0) - Vertex_3a = geompy.MakeVertex(-l0, r0/2, 0) - Vertex_4a = geompy.MakeVertex(l0, r0/2, 0) - Vertex_5a = geompy.MakeVertex(l0+r0/2, 0, 0) - Vertex_6a = geompy.MakeVertex(l0, -r0/2, 0) - Arc_1a = geompy.MakeArc(Vertex_1a, Vertex_2a, Vertex_3a) - Arc_2a = geompy.MakeArc(Vertex_4a, Vertex_5a, Vertex_6a) - Line_1a = geompy.MakeLineTwoPnt(Vertex_3a, Vertex_4a) - Line_2a = geompy.MakeLineTwoPnt(Vertex_6a, Vertex_1a) - Face_1a = geompy.MakeFaceWires([Arc_1a, Arc_2a, Line_1a, Line_2a], 1) - barrea = geompy.MakePrismVecH(Face_1a, OZ, h0) - barreb = geompy.MakeCut(barre0, barrea) - Plane_1 = geompy.MakePlane(Vertex_1, OX, 2000) - Plane_2 = geompy.MakePlane(Vertex_6, OX, 2000) - barre = geompy.MakePartition([barreb], [Plane_1, Plane_2], [], [], geompy.ShapeType["SOLID"], 0, [], 0) - v1 = geompy.MakeVertex(-l0-r0, 0, h0/2.) - v2 = geompy.MakeVertex(l0+r0, 0, h0/2.) - f1 = geompy.GetShapesNearPoint(barre, v1, geompy.ShapeType["FACE"]) - f2 = geompy.GetShapesNearPoint(barre, v2, geompy.ShapeType["FACE"]) - #f1 = geompy.CreateGroup(barre, geompy.ShapeType["FACE"]) - #geompy.UnionIDs(f1, [3]) - #f2 = geompy.CreateGroup(barre, geompy.ShapeType["FACE"]) - #geompy.UnionIDs(f2, [20]) - - Auto_group_for_Sub_mesh_1 = geompy.CreateGroup(barre, geompy.ShapeType["FACE"]) - geompy.UnionList(Auto_group_for_Sub_mesh_1, [f1, f2]) - nom = r'barre_l_{:03d}__r_{:05.2f}__h_{:05.2f}__d0_{:05.2f}__d1_{:05.2f}'.format(int(l0), r0, h0, d0, d1) - nombrep = nom + ".brep" - geompy.ExportBREP(barre, direc + os.sep + nombrep ) - props = geompy.BasicProperties(barre) - geomvol = props[2] - - #geompy.addToStudy( barre, 'barre' ) - #geompy.addToStudyInFather( barre, f1, 'f1' ) - #geompy.addToStudyInFather( barre, f2, 'f2' ) - - smesh.SetEnablePublish( False ) - - isTetra = False - barre_1 = smesh.Mesh(barre) - # SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(barre_1.GetMesh())) - # if SO: - # print ("_______",SO.GetID(),SO.GetName()) - # else: - # print ("_______NO_SO!!!") - if (isTetra): - NETGEN_1D_2D_3D = barre_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D) - NETGEN_3D_Parameters_1 = NETGEN_1D_2D_3D.Parameters() - NETGEN_3D_Parameters_1.SetMaxSize( d0 ) - NETGEN_3D_Parameters_1.SetSecondOrder( 0 ) - NETGEN_3D_Parameters_1.SetOptimize( 1 ) - NETGEN_3D_Parameters_1.SetFineness( 3 ) - NETGEN_3D_Parameters_1.SetChordalError( 0.1 ) - NETGEN_3D_Parameters_1.SetChordalErrorEnabled( 0 ) - NETGEN_3D_Parameters_1.SetMinSize( d0 ) - NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 ) - NETGEN_3D_Parameters_1.SetFuseEdges( 1 ) - NETGEN_3D_Parameters_1.SetQuadAllowed( 0 ) - NETGEN_1D_2D = barre_1.Triangle(algo=smeshBuilder.NETGEN_1D2D,geom=Auto_group_for_Sub_mesh_1) - NETGEN_2D_Parameters_1 = NETGEN_1D_2D.Parameters() - NETGEN_2D_Parameters_1.SetMaxSize( d1 ) - NETGEN_2D_Parameters_1.SetSecondOrder( 0 ) - NETGEN_2D_Parameters_1.SetOptimize( 1 ) - NETGEN_2D_Parameters_1.SetFineness( 3 ) - NETGEN_2D_Parameters_1.SetChordalError( 0.1 ) - NETGEN_2D_Parameters_1.SetChordalErrorEnabled( 0 ) - NETGEN_2D_Parameters_1.SetMinSize( d1 ) - NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 ) - NETGEN_2D_Parameters_1.SetFuseEdges( 1 ) - NETGEN_2D_Parameters_1.SetQuadAllowed( 0 ) - else: - Regular_1D = barre_1.Segment() - Number_of_Segments_1 = Regular_1D.NumberOfSegments(15) - Quadrangle_2D = barre_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) - Hexa_3D = barre_1.Hexahedron(algo=smeshBuilder.Hexa) - isDone = barre_1.Compute() - - f1_1 = barre_1.GroupOnGeom(f1,'f1',SMESH.FACE) - f2_1 = barre_1.GroupOnGeom(f2,'f2',SMESH.FACE) - smesh.SetName(barre_1, nom) - nommed = nom + ".med" - barre_1.ExportMED( direc + os.sep + nommed, auto_groups=0, minor=0, overwrite=1, meshPart=None, autoDimension=1 ) - measure = smesh.CreateMeasurements() - meshvol = measure.Volume(barre_1.mesh) - print("Maillage publié : ", direc + os.sep + nommed) - clearMesh(barre_1, salome.myStudy, nom) - deltag = abs(geomvol - volume)/volume - deltam = abs(meshvol - geomvol)/geomvol - delta = abs(meshvol - volume)/volume - print("volumes:", volume, geomvol, meshvol, deltag, deltam) - assert(deltag < 1.e-5) - assert(deltam < 2.e-3) - #import time - #time.sleep(30) - return delta - - -def clearMesh(theMesh, theStudy, aName): - theMesh.Clear() - aMesh = theMesh.GetMesh() - aMesh.UnRegister() - # aStudyBuilder = theStudy.NewBuilder() - # SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(aMesh)) - # objects_to_unpublish = [SO] - # refs = theStudy.FindDependances(SO) - # objects_to_unpublish += refs - # for o in objects_to_unpublish: - # if o is not None: - # aStudyBuilder.RemoveObjectWithChildren(o) - print("clearMesh done:", aName) - -def genere(r0, h0, my_container, direc): - l0 = 50.0 - d0 = min(r0/2., h0/6.) - d1 = d0/2. - res = geomesh(l0, r0, h0, d0, d1, my_container, direc) - return res - -def genere2(r0h0, my_container, direc): - l0 = 50.0 - r0 = r0h0[0] - h0 = r0h0[1] - d0 = min(r0/2., h0/6.) - d1 = d0/2. - res = geomesh(l0, r0, h0, d0, d1, my_container, direc) - return res diff --git a/src/SMESH_SWIG/ex00_all.py b/src/SMESH_SWIG/ex00_all.py deleted file mode 100644 index ccbdf2de9..000000000 --- a/src/SMESH_SWIG/ex00_all.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 -# - -# ================================== -# Load all examples -# ----------------- -# -import ex01_cube2build -import ex02_cube2primitive -import ex03_cube2partition -import ex04_cube5tetraHexa -import ex05_hole1build -import ex06_hole1boolean -import ex07_hole1partition -import ex08_hole2build -import ex09_grid4build -import ex10_grid4geometry -import ex11_grid3partition -import ex12_grid17partition -import ex13_hole1partial -import ex14_cyl1holed -import ex15_cyl2geometry -import ex16_cyl2complementary -import ex17_dome1 -import ex18_dome2 -import ex19_sphereINcube diff --git a/src/SMESH_SWIG/ex01_cube2build.py b/src/SMESH_SWIG/ex01_cube2build.py deleted file mode 100644 index ba1098e82..000000000 --- a/src/SMESH_SWIG/ex01_cube2build.py +++ /dev/null @@ -1,326 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# Geometry -# ======== - -# A small cube centered and put on a great cube build by points, edges, faces and solids - -# Points -# ------ - -greatPoint111 = geompy.MakeVertex( 0, 0, 0) -greatPoint211 = geompy.MakeVertex(10, 0, 0) -greatPoint311 = geompy.MakeVertex(20, 0, 0) -greatPoint411 = geompy.MakeVertex(30, 0, 0) - -greatPoint121 = geompy.MakeVertex( 0, 10, 0) -greatPoint221 = geompy.MakeVertex(10, 10, 0) -greatPoint321 = geompy.MakeVertex(20, 10, 0) -greatPoint421 = geompy.MakeVertex(30, 10, 0) - -greatPoint112 = geompy.MakeVertex( 0, 0, 10) -greatPoint212 = geompy.MakeVertex(10, 0, 10) -greatPoint312 = geompy.MakeVertex(20, 0, 10) -greatPoint412 = geompy.MakeVertex(30, 0, 10) - -greatPoint122 = geompy.MakeVertex( 0, 10, 10) -greatPoint222 = geompy.MakeVertex(10, 10, 10) -greatPoint322 = geompy.MakeVertex(20, 10, 10) -greatPoint422 = geompy.MakeVertex(30, 10, 10) - -greatPoint113 = geompy.MakeVertex( 0, 0, 20) -greatPoint213 = geompy.MakeVertex(10, 0, 20) -greatPoint313 = geompy.MakeVertex(20, 0, 20) -greatPoint413 = geompy.MakeVertex(30, 0, 20) - -greatPoint123 = geompy.MakeVertex( 0, 10, 20) -greatPoint223 = geompy.MakeVertex(10, 10, 20) -greatPoint323 = geompy.MakeVertex(20, 10, 20) -greatPoint423 = geompy.MakeVertex(30, 10, 20) - -greatPoint114 = geompy.MakeVertex( 0, 0, 30) -greatPoint214 = geompy.MakeVertex(10, 0, 30) -greatPoint314 = geompy.MakeVertex(20, 0, 30) -greatPoint414 = geompy.MakeVertex(30, 0, 30) - -greatPoint124 = geompy.MakeVertex( 0, 10, 30) -greatPoint224 = geompy.MakeVertex(10, 10, 30) -greatPoint324 = geompy.MakeVertex(20, 10, 30) -greatPoint424 = geompy.MakeVertex(30, 10, 30) - - -smallPoint111 = greatPoint222 -smallPoint211 = greatPoint322 -smallPoint121 = geompy.MakeVertex(10, 20, 10) -smallPoint221 = geompy.MakeVertex(20, 20, 10) - -smallPoint112 = greatPoint223 -smallPoint212 = greatPoint323 -smallPoint122 = geompy.MakeVertex(10, 20, 20) -smallPoint222 = geompy.MakeVertex(20, 20, 20) - -# Edges -# ----- - -smallEdgeX11 = geompy.MakeEdge(smallPoint111, smallPoint211) -smallEdgeX21 = geompy.MakeEdge(smallPoint121, smallPoint221) -smallEdgeX12 = geompy.MakeEdge(smallPoint112, smallPoint212) -smallEdgeX22 = geompy.MakeEdge(smallPoint122, smallPoint222) - -smallEdgeY11 = geompy.MakeEdge(smallPoint111, smallPoint121) -smallEdgeY21 = geompy.MakeEdge(smallPoint211, smallPoint221) -smallEdgeY12 = geompy.MakeEdge(smallPoint112, smallPoint122) -smallEdgeY22 = geompy.MakeEdge(smallPoint212, smallPoint222) - -smallEdgeZ11 = geompy.MakeEdge(smallPoint111, smallPoint112) -smallEdgeZ21 = geompy.MakeEdge(smallPoint211, smallPoint212) -smallEdgeZ12 = geompy.MakeEdge(smallPoint121, smallPoint122) -smallEdgeZ22 = geompy.MakeEdge(smallPoint221, smallPoint222) - - -greatEdgeX111 = geompy.MakeEdge(greatPoint111, greatPoint211) -greatEdgeX211 = geompy.MakeEdge(greatPoint211, greatPoint311) -greatEdgeX311 = geompy.MakeEdge(greatPoint311, greatPoint411) -greatEdgeX121 = geompy.MakeEdge(greatPoint121, greatPoint221) -greatEdgeX221 = geompy.MakeEdge(greatPoint221, greatPoint321) -greatEdgeX321 = geompy.MakeEdge(greatPoint321, greatPoint421) - -greatEdgeX112 = geompy.MakeEdge(greatPoint112, greatPoint212) -greatEdgeX212 = geompy.MakeEdge(greatPoint212, greatPoint312) -greatEdgeX312 = geompy.MakeEdge(greatPoint312, greatPoint412) -greatEdgeX122 = geompy.MakeEdge(greatPoint122, greatPoint222) -greatEdgeX222 = smallEdgeX11 -greatEdgeX322 = geompy.MakeEdge(greatPoint322, greatPoint422) - -greatEdgeX113 = geompy.MakeEdge(greatPoint113, greatPoint213) -greatEdgeX213 = geompy.MakeEdge(greatPoint213, greatPoint313) -greatEdgeX313 = geompy.MakeEdge(greatPoint313, greatPoint413) -greatEdgeX123 = geompy.MakeEdge(greatPoint123, greatPoint223) -greatEdgeX223 = smallEdgeX12 -greatEdgeX323 = geompy.MakeEdge(greatPoint323, greatPoint423) - -greatEdgeX114 = geompy.MakeEdge(greatPoint114, greatPoint214) -greatEdgeX214 = geompy.MakeEdge(greatPoint214, greatPoint314) -greatEdgeX314 = geompy.MakeEdge(greatPoint314, greatPoint414) -greatEdgeX124 = geompy.MakeEdge(greatPoint124, greatPoint224) -greatEdgeX224 = geompy.MakeEdge(greatPoint224, greatPoint324) -greatEdgeX324 = geompy.MakeEdge(greatPoint324, greatPoint424) - -greatEdgeY11 = geompy.MakeEdge(greatPoint111, greatPoint121) -greatEdgeY21 = geompy.MakeEdge(greatPoint211, greatPoint221) -greatEdgeY31 = geompy.MakeEdge(greatPoint311, greatPoint321) -greatEdgeY41 = geompy.MakeEdge(greatPoint411, greatPoint421) - -greatEdgeY12 = geompy.MakeEdge(greatPoint112, greatPoint122) -greatEdgeY22 = geompy.MakeEdge(greatPoint212, greatPoint222) -greatEdgeY32 = geompy.MakeEdge(greatPoint312, greatPoint322) -greatEdgeY42 = geompy.MakeEdge(greatPoint412, greatPoint422) - -greatEdgeY13 = geompy.MakeEdge(greatPoint113, greatPoint123) -greatEdgeY23 = geompy.MakeEdge(greatPoint213, greatPoint223) -greatEdgeY33 = geompy.MakeEdge(greatPoint313, greatPoint323) -greatEdgeY43 = geompy.MakeEdge(greatPoint413, greatPoint423) - -greatEdgeY14 = geompy.MakeEdge(greatPoint114, greatPoint124) -greatEdgeY24 = geompy.MakeEdge(greatPoint214, greatPoint224) -greatEdgeY34 = geompy.MakeEdge(greatPoint314, greatPoint324) -greatEdgeY44 = geompy.MakeEdge(greatPoint414, greatPoint424) - -greatEdgeZ111 = geompy.MakeEdge(greatPoint111, greatPoint112) -greatEdgeZ211 = geompy.MakeEdge(greatPoint211, greatPoint212) -greatEdgeZ311 = geompy.MakeEdge(greatPoint311, greatPoint312) -greatEdgeZ411 = geompy.MakeEdge(greatPoint411, greatPoint412) - -greatEdgeZ121 = geompy.MakeEdge(greatPoint121, greatPoint122) -greatEdgeZ221 = geompy.MakeEdge(greatPoint221, greatPoint222) -greatEdgeZ321 = geompy.MakeEdge(greatPoint321, greatPoint322) -greatEdgeZ421 = geompy.MakeEdge(greatPoint421, greatPoint422) - -greatEdgeZ112 = geompy.MakeEdge(greatPoint112, greatPoint113) -greatEdgeZ212 = geompy.MakeEdge(greatPoint212, greatPoint213) -greatEdgeZ312 = geompy.MakeEdge(greatPoint312, greatPoint313) -greatEdgeZ412 = geompy.MakeEdge(greatPoint412, greatPoint413) - -greatEdgeZ122 = geompy.MakeEdge(greatPoint122, greatPoint123) -greatEdgeZ222 = smallEdgeZ11 -greatEdgeZ322 = smallEdgeZ21 -greatEdgeZ422 = geompy.MakeEdge(greatPoint422, greatPoint423) - -greatEdgeZ113 = geompy.MakeEdge(greatPoint113, greatPoint114) -greatEdgeZ213 = geompy.MakeEdge(greatPoint213, greatPoint214) -greatEdgeZ313 = geompy.MakeEdge(greatPoint313, greatPoint314) -greatEdgeZ413 = geompy.MakeEdge(greatPoint413, greatPoint414) - -greatEdgeZ123 = geompy.MakeEdge(greatPoint123, greatPoint124) -greatEdgeZ223 = geompy.MakeEdge(greatPoint223, greatPoint224) -greatEdgeZ323 = geompy.MakeEdge(greatPoint323, greatPoint324) -greatEdgeZ423 = geompy.MakeEdge(greatPoint423, greatPoint424) - -# Faces -# ----- - -smallFaceX1 = geompy.MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12) -smallFaceX2 = geompy.MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22) -smallFaceY1 = geompy.MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21) -smallFaceY2 = geompy.MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22) -smallFaceZ1 = geompy.MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21) -smallFaceZ2 = geompy.MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22) - - -greatFaceX11 = geompy.MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121) -greatFaceX21 = geompy.MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221) -greatFaceX31 = geompy.MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321) -greatFaceX41 = geompy.MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421) - -greatFaceX12 = geompy.MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122) -greatFaceX22 = geompy.MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222) -greatFaceX32 = geompy.MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322) -greatFaceX42 = geompy.MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422) - -greatFaceX13 = geompy.MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123) -greatFaceX23 = geompy.MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223) -greatFaceX33 = geompy.MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323) -greatFaceX43 = geompy.MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423) - -greatFaceY111 = geompy.MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211) -greatFaceY211 = geompy.MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311) -greatFaceY311 = geompy.MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411) -greatFaceY121 = geompy.MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221) -greatFaceY221 = geompy.MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321) -greatFaceY321 = geompy.MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421) - -greatFaceY112 = geompy.MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212) -greatFaceY212 = geompy.MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312) -greatFaceY312 = geompy.MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412) -greatFaceY122 = geompy.MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222) -greatFaceY222 = smallFaceY1 -greatFaceY322 = geompy.MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422) - -greatFaceY113 = geompy.MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213) -greatFaceY213 = geompy.MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313) -greatFaceY313 = geompy.MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413) -greatFaceY123 = geompy.MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223) -greatFaceY223 = geompy.MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323) -greatFaceY323 = geompy.MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423) - -greatFaceZ11 = geompy.MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21) -greatFaceZ21 = geompy.MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31) -greatFaceZ31 = geompy.MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41) - -greatFaceZ12 = geompy.MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22) -greatFaceZ22 = geompy.MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32) -greatFaceZ32 = geompy.MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42) - -greatFaceZ13 = geompy.MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23) -greatFaceZ23 = geompy.MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33) -greatFaceZ33 = geompy.MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43) - -greatFaceZ14 = geompy.MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24) -greatFaceZ24 = geompy.MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34) -greatFaceZ34 = geompy.MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44) - -# Solids -# ------ - -smallBlock = geompy.MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2) - -greatBlock11 = geompy.MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12) -greatBlock21 = geompy.MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22) -greatBlock31 = geompy.MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32) - -greatBlock12 = geompy.MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13) -greatBlock22 = geompy.MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23) -greatBlock32 = geompy.MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33) - -greatBlock13 = geompy.MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14) -greatBlock23 = geompy.MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24) -greatBlock33 = geompy.MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34) - -# Compound -# -------- - -c_l = [] -c_l.append(smallBlock) -c_l.append(greatBlock11) -c_l.append(greatBlock21) -c_l.append(greatBlock31) -c_l.append(greatBlock12) -c_l.append(greatBlock22) -c_l.append(greatBlock32) -c_l.append(greatBlock13) -c_l.append(greatBlock23) -c_l.append(greatBlock33) - -piece = geompy.MakeCompound(c_l) - -# Add in study -# ------------ - -piece_id = geompy.addToStudy(piece, "ex01_cube2build") - -# Meshing -# ======= - -# Create hexahedrical mesh on piece -# --------------------------------- - -hexa = smesh.Mesh(piece, "ex01_cube2build:hexa") - -algo = hexa.Segment() -algo.NumberOfSegments(4) - -hexa.Quadrangle() - -hexa.Hexahedron() - -# Create local hypothesis -# ----------------------- - -algo = hexa.Segment(greatEdgeX111) - -algo.Arithmetic1D(1, 4) - -algo.Propagation() - -# Compute the mesh -# ---------------- - -hexa.Compute() - -# Update object browser -# --------------------- - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/ex02_cube2primitive.py b/src/SMESH_SWIG/ex02_cube2primitive.py deleted file mode 100644 index 627c10c0a..000000000 --- a/src/SMESH_SWIG/ex02_cube2primitive.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# Geometry -# ======== - -# A small cube centered and put on a great cube build by primitive geometric functionalities - -# Values -# ------ - -ox = 0 -oy = 0 -oz = 0 - -arete = 10 - -# Points -# ------ - -blockPoint111 = geompy.MakeVertex(ox , oy, oz) -blockPoint211 = geompy.MakeVertex(ox+arete, oy, oz) -blockPoint112 = geompy.MakeVertex(ox , oy, oz+arete) -blockPoint212 = geompy.MakeVertex(ox+arete, oy, oz+arete) - -# Face and solid -# -------------- - -blockFace1 = geompy.MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) - -blockSolid11 = geompy.MakePrismVecH(blockFace1, geompy.MakeVectorDXDYDZ(0, 1, 0), arete) - -# Translations -# ------------ - -blockSolid21 = geompy.MakeTranslation(blockSolid11, arete, 0, 0) -blockSolid31 = geompy.MakeTranslation(blockSolid21, arete, 0, 0) - -blockSolid12 = geompy.MakeTranslation(blockSolid11, 0, 0, arete) -blockSolid22 = geompy.MakeTranslation(blockSolid12, arete, 0, 0) -blockSolid32 = geompy.MakeTranslation(blockSolid22, arete, 0, 0) - -blockSolid13 = geompy.MakeTranslation(blockSolid12, 0, 0, arete) -blockSolid23 = geompy.MakeTranslation(blockSolid13, arete, 0, 0) -blockSolid33 = geompy.MakeTranslation(blockSolid23, arete, 0, 0) - -blockSolid111 = geompy.MakeTranslation(blockSolid22, 0, arete, 0) - -# Compound and glue -# ----------------- - -c_l = [] -c_l.append(blockSolid11) -c_l.append(blockSolid21) -c_l.append(blockSolid31) -c_l.append(blockSolid12) -c_l.append(blockSolid22) -c_l.append(blockSolid32) -c_l.append(blockSolid13) -c_l.append(blockSolid23) -c_l.append(blockSolid33) -c_l.append(blockSolid111) - -c_cpd = geompy.MakeCompound(c_l) - -piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) - -# Add in study -# ------------ - -piece_id = geompy.addToStudy(piece, "ex02_cube2primitive") - -# Meshing -# ======= - -# Create hexahedrical mesh on piece -# --------------------------------- - -hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa") - -algo = hexa.Segment() -algo.LocalLength(1) - -hexa.Quadrangle() - -hexa.Hexahedron() - -# Compute the mesh -# ---------------- - -hexa.Compute() - -# Update object browser -# --------------------- - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/ex03_cube2partition.py b/src/SMESH_SWIG/ex03_cube2partition.py deleted file mode 100644 index 8f6363908..000000000 --- a/src/SMESH_SWIG/ex03_cube2partition.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# Geometry -# ======== - -# A small cube centered and put on a great cube build with partition - -# Values -# ------ - -g_ox = 0 -g_oy = 0 -g_oz = 0 - -g_arete = 10 - -g_trim = 1000 - -# Points -# ------ - -v_arete2 = g_arete*2 -v_arete3 = g_arete*3 - -v_1 = geompy.MakeVertex(g_ox , g_oy , g_oz ) -v_2 = geompy.MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3) - -v_3 = geompy.MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete ) -v_4 = geompy.MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2) - -# Solids -# ------ - -s_base = geompy.MakeBoxTwoPnt(v_1, v_2) -s_haut = geompy.MakeBoxTwoPnt(v_3, v_4) - -# Partition -# --------- - -p_dir1 = geompy.MakeVectorDXDYDZ(1, 0, 0) -p_dir2 = geompy.MakeVectorDXDYDZ(0, 0, 1) -p_dir3 = geompy.MakeVectorDXDYDZ(0, 1, 0) - -p_tools = [] - -p_tools.append(geompy.MakePlane(v_3, p_dir1, g_trim)) -p_tools.append(geompy.MakePlane(v_4, p_dir1, g_trim)) -p_tools.append(geompy.MakePlane(v_3, p_dir2, g_trim)) -p_tools.append(geompy.MakePlane(v_4, p_dir2, g_trim)) -p_tools.append(geompy.MakePlane(v_3, p_dir3, g_trim)) - -piece = geompy.MakePartition([s_base, s_haut], p_tools, [], [], geompy.ShapeType["SOLID"]) - -# Study -# ----- - -piece_id = geompy.addToStudy(piece, "ex03_cube2partition") - -# Meshing -# ======= - -# Create hexahedrical mesh on piece -# --------------------------------- - -hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa") - -algo = hexa.Segment() -algo.NumberOfSegments(5) - -hexa.Quadrangle() - -hexa.Hexahedron() - -# Compute the mesh -# ---------------- - -hexa.Compute() - -# Update object browser -# --------------------- - -salome.sg.updateObjBrowser() diff --git a/src/SMESH_SWIG/ex04_cube5tetraHexa.py b/src/SMESH_SWIG/ex04_cube5tetraHexa.py deleted file mode 100644 index 83229a5c5..000000000 --- a/src/SMESH_SWIG/ex04_cube5tetraHexa.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 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, 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 salome -salome.salome_init() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -# Geometry -# ======== - -# 5 box with a hexahedral mesh and with 2 box in tetrahedral mesh - -# Values -# ------ - -arete = 100 - -arete0 = 0 -arete1 = arete -arete2 = arete*2 -arete3 = arete*3 - -# Solids -# ------ - -box_tetra1 = geompy.MakeBox(arete0, arete0, 0, arete1, arete1, arete) - -box_ijk1 = geompy.MakeBox(arete1, arete0, 0, arete2, arete1, arete) - -box_hexa = geompy.MakeBox(arete1, arete1, 0, arete2, arete2, arete) - -box_ijk2 = geompy.MakeBox(arete2, arete1, 0, arete3, arete2, arete) - -box_tetra2 = geompy.MakeBox(arete2, arete2, 0, arete3 ,arete3, arete) - -# Piece -# ----- - -piece_cpd = geompy.MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2]) - -piece = geompy.MakeGlueFaces(piece_cpd, 1e-4) - -piece_id = geompy.addToStudy(piece, "ex04_cube5tetraHexa") - -# Meshing -# ======= - -# Create a hexahedral mesh -# ------------------------ - -mixed = smesh.Mesh(piece, "ex04_cube5tetraHexa:mixed") - -algo = mixed.Segment() - -algo.StartEndLength(3, 25) - -mixed.Quadrangle() - -mixed.Hexahedron() - -# Tetrahedral local mesh -# ---------------------- - -def localMesh(b, hyp): - box = geompy.GetInPlace(piece, b) - faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) - - i = 0 - n = len(faces) - while i2: faces1.append(i) + pass +nbf1 = len(faces1) + +# create other two edges and rotate them for creation +# other full circle +n8 = mesh.AddNode(-65,0,0) +n9 = mesh.AddNode(-67.5,0,0) +n10 = mesh.AddNode(-70,0,0) +e8 = mesh.AddEdge([n8,n9]) +e9 = mesh.AddEdge([n9,n10]) +axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0) +mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol) +res = mesh.GetLastCreatedElems() +faces2 = [] +for i in res: + nbn = mesh.GetElemNbNodes(i) + if nbn>2: faces2.append(i) + pass +nbf2 = len(faces2) + +# there are coincident nodes after rotation +# therefore we have to merge nodes +nodes = mesh.FindCoincidentNodes(0.001) +mesh.MergeNodes(nodes) + +nbcircs = 2 +nbrsteps = 24 +nbrs = nbcircs*nbrsteps +dz = nbzsteps*zstep/nbrs + +# create first spiral +oldnodes = [] +newnodes = GetNewNodes(mesh,faces1,oldnodes) +oldnodes = newnodes + +nodes = [] +mesh.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol) +res = mesh.GetLastCreatedElems() + +for i in range(0,nbrs): + volumes = [] + for j in range(0,nbf1): volumes.append(res[i+j*nbrs]) + newnodes = GetNewNodes(mesh,volumes,oldnodes) + for j in newnodes: + xyz = mesh.GetNodeXYZ(j) + mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1)) + pass + oldnodes = newnodes + pass + +# create second spiral +oldnodes = [] +newnodes = GetNewNodes(mesh,faces2,oldnodes) +oldnodes = newnodes + +nodes = [] +mesh.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol) +res = mesh.GetLastCreatedElems() + +for i in range(0,nbrs): + volumes = [] + for j in range(0,nbf2): volumes.append(res[i+j*nbrs]) + newnodes = GetNewNodes(mesh,volumes,oldnodes) + for j in newnodes: + xyz = mesh.GetNodeXYZ(j) + mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1)) + pass + oldnodes = newnodes + pass + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_BelongToGeom.py b/test/SMESH_BelongToGeom.py new file mode 100644 index 000000000..5aee14d00 --- /dev/null +++ b/test/SMESH_BelongToGeom.py @@ -0,0 +1,66 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +from SMESH_test1 import * + +## Old style +def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType): + if theShape != theSubShape: + aName = str(theSubShape) + geompy.addToStudyInFather(theShape,theSubShape,aName) + + theMeshGen.Compute(theMesh,theShape) + + aFilterMgr = theMeshGen.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + + aBelongToGeom = aFilterMgr.CreateBelongToGeom() + aBelongToGeom.SetGeom(theSubShape) + aBelongToGeom.SetElementType(theElemType) + + aFilter.SetPredicate(aBelongToGeom) + aFilterMgr.UnRegister() + return aFilter.GetElementsId(theMesh) + +## Current style +def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType): + if theShape != theSubShape: + aName = str(theSubShape) + geompy.addToStudyInFather(theShape,theSubShape,aName) + + theMesh.Compute() + aFilter = smesh.GetFilter(theElemType, SMESH.FT_BelongToGeom, theSubShape) + return aFilter.GetElementsId(theMesh.GetMesh()) + + +anElemType = SMESH.FACE; +print("anElemType =", anElemType) +#anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType) +anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType) +print("Number of ids = ", len(anIds)) +print("anIds = ", anIds) +## Check old version +#anIds = CheckBelongToGeomFilterOld(smesh,mesh.GetMesh(),box,box,anElemType) +#print "anIds = ", anIds + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_BuildCompound.py b/test/SMESH_BuildCompound.py new file mode 100644 index 000000000..fcd721e06 --- /dev/null +++ b/test/SMESH_BuildCompound.py @@ -0,0 +1,107 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 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, 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 +# + +# File : SMESH_BuildCompound.py +# Author : Alexander KOVALEV +# Module : SMESH +# $Header$ +# ! Please, if you edit this example file, update also +# ! SMESH_SRC/doc/salome/gui/SMESH/input/tui_creating_meshes.doc +# ! as some sequences of symbols from this example are used during +# ! documentation generation to identify certain places of this file +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +## create a bottom box +Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.) + +# get a top face +Psup1=geompy.MakeVertex(100., 100., 50.) +Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1) +# get a bottom face +Pinf1=geompy.MakeVertex(100., 100., 0.) +Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1) + +## create a top box +Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.) + +# get a top face +Psup2=geompy.MakeVertex(150., 150., 100.) +Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2) +# get a bottom face +Pinf2=geompy.MakeVertex(150., 150., 50.) +Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2) + +## Publish in the study +geompy.addToStudy(Box_inf, "Box_inf") +geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup") +geompy.addToStudyInFather(Box_inf, Finf1, "Finf") + +geompy.addToStudy(Box_sup, "Box_sup") +geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup") +geompy.addToStudyInFather(Box_sup, Finf2, "Finf") + + +## create a bottom mesh +Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf") +algo1D_1=Mesh_inf.Segment() +algo1D_1.NumberOfSegments(10) +algo2D_1=Mesh_inf.Quadrangle() +algo3D_1=Mesh_inf.Hexahedron() +Mesh_inf.Compute() + +# create a group on the top face +Gsup1=Mesh_inf.Group(Fsup1, "Sup") +# create a group on the bottom face +Ginf1=Mesh_inf.Group(Finf1, "Inf") + +## create a top mesh +Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup") +algo1D_2=Mesh_sup.Segment() +algo1D_2.NumberOfSegments(5) +algo2D_2=Mesh_sup.Quadrangle() +algo3D_2=Mesh_sup.Hexahedron() +Mesh_sup.Compute() + +# create a group on the top face +Gsup2=Mesh_sup.Group(Fsup2, "Sup") +# create a group on the bottom face +Ginf2=Mesh_sup.Group(Finf2, "Inf") + +## create compounds +# create a compound of two meshes with renaming groups with the same names and +# merging of elements with the given tolerance +Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) +smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems') +# create a compound of two meshes with uniting groups with the same names and +# creating groups of all elements +Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) +smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems') +#end + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_GroupFromGeom.py b/test/SMESH_GroupFromGeom.py new file mode 100644 index 000000000..c73cb7e1f --- /dev/null +++ b/test/SMESH_GroupFromGeom.py @@ -0,0 +1,50 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_GroupFromGeom.py +# Module : SMESH +# +from SMESH_test1 import * + +# Compute the mesh created in SMESH_test1 + +mesh.Compute() + +# Create geometry groups on plane: +aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"]) +geompy.AddObject(aGeomGroup1, 1) + +aGeomGroup2 = geompy.CreateGroup(face , geompy.ShapeType["EDGE"]) + +geompy.AddObject(aGeomGroup2, 3) +geompy.AddObject(aGeomGroup2, 6) +geompy.AddObject(aGeomGroup2, 8) +geompy.AddObject(aGeomGroup2, 10) + +geompy.addToStudy(aGeomGroup1, "Group on Faces") +geompy.addToStudy(aGeomGroup2, "Group on Edges") + +aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) +aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_GroupFromGeom2.py b/test/SMESH_GroupFromGeom2.py new file mode 100644 index 000000000..2911d07a5 --- /dev/null +++ b/test/SMESH_GroupFromGeom2.py @@ -0,0 +1,77 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +#============================================================================== +# Info. +# Bug (from script, bug) : SMESH_GroupFromGeom.py, PAL6945 +# Modified : 25/11/2004 +# Author : Kovaltchuk Alexey +# Project : PAL/SALOME +#============================================================================== +# +from SMESH_test1 import * + + +# Compute the mesh created in SMESH_test1 + +mesh.Compute() + +# Create geometry groups on plane: +aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"]) +geompy.AddObject(aGeomGroup1, 1) + +aGeomGroup2 = geompy.CreateGroup(face , geompy.ShapeType["EDGE"]) + +geompy.AddObject(aGeomGroup2, 3) +geompy.AddObject(aGeomGroup2, 6) +geompy.AddObject(aGeomGroup2, 8) +geompy.AddObject(aGeomGroup2, 10) + +geompy.addToStudy(aGeomGroup1, "Group on Faces") +geompy.addToStudy(aGeomGroup2, "Group on Edges") + +aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) +aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) + +print("Create aGroupOnShell - a group linked to a shell") +aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", SMESH.EDGE) +print("aGroupOnShell type =", aGroupOnShell.GetType()) +print("aGroupOnShell size =", aGroupOnShell.Size()) +print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) + +print(" ") + +print("Modify hypothesis: 100 -> 50") +hypLen1.SetLength(50) +print("Contents of aGroupOnShell changes:") +print("aGroupOnShell size =", aGroupOnShell.Size()) +print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) + +print(" ") + +print("Re-compute mesh, contents of aGroupOnShell changes again:") +mesh.Compute() +print("aGroupOnShell size =", aGroupOnShell.Size()) +print("aGroupOnShell ids :", aGroupOnShell.GetListOfID()) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_GroupLyingOnGeom.py b/test/SMESH_GroupLyingOnGeom.py new file mode 100644 index 000000000..67a060c99 --- /dev/null +++ b/test/SMESH_GroupLyingOnGeom.py @@ -0,0 +1,50 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +def BuildGroupLyingOn(theMesh, theElemType, theName, theShape): + aFilterMgr = smesh.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + + aLyingOnGeom = aFilterMgr.CreateLyingOnGeom() + aLyingOnGeom.SetGeom(theShape) + aLyingOnGeom.SetElementType(theElemType) + + aFilter.SetPredicate(aLyingOnGeom) + anIds = aFilter.GetElementsId(theMesh) + aFilterMgr.UnRegister() + + aGroup = theMesh.CreateGroup(theElemType, theName) + aGroup.Add(anIds) + +#Example +from SMESH_test1 import * + +mesh.Compute() + +# First way +BuildGroupLyingOn(mesh.GetMesh(), SMESH.FACE, "Group of faces lying on edge #1", edge ) + +# Second way +mesh.MakeGroup("Group of faces lying on edge #2", SMESH.FACE, SMESH.FT_LyingOnGeom, edge) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_Nut.py b/test/SMESH_Nut.py new file mode 100644 index 000000000..1f45f16a8 --- /dev/null +++ b/test/SMESH_Nut.py @@ -0,0 +1,161 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +##################################################################### +#Created :17/02/2005 +#Author :MASLOV Eugeny, KOVALTCHUK Alexey +##################################################################### +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import os +import math + +#Sketcher_1 creation +print("Sketcher creation...") +Sketcher_1 = geompy.MakeSketcher("Sketcher:F 100 -57.7:TT 100 57.7:TT 0 115.47:TT -100 57.7:TT -100 -57.7:TT 0 -115.47:WW") +geompy.addToStudy(Sketcher_1, "Sketcher_1") +Face_1 = geompy.MakeFace(Sketcher_1, 1) +geompy.addToStudy(Face_1, "Face_1") + +#Line creation +print("Line creation...") +Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100)) +geompy.addToStudy(Line_1, "Line_1") + +#Prism creation +print("Prism creation...") +Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100) +geompy.addToStudy(Prism_1, "Prism_1") + +#Sketcher_2 creation +print("Sketcher creation...") +Sketcher_2 = geompy.MakeSketcher("Sketcher:F 50 0:TT 80 0:TT 112 13:TT 112 48:TT 80 63:TT 80 90:TT 50 90:WW", [0,0,0, 1,0,0, 0,1,0]) +geompy.addToStudy(Sketcher_2, "Sketcher_2") +Face_2 = geompy.MakeFace(Sketcher_2, 1) +geompy.addToStudy(Face_2, "Face_2") + +#Revolution creation +print("Revolution creation...") +Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi) +geompy.addToStudy(Revolution_1, "Revolution_1") + +#Common applying +print("Common of Revolution and Prism...") +Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1) +geompy.addToStudy(Common_1, "Common_1") + +#Explode Common_1 on edges +CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"]) +for i in range(0, len(CommonExplodedListEdges)): + name = "Edge_"+str(i+1) + geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name) + +#Fillet applying +print("Fillet creation...") +Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5]) +geompy.addToStudy(Fillet_1, "Fillet_1") + +#Chamfer applying +print("Chamfer creation...") +cyl_face = geompy.GetFaceNearPoint( Fillet_1, geompy.MakeVertex( 50, 0, 45 ), theName='cyl_face') +cyl_face_id = geompy.GetSubShapeID( Fillet_1, cyl_face ) +top_face = geompy.GetFaceNearPoint( Fillet_1, geompy.MakeVertex( 60, 0, 90 ), theName='top_face') +top_face_id = geompy.GetSubShapeID( Fillet_1, top_face ) +Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, cyl_face_id, top_face_id, theName='Chamfer_1' ) + +cyl_face = geompy.GetFaceNearPoint( Chamfer_1, geompy.MakeVertex( 80, 0, 85 ), theName='cyl_face') +cyl_face_id = geompy.GetSubShapeID( Chamfer_1, cyl_face ) +top_face = geompy.GetFaceNearPoint( Chamfer_1, geompy.MakeVertex( 65, 0, 90 ), theName='top_face') +top_face_id = geompy.GetSubShapeID( Chamfer_1, top_face ) +Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, cyl_face_id, top_face_id, theName='Chamfer_2' ) + +#Import of the shape from "slots.brep" +print("Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep") +thePath = os.getenv("DATA_DIR") +theFileName = os.path.join( thePath,"Shapes","Brep","slots.brep") +theShapeForCut = geompy.ImportBREP(theFileName) +geompy.addToStudy(theShapeForCut, "slot.brep_1") + +#Cut applying +print("Cut...") +Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2) +Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1") + +#Mesh creation + +# -- Init -- +shape_mesh = salome.IDToObject( Cut_1_ID ) + +mesh = smesh.Mesh(shape_mesh, "Nut") + +#HYPOTHESIS CREATION +print("-------------------------- Average length") +theAverageLength = 5 +algoReg1D = mesh.Segment() +hAvLength = algoReg1D.LocalLength(theAverageLength) +print(hAvLength.GetName()) +print(hAvLength.GetId()) +print(hAvLength.GetLength()) +smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength)) + +print("-------------------------- MaxElementArea") +theMaxElementArea = 20 +algoMef = mesh.Triangle(smeshBuilder.MEFISTO) +hArea = algoMef.MaxElementArea( theMaxElementArea ) +print(hArea.GetName()) +print(hArea.GetId()) +print(hArea.GetMaxElementArea()) +smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea)) + +print("-------------------------- MaxElementVolume") +theMaxElementVolume = 150 +algoNg = mesh.Tetrahedron(smeshBuilder.NETGEN) +hVolume = algoNg.MaxElementVolume( theMaxElementVolume ) +print(hVolume.GetName()) +print(hVolume.GetId()) +print(hVolume.GetMaxElementVolume()) +smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume)) + + +print("-------------------------- compute the mesh of the mechanic piece") +mesh.Compute() + +print("Information about the Nut:") +print("Number of nodes : ", mesh.NbNodes()) +print("Number of edges : ", mesh.NbEdges()) +print("Number of faces : ", mesh.NbFaces()) +print("Number of triangles : ", mesh.NbTriangles()) +print("Number of quadrangles : ", mesh.NbQuadrangles()) +print("Number of volumes : ", mesh.NbVolumes()) +print("Number of tetrahedrons: ", mesh.NbTetras()) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_Partition1_tetra.py b/test/SMESH_Partition1_tetra.py new file mode 100644 index 000000000..26ad2f73e --- /dev/null +++ b/test/SMESH_Partition1_tetra.py @@ -0,0 +1,187 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py +# Hypothesis and algorithms for the mesh generation are global +# -- Rayon de la bariere +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +from math import sqrt + + +#--------------------------------------------------------------- + +barier_height = 7.0 +barier_radius = 5.6 / 2 # Rayon de la bariere +colis_radius = 1.0 / 2 # Rayon du colis +colis_step = 2.0 # Distance s�parant deux colis +cc_width = 0.11 # Epaisseur du complement de colisage + +# -- + +cc_radius = colis_radius + cc_width +colis_center = sqrt(2.0)*colis_step/2 + +# -- + +boolean_common = 1 +boolean_cut = 2 +boolean_fuse = 3 +boolean_section = 4 + +# -- + +p0 = geompy.MakeVertex(0.,0.,0.) +vz = geompy.MakeVectorDXDYDZ(0.,0.,1.) + +# -- + +barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height) + +# -- + +colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height) +cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height) + +colis_cc = geompy.MakeCompound([colis, cc]) +colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0) + +colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4) + +# -- + +Compound1 = geompy.MakeCompound([colis_cc_multi, barier]) +SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"]) +alveole = geompy.MakePartition(SubShape_theShape) + +print("Analysis of the geometry to mesh (right after the Partition) :") + +subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) + +print("number of Shells in alveole : ", len(subShellList)) +print("number of Faces in alveole : ", len(subFaceList)) +print("number of Edges in alveole : ", len(subEdgeList)) + +subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"]) + +## there are 9 sub-shapes + +comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] ) +comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] ) +comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] ) +comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] ) + +compGOs = [] +compGOs.append( comp1 ) +compGOs.append( comp2 ) +compGOs.append( comp3 ) +compGOs.append( comp4 ) +comp = geompy.MakeCompound( compGOs ) + +alveole = geompy.MakeCompound( [ comp, subshapes[8] ]) + +idalveole = geompy.addToStudy(alveole, "alveole") + +print("Analysis of the geometry to mesh (right after the MakeCompound) :") + +subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) + +print("number of Shells in alveole : ", len(subShellList)) +print("number of Faces in alveole : ", len(subFaceList)) +print("number of Edges in alveole : ", len(subEdgeList)) + +status = geompy.CheckShape(alveole) +print(" check status ", status) + + +# ---- init a Mesh with the alveole +shape_mesh = salome.IDToObject( idalveole ) + +mesh = smesh.Mesh(shape_mesh, "MeshAlveole") + +print("-------------------------- create Hypothesis (In this case global hypothesis are used)") + +print("-------------------------- NumberOfSegments") + +numberOfSegments = 10 + +regular1D = mesh.Segment() +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +print("-------------------------- MaxElementArea") + +maxElementArea = 0.1 + +mefisto2D = mesh.Triangle() +hypArea = mefisto2D.MaxElementArea(maxElementArea) +print(hypArea.GetName()) +print(hypArea.GetId()) +print(hypArea.GetMaxElementArea()) +smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + +print("-------------------------- MaxElementVolume") + +maxElementVolume = 0.5 + +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) +hypVolume = netgen3D.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) + +print("-------------------------- compute the mesh of alveole ") +ret = mesh.Compute() + +if ret != 0: + log=mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the Mesh_mechanic:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons: ", mesh.NbTetras()) +else: + print("problem when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_Sphere.py b/test/SMESH_Sphere.py new file mode 100644 index 000000000..fdcb723cf --- /dev/null +++ b/test/SMESH_Sphere.py @@ -0,0 +1,121 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# GEOM GEOM_SWIG : binding of C++ implementation with Python +# File : GEOM_Sphere.py +# Author : Damien COQUERET, Open CASCADE +# Module : GEOM +# $Header: +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import math + +# It is an example of creating a hexahedrical mesh on a sphere. +# +# Used approach allows to avoid problems with degenerated and +# seam edges without special processing of geometrical shapes + +#----------------------------------------------------------------------- +#Variables +Radius = 100. +Dist = Radius / 2. +Factor = 2.5 +Angle90 = math.pi / 2. +NbSeg = 10 + +PointsList = [] +ShapesList = [] + +#Basic Elements +P0 = geompy.MakeVertex(0., 0., 0.) +P1 = geompy.MakeVertex(-Dist, -Dist, -Dist) +P2 = geompy.MakeVertex(-Dist, -Dist, Dist) +P3 = geompy.MakeVertex(-Dist, Dist, Dist) +P4 = geompy.MakeVertex(-Dist, Dist, -Dist) + +VZ = geompy.MakeVectorDXDYDZ(0., 0., 1.) + +#Construction Elements +PointsList.append(P1) +PointsList.append(P2) +PointsList.append(P3) +PointsList.append(P4) +PointsList.append(P1) + +PolyLine = geompy.MakePolyline(PointsList) + +Face1 = geompy.MakeFace(PolyLine, 1) +Face2 = geompy.MakeScaleTransform(Face1, P0, Factor) +Face3 = geompy.MakeScaleTransform(Face1, P0, -1.) + +#Models +Sphere = geompy.MakeSphereR(Radius) + +Block = geompy.MakeHexa2Faces(Face1, Face2) +Cube = geompy.MakeHexa2Faces(Face1, Face3) + +Common1 = geompy.MakeBoolean(Sphere, Block, 1) +Common2 = geompy.MakeRotation(Common1, VZ, Angle90) + +MultiBlock1 = geompy.MakeMultiTransformation1D(Common1, 20, -1, 3) +MultiBlock2 = geompy.MakeMultiTransformation1D(Common2, 30, -1, 3) + +#Reconstruct sphere from several blocks +ShapesList.append(Cube) +ShapesList.append(MultiBlock1) +ShapesList.append(MultiBlock2) +Compound = geompy.MakeCompound(ShapesList) + +Result = geompy.MakeGlueFaces(Compound, 0.1) + +#addToStudy +Id_Sphere = geompy.addToStudy(Sphere, "Sphere") +Id_Cube = geompy.addToStudy(Cube, "Cube") + +Id_Common1 = geompy.addToStudy(Common1, "Common1") +Id_Common2 = geompy.addToStudy(Common2, "Common2") + +Id_MultiBlock1 = geompy.addToStudy(MultiBlock1, "MultiBlock1") +Id_MultiBlock2 = geompy.addToStudy(MultiBlock2, "MultiBlock2") + +Id_Result = geompy.addToStudy(Result, "Result") + +#----------------------------------------------------------------------- +#Meshing +my_hexa = smesh.Mesh(Result, "Sphere_Mesh") +algo = my_hexa.Segment() +algo.NumberOfSegments(NbSeg) +my_hexa.Quadrangle() +my_hexa.Hexahedron() +my_hexa.Compute() + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_blocks.py b/test/SMESH_blocks.py new file mode 100644 index 000000000..9d1c47b1a --- /dev/null +++ b/test/SMESH_blocks.py @@ -0,0 +1,49 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# SMESH SMESH_SWIG : binding of C++ implementation with Python +# File : SMESH_blocks.py +# Author : Julia DOROVSKIKH +# Module : SMESH +# $Header$ +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import math + +import GEOM_Spanner + +isBlocksTest = 0 # False +isMeshTest = 1 # True + +GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_box.py b/test/SMESH_box.py new file mode 100644 index 000000000..7d2e291a0 --- /dev/null +++ b/test/SMESH_box.py @@ -0,0 +1,73 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +#============================================================================== +# Info. +# Bug (from script, bug) : box.py, PAL5223 +# Modified : 25/11/2004 +# Author : Kovaltchuk Alexey +# Project : PAL/SALOME +#============================================================================== +# Salome geometry and meshing for a box +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +from salome import sg + +# Plate + +box = geompy.MakeBox(0.,0.,0.,1.,1.,1.) +boxId = geompy.addToStudy(box,"box") + +# ---- SMESH + +# ---- init a Mesh + +box_mesh=smesh.Mesh(box, "box_mesh") + +# set Hypothesis and Algorithm + +alg1D = box_mesh.Segment() +alg1D.SetName("algo1D") +hypL1 = alg1D.LocalLength(0.25) +smesh.SetName(hypL1, "LocalLength") + +alg2D = box_mesh.Quadrangle() +alg2D.SetName("algo2D") + +alg3D = box_mesh.Hexahedron() +alg3D.SetName("algo3D") + +# compute mesh + +box_mesh.Compute() + +sg.updateObjBrowser() diff --git a/test/SMESH_box2_tetra.py b/test/SMESH_box2_tetra.py new file mode 100644 index 000000000..3cf795ced --- /dev/null +++ b/test/SMESH_box2_tetra.py @@ -0,0 +1,141 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of the geometry union of 2 boxes having a face in common +# Hypothesis and algorithms for the mesh generation are global +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + + +# ---- define 2 boxes box1 and box2 + +box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) + +idbox1 = geompy.addToStudy(box1, "box1") + +print("Analysis of the geometry box1 :") +subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) + +print("number of Shells in box1 : ", len(subShellList)) +print("number of Faces in box1 : ", len(subFaceList)) +print("number of Edges in box1 : ", len(subEdgeList)) + +box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) + +idbox2 = geompy.addToStudy(box2, "box2") + +print("Analysis of the geometry box2 :") +subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) + +print("number of Shells in box2 : ", len(subShellList)) +print("number of Faces in box2 : ", len(subFaceList)) +print("number of Edges in box2 : ", len(subEdgeList)) + +# append the tow boxes to make ine shel, referrencing only once +# the internal interface + +shell = geompy.MakePartition([box1, box2]) +idshell = geompy.addToStudy(shell, "shell") + +print("Analysis of the geometry shell (union of box1 and box2) :") +subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) + +print("number of Shells in shell : ", len(subShellList)) +print("number of Faces in shell : ", len(subFaceList)) +print("number of Edges in shell : ", len(subEdgeList)) + + +### ---------------------------- SMESH -------------------------------------- + +# ---- init a Mesh with the shell + +mesh = smesh.Mesh(shell, "MeshBox2") + + +# ---- set Hypothesis and Algorithm + +print("-------------------------- NumberOfSegments") + +numberOfSegments = 10 + +regular1D = mesh.Segment() +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +print("-------------------------- MaxElementArea") + +maxElementArea = 500 + +mefisto2D = mesh.Triangle() +hypArea = mefisto2D.MaxElementArea(maxElementArea) +print(hypArea.GetName()) +print(hypArea.GetId()) +print(hypArea.GetMaxElementArea()) +smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + +print("-------------------------- MaxElementVolume") + +maxElementVolume = 500 + +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) +hypVolume = netgen3D.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) + +print("-------------------------- compute shell") +ret = mesh.Compute() +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the MeshBox2:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons: ", mesh.NbTetras()) +else: + print("probleme when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_box3_tetra.py b/test/SMESH_box3_tetra.py new file mode 100644 index 000000000..38610c33f --- /dev/null +++ b/test/SMESH_box3_tetra.py @@ -0,0 +1,151 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of the geometry union of 3 boxes aligned where the middle +# one has a race in common with the two others. +# Hypothesis and algorithms for the mesh generation are global +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define 3 boxes box1, box2 and box3 + +box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) + +idbox1 = geompy.addToStudy(box1, "box1") + +print("Analysis of the geometry box1 :") +subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) + +print("number of Shells in box1 : ", len(subShellList)) +print("number of Faces in box1 : ", len(subFaceList)) +print("number of Edges in box1 : ", len(subEdgeList)) + +box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) + +idbox2 = geompy.addToStudy(box2, "box2") + +print("Analysis of the geometry box2 :") +subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) + +print("number of Shells in box2 : ", len(subShellList)) +print("number of Faces in box2 : ", len(subFaceList)) +print("number of Edges in box2 : ", len(subEdgeList)) + +box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.) + +idbox3 = geompy.addToStudy(box3, "box3") + +print("Analysis of the geometry box3 :") +subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"]) + +print("number of Shells in box3 : ", len(subShellList)) +print("number of Faces in box3 : ", len(subFaceList)) +print("number of Edges in box3 : ", len(subEdgeList)) + +shell = geompy.MakePartition([box1, box2, box3]) +idshell = geompy.addToStudy(shell,"shell") + +print("Analysis of the geometry shell (union of box1, box2 and box3) :") +subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) + +print("number of Shells in shell : ", len(subShellList)) +print("number of Faces in shell : ", len(subFaceList)) +print("number of Edges in shell : ", len(subEdgeList)) + + +### ---------------------------- SMESH -------------------------------------- + +# ---- init a Mesh with the shell + +mesh = smesh.Mesh(shell, "MeshBox3") + + +# ---- set Hypothesis and Algorithm + +print("-------------------------- NumberOfSegments") + +numberOfSegments = 10 + +regular1D = mesh.Segment() +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +print("-------------------------- MaxElementArea") + +maxElementArea = 500 + +mefisto2D = mesh.Triangle() +hypArea = mefisto2D.MaxElementArea(maxElementArea) +print(hypArea.GetName()) +print(hypArea.GetId()) +print(hypArea.GetMaxElementArea()) +smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + +print("-------------------------- MaxElementVolume") + +maxElementVolume = 500 + +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) +hypVolume = netgen3D.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) + +print("-------------------------- compute shell") +ret = mesh.Compute() +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the MeshBox3:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons: ", mesh.NbTetras()) +else: + print("probleme when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_box_tetra.py b/test/SMESH_box_tetra.py new file mode 100644 index 000000000..52618addf --- /dev/null +++ b/test/SMESH_box_tetra.py @@ -0,0 +1,110 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of a simple box. Hypothesis and algorithms for +# the mesh generation are global +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) + +idbox = geompy.addToStudy(box, "box") + +print("Analysis of the geometry box :") +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) + +print("number of Shells in box : ", len(subShellList)) +print("number of Faces in box : ", len(subFaceList)) +print("number of Edges in box : ", len(subEdgeList)) + + +### ---------------------------- SMESH -------------------------------------- + +# ---- init a Mesh with the box + +mesh = smesh.Mesh(box, "MeshBox") + +# ---- set Hypothesis and Algorithm + +print("-------------------------- NumberOfSegments") +numberOfSegments = 10 + +regular1D = mesh.Segment() +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +print("-------------------------- MaxElementArea") + +maxElementArea = 500 + +mefisto2D = mesh.Triangle() +hypArea = mefisto2D.MaxElementArea(maxElementArea) +print(hypArea.GetName()) +print(hypArea.GetId()) +print(hypArea.GetMaxElementArea()) +smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + +print("-------------------------- MaxElementVolume") + +maxElementVolume = 500 + +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) +hypVolume = netgen3D.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) + +print("-------------------------- compute the mesh of the box") +ret = mesh.Compute() +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the MeshBox:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons: ", mesh.NbTetras()) +else: + print("probleme when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_controls.py b/test/SMESH_controls.py new file mode 100644 index 000000000..d081611f9 --- /dev/null +++ b/test/SMESH_controls.py @@ -0,0 +1,144 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_control.py +# Author : Sergey LITONIN +# Module : SMESH +# +import salome +import SMESH_mechanic + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() +mesh = SMESH_mechanic.mesh + +# ---- Criterion : AREA > 100 + +# create group +aGroup = mesh.MakeGroup("Area > 100", SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Area > 100 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# ---- Criterion : Taper > 3e-15 + +# create group +aGroup = mesh.MakeGroup("Taper > 3e-15", SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, 3e-15) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Taper > 3e-15 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# ---- Criterion : ASPECT RATIO > 1.3 + +# create group +aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.3) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# ---- Criterion : MINIMUM ANGLE < 30 + +# create group +aGroup = mesh.MakeGroup("Minimum Angle < 30", SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, 30) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Minimum Angle < 30 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# ---- Criterion : Warp > 2e-13 + +# create group +aGroup = mesh.MakeGroup("Warp > 2e-13", SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, 2e-13 ) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Warp > 2e-13 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# ---- Criterion : Skew > 18 + +# create group +aGroup = mesh.MakeGroup("Skew > 18", SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 18 ) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Skew > 18 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# Criterion : Length > 10 + +# create group +aGroup = mesh.MakeGroup("Length > 10", SMESH.FACE, SMESH.FT_Length, SMESH.FT_MoreThan, 10 ) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Length > 10 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# Criterion : Borders at multi-connections = 2 + +# create group +aGroup = mesh.MakeGroup("Borders at multi-connections = 2", SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, 2) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +# Criterion : Element Diameter 2D > 10 + +# create group +aGroup = mesh.MakeGroup("Element Diameter 2D > 10", SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10 ) + +# print result +anIds = aGroup.GetIDs() +print("Criterion: Element Diameter 2D > 10 Nb = ", len( anIds )) +#for i in range( len( anIds ) ): + #print anIds[ i ] + + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_demo_hexa2_upd.py b/test/SMESH_demo_hexa2_upd.py new file mode 100644 index 000000000..d6c3c4325 --- /dev/null +++ b/test/SMESH_demo_hexa2_upd.py @@ -0,0 +1,200 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +#============================================================================== +# Info. +# Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781 +# Modified : 25/11/2004 +# Author : Kovaltchuk Alexey +# Project : PAL/SALOME +#============================================================================== +# Tetrahedrization of a geometry (box minus a inner cylinder). +# Hypothesis and algorithms for the mesh generation are not global: +# the mesh of some edges is thinner +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import math + + +# ----------------------------------------------------------------------------- + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +a = math.sqrt(2.)/4. +ma = - a +zero = 0. +un = 1. +mun= - un +demi = 1./2. + +Orig = geompy.MakeVertex(zero,zero,zero) +P0 = geompy.MakeVertex(a,a,zero) +P1 = geompy.MakeVertex(zero,demi,zero) +P2 = geompy.MakeVertex(ma,a,zero) +P3 = geompy.MakeVertex(mun,un,zero) +P4 = geompy.MakeVertex(un,un,zero) +P5 = geompy.MakeVertex(zero,zero,un) + +arc = geompy.MakeArc(P0,P1,P2) +e1 = geompy.MakeEdge(P2,P3) +e2 = geompy.MakeEdge(P3,P4) +e3 = geompy.MakeEdge(P4,P0) + +list = [] +list.append(arc) +list.append(e1) +list.append(e2) +list.append(e3) + +wire = geompy.MakeWire(list) +face = geompy.MakeFace(wire,1) + +dir = geompy.MakeVector(Orig,P5) +vol1 = geompy.MakePipe(face,dir) + +angle = math.pi/2. +#dir = geom.MakeVector(Orig,P5) +vol2 = geompy.MakeRotation(vol1,dir,angle) + +vol3 = geompy.MakeRotation(vol2,dir,angle) + +vol4 = geompy.MakeRotation(vol3,dir,angle) + +list = [] +list.append(vol1) +list.append(vol2) +list.append(vol3) +list.append(vol4) + +volComp = geompy.MakeCompound(list) + +tol3d = 1.e-3 +vol = geompy.MakeGlueFaces(volComp,tol3d) +idVol = geompy.addToStudy(vol,"volume") + +print("Analysis of the final volume:") +subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell) +subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace) +subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge) + +print("number of Shells in the volume : ",len(subShellList)) +print("number of Faces in the volume : ",len(subFaceList)) +print("number of Edges in the volume : ",len(subEdgeList)) + +idSubEdge = [] +for k in range(len(subEdgeList)): + idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k))) + +edgeZ = [] +edgeZ.append(subEdgeList[0]) +edgeZ.append(subEdgeList[3]) +edgeZ.append(subEdgeList[10]) +edgeZ.append(subEdgeList[11]) +edgeZ.append(subEdgeList[20]) +edgeZ.append(subEdgeList[21]) +edgeZ.append(subEdgeList[28]) +edgeZ.append(subEdgeList[31]) + +idEdgeZ = [] +for i in range(8): + idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1))) + +### ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +# ---- init a Mesh with the volume + +mesh = smesh.Mesh(vol, "meshVolume") + +# ---- set Hypothesis and Algorithm to main shape + +print("-------------------------- NumberOfSegments the global one") + +numberOfSegments = 10 + +regular1D = mesh.Segment() +regular1D.SetName("Wire Discretisation") +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments") + + +print("-------------------------- Quadrangle_2D") + +quad2D=mesh.Quadrangle() +quad2D.SetName("Quadrangle_2D") + +print("-------------------------- Hexa_3D") + +hexa3D=mesh.Hexahedron() +hexa3D.SetName("Hexa_3D") + + +print("-------------------------- NumberOfSegments in the Z direction") + +numberOfSegmentsZ = 40 + +for i in range(8): + print("-------------------------- add hypothesis to edge in the Z directions", (i+1)) + + algo = mesh.Segment(edgeZ[i]) + hyp = algo.NumberOfSegments(numberOfSegmentsZ) + smesh.SetName(hyp, "NumberOfSegmentsZ") + smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1)) + + +salome.sg.updateObjBrowser() + +print("-------------------------- compute the mesh of the volume") + +ret=mesh.Compute() + +print(ret) +if ret != 0: +## log=mesh.GetLog(0) # no erase trace +## for linelog in log: +## print linelog + print("Information about the MeshBox :") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons: ", mesh.NbTetras()) +else: + print("problem when Computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_fixation.py b/test/SMESH_fixation.py new file mode 100644 index 000000000..87cec63b9 --- /dev/null +++ b/test/SMESH_fixation.py @@ -0,0 +1,300 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_fix_volute.py +# Author : Paul RASCLE, EDF +# Module : SMESH +# $Header$ +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import math + +# ----------------------------------------------------------------------------- + +def MakeFace(lstEdges) : + """ + Create a planar face from 4 edges + """ + wire = geompy.MakeWire(lstEdges) + face = geompy.MakeFace(wire, 1) + return face + +# ----------------------------------------------------------------------------- + +# ---- dimensions + +##longueurPlq = 0.686 +##largeurPlq = 0.573 +##epaisseurPlq = 0.150 + +##hauteurFlanc = 0.380 +##epaisseurFlanc = 0.112 +##rayonConge = 0.150 - epaisseurFlanc + +##epaisseurFond = 0.162 +##rayonTrou = 0.075 +##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou) +##marge = 0.01 +##tol3d = 1.e-5 + +longueurPlq = 686 +largeurPlq = 573 +epaisseurPlq = 150 + +hauteurFlanc = 380 +epaisseurFlanc = 112 +rayonConge = 150 - epaisseurFlanc + +epaisseurFond = 162 +rayonTrou = 75 +posAxeTrou = hauteurFlanc - (180 + rayonTrou) +marge = 10 +tol3d = 1.e-3 + +# ---- points, directions de base + +p0 = geompy.MakeVertex(0., 0., 0.) + +vx = geompy.MakeVectorDXDYDZ(100., 0., 0.) +vy = geompy.MakeVectorDXDYDZ(0., 100., 0.) +vz = geompy.MakeVectorDXDYDZ(0., 0., 100.) + +# ---- ellipse du flanc + +he = hauteurFlanc - 2*rayonConge +re = 0.5*(largeurPlq - epaisseurFond) - rayonConge +sine = re/he +cose = math.sqrt(1. - sine*sine) + +ve = geompy.MakeVectorDXDYDZ(sine, 0., cose) +cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he) +cyl1 = geompy.MakeRotation(cyl0, ve, 0.5) +cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose) + +pbe = geompy.MakeVertex(3*he, -2*re, 3*he) +boxe = geompy.MakeBoxTwoPnt(p0, pbe) + +cylcoup = geompy.MakeBoolean(cyle, boxe, 2) + +aretes = [] +aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"]) + +shape = geompy.MakeCopy(aretes[0]) +aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge) + + +# ----------------------------------------------------------------------------- +# ---- decoupage de la piece en volumes a 6 faces de 4 cotes +# ----------------------------------------------------------------------------- + +# ---- cotes x + +x0 = 0. +x0h = rayonConge +x1 = rayonConge + epaisseurFlanc +xc = longueurPlq/2 +x2 = longueurPlq - rayonConge - epaisseurFlanc +x3h = longueurPlq - rayonConge +x3 = longueurPlq + +# ---- cotes y + +y0 = 0. +y0h = rayonConge +y1 = largeurPlq - epaisseurFond +y1m = y1 - marge +y2 = largeurPlq +y2p = largeurPlq + marge + +# ---- cotes z + +z0 = 0. +z1m = epaisseurPlq - marge +z1 = epaisseurPlq +z2 = epaisseurPlq + rayonConge +z3 = epaisseurPlq + 2*rayonConge +z4 = epaisseurPlq + hauteurFlanc +z4p = epaisseurPlq + hauteurFlanc + marge + +zc = epaisseurPlq + posAxeTrou +zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3 +zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3 + +# ---- decoupe du fond + +p11 = geompy.MakeVertex(x1, y1m, z1) +p12 = geompy.MakeVertex(x1, y1m, z2) +p13 = geompy.MakeVertex(x1, y1m, z3) +p14 = geompy.MakeVertex(x1, y1m, z4) +pc1 = geompy.MakeVertex(xc, y1m, z1) +pc2 = geompy.MakeVertex(xc, y1m, zc2) +pc3 = geompy.MakeVertex(xc, y1m, zc3) +pcc = geompy.MakeVertex(xc, y1m, zc) +pc4 = geompy.MakeVertex(xc, y1m, z4) +p21 = geompy.MakeVertex(x2, y1m, z1) +p22 = geompy.MakeVertex(x2, y1m, z2) +p23 = geompy.MakeVertex(x2, y1m, z3) +p24 = geompy.MakeVertex(x2, y1m, z4) +pcf = geompy.MakeVertex(xc, y2p, zc) + +arc2 = geompy.MakeArc(p12,pc2,p22) +arc3 = geompy.MakeArc(p13,pc3,p23) + +segz1 = geompy.MakeVector(p11,p21) +segz41 = geompy.MakeVector(p14,pc4) +segz42 = geompy.MakeVector(pc4,p24) +segx11 = geompy.MakeVector(p11,p12) +segx12 = geompy.MakeVector(p12,p13) +segx13 = geompy.MakeVector(p13,p14) +segxc2 = geompy.MakeVector(pc1,pc2) +segxc3 = geompy.MakeVector(pc2,pc3) +segxc4 = geompy.MakeVector(pcc,pc4) +segx21 = geompy.MakeVector(p21,p22) +segx22 = geompy.MakeVector(p22,p23) +segx23 = geompy.MakeVector(p23,p24) +segx1c1 = geompy.MakeVector(p13,pcc) +segx1c2 = geompy.MakeVector(p14,pcc) +segx2c1 = geompy.MakeVector(p23,pcc) +segx2c2 = geompy.MakeVector(p24,pcc) + +facef = [] +facef.append(MakeFace([segx13,segx1c2,segx1c1])) +facef.append(MakeFace([segx23,segx2c2,segx2c1])) +facef.append(MakeFace([segx2c2,segxc4,segz42])) +facef.append(MakeFace([segx1c2,segz41,segxc4])) +facef.append(MakeFace([segx1c1,arc3,segx2c1])) +facef.append(MakeFace([segx12,arc2,segx22,arc3])) +facef.append(MakeFace([segx11,segz1,segx21,arc2])) + +vcccf = geompy.MakeVector(pcc, pcf) +hcccf = y2p - y1m +decf = [] +for face in facef: + decf.append(geompy.MakePrismVecH(face,vcccf,hcccf)) + +pc = geompy.MakeVertex(xc, 0., zc) +py2 = geompy.MakeVertex(xc, y2, zc) +axeCyl = geompy.MakeVector(pc, py2) + +cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq) +cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi) + +fondec = [] +for id in (0,1,2,3): + fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2)) +fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2)) +for id in (5,6): + fondec.append(decf[id]) + +p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p) +p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p) +pxc = geompy.MakeVertex(xc,y0,z0) +bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p) +bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p) + +fondec2 = [] +for id in (0,1,2,3): + fondec2.append(fondec[id]) +for id in (4,5,6): + fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1)) + fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1)) + +# ----- autres blocs de decoupe + +bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2) +bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2) +bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2) +bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2) + +pcylx0 = geompy.MakeVertex(0., -marge, z2) +pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2) +pcyly0 = geompy.MakeVertex(-marge, 0., z2) + +cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge) +cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge) +cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge) + +bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2) +bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2) +bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2) +#NRI : inverse order of BOP +bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2) +bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2) +bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2) + +pf1 = geompy.MakeVertex(0., y0h, z3) +pf2 = geompy.MakeVertex(0., y1, z3) +pf3 = geompy.MakeVertex(0., y1, z4) +pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4) + +vf1 = geompy.MakeEdge(pf1, pf2) +vf2 = geompy.MakeEdge(pf2, pf3) +vf3 = geompy.MakeEdge(pf3, pf4) + +faceFlanc = MakeFace([vf1,vf2,vf3,aShape]) + +flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc) +flanc2 = geompy.MakeCopy(flanc1) +flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.) +flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.) + +# ---- constitution et decoupe des blocs +boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p) + +blocs = [] +for dec in fondec2: + blocs.append(geompy.MakeBoolean(boxfond2, dec, 1)) + +blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1)) +blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1)) +blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1)) +blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1)) +blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1)) +blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1)) +blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1)) +blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1)) +blocs.append(bcong2) +blocs.append(bcong4) +blocs.append(bcong1) +blocs.append(bcong3) +blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3)) +blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3)) +blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3)) +blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3)) +blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4)) +blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4)) +blocs.append(flanc1) +blocs.append(flanc2) + +compbloc = geompy.MakeCompound(blocs) +idcomp = geompy.addToStudy(compbloc, "compbloc") + +# ---- eliminer les faces en double, solid-->shell + +compshell = geompy.MakeGlueFaces(compbloc,tol3d) +idcomp = geompy.addToStudy(compshell, "compshell") diff --git a/test/SMESH_fixation_hexa.py b/test/SMESH_fixation_hexa.py new file mode 100644 index 000000000..b93723979 --- /dev/null +++ b/test/SMESH_fixation_hexa.py @@ -0,0 +1,102 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Hexahedrization of the geometry generated by the Python script +# SMESH_fixation.py +# Hypothesis and algorithms for the mesh generation are global +# +import salome +import SMESH_fixation + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +compshell = SMESH_fixation.compshell +idcomp = SMESH_fixation.idcomp +geompy = SMESH_fixation.geompy +salome = SMESH_fixation.salome + +print("Analysis of the geometry to be meshed :") +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) + +print("number of Shells in compshell : ", len(subShellList)) +print("number of Faces in compshell : ", len(subFaceList)) +print("number of Edges in compshell : ", len(subEdgeList)) + +status = geompy.CheckShape(compshell) +print(" check status ", status) + +### ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +# ---- init a Mesh with the compshell +shape_mesh = salome.IDToObject( idcomp ) + +mesh = smesh.Mesh(shape_mesh, "MeshCompShell") + + +# ---- set Hypothesis and Algorithm + +print("-------------------------- NumberOfSegments") + +numberOfSegments = 5 + +regular1D = mesh.Segment() +regular1D.SetName("Wire Discretisation") +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +print("-------------------------- Quadrangle_2D") + +quad2D = mesh.Quadrangle() +quad2D.SetName("Quadrangle_2D") + +print("-------------------------- Hexa_3D") + +hexa3D = mesh.Hexahedron() +hexa3D.SetName("Hexa_3D") + +print("-------------------------- compute compshell") +ret = mesh.Compute() +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the MeshcompShel:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of quadrangles : ", mesh.NbQuadrangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of hexahedrons : ", mesh.NbHexas()) +else: + print("problem when Computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_fixation_netgen.py b/test/SMESH_fixation_netgen.py new file mode 100644 index 000000000..ea850a933 --- /dev/null +++ b/test/SMESH_fixation_netgen.py @@ -0,0 +1,79 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of the geometry generated by the Python script +# SMESH_fixation.py +# The new Netgen algorithm is used that discretizes baoundaries itself +# +import salome +import SMESH_fixation + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +compshell = SMESH_fixation.compshell +idcomp = SMESH_fixation.idcomp +geompy = SMESH_fixation.geompy +salome = SMESH_fixation.salome + +print("Analysis of the geometry to be meshed :") +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) + +print("number of Shells in compshell : ", len(subShellList)) +print("number of Faces in compshell : ", len(subFaceList)) +print("number of Edges in compshell : ", len(subEdgeList)) + +status = geompy.CheckShape(compshell) +print(" check status ", status) + +### ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +print("-------------------------- create Mesh, algorithm, hypothesis") + +mesh = smesh.Mesh(compshell, "MeshcompShel"); +netgen = mesh.Tetrahedron(smeshBuilder.FULL_NETGEN) +netgen.SetMaxSize( 50 ) +#netgen.SetSecondOrder( 0 ) +netgen.SetFineness( smeshBuilder.Fine ) +#netgen.SetOptimize( 1 ) + +print("-------------------------- compute mesh") +ret = mesh.Compute() +print(ret) +if ret != 0: + print("Information about the MeshcompShel:") + print("Number of nodes : ", mesh.GetMesh().NbNodes()) + print("Number of edges : ", mesh.GetMesh().NbEdges()) + print("Number of faces : ", mesh.GetMesh().NbFaces()) + print("Number of triangles : ", mesh.GetMesh().NbTriangles()) + print("Number of volumes : ", mesh.GetMesh().NbVolumes()) + print("Number of tetrahedrons : ", mesh.GetMesh().NbTetras()) + +else: + print("problem when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_fixation_tetra.py b/test/SMESH_fixation_tetra.py new file mode 100644 index 000000000..32f8143a5 --- /dev/null +++ b/test/SMESH_fixation_tetra.py @@ -0,0 +1,126 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Tetrahedrization of the geometry generated by the Python script +# SMESH_fixation.py +# Hypothesis and algorithms for the mesh generation are global +# +import salome +import SMESH_fixation + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +compshell = SMESH_fixation.compshell +idcomp = SMESH_fixation.idcomp +geompy = SMESH_fixation.geompy +salome = SMESH_fixation.salome + +print("Analysis of the geometry to be meshed :") +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) + +print("number of Shells in compshell : ", len(subShellList)) +print("number of Faces in compshell : ", len(subFaceList)) +print("number of Edges in compshell : ", len(subEdgeList)) + +status = geompy.CheckShape(compshell) +print(" check status ", status) + +### ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +# ---- init a Mesh with the compshell + +mesh = smesh.Mesh(compshell, "MeshcompShell") + + +# ---- set Hypothesis and Algorithm + +print("-------------------------- NumberOfSegments") + +numberOfSegments = 5 + +regular1D = mesh.Segment() +regular1D.SetName("Wire Discretisation") +hypNbSeg = regular1D.NumberOfSegments(numberOfSegments) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments)) + +## print "-------------------------- MaxElementArea" + +## maxElementArea = 80 + +## mefisto2D = mesh.Triangle() +## mefisto2D.SetName("MEFISTO_2D") +## hypArea = mefisto2D.MaxElementArea(maxElementArea) +## print hypArea.GetName() +## print hypArea.GetId() +## print hypArea.GetMaxElementArea() +## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + +print("-------------------------- LengthFromEdges") + +mefisto2D = mesh.Triangle() +mefisto2D.SetName("MEFISTO_2D") +hypLengthFromEdges = mefisto2D.LengthFromEdges() +print(hypLengthFromEdges.GetName()) +print(hypLengthFromEdges.GetId()) +smesh.SetName(hypLengthFromEdges, "LengthFromEdges") + + +print("-------------------------- MaxElementVolume") + +maxElementVolume = 1000 + +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) +netgen3D.SetName("NETGEN_3D") +hypVolume = netgen3D.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume)) + +print("-------------------------- compute compshell") +ret = mesh.Compute(mesh) +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the MeshcompShel:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons : ", mesh.NbTetras()) + +else: + print("problem when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_flight_skin.py b/test/SMESH_flight_skin.py new file mode 100644 index 000000000..14757a3c2 --- /dev/null +++ b/test/SMESH_flight_skin.py @@ -0,0 +1,110 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Triangulation of the skin of the geometry from a Brep representing a plane +# Hypothesis and algorithms for the mesh generation are global +# +import os +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + + +# ---------------------------- GEOM -------------------------------------- + +# import a BRep +#before running this script, please be sure about +#the path the file fileName + +filePath = os.environ["DATA_DIR"] +filePath = filePath + "/Shapes/Brep/" + +filename = "flight_solid.brep" +filename = filePath + filename + +shape = geompy.ImportBREP(filename) +idShape = geompy.addToStudy(shape, "flight") + +print("Analysis of the geometry flight :") +subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"]) + +print("number of Shells in flight : ", len(subShellList)) +print("number of Faces in flight : ", len(subFaceList)) +print("number of Edges in flight : ", len(subEdgeList)) + + +### ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +# ---- init a Mesh with the shell +shape_mesh = salome.IDToObject( idShape ) + +mesh = smesh.Mesh(shape_mesh, "MeshFlight") + + +# ---- set Hypothesis and Algorithm + +print("-------------------------- LocalLength") + +lengthOfSegments = 0.3 + +regular1D = mesh.Segment() +hypLength = regular1D.LocalLength(lengthOfSegments) +print(hypLength.GetName()) +print(hypLength.GetId()) +print(hypLength.GetLength()) +smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments)) + +print("-------------------------- LengthFromEdges") + +mefisto2D = mesh.Triangle() +hypLengthFromEdge = mefisto2D.LengthFromEdges() +print(hypLengthFromEdge.GetName()) +print(hypLengthFromEdge.GetId()) +smesh.SetName(hypLengthFromEdge,"LengthFromEdge") + +print("-------------------------- compute the skin flight") +ret = mesh.Compute() +print(ret) +if ret != 0: + log = mesh.GetLog(0) # no erase trace + # for linelog in log: + # print(linelog) + print("Information about the Mesh_mechanic_tetra:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of volumes : ", mesh.NbVolumes()) +else: + print("probleme when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_freebord.py b/test/SMESH_freebord.py new file mode 100644 index 000000000..24a19df01 --- /dev/null +++ b/test/SMESH_freebord.py @@ -0,0 +1,78 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + + +# Create box without one plane + +box = geompy.MakeBox(0., 0., 0., 10., 20., 30.) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) + +FaceList = [] +for i in range( 5 ): + FaceList.append( subShapeList[ i ] ) + +aComp = geompy.MakeCompound( FaceList ) +aBox = geompy.Sew( aComp, 1. ) +idbox = geompy.addToStudy( aBox, "box" ) + +aBox = salome.IDToObject( idbox ) + +# Create mesh +smesh.UpdateStudy() + +mesh = smesh.Mesh(aBox, "Mesh_freebord") + +algoReg = mesh.Segment() +hypNbSeg = algoReg.NumberOfSegments(5) + +algoMef = mesh.Triangle() +hypArea = algoMef.MaxElementArea(20) + + +mesh.Compute() + + +# Criterion : Free edges. Create group. + +aCriterion = smesh.GetCriterion(SMESH.EDGE, SMESH.FT_FreeEdges) + +aGroup = mesh.MakeGroupByCriterion("Free edges", aCriterion) + +anIds = aGroup.GetIDs() + +# print result +print("Criterion: Free edges Nb = ", len( anIds )) +for i in range( len( anIds ) ): + print(anIds[ i ]) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_hexaedre.py b/test/SMESH_hexaedre.py new file mode 100644 index 000000000..1eecb94a7 --- /dev/null +++ b/test/SMESH_hexaedre.py @@ -0,0 +1,101 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ----------------------------------------------------------------------------- + +p0 = geompy.MakeVertex(0., 0., 0.) +px = geompy.MakeVertex(100., 0., 0.) +py = geompy.MakeVertex(0., 100., 0.) +pz = geompy.MakeVertex(0., 0., 100.) +vx = geompy.MakeVector(p0, px) +vy = geompy.MakeVector(p0, py) +vz = geompy.MakeVector(p0, pz) + +sphereExt = geompy.MakeSphere( 0., 0., 0., 400.) +sphereInt = geompy.MakeSphere( 0.,-50., 0., 350.) +sphereA = geompy.MakeSphere( -400., 50., 50., 400.) +sphereB = geompy.MakeSphere( 350.,-50.,-50., 350.) +ptcyle = geompy.MakeVertex(0., -300., -450.) +cylindre = geompy.MakeCylinder(ptcyle,vz,500.,900.) + +vol1=geompy.MakeCut(sphereExt,sphereA) +vol2=geompy.MakeCut(vol1,sphereB) +vol3=geompy.MakeCut(vol2,cylindre) +blob=geompy.MakeCut(vol3,sphereInt) +blob=geompy.RemoveExtraEdges(blob) + +idblob = geompy.addToStudy(blob,"blob") + +edgeGroups = geompy.Propagate( blob ) +assert len( edgeGroups ) == 3 + +salome.sg.updateObjBrowser() + +# ----------------------------------------------------------------------------- + +print("-------------------------- mesh") +smesh.UpdateStudy() + +# ---- define a mesh on the geom shape 'blob' +mesh=smesh.Mesh(blob, "MeshBlob") + +# ---- assign global hypothesis and algorithms to mesh +print("-------------------------- add hypothesis to mesh") +algo1 = mesh.Segment() +algo2 = mesh.Quadrangle() +algo3 = mesh.Hexahedron() + +# ---- assign local hypothesis and algorithms to mesh +for edges in edgeGroups: # loop on groups of logically parallel edges + length = geompy.BasicProperties( edges )[0] + if length < 500: nbSeg = 4 + elif length < 2000: nbSeg = 10 + else: nbSeg = 15 + algo = mesh.Segment( edges ) + algo.NumberOfSegments( nbSeg ) + pass + +# ---- compute mesh +print("-------------------------- compute mesh") +ok = mesh.Compute() +if ok: + print("Information about the Mesh:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of quadrangles : ", mesh.NbQuadrangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of hexahedrons : ", mesh.NbHexas()) +else: + print("problem when Computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_mechanic.py b/test/SMESH_mechanic.py new file mode 100644 index 000000000..0b2974282 --- /dev/null +++ b/test/SMESH_mechanic.py @@ -0,0 +1,191 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_withHole.py +# Author : Lucien PIGNOLONI +# Module : SMESH +# $Header$ +#------------------------------------------------------------------------- +# +import salome +salome.salome_init_without_session() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +from salome.StdMeshers import StdMeshersBuilder + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contiguous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1" ) + +# ---- create two cylinders +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) + +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- explode on faces +SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) + +# ---- add a face sub-shape in study to be meshed different +sub_face1 = SubFaceL[0] +name = geompy.SubShapeName( sub_face1, mechanic ) + +Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face2 = SubFaceL[4] +name = geompy.SubShapeName( sub_face2, mechanic ) + +Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face3 = SubFaceL[5] +name = geompy.SubShapeName( sub_face3, mechanic ) + +Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face4 = SubFaceL[10] +name = geompy.SubShapeName( sub_face4, mechanic ) + +Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) + +# ---------------------------- SMESH -------------------------------------- +smesh.UpdateStudy() + +# -- Init -- +shape_mesh = salome.IDToObject( Id_mechanic ) + +mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic") + +print("-------------------------- NumberOfSegments") + +numberOfSegment = 10 + +algo = mesh.Segment() +hypNbSeg = algo.NumberOfSegments(numberOfSegment) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_10") + +print("-------------------------- MaxElementArea") + +maxElementArea = 25 + +algo = mesh.Triangle() +hypArea25 = algo.MaxElementArea(maxElementArea) +print(hypArea25.GetName()) +print(hypArea25.GetId()) +print(hypArea25.GetMaxElementArea()) +smesh.SetName(hypArea25, "MaxElementArea_25") + +# Create submesh on sub_face1 - sub_face4 +# --------------------------------------- + +# Set 2D algorithm to submesh on sub_face1 +algo = mesh.Quadrangle(sub_face1) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace1") + +# Set 2D algorithm to submesh on sub_face2 +algo = mesh.Quadrangle(sub_face2) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace2") + +# Set 2D algorithm to submesh on sub_face3 +algo = mesh.Quadrangle(sub_face3) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace3") + +# Set 2D algorithm to submesh on sub_face4 +algo = mesh.Quadrangle(sub_face4) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace4") + +print("-------------------------- compute the mesh of the mechanic piece") + +mesh.Compute() + +print("Information about the Mesh_mechanic:") +print("Number of nodes : ", mesh.NbNodes()) +print("Number of edges : ", mesh.NbEdges()) +print("Number of faces : ", mesh.NbFaces()) +print("Number of triangles : ", mesh.NbTriangles()) +print("Number of quadrangles : ", mesh.NbQuadrangles()) +print("Number of volumes : ", mesh.NbVolumes()) +print("Number of tetrahedrons: ", mesh.NbTetras()) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_mechanic_editor.py b/test/SMESH_mechanic_editor.py new file mode 100644 index 000000000..5b20b16eb --- /dev/null +++ b/test/SMESH_mechanic_editor.py @@ -0,0 +1,237 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_withHole.py +# Author : Lucien PIGNOLONI +# Module : SMESH +# $Header$ +#------------------------------------------------------------------------- +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contiguous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1" ) + +# ---- create two cylinders +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) + +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- explode on faces +SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) + +# ---- add a face sub-shape in study to be meshed different +sub_face1 = SubFaceL[0] +name = geompy.SubShapeName( sub_face1, mechanic ) + +Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face2 = SubFaceL[4] +name = geompy.SubShapeName( sub_face2, mechanic ) + +Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face3 = SubFaceL[5] +name = geompy.SubShapeName( sub_face3, mechanic ) + +Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) + +# ---- add a face sub-shape in study to be meshed different +sub_face4 = SubFaceL[10] +name = geompy.SubShapeName( sub_face4, mechanic ) + +Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) + +# ---------------------------- SMESH -------------------------------------- + +# -- Init -- +shape_mesh = salome.IDToObject( Id_mechanic ) + +mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic") + +print("-------------------------- NumberOfSegments") + +numberOfSegment = 10 + +algo = mesh.Segment() +hypNbSeg = algo.NumberOfSegments(numberOfSegment) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) + + +print("-------------------------- MaxElementArea") + +maxElementArea = 25 + +algo = mesh.Triangle() +hypArea25 = algo.MaxElementArea(maxElementArea) +print(hypArea25.GetName()) +print(hypArea25.GetId()) +print(hypArea25.GetMaxElementArea()) +smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea)) + + +# Create submesh on sub_face1 - sub_face4 +# --------------------------------------- + +# Set 2D algorithm to submesh on sub_face1 +algo = mesh.Quadrangle(sub_face1) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace1") +submesh1 = algo.GetSubMesh() + +# Set 2D algorithm to submesh on sub_face2 +algo = mesh.Quadrangle(sub_face2) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace2") +submesh2 = algo.GetSubMesh() + +# Set 2D algorithm to submesh on sub_face3 +algo = mesh.Quadrangle(sub_face3) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace3") +submesh3 = algo.GetSubMesh() + +# Set 2D algorithm to submesh on sub_face4 +algo = mesh.Quadrangle(sub_face4) +smesh.SetName(algo.GetSubMesh(), "SubMeshFace4") +submesh4 = algo.GetSubMesh() + + +print("-------------------------- compute the mesh of the mechanic piece") + +mesh.Compute() + +print("Information about the Mesh_mechanic:") +print("Number of nodes : ", mesh.NbNodes()) +print("Number of edges : ", mesh.NbEdges()) +print("Number of faces : ", mesh.NbFaces()) +print("Number of triangles : ", mesh.NbTriangles()) +print("Number of quadrangles : ", mesh.NbQuadrangles()) +print("Number of volumes : ", mesh.NbVolumes()) +print("Number of tetrahedrons: ", mesh.NbTetras()) + + +#1 cutting of quadrangles of the 'SubMeshFace2' submesh +mesh.SplitQuadObject(submesh2, 1) + +#2 cutting of triangles of the group +FacesTriToQuad = [ 2391, 2824, 2825, 2826, 2827, 2828, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2841, 2844, 2845, 2847, 2854, 2861, 2863, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2946, 2951, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985 ] +GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", SMESH.FACE, FacesTriToQuad) +mesh.TriToQuadObject(GroupTriToQuad, SMESH.FT_AspectRatio , 1.57) + +#3 extrusion of the group +point = SMESH.PointStruct(0, 0, 5) +vector = SMESH.DirStruct(point) +mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5) + +#4 mirror object +mesh.Mirror([], SMESH.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0) + +#5 mesh translation +point = SMESH.PointStruct(10, 10, 10) +vector = SMESH.DirStruct(point) +mesh.Translate([], vector, 0) + +#6 mesh rotation +axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10) +angle180 = 180*3.141/180 +mesh.Rotate([], axisXYZ, angle180, 0) + +#7 group smoothing +FacesSmooth = [864, 933, 941, 950, 1005, 1013] +GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", SMESH.FACE, FacesSmooth) +mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH) + +#8 rotation sweep object +FacesRotate = [492, 493, 502, 503] +GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", SMESH.FACE, FacesRotate) +angle45 = 45*3.141/180 +axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632) +mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) + +#9 reorientation of the submesh1 +mesh.ReorientObject(submesh1) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_mechanic_netgen.py b/test/SMESH_mechanic_netgen.py new file mode 100644 index 000000000..786eec4ff --- /dev/null +++ b/test/SMESH_mechanic_netgen.py @@ -0,0 +1,138 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# Quadrangulation of the geometry generated by the Python script +# SMESH_mechanic.py +# The new Netgen algorithm is used that discretizes baoundaries itself +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contiguous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1") + +# ---- create two cylinders + +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- Analysis of the geometry + +print("Analysis of the geometry mechanic :") + +subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) + +print("number of Shells in mechanic : ",len(subShellList)) +print("number of Faces in mechanic : ",len(subFaceList)) +print("number of Edges in mechanic : ",len(subEdgeList)) + +### ---------------------------- SMESH -------------------------------------- + +print("-------------------------- create Mesh, algorithm, hypothesis") + +mesh = smesh.Mesh(mechanic, "Mesh_mechanic"); +netgen = mesh.Triangle(smeshBuilder.NETGEN) +netgen.SetMaxSize( 50 ) +#netgen.SetSecondOrder( 0 ) +netgen.SetFineness( smeshBuilder.Fine ) +netgen.SetQuadAllowed( 1 ) +#netgen.SetOptimize( 1 ) + +print("-------------------------- compute mesh") +ret = mesh.Compute() +print(ret) +if ret != 0: + print("Information about the MeshcompShel:") + print("Number of nodes : ", mesh.NbNodes()) + print("Number of edges : ", mesh.NbEdges()) + print("Number of faces : ", mesh.NbFaces()) + print("Number of triangles : ", mesh.NbTriangles()) + print("Number of quadrangles : ", mesh.NbQuadrangles()) + print("Number of volumes : ", mesh.NbVolumes()) + print("Number of tetrahedrons : ", mesh.NbTetras()) + +else: + print("problem when computing the mesh") + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_mechanic_tetra.py b/test/SMESH_mechanic_tetra.py new file mode 100644 index 000000000..1e424cbdd --- /dev/null +++ b/test/SMESH_mechanic_tetra.py @@ -0,0 +1,161 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_withHole.py +# Author : Lucien PIGNOLONI +# Module : SMESH +# $Header$ +# +import salome +salome.salome_init_without_session() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contiguous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1") + +# ---- create two cylinders + +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- Analysis of the geometry + +print("Analysis of the geometry mechanic :") + +subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) + +print("number of Shells in mechanic : ",len(subShellList)) +print("number of Faces in mechanic : ",len(subFaceList)) +print("number of Edges in mechanic : ",len(subEdgeList)) + +### ---------------------------- SMESH -------------------------------------- + +shape_mesh = salome.IDToObject( Id_mechanic ) + +mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic_tetra") + +print("-------------------------- add hypothesis to main mechanic") + +numberOfSegment = 10 + +algo1 = mesh.Segment() +hypNbSeg = algo1.NumberOfSegments(numberOfSegment) +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) +smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) + + +maxElementArea = 20 + +algo2 = mesh.Triangle(smeshBuilder.MEFISTO) +hypArea = algo2.MaxElementArea(maxElementArea) +print(hypArea.GetName()) +print(hypArea.GetId()) +print(hypArea.GetMaxElementArea()) +smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) + + +maxElementVolume = 20 + +algo3 = mesh.Tetrahedron(smeshBuilder.NETGEN) +hypVolume = algo3.MaxElementVolume(maxElementVolume) +print(hypVolume.GetName()) +print(hypVolume.GetId()) +print(hypVolume.GetMaxElementVolume()) +smesh.SetName(hypVolume, "maxElementVolume_" + str(maxElementVolume)) + + +print("-------------------------- compute the mesh of the mechanic piece") +mesh.Compute() + +print("Information about the Mesh_mechanic_tetra:") +print("Number of nodes : ", mesh.NbNodes()) +print("Number of edges : ", mesh.NbEdges()) +print("Number of faces : ", mesh.NbFaces()) +print("Number of triangles : ", mesh.NbTriangles()) +print("Number of quadrangles: ", mesh.NbQuadrangles()) +print("Number of volumes : ", mesh.NbVolumes()) +print("Number of tetrahedrons: ", mesh.NbTetras()) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_reg.py b/test/SMESH_reg.py new file mode 100644 index 000000000..b1981f487 --- /dev/null +++ b/test/SMESH_reg.py @@ -0,0 +1,119 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_reg.py +# Module : SMESH +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +from salome.StdMeshers import StdMeshersBuilder + + +# ---- define a box +print("Define box") +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +# ---- add faces of box to study +print("Add faces to study") +idface = [] +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +for f in subShapeList: + name = geompy.SubShapeName(f, box) + print(name) + idface.append( geompy.addToStudyInFather(box, f, name) ) + +# ---- add edges of box to study +print("Add edges to study") +idedge = [] +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) +for f in subShapeList: + name = geompy.SubShapeName(f, box) + print(name) + idedge.append( geompy.addToStudyInFather(box, f, name) ) + +salome.sg.updateObjBrowser() + +# ---- launch SMESH +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init() +smesh.UpdateStudy() + +# ---- Creating meshes + +box = salome.IDToObject(idbox) +names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ] + + +print("-------------------------- Create ", names[0], " mesh") +mesh = smesh.Mesh(box, names[0]) +algo = mesh.Segment() +hyp = algo.NumberOfSegments(7) +hyp.SetDistrType(0) +smesh.SetName(hyp, "NumberOfSegmentsReg") +algo = mesh.Triangle() +algo.MaxElementArea(2500) + +print("-------------------------- Create ", names[1], " mesh") +mesh = smesh.Mesh(box, names[1]) +algo = mesh.Segment() +hyp = algo.NumberOfSegments(7) +hyp.SetDistrType(1) +hyp.SetScaleFactor(2) +smesh.SetName(hyp, "NumberOfSegmentsScale") +algo = mesh.Triangle() +algo.MaxElementArea(2500) + +print("-------------------------- Create ", names[2], " mesh") +mesh = smesh.Mesh(box,names[2]) +algo = mesh.Segment() +hyp = algo.NumberOfSegments(7) +hyp.SetDistrType(2) +hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] ) +hyp.SetConversionMode(0) +smesh.SetName(hyp, "NumberOfSegmentsTable") +algo = mesh.Triangle() +algo.MaxElementArea(2500) + +print("-------------------------- Create ", names[3], " mesh") +mesh = smesh.Mesh(box, names[3]) +algo = mesh.Segment() +hyp = algo.NumberOfSegments(10) +hyp.SetDistrType(3) +hyp.SetExpressionFunction("sin(3*t)") +hyp.SetConversionMode(1) +smesh.SetName(hyp, "NumberOfSegmentsExpr") +algo = mesh.Triangle() +algo.MaxElementArea(2500) + + +salome.sg.updateObjBrowser() + diff --git a/test/SMESH_test.py b/test/SMESH_test.py new file mode 100644 index 000000000..c6504e37a --- /dev/null +++ b/test/SMESH_test.py @@ -0,0 +1,150 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +# File : SMESH_test.py +# Module : SMESH +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idb = geompy.addToStudy(box, "box") + +# ---- add first face of box in study + +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +idf = geompy.addToStudyInFather(box, face, name) + +# ---- add shell from box in study + +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +shell = subShellList[0] +name = geompy.SubShapeName(shell, box) +ids = geompy.addToStudyInFather(box, shell, name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0]; +name = geompy.SubShapeName(edge, face) +ide = geompy.addToStudyInFather(face, edge, name) + +# ---- SMESH + +smesh.UpdateStudy() +box = salome.IDToObject(idb) +mesh = smesh.Mesh(box, "Meshbox") + +print("-------------------------- add hypothesis to box") + +algo_1 = mesh.Segment(box) +hyp = algo_1.LocalLength(100) +print(hyp.GetName()) +print(hyp.GetId()) +print(hyp.GetLength()) + +algo_2 = mesh.Triangle(smeshBuilder.MEFISTO, box) +hyp = algo_2.MaxElementArea(5000) +print(hyp.GetName()) +print(hyp.GetId()) +print(hyp.GetMaxElementArea()) + +smesh.SetName(algo_2.GetSubMesh(), "SubMeshBox") + + +print("-------------------------- add hypothesis to edge") + +edge = salome.IDToObject(ide) + +algo_3 = mesh.Segment(edge) +hyp = algo_3.LocalLength(100) +print(hyp.GetName()) +print(hyp.GetId()) +print(hyp.GetLength()) + +smesh.SetName(algo_3.GetSubMesh(), "SubMeshEdge") + + +print("-------------------------- compute face") + +face = salome.IDToObject(idf) + +ret = mesh.Compute(face) +print(ret) +log = [] #mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after +for a in log: + print("-------") + ii = 0 + ir = 0 + comType = a.commandType + if comType == 0: + for i in range(a.number): + ind = a.indexes[ii] + ii = ii+1 + r1 = a.coords[ir] + ir = ir+1 + r2 = a.coords[ir] + ir = ir+1 + r3 = a.coords[ir] + ir = ir+1 + print("AddNode %i - %g %g %g" % (ind, r1, r2, r3)) + elif comType == 1: + for i in range(a.number): + ind = a.indexes[ii] + ii = ii+1 + i1 = a.indexes[ii] + ii = ii+1 + i2 = a.indexes[ii] + ii = ii+1 + print("AddEdge %i - %i %i" % (ind, i1, i2)) + elif comType == 2: + for i in range(a.number): + ind = a.indexes[ii] + print(ind) + ii = ii+1 + print(ii) + i1 = a.indexes[ii] + ii = ii+1 + i2 = a.indexes[ii] + print(i2) + ii = ii+1 + print("ii", ii) + i3 = a.indexes[ii] + print(i3) + #ii = ii+1 + ii = ii+1 + print("AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_test0.py b/test/SMESH_test0.py new file mode 100644 index 000000000..60b05309f --- /dev/null +++ b/test/SMESH_test0.py @@ -0,0 +1,66 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test0.py +# Module : SMESH +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +# ---- add first face of box in study + +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +print(name) +idface = geompy.addToStudyInFather(box, face, name) + +# ---- add shell from box in study + +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +shell = subShellList[0] +name = geompy.SubShapeName(shell, box) +print(name) +idshell = geompy.addToStudyInFather(box, shell, name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0] +name = geompy.SubShapeName(edge, face) +print(name) +idedge = geompy.addToStudyInFather(face, edge, name) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_test1.py b/test/SMESH_test1.py new file mode 100644 index 000000000..1f158a694 --- /dev/null +++ b/test/SMESH_test1.py @@ -0,0 +1,113 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test1.py +# Module : SMESH +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +# ---- add first face of box in study + +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +print(name) +idface = geompy.addToStudyInFather(box, face, name) + +# ---- add shell from box in study + +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +shell = subShellList[0] +name = geompy.SubShapeName(shell, box) +print(name) +idshell = geompy.addToStudyInFather(box, shell, name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0] +name = geompy.SubShapeName(edge, face) +print(name) +idedge = geompy.addToStudyInFather(face, edge, name) + + +# ---- SMESH + +# ---- Init a Mesh with the box + +mesh = smesh.Mesh(box, "Meshbox") + +print("-------------------------- add hypothesis to box") +algoReg1 = mesh.Segment() +hypNbSeg1 = algoReg1.NumberOfSegments(7) +print(hypNbSeg1.GetName()) +print(hypNbSeg1.GetId()) +print(hypNbSeg1.GetNumberOfSegments()) +smesh.SetName(hypNbSeg1, "NumberOfSegments_7") + +algoMef1 = mesh.Triangle() +hypArea1 = algoMef1.MaxElementArea(2500) +print(hypArea1.GetName()) +print(hypArea1.GetId()) +print(hypArea1.GetMaxElementArea()) +smesh.SetName(hypArea1, "MaxElementArea_2500") + +# ---- add hypothesis to edge +print("-------------------------- add hypothesis to edge") +edge = salome.IDToObject(idedge) + +algoReg2 = mesh.Segment(edge) +hypLen1 = algoReg2.LocalLength(100) +smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge") +print(hypLen1.GetName()) +print(hypLen1.GetId()) +print(hypLen1.GetLength()) +smesh.SetName(hypLen1, "Local_Length_100") + +# ---- add hypothesis to face +print("-------------------------- add hypothesis to face") +face = salome.IDToObject(idface) + +algoMef2 = mesh.Triangle(face) +hypArea2 = algoMef2.MaxElementArea(500) +smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace") +print(hypArea2.GetName()) +print(hypArea2.GetId()) +print(hypArea2.GetMaxElementArea()) +smesh.SetName(hypArea2, "MaxElementArea_500") + + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_test1_AndDisplay.py b/test/SMESH_test1_AndDisplay.py new file mode 100644 index 000000000..6c53c0a8b --- /dev/null +++ b/test/SMESH_test1_AndDisplay.py @@ -0,0 +1,118 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test1.py +# Module : SMESH +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +# ---- add first face of box in study + +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +print(name) +idface = geompy.addToStudyInFather(box, face, name) + +# ---- add shell from box in study + +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +shell = subShellList[0] +name = geompy.SubShapeName(shell, box) +print(name) +idshell = geompy.addToStudyInFather(box, shell, name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0] +name = geompy.SubShapeName(edge, face) +print(name) +idedge = geompy.addToStudyInFather(face, edge, name) + + +# ---- SMESH + +# ---- Init a Mesh with the box + +mesh = smesh.Mesh(box, "Meshbox") + +print("-------------------------- add hypothesis to box") +algoReg1 = mesh.Segment() +hypNbSeg1 = algoReg1.NumberOfSegments(7) +print(hypNbSeg1.GetName()) +print(hypNbSeg1.GetId()) +print(hypNbSeg1.GetNumberOfSegments()) +smesh.SetName(hypNbSeg1, "NumberOfSegments_7") + +algoMef1 = mesh.Triangle() +hypArea1 = algoMef1.MaxElementArea(2500) +print(hypArea1.GetName()) +print(hypArea1.GetId()) +print(hypArea1.GetMaxElementArea()) +smesh.SetName(hypArea1, "MaxElementArea_2500") + +# ---- add hypothesis to edge +print("-------------------------- add hypothesis to edge") +edge = salome.IDToObject(idedge) + +algoReg2 = mesh.Segment(edge) +hypLen1 = algoReg2.LocalLength(100) +smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge") +print(hypLen1.GetName()) +print(hypLen1.GetId()) +print(hypLen1.GetLength()) +smesh.SetName(hypLen1, "Local_Length_100") + +# ---- add hypothesis to face +print("-------------------------- add hypothesis to face") +face = salome.IDToObject(idface) + +algoMef2 = mesh.Triangle(face) +hypArea2 = algoMef2.MaxElementArea(500) +smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace") +print(hypArea2.GetName()) +print(hypArea2.GetId()) +print(hypArea2.GetMaxElementArea()) +smesh.SetName(hypArea2, "MaxElementArea_500") + +mesh.Compute() + +salome.sg.updateObjBrowser() + +sg = salome.ImportComponentGUI('SMESH') +if not isinstance(sg, type(salome.salome_ComponentGUI)): + sg.CreateAndDisplayActor('0:1:2:3') diff --git a/test/SMESH_test2.py b/test/SMESH_test2.py new file mode 100644 index 000000000..562519ca0 --- /dev/null +++ b/test/SMESH_test2.py @@ -0,0 +1,38 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test2.py +# Module : SMESH +# +from SMESH_test1 import * + +# ---- compute box + +print("-------------------------- compute box") +ret = mesh.Compute() +print(ret) +log = mesh.GetLog(0); # no erase trace +# for linelog in log: +# print(linelog) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_test3.py b/test/SMESH_test3.py new file mode 100644 index 000000000..edfbe6ec0 --- /dev/null +++ b/test/SMESH_test3.py @@ -0,0 +1,104 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test3.py +# Module : SMESH +#import salome +# +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() +import math + +pi = math.pi + +# --------------------------------------------- +xa = math.sin(pi/12) +ya = 0 +za = math.cos(pi/12) + +xb = 0 +yb = math.sin(pi/18) +zb = math.cos(pi/18) + +xc = math.cos(-pi/18) +yc = 0 +zc = math.sin(-pi/18) + +rc1 = 150 +rc2 = 150 +rc3 = 150 +rc4 = 300 + +hc1 = 300 +hc2 = 2*hc1 +hc3 = 2*hc1 +hc4 = 2*hc1 + +# --------------------------------------------- +point_0 = geompy.MakeVertex(0, 0, 0) +point_z = geompy.MakeVertex(0, 0, 1) + +point_a = geompy.MakeVertex(xa, ya, za) +point_b = geompy.MakeVertex(xb, yb, zb) +point_c = geompy.MakeVertex(xc, yc, zc) + +dir_z = geompy.MakeVector(point_0, point_z) +dir_a = geompy.MakeVector(point_0, point_a) +dir_b = geompy.MakeVector(point_0, point_b) +dir_c = geompy.MakeVector(point_0, point_c) + +axe_z = dir_z +axe_a = dir_a +axe_b = dir_b +axe_c = dir_c + +cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1) + +cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2) +cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1) + +cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3) +cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1) + +cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4) +cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2) +cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0) +cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4) + +inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common + +blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut +blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2) + +blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common + +idblob = geompy.addToStudy(blob,"blob") +#idc = geompy.addToStudy(cyl_c,"cyl_c") +#idd = geompy.addToStudy(cyl_d,"cyl_d") diff --git a/test/SMESH_test4.py b/test/SMESH_test4.py new file mode 100644 index 000000000..1fd277308 --- /dev/null +++ b/test/SMESH_test4.py @@ -0,0 +1,80 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + + +# ---- GEOM + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +idface = geompy.addToStudyInFather(box, face, name) + +box = salome.IDToObject(idbox) +face = salome.IDToObject(idface) + +# ---- SMESH + +smesh.UpdateStudy() +mesh = smesh.Mesh(box, "Meshbox") + +# Set 1D algorithm/hypotheses to mesh +algo1 = mesh.Segment() +algo1.NumberOfSegments(10) + +# Set 2D algorithm/hypotheses to mesh +algo2 = mesh.Triangle(smeshBuilder.MEFISTO) +algo2.MaxElementArea(10) + +# Create submesh on face +algo3 = mesh.Segment(face) +algo3.NumberOfSegments(10) +algo4 = mesh.Triangle(smeshBuilder.MEFISTO, face) +algo4.MaxElementArea(100) +submesh = algo4.GetSubMesh() +smesh.SetName(submesh, "SubMeshFace") + + +mesh.Compute() + +faces = submesh.GetElementsByType(SMESH.FACE) +if len(faces) > 1: + print(len(faces), len(faces)/2) + group1 = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces") + group2 = mesh.CreateEmptyGroup(SMESH.FACE,"Another group of faces") + group1.Add(faces[:int(len(faces)/2)]) + group2.Add(faces[int(len(faces)/2):]) + +salome.sg.updateObjBrowser() diff --git a/test/SMESH_test5.py b/test/SMESH_test5.py new file mode 100644 index 000000000..eca5389e7 --- /dev/null +++ b/test/SMESH_test5.py @@ -0,0 +1,79 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# File : SMESH_test5.py +# Module : SMESH +# + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import CORBA +import os +import shutil +import tempfile + +aOutPath = tempfile.mkdtemp() + +def SetSObjName(theSObj,theName) : + ok, anAttr = theSObj.FindAttribute("AttributeName") + if ok: + aName = anAttr._narrow(SALOMEDS.AttributeName) + #print aName.__dict__ + aName.SetValue(theName) + +def ConvertMED2UNV(theFile): + print(theFile) + aMeshes, aResult = smesh.CreateMeshesFromMED(theFile) + print(aMeshes, aResult) + + for aMesh in aMeshes: + print(aMesh.GetName(), end=' ') + aMesh.SetName(os.path.basename(theFile)) + print(aMesh.GetName()) + + aFileName = os.path.join(aOutPath, theFile + ".unv") + aMesh.ExportUNV(aFileName) + + aMesh = smesh.CreateMeshesFromUNV(aFileName) + print(aMesh.GetName(), end=' ') + aMesh.SetName(os.path.basename(aFileName)) + print(aMesh.GetName()) + +aPath = os.path.join(os.getenv('DATA_DIR'), 'MedFiles') + +for aFileName in sorted(os.listdir(aPath)): + if os.path.splitext(aFileName)[-1] == ".med": + ConvertMED2UNV(os.path.join(aPath, aFileName)) + +if os.getenv('SMESH_KEEP_TMP_DIR') != '1': + shutil.rmtree(aOutPath) + +salome.sg.updateObjBrowser() diff --git a/test/ex00_all.py b/test/ex00_all.py new file mode 100644 index 000000000..ccbdf2de9 --- /dev/null +++ b/test/ex00_all.py @@ -0,0 +1,46 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 +# + +# ================================== +# Load all examples +# ----------------- +# +import ex01_cube2build +import ex02_cube2primitive +import ex03_cube2partition +import ex04_cube5tetraHexa +import ex05_hole1build +import ex06_hole1boolean +import ex07_hole1partition +import ex08_hole2build +import ex09_grid4build +import ex10_grid4geometry +import ex11_grid3partition +import ex12_grid17partition +import ex13_hole1partial +import ex14_cyl1holed +import ex15_cyl2geometry +import ex16_cyl2complementary +import ex17_dome1 +import ex18_dome2 +import ex19_sphereINcube diff --git a/test/ex01_cube2build.py b/test/ex01_cube2build.py new file mode 100644 index 000000000..ba1098e82 --- /dev/null +++ b/test/ex01_cube2build.py @@ -0,0 +1,326 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# Geometry +# ======== + +# A small cube centered and put on a great cube build by points, edges, faces and solids + +# Points +# ------ + +greatPoint111 = geompy.MakeVertex( 0, 0, 0) +greatPoint211 = geompy.MakeVertex(10, 0, 0) +greatPoint311 = geompy.MakeVertex(20, 0, 0) +greatPoint411 = geompy.MakeVertex(30, 0, 0) + +greatPoint121 = geompy.MakeVertex( 0, 10, 0) +greatPoint221 = geompy.MakeVertex(10, 10, 0) +greatPoint321 = geompy.MakeVertex(20, 10, 0) +greatPoint421 = geompy.MakeVertex(30, 10, 0) + +greatPoint112 = geompy.MakeVertex( 0, 0, 10) +greatPoint212 = geompy.MakeVertex(10, 0, 10) +greatPoint312 = geompy.MakeVertex(20, 0, 10) +greatPoint412 = geompy.MakeVertex(30, 0, 10) + +greatPoint122 = geompy.MakeVertex( 0, 10, 10) +greatPoint222 = geompy.MakeVertex(10, 10, 10) +greatPoint322 = geompy.MakeVertex(20, 10, 10) +greatPoint422 = geompy.MakeVertex(30, 10, 10) + +greatPoint113 = geompy.MakeVertex( 0, 0, 20) +greatPoint213 = geompy.MakeVertex(10, 0, 20) +greatPoint313 = geompy.MakeVertex(20, 0, 20) +greatPoint413 = geompy.MakeVertex(30, 0, 20) + +greatPoint123 = geompy.MakeVertex( 0, 10, 20) +greatPoint223 = geompy.MakeVertex(10, 10, 20) +greatPoint323 = geompy.MakeVertex(20, 10, 20) +greatPoint423 = geompy.MakeVertex(30, 10, 20) + +greatPoint114 = geompy.MakeVertex( 0, 0, 30) +greatPoint214 = geompy.MakeVertex(10, 0, 30) +greatPoint314 = geompy.MakeVertex(20, 0, 30) +greatPoint414 = geompy.MakeVertex(30, 0, 30) + +greatPoint124 = geompy.MakeVertex( 0, 10, 30) +greatPoint224 = geompy.MakeVertex(10, 10, 30) +greatPoint324 = geompy.MakeVertex(20, 10, 30) +greatPoint424 = geompy.MakeVertex(30, 10, 30) + + +smallPoint111 = greatPoint222 +smallPoint211 = greatPoint322 +smallPoint121 = geompy.MakeVertex(10, 20, 10) +smallPoint221 = geompy.MakeVertex(20, 20, 10) + +smallPoint112 = greatPoint223 +smallPoint212 = greatPoint323 +smallPoint122 = geompy.MakeVertex(10, 20, 20) +smallPoint222 = geompy.MakeVertex(20, 20, 20) + +# Edges +# ----- + +smallEdgeX11 = geompy.MakeEdge(smallPoint111, smallPoint211) +smallEdgeX21 = geompy.MakeEdge(smallPoint121, smallPoint221) +smallEdgeX12 = geompy.MakeEdge(smallPoint112, smallPoint212) +smallEdgeX22 = geompy.MakeEdge(smallPoint122, smallPoint222) + +smallEdgeY11 = geompy.MakeEdge(smallPoint111, smallPoint121) +smallEdgeY21 = geompy.MakeEdge(smallPoint211, smallPoint221) +smallEdgeY12 = geompy.MakeEdge(smallPoint112, smallPoint122) +smallEdgeY22 = geompy.MakeEdge(smallPoint212, smallPoint222) + +smallEdgeZ11 = geompy.MakeEdge(smallPoint111, smallPoint112) +smallEdgeZ21 = geompy.MakeEdge(smallPoint211, smallPoint212) +smallEdgeZ12 = geompy.MakeEdge(smallPoint121, smallPoint122) +smallEdgeZ22 = geompy.MakeEdge(smallPoint221, smallPoint222) + + +greatEdgeX111 = geompy.MakeEdge(greatPoint111, greatPoint211) +greatEdgeX211 = geompy.MakeEdge(greatPoint211, greatPoint311) +greatEdgeX311 = geompy.MakeEdge(greatPoint311, greatPoint411) +greatEdgeX121 = geompy.MakeEdge(greatPoint121, greatPoint221) +greatEdgeX221 = geompy.MakeEdge(greatPoint221, greatPoint321) +greatEdgeX321 = geompy.MakeEdge(greatPoint321, greatPoint421) + +greatEdgeX112 = geompy.MakeEdge(greatPoint112, greatPoint212) +greatEdgeX212 = geompy.MakeEdge(greatPoint212, greatPoint312) +greatEdgeX312 = geompy.MakeEdge(greatPoint312, greatPoint412) +greatEdgeX122 = geompy.MakeEdge(greatPoint122, greatPoint222) +greatEdgeX222 = smallEdgeX11 +greatEdgeX322 = geompy.MakeEdge(greatPoint322, greatPoint422) + +greatEdgeX113 = geompy.MakeEdge(greatPoint113, greatPoint213) +greatEdgeX213 = geompy.MakeEdge(greatPoint213, greatPoint313) +greatEdgeX313 = geompy.MakeEdge(greatPoint313, greatPoint413) +greatEdgeX123 = geompy.MakeEdge(greatPoint123, greatPoint223) +greatEdgeX223 = smallEdgeX12 +greatEdgeX323 = geompy.MakeEdge(greatPoint323, greatPoint423) + +greatEdgeX114 = geompy.MakeEdge(greatPoint114, greatPoint214) +greatEdgeX214 = geompy.MakeEdge(greatPoint214, greatPoint314) +greatEdgeX314 = geompy.MakeEdge(greatPoint314, greatPoint414) +greatEdgeX124 = geompy.MakeEdge(greatPoint124, greatPoint224) +greatEdgeX224 = geompy.MakeEdge(greatPoint224, greatPoint324) +greatEdgeX324 = geompy.MakeEdge(greatPoint324, greatPoint424) + +greatEdgeY11 = geompy.MakeEdge(greatPoint111, greatPoint121) +greatEdgeY21 = geompy.MakeEdge(greatPoint211, greatPoint221) +greatEdgeY31 = geompy.MakeEdge(greatPoint311, greatPoint321) +greatEdgeY41 = geompy.MakeEdge(greatPoint411, greatPoint421) + +greatEdgeY12 = geompy.MakeEdge(greatPoint112, greatPoint122) +greatEdgeY22 = geompy.MakeEdge(greatPoint212, greatPoint222) +greatEdgeY32 = geompy.MakeEdge(greatPoint312, greatPoint322) +greatEdgeY42 = geompy.MakeEdge(greatPoint412, greatPoint422) + +greatEdgeY13 = geompy.MakeEdge(greatPoint113, greatPoint123) +greatEdgeY23 = geompy.MakeEdge(greatPoint213, greatPoint223) +greatEdgeY33 = geompy.MakeEdge(greatPoint313, greatPoint323) +greatEdgeY43 = geompy.MakeEdge(greatPoint413, greatPoint423) + +greatEdgeY14 = geompy.MakeEdge(greatPoint114, greatPoint124) +greatEdgeY24 = geompy.MakeEdge(greatPoint214, greatPoint224) +greatEdgeY34 = geompy.MakeEdge(greatPoint314, greatPoint324) +greatEdgeY44 = geompy.MakeEdge(greatPoint414, greatPoint424) + +greatEdgeZ111 = geompy.MakeEdge(greatPoint111, greatPoint112) +greatEdgeZ211 = geompy.MakeEdge(greatPoint211, greatPoint212) +greatEdgeZ311 = geompy.MakeEdge(greatPoint311, greatPoint312) +greatEdgeZ411 = geompy.MakeEdge(greatPoint411, greatPoint412) + +greatEdgeZ121 = geompy.MakeEdge(greatPoint121, greatPoint122) +greatEdgeZ221 = geompy.MakeEdge(greatPoint221, greatPoint222) +greatEdgeZ321 = geompy.MakeEdge(greatPoint321, greatPoint322) +greatEdgeZ421 = geompy.MakeEdge(greatPoint421, greatPoint422) + +greatEdgeZ112 = geompy.MakeEdge(greatPoint112, greatPoint113) +greatEdgeZ212 = geompy.MakeEdge(greatPoint212, greatPoint213) +greatEdgeZ312 = geompy.MakeEdge(greatPoint312, greatPoint313) +greatEdgeZ412 = geompy.MakeEdge(greatPoint412, greatPoint413) + +greatEdgeZ122 = geompy.MakeEdge(greatPoint122, greatPoint123) +greatEdgeZ222 = smallEdgeZ11 +greatEdgeZ322 = smallEdgeZ21 +greatEdgeZ422 = geompy.MakeEdge(greatPoint422, greatPoint423) + +greatEdgeZ113 = geompy.MakeEdge(greatPoint113, greatPoint114) +greatEdgeZ213 = geompy.MakeEdge(greatPoint213, greatPoint214) +greatEdgeZ313 = geompy.MakeEdge(greatPoint313, greatPoint314) +greatEdgeZ413 = geompy.MakeEdge(greatPoint413, greatPoint414) + +greatEdgeZ123 = geompy.MakeEdge(greatPoint123, greatPoint124) +greatEdgeZ223 = geompy.MakeEdge(greatPoint223, greatPoint224) +greatEdgeZ323 = geompy.MakeEdge(greatPoint323, greatPoint324) +greatEdgeZ423 = geompy.MakeEdge(greatPoint423, greatPoint424) + +# Faces +# ----- + +smallFaceX1 = geompy.MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12) +smallFaceX2 = geompy.MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22) +smallFaceY1 = geompy.MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21) +smallFaceY2 = geompy.MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22) +smallFaceZ1 = geompy.MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21) +smallFaceZ2 = geompy.MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22) + + +greatFaceX11 = geompy.MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121) +greatFaceX21 = geompy.MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221) +greatFaceX31 = geompy.MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321) +greatFaceX41 = geompy.MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421) + +greatFaceX12 = geompy.MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122) +greatFaceX22 = geompy.MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222) +greatFaceX32 = geompy.MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322) +greatFaceX42 = geompy.MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422) + +greatFaceX13 = geompy.MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123) +greatFaceX23 = geompy.MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223) +greatFaceX33 = geompy.MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323) +greatFaceX43 = geompy.MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423) + +greatFaceY111 = geompy.MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211) +greatFaceY211 = geompy.MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311) +greatFaceY311 = geompy.MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411) +greatFaceY121 = geompy.MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221) +greatFaceY221 = geompy.MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321) +greatFaceY321 = geompy.MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421) + +greatFaceY112 = geompy.MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212) +greatFaceY212 = geompy.MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312) +greatFaceY312 = geompy.MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412) +greatFaceY122 = geompy.MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222) +greatFaceY222 = smallFaceY1 +greatFaceY322 = geompy.MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422) + +greatFaceY113 = geompy.MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213) +greatFaceY213 = geompy.MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313) +greatFaceY313 = geompy.MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413) +greatFaceY123 = geompy.MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223) +greatFaceY223 = geompy.MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323) +greatFaceY323 = geompy.MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423) + +greatFaceZ11 = geompy.MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21) +greatFaceZ21 = geompy.MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31) +greatFaceZ31 = geompy.MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41) + +greatFaceZ12 = geompy.MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22) +greatFaceZ22 = geompy.MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32) +greatFaceZ32 = geompy.MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42) + +greatFaceZ13 = geompy.MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23) +greatFaceZ23 = geompy.MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33) +greatFaceZ33 = geompy.MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43) + +greatFaceZ14 = geompy.MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24) +greatFaceZ24 = geompy.MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34) +greatFaceZ34 = geompy.MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44) + +# Solids +# ------ + +smallBlock = geompy.MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2) + +greatBlock11 = geompy.MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12) +greatBlock21 = geompy.MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22) +greatBlock31 = geompy.MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32) + +greatBlock12 = geompy.MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13) +greatBlock22 = geompy.MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23) +greatBlock32 = geompy.MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33) + +greatBlock13 = geompy.MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14) +greatBlock23 = geompy.MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24) +greatBlock33 = geompy.MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34) + +# Compound +# -------- + +c_l = [] +c_l.append(smallBlock) +c_l.append(greatBlock11) +c_l.append(greatBlock21) +c_l.append(greatBlock31) +c_l.append(greatBlock12) +c_l.append(greatBlock22) +c_l.append(greatBlock32) +c_l.append(greatBlock13) +c_l.append(greatBlock23) +c_l.append(greatBlock33) + +piece = geompy.MakeCompound(c_l) + +# Add in study +# ------------ + +piece_id = geompy.addToStudy(piece, "ex01_cube2build") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +hexa = smesh.Mesh(piece, "ex01_cube2build:hexa") + +algo = hexa.Segment() +algo.NumberOfSegments(4) + +hexa.Quadrangle() + +hexa.Hexahedron() + +# Create local hypothesis +# ----------------------- + +algo = hexa.Segment(greatEdgeX111) + +algo.Arithmetic1D(1, 4) + +algo.Propagation() + +# Compute the mesh +# ---------------- + +hexa.Compute() + +# Update object browser +# --------------------- + +salome.sg.updateObjBrowser() diff --git a/test/ex02_cube2primitive.py b/test/ex02_cube2primitive.py new file mode 100644 index 000000000..627c10c0a --- /dev/null +++ b/test/ex02_cube2primitive.py @@ -0,0 +1,128 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# Geometry +# ======== + +# A small cube centered and put on a great cube build by primitive geometric functionalities + +# Values +# ------ + +ox = 0 +oy = 0 +oz = 0 + +arete = 10 + +# Points +# ------ + +blockPoint111 = geompy.MakeVertex(ox , oy, oz) +blockPoint211 = geompy.MakeVertex(ox+arete, oy, oz) +blockPoint112 = geompy.MakeVertex(ox , oy, oz+arete) +blockPoint212 = geompy.MakeVertex(ox+arete, oy, oz+arete) + +# Face and solid +# -------------- + +blockFace1 = geompy.MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) + +blockSolid11 = geompy.MakePrismVecH(blockFace1, geompy.MakeVectorDXDYDZ(0, 1, 0), arete) + +# Translations +# ------------ + +blockSolid21 = geompy.MakeTranslation(blockSolid11, arete, 0, 0) +blockSolid31 = geompy.MakeTranslation(blockSolid21, arete, 0, 0) + +blockSolid12 = geompy.MakeTranslation(blockSolid11, 0, 0, arete) +blockSolid22 = geompy.MakeTranslation(blockSolid12, arete, 0, 0) +blockSolid32 = geompy.MakeTranslation(blockSolid22, arete, 0, 0) + +blockSolid13 = geompy.MakeTranslation(blockSolid12, 0, 0, arete) +blockSolid23 = geompy.MakeTranslation(blockSolid13, arete, 0, 0) +blockSolid33 = geompy.MakeTranslation(blockSolid23, arete, 0, 0) + +blockSolid111 = geompy.MakeTranslation(blockSolid22, 0, arete, 0) + +# Compound and glue +# ----------------- + +c_l = [] +c_l.append(blockSolid11) +c_l.append(blockSolid21) +c_l.append(blockSolid31) +c_l.append(blockSolid12) +c_l.append(blockSolid22) +c_l.append(blockSolid32) +c_l.append(blockSolid13) +c_l.append(blockSolid23) +c_l.append(blockSolid33) +c_l.append(blockSolid111) + +c_cpd = geompy.MakeCompound(c_l) + +piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = geompy.addToStudy(piece, "ex02_cube2primitive") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa") + +algo = hexa.Segment() +algo.LocalLength(1) + +hexa.Quadrangle() + +hexa.Hexahedron() + +# Compute the mesh +# ---------------- + +hexa.Compute() + +# Update object browser +# --------------------- + +salome.sg.updateObjBrowser() diff --git a/test/ex03_cube2partition.py b/test/ex03_cube2partition.py new file mode 100644 index 000000000..8f6363908 --- /dev/null +++ b/test/ex03_cube2partition.py @@ -0,0 +1,115 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# Geometry +# ======== + +# A small cube centered and put on a great cube build with partition + +# Values +# ------ + +g_ox = 0 +g_oy = 0 +g_oz = 0 + +g_arete = 10 + +g_trim = 1000 + +# Points +# ------ + +v_arete2 = g_arete*2 +v_arete3 = g_arete*3 + +v_1 = geompy.MakeVertex(g_ox , g_oy , g_oz ) +v_2 = geompy.MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3) + +v_3 = geompy.MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete ) +v_4 = geompy.MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2) + +# Solids +# ------ + +s_base = geompy.MakeBoxTwoPnt(v_1, v_2) +s_haut = geompy.MakeBoxTwoPnt(v_3, v_4) + +# Partition +# --------- + +p_dir1 = geompy.MakeVectorDXDYDZ(1, 0, 0) +p_dir2 = geompy.MakeVectorDXDYDZ(0, 0, 1) +p_dir3 = geompy.MakeVectorDXDYDZ(0, 1, 0) + +p_tools = [] + +p_tools.append(geompy.MakePlane(v_3, p_dir1, g_trim)) +p_tools.append(geompy.MakePlane(v_4, p_dir1, g_trim)) +p_tools.append(geompy.MakePlane(v_3, p_dir2, g_trim)) +p_tools.append(geompy.MakePlane(v_4, p_dir2, g_trim)) +p_tools.append(geompy.MakePlane(v_3, p_dir3, g_trim)) + +piece = geompy.MakePartition([s_base, s_haut], p_tools, [], [], geompy.ShapeType["SOLID"]) + +# Study +# ----- + +piece_id = geompy.addToStudy(piece, "ex03_cube2partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa") + +algo = hexa.Segment() +algo.NumberOfSegments(5) + +hexa.Quadrangle() + +hexa.Hexahedron() + +# Compute the mesh +# ---------------- + +hexa.Compute() + +# Update object browser +# --------------------- + +salome.sg.updateObjBrowser() diff --git a/test/ex04_cube5tetraHexa.py b/test/ex04_cube5tetraHexa.py new file mode 100644 index 000000000..83229a5c5 --- /dev/null +++ b/test/ex04_cube5tetraHexa.py @@ -0,0 +1,120 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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, 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 salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# Geometry +# ======== + +# 5 box with a hexahedral mesh and with 2 box in tetrahedral mesh + +# Values +# ------ + +arete = 100 + +arete0 = 0 +arete1 = arete +arete2 = arete*2 +arete3 = arete*3 + +# Solids +# ------ + +box_tetra1 = geompy.MakeBox(arete0, arete0, 0, arete1, arete1, arete) + +box_ijk1 = geompy.MakeBox(arete1, arete0, 0, arete2, arete1, arete) + +box_hexa = geompy.MakeBox(arete1, arete1, 0, arete2, arete2, arete) + +box_ijk2 = geompy.MakeBox(arete2, arete1, 0, arete3, arete2, arete) + +box_tetra2 = geompy.MakeBox(arete2, arete2, 0, arete3 ,arete3, arete) + +# Piece +# ----- + +piece_cpd = geompy.MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2]) + +piece = geompy.MakeGlueFaces(piece_cpd, 1e-4) + +piece_id = geompy.addToStudy(piece, "ex04_cube5tetraHexa") + +# Meshing +# ======= + +# Create a hexahedral mesh +# ------------------------ + +mixed = smesh.Mesh(piece, "ex04_cube5tetraHexa:mixed") + +algo = mixed.Segment() + +algo.StartEndLength(3, 25) + +mixed.Quadrangle() + +mixed.Hexahedron() + +# Tetrahedral local mesh +# ---------------------- + +def localMesh(b, hyp): + box = geompy.GetInPlace(piece, b) + faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) + + i = 0 + n = len(faces) + while i