# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
# File : geompy.py
# Author : Paul RASCLE, EDF
# Module : GEOM
self.AdvOp = self.GetIAdvancedOperations (self.myStudyId)
pass
+ ## Dump component to the Python script
+ # This method overrides IDL function to allow default values for the parameters.
+ def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
+ return GEOM._objref_GEOM_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
+
## Get name for sub-shape aSubObj of shape aMainObj
#
# @ref swig_SubShapeAllSorted "Example"
return ""
return aShape.GetStudyEntry()
+ ## Unpublish object in study
+ #
+ def hideInStudy(self, obj):
+ ior = salome.orb.object_to_string(obj)
+ aSObject = self.myStudy.FindObjectIOR(ior)
+ if aSObject is not None:
+ genericAttribute = self.myBuilder.FindOrCreateAttribute(aSObject, "AttributeDrawable")
+ drwAttribute = genericAttribute._narrow(SALOMEDS.AttributeDrawable)
+ drwAttribute.SetDrawable(False)
+ pass
+
# end of l1_geompy_auxiliary
## @}
## Create a point, corresponding to the given length on the given curve.
# @param theRefCurve The referenced curve.
- # @param theLength Length on the referenced curve.
- # @param theReverse Flag allowing to choose the direction for the calculation of the length (False = forward or True = reversed).
+ # @param theLength Length on the referenced curve. It can be negative.
+ # @param theStartPoint Point allowing to choose the direction for the calculation
+ # of the length. If None, start from the first point of theRefCurve.
# @return New GEOM_Object, containing the created point.
#
# @ref tui_creation_point "Example"
- def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theReverse = False):
+ def MakeVertexOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None):
# Example: see GEOM_TestAll.py
theLength, Parameters = ParseParameters(theLength)
- anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theReverse)
+ anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theStartPoint)
RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp)
anObj.SetParameters(Parameters)
return anObj
## Create a polyline on the set of points.
# @param thePoints Sequence of points for the polyline.
+ # @param theIsClosed If True, build a closed wire.
# @return New GEOM_Object, containing the created polyline.
#
# @ref tui_creation_curve "Example"
- def MakePolyline(self,thePoints):
+ def MakePolyline(self, thePoints, theIsClosed=False):
# Example: see GEOM_TestAll.py
- anObj = self.CurvesOp.MakePolyline(thePoints)
+ anObj = self.CurvesOp.MakePolyline(thePoints, theIsClosed)
RaiseIfFailed("MakePolyline", self.CurvesOp)
return anObj
## Create bezier curve on the set of points.
# @param thePoints Sequence of points for the bezier curve.
+ # @param theIsClosed If True, build a closed curve.
# @return New GEOM_Object, containing the created bezier curve.
#
# @ref tui_creation_curve "Example"
- def MakeBezier(self,thePoints):
+ def MakeBezier(self, thePoints, theIsClosed=False):
# Example: see GEOM_TestAll.py
- anObj = self.CurvesOp.MakeSplineBezier(thePoints)
+ anObj = self.CurvesOp.MakeSplineBezier(thePoints, theIsClosed)
RaiseIfFailed("MakeSplineBezier", self.CurvesOp)
return anObj
## Create B-Spline curve on the set of points.
# @param thePoints Sequence of points for the B-Spline curve.
# @param theIsClosed If True, build a closed curve.
+ # @param theDoReordering If TRUE, the algo does not follow the order of
+ # \a thePoints but searches for the closest vertex.
# @return New GEOM_Object, containing the created B-Spline curve.
#
# @ref tui_creation_curve "Example"
- def MakeInterpol(self, thePoints, theIsClosed=False):
+ def MakeInterpol(self, thePoints, theIsClosed=False, theDoReordering=False):
# Example: see GEOM_TestAll.py
- anObj = self.CurvesOp.MakeSplineInterpolation(thePoints, theIsClosed)
+ anObj = self.CurvesOp.MakeSplineInterpolation(thePoints, theIsClosed, theDoReordering)
+ RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
+ return anObj
+
+
+ ## Creates a curve using the parametric definition of the basic points.
+ # @param thexExpr parametric equation of the coordinates X.
+ # @param theyExpr parametric equation of the coordinates Y.
+ # @param thezExpr parametric equation of the coordinates Z.
+ # @param theParamMin the minimal value of the parameter.
+ # @param theParamMax the maximum value of the parameter.
+ # @param theParamStep the step of the parameter.
+ # @param theCurveType the type of the curve.
+ # @return New GEOM_Object, containing the created curve.
+ #
+ # @ref tui_creation_curve "Example"
+ def MakeCurveParametric(self, thexExpr, theyExpr, thezExpr,
+ theParamMin, theParamMax, theParamStep, theCurveType, theNewMethod=False ):
+ theParamMin,theParamMax,theParamStep,Parameters = ParseParameters(theParamMin,theParamMax,theParamStep)
+ if theNewMethod:
+ anObj = self.CurvesOp.MakeCurveParametricNew(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
+ else:
+ anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
+ anObj.SetParameters(Parameters)
return anObj
+
+
# end of l4_curves
## @}
# @param theBase Base shape to be extruded.
# @param thePoint1 First end of extrusion vector.
# @param thePoint2 Second end of extrusion vector.
+ # @param theScaleFactor Use it to make prism with scaled second base.
+ # Nagative value means not scaled second base.
# @return New GEOM_Object, containing the created prism.
#
# @ref tui_creation_prism "Example"
- def MakePrism(self, theBase, thePoint1, thePoint2):
+ def MakePrism(self, theBase, thePoint1, thePoint2, theScaleFactor = -1.0):
# Example: see GEOM_TestAll.py
- anObj = self.PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
+ anObj = None
+ Parameters = ""
+ if theScaleFactor > 0:
+ theScaleFactor,Parameters = ParseParameters(theScaleFactor)
+ anObj = self.PrimOp.MakePrismTwoPntWithScaling(theBase, thePoint1, thePoint2, theScaleFactor)
+ else:
+ anObj = self.PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
RaiseIfFailed("MakePrismTwoPnt", self.PrimOp)
+ anObj.SetParameters(Parameters)
return anObj
## Create a shape by extrusion of the base shape along a
# @param theBase Base shape to be extruded.
# @param theVec Direction of extrusion.
# @param theH Prism dimension along theVec.
+ # @param theScaleFactor Use it to make prism with scaled second base.
+ # Nagative value means not scaled second base.
# @return New GEOM_Object, containing the created prism.
#
# @ref tui_creation_prism "Example"
- def MakePrismVecH(self, theBase, theVec, theH):
+ def MakePrismVecH(self, theBase, theVec, theH, theScaleFactor = -1.0):
# Example: see GEOM_TestAll.py
- theH,Parameters = ParseParameters(theH)
- anObj = self.PrimOp.MakePrismVecH(theBase, theVec, theH)
+ anObj = None
+ Parameters = ""
+ if theScaleFactor > 0:
+ theH,theScaleFactor,Parameters = ParseParameters(theH,theScaleFactor)
+ anObj = self.PrimOp.MakePrismVecHWithScaling(theBase, theVec, theH, theScaleFactor)
+ else:
+ theH,Parameters = ParseParameters(theH)
+ anObj = self.PrimOp.MakePrismVecH(theBase, theVec, theH)
RaiseIfFailed("MakePrismVecH", self.PrimOp)
anObj.SetParameters(Parameters)
return anObj
## Create a shape by extrusion of the base shape along the dx, dy, dz direction
# @param theBase Base shape to be extruded.
# @param theDX, theDY, theDZ Directions of extrusion.
+ # @param theScaleFactor Use it to make prism with scaled second base.
+ # Nagative value means not scaled second base.
# @return New GEOM_Object, containing the created prism.
#
# @ref tui_creation_prism "Example"
- def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ):
+ def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ, theScaleFactor = -1.0):
# Example: see GEOM_TestAll.py
- theDX,theDY,theDZ,Parameters = ParseParameters(theDX, theDY, theDZ)
- anObj = self.PrimOp.MakePrismDXDYDZ(theBase, theDX, theDY, theDZ)
+ anObj = None
+ Parameters = ""
+ if theScaleFactor > 0:
+ theDX,theDY,theDZ,theScaleFactor,Parameters = ParseParameters(theDX, theDY, theDZ, theScaleFactor)
+ anObj = self.PrimOp.MakePrismDXDYDZWithScaling(theBase, theDX, theDY, theDZ, theScaleFactor)
+ else:
+ theDX,theDY,theDZ,Parameters = ParseParameters(theDX, theDY, theDZ)
+ anObj = self.PrimOp.MakePrismDXDYDZ(theBase, theDX, theDY, theDZ)
RaiseIfFailed("MakePrismDXDYDZ", self.PrimOp)
anObj.SetParameters(Parameters)
return anObj
RaiseIfFailed("MakeEdge", self.ShapesOp)
return anObj
+ ## Create a new edge, corresponding to the given length on the given curve.
+ # @param theRefCurve The referenced curve (edge).
+ # @param theLength Length on the referenced curve. It can be negative.
+ # @param theStartPoint Any point can be selected for it, the new edge will begin
+ # at the end of \a theRefCurve, close to the selected point.
+ # If None, start from the first point of \a theRefCurve.
+ # @return New GEOM_Object, containing the created edge.
+ #
+ # @ref tui_creation_edge "Example"
+ def MakeEdgeOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None):
+ # Example: see GEOM_TestAll.py
+ theLength, Parameters = ParseParameters(theLength)
+ anObj = self.ShapesOp.MakeEdgeOnCurveByLength(theRefCurve, theLength, theStartPoint)
+ RaiseIfFailed("MakeEdgeOnCurveByLength", self.ShapesOp)
+ anObj.SetParameters(Parameters)
+ return anObj
+
## Create an edge from specified wire.
# @param theWire source Wire.
# @param theLinearTolerance linear tolerance value.
# @image html get_in_place_lost_part.png
#
# @ref swig_GetInPlace "Example"
- def GetInPlace(self, theShapeWhere, theShapeWhat):
+ def GetInPlace(self, theShapeWhere, theShapeWhat, isNewImplementation = False):
# Example: see GEOM_TestOthers.py
- anObj = self.ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
+ anObj = None
+ if isNewImplementation:
+ anObj = self.ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
+ else:
+ anObj = self.ShapesOp.GetInPlaceOld(theShapeWhere, theShapeWhat)
+ pass
RaiseIfFailed("GetInPlace", self.ShapesOp)
return anObj
RaiseIfFailed("ExtractSubShapes", self.ShapesOp)
return ListObj
+ ## Get a set of sub shapes defined by their unique IDs inside <VAR>theMainShape</VAR>
+ # @param theMainShape Main shape.
+ # @param theIndices List of unique IDs of sub shapes inside <VAR>theMainShape</VAR>.
+ # @return List of GEOM_Objects, corresponding to found sub shapes.
+ #
+ # @ref swig_all_decompose "Example"
+ def SubShapes(self, aShape, anIDs):
+ # Example: see GEOM_TestAll.py
+ ListObj = self.ShapesOp.MakeSubShapes(aShape, anIDs)
+ RaiseIfFailed("SubShapes", self.ShapesOp)
+ return ListObj
+
# end of l4_decompose
## @}
# which can be considered as coincident.
# @return ListOfGO.
#
- # @ref swig_todo "Example"
+ # @ref tui_glue_faces "Example"
def GetGlueFaces(self, theShape, theTolerance):
- # Example: see GEOM_Spanner.py
anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance)
RaiseIfFailed("GetGlueFaces", self.ShapesOp)
return anObj
# @param theFaces List of faces for gluing.
# @param doKeepNonSolids If FALSE, only solids will present in the result,
# otherwise all initial shapes.
+ # @param doGlueAllEdges If TRUE, all coincident edges of <VAR>theShape</VAR>
+ # will be glued, otherwise only the edges,
+ # belonging to <VAR>theFaces</VAR>.
# @return New GEOM_Object, containing a copy of theShape
# without some faces.
#
- # @ref swig_todo "Example"
- def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, doKeepNonSolids=True):
- # Example: see GEOM_Spanner.py
- anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
+ # @ref tui_glue_faces "Example"
+ def MakeGlueFacesByList(self, theShape, theTolerance, theFaces,
+ doKeepNonSolids=True, doGlueAllEdges=True):
+ anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces,
+ doKeepNonSolids, doGlueAllEdges)
if anObj is None:
raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode()
return anObj
+ ## Replace coincident edges in theShape by one edge.
+ # @param theShape Initial shape.
+ # @param theTolerance Maximum distance between edges, which can be considered as coincident.
+ # @return New GEOM_Object, containing a copy of theShape without coincident edges.
+ #
+ # @ref tui_glue_edges "Example"
+ def MakeGlueEdges(self, theShape, theTolerance):
+ theTolerance,Parameters = ParseParameters(theTolerance)
+ anObj = self.ShapesOp.MakeGlueEdges(theShape, theTolerance)
+ if anObj is None:
+ raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode()
+ anObj.SetParameters(Parameters)
+ return anObj
+
+ ## Find coincident edges in theShape for possible gluing.
+ # @param theShape Initial shape.
+ # @param theTolerance Maximum distance between edges,
+ # which can be considered as coincident.
+ # @return ListOfGO.
+ #
+ # @ref tui_glue_edges "Example"
+ def GetGlueEdges(self, theShape, theTolerance):
+ anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance)
+ RaiseIfFailed("GetGlueEdges", self.ShapesOp)
+ return anObj
+
+ ## Replace coincident edges in theShape by one edge
+ # in compliance with given list of edges
+ # @param theShape Initial shape.
+ # @param theTolerance Maximum distance between edges,
+ # which can be considered as coincident.
+ # @param theFaces List of edges for gluing.
+ # @return New GEOM_Object, containing a copy of theShape
+ # without some edges.
+ #
+ # @ref tui_glue_edges "Example"
+ def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges):
+ anObj = self.ShapesOp.MakeGlueEdgesByList(theShape, theTolerance, theEdges)
+ if anObj is None:
+ raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode()
+ return anObj
+
# end of l3_healing
## @}
anObj.SetParameters(Parameters)
return anObj
+ ## Create new object as projection of the given one on a 2D surface.
+ # @param theSource The source object for the projection. It can be a point, edge or wire.
+ # @param theTarget The target object. It can be planar or cylindrical face.
+ # @return New GEOM_Object, containing the projection.
+ #
+ # @ref tui_projection "Example"
+ def MakeProjection(self, theSource, theTarget):
+ # Example: see GEOM_TestAll.py
+ anObj = self.TrsfOp.ProjectShapeCopy(theSource, theTarget)
+ RaiseIfFailed("ProjectShapeCopy", self.TrsfOp)
+ return anObj
+
# -----------------------------------------------------------------------------
# Patterns
# -----------------------------------------------------------------------------
# @return New GEOM_Object, containing the imported shape.
#
# @ref swig_Import_Export "Example"
- def Import(self,theFileName, theFormatName):
+ def ImportFile(self,theFileName, theFormatName):
# Example: see GEOM_TestOthers.py
- anObj = self.InsertOp.Import(theFileName, theFormatName)
+ anObj = self.InsertOp.ImportFile(theFileName, theFormatName)
RaiseIfFailed("Import", self.InsertOp)
return anObj
- ## Shortcut to Import() for BREP format
+ ## Deprecated analog of ImportFile
+ def Import(self,theFileName, theFormatName):
+ print "WARNING: Function Import is deprecated, use ImportFile instead"
+ anObj = self.InsertOp.ImportFile(theFileName, theFormatName)
+ RaiseIfFailed("Import", self.InsertOp)
+ return anObj
+
+ ## Shortcut to ImportFile() for BREP format
#
# @ref swig_Import_Export "Example"
def ImportBREP(self,theFileName):
# Example: see GEOM_TestOthers.py
- return self.Import(theFileName, "BREP")
+ return self.ImportFile(theFileName, "BREP")
- ## Shortcut to Import() for IGES format
+ ## Shortcut to ImportFile() for IGES format
#
# @ref swig_Import_Export "Example"
def ImportIGES(self,theFileName):
# Example: see GEOM_TestOthers.py
- return self.Import(theFileName, "IGES")
+ return self.ImportFile(theFileName, "IGES")
## Return length unit from given IGES file
#
# @ref swig_Import_Export "Example"
def GetIGESUnit(self,theFileName):
# Example: see GEOM_TestOthers.py
- anObj = self.InsertOp.Import(theFileName, "IGES_UNIT")
+ anObj = self.InsertOp.ImportFile(theFileName, "IGES_UNIT")
#RaiseIfFailed("Import", self.InsertOp)
# recieve name using returned vertex
UnitName = "M"
UnitName = "MM"
return UnitName
- ## Shortcut to Import() for STEP format
+ ## Shortcut to ImportFile() for STEP format
#
# @ref swig_Import_Export "Example"
def ImportSTEP(self,theFileName):
# Example: see GEOM_TestOthers.py
- return self.Import(theFileName, "STEP")
+ return self.ImportFile(theFileName, "STEP")
## Export the given shape into a file with given name.
# @param theObject Shape to be stored in the file.
RaiseIfFailed("LoadTexture", self.InsertOp)
return ID
+ ## Get entry of the object
+ # @param obj geometry object
+ # @return unique object identifier
+ # @ingroup l1_geompy_auxiliary
+ def getObjectID(self, obj):
+ ID = ""
+ entry = salome.ObjectToID(obj)
+ if entry is not None:
+ lst = entry.split(":")
+ if len(lst) > 0:
+ ID = lst[-1] # -1 means last item in the list
+ return "GEOM_" + ID
+ return ID
+
+
+
## Add marker texture. @a Width and @a Height parameters
# specify width and height of the texture in pixels.
# If @a RowData is @c True, @a Texture parameter should represent texture data