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