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")
55 * Get name for sub-shape aSubObj of shape aMainObj
57 * Example: see GEOM_TestAll.py
59 def SubShapeName(aSubObj, aMainObj):
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)
67 * Publish in study aShape with name aName
69 * Example: see GEOM_TestAll.py
71 def addToStudy(aShape, aName):
73 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
75 print "addToStudy() failed"
77 return aShape.GetStudyEntry()
80 * Publish in study aShape with name aName as sub-object of previously published aFather
82 * Example: see GEOM_TestAll.py
84 def addToStudyInFather(aFather, aShape, aName):
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 # -----------------------------------------------------------------------------
120 * Create point by three coordinates.
121 * \param theX The X coordinate of the point.
122 * \param theY The Y coordinate of the point.
123 * \param theZ The Z coordinate of the point.
124 * \return New GEOM_Object, containing the created point.
126 * Example: see GEOM_TestAll.py
128 def MakeVertex(theX, theY, theZ):
129 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
130 if BasicOp.IsDone() == 0:
131 print "MakePointXYZ : ", BasicOp.GetErrorCode()
135 * Create a point, distant from the referenced point
136 * on the given distances along the coordinate axes.
137 * \param theReference The referenced point.
138 * \param theX Displacement from the referenced point along OX axis.
139 * \param theY Displacement from the referenced point along OY axis.
140 * \param theZ Displacement from the referenced point along OZ axis.
141 * \return New GEOM_Object, containing the created point.
143 * Example: see GEOM_TestAll.py
145 def MakeVertexWithRef(theReference, theX, theY, theZ):
146 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
147 if BasicOp.IsDone() == 0:
148 print "MakePointWithReference : ", BasicOp.GetErrorCode()
152 * Create a point, corresponding to the given parameter on the given curve.
153 * \param theRefCurve The referenced curve.
154 * \param theParameter Value of parameter on the referenced curve.
155 * \return New GEOM_Object, containing the created point.
157 * Example: see GEOM_TestAll.py
159 def MakeVertexOnCurve(theRefCurve, theParameter):
160 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
161 if BasicOp.IsDone() == 0:
162 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
166 * Create a vector with the given components.
167 * \param theDX X component of the vector.
168 * \param theDY Y component of the vector.
169 * \param theDZ Z component of the vector.
170 * \return New GEOM_Object, containing the created vector.
172 * Example: see GEOM_TestAll.py
174 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
175 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
176 if BasicOp.IsDone() == 0:
177 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
181 * Create a vector between two points.
182 * \param thePnt1 Start point for the vector.
183 * \param thePnt2 End point for the vector.
184 * \return New GEOM_Object, containing the created vector.
186 * Example: see GEOM_TestAll.py
188 def MakeVector(thePnt1, thePnt2):
189 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
190 if BasicOp.IsDone() == 0:
191 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
195 * Create a line, passing through the given point
196 * and parrallel to the given direction
197 * \param thePnt Point. The resulting line will pass through it.
198 * \param theDir Direction. The resulting line will be parallel to it.
199 * \return New GEOM_Object, containing the created line.
201 * Example: see GEOM_TestAll.py
203 def MakeLine(thePnt, theDir):
204 anObj = BasicOp.MakeLine(thePnt, theDir)
205 if BasicOp.IsDone() == 0:
206 print "MakeLine : ", BasicOp.GetErrorCode()
210 * Create a line, passing through the given points
211 * \param thePnt1 First of two points, defining the line.
212 * \param thePnt2 Second of two points, defining the line.
213 * \return New GEOM_Object, containing the created line.
215 * Example: see GEOM_TestAll.py
217 def MakeLineTwoPnt(thePnt1, thePnt2):
218 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
219 if BasicOp.IsDone() == 0:
220 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
224 * Create a plane, passing through the given point
225 * and normal to the given vector.
226 * \param thePnt Point, the plane has to pass through.
227 * \param theVec Vector, defining the plane normal direction.
228 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
229 * \return New GEOM_Object, containing the created plane.
231 * Example: see GEOM_TestAll.py
233 def MakePlane(thePnt, theVec, theTrimSize):
234 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
235 if BasicOp.IsDone() == 0:
236 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
240 * Create a plane, passing through the three given points
241 * \param thePnt1 First of three points, defining the plane.
242 * \param thePnt2 Second of three points, defining the plane.
243 * \param thePnt3 Fird of three points, defining the plane.
244 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
245 * \return New GEOM_Object, containing the created plane.
247 * Example: see GEOM_TestAll.py
249 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
250 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
251 if BasicOp.IsDone() == 0:
252 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
256 * Create a plane, similar to the existing one, but with another size of representing face.
257 * \param theFace Referenced plane.
258 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
259 * \return New GEOM_Object, containing the created plane.
261 * Example: see GEOM_TestAll.py
263 def MakePlaneFace(theFace, theTrimSize):
264 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
265 if BasicOp.IsDone() == 0:
266 print "MakePlaneFace : ", BasicOp.GetErrorCode()
270 * Create a local coordinate system.
271 * \param OX,OY,OZ Three coordinates of coordinate system origin.
272 * \param XDX,XDY,XDZ Three components of OX direction
273 * \param YDX,YDY,YDZ Three components of OY direction
274 * \return New GEOM_Object, containing the created coordinate system.
276 * Example: see GEOM_TestAll.py
278 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
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 # -----------------------------------------------------------------------------
289 * Create an arc of circle, passing through three given points.
290 * \param thePnt1 Start point of the arc.
291 * \param thePnt2 Middle point of the arc.
292 * \param thePnt3 End point of the arc.
293 * \return New GEOM_Object, containing the created arc.
295 * Example: see GEOM_TestAll.py
297 def MakeArc(thePnt1, thePnt2, thePnt3):
298 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
299 if CurvesOp.IsDone() == 0:
300 print "MakeArc : ", CurvesOp.GetErrorCode()
304 * Create a circle with given center, normal vector and radius.
305 * \param thePnt Circle center.
306 * \param theVec Vector, normal to the plane of the circle.
307 * \param theR Circle radius.
308 * \return New GEOM_Object, containing the created circle.
310 * Example: see GEOM_TestAll.py
312 def MakeCircle(thePnt, theVec, theR):
313 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
314 if CurvesOp.IsDone() == 0:
315 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
319 * Create a circle, passing through three given points
320 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
321 * \return New GEOM_Object, containing the created circle.
323 * Example: see GEOM_TestAll.py
325 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
326 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
327 if CurvesOp.IsDone() == 0:
328 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
332 * Create an ellipse with given center, normal vector and radiuses.
333 * \param thePnt Ellipse center.
334 * \param theVec Vector, normal to the plane of the ellipse.
335 * \param theRMajor Major ellipse radius.
336 * \param theRMinor Minor ellipse radius.
337 * \return New GEOM_Object, containing the created ellipse.
339 * Example: see GEOM_TestAll.py
341 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
342 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
343 if CurvesOp.IsDone() == 0:
344 print "MakeEllipse : ", CurvesOp.GetErrorCode()
348 * Create a polyline on the set of points.
349 * \param thePoints Sequence of points for the polyline.
350 * \return New GEOM_Object, containing the created polyline.
352 * Example: see GEOM_TestAll.py
354 def MakePolyline(thePoints):
355 anObj = CurvesOp.MakePolyline(thePoints)
356 if CurvesOp.IsDone() == 0:
357 print "MakePolyline : ", CurvesOp.GetErrorCode()
361 * Create bezier curve on the set of points.
362 * \param thePoints Sequence of points for the bezier curve.
363 * \return New GEOM_Object, containing the created bezier curve.
365 * Example: see GEOM_TestAll.py
367 def MakeBezier(thePoints):
368 anObj = CurvesOp.MakeSplineBezier(thePoints)
369 if CurvesOp.IsDone() == 0:
370 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
374 * Create B-Spline curve on the set of points.
375 * \param thePoints Sequence of points for the B-Spline curve.
376 * \return New GEOM_Object, containing the created B-Spline curve.
378 * Example: see GEOM_TestAll.py
380 def MakeInterpol(thePoints):
381 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
382 if CurvesOp.IsDone() == 0:
383 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
387 * Create a sketcher (wire or face), following the textual description,
388 * passed through \a theCommand argument. \n
389 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
390 * Format of the description string have to be the following:
392 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
395 * - x1, y1 are coordinates of the first sketcher point (zero by default),
397 * - "R angle" : Set the direction by angle
398 * - "D dx dy" : Set the direction by DX & DY
401 * - "TT x y" : Create segment by point at X & Y
402 * - "T dx dy" : Create segment by point with DX & DY
403 * - "L length" : Create segment by direction & Length
404 * - "IX x" : Create segment by direction & Intersect. X
405 * - "IY y" : Create segment by direction & Intersect. Y
408 * - "C radius length" : Create arc by direction, radius and length(in degree)
411 * - "WW" : Close Wire (to finish)
412 * - "WF" : Close Wire and build face (to finish)
414 * \param theCommand String, defining the sketcher in local
415 * coordinates of the working plane.
416 * \param theWorkingPlane Nine double values, defining origin,
417 * OZ and OX directions of the working plane.
418 * \return New GEOM_Object, containing the created wire.
420 * Example: see GEOM_TestAll.py
422 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
423 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
424 if CurvesOp.IsDone() == 0:
425 print "MakeSketcher : ", CurvesOp.GetErrorCode()
428 # -----------------------------------------------------------------------------
429 # Create 3D Primitives
430 # -----------------------------------------------------------------------------
433 * Create a box by coordinates of two opposite vertices.
435 * Example: see GEOM_TestAll.py
437 def MakeBox(x1,y1,z1,x2,y2,z2):
438 pnt1 = MakeVertex(x1,y1,z1)
439 pnt2 = MakeVertex(x2,y2,z2)
440 return MakeBoxTwoPnt(pnt1,pnt2)
443 * Create a box with specified dimensions along the coordinate axes
444 * and with edges, parallel to the coordinate axes.
445 * Center of the box will be at point (DX/2, DY/2, DZ/2).
446 * \param theDX Length of Box edges, parallel to OX axis.
447 * \param theDY Length of Box edges, parallel to OY axis.
448 * \param theDZ Length of Box edges, parallel to OZ axis.
449 * \return New GEOM_Object, containing the created box.
451 * Example: see GEOM_TestAll.py
453 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
454 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
455 if PrimOp.IsDone() == 0:
456 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
460 * Create a box with two specified opposite vertices,
461 * and with edges, parallel to the coordinate axes
462 * \param thePnt1 First of two opposite vertices.
463 * \param thePnt2 Second of two opposite vertices.
464 * \return New GEOM_Object, containing the created box.
466 * Example: see GEOM_TestAll.py
468 def MakeBoxTwoPnt(thePnt1, thePnt2):
469 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
470 if PrimOp.IsDone() == 0:
471 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
475 * Create a cylinder with given base point, axis, radius and height.
476 * \param thePnt Central point of cylinder base.
477 * \param theAxis Cylinder axis.
478 * \param theR Cylinder radius.
479 * \param theH Cylinder height.
480 * \return New GEOM_Object, containing the created cylinder.
482 * Example: see GEOM_TestAll.py
484 def MakeCylinder(thePnt, theAxis, theR, theH):
485 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
486 if PrimOp.IsDone() == 0:
487 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
491 * Create a cylinder with given radius and height at
492 * the origin of coordinate system. Axis of the cylinder
493 * will be collinear to the OZ axis of the coordinate system.
494 * \param theR Cylinder radius.
495 * \param theH Cylinder height.
496 * \return New GEOM_Object, containing the created cylinder.
498 * Example: see GEOM_TestAll.py
500 def MakeCylinderRH(theR, theH):
501 anObj = PrimOp.MakeCylinderRH(theR, theH)
502 if PrimOp.IsDone() == 0:
503 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
507 * Create a sphere with given center and radius.
508 * \param thePnt Sphere center.
509 * \param theR Sphere radius.
510 * \return New GEOM_Object, containing the created sphere.
512 * Example: see GEOM_TestAll.py
514 def MakeSpherePntR(thePnt, theR):
515 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
516 if PrimOp.IsDone() == 0:
517 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
521 * Create a sphere with given center and radius.
522 * \param x,y,z Coordinates of sphere center.
523 * \param theR Sphere radius.
524 * \return New GEOM_Object, containing the created sphere.
526 * Example: see GEOM_TestAll.py
528 def MakeSphere(x, y, z, theR):
529 point = MakeVertex(x, y, z)
530 anObj = MakeSpherePntR(point, theR)
534 * Create a sphere with given radius at the origin of coordinate system.
535 * \param theR Sphere radius.
536 * \return New GEOM_Object, containing the created sphere.
538 * Example: see GEOM_TestAll.py
540 def MakeSphereR(theR):
541 anObj = PrimOp.MakeSphereR(theR)
542 if PrimOp.IsDone() == 0:
543 print "MakeSphereR : ", PrimOp.GetErrorCode()
547 * Create a cone with given base point, axis, height and radiuses.
548 * \param thePnt Central point of the first cone base.
549 * \param theAxis Cone axis.
550 * \param theR1 Radius of the first cone base.
551 * \param theR2 Radius of the second cone base.
552 * \note If both radiuses are non-zero, the cone will be truncated.
553 * \note If the radiuses are equal, a cylinder will be created instead.
554 * \param theH Cone height.
555 * \return New GEOM_Object, containing the created cone.
557 * Example: see GEOM_TestAll.py
559 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
560 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
561 if PrimOp.IsDone() == 0:
562 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
566 * Create a cone with given height and radiuses at
567 * the origin of coordinate system. Axis of the cone will
568 * be collinear to the OZ axis of the coordinate system.
569 * \param theR1 Radius of the first cone base.
570 * \param theR2 Radius of the second cone base.
571 * \note If both radiuses are non-zero, the cone will be truncated.
572 * \note If the radiuses are equal, a cylinder will be created instead.
573 * \param theH Cone height.
574 * \return New GEOM_Object, containing the created cone.
576 * Example: see GEOM_TestAll.py
578 def MakeConeR1R2H(theR1, theR2, theH):
579 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
580 if PrimOp.IsDone() == 0:
581 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
585 * Create a torus with given center, normal vector and radiuses.
586 * \param thePnt Torus central point.
587 * \param theVec Torus axis of symmetry.
588 * \param theRMajor Torus major radius.
589 * \param theRMinor Torus minor radius.
590 * \return New GEOM_Object, containing the created torus.
592 * Example: see GEOM_TestAll.py
594 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
595 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
596 if PrimOp.IsDone() == 0:
597 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
601 * Create a torus with given radiuses at the origin of coordinate system.
602 * \param theRMajor Torus major radius.
603 * \param theRMinor Torus minor radius.
604 * \return New GEOM_Object, containing the created torus.
606 * Example: see GEOM_TestAll.py
608 def MakeTorusRR(theRMajor, theRMinor):
609 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
610 if PrimOp.IsDone() == 0:
611 print "MakeTorusRR : ", PrimOp.GetErrorCode()
615 * Create a shape by extrusion of the base shape along a vector, defined by two points.
616 * \param theBase Base shape to be extruded.
617 * \param thePoint1 First end of extrusion vector.
618 * \param thePoint2 Second end of extrusion vector.
619 * \return New GEOM_Object, containing the created prism.
621 * Example: see GEOM_TestAll.py
623 def MakePrism(theBase, thePoint1, thePoint2):
624 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
625 if PrimOp.IsDone() == 0:
626 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
630 * Create a shape by extrusion of the base shape along the vector,
631 * i.e. all the space, transfixed by the base shape during its translation
632 * along the vector on the given distance.
633 * \param theBase Base shape to be extruded.
634 * \param theVec Direction of extrusion.
635 * \param theH Prism dimension along theVec.
636 * \return New GEOM_Object, containing the created prism.
638 * Example: see GEOM_TestAll.py
640 def MakePrismVecH(theBase, theVec, theH):
641 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
642 if PrimOp.IsDone() == 0:
643 print "MakePrismVecH : ", PrimOp.GetErrorCode()
647 * Create a shape by extrusion of the base shape along
648 * the path shape. The path shape can be a wire or an edge.
649 * \param theBase Base shape to be extruded.
650 * \param thePath Path shape to extrude the base shape along it.
651 * \return New GEOM_Object, containing the created pipe.
653 * Example: see GEOM_TestAll.py
655 def MakePipe(theBase, thePath):
656 anObj = PrimOp.MakePipe(theBase, thePath)
657 if PrimOp.IsDone() == 0:
658 print "MakePipe : ", PrimOp.GetErrorCode()
662 * Create a shape by revolution of the base shape around the axis
663 * on the given angle, i.e. all the space, transfixed by the base
664 * shape during its rotation around the axis on the given angle.
665 * \param theBase Base shape to be rotated.
666 * \param theAxis Rotation axis.
667 * \param theAngle Rotation angle in radians.
668 * \return New GEOM_Object, containing the created revolution.
670 * Example: see GEOM_TestAll.py
672 def MakeRevolution(theBase, theAxis, theAngle):
673 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
674 if PrimOp.IsDone() == 0:
675 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
678 # -----------------------------------------------------------------------------
680 # -----------------------------------------------------------------------------
683 * Create a linear edge with specified ends.
684 * \param thePnt1 Point for the first end of edge.
685 * \param thePnt2 Point for the second end of edge.
686 * \return New GEOM_Object, containing the created edge.
688 * Example: see GEOM_TestAll.py
690 def MakeEdge(thePnt1, thePnt2):
691 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
692 if ShapesOp.IsDone() == 0:
693 print "MakeEdge : ", ShapesOp.GetErrorCode()
697 * Create a wire from the set of edges and wires.
698 * \param theEdgesAndWires List of edges and/or wires.
699 * \return New GEOM_Object, containing the created wire.
701 * Example: see GEOM_TestAll.py
703 def MakeWire(theEdgesAndWires):
704 anObj = ShapesOp.MakeWire(theEdgesAndWires)
705 if ShapesOp.IsDone() == 0:
706 print "MakeWire : ", ShapesOp.GetErrorCode()
710 * Create a face on the given wire.
711 * \param theWire Wire to build the face on.
712 * \param isPlanarWanted If TRUE, only planar face will be built.
713 * If impossible, NULL object will be returned.
714 * \return New GEOM_Object, containing the created face.
716 * Example: see GEOM_TestAll.py
718 def MakeFace(theWire, isPlanarWanted):
719 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
720 if ShapesOp.IsDone() == 0:
721 print "MakeFace : ", ShapesOp.GetErrorCode()
725 * Create a face on the given wires set.
726 * \param theWires List of wires to build the face on.
727 * \param isPlanarWanted If TRUE, only planar face will be built.
728 * If impossible, NULL object will be returned.
729 * \return New GEOM_Object, containing the created face.
731 * Example: see GEOM_TestAll.py
733 def MakeFaceWires(theWires, isPlanarWanted):
734 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
735 if ShapesOp.IsDone() == 0:
736 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
740 * Shortcut to MakeFaceWires()
742 * Example: see GEOM_TestOthers.py
744 def MakeFaces(theWires, isPlanarWanted):
745 anObj = MakeFaceWires(theWires, isPlanarWanted)
749 * Create a shell from the set of faces and shells.
750 * \param theFacesAndShells List of faces and/or shells.
751 * \return New GEOM_Object, containing the created shell.
753 * Example: see GEOM_TestAll.py
755 def MakeShell(theFacesAndShells):
756 anObj = ShapesOp.MakeShell(theFacesAndShells)
757 if ShapesOp.IsDone() == 0:
758 print "MakeShell : ", ShapesOp.GetErrorCode()
762 * Create a solid, bounded by the given shells.
763 * \param theShells Sequence of bounding shells.
764 * \return New GEOM_Object, containing the created solid.
766 * Example: see GEOM_TestAll.py
768 def MakeSolid(theShells):
769 anObj = ShapesOp.MakeSolidShells(theShells)
770 if ShapesOp.IsDone() == 0:
771 print "MakeSolid : ", ShapesOp.GetErrorCode()
775 * Create a compound of the given shapes.
776 * \param theShapes List of shapes to put in compound.
777 * \return New GEOM_Object, containing the created compound.
779 * Example: see GEOM_TestAll.py
781 def MakeCompound(theShapes):
782 anObj = ShapesOp.MakeCompound(theShapes)
783 if ShapesOp.IsDone() == 0:
784 print "MakeCompound : ", ShapesOp.GetErrorCode()
788 * Gives quantity of faces in the given shape.
789 * \param theShape Shape to count faces of.
790 * \return Quantity of faces.
792 * Example: see GEOM_TestOthers.py
794 def NumberOfFaces(theShape):
795 nb_faces = ShapesOp.NumberOfFaces(theShape)
796 if ShapesOp.IsDone() == 0:
797 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
801 * Gives quantity of edges in the given shape.
802 * \param theShape Shape to count edges of.
803 * \return Quantity of edges.
805 * Example: see GEOM_TestOthers.py
807 def NumberOfEdges(theShape):
808 nb_edges = ShapesOp.NumberOfEdges(theShape)
809 if ShapesOp.IsDone() == 0:
810 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
814 * Reverses an orientation the given shape.
815 * \param theShape Shape to be reversed.
816 * \return The reversed copy of theShape.
818 * Example: see GEOM_TestAll.py
820 def ChangeOrientation(theShape):
821 anObj = ShapesOp.ChangeOrientation(theShape)
822 if ShapesOp.IsDone() == 0:
823 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
827 * Shortcut to ChangeOrientation()
829 * Example: see GEOM_TestOthers.py
831 def OrientationChange(theShape):
832 anObj = ChangeOrientation(theShape)
836 * Retrieve all free faces from the given shape.
837 * Free face is a face, which is not shared between two shells of the shape.
838 * \param theShape Shape to find free faces in.
839 * \return List of IDs of all free faces, contained in theShape.
841 * Example: see GEOM_TestOthers.py
843 def GetFreeFacesIDs(theShape):
844 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
845 if ShapesOp.IsDone() == 0:
846 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
850 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
851 * \param theShape1 Shape to find sub-shapes in.
852 * \param theShape2 Shape to find shared sub-shapes with.
853 * \param theShapeType Type of sub-shapes to be retrieved.
854 * \return List of sub-shapes of theShape1, shared with theShape2.
856 * Example: see GEOM_TestOthers.py
858 def GetSharedShapes(theShape1, theShape2, theShapeType):
859 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
860 if ShapesOp.IsDone() == 0:
861 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
865 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
866 * the specified plane by the certain way, defined through \a theState parameter.
867 * \param theShape Shape to find sub-shapes of.
868 * \param theShapeType Type of sub-shapes to be retrieved.
869 * \param theAx1 Vector (or line, or linear edge), specifying normal
870 * direction and location of the plane to find shapes on.
871 * \param theState The state of the subshapes to find. It can be one of
872 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
873 * \return List of all found sub-shapes.
875 * Example: see GEOM_TestOthers.py
877 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
878 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
879 if ShapesOp.IsDone() == 0:
880 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
884 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
885 * the specified cylinder by the certain way, defined through \a theState parameter.
886 * \param theShape Shape to find sub-shapes of.
887 * \param theShapeType Type of sub-shapes to be retrieved.
888 * \param theAxis Vector (or line, or linear edge), specifying
889 * axis of the cylinder to find shapes on.
890 * \param theRadius Radius of the cylinder to find shapes on.
891 * \param theState The state of the subshapes to find. It can be one of
892 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
893 * \return List of all found sub-shapes.
895 * Example: see GEOM_TestOthers.py
897 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
898 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
899 if ShapesOp.IsDone() == 0:
900 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
904 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
905 * the specified sphere by the certain way, defined through \a theState parameter.
906 * \param theShape Shape to find sub-shapes of.
907 * \param theShapeType Type of sub-shapes to be retrieved.
908 * \param theCenter Point, specifying center of the sphere to find shapes on.
909 * \param theRadius Radius of the sphere to find shapes on.
910 * \param theState The state of the subshapes to find. It can be one of
911 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
912 * \return List of all found sub-shapes.
914 * Example: see GEOM_TestOthers.py
916 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
917 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
918 if ShapesOp.IsDone() == 0:
919 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
923 # * Get sub-shape(s) of theShapeWhere, which are
924 # * coincident with \a theShapeWhat or could be a part of it.
925 # * \param theShapeWhere Shape to find sub-shapes of.
926 # * \param theShapeWhat Shape, specifying what to find.
927 # * \return Group of all found sub-shapes or a single found sub-shape.
929 # * Example: see GEOM_TestOthers.py
931 #def GetInPlace(theShapeWhere, theShapeWhat):
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 # -----------------------------------------------------------------------------
942 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
943 * of <aShape>, selected by their unique IDs inside <aShape>
945 * Example: see GEOM_TestAll.py
947 def GetSubShape(aShape, ListOfID):
948 anObj = geom.AddSubShape(aShape,ListOfID)
952 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
954 * Example: see GEOM_TestAll.py
956 def GetSubShapeID(aShape, aSubShape):
957 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
958 if LocalOp.IsDone() == 0:
959 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
962 # -----------------------------------------------------------------------------
964 # -----------------------------------------------------------------------------
967 * Explode a shape on subshapes of a given type.
968 * \param theShape Shape to be exploded.
969 * \param theShapeType Type of sub-shapes to be retrieved.
970 * \return List of sub-shapes of type theShapeType, contained in theShape.
972 * Example: see GEOM_TestAll.py
974 def SubShapeAll(aShape, aType):
975 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
976 if ShapesOp.IsDone() == 0:
977 print "MakeExplode : ", ShapesOp.GetErrorCode()
981 * Explode a shape on subshapes of a given type.
982 * \param theShape Shape to be exploded.
983 * \param theShapeType Type of sub-shapes to be retrieved.
984 * \return List of IDs of sub-shapes.
986 def SubShapeAllIDs(aShape, aType):
987 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
988 if ShapesOp.IsDone() == 0:
989 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
993 * Explode a shape on subshapes of a given type.
994 * Sub-shapes will be sorted by coordinates of their gravity centers.
995 * \param theShape Shape to be exploded.
996 * \param theShapeType Type of sub-shapes to be retrieved.
997 * \return List of sub-shapes of type theShapeType, contained in theShape.
999 * Example: see GEOM_TestAll.py
1001 def SubShapeAllSorted(aShape, aType):
1002 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1003 if ShapesOp.IsDone() == 0:
1004 print "MakeExplode : ", ShapesOp.GetErrorCode()
1008 * Explode a shape on subshapes of a given type.
1009 * Sub-shapes will be sorted by coordinates of their gravity centers.
1010 * \param theShape Shape to be exploded.
1011 * \param theShapeType Type of sub-shapes to be retrieved.
1012 * \return List of IDs of sub-shapes.
1014 def SubShapeAllSortedIDs(aShape, aType):
1015 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1016 if ShapesOp.IsDone() == 0:
1017 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1021 * Obtain a compound of sub-shapes of <aShape>,
1022 * selected by they indices in list of all sub-shapes of type <aType>.
1023 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1025 * Example: see GEOM_TestAll.py
1027 def SubShape(aShape, aType, ListOfInd):
1029 AllShapeList = SubShapeAll(aShape, aType)
1030 for ind in ListOfInd:
1031 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1032 anObj = GetSubShape(aShape, ListOfIDs)
1036 * Obtain a compound of sub-shapes of <aShape>,
1037 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1038 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1040 * Example: see GEOM_TestAll.py
1042 def SubShapeSorted(aShape, aType, ListOfInd):
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 # -----------------------------------------------------------------------------
1055 * Apply a sequence of Shape Healing operators to the given object.
1056 * \param theShape Shape to be processed.
1057 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1058 * \param theParameters List of names of parameters
1059 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1060 * \param theValues List of values of parameters, in the same order
1061 * as parameters are listed in \a theParameters list.
1062 * \return New GEOM_Object, containing processed shape.
1064 * Example: see GEOM_TestHealing.py
1066 def ProcessShape(theShape, theOperators, theParameters, theValues):
1067 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1068 if HealOp.IsDone() == 0:
1069 print "ProcessShape : ", HealOp.GetErrorCode()
1073 * Remove faces from the given object (shape).
1074 * \param theObject Shape to be processed.
1075 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1076 * removes ALL faces of the given object.
1077 * \return New GEOM_Object, containing processed shape.
1079 * Example: see GEOM_TestHealing.py
1081 def SuppressFaces(theObject, theFaces):
1082 anObj = HealOp.SuppressFaces(theObject, theFaces)
1083 if HealOp.IsDone() == 0:
1084 print "SuppressFaces : ", HealOp.GetErrorCode()
1088 * Sewing of some shapes into single shape.
1090 * Example: see GEOM_TestHealing.py
1092 def MakeSewing(ListShape, theTolerance):
1093 comp = MakeCompound(ListShape)
1094 anObj = Sew(comp, theTolerance)
1098 * Sewing of the given object.
1099 * \param theObject Shape to be processed.
1100 * \param theTolerance Required tolerance value.
1101 * \return New GEOM_Object, containing processed shape.
1103 * Example: see MakeSewing() above
1105 def Sew(theObject, theTolerance):
1106 anObj = HealOp.Sew(theObject, theTolerance)
1107 if HealOp.IsDone() == 0:
1108 print "Sew : ", HealOp.GetErrorCode()
1112 * Remove internal wires and edges from the given object (face).
1113 * \param theObject Shape to be processed.
1114 * \param theWires Indices of wires to be removed, if EMPTY then the method
1115 * removes ALL internal wires of the given object.
1116 * \return New GEOM_Object, containing processed shape.
1118 * Example: see GEOM_TestHealing.py
1120 def SuppressInternalWires(theObject, theWires):
1121 anObj = HealOp.RemoveIntWires(theObject, theWires)
1122 if HealOp.IsDone() == 0:
1123 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1127 * Remove internal closed contours (holes) from the given object.
1128 * \param theObject Shape to be processed.
1129 * \param theWires Indices of wires to be removed, if EMPTY then the method
1130 * removes ALL internal holes of the given object
1131 * \return New GEOM_Object, containing processed shape.
1133 * Example: see GEOM_TestHealing.py
1135 def SuppressHoles(theObject, theWires):
1136 anObj = HealOp.FillHoles(theObject, theWires)
1137 if HealOp.IsDone() == 0:
1138 print "SuppressHoles : ", HealOp.GetErrorCode()
1142 * Close an open wire.
1143 * \param theObject Shape to be processed.
1144 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1145 * if -1, then theObject itself is a wire.
1146 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1147 * If FALS : closure by creation of an edge between ends.
1148 * \return New GEOM_Object, containing processed shape.
1150 * Example: see GEOM_TestHealing.py
1152 def CloseContour(theObject, theWires, isCommonVertex):
1153 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1154 if HealOp.IsDone() == 0:
1155 print "CloseContour : ", HealOp.GetErrorCode()
1159 * Addition of a point to a given edge object.
1160 * \param theObject Shape to be processed.
1161 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1162 * if -1, then theObject itself is the edge.
1163 * \param theValue Value of parameter on edge or length parameter,
1164 * depending on \a isByParameter.
1165 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1166 * if FALSE : \a theValue is treated as a length parameter [0..1]
1167 * \return New GEOM_Object, containing processed shape.
1169 * Example: see GEOM_TestHealing.py
1171 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1172 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1173 if HealOp.IsDone() == 0:
1174 print "DivideEdge : ", HealOp.GetErrorCode()
1178 * Get a list of wires (wrapped in GEOM_Object-s),
1179 * that constitute a free boundary of the given shape.
1180 * \param theObject Shape to get free boundary of.
1181 * \return [status, theClosedWires, theOpenWires]
1182 * status: FALSE, if an error(s) occured during the method execution.
1183 * theClosedWires: Closed wires on the free boundary of the given shape.
1184 * theOpenWires: Open wires on the free boundary of the given shape.
1186 * Example: see GEOM_TestHealing.py
1188 def GetFreeBoundary(theObject):
1189 anObj = HealOp.GetFreeBoundary(theObject)
1190 if HealOp.IsDone() == 0:
1191 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1194 # -----------------------------------------------------------------------------
1195 # Create advanced objects
1196 # -----------------------------------------------------------------------------
1199 * Create a copy of the given object
1201 * Example: see GEOM_TestAll.py
1203 def MakeCopy(theOriginal):
1204 anObj = InsertOp.MakeCopy(theOriginal)
1205 if InsertOp.IsDone() == 0:
1206 print "MakeCopy : ", InsertOp.GetErrorCode()
1210 * Create a filling from the given compound of contours.
1211 * \param theShape the compound of contours
1212 * \param theMinDeg a minimal degree
1213 * \param theMaxDeg a maximal degree
1214 * \param theTol2D a 2d tolerance
1215 * \param theTol3D a 3d tolerance
1216 * \param theNbIter a number of iteration
1217 * \return New GEOM_Object, containing the created filling surface.
1219 * Example: see GEOM_TestAll.py
1221 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1222 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1223 if PrimOp.IsDone() == 0:
1224 print "MakeFilling : ", PrimOp.GetErrorCode()
1228 * Replace coincident faces in theShape by one face.
1229 * \param theShape Initial shape.
1230 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1231 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1233 * Example: see GEOM_Spanner.py
1235 def MakeGlueFaces(theShape, theTolerance):
1236 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1237 if ShapesOp.IsDone() == 0:
1238 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1241 # -----------------------------------------------------------------------------
1242 # Boolean (Common, Cut, Fuse, Section)
1243 # -----------------------------------------------------------------------------
1246 * Perform one of boolean operations on two given shapes.
1247 * \param theShape1 First argument for boolean operation.
1248 * \param theShape2 Second argument for boolean operation.
1249 * \param theOperation Indicates the operation to be done:
1250 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1251 * \return New GEOM_Object, containing the result shape.
1253 * Example: see GEOM_TestAll.py
1255 def MakeBoolean(theShape1, theShape2, theOperation):
1256 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1257 if BoolOp.IsDone() == 0:
1258 print "MakeBoolean : ", BoolOp.GetErrorCode()
1262 * Shortcuts to MakeBoolean() for certain operations
1264 * Example: see GEOM_TestOthers.py
1266 def MakeCommon(s1, s2):
1267 return MakeBoolean(s1, s2, 1)
1269 def MakeCut(s1, s2):
1270 return MakeBoolean(s1, s2, 2)
1272 def MakeFuse(s1, s2):
1273 return MakeBoolean(s1, s2, 3)
1275 def MakeSection(s1, s2):
1276 return MakeBoolean(s1, s2, 4)
1279 * Perform partition operation.
1280 * \param ListShapes Shapes to be intersected.
1281 * \param ListTools Shapes to intersect theShapes.
1282 * \param ListKeepInside Shapes, outside which the results will be deleted.
1283 * Each shape from theKeepInside must belong to theShapes also.
1284 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1285 * Each shape from theRemoveInside must belong to theShapes also.
1286 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1287 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1288 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1289 * \return New GEOM_Object, containing the result shapes.
1291 * Example: see GEOM_TestAll.py
1293 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1294 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1295 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1296 ListKeepInside, ListRemoveInside,
1297 Limit, RemoveWebs, ListMaterials);
1298 if BoolOp.IsDone() == 0:
1299 print "MakePartition : ", BoolOp.GetErrorCode()
1303 * Shortcut to MakePartition()
1305 * Example: see GEOM_TestOthers.py
1307 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1308 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1309 anObj = MakePartition(ListShapes, ListTools,
1310 ListKeepInside, ListRemoveInside,
1311 Limit, RemoveWebs, ListMaterials);
1315 * Perform partition of the Shape with the Plane
1316 * \param theShape Shape to be intersected.
1317 * \param thePlane Tool shape, to intersect theShape.
1318 * \return New GEOM_Object, containing the result shape.
1320 * Example: see GEOM_TestAll.py
1322 def MakeHalfPartition(theShape, thePlane):
1323 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1324 if BoolOp.IsDone() == 0:
1325 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1328 # -----------------------------------------------------------------------------
1330 # -----------------------------------------------------------------------------
1333 * Translate the given object along the vector, specified
1334 * by its end points, creating its copy before the translation.
1335 * \param theObject The object to be translated.
1336 * \param thePoint1 Start point of translation vector.
1337 * \param thePoint2 End point of translation vector.
1338 * \return New GEOM_Object, containing the translated object.
1340 * Example: see GEOM_TestAll.py
1342 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1343 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1344 if TrsfOp.IsDone() == 0:
1345 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1349 * Translate the given object along the vector, specified
1350 * by its components, creating its copy before the translation.
1351 * \param theObject The object to be translated.
1352 * \param theDX,theDY,theDZ Components of translation vector.
1353 * \return New GEOM_Object, containing the translated object.
1355 * Example: see GEOM_TestAll.py
1357 def MakeTranslation(theObject, theDX, theDY, theDZ):
1358 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1359 if TrsfOp.IsDone() == 0:
1360 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1364 * Translate the given object along the given vector,
1365 * creating its copy before the translation.
1366 * \param theObject The object to be translated.
1367 * \param theVector The translation vector.
1368 * \return New GEOM_Object, containing the translated object.
1370 * Example: see GEOM_TestAll.py
1372 def MakeTranslationVector(theObject, theVector):
1373 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1374 if TrsfOp.IsDone() == 0:
1375 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1379 * Rotate the given object around the given axis
1380 * on the given angle, creating its copy before the rotatation.
1381 * \param theObject The object to be rotated.
1382 * \param theAxis Rotation axis.
1383 * \param theAngle Rotation angle in radians.
1384 * \return New GEOM_Object, containing the rotated object.
1386 * Example: see GEOM_TestAll.py
1388 def MakeRotation(theObject, theAxis, theAngle):
1389 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1390 if TrsfOp.IsDone() == 0:
1391 print "RotateCopy : ", TrsfOp.GetErrorCode()
1395 * Scale the given object by the factor, creating its copy before the scaling.
1396 * \param theObject The object to be scaled.
1397 * \param thePoint Center point for scaling.
1398 * \param theFactor Scaling factor value.
1399 * \return New GEOM_Object, containing the scaled shape.
1401 * Example: see GEOM_TestAll.py
1403 def MakeScaleTransform(theObject, thePoint, theFactor):
1404 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1405 if TrsfOp.IsDone() == 0:
1406 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1410 * Create an object, symmetrical
1411 * to the given one relatively the given plane.
1412 * \param theObject The object to be mirrored.
1413 * \param thePlane Plane of symmetry.
1414 * \return New GEOM_Object, containing the mirrored shape.
1416 * Example: see GEOM_TestAll.py
1418 def MakeMirrorByPlane(theObject, thePlane):
1419 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1420 if TrsfOp.IsDone() == 0:
1421 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1425 * Create an object, symmetrical
1426 * to the given one relatively the given axis.
1427 * \param theObject The object to be mirrored.
1428 * \param theAxis Axis of symmetry.
1429 * \return New GEOM_Object, containing the mirrored shape.
1431 * Example: see GEOM_TestAll.py
1433 def MakeMirrorByAxis(theObject, theAxis):
1434 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1435 if TrsfOp.IsDone() == 0:
1436 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1440 * Create an object, symmetrical
1441 * to the given one relatively the given point.
1442 * \param theObject The object to be mirrored.
1443 * \param thePoint Point of symmetry.
1444 * \return New GEOM_Object, containing the mirrored shape.
1446 * Example: see GEOM_TestAll.py
1448 def MakeMirrorByPoint(theObject, thePoint):
1449 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1450 if TrsfOp.IsDone() == 0:
1451 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1455 * Modify the Location of the given object by LCS
1456 * creating its copy before the setting
1458 * Example: see GEOM_TestAll.py
1460 def MakePosition(theObject, theStartLCS, theEndLCS):
1461 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1462 if TrsfOp.IsDone() == 0:
1463 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1467 * Create new object as offset of the given one.
1468 * \param theObject The base object for the offset.
1469 * \param theOffset Offset value.
1470 * \return New GEOM_Object, containing the offset object.
1472 * Example: see GEOM_TestAll.py
1474 def MakeOffset(theObject, theOffset):
1475 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1476 if TrsfOp.IsDone() == 0:
1477 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1480 # -----------------------------------------------------------------------------
1482 # -----------------------------------------------------------------------------
1485 * Translate the given object along the given vector a given number times
1486 * \param theObject The object to be translated.
1487 * \param theVector Direction of the translation.
1488 * \param theStep Distance to translate on.
1489 * \param theNbTimes Quantity of translations to be done.
1490 * \return New GEOM_Object, containing compound of all
1491 * the shapes, obtained after each translation.
1493 * Example: see GEOM_TestAll.py
1495 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1496 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1497 if TrsfOp.IsDone() == 0:
1498 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1502 * Conseqently apply two specified translations to theObject specified number of times.
1503 * \param theObject The object to be translated.
1504 * \param theVector1 Direction of the first translation.
1505 * \param theStep1 Step of the first translation.
1506 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1507 * \param theVector2 Direction of the second translation.
1508 * \param theStep2 Step of the second translation.
1509 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1510 * \return New GEOM_Object, containing compound of all
1511 * the shapes, obtained after each translation.
1513 * Example: see GEOM_TestAll.py
1515 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1516 theVector2, theStep2, theNbTimes2):
1517 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1518 theVector2, theStep2, theNbTimes2)
1519 if TrsfOp.IsDone() == 0:
1520 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1524 * Rotate the given object around the given axis a given number times.
1525 * Rotation angle will be 2*PI/theNbTimes.
1526 * \param theObject The object to be rotated.
1527 * \param theAxis The rotation axis.
1528 * \param theNbTimes Quantity of rotations to be done.
1529 * \return New GEOM_Object, containing compound of all the
1530 * shapes, obtained after each rotation.
1532 * Example: see GEOM_TestAll.py
1534 def MultiRotate1D(theObject, theAxis, theNbTimes):
1535 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1536 if TrsfOp.IsDone() == 0:
1537 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1541 * Rotate the given object around the
1542 * given axis on the given angle a given number
1543 * times and multi-translate each rotation result.
1544 * Translation direction passes through center of gravity
1545 * of rotated shape and its projection on the rotation axis.
1546 * \param theObject The object to be rotated.
1547 * \param theAxis Rotation axis.
1548 * \param theAngle Rotation angle in graduces.
1549 * \param theNbTimes1 Quantity of rotations to be done.
1550 * \param theStep Translation distance.
1551 * \param theNbTimes2 Quantity of translations to be done.
1552 * \return New GEOM_Object, containing compound of all the
1553 * shapes, obtained after each transformation.
1555 * Example: see GEOM_TestAll.py
1557 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1558 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1559 if TrsfOp.IsDone() == 0:
1560 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1564 * The same, as MultiRotate1D(), but axis is given by direction and point
1566 * Example: see GEOM_TestOthers.py
1568 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1569 aVec = MakeLine(aPoint,aDir)
1570 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1574 * The same, as MultiRotate2D(), but axis is given by direction and point
1576 * Example: see GEOM_TestOthers.py
1578 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1579 aVec = MakeLine(aPoint,aDir)
1580 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1583 # -----------------------------------------------------------------------------
1585 # -----------------------------------------------------------------------------
1588 * Perform a fillet on all edges of the given shape.
1589 * \param theShape Shape, to perform fillet on.
1590 * \param theR Fillet radius.
1591 * \return New GEOM_Object, containing the result shape.
1593 * Example: see GEOM_TestOthers.py
1595 def MakeFilletAll(theShape, theR):
1596 anObj = LocalOp.MakeFilletAll(theShape, theR)
1597 if LocalOp.IsDone() == 0:
1598 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1602 * Perform a fillet on the specified edges/faces of the given shape
1603 * \param theShape Shape, to perform fillet on.
1604 * \param theR Fillet radius.
1605 * \param theShapeType Type of shapes in <theListShapes>.
1606 * \param theListShapes Global indices of edges/faces to perform fillet on.
1607 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1608 * \return New GEOM_Object, containing the result shape.
1610 * Example: see GEOM_TestAll.py
1612 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1614 if theShapeType == ShapeType["EDGE"]:
1615 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1617 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1618 if LocalOp.IsDone() == 0:
1619 print "MakeFillet : ", LocalOp.GetErrorCode()
1623 * Perform a symmetric chamfer on all edges of the given shape.
1624 * \param theShape Shape, to perform chamfer on.
1625 * \param theD Chamfer size along each face.
1626 * \return New GEOM_Object, containing the result shape.
1628 * Example: see GEOM_TestOthers.py
1630 def MakeChamferAll(theShape, theD):
1631 anObj = LocalOp.MakeChamferAll(theShape, theD)
1632 if LocalOp.IsDone() == 0:
1633 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1637 * Perform a chamfer on edges, common to the specified faces,
1638 * with distance D1 on the Face1
1639 * \param theShape Shape, to perform chamfer on.
1640 * \param theD1 Chamfer size along \a theFace1.
1641 * \param theD2 Chamfer size along \a theFace2.
1642 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1643 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1644 * \return New GEOM_Object, containing the result shape.
1646 * Example: see GEOM_TestAll.py
1648 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1649 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1650 if LocalOp.IsDone() == 0:
1651 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1655 * Perform a chamfer on all edges of the specified faces,
1656 * with distance D1 on the first specified face (if several for one edge)
1657 * \param theShape Shape, to perform chamfer on.
1658 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1659 * connected to the edge, are in \a theFaces, \a theD1
1660 * will be get along face, which is nearer to \a theFaces beginning.
1661 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1662 * \param theFaces Sequence of global indices of faces of \a theShape.
1663 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1664 * \return New GEOM_Object, containing the result shape.
1666 * Example: see GEOM_TestAll.py
1668 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1669 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1670 if LocalOp.IsDone() == 0:
1671 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1675 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1677 * Example: see GEOM_TestOthers.py
1679 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1681 if aShapeType == ShapeType["EDGE"]:
1682 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1684 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1688 * Perform an Archimde operation on the given shape with given parameters.
1689 * The object presenting the resulting face is returned
1690 * \param theShape Shape to be put in water.
1691 * \param theWeight Weight og the shape.
1692 * \param theWaterDensity Density of the water.
1693 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1694 * \return New GEOM_Object, containing a section of \a theShape
1695 * by a plane, corresponding to water level.
1697 * Example: see GEOM_TestAll.py
1699 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1700 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1701 if LocalOp.IsDone() == 0:
1702 print "MakeArchimede : ", LocalOp.GetErrorCode()
1705 # -----------------------------------------------------------------------------
1706 # Information objects
1707 # -----------------------------------------------------------------------------
1710 * Get point coordinates
1713 * Example: see GEOM_TestMeasures.py
1715 def PointCoordinates(Point):
1716 aTuple = MeasuOp.PointCoordinates(Point)
1717 if MeasuOp.IsDone() == 0:
1718 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1722 * Get summarized length of all wires,
1723 * area of surface and volume of the given shape.
1724 * \param theShape Shape to define properties of.
1725 * \return [theLength, theSurfArea, theVolume]
1726 * theLength: Summarized length of all wires of the given shape.
1727 * theSurfArea: Area of surface of the given shape.
1728 * theVolume: Volume of the given shape.
1730 * Example: see GEOM_TestMeasures.py
1732 def BasicProperties(theShape):
1733 aTuple = MeasuOp.GetBasicProperties(theShape)
1734 if MeasuOp.IsDone() == 0:
1735 print "BasicProperties : ", MeasuOp.GetErrorCode()
1739 * Get parameters of bounding box of the given shape
1740 * \param theShape Shape to obtain bounding box of.
1741 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1742 * Xmin,Xmax: Limits of shape along OX axis.
1743 * Ymin,Ymax: Limits of shape along OY axis.
1744 * Zmin,Zmax: Limits of shape along OZ axis.
1746 * Example: see GEOM_TestMeasures.py
1748 def BoundingBox(theShape):
1749 aTuple = MeasuOp.GetBoundingBox(theShape)
1750 if MeasuOp.IsDone() == 0:
1751 print "BoundingBox : ", MeasuOp.GetErrorCode()
1755 * Get inertia matrix and moments of inertia of theShape.
1756 * \param theShape Shape to calculate inertia of.
1757 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1758 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1759 * Ix,Iy,Iz: Moments of inertia of the given shape.
1761 * Example: see GEOM_TestMeasures.py
1763 def Inertia(theShape):
1764 aTuple = MeasuOp.GetInertia(theShape)
1765 if MeasuOp.IsDone() == 0:
1766 print "Inertia : ", MeasuOp.GetErrorCode()
1770 * Get minimal distance between the given shapes.
1771 * \param theShape1,theShape2 Shapes to find minimal distance between.
1772 * \return Value of the minimal distance between the given shapes.
1774 * Example: see GEOM_TestMeasures.py
1776 def MinDistance(theShape1, theShape2):
1777 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1778 if MeasuOp.IsDone() == 0:
1779 print "MinDistance : ", MeasuOp.GetErrorCode()
1783 * Get min and max tolerances of sub-shapes of theShape
1784 * \param theShape Shape, to get tolerances of.
1785 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1786 * FaceMin,FaceMax: Min and max tolerances of the faces.
1787 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1788 * VertMin,VertMax: Min and max tolerances of the vertices.
1790 * Example: see GEOM_TestMeasures.py
1792 def Tolerance(theShape):
1793 aTuple = MeasuOp.GetTolerance(theShape)
1794 if MeasuOp.IsDone() == 0:
1795 print "Tolerance : ", MeasuOp.GetErrorCode()
1799 * Obtain description of the given shape (number of sub-shapes of each type)
1800 * \param theShape Shape to be described.
1801 * \return Description of the given shape.
1803 * Example: see GEOM_TestMeasures.py
1805 def WhatIs(theShape):
1806 aDescr = MeasuOp.WhatIs(theShape)
1807 if MeasuOp.IsDone() == 0:
1808 print "WhatIs : ", MeasuOp.GetErrorCode()
1812 * Get a point, situated at the centre of mass of theShape.
1813 * \param theShape Shape to define centre of mass of.
1814 * \return New GEOM_Object, containing the created point.
1816 * Example: see GEOM_TestMeasures.py
1818 def MakeCDG(theShape):
1819 anObj = MeasuOp.GetCentreOfMass(theShape)
1820 if MeasuOp.IsDone() == 0:
1821 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1825 * Check a topology of the given shape.
1826 * \param theShape Shape to check validity of.
1827 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1828 * If theShape is invalid, prints a description of problem.
1830 * Example: see GEOM_TestMeasures.py
1832 def CheckShape(theShape):
1833 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1834 if MeasuOp.IsDone() == 0:
1835 print "CheckShape : ", MeasuOp.GetErrorCode()
1841 # -----------------------------------------------------------------------------
1842 # Import/Export objects
1843 # -----------------------------------------------------------------------------
1846 * Import a shape from the BREP or IGES or STEP file
1847 * (depends on given format) with given name.
1848 * \param theFileName The file, containing the shape.
1849 * \param theFormatName Specify format for the file reading.
1850 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1851 * \return New GEOM_Object, containing the imported shape.
1853 * Example: see GEOM_TestOthers.py
1855 def Import(theFileName, theFormatName):
1856 anObj = InsertOp.Import(theFileName, theFormatName)
1857 if InsertOp.IsDone() == 0:
1858 print "Import : ", InsertOp.GetErrorCode()
1862 * Shortcuts to Import() for certain formats
1864 * Example: see GEOM_TestOthers.py
1866 def ImportBREP(theFileName):
1867 return Import(theFileName, "BREP")
1869 def ImportIGES(theFileName):
1870 return Import(theFileName, "IGES")
1872 def ImportSTEP(theFileName):
1873 return Import(theFileName, "STEP")
1876 * Export the given shape into a file with given name.
1877 * \param theObject Shape to be stored in the file.
1878 * \param theFileName Name of the file to store the given shape in.
1879 * \param theFormatName Specify format for the shape storage.
1880 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1882 * Example: see GEOM_TestOthers.py
1884 def Export(theObject, theFileName, theFormatName):
1885 InsertOp.Export(theObject, theFileName, theFormatName)
1886 if InsertOp.IsDone() == 0:
1887 print "Export : ", InsertOp.GetErrorCode()
1890 * Shortcuts to Export() for certain formats
1892 * Example: see GEOM_TestOthers.py
1894 def ExportBREP(theObject, theFileName):
1895 return Export(theObject, theFileName, "BREP")
1897 def ExportIGES(theObject, theFileName):
1898 return Export(theObject, theFileName, "IGES")
1900 def ExportSTEP(theObject, theFileName):
1901 return Export(theObject, theFileName, "STEP")
1903 # -----------------------------------------------------------------------------
1905 # -----------------------------------------------------------------------------
1908 * Create a quadrangle face from four edges. Order of Edges is not
1909 * important. It is not necessary that edges share the same vertex.
1910 * \param E1,E2,E3,E4 Edges for the face bound.
1911 * \return New GEOM_Object, containing the created face.
1913 * Example: see GEOM_Spanner.py
1915 def MakeQuad(E1, E2, E3, E4):
1916 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1917 if BlocksOp.IsDone() == 0:
1918 print "MakeQuad : ", BlocksOp.GetErrorCode()
1922 * Create a quadrangle face on two edges.
1923 * The missing edges will be built by creating the shortest ones.
1924 * \param E1,E2 Two opposite edges for the face.
1925 * \return New GEOM_Object, containing the created face.
1927 * Example: see GEOM_Spanner.py
1929 def MakeQuad2Edges(E1, E2):
1930 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1931 if BlocksOp.IsDone() == 0:
1932 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
1936 * Create a quadrangle face with specified corners.
1937 * The missing edges will be built by creating the shortest ones.
1938 * \param V1,V2,V3,V4 Corner vertices for the face.
1939 * \return New GEOM_Object, containing the created face.
1941 * Example: see GEOM_Spanner.py
1943 def MakeQuad4Vertices(V1, V2, V3, V4):
1944 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
1945 if BlocksOp.IsDone() == 0:
1946 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
1950 * Create a hexahedral solid, bounded by the six given faces. Order of
1951 * faces is not important. It is not necessary that Faces share the same edge.
1952 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
1953 * \return New GEOM_Object, containing the created solid.
1955 * Example: see GEOM_Spanner.py
1957 def MakeHexa(F1, F2, F3, F4, F5, F6):
1958 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
1959 if BlocksOp.IsDone() == 0:
1960 print "MakeHexa : ", BlocksOp.GetErrorCode()
1964 * Create a hexahedral solid between two given faces.
1965 * The missing faces will be built by creating the smallest ones.
1966 * \param F1,F2 Two opposite faces for the hexahedral solid.
1967 * \return New GEOM_Object, containing the created solid.
1969 * Example: see GEOM_Spanner.py
1971 def MakeHexa2Faces(F1, F2):
1972 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
1973 if BlocksOp.IsDone() == 0:
1974 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
1978 * Get a vertex, found in the given shape by its coordinates.
1979 * \param theShape Block or a compound of blocks.
1980 * \param theX,theY,theZ Coordinates of the sought vertex.
1981 * \param theEpsilon Maximum allowed distance between the resulting
1982 * vertex and point with the given coordinates.
1983 * \return New GEOM_Object, containing the found vertex.
1985 * Example: see GEOM_TestOthers.py
1987 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
1988 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
1989 if BlocksOp.IsDone() == 0:
1990 print "GetPoint : ", BlocksOp.GetErrorCode()
1994 * Get an edge, found in the given shape by two given vertices.
1995 * \param theShape Block or a compound of blocks.
1996 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
1997 * \return New GEOM_Object, containing the found edge.
1999 * Example: see GEOM_Spanner.py
2001 def GetEdge(theShape, thePoint1, thePoint2):
2002 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2003 if BlocksOp.IsDone() == 0:
2004 print "GetEdge : ", BlocksOp.GetErrorCode()
2008 * Find an edge of the given shape, which has minimal distance to the given point.
2009 * \param theShape Block or a compound of blocks.
2010 * \param thePoint Point, close to the desired edge.
2011 * \return New GEOM_Object, containing the found edge.
2013 * Example: see GEOM_TestOthers.py
2015 def GetEdgeNearPoint(theShape, thePoint):
2016 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2017 if BlocksOp.IsDone() == 0:
2018 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2022 * Returns a face, found in the given shape by four given corner vertices.
2023 * \param theShape Block or a compound of blocks.
2024 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2025 * \return New GEOM_Object, containing the found face.
2027 * Example: see GEOM_Spanner.py
2029 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2030 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2031 if BlocksOp.IsDone() == 0:
2032 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2036 * Get a face of block, found in the given shape by two given edges.
2037 * \param theShape Block or a compound of blocks.
2038 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2039 * \return New GEOM_Object, containing the found face.
2041 * Example: see GEOM_Spanner.py
2043 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2044 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2045 if BlocksOp.IsDone() == 0:
2046 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2050 * Find a face, opposite to the given one in the given block.
2051 * \param theBlock Must be a hexahedral solid.
2052 * \param theFace Face of \a theBlock, opposite to the desired face.
2053 * \return New GEOM_Object, containing the found face.
2055 * Example: see GEOM_Spanner.py
2057 def GetOppositeFace(theBlock, theFace):
2058 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2059 if BlocksOp.IsDone() == 0:
2060 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2064 * Find a face of the given shape, which has minimal distance to the given point.
2065 * \param theShape Block or a compound of blocks.
2066 * \param thePoint Point, close to the desired face.
2067 * \return New GEOM_Object, containing the found face.
2069 * Example: see GEOM_Spanner.py
2071 def GetFaceNearPoint(theShape, thePoint):
2072 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2073 if BlocksOp.IsDone() == 0:
2074 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2078 * Find a face of block, whose outside normale has minimal angle with the given vector.
2079 * \param theShape Block or a compound of blocks.
2080 * \param theVector Vector, close to the normale of the desired face.
2081 * \return New GEOM_Object, containing the found face.
2083 * Example: see GEOM_Spanner.py
2085 def GetFaceByNormale(theBlock, theVector):
2086 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2087 if BlocksOp.IsDone() == 0:
2088 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2092 * Check, if the compound of blocks is given.
2093 * To be considered as a compound of blocks, the
2094 * given shape must satisfy the following conditions:
2095 * - Each element of the compound should be a Block (6 faces and 12 edges).
2096 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2097 * - The compound should be connexe.
2098 * - The glue between two quadrangle faces should be applied.
2099 * \param theCompound The compound to check.
2100 * \return TRUE, if the given shape is a compound of blocks.
2101 * If theCompound is not valid, prints all discovered errors.
2103 * Example: see GEOM_Spanner.py
2105 def CheckCompoundOfBlocks(theCompound):
2106 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2107 if BlocksOp.IsDone() == 0:
2108 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2111 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2116 * Remove all seam and degenerated edges from \a theShape.
2117 * Unite faces and edges, sharing one surface.
2118 * \param theShape The compound or single solid to remove irregular edges from.
2119 * \return Improved shape.
2121 * Example: see GEOM_TestOthers.py
2123 def RemoveExtraEdges(theShape):
2124 anObj = BlocksOp.RemoveExtraEdges(theShape)
2125 if BlocksOp.IsDone() == 0:
2126 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2130 * Check, if the given shape is a blocks compound.
2131 * Fix all detected errors.
2132 * \note Single block can be also fixed by this method.
2133 * \param theCompound The compound to check and improve.
2134 * \return Improved compound.
2136 * Example: see GEOM_TestOthers.py
2138 def CheckAndImprove(theShape):
2139 anObj = BlocksOp.CheckAndImprove(theShape)
2140 if BlocksOp.IsDone() == 0:
2141 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2145 * Get all the blocks, contained in the given compound.
2146 * \param theCompound The compound to explode.
2147 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2148 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2149 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2150 * \return List of GEOM_Objects, containing the retrieved blocks.
2152 * Example: see GEOM_TestOthers.py
2154 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2155 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2156 if BlocksOp.IsDone() == 0:
2157 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2161 * Find block, containing the given point inside its volume or on boundary.
2162 * \param theCompound Compound, to find block in.
2163 * \param thePoint Point, close to the desired block. If the point lays on
2164 * boundary between some blocks, we return block with nearest center.
2165 * \return New GEOM_Object, containing the found block.
2167 * Example: see GEOM_Spanner.py
2169 def GetBlockNearPoint(theCompound, thePoint):
2170 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2171 if BlocksOp.IsDone() == 0:
2172 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2176 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2177 * \param theCompound Compound, to find block in.
2178 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2179 * \return New GEOM_Object, containing the found block.
2181 * Example: see GEOM_TestOthers.py
2183 def GetBlockByParts(theCompound, theParts):
2184 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2185 if BlocksOp.IsDone() == 0:
2186 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2190 * Return all blocks, containing all the elements, passed as the parts.
2191 * \param theCompound Compound, to find blocks in.
2192 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2193 * \return List of GEOM_Objects, containing the found blocks.
2195 * Example: see GEOM_Spanner.py
2197 def GetBlocksByParts(theCompound, theParts):
2198 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2199 if BlocksOp.IsDone() == 0:
2200 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2204 * Multi-transformate block and glue the result.
2205 * Transformation is defined so, as to superpose direction faces.
2206 * \param Block Hexahedral solid to be multi-transformed.
2207 * \param DirFace1 ID of First direction face.
2208 * \param DirFace2 ID of Second direction face.
2209 * \param NbTimes Quantity of transformations to be done.
2210 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2211 * \return New GEOM_Object, containing the result shape.
2213 * Example: see GEOM_Spanner.py
2215 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2216 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2217 if BlocksOp.IsDone() == 0:
2218 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2222 * Multi-transformate block and glue the result.
2223 * \param Block Hexahedral solid to be multi-transformed.
2224 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2225 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2226 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2227 * \return New GEOM_Object, containing the result shape.
2229 * Example: see GEOM_Spanner.py
2231 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2232 DirFace1V, DirFace2V, NbTimesV):
2233 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2234 DirFace1V, DirFace2V, NbTimesV)
2235 if BlocksOp.IsDone() == 0:
2236 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2240 * Build all possible propagation groups.
2241 * Propagation group is a set of all edges, opposite to one (main)
2242 * edge of this group directly or through other opposite edges.
2243 * Notion of Opposite Edge make sence only on quadrangle face.
2244 * \param theShape Shape to build propagation groups on.
2245 * \return List of GEOM_Objects, each of them is a propagation group.
2247 * Example: see GEOM_TestOthers.py
2249 def Propagate(theShape):
2250 listChains = BlocksOp.Propagate(theShape)
2251 if BlocksOp.IsDone() == 0:
2252 print "Propagate : ", BlocksOp.GetErrorCode()
2255 # -----------------------------------------------------------------------------
2257 # -----------------------------------------------------------------------------
2260 * Creates a new group which will store sub shapes of theMainShape
2261 * \param theMainShape is a GEOM object on which the group is selected
2262 * \param theShapeType defines a shape type of the group
2263 * \return a newly created GEOM group
2265 * Example: see GEOM_TestOthers.py
2267 def CreateGroup(theMainShape, theShapeType):
2268 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2269 if GroupOp.IsDone() == 0:
2270 print "CreateGroup : ", GroupOp.GetErrorCode()
2274 * Adds a sub object with ID theSubShapeId to the group
2275 * \param theGroup is a GEOM group to which the new sub shape is added
2276 * \param theSubShapeID is a sub shape ID in the main object.
2277 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2279 * Example: see GEOM_TestOthers.py
2281 def AddObject(theGroup, theSubShapeID):
2282 GroupOp.AddObject(theGroup, theSubShapeID)
2283 if GroupOp.IsDone() == 0:
2284 print "AddObject : ", GroupOp.GetErrorCode()
2287 * Removes a sub object with ID \a theSubShapeId from the group
2288 * \param theGroup is a GEOM group from which the new sub shape is removed
2289 * \param theSubShapeID is a sub shape ID in the main object.
2290 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2292 * Example: see GEOM_TestOthers.py
2294 def RemoveObject(theGroup, theSubShapeID):
2295 GroupOp.RemoveObject(theGroup, theSubShapeID)
2296 if GroupOp.IsDone() == 0:
2297 print "RemoveObject : ", GroupOp.GetErrorCode()
2300 * Returns a list of sub objects ID stored in the group
2301 * \param theGroup is a GEOM group for which a list of IDs is requested
2303 * Example: see GEOM_TestOthers.py
2305 def GetObjectIDs(theGroup):
2306 ListIDs = GroupOp.GetObjects(theGroup)
2307 if GroupOp.IsDone() == 0:
2308 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2312 * Returns a type of sub objects stored in the group
2313 * \param theGroup is a GEOM group which type is returned.
2315 * Example: see GEOM_TestOthers.py
2317 def GetType(theGroup):
2318 aType = GroupOp.GetType(theGroup)
2319 if GroupOp.IsDone() == 0:
2320 print "GetType : ", GroupOp.GetErrorCode()
2324 * Returns a main shape associated with the group
2325 * \param theGroup is a GEOM group for which a main shape object is requested
2326 * \return a GEOM object which is a main shape for theGroup
2328 * Example: see GEOM_TestOthers.py
2330 def GetMainShape(theGroup):
2331 anObj = GroupOp.GetMainShape(theGroup)
2332 if GroupOp.IsDone() == 0:
2333 print "GetMainShape : ", GroupOp.GetErrorCode()
2337 * Add Path to the system path
2340 if (sys.path.count(Path) < 1):
2341 sys.path.append(Path)