# Module : GEOM
# $Header$
+import salome
+salome.salome_init()
from salome import *
+
import GEOM
"""
ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
+# -----------------------------------------------------------------------------
+# enumeration shape_kind
+# -----------------------------------------------------------------------------
+
+kind = GEOM.GEOM_IKindOfShape
+
+class info:
+ UNKNOWN = 0
+ CLOSED = 1
+ UNCLOSED = 2
+
# -----------------------------------------------------------------------------
# Basic primitives
# -----------------------------------------------------------------------------
print "MakeArc : ", CurvesOp.GetErrorCode()
return anObj
+## Create an arc of circle from a center and 2 points.
+# @param thePnt1 Center of the arc
+# @param thePnt2 Start point of the arc. (Gives also the radius of the arc)
+# @param thePnt3 End point of the arc (Gives also a direction)
+# @return New GEOM_Object, containing the created arc.
+#
+# Example: see GEOM_TestAll.py
+def MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense):
+ anObj = CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense)
+ if CurvesOp.IsDone() == 0:
+ print "MakeArcCenter : ", CurvesOp.GetErrorCode()
+ return anObj
+
## Create a circle with given center, normal vector and radius.
# @param thePnt Circle center.
# @param theVec Vector, normal to the plane of the circle.
print "MakePipeWithDifferentSections : ", PrimOp.GetErrorCode()
return anObj
+## Create a shape by extrusion of the profile shape along
+# the path shape. The path shape can be a shell or a face.
+# the several profiles can be specified in the several locations of path.
+# @param theSeqBases - list of Bases shape to be extruded.
+# @param theSeqSubBases - list of corresponding subshapes of section shapes.
+# @param theLocations - list of locations on the path corresponding
+# specified list of the Bases shapes. Number of locations
+# should be equal to number of bases. First and last
+# locations must be coincided with first and last vertexes
+# of path correspondingly.
+# @param thePath - Path shape to extrude the base shape along it.
+# @param theWithContact - the mode defining that the section is translated to be in
+# contact with the spine.
+# @param - WithCorrection - defining that the section is rotated to be
+# orthogonal to the spine tangent in the correspondent point
+# @return New GEOM_Object, containing the created solids.
+#
+# Example: see GEOM_TestAll.py
+def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
+ theLocations, thePath,
+ theWithContact, theWithCorrection):
+ anObj = PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
+ theLocations, thePath,
+ theWithContact, theWithCorrection)
+ if PrimOp.IsDone() == 0:
+ print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
+ return anObj
+
+def MakePipeWithShellSectionsBySteps(theSeqBases, theSeqSubBases,
+ theLocations, thePath,
+ theWithContact, theWithCorrection):
+ res = []
+ nbsect = len(theSeqBases)
+ nbsubsect = len(theSeqSubBases)
+ #print "nbsect = ",nbsect
+ for i in range(1,nbsect):
+ #print " i = ",i
+ tmpSeqBases = [ theSeqBases[i-1], theSeqBases[i] ]
+ tmpLocations = [ theLocations[i-1], theLocations[i] ]
+ tmpSeqSubBases = []
+ if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ]
+ anObj = PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases,
+ tmpLocations, thePath,
+ theWithContact, theWithCorrection)
+ if PrimOp.IsDone() == 0:
+ print "Problems with pipe creation between ",i," and ",i+1," sections"
+ print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
+ break
+ else:
+ print "Pipe between ",i," and ",i+1," sections is OK"
+ res.append(anObj)
+ pass
+ pass
+
+ resc = MakeCompound(res)
+ #resc = MakeSewing(res, 0.001)
+ #print "resc: ",resc
+ return resc
+
+
+## Create solids between given sections
+# @param theSeqBases - list of sections (shell or face).
+# @param theLocations - list of corresponding vertexes
+# @return New GEOM_Object, containing the created solids.
+#
+# Example: see GEOM_TestAll.py
+def MakePipeShellsWithoutPath(theSeqBases, theLocations):
+ anObj = PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations)
+ if PrimOp.IsDone() == 0:
+ print "MakePipeShellsWithoutPath : ", PrimOp.GetErrorCode()
+ return anObj
+
+
# -----------------------------------------------------------------------------
# Create base shapes
# -----------------------------------------------------------------------------
return anObj
## Create a face on the given wire.
-# @param theWire Wire to build the face on.
+# @param theWire closed Wire or Edge to build the face on.
# @param isPlanarWanted If TRUE, only planar face will be built.
# If impossible, NULL object will be returned.
# @return New GEOM_Object, containing the created face.
return anObj
## Create a face on the given wires set.
-# @param theWires List of wires to build the face on.
+# @param theWires List of closed wires or edges to build the face on.
# @param isPlanarWanted If TRUE, only planar face will be built.
# If impossible, NULL object will be returned.
# @return New GEOM_Object, containing the created face.
print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
return aList
+## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
+# the specified plane by the certain way, defined through \a theState parameter.
+# @param theShape Shape to find sub-shapes of.
+# @param theShapeType Type of sub-shapes to be retrieved.
+# @param theAx1 Vector (or line, or linear edge), specifying normal
+# direction of the plane to find shapes on.
+# @param thePnt Point specifying location of the plane to find shapes on.
+# @param theState The state of the subshapes to find. It can be one of
+# ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
+# @return List of all found sub-shapes.
+#
+# Example: see GEOM_TestOthers.py
+def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
+ aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
+ return aList
+
+## Works like the above method, but returns list of sub-shapes indices
+#
+# Example: see GEOM_TestOthers.py
+def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
+ aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
# the specified cylinder by the certain way, defined through \a theState parameter.
# @param theShape Shape to find sub-shapes of.
print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
return aList
+## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
+# the specified \a theBox by the certain way, defined through \a theState parameter.
+# @param theBox Shape for relative comparing.
+# @param theShape Shape to find sub-shapes of.
+# @param theShapeType Type of sub-shapes to be retrieved.
+# @param theState The state of the subshapes to find. It can be one of
+# ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
+# @return List of all found sub-shapes.
+#
+def GetShapesOnBox(theBox, theShape, theShapeType, theState):
+ aList = ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnBox : ", ShapesOp.GetErrorCode()
+ return aList
+
+## Works like the above method, but returns list of sub-shapes indices
+#
+def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
+ aList = ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnBoxIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
## Get sub-shape(s) of theShapeWhere, which are
# coincident with \a theShapeWhat or could be a part of it.
# @param theShapeWhere Shape to find sub-shapes of.
-# @param theShapeWhat Shape, specifying what to find.
+# @param theShapeWhat Shape, specifying what to find (must be in the
+# building history of the ShapeWhere).
# @return Group of all found sub-shapes or a single found sub-shape.
#
# Example: see GEOM_TestOthers.py
print "GetInPlace : ", ShapesOp.GetErrorCode()
return anObj
+## Get sub-shape(s) of \a theShapeWhere, which are
+# coincident with \a theShapeWhat or could be a part of it.
+#
+# Implementation of this method is based on a saved history of an operation,
+# produced \a theShapeWhere. The \a theShapeWhat must be among this operation's
+# arguments (an argument shape or a sub-shape of an argument shape).
+# The operation could be the Partition or one of boolean operations,
+# performed on simple shapes (not on compounds).
+#
+# @param theShapeWhere Shape to find sub-shapes of.
+# @param theShapeWhat Shape, specifying what to find (must be in the
+# building history of the ShapeWhere).
+# @return Group of all found sub-shapes or a single found sub-shape.
+#
+# Example: see GEOM_TestOthers.py
+def GetInPlaceByHistory(theShapeWhere, theShapeWhat):
+ anObj = ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat)
+ if ShapesOp.IsDone() == 0:
+ print "GetInPlace : ", ShapesOp.GetErrorCode()
+ return anObj
+
+## Get sub-shape of theShapeWhere, which is
+# equal to \a theShapeWhat.
+# @param theShapeWhere Shape to find sub-shape of.
+# @param theShapeWhat Shape, specifying what to find
+# (must be usual shape).
+# @return New GEOM_Object for found sub-shape.
+#
+def GetSame(theShapeWhere, theShapeWhat):
+ anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
+ if ShapesOp.IsDone() == 0:
+ print "GetSame : ", ShapesOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Access to sub-shapes by their unique IDs inside the main shape.
# -----------------------------------------------------------------------------
ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
if ShapesOp.IsDone() == 0:
print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
- return ListObj
+ return ListIDs
## Obtain a compound of sub-shapes of <aShape>,
# selected by they indices in list of all sub-shapes of type <aType>.
# @param theObject Shape to be processed.
# @return New GEOM_Object, containing processed shape.
def ChangeOrientationShellCopy(theObject):
- anObj = HealOp.ChangeOrientation(theObject)
+ anObj = HealOp.ChangeOrientationCopy(theObject)
if HealOp.IsDone() == 0:
print "ChangeOrientation : ", HealOp.GetErrorCode()
return anObj
## Replace coincident faces in theShape by one face.
# @param theShape Initial shape.
# @param theTolerance Maximum distance between faces, which can be considered as coincident.
+# @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
# @return New GEOM_Object, containing a copy of theShape without coincident faces.
#
# Example: see GEOM_Spanner.py
-def MakeGlueFaces(theShape, theTolerance):
- anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
+def MakeGlueFaces(theShape, theTolerance, doKeepNonSolids=True):
+ anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
if ShapesOp.IsDone() == 0:
print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
return anObj
+
+## Find coincident faces in theShape for possible gluing.
+# @param theShape Initial shape.
+# @param theTolerance Maximum distance between faces,
+# which can be considered as coincident.
+# @return ListOfGO.
+#
+# Example: see GEOM_Spanner.py
+def GetGlueFaces(theShape, theTolerance):
+ anObj = ShapesOp.GetGlueFaces(theShape, theTolerance)
+ if ShapesOp.IsDone() == 0:
+ print "GetGlueFaces : ", ShapesOp.GetErrorCode()
+ return anObj
+
+
+## Replace coincident faces in theShape by one face
+# in compliance with given list of faces
+# @param theShape Initial shape.
+# @param theTolerance Maximum distance between faces,
+# which can be considered as coincident.
+# @param theFaces List of faces for gluing.
+# @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
+# @return New GEOM_Object, containing a copy of theShape
+# without some faces.
+#
+# Example: see GEOM_Spanner.py
+def MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids=True):
+ anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
+ if ShapesOp.IsDone() == 0:
+ print "MakeGlueFacesByList : ", ShapesOp.GetErrorCode()
+ return anObj
+
+
# -----------------------------------------------------------------------------
# Boolean (Common, Cut, Fuse, Section)
# -----------------------------------------------------------------------------
## Perform partition operation.
# @param ListShapes Shapes to be intersected.
# @param ListTools Shapes to intersect theShapes.
-# @param ListKeepInside Shapes, outside which the results will be deleted.
+# !!!NOTE: Each compound from ListShapes and ListTools will be exploded
+# in order to avoid possible intersection between shapes from
+# this compound.
+# @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
+# @param KeepNonlimitShapes: if this parameter == 0 - only shapes with
+# type <= Limit are kept in the result,
+# else - shapes with type > Limit are kept
+# also (if they exist)
+#
+# After implementation new version of PartitionAlgo (October 2006)
+# other parameters are ignored by current functionality. They are kept
+# in this function only for support old versions.
+# Ignored parameters:
+# @param ListKeepInside Shapes, outside which the results will be deleted.
# Each shape from theKeepInside must belong to theShapes also.
-# @param ListRemoveInside Shapes, inside which the results will be deleted.
+# @param ListRemoveInside Shapes, inside which the results will be deleted.
# Each shape from theRemoveInside must belong to theShapes also.
-# @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
-# @param RemoveWebs If TRUE, perform Glue 3D algorithm.
-# @param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
+# @param RemoveWebs If TRUE, perform Glue 3D algorithm.
+# @param ListMaterials Material indices for each shape. Make sence,
+# only if theRemoveWebs is TRUE.
+#
# @return New GEOM_Object, containing the result shapes.
#
# Example: see GEOM_TestAll.py
def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
- Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
+ Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+ KeepNonlimitShapes=0):
anObj = BoolOp.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials);
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes);
if BoolOp.IsDone() == 0:
print "MakePartition : ", BoolOp.GetErrorCode()
return anObj
+## Perform partition operation.
+# This method may be useful if it is needed to make a partition for
+# compound contains nonintersected shapes. Performance will be better
+# since intersection between shapes from compound is not performed.
+#
+# Description of all parameters as in previous method MakePartition()
+#
+# !!!NOTE: Passed compounds (via ListShapes or via ListTools)
+# have to consist of nonintersecting shapes.
+#
+# @return New GEOM_Object, containing the result shapes.
+#
+def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[],
+ ListKeepInside=[], ListRemoveInside=[],
+ Limit=ShapeType["SHAPE"], RemoveWebs=0,
+ ListMaterials=[], KeepNonlimitShapes=0):
+ anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
+ ListKeepInside, ListRemoveInside,
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes);
+ if BoolOp.IsDone() == 0:
+ print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
+ return anObj
+
## Shortcut to MakePartition()
#
# Example: see GEOM_TestOthers.py
def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
- Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
+ Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+ KeepNonlimitShapes=0):
anObj = MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials);
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes);
return anObj
## Perform partition of the Shape with the Plane
print "RotateCopy : ", TrsfOp.GetErrorCode()
return anObj
+## Rotate given object around vector perpendicular to plane
+# containing three points, creating its copy before the rotatation.
+# @param theObject The object to be rotated.
+# @param theCentPoint central point - the axis is the vector perpendicular to the plane
+# containing the three points.
+# @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
+# @return New GEOM_Object, containing the rotated object.
+#
+# Example: see GEOM_TestAll.py
+def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
+ anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
+ if TrsfOp.IsDone() == 0:
+ print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
## Scale the given object by the factor, creating its copy before the scaling.
# @param theObject The object to be scaled.
# @param thePoint Center point for scaling.
print "GetPosition : ", MeasuOp.GetErrorCode()
return aTuple
+## Get kind of theShape.
+#
+# @param theShape Shape to get a kind of.
+# @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
+# and a list of parameters, describing the shape.
+# @note Concrete meaning of each value, returned via \a theIntegers
+# or \a theDoubles list depends on the kind of the shape.
+# The full list of possible outputs is:
+#
+# geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices
+# geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices
+#
+# geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices
+# geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices
+#
+# geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices
+# geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices
+#
+# geompy.kind.SPHERE xc yc zc R
+# geompy.kind.CYLINDER xb yb zb dx dy dz R H
+# geompy.kind.BOX xc yc zc ax ay az
+# geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az
+# geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2
+# geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H
+# geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices
+# geompy.kind.SOLID nb_faces nb_edges nb_vertices
+#
+# geompy.kind.SPHERE2D xc yc zc R
+# geompy.kind.CYLINDER2D xb yb zb dx dy dz R H
+# geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2
+# geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H
+# geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R
+# geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2
+# geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices
+# geompy.kind.PLANE xo yo zo dx dy dz
+# geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices
+# geompy.kind.FACE nb_edges nb_vertices
+#
+# geompy.kind.CIRCLE xc yc zc dx dy dz R
+# geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2
+# geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2
+# geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2
+# geompy.kind.LINE xo yo zo dx dy dz
+# geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2
+# geompy.kind.EDGE nb_vertices
+#
+# geompy.kind.VERTEX x y z
+#
+# Example: see GEOM_TestMeasures.py
+def KindOfShape(theShape):
+ aRoughTuple = MeasuOp.KindOfShape(theShape)
+ if MeasuOp.IsDone() == 0:
+ print "KindOfShape : ", MeasuOp.GetErrorCode()
+ return []
+
+ aKind = aRoughTuple[0]
+ anInts = aRoughTuple[1]
+ aDbls = aRoughTuple[2]
+
+ # Now there is no exception from this rule:
+ aKindTuple = [aKind] + aDbls + anInts
+
+ # If they are we will regroup parameters for such kind of shape.
+ # For example:
+ #if aKind == kind.SOME_KIND:
+ # # SOME_KIND int int double int double double
+ # aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
+
+ return aKindTuple
+
# -----------------------------------------------------------------------------
# Import/Export objects
# -----------------------------------------------------------------------------