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 myBuilder = myStudy.NewBuilder()
41 father = myStudy.FindComponent("GEOM")
43 father = myBuilder.NewComponent("GEOM")
44 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
45 FName = A1._narrow(SALOMEDS.AttributeName)
46 FName.SetValue("Geometry")
47 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
48 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
49 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
50 myBuilder.DefineComponentInstance(father,geom)
52 gg = ImportComponentGUI("GEOM")
54 def SubShapeName(aSubObj, aMainObj):
56 * Get name for sub-shape aSubObj of shape aMainObj
58 * Example: see GEOM_TestAll.py
60 aSubId = orb.object_to_string(aSubObj)
61 aMainId = orb.object_to_string(aMainObj)
62 index = gg.getIndexTopology(aSubId, aMainId)
63 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
66 def addToStudy(aShape, aName):
68 * Publish in study aShape with name aName
70 * Example: see GEOM_TestAll.py
73 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
75 print "addToStudy() failed"
77 return aShape.GetStudyEntry()
79 def addToStudyInFather(aFather, aShape, aName):
81 * Publish in study aShape with name aName as sub-object of previously published aFather
83 * Example: see GEOM_TestAll.py
86 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
88 print "addToStudyInFather() failed"
90 return aShape.GetStudyEntry()
92 # -----------------------------------------------------------------------------
93 # enumeration ShapeType as a dictionary
94 # -----------------------------------------------------------------------------
96 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
98 # -----------------------------------------------------------------------------
99 # Get Operations Interfaces
100 # -----------------------------------------------------------------------------
102 BasicOp = geom.GetIBasicOperations (myStudyId)
103 CurvesOp = geom.GetICurvesOperations (myStudyId)
104 PrimOp = geom.GetI3DPrimOperations (myStudyId)
105 ShapesOp = geom.GetIShapesOperations (myStudyId)
106 HealOp = geom.GetIHealingOperations (myStudyId)
107 InsertOp = geom.GetIInsertOperations (myStudyId)
108 BoolOp = geom.GetIBooleanOperations (myStudyId)
109 TrsfOp = geom.GetITransformOperations(myStudyId)
110 LocalOp = geom.GetILocalOperations (myStudyId)
111 MeasuOp = geom.GetIMeasureOperations (myStudyId)
112 BlocksOp = geom.GetIBlocksOperations (myStudyId)
113 GroupOp = geom.GetIGroupOperations (myStudyId)
115 # -----------------------------------------------------------------------------
117 # -----------------------------------------------------------------------------
119 def MakeVertex(theX, theY, theZ):
121 * Create point by three coordinates.
122 * \param theX The X coordinate of the point.
123 * \param theY The Y coordinate of the point.
124 * \param theZ The Z coordinate of the point.
125 * \return New GEOM_Object, containing the created point.
127 * Example: see GEOM_TestAll.py
129 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
130 if BasicOp.IsDone() == 0:
131 print "MakePointXYZ : ", BasicOp.GetErrorCode()
134 def MakeVertexWithRef(theReference, theX, theY, theZ):
136 * Create a point, distant from the referenced point
137 * on the given distances along the coordinate axes.
138 * \param theReference The referenced point.
139 * \param theX Displacement from the referenced point along OX axis.
140 * \param theY Displacement from the referenced point along OY axis.
141 * \param theZ Displacement from the referenced point along OZ axis.
142 * \return New GEOM_Object, containing the created point.
144 * Example: see GEOM_TestAll.py
146 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
147 if BasicOp.IsDone() == 0:
148 print "MakePointWithReference : ", BasicOp.GetErrorCode()
151 def MakeVertexOnCurve(theRefCurve, theParameter):
153 * Create a point, corresponding to the given parameter on the given curve.
154 * \param theRefCurve The referenced curve.
155 * \param theParameter Value of parameter on the referenced curve.
156 * \return New GEOM_Object, containing the created point.
158 * Example: see GEOM_TestAll.py
160 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
161 if BasicOp.IsDone() == 0:
162 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
165 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
167 * Create a vector with the given components.
168 * \param theDX X component of the vector.
169 * \param theDY Y component of the vector.
170 * \param theDZ Z component of the vector.
171 * \return New GEOM_Object, containing the created vector.
173 * Example: see GEOM_TestAll.py
175 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
176 if BasicOp.IsDone() == 0:
177 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
180 def MakeVector(thePnt1, thePnt2):
182 * Create a vector between two points.
183 * \param thePnt1 Start point for the vector.
184 * \param thePnt2 End point for the vector.
185 * \return New GEOM_Object, containing the created vector.
187 * Example: see GEOM_TestAll.py
189 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
190 if BasicOp.IsDone() == 0:
191 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
194 def MakeLine(thePnt, theDir):
196 * Create a line, passing through the given point
197 * and parrallel to the given direction
198 * \param thePnt Point. The resulting line will pass through it.
199 * \param theDir Direction. The resulting line will be parallel to it.
200 * \return New GEOM_Object, containing the created line.
202 * Example: see GEOM_TestAll.py
204 anObj = BasicOp.MakeLine(thePnt, theDir)
205 if BasicOp.IsDone() == 0:
206 print "MakeLine : ", BasicOp.GetErrorCode()
209 def MakeLineTwoPnt(thePnt1, thePnt2):
211 * Create a line, passing through the given points
212 * \param thePnt1 First of two points, defining the line.
213 * \param thePnt2 Second of two points, defining the line.
214 * \return New GEOM_Object, containing the created line.
216 * Example: see GEOM_TestAll.py
218 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
219 if BasicOp.IsDone() == 0:
220 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
223 def MakePlane(thePnt, theVec, theTrimSize):
225 * Create a plane, passing through the given point
226 * and normal to the given vector.
227 * \param thePnt Point, the plane has to pass through.
228 * \param theVec Vector, defining the plane normal direction.
229 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
230 * \return New GEOM_Object, containing the created plane.
232 * Example: see GEOM_TestAll.py
234 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
235 if BasicOp.IsDone() == 0:
236 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
239 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
241 * Create a plane, passing through the three given points
242 * \param thePnt1 First of three points, defining the plane.
243 * \param thePnt2 Second of three points, defining the plane.
244 * \param thePnt3 Fird of three points, defining the plane.
245 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
246 * \return New GEOM_Object, containing the created plane.
248 * Example: see GEOM_TestAll.py
250 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
251 if BasicOp.IsDone() == 0:
252 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
255 def MakePlaneFace(theFace, theTrimSize):
257 * Create a plane, similar to the existing one, but with another size of representing face.
258 * \param theFace Referenced plane.
259 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
260 * \return New GEOM_Object, containing the created plane.
262 * Example: see GEOM_TestAll.py
264 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
265 if BasicOp.IsDone() == 0:
266 print "MakePlaneFace : ", BasicOp.GetErrorCode()
269 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
271 * Create a local coordinate system.
272 * \param OX,OY,OZ Three coordinates of coordinate system origin.
273 * \param XDX,XDY,XDZ Three components of OX direction
274 * \param YDX,YDY,YDZ Three components of OY direction
275 * \return New GEOM_Object, containing the created coordinate system.
277 * Example: see GEOM_TestAll.py
279 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
280 if BasicOp.IsDone() == 0:
281 print "MakeMarker : ", BasicOp.GetErrorCode()
284 # -----------------------------------------------------------------------------
286 # -----------------------------------------------------------------------------
288 def MakeArc(thePnt1, thePnt2, thePnt3):
290 * Create an arc of circle, passing through three given points.
291 * \param thePnt1 Start point of the arc.
292 * \param thePnt2 Middle point of the arc.
293 * \param thePnt3 End point of the arc.
294 * \return New GEOM_Object, containing the created arc.
296 * Example: see GEOM_TestAll.py
298 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
299 if CurvesOp.IsDone() == 0:
300 print "MakeArc : ", CurvesOp.GetErrorCode()
303 def MakeCircle(thePnt, theVec, theR):
305 * Create a circle with given center, normal vector and radius.
306 * \param thePnt Circle center.
307 * \param theVec Vector, normal to the plane of the circle.
308 * \param theR Circle radius.
309 * \return New GEOM_Object, containing the created circle.
311 * Example: see GEOM_TestAll.py
313 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
314 if CurvesOp.IsDone() == 0:
315 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
318 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
320 * Create a circle, passing through three given points
321 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
322 * \return New GEOM_Object, containing the created circle.
324 * Example: see GEOM_TestAll.py
326 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
327 if CurvesOp.IsDone() == 0:
328 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
331 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
333 * Create an ellipse with given center, normal vector and radiuses.
334 * \param thePnt Ellipse center.
335 * \param theVec Vector, normal to the plane of the ellipse.
336 * \param theRMajor Major ellipse radius.
337 * \param theRMinor Minor ellipse radius.
338 * \return New GEOM_Object, containing the created ellipse.
340 * Example: see GEOM_TestAll.py
342 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
343 if CurvesOp.IsDone() == 0:
344 print "MakeEllipse : ", CurvesOp.GetErrorCode()
347 def MakePolyline(thePoints):
349 * Create a polyline on the set of points.
350 * \param thePoints Sequence of points for the polyline.
351 * \return New GEOM_Object, containing the created polyline.
353 * Example: see GEOM_TestAll.py
355 anObj = CurvesOp.MakePolyline(thePoints)
356 if CurvesOp.IsDone() == 0:
357 print "MakePolyline : ", CurvesOp.GetErrorCode()
360 def MakeBezier(thePoints):
362 * Create bezier curve on the set of points.
363 * \param thePoints Sequence of points for the bezier curve.
364 * \return New GEOM_Object, containing the created bezier curve.
366 * Example: see GEOM_TestAll.py
368 anObj = CurvesOp.MakeSplineBezier(thePoints)
369 if CurvesOp.IsDone() == 0:
370 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
373 def MakeInterpol(thePoints):
375 * Create B-Spline curve on the set of points.
376 * \param thePoints Sequence of points for the B-Spline curve.
377 * \return New GEOM_Object, containing the created B-Spline curve.
379 * Example: see GEOM_TestAll.py
381 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
382 if CurvesOp.IsDone() == 0:
383 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
386 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
388 * Create a sketcher (wire or face), following the textual description,
389 * passed through \a theCommand argument. \n
390 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
391 * Format of the description string have to be the following:
393 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
396 * - x1, y1 are coordinates of the first sketcher point (zero by default),
398 * - "R angle" : Set the direction by angle
399 * - "D dx dy" : Set the direction by DX & DY
402 * - "TT x y" : Create segment by point at X & Y
403 * - "T dx dy" : Create segment by point with DX & DY
404 * - "L length" : Create segment by direction & Length
405 * - "IX x" : Create segment by direction & Intersect. X
406 * - "IY y" : Create segment by direction & Intersect. Y
409 * - "C radius length" : Create arc by direction, radius and length(in degree)
412 * - "WW" : Close Wire (to finish)
413 * - "WF" : Close Wire and build face (to finish)
415 * \param theCommand String, defining the sketcher in local
416 * coordinates of the working plane.
417 * \param theWorkingPlane Nine double values, defining origin,
418 * OZ and OX directions of the working plane.
419 * \return New GEOM_Object, containing the created wire.
421 * Example: see GEOM_TestAll.py
423 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
424 if CurvesOp.IsDone() == 0:
425 print "MakeSketcher : ", CurvesOp.GetErrorCode()
428 # -----------------------------------------------------------------------------
429 # Create 3D Primitives
430 # -----------------------------------------------------------------------------
432 def MakeBox(x1,y1,z1,x2,y2,z2):
434 * Create a box by coordinates of two opposite vertices.
436 * Example: see GEOM_TestAll.py
438 pnt1 = MakeVertex(x1,y1,z1)
439 pnt2 = MakeVertex(x2,y2,z2)
440 return MakeBoxTwoPnt(pnt1,pnt2)
442 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
444 * Create a box with specified dimensions along the coordinate axes
445 * and with edges, parallel to the coordinate axes.
446 * Center of the box will be at point (DX/2, DY/2, DZ/2).
447 * \param theDX Length of Box edges, parallel to OX axis.
448 * \param theDY Length of Box edges, parallel to OY axis.
449 * \param theDZ Length of Box edges, parallel to OZ axis.
450 * \return New GEOM_Object, containing the created box.
452 * Example: see GEOM_TestAll.py
454 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
455 if PrimOp.IsDone() == 0:
456 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
459 def MakeBoxTwoPnt(thePnt1, thePnt2):
461 * Create a box with two specified opposite vertices,
462 * and with edges, parallel to the coordinate axes
463 * \param thePnt1 First of two opposite vertices.
464 * \param thePnt2 Second of two opposite vertices.
465 * \return New GEOM_Object, containing the created box.
467 * Example: see GEOM_TestAll.py
469 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
470 if PrimOp.IsDone() == 0:
471 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
474 def MakeCylinder(thePnt, theAxis, theR, theH):
476 * Create a cylinder with given base point, axis, radius and height.
477 * \param thePnt Central point of cylinder base.
478 * \param theAxis Cylinder axis.
479 * \param theR Cylinder radius.
480 * \param theH Cylinder height.
481 * \return New GEOM_Object, containing the created cylinder.
483 * Example: see GEOM_TestAll.py
485 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
486 if PrimOp.IsDone() == 0:
487 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
490 def MakeCylinderRH(theR, theH):
492 * Create a cylinder with given radius and height at
493 * the origin of coordinate system. Axis of the cylinder
494 * will be collinear to the OZ axis of the coordinate system.
495 * \param theR Cylinder radius.
496 * \param theH Cylinder height.
497 * \return New GEOM_Object, containing the created cylinder.
499 * Example: see GEOM_TestAll.py
501 anObj = PrimOp.MakeCylinderRH(theR, theH)
502 if PrimOp.IsDone() == 0:
503 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
506 def MakeSpherePntR(thePnt, theR):
508 * Create a sphere with given center and radius.
509 * \param thePnt Sphere center.
510 * \param theR Sphere radius.
511 * \return New GEOM_Object, containing the created sphere.
513 * Example: see GEOM_TestAll.py
515 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
516 if PrimOp.IsDone() == 0:
517 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
520 def MakeSphere(x, y, z, theR):
522 * Create a sphere with given center and radius.
523 * \param x,y,z Coordinates of sphere center.
524 * \param theR Sphere radius.
525 * \return New GEOM_Object, containing the created sphere.
527 * Example: see GEOM_TestAll.py
529 point = MakeVertex(x, y, z)
530 anObj = MakeSpherePntR(point, theR)
533 def MakeSphereR(theR):
535 * Create a sphere with given radius at the origin of coordinate system.
536 * \param theR Sphere radius.
537 * \return New GEOM_Object, containing the created sphere.
539 * Example: see GEOM_TestAll.py
541 anObj = PrimOp.MakeSphereR(theR)
542 if PrimOp.IsDone() == 0:
543 print "MakeSphereR : ", PrimOp.GetErrorCode()
546 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
548 * Create a cone with given base point, axis, height and radiuses.
549 * \param thePnt Central point of the first cone base.
550 * \param theAxis Cone axis.
551 * \param theR1 Radius of the first cone base.
552 * \param theR2 Radius of the second cone base.
553 * \note If both radiuses are non-zero, the cone will be truncated.
554 * \note If the radiuses are equal, a cylinder will be created instead.
555 * \param theH Cone height.
556 * \return New GEOM_Object, containing the created cone.
558 * Example: see GEOM_TestAll.py
560 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
561 if PrimOp.IsDone() == 0:
562 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
565 def MakeConeR1R2H(theR1, theR2, theH):
567 * Create a cone with given height and radiuses at
568 * the origin of coordinate system. Axis of the cone will
569 * be collinear to the OZ axis of the coordinate system.
570 * \param theR1 Radius of the first cone base.
571 * \param theR2 Radius of the second cone base.
572 * \note If both radiuses are non-zero, the cone will be truncated.
573 * \note If the radiuses are equal, a cylinder will be created instead.
574 * \param theH Cone height.
575 * \return New GEOM_Object, containing the created cone.
577 * Example: see GEOM_TestAll.py
579 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
580 if PrimOp.IsDone() == 0:
581 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
584 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
586 * Create a torus with given center, normal vector and radiuses.
587 * \param thePnt Torus central point.
588 * \param theVec Torus axis of symmetry.
589 * \param theRMajor Torus major radius.
590 * \param theRMinor Torus minor radius.
591 * \return New GEOM_Object, containing the created torus.
593 * Example: see GEOM_TestAll.py
595 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
596 if PrimOp.IsDone() == 0:
597 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
600 def MakeTorusRR(theRMajor, theRMinor):
602 * Create a torus with given radiuses at the origin of coordinate system.
603 * \param theRMajor Torus major radius.
604 * \param theRMinor Torus minor radius.
605 * \return New GEOM_Object, containing the created torus.
607 * Example: see GEOM_TestAll.py
609 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
610 if PrimOp.IsDone() == 0:
611 print "MakeTorusRR : ", PrimOp.GetErrorCode()
614 def MakePrism(theBase, thePoint1, thePoint2):
616 * Create a shape by extrusion of the base shape along a vector, defined by two points.
617 * \param theBase Base shape to be extruded.
618 * \param thePoint1 First end of extrusion vector.
619 * \param thePoint2 Second end of extrusion vector.
620 * \return New GEOM_Object, containing the created prism.
622 * Example: see GEOM_TestAll.py
624 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
625 if PrimOp.IsDone() == 0:
626 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
629 def MakePrismVecH(theBase, theVec, theH):
631 * Create a shape by extrusion of the base shape along the vector,
632 * i.e. all the space, transfixed by the base shape during its translation
633 * along the vector on the given distance.
634 * \param theBase Base shape to be extruded.
635 * \param theVec Direction of extrusion.
636 * \param theH Prism dimension along theVec.
637 * \return New GEOM_Object, containing the created prism.
639 * Example: see GEOM_TestAll.py
641 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
642 if PrimOp.IsDone() == 0:
643 print "MakePrismVecH : ", PrimOp.GetErrorCode()
646 def MakePipe(theBase, thePath):
648 * Create a shape by extrusion of the base shape along
649 * the path shape. The path shape can be a wire or an edge.
650 * \param theBase Base shape to be extruded.
651 * \param thePath Path shape to extrude the base shape along it.
652 * \return New GEOM_Object, containing the created pipe.
654 * Example: see GEOM_TestAll.py
656 anObj = PrimOp.MakePipe(theBase, thePath)
657 if PrimOp.IsDone() == 0:
658 print "MakePipe : ", PrimOp.GetErrorCode()
661 def MakeRevolution(theBase, theAxis, theAngle):
663 * Create a shape by revolution of the base shape around the axis
664 * on the given angle, i.e. all the space, transfixed by the base
665 * shape during its rotation around the axis on the given angle.
666 * \param theBase Base shape to be rotated.
667 * \param theAxis Rotation axis.
668 * \param theAngle Rotation angle in radians.
669 * \return New GEOM_Object, containing the created revolution.
671 * Example: see GEOM_TestAll.py
673 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
674 if PrimOp.IsDone() == 0:
675 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
678 # -----------------------------------------------------------------------------
680 # -----------------------------------------------------------------------------
682 def MakeEdge(thePnt1, thePnt2):
684 * Create a linear edge with specified ends.
685 * \param thePnt1 Point for the first end of edge.
686 * \param thePnt2 Point for the second end of edge.
687 * \return New GEOM_Object, containing the created edge.
689 * Example: see GEOM_TestAll.py
691 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
692 if ShapesOp.IsDone() == 0:
693 print "MakeEdge : ", ShapesOp.GetErrorCode()
696 def MakeWire(theEdgesAndWires):
698 * Create a wire from the set of edges and wires.
699 * \param theEdgesAndWires List of edges and/or wires.
700 * \return New GEOM_Object, containing the created wire.
702 * Example: see GEOM_TestAll.py
704 anObj = ShapesOp.MakeWire(theEdgesAndWires)
705 if ShapesOp.IsDone() == 0:
706 print "MakeWire : ", ShapesOp.GetErrorCode()
709 def MakeFace(theWire, isPlanarWanted):
711 * Create a face on the given wire.
712 * \param theWire Wire to build the face on.
713 * \param isPlanarWanted If TRUE, only planar face will be built.
714 * If impossible, NULL object will be returned.
715 * \return New GEOM_Object, containing the created face.
717 * Example: see GEOM_TestAll.py
719 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
720 if ShapesOp.IsDone() == 0:
721 print "MakeFace : ", ShapesOp.GetErrorCode()
724 def MakeFaceWires(theWires, isPlanarWanted):
726 * Create a face on the given wires set.
727 * \param theWires List of wires to build the face on.
728 * \param isPlanarWanted If TRUE, only planar face will be built.
729 * If impossible, NULL object will be returned.
730 * \return New GEOM_Object, containing the created face.
732 * Example: see GEOM_TestAll.py
734 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
735 if ShapesOp.IsDone() == 0:
736 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
739 def MakeFaces(theWires, isPlanarWanted):
741 * Shortcut to MakeFaceWires()
743 * Example: see GEOM_TestOthers.py
745 anObj = MakeFaceWires(theWires, isPlanarWanted)
748 def MakeShell(theFacesAndShells):
750 * Create a shell from the set of faces and shells.
751 * \param theFacesAndShells List of faces and/or shells.
752 * \return New GEOM_Object, containing the created shell.
754 * Example: see GEOM_TestAll.py
756 anObj = ShapesOp.MakeShell(theFacesAndShells)
757 if ShapesOp.IsDone() == 0:
758 print "MakeShell : ", ShapesOp.GetErrorCode()
761 def MakeSolid(theShells):
763 * Create a solid, bounded by the given shells.
764 * \param theShells Sequence of bounding shells.
765 * \return New GEOM_Object, containing the created solid.
767 * Example: see GEOM_TestAll.py
769 anObj = ShapesOp.MakeSolidShells(theShells)
770 if ShapesOp.IsDone() == 0:
771 print "MakeSolid : ", ShapesOp.GetErrorCode()
774 def MakeCompound(theShapes):
776 * Create a compound of the given shapes.
777 * \param theShapes List of shapes to put in compound.
778 * \return New GEOM_Object, containing the created compound.
780 * Example: see GEOM_TestAll.py
782 anObj = ShapesOp.MakeCompound(theShapes)
783 if ShapesOp.IsDone() == 0:
784 print "MakeCompound : ", ShapesOp.GetErrorCode()
787 def NumberOfFaces(theShape):
789 * Gives quantity of faces in the given shape.
790 * \param theShape Shape to count faces of.
791 * \return Quantity of faces.
793 * Example: see GEOM_TestOthers.py
795 nb_faces = ShapesOp.NumberOfFaces(theShape)
796 if ShapesOp.IsDone() == 0:
797 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
800 def NumberOfEdges(theShape):
802 * Gives quantity of edges in the given shape.
803 * \param theShape Shape to count edges of.
804 * \return Quantity of edges.
806 * Example: see GEOM_TestOthers.py
808 nb_edges = ShapesOp.NumberOfEdges(theShape)
809 if ShapesOp.IsDone() == 0:
810 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
813 def ChangeOrientation(theShape):
815 * Reverses an orientation the given shape.
816 * \param theShape Shape to be reversed.
817 * \return The reversed copy of theShape.
819 * Example: see GEOM_TestAll.py
821 anObj = ShapesOp.ChangeOrientation(theShape)
822 if ShapesOp.IsDone() == 0:
823 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
826 def OrientationChange(theShape):
828 * Shortcut to ChangeOrientation()
830 * Example: see GEOM_TestOthers.py
832 anObj = ChangeOrientation(theShape)
835 def GetFreeFacesIDs(theShape):
837 * Retrieve all free faces from the given shape.
838 * Free face is a face, which is not shared between two shells of the shape.
839 * \param theShape Shape to find free faces in.
840 * \return List of IDs of all free faces, contained in theShape.
842 * Example: see GEOM_TestOthers.py
844 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
845 if ShapesOp.IsDone() == 0:
846 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
849 def GetSharedShapes(theShape1, theShape2, theShapeType):
851 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
852 * \param theShape1 Shape to find sub-shapes in.
853 * \param theShape2 Shape to find shared sub-shapes with.
854 * \param theShapeType Type of sub-shapes to be retrieved.
855 * \return List of sub-shapes of theShape1, shared with theShape2.
857 * Example: see GEOM_TestOthers.py
859 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
860 if ShapesOp.IsDone() == 0:
861 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
864 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
866 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
867 * the specified plane by the certain way, defined through \a theState parameter.
868 * \param theShape Shape to find sub-shapes of.
869 * \param theShapeType Type of sub-shapes to be retrieved.
870 * \param theAx1 Vector (or line, or linear edge), specifying normal
871 * direction and location of the plane to find shapes on.
872 * \param theState The state of the subshapes to find. It can be one of
873 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
874 * \return List of all found sub-shapes.
876 * Example: see GEOM_TestOthers.py
878 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
879 if ShapesOp.IsDone() == 0:
880 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
883 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
885 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
886 * the specified cylinder by the certain way, defined through \a theState parameter.
887 * \param theShape Shape to find sub-shapes of.
888 * \param theShapeType Type of sub-shapes to be retrieved.
889 * \param theAxis Vector (or line, or linear edge), specifying
890 * axis of the cylinder to find shapes on.
891 * \param theRadius Radius of the cylinder to find shapes on.
892 * \param theState The state of the subshapes to find. It can be one of
893 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
894 * \return List of all found sub-shapes.
896 * Example: see GEOM_TestOthers.py
898 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
899 if ShapesOp.IsDone() == 0:
900 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
903 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
905 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
906 * the specified sphere by the certain way, defined through \a theState parameter.
907 * \param theShape Shape to find sub-shapes of.
908 * \param theShapeType Type of sub-shapes to be retrieved.
909 * \param theCenter Point, specifying center of the sphere to find shapes on.
910 * \param theRadius Radius of the sphere to find shapes on.
911 * \param theState The state of the subshapes to find. It can be one of
912 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
913 * \return List of all found sub-shapes.
915 * Example: see GEOM_TestOthers.py
917 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
918 if ShapesOp.IsDone() == 0:
919 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
922 def GetInPlace(theShapeWhere, theShapeWhat):
924 * Get sub-shape(s) of theShapeWhere, which are
925 * coincident with \a theShapeWhat or could be a part of it.
926 * \param theShapeWhere Shape to find sub-shapes of.
927 * \param theShapeWhat Shape, specifying what to find.
928 * \return Group of all found sub-shapes or a single found sub-shape.
930 * Example: see GEOM_TestOthers.py
932 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
933 if ShapesOp.IsDone() == 0:
934 print "GetInPlace : ", ShapesOp.GetErrorCode()
937 # -----------------------------------------------------------------------------
938 # Access to sub-shapes by their unique IDs inside the main shape.
939 # -----------------------------------------------------------------------------
941 def GetSubShape(aShape, ListOfID):
943 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
944 * of <aShape>, selected by their unique IDs inside <aShape>
946 * Example: see GEOM_TestAll.py
948 anObj = geom.AddSubShape(aShape,ListOfID)
951 def GetSubShapeID(aShape, aSubShape):
953 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
955 * Example: see GEOM_TestAll.py
957 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
958 if LocalOp.IsDone() == 0:
959 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
962 # -----------------------------------------------------------------------------
964 # -----------------------------------------------------------------------------
966 def SubShapeAll(aShape, aType):
968 * Explode a shape on subshapes of a given type.
969 * \param theShape Shape to be exploded.
970 * \param theShapeType Type of sub-shapes to be retrieved.
971 * \return List of sub-shapes of type theShapeType, contained in theShape.
973 * Example: see GEOM_TestAll.py
975 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
976 if ShapesOp.IsDone() == 0:
977 print "MakeExplode : ", ShapesOp.GetErrorCode()
980 def SubShapeAllIDs(aShape, aType):
982 * Explode a shape on subshapes of a given type.
983 * \param theShape Shape to be exploded.
984 * \param theShapeType Type of sub-shapes to be retrieved.
985 * \return List of IDs of sub-shapes.
987 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
988 if ShapesOp.IsDone() == 0:
989 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
992 def SubShapeAllSorted(aShape, aType):
994 * Explode a shape on subshapes of a given type.
995 * Sub-shapes will be sorted by coordinates of their gravity centers.
996 * \param theShape Shape to be exploded.
997 * \param theShapeType Type of sub-shapes to be retrieved.
998 * \return List of sub-shapes of type theShapeType, contained in theShape.
1000 * Example: see GEOM_TestAll.py
1002 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1003 if ShapesOp.IsDone() == 0:
1004 print "MakeExplode : ", ShapesOp.GetErrorCode()
1007 def SubShapeAllSortedIDs(aShape, aType):
1009 * Explode a shape on subshapes of a given type.
1010 * Sub-shapes will be sorted by coordinates of their gravity centers.
1011 * \param theShape Shape to be exploded.
1012 * \param theShapeType Type of sub-shapes to be retrieved.
1013 * \return List of IDs of sub-shapes.
1015 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1016 if ShapesOp.IsDone() == 0:
1017 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1020 def SubShape(aShape, aType, ListOfInd):
1022 * Obtain a compound of sub-shapes of <aShape>,
1023 * selected by they indices in list of all sub-shapes of type <aType>.
1024 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1026 * Example: see GEOM_TestAll.py
1029 AllShapeList = SubShapeAll(aShape, aType)
1030 for ind in ListOfInd:
1031 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1032 anObj = GetSubShape(aShape, ListOfIDs)
1035 def SubShapeSorted(aShape, aType, ListOfInd):
1037 * Obtain a compound of sub-shapes of <aShape>,
1038 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1039 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1041 * Example: see GEOM_TestAll.py
1044 AllShapeList = SubShapeAllSorted(aShape, aType)
1045 for ind in ListOfInd:
1046 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1047 anObj = GetSubShape(aShape, ListOfIDs)
1050 # -----------------------------------------------------------------------------
1051 # Healing operations
1052 # -----------------------------------------------------------------------------
1054 def ProcessShape(theShape, theOperators, theParameters, theValues):
1056 * Apply a sequence of Shape Healing operators to the given object.
1057 * \param theShape Shape to be processed.
1058 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1059 * \param theParameters List of names of parameters
1060 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1061 * \param theValues List of values of parameters, in the same order
1062 * as parameters are listed in \a theParameters list.
1063 * \return New GEOM_Object, containing processed shape.
1065 * Example: see GEOM_TestHealing.py
1067 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1068 if HealOp.IsDone() == 0:
1069 print "ProcessShape : ", HealOp.GetErrorCode()
1072 def SuppressFaces(theObject, theFaces):
1074 * Remove faces from the given object (shape).
1075 * \param theObject Shape to be processed.
1076 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1077 * removes ALL faces of the given object.
1078 * \return New GEOM_Object, containing processed shape.
1080 * Example: see GEOM_TestHealing.py
1082 anObj = HealOp.SuppressFaces(theObject, theFaces)
1083 if HealOp.IsDone() == 0:
1084 print "SuppressFaces : ", HealOp.GetErrorCode()
1087 def MakeSewing(ListShape, theTolerance):
1089 * Sewing of some shapes into single shape.
1091 * Example: see GEOM_TestHealing.py
1093 comp = MakeCompound(ListShape)
1094 anObj = Sew(comp, theTolerance)
1097 def Sew(theObject, theTolerance):
1099 * Sewing of the given object.
1100 * \param theObject Shape to be processed.
1101 * \param theTolerance Required tolerance value.
1102 * \return New GEOM_Object, containing processed shape.
1104 * Example: see MakeSewing() above
1106 anObj = HealOp.Sew(theObject, theTolerance)
1107 if HealOp.IsDone() == 0:
1108 print "Sew : ", HealOp.GetErrorCode()
1111 def SuppressInternalWires(theObject, theWires):
1113 * Remove internal wires and edges from the given object (face).
1114 * \param theObject Shape to be processed.
1115 * \param theWires Indices of wires to be removed, if EMPTY then the method
1116 * removes ALL internal wires of the given object.
1117 * \return New GEOM_Object, containing processed shape.
1119 * Example: see GEOM_TestHealing.py
1121 anObj = HealOp.RemoveIntWires(theObject, theWires)
1122 if HealOp.IsDone() == 0:
1123 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1126 def SuppressHoles(theObject, theWires):
1128 * Remove internal closed contours (holes) from the given object.
1129 * \param theObject Shape to be processed.
1130 * \param theWires Indices of wires to be removed, if EMPTY then the method
1131 * removes ALL internal holes of the given object
1132 * \return New GEOM_Object, containing processed shape.
1134 * Example: see GEOM_TestHealing.py
1136 anObj = HealOp.FillHoles(theObject, theWires)
1137 if HealOp.IsDone() == 0:
1138 print "SuppressHoles : ", HealOp.GetErrorCode()
1141 def CloseContour(theObject, theWires, isCommonVertex):
1143 * Close an open wire.
1144 * \param theObject Shape to be processed.
1145 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1146 * if -1, then theObject itself is a wire.
1147 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1148 * If FALS : closure by creation of an edge between ends.
1149 * \return New GEOM_Object, containing processed shape.
1151 * Example: see GEOM_TestHealing.py
1153 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1154 if HealOp.IsDone() == 0:
1155 print "CloseContour : ", HealOp.GetErrorCode()
1158 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1160 * Addition of a point to a given edge object.
1161 * \param theObject Shape to be processed.
1162 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1163 * if -1, then theObject itself is the edge.
1164 * \param theValue Value of parameter on edge or length parameter,
1165 * depending on \a isByParameter.
1166 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1167 * if FALSE : \a theValue is treated as a length parameter [0..1]
1168 * \return New GEOM_Object, containing processed shape.
1170 * Example: see GEOM_TestHealing.py
1172 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1173 if HealOp.IsDone() == 0:
1174 print "DivideEdge : ", HealOp.GetErrorCode()
1177 def GetFreeBoundary(theObject):
1179 * Get a list of wires (wrapped in GEOM_Object-s),
1180 * that constitute a free boundary of the given shape.
1181 * \param theObject Shape to get free boundary of.
1182 * \return [status, theClosedWires, theOpenWires]
1183 * status: FALSE, if an error(s) occured during the method execution.
1184 * theClosedWires: Closed wires on the free boundary of the given shape.
1185 * theOpenWires: Open wires on the free boundary of the given shape.
1187 * Example: see GEOM_TestHealing.py
1189 anObj = HealOp.GetFreeBoundary(theObject)
1190 if HealOp.IsDone() == 0:
1191 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1194 # -----------------------------------------------------------------------------
1195 # Create advanced objects
1196 # -----------------------------------------------------------------------------
1198 def MakeCopy(theOriginal):
1200 * Create a copy of the given object
1202 * Example: see GEOM_TestAll.py
1204 anObj = InsertOp.MakeCopy(theOriginal)
1205 if InsertOp.IsDone() == 0:
1206 print "MakeCopy : ", InsertOp.GetErrorCode()
1209 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1211 * Create a filling from the given compound of contours.
1212 * \param theShape the compound of contours
1213 * \param theMinDeg a minimal degree
1214 * \param theMaxDeg a maximal degree
1215 * \param theTol2D a 2d tolerance
1216 * \param theTol3D a 3d tolerance
1217 * \param theNbIter a number of iteration
1218 * \return New GEOM_Object, containing the created filling surface.
1220 * Example: see GEOM_TestAll.py
1222 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1223 if PrimOp.IsDone() == 0:
1224 print "MakeFilling : ", PrimOp.GetErrorCode()
1227 def MakeGlueFaces(theShape, theTolerance):
1229 * Replace coincident faces in theShape by one face.
1230 * \param theShape Initial shape.
1231 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1232 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1234 * Example: see GEOM_Spanner.py
1236 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1237 if ShapesOp.IsDone() == 0:
1238 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1241 # -----------------------------------------------------------------------------
1242 # Boolean (Common, Cut, Fuse, Section)
1243 # -----------------------------------------------------------------------------
1245 def MakeBoolean(theShape1, theShape2, theOperation):
1247 * Perform one of boolean operations on two given shapes.
1248 * \param theShape1 First argument for boolean operation.
1249 * \param theShape2 Second argument for boolean operation.
1250 * \param theOperation Indicates the operation to be done:
1251 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1252 * \return New GEOM_Object, containing the result shape.
1254 * Example: see GEOM_TestAll.py
1256 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1257 if BoolOp.IsDone() == 0:
1258 print "MakeBoolean : ", BoolOp.GetErrorCode()
1261 def MakeCommon(s1, s2):
1263 * Shortcut to MakeBoolean(s1, s2, 1)
1265 * Example: see GEOM_TestOthers.py
1267 return MakeBoolean(s1, s2, 1)
1269 def MakeCut(s1, s2):
1271 * Shortcut to MakeBoolean(s1, s2, 2)
1273 * Example: see GEOM_TestOthers.py
1275 return MakeBoolean(s1, s2, 2)
1277 def MakeFuse(s1, s2):
1279 * Shortcut to MakeBoolean(s1, s2, 3)
1281 * Example: see GEOM_TestOthers.py
1283 return MakeBoolean(s1, s2, 3)
1285 def MakeSection(s1, s2):
1287 * Shortcut to MakeBoolean(s1, s2, 4)
1289 * Example: see GEOM_TestOthers.py
1291 return MakeBoolean(s1, s2, 4)
1293 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1294 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1296 * Perform partition operation.
1297 * \param ListShapes Shapes to be intersected.
1298 * \param ListTools Shapes to intersect theShapes.
1299 * \param ListKeepInside Shapes, outside which the results will be deleted.
1300 * Each shape from theKeepInside must belong to theShapes also.
1301 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1302 * Each shape from theRemoveInside must belong to theShapes also.
1303 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1304 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1305 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1306 * \return New GEOM_Object, containing the result shapes.
1308 * Example: see GEOM_TestAll.py
1310 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1311 ListKeepInside, ListRemoveInside,
1312 Limit, RemoveWebs, ListMaterials);
1313 if BoolOp.IsDone() == 0:
1314 print "MakePartition : ", BoolOp.GetErrorCode()
1317 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1318 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1320 * Shortcut to MakePartition()
1322 * Example: see GEOM_TestOthers.py
1324 anObj = MakePartition(ListShapes, ListTools,
1325 ListKeepInside, ListRemoveInside,
1326 Limit, RemoveWebs, ListMaterials);
1329 def MakeHalfPartition(theShape, thePlane):
1331 * Perform partition of the Shape with the Plane
1332 * \param theShape Shape to be intersected.
1333 * \param thePlane Tool shape, to intersect theShape.
1334 * \return New GEOM_Object, containing the result shape.
1336 * Example: see GEOM_TestAll.py
1338 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1339 if BoolOp.IsDone() == 0:
1340 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1343 # -----------------------------------------------------------------------------
1345 # -----------------------------------------------------------------------------
1347 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1349 * Translate the given object along the vector, specified
1350 * by its end points, creating its copy before the translation.
1351 * \param theObject The object to be translated.
1352 * \param thePoint1 Start point of translation vector.
1353 * \param thePoint2 End point of translation vector.
1354 * \return New GEOM_Object, containing the translated object.
1356 * Example: see GEOM_TestAll.py
1358 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1359 if TrsfOp.IsDone() == 0:
1360 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1363 def MakeTranslation(theObject, theDX, theDY, theDZ):
1365 * Translate the given object along the vector, specified
1366 * by its components, creating its copy before the translation.
1367 * \param theObject The object to be translated.
1368 * \param theDX,theDY,theDZ Components of translation vector.
1369 * \return New GEOM_Object, containing the translated object.
1371 * Example: see GEOM_TestAll.py
1373 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1374 if TrsfOp.IsDone() == 0:
1375 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1378 def MakeTranslationVector(theObject, theVector):
1380 * Translate the given object along the given vector,
1381 * creating its copy before the translation.
1382 * \param theObject The object to be translated.
1383 * \param theVector The translation vector.
1384 * \return New GEOM_Object, containing the translated object.
1386 * Example: see GEOM_TestAll.py
1388 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1389 if TrsfOp.IsDone() == 0:
1390 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1393 def MakeRotation(theObject, theAxis, theAngle):
1395 * Rotate the given object around the given axis
1396 * on the given angle, creating its copy before the rotatation.
1397 * \param theObject The object to be rotated.
1398 * \param theAxis Rotation axis.
1399 * \param theAngle Rotation angle in radians.
1400 * \return New GEOM_Object, containing the rotated object.
1402 * Example: see GEOM_TestAll.py
1404 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1405 if TrsfOp.IsDone() == 0:
1406 print "RotateCopy : ", TrsfOp.GetErrorCode()
1409 def MakeScaleTransform(theObject, thePoint, theFactor):
1411 * Scale the given object by the factor, creating its copy before the scaling.
1412 * \param theObject The object to be scaled.
1413 * \param thePoint Center point for scaling.
1414 * \param theFactor Scaling factor value.
1415 * \return New GEOM_Object, containing the scaled shape.
1417 * Example: see GEOM_TestAll.py
1419 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1420 if TrsfOp.IsDone() == 0:
1421 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1424 def MakeMirrorByPlane(theObject, thePlane):
1426 * Create an object, symmetrical
1427 * to the given one relatively the given plane.
1428 * \param theObject The object to be mirrored.
1429 * \param thePlane Plane of symmetry.
1430 * \return New GEOM_Object, containing the mirrored shape.
1432 * Example: see GEOM_TestAll.py
1434 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1435 if TrsfOp.IsDone() == 0:
1436 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1439 def MakeMirrorByAxis(theObject, theAxis):
1441 * Create an object, symmetrical
1442 * to the given one relatively the given axis.
1443 * \param theObject The object to be mirrored.
1444 * \param theAxis Axis of symmetry.
1445 * \return New GEOM_Object, containing the mirrored shape.
1447 * Example: see GEOM_TestAll.py
1449 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1450 if TrsfOp.IsDone() == 0:
1451 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1454 def MakeMirrorByPoint(theObject, thePoint):
1456 * Create an object, symmetrical
1457 * to the given one relatively the given point.
1458 * \param theObject The object to be mirrored.
1459 * \param thePoint Point of symmetry.
1460 * \return New GEOM_Object, containing the mirrored shape.
1462 * Example: see GEOM_TestAll.py
1464 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1465 if TrsfOp.IsDone() == 0:
1466 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1469 def MakePosition(theObject, theStartLCS, theEndLCS):
1471 * Modify the Location of the given object by LCS
1472 * creating its copy before the setting
1474 * Example: see GEOM_TestAll.py
1476 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1477 if TrsfOp.IsDone() == 0:
1478 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1481 def MakeOffset(theObject, theOffset):
1483 * Create new object as offset of the given one.
1484 * \param theObject The base object for the offset.
1485 * \param theOffset Offset value.
1486 * \return New GEOM_Object, containing the offset object.
1488 * Example: see GEOM_TestAll.py
1490 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1491 if TrsfOp.IsDone() == 0:
1492 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1495 # -----------------------------------------------------------------------------
1497 # -----------------------------------------------------------------------------
1499 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1501 * Translate the given object along the given vector a given number times
1502 * \param theObject The object to be translated.
1503 * \param theVector Direction of the translation.
1504 * \param theStep Distance to translate on.
1505 * \param theNbTimes Quantity of translations to be done.
1506 * \return New GEOM_Object, containing compound of all
1507 * the shapes, obtained after each translation.
1509 * Example: see GEOM_TestAll.py
1511 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1512 if TrsfOp.IsDone() == 0:
1513 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1516 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1517 theVector2, theStep2, theNbTimes2):
1519 * Conseqently apply two specified translations to theObject specified number of times.
1520 * \param theObject The object to be translated.
1521 * \param theVector1 Direction of the first translation.
1522 * \param theStep1 Step of the first translation.
1523 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1524 * \param theVector2 Direction of the second translation.
1525 * \param theStep2 Step of the second translation.
1526 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1527 * \return New GEOM_Object, containing compound of all
1528 * the shapes, obtained after each translation.
1530 * Example: see GEOM_TestAll.py
1532 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1533 theVector2, theStep2, theNbTimes2)
1534 if TrsfOp.IsDone() == 0:
1535 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1538 def MultiRotate1D(theObject, theAxis, theNbTimes):
1540 * Rotate the given object around the given axis a given number times.
1541 * Rotation angle will be 2*PI/theNbTimes.
1542 * \param theObject The object to be rotated.
1543 * \param theAxis The rotation axis.
1544 * \param theNbTimes Quantity of rotations to be done.
1545 * \return New GEOM_Object, containing compound of all the
1546 * shapes, obtained after each rotation.
1548 * Example: see GEOM_TestAll.py
1550 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1551 if TrsfOp.IsDone() == 0:
1552 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1555 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1557 * Rotate the given object around the
1558 * given axis on the given angle a given number
1559 * times and multi-translate each rotation result.
1560 * Translation direction passes through center of gravity
1561 * of rotated shape and its projection on the rotation axis.
1562 * \param theObject The object to be rotated.
1563 * \param theAxis Rotation axis.
1564 * \param theAngle Rotation angle in graduces.
1565 * \param theNbTimes1 Quantity of rotations to be done.
1566 * \param theStep Translation distance.
1567 * \param theNbTimes2 Quantity of translations to be done.
1568 * \return New GEOM_Object, containing compound of all the
1569 * shapes, obtained after each transformation.
1571 * Example: see GEOM_TestAll.py
1573 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1574 if TrsfOp.IsDone() == 0:
1575 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1578 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1580 * The same, as MultiRotate1D(), but axis is given by direction and point
1582 * Example: see GEOM_TestOthers.py
1584 aVec = MakeLine(aPoint,aDir)
1585 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1588 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1590 * The same, as MultiRotate2D(), but axis is given by direction and point
1592 * Example: see GEOM_TestOthers.py
1594 aVec = MakeLine(aPoint,aDir)
1595 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1598 # -----------------------------------------------------------------------------
1600 # -----------------------------------------------------------------------------
1602 def MakeFilletAll(theShape, theR):
1604 * Perform a fillet on all edges of the given shape.
1605 * \param theShape Shape, to perform fillet on.
1606 * \param theR Fillet radius.
1607 * \return New GEOM_Object, containing the result shape.
1609 * Example: see GEOM_TestOthers.py
1611 anObj = LocalOp.MakeFilletAll(theShape, theR)
1612 if LocalOp.IsDone() == 0:
1613 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1616 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1618 * Perform a fillet on the specified edges/faces of the given shape
1619 * \param theShape Shape, to perform fillet on.
1620 * \param theR Fillet radius.
1621 * \param theShapeType Type of shapes in <theListShapes>.
1622 * \param theListShapes Global indices of edges/faces to perform fillet on.
1623 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1624 * \return New GEOM_Object, containing the result shape.
1626 * Example: see GEOM_TestAll.py
1629 if theShapeType == ShapeType["EDGE"]:
1630 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1632 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1633 if LocalOp.IsDone() == 0:
1634 print "MakeFillet : ", LocalOp.GetErrorCode()
1637 def MakeChamferAll(theShape, theD):
1639 * Perform a symmetric chamfer on all edges of the given shape.
1640 * \param theShape Shape, to perform chamfer on.
1641 * \param theD Chamfer size along each face.
1642 * \return New GEOM_Object, containing the result shape.
1644 * Example: see GEOM_TestOthers.py
1646 anObj = LocalOp.MakeChamferAll(theShape, theD)
1647 if LocalOp.IsDone() == 0:
1648 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1651 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1653 * Perform a chamfer on edges, common to the specified faces,
1654 * with distance D1 on the Face1
1655 * \param theShape Shape, to perform chamfer on.
1656 * \param theD1 Chamfer size along \a theFace1.
1657 * \param theD2 Chamfer size along \a theFace2.
1658 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1659 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1660 * \return New GEOM_Object, containing the result shape.
1662 * Example: see GEOM_TestAll.py
1664 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1665 if LocalOp.IsDone() == 0:
1666 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1669 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1671 * Perform a chamfer on all edges of the specified faces,
1672 * with distance D1 on the first specified face (if several for one edge)
1673 * \param theShape Shape, to perform chamfer on.
1674 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1675 * connected to the edge, are in \a theFaces, \a theD1
1676 * will be get along face, which is nearer to \a theFaces beginning.
1677 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1678 * \param theFaces Sequence of global indices of faces of \a theShape.
1679 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1680 * \return New GEOM_Object, containing the result shape.
1682 * Example: see GEOM_TestAll.py
1684 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1685 if LocalOp.IsDone() == 0:
1686 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1689 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1691 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1693 * Example: see GEOM_TestOthers.py
1696 if aShapeType == ShapeType["EDGE"]:
1697 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1699 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1702 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1704 * Perform an Archimde operation on the given shape with given parameters.
1705 * The object presenting the resulting face is returned
1706 * \param theShape Shape to be put in water.
1707 * \param theWeight Weight og the shape.
1708 * \param theWaterDensity Density of the water.
1709 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1710 * \return New GEOM_Object, containing a section of \a theShape
1711 * by a plane, corresponding to water level.
1713 * Example: see GEOM_TestAll.py
1715 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1716 if LocalOp.IsDone() == 0:
1717 print "MakeArchimede : ", LocalOp.GetErrorCode()
1720 # -----------------------------------------------------------------------------
1721 # Information objects
1722 # -----------------------------------------------------------------------------
1724 def PointCoordinates(Point):
1726 * Get point coordinates
1729 * Example: see GEOM_TestMeasures.py
1731 aTuple = MeasuOp.PointCoordinates(Point)
1732 if MeasuOp.IsDone() == 0:
1733 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1736 def BasicProperties(theShape):
1738 * Get summarized length of all wires,
1739 * area of surface and volume of the given shape.
1740 * \param theShape Shape to define properties of.
1741 * \return [theLength, theSurfArea, theVolume]
1742 * theLength: Summarized length of all wires of the given shape.
1743 * theSurfArea: Area of surface of the given shape.
1744 * theVolume: Volume of the given shape.
1746 * Example: see GEOM_TestMeasures.py
1748 aTuple = MeasuOp.GetBasicProperties(theShape)
1749 if MeasuOp.IsDone() == 0:
1750 print "BasicProperties : ", MeasuOp.GetErrorCode()
1753 def BoundingBox(theShape):
1755 * Get parameters of bounding box of the given shape
1756 * \param theShape Shape to obtain bounding box of.
1757 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1758 * Xmin,Xmax: Limits of shape along OX axis.
1759 * Ymin,Ymax: Limits of shape along OY axis.
1760 * Zmin,Zmax: Limits of shape along OZ axis.
1762 * Example: see GEOM_TestMeasures.py
1764 aTuple = MeasuOp.GetBoundingBox(theShape)
1765 if MeasuOp.IsDone() == 0:
1766 print "BoundingBox : ", MeasuOp.GetErrorCode()
1769 def Inertia(theShape):
1771 * Get inertia matrix and moments of inertia of theShape.
1772 * \param theShape Shape to calculate inertia of.
1773 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1774 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1775 * Ix,Iy,Iz: Moments of inertia of the given shape.
1777 * Example: see GEOM_TestMeasures.py
1779 aTuple = MeasuOp.GetInertia(theShape)
1780 if MeasuOp.IsDone() == 0:
1781 print "Inertia : ", MeasuOp.GetErrorCode()
1784 def MinDistance(theShape1, theShape2):
1786 * Get minimal distance between the given shapes.
1787 * \param theShape1,theShape2 Shapes to find minimal distance between.
1788 * \return Value of the minimal distance between the given shapes.
1790 * Example: see GEOM_TestMeasures.py
1792 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1793 if MeasuOp.IsDone() == 0:
1794 print "MinDistance : ", MeasuOp.GetErrorCode()
1797 def Tolerance(theShape):
1799 * Get min and max tolerances of sub-shapes of theShape
1800 * \param theShape Shape, to get tolerances of.
1801 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1802 * FaceMin,FaceMax: Min and max tolerances of the faces.
1803 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1804 * VertMin,VertMax: Min and max tolerances of the vertices.
1806 * Example: see GEOM_TestMeasures.py
1808 aTuple = MeasuOp.GetTolerance(theShape)
1809 if MeasuOp.IsDone() == 0:
1810 print "Tolerance : ", MeasuOp.GetErrorCode()
1813 def WhatIs(theShape):
1815 * Obtain description of the given shape (number of sub-shapes of each type)
1816 * \param theShape Shape to be described.
1817 * \return Description of the given shape.
1819 * Example: see GEOM_TestMeasures.py
1821 aDescr = MeasuOp.WhatIs(theShape)
1822 if MeasuOp.IsDone() == 0:
1823 print "WhatIs : ", MeasuOp.GetErrorCode()
1826 def MakeCDG(theShape):
1828 * Get a point, situated at the centre of mass of theShape.
1829 * \param theShape Shape to define centre of mass of.
1830 * \return New GEOM_Object, containing the created point.
1832 * Example: see GEOM_TestMeasures.py
1834 anObj = MeasuOp.GetCentreOfMass(theShape)
1835 if MeasuOp.IsDone() == 0:
1836 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1839 def CheckShape(theShape):
1841 * Check a topology of the given shape.
1842 * \param theShape Shape to check validity of.
1843 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1844 * If theShape is invalid, prints a description of problem.
1846 * Example: see GEOM_TestMeasures.py
1848 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1849 if MeasuOp.IsDone() == 0:
1850 print "CheckShape : ", MeasuOp.GetErrorCode()
1856 # -----------------------------------------------------------------------------
1857 # Import/Export objects
1858 # -----------------------------------------------------------------------------
1860 def Import(theFileName, theFormatName):
1862 * Import a shape from the BREP or IGES or STEP file
1863 * (depends on given format) with given name.
1864 * \param theFileName The file, containing the shape.
1865 * \param theFormatName Specify format for the file reading.
1866 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1867 * \return New GEOM_Object, containing the imported shape.
1869 * Example: see GEOM_TestOthers.py
1871 anObj = InsertOp.Import(theFileName, theFormatName)
1872 if InsertOp.IsDone() == 0:
1873 print "Import : ", InsertOp.GetErrorCode()
1876 def ImportBREP(theFileName):
1878 * Shortcut to Import() for BREP format
1880 * Example: see GEOM_TestOthers.py
1882 return Import(theFileName, "BREP")
1884 def ImportIGES(theFileName):
1886 * Shortcut to Import() for IGES format
1888 * Example: see GEOM_TestOthers.py
1890 return Import(theFileName, "IGES")
1892 def ImportSTEP(theFileName):
1894 * Shortcut to Import() for STEP format
1896 * Example: see GEOM_TestOthers.py
1898 return Import(theFileName, "STEP")
1900 def Export(theObject, theFileName, theFormatName):
1902 * Export the given shape into a file with given name.
1903 * \param theObject Shape to be stored in the file.
1904 * \param theFileName Name of the file to store the given shape in.
1905 * \param theFormatName Specify format for the shape storage.
1906 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1908 * Example: see GEOM_TestOthers.py
1910 InsertOp.Export(theObject, theFileName, theFormatName)
1911 if InsertOp.IsDone() == 0:
1912 print "Export : ", InsertOp.GetErrorCode()
1914 def ExportBREP(theObject, theFileName):
1916 * Shortcut to Export() for BREP format
1918 * Example: see GEOM_TestOthers.py
1920 return Export(theObject, theFileName, "BREP")
1922 def ExportIGES(theObject, theFileName):
1924 * Shortcut to Export() for IGES format
1926 * Example: see GEOM_TestOthers.py
1928 return Export(theObject, theFileName, "IGES")
1930 def ExportSTEP(theObject, theFileName):
1932 * Shortcut to Export() for STEP format
1934 * Example: see GEOM_TestOthers.py
1936 return Export(theObject, theFileName, "STEP")
1938 # -----------------------------------------------------------------------------
1940 # -----------------------------------------------------------------------------
1942 def MakeQuad(E1, E2, E3, E4):
1944 * Create a quadrangle face from four edges. Order of Edges is not
1945 * important. It is not necessary that edges share the same vertex.
1946 * \param E1,E2,E3,E4 Edges for the face bound.
1947 * \return New GEOM_Object, containing the created face.
1949 * Example: see GEOM_Spanner.py
1951 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1952 if BlocksOp.IsDone() == 0:
1953 print "MakeQuad : ", BlocksOp.GetErrorCode()
1956 def MakeQuad2Edges(E1, E2):
1958 * Create a quadrangle face on two edges.
1959 * The missing edges will be built by creating the shortest ones.
1960 * \param E1,E2 Two opposite edges for the face.
1961 * \return New GEOM_Object, containing the created face.
1963 * Example: see GEOM_Spanner.py
1965 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1966 if BlocksOp.IsDone() == 0:
1967 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
1970 def MakeQuad4Vertices(V1, V2, V3, V4):
1972 * Create a quadrangle face with specified corners.
1973 * The missing edges will be built by creating the shortest ones.
1974 * \param V1,V2,V3,V4 Corner vertices for the face.
1975 * \return New GEOM_Object, containing the created face.
1977 * Example: see GEOM_Spanner.py
1979 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
1980 if BlocksOp.IsDone() == 0:
1981 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
1984 def MakeHexa(F1, F2, F3, F4, F5, F6):
1986 * Create a hexahedral solid, bounded by the six given faces. Order of
1987 * faces is not important. It is not necessary that Faces share the same edge.
1988 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
1989 * \return New GEOM_Object, containing the created solid.
1991 * Example: see GEOM_Spanner.py
1993 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
1994 if BlocksOp.IsDone() == 0:
1995 print "MakeHexa : ", BlocksOp.GetErrorCode()
1998 def MakeHexa2Faces(F1, F2):
2000 * Create a hexahedral solid between two given faces.
2001 * The missing faces will be built by creating the smallest ones.
2002 * \param F1,F2 Two opposite faces for the hexahedral solid.
2003 * \return New GEOM_Object, containing the created solid.
2005 * Example: see GEOM_Spanner.py
2007 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2008 if BlocksOp.IsDone() == 0:
2009 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2012 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2014 * Get a vertex, found in the given shape by its coordinates.
2015 * \param theShape Block or a compound of blocks.
2016 * \param theX,theY,theZ Coordinates of the sought vertex.
2017 * \param theEpsilon Maximum allowed distance between the resulting
2018 * vertex and point with the given coordinates.
2019 * \return New GEOM_Object, containing the found vertex.
2021 * Example: see GEOM_TestOthers.py
2023 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2024 if BlocksOp.IsDone() == 0:
2025 print "GetPoint : ", BlocksOp.GetErrorCode()
2028 def GetEdge(theShape, thePoint1, thePoint2):
2030 * Get an edge, found in the given shape by two given vertices.
2031 * \param theShape Block or a compound of blocks.
2032 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2033 * \return New GEOM_Object, containing the found edge.
2035 * Example: see GEOM_Spanner.py
2037 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2038 if BlocksOp.IsDone() == 0:
2039 print "GetEdge : ", BlocksOp.GetErrorCode()
2042 def GetEdgeNearPoint(theShape, thePoint):
2044 * Find an edge of the given shape, which has minimal distance to the given point.
2045 * \param theShape Block or a compound of blocks.
2046 * \param thePoint Point, close to the desired edge.
2047 * \return New GEOM_Object, containing the found edge.
2049 * Example: see GEOM_TestOthers.py
2051 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2052 if BlocksOp.IsDone() == 0:
2053 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2056 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2058 * Returns a face, found in the given shape by four given corner vertices.
2059 * \param theShape Block or a compound of blocks.
2060 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2061 * \return New GEOM_Object, containing the found face.
2063 * Example: see GEOM_Spanner.py
2065 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2066 if BlocksOp.IsDone() == 0:
2067 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2070 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2072 * Get a face of block, found in the given shape by two given edges.
2073 * \param theShape Block or a compound of blocks.
2074 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2075 * \return New GEOM_Object, containing the found face.
2077 * Example: see GEOM_Spanner.py
2079 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2080 if BlocksOp.IsDone() == 0:
2081 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2084 def GetOppositeFace(theBlock, theFace):
2086 * Find a face, opposite to the given one in the given block.
2087 * \param theBlock Must be a hexahedral solid.
2088 * \param theFace Face of \a theBlock, opposite to the desired face.
2089 * \return New GEOM_Object, containing the found face.
2091 * Example: see GEOM_Spanner.py
2093 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2094 if BlocksOp.IsDone() == 0:
2095 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2098 def GetFaceNearPoint(theShape, thePoint):
2100 * Find a face of the given shape, which has minimal distance to the given point.
2101 * \param theShape Block or a compound of blocks.
2102 * \param thePoint Point, close to the desired face.
2103 * \return New GEOM_Object, containing the found face.
2105 * Example: see GEOM_Spanner.py
2107 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2108 if BlocksOp.IsDone() == 0:
2109 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2112 def GetFaceByNormale(theBlock, theVector):
2114 * Find a face of block, whose outside normale has minimal angle with the given vector.
2115 * \param theShape Block or a compound of blocks.
2116 * \param theVector Vector, close to the normale of the desired face.
2117 * \return New GEOM_Object, containing the found face.
2119 * Example: see GEOM_Spanner.py
2121 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2122 if BlocksOp.IsDone() == 0:
2123 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2126 def CheckCompoundOfBlocks(theCompound):
2128 * Check, if the compound of blocks is given.
2129 * To be considered as a compound of blocks, the
2130 * given shape must satisfy the following conditions:
2131 * - Each element of the compound should be a Block (6 faces and 12 edges).
2132 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2133 * - The compound should be connexe.
2134 * - The glue between two quadrangle faces should be applied.
2135 * \param theCompound The compound to check.
2136 * \return TRUE, if the given shape is a compound of blocks.
2137 * If theCompound is not valid, prints all discovered errors.
2139 * Example: see GEOM_Spanner.py
2141 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2142 if BlocksOp.IsDone() == 0:
2143 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2146 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2150 def RemoveExtraEdges(theShape):
2152 * Remove all seam and degenerated edges from \a theShape.
2153 * Unite faces and edges, sharing one surface.
2154 * \param theShape The compound or single solid to remove irregular edges from.
2155 * \return Improved shape.
2157 * Example: see GEOM_TestOthers.py
2159 anObj = BlocksOp.RemoveExtraEdges(theShape)
2160 if BlocksOp.IsDone() == 0:
2161 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2164 def CheckAndImprove(theShape):
2166 * Check, if the given shape is a blocks compound.
2167 * Fix all detected errors.
2168 * \note Single block can be also fixed by this method.
2169 * \param theCompound The compound to check and improve.
2170 * \return Improved compound.
2172 * Example: see GEOM_TestOthers.py
2174 anObj = BlocksOp.CheckAndImprove(theShape)
2175 if BlocksOp.IsDone() == 0:
2176 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2179 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2181 * Get all the blocks, contained in the given compound.
2182 * \param theCompound The compound to explode.
2183 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2184 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2185 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2186 * \return List of GEOM_Objects, containing the retrieved blocks.
2188 * Example: see GEOM_TestOthers.py
2190 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2191 if BlocksOp.IsDone() == 0:
2192 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2195 def GetBlockNearPoint(theCompound, thePoint):
2197 * Find block, containing the given point inside its volume or on boundary.
2198 * \param theCompound Compound, to find block in.
2199 * \param thePoint Point, close to the desired block. If the point lays on
2200 * boundary between some blocks, we return block with nearest center.
2201 * \return New GEOM_Object, containing the found block.
2203 * Example: see GEOM_Spanner.py
2205 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2206 if BlocksOp.IsDone() == 0:
2207 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2210 def GetBlockByParts(theCompound, theParts):
2212 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2213 * \param theCompound Compound, to find block in.
2214 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2215 * \return New GEOM_Object, containing the found block.
2217 * Example: see GEOM_TestOthers.py
2219 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2220 if BlocksOp.IsDone() == 0:
2221 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2224 def GetBlocksByParts(theCompound, theParts):
2226 * Return all blocks, containing all the elements, passed as the parts.
2227 * \param theCompound Compound, to find blocks in.
2228 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2229 * \return List of GEOM_Objects, containing the found blocks.
2231 * Example: see GEOM_Spanner.py
2233 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2234 if BlocksOp.IsDone() == 0:
2235 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2238 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2240 * Multi-transformate block and glue the result.
2241 * Transformation is defined so, as to superpose direction faces.
2242 * \param Block Hexahedral solid to be multi-transformed.
2243 * \param DirFace1 ID of First direction face.
2244 * \param DirFace2 ID of Second direction face.
2245 * \param NbTimes Quantity of transformations to be done.
2246 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2247 * \return New GEOM_Object, containing the result shape.
2249 * Example: see GEOM_Spanner.py
2251 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2252 if BlocksOp.IsDone() == 0:
2253 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2256 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2257 DirFace1V, DirFace2V, NbTimesV):
2259 * Multi-transformate block and glue the result.
2260 * \param Block Hexahedral solid to be multi-transformed.
2261 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2262 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2263 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2264 * \return New GEOM_Object, containing the result shape.
2266 * Example: see GEOM_Spanner.py
2268 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2269 DirFace1V, DirFace2V, NbTimesV)
2270 if BlocksOp.IsDone() == 0:
2271 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2274 def Propagate(theShape):
2276 * Build all possible propagation groups.
2277 * Propagation group is a set of all edges, opposite to one (main)
2278 * edge of this group directly or through other opposite edges.
2279 * Notion of Opposite Edge make sence only on quadrangle face.
2280 * \param theShape Shape to build propagation groups on.
2281 * \return List of GEOM_Objects, each of them is a propagation group.
2283 * Example: see GEOM_TestOthers.py
2285 listChains = BlocksOp.Propagate(theShape)
2286 if BlocksOp.IsDone() == 0:
2287 print "Propagate : ", BlocksOp.GetErrorCode()
2290 # -----------------------------------------------------------------------------
2292 # -----------------------------------------------------------------------------
2294 def CreateGroup(theMainShape, theShapeType):
2296 * Creates a new group which will store sub shapes of theMainShape
2297 * \param theMainShape is a GEOM object on which the group is selected
2298 * \param theShapeType defines a shape type of the group
2299 * \return a newly created GEOM group
2301 * Example: see GEOM_TestOthers.py
2303 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2304 if GroupOp.IsDone() == 0:
2305 print "CreateGroup : ", GroupOp.GetErrorCode()
2308 def AddObject(theGroup, theSubShapeID):
2310 * Adds a sub object with ID theSubShapeId to the group
2311 * \param theGroup is a GEOM group to which the new sub shape is added
2312 * \param theSubShapeID is a sub shape ID in the main object.
2313 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2315 * Example: see GEOM_TestOthers.py
2317 GroupOp.AddObject(theGroup, theSubShapeID)
2318 if GroupOp.IsDone() == 0:
2319 print "AddObject : ", GroupOp.GetErrorCode()
2321 def RemoveObject(theGroup, theSubShapeID):
2323 * Removes a sub object with ID \a theSubShapeId from the group
2324 * \param theGroup is a GEOM group from which the new sub shape is removed
2325 * \param theSubShapeID is a sub shape ID in the main object.
2326 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2328 * Example: see GEOM_TestOthers.py
2330 GroupOp.RemoveObject(theGroup, theSubShapeID)
2331 if GroupOp.IsDone() == 0:
2332 print "RemoveObject : ", GroupOp.GetErrorCode()
2334 def UnionList (theGroup, theSubShapes):
2336 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2337 * \param theGroup is a GEOM group to which the new sub shapes are added.
2338 * \param theSubShapes is a list of sub shapes to be added.
2340 * Example: see GEOM_TestOthers.py
2342 GroupOp.UnionList(theGroup, theSubShapes)
2343 if GroupOp.IsDone() == 0:
2344 print "UnionList : ", GroupOp.GetErrorCode()
2346 def DifferenceList (theGroup, theSubShapes):
2348 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2349 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2350 * \param theSubShapes is a list of sub-shapes to be removed.
2352 * Example: see GEOM_TestOthers.py
2354 GroupOp.DifferenceList(theGroup, theSubShapes)
2355 if GroupOp.IsDone() == 0:
2356 print "DifferenceList : ", GroupOp.GetErrorCode()
2358 def GetObjectIDs(theGroup):
2360 * Returns a list of sub objects ID stored in the group
2361 * \param theGroup is a GEOM group for which a list of IDs is requested
2363 * Example: see GEOM_TestOthers.py
2365 ListIDs = GroupOp.GetObjects(theGroup)
2366 if GroupOp.IsDone() == 0:
2367 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2370 def GetType(theGroup):
2372 * Returns a type of sub objects stored in the group
2373 * \param theGroup is a GEOM group which type is returned.
2375 * Example: see GEOM_TestOthers.py
2377 aType = GroupOp.GetType(theGroup)
2378 if GroupOp.IsDone() == 0:
2379 print "GetType : ", GroupOp.GetErrorCode()
2382 def GetMainShape(theGroup):
2384 * Returns a main shape associated with the group
2385 * \param theGroup is a GEOM group for which a main shape object is requested
2386 * \return a GEOM object which is a main shape for theGroup
2388 * Example: see GEOM_TestOthers.py
2390 anObj = GroupOp.GetMainShape(theGroup)
2391 if GroupOp.IsDone() == 0:
2392 print "GetMainShape : ", GroupOp.GetErrorCode()
2395 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2397 Create group of edges of theShape, whose length is in range [min_length, max_length].
2398 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2401 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2404 Props = BasicProperties(edge)
2405 if min_length <= Props[0] and Props[0] <= max_length:
2406 if (not include_min) and (min_length == Props[0]):
2409 if (not include_max) and (Props[0] == max_length):
2412 edges_in_range.append(edge)
2414 if len(edges_in_range) <= 0:
2415 print "No edges found by given criteria"
2418 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2419 UnionList(group_edges, edges_in_range)
2423 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2425 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2426 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2429 nb_selected = sg.SelectedCount()
2431 print "Select a shape before calling this function, please."
2434 print "Only one shape must be selected"
2437 id_shape = sg.getSelected(0)
2438 shape = IDToObject( id_shape )
2440 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2444 if include_min: left_str = " <= "
2445 if include_max: right_str = " <= "
2447 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2448 + left_str + "length" + right_str + `max_length`)
2450 sg.updateObjBrowser(1)
2456 * Add Path to load python scripts from
2458 if (sys.path.count(Path) < 1):
2459 sys.path.append(Path)