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