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