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")
41 #SRN: modified on Mar 18, 2005
60 def init_geom(theStudy):
62 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
63 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
66 myStudyId = myStudy._get_StudyId()
67 myBuilder = myStudy.NewBuilder()
68 father = myStudy.FindComponent("GEOM")
70 father = myBuilder.NewComponent("GEOM")
71 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
72 FName = A1._narrow(SALOMEDS.AttributeName)
73 FName.SetValue("Geometry")
74 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
75 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
76 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
77 myBuilder.DefineComponentInstance(father,geom)
80 # -----------------------------------------------------------------------------
81 # Assign Operations Interfaces
82 # -----------------------------------------------------------------------------
84 BasicOp = geom.GetIBasicOperations (myStudyId)
85 CurvesOp = geom.GetICurvesOperations (myStudyId)
86 PrimOp = geom.GetI3DPrimOperations (myStudyId)
87 ShapesOp = geom.GetIShapesOperations (myStudyId)
88 HealOp = geom.GetIHealingOperations (myStudyId)
89 InsertOp = geom.GetIInsertOperations (myStudyId)
90 BoolOp = geom.GetIBooleanOperations (myStudyId)
91 TrsfOp = geom.GetITransformOperations(myStudyId)
92 LocalOp = geom.GetILocalOperations (myStudyId)
93 MeasuOp = geom.GetIMeasureOperations (myStudyId)
94 BlocksOp = geom.GetIBlocksOperations (myStudyId)
95 GroupOp = geom.GetIGroupOperations (myStudyId)
100 #SRN: end of modifications
102 def SubShapeName(aSubObj, aMainObj):
104 * Get name for sub-shape aSubObj of shape aMainObj
106 * Example: see GEOM_TestAll.py
108 aSubId = orb.object_to_string(aSubObj)
109 aMainId = orb.object_to_string(aMainObj)
110 index = gg.getIndexTopology(aSubId, aMainId)
111 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
114 def addToStudy(aShape, aName):
116 * Publish in study aShape with name aName
118 * Example: see GEOM_TestAll.py
121 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
123 print "addToStudy() failed"
125 return aShape.GetStudyEntry()
127 def addToStudyInFather(aFather, aShape, aName):
129 * Publish in study aShape with name aName as sub-object of previously published aFather
131 * Example: see GEOM_TestAll.py
134 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
136 print "addToStudyInFather() failed"
138 return aShape.GetStudyEntry()
140 # -----------------------------------------------------------------------------
141 # enumeration ShapeType as a dictionary
142 # -----------------------------------------------------------------------------
144 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
146 # -----------------------------------------------------------------------------
148 # -----------------------------------------------------------------------------
150 def MakeVertex(theX, theY, theZ):
152 * Create point by three coordinates.
153 * \param theX The X coordinate of the point.
154 * \param theY The Y coordinate of the point.
155 * \param theZ The Z coordinate of the point.
156 * \return New GEOM_Object, containing the created point.
158 * Example: see GEOM_TestAll.py
160 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
161 if BasicOp.IsDone() == 0:
162 print "MakePointXYZ : ", BasicOp.GetErrorCode()
165 def MakeVertexWithRef(theReference, theX, theY, theZ):
167 * Create a point, distant from the referenced point
168 * on the given distances along the coordinate axes.
169 * \param theReference The referenced point.
170 * \param theX Displacement from the referenced point along OX axis.
171 * \param theY Displacement from the referenced point along OY axis.
172 * \param theZ Displacement from the referenced point along OZ axis.
173 * \return New GEOM_Object, containing the created point.
175 * Example: see GEOM_TestAll.py
177 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
178 if BasicOp.IsDone() == 0:
179 print "MakePointWithReference : ", BasicOp.GetErrorCode()
182 def MakeVertexOnCurve(theRefCurve, theParameter):
184 * Create a point, corresponding to the given parameter on the given curve.
185 * \param theRefCurve The referenced curve.
186 * \param theParameter Value of parameter on the referenced curve.
187 * \return New GEOM_Object, containing the created point.
189 * Example: see GEOM_TestAll.py
191 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
192 if BasicOp.IsDone() == 0:
193 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
196 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
198 * Create a vector with the given components.
199 * \param theDX X component of the vector.
200 * \param theDY Y component of the vector.
201 * \param theDZ Z component of the vector.
202 * \return New GEOM_Object, containing the created vector.
204 * Example: see GEOM_TestAll.py
206 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
207 if BasicOp.IsDone() == 0:
208 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
211 def MakeVector(thePnt1, thePnt2):
213 * Create a vector between two points.
214 * \param thePnt1 Start point for the vector.
215 * \param thePnt2 End point for the vector.
216 * \return New GEOM_Object, containing the created vector.
218 * Example: see GEOM_TestAll.py
220 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
221 if BasicOp.IsDone() == 0:
222 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
225 def MakeLine(thePnt, theDir):
227 * Create a line, passing through the given point
228 * and parrallel to the given direction
229 * \param thePnt Point. The resulting line will pass through it.
230 * \param theDir Direction. The resulting line will be parallel to it.
231 * \return New GEOM_Object, containing the created line.
233 * Example: see GEOM_TestAll.py
235 anObj = BasicOp.MakeLine(thePnt, theDir)
236 if BasicOp.IsDone() == 0:
237 print "MakeLine : ", BasicOp.GetErrorCode()
240 def MakeLineTwoPnt(thePnt1, thePnt2):
242 * Create a line, passing through the given points
243 * \param thePnt1 First of two points, defining the line.
244 * \param thePnt2 Second of two points, defining the line.
245 * \return New GEOM_Object, containing the created line.
247 * Example: see GEOM_TestAll.py
249 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
250 if BasicOp.IsDone() == 0:
251 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
254 def MakePlane(thePnt, theVec, theTrimSize):
256 * Create a plane, passing through the given point
257 * and normal to the given vector.
258 * \param thePnt Point, the plane has to pass through.
259 * \param theVec Vector, defining the plane normal direction.
260 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
261 * \return New GEOM_Object, containing the created plane.
263 * Example: see GEOM_TestAll.py
265 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
266 if BasicOp.IsDone() == 0:
267 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
270 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
272 * Create a plane, passing through the three given points
273 * \param thePnt1 First of three points, defining the plane.
274 * \param thePnt2 Second of three points, defining the plane.
275 * \param thePnt3 Fird of three points, defining the plane.
276 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
277 * \return New GEOM_Object, containing the created plane.
279 * Example: see GEOM_TestAll.py
281 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
282 if BasicOp.IsDone() == 0:
283 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
286 def MakePlaneFace(theFace, theTrimSize):
288 * Create a plane, similar to the existing one, but with another size of representing face.
289 * \param theFace Referenced plane.
290 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
291 * \return New GEOM_Object, containing the created plane.
293 * Example: see GEOM_TestAll.py
295 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
296 if BasicOp.IsDone() == 0:
297 print "MakePlaneFace : ", BasicOp.GetErrorCode()
300 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
302 * Create a local coordinate system.
303 * \param OX,OY,OZ Three coordinates of coordinate system origin.
304 * \param XDX,XDY,XDZ Three components of OX direction
305 * \param YDX,YDY,YDZ Three components of OY direction
306 * \return New GEOM_Object, containing the created coordinate system.
308 * Example: see GEOM_TestAll.py
310 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
311 if BasicOp.IsDone() == 0:
312 print "MakeMarker : ", BasicOp.GetErrorCode()
315 # -----------------------------------------------------------------------------
317 # -----------------------------------------------------------------------------
319 def MakeArc(thePnt1, thePnt2, thePnt3):
321 * Create an arc of circle, passing through three given points.
322 * \param thePnt1 Start point of the arc.
323 * \param thePnt2 Middle point of the arc.
324 * \param thePnt3 End point of the arc.
325 * \return New GEOM_Object, containing the created arc.
327 * Example: see GEOM_TestAll.py
329 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
330 if CurvesOp.IsDone() == 0:
331 print "MakeArc : ", CurvesOp.GetErrorCode()
334 def MakeCircle(thePnt, theVec, theR):
336 * Create a circle with given center, normal vector and radius.
337 * \param thePnt Circle center.
338 * \param theVec Vector, normal to the plane of the circle.
339 * \param theR Circle radius.
340 * \return New GEOM_Object, containing the created circle.
342 * Example: see GEOM_TestAll.py
344 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
345 if CurvesOp.IsDone() == 0:
346 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
349 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
351 * Create a circle, passing through three given points
352 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
353 * \return New GEOM_Object, containing the created circle.
355 * Example: see GEOM_TestAll.py
357 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
358 if CurvesOp.IsDone() == 0:
359 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
362 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
364 * Create an ellipse with given center, normal vector and radiuses.
365 * \param thePnt Ellipse center.
366 * \param theVec Vector, normal to the plane of the ellipse.
367 * \param theRMajor Major ellipse radius.
368 * \param theRMinor Minor ellipse radius.
369 * \return New GEOM_Object, containing the created ellipse.
371 * Example: see GEOM_TestAll.py
373 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
374 if CurvesOp.IsDone() == 0:
375 print "MakeEllipse : ", CurvesOp.GetErrorCode()
378 def MakePolyline(thePoints):
380 * Create a polyline on the set of points.
381 * \param thePoints Sequence of points for the polyline.
382 * \return New GEOM_Object, containing the created polyline.
384 * Example: see GEOM_TestAll.py
386 anObj = CurvesOp.MakePolyline(thePoints)
387 if CurvesOp.IsDone() == 0:
388 print "MakePolyline : ", CurvesOp.GetErrorCode()
391 def MakeBezier(thePoints):
393 * Create bezier curve on the set of points.
394 * \param thePoints Sequence of points for the bezier curve.
395 * \return New GEOM_Object, containing the created bezier curve.
397 * Example: see GEOM_TestAll.py
399 anObj = CurvesOp.MakeSplineBezier(thePoints)
400 if CurvesOp.IsDone() == 0:
401 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
404 def MakeInterpol(thePoints):
406 * Create B-Spline curve on the set of points.
407 * \param thePoints Sequence of points for the B-Spline curve.
408 * \return New GEOM_Object, containing the created B-Spline curve.
410 * Example: see GEOM_TestAll.py
412 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
413 if CurvesOp.IsDone() == 0:
414 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
417 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
419 * Create a sketcher (wire or face), following the textual description,
420 * passed through \a theCommand argument. \n
421 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
422 * Format of the description string have to be the following:
424 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
427 * - x1, y1 are coordinates of the first sketcher point (zero by default),
429 * - "R angle" : Set the direction by angle
430 * - "D dx dy" : Set the direction by DX & DY
433 * - "TT x y" : Create segment by point at X & Y
434 * - "T dx dy" : Create segment by point with DX & DY
435 * - "L length" : Create segment by direction & Length
436 * - "IX x" : Create segment by direction & Intersect. X
437 * - "IY y" : Create segment by direction & Intersect. Y
440 * - "C radius length" : Create arc by direction, radius and length(in degree)
443 * - "WW" : Close Wire (to finish)
444 * - "WF" : Close Wire and build face (to finish)
446 * \param theCommand String, defining the sketcher in local
447 * coordinates of the working plane.
448 * \param theWorkingPlane Nine double values, defining origin,
449 * OZ and OX directions of the working plane.
450 * \return New GEOM_Object, containing the created wire.
452 * Example: see GEOM_TestAll.py
454 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
455 if CurvesOp.IsDone() == 0:
456 print "MakeSketcher : ", CurvesOp.GetErrorCode()
459 # -----------------------------------------------------------------------------
460 # Create 3D Primitives
461 # -----------------------------------------------------------------------------
463 def MakeBox(x1,y1,z1,x2,y2,z2):
465 * Create a box by coordinates of two opposite vertices.
467 * Example: see GEOM_TestAll.py
469 pnt1 = MakeVertex(x1,y1,z1)
470 pnt2 = MakeVertex(x2,y2,z2)
471 return MakeBoxTwoPnt(pnt1,pnt2)
473 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
475 * Create a box with specified dimensions along the coordinate axes
476 * and with edges, parallel to the coordinate axes.
477 * Center of the box will be at point (DX/2, DY/2, DZ/2).
478 * \param theDX Length of Box edges, parallel to OX axis.
479 * \param theDY Length of Box edges, parallel to OY axis.
480 * \param theDZ Length of Box edges, parallel to OZ axis.
481 * \return New GEOM_Object, containing the created box.
483 * Example: see GEOM_TestAll.py
485 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
486 if PrimOp.IsDone() == 0:
487 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
490 def MakeBoxTwoPnt(thePnt1, thePnt2):
492 * Create a box with two specified opposite vertices,
493 * and with edges, parallel to the coordinate axes
494 * \param thePnt1 First of two opposite vertices.
495 * \param thePnt2 Second of two opposite vertices.
496 * \return New GEOM_Object, containing the created box.
498 * Example: see GEOM_TestAll.py
500 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
501 if PrimOp.IsDone() == 0:
502 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
505 def MakeCylinder(thePnt, theAxis, theR, theH):
507 * Create a cylinder with given base point, axis, radius and height.
508 * \param thePnt Central point of cylinder base.
509 * \param theAxis Cylinder axis.
510 * \param theR Cylinder radius.
511 * \param theH Cylinder height.
512 * \return New GEOM_Object, containing the created cylinder.
514 * Example: see GEOM_TestAll.py
516 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
517 if PrimOp.IsDone() == 0:
518 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
521 def MakeCylinderRH(theR, theH):
523 * Create a cylinder with given radius and height at
524 * the origin of coordinate system. Axis of the cylinder
525 * will be collinear to the OZ axis of the coordinate system.
526 * \param theR Cylinder radius.
527 * \param theH Cylinder height.
528 * \return New GEOM_Object, containing the created cylinder.
530 * Example: see GEOM_TestAll.py
532 anObj = PrimOp.MakeCylinderRH(theR, theH)
533 if PrimOp.IsDone() == 0:
534 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
537 def MakeSpherePntR(thePnt, theR):
539 * Create a sphere with given center and radius.
540 * \param thePnt Sphere center.
541 * \param theR Sphere radius.
542 * \return New GEOM_Object, containing the created sphere.
544 * Example: see GEOM_TestAll.py
546 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
547 if PrimOp.IsDone() == 0:
548 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
551 def MakeSphere(x, y, z, theR):
553 * Create a sphere with given center and radius.
554 * \param x,y,z Coordinates of sphere center.
555 * \param theR Sphere radius.
556 * \return New GEOM_Object, containing the created sphere.
558 * Example: see GEOM_TestAll.py
560 point = MakeVertex(x, y, z)
561 anObj = MakeSpherePntR(point, theR)
564 def MakeSphereR(theR):
566 * Create a sphere with given radius at the origin of coordinate system.
567 * \param theR Sphere radius.
568 * \return New GEOM_Object, containing the created sphere.
570 * Example: see GEOM_TestAll.py
572 anObj = PrimOp.MakeSphereR(theR)
573 if PrimOp.IsDone() == 0:
574 print "MakeSphereR : ", PrimOp.GetErrorCode()
577 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
579 * Create a cone with given base point, axis, height and radiuses.
580 * \param thePnt Central point of the first cone base.
581 * \param theAxis Cone axis.
582 * \param theR1 Radius of the first cone base.
583 * \param theR2 Radius of the second cone base.
584 * \note If both radiuses are non-zero, the cone will be truncated.
585 * \note If the radiuses are equal, a cylinder will be created instead.
586 * \param theH Cone height.
587 * \return New GEOM_Object, containing the created cone.
589 * Example: see GEOM_TestAll.py
591 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
592 if PrimOp.IsDone() == 0:
593 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
596 def MakeConeR1R2H(theR1, theR2, theH):
598 * Create a cone with given height and radiuses at
599 * the origin of coordinate system. Axis of the cone will
600 * be collinear to the OZ axis of the coordinate system.
601 * \param theR1 Radius of the first cone base.
602 * \param theR2 Radius of the second cone base.
603 * \note If both radiuses are non-zero, the cone will be truncated.
604 * \note If the radiuses are equal, a cylinder will be created instead.
605 * \param theH Cone height.
606 * \return New GEOM_Object, containing the created cone.
608 * Example: see GEOM_TestAll.py
610 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
611 if PrimOp.IsDone() == 0:
612 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
615 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
617 * Create a torus with given center, normal vector and radiuses.
618 * \param thePnt Torus central point.
619 * \param theVec Torus axis of symmetry.
620 * \param theRMajor Torus major radius.
621 * \param theRMinor Torus minor radius.
622 * \return New GEOM_Object, containing the created torus.
624 * Example: see GEOM_TestAll.py
626 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
627 if PrimOp.IsDone() == 0:
628 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
631 def MakeTorusRR(theRMajor, theRMinor):
633 * Create a torus with given radiuses at the origin of coordinate system.
634 * \param theRMajor Torus major radius.
635 * \param theRMinor Torus minor radius.
636 * \return New GEOM_Object, containing the created torus.
638 * Example: see GEOM_TestAll.py
640 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
641 if PrimOp.IsDone() == 0:
642 print "MakeTorusRR : ", PrimOp.GetErrorCode()
645 def MakePrism(theBase, thePoint1, thePoint2):
647 * Create a shape by extrusion of the base shape along a vector, defined by two points.
648 * \param theBase Base shape to be extruded.
649 * \param thePoint1 First end of extrusion vector.
650 * \param thePoint2 Second end of extrusion vector.
651 * \return New GEOM_Object, containing the created prism.
653 * Example: see GEOM_TestAll.py
655 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
656 if PrimOp.IsDone() == 0:
657 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
660 def MakePrismVecH(theBase, theVec, theH):
662 * Create a shape by extrusion of the base shape along the vector,
663 * i.e. all the space, transfixed by the base shape during its translation
664 * along the vector on the given distance.
665 * \param theBase Base shape to be extruded.
666 * \param theVec Direction of extrusion.
667 * \param theH Prism dimension along theVec.
668 * \return New GEOM_Object, containing the created prism.
670 * Example: see GEOM_TestAll.py
672 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
673 if PrimOp.IsDone() == 0:
674 print "MakePrismVecH : ", PrimOp.GetErrorCode()
677 def MakePipe(theBase, thePath):
679 * Create a shape by extrusion of the base shape along
680 * the path shape. The path shape can be a wire or an edge.
681 * \param theBase Base shape to be extruded.
682 * \param thePath Path shape to extrude the base shape along it.
683 * \return New GEOM_Object, containing the created pipe.
685 * Example: see GEOM_TestAll.py
687 anObj = PrimOp.MakePipe(theBase, thePath)
688 if PrimOp.IsDone() == 0:
689 print "MakePipe : ", PrimOp.GetErrorCode()
692 def MakeRevolution(theBase, theAxis, theAngle):
694 * Create a shape by revolution of the base shape around the axis
695 * on the given angle, i.e. all the space, transfixed by the base
696 * shape during its rotation around the axis on the given angle.
697 * \param theBase Base shape to be rotated.
698 * \param theAxis Rotation axis.
699 * \param theAngle Rotation angle in radians.
700 * \return New GEOM_Object, containing the created revolution.
702 * Example: see GEOM_TestAll.py
704 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
705 if PrimOp.IsDone() == 0:
706 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
709 # -----------------------------------------------------------------------------
711 # -----------------------------------------------------------------------------
713 def MakeEdge(thePnt1, thePnt2):
715 * Create a linear edge with specified ends.
716 * \param thePnt1 Point for the first end of edge.
717 * \param thePnt2 Point for the second end of edge.
718 * \return New GEOM_Object, containing the created edge.
720 * Example: see GEOM_TestAll.py
722 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
723 if ShapesOp.IsDone() == 0:
724 print "MakeEdge : ", ShapesOp.GetErrorCode()
727 def MakeWire(theEdgesAndWires):
729 * Create a wire from the set of edges and wires.
730 * \param theEdgesAndWires List of edges and/or wires.
731 * \return New GEOM_Object, containing the created wire.
733 * Example: see GEOM_TestAll.py
735 anObj = ShapesOp.MakeWire(theEdgesAndWires)
736 if ShapesOp.IsDone() == 0:
737 print "MakeWire : ", ShapesOp.GetErrorCode()
740 def MakeFace(theWire, isPlanarWanted):
742 * Create a face on the given wire.
743 * \param theWire Wire to build the face on.
744 * \param isPlanarWanted If TRUE, only planar face will be built.
745 * If impossible, NULL object will be returned.
746 * \return New GEOM_Object, containing the created face.
748 * Example: see GEOM_TestAll.py
750 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
751 if ShapesOp.IsDone() == 0:
752 print "MakeFace : ", ShapesOp.GetErrorCode()
755 def MakeFaceWires(theWires, isPlanarWanted):
757 * Create a face on the given wires set.
758 * \param theWires List of wires to build the face on.
759 * \param isPlanarWanted If TRUE, only planar face will be built.
760 * If impossible, NULL object will be returned.
761 * \return New GEOM_Object, containing the created face.
763 * Example: see GEOM_TestAll.py
765 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
766 if ShapesOp.IsDone() == 0:
767 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
770 def MakeFaces(theWires, isPlanarWanted):
772 * Shortcut to MakeFaceWires()
774 * Example: see GEOM_TestOthers.py
776 anObj = MakeFaceWires(theWires, isPlanarWanted)
779 def MakeShell(theFacesAndShells):
781 * Create a shell from the set of faces and shells.
782 * \param theFacesAndShells List of faces and/or shells.
783 * \return New GEOM_Object, containing the created shell.
785 * Example: see GEOM_TestAll.py
787 anObj = ShapesOp.MakeShell(theFacesAndShells)
788 if ShapesOp.IsDone() == 0:
789 print "MakeShell : ", ShapesOp.GetErrorCode()
792 def MakeSolid(theShells):
794 * Create a solid, bounded by the given shells.
795 * \param theShells Sequence of bounding shells.
796 * \return New GEOM_Object, containing the created solid.
798 * Example: see GEOM_TestAll.py
800 anObj = ShapesOp.MakeSolidShells(theShells)
801 if ShapesOp.IsDone() == 0:
802 print "MakeSolid : ", ShapesOp.GetErrorCode()
805 def MakeCompound(theShapes):
807 * Create a compound of the given shapes.
808 * \param theShapes List of shapes to put in compound.
809 * \return New GEOM_Object, containing the created compound.
811 * Example: see GEOM_TestAll.py
813 anObj = ShapesOp.MakeCompound(theShapes)
814 if ShapesOp.IsDone() == 0:
815 print "MakeCompound : ", ShapesOp.GetErrorCode()
818 def NumberOfFaces(theShape):
820 * Gives quantity of faces in the given shape.
821 * \param theShape Shape to count faces of.
822 * \return Quantity of faces.
824 * Example: see GEOM_TestOthers.py
826 nb_faces = ShapesOp.NumberOfFaces(theShape)
827 if ShapesOp.IsDone() == 0:
828 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
831 def NumberOfEdges(theShape):
833 * Gives quantity of edges in the given shape.
834 * \param theShape Shape to count edges of.
835 * \return Quantity of edges.
837 * Example: see GEOM_TestOthers.py
839 nb_edges = ShapesOp.NumberOfEdges(theShape)
840 if ShapesOp.IsDone() == 0:
841 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
844 def ChangeOrientation(theShape):
846 * Reverses an orientation the given shape.
847 * \param theShape Shape to be reversed.
848 * \return The reversed copy of theShape.
850 * Example: see GEOM_TestAll.py
852 anObj = ShapesOp.ChangeOrientation(theShape)
853 if ShapesOp.IsDone() == 0:
854 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
857 def OrientationChange(theShape):
859 * Shortcut to ChangeOrientation()
861 * Example: see GEOM_TestOthers.py
863 anObj = ChangeOrientation(theShape)
866 def GetFreeFacesIDs(theShape):
868 * Retrieve all free faces from the given shape.
869 * Free face is a face, which is not shared between two shells of the shape.
870 * \param theShape Shape to find free faces in.
871 * \return List of IDs of all free faces, contained in theShape.
873 * Example: see GEOM_TestOthers.py
875 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
876 if ShapesOp.IsDone() == 0:
877 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
880 def GetSharedShapes(theShape1, theShape2, theShapeType):
882 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
883 * \param theShape1 Shape to find sub-shapes in.
884 * \param theShape2 Shape to find shared sub-shapes with.
885 * \param theShapeType Type of sub-shapes to be retrieved.
886 * \return List of sub-shapes of theShape1, shared with theShape2.
888 * Example: see GEOM_TestOthers.py
890 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
891 if ShapesOp.IsDone() == 0:
892 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
895 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
897 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
898 * the specified plane by the certain way, defined through \a theState parameter.
899 * \param theShape Shape to find sub-shapes of.
900 * \param theShapeType Type of sub-shapes to be retrieved.
901 * \param theAx1 Vector (or line, or linear edge), specifying normal
902 * direction and location of the plane to find shapes on.
903 * \param theState The state of the subshapes to find. It can be one of
904 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
905 * \return List of all found sub-shapes.
907 * Example: see GEOM_TestOthers.py
909 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
910 if ShapesOp.IsDone() == 0:
911 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
914 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
916 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
917 * the specified cylinder by the certain way, defined through \a theState parameter.
918 * \param theShape Shape to find sub-shapes of.
919 * \param theShapeType Type of sub-shapes to be retrieved.
920 * \param theAxis Vector (or line, or linear edge), specifying
921 * axis of the cylinder to find shapes on.
922 * \param theRadius Radius of the cylinder to find shapes on.
923 * \param theState The state of the subshapes to find. It can be one of
924 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
925 * \return List of all found sub-shapes.
927 * Example: see GEOM_TestOthers.py
929 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
930 if ShapesOp.IsDone() == 0:
931 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
934 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
936 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
937 * the specified sphere by the certain way, defined through \a theState parameter.
938 * \param theShape Shape to find sub-shapes of.
939 * \param theShapeType Type of sub-shapes to be retrieved.
940 * \param theCenter Point, specifying center of the sphere to find shapes on.
941 * \param theRadius Radius of the sphere to find shapes on.
942 * \param theState The state of the subshapes to find. It can be one of
943 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
944 * \return List of all found sub-shapes.
946 * Example: see GEOM_TestOthers.py
948 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
949 if ShapesOp.IsDone() == 0:
950 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
953 def GetInPlace(theShapeWhere, theShapeWhat):
955 * Get sub-shape(s) of theShapeWhere, which are
956 * coincident with \a theShapeWhat or could be a part of it.
957 * \param theShapeWhere Shape to find sub-shapes of.
958 * \param theShapeWhat Shape, specifying what to find.
959 * \return Group of all found sub-shapes or a single found sub-shape.
961 * Example: see GEOM_TestOthers.py
963 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
964 if ShapesOp.IsDone() == 0:
965 print "GetInPlace : ", ShapesOp.GetErrorCode()
968 # -----------------------------------------------------------------------------
969 # Access to sub-shapes by their unique IDs inside the main shape.
970 # -----------------------------------------------------------------------------
972 def GetSubShape(aShape, ListOfID):
974 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
975 * of <aShape>, selected by their unique IDs inside <aShape>
977 * Example: see GEOM_TestAll.py
979 anObj = geom.AddSubShape(aShape,ListOfID)
982 def GetSubShapeID(aShape, aSubShape):
984 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
986 * Example: see GEOM_TestAll.py
988 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
989 if LocalOp.IsDone() == 0:
990 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
993 # -----------------------------------------------------------------------------
995 # -----------------------------------------------------------------------------
997 def SubShapeAll(aShape, aType):
999 * Explode a shape on subshapes of a given type.
1000 * \param theShape Shape to be exploded.
1001 * \param theShapeType Type of sub-shapes to be retrieved.
1002 * \return List of sub-shapes of type theShapeType, contained in theShape.
1004 * Example: see GEOM_TestAll.py
1006 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1007 if ShapesOp.IsDone() == 0:
1008 print "MakeExplode : ", ShapesOp.GetErrorCode()
1011 def SubShapeAllIDs(aShape, aType):
1013 * Explode a shape on subshapes of a given type.
1014 * \param theShape Shape to be exploded.
1015 * \param theShapeType Type of sub-shapes to be retrieved.
1016 * \return List of IDs of sub-shapes.
1018 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1019 if ShapesOp.IsDone() == 0:
1020 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1023 def SubShapeAllSorted(aShape, aType):
1025 * Explode a shape on subshapes of a given type.
1026 * Sub-shapes will be sorted by coordinates of their gravity centers.
1027 * \param theShape Shape to be exploded.
1028 * \param theShapeType Type of sub-shapes to be retrieved.
1029 * \return List of sub-shapes of type theShapeType, contained in theShape.
1031 * Example: see GEOM_TestAll.py
1033 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1034 if ShapesOp.IsDone() == 0:
1035 print "MakeExplode : ", ShapesOp.GetErrorCode()
1038 def SubShapeAllSortedIDs(aShape, aType):
1040 * Explode a shape on subshapes of a given type.
1041 * Sub-shapes will be sorted by coordinates of their gravity centers.
1042 * \param theShape Shape to be exploded.
1043 * \param theShapeType Type of sub-shapes to be retrieved.
1044 * \return List of IDs of sub-shapes.
1046 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1047 if ShapesOp.IsDone() == 0:
1048 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1051 def SubShape(aShape, aType, ListOfInd):
1053 * Obtain a compound of sub-shapes of <aShape>,
1054 * selected by they indices in list of all sub-shapes of type <aType>.
1055 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1057 * Example: see GEOM_TestAll.py
1060 AllShapeList = SubShapeAll(aShape, aType)
1061 for ind in ListOfInd:
1062 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1063 anObj = GetSubShape(aShape, ListOfIDs)
1066 def SubShapeSorted(aShape, aType, ListOfInd):
1068 * Obtain a compound of sub-shapes of <aShape>,
1069 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1070 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1072 * Example: see GEOM_TestAll.py
1075 AllShapeList = SubShapeAllSorted(aShape, aType)
1076 for ind in ListOfInd:
1077 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1078 anObj = GetSubShape(aShape, ListOfIDs)
1081 # -----------------------------------------------------------------------------
1082 # Healing operations
1083 # -----------------------------------------------------------------------------
1085 def ProcessShape(theShape, theOperators, theParameters, theValues):
1087 * Apply a sequence of Shape Healing operators to the given object.
1088 * \param theShape Shape to be processed.
1089 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1090 * \param theParameters List of names of parameters
1091 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1092 * \param theValues List of values of parameters, in the same order
1093 * as parameters are listed in \a theParameters list.
1094 * \return New GEOM_Object, containing processed shape.
1096 * Example: see GEOM_TestHealing.py
1098 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1099 if HealOp.IsDone() == 0:
1100 print "ProcessShape : ", HealOp.GetErrorCode()
1103 def SuppressFaces(theObject, theFaces):
1105 * Remove faces from the given object (shape).
1106 * \param theObject Shape to be processed.
1107 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1108 * removes ALL faces of the given object.
1109 * \return New GEOM_Object, containing processed shape.
1111 * Example: see GEOM_TestHealing.py
1113 anObj = HealOp.SuppressFaces(theObject, theFaces)
1114 if HealOp.IsDone() == 0:
1115 print "SuppressFaces : ", HealOp.GetErrorCode()
1118 def MakeSewing(ListShape, theTolerance):
1120 * Sewing of some shapes into single shape.
1122 * Example: see GEOM_TestHealing.py
1124 comp = MakeCompound(ListShape)
1125 anObj = Sew(comp, theTolerance)
1128 def Sew(theObject, theTolerance):
1130 * Sewing of the given object.
1131 * \param theObject Shape to be processed.
1132 * \param theTolerance Required tolerance value.
1133 * \return New GEOM_Object, containing processed shape.
1135 * Example: see MakeSewing() above
1137 anObj = HealOp.Sew(theObject, theTolerance)
1138 if HealOp.IsDone() == 0:
1139 print "Sew : ", HealOp.GetErrorCode()
1142 def SuppressInternalWires(theObject, theWires):
1144 * Remove internal wires and edges from the given object (face).
1145 * \param theObject Shape to be processed.
1146 * \param theWires Indices of wires to be removed, if EMPTY then the method
1147 * removes ALL internal wires of the given object.
1148 * \return New GEOM_Object, containing processed shape.
1150 * Example: see GEOM_TestHealing.py
1152 anObj = HealOp.RemoveIntWires(theObject, theWires)
1153 if HealOp.IsDone() == 0:
1154 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1157 def SuppressHoles(theObject, theWires):
1159 * Remove internal closed contours (holes) from the given object.
1160 * \param theObject Shape to be processed.
1161 * \param theWires Indices of wires to be removed, if EMPTY then the method
1162 * removes ALL internal holes of the given object
1163 * \return New GEOM_Object, containing processed shape.
1165 * Example: see GEOM_TestHealing.py
1167 anObj = HealOp.FillHoles(theObject, theWires)
1168 if HealOp.IsDone() == 0:
1169 print "SuppressHoles : ", HealOp.GetErrorCode()
1172 def CloseContour(theObject, theWires, isCommonVertex):
1174 * Close an open wire.
1175 * \param theObject Shape to be processed.
1176 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1177 * if -1, then theObject itself is a wire.
1178 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1179 * If FALS : closure by creation of an edge between ends.
1180 * \return New GEOM_Object, containing processed shape.
1182 * Example: see GEOM_TestHealing.py
1184 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1185 if HealOp.IsDone() == 0:
1186 print "CloseContour : ", HealOp.GetErrorCode()
1189 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1191 * Addition of a point to a given edge object.
1192 * \param theObject Shape to be processed.
1193 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1194 * if -1, then theObject itself is the edge.
1195 * \param theValue Value of parameter on edge or length parameter,
1196 * depending on \a isByParameter.
1197 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1198 * if FALSE : \a theValue is treated as a length parameter [0..1]
1199 * \return New GEOM_Object, containing processed shape.
1201 * Example: see GEOM_TestHealing.py
1203 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1204 if HealOp.IsDone() == 0:
1205 print "DivideEdge : ", HealOp.GetErrorCode()
1208 def GetFreeBoundary(theObject):
1210 * Get a list of wires (wrapped in GEOM_Object-s),
1211 * that constitute a free boundary of the given shape.
1212 * \param theObject Shape to get free boundary of.
1213 * \return [status, theClosedWires, theOpenWires]
1214 * status: FALSE, if an error(s) occured during the method execution.
1215 * theClosedWires: Closed wires on the free boundary of the given shape.
1216 * theOpenWires: Open wires on the free boundary of the given shape.
1218 * Example: see GEOM_TestHealing.py
1220 anObj = HealOp.GetFreeBoundary(theObject)
1221 if HealOp.IsDone() == 0:
1222 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1225 # -----------------------------------------------------------------------------
1226 # Create advanced objects
1227 # -----------------------------------------------------------------------------
1229 def MakeCopy(theOriginal):
1231 * Create a copy of the given object
1233 * Example: see GEOM_TestAll.py
1235 anObj = InsertOp.MakeCopy(theOriginal)
1236 if InsertOp.IsDone() == 0:
1237 print "MakeCopy : ", InsertOp.GetErrorCode()
1240 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1242 * Create a filling from the given compound of contours.
1243 * \param theShape the compound of contours
1244 * \param theMinDeg a minimal degree
1245 * \param theMaxDeg a maximal degree
1246 * \param theTol2D a 2d tolerance
1247 * \param theTol3D a 3d tolerance
1248 * \param theNbIter a number of iteration
1249 * \return New GEOM_Object, containing the created filling surface.
1251 * Example: see GEOM_TestAll.py
1253 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1254 if PrimOp.IsDone() == 0:
1255 print "MakeFilling : ", PrimOp.GetErrorCode()
1258 def MakeGlueFaces(theShape, theTolerance):
1260 * Replace coincident faces in theShape by one face.
1261 * \param theShape Initial shape.
1262 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1263 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1265 * Example: see GEOM_Spanner.py
1267 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1268 if ShapesOp.IsDone() == 0:
1269 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1272 # -----------------------------------------------------------------------------
1273 # Boolean (Common, Cut, Fuse, Section)
1274 # -----------------------------------------------------------------------------
1276 def MakeBoolean(theShape1, theShape2, theOperation):
1278 * Perform one of boolean operations on two given shapes.
1279 * \param theShape1 First argument for boolean operation.
1280 * \param theShape2 Second argument for boolean operation.
1281 * \param theOperation Indicates the operation to be done:
1282 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1283 * \return New GEOM_Object, containing the result shape.
1285 * Example: see GEOM_TestAll.py
1287 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1288 if BoolOp.IsDone() == 0:
1289 print "MakeBoolean : ", BoolOp.GetErrorCode()
1292 def MakeCommon(s1, s2):
1294 * Shortcut to MakeBoolean(s1, s2, 1)
1296 * Example: see GEOM_TestOthers.py
1298 return MakeBoolean(s1, s2, 1)
1300 def MakeCut(s1, s2):
1302 * Shortcut to MakeBoolean(s1, s2, 2)
1304 * Example: see GEOM_TestOthers.py
1306 return MakeBoolean(s1, s2, 2)
1308 def MakeFuse(s1, s2):
1310 * Shortcut to MakeBoolean(s1, s2, 3)
1312 * Example: see GEOM_TestOthers.py
1314 return MakeBoolean(s1, s2, 3)
1316 def MakeSection(s1, s2):
1318 * Shortcut to MakeBoolean(s1, s2, 4)
1320 * Example: see GEOM_TestOthers.py
1322 return MakeBoolean(s1, s2, 4)
1324 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1325 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1327 * Perform partition operation.
1328 * \param ListShapes Shapes to be intersected.
1329 * \param ListTools Shapes to intersect theShapes.
1330 * \param ListKeepInside Shapes, outside which the results will be deleted.
1331 * Each shape from theKeepInside must belong to theShapes also.
1332 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1333 * Each shape from theRemoveInside must belong to theShapes also.
1334 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1335 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1336 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1337 * \return New GEOM_Object, containing the result shapes.
1339 * Example: see GEOM_TestAll.py
1341 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1342 ListKeepInside, ListRemoveInside,
1343 Limit, RemoveWebs, ListMaterials);
1344 if BoolOp.IsDone() == 0:
1345 print "MakePartition : ", BoolOp.GetErrorCode()
1348 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1349 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1351 * Shortcut to MakePartition()
1353 * Example: see GEOM_TestOthers.py
1355 anObj = MakePartition(ListShapes, ListTools,
1356 ListKeepInside, ListRemoveInside,
1357 Limit, RemoveWebs, ListMaterials);
1360 def MakeHalfPartition(theShape, thePlane):
1362 * Perform partition of the Shape with the Plane
1363 * \param theShape Shape to be intersected.
1364 * \param thePlane Tool shape, to intersect theShape.
1365 * \return New GEOM_Object, containing the result shape.
1367 * Example: see GEOM_TestAll.py
1369 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1370 if BoolOp.IsDone() == 0:
1371 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1374 # -----------------------------------------------------------------------------
1376 # -----------------------------------------------------------------------------
1378 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1380 * Translate the given object along the vector, specified
1381 * by its end points, creating its copy before the translation.
1382 * \param theObject The object to be translated.
1383 * \param thePoint1 Start point of translation vector.
1384 * \param thePoint2 End point of translation vector.
1385 * \return New GEOM_Object, containing the translated object.
1387 * Example: see GEOM_TestAll.py
1389 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1390 if TrsfOp.IsDone() == 0:
1391 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1394 def MakeTranslation(theObject, theDX, theDY, theDZ):
1396 * Translate the given object along the vector, specified
1397 * by its components, creating its copy before the translation.
1398 * \param theObject The object to be translated.
1399 * \param theDX,theDY,theDZ Components of translation vector.
1400 * \return New GEOM_Object, containing the translated object.
1402 * Example: see GEOM_TestAll.py
1404 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1405 if TrsfOp.IsDone() == 0:
1406 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1409 def MakeTranslationVector(theObject, theVector):
1411 * Translate the given object along the given vector,
1412 * creating its copy before the translation.
1413 * \param theObject The object to be translated.
1414 * \param theVector The translation vector.
1415 * \return New GEOM_Object, containing the translated object.
1417 * Example: see GEOM_TestAll.py
1419 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1420 if TrsfOp.IsDone() == 0:
1421 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1424 def MakeRotation(theObject, theAxis, theAngle):
1426 * Rotate the given object around the given axis
1427 * on the given angle, creating its copy before the rotatation.
1428 * \param theObject The object to be rotated.
1429 * \param theAxis Rotation axis.
1430 * \param theAngle Rotation angle in radians.
1431 * \return New GEOM_Object, containing the rotated object.
1433 * Example: see GEOM_TestAll.py
1435 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1436 if TrsfOp.IsDone() == 0:
1437 print "RotateCopy : ", TrsfOp.GetErrorCode()
1440 def MakeScaleTransform(theObject, thePoint, theFactor):
1442 * Scale the given object by the factor, creating its copy before the scaling.
1443 * \param theObject The object to be scaled.
1444 * \param thePoint Center point for scaling.
1445 * \param theFactor Scaling factor value.
1446 * \return New GEOM_Object, containing the scaled shape.
1448 * Example: see GEOM_TestAll.py
1450 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1451 if TrsfOp.IsDone() == 0:
1452 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1455 def MakeMirrorByPlane(theObject, thePlane):
1457 * Create an object, symmetrical
1458 * to the given one relatively the given plane.
1459 * \param theObject The object to be mirrored.
1460 * \param thePlane Plane of symmetry.
1461 * \return New GEOM_Object, containing the mirrored shape.
1463 * Example: see GEOM_TestAll.py
1465 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1466 if TrsfOp.IsDone() == 0:
1467 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1470 def MakeMirrorByAxis(theObject, theAxis):
1472 * Create an object, symmetrical
1473 * to the given one relatively the given axis.
1474 * \param theObject The object to be mirrored.
1475 * \param theAxis Axis of symmetry.
1476 * \return New GEOM_Object, containing the mirrored shape.
1478 * Example: see GEOM_TestAll.py
1480 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1481 if TrsfOp.IsDone() == 0:
1482 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1485 def MakeMirrorByPoint(theObject, thePoint):
1487 * Create an object, symmetrical
1488 * to the given one relatively the given point.
1489 * \param theObject The object to be mirrored.
1490 * \param thePoint Point of symmetry.
1491 * \return New GEOM_Object, containing the mirrored shape.
1493 * Example: see GEOM_TestAll.py
1495 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1496 if TrsfOp.IsDone() == 0:
1497 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1500 def MakePosition(theObject, theStartLCS, theEndLCS):
1502 * Modify the Location of the given object by LCS
1503 * creating its copy before the setting
1505 * Example: see GEOM_TestAll.py
1507 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1508 if TrsfOp.IsDone() == 0:
1509 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1512 def MakeOffset(theObject, theOffset):
1514 * Create new object as offset of the given one.
1515 * \param theObject The base object for the offset.
1516 * \param theOffset Offset value.
1517 * \return New GEOM_Object, containing the offset object.
1519 * Example: see GEOM_TestAll.py
1521 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1522 if TrsfOp.IsDone() == 0:
1523 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1526 # -----------------------------------------------------------------------------
1528 # -----------------------------------------------------------------------------
1530 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1532 * Translate the given object along the given vector a given number times
1533 * \param theObject The object to be translated.
1534 * \param theVector Direction of the translation.
1535 * \param theStep Distance to translate on.
1536 * \param theNbTimes Quantity of translations to be done.
1537 * \return New GEOM_Object, containing compound of all
1538 * the shapes, obtained after each translation.
1540 * Example: see GEOM_TestAll.py
1542 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1543 if TrsfOp.IsDone() == 0:
1544 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1547 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1548 theVector2, theStep2, theNbTimes2):
1550 * Conseqently apply two specified translations to theObject specified number of times.
1551 * \param theObject The object to be translated.
1552 * \param theVector1 Direction of the first translation.
1553 * \param theStep1 Step of the first translation.
1554 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1555 * \param theVector2 Direction of the second translation.
1556 * \param theStep2 Step of the second translation.
1557 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1558 * \return New GEOM_Object, containing compound of all
1559 * the shapes, obtained after each translation.
1561 * Example: see GEOM_TestAll.py
1563 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1564 theVector2, theStep2, theNbTimes2)
1565 if TrsfOp.IsDone() == 0:
1566 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1569 def MultiRotate1D(theObject, theAxis, theNbTimes):
1571 * Rotate the given object around the given axis a given number times.
1572 * Rotation angle will be 2*PI/theNbTimes.
1573 * \param theObject The object to be rotated.
1574 * \param theAxis The rotation axis.
1575 * \param theNbTimes Quantity of rotations to be done.
1576 * \return New GEOM_Object, containing compound of all the
1577 * shapes, obtained after each rotation.
1579 * Example: see GEOM_TestAll.py
1581 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1582 if TrsfOp.IsDone() == 0:
1583 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1586 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1588 * Rotate the given object around the
1589 * given axis on the given angle a given number
1590 * times and multi-translate each rotation result.
1591 * Translation direction passes through center of gravity
1592 * of rotated shape and its projection on the rotation axis.
1593 * \param theObject The object to be rotated.
1594 * \param theAxis Rotation axis.
1595 * \param theAngle Rotation angle in graduces.
1596 * \param theNbTimes1 Quantity of rotations to be done.
1597 * \param theStep Translation distance.
1598 * \param theNbTimes2 Quantity of translations to be done.
1599 * \return New GEOM_Object, containing compound of all the
1600 * shapes, obtained after each transformation.
1602 * Example: see GEOM_TestAll.py
1604 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1605 if TrsfOp.IsDone() == 0:
1606 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1609 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1611 * The same, as MultiRotate1D(), but axis is given by direction and point
1613 * Example: see GEOM_TestOthers.py
1615 aVec = MakeLine(aPoint,aDir)
1616 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1619 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1621 * The same, as MultiRotate2D(), but axis is given by direction and point
1623 * Example: see GEOM_TestOthers.py
1625 aVec = MakeLine(aPoint,aDir)
1626 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1629 # -----------------------------------------------------------------------------
1631 # -----------------------------------------------------------------------------
1633 def MakeFilletAll(theShape, theR):
1635 * Perform a fillet on all edges of the given shape.
1636 * \param theShape Shape, to perform fillet on.
1637 * \param theR Fillet radius.
1638 * \return New GEOM_Object, containing the result shape.
1640 * Example: see GEOM_TestOthers.py
1642 anObj = LocalOp.MakeFilletAll(theShape, theR)
1643 if LocalOp.IsDone() == 0:
1644 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1647 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1649 * Perform a fillet on the specified edges/faces of the given shape
1650 * \param theShape Shape, to perform fillet on.
1651 * \param theR Fillet radius.
1652 * \param theShapeType Type of shapes in <theListShapes>.
1653 * \param theListShapes Global indices of edges/faces to perform fillet on.
1654 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1655 * \return New GEOM_Object, containing the result shape.
1657 * Example: see GEOM_TestAll.py
1660 if theShapeType == ShapeType["EDGE"]:
1661 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1663 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1664 if LocalOp.IsDone() == 0:
1665 print "MakeFillet : ", LocalOp.GetErrorCode()
1668 def MakeChamferAll(theShape, theD):
1670 * Perform a symmetric chamfer on all edges of the given shape.
1671 * \param theShape Shape, to perform chamfer on.
1672 * \param theD Chamfer size along each face.
1673 * \return New GEOM_Object, containing the result shape.
1675 * Example: see GEOM_TestOthers.py
1677 anObj = LocalOp.MakeChamferAll(theShape, theD)
1678 if LocalOp.IsDone() == 0:
1679 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1682 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1684 * Perform a chamfer on edges, common to the specified faces,
1685 * with distance D1 on the Face1
1686 * \param theShape Shape, to perform chamfer on.
1687 * \param theD1 Chamfer size along \a theFace1.
1688 * \param theD2 Chamfer size along \a theFace2.
1689 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1690 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1691 * \return New GEOM_Object, containing the result shape.
1693 * Example: see GEOM_TestAll.py
1695 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1696 if LocalOp.IsDone() == 0:
1697 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1700 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1702 * Perform a chamfer on all edges of the specified faces,
1703 * with distance D1 on the first specified face (if several for one edge)
1704 * \param theShape Shape, to perform chamfer on.
1705 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1706 * connected to the edge, are in \a theFaces, \a theD1
1707 * will be get along face, which is nearer to \a theFaces beginning.
1708 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1709 * \param theFaces Sequence of global indices of faces of \a theShape.
1710 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1711 * \return New GEOM_Object, containing the result shape.
1713 * Example: see GEOM_TestAll.py
1715 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1716 if LocalOp.IsDone() == 0:
1717 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1720 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1722 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1724 * Example: see GEOM_TestOthers.py
1727 if aShapeType == ShapeType["EDGE"]:
1728 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1730 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1733 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1735 * Perform an Archimde operation on the given shape with given parameters.
1736 * The object presenting the resulting face is returned
1737 * \param theShape Shape to be put in water.
1738 * \param theWeight Weight og the shape.
1739 * \param theWaterDensity Density of the water.
1740 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1741 * \return New GEOM_Object, containing a section of \a theShape
1742 * by a plane, corresponding to water level.
1744 * Example: see GEOM_TestAll.py
1746 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1747 if LocalOp.IsDone() == 0:
1748 print "MakeArchimede : ", LocalOp.GetErrorCode()
1751 # -----------------------------------------------------------------------------
1752 # Information objects
1753 # -----------------------------------------------------------------------------
1755 def PointCoordinates(Point):
1757 * Get point coordinates
1760 * Example: see GEOM_TestMeasures.py
1762 aTuple = MeasuOp.PointCoordinates(Point)
1763 if MeasuOp.IsDone() == 0:
1764 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1767 def BasicProperties(theShape):
1769 * Get summarized length of all wires,
1770 * area of surface and volume of the given shape.
1771 * \param theShape Shape to define properties of.
1772 * \return [theLength, theSurfArea, theVolume]
1773 * theLength: Summarized length of all wires of the given shape.
1774 * theSurfArea: Area of surface of the given shape.
1775 * theVolume: Volume of the given shape.
1777 * Example: see GEOM_TestMeasures.py
1779 aTuple = MeasuOp.GetBasicProperties(theShape)
1780 if MeasuOp.IsDone() == 0:
1781 print "BasicProperties : ", MeasuOp.GetErrorCode()
1784 def BoundingBox(theShape):
1786 * Get parameters of bounding box of the given shape
1787 * \param theShape Shape to obtain bounding box of.
1788 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1789 * Xmin,Xmax: Limits of shape along OX axis.
1790 * Ymin,Ymax: Limits of shape along OY axis.
1791 * Zmin,Zmax: Limits of shape along OZ axis.
1793 * Example: see GEOM_TestMeasures.py
1795 aTuple = MeasuOp.GetBoundingBox(theShape)
1796 if MeasuOp.IsDone() == 0:
1797 print "BoundingBox : ", MeasuOp.GetErrorCode()
1800 def Inertia(theShape):
1802 * Get inertia matrix and moments of inertia of theShape.
1803 * \param theShape Shape to calculate inertia of.
1804 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1805 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1806 * Ix,Iy,Iz: Moments of inertia of the given shape.
1808 * Example: see GEOM_TestMeasures.py
1810 aTuple = MeasuOp.GetInertia(theShape)
1811 if MeasuOp.IsDone() == 0:
1812 print "Inertia : ", MeasuOp.GetErrorCode()
1815 def MinDistance(theShape1, theShape2):
1817 * Get minimal distance between the given shapes.
1818 * \param theShape1,theShape2 Shapes to find minimal distance between.
1819 * \return Value of the minimal distance between the given shapes.
1821 * Example: see GEOM_TestMeasures.py
1823 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1824 if MeasuOp.IsDone() == 0:
1825 print "MinDistance : ", MeasuOp.GetErrorCode()
1828 def Tolerance(theShape):
1830 * Get min and max tolerances of sub-shapes of theShape
1831 * \param theShape Shape, to get tolerances of.
1832 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1833 * FaceMin,FaceMax: Min and max tolerances of the faces.
1834 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1835 * VertMin,VertMax: Min and max tolerances of the vertices.
1837 * Example: see GEOM_TestMeasures.py
1839 aTuple = MeasuOp.GetTolerance(theShape)
1840 if MeasuOp.IsDone() == 0:
1841 print "Tolerance : ", MeasuOp.GetErrorCode()
1844 def WhatIs(theShape):
1846 * Obtain description of the given shape (number of sub-shapes of each type)
1847 * \param theShape Shape to be described.
1848 * \return Description of the given shape.
1850 * Example: see GEOM_TestMeasures.py
1852 aDescr = MeasuOp.WhatIs(theShape)
1853 if MeasuOp.IsDone() == 0:
1854 print "WhatIs : ", MeasuOp.GetErrorCode()
1857 def MakeCDG(theShape):
1859 * Get a point, situated at the centre of mass of theShape.
1860 * \param theShape Shape to define centre of mass of.
1861 * \return New GEOM_Object, containing the created point.
1863 * Example: see GEOM_TestMeasures.py
1865 anObj = MeasuOp.GetCentreOfMass(theShape)
1866 if MeasuOp.IsDone() == 0:
1867 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1870 def CheckShape(theShape):
1872 * Check a topology of the given shape.
1873 * \param theShape Shape to check validity of.
1874 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1875 * If theShape is invalid, prints a description of problem.
1877 * Example: see GEOM_TestMeasures.py
1879 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1880 if MeasuOp.IsDone() == 0:
1881 print "CheckShape : ", MeasuOp.GetErrorCode()
1887 # -----------------------------------------------------------------------------
1888 # Import/Export objects
1889 # -----------------------------------------------------------------------------
1891 def Import(theFileName, theFormatName):
1893 * Import a shape from the BREP or IGES or STEP file
1894 * (depends on given format) with given name.
1895 * \param theFileName The file, containing the shape.
1896 * \param theFormatName Specify format for the file reading.
1897 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1898 * \return New GEOM_Object, containing the imported shape.
1900 * Example: see GEOM_TestOthers.py
1902 anObj = InsertOp.Import(theFileName, theFormatName)
1903 if InsertOp.IsDone() == 0:
1904 print "Import : ", InsertOp.GetErrorCode()
1907 def ImportBREP(theFileName):
1909 * Shortcut to Import() for BREP format
1911 * Example: see GEOM_TestOthers.py
1913 return Import(theFileName, "BREP")
1915 def ImportIGES(theFileName):
1917 * Shortcut to Import() for IGES format
1919 * Example: see GEOM_TestOthers.py
1921 return Import(theFileName, "IGES")
1923 def ImportSTEP(theFileName):
1925 * Shortcut to Import() for STEP format
1927 * Example: see GEOM_TestOthers.py
1929 return Import(theFileName, "STEP")
1931 def Export(theObject, theFileName, theFormatName):
1933 * Export the given shape into a file with given name.
1934 * \param theObject Shape to be stored in the file.
1935 * \param theFileName Name of the file to store the given shape in.
1936 * \param theFormatName Specify format for the shape storage.
1937 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1939 * Example: see GEOM_TestOthers.py
1941 InsertOp.Export(theObject, theFileName, theFormatName)
1942 if InsertOp.IsDone() == 0:
1943 print "Export : ", InsertOp.GetErrorCode()
1945 def ExportBREP(theObject, theFileName):
1947 * Shortcut to Export() for BREP format
1949 * Example: see GEOM_TestOthers.py
1951 return Export(theObject, theFileName, "BREP")
1953 def ExportIGES(theObject, theFileName):
1955 * Shortcut to Export() for IGES format
1957 * Example: see GEOM_TestOthers.py
1959 return Export(theObject, theFileName, "IGES")
1961 def ExportSTEP(theObject, theFileName):
1963 * Shortcut to Export() for STEP format
1965 * Example: see GEOM_TestOthers.py
1967 return Export(theObject, theFileName, "STEP")
1969 # -----------------------------------------------------------------------------
1971 # -----------------------------------------------------------------------------
1973 def MakeQuad(E1, E2, E3, E4):
1975 * Create a quadrangle face from four edges. Order of Edges is not
1976 * important. It is not necessary that edges share the same vertex.
1977 * \param E1,E2,E3,E4 Edges for the face bound.
1978 * \return New GEOM_Object, containing the created face.
1980 * Example: see GEOM_Spanner.py
1982 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1983 if BlocksOp.IsDone() == 0:
1984 print "MakeQuad : ", BlocksOp.GetErrorCode()
1987 def MakeQuad2Edges(E1, E2):
1989 * Create a quadrangle face on two edges.
1990 * The missing edges will be built by creating the shortest ones.
1991 * \param E1,E2 Two opposite edges for the face.
1992 * \return New GEOM_Object, containing the created face.
1994 * Example: see GEOM_Spanner.py
1996 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1997 if BlocksOp.IsDone() == 0:
1998 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2001 def MakeQuad4Vertices(V1, V2, V3, V4):
2003 * Create a quadrangle face with specified corners.
2004 * The missing edges will be built by creating the shortest ones.
2005 * \param V1,V2,V3,V4 Corner vertices for the face.
2006 * \return New GEOM_Object, containing the created face.
2008 * Example: see GEOM_Spanner.py
2010 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2011 if BlocksOp.IsDone() == 0:
2012 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2015 def MakeHexa(F1, F2, F3, F4, F5, F6):
2017 * Create a hexahedral solid, bounded by the six given faces. Order of
2018 * faces is not important. It is not necessary that Faces share the same edge.
2019 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2020 * \return New GEOM_Object, containing the created solid.
2022 * Example: see GEOM_Spanner.py
2024 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2025 if BlocksOp.IsDone() == 0:
2026 print "MakeHexa : ", BlocksOp.GetErrorCode()
2029 def MakeHexa2Faces(F1, F2):
2031 * Create a hexahedral solid between two given faces.
2032 * The missing faces will be built by creating the smallest ones.
2033 * \param F1,F2 Two opposite faces for the hexahedral solid.
2034 * \return New GEOM_Object, containing the created solid.
2036 * Example: see GEOM_Spanner.py
2038 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2039 if BlocksOp.IsDone() == 0:
2040 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2043 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2045 * Get a vertex, found in the given shape by its coordinates.
2046 * \param theShape Block or a compound of blocks.
2047 * \param theX,theY,theZ Coordinates of the sought vertex.
2048 * \param theEpsilon Maximum allowed distance between the resulting
2049 * vertex and point with the given coordinates.
2050 * \return New GEOM_Object, containing the found vertex.
2052 * Example: see GEOM_TestOthers.py
2054 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2055 if BlocksOp.IsDone() == 0:
2056 print "GetPoint : ", BlocksOp.GetErrorCode()
2059 def GetEdge(theShape, thePoint1, thePoint2):
2061 * Get an edge, found in the given shape by two given vertices.
2062 * \param theShape Block or a compound of blocks.
2063 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2064 * \return New GEOM_Object, containing the found edge.
2066 * Example: see GEOM_Spanner.py
2068 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2069 if BlocksOp.IsDone() == 0:
2070 print "GetEdge : ", BlocksOp.GetErrorCode()
2073 def GetEdgeNearPoint(theShape, thePoint):
2075 * Find an edge of the given shape, which has minimal distance to the given point.
2076 * \param theShape Block or a compound of blocks.
2077 * \param thePoint Point, close to the desired edge.
2078 * \return New GEOM_Object, containing the found edge.
2080 * Example: see GEOM_TestOthers.py
2082 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2083 if BlocksOp.IsDone() == 0:
2084 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2087 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2089 * Returns a face, found in the given shape by four given corner vertices.
2090 * \param theShape Block or a compound of blocks.
2091 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2092 * \return New GEOM_Object, containing the found face.
2094 * Example: see GEOM_Spanner.py
2096 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2097 if BlocksOp.IsDone() == 0:
2098 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2101 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2103 * Get a face of block, found in the given shape by two given edges.
2104 * \param theShape Block or a compound of blocks.
2105 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2106 * \return New GEOM_Object, containing the found face.
2108 * Example: see GEOM_Spanner.py
2110 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2111 if BlocksOp.IsDone() == 0:
2112 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2115 def GetOppositeFace(theBlock, theFace):
2117 * Find a face, opposite to the given one in the given block.
2118 * \param theBlock Must be a hexahedral solid.
2119 * \param theFace Face of \a theBlock, opposite to the desired face.
2120 * \return New GEOM_Object, containing the found face.
2122 * Example: see GEOM_Spanner.py
2124 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2125 if BlocksOp.IsDone() == 0:
2126 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2129 def GetFaceNearPoint(theShape, thePoint):
2131 * Find a face of the given shape, which has minimal distance to the given point.
2132 * \param theShape Block or a compound of blocks.
2133 * \param thePoint Point, close to the desired face.
2134 * \return New GEOM_Object, containing the found face.
2136 * Example: see GEOM_Spanner.py
2138 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2139 if BlocksOp.IsDone() == 0:
2140 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2143 def GetFaceByNormale(theBlock, theVector):
2145 * Find a face of block, whose outside normale has minimal angle with the given vector.
2146 * \param theShape Block or a compound of blocks.
2147 * \param theVector Vector, close to the normale of the desired face.
2148 * \return New GEOM_Object, containing the found face.
2150 * Example: see GEOM_Spanner.py
2152 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2153 if BlocksOp.IsDone() == 0:
2154 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2157 def CheckCompoundOfBlocks(theCompound):
2159 * Check, if the compound of blocks is given.
2160 * To be considered as a compound of blocks, the
2161 * given shape must satisfy the following conditions:
2162 * - Each element of the compound should be a Block (6 faces and 12 edges).
2163 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2164 * - The compound should be connexe.
2165 * - The glue between two quadrangle faces should be applied.
2166 * \param theCompound The compound to check.
2167 * \return TRUE, if the given shape is a compound of blocks.
2168 * If theCompound is not valid, prints all discovered errors.
2170 * Example: see GEOM_Spanner.py
2172 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2173 if BlocksOp.IsDone() == 0:
2174 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2177 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2181 def RemoveExtraEdges(theShape):
2183 * Remove all seam and degenerated edges from \a theShape.
2184 * Unite faces and edges, sharing one surface.
2185 * \param theShape The compound or single solid to remove irregular edges from.
2186 * \return Improved shape.
2188 * Example: see GEOM_TestOthers.py
2190 anObj = BlocksOp.RemoveExtraEdges(theShape)
2191 if BlocksOp.IsDone() == 0:
2192 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2195 def CheckAndImprove(theShape):
2197 * Check, if the given shape is a blocks compound.
2198 * Fix all detected errors.
2199 * \note Single block can be also fixed by this method.
2200 * \param theCompound The compound to check and improve.
2201 * \return Improved compound.
2203 * Example: see GEOM_TestOthers.py
2205 anObj = BlocksOp.CheckAndImprove(theShape)
2206 if BlocksOp.IsDone() == 0:
2207 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2210 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2212 * Get all the blocks, contained in the given compound.
2213 * \param theCompound The compound to explode.
2214 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2215 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2216 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2217 * \return List of GEOM_Objects, containing the retrieved blocks.
2219 * Example: see GEOM_TestOthers.py
2221 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2222 if BlocksOp.IsDone() == 0:
2223 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2226 def GetBlockNearPoint(theCompound, thePoint):
2228 * Find block, containing the given point inside its volume or on boundary.
2229 * \param theCompound Compound, to find block in.
2230 * \param thePoint Point, close to the desired block. If the point lays on
2231 * boundary between some blocks, we return block with nearest center.
2232 * \return New GEOM_Object, containing the found block.
2234 * Example: see GEOM_Spanner.py
2236 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2237 if BlocksOp.IsDone() == 0:
2238 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2241 def GetBlockByParts(theCompound, theParts):
2243 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2244 * \param theCompound Compound, to find block in.
2245 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2246 * \return New GEOM_Object, containing the found block.
2248 * Example: see GEOM_TestOthers.py
2250 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2251 if BlocksOp.IsDone() == 0:
2252 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2255 def GetBlocksByParts(theCompound, theParts):
2257 * Return all blocks, containing all the elements, passed as the parts.
2258 * \param theCompound Compound, to find blocks in.
2259 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2260 * \return List of GEOM_Objects, containing the found blocks.
2262 * Example: see GEOM_Spanner.py
2264 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2265 if BlocksOp.IsDone() == 0:
2266 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2269 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2271 * Multi-transformate block and glue the result.
2272 * Transformation is defined so, as to superpose direction faces.
2273 * \param Block Hexahedral solid to be multi-transformed.
2274 * \param DirFace1 ID of First direction face.
2275 * \param DirFace2 ID of Second direction face.
2276 * \param NbTimes Quantity of transformations to be done.
2277 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2278 * \return New GEOM_Object, containing the result shape.
2280 * Example: see GEOM_Spanner.py
2282 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2283 if BlocksOp.IsDone() == 0:
2284 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2287 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2288 DirFace1V, DirFace2V, NbTimesV):
2290 * Multi-transformate block and glue the result.
2291 * \param Block Hexahedral solid to be multi-transformed.
2292 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2293 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2294 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2295 * \return New GEOM_Object, containing the result shape.
2297 * Example: see GEOM_Spanner.py
2299 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2300 DirFace1V, DirFace2V, NbTimesV)
2301 if BlocksOp.IsDone() == 0:
2302 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2305 def Propagate(theShape):
2307 * Build all possible propagation groups.
2308 * Propagation group is a set of all edges, opposite to one (main)
2309 * edge of this group directly or through other opposite edges.
2310 * Notion of Opposite Edge make sence only on quadrangle face.
2311 * \param theShape Shape to build propagation groups on.
2312 * \return List of GEOM_Objects, each of them is a propagation group.
2314 * Example: see GEOM_TestOthers.py
2316 listChains = BlocksOp.Propagate(theShape)
2317 if BlocksOp.IsDone() == 0:
2318 print "Propagate : ", BlocksOp.GetErrorCode()
2321 # -----------------------------------------------------------------------------
2323 # -----------------------------------------------------------------------------
2325 def CreateGroup(theMainShape, theShapeType):
2327 * Creates a new group which will store sub shapes of theMainShape
2328 * \param theMainShape is a GEOM object on which the group is selected
2329 * \param theShapeType defines a shape type of the group
2330 * \return a newly created GEOM group
2332 * Example: see GEOM_TestOthers.py
2334 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2335 if GroupOp.IsDone() == 0:
2336 print "CreateGroup : ", GroupOp.GetErrorCode()
2339 def AddObject(theGroup, theSubShapeID):
2341 * Adds a sub object with ID theSubShapeId to the group
2342 * \param theGroup is a GEOM group to which the new sub shape is added
2343 * \param theSubShapeID is a sub shape ID in the main object.
2344 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2346 * Example: see GEOM_TestOthers.py
2348 GroupOp.AddObject(theGroup, theSubShapeID)
2349 if GroupOp.IsDone() == 0:
2350 print "AddObject : ", GroupOp.GetErrorCode()
2352 def RemoveObject(theGroup, theSubShapeID):
2354 * Removes a sub object with ID \a theSubShapeId from the group
2355 * \param theGroup is a GEOM group from which the new sub shape is removed
2356 * \param theSubShapeID is a sub shape ID in the main object.
2357 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2359 * Example: see GEOM_TestOthers.py
2361 GroupOp.RemoveObject(theGroup, theSubShapeID)
2362 if GroupOp.IsDone() == 0:
2363 print "RemoveObject : ", GroupOp.GetErrorCode()
2365 def UnionList (theGroup, theSubShapes):
2367 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2368 * \param theGroup is a GEOM group to which the new sub shapes are added.
2369 * \param theSubShapes is a list of sub shapes to be added.
2371 * Example: see GEOM_TestOthers.py
2373 GroupOp.UnionList(theGroup, theSubShapes)
2374 if GroupOp.IsDone() == 0:
2375 print "UnionList : ", GroupOp.GetErrorCode()
2377 def DifferenceList (theGroup, theSubShapes):
2379 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2380 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2381 * \param theSubShapes is a list of sub-shapes to be removed.
2383 * Example: see GEOM_TestOthers.py
2385 GroupOp.DifferenceList(theGroup, theSubShapes)
2386 if GroupOp.IsDone() == 0:
2387 print "DifferenceList : ", GroupOp.GetErrorCode()
2389 def GetObjectIDs(theGroup):
2391 * Returns a list of sub objects ID stored in the group
2392 * \param theGroup is a GEOM group for which a list of IDs is requested
2394 * Example: see GEOM_TestOthers.py
2396 ListIDs = GroupOp.GetObjects(theGroup)
2397 if GroupOp.IsDone() == 0:
2398 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2401 def GetType(theGroup):
2403 * Returns a type of sub objects stored in the group
2404 * \param theGroup is a GEOM group which type is returned.
2406 * Example: see GEOM_TestOthers.py
2408 aType = GroupOp.GetType(theGroup)
2409 if GroupOp.IsDone() == 0:
2410 print "GetType : ", GroupOp.GetErrorCode()
2413 def GetMainShape(theGroup):
2415 * Returns a main shape associated with the group
2416 * \param theGroup is a GEOM group for which a main shape object is requested
2417 * \return a GEOM object which is a main shape for theGroup
2419 * Example: see GEOM_TestOthers.py
2421 anObj = GroupOp.GetMainShape(theGroup)
2422 if GroupOp.IsDone() == 0:
2423 print "GetMainShape : ", GroupOp.GetErrorCode()
2426 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2428 Create group of edges of theShape, whose length is in range [min_length, max_length].
2429 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2432 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2435 Props = BasicProperties(edge)
2436 if min_length <= Props[0] and Props[0] <= max_length:
2437 if (not include_min) and (min_length == Props[0]):
2440 if (not include_max) and (Props[0] == max_length):
2443 edges_in_range.append(edge)
2445 if len(edges_in_range) <= 0:
2446 print "No edges found by given criteria"
2449 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2450 UnionList(group_edges, edges_in_range)
2454 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2456 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2457 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2460 nb_selected = sg.SelectedCount()
2462 print "Select a shape before calling this function, please."
2465 print "Only one shape must be selected"
2468 id_shape = sg.getSelected(0)
2469 shape = IDToObject( id_shape )
2471 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2475 if include_min: left_str = " <= "
2476 if include_max: right_str = " <= "
2478 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2479 + left_str + "length" + right_str + `max_length`)
2481 sg.updateObjBrowser(1)
2487 * Add Path to load python scripts from
2489 if (sys.path.count(Path) < 1):
2490 sys.path.append(Path)