## to a lot of duplicated items in the study.
## - Sub-shapes are automatically published as child items of the parent main shape in the study if main
## shape was also published before. Otherwise, sub-shapes are published as top-level objects.
-## - Not that some functions of \ref geomBuilder.geomBuilder "geomBuilder" class do not have
+## - Some functions of \ref geomBuilder.geomBuilder "geomBuilder" class do not have
## \a theName parameter (and, thus, do not support automatic publication).
## For example, some transformation operations like
## \ref geomBuilder.geomBuilder.TranslateDXDYDZ() "TranslateDXDYDZ()".
## Refer to the documentation to check if some function has such possibility.
##
+## It is possible to customize the representation of the geometrical
+## data in the data tree; this can be done by using folders. A folder can
+## be created in the study tree using function
+## \ref geomBuilder.geomBuilder.NewFolder() "NewFolder()"
+## (by default it is created under the "Geometry" root object).
+## As soon as folder is created, any published geometry object
+## can be moved into it.
+##
+## For example:
+##
+## @code
+## import salome
+## from salome.geom import geomBuilder
+## geompy = geomBuilder.New(salome.myStudy)
+## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "Box")
+## # the box was created and published in the study
+## folder = geompy.NewFolder("Primitives")
+## # an empty "Primitives" folder was created under default "Geometry" root object
+## geompy.PutToFolder(box, folder)
+## # the box was moved into "Primitives" folder
+## @endcode
+##
+## Subfolders are also can be created by specifying another folder as a parent:
+##
+## @code
+## subfolder = geompy.NewFolder("3D", folder)
+## # "3D" folder was created under "Primitives" folder
+## @endcode
+##
+## @note
+## - Folder container is just a representation layer object that
+## deals with already published objects only. So, any geometry object
+## should be published in the study (for example, with
+## \ref geomBuilder.geomBuilder.PutToFolder() "addToStudy()" function)
+## BEFORE moving it into any existing folder.
+## - \ref geomBuilder.geomBuilder.PutToFolder() "PutToFolder()" function
+## does not change physical position of geometry object in the study tree,
+## it only affects on the representation of the data tree.
+## - It is impossible to publish geometry object using any folder as father.
+##
## @}
## @}
## @defgroup l2_measure Using measurement tools
+## @defgroup l2_field Field on Geometry
## @}
## @ingroup l1_geomBuilder_auxiliary
def RaiseIfFailed (Method_name, Operation):
if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY":
+ Operation.AbortOperation()
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
+ else:
+ Operation.FinishOperation()
+ pass
## Return list of variables value from salome notebook
## @ingroup l1_geomBuilder_auxiliary
CLOSED = 1
UNCLOSED = 2
+##! Private class used to bind calls of plugin operations to geomBuilder
+class PluginOperation:
+ def __init__(self, operation, function):
+ self.operation = operation
+ self.function = function
+ pass
+
+ def __call__(self, *args):
+ res = self.function(self.operation, *args)
+ RaiseIfFailed(self.function.__name__, self.operation)
+ return res
+
# Warning: geom is a singleton
geom = None
engine = None
self.BlocksOp = None
self.GroupOp = None
self.AdvOp = None
+ self.FieldOp = None
pass
## Process object publication in the study, as follows:
pass
return _name
# ---
+ def _publish( _name, _obj ):
+ fatherObj = None
+ if isinstance( _obj, GEOM._objref_GEOM_Field ):
+ fatherObj = _obj.GetShape()
+ elif isinstance( _obj, GEOM._objref_GEOM_FieldStep ):
+ fatherObj = _obj.GetField()
+ elif not _obj.IsMainShape():
+ fatherObj = _obj.GetMainShape()
+ pass
+ if fatherObj and fatherObj.GetStudyEntry():
+ self.addToStudyInFather(fatherObj, _obj, _name)
+ else:
+ self.addToStudy(_obj, _name)
+ pass
+ return
+ # ---
if not theObj:
return # null object
if not theName and not self.myMaxNbSubShapesAllowed:
idx = 0
for obj in theObj:
if not obj: continue # bad object
- ###if obj.GetStudyEntry(): continue # already published
name = _item_name(theName, theDefaultName, idx)
- if obj.IsMainShape() or not obj.GetMainShape().GetStudyEntry():
- self.addToStudy(obj, name) # "%s_%d"%(aName, idx)
- else:
- self.addToStudyInFather(obj.GetMainShape(), obj, name) # "%s_%d"%(aName, idx)
- pass
+ _publish( name, obj )
idx = idx+1
if not theName and idx == self.myMaxNbSubShapesAllowed: break
pass
pass
else:
# single object is published
- ###if theObj.GetStudyEntry(): return # already published
name = _item_name(theName, theDefaultName)
- if theObj.IsMainShape():
- self.addToStudy(theObj, name)
- else:
- self.addToStudyInFather(theObj.GetMainShape(), theObj, name)
- pass
- pass
+ _publish( name, theObj )
pass
## @addtogroup l1_geomBuilder_auxiliary
self.MeasuOp = self.GetIMeasureOperations (self.myStudyId)
self.BlocksOp = self.GetIBlocksOperations (self.myStudyId)
self.GroupOp = self.GetIGroupOperations (self.myStudyId)
- self.AdvOp = self.GetIAdvancedOperations (self.myStudyId)
+ self.FieldOp = self.GetIFieldOperations (self.myStudyId)
+
+ # The below line is a right way to map all plugin functions to geomBuilder,
+ # but AdvancedOperations are already mapped, that is why this line is commented
+ # and presents here only as an axample
+ #self.AdvOp = self.GetPluginOperations (self.myStudyId, "AdvancedEngine")
+
+ # self.AdvOp is used by functions MakePipeTShape*, MakeDividedDisk, etc.
+ self.AdvOp = GEOM._objref_GEOM_Gen.GetPluginOperations (self, self.myStudyId, "AdvancedEngine")
+
# set GEOM as root in the use case tree
self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder()
self.myUseCaseBuilder.SetRootCurrent()
self.myUseCaseBuilder.Append(self.father)
pass
+ def GetPluginOperations(self, studyID, libraryName):
+ op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, studyID, libraryName)
+ if op:
+ # bind methods of operations to self
+ methods = op.__class__.__dict__['__methods__']
+ avoid_methods = self.BasicOp.__class__.__dict__['__methods__']
+ for meth_name in methods:
+ if not meth_name in avoid_methods: # avoid basic methods
+ function = getattr(op.__class__, meth_name)
+ if callable(function):
+ #self.__dict__[meth_name] = self.__PluginOperation(op, function)
+ self.__dict__[meth_name] = PluginOperation(op, function)
+ return op
+
## Enable / disable results auto-publishing
#
# The automatic publishing is managed in the following way:
# @param theParamMin the minimal value of the parameter.
# @param theParamMax the maximum value of the parameter.
# @param theParamStep the number of steps if theNewMethod = True, else step value of the parameter.
- # @param theCurveType the type of the curve.
+ # @param theCurveType the type of the curve,
+ # one of GEOM.Polyline, GEOM.Bezier, GEOM.Interpolation.
# @param theNewMethod flag for switching to the new method if the flag is set to false a deprecated method is used which can lead to a bug.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
theParamMin the minimal value of the parameter.
theParamMax the maximum value of the parameter.
theParamStep the number of steps if theNewMethod = True, else step value of the parameter.
- theCurveType the type of the curve.
+ theCurveType the type of the curve,
+ one of GEOM.Polyline, GEOM.Bezier, GEOM.Interpolation.
theNewMethod flag for switching to the new method if the flag is set to false a deprecated
method is used which can lead to a bug.
theName Object name; when specified, this parameter is used
self._autoPublish(anObj, theName, "curve")
return anObj
+ ## Create an isoline curve on a face.
+ # @param theFace the face for which an isoline is created.
+ # @param IsUIsoline True for U-isoline creation; False for V-isoline
+ # creation.
+ # @param theParameter the U parameter for U-isoline or V parameter
+ # for V-isoline.
+ # @param theName Object name; when specified, this parameter is used
+ # for result publication in the study. Otherwise, if automatic
+ # publication is switched on, default value is used for result name.
+ #
+ # @return New GEOM.GEOM_Object, containing the created isoline edge or
+ # a compound of edges.
+ #
+ # @ref tui_creation_curve "Example"
+ def MakeIsoline(self, theFace, IsUIsoline, theParameter, theName=None):
+ """
+ Create an isoline curve on a face.
+
+ Parameters:
+ theFace the face for which an isoline is created.
+ IsUIsoline True for U-isoline creation; False for V-isoline
+ creation.
+ theParameter the U parameter for U-isoline or V parameter
+ for V-isoline.
+ theName Object name; when specified, this parameter is used
+ for result publication in the study. Otherwise, if automatic
+ publication is switched on, default value is used for result name.
+
+ Returns:
+ New GEOM.GEOM_Object, containing the created isoline edge or a
+ compound of edges.
+ """
+ # Example: see GEOM_TestAll.py
+ anObj = self.CurvesOp.MakeIsoline(theFace, IsUIsoline, theParameter)
+ RaiseIfFailed("MakeIsoline", self.CurvesOp)
+ if IsUIsoline:
+ self._autoPublish(anObj, theName, "U-Isoline")
+ else:
+ self._autoPublish(anObj, theName, "V-Isoline")
+ return anObj
+
# end of l4_curves
## @}
New GEOM.GEOM_Object, containing the created compound.
"""
# Example: see GEOM_TestAll.py
+ self.ShapesOp.StartOperation()
anObj = self.ShapesOp.MakeCompound(theShapes)
RaiseIfFailed("MakeCompound", self.ShapesOp)
self._autoPublish(anObj, theName, "compound")
return ListObj
## Obtain a compound of sub-shapes of <VAR>aShape</VAR>,
- # selected by they indices in list of all sub-shapes of type <VAR>aType</VAR>.
+ # selected by their indices in list of all sub-shapes of type <VAR>aType</VAR>.
# Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
# @param aShape Shape to get sub-shape of.
# @param ListOfInd List of sub-shapes indices.
def SubShape(self, aShape, aType, ListOfInd, theName=None):
"""
Obtain a compound of sub-shapes of aShape,
- selected by they indices in list of all sub-shapes of type aType.
+ selected by their indices in list of all sub-shapes of type aType.
Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
Parameters:
anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance)
else:
anObj = self.HealOp.Sew(theObject, theTolerance)
+ # To avoid script failure in case of good argument shape
+ if self.HealOp.GetErrorCode() == "ShHealOper_NotError_msg":
+ return theObject
RaiseIfFailed("Sew", self.HealOp)
anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "sewed")
# @param theShape2 Second argument for boolean operation.
# @param theOperation Indicates the operation to be done:\n
# 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
# @return New GEOM.GEOM_Object, containing the result shape.
#
# @ref tui_fuse "Example"
- def MakeBoolean(self, theShape1, theShape2, theOperation, theName=None):
+ def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None):
"""
Perform one of boolean operations on two given shapes.
theShape2 Second argument for boolean operation.
theOperation Indicates the operation to be done:
1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
New GEOM.GEOM_Object, containing the result shape.
"""
# Example: see GEOM_TestAll.py
- anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
+ anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation, checkSelfInte)
RaiseIfFailed("MakeBoolean", self.BoolOp)
def_names = { 1: "common", 2: "cut", 3: "fuse", 4: "section" }
self._autoPublish(anObj, theName, def_names[theOperation])
## Perform Common boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @param theShape2 Second argument for boolean operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_common "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCommon(self, theShape1, theShape2, theName=None):
+ def MakeCommon(self, theShape1, theShape2, checkSelfInte=False, theName=None):
"""
Perform Common boolean operation on two given shapes.
Parameters:
theShape1 First argument for boolean operation.
theShape2 Second argument for boolean operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 1, theName)
+ return self.MakeBoolean(theShape1, theShape2, 1, checkSelfInte, theName)
## Perform Cut boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @param theShape2 Second argument for boolean operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_cut "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCut(self, theShape1, theShape2, theName=None):
+ def MakeCut(self, theShape1, theShape2, checkSelfInte=False, theName=None):
"""
Perform Cut boolean operation on two given shapes.
Parameters:
theShape1 First argument for boolean operation.
theShape2 Second argument for boolean operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 2, theName)
+ return self.MakeBoolean(theShape1, theShape2, 2, checkSelfInte, theName)
## Perform Fuse boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @param theShape2 Second argument for boolean operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_fuse "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeFuse(self, theShape1, theShape2, theName=None):
+ def MakeFuse(self, theShape1, theShape2, checkSelfInte=False, theName=None):
"""
Perform Fuse boolean operation on two given shapes.
Parameters:
theShape1 First argument for boolean operation.
theShape2 Second argument for boolean operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 3, theName)
+ return self.MakeBoolean(theShape1, theShape2, 3, checkSelfInte, theName)
## Perform Section boolean operation on two given shapes.
# @param theShape1 First argument for boolean operation.
# @param theShape2 Second argument for boolean operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_section "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeSection(self, theShape1, theShape2, theName=None):
+ def MakeSection(self, theShape1, theShape2, checkSelfInte=False, theName=None):
"""
Perform Section boolean operation on two given shapes.
Parameters:
theShape1 First argument for boolean operation.
theShape2 Second argument for boolean operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
# note: auto-publishing is done in self.MakeBoolean()
- return self.MakeBoolean(theShape1, theShape2, 4, theName)
+ return self.MakeBoolean(theShape1, theShape2, 4, checkSelfInte, theName)
## Perform Fuse boolean operation on the list of shapes.
# @param theShapesList Shapes to be fused.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_fuse "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeFuseList(self, theShapesList, theName=None):
+ def MakeFuseList(self, theShapesList, checkSelfInte=False, theName=None):
"""
Perform Fuse boolean operation on the list of shapes.
Parameters:
theShapesList Shapes to be fused.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeFuseList(theShapesList)
+ anObj = self.BoolOp.MakeFuseList(theShapesList, checkSelfInte)
RaiseIfFailed("MakeFuseList", self.BoolOp)
self._autoPublish(anObj, theName, "fuse")
return anObj
## Perform Common boolean operation on the list of shapes.
# @param theShapesList Shapes for Common operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_common "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCommonList(self, theShapesList, theName=None):
+ def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None):
"""
Perform Common boolean operation on the list of shapes.
Parameters:
theShapesList Shapes for Common operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeCommonList(theShapesList)
+ anObj = self.BoolOp.MakeCommonList(theShapesList, checkSelfInte)
RaiseIfFailed("MakeCommonList", self.BoolOp)
self._autoPublish(anObj, theName, "common")
return anObj
## Perform Cut boolean operation on one object and the list of tools.
# @param theMainShape The object of the operation.
# @param theShapesList The list of tools of the operation.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
#
# @ref tui_cut "Example 1"
# \n @ref swig_MakeCommon "Example 2"
- def MakeCutList(self, theMainShape, theShapesList, theName=None):
+ def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None):
"""
Perform Cut boolean operation on one object and the list of tools.
Parameters:
theMainShape The object of the operation.
theShapesList The list of tools of the operation.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
"""
# Example: see GEOM_TestOthers.py
- anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList)
+ anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList, checkSelfInte)
RaiseIfFailed("MakeCutList", self.BoolOp)
self._autoPublish(anObj, theName, "cut")
return anObj
# target type (equal to Limit) are kept in the result,
# else standalone shapes of lower dimension
# are kept also (if they exist).
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
# @ref tui_partition "Example"
def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
- KeepNonlimitShapes=0, theName=None):
+ KeepNonlimitShapes=0, checkSelfInte=False, theName=None):
"""
Perform partition operation.
target type (equal to Limit) are kept in the result,
else standalone shapes of lower dimension
are kept also (if they exist).
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
anObj = self.BoolOp.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes);
+ KeepNonlimitShapes, checkSelfInte);
RaiseIfFailed("MakePartition", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0,
ListMaterials=[], KeepNonlimitShapes=0,
- theName=None):
+ checkSelfInte=False, theName=None):
"""
Perform partition operation.
This method may be useful if it is needed to make a partition for
anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes);
+ KeepNonlimitShapes, checkSelfInte);
RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
# \n @ref swig_Partition "Example 2"
def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
- KeepNonlimitShapes=0, theName=None):
+ KeepNonlimitShapes=0, checkSelfInte=False, theName=None):
"""
See method geompy.MakePartition for more information.
"""
anObj = self.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
Limit, RemoveWebs, ListMaterials,
- KeepNonlimitShapes, theName);
+ KeepNonlimitShapes, checkSelfInte,
+ theName);
return anObj
## Perform partition of the Shape with the Plane
# @param theShape Shape to be intersected.
# @param thePlane Tool shape, to intersect theShape.
+ # @param checkSelfInte The flag that tells if the arguments should
+ # be checked for self-intersection prior to the operation.
# @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name.
# @return New GEOM.GEOM_Object, containing the result shape.
#
# @ref tui_partition "Example"
- def MakeHalfPartition(self, theShape, thePlane, theName=None):
+ def MakeHalfPartition(self, theShape, thePlane, checkSelfInte=False, theName=None):
"""
Perform partition of the Shape with the Plane
Parameters:
theShape Shape to be intersected.
thePlane Tool shape, to intersect theShape.
+ checkSelfInte The flag that tells if the arguments should
+ be checked for self-intersection prior to
+ the operation.
theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name.
New GEOM.GEOM_Object, containing the result shape.
"""
# Example: see GEOM_TestAll.py
- anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane)
+ anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane, checkSelfInte)
RaiseIfFailed("MakeHalfPartition", self.BoolOp)
self._autoPublish(anObj, theName, "partition")
return anObj
RaiseIfFailed("ProjectShapeCopy", self.TrsfOp)
self._autoPublish(anObj, theName, "projection")
return anObj
+
+ ## Create a projection projection of the given point on a wire or an edge.
+ # If there are no solutions or there are 2 or more solutions It throws an
+ # exception.
+ # @param thePoint the point to be projected.
+ # @param theWire the wire. The edge is accepted as well.
+ # @param theName Object name; when specified, this parameter is used
+ # for result publication in the study. Otherwise, if automatic
+ # publication is switched on, default value is used for result name.
+ #
+ # @return [\a u, \a PointOnEdge, \a EdgeInWireIndex]
+ # \n \a u: The parameter of projection point on edge.
+ # \n \a PointOnEdge: The projection point.
+ # \n \a EdgeInWireIndex: The index of an edge in a wire.
+ #
+ # @ref tui_projection "Example"
+ def MakeProjectionOnWire(self, thePoint, theWire, theName=None):
+ """
+ Create a projection projection of the given point on a wire or an edge.
+ If there are no solutions or there are 2 or more solutions It throws an
+ exception.
+
+ Parameters:
+ thePoint the point to be projected.
+ theWire the wire. The edge is accepted as well.
+ theName Object name; when specified, this parameter is used
+ for result publication in the study. Otherwise, if automatic
+ publication is switched on, default value is used for result name.
+
+ Returns:
+ [u, PointOnEdge, EdgeInWireIndex]
+ u: The parameter of projection point on edge.
+ PointOnEdge: The projection point.
+ EdgeInWireIndex: The index of an edge in a wire.
+ """
+ # Example: see GEOM_TestAll.py
+ anObj = self.TrsfOp.ProjectPointOnWire(thePoint, theWire)
+ RaiseIfFailed("ProjectPointOnWire", self.TrsfOp)
+ self._autoPublish(anObj[1], theName, "projection")
+ return anObj
# -----------------------------------------------------------------------------
# Patterns
# Example: see GEOM_TestMeasures.py
listSh = self.SubShapeAllIDs(theShape, theType)
Nb = len(listSh)
- t = EnumToLong(theShape.GetShapeType())
- theType = EnumToLong(theType)
- if t == theType:
- Nb = Nb + 1
- pass
return Nb
## Obtain quantity of shapes of each type in \a theShape.
if typeSh in ( "AUTO", "SHAPE" ): continue
listSh = self.SubShapeAllIDs(theShape, self.ShapeType[typeSh])
Nb = len(listSh)
- if EnumToLong(theShape.GetShapeType()) == self.ShapeType[typeSh]:
- Nb = Nb + 1
- pass
aDict[typeSh] = Nb
pass
return aDict
self._autoPublish(anObj, theName, "dividedCylinder")
return anObj
+ ## Create a surface from a cloud of points
+ # @param thelPoints list of points
+ # @return New GEOM_Object, containing the created shape.
+ #
+ # @ref tui_creation_smoothingsurface "Example"
+ def MakeSmoothingSurface(self, thelPoints):
+ anObj = self.AdvOp.MakeSmoothingSurface(thelPoints)
+ RaiseIfFailed("MakeSmoothingSurface", self.AdvOp)
+ return anObj
+
+ ## Export a shape to XAO format
+ # @param shape The shape to export
+ # @param groups The list of groups to export
+ # @param fields The list of fields to export
+ # @param author The author of the export
+ # @param fileName The name of the file to export
+ # @return boolean
+ #
+ # @ref tui_exportxao "Example"
+ def ExportXAO(self, shape, groups, fields, author, fileName):
+ res = self.InsertOp.ExportXAO(shape, groups, fields, author, fileName)
+ RaiseIfFailed("ExportXAO", self.InsertOp)
+ return res
+
+ ## Import a shape from XAO format
+ # @param shape Shape to export
+ # @param fileName The name of the file to import
+ # @return tuple (res, shape, subShapes, groups, fields)
+ # res Flag indicating if the import was successful
+ # shape The imported shape
+ # subShapes The list of imported subShapes
+ # groups The list of imported groups
+ # fields The list of imported fields
+ #
+ # @ref tui_importxao "Example"
+ def ImportXAO(self, fileName):
+ res = self.InsertOp.ImportXAO(fileName)
+ RaiseIfFailed("ImportXAO", self.InsertOp)
+ return res
+
#@@ insert new functions before this line @@ do not remove this line @@#
# end of l4_advanced
# @param Father parent object. If None,
# folder under 'Geometry' root object will be created.
# @return a new created folder
+ # @ingroup l1_publish_data
def NewFolder(self, Name, Father=None):
"""
Create a new folder object. It is an auxiliary container for any GEOM objects.
## Move object to the specified folder
# @param Object object to move
# @param Folder target folder
+ # @ingroup l1_publish_data
def PutToFolder(self, Object, Folder):
"""
Move object to the specified folder
## Move list of objects to the specified folder
# @param ListOfSO list of objects to move
# @param Folder target folder
+ # @ingroup l1_publish_data
def PutListToFolder(self, ListOfSO, Folder):
"""
Move list of objects to the specified folder
self.MoveListToFolder(ListOfSO, Folder)
pass
+ ## @addtogroup l2_field
+ ## @{
+
+ ## Creates a field
+ # @param shape the shape the field lies on
+ # @param name the field name
+ # @param type type of field data: 0 - bool, 1 - int, 2 - double, 3 - string
+ # @param dimension dimension of the shape the field lies on
+ # 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+ # @param componentNames names of components
+ # @return a created field
+ def CreateField(self, shape, name, type, dimension, componentNames):
+ """
+ Creates a field
+
+ Parameters:
+ shape the shape the field lies on
+ name the field name
+ type type of field data
+ dimension dimension of the shape the field lies on
+ 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+ componentNames names of components
+
+ Returns:
+ a created field
+ """
+ if isinstance( type, int ):
+ if type < 0 or type > 3:
+ raise RuntimeError, "CreateField : Error: data type must be within [0-3] range"
+ type = [GEOM.FDT_Bool,GEOM.FDT_Int,GEOM.FDT_Double,GEOM.FDT_String][type]
+
+ f = self.FieldOp.CreateField( shape, name, type, dimension, componentNames)
+ RaiseIfFailed("CreateField", self.FieldOp)
+ global geom
+ geom._autoPublish( f, "", name)
+ return f
+
+ ## Removes a field from the GEOM component
+ # @param field the field to remove
+ def RemoveField(self, field):
+ "Removes a field from the GEOM component"
+ global geom
+ if isinstance( field, GEOM._objref_GEOM_Field ):
+ geom.RemoveObject( field )
+ elif isinstance( field, geomField ):
+ geom.RemoveObject( field.field )
+ else:
+ raise RuntimeError, "RemoveField() : the object is not a field"
+ return
+
+ ## Returns number of fields on a shape
+ def CountFields(self, shape):
+ "Returns number of fields on a shape"
+ nb = self.FieldOp.CountFields( shape )
+ RaiseIfFailed("CountFields", self.FieldOp)
+ return nb
+
+ ## Returns all fields on a shape
+ def GetFields(self, shape):
+ "Returns all fields on a shape"
+ ff = self.FieldOp.GetFields( shape )
+ RaiseIfFailed("GetFields", self.FieldOp)
+ return ff
+
+ ## Returns a field on a shape by its name
+ def GetField(self, shape, name):
+ "Returns a field on a shape by its name"
+ f = self.FieldOp.GetField( shape, name )
+ RaiseIfFailed("GetField", self.FieldOp)
+ return f
+
+ # end of l2_field
+ ## @}
+
+
import omniORB
# Register the new proxy for GEOM_Gen
omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)
+
+## Field on Geometry
+# @ingroup l2_field
+class geomField( GEOM._objref_GEOM_Field ):
+
+ def __init__(self):
+ GEOM._objref_GEOM_Field.__init__(self)
+ self.field = GEOM._objref_GEOM_Field
+ return
+
+ ## Returns the shape the field lies on
+ def getShape(self):
+ "Returns the shape the field lies on"
+ return self.field.GetShape(self)
+
+ ## Returns the field name
+ def getName(self):
+ "Returns the field name"
+ return self.field.GetName(self)
+
+ ## Returns type of field data as integer [0-3]
+ def getType(self):
+ "Returns type of field data"
+ return self.field.GetDataType(self)._v
+
+ ## Returns type of field data:
+ # one of GEOM.FDT_Bool, GEOM.FDT_Int, GEOM.FDT_Double, GEOM.FDT_String
+ def getTypeEnum(self):
+ "Returns type of field data"
+ return self.field.GetDataType(self)
+
+ ## Returns dimension of the shape the field lies on:
+ # 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape
+ def getDimension(self):
+ """Returns dimension of the shape the field lies on:
+ 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape"""
+ return self.field.GetDimension(self)
+
+ ## Returns names of components
+ def getComponents(self):
+ "Returns names of components"
+ return self.field.GetComponents(self)
+
+ ## Adds a time step to the field
+ # @param step the time step number futher used as the step identifier
+ # @param stamp the time step time
+ # @param values the values of the time step
+ def addStep(self, step, stamp, values):
+ "Adds a time step to the field"
+ stp = self.field.AddStep( self, step, stamp )
+ if not stp:
+ raise RuntimeError, \
+ "Field.addStep() : Error: step %s already exists in this field"%step
+ global geom
+ geom._autoPublish( stp, "", "Step %s, %s"%(step,stamp))
+ self.setValues( step, values )
+ return stp
+
+ ## Remove a time step from the field
+ def removeStep(self,step):
+ "Remove a time step from the field"
+ stepSO = None
+ try:
+ stepObj = self.field.GetStep( self, step )
+ if stepObj:
+ stepSO = geom.myStudy.FindObjectID( stepObj.GetStudyEntry() )
+ except:
+ #import traceback
+ #traceback.print_exc()
+ pass
+ self.field.RemoveStep( self, step )
+ if stepSO:
+ geom.myBuilder.RemoveObjectWithChildren( stepSO )
+ return
+
+ ## Returns number of time steps in the field
+ def countSteps(self):
+ "Returns number of time steps in the field"
+ return self.field.CountSteps(self)
+
+ ## Returns a list of time step IDs in the field
+ def getSteps(self):
+ "Returns a list of time step IDs in the field"
+ return self.field.GetSteps(self)
+
+ ## Returns a time step by its ID
+ def getStep(self,step):
+ "Returns a time step by its ID"
+ stp = self.field.GetStep(self, step)
+ if not stp:
+ raise RuntimeError, "Step %s is missing from this field"%step
+ return stp
+
+ ## Returns the time of the field step
+ def getStamp(self,step):
+ "Returns the time of the field step"
+ return self.getStep(step).GetStamp()
+
+ ## Changes the time of the field step
+ def setStamp(self, step, stamp):
+ "Changes the time of the field step"
+ return self.getStep(step).SetStamp(stamp)
+
+ ## Returns values of the field step
+ def getValues(self, step):
+ "Returns values of the field step"
+ return self.getStep(step).GetValues()
+
+ ## Changes values of the field step
+ def setValues(self, step, values):
+ "Changes values of the field step"
+ stp = self.getStep(step)
+ errBeg = "Field.setValues(values) : Error: "
+ try:
+ ok = stp.SetValues( values )
+ except Exception, e:
+ excStr = str(e)
+ if excStr.find("WrongPythonType") > 0:
+ raise RuntimeError, errBeg +\
+ "wrong type of values, %s values are expected"%str(self.getTypeEnum())[4:]
+ raise RuntimeError, errBeg + str(e)
+ if not ok:
+ nbOK = self.field.GetArraySize(self)
+ nbKO = len(values)
+ if nbOK != nbKO:
+ raise RuntimeError, errBeg + "len(values) must be %s but not %s"%(nbOK,nbKO)
+ else:
+ raise RuntimeError, errBeg + "failed"
+ return
+
+ pass # end of class geomField
+
+# Register the new proxy for GEOM_Field
+omniORB.registerObjref(GEOM._objref_GEOM_Field._NP_RepositoryId, geomField)
+
+
## Create a new geomBuilder instance.The geomBuilder class provides the Python
# interface to GEOM operations.
#