]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_SWIG/geompy.py
Salome HOME
Fix crash of BugRevolution.py import: apply the same patch, as on V2_2_0_maintainance
[modules/geom.git] / src / GEOM_SWIG / geompy.py
1 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
2 #
3 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 #
22 #
23 #
24 #  File   : geompy.py
25 #  Author : Paul RASCLE, EDF
26 #  Module : GEOM
27 #  $Header$
28
29 from salome import *
30 import GEOM
31
32 """
33     \namespace geompy
34     \brief Module geompy
35 """
36
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 geom = g._narrow( GEOM.GEOM_Gen )
39 gg = ImportComponentGUI("GEOM") 
40 gg.initGeomGen()
41
42 #SRN: modified on Mar 18, 2005
43
44 myBuilder = None
45 myStudyId = 0
46 father    = None
47
48 BasicOp  = None
49 CurvesOp = None
50 PrimOp   = None
51 ShapesOp = None
52 HealOp   = None
53 InsertOp = None 
54 BoolOp   = None 
55 TrsfOp   = None
56 LocalOp  = None
57 MeasuOp  = None
58 BlocksOp = None
59 GroupOp  = None 
60                                                
61 def init_geom(theStudy):
62
63     global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
64     global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
65     
66     myStudy = theStudy
67     myStudyId = myStudy._get_StudyId()
68     myBuilder = myStudy.NewBuilder()
69     father = myStudy.FindComponent("GEOM")
70     if father is None:
71         father = myBuilder.NewComponent("GEOM")
72         A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
73         FName = A1._narrow(SALOMEDS.AttributeName)
74         FName.SetValue("Geometry")
75         A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
76         aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
77         aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
78         myBuilder.DefineComponentInstance(father,geom)
79         pass
80          
81     # -----------------------------------------------------------------------------
82     # Assign Operations Interfaces
83     # -----------------------------------------------------------------------------
84
85     BasicOp  = geom.GetIBasicOperations    (myStudyId)
86     CurvesOp = geom.GetICurvesOperations   (myStudyId)
87     PrimOp   = geom.GetI3DPrimOperations   (myStudyId)
88     ShapesOp = geom.GetIShapesOperations   (myStudyId)
89     HealOp   = geom.GetIHealingOperations  (myStudyId)
90     InsertOp = geom.GetIInsertOperations   (myStudyId)
91     BoolOp   = geom.GetIBooleanOperations  (myStudyId)
92     TrsfOp   = geom.GetITransformOperations(myStudyId)
93     LocalOp  = geom.GetILocalOperations    (myStudyId)
94     MeasuOp  = geom.GetIMeasureOperations  (myStudyId)
95     BlocksOp = geom.GetIBlocksOperations   (myStudyId)
96     GroupOp  = geom.GetIGroupOperations   (myStudyId) 
97     pass
98
99 init_geom(myStudy)
100
101 #SRN: end of modifications
102
103 def SubShapeName(aSubObj, aMainObj):
104     """
105      *  Get name for sub-shape aSubObj of shape aMainObj
106
107      *  Example: see GEOM_TestAll.py
108     """
109     aSubId  = orb.object_to_string(aSubObj)
110     aMainId = orb.object_to_string(aMainObj)
111     index = gg.getIndexTopology(aSubId, aMainId)
112     name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
113     return name
114
115 def addToStudy(aShape, aName):
116     """
117      *  Publish in study aShape with name aName
118
119      *  Example: see GEOM_TestAll.py
120     """
121     try:
122         aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
123     except:
124         print "addToStudy() failed"
125         return ""
126     return aShape.GetStudyEntry()
127
128 def addToStudyInFather(aFather, aShape, aName):
129     """
130      *  Publish in study aShape with name aName as sub-object of previously published aFather
131
132      *  Example: see GEOM_TestAll.py
133     """
134     try:
135         aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
136     except:
137         print "addToStudyInFather() failed"
138         return ""
139     return aShape.GetStudyEntry()
140
141 # -----------------------------------------------------------------------------
142 # enumeration ShapeType as a dictionary
143 # -----------------------------------------------------------------------------
144
145 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
146
147 # -----------------------------------------------------------------------------
148 # Basic primitives
149 # -----------------------------------------------------------------------------
150
151 def MakeVertex(theX, theY, theZ):
152     """
153      *  Create point by three coordinates.
154      *  \param theX The X coordinate of the point.
155      *  \param theY The Y coordinate of the point.
156      *  \param theZ The Z coordinate of the point.
157      *  \return New GEOM_Object, containing the created point.
158
159      *  Example: see GEOM_TestAll.py
160     """
161     anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
162     if BasicOp.IsDone() == 0:
163       print "MakePointXYZ : ", BasicOp.GetErrorCode()
164     return anObj
165
166 def MakeVertexWithRef(theReference, theX, theY, theZ):
167     """
168      *  Create a point, distant from the referenced point
169      *  on the given distances along the coordinate axes.
170      *  \param theReference The referenced point.
171      *  \param theX Displacement from the referenced point along OX axis.
172      *  \param theY Displacement from the referenced point along OY axis.
173      *  \param theZ Displacement from the referenced point along OZ axis.
174      *  \return New GEOM_Object, containing the created point.
175
176      *  Example: see GEOM_TestAll.py
177     """
178     anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
179     if BasicOp.IsDone() == 0:
180       print "MakePointWithReference : ", BasicOp.GetErrorCode()
181     return anObj
182
183 def MakeVertexOnCurve(theRefCurve, theParameter):
184     """
185      *  Create a point, corresponding to the given parameter on the given curve.
186      *  \param theRefCurve The referenced curve.
187      *  \param theParameter Value of parameter on the referenced curve.
188      *  \return New GEOM_Object, containing the created point.
189
190      *  Example: see GEOM_TestAll.py
191     """
192     anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
193     if BasicOp.IsDone() == 0:
194       print "MakePointOnCurve : ", BasicOp.GetErrorCode()
195     return anObj
196
197 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
198     """
199      *  Create a vector with the given components.
200      *  \param theDX X component of the vector.
201      *  \param theDY Y component of the vector.
202      *  \param theDZ Z component of the vector.
203      *  \return New GEOM_Object, containing the created vector.
204
205      *  Example: see GEOM_TestAll.py
206     """
207     anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
208     if BasicOp.IsDone() == 0:
209       print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
210     return anObj
211
212 def MakeVector(thePnt1, thePnt2):
213     """
214      *  Create a vector between two points.
215      *  \param thePnt1 Start point for the vector.
216      *  \param thePnt2 End point for the vector.
217      *  \return New GEOM_Object, containing the created vector.
218
219      *  Example: see GEOM_TestAll.py
220     """
221     anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
222     if BasicOp.IsDone() == 0:
223       print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
224     return anObj
225
226 def MakeLine(thePnt, theDir):
227     """
228      *  Create a line, passing through the given point
229      *  and parrallel to the given direction
230      *  \param thePnt Point. The resulting line will pass through it.
231      *  \param theDir Direction. The resulting line will be parallel to it.
232      *  \return New GEOM_Object, containing the created line.
233
234      *  Example: see GEOM_TestAll.py
235     """
236     anObj = BasicOp.MakeLine(thePnt, theDir)
237     if BasicOp.IsDone() == 0:
238       print "MakeLine : ", BasicOp.GetErrorCode()
239     return anObj
240
241 def MakeLineTwoPnt(thePnt1, thePnt2):
242     """
243      *  Create a line, passing through the given points
244      *  \param thePnt1 First of two points, defining the line.
245      *  \param thePnt2 Second of two points, defining the line.
246      *  \return New GEOM_Object, containing the created line.
247
248      *  Example: see GEOM_TestAll.py
249     """
250     anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
251     if BasicOp.IsDone() == 0:
252       print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
253     return anObj
254
255 def MakePlane(thePnt, theVec, theTrimSize):
256     """
257      *  Create a plane, passing through the given point
258      *  and normal to the given vector.
259      *  \param thePnt Point, the plane has to pass through.
260      *  \param theVec Vector, defining the plane normal direction.
261      *  \param theTrimSize Half size of a side of quadrangle face, representing the plane.
262      *  \return New GEOM_Object, containing the created plane.
263
264      *  Example: see GEOM_TestAll.py
265     """
266     anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
267     if BasicOp.IsDone() == 0:
268       print "MakePlanePntVec : ", BasicOp.GetErrorCode()
269     return anObj
270
271 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
272     """
273      *  Create a plane, passing through the three given points
274      *  \param thePnt1 First of three points, defining the plane.
275      *  \param thePnt2 Second of three points, defining the plane.
276      *  \param thePnt3 Fird of three points, defining the plane.
277      *  \param theTrimSize Half size of a side of quadrangle face, representing the plane.
278      *  \return New GEOM_Object, containing the created plane.
279
280      *  Example: see GEOM_TestAll.py
281     """
282     anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
283     if BasicOp.IsDone() == 0:
284       print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
285     return anObj
286
287 def MakePlaneFace(theFace, theTrimSize):
288     """
289      *  Create a plane, similar to the existing one, but with another size of representing face.
290      *  \param theFace Referenced plane.
291      *  \param theTrimSize New half size of a side of quadrangle face, representing the plane.
292      *  \return New GEOM_Object, containing the created plane.
293
294      *  Example: see GEOM_TestAll.py
295     """
296     anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
297     if BasicOp.IsDone() == 0:
298       print "MakePlaneFace : ", BasicOp.GetErrorCode()
299     return anObj
300
301 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
302     """
303      *  Create a local coordinate system.
304      *  \param OX,OY,OZ Three coordinates of coordinate system origin.
305      *  \param XDX,XDY,XDZ Three components of OX direction
306      *  \param YDX,YDY,YDZ Three components of OY direction
307      *  \return New GEOM_Object, containing the created coordinate system.
308
309      *  Example: see GEOM_TestAll.py
310     """
311     anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
312     if BasicOp.IsDone() == 0:
313       print "MakeMarker : ", BasicOp.GetErrorCode()
314     return anObj
315
316 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
317     """
318      *  Create a local coordinate system.
319      *  \param theOrigin Point of coordinate system origin.
320      *  \param theXVec Vector of X direction
321      *  \param theYVec Vector of Y direction
322      *  \return New GEOM_Object, containing the created coordinate system.
323     """
324     O = PointCoordinates( theOrigin )
325     OXOY = []
326     for vec in [ theXVec, theYVec ]:
327         v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
328         p1 = PointCoordinates( v1 )
329         p2 = PointCoordinates( v2 )
330         for i in range( 0, 3 ):
331              OXOY.append( p2[i] - p1[i] )
332     #
333     anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
334                                 OXOY[0], OXOY[1], OXOY[2],
335                                 OXOY[3], OXOY[4], OXOY[5], )
336     if BasicOp.IsDone() == 0:
337       print "MakeMarker : ", BasicOp.GetErrorCode()
338     return anObj
339
340 # -----------------------------------------------------------------------------
341 # Curves
342 # -----------------------------------------------------------------------------
343
344 def MakeArc(thePnt1, thePnt2, thePnt3):
345     """
346      *  Create an arc of circle, passing through three given points.
347      *  \param thePnt1 Start point of the arc.
348      *  \param thePnt2 Middle point of the arc.
349      *  \param thePnt3 End point of the arc.
350      *  \return New GEOM_Object, containing the created arc.
351
352      *  Example: see GEOM_TestAll.py
353     """
354     anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
355     if CurvesOp.IsDone() == 0:
356       print "MakeArc : ", CurvesOp.GetErrorCode()
357     return anObj
358
359 def MakeCircle(thePnt, theVec, theR):
360     """
361      *  Create a circle with given center, normal vector and radius.
362      *  \param thePnt Circle center.
363      *  \param theVec Vector, normal to the plane of the circle.
364      *  \param theR Circle radius.
365      *  \return New GEOM_Object, containing the created circle.
366
367      *  Example: see GEOM_TestAll.py
368     """
369     anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
370     if CurvesOp.IsDone() == 0:
371       print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
372     return anObj
373
374 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
375     """
376      *  Create a circle, passing through three given points
377      *  \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
378      *  \return New GEOM_Object, containing the created circle.
379
380      *  Example: see GEOM_TestAll.py
381     """
382     anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
383     if CurvesOp.IsDone() == 0:
384       print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
385     return anObj
386
387 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
388     """
389      *  Create an ellipse with given center, normal vector and radiuses.
390      *  \param thePnt Ellipse center.
391      *  \param theVec Vector, normal to the plane of the ellipse.
392      *  \param theRMajor Major ellipse radius.
393      *  \param theRMinor Minor ellipse radius.
394      *  \return New GEOM_Object, containing the created ellipse.
395
396      *  Example: see GEOM_TestAll.py
397     """
398     anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
399     if CurvesOp.IsDone() == 0:
400       print "MakeEllipse : ", CurvesOp.GetErrorCode()
401     return anObj
402
403 def MakePolyline(thePoints):
404     """
405      *  Create a polyline on the set of points.
406      *  \param thePoints Sequence of points for the polyline.
407      *  \return New GEOM_Object, containing the created polyline.
408
409      *  Example: see GEOM_TestAll.py
410     """
411     anObj = CurvesOp.MakePolyline(thePoints)
412     if CurvesOp.IsDone() == 0:
413       print "MakePolyline : ", CurvesOp.GetErrorCode()
414     return anObj
415
416 def MakeBezier(thePoints):
417     """
418      *  Create bezier curve on the set of points.
419      *  \param thePoints Sequence of points for the bezier curve.
420      *  \return New GEOM_Object, containing the created bezier curve.
421
422      *  Example: see GEOM_TestAll.py
423     """
424     anObj = CurvesOp.MakeSplineBezier(thePoints)
425     if CurvesOp.IsDone() == 0:
426       print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
427     return anObj
428
429 def MakeInterpol(thePoints):
430     """
431      *  Create B-Spline curve on the set of points.
432      *  \param thePoints Sequence of points for the B-Spline curve.
433      *  \return New GEOM_Object, containing the created B-Spline curve.
434
435      *  Example: see GEOM_TestAll.py
436     """
437     anObj = CurvesOp.MakeSplineInterpolation(thePoints)
438     if CurvesOp.IsDone() == 0:
439       print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
440     return anObj
441
442 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
443     """
444      *  Create a sketcher (wire or face), following the textual description,
445      *  passed through \a theCommand argument. \n
446      *  Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
447      *  Format of the description string have to be the following:
448      *
449      *  "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
450      *
451      *  Where:
452      *  - x1, y1 are coordinates of the first sketcher point (zero by default),
453      *  - CMD is one of
454      *     - "R angle" : Set the direction by angle
455      *     - "D dx dy" : Set the direction by DX & DY
456      *     .
457      *       \n
458      *     - "TT x y" : Create segment by point at X & Y
459      *     - "T dx dy" : Create segment by point with DX & DY
460      *     - "L length" : Create segment by direction & Length
461      *     - "IX x" : Create segment by direction & Intersect. X
462      *     - "IY y" : Create segment by direction & Intersect. Y
463      *     .
464      *       \n
465      *     - "C radius length" : Create arc by direction, radius and length(in degree)
466      *     .
467      *       \n
468      *     - "WW" : Close Wire (to finish)
469      *     - "WF" : Close Wire and build face (to finish)
470      *
471      *  \param theCommand String, defining the sketcher in local
472      *                    coordinates of the working plane.
473      *  \param theWorkingPlane Nine double values, defining origin,
474      *                         OZ and OX directions of the working plane.
475      *  \return New GEOM_Object, containing the created wire.
476
477      *  Example: see GEOM_TestAll.py
478     """
479     anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
480     if CurvesOp.IsDone() == 0:
481       print "MakeSketcher : ", CurvesOp.GetErrorCode()
482     return anObj
483
484 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
485     """
486      *  Create a sketcher (wire or face), following the textual description,
487      *  passed through \a theCommand argument. \n
488      *  For format of the description string see the previous method.\n
489      *  \param theCommand String, defining the sketcher in local
490      *                    coordinates of the working plane.
491      *  \param theWorkingPlane Planar Face of the working plane.
492      *  \return New GEOM_Object, containing the created wire.
493     """
494     anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
495     if CurvesOp.IsDone() == 0:
496       print "MakeSketcher : ", CurvesOp.GetErrorCode()
497     return anObj
498
499 # -----------------------------------------------------------------------------
500 # Create 3D Primitives
501 # -----------------------------------------------------------------------------
502
503 def MakeBox(x1,y1,z1,x2,y2,z2):
504     """
505      *  Create a box by coordinates of two opposite vertices.
506
507      *  Example: see GEOM_TestAll.py
508     """
509     pnt1 = MakeVertex(x1,y1,z1)
510     pnt2 = MakeVertex(x2,y2,z2)
511     return MakeBoxTwoPnt(pnt1,pnt2)
512
513 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
514     """
515      *  Create a box with specified dimensions along the coordinate axes
516      *  and with edges, parallel to the coordinate axes.
517      *  Center of the box will be at point (DX/2, DY/2, DZ/2).
518      *  \param theDX Length of Box edges, parallel to OX axis.
519      *  \param theDY Length of Box edges, parallel to OY axis.
520      *  \param theDZ Length of Box edges, parallel to OZ axis.
521      *  \return New GEOM_Object, containing the created box.
522
523      *  Example: see GEOM_TestAll.py
524     """
525     anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
526     if PrimOp.IsDone() == 0:
527       print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
528     return anObj
529
530 def MakeBoxTwoPnt(thePnt1, thePnt2):
531     """
532      *  Create a box with two specified opposite vertices,
533      *  and with edges, parallel to the coordinate axes
534      *  \param thePnt1 First of two opposite vertices.
535      *  \param thePnt2 Second of two opposite vertices.
536      *  \return New GEOM_Object, containing the created box.
537
538      *  Example: see GEOM_TestAll.py
539     """
540     anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
541     if PrimOp.IsDone() == 0:
542       print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
543     return anObj
544
545 def MakeCylinder(thePnt, theAxis, theR, theH):
546     """
547      *  Create a cylinder with given base point, axis, radius and height.
548      *  \param thePnt Central point of cylinder base.
549      *  \param theAxis Cylinder axis.
550      *  \param theR Cylinder radius.
551      *  \param theH Cylinder height.
552      *  \return New GEOM_Object, containing the created cylinder.
553
554      *  Example: see GEOM_TestAll.py
555     """
556     anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
557     if PrimOp.IsDone() == 0:
558       print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
559     return anObj
560
561 def MakeCylinderRH(theR, theH):
562     """
563      *  Create a cylinder with given radius and height at
564      *  the origin of coordinate system. Axis of the cylinder
565      *  will be collinear to the OZ axis of the coordinate system.
566      *  \param theR Cylinder radius.
567      *  \param theH Cylinder height.
568      *  \return New GEOM_Object, containing the created cylinder.
569
570      *  Example: see GEOM_TestAll.py
571     """
572     anObj = PrimOp.MakeCylinderRH(theR, theH)
573     if PrimOp.IsDone() == 0:
574       print "MakeCylinderRH : ", PrimOp.GetErrorCode()
575     return anObj
576
577 def MakeSpherePntR(thePnt, theR):
578     """
579      *  Create a sphere with given center and radius.
580      *  \param thePnt Sphere center.
581      *  \param theR Sphere radius.
582      *  \return New GEOM_Object, containing the created sphere.
583
584      *  Example: see GEOM_TestAll.py
585     """
586     anObj = PrimOp.MakeSpherePntR(thePnt, theR)
587     if PrimOp.IsDone() == 0:
588       print "MakeSpherePntR : ", PrimOp.GetErrorCode()
589     return anObj
590
591 def MakeSphere(x, y, z, theR):
592     """
593      *  Create a sphere with given center and radius.
594      *  \param x,y,z Coordinates of sphere center.
595      *  \param theR Sphere radius.
596      *  \return New GEOM_Object, containing the created sphere.
597
598      *  Example: see GEOM_TestAll.py
599     """
600     point = MakeVertex(x, y, z)
601     anObj = MakeSpherePntR(point, theR)
602     return anObj
603
604 def MakeSphereR(theR):
605     """
606      *  Create a sphere with given radius at the origin of coordinate system.
607      *  \param theR Sphere radius.
608      *  \return New GEOM_Object, containing the created sphere.
609
610      *  Example: see GEOM_TestAll.py
611     """
612     anObj = PrimOp.MakeSphereR(theR)
613     if PrimOp.IsDone() == 0:
614       print "MakeSphereR : ", PrimOp.GetErrorCode()
615     return anObj
616
617 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
618     """
619      *  Create a cone with given base point, axis, height and radiuses.
620      *  \param thePnt Central point of the first cone base.
621      *  \param theAxis Cone axis.
622      *  \param theR1 Radius of the first cone base.
623      *  \param theR2 Radius of the second cone base.
624      *    \note If both radiuses are non-zero, the cone will be truncated.
625      *    \note If the radiuses are equal, a cylinder will be created instead.
626      *  \param theH Cone height.
627      *  \return New GEOM_Object, containing the created cone.
628
629      *  Example: see GEOM_TestAll.py
630     """
631     anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
632     if PrimOp.IsDone() == 0:
633       print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
634     return anObj
635
636 def MakeConeR1R2H(theR1, theR2, theH):
637     """
638      *  Create a cone with given height and radiuses at
639      *  the origin of coordinate system. Axis of the cone will
640      *  be collinear to the OZ axis of the coordinate system.
641      *  \param theR1 Radius of the first cone base.
642      *  \param theR2 Radius of the second cone base.
643      *    \note If both radiuses are non-zero, the cone will be truncated.
644      *    \note If the radiuses are equal, a cylinder will be created instead.
645      *  \param theH Cone height.
646      *  \return New GEOM_Object, containing the created cone.
647
648      *  Example: see GEOM_TestAll.py
649     """
650     anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
651     if PrimOp.IsDone() == 0:
652       print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
653     return anObj
654
655 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
656     """
657      *  Create a torus with given center, normal vector and radiuses.
658      *  \param thePnt Torus central point.
659      *  \param theVec Torus axis of symmetry.
660      *  \param theRMajor Torus major radius.
661      *  \param theRMinor Torus minor radius.
662      *  \return New GEOM_Object, containing the created torus.
663
664      *  Example: see GEOM_TestAll.py
665     """
666     anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
667     if PrimOp.IsDone() == 0:
668       print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
669     return anObj
670
671 def MakeTorusRR(theRMajor, theRMinor):
672     """
673      *  Create a torus with given radiuses at the origin of coordinate system.
674      *  \param theRMajor Torus major radius.
675      *  \param theRMinor Torus minor radius.
676      *  \return New GEOM_Object, containing the created torus.
677
678      *  Example: see GEOM_TestAll.py
679     """
680     anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
681     if PrimOp.IsDone() == 0:
682       print "MakeTorusRR : ", PrimOp.GetErrorCode()
683     return anObj
684
685 def MakePrism(theBase, thePoint1, thePoint2):
686     """
687      *  Create a shape by extrusion of the base shape along a vector, defined by two points.
688      *  \param theBase Base shape to be extruded.
689      *  \param thePoint1 First end of extrusion vector.
690      *  \param thePoint2 Second end of extrusion vector.
691      *  \return New GEOM_Object, containing the created prism.
692
693      *  Example: see GEOM_TestAll.py
694     """
695     anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
696     if PrimOp.IsDone() == 0:
697       print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
698     return anObj
699
700 def MakePrismVecH(theBase, theVec, theH):
701     """
702      *  Create a shape by extrusion of the base shape along the vector,
703      *  i.e. all the space, transfixed by the base shape during its translation
704      *  along the vector on the given distance.
705      *  \param theBase Base shape to be extruded.
706      *  \param theVec Direction of extrusion.
707      *  \param theH Prism dimension along theVec.
708      *  \return New GEOM_Object, containing the created prism.
709
710      *  Example: see GEOM_TestAll.py
711     """
712     anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
713     if PrimOp.IsDone() == 0:
714       print "MakePrismVecH : ", PrimOp.GetErrorCode()
715     return anObj
716
717 def MakePipe(theBase, thePath):
718     """
719      *  Create a shape by extrusion of the base shape along
720      *  the path shape. The path shape can be a wire or an edge.
721      *  \param theBase Base shape to be extruded.
722      *  \param thePath Path shape to extrude the base shape along it.
723      *  \return New GEOM_Object, containing the created pipe.
724
725      *  Example: see GEOM_TestAll.py
726     """
727     anObj = PrimOp.MakePipe(theBase, thePath)
728     if PrimOp.IsDone() == 0:
729       print "MakePipe : ", PrimOp.GetErrorCode()
730     return anObj
731
732 def MakeRevolution(theBase, theAxis, theAngle):
733     """
734      *  Create a shape by revolution of the base shape around the axis
735      *  on the given angle, i.e. all the space, transfixed by the base
736      *  shape during its rotation around the axis on the given angle.
737      *  \param theBase Base shape to be rotated.
738      *  \param theAxis Rotation axis.
739      *  \param theAngle Rotation angle in radians.
740      *  \return New GEOM_Object, containing the created revolution.
741
742      *  Example: see GEOM_TestAll.py
743     """
744     anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
745     if PrimOp.IsDone() == 0:
746       print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
747     return anObj
748
749 # -----------------------------------------------------------------------------
750 # Create base shapes
751 # -----------------------------------------------------------------------------
752
753 def MakeEdge(thePnt1, thePnt2):
754     """
755      *  Create a linear edge with specified ends.
756      *  \param thePnt1 Point for the first end of edge.
757      *  \param thePnt2 Point for the second end of edge.
758      *  \return New GEOM_Object, containing the created edge.
759
760      *  Example: see GEOM_TestAll.py
761     """
762     anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
763     if ShapesOp.IsDone() == 0:
764       print "MakeEdge : ", ShapesOp.GetErrorCode()
765     return anObj
766
767 def MakeWire(theEdgesAndWires):
768     """
769      *  Create a wire from the set of edges and wires.
770      *  \param theEdgesAndWires List of edges and/or wires.
771      *  \return New GEOM_Object, containing the created wire.
772
773      *  Example: see GEOM_TestAll.py
774     """
775     anObj = ShapesOp.MakeWire(theEdgesAndWires)
776     if ShapesOp.IsDone() == 0:
777       print "MakeWire : ", ShapesOp.GetErrorCode()
778     return anObj
779
780 def MakeFace(theWire, isPlanarWanted):
781     """
782      *  Create a face on the given wire.
783      *  \param theWire Wire to build the face on.
784      *  \param isPlanarWanted If TRUE, only planar face will be built.
785      *                        If impossible, NULL object will be returned.
786      *  \return New GEOM_Object, containing the created face.
787
788      *  Example: see GEOM_TestAll.py
789     """
790     anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
791     if ShapesOp.IsDone() == 0:
792       print "MakeFace : ", ShapesOp.GetErrorCode()
793     return anObj
794
795 def MakeFaceWires(theWires, isPlanarWanted):
796     """
797      *  Create a face on the given wires set.
798      *  \param theWires List of wires to build the face on.
799      *  \param isPlanarWanted If TRUE, only planar face will be built.
800      *                        If impossible, NULL object will be returned.
801      *  \return New GEOM_Object, containing the created face.
802
803      *  Example: see GEOM_TestAll.py
804     """
805     anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
806     if ShapesOp.IsDone() == 0:
807       print "MakeFaceWires : ", ShapesOp.GetErrorCode()
808     return anObj
809
810 def MakeFaces(theWires, isPlanarWanted):
811     """
812      *  Shortcut to MakeFaceWires()
813
814      *  Example: see GEOM_TestOthers.py
815     """
816     anObj = MakeFaceWires(theWires, isPlanarWanted)
817     return anObj
818
819 def MakeShell(theFacesAndShells):
820     """
821      *  Create a shell from the set of faces and shells.
822      *  \param theFacesAndShells List of faces and/or shells.
823      *  \return New GEOM_Object, containing the created shell.
824
825      *  Example: see GEOM_TestAll.py
826     """
827     anObj = ShapesOp.MakeShell(theFacesAndShells)
828     if ShapesOp.IsDone() == 0:
829         print "MakeShell : ", ShapesOp.GetErrorCode()
830     return anObj
831
832 def MakeSolid(theShells):
833     """
834      *  Create a solid, bounded by the given shells.
835      *  \param theShells Sequence of bounding shells.
836      *  \return New GEOM_Object, containing the created solid.
837
838      *  Example: see GEOM_TestAll.py
839     """
840     anObj = ShapesOp.MakeSolidShells(theShells)
841     if ShapesOp.IsDone() == 0:
842         print "MakeSolid : ", ShapesOp.GetErrorCode()
843     return anObj
844
845 def MakeCompound(theShapes):
846     """
847      *  Create a compound of the given shapes.
848      *  \param theShapes List of shapes to put in compound.
849      *  \return New GEOM_Object, containing the created compound.
850
851      *  Example: see GEOM_TestAll.py
852     """
853     anObj = ShapesOp.MakeCompound(theShapes)
854     if ShapesOp.IsDone() == 0:
855       print "MakeCompound : ", ShapesOp.GetErrorCode()
856     return anObj
857
858 def NumberOfFaces(theShape):
859     """
860      *  Gives quantity of faces in the given shape.
861      *  \param theShape Shape to count faces of.
862      *  \return Quantity of faces.
863
864      *  Example: see GEOM_TestOthers.py
865     """
866     nb_faces = ShapesOp.NumberOfFaces(theShape)
867     if ShapesOp.IsDone() == 0:
868       print "NumberOfFaces : ", ShapesOp.GetErrorCode()
869     return nb_faces
870
871 def NumberOfEdges(theShape):
872     """
873      *  Gives quantity of edges in the given shape.
874      *  \param theShape Shape to count edges of.
875      *  \return Quantity of edges.
876
877      *  Example: see GEOM_TestOthers.py
878     """
879     nb_edges = ShapesOp.NumberOfEdges(theShape)
880     if ShapesOp.IsDone() == 0:
881       print "NumberOfEdges : ", ShapesOp.GetErrorCode()
882     return nb_edges
883
884 def ChangeOrientation(theShape):
885     """
886      *  Reverses an orientation the given shape.
887      *  \param theShape Shape to be reversed.
888      *  \return The reversed copy of theShape.
889
890      *  Example: see GEOM_TestAll.py
891     """
892     anObj = ShapesOp.ChangeOrientation(theShape)
893     if ShapesOp.IsDone() == 0:
894       print "ChangeOrientation : ", ShapesOp.GetErrorCode()
895     return anObj
896
897 def OrientationChange(theShape):
898     """
899      *  Shortcut to ChangeOrientation()
900
901      *  Example: see GEOM_TestOthers.py
902     """
903     anObj = ChangeOrientation(theShape)
904     return anObj
905
906 def GetFreeFacesIDs(theShape):
907     """
908      *  Retrieve all free faces from the given shape.
909      *  Free face is a face, which is not shared between two shells of the shape.
910      *  \param theShape Shape to find free faces in.
911      *  \return List of IDs of all free faces, contained in theShape.
912
913      *  Example: see GEOM_TestOthers.py
914     """
915     anIDs = ShapesOp.GetFreeFacesIDs(theShape)
916     if ShapesOp.IsDone() == 0:
917       print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
918     return anIDs
919
920 def GetSharedShapes(theShape1, theShape2, theShapeType):
921     """
922      *  Get all sub-shapes of theShape1 of the given type, shared with theShape2.
923      *  \param theShape1 Shape to find sub-shapes in.
924      *  \param theShape2 Shape to find shared sub-shapes with.
925      *  \param theShapeType Type of sub-shapes to be retrieved.
926      *  \return List of sub-shapes of theShape1, shared with theShape2.
927
928      *  Example: see GEOM_TestOthers.py
929     """
930     aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
931     if ShapesOp.IsDone() == 0:
932       print "GetSharedShapes : ", ShapesOp.GetErrorCode()
933     return aList
934
935 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
936     """
937      *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
938      *  the specified plane by the certain way, defined through \a theState parameter.
939      *  \param theShape Shape to find sub-shapes of.
940      *  \param theShapeType Type of sub-shapes to be retrieved.
941      *  \param theAx1 Vector (or line, or linear edge), specifying normal
942      *                direction and location of the plane to find shapes on.
943      *  \param theState The state of the subshapes to find. It can be one of
944      *   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
945      *  \return List of all found sub-shapes.
946
947      *  Example: see GEOM_TestOthers.py
948     """
949     aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
950     if ShapesOp.IsDone() == 0:
951       print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
952     return aList
953
954 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
955     """
956      *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
957      *  the specified cylinder by the certain way, defined through \a theState parameter.
958      *  \param theShape Shape to find sub-shapes of.
959      *  \param theShapeType Type of sub-shapes to be retrieved.
960      *  \param theAxis Vector (or line, or linear edge), specifying
961      *                 axis of the cylinder to find shapes on.
962      *  \param theRadius Radius of the cylinder to find shapes on.
963      *  \param theState The state of the subshapes to find. It can be one of
964      *   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
965      *  \return List of all found sub-shapes.
966
967      *  Example: see GEOM_TestOthers.py
968     """
969     aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
970     if ShapesOp.IsDone() == 0:
971       print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
972     return aList
973
974 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
975     """
976      *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
977      *  the specified sphere by the certain way, defined through \a theState parameter.
978      *  \param theShape Shape to find sub-shapes of.
979      *  \param theShapeType Type of sub-shapes to be retrieved.
980      *  \param theCenter Point, specifying center of the sphere to find shapes on.
981      *  \param theRadius Radius of the sphere to find shapes on.
982      *  \param theState The state of the subshapes to find. It can be one of
983      *   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
984      *  \return List of all found sub-shapes.
985
986      *  Example: see GEOM_TestOthers.py
987     """
988     aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
989     if ShapesOp.IsDone() == 0:
990       print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
991     return aList
992
993 def GetInPlace(theShapeWhere, theShapeWhat):
994     """
995      *  Get sub-shape(s) of theShapeWhere, which are
996      *  coincident with \a theShapeWhat or could be a part of it.
997      *  \param theShapeWhere Shape to find sub-shapes of.
998      *  \param theShapeWhat Shape, specifying what to find.
999      *  \return Group of all found sub-shapes or a single found sub-shape.
1000
1001      *  Example: see GEOM_TestOthers.py
1002     """
1003     anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1004     if ShapesOp.IsDone() == 0:
1005       print "GetInPlace : ", ShapesOp.GetErrorCode()
1006     return anObj
1007
1008 # -----------------------------------------------------------------------------
1009 # Access to sub-shapes by their unique IDs inside the main shape.
1010 # -----------------------------------------------------------------------------
1011
1012 def GetSubShape(aShape, ListOfID):
1013     """
1014      *  Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1015      *  of <aShape>, selected by their unique IDs inside <aShape>
1016
1017      *  Example: see GEOM_TestAll.py
1018     """
1019     anObj = geom.AddSubShape(aShape,ListOfID)
1020     return anObj
1021
1022 def GetSubShapeID(aShape, aSubShape):
1023     """
1024      *  Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1025
1026      *  Example: see GEOM_TestAll.py
1027     """
1028     anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1029     if LocalOp.IsDone() == 0:
1030       print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1031     return anID
1032
1033 # -----------------------------------------------------------------------------
1034 # Decompose objects
1035 # -----------------------------------------------------------------------------
1036
1037 def SubShapeAll(aShape, aType):
1038     """
1039      *  Explode a shape on subshapes of a given type.
1040      *  \param theShape Shape to be exploded.
1041      *  \param theShapeType Type of sub-shapes to be retrieved.
1042      *  \return List of sub-shapes of type theShapeType, contained in theShape.
1043
1044      *  Example: see GEOM_TestAll.py
1045     """
1046     ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1047     if ShapesOp.IsDone() == 0:
1048       print "MakeExplode : ", ShapesOp.GetErrorCode()
1049     return ListObj
1050
1051 def SubShapeAllIDs(aShape, aType):
1052     """
1053      *  Explode a shape on subshapes of a given type.
1054      *  \param theShape Shape to be exploded.
1055      *  \param theShapeType Type of sub-shapes to be retrieved.
1056      *  \return List of IDs of sub-shapes.
1057     """
1058     ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1059     if ShapesOp.IsDone() == 0:
1060       print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1061     return ListObj
1062
1063 def SubShapeAllSorted(aShape, aType):
1064     """
1065      *  Explode a shape on subshapes of a given type.
1066      *  Sub-shapes will be sorted by coordinates of their gravity centers.
1067      *  \param theShape Shape to be exploded.
1068      *  \param theShapeType Type of sub-shapes to be retrieved.
1069      *  \return List of sub-shapes of type theShapeType, contained in theShape.
1070
1071      *  Example: see GEOM_TestAll.py
1072     """
1073     ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1074     if ShapesOp.IsDone() == 0:
1075       print "MakeExplode : ", ShapesOp.GetErrorCode()
1076     return ListObj
1077
1078 def SubShapeAllSortedIDs(aShape, aType):
1079     """
1080      *  Explode a shape on subshapes of a given type.
1081      *  Sub-shapes will be sorted by coordinates of their gravity centers.
1082      *  \param theShape Shape to be exploded.
1083      *  \param theShapeType Type of sub-shapes to be retrieved.
1084      *  \return List of IDs of sub-shapes.
1085     """
1086     ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1087     if ShapesOp.IsDone() == 0:
1088       print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1089     return ListObj
1090
1091 def SubShape(aShape, aType, ListOfInd):
1092     """
1093      *  Obtain a compound of sub-shapes of <aShape>,
1094      *  selected by they indices in list of all sub-shapes of type <aType>.
1095      *  Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1096
1097      *  Example: see GEOM_TestAll.py
1098     """
1099     ListOfIDs = []
1100     AllShapeList = SubShapeAll(aShape, aType)
1101     for ind in ListOfInd:
1102         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1103     anObj = GetSubShape(aShape, ListOfIDs)
1104     return anObj
1105
1106 def SubShapeSorted(aShape, aType, ListOfInd):
1107     """
1108      *  Obtain a compound of sub-shapes of <aShape>,
1109      *  selected by they indices in sorted list of all sub-shapes of type <aType>.
1110      *  Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1111
1112      *  Example: see GEOM_TestAll.py
1113     """
1114     ListOfIDs = []
1115     AllShapeList = SubShapeAllSorted(aShape, aType)
1116     for ind in ListOfInd:
1117         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1118     anObj = GetSubShape(aShape, ListOfIDs)
1119     return anObj
1120
1121 # -----------------------------------------------------------------------------
1122 # Healing operations
1123 # -----------------------------------------------------------------------------
1124
1125 def ProcessShape(theShape, theOperators, theParameters, theValues):
1126     """
1127      *  Apply a sequence of Shape Healing operators to the given object.
1128      *  \param theShape Shape to be processed.
1129      *  \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1130      *  \param theParameters List of names of parameters
1131      *                    ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1132      *  \param theValues List of values of parameters, in the same order
1133      *                    as parameters are listed in \a theParameters list.
1134      *  \return New GEOM_Object, containing processed shape.
1135
1136      *  Example: see GEOM_TestHealing.py
1137     """
1138     anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1139     if HealOp.IsDone() == 0:
1140         print "ProcessShape : ", HealOp.GetErrorCode()
1141     return anObj
1142
1143 def SuppressFaces(theObject, theFaces):
1144     """
1145      *  Remove faces from the given object (shape).
1146      *  \param theObject Shape to be processed.
1147      *  \param theFaces Indices of faces to be removed, if EMPTY then the method
1148      *                  removes ALL faces of the given object.
1149      *  \return New GEOM_Object, containing processed shape.
1150
1151      *  Example: see GEOM_TestHealing.py
1152     """
1153     anObj = HealOp.SuppressFaces(theObject, theFaces)
1154     if HealOp.IsDone() == 0:
1155       print "SuppressFaces : ", HealOp.GetErrorCode()
1156     return anObj
1157
1158 def MakeSewing(ListShape, theTolerance):
1159     """
1160      *  Sewing of some shapes into single shape.
1161
1162      *  Example: see GEOM_TestHealing.py
1163     """
1164     comp = MakeCompound(ListShape)
1165     anObj = Sew(comp, theTolerance)
1166     return anObj
1167
1168 def Sew(theObject, theTolerance):
1169     """
1170      *  Sewing of the given object.
1171      *  \param theObject Shape to be processed.
1172      *  \param theTolerance Required tolerance value.
1173      *  \return New GEOM_Object, containing processed shape.
1174
1175      *  Example: see MakeSewing() above
1176     """
1177     anObj = HealOp.Sew(theObject, theTolerance)
1178     if HealOp.IsDone() == 0:
1179       print "Sew : ", HealOp.GetErrorCode()
1180     return anObj
1181
1182 def SuppressInternalWires(theObject, theWires):
1183     """
1184      *  Remove internal wires and edges from the given object (face).
1185      *  \param theObject Shape to be processed.
1186      *  \param theWires Indices of wires to be removed, if EMPTY then the method
1187      *                  removes ALL internal wires of the given object.
1188      *  \return New GEOM_Object, containing processed shape.
1189
1190      *  Example: see GEOM_TestHealing.py
1191     """
1192     anObj = HealOp.RemoveIntWires(theObject, theWires)
1193     if HealOp.IsDone() == 0:
1194       print "SuppressInternalWires : ", HealOp.GetErrorCode()
1195     return anObj
1196
1197 def SuppressHoles(theObject, theWires):
1198     """
1199      *  Remove internal closed contours (holes) from the given object.
1200      *  \param theObject Shape to be processed.
1201      *  \param theWires Indices of wires to be removed, if EMPTY then the method
1202      *                  removes ALL internal holes of the given object
1203      *  \return New GEOM_Object, containing processed shape.
1204
1205      *  Example: see GEOM_TestHealing.py
1206     """
1207     anObj = HealOp.FillHoles(theObject, theWires)
1208     if HealOp.IsDone() == 0:
1209       print "SuppressHoles : ", HealOp.GetErrorCode()
1210     return anObj
1211
1212 def CloseContour(theObject, theWires, isCommonVertex):
1213     """
1214      *  Close an open wire.
1215      *  \param theObject Shape to be processed.
1216      *  \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1217      *                  if -1, then theObject itself is a wire.
1218      *  \param isCommonVertex If TRUE : closure by creation of a common vertex,
1219      *                        If FALS : closure by creation of an edge between ends.
1220      *  \return New GEOM_Object, containing processed shape.
1221
1222      *  Example: see GEOM_TestHealing.py
1223     """
1224     anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1225     if HealOp.IsDone() == 0:
1226       print "CloseContour : ", HealOp.GetErrorCode()
1227     return anObj
1228
1229 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1230     """
1231      *  Addition of a point to a given edge object.
1232      *  \param theObject Shape to be processed.
1233      *  \param theEdgeIndex Index of edge to be divided within theObject's shape,
1234      *                      if -1, then theObject itself is the edge.
1235      *  \param theValue Value of parameter on edge or length parameter,
1236      *                  depending on \a isByParameter.
1237      *  \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1238      *                       if FALSE : \a theValue is treated as a length parameter [0..1]
1239      *  \return New GEOM_Object, containing processed shape.
1240
1241      *  Example: see GEOM_TestHealing.py
1242     """
1243     anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1244     if HealOp.IsDone() == 0:
1245       print "DivideEdge : ", HealOp.GetErrorCode()
1246     return anObj
1247
1248 def GetFreeBoundary(theObject):
1249     """
1250      *  Get a list of wires (wrapped in GEOM_Object-s),
1251      *  that constitute a free boundary of the given shape.
1252      *  \param theObject Shape to get free boundary of.
1253      *  \return [status, theClosedWires, theOpenWires]
1254      *  status: FALSE, if an error(s) occured during the method execution.
1255      *  theClosedWires: Closed wires on the free boundary of the given shape.
1256      *  theOpenWires: Open wires on the free boundary of the given shape.
1257
1258      *  Example: see GEOM_TestHealing.py
1259     """
1260     anObj = HealOp.GetFreeBoundary(theObject)
1261     if HealOp.IsDone() == 0:
1262       print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1263     return anObj
1264
1265 # -----------------------------------------------------------------------------
1266 # Create advanced objects
1267 # -----------------------------------------------------------------------------
1268
1269 def MakeCopy(theOriginal):
1270     """
1271      *  Create a copy of the given object
1272
1273      *  Example: see GEOM_TestAll.py
1274     """
1275     anObj = InsertOp.MakeCopy(theOriginal)
1276     if InsertOp.IsDone() == 0:
1277       print "MakeCopy : ", InsertOp.GetErrorCode()
1278     return anObj
1279
1280 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1281     """
1282      *  Create a filling from the given compound of contours.
1283      *  \param theShape the compound of contours
1284      *  \param theMinDeg a minimal degree
1285      *  \param theMaxDeg a maximal degree
1286      *  \param theTol2D a 2d tolerance
1287      *  \param theTol3D a 3d tolerance
1288      *  \param theNbIter a number of iteration
1289      *  \return New GEOM_Object, containing the created filling surface.
1290
1291      *  Example: see GEOM_TestAll.py
1292     """
1293     anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1294     if PrimOp.IsDone() == 0:
1295       print "MakeFilling : ", PrimOp.GetErrorCode()
1296     return anObj
1297
1298 def MakeGlueFaces(theShape, theTolerance):
1299     """
1300      *  Replace coincident faces in theShape by one face.
1301      *  \param theShape Initial shape.
1302      *  \param theTolerance Maximum distance between faces, which can be considered as coincident.
1303      *  \return New GEOM_Object, containing a copy of theShape without coincident faces.
1304
1305      *  Example: see GEOM_Spanner.py
1306     """
1307     anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1308     if ShapesOp.IsDone() == 0:
1309       print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1310     return anObj
1311
1312 # -----------------------------------------------------------------------------
1313 # Boolean (Common, Cut, Fuse, Section)
1314 # -----------------------------------------------------------------------------
1315
1316 def MakeBoolean(theShape1, theShape2, theOperation):
1317     """
1318      *  Perform one of boolean operations on two given shapes.
1319      *  \param theShape1 First argument for boolean operation.
1320      *  \param theShape2 Second argument for boolean operation.
1321      *  \param theOperation Indicates the operation to be done:
1322      *                      1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1323      *  \return New GEOM_Object, containing the result shape.
1324
1325      *  Example: see GEOM_TestAll.py
1326     """
1327     anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1328     if BoolOp.IsDone() == 0:
1329       print "MakeBoolean : ", BoolOp.GetErrorCode()
1330     return anObj
1331
1332 def MakeCommon(s1, s2):
1333     """
1334      *  Shortcut to MakeBoolean(s1, s2, 1)
1335
1336      *  Example: see GEOM_TestOthers.py
1337     """
1338     return MakeBoolean(s1, s2, 1)
1339
1340 def MakeCut(s1, s2):
1341     """
1342      *  Shortcut to MakeBoolean(s1, s2, 2)
1343
1344      *  Example: see GEOM_TestOthers.py
1345     """
1346     return MakeBoolean(s1, s2, 2)
1347
1348 def MakeFuse(s1, s2):
1349     """
1350      *  Shortcut to MakeBoolean(s1, s2, 3)
1351
1352      *  Example: see GEOM_TestOthers.py
1353     """
1354     return MakeBoolean(s1, s2, 3)
1355
1356 def MakeSection(s1, s2):
1357     """
1358      *  Shortcut to MakeBoolean(s1, s2, 4)
1359
1360      *  Example: see GEOM_TestOthers.py
1361     """
1362     return MakeBoolean(s1, s2, 4)
1363
1364 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1365                   Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1366     """
1367      *  Perform partition operation.
1368      *  \param ListShapes Shapes to be intersected.
1369      *  \param ListTools Shapes to intersect theShapes.
1370      *  \param ListKeepInside Shapes, outside which the results will be deleted.
1371      *         Each shape from theKeepInside must belong to theShapes also.
1372      *  \param ListRemoveInside Shapes, inside which the results will be deleted.
1373      *         Each shape from theRemoveInside must belong to theShapes also.
1374      *  \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1375      *  \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1376      *  \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1377      *  \return New GEOM_Object, containing the result shapes.
1378
1379      *  Example: see GEOM_TestAll.py
1380     """
1381     anObj = BoolOp.MakePartition(ListShapes, ListTools,
1382                                  ListKeepInside, ListRemoveInside,
1383                                  Limit, RemoveWebs, ListMaterials);
1384     if BoolOp.IsDone() == 0:
1385       print "MakePartition : ", BoolOp.GetErrorCode()
1386     return anObj
1387
1388 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1389               Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1390     """
1391      *  Shortcut to MakePartition()
1392
1393      *  Example: see GEOM_TestOthers.py
1394     """
1395     anObj = MakePartition(ListShapes, ListTools,
1396                           ListKeepInside, ListRemoveInside,
1397                           Limit, RemoveWebs, ListMaterials);
1398     return anObj
1399
1400 def MakeHalfPartition(theShape, thePlane):
1401     """
1402      *  Perform partition of the Shape with the Plane
1403      *  \param theShape Shape to be intersected.
1404      *  \param thePlane Tool shape, to intersect theShape.
1405      *  \return New GEOM_Object, containing the result shape.
1406
1407      *  Example: see GEOM_TestAll.py
1408     """
1409     anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1410     if BoolOp.IsDone() == 0:
1411       print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1412     return anObj
1413
1414 # -----------------------------------------------------------------------------
1415 # Transform objects
1416 # -----------------------------------------------------------------------------
1417
1418 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1419     """
1420      *  Translate the given object along the vector, specified
1421      *  by its end points, creating its copy before the translation.
1422      *  \param theObject The object to be translated.
1423      *  \param thePoint1 Start point of translation vector.
1424      *  \param thePoint2 End point of translation vector.
1425      *  \return New GEOM_Object, containing the translated object.
1426
1427      *  Example: see GEOM_TestAll.py
1428     """
1429     anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1430     if TrsfOp.IsDone() == 0:
1431       print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1432     return anObj
1433
1434 def MakeTranslation(theObject, theDX, theDY, theDZ):
1435     """
1436      *  Translate the given object along the vector, specified
1437      *  by its components, creating its copy before the translation.
1438      *  \param theObject The object to be translated.
1439      *  \param theDX,theDY,theDZ Components of translation vector.
1440      *  \return New GEOM_Object, containing the translated object.
1441
1442      *  Example: see GEOM_TestAll.py
1443     """
1444     anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1445     if TrsfOp.IsDone() == 0:
1446       print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1447     return anObj
1448
1449 def MakeTranslationVector(theObject, theVector):
1450     """
1451      *  Translate the given object along the given vector,
1452      *  creating its copy before the translation.
1453      *  \param theObject The object to be translated.
1454      *  \param theVector The translation vector.
1455      *  \return New GEOM_Object, containing the translated object.
1456
1457      *  Example: see GEOM_TestAll.py
1458     """
1459     anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1460     if TrsfOp.IsDone() == 0:
1461       print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1462     return anObj
1463
1464 def MakeRotation(theObject, theAxis, theAngle):
1465     """
1466      *  Rotate the given object around the given axis
1467      *  on the given angle, creating its copy before the rotatation.
1468      *  \param theObject The object to be rotated.
1469      *  \param theAxis Rotation axis.
1470      *  \param theAngle Rotation angle in radians.
1471      *  \return New GEOM_Object, containing the rotated object.
1472
1473      *  Example: see GEOM_TestAll.py
1474     """
1475     anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1476     if TrsfOp.IsDone() == 0:
1477       print "RotateCopy : ", TrsfOp.GetErrorCode()
1478     return anObj
1479
1480 def MakeScaleTransform(theObject, thePoint, theFactor):
1481     """
1482      *  Scale the given object by the factor, creating its copy before the scaling.
1483      *  \param theObject The object to be scaled.
1484      *  \param thePoint Center point for scaling.
1485      *  \param theFactor Scaling factor value.
1486      *  \return New GEOM_Object, containing the scaled shape.
1487
1488      *  Example: see GEOM_TestAll.py
1489     """
1490     anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1491     if TrsfOp.IsDone() == 0:
1492       print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1493     return anObj
1494
1495 def MakeMirrorByPlane(theObject, thePlane):
1496     """
1497      *  Create an object, symmetrical
1498      *  to the given one relatively the given plane.
1499      *  \param theObject The object to be mirrored.
1500      *  \param thePlane Plane of symmetry.
1501      *  \return New GEOM_Object, containing the mirrored shape.
1502
1503      *  Example: see GEOM_TestAll.py
1504     """
1505     anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1506     if TrsfOp.IsDone() == 0:
1507       print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1508     return anObj
1509
1510 def MakeMirrorByAxis(theObject, theAxis):
1511     """
1512      *  Create an object, symmetrical
1513      *  to the given one relatively the given axis.
1514      *  \param theObject The object to be mirrored.
1515      *  \param theAxis Axis of symmetry.
1516      *  \return New GEOM_Object, containing the mirrored shape.
1517
1518      *  Example: see GEOM_TestAll.py
1519     """
1520     anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1521     if TrsfOp.IsDone() == 0:
1522       print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1523     return anObj
1524
1525 def MakeMirrorByPoint(theObject, thePoint):
1526     """
1527      *  Create an object, symmetrical
1528      *  to the given one relatively the given point.
1529      *  \param theObject The object to be mirrored.
1530      *  \param thePoint Point of symmetry.
1531      *  \return New GEOM_Object, containing the mirrored shape.
1532
1533      *  Example: see GEOM_TestAll.py
1534     """
1535     anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1536     if TrsfOp.IsDone() == 0:
1537       print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1538     return anObj
1539
1540 def MakePosition(theObject, theStartLCS, theEndLCS):
1541     """
1542      *  Modify the Location of the given object by LCS
1543      *  creating its copy before the setting
1544
1545      *  Example: see GEOM_TestAll.py
1546     """
1547     anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1548     if TrsfOp.IsDone() == 0:
1549       print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1550     return anObj
1551
1552 def MakeOffset(theObject, theOffset):
1553     """
1554      *  Create new object as offset of the given one.
1555      *  \param theObject The base object for the offset.
1556      *  \param theOffset Offset value.
1557      *  \return New GEOM_Object, containing the offset object.
1558
1559      *  Example: see GEOM_TestAll.py
1560     """
1561     anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1562     if TrsfOp.IsDone() == 0:
1563       print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1564     return anObj
1565
1566 # -----------------------------------------------------------------------------
1567 # Patterns
1568 # -----------------------------------------------------------------------------
1569
1570 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1571     """
1572      *  Translate the given object along the given vector a given number times
1573      *  \param theObject The object to be translated.
1574      *  \param theVector Direction of the translation.
1575      *  \param theStep Distance to translate on.
1576      *  \param theNbTimes Quantity of translations to be done.
1577      *  \return New GEOM_Object, containing compound of all
1578      *          the shapes, obtained after each translation.
1579
1580      *  Example: see GEOM_TestAll.py
1581     """
1582     anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1583     if TrsfOp.IsDone() == 0:
1584       print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1585     return anObj
1586
1587 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1588                                       theVector2, theStep2, theNbTimes2):
1589     """
1590      *  Conseqently apply two specified translations to theObject specified number of times.
1591      *  \param theObject The object to be translated.
1592      *  \param theVector1 Direction of the first translation.
1593      *  \param theStep1 Step of the first translation.
1594      *  \param theNbTimes1 Quantity of translations to be done along theVector1.
1595      *  \param theVector2 Direction of the second translation.
1596      *  \param theStep2 Step of the second translation.
1597      *  \param theNbTimes2 Quantity of translations to be done along theVector2.
1598      *  \return New GEOM_Object, containing compound of all
1599      *          the shapes, obtained after each translation.
1600
1601      *  Example: see GEOM_TestAll.py
1602     """
1603     anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1604                                                theVector2, theStep2, theNbTimes2)
1605     if TrsfOp.IsDone() == 0:
1606       print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1607     return anObj
1608
1609 def MultiRotate1D(theObject, theAxis, theNbTimes):
1610     """
1611      *  Rotate the given object around the given axis a given number times.
1612      *  Rotation angle will be 2*PI/theNbTimes.
1613      *  \param theObject The object to be rotated.
1614      *  \param theAxis The rotation axis.
1615      *  \param theNbTimes Quantity of rotations to be done.
1616      *  \return New GEOM_Object, containing compound of all the
1617      *          shapes, obtained after each rotation.
1618
1619      *  Example: see GEOM_TestAll.py
1620     """
1621     anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1622     if TrsfOp.IsDone() == 0:
1623       print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1624     return anObj
1625
1626 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1627     """
1628      *  Rotate the given object around the
1629      *  given axis on the given angle a given number
1630      *  times and multi-translate each rotation result.
1631      *  Translation direction passes through center of gravity
1632      *  of rotated shape and its projection on the rotation axis.
1633      *  \param theObject The object to be rotated.
1634      *  \param theAxis Rotation axis.
1635      *  \param theAngle Rotation angle in graduces.
1636      *  \param theNbTimes1 Quantity of rotations to be done.
1637      *  \param theStep Translation distance.
1638      *  \param theNbTimes2 Quantity of translations to be done.
1639      *  \return New GEOM_Object, containing compound of all the
1640      *          shapes, obtained after each transformation.
1641
1642      *  Example: see GEOM_TestAll.py
1643     """
1644     anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1645     if TrsfOp.IsDone() == 0:
1646       print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1647     return anObj
1648
1649 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1650     """
1651      *  The same, as MultiRotate1D(), but axis is given by direction and point
1652
1653      *  Example: see GEOM_TestOthers.py
1654     """
1655     aVec = MakeLine(aPoint,aDir)
1656     anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1657     return anObj
1658
1659 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1660     """
1661      *  The same, as MultiRotate2D(), but axis is given by direction and point
1662
1663      *  Example: see GEOM_TestOthers.py
1664     """
1665     aVec = MakeLine(aPoint,aDir)
1666     anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1667     return anObj
1668
1669 # -----------------------------------------------------------------------------
1670 # Local operations
1671 # -----------------------------------------------------------------------------
1672
1673 def MakeFilletAll(theShape, theR):
1674     """
1675      *  Perform a fillet on all edges of the given shape.
1676      *  \param theShape Shape, to perform fillet on.
1677      *  \param theR Fillet radius.
1678      *  \return New GEOM_Object, containing the result shape.
1679
1680      *  Example: see GEOM_TestOthers.py
1681     """
1682     anObj = LocalOp.MakeFilletAll(theShape, theR)
1683     if LocalOp.IsDone() == 0:
1684       print "MakeFilletAll : ", LocalOp.GetErrorCode()
1685     return anObj
1686
1687 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1688     """
1689      *  Perform a fillet on the specified edges/faces of the given shape
1690      *  \param theShape Shape, to perform fillet on.
1691      *  \param theR Fillet radius.
1692      *  \param theShapeType Type of shapes in <theListShapes>.
1693      *  \param theListShapes Global indices of edges/faces to perform fillet on.
1694      *    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1695      *  \return New GEOM_Object, containing the result shape.
1696
1697      *  Example: see GEOM_TestAll.py
1698     """
1699     anObj = None
1700     if theShapeType == ShapeType["EDGE"]:
1701         anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1702     else:
1703         anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1704     if LocalOp.IsDone() == 0:
1705       print "MakeFillet : ", LocalOp.GetErrorCode()
1706     return anObj
1707
1708 def MakeChamferAll(theShape, theD):
1709     """
1710      *  Perform a symmetric chamfer on all edges of the given shape.
1711      *  \param theShape Shape, to perform chamfer on.
1712      *  \param theD Chamfer size along each face.
1713      *  \return New GEOM_Object, containing the result shape.
1714
1715      *  Example: see GEOM_TestOthers.py
1716     """
1717     anObj = LocalOp.MakeChamferAll(theShape, theD)
1718     if LocalOp.IsDone() == 0:
1719       print "MakeChamferAll : ", LocalOp.GetErrorCode()
1720     return anObj
1721
1722 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1723     """
1724      *  Perform a chamfer on edges, common to the specified faces,
1725      *  with distance D1 on the Face1
1726      *  \param theShape Shape, to perform chamfer on.
1727      *  \param theD1 Chamfer size along \a theFace1.
1728      *  \param theD2 Chamfer size along \a theFace2.
1729      *  \param theFace1,theFace2 Global indices of two faces of \a theShape.
1730      *    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1731      *  \return New GEOM_Object, containing the result shape.
1732
1733      *  Example: see GEOM_TestAll.py
1734     """
1735     anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1736     if LocalOp.IsDone() == 0:
1737       print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1738     return anObj
1739
1740 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1741     """
1742      *  Perform a chamfer on all edges of the specified faces,
1743      *  with distance D1 on the first specified face (if several for one edge)
1744      *  \param theShape Shape, to perform chamfer on.
1745      *  \param theD1 Chamfer size along face from \a theFaces. If both faces,
1746      *               connected to the edge, are in \a theFaces, \a theD1
1747      *               will be get along face, which is nearer to \a theFaces beginning.
1748      *  \param theD2 Chamfer size along another of two faces, connected to the edge.
1749      *  \param theFaces Sequence of global indices of faces of \a theShape.
1750      *    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1751      *  \return New GEOM_Object, containing the result shape.
1752
1753      *  Example: see GEOM_TestAll.py
1754     """
1755     anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1756     if LocalOp.IsDone() == 0:
1757       print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1758     return anObj
1759
1760 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1761     """
1762      *  Shortcut to MakeChamferEdge() and MakeChamferFaces()
1763
1764      *  Example: see GEOM_TestOthers.py
1765     """
1766     anObj = None
1767     if aShapeType == ShapeType["EDGE"]:
1768         anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1769     else:
1770         anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1771     return anObj
1772
1773 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1774     """
1775      *  Perform an Archimde operation on the given shape with given parameters.
1776      *                    The object presenting the resulting face is returned
1777      *  \param theShape Shape to be put in water.
1778      *  \param theWeight Weight og the shape.
1779      *  \param theWaterDensity Density of the water.
1780      *  \param theMeshDeflection Deflection of the mesh, using to compute the section.
1781      *  \return New GEOM_Object, containing a section of \a theShape
1782      *          by a plane, corresponding to water level.
1783
1784      *  Example: see GEOM_TestAll.py
1785     """
1786     anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1787     if LocalOp.IsDone() == 0:
1788       print "MakeArchimede : ", LocalOp.GetErrorCode()
1789     return anObj
1790
1791 # -----------------------------------------------------------------------------
1792 # Information objects
1793 # -----------------------------------------------------------------------------
1794
1795 def PointCoordinates(Point):
1796     """
1797      *  Get point coordinates
1798      *  \return [x, y, z]
1799
1800      *  Example: see GEOM_TestMeasures.py
1801     """
1802     aTuple = MeasuOp.PointCoordinates(Point)
1803     if MeasuOp.IsDone() == 0:
1804       print "PointCoordinates : ", MeasuOp.GetErrorCode()
1805     return aTuple
1806
1807 def BasicProperties(theShape):
1808     """
1809      *  Get summarized length of all wires,
1810      *  area of surface and volume of the given shape.
1811      *  \param theShape Shape to define properties of.
1812      *  \return [theLength, theSurfArea, theVolume]
1813      *  theLength:   Summarized length of all wires of the given shape.
1814      *  theSurfArea: Area of surface of the given shape.
1815      *  theVolume:   Volume of the given shape.
1816
1817      *  Example: see GEOM_TestMeasures.py
1818     """
1819     aTuple = MeasuOp.GetBasicProperties(theShape)
1820     if MeasuOp.IsDone() == 0:
1821       print "BasicProperties : ", MeasuOp.GetErrorCode()
1822     return aTuple
1823
1824 def BoundingBox(theShape):
1825     """
1826      *  Get parameters of bounding box of the given shape
1827      *  \param theShape Shape to obtain bounding box of.
1828      *  \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1829      *  Xmin,Xmax: Limits of shape along OX axis.
1830      *  Ymin,Ymax: Limits of shape along OY axis.
1831      *  Zmin,Zmax: Limits of shape along OZ axis.
1832
1833      *  Example: see GEOM_TestMeasures.py
1834     """
1835     aTuple = MeasuOp.GetBoundingBox(theShape)
1836     if MeasuOp.IsDone() == 0:
1837       print "BoundingBox : ", MeasuOp.GetErrorCode()
1838     return aTuple
1839
1840 def Inertia(theShape):
1841     """
1842      *  Get inertia matrix and moments of inertia of theShape.
1843      *  \param theShape Shape to calculate inertia of.
1844      *  \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1845      *  I(1-3)(1-3): Components of the inertia matrix of the given shape.
1846      *  Ix,Iy,Iz:    Moments of inertia of the given shape.
1847
1848      *  Example: see GEOM_TestMeasures.py
1849     """
1850     aTuple = MeasuOp.GetInertia(theShape)
1851     if MeasuOp.IsDone() == 0:
1852       print "Inertia : ", MeasuOp.GetErrorCode()
1853     return aTuple
1854
1855 def MinDistance(theShape1, theShape2):
1856     """
1857      *  Get minimal distance between the given shapes.
1858      *  \param theShape1,theShape2 Shapes to find minimal distance between.
1859      *  \return Value of the minimal distance between the given shapes.
1860
1861      *  Example: see GEOM_TestMeasures.py
1862     """
1863     aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1864     if MeasuOp.IsDone() == 0:
1865       print "MinDistance : ", MeasuOp.GetErrorCode()
1866     return aTuple[0]
1867
1868 def Tolerance(theShape):
1869     """
1870      *  Get min and max tolerances of sub-shapes of theShape
1871      *  \param theShape Shape, to get tolerances of.
1872      *  \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1873      *  FaceMin,FaceMax: Min and max tolerances of the faces.
1874      *  EdgeMin,EdgeMax: Min and max tolerances of the edges.
1875      *  VertMin,VertMax: Min and max tolerances of the vertices.
1876
1877      *  Example: see GEOM_TestMeasures.py
1878     """
1879     aTuple = MeasuOp.GetTolerance(theShape)
1880     if MeasuOp.IsDone() == 0:
1881       print "Tolerance : ", MeasuOp.GetErrorCode()
1882     return aTuple
1883
1884 def WhatIs(theShape):
1885     """
1886      *  Obtain description of the given shape (number of sub-shapes of each type)
1887      *  \param theShape Shape to be described.
1888      *  \return Description of the given shape.
1889
1890      *  Example: see GEOM_TestMeasures.py
1891     """
1892     aDescr = MeasuOp.WhatIs(theShape)
1893     if MeasuOp.IsDone() == 0:
1894       print "WhatIs : ", MeasuOp.GetErrorCode()
1895     return aDescr
1896
1897 def MakeCDG(theShape):
1898     """
1899      *  Get a point, situated at the centre of mass of theShape.
1900      *  \param theShape Shape to define centre of mass of.
1901      *  \return New GEOM_Object, containing the created point.
1902
1903      *  Example: see GEOM_TestMeasures.py
1904     """
1905     anObj = MeasuOp.GetCentreOfMass(theShape)
1906     if MeasuOp.IsDone() == 0:
1907       print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1908     return anObj
1909
1910 def CheckShape(theShape):
1911     """
1912      *  Check a topology of the given shape.
1913      *  \param theShape Shape to check validity of.
1914      *  \return TRUE, if the shape "seems to be valid" from the topological point of view.
1915      *  If theShape is invalid, prints a description of problem.
1916
1917      *  Example: see GEOM_TestMeasures.py
1918     """
1919     (IsValid, Status) = MeasuOp.CheckShape(theShape)
1920     if MeasuOp.IsDone() == 0:
1921       print "CheckShape : ", MeasuOp.GetErrorCode()
1922     else:
1923       if IsValid == 0:
1924         print Status
1925     return IsValid
1926
1927 # -----------------------------------------------------------------------------
1928 # Import/Export objects
1929 # -----------------------------------------------------------------------------
1930
1931 def Import(theFileName, theFormatName):
1932     """
1933      *  Import a shape from the BREP or IGES or STEP file
1934      *  (depends on given format) with given name.
1935      *  \param theFileName The file, containing the shape.
1936      *  \param theFormatName Specify format for the file reading.
1937      *         Available formats can be obtained with InsertOp.ImportTranslators() method.
1938      *  \return New GEOM_Object, containing the imported shape.
1939
1940      *  Example: see GEOM_TestOthers.py
1941     """
1942     anObj = InsertOp.Import(theFileName, theFormatName)
1943     if InsertOp.IsDone() == 0:
1944       print "Import : ", InsertOp.GetErrorCode()
1945     return anObj
1946
1947 def ImportBREP(theFileName):
1948     """
1949      *  Shortcut to Import() for BREP format
1950
1951      *  Example: see GEOM_TestOthers.py
1952     """
1953     return Import(theFileName, "BREP")
1954
1955 def ImportIGES(theFileName):
1956     """
1957      *  Shortcut to Import() for IGES format
1958
1959      *  Example: see GEOM_TestOthers.py
1960     """
1961     return Import(theFileName, "IGES")
1962
1963 def ImportSTEP(theFileName):
1964     """
1965      *  Shortcut to Import() for STEP format
1966
1967      *  Example: see GEOM_TestOthers.py
1968     """
1969     return Import(theFileName, "STEP")
1970
1971 def Export(theObject, theFileName, theFormatName):
1972     """
1973      *  Export the given shape into a file with given name.
1974      *  \param theObject Shape to be stored in the file.
1975      *  \param theFileName Name of the file to store the given shape in.
1976      *  \param theFormatName Specify format for the shape storage.
1977      *         Available formats can be obtained with InsertOp.ImportTranslators() method.
1978
1979      *  Example: see GEOM_TestOthers.py
1980     """
1981     InsertOp.Export(theObject, theFileName, theFormatName)
1982     if InsertOp.IsDone() == 0:
1983       print "Export : ", InsertOp.GetErrorCode()
1984
1985 def ExportBREP(theObject, theFileName):
1986     """
1987      *  Shortcut to Export() for BREP format
1988
1989      *  Example: see GEOM_TestOthers.py
1990     """
1991     return Export(theObject, theFileName, "BREP")
1992
1993 def ExportIGES(theObject, theFileName):
1994     """
1995      *  Shortcut to Export() for IGES format
1996
1997      *  Example: see GEOM_TestOthers.py
1998     """
1999     return Export(theObject, theFileName, "IGES")
2000
2001 def ExportSTEP(theObject, theFileName):
2002     """
2003      *  Shortcut to Export() for STEP format
2004
2005      *  Example: see GEOM_TestOthers.py
2006     """
2007     return Export(theObject, theFileName, "STEP")
2008
2009 # -----------------------------------------------------------------------------
2010 # Block operations
2011 # -----------------------------------------------------------------------------
2012
2013 def MakeQuad(E1, E2, E3, E4):
2014     """
2015      *  Create a quadrangle face from four edges. Order of Edges is not
2016      *  important. It is  not necessary that edges share the same vertex.
2017      *  \param E1,E2,E3,E4 Edges for the face bound.
2018      *  \return New GEOM_Object, containing the created face.
2019
2020      *  Example: see GEOM_Spanner.py
2021     """
2022     anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2023     if BlocksOp.IsDone() == 0:
2024       print "MakeQuad : ", BlocksOp.GetErrorCode()
2025     return anObj
2026
2027 def MakeQuad2Edges(E1, E2):
2028     """
2029      *  Create a quadrangle face on two edges.
2030      *  The missing edges will be built by creating the shortest ones.
2031      *  \param E1,E2 Two opposite edges for the face.
2032      *  \return New GEOM_Object, containing the created face.
2033
2034      *  Example: see GEOM_Spanner.py
2035     """
2036     anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2037     if BlocksOp.IsDone() == 0:
2038       print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2039     return anObj
2040
2041 def MakeQuad4Vertices(V1, V2, V3, V4):
2042     """
2043      *  Create a quadrangle face with specified corners.
2044      *  The missing edges will be built by creating the shortest ones.
2045      *  \param V1,V2,V3,V4 Corner vertices for the face.
2046      *  \return New GEOM_Object, containing the created face.
2047
2048      *  Example: see GEOM_Spanner.py
2049     """
2050     anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2051     if BlocksOp.IsDone() == 0:
2052       print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2053     return anObj
2054
2055 def MakeHexa(F1, F2, F3, F4, F5, F6):
2056     """
2057      *  Create a hexahedral solid, bounded by the six given faces. Order of
2058      *  faces is not important. It is  not necessary that Faces share the same edge.
2059      *  \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2060      *  \return New GEOM_Object, containing the created solid.
2061
2062      *  Example: see GEOM_Spanner.py
2063     """
2064     anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2065     if BlocksOp.IsDone() == 0:
2066       print "MakeHexa : ", BlocksOp.GetErrorCode()
2067     return anObj
2068
2069 def MakeHexa2Faces(F1, F2):
2070     """
2071      *  Create a hexahedral solid between two given faces.
2072      *  The missing faces will be built by creating the smallest ones.
2073      *  \param F1,F2 Two opposite faces for the hexahedral solid.
2074      *  \return New GEOM_Object, containing the created solid.
2075
2076      *  Example: see GEOM_Spanner.py
2077     """
2078     anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2079     if BlocksOp.IsDone() == 0:
2080       print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2081     return anObj
2082
2083 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2084     """
2085      *  Get a vertex, found in the given shape by its coordinates.
2086      *  \param theShape Block or a compound of blocks.
2087      *  \param theX,theY,theZ Coordinates of the sought vertex.
2088      *  \param theEpsilon Maximum allowed distance between the resulting
2089      *                    vertex and point with the given coordinates.
2090      *  \return New GEOM_Object, containing the found vertex.
2091
2092      *  Example: see GEOM_TestOthers.py
2093     """
2094     anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2095     if BlocksOp.IsDone() == 0:
2096       print "GetPoint : ", BlocksOp.GetErrorCode()
2097     return anObj
2098
2099 def GetEdge(theShape, thePoint1, thePoint2):
2100     """
2101      *  Get an edge, found in the given shape by two given vertices.
2102      *  \param theShape Block or a compound of blocks.
2103      *  \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2104      *  \return New GEOM_Object, containing the found edge.
2105
2106      *  Example: see GEOM_Spanner.py
2107     """
2108     anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2109     if BlocksOp.IsDone() == 0:
2110       print "GetEdge : ", BlocksOp.GetErrorCode()
2111     return anObj
2112
2113 def GetEdgeNearPoint(theShape, thePoint):
2114     """
2115      *  Find an edge of the given shape, which has minimal distance to the given point.
2116      *  \param theShape Block or a compound of blocks.
2117      *  \param thePoint Point, close to the desired edge.
2118      *  \return New GEOM_Object, containing the found edge.
2119
2120      *  Example: see GEOM_TestOthers.py
2121     """
2122     anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2123     if BlocksOp.IsDone() == 0:
2124       print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2125     return anObj
2126
2127 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2128     """
2129      *  Returns a face, found in the given shape by four given corner vertices.
2130      *  \param theShape Block or a compound of blocks.
2131      *  \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2132      *  \return New GEOM_Object, containing the found face.
2133
2134      *  Example: see GEOM_Spanner.py
2135     """
2136     anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2137     if BlocksOp.IsDone() == 0:
2138       print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2139     return anObj
2140
2141 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2142     """
2143      *  Get a face of block, found in the given shape by two given edges.
2144      *  \param theShape Block or a compound of blocks.
2145      *  \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2146      *  \return New GEOM_Object, containing the found face.
2147
2148      *  Example: see GEOM_Spanner.py
2149     """
2150     anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2151     if BlocksOp.IsDone() == 0:
2152       print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2153     return anObj
2154
2155 def GetOppositeFace(theBlock, theFace):
2156     """
2157      *  Find a face, opposite to the given one in the given block.
2158      *  \param theBlock Must be a hexahedral solid.
2159      *  \param theFace Face of \a theBlock, opposite to the desired face.
2160      *  \return New GEOM_Object, containing the found face.
2161
2162      *  Example: see GEOM_Spanner.py
2163     """
2164     anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2165     if BlocksOp.IsDone() == 0:
2166       print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2167     return anObj
2168
2169 def GetFaceNearPoint(theShape, thePoint):
2170     """
2171      *  Find a face of the given shape, which has minimal distance to the given point.
2172      *  \param theShape Block or a compound of blocks.
2173      *  \param thePoint Point, close to the desired face.
2174      *  \return New GEOM_Object, containing the found face.
2175
2176      *  Example: see GEOM_Spanner.py
2177     """
2178     anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2179     if BlocksOp.IsDone() == 0:
2180       print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2181     return anObj
2182
2183 def GetFaceByNormale(theBlock, theVector):
2184     """
2185      *  Find a face of block, whose outside normale has minimal angle with the given vector.
2186      *  \param theShape Block or a compound of blocks.
2187      *  \param theVector Vector, close to the normale of the desired face.
2188      *  \return New GEOM_Object, containing the found face.
2189
2190      *  Example: see GEOM_Spanner.py
2191     """
2192     anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2193     if BlocksOp.IsDone() == 0:
2194       print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2195     return anObj
2196
2197 def CheckCompoundOfBlocks(theCompound):
2198     """
2199      *  Check, if the compound of blocks is given.
2200      *  To be considered as a compound of blocks, the
2201      *  given shape must satisfy the following conditions:
2202      *  - Each element of the compound should be a Block (6 faces and 12 edges).
2203      *  - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2204      *  - The compound should be connexe.
2205      *  - The glue between two quadrangle faces should be applied.
2206      *  \param theCompound The compound to check.
2207      *  \return TRUE, if the given shape is a compound of blocks.
2208      *  If theCompound is not valid, prints all discovered errors.
2209
2210      *  Example: see GEOM_Spanner.py
2211     """
2212     (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2213     if BlocksOp.IsDone() == 0:
2214       print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2215     else:
2216       if IsValid == 0:
2217         Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2218         print Descr
2219     return IsValid
2220
2221 def RemoveExtraEdges(theShape):
2222     """
2223      *  Remove all seam and degenerated edges from \a theShape.
2224      *  Unite faces and edges, sharing one surface.
2225      *  \param theShape The compound or single solid to remove irregular edges from.
2226      *  \return Improved shape.
2227
2228      *  Example: see GEOM_TestOthers.py
2229     """
2230     anObj = BlocksOp.RemoveExtraEdges(theShape)
2231     if BlocksOp.IsDone() == 0:
2232       print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2233     return anObj
2234
2235 def CheckAndImprove(theShape):
2236     """
2237      *  Check, if the given shape is a blocks compound.
2238      *  Fix all detected errors.
2239      *    \note Single block can be also fixed by this method.
2240      *  \param theCompound The compound to check and improve.
2241      *  \return Improved compound.
2242
2243      *  Example: see GEOM_TestOthers.py
2244     """
2245     anObj = BlocksOp.CheckAndImprove(theShape)
2246     if BlocksOp.IsDone() == 0:
2247       print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2248     return anObj
2249
2250 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2251     """
2252      *  Get all the blocks, contained in the given compound.
2253      *  \param theCompound The compound to explode.
2254      *  \param theMinNbFaces If solid has lower number of faces, it is not a block.
2255      *  \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2256      *    \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2257      *  \return List of GEOM_Objects, containing the retrieved blocks.
2258
2259      *  Example: see GEOM_TestOthers.py
2260     """
2261     aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2262     if BlocksOp.IsDone() == 0:
2263       print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2264     return aList
2265
2266 def GetBlockNearPoint(theCompound, thePoint):
2267     """
2268      *  Find block, containing the given point inside its volume or on boundary.
2269      *  \param theCompound Compound, to find block in.
2270      *  \param thePoint Point, close to the desired block. If the point lays on
2271      *         boundary between some blocks, we return block with nearest center.
2272      *  \return New GEOM_Object, containing the found block.
2273
2274      *  Example: see GEOM_Spanner.py
2275     """
2276     anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2277     if BlocksOp.IsDone() == 0:
2278       print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2279     return anObj
2280
2281 def GetBlockByParts(theCompound, theParts):
2282     """
2283      *  Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2284      *  \param theCompound Compound, to find block in.
2285      *  \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2286      *  \return New GEOM_Object, containing the found block.
2287
2288      *  Example: see GEOM_TestOthers.py
2289     """
2290     anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2291     if BlocksOp.IsDone() == 0:
2292       print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2293     return anObj
2294
2295 def GetBlocksByParts(theCompound, theParts):
2296     """
2297      *  Return all blocks, containing all the elements, passed as the parts.
2298      *  \param theCompound Compound, to find blocks in.
2299      *  \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2300      *  \return List of GEOM_Objects, containing the found blocks.
2301
2302      *  Example: see GEOM_Spanner.py
2303     """
2304     aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2305     if BlocksOp.IsDone() == 0:
2306       print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2307     return aList
2308
2309 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2310     """
2311      *  Multi-transformate block and glue the result.
2312      *  Transformation is defined so, as to superpose direction faces.
2313      *  \param Block Hexahedral solid to be multi-transformed.
2314      *  \param DirFace1 ID of First direction face.
2315      *  \param DirFace2 ID of Second direction face.
2316      *  \param NbTimes Quantity of transformations to be done.
2317      *    \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2318      *  \return New GEOM_Object, containing the result shape.
2319
2320      *  Example: see GEOM_Spanner.py
2321     """
2322     anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2323     if BlocksOp.IsDone() == 0:
2324       print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2325     return anObj
2326
2327 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2328                                      DirFace1V, DirFace2V, NbTimesV):
2329     """
2330      *  Multi-transformate block and glue the result.
2331      *  \param Block Hexahedral solid to be multi-transformed.
2332      *  \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2333      *  \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2334      *  \param NbTimesU,NbTimesV Quantity of transformations to be done.
2335      *  \return New GEOM_Object, containing the result shape.
2336
2337      *  Example: see GEOM_Spanner.py
2338     """
2339     anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2340                                                       DirFace1V, DirFace2V, NbTimesV)
2341     if BlocksOp.IsDone() == 0:
2342       print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2343     return anObj
2344
2345 def Propagate(theShape):
2346     """
2347      *  Build all possible propagation groups.
2348      *  Propagation group is a set of all edges, opposite to one (main)
2349      *  edge of this group directly or through other opposite edges.
2350      *  Notion of Opposite Edge make sence only on quadrangle face.
2351      *  \param theShape Shape to build propagation groups on.
2352      *  \return List of GEOM_Objects, each of them is a propagation group.
2353
2354      *  Example: see GEOM_TestOthers.py
2355     """
2356     listChains = BlocksOp.Propagate(theShape)
2357     if BlocksOp.IsDone() == 0:
2358       print "Propagate : ", BlocksOp.GetErrorCode()
2359     return listChains
2360
2361 # -----------------------------------------------------------------------------
2362 # Group operations
2363 # -----------------------------------------------------------------------------
2364
2365 def CreateGroup(theMainShape, theShapeType):
2366     """
2367      *  Creates a new group which will store sub shapes of theMainShape
2368      *  \param theMainShape is a GEOM object on which the group is selected
2369      *  \param theShapeType defines a shape type of the group
2370      *  \return a newly created GEOM group
2371
2372      *  Example: see GEOM_TestOthers.py
2373     """
2374     anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2375     if GroupOp.IsDone() == 0:
2376        print "CreateGroup : ", GroupOp.GetErrorCode()
2377     return anObj
2378
2379 def AddObject(theGroup, theSubShapeID):
2380     """
2381      *  Adds a sub object with ID theSubShapeId to the group
2382      *  \param theGroup is a GEOM group to which the new sub shape is added
2383      *  \param theSubShapeID is a sub shape ID in the main object.
2384      *  \note Use method GetSubShapeID() to get an unique ID of the sub shape
2385
2386      *  Example: see GEOM_TestOthers.py
2387     """
2388     GroupOp.AddObject(theGroup, theSubShapeID)
2389     if GroupOp.IsDone() == 0:
2390       print "AddObject : ", GroupOp.GetErrorCode()
2391
2392 def RemoveObject(theGroup, theSubShapeID):
2393     """
2394      *  Removes a sub object with ID \a theSubShapeId from the group
2395      *  \param theGroup is a GEOM group from which the new sub shape is removed
2396      *  \param theSubShapeID is a sub shape ID in the main object.
2397      *  \note Use method GetSubShapeID() to get an unique ID of the sub shape
2398
2399      *  Example: see GEOM_TestOthers.py
2400     """
2401     GroupOp.RemoveObject(theGroup, theSubShapeID)
2402     if GroupOp.IsDone() == 0:
2403       print "RemoveObject : ", GroupOp.GetErrorCode()
2404
2405 def UnionList (theGroup, theSubShapes):
2406     """
2407      *  Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2408      *  \param theGroup is a GEOM group to which the new sub shapes are added.
2409      *  \param theSubShapes is a list of sub shapes to be added.
2410
2411      *  Example: see GEOM_TestOthers.py
2412     """
2413     GroupOp.UnionList(theGroup, theSubShapes)
2414     if GroupOp.IsDone() == 0:
2415       print "UnionList : ", GroupOp.GetErrorCode()
2416
2417 def DifferenceList (theGroup, theSubShapes):
2418     """
2419      *  Removes from the group all the given shapes. No errors, if some shapes are not included.
2420      *  \param theGroup is a GEOM group from which the sub-shapes are removed.
2421      *  \param theSubShapes is a list of sub-shapes to be removed.
2422
2423      *  Example: see GEOM_TestOthers.py
2424     """
2425     GroupOp.DifferenceList(theGroup, theSubShapes)
2426     if GroupOp.IsDone() == 0:
2427       print "DifferenceList : ", GroupOp.GetErrorCode()
2428
2429 def GetObjectIDs(theGroup):
2430     """
2431      *  Returns a list of sub objects ID stored in the group
2432      *  \param theGroup is a GEOM group for which a list of IDs is requested
2433
2434      *  Example: see GEOM_TestOthers.py
2435     """
2436     ListIDs = GroupOp.GetObjects(theGroup)
2437     if GroupOp.IsDone() == 0:
2438       print "GetObjectIDs : ", GroupOp.GetErrorCode()
2439     return ListIDs
2440
2441 def GetType(theGroup):
2442     """
2443      *  Returns a type of sub objects stored in the group
2444      *  \param theGroup is a GEOM group which type is returned.
2445
2446      *  Example: see GEOM_TestOthers.py
2447     """
2448     aType = GroupOp.GetType(theGroup)
2449     if GroupOp.IsDone() == 0:
2450       print "GetType : ", GroupOp.GetErrorCode()
2451     return aType
2452
2453 def GetMainShape(theGroup):
2454     """
2455      *  Returns a main shape associated with the group
2456      *  \param theGroup is a GEOM group for which a main shape object is requested
2457      *  \return a GEOM object which is a main shape for theGroup
2458
2459      *  Example: see GEOM_TestOthers.py
2460     """
2461     anObj = GroupOp.GetMainShape(theGroup)
2462     if GroupOp.IsDone() == 0:
2463       print "GetMainShape : ", GroupOp.GetErrorCode()
2464     return anObj
2465
2466 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2467     """
2468     Create group of edges of theShape, whose length is in range [min_length, max_length].
2469     If include_min/max == 0, edges with length == min/max_length will not be included in result.
2470     """
2471
2472     edges = SubShapeAll(theShape, ShapeType["EDGE"])
2473     edges_in_range = []
2474     for edge in edges:
2475         Props = BasicProperties(edge)
2476         if min_length <= Props[0] and Props[0] <= max_length:
2477             if (not include_min) and (min_length == Props[0]):
2478                 skip = 1
2479             else:
2480                 if (not include_max) and (Props[0] == max_length):
2481                     skip = 1
2482                 else:
2483                     edges_in_range.append(edge)
2484
2485     if len(edges_in_range) <= 0:
2486         print "No edges found by given criteria"
2487         return 0
2488
2489     group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2490     UnionList(group_edges, edges_in_range)
2491
2492     return group_edges
2493
2494 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2495     """
2496     Create group of edges of selected shape, whose length is in range [min_length, max_length].
2497     If include_min/max == 0, edges with length == min/max_length will not be included in result.
2498     """
2499
2500     nb_selected = sg.SelectedCount()
2501     if nb_selected < 1:
2502         print "Select a shape before calling this function, please."
2503         return 0
2504     if nb_selected > 1:
2505         print "Only one shape must be selected"
2506         return 0
2507
2508     id_shape = sg.getSelected(0)
2509     shape = IDToObject( id_shape )
2510
2511     group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2512
2513     left_str  = " < "
2514     right_str = " < "
2515     if include_min: left_str  = " <= "
2516     if include_max: right_str  = " <= "
2517
2518     addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2519                        + left_str + "length" + right_str + `max_length`)
2520
2521     sg.updateObjBrowser(1)
2522
2523     return group_edges
2524
2525 def addPath(Path):
2526     """
2527      * Add Path to load python scripts from
2528     """
2529     if (sys.path.count(Path) < 1):
2530         sys.path.append(Path)