-# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2016 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.
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
-# 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.
+# 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.
#
-# 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
+# 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 smesh
-import SMESH
+
+import salome
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
+
import math
def GetNewNodes(mesh,Elems,OldNodes):
pass
return newnodes
-
+
# create empty mesh
-mesh = smesh.smesh.CreateEmptyMesh()
+mesh = smesh.Mesh()
-ed = mesh.GetMeshEditor()
tol = 0.001
# create a cross from quadrangle faces
# 1. create first edge and make extrusion along 0x
-n1 = ed.AddNode(55,-5,0)
-n2 = ed.AddNode(55,5,0)
-e1 = ed.AddEdge([n1,n2])
+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))
-ed.ExtrusionSweep([e1],dir1,11)
+mesh.ExtrusionSweep([e1],dir1,11)
# 2. create second edge and make extrusion along 0y
-n3 = ed.AddNode(-5,-55,0)
-n4 = ed.AddNode(5,-55,0)
-e2 = ed.AddEdge([n3,n4])
+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))
-ed.ExtrusionSweep([e2],dir2,11)
+mesh.ExtrusionSweep([e2],dir2,11)
# since result has coincident nodes and faces
# we have to make merge
-nodes = ed.FindCoincidentNodes(0.001)
-ed.MergeNodes(nodes)
-ed.MergeEqualElements()
+nodes = mesh.FindCoincidentNodes(0.001)
+mesh.MergeNodes(nodes)
+mesh.MergeEqualElements()
# make extrusion faces along 0z
faces = mesh.GetElementsByType(SMESH.FACE)
# during extrusion
for i in range(0,nbzsteps):
- ed.ExtrusionSweep(faces,dir3,1)
+ mesh.ExtrusionSweep(faces,dir3,1)
# find top faces after each extrusion and keep them
- res = ed.GetLastCreatedElems()
+ res = mesh.GetLastCreatedElems()
nbr = len(res)
nfaces = []
for j in res:
axisr1 = SMESH.AxisStruct(0,0,0,0,0,1)
for i in range(0,nbzsteps):
ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps))
- ed.Rotate(newfaces[i],axisr1,ang,0)
+ mesh.Rotate(newfaces[i],axisr1,ang,0)
# create circles
# create two edges and rotate them for creation
# full circle
-n5 = ed.AddNode(65,0,0)
-n6 = ed.AddNode(67.5,0,0)
-n7 = ed.AddNode(70,0,0)
-e56 = ed.AddEdge([n5,n6])
-e67 = ed.AddEdge([n6,n7])
+n5 = mesh.AddNode(65,0,0)
+n6 = mesh.AddNode(67.5,0,0)
+n7 = mesh.AddNode(70,0,0)
+e56 = mesh.AddEdge([n5,n6])
+e67 = mesh.AddEdge([n6,n7])
axisr2 = SMESH.AxisStruct(65,0,0,0,1,0)
-ed.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
-res = ed.GetLastCreatedElems()
+mesh.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
+res = mesh.GetLastCreatedElems()
faces1 = []
for i in res:
nbn = mesh.GetElemNbNodes(i)
# create other two edges and rotate them for creation
# other full circle
-n8 = ed.AddNode(-65,0,0)
-n9 = ed.AddNode(-67.5,0,0)
-n10 = ed.AddNode(-70,0,0)
-e8 = ed.AddEdge([n8,n9])
-e9 = ed.AddEdge([n9,n10])
+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)
-ed.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
-res = ed.GetLastCreatedElems()
+mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
+res = mesh.GetLastCreatedElems()
faces2 = []
for i in res:
nbn = mesh.GetElemNbNodes(i)
# there are coincident nodes after rotation
# therefore we have to merge nodes
-nodes = ed.FindCoincidentNodes(0.001)
-ed.MergeNodes(nodes)
+nodes = mesh.FindCoincidentNodes(0.001)
+mesh.MergeNodes(nodes)
nbcircs = 2
nbrsteps = 24
oldnodes = newnodes
nodes = []
-ed.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
-res = ed.GetLastCreatedElems()
+mesh.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
+res = mesh.GetLastCreatedElems()
for i in range(0,nbrs):
volumes = []
newnodes = GetNewNodes(mesh,volumes,oldnodes)
for j in newnodes:
xyz = mesh.GetNodeXYZ(j)
- ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
+ mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
pass
oldnodes = newnodes
pass
oldnodes = newnodes
nodes = []
-ed.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
-res = ed.GetLastCreatedElems()
+mesh.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
+res = mesh.GetLastCreatedElems()
for i in range(0,nbrs):
volumes = []
newnodes = GetNewNodes(mesh,volumes,oldnodes)
for j in newnodes:
xyz = mesh.GetNodeXYZ(j)
- ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
+ mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
pass
oldnodes = newnodes
pass
-
+salome.sg.updateObjBrowser(1)