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