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