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