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