X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_SWIG%2FgeompyDC.py;h=0f570563f7b0d62df73223995b8cd0682beffa88;hb=da9569a4257702366c8a827ee0f7c31594110282;hp=c8ef92793f9a967e0a405260321f5ad3903b1394;hpb=cb234e246225d575d6682ca4587e54b5f6f30497;p=modules%2Fgeom.git diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index c8ef92793..0f570563f 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -1,8 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# Copyright (C) 2007-2010 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 @@ -56,6 +53,7 @@ ## @defgroup l4_decompose Decompose objects ## @defgroup l4_access Access to sub-shapes by their unique IDs inside the main shape ## @defgroup l4_obtain Access to subshapes by a criteria +## @defgroup l4_advanced Advanced objects creation functions ## @} @@ -98,22 +96,32 @@ def RaiseIfFailed (Method_name, Operation): ## @ingroup l1_geompy_auxiliary def ParseParameters(*parameters): Result = [] - StringResult = "" + StringResult = [] for parameter in parameters: - if isinstance(parameter,str): - if notebook.isVariable(parameter): - Result.append(notebook.get(parameter)) - else: - raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!" + if isinstance(parameter, list): + lResults = ParseParameters(*parameter) + if len(lResults) > 0: + Result.append(lResults[:-1]) + StringResult += lResults[-1].split(":") + pass + pass else: - Result.append(parameter) + if isinstance(parameter,str): + if notebook.isVariable(parameter): + Result.append(notebook.get(parameter)) + else: + raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!" + pass + else: + Result.append(parameter) + pass + StringResult.append(str(parameter)) pass - - StringResult = StringResult + str(parameter) - StringResult = StringResult + ":" pass - StringResult = StringResult[:len(StringResult)-1] - Result.append(StringResult) + if Result: + Result.append(":".join(StringResult)) + else: + Result = ":".join(StringResult) return Result ## Return list of variables value from salome notebook @@ -281,6 +289,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): self.MeasuOp = None self.BlocksOp = None self.GroupOp = None + self.AdvOp = None pass ## @addtogroup l1_geompy_auxiliary @@ -312,6 +321,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): self.MeasuOp = self.GetIMeasureOperations (self.myStudyId) self.BlocksOp = self.GetIBlocksOperations (self.myStudyId) self.GroupOp = self.GetIGroupOperations (self.myStudyId) + self.AdvOp = self.GetIAdvancedOperations (self.myStudyId) pass ## Get name for sub-shape aSubObj of shape aMainObj @@ -347,7 +357,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): aSObject = self.AddInStudy(self.myStudy, aShape, aName, None) if doRestoreSubShapes: self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs, - theFindMethod, theInheritFirstArg) + theFindMethod, theInheritFirstArg, True ) except: print "addToStudy() failed" return "" @@ -387,14 +397,43 @@ class geompyDC(GEOM._objref_GEOM_Gen): # operations, where only the first argument has to be considered. # If theObject has only one argument shape, this flag is automatically # considered as True, not regarding really passed value. + # \param theAddPrefix add prefix "from_" to names of restored sub-shapes, + # and prefix "from_subshapes_of_" to names of partially restored subshapes. # \return list of published sub-shapes # # @ref tui_restore_prs_params "Example" - def RestoreSubShapes (self, theObject, theArgs=[], - theFindMethod=GEOM.FSM_GetInPlace, theInheritFirstArg=False): + def RestoreSubShapes (self, theObject, theArgs=[], theFindMethod=GEOM.FSM_GetInPlace, + theInheritFirstArg=False, theAddPrefix=True): # Example: see GEOM_TestAll.py return self.RestoreSubShapesO(self.myStudy, theObject, theArgs, - theFindMethod, theInheritFirstArg) + theFindMethod, theInheritFirstArg, theAddPrefix) + + ## Publish sub-shapes, standing for arguments and sub-shapes of arguments + # To be used from python scripts out of geompy.addToStudy (non-default usage) + # \param theObject published GEOM object, arguments of which will be published + # \param theArgs list of GEOM_Object, operation arguments to be published. + # If this list is empty, all operation arguments will be published + # \param theFindMethod method to search subshapes, corresponding to arguments and + # their subshapes. Value from enumeration GEOM::find_shape_method. + # \param theInheritFirstArg set properties of the first argument for theObject. + # Do not publish subshapes in place of arguments, but only + # in place of subshapes of the first argument, + # because the whole shape corresponds to the first argument. + # Mainly to be used after transformations, but it also can be + # usefull after partition with one object shape, and some other + # operations, where only the first argument has to be considered. + # If theObject has only one argument shape, this flag is automatically + # considered as True, not regarding really passed value. + # \param theAddPrefix add prefix "from_" to names of restored sub-shapes, + # and prefix "from_subshapes_of_" to names of partially restored subshapes. + # \return list of published sub-shapes + # + # @ref tui_restore_prs_params "Example" + def RestoreGivenSubShapes (self, theObject, theArgs=[], theFindMethod=GEOM.FSM_GetInPlace, + theInheritFirstArg=False, theAddPrefix=True): + # Example: see GEOM_TestAll.py + return self.RestoreGivenSubShapesO(self.myStudy, theObject, theArgs, + theFindMethod, theInheritFirstArg, theAddPrefix) # end of l3_restore_ss ## @} @@ -409,7 +448,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertex(self,theX, theY, theZ): + def MakeVertex(self, theX, theY, theZ): # Example: see GEOM_TestAll.py theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ) anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ) @@ -522,13 +561,13 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theFace The face for which tangent plane should be built. # @param theParameterV vertical value of the center point (0.0 - 1.0). # @param theParameterU horisontal value of the center point (0.0 - 1.0). - # @param theTrimSize the size of plane. + # @param theTrimSize the size of plane. # @return New GEOM_Object, containing the created tangent. # # @ref swig_MakeTangentPlaneOnFace "Example" - def MakeTangentPlaneOnFace(self, theFace, theParameterU, theParameterV, theTrimSize): - anObj = self.BasicOp.MakeTangentPlaneOnFace(theFace, theParameterU, theParameterV, theTrimSize) - RaiseIfFailed("MakeTangentPlaneOnFace", self.BasicOp) + def MakeTangentPlaneOnFace(self, theFace, theParameterU, theParameterV, theTrimSize): + anObj = self.BasicOp.MakeTangentPlaneOnFace(theFace, theParameterU, theParameterV, theTrimSize) + RaiseIfFailed("MakeTangentPlaneOnFace", self.BasicOp) return anObj ## Create a vector with the given components. @@ -641,7 +680,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj - ## Create a plane, passing through the 2 vectors + ## Create a plane, passing through the 2 vectors # with center in a start point of the first vector. # @param theVec1 Vector, defining center point and plane direction. # @param theVec2 Vector, defining the plane normal direction. @@ -657,10 +696,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj - ## Create a plane, based on a Local coordinate system. + ## Create a plane, based on a Local coordinate system. # @param theLCS coordinate system, defining plane. # @param theTrimSize Half size of a side of quadrangle face, representing the plane. - # @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) + # @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) # @return New GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" @@ -687,27 +726,26 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj - ## Create a local coordinate system. + ## Create a local coordinate system from shape. + # @param theShape The initial shape to detect the coordinate system. + # @return New GEOM_Object, containing the created coordinate system. + # + # @ref tui_creation_lcs "Example" + def MakeMarkerFromShape(self, theShape): + anObj = self.BasicOp.MakeMarkerFromShape(theShape) + RaiseIfFailed("MakeMarkerFromShape", self.BasicOp) + return anObj + + ## Create a local coordinate system from point and two vectors. # @param theOrigin Point of coordinate system origin. # @param theXVec Vector of X direction # @param theYVec Vector of Y direction # @return New GEOM_Object, containing the created coordinate system. # - # @ref swig_MakeMarker "Example" + # @ref tui_creation_lcs "Example" def MakeMarkerPntTwoVec(self, theOrigin, theXVec, theYVec): - O = self.PointCoordinates( theOrigin ) - OXOY = [] - for vec in [ theXVec, theYVec ]: - v1, v2 = self.SubShapeAll( vec, ShapeType["VERTEX"] ) - p1 = self.PointCoordinates( v1 ) - p2 = self.PointCoordinates( v2 ) - for i in range( 0, 3 ): - OXOY.append( p2[i] - p1[i] ) - # - anObj = self.BasicOp.MakeMarker( O[0], O[1], O[2], - OXOY[0], OXOY[1], OXOY[2], - OXOY[3], OXOY[4], OXOY[5], ) - RaiseIfFailed("MakeMarker", self.BasicOp) + anObj = self.BasicOp.MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec) + RaiseIfFailed("MakeMarkerPntTwoVec", self.BasicOp) return anObj # end of l3_basic_go @@ -742,7 +780,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3, theSense) RaiseIfFailed("MakeArcCenter", self.CurvesOp) return anObj - + ## Create an arc of ellipse, of center and two points. # @param theCenter Center of the arc. # @param thePnt1 defines major radius of the arc by distance from Pnt1 to Pnt2. @@ -933,16 +971,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp) return anObj - ## Create a sketcher wire, following the numerical description, + ## Create a sketcher wire, following the numerical description, # passed through theCoordinates argument. \n - # @param theCoordinates double values, defining points to create a wire, + # @param theCoordinates double values, defining points to create a wire, # passing from it. # @return New GEOM_Object, containing the created wire. # # @ref tui_sketcher_page "Example" def Make3DSketcher(self, theCoordinates): + theCoordinates,Parameters = ParseParameters(theCoordinates) anObj = self.CurvesOp.Make3DSketcher(theCoordinates) RaiseIfFailed("Make3DSketcher", self.CurvesOp) + anObj.SetParameters(Parameters) return anObj # end of l3_sketcher @@ -994,7 +1034,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # with edges, parallel to this coordinate axes. # @param theH height of Face. # @param theW width of Face. - # @param theOrientation orientation belong axis OXY OYZ OZX + # @param theOrientation orientation belong axis OXY OYZ OZX # @return New GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" @@ -1009,7 +1049,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a face from another plane and two sizes, # vertical size and horisontal size. # @param theObj Normale vector to the creating face or - # the face object. + # the face object. # @param theH Height (vertical size). # @param theW Width (horisontal size). # @return New GEOM_Object, containing the created face. @@ -1051,7 +1091,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a disk with specified dimensions along OX-OY coordinate axes. # @param theR Radius of Face. - # @param theOrientation set the orientation belong axis OXY or OYZ or OZX + # @param theOrientation set the orientation belong axis OXY or OYZ or OZX # @return New GEOM_Object, containing the created disk. # # @ref tui_creation_face "Example" @@ -1255,7 +1295,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj - ## Create a shape by extrusion of the base shape along the dx, dy, dz direction + ## 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. # @return New GEOM_Object, containing the created prism. @@ -1269,7 +1309,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj - ## Create a shape by extrusion of the base shape along the dx, dy, dz direction + ## Create a shape by extrusion of the base shape along the dx, dy, dz direction # i.e. all the space, transfixed by the base shape during its translation # along the vector on the given distance in 2 Ways (forward/backward) . # @param theBase Base shape to be extruded. @@ -1317,6 +1357,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theTol2D a 2d tolerance to be reached # @param theTol3D a 3d tolerance to be reached # @param theNbIter a number of iteration of approximation algorithm + # @param theMethod Kind of method to perform filling operation: + # 0 - Default - standard behaviour + # 1 - Use edges orientation - orientation of edges are + # used: if edge is reversed curve from this edge + # is reversed before using in filling algorithm. + # 2 - Auto-correct orientation - change orientation + # of curves using minimization of sum of distances + # between ends points of edges. # @param isApprox if True, BSpline curves are generated in the process # of surface construction. By default it is False, that means # the surface is created using Besier curves. The usage of @@ -1325,12 +1373,13 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the created filling surface. # # @ref tui_creation_filling "Example" - def MakeFilling(self, theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, isApprox=0): + def MakeFilling(self, theShape, theMinDeg, theMaxDeg, theTol2D, + theTol3D, theNbIter, theMethod=GEOM.FOM_Default, isApprox=0): # Example: see GEOM_TestAll.py - theMinDeg,theMaxDeg,theTol2D,theTol3D,theNbIter,Parameters = ParseParameters(theMinDeg, theMaxDeg, - theTol2D, theTol3D, theNbIter) + theMinDeg,theMaxDeg,theTol2D,theTol3D,theNbIter,Parameters = ParseParameters(theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter) anObj = self.PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, - theTol2D, theTol3D, theNbIter, isApprox) + theTol2D, theTol3D, theNbIter, + theMethod, isApprox) RaiseIfFailed("MakeFilling", self.PrimOp) anObj.SetParameters(Parameters) return anObj @@ -1364,7 +1413,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a shape by extrusion of the profile shape along # the path shape. The path shape can be a wire or an edge. - # the several profiles can be specified in the several locations of path. + # the several profiles can be specified in the several locations of path. # @param theSeqBases - list of Bases shape to be extruded. # @param theLocations - list of locations on the path corresponding # specified list of the Bases shapes. Number of locations @@ -1388,7 +1437,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a shape by extrusion of the profile shape along # the path shape. The path shape can be a wire or a edge. - # the several profiles can be specified in the several locations of path. + # the several profiles can be specified in the several locations of path. # @param theSeqBases - list of Bases shape to be extruded. Base shape must be # shell or face. If number of faces in neighbour sections # aren't coincided result solid between such sections will @@ -1774,6 +1823,34 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetShapesOnCylinderIDs", self.ShapesOp) 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. + # @param theShapeType Type of sub-shapes to be retrieved. + # @param theAxis Vector (or line, or linear edge), specifying + # axis of the cylinder to find shapes on. + # @param thePnt Point specifying location of the bottom of the cylinder. + # @param theRadius Radius of the cylinder 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. + # + # @ref swig_GetShapesOnCylinderWithLocation "Example" + def GetShapesOnCylinderWithLocation(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState): + # Example: see GEOM_TestOthers.py + aList = self.ShapesOp.GetShapesOnCylinderWithLocation(theShape, theShapeType, theAxis, thePnt, theRadius, theState) + RaiseIfFailed("GetShapesOnCylinderWithLocation", self.ShapesOp) + return aList + + ## Works like the above method, but returns list of sub-shapes indices + # + # @ref swig_GetShapesOnCylinderWithLocationIDs "Example" + def GetShapesOnCylinderWithLocationIDs(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState): + # Example: see GEOM_TestOthers.py + aList = self.ShapesOp.GetShapesOnCylinderWithLocationIDs(theShape, theShapeType, theAxis, thePnt, theRadius, theState) + RaiseIfFailed("GetShapesOnCylinderWithLocationIDs", self.ShapesOp) + return aList + ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively # the specified sphere by the certain way, defined through \a theState parameter. # @param theShape Shape to find sub-shapes of. @@ -1864,7 +1941,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Find in \a theShape all sub-shapes of type \a theShapeType, # situated relatively the specified \a theCheckShape by the # certain way, defined through \a theState parameter. - # @param theCheckShape Shape for relative comparing. + # @param theCheckShape Shape for relative comparing. It must be a solid. # @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 @@ -2067,10 +2144,13 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing processed shape. # # @ref tui_shape_processing "Example" - def ProcessShape(self,theShape, theOperators, theParameters, theValues): + def ProcessShape(self, theShape, theOperators, theParameters, theValues): # Example: see GEOM_TestHealing.py theValues,Parameters = ParseList(theValues) anObj = self.HealOp.ProcessShape(theShape, theOperators, theParameters, theValues) + # To avoid script failure in case of good argument shape + if self.HealOp.GetErrorCode() == "ShHealOper_NotError_msg": + return theShape RaiseIfFailed("ProcessShape", self.HealOp) for string in (theOperators + theParameters): Parameters = ":" + Parameters @@ -2186,11 +2266,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing processed shape. # # @ref swig_todo "Example" - def ChangeOrientationShellCopy(self,theObject): + def ChangeOrientationShellCopy(self, theObject): anObj = self.HealOp.ChangeOrientationCopy(theObject) RaiseIfFailed("ChangeOrientationCopy", self.HealOp) return anObj + ## Try to limit tolerance of the given object by value \a theTolerance. + # @param theObject Shape to be processed. + # @param theTolerance Required tolerance value. + # @return New GEOM_Object, containing processed shape. + # + # @ref tui_limit_tolerance "Example" + def LimitTolerance(self, theObject, theTolerance = 1e-07): + anObj = self.HealOp.LimitTolerance(theObject, theTolerance) + RaiseIfFailed("LimitTolerance", self.HealOp) + return anObj + ## Get a list of wires (wrapped in GEOM_Object-s), # that constitute a free boundary of the given shape. # @param theObject Shape to get free boundary of. @@ -2200,7 +2291,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # theOpenWires: Open wires on the free boundary of the given shape. # # @ref tui_measurement_tools_page "Example" - def GetFreeBoundary(self,theObject): + def GetFreeBoundary(self, theObject): # Example: see GEOM_TestHealing.py anObj = self.HealOp.GetFreeBoundary(theObject) RaiseIfFailed("GetFreeBoundary", self.HealOp) @@ -2324,10 +2415,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # 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) + # @param KeepNonlimitShapes: if this parameter == 0, then only shapes of + # target type (equal to Limit) are kept in the result, + # else standalone shapes of lower dimension + # are kept also (if they exist). # # After implementation new version of PartitionAlgo (October 2006) # other parameters are ignored by current functionality. They are kept @@ -2650,9 +2741,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Modify the Location of the given object by Path, # @param theObject The object to be displaced. # @param thePath Wire or Edge along that the object will be translated. - # @param theDistance progress of Path (0 = start location, 1 = end of path location). - # @param theCopy is to create a copy objects if true. - # @param theReverse - 0 for usual direction, 1 to reverse path direction. + # @param theDistance progress of Path (0 = start location, 1 = end of path location). + # @param theCopy is to create a copy objects if true. + # @param theReverse - 0 for usual direction, 1 to reverse path direction. # @return New GEOM_Object, containing the displaced shape. # # @ref tui_modify_location "Example" @@ -3204,6 +3295,41 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetCentreOfMass", self.MeasuOp) return anObj + ## Get a vertex subshape by index depended with orientation. + # @param theShape Shape to find subshape. + # @param theIndex Index to find vertex by this index. + # @return New GEOM_Object, containing the created vertex. + # + # @ref tui_measurement_tools_page "Example" + def GetVertexByIndex(self,theShape, theIndex): + # Example: see GEOM_TestMeasures.py + anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex) + RaiseIfFailed("GetVertexByIndex", self.MeasuOp) + return anObj + + ## Get the first vertex of wire/edge depended orientation. + # @param theShape Shape to find first vertex. + # @return New GEOM_Object, containing the created vertex. + # + # @ref tui_measurement_tools_page "Example" + def GetFirstVertex(self,theShape): + # Example: see GEOM_TestMeasures.py + anObj = self.GetVertexByIndex(theShape, 0) + RaiseIfFailed("GetFirstVertex", self.MeasuOp) + return anObj + + ## Get the last vertex of wire/edge depended orientation. + # @param theShape Shape to find last vertex. + # @return New GEOM_Object, containing the created vertex. + # + # @ref tui_measurement_tools_page "Example" + def GetLastVertex(self,theShape): + # Example: see GEOM_TestMeasures.py + nb_vert = self.ShapesOp.NumberOfSubShapes(theShape, ShapeType["VERTEX"]) + anObj = self.GetVertexByIndex(theShape, (nb_vert-1)) + RaiseIfFailed("GetLastVertex", self.MeasuOp) + return anObj + ## Get a normale to the given face. If the point is not given, # the normale is calculated at the center of mass. # @param theFace Face to define normale of. @@ -3505,19 +3631,31 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the found vertex. # # @ref swig_GetPoint "Example" - def GetPoint(self,theShape, theX, theY, theZ, theEpsilon): + def GetPoint(self, theShape, theX, theY, theZ, theEpsilon): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon) RaiseIfFailed("GetPoint", self.BlocksOp) return anObj + ## Find a vertex of the given shape, which has minimal distance to the given point. + # @param theShape Any shape. + # @param thePoint Point, close to the desired vertex. + # @return New GEOM_Object, containing the found vertex. + # + # @ref swig_GetVertexNearPoint "Example" + def GetVertexNearPoint(self, theShape, thePoint): + # Example: see GEOM_TestOthers.py + anObj = self.BlocksOp.GetVertexNearPoint(theShape, thePoint) + RaiseIfFailed("GetVertexNearPoint", self.BlocksOp) + return anObj + ## Get an edge, found in the given shape by two given vertices. # @param theShape Block or a compound of blocks. # @param thePoint1,thePoint2 Points, close to the ends of the desired edge. # @return New GEOM_Object, containing the found edge. # - # @ref swig_todo "Example" - def GetEdge(self,theShape, thePoint1, thePoint2): + # @ref swig_GetEdge "Example" + def GetEdge(self, theShape, thePoint1, thePoint2): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetEdge(theShape, thePoint1, thePoint2) RaiseIfFailed("GetEdge", self.BlocksOp) @@ -3529,7 +3667,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the found edge. # # @ref swig_GetEdgeNearPoint "Example" - def GetEdgeNearPoint(self,theShape, thePoint): + def GetEdgeNearPoint(self, theShape, thePoint): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetEdgeNearPoint(theShape, thePoint) RaiseIfFailed("GetEdgeNearPoint", self.BlocksOp) @@ -3577,7 +3715,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the found face. # # @ref swig_GetFaceNearPoint "Example" - def GetFaceNearPoint(self,theShape, thePoint): + def GetFaceNearPoint(self, theShape, thePoint): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetFaceNearPoint(theShape, thePoint) RaiseIfFailed("GetFaceNearPoint", self.BlocksOp) @@ -3595,6 +3733,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetFaceByNormale", self.BlocksOp) return anObj + ## Find all subshapes of type \a theShapeType of the given shape, + # which have minimal distance to the given point. + # @param theShape Any shape. + # @param thePoint Point, close to the desired shape. + # @param theShapeType Defines what kind of subshapes is searched. + # @param theTolerance The tolerance for distances comparison. All shapes + # with distances to the given point in interval + # [minimal_distance, minimal_distance + theTolerance] will be gathered. + # @return New GEOM_Object, containing a group of all found shapes. + # + # @ref swig_GetShapesNearPoint "Example" + def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07): + # Example: see GEOM_TestOthers.py + anObj = self.BlocksOp.GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance) + RaiseIfFailed("GetShapesNearPoint", self.BlocksOp) + return anObj + # end of l3_blocks_op ## @} @@ -3871,6 +4026,107 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetType", self.GroupOp) return aType + ## Convert a type of geom object from id to string value + # @param theId is a GEOM obect type id. + # + # @ref swig_GetType "Example" + def ShapeIdToType(self, theId): + if theId == 0: + return "COPY" + if theId == 1: + return "IMPORT" + if theId == 2: + return "POINT" + if theId == 3: + return "VECTOR" + if theId == 4: + return "PLANE" + if theId == 5: + return "LINE" + if theId == 6: + return "TORUS" + if theId == 7: + return "BOX" + if theId == 8: + return "CYLINDER" + if theId == 9: + return "CONE" + if theId == 10: + return "SPHERE" + if theId == 11: + return "PRISM" + if theId == 12: + return "REVOLUTION" + if theId == 13: + return "BOOLEAN" + if theId == 14: + return "PARTITION" + if theId == 15: + return "POLYLINE" + if theId == 16: + return "CIRCLE" + if theId == 17: + return "SPLINE" + if theId == 18: + return "ELLIPSE" + if theId == 19: + return "CIRC_ARC" + if theId == 20: + return "FILLET" + if theId == 21: + return "CHAMFER" + if theId == 22: + return "EDGE" + if theId == 23: + return "WIRE" + if theId == 24: + return "FACE" + if theId == 25: + return "SHELL" + if theId == 26: + return "SOLID" + if theId == 27: + return "COMPOUND" + if theId == 28: + return "SUBSHAPE" + if theId == 29: + return "PIPE" + if theId == 30: + return "ARCHIMEDE" + if theId == 31: + return "FILLING" + if theId == 32: + return "EXPLODE" + if theId == 33: + return "GLUED" + if theId == 34: + return "SKETCHER" + if theId == 35: + return "CDG" + if theId == 36: + return "FREE_BOUNDS" + if theId == 37: + return "GROUP" + if theId == 38: + return "BLOCK" + if theId == 39: + return "MARKER" + if theId == 40: + return "THRUSECTIONS" + if theId == 41: + return "COMPOUNDFILTER" + if theId == 42: + return "SHAPES_ON_SHAPE" + if theId == 43: + return "ELLIPSE_ARC" + if theId == 44: + return "3DSKETCHER" + if theId == 45: + return "FILLET_2D" + if theId == 46: + return "FILLET_1D" + return "Shape Id not exist." + ## Returns a main shape associated with the group # @param theGroup is a GEOM group for which a main shape object is requested # @return a GEOM object which is a main shape for theGroup @@ -3942,6 +4198,106 @@ class geompyDC(GEOM._objref_GEOM_Gen): # end of l3_groups ## @} + ## @addtogroup l4_advanced + ## @{ + + ## Create a T-shape object with specified caracteristics for the main + # and the incident pipes (radius, width, half-length). + # The extremities of the main pipe are located on junctions points P1 and P2. + # The extremity of the incident pipe is located on junction point P3. + # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + # the main plane of the T-shape is XOY. + # @param theR1 Internal radius of main pipe + # @param theW1 Width of main pipe + # @param theL1 Half-length of main pipe + # @param theR2 Internal radius of incident pipe (R2 < R1) + # @param theW2 Width of incident pipe (R2+W2 < R1+W1) + # @param theL2 Half-length of incident pipe + # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + # @param theP1 1st junction point of main pipe + # @param theP2 2nd junction point of main pipe + # @param theP3 Junction point of incident pipe + # @return List of GEOM_Objects, containing the created shape and propagation groups. + # + # @ref tui_creation_pipetshape "Example" + def MakePipeTShape(self, theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh=True, theP1=None, theP2=None, theP3=None): + theR1, theW1, theL1, theR2, theW2, theL2, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2) + if (theP1 and theP2 and theP3): + anObj = self.AdvOp.MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh, theP1, theP2, theP3) + else: + anObj = self.AdvOp.MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh) + RaiseIfFailed("MakePipeTShape", self.AdvOp) + if Parameters: anObj[0].SetParameters(Parameters) + return anObj + + ## Create a T-shape object with chamfer and with specified caracteristics for the main + # and the incident pipes (radius, width, half-length). The chamfer is + # created on the junction of the pipes. + # The extremities of the main pipe are located on junctions points P1 and P2. + # The extremity of the incident pipe is located on junction point P3. + # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + # the main plane of the T-shape is XOY. + # @param theR1 Internal radius of main pipe + # @param theW1 Width of main pipe + # @param theL1 Half-length of main pipe + # @param theR2 Internal radius of incident pipe (R2 < R1) + # @param theW2 Width of incident pipe (R2+W2 < R1+W1) + # @param theL2 Half-length of incident pipe + # @param theH Height of the chamfer. + # @param theW Width of the chamfer. + # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + # @param theP1 1st junction point of main pipe + # @param theP2 2nd junction point of main pipe + # @param theP3 Junction point of incident pipe + # @return List of GEOM_Objects, containing the created shape and propagation groups. + # + # @ref tui_creation_pipetshape "Example" + def MakePipeTShapeChamfer(self, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh=True, theP1=None, theP2=None, theP3=None): + theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW) + if (theP1 and theP2 and theP3): + anObj = self.AdvOp.MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh, theP1, theP2, theP3) + else: + anObj = self.AdvOp.MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh) + RaiseIfFailed("MakePipeTShapeChamfer", self.AdvOp) + if Parameters: anObj[0].SetParameters(Parameters) + return anObj + + ## Create a T-shape object with fillet and with specified caracteristics for the main + # and the incident pipes (radius, width, half-length). The fillet is + # created on the junction of the pipes. + # The extremities of the main pipe are located on junctions points P1 and P2. + # The extremity of the incident pipe is located on junction point P3. + # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + # the main plane of the T-shape is XOY. + # @param theR1 Internal radius of main pipe + # @param theW1 Width of main pipe + # @param theL1 Half-length of main pipe + # @param theR2 Internal radius of incident pipe (R2 < R1) + # @param theW2 Width of incident pipe (R2+W2 < R1+W1) + # @param theL2 Half-length of incident pipe + # @param theRF Radius of curvature of fillet. + # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + # @param theP1 1st junction point of main pipe + # @param theP2 2nd junction point of main pipe + # @param theP3 Junction point of incident pipe + # @return List of GEOM_Objects, containing the created shape and propagation groups. + # + # @ref tui_creation_pipetshape "Example" + def MakePipeTShapeFillet(self, theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh=True, theP1=None, theP2=None, theP3=None): + theR1, theW1, theL1, theR2, theW2, theL2, theRF, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theRF) + if (theP1 and theP2 and theP3): + anObj = self.AdvOp.MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh, theP1, theP2, theP3) + else: + anObj = self.AdvOp.MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh) + RaiseIfFailed("MakePipeTShapeFillet", self.AdvOp) + if Parameters: anObj[0].SetParameters(Parameters) + return anObj + + #@@ insert new functions before this line @@ do not remove this line @@# + + # end of l4_advanced + ## @} + ## Create a copy of the given object # @ingroup l1_geompy_auxiliary #