##
## @details
##
-## By default, all functions of geompy.py Python interface do not publish
+## By default, all functions of geomBuilder Python module do not publish
## resulting geometrical objects. This can be done in the Python script
-## by means of geompy.addToStudy() or geompy.addToStudyInFather()
+## by means of \ref geomBuilder.geomBuilder.addToStudy() "addToStudy()"
+## or \ref geomBuilder.geomBuilder.addToStudyInFather() "addToStudyInFather()"
## functions.
##
## However, it is possible to publish result data in the study
-## automatically. For this, almost each function of geompy.py module has
+## automatically. For this, almost each function of
+## \ref geomBuilder.geomBuilder "geomBuilder" class has
## an additional @a theName parameter (@c None by default).
## As soon as non-empty string value is passed to this parameter,
## the result object is published in the study automatically.
##
-## For example,
+## For example, consider the following Python script:
##
## @code
+## import salome
+## from salome.geom import geomBuilder
+## geompy = geomBuilder.New(salome.myStudy)
## box = geompy.MakeBoxDXDYDZ(100, 100, 100) # box is not published in the study yet
## geompy.addToStudy(box, "box") # explicit publishing
## @endcode
##
-## can be replaced by one-line instruction
+## Last two lines can be replaced by one-line instruction:
##
## @code
## box = geompy.MakeBoxDXDYDZ(100, 100, 100, theName="box") # box is published in the study with "box" name
## @endcode
##
## Note, that some functions produce more than one geometrical objects. For example,
-## geompy.GetNonBlocks() function returns two objects: group of all non-hexa solids and group of
-## all non-quad faces. For such functions it is possible to specify separate names for results.
+## \ref geomBuilder.geomBuilder.GetNonBlocks() "GetNonBlocks()" function returns two objects:
+## group of all non-hexa solids and group of all non-quad faces.
+## For such functions it is possible to specify separate names for results.
##
## For example
##
## ... the first compound will be published with "nonhexa" name, and second will be named "nonquad".
##
## Automatic publication of all results can be also enabled/disabled by means of the function
-## geompy.addToStudyAuto(). The automatic publishing is managed by the numeric parameter passed
-## to this function:
+## \ref geomBuilder.geomBuilder.addToStudyAuto() "addToStudyAuto()". The automatic publishing
+## is managed by the numeric parameter passed to this function:
## - if @a maxNbSubShapes = 0, automatic publishing is disabled.
## - if @a maxNbSubShapes = -1 (default), automatic publishing is enabled and
## maximum number of sub-shapes allowed for publishing is unlimited; any negative
## For example:
##
## @code
+## import salome
+## from salome.geom import geomBuilder
+## geompy = geomBuilder.New(salome.myStudy)
## geompy.addToStudyAuto() # enable automatic publication
## box = geompy.MakeBoxDXDYDZ(100, 100, 100)
## # the box is created and published in the study with default name
## geompy.addToStudyAuto(5) # set max allowed number of sub-shapes to 5
-## vertices = geompy.SubShapeAll(box, geompy.ShapeType['VERTEX'])
+## vertices = geompy.SubShapeAll(box, geomBuilder.ShapeType['VERTEX'])
## # only 5 first vertices will be published, with default names
## print len(vertices)
## # note, that result value still containes all 8 vertices
## This feature can be used, for example, for debugging purposes.
##
## @note
-## - Use automatic publication feature with caution. When it is enabled, any function of geompy.py module
-## publishes the results in the study, that can lead to the huge size of the study data tree.
-## For example, repeating call of geompy.SubShapeAll() command on the same main shape each time will
-## publish all child objects, that will lead to a lot of duplicated items in the study.
+## - Use automatic publication feature with caution. When it is enabled, any function of
+## \ref geomBuilder.geomBuilder "geomBuilder" class publishes the results in the study,
+## that can lead to the huge size of the study data tree.
+## For example, repeating call of \ref geomBuilder.geomBuilder.SubShapeAll() "SubShapeAll()"
+## command on the same main shape each time will publish all child objects, that will lead
+## 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 geompy.py module do not have @theName parameter (and, thus, do not support
-## automatic publication). For example, some transformation operations like geompy.TranslateDXDYDZ().
+## - Not that 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.
##
## @}
-## @defgroup l1_geompy_auxiliary Auxiliary data structures and methods
+## @defgroup l1_geomBuilder_auxiliary Auxiliary data structures and methods
## @defgroup l1_geomBuilder_purpose All package methods, grouped by their purpose
## @{
import math
import os
-from salome.geom.gsketcher import Sketcher3D
+from salome.geom.gsketcher import Sketcher3D, Sketcher2D
# service function
def _toListOfNames(_names, _size=-1):
global geom
global doLcc
global created
- #print "__new__ ", engine, geom, doLcc, created
+ #print "==== __new__ ", engine, geom, doLcc, created
if geom is None:
# geom engine is either retrieved from engine, or created
geom = engine
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
+ #print "==== FindOrLoadComponent ", engine, geom, doLcc, created
geom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" )
+ #print "====1 ",geom
else:
# FindOrLoadComponent not called
if geom is None:
# geomBuilder instance is created from lcc.FindOrLoadComponent
- created = True
- #print "super ", engine, geom, doLcc, created
+ #print "==== super ", engine, geom, doLcc, created
geom = super(geomBuilder,cls).__new__(cls)
+ #print "====2 ",geom
else:
# geom engine not created: existing engine found
- #print "existing ", engine, geom, doLcc, created
+ #print "==== existing ", engine, geom, doLcc, created
pass
-
+ #print "return geom 1 ", geom
return geom
+ #print "return geom 2 ", geom
return geom
def __init__(self):
- #global created
+ global created
#print "-------- geomBuilder __init__ --- ", created, self
- GEOM._objref_GEOM_Gen.__init__(self)
- self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default
- self.myBuilder = None
- self.myStudyId = 0
- self.father = None
-
- self.BasicOp = None
- self.CurvesOp = None
- self.PrimOp = None
- self.ShapesOp = None
- self.HealOp = None
- self.InsertOp = None
- self.BoolOp = None
- self.TrsfOp = None
- self.LocalOp = None
- self.MeasuOp = None
- self.BlocksOp = None
- self.GroupOp = None
- self.AdvOp = None
+ if not created:
+ created = True
+ GEOM._objref_GEOM_Gen.__init__(self)
+ self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default
+ self.myBuilder = None
+ self.myStudyId = 0
+ self.father = None
+
+ self.BasicOp = None
+ self.CurvesOp = None
+ self.PrimOp = None
+ self.ShapesOp = None
+ self.HealOp = None
+ self.InsertOp = None
+ self.BoolOp = None
+ self.TrsfOp = None
+ self.LocalOp = None
+ self.MeasuOp = None
+ self.BlocksOp = None
+ self.GroupOp = None
+ self.AdvOp = None
pass
## Process object publication in the study, as follows:
pass
pass
- ## @addtogroup l1_geompy_auxiliary
+ ## @addtogroup l1_geomBuilder_auxiliary
## @{
def init_geom(self,theStudy):
self.myStudy = theStudy
drwAttribute.SetDrawable(False)
pass
- # end of l1_geompy_auxiliary
+ # end of l1_geomBuilder_auxiliary
## @}
## @addtogroup l3_restore_ss
self._autoPublish(anObj, theName, "wire")
return anObj
+ ## Obtain a 2D sketcher interface
+ # @return An instance of @ref gsketcher.Sketcher2D "Sketcher2D" interface
+ def Sketcher2D (self):
+ """
+ Obtain a 2D sketcher interface.
+
+ Example of usage:
+ sk = geompy.Sketcher2D()
+ sk.addPoint(20, 20)
+ sk.addSegmentRelative(15, 70)
+ sk.addSegmentPerpY(50)
+ sk.addArcRadiusRelative(25, 15, 14.5, 0)
+ sk.addArcCenterAbsolute(1, 1, 50, 50, 0, 0)
+ sk.addArcDirectionRadiusLength(20, 20, 101, 162.13)
+ sk.close()
+ Sketch_1 = sk.wire(geomObj_1)
+ """
+ sk = Sketcher2D (self)
+ return sk
+
## Create a sketcher wire, following the numerical description,
# passed through <VAR>theCoordinates</VAR> argument. \n
# @param theCoordinates double values, defining points to create a wire,
## Sewing of some shapes into single shape.
# @param ListShape Shapes to be processed.
# @param theTolerance Required tolerance value.
+ # @param AllowNonManifold Flag that allows non-manifold sewing.
# @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 processed shape.
#
# @ref tui_sewing "Example"
- def MakeSewing(self, ListShape, theTolerance, theName=None):
+ def MakeSewing(self, ListShape, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of some shapes into single shape.
Parameters:
ListShape Shapes to be processed.
theTolerance Required tolerance value.
+ AllowNonManifold Flag that allows non-manifold sewing.
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_TestHealing.py
comp = self.MakeCompound(ListShape)
# note: auto-publishing is done in self.Sew()
- anObj = self.Sew(comp, theTolerance, theName)
+ anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName)
return anObj
## Sewing of the given object.
# @param theObject Shape to be processed.
# @param theTolerance Required tolerance value.
+ # @param AllowNonManifold Flag that allows non-manifold sewing.
# @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 processed shape.
- def Sew(self, theObject, theTolerance, theName=None):
+ def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of the given object.
Parameters:
theObject Shape to be processed.
theTolerance Required tolerance value.
+ AllowNonManifold Flag that allows non-manifold sewing.
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 MakeSewing() above
theTolerance,Parameters = ParseParameters(theTolerance)
- anObj = self.HealOp.Sew(theObject, theTolerance)
+ if AllowNonManifold:
+ anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance)
+ else:
+ anObj = self.HealOp.Sew(theObject, theTolerance)
RaiseIfFailed("Sew", self.HealOp)
anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "sewed")
return anObj
+ ## Rebuild the topology of theCompound of solids by removing
+ # of the faces that are shared by several solids.
+ # @param theCompound Shape to be processed.
+ # @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 processed shape.
+ #
+ # @ref tui_remove_webs "Example"
+ def RemoveInternalFaces (self, theCompound, theName=None):
+ """
+ Rebuild the topology of theCompound of solids by removing
+ of the faces that are shared by several solids.
+
+ Parameters:
+ theCompound Shape to be processed.
+ 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 processed shape.
+ """
+ # Example: see GEOM_TestHealing.py
+ anObj = self.HealOp.RemoveInternalFaces(theCompound)
+ RaiseIfFailed("RemoveInternalFaces", self.HealOp)
+ self._autoPublish(anObj, theName, "removeWebs")
+ return anObj
+
## Remove internal wires and edges from the given object (face).
# @param theObject Shape to be processed.
# @param theWires Indices of wires to be removed, if EMPTY then the method
# note: auto-publishing is done in self.MakeBoolean()
return self.MakeBoolean(theShape1, theShape2, 4, theName)
+ ## Perform Fuse boolean operation on the list of shapes.
+ # @param theShapesList Shapes to be fused.
+ # @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 1"
+ # \n @ref swig_MakeCommon "Example 2"
+ def MakeFuseList(self, theShapesList, theName=None):
+ """
+ Perform Fuse boolean operation on the list of shapes.
+
+ Parameters:
+ theShapesList Shapes to be fused.
+ 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 result shape.
+
+ """
+ # Example: see GEOM_TestOthers.py
+ anObj = self.BoolOp.MakeFuseList(theShapesList)
+ 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 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_common "Example 1"
+ # \n @ref swig_MakeCommon "Example 2"
+ def MakeCommonList(self, theShapesList, theName=None):
+ """
+ Perform Common boolean operation on the list of shapes.
+
+ Parameters:
+ theShapesList Shapes for Common 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.
+
+ Returns:
+ New GEOM.GEOM_Object, containing the result shape.
+
+ """
+ # Example: see GEOM_TestOthers.py
+ anObj = self.BoolOp.MakeCommonList(theShapesList)
+ 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 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_cut "Example 1"
+ # \n @ref swig_MakeCommon "Example 2"
+ def MakeCutList(self, theMainShape, theShapesList, 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.
+ 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 result shape.
+
+ """
+ # Example: see GEOM_TestOthers.py
+ anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList)
+ RaiseIfFailed("MakeCutList", self.BoolOp)
+ self._autoPublish(anObj, theName, "cut")
+ return anObj
+
# end of l3_boolean
## @}
## Get parameters of bounding box of the given shape
# @param theShape Shape to obtain bounding box of.
+ # @param precise TRUE for precise computation; FALSE for fast one.
# @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
# Xmin,Xmax: Limits of shape along OX axis.
# Ymin,Ymax: Limits of shape along OY axis.
# Zmin,Zmax: Limits of shape along OZ axis.
#
# @ref tui_measurement_tools_page "Example"
- def BoundingBox (self, theShape):
+ def BoundingBox (self, theShape, precise=False):
"""
Get parameters of bounding box of the given shape
Parameters:
theShape Shape to obtain bounding box of.
+ precise TRUE for precise computation; FALSE for fast one.
Returns:
[Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
Zmin,Zmax: Limits of shape along OZ axis.
"""
# Example: see GEOM_TestMeasures.py
- aTuple = self.MeasuOp.GetBoundingBox(theShape)
+ aTuple = self.MeasuOp.GetBoundingBox(theShape, precise)
RaiseIfFailed("GetBoundingBox", self.MeasuOp)
return aTuple
## Get bounding box of the given shape
# @param theShape Shape to obtain bounding box of.
+ # @param precise TRUE for precise computation; FALSE for fast one.
# @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 box.
#
# @ref tui_measurement_tools_page "Example"
- def MakeBoundingBox (self, theShape, theName=None):
+ def MakeBoundingBox (self, theShape, precise=False, theName=None):
"""
Get bounding box of the given shape
Parameters:
theShape Shape to obtain bounding box of.
+ precise TRUE for precise computation; FALSE for fast one.
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 created box.
"""
# Example: see GEOM_TestMeasures.py
- anObj = self.MeasuOp.MakeBoundingBox(theShape)
+ anObj = self.MeasuOp.MakeBoundingBox(theShape, precise)
RaiseIfFailed("MakeBoundingBox", self.MeasuOp)
self._autoPublish(anObj, theName, "bndbox")
return anObj
pass
return aDict
+ def GetCreationInformation(self, theShape):
+ info = theShape.GetCreationInformation()
+ # operationName
+ opName = info.operationName
+ if not opName: opName = "no info available"
+ res = "Operation: " + opName
+ # parameters
+ for parVal in info.params:
+ res += " \n %s = %s" % ( parVal.name, parVal.value )
+ return res
+
## Get a point, situated at the centre of mass of theShape.
# @param theShape Shape to define centre of mass of.
# @param theName Object name; when specified, this parameter is used
self._autoPublish(anObj, theName, "removeExtraEdges")
return anObj
+ ## Performs union faces of \a theShape
+ # Unite faces sharing one surface. It means that
+ # these faces must have references to one C++ surface object (handle).
+ # @param theShape The compound or single solid that contains faces
+ # to perform union.
+ # @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 Improved shape.
+ #
+ # @ref swig_UnionFaces "Example"
+ def UnionFaces(self, theShape, theName=None):
+ """
+ Performs union faces of theShape.
+ Unite faces sharing one surface. It means that
+ these faces must have references to one C++ surface object (handle).
+
+ Parameters:
+ theShape The compound or single solid that contains faces
+ to perform union.
+ 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:
+ Improved shape.
+ """
+ # Example: see GEOM_TestOthers.py
+ anObj = self.BlocksOp.UnionFaces(theShape)
+ RaiseIfFailed("UnionFaces", self.BlocksOp)
+ self._autoPublish(anObj, theName, "unionFaces")
+ return anObj
+
## Check, if the given shape is a blocks compound.
# Fix all detected errors.
# \note Single block can be also fixed by this method.
## Cut of lists of groups.
# New group is created. It will contain only entities
- # which are present in groups listed in theGList1 but
- # are not present in groups from theGList2.
- # @param theGList1 is a list of GEOM groups to include elements of.
- # @param theGList2 is a list of GEOM groups to exclude elements of.
+ # which are present in groups listed in theGList.
+ # @param theGList is a list of GEOM groups to include elements of.
# @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.
"""
Cut of lists of groups.
New group is created. It will contain only entities
- which are present in groups listed in theGList1 but
- are not present in groups from theGList2.
+ which are present in groups listed in theGList.
Parameters:
- theGList1 is a list of GEOM groups to include elements of.
- theGList2 is a list of GEOM groups to exclude elements of.
+ theGList is a list of GEOM groups to include elements of.
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_Object, containing the copied shape.
#
- # @ingroup l1_geompy_auxiliary
+ # @ingroup l1_geomBuilder_auxiliary
# @ref swig_MakeCopy "Example"
def MakeCopy(self, theOriginal, theName=None):
"""