X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_SWIG%2FgeompyDC.py;h=be5a1e3154e364c8142c1273f5ab9febafd69afc;hb=55423f9957d470bc998afbf81e64b5a1e30409e9;hp=c3d4ddf7744204d6c3edbf9939e115eb6d7ac42f;hpb=723f0c59fbe9ee4bc11f11513a971fd4e691b55d;p=modules%2Fgeom.git diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index c3d4ddf77..be5a1e315 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -1,23 +1,22 @@ # -*- 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 @@ -333,6 +332,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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" @@ -384,6 +388,17 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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 ## @} @@ -938,6 +953,31 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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 ## @} @@ -1650,7 +1690,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py theLength, Parameters = ParseParameters(theLength) anObj = self.ShapesOp.MakeEdgeOnCurveByLength(theRefCurve, theLength, theStartPoint) - RaiseIfFailed("MakeEdgeOnCurveByLength", self.BasicOp) + RaiseIfFailed("MakeEdgeOnCurveByLength", self.ShapesOp) anObj.SetParameters(Parameters) return anObj @@ -2117,9 +2157,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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 @@ -2303,6 +2348,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("ExtractSubShapes", self.ShapesOp) return ListObj + ## Get a set of sub shapes defined by their unique IDs inside theMainShape + # @param theMainShape Main shape. + # @param theIndices List of unique IDs of sub shapes inside theMainShape. + # @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 ## @} @@ -2528,9 +2585,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # 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 @@ -2543,17 +2599,63 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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 theShape + # will be glued, otherwise only the edges, + # belonging to theFaces. # @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 ## @} @@ -2989,6 +3091,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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 # ----------------------------------------------------------------------------- @@ -3738,32 +3852,39 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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" @@ -3779,12 +3900,12 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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. @@ -4602,6 +4723,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): 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