mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 14:40:33 +05:00
PR: distributed geom and smesh scripts: first step
This commit is contained in:
parent
dee3117354
commit
9f6e75062d
@ -34,10 +34,9 @@ from salome import *
|
|||||||
# retrieve GEOM engine in try/except block
|
# retrieve GEOM engine in try/except block
|
||||||
# to avoid problems in some cases, e.g. when generating documentation
|
# to avoid problems in some cases, e.g. when generating documentation
|
||||||
try:
|
try:
|
||||||
# get GEOM engine
|
# get GEOM engine and initialize GEOM with current study
|
||||||
geom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" )
|
engineGeom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" )
|
||||||
# initialize GEOM with current study
|
geom = geompyDC.geomInstance(salome.myStudy, engineGeom)
|
||||||
geom.init_geom( salome.myStudy )
|
|
||||||
|
|
||||||
# export the methods of geompyDC
|
# export the methods of geompyDC
|
||||||
for k in dir( geom ):
|
for k in dir( geom ):
|
||||||
@ -50,3 +49,26 @@ try:
|
|||||||
except:
|
except:
|
||||||
geom = None
|
geom = None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print """
|
||||||
|
===============================================================================
|
||||||
|
WARNING: |
|
||||||
|
Usage of geompy.py is deprecated after SALOME V6.6! |
|
||||||
|
geompy.py will be removed in a future version! |
|
||||||
|
TODO: |
|
||||||
|
The following changes in your scripts are required to avoid this message: |
|
||||||
|
|
|
||||||
|
replace |
|
||||||
|
------- |
|
||||||
|
|
|
||||||
|
import geompy |
|
||||||
|
geompy.init_geom(theStudy) |
|
||||||
|
|
|
||||||
|
with |
|
||||||
|
---- |
|
||||||
|
|
|
||||||
|
import geompyDC |
|
||||||
|
geompy = geompyDC.geomInstance(theStudy) |
|
||||||
|
|
|
||||||
|
===============================================================================
|
||||||
|
"""
|
||||||
|
@ -17,18 +17,20 @@
|
|||||||
#
|
#
|
||||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
#
|
#
|
||||||
# File : geompy.py
|
|
||||||
|
# GEOM GEOM_SWIG : binding of C++ implementation with Python
|
||||||
|
# File : geompyDC.py
|
||||||
# Author : Paul RASCLE, EDF
|
# Author : Paul RASCLE, EDF
|
||||||
# Module : GEOM
|
# Module : GEOM
|
||||||
|
|
||||||
"""
|
"""
|
||||||
\namespace geompy
|
\namespace geompyDC
|
||||||
\brief Module geompy
|
\brief Module geompyDC
|
||||||
"""
|
"""
|
||||||
|
|
||||||
## @defgroup l1_geompy_auxiliary Auxiliary data structures and methods
|
## @defgroup l1_geompyDC_auxiliary Auxiliary data structures and methods
|
||||||
|
|
||||||
## @defgroup l1_geompy_purpose All package methods, grouped by their purpose
|
## @defgroup l1_geompyDC_purpose All package methods, grouped by their purpose
|
||||||
## @{
|
## @{
|
||||||
## @defgroup l2_import_export Importing/exporting geometrical objects
|
## @defgroup l2_import_export Importing/exporting geometrical objects
|
||||||
## @defgroup l2_creating Creating geometrical objects
|
## @defgroup l2_creating Creating geometrical objects
|
||||||
@ -92,17 +94,17 @@ from gsketcher import Sketcher3D
|
|||||||
|
|
||||||
## Enumeration ShapeType as a dictionary. \n
|
## Enumeration ShapeType as a dictionary. \n
|
||||||
## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
|
## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
|
ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
|
||||||
|
|
||||||
## Raise an Error, containing the Method_name, if Operation is Failed
|
## Raise an Error, containing the Method_name, if Operation is Failed
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def RaiseIfFailed (Method_name, Operation):
|
def RaiseIfFailed (Method_name, Operation):
|
||||||
if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY":
|
if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY":
|
||||||
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
|
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
|
||||||
|
|
||||||
## Return list of variables value from salome notebook
|
## Return list of variables value from salome notebook
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def ParseParameters(*parameters):
|
def ParseParameters(*parameters):
|
||||||
Result = []
|
Result = []
|
||||||
StringResult = []
|
StringResult = []
|
||||||
@ -134,7 +136,7 @@ def ParseParameters(*parameters):
|
|||||||
return Result
|
return Result
|
||||||
|
|
||||||
## Return list of variables value from salome notebook
|
## Return list of variables value from salome notebook
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def ParseList(list):
|
def ParseList(list):
|
||||||
Result = []
|
Result = []
|
||||||
StringResult = ""
|
StringResult = ""
|
||||||
@ -153,7 +155,7 @@ def ParseList(list):
|
|||||||
return Result, StringResult
|
return Result, StringResult
|
||||||
|
|
||||||
## Return list of variables value from salome notebook
|
## Return list of variables value from salome notebook
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def ParseSketcherCommand(command):
|
def ParseSketcherCommand(command):
|
||||||
Result = ""
|
Result = ""
|
||||||
StringResult = ""
|
StringResult = ""
|
||||||
@ -195,7 +197,7 @@ def ParseSketcherCommand(command):
|
|||||||
## \endcode
|
## \endcode
|
||||||
## @param data unpacked data - a string containing '1' and '0' symbols
|
## @param data unpacked data - a string containing '1' and '0' symbols
|
||||||
## @return data packed to the byte stream
|
## @return data packed to the byte stream
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def PackData(data):
|
def PackData(data):
|
||||||
"""
|
"""
|
||||||
Helper function which can be used to pack the passed string to the byte data.
|
Helper function which can be used to pack the passed string to the byte data.
|
||||||
@ -237,18 +239,18 @@ def PackData(data):
|
|||||||
## texture bitmap itself.
|
## texture bitmap itself.
|
||||||
##
|
##
|
||||||
## This function can be used to read the texture to the byte stream in order to pass it to
|
## This function can be used to read the texture to the byte stream in order to pass it to
|
||||||
## the AddTexture() function of geompy class.
|
## the AddTexture() function of geompyDC class.
|
||||||
## For example,
|
## For example,
|
||||||
## \code
|
## \code
|
||||||
## import geompy
|
## import geompyDC
|
||||||
## geompy.init_geom(salome.myStudy)
|
## geompy = geompyDC.geomInstance(salome.myStudy)
|
||||||
## texture = geompy.readtexture('mytexture.dat')
|
## texture = geompy.readtexture('mytexture.dat')
|
||||||
## texture = geompy.AddTexture(*texture)
|
## texture = geompy.AddTexture(*texture)
|
||||||
## obj.SetMarkerTexture(texture)
|
## obj.SetMarkerTexture(texture)
|
||||||
## \endcode
|
## \endcode
|
||||||
## @param fname texture file name
|
## @param fname texture file name
|
||||||
## @return sequence of tree values: texture's width, height in pixels and its byte stream
|
## @return sequence of tree values: texture's width, height in pixels and its byte stream
|
||||||
## @ingroup l1_geompy_auxiliary
|
## @ingroup l1_geompyDC_auxiliary
|
||||||
def ReadTexture(fname):
|
def ReadTexture(fname):
|
||||||
"""
|
"""
|
||||||
Read bitmap texture from the text file.
|
Read bitmap texture from the text file.
|
||||||
@ -257,7 +259,7 @@ def ReadTexture(fname):
|
|||||||
The function returns width and height of the pixmap in pixels and byte stream representing
|
The function returns width and height of the pixmap in pixels and byte stream representing
|
||||||
texture bitmap itself.
|
texture bitmap itself.
|
||||||
This function can be used to read the texture to the byte stream in order to pass it to
|
This function can be used to read the texture to the byte stream in order to pass it to
|
||||||
the AddTexture() function of geompy class.
|
the AddTexture() function of geompyDC class.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
fname texture file name
|
fname texture file name
|
||||||
@ -266,8 +268,8 @@ def ReadTexture(fname):
|
|||||||
sequence of tree values: texture's width, height in pixels and its byte stream
|
sequence of tree values: texture's width, height in pixels and its byte stream
|
||||||
|
|
||||||
Example of usage:
|
Example of usage:
|
||||||
import geompy
|
import geompyDC
|
||||||
geompy.init_geom(salome.myStudy)
|
geompy = geompyDC.geomInstance(salome.myStudy)
|
||||||
texture = geompy.readtexture('mytexture.dat')
|
texture = geompy.readtexture('mytexture.dat')
|
||||||
texture = geompy.AddTexture(*texture)
|
texture = geompy.AddTexture(*texture)
|
||||||
obj.SetMarkerTexture(texture)
|
obj.SetMarkerTexture(texture)
|
||||||
@ -307,11 +309,11 @@ def ReadTexture(fname):
|
|||||||
## Returns a long value from enumeration type
|
## Returns a long value from enumeration type
|
||||||
# Can be used for CORBA enumerator types like GEOM.shape_type
|
# Can be used for CORBA enumerator types like GEOM.shape_type
|
||||||
# @param theItem enumeration type
|
# @param theItem enumeration type
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
def EnumToLong(theItem):
|
def EnumToLong(theItem):
|
||||||
"""
|
"""
|
||||||
Returns a long value from enumeration type
|
Returns a long value from enumeration type
|
||||||
Can be used for CORBA enumerator types like geompy.ShapeType
|
Can be used for CORBA enumerator types like geompyDC.ShapeType
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
theItem enumeration type
|
theItem enumeration type
|
||||||
@ -359,11 +361,11 @@ def EnumToLong(theItem):
|
|||||||
# - EDGE: [nb_vertices]
|
# - EDGE: [nb_vertices]
|
||||||
#
|
#
|
||||||
# - VERTEX: [x y z]
|
# - VERTEX: [x y z]
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
kind = GEOM.GEOM_IKindOfShape
|
kind = GEOM.GEOM_IKindOfShape
|
||||||
|
|
||||||
## Information about closed/unclosed state of shell or wire
|
## Information about closed/unclosed state of shell or wire
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
class info:
|
class info:
|
||||||
"""
|
"""
|
||||||
Information about closed/unclosed state of shell or wire
|
Information about closed/unclosed state of shell or wire
|
||||||
@ -372,9 +374,55 @@ class info:
|
|||||||
CLOSED = 1
|
CLOSED = 1
|
||||||
UNCLOSED = 2
|
UNCLOSED = 2
|
||||||
|
|
||||||
class geompyDC(GEOM._objref_GEOM_Gen):
|
# Warning: geom is a singleton
|
||||||
|
geom = None
|
||||||
|
engine = None
|
||||||
|
doLcc = False
|
||||||
|
created = False
|
||||||
|
|
||||||
|
class geompyDC(object, GEOM._objref_GEOM_Gen):
|
||||||
|
|
||||||
|
def __new__(cls):
|
||||||
|
global engine
|
||||||
|
global geom
|
||||||
|
global doLcc
|
||||||
|
global created
|
||||||
|
print "__new__ ", engine, geom, doLcc, created
|
||||||
|
if geom is None:
|
||||||
|
# geom engine is either retrieved from engine, or created
|
||||||
|
geom = engine
|
||||||
|
# Following test avoids a recursive loop
|
||||||
|
if doLcc:
|
||||||
|
if geom is not None:
|
||||||
|
# geom engine not created: existing engine found
|
||||||
|
doLcc = False
|
||||||
|
if doLcc and not created:
|
||||||
|
doLcc = False
|
||||||
|
created = True
|
||||||
|
# FindOrLoadComponent called:
|
||||||
|
# 1. CORBA resolution of server
|
||||||
|
# 2. the __new__ method is called again
|
||||||
|
print "FindOrLoadComponent ", engine, geom, doLcc, created
|
||||||
|
geom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" )
|
||||||
|
else:
|
||||||
|
# FindOrLoadComponent not called
|
||||||
|
if geom is None:
|
||||||
|
# geompyDC instance is created from lcc.FindOrLoadComponent
|
||||||
|
created = True
|
||||||
|
print "super ", engine, geom, doLcc, created
|
||||||
|
geom = super(geompyDC,cls).__new__(cls)
|
||||||
|
else:
|
||||||
|
# geom engine not created: existing engine found
|
||||||
|
print "existing ", engine, geom, doLcc, created
|
||||||
|
pass
|
||||||
|
|
||||||
|
return geom
|
||||||
|
|
||||||
|
return geom
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
#global created
|
||||||
|
#print "-------- geompyDC __init__ --- ", created, self
|
||||||
GEOM._objref_GEOM_Gen.__init__(self)
|
GEOM._objref_GEOM_Gen.__init__(self)
|
||||||
self.myBuilder = None
|
self.myBuilder = None
|
||||||
self.myStudyId = 0
|
self.myStudyId = 0
|
||||||
@ -395,7 +443,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
self.AdvOp = None
|
self.AdvOp = None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
## @addtogroup l1_geompy_auxiliary
|
## @addtogroup l1_geompyDC_auxiliary
|
||||||
## @{
|
## @{
|
||||||
def init_geom(self,theStudy):
|
def init_geom(self,theStudy):
|
||||||
self.myStudy = theStudy
|
self.myStudy = theStudy
|
||||||
@ -543,7 +591,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
drwAttribute.SetDrawable(False)
|
drwAttribute.SetDrawable(False)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# end of l1_geompy_auxiliary
|
# end of l1_geompyDC_auxiliary
|
||||||
## @}
|
## @}
|
||||||
|
|
||||||
## @addtogroup l3_restore_ss
|
## @addtogroup l3_restore_ss
|
||||||
@ -4187,7 +4235,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
aShape Shape to be exploded.
|
aShape Shape to be exploded.
|
||||||
aType Type of sub-shapes to be retrieved (see geompy.ShapeType)
|
aType Type of sub-shapes to be retrieved (see geompy.ShapeType)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of sub-shapes of type theShapeType, contained in theShape.
|
List of sub-shapes of type theShapeType, contained in theShape.
|
||||||
@ -4208,7 +4256,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
Explode a shape on sub-shapes of a given type.
|
Explode a shape on sub-shapes of a given type.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
aShape Shape to be exploded (see geompy.ShapeType)
|
aShape Shape to be exploded (see geompy.ShapeType)
|
||||||
aType Type of sub-shapes to be retrieved (see geompy.ShapeType)
|
aType Type of sub-shapes to be retrieved (see geompy.ShapeType)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -6071,7 +6119,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
New GEOM.GEOM_Object, containing the result shape.
|
New GEOM.GEOM_Object, containing the result shape.
|
||||||
|
|
||||||
Example of usage:
|
Example of usage:
|
||||||
filletall = geompy.MakeFilletAll(prism, 10.)
|
filletall = geompy.MakeFilletAll(prism, 10.)
|
||||||
"""
|
"""
|
||||||
# Example: see GEOM_TestOthers.py
|
# Example: see GEOM_TestOthers.py
|
||||||
theR,Parameters = ParseParameters(theR)
|
theR,Parameters = ParseParameters(theR)
|
||||||
@ -9080,7 +9128,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
#
|
#
|
||||||
# @param theOriginal geometry object for copy
|
# @param theOriginal geometry object for copy
|
||||||
# @return unique object identifier
|
# @return unique object identifier
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
# @ref swig_MakeCopy "Example"
|
# @ref swig_MakeCopy "Example"
|
||||||
def MakeCopy(self,theOriginal):
|
def MakeCopy(self,theOriginal):
|
||||||
"""
|
"""
|
||||||
@ -9101,7 +9149,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
|
|
||||||
## Add Path to load python scripts from
|
## Add Path to load python scripts from
|
||||||
# @param Path a path to load python scripts from
|
# @param Path a path to load python scripts from
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
def addPath(self,Path):
|
def addPath(self,Path):
|
||||||
"""
|
"""
|
||||||
Add Path to load python scripts from
|
Add Path to load python scripts from
|
||||||
@ -9117,7 +9165,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
## Load marker texture from the file
|
## Load marker texture from the file
|
||||||
# @param Path a path to the texture file
|
# @param Path a path to the texture file
|
||||||
# @return unique texture identifier
|
# @return unique texture identifier
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
def LoadTexture(self, Path):
|
def LoadTexture(self, Path):
|
||||||
"""
|
"""
|
||||||
Load marker texture from the file
|
Load marker texture from the file
|
||||||
@ -9139,7 +9187,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
# appropriate reason (e.g. for identification of geometry object).
|
# appropriate reason (e.g. for identification of geometry object).
|
||||||
# @param obj geometry object
|
# @param obj geometry object
|
||||||
# @return unique object identifier
|
# @return unique object identifier
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
def getObjectID(self, obj):
|
def getObjectID(self, obj):
|
||||||
"""
|
"""
|
||||||
Get internal name of the object based on its study entry.
|
Get internal name of the object based on its study entry.
|
||||||
@ -9176,7 +9224,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
# @param Texture texture data
|
# @param Texture texture data
|
||||||
# @param RowData if @c True, @a Texture data are packed in the byte stream
|
# @param RowData if @c True, @a Texture data are packed in the byte stream
|
||||||
# @return unique texture identifier
|
# @return unique texture identifier
|
||||||
# @ingroup l1_geompy_auxiliary
|
# @ingroup l1_geompyDC_auxiliary
|
||||||
def AddTexture(self, Width, Height, Texture, RowData=False):
|
def AddTexture(self, Width, Height, Texture, RowData=False):
|
||||||
"""
|
"""
|
||||||
Add marker texture. Width and Height parameters
|
Add marker texture. Width and Height parameters
|
||||||
@ -9201,5 +9249,18 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
return ID
|
return ID
|
||||||
|
|
||||||
import omniORB
|
import omniORB
|
||||||
#Register the new proxy for GEOM_Gen
|
# Register the new proxy for GEOM_Gen
|
||||||
omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC)
|
omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC)
|
||||||
|
|
||||||
|
def geomInstance( study, instance=None):
|
||||||
|
print "geomInstance ", study, instance
|
||||||
|
global engine
|
||||||
|
global geom
|
||||||
|
global doLcc
|
||||||
|
engine = instance
|
||||||
|
if engine is None:
|
||||||
|
doLcc = True
|
||||||
|
geom = geompyDC()
|
||||||
|
assert isinstance(geom,geompyDC), "Geom engine class is %s but should be geompyDC.geompyDC. Import geompyDC before creating the instance."%geom.__class__
|
||||||
|
geom.init_geom(study)
|
||||||
|
return geom
|
||||||
|
Loading…
Reference in New Issue
Block a user