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