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