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