import libSALOME_Swig
SalomeGUI = libSALOME_Swig.SALOMEGUI_Swig()
-#
-# ==================================================================
-# General helper function for GUI programming actions
-# ==================================================================
-#
-# Get the active study
-#
-def getActiveStudy():
- """
- This returns a study object that corresponds to the active
- study. The active study is a GUI concept: it's the study currently
- active on the desktop.
- """
- study = services.getStudy()
- return study
-
#
# ==================================================================
# Functions to manipulate the objects in the browser (generic)
'''
sobj = None
entry = None
- study = getActiveStudy()
+ study = services.getStudy()
if SalomeGUI.SelectedCount() == 1:
# We only considere the first element of the list. If you need
# something else, create another function in your own context.
'''
sobj, entry = getSObjectSelected()
if ( sobj ):
- study = getActiveStudy()
+ study = services.getStudy()
builder = study.NewBuilder()
builder.RemoveObject( sobj )
SalomeGUI.updateObjBrowser()
#
# Definitions:
-# - the SObject is an item in the active study (Study Object).
+# - the SObject is an item in the study (Study Object).
# - the entry is the identifier of an item.
# - the object (geom object or smesh object) is a CORBA servant
# embedded in the SALOME component container and with a reference in
from salome.geom import geomtools
-def createGeometry(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
+def createGeometry(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
'''
This function creates the geometry on the specified study and with
given parameters.
Tube = geompy.MakeCut(CylinderExt, CylinderInt)
return Tube
-def createGeometryWithPartition(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
+def createGeometryWithPartition(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
'''
This function create the geometrical shape with a partition so
that the hexaedric algorithm could be used for meshing.
'''
- shape = createGeometry(study,radius,length,width)
+ shape = createGeometry(radius,length,width)
# We have to create a partition so that we can use an hexaedric
# meshing algorithm.
return mesh
-def createModel(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH):
+def createModel(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH):
'''
This function create the geomtrical shape AND the associated mesh.
'''
# We first create a shape with a partition so that the hexaedric
# algorithm could be used.
- shape = createGeometryWithPartition(study,radius,length,width)
+ shape = createGeometryWithPartition(radius,length,width)
# Then the mesh can be defined and computed
mesh = createMesh(shape)
#
def TEST_createGeometry():
salome.salome_init()
- theStudy=salome.myStudy
- createGeometry(theStudy)
+ createGeometry()
def TEST_createMesh():
salome.salome_init()
- shape = createGeometryWithPartition(salome.myStudy)
+ shape = createGeometryWithPartition()
mesh = createMesh(shape)
def TEST_createModel():
salome.salome_init()
- theStudy=salome.myStudy
- createModel(theStudy)
+ createModel()
def TEST_exportModel():
salome.salome_init()
- shape = createGeometryWithPartition(salome.myStudy)
- mesh = createMesh()
+ shape = createGeometryWithPartition()
+ mesh = createMesh(shape)
exportModel(mesh,"tubemesh.med")
if __name__ == "__main__":
# Helper functions to add/remove a geometrical shape in/from the study
# ======================================================================
-def addToStudy(study,shape,shapeName,folderName=None):
+def addToStudy(shape,shapeName,folderName=None):
"""
Add a GEOM shape in the study. It returns the associated entry
that corresponds to the identifier of the entry in the study. This
return entry
-def removeFromStudy(study,shapeStudyEntry):
+def removeFromStudy(shapeStudyEntry):
"""
This removes the specified entry from the study. Note that this
operation does not destroy the underlying GEOM object, neither
# Helper functions for a complete suppression of a shape from the
# SALOME session.
# ======================================================================
-def deleteShape(study,shapeStudyEntry):
+def deleteShape(shapeStudyEntry):
"""
This completly deletes a geom shape.
3. destroy the underlying geom object
"""
eraseShape(shapeStudyEntry)
- shape = removeFromStudy(study, shapeStudyEntry)
+ shape = removeFromStudy(shapeStudyEntry)
if shape is not None:
shape.Destroy()
"""
import salome
salome.salome_init()
- study = salome.myStudy
+ study = salome.myStudy
from salome.geom import geomtools
geompy = geomtools.getGeompy()
# folder. A name must be specified. The register operation
# (addToStudy) returns an identifier of the entry in the study.
cylinderName = "cyl.r%s.l%s"%(radius,length)
- cylinderStudyEntry = addToStudy(study, cylinder, cylinderName)
+ cylinderStudyEntry = addToStudy(cylinder, cylinderName)
# Display the registered shape in a viewer
displayShape(cylinderStudyEntry)
radius = 10
sphere = geompy.MakeSphereR(radius)
sphereName = "sph.r%s"%radius
- sphereStudyEntry = addToStudy(study, sphere, sphereName)
+ sphereStudyEntry = addToStudy(sphere, sphereName)
displayShape(sphereStudyEntry)
# --------------------------------------------------
box = geompy.MakeBoxDXDYDZ(length,length,length)
boxName = "box.l%s"%length
folderName = "boxset"
- boxStudyEntry = addToStudy(study, box, boxName, folderName)
+ boxStudyEntry = addToStudy(box, boxName, folderName)
displayShape(boxStudyEntry,PreviewColor)
# --------------------------------------------------
# SALOME session (erase from viewer, remove from study and finnaly
# destroy the object). This is done by a simple call to
# deleteShape().
- deleteShape(study,cylinderStudyEntry)
+ deleteShape(cylinderStudyEntry)
# --------------------------------------------------
# At the end of the executioon of this test, you should have in