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)
113 index = ShapesOp.GetTopologyIndex(aMainObj, aSubObj)
114 name = ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index)
117 def addToStudy(aShape, aName):
119 * Publish in study aShape with name aName
121 * Example: see GEOM_TestAll.py
124 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
126 print "addToStudy() failed"
128 return aShape.GetStudyEntry()
130 def addToStudyInFather(aFather, aShape, aName):
132 * Publish in study aShape with name aName as sub-object of previously published aFather
134 * Example: see GEOM_TestAll.py
137 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
139 print "addToStudyInFather() failed"
141 return aShape.GetStudyEntry()
143 # -----------------------------------------------------------------------------
144 # enumeration ShapeType as a dictionary
145 # -----------------------------------------------------------------------------
147 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
149 # -----------------------------------------------------------------------------
151 # -----------------------------------------------------------------------------
153 def MakeVertex(theX, theY, theZ):
155 * Create point by three coordinates.
156 * \param theX The X coordinate of the point.
157 * \param theY The Y coordinate of the point.
158 * \param theZ The Z coordinate of the point.
159 * \return New GEOM_Object, containing the created point.
161 * Example: see GEOM_TestAll.py
163 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
164 if BasicOp.IsDone() == 0:
165 print "MakePointXYZ : ", BasicOp.GetErrorCode()
168 def MakeVertexWithRef(theReference, theX, theY, theZ):
170 * Create a point, distant from the referenced point
171 * on the given distances along the coordinate axes.
172 * \param theReference The referenced point.
173 * \param theX Displacement from the referenced point along OX axis.
174 * \param theY Displacement from the referenced point along OY axis.
175 * \param theZ Displacement from the referenced point along OZ axis.
176 * \return New GEOM_Object, containing the created point.
178 * Example: see GEOM_TestAll.py
180 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
181 if BasicOp.IsDone() == 0:
182 print "MakePointWithReference : ", BasicOp.GetErrorCode()
185 def MakeVertexOnCurve(theRefCurve, theParameter):
187 * Create a point, corresponding to the given parameter on the given curve.
188 * \param theRefCurve The referenced curve.
189 * \param theParameter Value of parameter on the referenced curve.
190 * \return New GEOM_Object, containing the created point.
192 * Example: see GEOM_TestAll.py
194 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
195 if BasicOp.IsDone() == 0:
196 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
199 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
201 * Create a vector with the given components.
202 * \param theDX X component of the vector.
203 * \param theDY Y component of the vector.
204 * \param theDZ Z component of the vector.
205 * \return New GEOM_Object, containing the created vector.
207 * Example: see GEOM_TestAll.py
209 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
210 if BasicOp.IsDone() == 0:
211 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
214 def MakeVector(thePnt1, thePnt2):
216 * Create a vector between two points.
217 * \param thePnt1 Start point for the vector.
218 * \param thePnt2 End point for the vector.
219 * \return New GEOM_Object, containing the created vector.
221 * Example: see GEOM_TestAll.py
223 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
224 if BasicOp.IsDone() == 0:
225 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
228 def MakeLine(thePnt, theDir):
230 * Create a line, passing through the given point
231 * and parrallel to the given direction
232 * \param thePnt Point. The resulting line will pass through it.
233 * \param theDir Direction. The resulting line will be parallel to it.
234 * \return New GEOM_Object, containing the created line.
236 * Example: see GEOM_TestAll.py
238 anObj = BasicOp.MakeLine(thePnt, theDir)
239 if BasicOp.IsDone() == 0:
240 print "MakeLine : ", BasicOp.GetErrorCode()
243 def MakeLineTwoPnt(thePnt1, thePnt2):
245 * Create a line, passing through the given points
246 * \param thePnt1 First of two points, defining the line.
247 * \param thePnt2 Second of two points, defining the line.
248 * \return New GEOM_Object, containing the created line.
250 * Example: see GEOM_TestAll.py
252 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
253 if BasicOp.IsDone() == 0:
254 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
257 def MakePlane(thePnt, theVec, theTrimSize):
259 * Create a plane, passing through the given point
260 * and normal to the given vector.
261 * \param thePnt Point, the plane has to pass through.
262 * \param theVec Vector, defining the plane normal direction.
263 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
264 * \return New GEOM_Object, containing the created plane.
266 * Example: see GEOM_TestAll.py
268 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
269 if BasicOp.IsDone() == 0:
270 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
273 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
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.
282 * Example: see GEOM_TestAll.py
284 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
285 if BasicOp.IsDone() == 0:
286 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
289 def MakePlaneFace(theFace, theTrimSize):
291 * Create a plane, similar to the existing one, but with another size of representing face.
292 * \param theFace Referenced plane.
293 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
294 * \return New GEOM_Object, containing the created plane.
296 * Example: see GEOM_TestAll.py
298 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
299 if BasicOp.IsDone() == 0:
300 print "MakePlaneFace : ", BasicOp.GetErrorCode()
303 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
305 * Create a local coordinate system.
306 * \param OX,OY,OZ Three coordinates of coordinate system origin.
307 * \param XDX,XDY,XDZ Three components of OX direction
308 * \param YDX,YDY,YDZ Three components of OY direction
309 * \return New GEOM_Object, containing the created coordinate system.
311 * Example: see GEOM_TestAll.py
313 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
314 if BasicOp.IsDone() == 0:
315 print "MakeMarker : ", BasicOp.GetErrorCode()
318 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
320 * Create a local coordinate system.
321 * \param theOrigin Point of coordinate system origin.
322 * \param theXVec Vector of X direction
323 * \param theYVec Vector of Y direction
324 * \return New GEOM_Object, containing the created coordinate system.
326 O = PointCoordinates( theOrigin )
328 for vec in [ theXVec, theYVec ]:
329 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
330 p1 = PointCoordinates( v1 )
331 p2 = PointCoordinates( v2 )
332 for i in range( 0, 3 ):
333 OXOY.append( p2[i] - p1[i] )
335 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
336 OXOY[0], OXOY[1], OXOY[2],
337 OXOY[3], OXOY[4], OXOY[5], )
338 if BasicOp.IsDone() == 0:
339 print "MakeMarker : ", BasicOp.GetErrorCode()
342 # -----------------------------------------------------------------------------
344 # -----------------------------------------------------------------------------
346 def MakeArc(thePnt1, thePnt2, thePnt3):
348 * Create an arc of circle, passing through three given points.
349 * \param thePnt1 Start point of the arc.
350 * \param thePnt2 Middle point of the arc.
351 * \param thePnt3 End point of the arc.
352 * \return New GEOM_Object, containing the created arc.
354 * Example: see GEOM_TestAll.py
356 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
357 if CurvesOp.IsDone() == 0:
358 print "MakeArc : ", CurvesOp.GetErrorCode()
361 def MakeCircle(thePnt, theVec, theR):
363 * Create a circle with given center, normal vector and radius.
364 * \param thePnt Circle center.
365 * \param theVec Vector, normal to the plane of the circle.
366 * \param theR Circle radius.
367 * \return New GEOM_Object, containing the created circle.
369 * Example: see GEOM_TestAll.py
371 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
372 if CurvesOp.IsDone() == 0:
373 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
376 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
378 * Create a circle, passing through three given points
379 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
380 * \return New GEOM_Object, containing the created circle.
382 * Example: see GEOM_TestAll.py
384 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
385 if CurvesOp.IsDone() == 0:
386 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
389 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
391 * Create an ellipse with given center, normal vector and radiuses.
392 * \param thePnt Ellipse center.
393 * \param theVec Vector, normal to the plane of the ellipse.
394 * \param theRMajor Major ellipse radius.
395 * \param theRMinor Minor ellipse radius.
396 * \return New GEOM_Object, containing the created ellipse.
398 * Example: see GEOM_TestAll.py
400 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
401 if CurvesOp.IsDone() == 0:
402 print "MakeEllipse : ", CurvesOp.GetErrorCode()
405 def MakePolyline(thePoints):
407 * Create a polyline on the set of points.
408 * \param thePoints Sequence of points for the polyline.
409 * \return New GEOM_Object, containing the created polyline.
411 * Example: see GEOM_TestAll.py
413 anObj = CurvesOp.MakePolyline(thePoints)
414 if CurvesOp.IsDone() == 0:
415 print "MakePolyline : ", CurvesOp.GetErrorCode()
418 def MakeBezier(thePoints):
420 * Create bezier curve on the set of points.
421 * \param thePoints Sequence of points for the bezier curve.
422 * \return New GEOM_Object, containing the created bezier curve.
424 * Example: see GEOM_TestAll.py
426 anObj = CurvesOp.MakeSplineBezier(thePoints)
427 if CurvesOp.IsDone() == 0:
428 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
431 def MakeInterpol(thePoints):
433 * Create B-Spline curve on the set of points.
434 * \param thePoints Sequence of points for the B-Spline curve.
435 * \return New GEOM_Object, containing the created B-Spline curve.
437 * Example: see GEOM_TestAll.py
439 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
440 if CurvesOp.IsDone() == 0:
441 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
444 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
446 * Create a sketcher (wire or face), following the textual description,
447 * passed through \a theCommand argument. \n
448 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
449 * Format of the description string have to be the following:
451 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
454 * - x1, y1 are coordinates of the first sketcher point (zero by default),
456 * - "R angle" : Set the direction by angle
457 * - "D dx dy" : Set the direction by DX & DY
460 * - "TT x y" : Create segment by point at X & Y
461 * - "T dx dy" : Create segment by point with DX & DY
462 * - "L length" : Create segment by direction & Length
463 * - "IX x" : Create segment by direction & Intersect. X
464 * - "IY y" : Create segment by direction & Intersect. Y
467 * - "C radius length" : Create arc by direction, radius and length(in degree)
470 * - "WW" : Close Wire (to finish)
471 * - "WF" : Close Wire and build face (to finish)
473 * \param theCommand String, defining the sketcher in local
474 * coordinates of the working plane.
475 * \param theWorkingPlane Nine double values, defining origin,
476 * OZ and OX directions of the working plane.
477 * \return New GEOM_Object, containing the created wire.
479 * Example: see GEOM_TestAll.py
481 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
482 if CurvesOp.IsDone() == 0:
483 print "MakeSketcher : ", CurvesOp.GetErrorCode()
486 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
488 * Create a sketcher (wire or face), following the textual description,
489 * passed through \a theCommand argument. \n
490 * For format of the description string see the previous method.\n
491 * \param theCommand String, defining the sketcher in local
492 * coordinates of the working plane.
493 * \param theWorkingPlane Planar Face of the working plane.
494 * \return New GEOM_Object, containing the created wire.
496 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
497 if CurvesOp.IsDone() == 0:
498 print "MakeSketcher : ", CurvesOp.GetErrorCode()
501 # -----------------------------------------------------------------------------
502 # Create 3D Primitives
503 # -----------------------------------------------------------------------------
505 def MakeBox(x1,y1,z1,x2,y2,z2):
507 * Create a box by coordinates of two opposite vertices.
509 * Example: see GEOM_TestAll.py
511 pnt1 = MakeVertex(x1,y1,z1)
512 pnt2 = MakeVertex(x2,y2,z2)
513 return MakeBoxTwoPnt(pnt1,pnt2)
515 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
517 * Create a box with specified dimensions along the coordinate axes
518 * and with edges, parallel to the coordinate axes.
519 * Center of the box will be at point (DX/2, DY/2, DZ/2).
520 * \param theDX Length of Box edges, parallel to OX axis.
521 * \param theDY Length of Box edges, parallel to OY axis.
522 * \param theDZ Length of Box edges, parallel to OZ axis.
523 * \return New GEOM_Object, containing the created box.
525 * Example: see GEOM_TestAll.py
527 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
528 if PrimOp.IsDone() == 0:
529 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
532 def MakeBoxTwoPnt(thePnt1, thePnt2):
534 * Create a box with two specified opposite vertices,
535 * and with edges, parallel to the coordinate axes
536 * \param thePnt1 First of two opposite vertices.
537 * \param thePnt2 Second of two opposite vertices.
538 * \return New GEOM_Object, containing the created box.
540 * Example: see GEOM_TestAll.py
542 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
543 if PrimOp.IsDone() == 0:
544 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
547 def MakeCylinder(thePnt, theAxis, theR, theH):
549 * Create a cylinder with given base point, axis, radius and height.
550 * \param thePnt Central point of cylinder base.
551 * \param theAxis Cylinder axis.
552 * \param theR Cylinder radius.
553 * \param theH Cylinder height.
554 * \return New GEOM_Object, containing the created cylinder.
556 * Example: see GEOM_TestAll.py
558 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
559 if PrimOp.IsDone() == 0:
560 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
563 def MakeCylinderRH(theR, theH):
565 * Create a cylinder with given radius and height at
566 * the origin of coordinate system. Axis of the cylinder
567 * will be collinear to the OZ axis of the coordinate system.
568 * \param theR Cylinder radius.
569 * \param theH Cylinder height.
570 * \return New GEOM_Object, containing the created cylinder.
572 * Example: see GEOM_TestAll.py
574 anObj = PrimOp.MakeCylinderRH(theR, theH)
575 if PrimOp.IsDone() == 0:
576 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
579 def MakeSpherePntR(thePnt, theR):
581 * Create a sphere with given center and radius.
582 * \param thePnt Sphere center.
583 * \param theR Sphere radius.
584 * \return New GEOM_Object, containing the created sphere.
586 * Example: see GEOM_TestAll.py
588 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
589 if PrimOp.IsDone() == 0:
590 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
593 def MakeSphere(x, y, z, theR):
595 * Create a sphere with given center and radius.
596 * \param x,y,z Coordinates of sphere center.
597 * \param theR Sphere radius.
598 * \return New GEOM_Object, containing the created sphere.
600 * Example: see GEOM_TestAll.py
602 point = MakeVertex(x, y, z)
603 anObj = MakeSpherePntR(point, theR)
606 def MakeSphereR(theR):
608 * Create a sphere with given radius at the origin of coordinate system.
609 * \param theR Sphere radius.
610 * \return New GEOM_Object, containing the created sphere.
612 * Example: see GEOM_TestAll.py
614 anObj = PrimOp.MakeSphereR(theR)
615 if PrimOp.IsDone() == 0:
616 print "MakeSphereR : ", PrimOp.GetErrorCode()
619 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
621 * Create a cone with given base point, axis, height and radiuses.
622 * \param thePnt Central point of the first cone base.
623 * \param theAxis Cone axis.
624 * \param theR1 Radius of the first cone base.
625 * \param theR2 Radius of the second cone base.
626 * \note If both radiuses are non-zero, the cone will be truncated.
627 * \note If the radiuses are equal, a cylinder will be created instead.
628 * \param theH Cone height.
629 * \return New GEOM_Object, containing the created cone.
631 * Example: see GEOM_TestAll.py
633 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
634 if PrimOp.IsDone() == 0:
635 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
638 def MakeConeR1R2H(theR1, theR2, theH):
640 * Create a cone with given height and radiuses at
641 * the origin of coordinate system. Axis of the cone will
642 * be collinear to the OZ axis of the coordinate system.
643 * \param theR1 Radius of the first cone base.
644 * \param theR2 Radius of the second cone base.
645 * \note If both radiuses are non-zero, the cone will be truncated.
646 * \note If the radiuses are equal, a cylinder will be created instead.
647 * \param theH Cone height.
648 * \return New GEOM_Object, containing the created cone.
650 * Example: see GEOM_TestAll.py
652 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
653 if PrimOp.IsDone() == 0:
654 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
657 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
659 * Create a torus with given center, normal vector and radiuses.
660 * \param thePnt Torus central point.
661 * \param theVec Torus axis of symmetry.
662 * \param theRMajor Torus major radius.
663 * \param theRMinor Torus minor radius.
664 * \return New GEOM_Object, containing the created torus.
666 * Example: see GEOM_TestAll.py
668 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
669 if PrimOp.IsDone() == 0:
670 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
673 def MakeTorusRR(theRMajor, theRMinor):
675 * Create a torus with given radiuses at the origin of coordinate system.
676 * \param theRMajor Torus major radius.
677 * \param theRMinor Torus minor radius.
678 * \return New GEOM_Object, containing the created torus.
680 * Example: see GEOM_TestAll.py
682 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
683 if PrimOp.IsDone() == 0:
684 print "MakeTorusRR : ", PrimOp.GetErrorCode()
687 def MakePrism(theBase, thePoint1, thePoint2):
689 * Create a shape by extrusion of the base shape along a vector, defined by two points.
690 * \param theBase Base shape to be extruded.
691 * \param thePoint1 First end of extrusion vector.
692 * \param thePoint2 Second end of extrusion vector.
693 * \return New GEOM_Object, containing the created prism.
695 * Example: see GEOM_TestAll.py
697 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
698 if PrimOp.IsDone() == 0:
699 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
702 def MakePrismVecH(theBase, theVec, theH):
704 * Create a shape by extrusion of the base shape along the vector,
705 * i.e. all the space, transfixed by the base shape during its translation
706 * along the vector on the given distance.
707 * \param theBase Base shape to be extruded.
708 * \param theVec Direction of extrusion.
709 * \param theH Prism dimension along theVec.
710 * \return New GEOM_Object, containing the created prism.
712 * Example: see GEOM_TestAll.py
714 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
715 if PrimOp.IsDone() == 0:
716 print "MakePrismVecH : ", PrimOp.GetErrorCode()
719 def MakePipe(theBase, thePath):
721 * Create a shape by extrusion of the base shape along
722 * the path shape. The path shape can be a wire or an edge.
723 * \param theBase Base shape to be extruded.
724 * \param thePath Path shape to extrude the base shape along it.
725 * \return New GEOM_Object, containing the created pipe.
727 * Example: see GEOM_TestAll.py
729 anObj = PrimOp.MakePipe(theBase, thePath)
730 if PrimOp.IsDone() == 0:
731 print "MakePipe : ", PrimOp.GetErrorCode()
734 def MakeRevolution(theBase, theAxis, theAngle):
736 * Create a shape by revolution of the base shape around the axis
737 * on the given angle, i.e. all the space, transfixed by the base
738 * shape during its rotation around the axis on the given angle.
739 * \param theBase Base shape to be rotated.
740 * \param theAxis Rotation axis.
741 * \param theAngle Rotation angle in radians.
742 * \return New GEOM_Object, containing the created revolution.
744 * Example: see GEOM_TestAll.py
746 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
747 if PrimOp.IsDone() == 0:
748 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
751 # -----------------------------------------------------------------------------
753 # -----------------------------------------------------------------------------
755 def MakeEdge(thePnt1, thePnt2):
757 * Create a linear edge with specified ends.
758 * \param thePnt1 Point for the first end of edge.
759 * \param thePnt2 Point for the second end of edge.
760 * \return New GEOM_Object, containing the created edge.
762 * Example: see GEOM_TestAll.py
764 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
765 if ShapesOp.IsDone() == 0:
766 print "MakeEdge : ", ShapesOp.GetErrorCode()
769 def MakeWire(theEdgesAndWires):
771 * Create a wire from the set of edges and wires.
772 * \param theEdgesAndWires List of edges and/or wires.
773 * \return New GEOM_Object, containing the created wire.
775 * Example: see GEOM_TestAll.py
777 anObj = ShapesOp.MakeWire(theEdgesAndWires)
778 if ShapesOp.IsDone() == 0:
779 print "MakeWire : ", ShapesOp.GetErrorCode()
782 def MakeFace(theWire, isPlanarWanted):
784 * Create a face on the given wire.
785 * \param theWire Wire to build the face on.
786 * \param isPlanarWanted If TRUE, only planar face will be built.
787 * If impossible, NULL object will be returned.
788 * \return New GEOM_Object, containing the created face.
790 * Example: see GEOM_TestAll.py
792 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
793 if ShapesOp.IsDone() == 0:
794 print "MakeFace : ", ShapesOp.GetErrorCode()
797 def MakeFaceWires(theWires, isPlanarWanted):
799 * Create a face on the given wires set.
800 * \param theWires List of wires to build the face on.
801 * \param isPlanarWanted If TRUE, only planar face will be built.
802 * If impossible, NULL object will be returned.
803 * \return New GEOM_Object, containing the created face.
805 * Example: see GEOM_TestAll.py
807 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
808 if ShapesOp.IsDone() == 0:
809 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
812 def MakeFaces(theWires, isPlanarWanted):
814 * Shortcut to MakeFaceWires()
816 * Example: see GEOM_TestOthers.py
818 anObj = MakeFaceWires(theWires, isPlanarWanted)
821 def MakeShell(theFacesAndShells):
823 * Create a shell from the set of faces and shells.
824 * \param theFacesAndShells List of faces and/or shells.
825 * \return New GEOM_Object, containing the created shell.
827 * Example: see GEOM_TestAll.py
829 anObj = ShapesOp.MakeShell(theFacesAndShells)
830 if ShapesOp.IsDone() == 0:
831 print "MakeShell : ", ShapesOp.GetErrorCode()
834 def MakeSolid(theShells):
836 * Create a solid, bounded by the given shells.
837 * \param theShells Sequence of bounding shells.
838 * \return New GEOM_Object, containing the created solid.
840 * Example: see GEOM_TestAll.py
842 anObj = ShapesOp.MakeSolidShells(theShells)
843 if ShapesOp.IsDone() == 0:
844 print "MakeSolid : ", ShapesOp.GetErrorCode()
847 def MakeCompound(theShapes):
849 * Create a compound of the given shapes.
850 * \param theShapes List of shapes to put in compound.
851 * \return New GEOM_Object, containing the created compound.
853 * Example: see GEOM_TestAll.py
855 anObj = ShapesOp.MakeCompound(theShapes)
856 if ShapesOp.IsDone() == 0:
857 print "MakeCompound : ", ShapesOp.GetErrorCode()
860 def NumberOfFaces(theShape):
862 * Gives quantity of faces in the given shape.
863 * \param theShape Shape to count faces of.
864 * \return Quantity of faces.
866 * Example: see GEOM_TestOthers.py
868 nb_faces = ShapesOp.NumberOfFaces(theShape)
869 if ShapesOp.IsDone() == 0:
870 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
873 def NumberOfEdges(theShape):
875 * Gives quantity of edges in the given shape.
876 * \param theShape Shape to count edges of.
877 * \return Quantity of edges.
879 * Example: see GEOM_TestOthers.py
881 nb_edges = ShapesOp.NumberOfEdges(theShape)
882 if ShapesOp.IsDone() == 0:
883 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
886 def ChangeOrientation(theShape):
888 * Reverses an orientation the given shape.
889 * \param theShape Shape to be reversed.
890 * \return The reversed copy of theShape.
892 * Example: see GEOM_TestAll.py
894 anObj = ShapesOp.ChangeOrientation(theShape)
895 if ShapesOp.IsDone() == 0:
896 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
899 def OrientationChange(theShape):
901 * Shortcut to ChangeOrientation()
903 * Example: see GEOM_TestOthers.py
905 anObj = ChangeOrientation(theShape)
908 def GetFreeFacesIDs(theShape):
910 * Retrieve all free faces from the given shape.
911 * Free face is a face, which is not shared between two shells of the shape.
912 * \param theShape Shape to find free faces in.
913 * \return List of IDs of all free faces, contained in theShape.
915 * Example: see GEOM_TestOthers.py
917 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
918 if ShapesOp.IsDone() == 0:
919 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
922 def GetSharedShapes(theShape1, theShape2, theShapeType):
924 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
925 * \param theShape1 Shape to find sub-shapes in.
926 * \param theShape2 Shape to find shared sub-shapes with.
927 * \param theShapeType Type of sub-shapes to be retrieved.
928 * \return List of sub-shapes of theShape1, shared with theShape2.
930 * Example: see GEOM_TestOthers.py
932 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
933 if ShapesOp.IsDone() == 0:
934 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
937 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
939 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
940 * the specified plane by the certain way, defined through \a theState parameter.
941 * \param theShape Shape to find sub-shapes of.
942 * \param theShapeType Type of sub-shapes to be retrieved.
943 * \param theAx1 Vector (or line, or linear edge), specifying normal
944 * direction and location of the plane to find shapes on.
945 * \param theState The state of the subshapes to find. It can be one of
946 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
947 * \return List of all found sub-shapes.
949 * Example: see GEOM_TestOthers.py
951 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
952 if ShapesOp.IsDone() == 0:
953 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
956 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
958 * Works like the above method, but returns list of sub-shapes indices
960 * Example: see GEOM_TestOthers.py
962 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
963 if ShapesOp.IsDone() == 0:
964 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
967 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
969 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
970 * the specified cylinder by the certain way, defined through \a theState parameter.
971 * \param theShape Shape to find sub-shapes of.
972 * \param theShapeType Type of sub-shapes to be retrieved.
973 * \param theAxis Vector (or line, or linear edge), specifying
974 * axis of the cylinder to find shapes on.
975 * \param theRadius Radius of the cylinder to find shapes on.
976 * \param theState The state of the subshapes to find. It can be one of
977 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
978 * \return List of all found sub-shapes.
980 * Example: see GEOM_TestOthers.py
982 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
983 if ShapesOp.IsDone() == 0:
984 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
987 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
989 * Works like the above method, but returns list of sub-shapes indices
991 * Example: see GEOM_TestOthers.py
993 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
994 if ShapesOp.IsDone() == 0:
995 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
998 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
1000 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1001 * the specified sphere by the certain way, defined through \a theState parameter.
1002 * \param theShape Shape to find sub-shapes of.
1003 * \param theShapeType Type of sub-shapes to be retrieved.
1004 * \param theCenter Point, specifying center of the sphere to find shapes on.
1005 * \param theRadius Radius of the sphere to find shapes on.
1006 * \param theState The state of the subshapes to find. It can be one of
1007 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1008 * \return List of all found sub-shapes.
1010 * Example: see GEOM_TestOthers.py
1012 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1013 if ShapesOp.IsDone() == 0:
1014 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1017 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1019 * Works like the above method, but returns list of sub-shapes indices
1021 * Example: see GEOM_TestOthers.py
1023 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1024 if ShapesOp.IsDone() == 0:
1025 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1028 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1030 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1031 * the specified quadrangle by the certain way, defined through \a theState parameter.
1032 * \param theShape Shape to find sub-shapes of.
1033 * \param theShapeType Type of sub-shapes to be retrieved.
1034 * \param theCenter Point, specifying center of the sphere to find shapes on.
1035 * \param theRadius Radius of the sphere to find shapes on.
1036 * \param theState The state of the subshapes to find. It can be one of
1037 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1038 * \return List of all found sub-shapes.
1040 * Example: see GEOM_TestOthers.py
1042 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1043 if ShapesOp.IsDone() == 0:
1044 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1047 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1049 * Works like the above method, but returns list of sub-shapes indices
1051 * Example: see GEOM_TestOthers.py
1053 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1054 if ShapesOp.IsDone() == 0:
1055 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1058 def GetInPlace(theShapeWhere, theShapeWhat):
1060 * Get sub-shape(s) of theShapeWhere, which are
1061 * coincident with \a theShapeWhat or could be a part of it.
1062 * \param theShapeWhere Shape to find sub-shapes of.
1063 * \param theShapeWhat Shape, specifying what to find.
1064 * \return Group of all found sub-shapes or a single found sub-shape.
1066 * Example: see GEOM_TestOthers.py
1068 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1069 if ShapesOp.IsDone() == 0:
1070 print "GetInPlace : ", ShapesOp.GetErrorCode()
1073 # -----------------------------------------------------------------------------
1074 # Access to sub-shapes by their unique IDs inside the main shape.
1075 # -----------------------------------------------------------------------------
1077 def GetSubShape(aShape, ListOfID):
1079 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1080 * of <aShape>, selected by their unique IDs inside <aShape>
1082 * Example: see GEOM_TestAll.py
1084 anObj = geom.AddSubShape(aShape,ListOfID)
1087 def GetSubShapeID(aShape, aSubShape):
1089 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1091 * Example: see GEOM_TestAll.py
1093 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1094 if LocalOp.IsDone() == 0:
1095 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1098 # -----------------------------------------------------------------------------
1100 # -----------------------------------------------------------------------------
1102 def SubShapeAll(aShape, aType):
1104 * Explode a shape on subshapes of a given type.
1105 * \param theShape Shape to be exploded.
1106 * \param theShapeType Type of sub-shapes to be retrieved.
1107 * \return List of sub-shapes of type theShapeType, contained in theShape.
1109 * Example: see GEOM_TestAll.py
1111 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1112 if ShapesOp.IsDone() == 0:
1113 print "MakeExplode : ", ShapesOp.GetErrorCode()
1116 def SubShapeAllIDs(aShape, aType):
1118 * Explode a shape on subshapes of a given type.
1119 * \param theShape Shape to be exploded.
1120 * \param theShapeType Type of sub-shapes to be retrieved.
1121 * \return List of IDs of sub-shapes.
1123 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1124 if ShapesOp.IsDone() == 0:
1125 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1128 def SubShapeAllSorted(aShape, aType):
1130 * Explode a shape on subshapes of a given type.
1131 * Sub-shapes will be sorted by coordinates of their gravity centers.
1132 * \param theShape Shape to be exploded.
1133 * \param theShapeType Type of sub-shapes to be retrieved.
1134 * \return List of sub-shapes of type theShapeType, contained in theShape.
1136 * Example: see GEOM_TestAll.py
1138 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1139 if ShapesOp.IsDone() == 0:
1140 print "MakeExplode : ", ShapesOp.GetErrorCode()
1143 def SubShapeAllSortedIDs(aShape, aType):
1145 * Explode a shape on subshapes of a given type.
1146 * Sub-shapes will be sorted by coordinates of their gravity centers.
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.
1151 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1152 if ShapesOp.IsDone() == 0:
1153 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1156 def SubShape(aShape, aType, ListOfInd):
1158 * Obtain a compound of sub-shapes of <aShape>,
1159 * selected by they indices in list of all sub-shapes of type <aType>.
1160 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1162 * Example: see GEOM_TestAll.py
1165 AllShapeList = SubShapeAll(aShape, aType)
1166 for ind in ListOfInd:
1167 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1168 anObj = GetSubShape(aShape, ListOfIDs)
1171 def SubShapeSorted(aShape, aType, ListOfInd):
1173 * Obtain a compound of sub-shapes of <aShape>,
1174 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1175 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1177 * Example: see GEOM_TestAll.py
1180 AllShapeList = SubShapeAllSorted(aShape, aType)
1181 for ind in ListOfInd:
1182 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1183 anObj = GetSubShape(aShape, ListOfIDs)
1186 # -----------------------------------------------------------------------------
1187 # Healing operations
1188 # -----------------------------------------------------------------------------
1190 def ProcessShape(theShape, theOperators, theParameters, theValues):
1192 * Apply a sequence of Shape Healing operators to the given object.
1193 * \param theShape Shape to be processed.
1194 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1195 * \param theParameters List of names of parameters
1196 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1197 * \param theValues List of values of parameters, in the same order
1198 * as parameters are listed in \a theParameters list.
1199 * \return New GEOM_Object, containing processed shape.
1201 * Example: see GEOM_TestHealing.py
1203 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1204 if HealOp.IsDone() == 0:
1205 print "ProcessShape : ", HealOp.GetErrorCode()
1208 def SuppressFaces(theObject, theFaces):
1210 * Remove faces from the given object (shape).
1211 * \param theObject Shape to be processed.
1212 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1213 * removes ALL faces of the given object.
1214 * \return New GEOM_Object, containing processed shape.
1216 * Example: see GEOM_TestHealing.py
1218 anObj = HealOp.SuppressFaces(theObject, theFaces)
1219 if HealOp.IsDone() == 0:
1220 print "SuppressFaces : ", HealOp.GetErrorCode()
1223 def MakeSewing(ListShape, theTolerance):
1225 * Sewing of some shapes into single shape.
1227 * Example: see GEOM_TestHealing.py
1229 comp = MakeCompound(ListShape)
1230 anObj = Sew(comp, theTolerance)
1233 def Sew(theObject, theTolerance):
1235 * Sewing of the given object.
1236 * \param theObject Shape to be processed.
1237 * \param theTolerance Required tolerance value.
1238 * \return New GEOM_Object, containing processed shape.
1240 * Example: see MakeSewing() above
1242 anObj = HealOp.Sew(theObject, theTolerance)
1243 if HealOp.IsDone() == 0:
1244 print "Sew : ", HealOp.GetErrorCode()
1247 def SuppressInternalWires(theObject, theWires):
1249 * Remove internal wires and edges from the given object (face).
1250 * \param theObject Shape to be processed.
1251 * \param theWires Indices of wires to be removed, if EMPTY then the method
1252 * removes ALL internal wires of the given object.
1253 * \return New GEOM_Object, containing processed shape.
1255 * Example: see GEOM_TestHealing.py
1257 anObj = HealOp.RemoveIntWires(theObject, theWires)
1258 if HealOp.IsDone() == 0:
1259 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1262 def SuppressHoles(theObject, theWires):
1264 * Remove internal closed contours (holes) from the given object.
1265 * \param theObject Shape to be processed.
1266 * \param theWires Indices of wires to be removed, if EMPTY then the method
1267 * removes ALL internal holes of the given object
1268 * \return New GEOM_Object, containing processed shape.
1270 * Example: see GEOM_TestHealing.py
1272 anObj = HealOp.FillHoles(theObject, theWires)
1273 if HealOp.IsDone() == 0:
1274 print "SuppressHoles : ", HealOp.GetErrorCode()
1277 def CloseContour(theObject, theWires, isCommonVertex):
1279 * Close an open wire.
1280 * \param theObject Shape to be processed.
1281 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1282 * if -1, then theObject itself is a wire.
1283 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1284 * If FALS : closure by creation of an edge between ends.
1285 * \return New GEOM_Object, containing processed shape.
1287 * Example: see GEOM_TestHealing.py
1289 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1290 if HealOp.IsDone() == 0:
1291 print "CloseContour : ", HealOp.GetErrorCode()
1294 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1296 * Addition of a point to a given edge object.
1297 * \param theObject Shape to be processed.
1298 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1299 * if -1, then theObject itself is the edge.
1300 * \param theValue Value of parameter on edge or length parameter,
1301 * depending on \a isByParameter.
1302 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1303 * if FALSE : \a theValue is treated as a length parameter [0..1]
1304 * \return New GEOM_Object, containing processed shape.
1306 * Example: see GEOM_TestHealing.py
1308 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1309 if HealOp.IsDone() == 0:
1310 print "DivideEdge : ", HealOp.GetErrorCode()
1313 def GetFreeBoundary(theObject):
1315 * Get a list of wires (wrapped in GEOM_Object-s),
1316 * that constitute a free boundary of the given shape.
1317 * \param theObject Shape to get free boundary of.
1318 * \return [status, theClosedWires, theOpenWires]
1319 * status: FALSE, if an error(s) occured during the method execution.
1320 * theClosedWires: Closed wires on the free boundary of the given shape.
1321 * theOpenWires: Open wires on the free boundary of the given shape.
1323 * Example: see GEOM_TestHealing.py
1325 anObj = HealOp.GetFreeBoundary(theObject)
1326 if HealOp.IsDone() == 0:
1327 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1330 # -----------------------------------------------------------------------------
1331 # Create advanced objects
1332 # -----------------------------------------------------------------------------
1334 def MakeCopy(theOriginal):
1336 * Create a copy of the given object
1338 * Example: see GEOM_TestAll.py
1340 anObj = InsertOp.MakeCopy(theOriginal)
1341 if InsertOp.IsDone() == 0:
1342 print "MakeCopy : ", InsertOp.GetErrorCode()
1345 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1347 * Create a filling from the given compound of contours.
1348 * \param theShape the compound of contours
1349 * \param theMinDeg a minimal degree
1350 * \param theMaxDeg a maximal degree
1351 * \param theTol2D a 2d tolerance
1352 * \param theTol3D a 3d tolerance
1353 * \param theNbIter a number of iteration
1354 * \return New GEOM_Object, containing the created filling surface.
1356 * Example: see GEOM_TestAll.py
1358 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1359 if PrimOp.IsDone() == 0:
1360 print "MakeFilling : ", PrimOp.GetErrorCode()
1363 def MakeGlueFaces(theShape, theTolerance):
1365 * Replace coincident faces in theShape by one face.
1366 * \param theShape Initial shape.
1367 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1368 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1370 * Example: see GEOM_Spanner.py
1372 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1373 if ShapesOp.IsDone() == 0:
1374 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1377 # -----------------------------------------------------------------------------
1378 # Boolean (Common, Cut, Fuse, Section)
1379 # -----------------------------------------------------------------------------
1381 def MakeBoolean(theShape1, theShape2, theOperation):
1383 * Perform one of boolean operations on two given shapes.
1384 * \param theShape1 First argument for boolean operation.
1385 * \param theShape2 Second argument for boolean operation.
1386 * \param theOperation Indicates the operation to be done:
1387 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1388 * \return New GEOM_Object, containing the result shape.
1390 * Example: see GEOM_TestAll.py
1392 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1393 if BoolOp.IsDone() == 0:
1394 print "MakeBoolean : ", BoolOp.GetErrorCode()
1397 def MakeCommon(s1, s2):
1399 * Shortcut to MakeBoolean(s1, s2, 1)
1401 * Example: see GEOM_TestOthers.py
1403 return MakeBoolean(s1, s2, 1)
1405 def MakeCut(s1, s2):
1407 * Shortcut to MakeBoolean(s1, s2, 2)
1409 * Example: see GEOM_TestOthers.py
1411 return MakeBoolean(s1, s2, 2)
1413 def MakeFuse(s1, s2):
1415 * Shortcut to MakeBoolean(s1, s2, 3)
1417 * Example: see GEOM_TestOthers.py
1419 return MakeBoolean(s1, s2, 3)
1421 def MakeSection(s1, s2):
1423 * Shortcut to MakeBoolean(s1, s2, 4)
1425 * Example: see GEOM_TestOthers.py
1427 return MakeBoolean(s1, s2, 4)
1429 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1430 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1432 * Perform partition operation.
1433 * \param ListShapes Shapes to be intersected.
1434 * \param ListTools Shapes to intersect theShapes.
1435 * \param ListKeepInside Shapes, outside which the results will be deleted.
1436 * Each shape from theKeepInside must belong to theShapes also.
1437 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1438 * Each shape from theRemoveInside must belong to theShapes also.
1439 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1440 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1441 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1442 * \return New GEOM_Object, containing the result shapes.
1444 * Example: see GEOM_TestAll.py
1446 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1447 ListKeepInside, ListRemoveInside,
1448 Limit, RemoveWebs, ListMaterials);
1449 if BoolOp.IsDone() == 0:
1450 print "MakePartition : ", BoolOp.GetErrorCode()
1453 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1454 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1456 * Shortcut to MakePartition()
1458 * Example: see GEOM_TestOthers.py
1460 anObj = MakePartition(ListShapes, ListTools,
1461 ListKeepInside, ListRemoveInside,
1462 Limit, RemoveWebs, ListMaterials);
1465 def MakeHalfPartition(theShape, thePlane):
1467 * Perform partition of the Shape with the Plane
1468 * \param theShape Shape to be intersected.
1469 * \param thePlane Tool shape, to intersect theShape.
1470 * \return New GEOM_Object, containing the result shape.
1472 * Example: see GEOM_TestAll.py
1474 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1475 if BoolOp.IsDone() == 0:
1476 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1479 # -----------------------------------------------------------------------------
1481 # -----------------------------------------------------------------------------
1483 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1485 * Translate the given object along the vector, specified
1486 * by its end points, creating its copy before the translation.
1487 * \param theObject The object to be translated.
1488 * \param thePoint1 Start point of translation vector.
1489 * \param thePoint2 End point of translation vector.
1490 * \return New GEOM_Object, containing the translated object.
1492 * Example: see GEOM_TestAll.py
1494 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1495 if TrsfOp.IsDone() == 0:
1496 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1499 def MakeTranslation(theObject, theDX, theDY, theDZ):
1501 * Translate the given object along the vector, specified
1502 * by its components, creating its copy before the translation.
1503 * \param theObject The object to be translated.
1504 * \param theDX,theDY,theDZ Components of translation vector.
1505 * \return New GEOM_Object, containing the translated object.
1507 * Example: see GEOM_TestAll.py
1509 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1510 if TrsfOp.IsDone() == 0:
1511 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1514 def MakeTranslationVector(theObject, theVector):
1516 * Translate the given object along the given vector,
1517 * creating its copy before the translation.
1518 * \param theObject The object to be translated.
1519 * \param theVector The translation vector.
1520 * \return New GEOM_Object, containing the translated object.
1522 * Example: see GEOM_TestAll.py
1524 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1525 if TrsfOp.IsDone() == 0:
1526 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1529 def MakeRotation(theObject, theAxis, theAngle):
1531 * Rotate the given object around the given axis
1532 * on the given angle, creating its copy before the rotatation.
1533 * \param theObject The object to be rotated.
1534 * \param theAxis Rotation axis.
1535 * \param theAngle Rotation angle in radians.
1536 * \return New GEOM_Object, containing the rotated object.
1538 * Example: see GEOM_TestAll.py
1540 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1541 if TrsfOp.IsDone() == 0:
1542 print "RotateCopy : ", TrsfOp.GetErrorCode()
1545 def MakeScaleTransform(theObject, thePoint, theFactor):
1547 * Scale the given object by the factor, creating its copy before the scaling.
1548 * \param theObject The object to be scaled.
1549 * \param thePoint Center point for scaling.
1550 * \param theFactor Scaling factor value.
1551 * \return New GEOM_Object, containing the scaled shape.
1553 * Example: see GEOM_TestAll.py
1555 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1556 if TrsfOp.IsDone() == 0:
1557 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1560 def MakeMirrorByPlane(theObject, thePlane):
1562 * Create an object, symmetrical
1563 * to the given one relatively the given plane.
1564 * \param theObject The object to be mirrored.
1565 * \param thePlane Plane of symmetry.
1566 * \return New GEOM_Object, containing the mirrored shape.
1568 * Example: see GEOM_TestAll.py
1570 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1571 if TrsfOp.IsDone() == 0:
1572 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1575 def MakeMirrorByAxis(theObject, theAxis):
1577 * Create an object, symmetrical
1578 * to the given one relatively the given axis.
1579 * \param theObject The object to be mirrored.
1580 * \param theAxis Axis of symmetry.
1581 * \return New GEOM_Object, containing the mirrored shape.
1583 * Example: see GEOM_TestAll.py
1585 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1586 if TrsfOp.IsDone() == 0:
1587 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1590 def MakeMirrorByPoint(theObject, thePoint):
1592 * Create an object, symmetrical
1593 * to the given one relatively the given point.
1594 * \param theObject The object to be mirrored.
1595 * \param thePoint Point of symmetry.
1596 * \return New GEOM_Object, containing the mirrored shape.
1598 * Example: see GEOM_TestAll.py
1600 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1601 if TrsfOp.IsDone() == 0:
1602 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1605 def MakePosition(theObject, theStartLCS, theEndLCS):
1607 * Modify the Location of the given object by LCS
1608 * creating its copy before the setting
1610 * Example: see GEOM_TestAll.py
1612 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1613 if TrsfOp.IsDone() == 0:
1614 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1617 def MakeOffset(theObject, theOffset):
1619 * Create new object as offset of the given one.
1620 * \param theObject The base object for the offset.
1621 * \param theOffset Offset value.
1622 * \return New GEOM_Object, containing the offset object.
1624 * Example: see GEOM_TestAll.py
1626 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1627 if TrsfOp.IsDone() == 0:
1628 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1631 # -----------------------------------------------------------------------------
1633 # -----------------------------------------------------------------------------
1635 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1637 * Translate the given object along the given vector a given number times
1638 * \param theObject The object to be translated.
1639 * \param theVector Direction of the translation.
1640 * \param theStep Distance to translate on.
1641 * \param theNbTimes Quantity of translations to be done.
1642 * \return New GEOM_Object, containing compound of all
1643 * the shapes, obtained after each translation.
1645 * Example: see GEOM_TestAll.py
1647 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1648 if TrsfOp.IsDone() == 0:
1649 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1652 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1653 theVector2, theStep2, theNbTimes2):
1655 * Conseqently apply two specified translations to theObject specified number of times.
1656 * \param theObject The object to be translated.
1657 * \param theVector1 Direction of the first translation.
1658 * \param theStep1 Step of the first translation.
1659 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1660 * \param theVector2 Direction of the second translation.
1661 * \param theStep2 Step of the second translation.
1662 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1663 * \return New GEOM_Object, containing compound of all
1664 * the shapes, obtained after each translation.
1666 * Example: see GEOM_TestAll.py
1668 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1669 theVector2, theStep2, theNbTimes2)
1670 if TrsfOp.IsDone() == 0:
1671 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1674 def MultiRotate1D(theObject, theAxis, theNbTimes):
1676 * Rotate the given object around the given axis a given number times.
1677 * Rotation angle will be 2*PI/theNbTimes.
1678 * \param theObject The object to be rotated.
1679 * \param theAxis The rotation axis.
1680 * \param theNbTimes Quantity of rotations to be done.
1681 * \return New GEOM_Object, containing compound of all the
1682 * shapes, obtained after each rotation.
1684 * Example: see GEOM_TestAll.py
1686 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1687 if TrsfOp.IsDone() == 0:
1688 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1691 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1693 * Rotate the given object around the
1694 * given axis on the given angle a given number
1695 * times and multi-translate each rotation result.
1696 * Translation direction passes through center of gravity
1697 * of rotated shape and its projection on the rotation axis.
1698 * \param theObject The object to be rotated.
1699 * \param theAxis Rotation axis.
1700 * \param theAngle Rotation angle in graduces.
1701 * \param theNbTimes1 Quantity of rotations to be done.
1702 * \param theStep Translation distance.
1703 * \param theNbTimes2 Quantity of translations to be done.
1704 * \return New GEOM_Object, containing compound of all the
1705 * shapes, obtained after each transformation.
1707 * Example: see GEOM_TestAll.py
1709 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1710 if TrsfOp.IsDone() == 0:
1711 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1714 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1716 * The same, as MultiRotate1D(), but axis is given by direction and point
1718 * Example: see GEOM_TestOthers.py
1720 aVec = MakeLine(aPoint,aDir)
1721 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1724 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1726 * The same, as MultiRotate2D(), but axis is given by direction and point
1728 * Example: see GEOM_TestOthers.py
1730 aVec = MakeLine(aPoint,aDir)
1731 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1734 # -----------------------------------------------------------------------------
1736 # -----------------------------------------------------------------------------
1738 def MakeFilletAll(theShape, theR):
1740 * Perform a fillet on all edges of the given shape.
1741 * \param theShape Shape, to perform fillet on.
1742 * \param theR Fillet radius.
1743 * \return New GEOM_Object, containing the result shape.
1745 * Example: see GEOM_TestOthers.py
1747 anObj = LocalOp.MakeFilletAll(theShape, theR)
1748 if LocalOp.IsDone() == 0:
1749 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1752 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1754 * Perform a fillet on the specified edges/faces of the given shape
1755 * \param theShape Shape, to perform fillet on.
1756 * \param theR Fillet radius.
1757 * \param theShapeType Type of shapes in <theListShapes>.
1758 * \param theListShapes Global indices of edges/faces to perform fillet on.
1759 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1760 * \return New GEOM_Object, containing the result shape.
1762 * Example: see GEOM_TestAll.py
1765 if theShapeType == ShapeType["EDGE"]:
1766 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1768 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1769 if LocalOp.IsDone() == 0:
1770 print "MakeFillet : ", LocalOp.GetErrorCode()
1773 def MakeChamferAll(theShape, theD):
1775 * Perform a symmetric chamfer on all edges of the given shape.
1776 * \param theShape Shape, to perform chamfer on.
1777 * \param theD Chamfer size along each face.
1778 * \return New GEOM_Object, containing the result shape.
1780 * Example: see GEOM_TestOthers.py
1782 anObj = LocalOp.MakeChamferAll(theShape, theD)
1783 if LocalOp.IsDone() == 0:
1784 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1787 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1789 * Perform a chamfer on edges, common to the specified faces,
1790 * with distance D1 on the Face1
1791 * \param theShape Shape, to perform chamfer on.
1792 * \param theD1 Chamfer size along \a theFace1.
1793 * \param theD2 Chamfer size along \a theFace2.
1794 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1795 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1796 * \return New GEOM_Object, containing the result shape.
1798 * Example: see GEOM_TestAll.py
1800 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1801 if LocalOp.IsDone() == 0:
1802 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1805 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1807 * Perform a chamfer on all edges of the specified faces,
1808 * with distance D1 on the first specified face (if several for one edge)
1809 * \param theShape Shape, to perform chamfer on.
1810 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1811 * connected to the edge, are in \a theFaces, \a theD1
1812 * will be get along face, which is nearer to \a theFaces beginning.
1813 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1814 * \param theFaces Sequence of global indices of faces of \a theShape.
1815 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1816 * \return New GEOM_Object, containing the result shape.
1818 * Example: see GEOM_TestAll.py
1820 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1821 if LocalOp.IsDone() == 0:
1822 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1825 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1827 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1829 * Example: see GEOM_TestOthers.py
1832 if aShapeType == ShapeType["EDGE"]:
1833 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1835 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1838 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1840 * Perform an Archimde operation on the given shape with given parameters.
1841 * The object presenting the resulting face is returned
1842 * \param theShape Shape to be put in water.
1843 * \param theWeight Weight og the shape.
1844 * \param theWaterDensity Density of the water.
1845 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1846 * \return New GEOM_Object, containing a section of \a theShape
1847 * by a plane, corresponding to water level.
1849 * Example: see GEOM_TestAll.py
1851 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1852 if LocalOp.IsDone() == 0:
1853 print "MakeArchimede : ", LocalOp.GetErrorCode()
1856 # -----------------------------------------------------------------------------
1857 # Information objects
1858 # -----------------------------------------------------------------------------
1860 def PointCoordinates(Point):
1862 * Get point coordinates
1865 * Example: see GEOM_TestMeasures.py
1867 aTuple = MeasuOp.PointCoordinates(Point)
1868 if MeasuOp.IsDone() == 0:
1869 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1872 def BasicProperties(theShape):
1874 * Get summarized length of all wires,
1875 * area of surface and volume of the given shape.
1876 * \param theShape Shape to define properties of.
1877 * \return [theLength, theSurfArea, theVolume]
1878 * theLength: Summarized length of all wires of the given shape.
1879 * theSurfArea: Area of surface of the given shape.
1880 * theVolume: Volume of the given shape.
1882 * Example: see GEOM_TestMeasures.py
1884 aTuple = MeasuOp.GetBasicProperties(theShape)
1885 if MeasuOp.IsDone() == 0:
1886 print "BasicProperties : ", MeasuOp.GetErrorCode()
1889 def BoundingBox(theShape):
1891 * Get parameters of bounding box of the given shape
1892 * \param theShape Shape to obtain bounding box of.
1893 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1894 * Xmin,Xmax: Limits of shape along OX axis.
1895 * Ymin,Ymax: Limits of shape along OY axis.
1896 * Zmin,Zmax: Limits of shape along OZ axis.
1898 * Example: see GEOM_TestMeasures.py
1900 aTuple = MeasuOp.GetBoundingBox(theShape)
1901 if MeasuOp.IsDone() == 0:
1902 print "BoundingBox : ", MeasuOp.GetErrorCode()
1905 def Inertia(theShape):
1907 * Get inertia matrix and moments of inertia of theShape.
1908 * \param theShape Shape to calculate inertia of.
1909 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1910 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1911 * Ix,Iy,Iz: Moments of inertia of the given shape.
1913 * Example: see GEOM_TestMeasures.py
1915 aTuple = MeasuOp.GetInertia(theShape)
1916 if MeasuOp.IsDone() == 0:
1917 print "Inertia : ", MeasuOp.GetErrorCode()
1920 def MinDistance(theShape1, theShape2):
1922 * Get minimal distance between the given shapes.
1923 * \param theShape1,theShape2 Shapes to find minimal distance between.
1924 * \return Value of the minimal distance between the given shapes.
1926 * Example: see GEOM_TestMeasures.py
1928 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1929 if MeasuOp.IsDone() == 0:
1930 print "MinDistance : ", MeasuOp.GetErrorCode()
1933 def Tolerance(theShape):
1935 * Get min and max tolerances of sub-shapes of theShape
1936 * \param theShape Shape, to get tolerances of.
1937 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1938 * FaceMin,FaceMax: Min and max tolerances of the faces.
1939 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1940 * VertMin,VertMax: Min and max tolerances of the vertices.
1942 * Example: see GEOM_TestMeasures.py
1944 aTuple = MeasuOp.GetTolerance(theShape)
1945 if MeasuOp.IsDone() == 0:
1946 print "Tolerance : ", MeasuOp.GetErrorCode()
1949 def WhatIs(theShape):
1951 * Obtain description of the given shape (number of sub-shapes of each type)
1952 * \param theShape Shape to be described.
1953 * \return Description of the given shape.
1955 * Example: see GEOM_TestMeasures.py
1957 aDescr = MeasuOp.WhatIs(theShape)
1958 if MeasuOp.IsDone() == 0:
1959 print "WhatIs : ", MeasuOp.GetErrorCode()
1962 def MakeCDG(theShape):
1964 * Get a point, situated at the centre of mass of theShape.
1965 * \param theShape Shape to define centre of mass of.
1966 * \return New GEOM_Object, containing the created point.
1968 * Example: see GEOM_TestMeasures.py
1970 anObj = MeasuOp.GetCentreOfMass(theShape)
1971 if MeasuOp.IsDone() == 0:
1972 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1975 def CheckShape(theShape):
1977 * Check a topology of the given shape.
1978 * \param theShape Shape to check validity of.
1979 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1980 * If theShape is invalid, prints a description of problem.
1982 * Example: see GEOM_TestMeasures.py
1984 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1985 if MeasuOp.IsDone() == 0:
1986 print "CheckShape : ", MeasuOp.GetErrorCode()
1992 # -----------------------------------------------------------------------------
1993 # Import/Export objects
1994 # -----------------------------------------------------------------------------
1996 def Import(theFileName, theFormatName):
1998 * Import a shape from the BREP or IGES or STEP file
1999 * (depends on given format) with given name.
2000 * \param theFileName The file, containing the shape.
2001 * \param theFormatName Specify format for the file reading.
2002 * Available formats can be obtained with InsertOp.ImportTranslators() method.
2003 * \return New GEOM_Object, containing the imported shape.
2005 * Example: see GEOM_TestOthers.py
2007 anObj = InsertOp.Import(theFileName, theFormatName)
2008 if InsertOp.IsDone() == 0:
2009 print "Import : ", InsertOp.GetErrorCode()
2012 def ImportBREP(theFileName):
2014 * Shortcut to Import() for BREP format
2016 * Example: see GEOM_TestOthers.py
2018 return Import(theFileName, "BREP")
2020 def ImportIGES(theFileName):
2022 * Shortcut to Import() for IGES format
2024 * Example: see GEOM_TestOthers.py
2026 return Import(theFileName, "IGES")
2028 def ImportSTEP(theFileName):
2030 * Shortcut to Import() for STEP format
2032 * Example: see GEOM_TestOthers.py
2034 return Import(theFileName, "STEP")
2036 def Export(theObject, theFileName, theFormatName):
2038 * Export the given shape into a file with given name.
2039 * \param theObject Shape to be stored in the file.
2040 * \param theFileName Name of the file to store the given shape in.
2041 * \param theFormatName Specify format for the shape storage.
2042 * Available formats can be obtained with InsertOp.ImportTranslators() method.
2044 * Example: see GEOM_TestOthers.py
2046 InsertOp.Export(theObject, theFileName, theFormatName)
2047 if InsertOp.IsDone() == 0:
2048 print "Export : ", InsertOp.GetErrorCode()
2050 def ExportBREP(theObject, theFileName):
2052 * Shortcut to Export() for BREP format
2054 * Example: see GEOM_TestOthers.py
2056 return Export(theObject, theFileName, "BREP")
2058 def ExportIGES(theObject, theFileName):
2060 * Shortcut to Export() for IGES format
2062 * Example: see GEOM_TestOthers.py
2064 return Export(theObject, theFileName, "IGES")
2066 def ExportSTEP(theObject, theFileName):
2068 * Shortcut to Export() for STEP format
2070 * Example: see GEOM_TestOthers.py
2072 return Export(theObject, theFileName, "STEP")
2074 # -----------------------------------------------------------------------------
2076 # -----------------------------------------------------------------------------
2078 def MakeQuad(E1, E2, E3, E4):
2080 * Create a quadrangle face from four edges. Order of Edges is not
2081 * important. It is not necessary that edges share the same vertex.
2082 * \param E1,E2,E3,E4 Edges for the face bound.
2083 * \return New GEOM_Object, containing the created face.
2085 * Example: see GEOM_Spanner.py
2087 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2088 if BlocksOp.IsDone() == 0:
2089 print "MakeQuad : ", BlocksOp.GetErrorCode()
2092 def MakeQuad2Edges(E1, E2):
2094 * Create a quadrangle face on two edges.
2095 * The missing edges will be built by creating the shortest ones.
2096 * \param E1,E2 Two opposite edges for the face.
2097 * \return New GEOM_Object, containing the created face.
2099 * Example: see GEOM_Spanner.py
2101 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2102 if BlocksOp.IsDone() == 0:
2103 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2106 def MakeQuad4Vertices(V1, V2, V3, V4):
2108 * Create a quadrangle face with specified corners.
2109 * The missing edges will be built by creating the shortest ones.
2110 * \param V1,V2,V3,V4 Corner vertices for the face.
2111 * \return New GEOM_Object, containing the created face.
2113 * Example: see GEOM_Spanner.py
2115 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2116 if BlocksOp.IsDone() == 0:
2117 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2120 def MakeHexa(F1, F2, F3, F4, F5, F6):
2122 * Create a hexahedral solid, bounded by the six given faces. Order of
2123 * faces is not important. It is not necessary that Faces share the same edge.
2124 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2125 * \return New GEOM_Object, containing the created solid.
2127 * Example: see GEOM_Spanner.py
2129 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2130 if BlocksOp.IsDone() == 0:
2131 print "MakeHexa : ", BlocksOp.GetErrorCode()
2134 def MakeHexa2Faces(F1, F2):
2136 * Create a hexahedral solid between two given faces.
2137 * The missing faces will be built by creating the smallest ones.
2138 * \param F1,F2 Two opposite faces for the hexahedral solid.
2139 * \return New GEOM_Object, containing the created solid.
2141 * Example: see GEOM_Spanner.py
2143 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2144 if BlocksOp.IsDone() == 0:
2145 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2148 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2150 * Get a vertex, found in the given shape by its coordinates.
2151 * \param theShape Block or a compound of blocks.
2152 * \param theX,theY,theZ Coordinates of the sought vertex.
2153 * \param theEpsilon Maximum allowed distance between the resulting
2154 * vertex and point with the given coordinates.
2155 * \return New GEOM_Object, containing the found vertex.
2157 * Example: see GEOM_TestOthers.py
2159 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2160 if BlocksOp.IsDone() == 0:
2161 print "GetPoint : ", BlocksOp.GetErrorCode()
2164 def GetEdge(theShape, thePoint1, thePoint2):
2166 * Get an edge, found in the given shape by two given vertices.
2167 * \param theShape Block or a compound of blocks.
2168 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2169 * \return New GEOM_Object, containing the found edge.
2171 * Example: see GEOM_Spanner.py
2173 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2174 if BlocksOp.IsDone() == 0:
2175 print "GetEdge : ", BlocksOp.GetErrorCode()
2178 def GetEdgeNearPoint(theShape, thePoint):
2180 * Find an edge of the given shape, which has minimal distance to the given point.
2181 * \param theShape Block or a compound of blocks.
2182 * \param thePoint Point, close to the desired edge.
2183 * \return New GEOM_Object, containing the found edge.
2185 * Example: see GEOM_TestOthers.py
2187 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2188 if BlocksOp.IsDone() == 0:
2189 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2192 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2194 * Returns a face, found in the given shape by four given corner vertices.
2195 * \param theShape Block or a compound of blocks.
2196 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2197 * \return New GEOM_Object, containing the found face.
2199 * Example: see GEOM_Spanner.py
2201 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2202 if BlocksOp.IsDone() == 0:
2203 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2206 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2208 * Get a face of block, found in the given shape by two given edges.
2209 * \param theShape Block or a compound of blocks.
2210 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2211 * \return New GEOM_Object, containing the found face.
2213 * Example: see GEOM_Spanner.py
2215 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2216 if BlocksOp.IsDone() == 0:
2217 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2220 def GetOppositeFace(theBlock, theFace):
2222 * Find a face, opposite to the given one in the given block.
2223 * \param theBlock Must be a hexahedral solid.
2224 * \param theFace Face of \a theBlock, opposite to the desired face.
2225 * \return New GEOM_Object, containing the found face.
2227 * Example: see GEOM_Spanner.py
2229 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2230 if BlocksOp.IsDone() == 0:
2231 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2234 def GetFaceNearPoint(theShape, thePoint):
2236 * Find a face of the given shape, which has minimal distance to the given point.
2237 * \param theShape Block or a compound of blocks.
2238 * \param thePoint Point, close to the desired face.
2239 * \return New GEOM_Object, containing the found face.
2241 * Example: see GEOM_Spanner.py
2243 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2244 if BlocksOp.IsDone() == 0:
2245 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2248 def GetFaceByNormale(theBlock, theVector):
2250 * Find a face of block, whose outside normale has minimal angle with the given vector.
2251 * \param theShape Block or a compound of blocks.
2252 * \param theVector Vector, close to the normale of the desired face.
2253 * \return New GEOM_Object, containing the found face.
2255 * Example: see GEOM_Spanner.py
2257 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2258 if BlocksOp.IsDone() == 0:
2259 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2262 def CheckCompoundOfBlocks(theCompound):
2264 * Check, if the compound of blocks is given.
2265 * To be considered as a compound of blocks, the
2266 * given shape must satisfy the following conditions:
2267 * - Each element of the compound should be a Block (6 faces and 12 edges).
2268 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2269 * - The compound should be connexe.
2270 * - The glue between two quadrangle faces should be applied.
2271 * \param theCompound The compound to check.
2272 * \return TRUE, if the given shape is a compound of blocks.
2273 * If theCompound is not valid, prints all discovered errors.
2275 * Example: see GEOM_Spanner.py
2277 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2278 if BlocksOp.IsDone() == 0:
2279 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2282 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2286 def RemoveExtraEdges(theShape):
2288 * Remove all seam and degenerated edges from \a theShape.
2289 * Unite faces and edges, sharing one surface.
2290 * \param theShape The compound or single solid to remove irregular edges from.
2291 * \return Improved shape.
2293 * Example: see GEOM_TestOthers.py
2295 anObj = BlocksOp.RemoveExtraEdges(theShape)
2296 if BlocksOp.IsDone() == 0:
2297 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2300 def CheckAndImprove(theShape):
2302 * Check, if the given shape is a blocks compound.
2303 * Fix all detected errors.
2304 * \note Single block can be also fixed by this method.
2305 * \param theCompound The compound to check and improve.
2306 * \return Improved compound.
2308 * Example: see GEOM_TestOthers.py
2310 anObj = BlocksOp.CheckAndImprove(theShape)
2311 if BlocksOp.IsDone() == 0:
2312 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2315 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2317 * Get all the blocks, contained in the given compound.
2318 * \param theCompound The compound to explode.
2319 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2320 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2321 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2322 * \return List of GEOM_Objects, containing the retrieved blocks.
2324 * Example: see GEOM_TestOthers.py
2326 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2327 if BlocksOp.IsDone() == 0:
2328 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2331 def GetBlockNearPoint(theCompound, thePoint):
2333 * Find block, containing the given point inside its volume or on boundary.
2334 * \param theCompound Compound, to find block in.
2335 * \param thePoint Point, close to the desired block. If the point lays on
2336 * boundary between some blocks, we return block with nearest center.
2337 * \return New GEOM_Object, containing the found block.
2339 * Example: see GEOM_Spanner.py
2341 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2342 if BlocksOp.IsDone() == 0:
2343 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2346 def GetBlockByParts(theCompound, theParts):
2348 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2349 * \param theCompound Compound, to find block in.
2350 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2351 * \return New GEOM_Object, containing the found block.
2353 * Example: see GEOM_TestOthers.py
2355 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2356 if BlocksOp.IsDone() == 0:
2357 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2360 def GetBlocksByParts(theCompound, theParts):
2362 * Return all blocks, containing all the elements, passed as the parts.
2363 * \param theCompound Compound, to find blocks in.
2364 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2365 * \return List of GEOM_Objects, containing the found blocks.
2367 * Example: see GEOM_Spanner.py
2369 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2370 if BlocksOp.IsDone() == 0:
2371 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2374 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2376 * Multi-transformate block and glue the result.
2377 * Transformation is defined so, as to superpose direction faces.
2378 * \param Block Hexahedral solid to be multi-transformed.
2379 * \param DirFace1 ID of First direction face.
2380 * \param DirFace2 ID of Second direction face.
2381 * \param NbTimes Quantity of transformations to be done.
2382 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2383 * \return New GEOM_Object, containing the result shape.
2385 * Example: see GEOM_Spanner.py
2387 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2388 if BlocksOp.IsDone() == 0:
2389 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2392 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2393 DirFace1V, DirFace2V, NbTimesV):
2395 * Multi-transformate block and glue the result.
2396 * \param Block Hexahedral solid to be multi-transformed.
2397 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2398 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2399 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2400 * \return New GEOM_Object, containing the result shape.
2402 * Example: see GEOM_Spanner.py
2404 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2405 DirFace1V, DirFace2V, NbTimesV)
2406 if BlocksOp.IsDone() == 0:
2407 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2410 def Propagate(theShape):
2412 * Build all possible propagation groups.
2413 * Propagation group is a set of all edges, opposite to one (main)
2414 * edge of this group directly or through other opposite edges.
2415 * Notion of Opposite Edge make sence only on quadrangle face.
2416 * \param theShape Shape to build propagation groups on.
2417 * \return List of GEOM_Objects, each of them is a propagation group.
2419 * Example: see GEOM_TestOthers.py
2421 listChains = BlocksOp.Propagate(theShape)
2422 if BlocksOp.IsDone() == 0:
2423 print "Propagate : ", BlocksOp.GetErrorCode()
2426 # -----------------------------------------------------------------------------
2428 # -----------------------------------------------------------------------------
2430 def CreateGroup(theMainShape, theShapeType):
2432 * Creates a new group which will store sub shapes of theMainShape
2433 * \param theMainShape is a GEOM object on which the group is selected
2434 * \param theShapeType defines a shape type of the group
2435 * \return a newly created GEOM group
2437 * Example: see GEOM_TestOthers.py
2439 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2440 if GroupOp.IsDone() == 0:
2441 print "CreateGroup : ", GroupOp.GetErrorCode()
2444 def AddObject(theGroup, theSubShapeID):
2446 * Adds a sub object with ID theSubShapeId to the group
2447 * \param theGroup is a GEOM group to which the new sub shape is added
2448 * \param theSubShapeID is a sub shape ID in the main object.
2449 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2451 * Example: see GEOM_TestOthers.py
2453 GroupOp.AddObject(theGroup, theSubShapeID)
2454 if GroupOp.IsDone() == 0:
2455 print "AddObject : ", GroupOp.GetErrorCode()
2457 def RemoveObject(theGroup, theSubShapeID):
2459 * Removes a sub object with ID \a theSubShapeId from the group
2460 * \param theGroup is a GEOM group from which the new sub shape is removed
2461 * \param theSubShapeID is a sub shape ID in the main object.
2462 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2464 * Example: see GEOM_TestOthers.py
2466 GroupOp.RemoveObject(theGroup, theSubShapeID)
2467 if GroupOp.IsDone() == 0:
2468 print "RemoveObject : ", GroupOp.GetErrorCode()
2470 def UnionList (theGroup, theSubShapes):
2472 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2473 * \param theGroup is a GEOM group to which the new sub shapes are added.
2474 * \param theSubShapes is a list of sub shapes to be added.
2476 * Example: see GEOM_TestOthers.py
2478 GroupOp.UnionList(theGroup, theSubShapes)
2479 if GroupOp.IsDone() == 0:
2480 print "UnionList : ", GroupOp.GetErrorCode()
2482 def UnionIDs(theGroup, theSubShapes):
2484 * Works like the above method, but argument
2485 * theSubShapes here is a list of sub-shapes indices
2487 * Example: see GEOM_TestOthers.py
2489 GroupOp.UnionIDs(theGroup, theSubShapes)
2490 if GroupOp.IsDone() == 0:
2491 print "UnionIDs : ", GroupOp.GetErrorCode()
2493 def DifferenceList (theGroup, theSubShapes):
2495 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2496 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2497 * \param theSubShapes is a list of sub-shapes to be removed.
2499 * Example: see GEOM_TestOthers.py
2501 GroupOp.DifferenceList(theGroup, theSubShapes)
2502 if GroupOp.IsDone() == 0:
2503 print "DifferenceList : ", GroupOp.GetErrorCode()
2505 def DifferenceIDs(theGroup, theSubShapes):
2507 * Works like the above method, but argument
2508 * theSubShapes here is a list of sub-shapes indices
2510 * Example: see GEOM_TestOthers.py
2512 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2513 if GroupOp.IsDone() == 0:
2514 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2516 def GetObjectIDs(theGroup):
2518 * Returns a list of sub objects ID stored in the group
2519 * \param theGroup is a GEOM group for which a list of IDs is requested
2521 * Example: see GEOM_TestOthers.py
2523 ListIDs = GroupOp.GetObjects(theGroup)
2524 if GroupOp.IsDone() == 0:
2525 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2528 def GetType(theGroup):
2530 * Returns a type of sub objects stored in the group
2531 * \param theGroup is a GEOM group which type is returned.
2533 * Example: see GEOM_TestOthers.py
2535 aType = GroupOp.GetType(theGroup)
2536 if GroupOp.IsDone() == 0:
2537 print "GetType : ", GroupOp.GetErrorCode()
2540 def GetMainShape(theGroup):
2542 * Returns a main shape associated with the group
2543 * \param theGroup is a GEOM group for which a main shape object is requested
2544 * \return a GEOM object which is a main shape for theGroup
2546 * Example: see GEOM_TestOthers.py
2548 anObj = GroupOp.GetMainShape(theGroup)
2549 if GroupOp.IsDone() == 0:
2550 print "GetMainShape : ", GroupOp.GetErrorCode()
2553 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2555 Create group of edges of theShape, whose length is in range [min_length, max_length].
2556 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2559 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2562 Props = BasicProperties(edge)
2563 if min_length <= Props[0] and Props[0] <= max_length:
2564 if (not include_min) and (min_length == Props[0]):
2567 if (not include_max) and (Props[0] == max_length):
2570 edges_in_range.append(edge)
2572 if len(edges_in_range) <= 0:
2573 print "No edges found by given criteria"
2576 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2577 UnionList(group_edges, edges_in_range)
2581 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2583 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2584 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2587 nb_selected = sg.SelectedCount()
2589 print "Select a shape before calling this function, please."
2592 print "Only one shape must be selected"
2595 id_shape = sg.getSelected(0)
2596 shape = IDToObject( id_shape )
2598 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2602 if include_min: left_str = " <= "
2603 if include_max: right_str = " <= "
2605 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2606 + left_str + "length" + right_str + `max_length`)
2608 sg.updateObjBrowser(1)
2614 * Add Path to load python scripts from
2616 if (sys.path.count(Path) < 1):
2617 sys.path.append(Path)