]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_SWIG/geompy.py
Salome HOME
Join modifications for CCRT by Jean Rahuel.src/GEOM_SWIG/Makefile.in
[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.
751 #  @param thePath - Path shape to extrude the base shape along it.
752 #  @param theWithContact - the mode defining that the section is translated to be in
753 #                          contact with the spine.
754 #  @param - WithCorrection - defining that the section is rotated to be
755 #                            orthogonal to the spine tangent in the correspondent point
756 #  @return New GEOM_Object, containing the created solids.
757 #
758 #  Example: see GEOM_TestAll.py
759 def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
760                               theLocations, thePath,
761                               theWithContact, theWithCorrection):
762     anObj = PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
763                                              theLocations, thePath,
764                                              theWithContact, theWithCorrection)
765     if PrimOp.IsDone() == 0:
766       print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
767     return anObj
768
769 # -----------------------------------------------------------------------------
770 # Create base shapes
771 # -----------------------------------------------------------------------------
772
773 ## Create a linear edge with specified ends.
774 #  @param thePnt1 Point for the first end of edge.
775 #  @param thePnt2 Point for the second end of edge.
776 #  @return New GEOM_Object, containing the created edge.
777 #
778 #  Example: see GEOM_TestAll.py
779 def MakeEdge(thePnt1, thePnt2):
780     anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
781     if ShapesOp.IsDone() == 0:
782       print "MakeEdge : ", ShapesOp.GetErrorCode()
783     return anObj
784
785 ## Create a wire from the set of edges and wires.
786 #  @param theEdgesAndWires List of edges and/or wires.
787 #  @return New GEOM_Object, containing the created wire.
788 #
789 #  Example: see GEOM_TestAll.py
790 def MakeWire(theEdgesAndWires):
791     anObj = ShapesOp.MakeWire(theEdgesAndWires)
792     if ShapesOp.IsDone() == 0:
793       print "MakeWire : ", ShapesOp.GetErrorCode()
794     return anObj
795
796 ## Create a face on the given wire.
797 #  @param theWire closed Wire or Edge to build the face on.
798 #  @param isPlanarWanted If TRUE, only planar face will be built.
799 #                        If impossible, NULL object will be returned.
800 #  @return New GEOM_Object, containing the created face.
801 #
802 #  Example: see GEOM_TestAll.py
803 def MakeFace(theWire, isPlanarWanted):
804     anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
805     if ShapesOp.IsDone() == 0:
806       print "MakeFace : ", ShapesOp.GetErrorCode()
807     return anObj
808
809 ## Create a face on the given wires set.
810 #  @param theWires List of closed wires or edges to build the face on.
811 #  @param isPlanarWanted If TRUE, only planar face will be built.
812 #                        If impossible, NULL object will be returned.
813 #  @return New GEOM_Object, containing the created face.
814 #
815 #  Example: see GEOM_TestAll.py
816 def MakeFaceWires(theWires, isPlanarWanted):
817     anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
818     if ShapesOp.IsDone() == 0:
819       print "MakeFaceWires : ", ShapesOp.GetErrorCode()
820     return anObj
821
822 ## Shortcut to MakeFaceWires()
823 #
824 #  Example: see GEOM_TestOthers.py
825 def MakeFaces(theWires, isPlanarWanted):
826     anObj = MakeFaceWires(theWires, isPlanarWanted)
827     return anObj
828
829 ## Create a shell from the set of faces and shells.
830 #  @param theFacesAndShells List of faces and/or shells.
831 #  @return New GEOM_Object, containing the created shell.
832 #
833 #  Example: see GEOM_TestAll.py
834 def MakeShell(theFacesAndShells):
835     anObj = ShapesOp.MakeShell(theFacesAndShells)
836     if ShapesOp.IsDone() == 0:
837         print "MakeShell : ", ShapesOp.GetErrorCode()
838     return anObj
839
840 ## Create a solid, bounded by the given shells.
841 #  @param theShells Sequence of bounding shells.
842 #  @return New GEOM_Object, containing the created solid.
843 #
844 #  Example: see GEOM_TestAll.py
845 def MakeSolid(theShells):
846     anObj = ShapesOp.MakeSolidShells(theShells)
847     if ShapesOp.IsDone() == 0:
848         print "MakeSolid : ", ShapesOp.GetErrorCode()
849     return anObj
850
851 ## Create a compound of the given shapes.
852 #  @param theShapes List of shapes to put in compound.
853 #  @return New GEOM_Object, containing the created compound.
854 #
855 #  Example: see GEOM_TestAll.py
856 def MakeCompound(theShapes):
857     anObj = ShapesOp.MakeCompound(theShapes)
858     if ShapesOp.IsDone() == 0:
859       print "MakeCompound : ", ShapesOp.GetErrorCode()
860     return anObj
861
862 ## Gives quantity of faces in the given shape.
863 #  @param theShape Shape to count faces of.
864 #  @return Quantity of faces.
865 #
866 #  Example: see GEOM_TestOthers.py
867 def NumberOfFaces(theShape):
868     nb_faces = ShapesOp.NumberOfFaces(theShape)
869     if ShapesOp.IsDone() == 0:
870       print "NumberOfFaces : ", ShapesOp.GetErrorCode()
871     return nb_faces
872
873 ## Gives quantity of edges in the given shape.
874 #  @param theShape Shape to count edges of.
875 #  @return Quantity of edges.
876 #
877 #  Example: see GEOM_TestOthers.py
878 def NumberOfEdges(theShape):
879     nb_edges = ShapesOp.NumberOfEdges(theShape)
880     if ShapesOp.IsDone() == 0:
881       print "NumberOfEdges : ", ShapesOp.GetErrorCode()
882     return nb_edges
883
884 ## Reverses an orientation the given shape.
885 #  @param theShape Shape to be reversed.
886 #  @return The reversed copy of theShape.
887 #
888 #  Example: see GEOM_TestAll.py
889 def ChangeOrientation(theShape):
890     anObj = ShapesOp.ChangeOrientation(theShape)
891     if ShapesOp.IsDone() == 0:
892       print "ChangeOrientation : ", ShapesOp.GetErrorCode()
893     return anObj
894
895 ## Shortcut to ChangeOrientation()
896 #
897 #  Example: see GEOM_TestOthers.py
898 def OrientationChange(theShape):
899     anObj = ChangeOrientation(theShape)
900     return anObj
901
902 ## Retrieve all free faces from the given shape.
903 #  Free face is a face, which is not shared between two shells of the shape.
904 #  @param theShape Shape to find free faces in.
905 #  @return List of IDs of all free faces, contained in theShape.
906 #
907 #  Example: see GEOM_TestOthers.py
908 def GetFreeFacesIDs(theShape):
909     anIDs = ShapesOp.GetFreeFacesIDs(theShape)
910     if ShapesOp.IsDone() == 0:
911       print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
912     return anIDs
913
914 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
915 #  @param theShape1 Shape to find sub-shapes in.
916 #  @param theShape2 Shape to find shared sub-shapes with.
917 #  @param theShapeType Type of sub-shapes to be retrieved.
918 #  @return List of sub-shapes of theShape1, shared with theShape2.
919 #
920 #  Example: see GEOM_TestOthers.py
921 def GetSharedShapes(theShape1, theShape2, theShapeType):
922     aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
923     if ShapesOp.IsDone() == 0:
924       print "GetSharedShapes : ", ShapesOp.GetErrorCode()
925     return aList
926
927 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
928 #  the specified plane by the certain way, defined through \a theState parameter.
929 #  @param theShape Shape to find sub-shapes of.
930 #  @param theShapeType Type of sub-shapes to be retrieved.
931 #  @param theAx1 Vector (or line, or linear edge), specifying normal
932 #                direction and location of the plane to find shapes on.
933 #  @param theState The state of the subshapes to find. It can be one of
934 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
935 #  @return List of all found sub-shapes.
936 #
937 #  Example: see GEOM_TestOthers.py
938 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
939     aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
940     if ShapesOp.IsDone() == 0:
941       print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
942     return aList
943
944 ## Works like the above method, but returns list of sub-shapes indices
945 #
946 #  Example: see GEOM_TestOthers.py
947 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
948     aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
949     if ShapesOp.IsDone() == 0:
950         print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
951     return aList
952
953 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
954 #  the specified plane by the certain way, defined through \a theState parameter.
955 #  @param theShape Shape to find sub-shapes of.
956 #  @param theShapeType Type of sub-shapes to be retrieved.
957 #  @param theAx1 Vector (or line, or linear edge), specifying normal
958 #                direction of the plane to find shapes on.
959 #  @param thePnt Point specifying location of the plane to find shapes on.
960 #  @param theState The state of the subshapes to find. It can be one of
961 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
962 #  @return List of all found sub-shapes.
963 #
964 #  Example: see GEOM_TestOthers.py
965 def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
966     aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
967     if ShapesOp.IsDone() == 0:
968       print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
969     return aList
970
971 ## Works like the above method, but returns list of sub-shapes indices
972 #
973 #  Example: see GEOM_TestOthers.py
974 def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
975     aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
976     if ShapesOp.IsDone() == 0:
977         print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
978     return aList
979
980 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
981 #  the specified cylinder by the certain way, defined through \a theState parameter.
982 #  @param theShape Shape to find sub-shapes of.
983 #  @param theShapeType Type of sub-shapes to be retrieved.
984 #  @param theAxis Vector (or line, or linear edge), specifying
985 #                 axis of the cylinder to find shapes on.
986 #  @param theRadius Radius of the cylinder to find shapes on.
987 #  @param theState The state of the subshapes to find. It can be one of
988 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
989 #  @return List of all found sub-shapes.
990 #
991 #  Example: see GEOM_TestOthers.py
992 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
993     aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
994     if ShapesOp.IsDone() == 0:
995       print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
996     return aList
997
998 ## Works like the above method, but returns list of sub-shapes indices
999 #
1000 #  Example: see GEOM_TestOthers.py
1001 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
1002     aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
1003     if ShapesOp.IsDone() == 0:
1004         print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
1005     return aList
1006
1007 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1008 #  the specified sphere by the certain way, defined through \a theState parameter.
1009 #  @param theShape Shape to find sub-shapes of.
1010 #  @param theShapeType Type of sub-shapes to be retrieved.
1011 #  @param theCenter Point, specifying center of the sphere to find shapes on.
1012 #  @param theRadius Radius of the sphere to find shapes on.
1013 #  @param theState The state of the subshapes to find. It can be one of
1014 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1015 #  @return List of all found sub-shapes.
1016 #
1017 #  Example: see GEOM_TestOthers.py
1018 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
1019     aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1020     if ShapesOp.IsDone() == 0:
1021       print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1022     return aList
1023
1024 ## Works like the above method, but returns list of sub-shapes indices
1025 #
1026 #  Example: see GEOM_TestOthers.py
1027 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1028     aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1029     if ShapesOp.IsDone() == 0:
1030         print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1031     return aList
1032
1033 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1034 #  the specified quadrangle by the certain way, defined through \a theState parameter.
1035 #  @param theShape Shape to find sub-shapes of.
1036 #  @param theShapeType Type of sub-shapes to be retrieved.
1037 #  @param theTopLeftPoint Point, specifying top left corner of a quadrangle
1038 #  @param theTopRigthPoint Point, specifying top right corner of a quadrangle
1039 #  @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
1040 #  @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
1041 #  @param theState The state of the subshapes to find. It can be one of
1042 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1043 #  @return List of all found sub-shapes.
1044 #
1045 #  Example: see GEOM_TestOthers.py
1046 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1047     aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1048     if ShapesOp.IsDone() == 0:
1049       print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1050     return aList
1051
1052 ## Works like the above method, but returns list of sub-shapes indices
1053 #
1054 #  Example: see GEOM_TestOthers.py
1055 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1056     aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1057     if ShapesOp.IsDone() == 0:
1058         print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1059     return aList
1060
1061 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1062 #  the specified \a theBox by the certain way, defined through \a theState parameter.
1063 #  @param theBox Shape for relative comparing.
1064 #  @param theShape Shape to find sub-shapes of.
1065 #  @param theShapeType Type of sub-shapes to be retrieved.
1066 #  @param theState The state of the subshapes to find. It can be one of
1067 #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1068 #  @return List of all found sub-shapes.
1069 #
1070 def GetShapesOnBox(theBox, theShape, theShapeType, theState):
1071     aList = ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
1072     if ShapesOp.IsDone() == 0:
1073       print "GetShapesOnBox : ", ShapesOp.GetErrorCode()
1074     return aList
1075
1076 ## Works like the above method, but returns list of sub-shapes indices
1077 #
1078 def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
1079     aList = ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
1080     if ShapesOp.IsDone() == 0:
1081         print "GetShapesOnBoxIDs : ", ShapesOp.GetErrorCode()
1082     return aList
1083
1084 ## Get sub-shape(s) of theShapeWhere, which are
1085 #  coincident with \a theShapeWhat or could be a part of it.
1086 #  @param theShapeWhere Shape to find sub-shapes of.
1087 #  @param theShapeWhat Shape, specifying what to find.
1088 #  @return Group of all found sub-shapes or a single found sub-shape.
1089 #
1090 #  Example: see GEOM_TestOthers.py
1091 def GetInPlace(theShapeWhere, theShapeWhat):
1092     anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1093     if ShapesOp.IsDone() == 0:
1094       print "GetInPlace : ", ShapesOp.GetErrorCode()
1095     return anObj
1096
1097 ## Get sub-shape of theShapeWhere, which is
1098 #  equal to \a theShapeWhat.
1099 #  @param theShapeWhere Shape to find sub-shape of.
1100 #  @param theShapeWhat Shape, specifying what to find.
1101 #  @return New GEOM_Object for found sub-shape.
1102 #
1103 def GetSame(theShapeWhere, theShapeWhat):
1104     anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1105     if ShapesOp.IsDone() == 0:
1106       print "GetSame : ", ShapesOp.GetErrorCode()
1107     return anObj
1108
1109 # -----------------------------------------------------------------------------
1110 # Access to sub-shapes by their unique IDs inside the main shape.
1111 # -----------------------------------------------------------------------------
1112
1113 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1114 #  of <aShape>, selected by their unique IDs inside <aShape>
1115 #
1116 #  Example: see GEOM_TestAll.py
1117 def GetSubShape(aShape, ListOfID):
1118     anObj = geom.AddSubShape(aShape,ListOfID)
1119     return anObj
1120
1121 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1122 #
1123 #  Example: see GEOM_TestAll.py
1124 def GetSubShapeID(aShape, aSubShape):
1125     anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1126     if LocalOp.IsDone() == 0:
1127       print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1128     return anID
1129
1130 # -----------------------------------------------------------------------------
1131 # Decompose objects
1132 # -----------------------------------------------------------------------------
1133
1134 ## Explode a shape on subshapes of a given type.
1135 #  @param theShape Shape to be exploded.
1136 #  @param theShapeType Type of sub-shapes to be retrieved.
1137 #  @return List of sub-shapes of type theShapeType, contained in theShape.
1138 #
1139 #  Example: see GEOM_TestAll.py
1140 def SubShapeAll(aShape, aType):
1141     ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1142     if ShapesOp.IsDone() == 0:
1143       print "MakeExplode : ", ShapesOp.GetErrorCode()
1144     return ListObj
1145
1146 ## Explode a shape on subshapes of a given type.
1147 #  @param theShape Shape to be exploded.
1148 #  @param theShapeType Type of sub-shapes to be retrieved.
1149 #  @return List of IDs of sub-shapes.
1150 def SubShapeAllIDs(aShape, aType):
1151     ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1152     if ShapesOp.IsDone() == 0:
1153       print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1154     return ListObj
1155
1156 ## Explode a shape on subshapes of a given type.
1157 #  Sub-shapes will be sorted by coordinates of their gravity centers.
1158 #  @param theShape Shape to be exploded.
1159 #  @param theShapeType Type of sub-shapes to be retrieved.
1160 #  @return List of sub-shapes of type theShapeType, contained in theShape.
1161 #
1162 #  Example: see GEOM_TestAll.py
1163 def SubShapeAllSorted(aShape, aType):
1164     ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1165     if ShapesOp.IsDone() == 0:
1166       print "MakeExplode : ", ShapesOp.GetErrorCode()
1167     return ListObj
1168
1169 ## Explode a shape on subshapes of a given type.
1170 #  Sub-shapes will be sorted by coordinates of their gravity centers.
1171 #  @param theShape Shape to be exploded.
1172 #  @param theShapeType Type of sub-shapes to be retrieved.
1173 #  @return List of IDs of sub-shapes.
1174 def SubShapeAllSortedIDs(aShape, aType):
1175     ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1176     if ShapesOp.IsDone() == 0:
1177       print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1178     return ListIDs
1179
1180 ## Obtain a compound of sub-shapes of <aShape>,
1181 #  selected by they indices in list of all sub-shapes of type <aType>.
1182 #  Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1183 #
1184 #  Example: see GEOM_TestAll.py
1185 def SubShape(aShape, aType, ListOfInd):
1186     ListOfIDs = []
1187     AllShapeList = SubShapeAll(aShape, aType)
1188     for ind in ListOfInd:
1189         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1190     anObj = GetSubShape(aShape, ListOfIDs)
1191     return anObj
1192
1193 ## Obtain a compound of sub-shapes of <aShape>,
1194 #  selected by they indices in sorted list of all sub-shapes of type <aType>.
1195 #  Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1196 #
1197 #  Example: see GEOM_TestAll.py
1198 def SubShapeSorted(aShape, aType, ListOfInd):
1199     ListOfIDs = []
1200     AllShapeList = SubShapeAllSorted(aShape, aType)
1201     for ind in ListOfInd:
1202         ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1203     anObj = GetSubShape(aShape, ListOfIDs)
1204     return anObj
1205
1206 # -----------------------------------------------------------------------------
1207 # Healing operations
1208 # -----------------------------------------------------------------------------
1209
1210 ## Apply a sequence of Shape Healing operators to the given object.
1211 #  @param theShape Shape to be processed.
1212 #  @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1213 #  @param theParameters List of names of parameters
1214 #                    ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1215 #  @param theValues List of values of parameters, in the same order
1216 #                    as parameters are listed in \a theParameters list.
1217 #  @return New GEOM_Object, containing processed shape.
1218 #
1219 #  Example: see GEOM_TestHealing.py
1220 def ProcessShape(theShape, theOperators, theParameters, theValues):
1221     anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1222     if HealOp.IsDone() == 0:
1223         print "ProcessShape : ", HealOp.GetErrorCode()
1224     return anObj
1225
1226 ## Remove faces from the given object (shape).
1227 #  @param theObject Shape to be processed.
1228 #  @param theFaces Indices of faces to be removed, if EMPTY then the method
1229 #                  removes ALL faces of the given object.
1230 #  @return New GEOM_Object, containing processed shape.
1231 #
1232 #  Example: see GEOM_TestHealing.py
1233 def SuppressFaces(theObject, theFaces):
1234     anObj = HealOp.SuppressFaces(theObject, theFaces)
1235     if HealOp.IsDone() == 0:
1236       print "SuppressFaces : ", HealOp.GetErrorCode()
1237     return anObj
1238
1239 ## Sewing of some shapes into single shape.
1240 #
1241 #  Example: see GEOM_TestHealing.py
1242 def MakeSewing(ListShape, theTolerance):
1243     comp = MakeCompound(ListShape)
1244     anObj = Sew(comp, theTolerance)
1245     return anObj
1246
1247 ## Sewing of the given object.
1248 #  @param theObject Shape to be processed.
1249 #  @param theTolerance Required tolerance value.
1250 #  @return New GEOM_Object, containing processed shape.
1251 #
1252 #  Example: see MakeSewing() above
1253 def Sew(theObject, theTolerance):
1254     anObj = HealOp.Sew(theObject, theTolerance)
1255     if HealOp.IsDone() == 0:
1256       print "Sew : ", HealOp.GetErrorCode()
1257     return anObj
1258
1259 ## Remove internal wires and edges from the given object (face).
1260 #  @param theObject Shape to be processed.
1261 #  @param theWires Indices of wires to be removed, if EMPTY then the method
1262 #                  removes ALL internal wires of the given object.
1263 #  @return New GEOM_Object, containing processed shape.
1264 #
1265 #  Example: see GEOM_TestHealing.py
1266 def SuppressInternalWires(theObject, theWires):
1267     anObj = HealOp.RemoveIntWires(theObject, theWires)
1268     if HealOp.IsDone() == 0:
1269       print "SuppressInternalWires : ", HealOp.GetErrorCode()
1270     return anObj
1271
1272 ## Remove internal closed contours (holes) from the given object.
1273 #  @param theObject Shape to be processed.
1274 #  @param theWires Indices of wires to be removed, if EMPTY then the method
1275 #                  removes ALL internal holes of the given object
1276 #  @return New GEOM_Object, containing processed shape.
1277 #
1278 #  Example: see GEOM_TestHealing.py
1279 def SuppressHoles(theObject, theWires):
1280     anObj = HealOp.FillHoles(theObject, theWires)
1281     if HealOp.IsDone() == 0:
1282       print "SuppressHoles : ", HealOp.GetErrorCode()
1283     return anObj
1284
1285 ## Close an open wire.
1286 #  @param theObject Shape to be processed.
1287 #  @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1288 #                  if -1, then theObject itself is a wire.
1289 #  @param isCommonVertex If TRUE : closure by creation of a common vertex,
1290 #                        If FALS : closure by creation of an edge between ends.
1291 #  @return New GEOM_Object, containing processed shape.
1292 #
1293 #  Example: see GEOM_TestHealing.py
1294 def CloseContour(theObject, theWires, isCommonVertex):
1295     anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1296     if HealOp.IsDone() == 0:
1297       print "CloseContour : ", HealOp.GetErrorCode()
1298     return anObj
1299
1300 ## Addition of a point to a given edge object.
1301 #  @param theObject Shape to be processed.
1302 #  @param theEdgeIndex Index of edge to be divided within theObject's shape,
1303 #                      if -1, then theObject itself is the edge.
1304 #  @param theValue Value of parameter on edge or length parameter,
1305 #                  depending on \a isByParameter.
1306 #  @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1307 #                       if FALSE : \a theValue is treated as a length parameter [0..1]
1308 #  @return New GEOM_Object, containing processed shape.
1309 #
1310 #  Example: see GEOM_TestHealing.py
1311 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1312     anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1313     if HealOp.IsDone() == 0:
1314       print "DivideEdge : ", HealOp.GetErrorCode()
1315     return anObj
1316
1317 ## Change orientation of the given object.
1318 #  @param theObject Shape to be processed.
1319 #  @update given shape
1320 def ChangeOrientationShell(theObject):
1321     theObject = HealOp.ChangeOrientation(theObject)
1322     if HealOp.IsDone() == 0:
1323       print "ChangeOrientation : ", HealOp.GetErrorCode()
1324
1325 ## Change orientation of the given object.
1326 #  @param theObject Shape to be processed.
1327 #  @return New GEOM_Object, containing processed shape.
1328 def ChangeOrientationShellCopy(theObject):
1329     anObj = HealOp.ChangeOrientationCopy(theObject)
1330     if HealOp.IsDone() == 0:
1331       print "ChangeOrientation : ", HealOp.GetErrorCode()
1332     return anObj
1333
1334 ## Get a list of wires (wrapped in GEOM_Object-s),
1335 #  that constitute a free boundary of the given shape.
1336 #  @param theObject Shape to get free boundary of.
1337 #  @return [status, theClosedWires, theOpenWires]
1338 #  status: FALSE, if an error(s) occured during the method execution.
1339 #  theClosedWires: Closed wires on the free boundary of the given shape.
1340 #  theOpenWires: Open wires on the free boundary of the given shape.
1341 #
1342 #  Example: see GEOM_TestHealing.py
1343 def GetFreeBoundary(theObject):
1344     anObj = HealOp.GetFreeBoundary(theObject)
1345     if HealOp.IsDone() == 0:
1346       print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1347     return anObj
1348
1349 # -----------------------------------------------------------------------------
1350 # Create advanced objects
1351 # -----------------------------------------------------------------------------
1352
1353 ## Create a copy of the given object
1354 #
1355 #  Example: see GEOM_TestAll.py
1356 def MakeCopy(theOriginal):
1357     anObj = InsertOp.MakeCopy(theOriginal)
1358     if InsertOp.IsDone() == 0:
1359       print "MakeCopy : ", InsertOp.GetErrorCode()
1360     return anObj
1361
1362 ## Create a filling from the given compound of contours.
1363 #  @param theShape the compound of contours
1364 #  @param theMinDeg a minimal degree
1365 #  @param theMaxDeg a maximal degree
1366 #  @param theTol2D a 2d tolerance
1367 #  @param theTol3D a 3d tolerance
1368 #  @param theNbIter a number of iteration
1369 #  @return New GEOM_Object, containing the created filling surface.
1370 #
1371 #  Example: see GEOM_TestAll.py
1372 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1373     anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1374     if PrimOp.IsDone() == 0:
1375       print "MakeFilling : ", PrimOp.GetErrorCode()
1376     return anObj
1377
1378 ## Replace coincident faces in theShape by one face.
1379 #  @param theShape Initial shape.
1380 #  @param theTolerance Maximum distance between faces, which can be considered as coincident.
1381 #  @return New GEOM_Object, containing a copy of theShape without coincident faces.
1382 #
1383 #  Example: see GEOM_Spanner.py
1384 def MakeGlueFaces(theShape, theTolerance):
1385     anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1386     if ShapesOp.IsDone() == 0:
1387       print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1388     return anObj
1389
1390
1391 ## Find coincident faces in theShape for possible gluing.
1392 #  @param theShape Initial shape.
1393 #  @param theTolerance Maximum distance between faces,
1394 #                      which can be considered as coincident.
1395 #  @return ListOfGO.
1396 #
1397 #  Example: see GEOM_Spanner.py
1398 def GetGlueFaces(theShape, theTolerance):
1399     anObj = ShapesOp.GetGlueFaces(theShape, theTolerance)
1400     if ShapesOp.IsDone() == 0:
1401       print "GetGlueFaces : ", ShapesOp.GetErrorCode()
1402     return anObj
1403
1404
1405 ## Replace coincident faces in theShape by one face
1406 #  in compliance with given list of faces
1407 #  @param theShape Initial shape.
1408 #  @param theTolerance Maximum distance between faces,
1409 #                      which can be considered as coincident.
1410 #  @param theFaces List of faces for gluing.
1411 #  @return New GEOM_Object, containing a copy of theShape
1412 #          without some faces.
1413 #
1414 #  Example: see GEOM_Spanner.py
1415 def MakeGlueFacesByList(theShape, theTolerance, theFaces):
1416     anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces)
1417     if ShapesOp.IsDone() == 0:
1418       print "MakeGlueFacesByList : ", ShapesOp.GetErrorCode()
1419     return anObj
1420
1421
1422 # -----------------------------------------------------------------------------
1423 # Boolean (Common, Cut, Fuse, Section)
1424 # -----------------------------------------------------------------------------
1425
1426 ## Perform one of boolean operations on two given shapes.
1427 #  @param theShape1 First argument for boolean operation.
1428 #  @param theShape2 Second argument for boolean operation.
1429 #  @param theOperation Indicates the operation to be done:
1430 #                      1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1431 #  @return New GEOM_Object, containing the result shape.
1432 #
1433 #  Example: see GEOM_TestAll.py
1434 def MakeBoolean(theShape1, theShape2, theOperation):
1435     anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1436     if BoolOp.IsDone() == 0:
1437       print "MakeBoolean : ", BoolOp.GetErrorCode()
1438     return anObj
1439
1440 ## Shortcut to MakeBoolean(s1, s2, 1)
1441 #
1442 #  Example: see GEOM_TestOthers.py
1443 def MakeCommon(s1, s2):
1444     return MakeBoolean(s1, s2, 1)
1445
1446 ## Shortcut to MakeBoolean(s1, s2, 2)
1447 #
1448 #  Example: see GEOM_TestOthers.py
1449 def MakeCut(s1, s2):
1450     return MakeBoolean(s1, s2, 2)
1451
1452 ## Shortcut to MakeBoolean(s1, s2, 3)
1453 #
1454 #  Example: see GEOM_TestOthers.py
1455 def MakeFuse(s1, s2):
1456     return MakeBoolean(s1, s2, 3)
1457
1458 ## Shortcut to MakeBoolean(s1, s2, 4)
1459 #
1460 #  Example: see GEOM_TestOthers.py
1461 def MakeSection(s1, s2):
1462     return MakeBoolean(s1, s2, 4)
1463
1464 ## Perform partition operation.
1465 #  @param ListShapes Shapes to be intersected.
1466 #  @param ListTools Shapes to intersect theShapes.
1467 #  !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1468 #           in order to avoid possible intersection between shapes from
1469 #           this compound.
1470 #  @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1471 #  @param KeepNonlimitShapes: if this parameter == 0 - only shapes with
1472 #                             type <= Limit are kept in the result,
1473 #                             else - shapes with type > Limit are kept
1474 #                             also (if they exist)
1475 #
1476 #  After implementation new version of PartitionAlgo (October 2006)
1477 #  other parameters are ignored by current functionality. They are kept
1478 #  in this function only for support old versions.
1479 #  Ignored parameters:
1480 #      @param ListKeepInside Shapes, outside which the results will be deleted.
1481 #         Each shape from theKeepInside must belong to theShapes also.
1482 #      @param ListRemoveInside Shapes, inside which the results will be deleted.
1483 #         Each shape from theRemoveInside must belong to theShapes also.
1484 #      @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1485 #      @param ListMaterials Material indices for each shape. Make sence,
1486 #         only if theRemoveWebs is TRUE.
1487 #
1488 #  @return New GEOM_Object, containing the result shapes.
1489 #
1490 #  Example: see GEOM_TestAll.py
1491 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1492                   Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1493                   KeepNonlimitShapes=0):
1494     anObj = BoolOp.MakePartition(ListShapes, ListTools,
1495                                  ListKeepInside, ListRemoveInside,
1496                                  Limit, RemoveWebs, ListMaterials,
1497                                  KeepNonlimitShapes);
1498     if BoolOp.IsDone() == 0:
1499       print "MakePartition : ", BoolOp.GetErrorCode()
1500     return anObj
1501
1502 ## Perform partition operation.
1503 #  This method may be useful if it is needed to make a partition for
1504 #  compound contains nonintersected shapes. Performance will be better
1505 #  since intersection between shapes from compound is not performed.
1506 #
1507 #  Description of all parameters as in previous method MakePartition()
1508 #
1509 #  !!!NOTE: Passed compounds (via ListShapes or via ListTools)
1510 #           have to consist of nonintersecting shapes.
1511 #
1512 #  @return New GEOM_Object, containing the result shapes.
1513 #
1514 def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[],
1515                                          ListKeepInside=[], ListRemoveInside=[],
1516                                          Limit=ShapeType["SHAPE"], RemoveWebs=0,
1517                                          ListMaterials=[], KeepNonlimitShapes=0):
1518     anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
1519                                                         ListKeepInside, ListRemoveInside,
1520                                                         Limit, RemoveWebs, ListMaterials,
1521                                                         KeepNonlimitShapes);
1522     if BoolOp.IsDone() == 0:
1523       print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
1524     return anObj
1525
1526 ## Shortcut to MakePartition()
1527 #
1528 #  Example: see GEOM_TestOthers.py
1529 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1530               Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1531               KeepNonlimitShapes=0):
1532     anObj = MakePartition(ListShapes, ListTools,
1533                           ListKeepInside, ListRemoveInside,
1534                           Limit, RemoveWebs, ListMaterials,
1535                           KeepNonlimitShapes);
1536     return anObj
1537
1538 ## Perform partition of the Shape with the Plane
1539 #  @param theShape Shape to be intersected.
1540 #  @param thePlane Tool shape, to intersect theShape.
1541 #  @return New GEOM_Object, containing the result shape.
1542 #
1543 #  Example: see GEOM_TestAll.py
1544 def MakeHalfPartition(theShape, thePlane):
1545     anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1546     if BoolOp.IsDone() == 0:
1547       print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1548     return anObj
1549
1550 # -----------------------------------------------------------------------------
1551 # Transform objects
1552 # -----------------------------------------------------------------------------
1553
1554 ## Translate the given object along the vector, specified
1555 #  by its end points, creating its copy before the translation.
1556 #  @param theObject The object to be translated.
1557 #  @param thePoint1 Start point of translation vector.
1558 #  @param thePoint2 End point of translation vector.
1559 #  @return New GEOM_Object, containing the translated object.
1560 #
1561 #  Example: see GEOM_TestAll.py
1562 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1563     anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1564     if TrsfOp.IsDone() == 0:
1565       print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1566     return anObj
1567
1568 ## Translate the given object along the vector, specified
1569 #  by its components, creating its copy before the translation.
1570 #  @param theObject The object to be translated.
1571 #  @param theDX,theDY,theDZ Components of translation vector.
1572 #  @return New GEOM_Object, containing the translated object.
1573 #
1574 #  Example: see GEOM_TestAll.py
1575 def MakeTranslation(theObject, theDX, theDY, theDZ):
1576     anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1577     if TrsfOp.IsDone() == 0:
1578       print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1579     return anObj
1580
1581 ## Translate the given object along the given vector,
1582 #  creating its copy before the translation.
1583 #  @param theObject The object to be translated.
1584 #  @param theVector The translation vector.
1585 #  @return New GEOM_Object, containing the translated object.
1586 #
1587 #  Example: see GEOM_TestAll.py
1588 def MakeTranslationVector(theObject, theVector):
1589     anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1590     if TrsfOp.IsDone() == 0:
1591       print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1592     return anObj
1593
1594 ## Rotate the given object around the given axis
1595 #  on the given angle, creating its copy before the rotatation.
1596 #  @param theObject The object to be rotated.
1597 #  @param theAxis Rotation axis.
1598 #  @param theAngle Rotation angle in radians.
1599 #  @return New GEOM_Object, containing the rotated object.
1600 #
1601 #  Example: see GEOM_TestAll.py
1602 def MakeRotation(theObject, theAxis, theAngle):
1603     anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1604     if TrsfOp.IsDone() == 0:
1605       print "RotateCopy : ", TrsfOp.GetErrorCode()
1606     return anObj
1607
1608 ## Rotate given object around vector perpendicular to plane
1609 #  containing three points, creating its copy before the rotatation.
1610 #  @param theObject The object to be rotated.
1611 #  @param theCentPoint central point - the axis is the vector perpendicular to the plane
1612 #  containing the three points.
1613 #  @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1614 #  @return New GEOM_Object, containing the rotated object.
1615 #
1616 #  Example: see GEOM_TestAll.py
1617 def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
1618     anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1619     if TrsfOp.IsDone() == 0:
1620       print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
1621     return anObj
1622
1623 ## Scale the given object by the factor, creating its copy before the scaling.
1624 #  @param theObject The object to be scaled.
1625 #  @param thePoint Center point for scaling.
1626 #  @param theFactor Scaling factor value.
1627 #  @return New GEOM_Object, containing the scaled shape.
1628 #
1629 #  Example: see GEOM_TestAll.py
1630 def MakeScaleTransform(theObject, thePoint, theFactor):
1631     anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1632     if TrsfOp.IsDone() == 0:
1633       print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1634     return anObj
1635
1636 ## Create an object, symmetrical
1637 #  to the given one relatively the given plane.
1638 #  @param theObject The object to be mirrored.
1639 #  @param thePlane Plane of symmetry.
1640 #  @return New GEOM_Object, containing the mirrored shape.
1641 #
1642 #  Example: see GEOM_TestAll.py
1643 def MakeMirrorByPlane(theObject, thePlane):
1644     anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1645     if TrsfOp.IsDone() == 0:
1646       print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1647     return anObj
1648
1649 ## Create an object, symmetrical
1650 #  to the given one relatively the given axis.
1651 #  @param theObject The object to be mirrored.
1652 #  @param theAxis Axis of symmetry.
1653 #  @return New GEOM_Object, containing the mirrored shape.
1654 #
1655 #  Example: see GEOM_TestAll.py
1656 def MakeMirrorByAxis(theObject, theAxis):
1657     anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1658     if TrsfOp.IsDone() == 0:
1659       print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1660     return anObj
1661
1662 ## Create an object, symmetrical
1663 #  to the given one relatively the given point.
1664 #  @param theObject The object to be mirrored.
1665 #  @param thePoint Point of symmetry.
1666 #  @return New GEOM_Object, containing the mirrored shape.
1667 #
1668 #  Example: see GEOM_TestAll.py
1669 def MakeMirrorByPoint(theObject, thePoint):
1670     anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1671     if TrsfOp.IsDone() == 0:
1672       print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1673     return anObj
1674
1675 ## Modify the Location of the given object by LCS,
1676 #  creating its copy before the setting.
1677 #  @param theObject The object to be displaced.
1678 #  @param theStartLCS Coordinate system to perform displacement from it.
1679 #                     If \a theStartLCS is NULL, displacement
1680 #                     will be performed from global CS.
1681 #                     If \a theObject itself is used as \a theStartLCS,
1682 #                     its location will be changed to \a theEndLCS.
1683 #  @param theEndLCS Coordinate system to perform displacement to it.
1684 #  @return New GEOM_Object, containing the displaced shape.
1685 #
1686 #  Example: see GEOM_TestAll.py
1687 def MakePosition(theObject, theStartLCS, theEndLCS):
1688     anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1689     if TrsfOp.IsDone() == 0:
1690       print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1691     return anObj
1692
1693 ## Create new object as offset of the given one.
1694 #  @param theObject The base object for the offset.
1695 #  @param theOffset Offset value.
1696 #  @return New GEOM_Object, containing the offset object.
1697 #
1698 #  Example: see GEOM_TestAll.py
1699 def MakeOffset(theObject, theOffset):
1700     anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1701     if TrsfOp.IsDone() == 0:
1702       print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1703     return anObj
1704
1705 # -----------------------------------------------------------------------------
1706 # Patterns
1707 # -----------------------------------------------------------------------------
1708
1709 ## Translate the given object along the given vector a given number times
1710 #  @param theObject The object to be translated.
1711 #  @param theVector Direction of the translation.
1712 #  @param theStep Distance to translate on.
1713 #  @param theNbTimes Quantity of translations to be done.
1714 #  @return New GEOM_Object, containing compound of all
1715 #          the shapes, obtained after each translation.
1716 #
1717 #  Example: see GEOM_TestAll.py
1718 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1719     anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1720     if TrsfOp.IsDone() == 0:
1721       print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1722     return anObj
1723
1724 ## Conseqently apply two specified translations to theObject specified number of times.
1725 #  @param theObject The object to be translated.
1726 #  @param theVector1 Direction of the first translation.
1727 #  @param theStep1 Step of the first translation.
1728 #  @param theNbTimes1 Quantity of translations to be done along theVector1.
1729 #  @param theVector2 Direction of the second translation.
1730 #  @param theStep2 Step of the second translation.
1731 #  @param theNbTimes2 Quantity of translations to be done along theVector2.
1732 #  @return New GEOM_Object, containing compound of all
1733 #          the shapes, obtained after each translation.
1734 #
1735 #  Example: see GEOM_TestAll.py
1736 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1737                                       theVector2, theStep2, theNbTimes2):
1738     anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1739                                                theVector2, theStep2, theNbTimes2)
1740     if TrsfOp.IsDone() == 0:
1741       print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1742     return anObj
1743
1744 ## Rotate the given object around the given axis a given number times.
1745 #  Rotation angle will be 2*PI/theNbTimes.
1746 #  @param theObject The object to be rotated.
1747 #  @param theAxis The rotation axis.
1748 #  @param theNbTimes Quantity of rotations to be done.
1749 #  @return New GEOM_Object, containing compound of all the
1750 #          shapes, obtained after each rotation.
1751 #
1752 #  Example: see GEOM_TestAll.py
1753 def MultiRotate1D(theObject, theAxis, theNbTimes):
1754     anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1755     if TrsfOp.IsDone() == 0:
1756       print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1757     return anObj
1758
1759 ## Rotate the given object around the
1760 #  given axis on the given angle a given number
1761 #  times and multi-translate each rotation result.
1762 #  Translation direction passes through center of gravity
1763 #  of rotated shape and its projection on the rotation axis.
1764 #  @param theObject The object to be rotated.
1765 #  @param theAxis Rotation axis.
1766 #  @param theAngle Rotation angle in graduces.
1767 #  @param theNbTimes1 Quantity of rotations to be done.
1768 #  @param theStep Translation distance.
1769 #  @param theNbTimes2 Quantity of translations to be done.
1770 #  @return New GEOM_Object, containing compound of all the
1771 #          shapes, obtained after each transformation.
1772 #
1773 #  Example: see GEOM_TestAll.py
1774 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1775     anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1776     if TrsfOp.IsDone() == 0:
1777       print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1778     return anObj
1779
1780 ## The same, as MultiRotate1D(), but axis is given by direction and point
1781 #
1782 #  Example: see GEOM_TestOthers.py
1783 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1784     aVec = MakeLine(aPoint,aDir)
1785     anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1786     return anObj
1787
1788 ## The same, as MultiRotate2D(), but axis is given by direction and point
1789 #
1790 #  Example: see GEOM_TestOthers.py
1791 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1792     aVec = MakeLine(aPoint,aDir)
1793     anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1794     return anObj
1795
1796 # -----------------------------------------------------------------------------
1797 # Local operations
1798 # -----------------------------------------------------------------------------
1799
1800 ## Perform a fillet on all edges of the given shape.
1801 #  @param theShape Shape, to perform fillet on.
1802 #  @param theR Fillet radius.
1803 #  @return New GEOM_Object, containing the result shape.
1804 #
1805 #  Example: see GEOM_TestOthers.py
1806 def MakeFilletAll(theShape, theR):
1807     anObj = LocalOp.MakeFilletAll(theShape, theR)
1808     if LocalOp.IsDone() == 0:
1809       print "MakeFilletAll : ", LocalOp.GetErrorCode()
1810     return anObj
1811
1812 ## Perform a fillet on the specified edges/faces of the given shape
1813 #  @param theShape Shape, to perform fillet on.
1814 #  @param theR Fillet radius.
1815 #  @param theShapeType Type of shapes in <theListShapes>.
1816 #  @param theListShapes Global indices of edges/faces to perform fillet on.
1817 #    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1818 #  @return New GEOM_Object, containing the result shape.
1819 #
1820 #  Example: see GEOM_TestAll.py
1821 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1822     anObj = None
1823     if theShapeType == ShapeType["EDGE"]:
1824         anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1825     else:
1826         anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1827     if LocalOp.IsDone() == 0:
1828       print "MakeFillet : ", LocalOp.GetErrorCode()
1829     return anObj
1830
1831 ## Perform a symmetric chamfer on all edges of the given shape.
1832 #  @param theShape Shape, to perform chamfer on.
1833 #  @param theD Chamfer size along each face.
1834 #  @return New GEOM_Object, containing the result shape.
1835 #
1836 #  Example: see GEOM_TestOthers.py
1837 def MakeChamferAll(theShape, theD):
1838     anObj = LocalOp.MakeChamferAll(theShape, theD)
1839     if LocalOp.IsDone() == 0:
1840       print "MakeChamferAll : ", LocalOp.GetErrorCode()
1841     return anObj
1842
1843 ## Perform a chamfer on edges, common to the specified faces,
1844 #  with distance D1 on the Face1
1845 #  @param theShape Shape, to perform chamfer on.
1846 #  @param theD1 Chamfer size along \a theFace1.
1847 #  @param theD2 Chamfer size along \a theFace2.
1848 #  @param theFace1,theFace2 Global indices of two faces of \a theShape.
1849 #    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1850 #  @return New GEOM_Object, containing the result shape.
1851 #
1852 #  Example: see GEOM_TestAll.py
1853 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1854     anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1855     if LocalOp.IsDone() == 0:
1856       print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1857     return anObj
1858
1859 ## Perform a chamfer on all edges of the specified faces,
1860 #  with distance D1 on the first specified face (if several for one edge)
1861 #  @param theShape Shape, to perform chamfer on.
1862 #  @param theD1 Chamfer size along face from \a theFaces. If both faces,
1863 #               connected to the edge, are in \a theFaces, \a theD1
1864 #               will be get along face, which is nearer to \a theFaces beginning.
1865 #  @param theD2 Chamfer size along another of two faces, connected to the edge.
1866 #  @param theFaces Sequence of global indices of faces of \a theShape.
1867 #    \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1868 #  @return New GEOM_Object, containing the result shape.
1869 #
1870 #  Example: see GEOM_TestAll.py
1871 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1872     anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1873     if LocalOp.IsDone() == 0:
1874       print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1875     return anObj
1876
1877 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1878 #
1879 #  Example: see GEOM_TestOthers.py
1880 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1881     anObj = None
1882     if aShapeType == ShapeType["EDGE"]:
1883         anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1884     else:
1885         anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1886     return anObj
1887
1888 ## Perform an Archimde operation on the given shape with given parameters.
1889 #  The object presenting the resulting face is returned.
1890 #  @param theShape Shape to be put in water.
1891 #  @param theWeight Weight og the shape.
1892 #  @param theWaterDensity Density of the water.
1893 #  @param theMeshDeflection Deflection of the mesh, using to compute the section.
1894 #  @return New GEOM_Object, containing a section of \a theShape
1895 #          by a plane, corresponding to water level.
1896 #
1897 #  Example: see GEOM_TestAll.py
1898 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1899     anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1900     if LocalOp.IsDone() == 0:
1901       print "MakeArchimede : ", LocalOp.GetErrorCode()
1902     return anObj
1903
1904 # -----------------------------------------------------------------------------
1905 # Information objects
1906 # -----------------------------------------------------------------------------
1907
1908 ## Get point coordinates
1909 #  @return [x, y, z]
1910 #
1911 #  Example: see GEOM_TestMeasures.py
1912 def PointCoordinates(Point):
1913     aTuple = MeasuOp.PointCoordinates(Point)
1914     if MeasuOp.IsDone() == 0:
1915       print "PointCoordinates : ", MeasuOp.GetErrorCode()
1916     return aTuple
1917
1918 ## Get summarized length of all wires,
1919 #  area of surface and volume of the given shape.
1920 #  @param theShape Shape to define properties of.
1921 #  @return [theLength, theSurfArea, theVolume]
1922 #  theLength:   Summarized length of all wires of the given shape.
1923 #  theSurfArea: Area of surface of the given shape.
1924 #  theVolume:   Volume of the given shape.
1925 #
1926 #  Example: see GEOM_TestMeasures.py
1927 def BasicProperties(theShape):
1928     aTuple = MeasuOp.GetBasicProperties(theShape)
1929     if MeasuOp.IsDone() == 0:
1930       print "BasicProperties : ", MeasuOp.GetErrorCode()
1931     return aTuple
1932
1933 ## Get parameters of bounding box of the given shape
1934 #  @param theShape Shape to obtain bounding box of.
1935 #  @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1936 #  Xmin,Xmax: Limits of shape along OX axis.
1937 #  Ymin,Ymax: Limits of shape along OY axis.
1938 #  Zmin,Zmax: Limits of shape along OZ axis.
1939 #
1940 #  Example: see GEOM_TestMeasures.py
1941 def BoundingBox(theShape):
1942     aTuple = MeasuOp.GetBoundingBox(theShape)
1943     if MeasuOp.IsDone() == 0:
1944       print "BoundingBox : ", MeasuOp.GetErrorCode()
1945     return aTuple
1946
1947 ## Get inertia matrix and moments of inertia of theShape.
1948 #  @param theShape Shape to calculate inertia of.
1949 #  @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1950 #  I(1-3)(1-3): Components of the inertia matrix of the given shape.
1951 #  Ix,Iy,Iz:    Moments of inertia of the given shape.
1952 #
1953 #  Example: see GEOM_TestMeasures.py
1954 def Inertia(theShape):
1955     aTuple = MeasuOp.GetInertia(theShape)
1956     if MeasuOp.IsDone() == 0:
1957       print "Inertia : ", MeasuOp.GetErrorCode()
1958     return aTuple
1959
1960 ## Get minimal distance between the given shapes.
1961 #  @param theShape1,theShape2 Shapes to find minimal distance between.
1962 #  @return Value of the minimal distance between the given shapes.
1963 #
1964 #  Example: see GEOM_TestMeasures.py
1965 def MinDistance(theShape1, theShape2):
1966     aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1967     if MeasuOp.IsDone() == 0:
1968       print "MinDistance : ", MeasuOp.GetErrorCode()
1969     return aTuple[0]
1970
1971 ## Get min and max tolerances of sub-shapes of theShape
1972 #  @param theShape Shape, to get tolerances of.
1973 #  @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1974 #  FaceMin,FaceMax: Min and max tolerances of the faces.
1975 #  EdgeMin,EdgeMax: Min and max tolerances of the edges.
1976 #  VertMin,VertMax: Min and max tolerances of the vertices.
1977 #
1978 #  Example: see GEOM_TestMeasures.py
1979 def Tolerance(theShape):
1980     aTuple = MeasuOp.GetTolerance(theShape)
1981     if MeasuOp.IsDone() == 0:
1982       print "Tolerance : ", MeasuOp.GetErrorCode()
1983     return aTuple
1984
1985 ## Obtain description of the given shape (number of sub-shapes of each type)
1986 #  @param theShape Shape to be described.
1987 #  @return Description of the given shape.
1988 #
1989 #  Example: see GEOM_TestMeasures.py
1990 def WhatIs(theShape):
1991     aDescr = MeasuOp.WhatIs(theShape)
1992     if MeasuOp.IsDone() == 0:
1993       print "WhatIs : ", MeasuOp.GetErrorCode()
1994     return aDescr
1995
1996 ## Get a point, situated at the centre of mass of theShape.
1997 #  @param theShape Shape to define centre of mass of.
1998 #  @return New GEOM_Object, containing the created point.
1999 #
2000 #  Example: see GEOM_TestMeasures.py
2001 def MakeCDG(theShape):
2002     anObj = MeasuOp.GetCentreOfMass(theShape)
2003     if MeasuOp.IsDone() == 0:
2004       print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
2005     return anObj
2006
2007 ## Check a topology of the given shape.
2008 #  @param theShape Shape to check validity of.
2009 #  @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
2010 #                        if TRUE, the shape's geometry will be checked also.
2011 #  @return TRUE, if the shape "seems to be valid".
2012 #  If theShape is invalid, prints a description of problem.
2013 #
2014 #  Example: see GEOM_TestMeasures.py
2015 def CheckShape(theShape, theIsCheckGeom = 0):
2016     if theIsCheckGeom:
2017         (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
2018     else:
2019         (IsValid, Status) = MeasuOp.CheckShape(theShape)
2020
2021     if MeasuOp.IsDone() == 0:
2022       print "CheckShape : ", MeasuOp.GetErrorCode()
2023     else:
2024       if IsValid == 0:
2025         print Status
2026     return IsValid
2027
2028 ## Get position (LCS) of theShape.
2029 #
2030 #  Origin of the LCS is situated at the shape's center of mass.
2031 #  Axes of the LCS are obtained from shape's location or,
2032 #  if the shape is a planar face, from position of its plane.
2033 #
2034 #  @param theShape Shape to calculate position of.
2035 #  @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
2036 #          Ox,Oy,Oz: Coordinates of shape's LCS origin.
2037 #          Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
2038 #          Xx,Xy,Xz: Coordinates of shape's LCS X direction.
2039 #
2040 #  Example: see GEOM_TestMeasures.py
2041 def GetPosition(theShape):
2042     aTuple = MeasuOp.GetPosition(theShape)
2043     if MeasuOp.IsDone() == 0:
2044       print "GetPosition : ", MeasuOp.GetErrorCode()
2045     return aTuple
2046
2047 ## Get kind of theShape.
2048 #
2049 #  @param theShape Shape to get a kind of.
2050 #  @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
2051 #          and a list of parameters, describing the shape.
2052 #  @note  Concrete meaning of each value, returned via \a theIntegers
2053 #         or \a theDoubles list depends on the kind of the shape.
2054 #         The full list of possible outputs is:
2055 #
2056 #  geompy.kind.COMPOUND              nb_solids  nb_faces  nb_edges  nb_vertices
2057 #  geompy.kind.COMPSOLID             nb_solids  nb_faces  nb_edges  nb_vertices
2058 #
2059 #  geompy.kind.SHELL       geompy.info.CLOSED   nb_faces  nb_edges  nb_vertices
2060 #  geompy.kind.SHELL       geompy.info.UNCLOSED nb_faces  nb_edges  nb_vertices
2061 #
2062 #  geompy.kind.WIRE        geompy.info.CLOSED             nb_edges  nb_vertices
2063 #  geompy.kind.WIRE        geompy.info.UNCLOSED           nb_edges  nb_vertices
2064 #
2065 #  geompy.kind.SPHERE       xc yc zc            R
2066 #  geompy.kind.CYLINDER     xb yb zb  dx dy dz  R         H
2067 #  geompy.kind.BOX          xc yc zc                      ax ay az
2068 #  geompy.kind.ROTATED_BOX  xc yc zc  zx zy zz  xx xy xz  ax ay az
2069 #  geompy.kind.TORUS        xc yc zc  dx dy dz  R_1  R_2
2070 #  geompy.kind.CONE         xb yb zb  dx dy dz  R_1  R_2  H
2071 #  geompy.kind.POLYHEDRON                       nb_faces  nb_edges  nb_vertices
2072 #  geompy.kind.SOLID                            nb_faces  nb_edges  nb_vertices
2073 #
2074 #  geompy.kind.SPHERE2D     xc yc zc            R
2075 #  geompy.kind.CYLINDER2D   xb yb zb  dx dy dz  R         H
2076 #  geompy.kind.TORUS2D      xc yc zc  dx dy dz  R_1  R_2
2077 #  geompy.kind.CONE2D       xc yc zc  dx dy dz  R_1  R_2  H
2078 #  geompy.kind.DISK_CIRCLE  xc yc zc  dx dy dz  R
2079 #  geompy.kind.DISK_ELLIPSE xc yc zc  dx dy dz  R_1  R_2
2080 #  geompy.kind.POLYGON      xo yo zo  dx dy dz            nb_edges  nb_vertices
2081 #  geompy.kind.PLANE        xo yo zo  dx dy dz
2082 #  geompy.kind.PLANAR       xo yo zo  dx dy dz            nb_edges  nb_vertices
2083 #  geompy.kind.FACE                                       nb_edges  nb_vertices
2084 #
2085 #  geompy.kind.CIRCLE       xc yc zc  dx dy dz  R
2086 #  geompy.kind.ARC_CIRCLE   xc yc zc  dx dy dz  R         x1 y1 z1  x2 y2 z2
2087 #  geompy.kind.ELLIPSE      xc yc zc  dx dy dz  R_1  R_2
2088 #  geompy.kind.ARC_ELLIPSE  xc yc zc  dx dy dz  R_1  R_2  x1 y1 z1  x2 y2 z2
2089 #  geompy.kind.LINE         xo yo zo  dx dy dz
2090 #  geompy.kind.SEGMENT      x1 y1 z1  x2 y2 z2
2091 #  geompy.kind.EDGE                                                 nb_vertices
2092 #
2093 #  geompy.kind.VERTEX       x  y  z
2094 #
2095 #  Example: see GEOM_TestMeasures.py
2096 def KindOfShape(theShape):
2097     aRoughTuple = MeasuOp.KindOfShape(theShape)
2098     if MeasuOp.IsDone() == 0:
2099         print "KindOfShape : ", MeasuOp.GetErrorCode()
2100         return []
2101
2102     aKind  = aRoughTuple[0]
2103     anInts = aRoughTuple[1]
2104     aDbls  = aRoughTuple[2]
2105
2106     # Now there is no exception from this rule:
2107     aKindTuple = [aKind] + aDbls + anInts
2108
2109     # If they are we will regroup parameters for such kind of shape.
2110     # For example:
2111     #if aKind == kind.SOME_KIND:
2112     #    #  SOME_KIND     int int double int double double
2113     #    aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
2114
2115     return aKindTuple
2116
2117 # -----------------------------------------------------------------------------
2118 # Import/Export objects
2119 # -----------------------------------------------------------------------------
2120
2121 ## Import a shape from the BREP or IGES or STEP file
2122 #  (depends on given format) with given name.
2123 #  @param theFileName The file, containing the shape.
2124 #  @param theFormatName Specify format for the file reading.
2125 #         Available formats can be obtained with InsertOp.ImportTranslators() method.
2126 #  @return New GEOM_Object, containing the imported shape.
2127 #
2128 #  Example: see GEOM_TestOthers.py
2129 def Import(theFileName, theFormatName):
2130     anObj = InsertOp.Import(theFileName, theFormatName)
2131     if InsertOp.IsDone() == 0:
2132       print "Import : ", InsertOp.GetErrorCode()
2133     return anObj
2134
2135 ## Shortcut to Import() for BREP format
2136 #
2137 #  Example: see GEOM_TestOthers.py
2138 def ImportBREP(theFileName):
2139     return Import(theFileName, "BREP")
2140
2141 ## Shortcut to Import() for IGES format
2142 #
2143 #  Example: see GEOM_TestOthers.py
2144 def ImportIGES(theFileName):
2145     return Import(theFileName, "IGES")
2146
2147 ## Shortcut to Import() for STEP format
2148 #
2149 #  Example: see GEOM_TestOthers.py
2150 def ImportSTEP(theFileName):
2151     return Import(theFileName, "STEP")
2152
2153 ## Export the given shape into a file with given name.
2154 #  @param theObject Shape to be stored in the file.
2155 #  @param theFileName Name of the file to store the given shape in.
2156 #  @param theFormatName Specify format for the shape storage.
2157 #         Available formats can be obtained with InsertOp.ImportTranslators() method.
2158 #
2159 #  Example: see GEOM_TestOthers.py
2160 def Export(theObject, theFileName, theFormatName):
2161     InsertOp.Export(theObject, theFileName, theFormatName)
2162     if InsertOp.IsDone() == 0:
2163       print "Export : ", InsertOp.GetErrorCode()
2164
2165 ## Shortcut to Export() for BREP format
2166 #
2167 #  Example: see GEOM_TestOthers.py
2168 def ExportBREP(theObject, theFileName):
2169     return Export(theObject, theFileName, "BREP")
2170
2171 ## Shortcut to Export() for IGES format
2172 #
2173 #  Example: see GEOM_TestOthers.py
2174 def ExportIGES(theObject, theFileName):
2175     return Export(theObject, theFileName, "IGES")
2176
2177 ## Shortcut to Export() for STEP format
2178 #
2179 #  Example: see GEOM_TestOthers.py
2180 def ExportSTEP(theObject, theFileName):
2181     return Export(theObject, theFileName, "STEP")
2182
2183 # -----------------------------------------------------------------------------
2184 # Block operations
2185 # -----------------------------------------------------------------------------
2186
2187 ## Create a quadrangle face from four edges. Order of Edges is not
2188 #  important. It is  not necessary that edges share the same vertex.
2189 #  @param E1,E2,E3,E4 Edges for the face bound.
2190 #  @return New GEOM_Object, containing the created face.
2191 #
2192 #  Example: see GEOM_Spanner.py
2193 def MakeQuad(E1, E2, E3, E4):
2194     anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2195     if BlocksOp.IsDone() == 0:
2196       print "MakeQuad : ", BlocksOp.GetErrorCode()
2197     return anObj
2198
2199 ## Create a quadrangle face on two edges.
2200 #  The missing edges will be built by creating the shortest ones.
2201 #  @param E1,E2 Two opposite edges for the face.
2202 #  @return New GEOM_Object, containing the created face.
2203 #
2204 #  Example: see GEOM_Spanner.py
2205 def MakeQuad2Edges(E1, E2):
2206     anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2207     if BlocksOp.IsDone() == 0:
2208       print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2209     return anObj
2210
2211 ## Create a quadrangle face with specified corners.
2212 #  The missing edges will be built by creating the shortest ones.
2213 #  @param V1,V2,V3,V4 Corner vertices for the face.
2214 #  @return New GEOM_Object, containing the created face.
2215 #
2216 #  Example: see GEOM_Spanner.py
2217 def MakeQuad4Vertices(V1, V2, V3, V4):
2218     anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2219     if BlocksOp.IsDone() == 0:
2220       print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2221     return anObj
2222
2223 ## Create a hexahedral solid, bounded by the six given faces. Order of
2224 #  faces is not important. It is  not necessary that Faces share the same edge.
2225 #  @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2226 #  @return New GEOM_Object, containing the created solid.
2227 #
2228 #  Example: see GEOM_Spanner.py
2229 def MakeHexa(F1, F2, F3, F4, F5, F6):
2230     anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2231     if BlocksOp.IsDone() == 0:
2232       print "MakeHexa : ", BlocksOp.GetErrorCode()
2233     return anObj
2234
2235 ## Create a hexahedral solid between two given faces.
2236 #  The missing faces will be built by creating the smallest ones.
2237 #  @param F1,F2 Two opposite faces for the hexahedral solid.
2238 #  @return New GEOM_Object, containing the created solid.
2239 #
2240 #  Example: see GEOM_Spanner.py
2241 def MakeHexa2Faces(F1, F2):
2242     anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2243     if BlocksOp.IsDone() == 0:
2244       print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2245     return anObj
2246
2247 ## Get a vertex, found in the given shape by its coordinates.
2248 #  @param theShape Block or a compound of blocks.
2249 #  @param theX,theY,theZ Coordinates of the sought vertex.
2250 #  @param theEpsilon Maximum allowed distance between the resulting
2251 #                    vertex and point with the given coordinates.
2252 #  @return New GEOM_Object, containing the found vertex.
2253 #
2254 #  Example: see GEOM_TestOthers.py
2255 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2256     anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2257     if BlocksOp.IsDone() == 0:
2258       print "GetPoint : ", BlocksOp.GetErrorCode()
2259     return anObj
2260
2261 ## Get an edge, found in the given shape by two given vertices.
2262 #  @param theShape Block or a compound of blocks.
2263 #  @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2264 #  @return New GEOM_Object, containing the found edge.
2265 #
2266 #  Example: see GEOM_Spanner.py
2267 def GetEdge(theShape, thePoint1, thePoint2):
2268     anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2269     if BlocksOp.IsDone() == 0:
2270       print "GetEdge : ", BlocksOp.GetErrorCode()
2271     return anObj
2272
2273 ## Find an edge of the given shape, which has minimal distance to the given point.
2274 #  @param theShape Block or a compound of blocks.
2275 #  @param thePoint Point, close to the desired edge.
2276 #  @return New GEOM_Object, containing the found edge.
2277 #
2278 #  Example: see GEOM_TestOthers.py
2279 def GetEdgeNearPoint(theShape, thePoint):
2280     anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2281     if BlocksOp.IsDone() == 0:
2282       print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2283     return anObj
2284
2285 ## Returns a face, found in the given shape by four given corner vertices.
2286 #  @param theShape Block or a compound of blocks.
2287 #  @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2288 #  @return New GEOM_Object, containing the found face.
2289 #
2290 #  Example: see GEOM_Spanner.py
2291 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2292     anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2293     if BlocksOp.IsDone() == 0:
2294       print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2295     return anObj
2296
2297 ## Get a face of block, found in the given shape by two given edges.
2298 #  @param theShape Block or a compound of blocks.
2299 #  @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2300 #  @return New GEOM_Object, containing the found face.
2301 #
2302 #  Example: see GEOM_Spanner.py
2303 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2304     anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2305     if BlocksOp.IsDone() == 0:
2306       print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2307     return anObj
2308
2309 ## Find a face, opposite to the given one in the given block.
2310 #  @param theBlock Must be a hexahedral solid.
2311 #  @param theFace Face of \a theBlock, opposite to the desired face.
2312 #  @return New GEOM_Object, containing the found face.
2313 #
2314 #  Example: see GEOM_Spanner.py
2315 def GetOppositeFace(theBlock, theFace):
2316     anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2317     if BlocksOp.IsDone() == 0:
2318       print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2319     return anObj
2320
2321 ## Find a face of the given shape, which has minimal distance to the given point.
2322 #  @param theShape Block or a compound of blocks.
2323 #  @param thePoint Point, close to the desired face.
2324 #  @return New GEOM_Object, containing the found face.
2325 #
2326 #  Example: see GEOM_Spanner.py
2327 def GetFaceNearPoint(theShape, thePoint):
2328     anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2329     if BlocksOp.IsDone() == 0:
2330       print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2331     return anObj
2332
2333 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2334 #  @param theShape Block or a compound of blocks.
2335 #  @param theVector Vector, close to the normale of the desired face.
2336 #  @return New GEOM_Object, containing the found face.
2337 #
2338 #  Example: see GEOM_Spanner.py
2339 def GetFaceByNormale(theBlock, theVector):
2340     anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2341     if BlocksOp.IsDone() == 0:
2342       print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2343     return anObj
2344
2345 ## Check, if the compound of blocks is given.
2346 #  To be considered as a compound of blocks, the
2347 #  given shape must satisfy the following conditions:
2348 #  - Each element of the compound should be a Block (6 faces and 12 edges).
2349 #  - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2350 #  - The compound should be connexe.
2351 #  - The glue between two quadrangle faces should be applied.
2352 #  @param theCompound The compound to check.
2353 #  @return TRUE, if the given shape is a compound of blocks.
2354 #  If theCompound is not valid, prints all discovered errors.
2355 #
2356 #  Example: see GEOM_Spanner.py
2357 def CheckCompoundOfBlocks(theCompound):
2358     (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2359     if BlocksOp.IsDone() == 0:
2360       print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2361     else:
2362       if IsValid == 0:
2363         Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2364         print Descr
2365     return IsValid
2366
2367 ## Remove all seam and degenerated edges from \a theShape.
2368 #  Unite faces and edges, sharing one surface. It means that
2369 #  this faces must have references to one C++ surface object (handle).
2370 #  @param theShape The compound or single solid to remove irregular edges from.
2371 #  @return Improved shape.
2372 #
2373 #  Example: see GEOM_TestOthers.py
2374 def RemoveExtraEdges(theShape):
2375     anObj = BlocksOp.RemoveExtraEdges(theShape)
2376     if BlocksOp.IsDone() == 0:
2377       print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2378     return anObj
2379
2380 ## Check, if the given shape is a blocks compound.
2381 #  Fix all detected errors.
2382 #    \note Single block can be also fixed by this method.
2383 #  @param theCompound The compound to check and improve.
2384 #  @return Improved compound.
2385 #
2386 #  Example: see GEOM_TestOthers.py
2387 def CheckAndImprove(theShape):
2388     anObj = BlocksOp.CheckAndImprove(theShape)
2389     if BlocksOp.IsDone() == 0:
2390       print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2391     return anObj
2392
2393 ## Get all the blocks, contained in the given compound.
2394 #  @param theCompound The compound to explode.
2395 #  @param theMinNbFaces If solid has lower number of faces, it is not a block.
2396 #  @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2397 #    \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2398 #  @return List of GEOM_Objects, containing the retrieved blocks.
2399 #
2400 #  Example: see GEOM_TestOthers.py
2401 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2402     aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2403     if BlocksOp.IsDone() == 0:
2404       print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2405     return aList
2406
2407 ## Find block, containing the given point inside its volume or on boundary.
2408 #  @param theCompound Compound, to find block in.
2409 #  @param thePoint Point, close to the desired block. If the point lays on
2410 #         boundary between some blocks, we return block with nearest center.
2411 #  @return New GEOM_Object, containing the found block.
2412 #
2413 #  Example: see GEOM_Spanner.py
2414 def GetBlockNearPoint(theCompound, thePoint):
2415     anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2416     if BlocksOp.IsDone() == 0:
2417       print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2418     return anObj
2419
2420 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2421 #  @param theCompound Compound, to find block in.
2422 #  @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2423 #  @return New GEOM_Object, containing the found block.
2424 #
2425 #  Example: see GEOM_TestOthers.py
2426 def GetBlockByParts(theCompound, theParts):
2427     anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2428     if BlocksOp.IsDone() == 0:
2429       print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2430     return anObj
2431
2432 ## Return all blocks, containing all the elements, passed as the parts.
2433 #  @param theCompound Compound, to find blocks in.
2434 #  @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2435 #  @return List of GEOM_Objects, containing the found blocks.
2436 #
2437 #  Example: see GEOM_Spanner.py
2438 def GetBlocksByParts(theCompound, theParts):
2439     aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2440     if BlocksOp.IsDone() == 0:
2441       print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2442     return aList
2443
2444 ## Multi-transformate block and glue the result.
2445 #  Transformation is defined so, as to superpose direction faces.
2446 #  @param Block Hexahedral solid to be multi-transformed.
2447 #  @param DirFace1 ID of First direction face.
2448 #  @param DirFace2 ID of Second direction face.
2449 #  @param NbTimes Quantity of transformations to be done.
2450 #    \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2451 #  @return New GEOM_Object, containing the result shape.
2452 #
2453 #  Example: see GEOM_Spanner.py
2454 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2455     anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2456     if BlocksOp.IsDone() == 0:
2457       print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2458     return anObj
2459
2460 ## Multi-transformate block and glue the result.
2461 #  @param Block Hexahedral solid to be multi-transformed.
2462 #  @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2463 #  @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2464 #  @param NbTimesU,NbTimesV Quantity of transformations to be done.
2465 #  @return New GEOM_Object, containing the result shape.
2466 #
2467 #  Example: see GEOM_Spanner.py
2468 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2469                                      DirFace1V, DirFace2V, NbTimesV):
2470     anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2471                                                       DirFace1V, DirFace2V, NbTimesV)
2472     if BlocksOp.IsDone() == 0:
2473       print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2474     return anObj
2475
2476 ## Build all possible propagation groups.
2477 #  Propagation group is a set of all edges, opposite to one (main)
2478 #  edge of this group directly or through other opposite edges.
2479 #  Notion of Opposite Edge make sence only on quadrangle face.
2480 #  @param theShape Shape to build propagation groups on.
2481 #  @return List of GEOM_Objects, each of them is a propagation group.
2482 #
2483 #  Example: see GEOM_TestOthers.py
2484 def Propagate(theShape):
2485     listChains = BlocksOp.Propagate(theShape)
2486     if BlocksOp.IsDone() == 0:
2487       print "Propagate : ", BlocksOp.GetErrorCode()
2488     return listChains
2489
2490 # -----------------------------------------------------------------------------
2491 # Group operations
2492 # -----------------------------------------------------------------------------
2493
2494 ## Creates a new group which will store sub shapes of theMainShape
2495 #  @param theMainShape is a GEOM object on which the group is selected
2496 #  @param theShapeType defines a shape type of the group
2497 #  @return a newly created GEOM group
2498 #
2499 #  Example: see GEOM_TestOthers.py
2500 def CreateGroup(theMainShape, theShapeType):
2501     anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2502     if GroupOp.IsDone() == 0:
2503        print "CreateGroup : ", GroupOp.GetErrorCode()
2504     return anObj
2505
2506 ## Adds a sub object with ID theSubShapeId to the group
2507 #  @param theGroup is a GEOM group to which the new sub shape is added
2508 #  @param theSubShapeID is a sub shape ID in the main object.
2509 #  \note Use method GetSubShapeID() to get an unique ID of the sub shape
2510 #
2511 #  Example: see GEOM_TestOthers.py
2512 def AddObject(theGroup, theSubShapeID):
2513     GroupOp.AddObject(theGroup, theSubShapeID)
2514     if GroupOp.IsDone() == 0:
2515       print "AddObject : ", GroupOp.GetErrorCode()
2516
2517 ## Removes a sub object with ID \a theSubShapeId from the group
2518 #  @param theGroup is a GEOM group from which the new sub shape is removed
2519 #  @param theSubShapeID is a sub shape ID in the main object.
2520 #  \note Use method GetSubShapeID() to get an unique ID of the sub shape
2521 #
2522 #  Example: see GEOM_TestOthers.py
2523 def RemoveObject(theGroup, theSubShapeID):
2524     GroupOp.RemoveObject(theGroup, theSubShapeID)
2525     if GroupOp.IsDone() == 0:
2526       print "RemoveObject : ", GroupOp.GetErrorCode()
2527
2528 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2529 #  @param theGroup is a GEOM group to which the new sub shapes are added.
2530 #  @param theSubShapes is a list of sub shapes to be added.
2531 #
2532 #  Example: see GEOM_TestOthers.py
2533 def UnionList (theGroup, theSubShapes):
2534     GroupOp.UnionList(theGroup, theSubShapes)
2535     if GroupOp.IsDone() == 0:
2536       print "UnionList : ", GroupOp.GetErrorCode()
2537
2538 ## Works like the above method, but argument
2539 #  theSubShapes here is a list of sub-shapes indices
2540 #
2541 #  Example: see GEOM_TestOthers.py
2542 def UnionIDs(theGroup, theSubShapes):
2543     GroupOp.UnionIDs(theGroup, theSubShapes)
2544     if GroupOp.IsDone() == 0:
2545         print "UnionIDs : ", GroupOp.GetErrorCode()
2546
2547 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2548 #  @param theGroup is a GEOM group from which the sub-shapes are removed.
2549 #  @param theSubShapes is a list of sub-shapes to be removed.
2550 #
2551 #  Example: see GEOM_TestOthers.py
2552 def DifferenceList (theGroup, theSubShapes):
2553     GroupOp.DifferenceList(theGroup, theSubShapes)
2554     if GroupOp.IsDone() == 0:
2555       print "DifferenceList : ", GroupOp.GetErrorCode()
2556
2557 ## Works like the above method, but argument
2558 #  theSubShapes here is a list of sub-shapes indices
2559 #
2560 #  Example: see GEOM_TestOthers.py
2561 def DifferenceIDs(theGroup, theSubShapes):
2562     GroupOp.DifferenceIDs(theGroup, theSubShapes)
2563     if GroupOp.IsDone() == 0:
2564         print "DifferenceIDs : ", GroupOp.GetErrorCode()
2565
2566 ## Returns a list of sub objects ID stored in the group
2567 #  @param theGroup is a GEOM group for which a list of IDs is requested
2568 #
2569 #  Example: see GEOM_TestOthers.py
2570 def GetObjectIDs(theGroup):
2571     ListIDs = GroupOp.GetObjects(theGroup)
2572     if GroupOp.IsDone() == 0:
2573       print "GetObjectIDs : ", GroupOp.GetErrorCode()
2574     return ListIDs
2575
2576 ## Returns a type of sub objects stored in the group
2577 #  @param theGroup is a GEOM group which type is returned.
2578 #
2579 #  Example: see GEOM_TestOthers.py
2580 def GetType(theGroup):
2581     aType = GroupOp.GetType(theGroup)
2582     if GroupOp.IsDone() == 0:
2583       print "GetType : ", GroupOp.GetErrorCode()
2584     return aType
2585
2586 ## Returns a main shape associated with the group
2587 #  @param theGroup is a GEOM group for which a main shape object is requested
2588 #  @return a GEOM object which is a main shape for theGroup
2589 #
2590 #  Example: see GEOM_TestOthers.py
2591 def GetMainShape(theGroup):
2592     anObj = GroupOp.GetMainShape(theGroup)
2593     if GroupOp.IsDone() == 0:
2594       print "GetMainShape : ", GroupOp.GetErrorCode()
2595     return anObj
2596
2597 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2598 #  If include_min/max == 0, edges with length == min/max_length will not be included in result.
2599 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2600     edges = SubShapeAll(theShape, ShapeType["EDGE"])
2601     edges_in_range = []
2602     for edge in edges:
2603         Props = BasicProperties(edge)
2604         if min_length <= Props[0] and Props[0] <= max_length:
2605             if (not include_min) and (min_length == Props[0]):
2606                 skip = 1
2607             else:
2608                 if (not include_max) and (Props[0] == max_length):
2609                     skip = 1
2610                 else:
2611                     edges_in_range.append(edge)
2612
2613     if len(edges_in_range) <= 0:
2614         print "No edges found by given criteria"
2615         return 0
2616
2617     group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2618     UnionList(group_edges, edges_in_range)
2619
2620     return group_edges
2621
2622 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2623 #  If include_min/max == 0, edges with length == min/max_length will not be included in result.
2624 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2625     nb_selected = sg.SelectedCount()
2626     if nb_selected < 1:
2627         print "Select a shape before calling this function, please."
2628         return 0
2629     if nb_selected > 1:
2630         print "Only one shape must be selected"
2631         return 0
2632
2633     id_shape = sg.getSelected(0)
2634     shape = IDToObject( id_shape )
2635
2636     group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2637
2638     left_str  = " < "
2639     right_str = " < "
2640     if include_min: left_str  = " <= "
2641     if include_max: right_str  = " <= "
2642
2643     addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2644                        + left_str + "length" + right_str + `max_length`)
2645
2646     sg.updateObjBrowser(1)
2647
2648     return group_edges
2649
2650 ## Add Path to load python scripts from
2651 def addPath(Path):
2652     if (sys.path.count(Path) < 1):
2653         sys.path.append(Path)