X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fsalome%2Fexamples%2Fcartesian_algo.py;h=e5651cb670a2a96a2e9c8492e8220d647ddd0582;hp=b15455f2824bec19b4d8a553cb3f01cbe5cbf617;hb=f0f67c0b47e58361bc50c7169734da604fbfca01;hpb=9a54694a0ab1e5cbc558a35c4606ceea4f7af2ef diff --git a/doc/salome/examples/cartesian_algo.py b/doc/salome/examples/cartesian_algo.py index b15455f28..e5651cb67 100644 --- a/doc/salome/examples/cartesian_algo.py +++ b/doc/salome/examples/cartesian_algo.py @@ -1,14 +1,24 @@ # Usage of Body Fitting algorithm -from smesh import * -SetCurrentStudy(salome.myStudy) + +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 salome_notebook + # create a sphere sphere = geompy.MakeSphereR( 50 ) geompy.addToStudy( sphere, "sphere" ) # create a mesh and assign a "Body Fitting" algo -mesh = Mesh( sphere ) +mesh = smesh.Mesh( sphere ) cartAlgo = mesh.BodyFitted() # define a cartesian grid using Coordinates @@ -40,3 +50,40 @@ print "nb hexahedra",mesh.NbHexas() print "nb tetrahedra",mesh.NbTetras() print "nb polyhedra",mesh.NbPolyhedrons() print + +# Example of customization of dirtections of the grid axes + +# make a box with non-orthogonal edges +xDir = geompy.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" ) +yDir = geompy.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" ) +zDir = geompy.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" ) +face = geompy.MakePrismVecH( xDir, yDir, 1.0 ) +box = geompy.MakePrismVecH( face, zDir, 1.0, theName="box" ) + +spc = "0.1" # spacing + +# default axes +mesh = smesh.Mesh( box, "custom axes") +algo = mesh.BodyFitted() +algo.SetGrid( spc, spc, spc, 10000 ) +mesh.Compute() +print "Default axes" +print " nb hex:",mesh.NbHexas() + +# set axes using edges of the box +algo.SetAxesDirs( xDir, [-0.1,1,0], zDir ) +mesh.Compute() +print "Manual axes" +print " nb hex:",mesh.NbHexas() + +# set optimal orthogonal axes +algo.SetOptimalAxesDirs( isOrthogonal=True ) +mesh.Compute() +print "Optimal orthogonal axes" +print " nb hex:",mesh.NbHexas() + +# set optimal non-orthogonal axes +algo.SetOptimalAxesDirs( isOrthogonal=False ) +mesh.Compute() +print "Optimal non-orthogonal axes" +print " nb hex:",mesh.NbHexas()