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