1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 # Author : Paul RASCLE, EDF
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 geom = g._narrow( GEOM.GEOM_Gen )
39 gg = ImportComponentGUI("GEOM")
42 #SRN: modified on Mar 18, 2005
61 def init_geom(theStudy):
63 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
64 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
67 myStudyId = myStudy._get_StudyId()
68 myBuilder = myStudy.NewBuilder()
69 father = myStudy.FindComponent("GEOM")
71 father = myBuilder.NewComponent("GEOM")
72 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
73 FName = A1._narrow(SALOMEDS.AttributeName)
74 FName.SetValue("Geometry")
75 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
76 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
77 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
78 myBuilder.DefineComponentInstance(father,geom)
81 # -----------------------------------------------------------------------------
82 # Assign Operations Interfaces
83 # -----------------------------------------------------------------------------
85 BasicOp = geom.GetIBasicOperations (myStudyId)
86 CurvesOp = geom.GetICurvesOperations (myStudyId)
87 PrimOp = geom.GetI3DPrimOperations (myStudyId)
88 ShapesOp = geom.GetIShapesOperations (myStudyId)
89 HealOp = geom.GetIHealingOperations (myStudyId)
90 InsertOp = geom.GetIInsertOperations (myStudyId)
91 BoolOp = geom.GetIBooleanOperations (myStudyId)
92 TrsfOp = geom.GetITransformOperations(myStudyId)
93 LocalOp = geom.GetILocalOperations (myStudyId)
94 MeasuOp = geom.GetIMeasureOperations (myStudyId)
95 BlocksOp = geom.GetIBlocksOperations (myStudyId)
96 GroupOp = geom.GetIGroupOperations (myStudyId)
101 #SRN: end of modifications
103 def SubShapeName(aSubObj, aMainObj):
105 * Get name for sub-shape aSubObj of shape aMainObj
107 * Example: see GEOM_TestAll.py
109 aSubId = orb.object_to_string(aSubObj)
110 aMainId = orb.object_to_string(aMainObj)
111 index = gg.getIndexTopology(aSubId, aMainId)
112 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
115 def addToStudy(aShape, aName):
117 * Publish in study aShape with name aName
119 * Example: see GEOM_TestAll.py
122 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
124 print "addToStudy() failed"
126 return aShape.GetStudyEntry()
128 def addToStudyInFather(aFather, aShape, aName):
130 * Publish in study aShape with name aName as sub-object of previously published aFather
132 * Example: see GEOM_TestAll.py
135 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
137 print "addToStudyInFather() failed"
139 return aShape.GetStudyEntry()
141 # -----------------------------------------------------------------------------
142 # enumeration ShapeType as a dictionary
143 # -----------------------------------------------------------------------------
145 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
147 # -----------------------------------------------------------------------------
149 # -----------------------------------------------------------------------------
151 def MakeVertex(theX, theY, theZ):
153 * Create point by three coordinates.
154 * \param theX The X coordinate of the point.
155 * \param theY The Y coordinate of the point.
156 * \param theZ The Z coordinate of the point.
157 * \return New GEOM_Object, containing the created point.
159 * Example: see GEOM_TestAll.py
161 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
162 if BasicOp.IsDone() == 0:
163 print "MakePointXYZ : ", BasicOp.GetErrorCode()
166 def MakeVertexWithRef(theReference, theX, theY, theZ):
168 * Create a point, distant from the referenced point
169 * on the given distances along the coordinate axes.
170 * \param theReference The referenced point.
171 * \param theX Displacement from the referenced point along OX axis.
172 * \param theY Displacement from the referenced point along OY axis.
173 * \param theZ Displacement from the referenced point along OZ axis.
174 * \return New GEOM_Object, containing the created point.
176 * Example: see GEOM_TestAll.py
178 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
179 if BasicOp.IsDone() == 0:
180 print "MakePointWithReference : ", BasicOp.GetErrorCode()
183 def MakeVertexOnCurve(theRefCurve, theParameter):
185 * Create a point, corresponding to the given parameter on the given curve.
186 * \param theRefCurve The referenced curve.
187 * \param theParameter Value of parameter on the referenced curve.
188 * \return New GEOM_Object, containing the created point.
190 * Example: see GEOM_TestAll.py
192 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
193 if BasicOp.IsDone() == 0:
194 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
197 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
199 * Create a vector with the given components.
200 * \param theDX X component of the vector.
201 * \param theDY Y component of the vector.
202 * \param theDZ Z component of the vector.
203 * \return New GEOM_Object, containing the created vector.
205 * Example: see GEOM_TestAll.py
207 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
208 if BasicOp.IsDone() == 0:
209 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
212 def MakeVector(thePnt1, thePnt2):
214 * Create a vector between two points.
215 * \param thePnt1 Start point for the vector.
216 * \param thePnt2 End point for the vector.
217 * \return New GEOM_Object, containing the created vector.
219 * Example: see GEOM_TestAll.py
221 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
222 if BasicOp.IsDone() == 0:
223 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
226 def MakeLine(thePnt, theDir):
228 * Create a line, passing through the given point
229 * and parrallel to the given direction
230 * \param thePnt Point. The resulting line will pass through it.
231 * \param theDir Direction. The resulting line will be parallel to it.
232 * \return New GEOM_Object, containing the created line.
234 * Example: see GEOM_TestAll.py
236 anObj = BasicOp.MakeLine(thePnt, theDir)
237 if BasicOp.IsDone() == 0:
238 print "MakeLine : ", BasicOp.GetErrorCode()
241 def MakeLineTwoPnt(thePnt1, thePnt2):
243 * Create a line, passing through the given points
244 * \param thePnt1 First of two points, defining the line.
245 * \param thePnt2 Second of two points, defining the line.
246 * \return New GEOM_Object, containing the created line.
248 * Example: see GEOM_TestAll.py
250 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
251 if BasicOp.IsDone() == 0:
252 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
255 def MakePlane(thePnt, theVec, theTrimSize):
257 * Create a plane, passing through the given point
258 * and normal to the given vector.
259 * \param thePnt Point, the plane has to pass through.
260 * \param theVec Vector, defining the plane normal direction.
261 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
262 * \return New GEOM_Object, containing the created plane.
264 * Example: see GEOM_TestAll.py
266 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
267 if BasicOp.IsDone() == 0:
268 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
271 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
273 * Create a plane, passing through the three given points
274 * \param thePnt1 First of three points, defining the plane.
275 * \param thePnt2 Second of three points, defining the plane.
276 * \param thePnt3 Fird of three points, defining the plane.
277 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
278 * \return New GEOM_Object, containing the created plane.
280 * Example: see GEOM_TestAll.py
282 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
283 if BasicOp.IsDone() == 0:
284 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
287 def MakePlaneFace(theFace, theTrimSize):
289 * Create a plane, similar to the existing one, but with another size of representing face.
290 * \param theFace Referenced plane.
291 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
292 * \return New GEOM_Object, containing the created plane.
294 * Example: see GEOM_TestAll.py
296 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
297 if BasicOp.IsDone() == 0:
298 print "MakePlaneFace : ", BasicOp.GetErrorCode()
301 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
303 * Create a local coordinate system.
304 * \param OX,OY,OZ Three coordinates of coordinate system origin.
305 * \param XDX,XDY,XDZ Three components of OX direction
306 * \param YDX,YDY,YDZ Three components of OY direction
307 * \return New GEOM_Object, containing the created coordinate system.
309 * Example: see GEOM_TestAll.py
311 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
312 if BasicOp.IsDone() == 0:
313 print "MakeMarker : ", BasicOp.GetErrorCode()
316 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
318 * Create a local coordinate system.
319 * \param theOrigin Point of coordinate system origin.
320 * \param theXVec Vector of X direction
321 * \param theYVec Vector of Y direction
322 * \return New GEOM_Object, containing the created coordinate system.
324 O = PointCoordinates( theOrigin )
326 for vec in [ theXVec, theYVec ]:
327 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
328 p1 = PointCoordinates( v1 )
329 p2 = PointCoordinates( v2 )
330 for i in range( 0, 3 ):
331 OXOY.append( p2[i] - p1[i] )
333 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
334 OXOY[0], OXOY[1], OXOY[2],
335 OXOY[3], OXOY[4], OXOY[5], )
336 if BasicOp.IsDone() == 0:
337 print "MakeMarker : ", BasicOp.GetErrorCode()
340 # -----------------------------------------------------------------------------
342 # -----------------------------------------------------------------------------
344 def MakeArc(thePnt1, thePnt2, thePnt3):
346 * Create an arc of circle, passing through three given points.
347 * \param thePnt1 Start point of the arc.
348 * \param thePnt2 Middle point of the arc.
349 * \param thePnt3 End point of the arc.
350 * \return New GEOM_Object, containing the created arc.
352 * Example: see GEOM_TestAll.py
354 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
355 if CurvesOp.IsDone() == 0:
356 print "MakeArc : ", CurvesOp.GetErrorCode()
359 def MakeCircle(thePnt, theVec, theR):
361 * Create a circle with given center, normal vector and radius.
362 * \param thePnt Circle center.
363 * \param theVec Vector, normal to the plane of the circle.
364 * \param theR Circle radius.
365 * \return New GEOM_Object, containing the created circle.
367 * Example: see GEOM_TestAll.py
369 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
370 if CurvesOp.IsDone() == 0:
371 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
374 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
376 * Create a circle, passing through three given points
377 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
378 * \return New GEOM_Object, containing the created circle.
380 * Example: see GEOM_TestAll.py
382 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
383 if CurvesOp.IsDone() == 0:
384 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
387 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
389 * Create an ellipse with given center, normal vector and radiuses.
390 * \param thePnt Ellipse center.
391 * \param theVec Vector, normal to the plane of the ellipse.
392 * \param theRMajor Major ellipse radius.
393 * \param theRMinor Minor ellipse radius.
394 * \return New GEOM_Object, containing the created ellipse.
396 * Example: see GEOM_TestAll.py
398 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
399 if CurvesOp.IsDone() == 0:
400 print "MakeEllipse : ", CurvesOp.GetErrorCode()
403 def MakePolyline(thePoints):
405 * Create a polyline on the set of points.
406 * \param thePoints Sequence of points for the polyline.
407 * \return New GEOM_Object, containing the created polyline.
409 * Example: see GEOM_TestAll.py
411 anObj = CurvesOp.MakePolyline(thePoints)
412 if CurvesOp.IsDone() == 0:
413 print "MakePolyline : ", CurvesOp.GetErrorCode()
416 def MakeBezier(thePoints):
418 * Create bezier curve on the set of points.
419 * \param thePoints Sequence of points for the bezier curve.
420 * \return New GEOM_Object, containing the created bezier curve.
422 * Example: see GEOM_TestAll.py
424 anObj = CurvesOp.MakeSplineBezier(thePoints)
425 if CurvesOp.IsDone() == 0:
426 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
429 def MakeInterpol(thePoints):
431 * Create B-Spline curve on the set of points.
432 * \param thePoints Sequence of points for the B-Spline curve.
433 * \return New GEOM_Object, containing the created B-Spline curve.
435 * Example: see GEOM_TestAll.py
437 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
438 if CurvesOp.IsDone() == 0:
439 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
442 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
444 * Create a sketcher (wire or face), following the textual description,
445 * passed through \a theCommand argument. \n
446 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
447 * Format of the description string have to be the following:
449 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
452 * - x1, y1 are coordinates of the first sketcher point (zero by default),
454 * - "R angle" : Set the direction by angle
455 * - "D dx dy" : Set the direction by DX & DY
458 * - "TT x y" : Create segment by point at X & Y
459 * - "T dx dy" : Create segment by point with DX & DY
460 * - "L length" : Create segment by direction & Length
461 * - "IX x" : Create segment by direction & Intersect. X
462 * - "IY y" : Create segment by direction & Intersect. Y
465 * - "C radius length" : Create arc by direction, radius and length(in degree)
468 * - "WW" : Close Wire (to finish)
469 * - "WF" : Close Wire and build face (to finish)
471 * \param theCommand String, defining the sketcher in local
472 * coordinates of the working plane.
473 * \param theWorkingPlane Nine double values, defining origin,
474 * OZ and OX directions of the working plane.
475 * \return New GEOM_Object, containing the created wire.
477 * Example: see GEOM_TestAll.py
479 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
480 if CurvesOp.IsDone() == 0:
481 print "MakeSketcher : ", CurvesOp.GetErrorCode()
484 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
486 * Create a sketcher (wire or face), following the textual description,
487 * passed through \a theCommand argument. \n
488 * For format of the description string see the previous method.\n
489 * \param theCommand String, defining the sketcher in local
490 * coordinates of the working plane.
491 * \param theWorkingPlane Planar Face of the working plane.
492 * \return New GEOM_Object, containing the created wire.
494 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
495 if CurvesOp.IsDone() == 0:
496 print "MakeSketcher : ", CurvesOp.GetErrorCode()
499 # -----------------------------------------------------------------------------
500 # Create 3D Primitives
501 # -----------------------------------------------------------------------------
503 def MakeBox(x1,y1,z1,x2,y2,z2):
505 * Create a box by coordinates of two opposite vertices.
507 * Example: see GEOM_TestAll.py
509 pnt1 = MakeVertex(x1,y1,z1)
510 pnt2 = MakeVertex(x2,y2,z2)
511 return MakeBoxTwoPnt(pnt1,pnt2)
513 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
515 * Create a box with specified dimensions along the coordinate axes
516 * and with edges, parallel to the coordinate axes.
517 * Center of the box will be at point (DX/2, DY/2, DZ/2).
518 * \param theDX Length of Box edges, parallel to OX axis.
519 * \param theDY Length of Box edges, parallel to OY axis.
520 * \param theDZ Length of Box edges, parallel to OZ axis.
521 * \return New GEOM_Object, containing the created box.
523 * Example: see GEOM_TestAll.py
525 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
526 if PrimOp.IsDone() == 0:
527 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
530 def MakeBoxTwoPnt(thePnt1, thePnt2):
532 * Create a box with two specified opposite vertices,
533 * and with edges, parallel to the coordinate axes
534 * \param thePnt1 First of two opposite vertices.
535 * \param thePnt2 Second of two opposite vertices.
536 * \return New GEOM_Object, containing the created box.
538 * Example: see GEOM_TestAll.py
540 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
541 if PrimOp.IsDone() == 0:
542 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
545 def MakeCylinder(thePnt, theAxis, theR, theH):
547 * Create a cylinder with given base point, axis, radius and height.
548 * \param thePnt Central point of cylinder base.
549 * \param theAxis Cylinder axis.
550 * \param theR Cylinder radius.
551 * \param theH Cylinder height.
552 * \return New GEOM_Object, containing the created cylinder.
554 * Example: see GEOM_TestAll.py
556 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
557 if PrimOp.IsDone() == 0:
558 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
561 def MakeCylinderRH(theR, theH):
563 * Create a cylinder with given radius and height at
564 * the origin of coordinate system. Axis of the cylinder
565 * will be collinear to the OZ axis of the coordinate system.
566 * \param theR Cylinder radius.
567 * \param theH Cylinder height.
568 * \return New GEOM_Object, containing the created cylinder.
570 * Example: see GEOM_TestAll.py
572 anObj = PrimOp.MakeCylinderRH(theR, theH)
573 if PrimOp.IsDone() == 0:
574 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
577 def MakeSpherePntR(thePnt, theR):
579 * Create a sphere with given center and radius.
580 * \param thePnt Sphere center.
581 * \param theR Sphere radius.
582 * \return New GEOM_Object, containing the created sphere.
584 * Example: see GEOM_TestAll.py
586 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
587 if PrimOp.IsDone() == 0:
588 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
591 def MakeSphere(x, y, z, theR):
593 * Create a sphere with given center and radius.
594 * \param x,y,z Coordinates of sphere center.
595 * \param theR Sphere radius.
596 * \return New GEOM_Object, containing the created sphere.
598 * Example: see GEOM_TestAll.py
600 point = MakeVertex(x, y, z)
601 anObj = MakeSpherePntR(point, theR)
604 def MakeSphereR(theR):
606 * Create a sphere with given radius at the origin of coordinate system.
607 * \param theR Sphere radius.
608 * \return New GEOM_Object, containing the created sphere.
610 * Example: see GEOM_TestAll.py
612 anObj = PrimOp.MakeSphereR(theR)
613 if PrimOp.IsDone() == 0:
614 print "MakeSphereR : ", PrimOp.GetErrorCode()
617 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
619 * Create a cone with given base point, axis, height and radiuses.
620 * \param thePnt Central point of the first cone base.
621 * \param theAxis Cone axis.
622 * \param theR1 Radius of the first cone base.
623 * \param theR2 Radius of the second cone base.
624 * \note If both radiuses are non-zero, the cone will be truncated.
625 * \note If the radiuses are equal, a cylinder will be created instead.
626 * \param theH Cone height.
627 * \return New GEOM_Object, containing the created cone.
629 * Example: see GEOM_TestAll.py
631 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
632 if PrimOp.IsDone() == 0:
633 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
636 def MakeConeR1R2H(theR1, theR2, theH):
638 * Create a cone with given height and radiuses at
639 * the origin of coordinate system. Axis of the cone will
640 * be collinear to the OZ axis of the coordinate system.
641 * \param theR1 Radius of the first cone base.
642 * \param theR2 Radius of the second cone base.
643 * \note If both radiuses are non-zero, the cone will be truncated.
644 * \note If the radiuses are equal, a cylinder will be created instead.
645 * \param theH Cone height.
646 * \return New GEOM_Object, containing the created cone.
648 * Example: see GEOM_TestAll.py
650 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
651 if PrimOp.IsDone() == 0:
652 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
655 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
657 * Create a torus with given center, normal vector and radiuses.
658 * \param thePnt Torus central point.
659 * \param theVec Torus axis of symmetry.
660 * \param theRMajor Torus major radius.
661 * \param theRMinor Torus minor radius.
662 * \return New GEOM_Object, containing the created torus.
664 * Example: see GEOM_TestAll.py
666 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
667 if PrimOp.IsDone() == 0:
668 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
671 def MakeTorusRR(theRMajor, theRMinor):
673 * Create a torus with given radiuses at the origin of coordinate system.
674 * \param theRMajor Torus major radius.
675 * \param theRMinor Torus minor radius.
676 * \return New GEOM_Object, containing the created torus.
678 * Example: see GEOM_TestAll.py
680 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
681 if PrimOp.IsDone() == 0:
682 print "MakeTorusRR : ", PrimOp.GetErrorCode()
685 def MakePrism(theBase, thePoint1, thePoint2):
687 * Create a shape by extrusion of the base shape along a vector, defined by two points.
688 * \param theBase Base shape to be extruded.
689 * \param thePoint1 First end of extrusion vector.
690 * \param thePoint2 Second end of extrusion vector.
691 * \return New GEOM_Object, containing the created prism.
693 * Example: see GEOM_TestAll.py
695 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
696 if PrimOp.IsDone() == 0:
697 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
700 def MakePrismVecH(theBase, theVec, theH):
702 * Create a shape by extrusion of the base shape along the vector,
703 * i.e. all the space, transfixed by the base shape during its translation
704 * along the vector on the given distance.
705 * \param theBase Base shape to be extruded.
706 * \param theVec Direction of extrusion.
707 * \param theH Prism dimension along theVec.
708 * \return New GEOM_Object, containing the created prism.
710 * Example: see GEOM_TestAll.py
712 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
713 if PrimOp.IsDone() == 0:
714 print "MakePrismVecH : ", PrimOp.GetErrorCode()
717 def MakePipe(theBase, thePath):
719 * Create a shape by extrusion of the base shape along
720 * the path shape. The path shape can be a wire or an edge.
721 * \param theBase Base shape to be extruded.
722 * \param thePath Path shape to extrude the base shape along it.
723 * \return New GEOM_Object, containing the created pipe.
725 * Example: see GEOM_TestAll.py
727 anObj = PrimOp.MakePipe(theBase, thePath)
728 if PrimOp.IsDone() == 0:
729 print "MakePipe : ", PrimOp.GetErrorCode()
732 def MakeRevolution(theBase, theAxis, theAngle):
734 * Create a shape by revolution of the base shape around the axis
735 * on the given angle, i.e. all the space, transfixed by the base
736 * shape during its rotation around the axis on the given angle.
737 * \param theBase Base shape to be rotated.
738 * \param theAxis Rotation axis.
739 * \param theAngle Rotation angle in radians.
740 * \return New GEOM_Object, containing the created revolution.
742 * Example: see GEOM_TestAll.py
744 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
745 if PrimOp.IsDone() == 0:
746 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
749 # -----------------------------------------------------------------------------
751 # -----------------------------------------------------------------------------
753 def MakeEdge(thePnt1, thePnt2):
755 * Create a linear edge with specified ends.
756 * \param thePnt1 Point for the first end of edge.
757 * \param thePnt2 Point for the second end of edge.
758 * \return New GEOM_Object, containing the created edge.
760 * Example: see GEOM_TestAll.py
762 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
763 if ShapesOp.IsDone() == 0:
764 print "MakeEdge : ", ShapesOp.GetErrorCode()
767 def MakeWire(theEdgesAndWires):
769 * Create a wire from the set of edges and wires.
770 * \param theEdgesAndWires List of edges and/or wires.
771 * \return New GEOM_Object, containing the created wire.
773 * Example: see GEOM_TestAll.py
775 anObj = ShapesOp.MakeWire(theEdgesAndWires)
776 if ShapesOp.IsDone() == 0:
777 print "MakeWire : ", ShapesOp.GetErrorCode()
780 def MakeFace(theWire, isPlanarWanted):
782 * Create a face on the given wire.
783 * \param theWire Wire to build the face on.
784 * \param isPlanarWanted If TRUE, only planar face will be built.
785 * If impossible, NULL object will be returned.
786 * \return New GEOM_Object, containing the created face.
788 * Example: see GEOM_TestAll.py
790 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
791 if ShapesOp.IsDone() == 0:
792 print "MakeFace : ", ShapesOp.GetErrorCode()
795 def MakeFaceWires(theWires, isPlanarWanted):
797 * Create a face on the given wires set.
798 * \param theWires List of wires to build the face on.
799 * \param isPlanarWanted If TRUE, only planar face will be built.
800 * If impossible, NULL object will be returned.
801 * \return New GEOM_Object, containing the created face.
803 * Example: see GEOM_TestAll.py
805 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
806 if ShapesOp.IsDone() == 0:
807 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
810 def MakeFaces(theWires, isPlanarWanted):
812 * Shortcut to MakeFaceWires()
814 * Example: see GEOM_TestOthers.py
816 anObj = MakeFaceWires(theWires, isPlanarWanted)
819 def MakeShell(theFacesAndShells):
821 * Create a shell from the set of faces and shells.
822 * \param theFacesAndShells List of faces and/or shells.
823 * \return New GEOM_Object, containing the created shell.
825 * Example: see GEOM_TestAll.py
827 anObj = ShapesOp.MakeShell(theFacesAndShells)
828 if ShapesOp.IsDone() == 0:
829 print "MakeShell : ", ShapesOp.GetErrorCode()
832 def MakeSolid(theShells):
834 * Create a solid, bounded by the given shells.
835 * \param theShells Sequence of bounding shells.
836 * \return New GEOM_Object, containing the created solid.
838 * Example: see GEOM_TestAll.py
840 anObj = ShapesOp.MakeSolidShells(theShells)
841 if ShapesOp.IsDone() == 0:
842 print "MakeSolid : ", ShapesOp.GetErrorCode()
845 def MakeCompound(theShapes):
847 * Create a compound of the given shapes.
848 * \param theShapes List of shapes to put in compound.
849 * \return New GEOM_Object, containing the created compound.
851 * Example: see GEOM_TestAll.py
853 anObj = ShapesOp.MakeCompound(theShapes)
854 if ShapesOp.IsDone() == 0:
855 print "MakeCompound : ", ShapesOp.GetErrorCode()
858 def NumberOfFaces(theShape):
860 * Gives quantity of faces in the given shape.
861 * \param theShape Shape to count faces of.
862 * \return Quantity of faces.
864 * Example: see GEOM_TestOthers.py
866 nb_faces = ShapesOp.NumberOfFaces(theShape)
867 if ShapesOp.IsDone() == 0:
868 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
871 def NumberOfEdges(theShape):
873 * Gives quantity of edges in the given shape.
874 * \param theShape Shape to count edges of.
875 * \return Quantity of edges.
877 * Example: see GEOM_TestOthers.py
879 nb_edges = ShapesOp.NumberOfEdges(theShape)
880 if ShapesOp.IsDone() == 0:
881 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
884 def ChangeOrientation(theShape):
886 * Reverses an orientation the given shape.
887 * \param theShape Shape to be reversed.
888 * \return The reversed copy of theShape.
890 * Example: see GEOM_TestAll.py
892 anObj = ShapesOp.ChangeOrientation(theShape)
893 if ShapesOp.IsDone() == 0:
894 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
897 def OrientationChange(theShape):
899 * Shortcut to ChangeOrientation()
901 * Example: see GEOM_TestOthers.py
903 anObj = ChangeOrientation(theShape)
906 def GetFreeFacesIDs(theShape):
908 * Retrieve all free faces from the given shape.
909 * Free face is a face, which is not shared between two shells of the shape.
910 * \param theShape Shape to find free faces in.
911 * \return List of IDs of all free faces, contained in theShape.
913 * Example: see GEOM_TestOthers.py
915 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
916 if ShapesOp.IsDone() == 0:
917 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
920 def GetSharedShapes(theShape1, theShape2, theShapeType):
922 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
923 * \param theShape1 Shape to find sub-shapes in.
924 * \param theShape2 Shape to find shared sub-shapes with.
925 * \param theShapeType Type of sub-shapes to be retrieved.
926 * \return List of sub-shapes of theShape1, shared with theShape2.
928 * Example: see GEOM_TestOthers.py
930 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
931 if ShapesOp.IsDone() == 0:
932 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
935 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
937 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
938 * the specified plane by the certain way, defined through \a theState parameter.
939 * \param theShape Shape to find sub-shapes of.
940 * \param theShapeType Type of sub-shapes to be retrieved.
941 * \param theAx1 Vector (or line, or linear edge), specifying normal
942 * direction and location of the plane to find shapes on.
943 * \param theState The state of the subshapes to find. It can be one of
944 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
945 * \return List of all found sub-shapes.
947 * Example: see GEOM_TestOthers.py
949 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
950 if ShapesOp.IsDone() == 0:
951 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
954 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
956 * Works like the above method, but returns list of sub-shapes indices
958 * Example: see GEOM_TestOthers.py
960 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
961 if ShapesOp.IsDone() == 0:
962 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
965 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
967 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
968 * the specified cylinder by the certain way, defined through \a theState parameter.
969 * \param theShape Shape to find sub-shapes of.
970 * \param theShapeType Type of sub-shapes to be retrieved.
971 * \param theAxis Vector (or line, or linear edge), specifying
972 * axis of the cylinder to find shapes on.
973 * \param theRadius Radius of the cylinder to find shapes on.
974 * \param theState The state of the subshapes to find. It can be one of
975 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
976 * \return List of all found sub-shapes.
978 * Example: see GEOM_TestOthers.py
980 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
981 if ShapesOp.IsDone() == 0:
982 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
985 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
987 * Works like the above method, but returns list of sub-shapes indices
989 * Example: see GEOM_TestOthers.py
991 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
992 if ShapesOp.IsDone() == 0:
993 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
996 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
998 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
999 * the specified sphere by the certain way, defined through \a theState parameter.
1000 * \param theShape Shape to find sub-shapes of.
1001 * \param theShapeType Type of sub-shapes to be retrieved.
1002 * \param theCenter Point, specifying center of the sphere to find shapes on.
1003 * \param theRadius Radius of the sphere to find shapes on.
1004 * \param theState The state of the subshapes to find. It can be one of
1005 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1006 * \return List of all found sub-shapes.
1008 * Example: see GEOM_TestOthers.py
1010 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1011 if ShapesOp.IsDone() == 0:
1012 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1015 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1017 * Works like the above method, but returns list of sub-shapes indices
1019 * Example: see GEOM_TestOthers.py
1021 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1022 if ShapesOp.IsDone() == 0:
1023 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1026 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1028 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1029 * the specified quadrangle by the certain way, defined through \a theState parameter.
1030 * \param theShape Shape to find sub-shapes of.
1031 * \param theShapeType Type of sub-shapes to be retrieved.
1032 * \param theCenter Point, specifying center of the sphere to find shapes on.
1033 * \param theRadius Radius of the sphere to find shapes on.
1034 * \param theState The state of the subshapes to find. It can be one of
1035 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1036 * \return List of all found sub-shapes.
1038 * Example: see GEOM_TestOthers.py
1040 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1041 if ShapesOp.IsDone() == 0:
1042 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1045 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1047 * Works like the above method, but returns list of sub-shapes indices
1049 * Example: see GEOM_TestOthers.py
1051 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1052 if ShapesOp.IsDone() == 0:
1053 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1056 def GetInPlace(theShapeWhere, theShapeWhat):
1058 * Get sub-shape(s) of theShapeWhere, which are
1059 * coincident with \a theShapeWhat or could be a part of it.
1060 * \param theShapeWhere Shape to find sub-shapes of.
1061 * \param theShapeWhat Shape, specifying what to find.
1062 * \return Group of all found sub-shapes or a single found sub-shape.
1064 * Example: see GEOM_TestOthers.py
1066 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1067 if ShapesOp.IsDone() == 0:
1068 print "GetInPlace : ", ShapesOp.GetErrorCode()
1071 # -----------------------------------------------------------------------------
1072 # Access to sub-shapes by their unique IDs inside the main shape.
1073 # -----------------------------------------------------------------------------
1075 def GetSubShape(aShape, ListOfID):
1077 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1078 * of <aShape>, selected by their unique IDs inside <aShape>
1080 * Example: see GEOM_TestAll.py
1082 anObj = geom.AddSubShape(aShape,ListOfID)
1085 def GetSubShapeID(aShape, aSubShape):
1087 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1089 * Example: see GEOM_TestAll.py
1091 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1092 if LocalOp.IsDone() == 0:
1093 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1096 # -----------------------------------------------------------------------------
1098 # -----------------------------------------------------------------------------
1100 def SubShapeAll(aShape, aType):
1102 * Explode a shape on subshapes of a given type.
1103 * \param theShape Shape to be exploded.
1104 * \param theShapeType Type of sub-shapes to be retrieved.
1105 * \return List of sub-shapes of type theShapeType, contained in theShape.
1107 * Example: see GEOM_TestAll.py
1109 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1110 if ShapesOp.IsDone() == 0:
1111 print "MakeExplode : ", ShapesOp.GetErrorCode()
1114 def SubShapeAllIDs(aShape, aType):
1116 * Explode a shape on subshapes of a given type.
1117 * \param theShape Shape to be exploded.
1118 * \param theShapeType Type of sub-shapes to be retrieved.
1119 * \return List of IDs of sub-shapes.
1121 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1122 if ShapesOp.IsDone() == 0:
1123 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1126 def SubShapeAllSorted(aShape, aType):
1128 * Explode a shape on subshapes of a given type.
1129 * Sub-shapes will be sorted by coordinates of their gravity centers.
1130 * \param theShape Shape to be exploded.
1131 * \param theShapeType Type of sub-shapes to be retrieved.
1132 * \return List of sub-shapes of type theShapeType, contained in theShape.
1134 * Example: see GEOM_TestAll.py
1136 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1137 if ShapesOp.IsDone() == 0:
1138 print "MakeExplode : ", ShapesOp.GetErrorCode()
1141 def SubShapeAllSortedIDs(aShape, aType):
1143 * Explode a shape on subshapes of a given type.
1144 * Sub-shapes will be sorted by coordinates of their gravity centers.
1145 * \param theShape Shape to be exploded.
1146 * \param theShapeType Type of sub-shapes to be retrieved.
1147 * \return List of IDs of sub-shapes.
1149 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1150 if ShapesOp.IsDone() == 0:
1151 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1154 def SubShape(aShape, aType, ListOfInd):
1156 * Obtain a compound of sub-shapes of <aShape>,
1157 * selected by they indices in list of all sub-shapes of type <aType>.
1158 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1160 * Example: see GEOM_TestAll.py
1163 AllShapeList = SubShapeAll(aShape, aType)
1164 for ind in ListOfInd:
1165 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1166 anObj = GetSubShape(aShape, ListOfIDs)
1169 def SubShapeSorted(aShape, aType, ListOfInd):
1171 * Obtain a compound of sub-shapes of <aShape>,
1172 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1173 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1175 * Example: see GEOM_TestAll.py
1178 AllShapeList = SubShapeAllSorted(aShape, aType)
1179 for ind in ListOfInd:
1180 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1181 anObj = GetSubShape(aShape, ListOfIDs)
1184 # -----------------------------------------------------------------------------
1185 # Healing operations
1186 # -----------------------------------------------------------------------------
1188 def ProcessShape(theShape, theOperators, theParameters, theValues):
1190 * Apply a sequence of Shape Healing operators to the given object.
1191 * \param theShape Shape to be processed.
1192 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1193 * \param theParameters List of names of parameters
1194 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1195 * \param theValues List of values of parameters, in the same order
1196 * as parameters are listed in \a theParameters list.
1197 * \return New GEOM_Object, containing processed shape.
1199 * Example: see GEOM_TestHealing.py
1201 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1202 if HealOp.IsDone() == 0:
1203 print "ProcessShape : ", HealOp.GetErrorCode()
1206 def SuppressFaces(theObject, theFaces):
1208 * Remove faces from the given object (shape).
1209 * \param theObject Shape to be processed.
1210 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1211 * removes ALL faces of the given object.
1212 * \return New GEOM_Object, containing processed shape.
1214 * Example: see GEOM_TestHealing.py
1216 anObj = HealOp.SuppressFaces(theObject, theFaces)
1217 if HealOp.IsDone() == 0:
1218 print "SuppressFaces : ", HealOp.GetErrorCode()
1221 def MakeSewing(ListShape, theTolerance):
1223 * Sewing of some shapes into single shape.
1225 * Example: see GEOM_TestHealing.py
1227 comp = MakeCompound(ListShape)
1228 anObj = Sew(comp, theTolerance)
1231 def Sew(theObject, theTolerance):
1233 * Sewing of the given object.
1234 * \param theObject Shape to be processed.
1235 * \param theTolerance Required tolerance value.
1236 * \return New GEOM_Object, containing processed shape.
1238 * Example: see MakeSewing() above
1240 anObj = HealOp.Sew(theObject, theTolerance)
1241 if HealOp.IsDone() == 0:
1242 print "Sew : ", HealOp.GetErrorCode()
1245 def SuppressInternalWires(theObject, theWires):
1247 * Remove internal wires and edges from the given object (face).
1248 * \param theObject Shape to be processed.
1249 * \param theWires Indices of wires to be removed, if EMPTY then the method
1250 * removes ALL internal wires of the given object.
1251 * \return New GEOM_Object, containing processed shape.
1253 * Example: see GEOM_TestHealing.py
1255 anObj = HealOp.RemoveIntWires(theObject, theWires)
1256 if HealOp.IsDone() == 0:
1257 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1260 def SuppressHoles(theObject, theWires):
1262 * Remove internal closed contours (holes) from the given object.
1263 * \param theObject Shape to be processed.
1264 * \param theWires Indices of wires to be removed, if EMPTY then the method
1265 * removes ALL internal holes of the given object
1266 * \return New GEOM_Object, containing processed shape.
1268 * Example: see GEOM_TestHealing.py
1270 anObj = HealOp.FillHoles(theObject, theWires)
1271 if HealOp.IsDone() == 0:
1272 print "SuppressHoles : ", HealOp.GetErrorCode()
1275 def CloseContour(theObject, theWires, isCommonVertex):
1277 * Close an open wire.
1278 * \param theObject Shape to be processed.
1279 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1280 * if -1, then theObject itself is a wire.
1281 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1282 * If FALS : closure by creation of an edge between ends.
1283 * \return New GEOM_Object, containing processed shape.
1285 * Example: see GEOM_TestHealing.py
1287 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1288 if HealOp.IsDone() == 0:
1289 print "CloseContour : ", HealOp.GetErrorCode()
1292 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1294 * Addition of a point to a given edge object.
1295 * \param theObject Shape to be processed.
1296 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1297 * if -1, then theObject itself is the edge.
1298 * \param theValue Value of parameter on edge or length parameter,
1299 * depending on \a isByParameter.
1300 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1301 * if FALSE : \a theValue is treated as a length parameter [0..1]
1302 * \return New GEOM_Object, containing processed shape.
1304 * Example: see GEOM_TestHealing.py
1306 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1307 if HealOp.IsDone() == 0:
1308 print "DivideEdge : ", HealOp.GetErrorCode()
1311 def GetFreeBoundary(theObject):
1313 * Get a list of wires (wrapped in GEOM_Object-s),
1314 * that constitute a free boundary of the given shape.
1315 * \param theObject Shape to get free boundary of.
1316 * \return [status, theClosedWires, theOpenWires]
1317 * status: FALSE, if an error(s) occured during the method execution.
1318 * theClosedWires: Closed wires on the free boundary of the given shape.
1319 * theOpenWires: Open wires on the free boundary of the given shape.
1321 * Example: see GEOM_TestHealing.py
1323 anObj = HealOp.GetFreeBoundary(theObject)
1324 if HealOp.IsDone() == 0:
1325 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1328 # -----------------------------------------------------------------------------
1329 # Create advanced objects
1330 # -----------------------------------------------------------------------------
1332 def MakeCopy(theOriginal):
1334 * Create a copy of the given object
1336 * Example: see GEOM_TestAll.py
1338 anObj = InsertOp.MakeCopy(theOriginal)
1339 if InsertOp.IsDone() == 0:
1340 print "MakeCopy : ", InsertOp.GetErrorCode()
1343 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1345 * Create a filling from the given compound of contours.
1346 * \param theShape the compound of contours
1347 * \param theMinDeg a minimal degree
1348 * \param theMaxDeg a maximal degree
1349 * \param theTol2D a 2d tolerance
1350 * \param theTol3D a 3d tolerance
1351 * \param theNbIter a number of iteration
1352 * \return New GEOM_Object, containing the created filling surface.
1354 * Example: see GEOM_TestAll.py
1356 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1357 if PrimOp.IsDone() == 0:
1358 print "MakeFilling : ", PrimOp.GetErrorCode()
1361 def MakeGlueFaces(theShape, theTolerance):
1363 * Replace coincident faces in theShape by one face.
1364 * \param theShape Initial shape.
1365 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1366 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1368 * Example: see GEOM_Spanner.py
1370 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1371 if ShapesOp.IsDone() == 0:
1372 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1375 # -----------------------------------------------------------------------------
1376 # Boolean (Common, Cut, Fuse, Section)
1377 # -----------------------------------------------------------------------------
1379 def MakeBoolean(theShape1, theShape2, theOperation):
1381 * Perform one of boolean operations on two given shapes.
1382 * \param theShape1 First argument for boolean operation.
1383 * \param theShape2 Second argument for boolean operation.
1384 * \param theOperation Indicates the operation to be done:
1385 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1386 * \return New GEOM_Object, containing the result shape.
1388 * Example: see GEOM_TestAll.py
1390 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1391 if BoolOp.IsDone() == 0:
1392 print "MakeBoolean : ", BoolOp.GetErrorCode()
1395 def MakeCommon(s1, s2):
1397 * Shortcut to MakeBoolean(s1, s2, 1)
1399 * Example: see GEOM_TestOthers.py
1401 return MakeBoolean(s1, s2, 1)
1403 def MakeCut(s1, s2):
1405 * Shortcut to MakeBoolean(s1, s2, 2)
1407 * Example: see GEOM_TestOthers.py
1409 return MakeBoolean(s1, s2, 2)
1411 def MakeFuse(s1, s2):
1413 * Shortcut to MakeBoolean(s1, s2, 3)
1415 * Example: see GEOM_TestOthers.py
1417 return MakeBoolean(s1, s2, 3)
1419 def MakeSection(s1, s2):
1421 * Shortcut to MakeBoolean(s1, s2, 4)
1423 * Example: see GEOM_TestOthers.py
1425 return MakeBoolean(s1, s2, 4)
1427 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1428 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1430 * Perform partition operation.
1431 * \param ListShapes Shapes to be intersected.
1432 * \param ListTools Shapes to intersect theShapes.
1433 * \param ListKeepInside Shapes, outside which the results will be deleted.
1434 * Each shape from theKeepInside must belong to theShapes also.
1435 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1436 * Each shape from theRemoveInside must belong to theShapes also.
1437 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1438 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1439 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1440 * \return New GEOM_Object, containing the result shapes.
1442 * Example: see GEOM_TestAll.py
1444 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1445 ListKeepInside, ListRemoveInside,
1446 Limit, RemoveWebs, ListMaterials);
1447 if BoolOp.IsDone() == 0:
1448 print "MakePartition : ", BoolOp.GetErrorCode()
1451 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1452 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1454 * Shortcut to MakePartition()
1456 * Example: see GEOM_TestOthers.py
1458 anObj = MakePartition(ListShapes, ListTools,
1459 ListKeepInside, ListRemoveInside,
1460 Limit, RemoveWebs, ListMaterials);
1463 def MakeHalfPartition(theShape, thePlane):
1465 * Perform partition of the Shape with the Plane
1466 * \param theShape Shape to be intersected.
1467 * \param thePlane Tool shape, to intersect theShape.
1468 * \return New GEOM_Object, containing the result shape.
1470 * Example: see GEOM_TestAll.py
1472 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1473 if BoolOp.IsDone() == 0:
1474 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1477 # -----------------------------------------------------------------------------
1479 # -----------------------------------------------------------------------------
1481 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1483 * Translate the given object along the vector, specified
1484 * by its end points, creating its copy before the translation.
1485 * \param theObject The object to be translated.
1486 * \param thePoint1 Start point of translation vector.
1487 * \param thePoint2 End point of translation vector.
1488 * \return New GEOM_Object, containing the translated object.
1490 * Example: see GEOM_TestAll.py
1492 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1493 if TrsfOp.IsDone() == 0:
1494 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1497 def MakeTranslation(theObject, theDX, theDY, theDZ):
1499 * Translate the given object along the vector, specified
1500 * by its components, creating its copy before the translation.
1501 * \param theObject The object to be translated.
1502 * \param theDX,theDY,theDZ Components of translation vector.
1503 * \return New GEOM_Object, containing the translated object.
1505 * Example: see GEOM_TestAll.py
1507 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1508 if TrsfOp.IsDone() == 0:
1509 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1512 def MakeTranslationVector(theObject, theVector):
1514 * Translate the given object along the given vector,
1515 * creating its copy before the translation.
1516 * \param theObject The object to be translated.
1517 * \param theVector The translation vector.
1518 * \return New GEOM_Object, containing the translated object.
1520 * Example: see GEOM_TestAll.py
1522 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1523 if TrsfOp.IsDone() == 0:
1524 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1527 def MakeRotation(theObject, theAxis, theAngle):
1529 * Rotate the given object around the given axis
1530 * on the given angle, creating its copy before the rotatation.
1531 * \param theObject The object to be rotated.
1532 * \param theAxis Rotation axis.
1533 * \param theAngle Rotation angle in radians.
1534 * \return New GEOM_Object, containing the rotated object.
1536 * Example: see GEOM_TestAll.py
1538 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1539 if TrsfOp.IsDone() == 0:
1540 print "RotateCopy : ", TrsfOp.GetErrorCode()
1543 def MakeScaleTransform(theObject, thePoint, theFactor):
1545 * Scale the given object by the factor, creating its copy before the scaling.
1546 * \param theObject The object to be scaled.
1547 * \param thePoint Center point for scaling.
1548 * \param theFactor Scaling factor value.
1549 * \return New GEOM_Object, containing the scaled shape.
1551 * Example: see GEOM_TestAll.py
1553 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1554 if TrsfOp.IsDone() == 0:
1555 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1558 def MakeMirrorByPlane(theObject, thePlane):
1560 * Create an object, symmetrical
1561 * to the given one relatively the given plane.
1562 * \param theObject The object to be mirrored.
1563 * \param thePlane Plane of symmetry.
1564 * \return New GEOM_Object, containing the mirrored shape.
1566 * Example: see GEOM_TestAll.py
1568 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1569 if TrsfOp.IsDone() == 0:
1570 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1573 def MakeMirrorByAxis(theObject, theAxis):
1575 * Create an object, symmetrical
1576 * to the given one relatively the given axis.
1577 * \param theObject The object to be mirrored.
1578 * \param theAxis Axis of symmetry.
1579 * \return New GEOM_Object, containing the mirrored shape.
1581 * Example: see GEOM_TestAll.py
1583 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1584 if TrsfOp.IsDone() == 0:
1585 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1588 def MakeMirrorByPoint(theObject, thePoint):
1590 * Create an object, symmetrical
1591 * to the given one relatively the given point.
1592 * \param theObject The object to be mirrored.
1593 * \param thePoint Point of symmetry.
1594 * \return New GEOM_Object, containing the mirrored shape.
1596 * Example: see GEOM_TestAll.py
1598 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1599 if TrsfOp.IsDone() == 0:
1600 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1603 def MakePosition(theObject, theStartLCS, theEndLCS):
1605 * Modify the Location of the given object by LCS
1606 * creating its copy before the setting
1608 * Example: see GEOM_TestAll.py
1610 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1611 if TrsfOp.IsDone() == 0:
1612 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1615 def MakeOffset(theObject, theOffset):
1617 * Create new object as offset of the given one.
1618 * \param theObject The base object for the offset.
1619 * \param theOffset Offset value.
1620 * \return New GEOM_Object, containing the offset object.
1622 * Example: see GEOM_TestAll.py
1624 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1625 if TrsfOp.IsDone() == 0:
1626 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1629 # -----------------------------------------------------------------------------
1631 # -----------------------------------------------------------------------------
1633 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1635 * Translate the given object along the given vector a given number times
1636 * \param theObject The object to be translated.
1637 * \param theVector Direction of the translation.
1638 * \param theStep Distance to translate on.
1639 * \param theNbTimes Quantity of translations to be done.
1640 * \return New GEOM_Object, containing compound of all
1641 * the shapes, obtained after each translation.
1643 * Example: see GEOM_TestAll.py
1645 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1646 if TrsfOp.IsDone() == 0:
1647 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1650 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1651 theVector2, theStep2, theNbTimes2):
1653 * Conseqently apply two specified translations to theObject specified number of times.
1654 * \param theObject The object to be translated.
1655 * \param theVector1 Direction of the first translation.
1656 * \param theStep1 Step of the first translation.
1657 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1658 * \param theVector2 Direction of the second translation.
1659 * \param theStep2 Step of the second translation.
1660 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1661 * \return New GEOM_Object, containing compound of all
1662 * the shapes, obtained after each translation.
1664 * Example: see GEOM_TestAll.py
1666 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1667 theVector2, theStep2, theNbTimes2)
1668 if TrsfOp.IsDone() == 0:
1669 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1672 def MultiRotate1D(theObject, theAxis, theNbTimes):
1674 * Rotate the given object around the given axis a given number times.
1675 * Rotation angle will be 2*PI/theNbTimes.
1676 * \param theObject The object to be rotated.
1677 * \param theAxis The rotation axis.
1678 * \param theNbTimes Quantity of rotations to be done.
1679 * \return New GEOM_Object, containing compound of all the
1680 * shapes, obtained after each rotation.
1682 * Example: see GEOM_TestAll.py
1684 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1685 if TrsfOp.IsDone() == 0:
1686 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1689 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1691 * Rotate the given object around the
1692 * given axis on the given angle a given number
1693 * times and multi-translate each rotation result.
1694 * Translation direction passes through center of gravity
1695 * of rotated shape and its projection on the rotation axis.
1696 * \param theObject The object to be rotated.
1697 * \param theAxis Rotation axis.
1698 * \param theAngle Rotation angle in graduces.
1699 * \param theNbTimes1 Quantity of rotations to be done.
1700 * \param theStep Translation distance.
1701 * \param theNbTimes2 Quantity of translations to be done.
1702 * \return New GEOM_Object, containing compound of all the
1703 * shapes, obtained after each transformation.
1705 * Example: see GEOM_TestAll.py
1707 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1708 if TrsfOp.IsDone() == 0:
1709 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1712 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1714 * The same, as MultiRotate1D(), but axis is given by direction and point
1716 * Example: see GEOM_TestOthers.py
1718 aVec = MakeLine(aPoint,aDir)
1719 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1722 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1724 * The same, as MultiRotate2D(), but axis is given by direction and point
1726 * Example: see GEOM_TestOthers.py
1728 aVec = MakeLine(aPoint,aDir)
1729 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1732 # -----------------------------------------------------------------------------
1734 # -----------------------------------------------------------------------------
1736 def MakeFilletAll(theShape, theR):
1738 * Perform a fillet on all edges of the given shape.
1739 * \param theShape Shape, to perform fillet on.
1740 * \param theR Fillet radius.
1741 * \return New GEOM_Object, containing the result shape.
1743 * Example: see GEOM_TestOthers.py
1745 anObj = LocalOp.MakeFilletAll(theShape, theR)
1746 if LocalOp.IsDone() == 0:
1747 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1750 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1752 * Perform a fillet on the specified edges/faces of the given shape
1753 * \param theShape Shape, to perform fillet on.
1754 * \param theR Fillet radius.
1755 * \param theShapeType Type of shapes in <theListShapes>.
1756 * \param theListShapes Global indices of edges/faces to perform fillet on.
1757 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1758 * \return New GEOM_Object, containing the result shape.
1760 * Example: see GEOM_TestAll.py
1763 if theShapeType == ShapeType["EDGE"]:
1764 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1766 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1767 if LocalOp.IsDone() == 0:
1768 print "MakeFillet : ", LocalOp.GetErrorCode()
1771 def MakeChamferAll(theShape, theD):
1773 * Perform a symmetric chamfer on all edges of the given shape.
1774 * \param theShape Shape, to perform chamfer on.
1775 * \param theD Chamfer size along each face.
1776 * \return New GEOM_Object, containing the result shape.
1778 * Example: see GEOM_TestOthers.py
1780 anObj = LocalOp.MakeChamferAll(theShape, theD)
1781 if LocalOp.IsDone() == 0:
1782 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1785 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1787 * Perform a chamfer on edges, common to the specified faces,
1788 * with distance D1 on the Face1
1789 * \param theShape Shape, to perform chamfer on.
1790 * \param theD1 Chamfer size along \a theFace1.
1791 * \param theD2 Chamfer size along \a theFace2.
1792 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1793 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1794 * \return New GEOM_Object, containing the result shape.
1796 * Example: see GEOM_TestAll.py
1798 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1799 if LocalOp.IsDone() == 0:
1800 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1803 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1805 * Perform a chamfer on all edges of the specified faces,
1806 * with distance D1 on the first specified face (if several for one edge)
1807 * \param theShape Shape, to perform chamfer on.
1808 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1809 * connected to the edge, are in \a theFaces, \a theD1
1810 * will be get along face, which is nearer to \a theFaces beginning.
1811 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1812 * \param theFaces Sequence of global indices of faces of \a theShape.
1813 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1814 * \return New GEOM_Object, containing the result shape.
1816 * Example: see GEOM_TestAll.py
1818 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1819 if LocalOp.IsDone() == 0:
1820 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1823 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1825 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1827 * Example: see GEOM_TestOthers.py
1830 if aShapeType == ShapeType["EDGE"]:
1831 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1833 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1836 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1838 * Perform an Archimde operation on the given shape with given parameters.
1839 * The object presenting the resulting face is returned
1840 * \param theShape Shape to be put in water.
1841 * \param theWeight Weight og the shape.
1842 * \param theWaterDensity Density of the water.
1843 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1844 * \return New GEOM_Object, containing a section of \a theShape
1845 * by a plane, corresponding to water level.
1847 * Example: see GEOM_TestAll.py
1849 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1850 if LocalOp.IsDone() == 0:
1851 print "MakeArchimede : ", LocalOp.GetErrorCode()
1854 # -----------------------------------------------------------------------------
1855 # Information objects
1856 # -----------------------------------------------------------------------------
1858 def PointCoordinates(Point):
1860 * Get point coordinates
1863 * Example: see GEOM_TestMeasures.py
1865 aTuple = MeasuOp.PointCoordinates(Point)
1866 if MeasuOp.IsDone() == 0:
1867 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1870 def BasicProperties(theShape):
1872 * Get summarized length of all wires,
1873 * area of surface and volume of the given shape.
1874 * \param theShape Shape to define properties of.
1875 * \return [theLength, theSurfArea, theVolume]
1876 * theLength: Summarized length of all wires of the given shape.
1877 * theSurfArea: Area of surface of the given shape.
1878 * theVolume: Volume of the given shape.
1880 * Example: see GEOM_TestMeasures.py
1882 aTuple = MeasuOp.GetBasicProperties(theShape)
1883 if MeasuOp.IsDone() == 0:
1884 print "BasicProperties : ", MeasuOp.GetErrorCode()
1887 def BoundingBox(theShape):
1889 * Get parameters of bounding box of the given shape
1890 * \param theShape Shape to obtain bounding box of.
1891 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1892 * Xmin,Xmax: Limits of shape along OX axis.
1893 * Ymin,Ymax: Limits of shape along OY axis.
1894 * Zmin,Zmax: Limits of shape along OZ axis.
1896 * Example: see GEOM_TestMeasures.py
1898 aTuple = MeasuOp.GetBoundingBox(theShape)
1899 if MeasuOp.IsDone() == 0:
1900 print "BoundingBox : ", MeasuOp.GetErrorCode()
1903 def Inertia(theShape):
1905 * Get inertia matrix and moments of inertia of theShape.
1906 * \param theShape Shape to calculate inertia of.
1907 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1908 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1909 * Ix,Iy,Iz: Moments of inertia of the given shape.
1911 * Example: see GEOM_TestMeasures.py
1913 aTuple = MeasuOp.GetInertia(theShape)
1914 if MeasuOp.IsDone() == 0:
1915 print "Inertia : ", MeasuOp.GetErrorCode()
1918 def MinDistance(theShape1, theShape2):
1920 * Get minimal distance between the given shapes.
1921 * \param theShape1,theShape2 Shapes to find minimal distance between.
1922 * \return Value of the minimal distance between the given shapes.
1924 * Example: see GEOM_TestMeasures.py
1926 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1927 if MeasuOp.IsDone() == 0:
1928 print "MinDistance : ", MeasuOp.GetErrorCode()
1931 def Tolerance(theShape):
1933 * Get min and max tolerances of sub-shapes of theShape
1934 * \param theShape Shape, to get tolerances of.
1935 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1936 * FaceMin,FaceMax: Min and max tolerances of the faces.
1937 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1938 * VertMin,VertMax: Min and max tolerances of the vertices.
1940 * Example: see GEOM_TestMeasures.py
1942 aTuple = MeasuOp.GetTolerance(theShape)
1943 if MeasuOp.IsDone() == 0:
1944 print "Tolerance : ", MeasuOp.GetErrorCode()
1947 def WhatIs(theShape):
1949 * Obtain description of the given shape (number of sub-shapes of each type)
1950 * \param theShape Shape to be described.
1951 * \return Description of the given shape.
1953 * Example: see GEOM_TestMeasures.py
1955 aDescr = MeasuOp.WhatIs(theShape)
1956 if MeasuOp.IsDone() == 0:
1957 print "WhatIs : ", MeasuOp.GetErrorCode()
1960 def MakeCDG(theShape):
1962 * Get a point, situated at the centre of mass of theShape.
1963 * \param theShape Shape to define centre of mass of.
1964 * \return New GEOM_Object, containing the created point.
1966 * Example: see GEOM_TestMeasures.py
1968 anObj = MeasuOp.GetCentreOfMass(theShape)
1969 if MeasuOp.IsDone() == 0:
1970 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1973 def CheckShape(theShape):
1975 * Check a topology of the given shape.
1976 * \param theShape Shape to check validity of.
1977 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1978 * If theShape is invalid, prints a description of problem.
1980 * Example: see GEOM_TestMeasures.py
1982 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1983 if MeasuOp.IsDone() == 0:
1984 print "CheckShape : ", MeasuOp.GetErrorCode()
1990 # -----------------------------------------------------------------------------
1991 # Import/Export objects
1992 # -----------------------------------------------------------------------------
1994 def Import(theFileName, theFormatName):
1996 * Import a shape from the BREP or IGES or STEP file
1997 * (depends on given format) with given name.
1998 * \param theFileName The file, containing the shape.
1999 * \param theFormatName Specify format for the file reading.
2000 * Available formats can be obtained with InsertOp.ImportTranslators() method.
2001 * \return New GEOM_Object, containing the imported shape.
2003 * Example: see GEOM_TestOthers.py
2005 anObj = InsertOp.Import(theFileName, theFormatName)
2006 if InsertOp.IsDone() == 0:
2007 print "Import : ", InsertOp.GetErrorCode()
2010 def ImportBREP(theFileName):
2012 * Shortcut to Import() for BREP format
2014 * Example: see GEOM_TestOthers.py
2016 return Import(theFileName, "BREP")
2018 def ImportIGES(theFileName):
2020 * Shortcut to Import() for IGES format
2022 * Example: see GEOM_TestOthers.py
2024 return Import(theFileName, "IGES")
2026 def ImportSTEP(theFileName):
2028 * Shortcut to Import() for STEP format
2030 * Example: see GEOM_TestOthers.py
2032 return Import(theFileName, "STEP")
2034 def Export(theObject, theFileName, theFormatName):
2036 * Export the given shape into a file with given name.
2037 * \param theObject Shape to be stored in the file.
2038 * \param theFileName Name of the file to store the given shape in.
2039 * \param theFormatName Specify format for the shape storage.
2040 * Available formats can be obtained with InsertOp.ImportTranslators() method.
2042 * Example: see GEOM_TestOthers.py
2044 InsertOp.Export(theObject, theFileName, theFormatName)
2045 if InsertOp.IsDone() == 0:
2046 print "Export : ", InsertOp.GetErrorCode()
2048 def ExportBREP(theObject, theFileName):
2050 * Shortcut to Export() for BREP format
2052 * Example: see GEOM_TestOthers.py
2054 return Export(theObject, theFileName, "BREP")
2056 def ExportIGES(theObject, theFileName):
2058 * Shortcut to Export() for IGES format
2060 * Example: see GEOM_TestOthers.py
2062 return Export(theObject, theFileName, "IGES")
2064 def ExportSTEP(theObject, theFileName):
2066 * Shortcut to Export() for STEP format
2068 * Example: see GEOM_TestOthers.py
2070 return Export(theObject, theFileName, "STEP")
2072 # -----------------------------------------------------------------------------
2074 # -----------------------------------------------------------------------------
2076 def MakeQuad(E1, E2, E3, E4):
2078 * Create a quadrangle face from four edges. Order of Edges is not
2079 * important. It is not necessary that edges share the same vertex.
2080 * \param E1,E2,E3,E4 Edges for the face bound.
2081 * \return New GEOM_Object, containing the created face.
2083 * Example: see GEOM_Spanner.py
2085 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2086 if BlocksOp.IsDone() == 0:
2087 print "MakeQuad : ", BlocksOp.GetErrorCode()
2090 def MakeQuad2Edges(E1, E2):
2092 * Create a quadrangle face on two edges.
2093 * The missing edges will be built by creating the shortest ones.
2094 * \param E1,E2 Two opposite edges for the face.
2095 * \return New GEOM_Object, containing the created face.
2097 * Example: see GEOM_Spanner.py
2099 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2100 if BlocksOp.IsDone() == 0:
2101 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2104 def MakeQuad4Vertices(V1, V2, V3, V4):
2106 * Create a quadrangle face with specified corners.
2107 * The missing edges will be built by creating the shortest ones.
2108 * \param V1,V2,V3,V4 Corner vertices for the face.
2109 * \return New GEOM_Object, containing the created face.
2111 * Example: see GEOM_Spanner.py
2113 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2114 if BlocksOp.IsDone() == 0:
2115 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2118 def MakeHexa(F1, F2, F3, F4, F5, F6):
2120 * Create a hexahedral solid, bounded by the six given faces. Order of
2121 * faces is not important. It is not necessary that Faces share the same edge.
2122 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2123 * \return New GEOM_Object, containing the created solid.
2125 * Example: see GEOM_Spanner.py
2127 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2128 if BlocksOp.IsDone() == 0:
2129 print "MakeHexa : ", BlocksOp.GetErrorCode()
2132 def MakeHexa2Faces(F1, F2):
2134 * Create a hexahedral solid between two given faces.
2135 * The missing faces will be built by creating the smallest ones.
2136 * \param F1,F2 Two opposite faces for the hexahedral solid.
2137 * \return New GEOM_Object, containing the created solid.
2139 * Example: see GEOM_Spanner.py
2141 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2142 if BlocksOp.IsDone() == 0:
2143 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2146 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2148 * Get a vertex, found in the given shape by its coordinates.
2149 * \param theShape Block or a compound of blocks.
2150 * \param theX,theY,theZ Coordinates of the sought vertex.
2151 * \param theEpsilon Maximum allowed distance between the resulting
2152 * vertex and point with the given coordinates.
2153 * \return New GEOM_Object, containing the found vertex.
2155 * Example: see GEOM_TestOthers.py
2157 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2158 if BlocksOp.IsDone() == 0:
2159 print "GetPoint : ", BlocksOp.GetErrorCode()
2162 def GetEdge(theShape, thePoint1, thePoint2):
2164 * Get an edge, found in the given shape by two given vertices.
2165 * \param theShape Block or a compound of blocks.
2166 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2167 * \return New GEOM_Object, containing the found edge.
2169 * Example: see GEOM_Spanner.py
2171 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2172 if BlocksOp.IsDone() == 0:
2173 print "GetEdge : ", BlocksOp.GetErrorCode()
2176 def GetEdgeNearPoint(theShape, thePoint):
2178 * Find an edge of the given shape, which has minimal distance to the given point.
2179 * \param theShape Block or a compound of blocks.
2180 * \param thePoint Point, close to the desired edge.
2181 * \return New GEOM_Object, containing the found edge.
2183 * Example: see GEOM_TestOthers.py
2185 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2186 if BlocksOp.IsDone() == 0:
2187 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2190 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2192 * Returns a face, found in the given shape by four given corner vertices.
2193 * \param theShape Block or a compound of blocks.
2194 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2195 * \return New GEOM_Object, containing the found face.
2197 * Example: see GEOM_Spanner.py
2199 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2200 if BlocksOp.IsDone() == 0:
2201 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2204 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2206 * Get a face of block, found in the given shape by two given edges.
2207 * \param theShape Block or a compound of blocks.
2208 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2209 * \return New GEOM_Object, containing the found face.
2211 * Example: see GEOM_Spanner.py
2213 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2214 if BlocksOp.IsDone() == 0:
2215 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2218 def GetOppositeFace(theBlock, theFace):
2220 * Find a face, opposite to the given one in the given block.
2221 * \param theBlock Must be a hexahedral solid.
2222 * \param theFace Face of \a theBlock, opposite to the desired face.
2223 * \return New GEOM_Object, containing the found face.
2225 * Example: see GEOM_Spanner.py
2227 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2228 if BlocksOp.IsDone() == 0:
2229 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2232 def GetFaceNearPoint(theShape, thePoint):
2234 * Find a face of the given shape, which has minimal distance to the given point.
2235 * \param theShape Block or a compound of blocks.
2236 * \param thePoint Point, close to the desired face.
2237 * \return New GEOM_Object, containing the found face.
2239 * Example: see GEOM_Spanner.py
2241 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2242 if BlocksOp.IsDone() == 0:
2243 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2246 def GetFaceByNormale(theBlock, theVector):
2248 * Find a face of block, whose outside normale has minimal angle with the given vector.
2249 * \param theShape Block or a compound of blocks.
2250 * \param theVector Vector, close to the normale of the desired face.
2251 * \return New GEOM_Object, containing the found face.
2253 * Example: see GEOM_Spanner.py
2255 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2256 if BlocksOp.IsDone() == 0:
2257 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2260 def CheckCompoundOfBlocks(theCompound):
2262 * Check, if the compound of blocks is given.
2263 * To be considered as a compound of blocks, the
2264 * given shape must satisfy the following conditions:
2265 * - Each element of the compound should be a Block (6 faces and 12 edges).
2266 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2267 * - The compound should be connexe.
2268 * - The glue between two quadrangle faces should be applied.
2269 * \param theCompound The compound to check.
2270 * \return TRUE, if the given shape is a compound of blocks.
2271 * If theCompound is not valid, prints all discovered errors.
2273 * Example: see GEOM_Spanner.py
2275 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2276 if BlocksOp.IsDone() == 0:
2277 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2280 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2284 def RemoveExtraEdges(theShape):
2286 * Remove all seam and degenerated edges from \a theShape.
2287 * Unite faces and edges, sharing one surface.
2288 * \param theShape The compound or single solid to remove irregular edges from.
2289 * \return Improved shape.
2291 * Example: see GEOM_TestOthers.py
2293 anObj = BlocksOp.RemoveExtraEdges(theShape)
2294 if BlocksOp.IsDone() == 0:
2295 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2298 def CheckAndImprove(theShape):
2300 * Check, if the given shape is a blocks compound.
2301 * Fix all detected errors.
2302 * \note Single block can be also fixed by this method.
2303 * \param theCompound The compound to check and improve.
2304 * \return Improved compound.
2306 * Example: see GEOM_TestOthers.py
2308 anObj = BlocksOp.CheckAndImprove(theShape)
2309 if BlocksOp.IsDone() == 0:
2310 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2313 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2315 * Get all the blocks, contained in the given compound.
2316 * \param theCompound The compound to explode.
2317 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2318 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2319 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2320 * \return List of GEOM_Objects, containing the retrieved blocks.
2322 * Example: see GEOM_TestOthers.py
2324 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2325 if BlocksOp.IsDone() == 0:
2326 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2329 def GetBlockNearPoint(theCompound, thePoint):
2331 * Find block, containing the given point inside its volume or on boundary.
2332 * \param theCompound Compound, to find block in.
2333 * \param thePoint Point, close to the desired block. If the point lays on
2334 * boundary between some blocks, we return block with nearest center.
2335 * \return New GEOM_Object, containing the found block.
2337 * Example: see GEOM_Spanner.py
2339 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2340 if BlocksOp.IsDone() == 0:
2341 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2344 def GetBlockByParts(theCompound, theParts):
2346 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2347 * \param theCompound Compound, to find block in.
2348 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2349 * \return New GEOM_Object, containing the found block.
2351 * Example: see GEOM_TestOthers.py
2353 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2354 if BlocksOp.IsDone() == 0:
2355 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2358 def GetBlocksByParts(theCompound, theParts):
2360 * Return all blocks, containing all the elements, passed as the parts.
2361 * \param theCompound Compound, to find blocks in.
2362 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2363 * \return List of GEOM_Objects, containing the found blocks.
2365 * Example: see GEOM_Spanner.py
2367 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2368 if BlocksOp.IsDone() == 0:
2369 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2372 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2374 * Multi-transformate block and glue the result.
2375 * Transformation is defined so, as to superpose direction faces.
2376 * \param Block Hexahedral solid to be multi-transformed.
2377 * \param DirFace1 ID of First direction face.
2378 * \param DirFace2 ID of Second direction face.
2379 * \param NbTimes Quantity of transformations to be done.
2380 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2381 * \return New GEOM_Object, containing the result shape.
2383 * Example: see GEOM_Spanner.py
2385 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2386 if BlocksOp.IsDone() == 0:
2387 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2390 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2391 DirFace1V, DirFace2V, NbTimesV):
2393 * Multi-transformate block and glue the result.
2394 * \param Block Hexahedral solid to be multi-transformed.
2395 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2396 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2397 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2398 * \return New GEOM_Object, containing the result shape.
2400 * Example: see GEOM_Spanner.py
2402 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2403 DirFace1V, DirFace2V, NbTimesV)
2404 if BlocksOp.IsDone() == 0:
2405 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2408 def Propagate(theShape):
2410 * Build all possible propagation groups.
2411 * Propagation group is a set of all edges, opposite to one (main)
2412 * edge of this group directly or through other opposite edges.
2413 * Notion of Opposite Edge make sence only on quadrangle face.
2414 * \param theShape Shape to build propagation groups on.
2415 * \return List of GEOM_Objects, each of them is a propagation group.
2417 * Example: see GEOM_TestOthers.py
2419 listChains = BlocksOp.Propagate(theShape)
2420 if BlocksOp.IsDone() == 0:
2421 print "Propagate : ", BlocksOp.GetErrorCode()
2424 # -----------------------------------------------------------------------------
2426 # -----------------------------------------------------------------------------
2428 def CreateGroup(theMainShape, theShapeType):
2430 * Creates a new group which will store sub shapes of theMainShape
2431 * \param theMainShape is a GEOM object on which the group is selected
2432 * \param theShapeType defines a shape type of the group
2433 * \return a newly created GEOM group
2435 * Example: see GEOM_TestOthers.py
2437 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2438 if GroupOp.IsDone() == 0:
2439 print "CreateGroup : ", GroupOp.GetErrorCode()
2442 def AddObject(theGroup, theSubShapeID):
2444 * Adds a sub object with ID theSubShapeId to the group
2445 * \param theGroup is a GEOM group to which the new sub shape is added
2446 * \param theSubShapeID is a sub shape ID in the main object.
2447 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2449 * Example: see GEOM_TestOthers.py
2451 GroupOp.AddObject(theGroup, theSubShapeID)
2452 if GroupOp.IsDone() == 0:
2453 print "AddObject : ", GroupOp.GetErrorCode()
2455 def RemoveObject(theGroup, theSubShapeID):
2457 * Removes a sub object with ID \a theSubShapeId from the group
2458 * \param theGroup is a GEOM group from which the new sub shape is removed
2459 * \param theSubShapeID is a sub shape ID in the main object.
2460 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2462 * Example: see GEOM_TestOthers.py
2464 GroupOp.RemoveObject(theGroup, theSubShapeID)
2465 if GroupOp.IsDone() == 0:
2466 print "RemoveObject : ", GroupOp.GetErrorCode()
2468 def UnionList (theGroup, theSubShapes):
2470 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2471 * \param theGroup is a GEOM group to which the new sub shapes are added.
2472 * \param theSubShapes is a list of sub shapes to be added.
2474 * Example: see GEOM_TestOthers.py
2476 GroupOp.UnionList(theGroup, theSubShapes)
2477 if GroupOp.IsDone() == 0:
2478 print "UnionList : ", GroupOp.GetErrorCode()
2480 def UnionIDs(theGroup, theSubShapes):
2482 * Works like the above method, but argument
2483 * theSubShapes here is a list of sub-shapes indices
2485 * Example: see GEOM_TestOthers.py
2487 GroupOp.UnionIDs(theGroup, theSubShapes)
2488 if GroupOp.IsDone() == 0:
2489 print "UnionIDs : ", GroupOp.GetErrorCode()
2491 def DifferenceList (theGroup, theSubShapes):
2493 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2494 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2495 * \param theSubShapes is a list of sub-shapes to be removed.
2497 * Example: see GEOM_TestOthers.py
2499 GroupOp.DifferenceList(theGroup, theSubShapes)
2500 if GroupOp.IsDone() == 0:
2501 print "DifferenceList : ", GroupOp.GetErrorCode()
2503 def DifferenceIDs(theGroup, theSubShapes):
2505 * Works like the above method, but argument
2506 * theSubShapes here is a list of sub-shapes indices
2508 * Example: see GEOM_TestOthers.py
2510 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2511 if GroupOp.IsDone() == 0:
2512 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2514 def GetObjectIDs(theGroup):
2516 * Returns a list of sub objects ID stored in the group
2517 * \param theGroup is a GEOM group for which a list of IDs is requested
2519 * Example: see GEOM_TestOthers.py
2521 ListIDs = GroupOp.GetObjects(theGroup)
2522 if GroupOp.IsDone() == 0:
2523 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2526 def GetType(theGroup):
2528 * Returns a type of sub objects stored in the group
2529 * \param theGroup is a GEOM group which type is returned.
2531 * Example: see GEOM_TestOthers.py
2533 aType = GroupOp.GetType(theGroup)
2534 if GroupOp.IsDone() == 0:
2535 print "GetType : ", GroupOp.GetErrorCode()
2538 def GetMainShape(theGroup):
2540 * Returns a main shape associated with the group
2541 * \param theGroup is a GEOM group for which a main shape object is requested
2542 * \return a GEOM object which is a main shape for theGroup
2544 * Example: see GEOM_TestOthers.py
2546 anObj = GroupOp.GetMainShape(theGroup)
2547 if GroupOp.IsDone() == 0:
2548 print "GetMainShape : ", GroupOp.GetErrorCode()
2551 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2553 Create group of edges of theShape, whose length is in range [min_length, max_length].
2554 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2557 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2560 Props = BasicProperties(edge)
2561 if min_length <= Props[0] and Props[0] <= max_length:
2562 if (not include_min) and (min_length == Props[0]):
2565 if (not include_max) and (Props[0] == max_length):
2568 edges_in_range.append(edge)
2570 if len(edges_in_range) <= 0:
2571 print "No edges found by given criteria"
2574 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2575 UnionList(group_edges, edges_in_range)
2579 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2581 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2582 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2585 nb_selected = sg.SelectedCount()
2587 print "Select a shape before calling this function, please."
2590 print "Only one shape must be selected"
2593 id_shape = sg.getSelected(0)
2594 shape = IDToObject( id_shape )
2596 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2600 if include_min: left_str = " <= "
2601 if include_max: right_str = " <= "
2603 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2604 + left_str + "length" + right_str + `max_length`)
2606 sg.updateObjBrowser(1)
2612 * Add Path to load python scripts from
2614 if (sys.path.count(Path) < 1):
2615 sys.path.append(Path)