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