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