1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 # Author : Paul RASCLE, EDF
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 geom = g._narrow( GEOM.GEOM_Gen )
39 gg = ImportComponentGUI("GEOM")
42 #SRN: modified on Mar 18, 2005
61 def init_geom(theStudy):
63 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
64 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
67 myStudyId = myStudy._get_StudyId()
68 myBuilder = myStudy.NewBuilder()
69 father = myStudy.FindComponent("GEOM")
71 father = myBuilder.NewComponent("GEOM")
72 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
73 FName = A1._narrow(SALOMEDS.AttributeName)
74 FName.SetValue("Geometry")
75 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
76 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
77 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
78 myBuilder.DefineComponentInstance(father,geom)
81 # -----------------------------------------------------------------------------
82 # Assign Operations Interfaces
83 # -----------------------------------------------------------------------------
85 BasicOp = geom.GetIBasicOperations (myStudyId)
86 CurvesOp = geom.GetICurvesOperations (myStudyId)
87 PrimOp = geom.GetI3DPrimOperations (myStudyId)
88 ShapesOp = geom.GetIShapesOperations (myStudyId)
89 HealOp = geom.GetIHealingOperations (myStudyId)
90 InsertOp = geom.GetIInsertOperations (myStudyId)
91 BoolOp = geom.GetIBooleanOperations (myStudyId)
92 TrsfOp = geom.GetITransformOperations(myStudyId)
93 LocalOp = geom.GetILocalOperations (myStudyId)
94 MeasuOp = geom.GetIMeasureOperations (myStudyId)
95 BlocksOp = geom.GetIBlocksOperations (myStudyId)
96 GroupOp = geom.GetIGroupOperations (myStudyId)
101 #SRN: end of modifications
103 def SubShapeName(aSubObj, aMainObj):
105 * Get name for sub-shape aSubObj of shape aMainObj
107 * Example: see GEOM_TestAll.py
109 aSubId = orb.object_to_string(aSubObj)
110 aMainId = orb.object_to_string(aMainObj)
111 index = gg.getIndexTopology(aSubId, aMainId)
112 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
115 def addToStudy(aShape, aName):
117 * Publish in study aShape with name aName
119 * Example: see GEOM_TestAll.py
122 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
124 print "addToStudy() failed"
126 return aShape.GetStudyEntry()
128 def addToStudyInFather(aFather, aShape, aName):
130 * Publish in study aShape with name aName as sub-object of previously published aFather
132 * Example: see GEOM_TestAll.py
135 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
137 print "addToStudyInFather() failed"
139 return aShape.GetStudyEntry()
141 # -----------------------------------------------------------------------------
142 # enumeration ShapeType as a dictionary
143 # -----------------------------------------------------------------------------
145 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
147 # -----------------------------------------------------------------------------
149 # -----------------------------------------------------------------------------
151 def MakeVertex(theX, theY, theZ):
153 * Create point by three coordinates.
154 * \param theX The X coordinate of the point.
155 * \param theY The Y coordinate of the point.
156 * \param theZ The Z coordinate of the point.
157 * \return New GEOM_Object, containing the created point.
159 * Example: see GEOM_TestAll.py
161 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
162 if BasicOp.IsDone() == 0:
163 print "MakePointXYZ : ", BasicOp.GetErrorCode()
166 def MakeVertexWithRef(theReference, theX, theY, theZ):
168 * Create a point, distant from the referenced point
169 * on the given distances along the coordinate axes.
170 * \param theReference The referenced point.
171 * \param theX Displacement from the referenced point along OX axis.
172 * \param theY Displacement from the referenced point along OY axis.
173 * \param theZ Displacement from the referenced point along OZ axis.
174 * \return New GEOM_Object, containing the created point.
176 * Example: see GEOM_TestAll.py
178 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
179 if BasicOp.IsDone() == 0:
180 print "MakePointWithReference : ", BasicOp.GetErrorCode()
183 def MakeVertexOnCurve(theRefCurve, theParameter):
185 * Create a point, corresponding to the given parameter on the given curve.
186 * \param theRefCurve The referenced curve.
187 * \param theParameter Value of parameter on the referenced curve.
188 * \return New GEOM_Object, containing the created point.
190 * Example: see GEOM_TestAll.py
192 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
193 if BasicOp.IsDone() == 0:
194 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
197 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
199 * Create a vector with the given components.
200 * \param theDX X component of the vector.
201 * \param theDY Y component of the vector.
202 * \param theDZ Z component of the vector.
203 * \return New GEOM_Object, containing the created vector.
205 * Example: see GEOM_TestAll.py
207 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
208 if BasicOp.IsDone() == 0:
209 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
212 def MakeVector(thePnt1, thePnt2):
214 * Create a vector between two points.
215 * \param thePnt1 Start point for the vector.
216 * \param thePnt2 End point for the vector.
217 * \return New GEOM_Object, containing the created vector.
219 * Example: see GEOM_TestAll.py
221 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
222 if BasicOp.IsDone() == 0:
223 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
226 def MakeLine(thePnt, theDir):
228 * Create a line, passing through the given point
229 * and parrallel to the given direction
230 * \param thePnt Point. The resulting line will pass through it.
231 * \param theDir Direction. The resulting line will be parallel to it.
232 * \return New GEOM_Object, containing the created line.
234 * Example: see GEOM_TestAll.py
236 anObj = BasicOp.MakeLine(thePnt, theDir)
237 if BasicOp.IsDone() == 0:
238 print "MakeLine : ", BasicOp.GetErrorCode()
241 def MakeLineTwoPnt(thePnt1, thePnt2):
243 * Create a line, passing through the given points
244 * \param thePnt1 First of two points, defining the line.
245 * \param thePnt2 Second of two points, defining the line.
246 * \return New GEOM_Object, containing the created line.
248 * Example: see GEOM_TestAll.py
250 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
251 if BasicOp.IsDone() == 0:
252 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
255 def MakePlane(thePnt, theVec, theTrimSize):
257 * Create a plane, passing through the given point
258 * and normal to the given vector.
259 * \param thePnt Point, the plane has to pass through.
260 * \param theVec Vector, defining the plane normal direction.
261 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
262 * \return New GEOM_Object, containing the created plane.
264 * Example: see GEOM_TestAll.py
266 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
267 if BasicOp.IsDone() == 0:
268 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
271 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
273 * Create a plane, passing through the three given points
274 * \param thePnt1 First of three points, defining the plane.
275 * \param thePnt2 Second of three points, defining the plane.
276 * \param thePnt3 Fird of three points, defining the plane.
277 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
278 * \return New GEOM_Object, containing the created plane.
280 * Example: see GEOM_TestAll.py
282 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
283 if BasicOp.IsDone() == 0:
284 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
287 def MakePlaneFace(theFace, theTrimSize):
289 * Create a plane, similar to the existing one, but with another size of representing face.
290 * \param theFace Referenced plane.
291 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
292 * \return New GEOM_Object, containing the created plane.
294 * Example: see GEOM_TestAll.py
296 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
297 if BasicOp.IsDone() == 0:
298 print "MakePlaneFace : ", BasicOp.GetErrorCode()
301 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
303 * Create a local coordinate system.
304 * \param OX,OY,OZ Three coordinates of coordinate system origin.
305 * \param XDX,XDY,XDZ Three components of OX direction
306 * \param YDX,YDY,YDZ Three components of OY direction
307 * \return New GEOM_Object, containing the created coordinate system.
309 * Example: see GEOM_TestAll.py
311 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
312 if BasicOp.IsDone() == 0:
313 print "MakeMarker : ", BasicOp.GetErrorCode()
316 # -----------------------------------------------------------------------------
318 # -----------------------------------------------------------------------------
320 def MakeArc(thePnt1, thePnt2, thePnt3):
322 * Create an arc of circle, passing through three given points.
323 * \param thePnt1 Start point of the arc.
324 * \param thePnt2 Middle point of the arc.
325 * \param thePnt3 End point of the arc.
326 * \return New GEOM_Object, containing the created arc.
328 * Example: see GEOM_TestAll.py
330 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
331 if CurvesOp.IsDone() == 0:
332 print "MakeArc : ", CurvesOp.GetErrorCode()
335 def MakeCircle(thePnt, theVec, theR):
337 * Create a circle with given center, normal vector and radius.
338 * \param thePnt Circle center.
339 * \param theVec Vector, normal to the plane of the circle.
340 * \param theR Circle radius.
341 * \return New GEOM_Object, containing the created circle.
343 * Example: see GEOM_TestAll.py
345 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
346 if CurvesOp.IsDone() == 0:
347 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
350 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
352 * Create a circle, passing through three given points
353 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
354 * \return New GEOM_Object, containing the created circle.
356 * Example: see GEOM_TestAll.py
358 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
359 if CurvesOp.IsDone() == 0:
360 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
363 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
365 * Create an ellipse with given center, normal vector and radiuses.
366 * \param thePnt Ellipse center.
367 * \param theVec Vector, normal to the plane of the ellipse.
368 * \param theRMajor Major ellipse radius.
369 * \param theRMinor Minor ellipse radius.
370 * \return New GEOM_Object, containing the created ellipse.
372 * Example: see GEOM_TestAll.py
374 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
375 if CurvesOp.IsDone() == 0:
376 print "MakeEllipse : ", CurvesOp.GetErrorCode()
379 def MakePolyline(thePoints):
381 * Create a polyline on the set of points.
382 * \param thePoints Sequence of points for the polyline.
383 * \return New GEOM_Object, containing the created polyline.
385 * Example: see GEOM_TestAll.py
387 anObj = CurvesOp.MakePolyline(thePoints)
388 if CurvesOp.IsDone() == 0:
389 print "MakePolyline : ", CurvesOp.GetErrorCode()
392 def MakeBezier(thePoints):
394 * Create bezier curve on the set of points.
395 * \param thePoints Sequence of points for the bezier curve.
396 * \return New GEOM_Object, containing the created bezier curve.
398 * Example: see GEOM_TestAll.py
400 anObj = CurvesOp.MakeSplineBezier(thePoints)
401 if CurvesOp.IsDone() == 0:
402 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
405 def MakeInterpol(thePoints):
407 * Create B-Spline curve on the set of points.
408 * \param thePoints Sequence of points for the B-Spline curve.
409 * \return New GEOM_Object, containing the created B-Spline curve.
411 * Example: see GEOM_TestAll.py
413 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
414 if CurvesOp.IsDone() == 0:
415 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
418 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
420 * Create a sketcher (wire or face), following the textual description,
421 * passed through \a theCommand argument. \n
422 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
423 * Format of the description string have to be the following:
425 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
428 * - x1, y1 are coordinates of the first sketcher point (zero by default),
430 * - "R angle" : Set the direction by angle
431 * - "D dx dy" : Set the direction by DX & DY
434 * - "TT x y" : Create segment by point at X & Y
435 * - "T dx dy" : Create segment by point with DX & DY
436 * - "L length" : Create segment by direction & Length
437 * - "IX x" : Create segment by direction & Intersect. X
438 * - "IY y" : Create segment by direction & Intersect. Y
441 * - "C radius length" : Create arc by direction, radius and length(in degree)
444 * - "WW" : Close Wire (to finish)
445 * - "WF" : Close Wire and build face (to finish)
447 * \param theCommand String, defining the sketcher in local
448 * coordinates of the working plane.
449 * \param theWorkingPlane Nine double values, defining origin,
450 * OZ and OX directions of the working plane.
451 * \return New GEOM_Object, containing the created wire.
453 * Example: see GEOM_TestAll.py
455 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
456 if CurvesOp.IsDone() == 0:
457 print "MakeSketcher : ", CurvesOp.GetErrorCode()
460 # -----------------------------------------------------------------------------
461 # Create 3D Primitives
462 # -----------------------------------------------------------------------------
464 def MakeBox(x1,y1,z1,x2,y2,z2):
466 * Create a box by coordinates of two opposite vertices.
468 * Example: see GEOM_TestAll.py
470 pnt1 = MakeVertex(x1,y1,z1)
471 pnt2 = MakeVertex(x2,y2,z2)
472 return MakeBoxTwoPnt(pnt1,pnt2)
474 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
476 * Create a box with specified dimensions along the coordinate axes
477 * and with edges, parallel to the coordinate axes.
478 * Center of the box will be at point (DX/2, DY/2, DZ/2).
479 * \param theDX Length of Box edges, parallel to OX axis.
480 * \param theDY Length of Box edges, parallel to OY axis.
481 * \param theDZ Length of Box edges, parallel to OZ axis.
482 * \return New GEOM_Object, containing the created box.
484 * Example: see GEOM_TestAll.py
486 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
487 if PrimOp.IsDone() == 0:
488 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
491 def MakeBoxTwoPnt(thePnt1, thePnt2):
493 * Create a box with two specified opposite vertices,
494 * and with edges, parallel to the coordinate axes
495 * \param thePnt1 First of two opposite vertices.
496 * \param thePnt2 Second of two opposite vertices.
497 * \return New GEOM_Object, containing the created box.
499 * Example: see GEOM_TestAll.py
501 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
502 if PrimOp.IsDone() == 0:
503 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
506 def MakeCylinder(thePnt, theAxis, theR, theH):
508 * Create a cylinder with given base point, axis, radius and height.
509 * \param thePnt Central point of cylinder base.
510 * \param theAxis Cylinder axis.
511 * \param theR Cylinder radius.
512 * \param theH Cylinder height.
513 * \return New GEOM_Object, containing the created cylinder.
515 * Example: see GEOM_TestAll.py
517 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
518 if PrimOp.IsDone() == 0:
519 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
522 def MakeCylinderRH(theR, theH):
524 * Create a cylinder with given radius and height at
525 * the origin of coordinate system. Axis of the cylinder
526 * will be collinear to the OZ axis of the coordinate system.
527 * \param theR Cylinder radius.
528 * \param theH Cylinder height.
529 * \return New GEOM_Object, containing the created cylinder.
531 * Example: see GEOM_TestAll.py
533 anObj = PrimOp.MakeCylinderRH(theR, theH)
534 if PrimOp.IsDone() == 0:
535 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
538 def MakeSpherePntR(thePnt, theR):
540 * Create a sphere with given center and radius.
541 * \param thePnt Sphere center.
542 * \param theR Sphere radius.
543 * \return New GEOM_Object, containing the created sphere.
545 * Example: see GEOM_TestAll.py
547 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
548 if PrimOp.IsDone() == 0:
549 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
552 def MakeSphere(x, y, z, theR):
554 * Create a sphere with given center and radius.
555 * \param x,y,z Coordinates of sphere center.
556 * \param theR Sphere radius.
557 * \return New GEOM_Object, containing the created sphere.
559 * Example: see GEOM_TestAll.py
561 point = MakeVertex(x, y, z)
562 anObj = MakeSpherePntR(point, theR)
565 def MakeSphereR(theR):
567 * Create a sphere with given radius at the origin of coordinate system.
568 * \param theR Sphere radius.
569 * \return New GEOM_Object, containing the created sphere.
571 * Example: see GEOM_TestAll.py
573 anObj = PrimOp.MakeSphereR(theR)
574 if PrimOp.IsDone() == 0:
575 print "MakeSphereR : ", PrimOp.GetErrorCode()
578 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
580 * Create a cone with given base point, axis, height and radiuses.
581 * \param thePnt Central point of the first cone base.
582 * \param theAxis Cone axis.
583 * \param theR1 Radius of the first cone base.
584 * \param theR2 Radius of the second cone base.
585 * \note If both radiuses are non-zero, the cone will be truncated.
586 * \note If the radiuses are equal, a cylinder will be created instead.
587 * \param theH Cone height.
588 * \return New GEOM_Object, containing the created cone.
590 * Example: see GEOM_TestAll.py
592 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
593 if PrimOp.IsDone() == 0:
594 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
597 def MakeConeR1R2H(theR1, theR2, theH):
599 * Create a cone with given height and radiuses at
600 * the origin of coordinate system. Axis of the cone will
601 * be collinear to the OZ axis of the coordinate system.
602 * \param theR1 Radius of the first cone base.
603 * \param theR2 Radius of the second cone base.
604 * \note If both radiuses are non-zero, the cone will be truncated.
605 * \note If the radiuses are equal, a cylinder will be created instead.
606 * \param theH Cone height.
607 * \return New GEOM_Object, containing the created cone.
609 * Example: see GEOM_TestAll.py
611 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
612 if PrimOp.IsDone() == 0:
613 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
616 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
618 * Create a torus with given center, normal vector and radiuses.
619 * \param thePnt Torus central point.
620 * \param theVec Torus axis of symmetry.
621 * \param theRMajor Torus major radius.
622 * \param theRMinor Torus minor radius.
623 * \return New GEOM_Object, containing the created torus.
625 * Example: see GEOM_TestAll.py
627 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
628 if PrimOp.IsDone() == 0:
629 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
632 def MakeTorusRR(theRMajor, theRMinor):
634 * Create a torus with given radiuses at the origin of coordinate system.
635 * \param theRMajor Torus major radius.
636 * \param theRMinor Torus minor radius.
637 * \return New GEOM_Object, containing the created torus.
639 * Example: see GEOM_TestAll.py
641 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
642 if PrimOp.IsDone() == 0:
643 print "MakeTorusRR : ", PrimOp.GetErrorCode()
646 def MakePrism(theBase, thePoint1, thePoint2):
648 * Create a shape by extrusion of the base shape along a vector, defined by two points.
649 * \param theBase Base shape to be extruded.
650 * \param thePoint1 First end of extrusion vector.
651 * \param thePoint2 Second end of extrusion vector.
652 * \return New GEOM_Object, containing the created prism.
654 * Example: see GEOM_TestAll.py
656 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
657 if PrimOp.IsDone() == 0:
658 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
661 def MakePrismVecH(theBase, theVec, theH):
663 * Create a shape by extrusion of the base shape along the vector,
664 * i.e. all the space, transfixed by the base shape during its translation
665 * along the vector on the given distance.
666 * \param theBase Base shape to be extruded.
667 * \param theVec Direction of extrusion.
668 * \param theH Prism dimension along theVec.
669 * \return New GEOM_Object, containing the created prism.
671 * Example: see GEOM_TestAll.py
673 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
674 if PrimOp.IsDone() == 0:
675 print "MakePrismVecH : ", PrimOp.GetErrorCode()
678 def MakePipe(theBase, thePath):
680 * Create a shape by extrusion of the base shape along
681 * the path shape. The path shape can be a wire or an edge.
682 * \param theBase Base shape to be extruded.
683 * \param thePath Path shape to extrude the base shape along it.
684 * \return New GEOM_Object, containing the created pipe.
686 * Example: see GEOM_TestAll.py
688 anObj = PrimOp.MakePipe(theBase, thePath)
689 if PrimOp.IsDone() == 0:
690 print "MakePipe : ", PrimOp.GetErrorCode()
693 def MakeRevolution(theBase, theAxis, theAngle):
695 * Create a shape by revolution of the base shape around the axis
696 * on the given angle, i.e. all the space, transfixed by the base
697 * shape during its rotation around the axis on the given angle.
698 * \param theBase Base shape to be rotated.
699 * \param theAxis Rotation axis.
700 * \param theAngle Rotation angle in radians.
701 * \return New GEOM_Object, containing the created revolution.
703 * Example: see GEOM_TestAll.py
705 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
706 if PrimOp.IsDone() == 0:
707 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
710 # -----------------------------------------------------------------------------
712 # -----------------------------------------------------------------------------
714 def MakeEdge(thePnt1, thePnt2):
716 * Create a linear edge with specified ends.
717 * \param thePnt1 Point for the first end of edge.
718 * \param thePnt2 Point for the second end of edge.
719 * \return New GEOM_Object, containing the created edge.
721 * Example: see GEOM_TestAll.py
723 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
724 if ShapesOp.IsDone() == 0:
725 print "MakeEdge : ", ShapesOp.GetErrorCode()
728 def MakeWire(theEdgesAndWires):
730 * Create a wire from the set of edges and wires.
731 * \param theEdgesAndWires List of edges and/or wires.
732 * \return New GEOM_Object, containing the created wire.
734 * Example: see GEOM_TestAll.py
736 anObj = ShapesOp.MakeWire(theEdgesAndWires)
737 if ShapesOp.IsDone() == 0:
738 print "MakeWire : ", ShapesOp.GetErrorCode()
741 def MakeFace(theWire, isPlanarWanted):
743 * Create a face on the given wire.
744 * \param theWire Wire to build the face on.
745 * \param isPlanarWanted If TRUE, only planar face will be built.
746 * If impossible, NULL object will be returned.
747 * \return New GEOM_Object, containing the created face.
749 * Example: see GEOM_TestAll.py
751 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
752 if ShapesOp.IsDone() == 0:
753 print "MakeFace : ", ShapesOp.GetErrorCode()
756 def MakeFaceWires(theWires, isPlanarWanted):
758 * Create a face on the given wires set.
759 * \param theWires List of wires to build the face on.
760 * \param isPlanarWanted If TRUE, only planar face will be built.
761 * If impossible, NULL object will be returned.
762 * \return New GEOM_Object, containing the created face.
764 * Example: see GEOM_TestAll.py
766 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
767 if ShapesOp.IsDone() == 0:
768 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
771 def MakeFaces(theWires, isPlanarWanted):
773 * Shortcut to MakeFaceWires()
775 * Example: see GEOM_TestOthers.py
777 anObj = MakeFaceWires(theWires, isPlanarWanted)
780 def MakeShell(theFacesAndShells):
782 * Create a shell from the set of faces and shells.
783 * \param theFacesAndShells List of faces and/or shells.
784 * \return New GEOM_Object, containing the created shell.
786 * Example: see GEOM_TestAll.py
788 anObj = ShapesOp.MakeShell(theFacesAndShells)
789 if ShapesOp.IsDone() == 0:
790 print "MakeShell : ", ShapesOp.GetErrorCode()
793 def MakeSolid(theShells):
795 * Create a solid, bounded by the given shells.
796 * \param theShells Sequence of bounding shells.
797 * \return New GEOM_Object, containing the created solid.
799 * Example: see GEOM_TestAll.py
801 anObj = ShapesOp.MakeSolidShells(theShells)
802 if ShapesOp.IsDone() == 0:
803 print "MakeSolid : ", ShapesOp.GetErrorCode()
806 def MakeCompound(theShapes):
808 * Create a compound of the given shapes.
809 * \param theShapes List of shapes to put in compound.
810 * \return New GEOM_Object, containing the created compound.
812 * Example: see GEOM_TestAll.py
814 anObj = ShapesOp.MakeCompound(theShapes)
815 if ShapesOp.IsDone() == 0:
816 print "MakeCompound : ", ShapesOp.GetErrorCode()
819 def NumberOfFaces(theShape):
821 * Gives quantity of faces in the given shape.
822 * \param theShape Shape to count faces of.
823 * \return Quantity of faces.
825 * Example: see GEOM_TestOthers.py
827 nb_faces = ShapesOp.NumberOfFaces(theShape)
828 if ShapesOp.IsDone() == 0:
829 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
832 def NumberOfEdges(theShape):
834 * Gives quantity of edges in the given shape.
835 * \param theShape Shape to count edges of.
836 * \return Quantity of edges.
838 * Example: see GEOM_TestOthers.py
840 nb_edges = ShapesOp.NumberOfEdges(theShape)
841 if ShapesOp.IsDone() == 0:
842 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
845 def ChangeOrientation(theShape):
847 * Reverses an orientation the given shape.
848 * \param theShape Shape to be reversed.
849 * \return The reversed copy of theShape.
851 * Example: see GEOM_TestAll.py
853 anObj = ShapesOp.ChangeOrientation(theShape)
854 if ShapesOp.IsDone() == 0:
855 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
858 def OrientationChange(theShape):
860 * Shortcut to ChangeOrientation()
862 * Example: see GEOM_TestOthers.py
864 anObj = ChangeOrientation(theShape)
867 def GetFreeFacesIDs(theShape):
869 * Retrieve all free faces from the given shape.
870 * Free face is a face, which is not shared between two shells of the shape.
871 * \param theShape Shape to find free faces in.
872 * \return List of IDs of all free faces, contained in theShape.
874 * Example: see GEOM_TestOthers.py
876 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
877 if ShapesOp.IsDone() == 0:
878 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
881 def GetSharedShapes(theShape1, theShape2, theShapeType):
883 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
884 * \param theShape1 Shape to find sub-shapes in.
885 * \param theShape2 Shape to find shared sub-shapes with.
886 * \param theShapeType Type of sub-shapes to be retrieved.
887 * \return List of sub-shapes of theShape1, shared with theShape2.
889 * Example: see GEOM_TestOthers.py
891 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
892 if ShapesOp.IsDone() == 0:
893 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
896 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
898 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
899 * the specified plane by the certain way, defined through \a theState parameter.
900 * \param theShape Shape to find sub-shapes of.
901 * \param theShapeType Type of sub-shapes to be retrieved.
902 * \param theAx1 Vector (or line, or linear edge), specifying normal
903 * direction and location of the plane to find shapes on.
904 * \param theState The state of the subshapes to find. It can be one of
905 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
906 * \return List of all found sub-shapes.
908 * Example: see GEOM_TestOthers.py
910 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
911 if ShapesOp.IsDone() == 0:
912 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
915 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
917 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
918 * the specified cylinder by the certain way, defined through \a theState parameter.
919 * \param theShape Shape to find sub-shapes of.
920 * \param theShapeType Type of sub-shapes to be retrieved.
921 * \param theAxis Vector (or line, or linear edge), specifying
922 * axis of the cylinder to find shapes on.
923 * \param theRadius Radius of the cylinder to find shapes on.
924 * \param theState The state of the subshapes to find. It can be one of
925 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
926 * \return List of all found sub-shapes.
928 * Example: see GEOM_TestOthers.py
930 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
931 if ShapesOp.IsDone() == 0:
932 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
935 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
937 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
938 * the specified sphere by the certain way, defined through \a theState parameter.
939 * \param theShape Shape to find sub-shapes of.
940 * \param theShapeType Type of sub-shapes to be retrieved.
941 * \param theCenter Point, specifying center of the sphere to find shapes on.
942 * \param theRadius Radius of the sphere to find shapes on.
943 * \param theState The state of the subshapes to find. It can be one of
944 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
945 * \return List of all found sub-shapes.
947 * Example: see GEOM_TestOthers.py
949 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
950 if ShapesOp.IsDone() == 0:
951 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
954 def GetInPlace(theShapeWhere, theShapeWhat):
956 * Get sub-shape(s) of theShapeWhere, which are
957 * coincident with \a theShapeWhat or could be a part of it.
958 * \param theShapeWhere Shape to find sub-shapes of.
959 * \param theShapeWhat Shape, specifying what to find.
960 * \return Group of all found sub-shapes or a single found sub-shape.
962 * Example: see GEOM_TestOthers.py
964 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
965 if ShapesOp.IsDone() == 0:
966 print "GetInPlace : ", ShapesOp.GetErrorCode()
969 # -----------------------------------------------------------------------------
970 # Access to sub-shapes by their unique IDs inside the main shape.
971 # -----------------------------------------------------------------------------
973 def GetSubShape(aShape, ListOfID):
975 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
976 * of <aShape>, selected by their unique IDs inside <aShape>
978 * Example: see GEOM_TestAll.py
980 anObj = geom.AddSubShape(aShape,ListOfID)
983 def GetSubShapeID(aShape, aSubShape):
985 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
987 * Example: see GEOM_TestAll.py
989 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
990 if LocalOp.IsDone() == 0:
991 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
994 # -----------------------------------------------------------------------------
996 # -----------------------------------------------------------------------------
998 def SubShapeAll(aShape, aType):
1000 * Explode a shape on subshapes of a given type.
1001 * \param theShape Shape to be exploded.
1002 * \param theShapeType Type of sub-shapes to be retrieved.
1003 * \return List of sub-shapes of type theShapeType, contained in theShape.
1005 * Example: see GEOM_TestAll.py
1007 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1008 if ShapesOp.IsDone() == 0:
1009 print "MakeExplode : ", ShapesOp.GetErrorCode()
1012 def SubShapeAllIDs(aShape, aType):
1014 * Explode a shape on subshapes of a given type.
1015 * \param theShape Shape to be exploded.
1016 * \param theShapeType Type of sub-shapes to be retrieved.
1017 * \return List of IDs of sub-shapes.
1019 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1020 if ShapesOp.IsDone() == 0:
1021 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1024 def SubShapeAllSorted(aShape, aType):
1026 * Explode a shape on subshapes of a given type.
1027 * Sub-shapes will be sorted by coordinates of their gravity centers.
1028 * \param theShape Shape to be exploded.
1029 * \param theShapeType Type of sub-shapes to be retrieved.
1030 * \return List of sub-shapes of type theShapeType, contained in theShape.
1032 * Example: see GEOM_TestAll.py
1034 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1035 if ShapesOp.IsDone() == 0:
1036 print "MakeExplode : ", ShapesOp.GetErrorCode()
1039 def SubShapeAllSortedIDs(aShape, aType):
1041 * Explode a shape on subshapes of a given type.
1042 * Sub-shapes will be sorted by coordinates of their gravity centers.
1043 * \param theShape Shape to be exploded.
1044 * \param theShapeType Type of sub-shapes to be retrieved.
1045 * \return List of IDs of sub-shapes.
1047 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1048 if ShapesOp.IsDone() == 0:
1049 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1052 def SubShape(aShape, aType, ListOfInd):
1054 * Obtain a compound of sub-shapes of <aShape>,
1055 * selected by they indices in list of all sub-shapes of type <aType>.
1056 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1058 * Example: see GEOM_TestAll.py
1061 AllShapeList = SubShapeAll(aShape, aType)
1062 for ind in ListOfInd:
1063 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1064 anObj = GetSubShape(aShape, ListOfIDs)
1067 def SubShapeSorted(aShape, aType, ListOfInd):
1069 * Obtain a compound of sub-shapes of <aShape>,
1070 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1071 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1073 * Example: see GEOM_TestAll.py
1076 AllShapeList = SubShapeAllSorted(aShape, aType)
1077 for ind in ListOfInd:
1078 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1079 anObj = GetSubShape(aShape, ListOfIDs)
1082 # -----------------------------------------------------------------------------
1083 # Healing operations
1084 # -----------------------------------------------------------------------------
1086 def ProcessShape(theShape, theOperators, theParameters, theValues):
1088 * Apply a sequence of Shape Healing operators to the given object.
1089 * \param theShape Shape to be processed.
1090 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1091 * \param theParameters List of names of parameters
1092 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1093 * \param theValues List of values of parameters, in the same order
1094 * as parameters are listed in \a theParameters list.
1095 * \return New GEOM_Object, containing processed shape.
1097 * Example: see GEOM_TestHealing.py
1099 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1100 if HealOp.IsDone() == 0:
1101 print "ProcessShape : ", HealOp.GetErrorCode()
1104 def SuppressFaces(theObject, theFaces):
1106 * Remove faces from the given object (shape).
1107 * \param theObject Shape to be processed.
1108 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1109 * removes ALL faces of the given object.
1110 * \return New GEOM_Object, containing processed shape.
1112 * Example: see GEOM_TestHealing.py
1114 anObj = HealOp.SuppressFaces(theObject, theFaces)
1115 if HealOp.IsDone() == 0:
1116 print "SuppressFaces : ", HealOp.GetErrorCode()
1119 def MakeSewing(ListShape, theTolerance):
1121 * Sewing of some shapes into single shape.
1123 * Example: see GEOM_TestHealing.py
1125 comp = MakeCompound(ListShape)
1126 anObj = Sew(comp, theTolerance)
1129 def Sew(theObject, theTolerance):
1131 * Sewing of the given object.
1132 * \param theObject Shape to be processed.
1133 * \param theTolerance Required tolerance value.
1134 * \return New GEOM_Object, containing processed shape.
1136 * Example: see MakeSewing() above
1138 anObj = HealOp.Sew(theObject, theTolerance)
1139 if HealOp.IsDone() == 0:
1140 print "Sew : ", HealOp.GetErrorCode()
1143 def SuppressInternalWires(theObject, theWires):
1145 * Remove internal wires and edges from the given object (face).
1146 * \param theObject Shape to be processed.
1147 * \param theWires Indices of wires to be removed, if EMPTY then the method
1148 * removes ALL internal wires of the given object.
1149 * \return New GEOM_Object, containing processed shape.
1151 * Example: see GEOM_TestHealing.py
1153 anObj = HealOp.RemoveIntWires(theObject, theWires)
1154 if HealOp.IsDone() == 0:
1155 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1158 def SuppressHoles(theObject, theWires):
1160 * Remove internal closed contours (holes) from the given object.
1161 * \param theObject Shape to be processed.
1162 * \param theWires Indices of wires to be removed, if EMPTY then the method
1163 * removes ALL internal holes of the given object
1164 * \return New GEOM_Object, containing processed shape.
1166 * Example: see GEOM_TestHealing.py
1168 anObj = HealOp.FillHoles(theObject, theWires)
1169 if HealOp.IsDone() == 0:
1170 print "SuppressHoles : ", HealOp.GetErrorCode()
1173 def CloseContour(theObject, theWires, isCommonVertex):
1175 * Close an open wire.
1176 * \param theObject Shape to be processed.
1177 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1178 * if -1, then theObject itself is a wire.
1179 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1180 * If FALS : closure by creation of an edge between ends.
1181 * \return New GEOM_Object, containing processed shape.
1183 * Example: see GEOM_TestHealing.py
1185 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1186 if HealOp.IsDone() == 0:
1187 print "CloseContour : ", HealOp.GetErrorCode()
1190 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1192 * Addition of a point to a given edge object.
1193 * \param theObject Shape to be processed.
1194 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1195 * if -1, then theObject itself is the edge.
1196 * \param theValue Value of parameter on edge or length parameter,
1197 * depending on \a isByParameter.
1198 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1199 * if FALSE : \a theValue is treated as a length parameter [0..1]
1200 * \return New GEOM_Object, containing processed shape.
1202 * Example: see GEOM_TestHealing.py
1204 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1205 if HealOp.IsDone() == 0:
1206 print "DivideEdge : ", HealOp.GetErrorCode()
1209 def GetFreeBoundary(theObject):
1211 * Get a list of wires (wrapped in GEOM_Object-s),
1212 * that constitute a free boundary of the given shape.
1213 * \param theObject Shape to get free boundary of.
1214 * \return [status, theClosedWires, theOpenWires]
1215 * status: FALSE, if an error(s) occured during the method execution.
1216 * theClosedWires: Closed wires on the free boundary of the given shape.
1217 * theOpenWires: Open wires on the free boundary of the given shape.
1219 * Example: see GEOM_TestHealing.py
1221 anObj = HealOp.GetFreeBoundary(theObject)
1222 if HealOp.IsDone() == 0:
1223 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1226 # -----------------------------------------------------------------------------
1227 # Create advanced objects
1228 # -----------------------------------------------------------------------------
1230 def MakeCopy(theOriginal):
1232 * Create a copy of the given object
1234 * Example: see GEOM_TestAll.py
1236 anObj = InsertOp.MakeCopy(theOriginal)
1237 if InsertOp.IsDone() == 0:
1238 print "MakeCopy : ", InsertOp.GetErrorCode()
1241 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1243 * Create a filling from the given compound of contours.
1244 * \param theShape the compound of contours
1245 * \param theMinDeg a minimal degree
1246 * \param theMaxDeg a maximal degree
1247 * \param theTol2D a 2d tolerance
1248 * \param theTol3D a 3d tolerance
1249 * \param theNbIter a number of iteration
1250 * \return New GEOM_Object, containing the created filling surface.
1252 * Example: see GEOM_TestAll.py
1254 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1255 if PrimOp.IsDone() == 0:
1256 print "MakeFilling : ", PrimOp.GetErrorCode()
1259 def MakeGlueFaces(theShape, theTolerance):
1261 * Replace coincident faces in theShape by one face.
1262 * \param theShape Initial shape.
1263 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1264 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1266 * Example: see GEOM_Spanner.py
1268 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1269 if ShapesOp.IsDone() == 0:
1270 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1273 # -----------------------------------------------------------------------------
1274 # Boolean (Common, Cut, Fuse, Section)
1275 # -----------------------------------------------------------------------------
1277 def MakeBoolean(theShape1, theShape2, theOperation):
1279 * Perform one of boolean operations on two given shapes.
1280 * \param theShape1 First argument for boolean operation.
1281 * \param theShape2 Second argument for boolean operation.
1282 * \param theOperation Indicates the operation to be done:
1283 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1284 * \return New GEOM_Object, containing the result shape.
1286 * Example: see GEOM_TestAll.py
1288 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1289 if BoolOp.IsDone() == 0:
1290 print "MakeBoolean : ", BoolOp.GetErrorCode()
1293 def MakeCommon(s1, s2):
1295 * Shortcut to MakeBoolean(s1, s2, 1)
1297 * Example: see GEOM_TestOthers.py
1299 return MakeBoolean(s1, s2, 1)
1301 def MakeCut(s1, s2):
1303 * Shortcut to MakeBoolean(s1, s2, 2)
1305 * Example: see GEOM_TestOthers.py
1307 return MakeBoolean(s1, s2, 2)
1309 def MakeFuse(s1, s2):
1311 * Shortcut to MakeBoolean(s1, s2, 3)
1313 * Example: see GEOM_TestOthers.py
1315 return MakeBoolean(s1, s2, 3)
1317 def MakeSection(s1, s2):
1319 * Shortcut to MakeBoolean(s1, s2, 4)
1321 * Example: see GEOM_TestOthers.py
1323 return MakeBoolean(s1, s2, 4)
1325 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1326 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1328 * Perform partition operation.
1329 * \param ListShapes Shapes to be intersected.
1330 * \param ListTools Shapes to intersect theShapes.
1331 * \param ListKeepInside Shapes, outside which the results will be deleted.
1332 * Each shape from theKeepInside must belong to theShapes also.
1333 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1334 * Each shape from theRemoveInside must belong to theShapes also.
1335 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1336 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1337 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1338 * \return New GEOM_Object, containing the result shapes.
1340 * Example: see GEOM_TestAll.py
1342 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1343 ListKeepInside, ListRemoveInside,
1344 Limit, RemoveWebs, ListMaterials);
1345 if BoolOp.IsDone() == 0:
1346 print "MakePartition : ", BoolOp.GetErrorCode()
1349 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1350 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1352 * Shortcut to MakePartition()
1354 * Example: see GEOM_TestOthers.py
1356 anObj = MakePartition(ListShapes, ListTools,
1357 ListKeepInside, ListRemoveInside,
1358 Limit, RemoveWebs, ListMaterials);
1361 def MakeHalfPartition(theShape, thePlane):
1363 * Perform partition of the Shape with the Plane
1364 * \param theShape Shape to be intersected.
1365 * \param thePlane Tool shape, to intersect theShape.
1366 * \return New GEOM_Object, containing the result shape.
1368 * Example: see GEOM_TestAll.py
1370 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1371 if BoolOp.IsDone() == 0:
1372 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1375 # -----------------------------------------------------------------------------
1377 # -----------------------------------------------------------------------------
1379 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1381 * Translate the given object along the vector, specified
1382 * by its end points, creating its copy before the translation.
1383 * \param theObject The object to be translated.
1384 * \param thePoint1 Start point of translation vector.
1385 * \param thePoint2 End point of translation vector.
1386 * \return New GEOM_Object, containing the translated object.
1388 * Example: see GEOM_TestAll.py
1390 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1391 if TrsfOp.IsDone() == 0:
1392 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1395 def MakeTranslation(theObject, theDX, theDY, theDZ):
1397 * Translate the given object along the vector, specified
1398 * by its components, creating its copy before the translation.
1399 * \param theObject The object to be translated.
1400 * \param theDX,theDY,theDZ Components of translation vector.
1401 * \return New GEOM_Object, containing the translated object.
1403 * Example: see GEOM_TestAll.py
1405 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1406 if TrsfOp.IsDone() == 0:
1407 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1410 def MakeTranslationVector(theObject, theVector):
1412 * Translate the given object along the given vector,
1413 * creating its copy before the translation.
1414 * \param theObject The object to be translated.
1415 * \param theVector The translation vector.
1416 * \return New GEOM_Object, containing the translated object.
1418 * Example: see GEOM_TestAll.py
1420 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1421 if TrsfOp.IsDone() == 0:
1422 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1425 def MakeRotation(theObject, theAxis, theAngle):
1427 * Rotate the given object around the given axis
1428 * on the given angle, creating its copy before the rotatation.
1429 * \param theObject The object to be rotated.
1430 * \param theAxis Rotation axis.
1431 * \param theAngle Rotation angle in radians.
1432 * \return New GEOM_Object, containing the rotated object.
1434 * Example: see GEOM_TestAll.py
1436 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1437 if TrsfOp.IsDone() == 0:
1438 print "RotateCopy : ", TrsfOp.GetErrorCode()
1441 def MakeScaleTransform(theObject, thePoint, theFactor):
1443 * Scale the given object by the factor, creating its copy before the scaling.
1444 * \param theObject The object to be scaled.
1445 * \param thePoint Center point for scaling.
1446 * \param theFactor Scaling factor value.
1447 * \return New GEOM_Object, containing the scaled shape.
1449 * Example: see GEOM_TestAll.py
1451 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1452 if TrsfOp.IsDone() == 0:
1453 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1456 def MakeMirrorByPlane(theObject, thePlane):
1458 * Create an object, symmetrical
1459 * to the given one relatively the given plane.
1460 * \param theObject The object to be mirrored.
1461 * \param thePlane Plane of symmetry.
1462 * \return New GEOM_Object, containing the mirrored shape.
1464 * Example: see GEOM_TestAll.py
1466 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1467 if TrsfOp.IsDone() == 0:
1468 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1471 def MakeMirrorByAxis(theObject, theAxis):
1473 * Create an object, symmetrical
1474 * to the given one relatively the given axis.
1475 * \param theObject The object to be mirrored.
1476 * \param theAxis Axis of symmetry.
1477 * \return New GEOM_Object, containing the mirrored shape.
1479 * Example: see GEOM_TestAll.py
1481 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1482 if TrsfOp.IsDone() == 0:
1483 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1486 def MakeMirrorByPoint(theObject, thePoint):
1488 * Create an object, symmetrical
1489 * to the given one relatively the given point.
1490 * \param theObject The object to be mirrored.
1491 * \param thePoint Point of symmetry.
1492 * \return New GEOM_Object, containing the mirrored shape.
1494 * Example: see GEOM_TestAll.py
1496 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1497 if TrsfOp.IsDone() == 0:
1498 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1501 def MakePosition(theObject, theStartLCS, theEndLCS):
1503 * Modify the Location of the given object by LCS
1504 * creating its copy before the setting
1506 * Example: see GEOM_TestAll.py
1508 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1509 if TrsfOp.IsDone() == 0:
1510 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1513 def MakeOffset(theObject, theOffset):
1515 * Create new object as offset of the given one.
1516 * \param theObject The base object for the offset.
1517 * \param theOffset Offset value.
1518 * \return New GEOM_Object, containing the offset object.
1520 * Example: see GEOM_TestAll.py
1522 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1523 if TrsfOp.IsDone() == 0:
1524 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1527 # -----------------------------------------------------------------------------
1529 # -----------------------------------------------------------------------------
1531 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1533 * Translate the given object along the given vector a given number times
1534 * \param theObject The object to be translated.
1535 * \param theVector Direction of the translation.
1536 * \param theStep Distance to translate on.
1537 * \param theNbTimes Quantity of translations to be done.
1538 * \return New GEOM_Object, containing compound of all
1539 * the shapes, obtained after each translation.
1541 * Example: see GEOM_TestAll.py
1543 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1544 if TrsfOp.IsDone() == 0:
1545 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1548 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1549 theVector2, theStep2, theNbTimes2):
1551 * Conseqently apply two specified translations to theObject specified number of times.
1552 * \param theObject The object to be translated.
1553 * \param theVector1 Direction of the first translation.
1554 * \param theStep1 Step of the first translation.
1555 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1556 * \param theVector2 Direction of the second translation.
1557 * \param theStep2 Step of the second translation.
1558 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1559 * \return New GEOM_Object, containing compound of all
1560 * the shapes, obtained after each translation.
1562 * Example: see GEOM_TestAll.py
1564 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1565 theVector2, theStep2, theNbTimes2)
1566 if TrsfOp.IsDone() == 0:
1567 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1570 def MultiRotate1D(theObject, theAxis, theNbTimes):
1572 * Rotate the given object around the given axis a given number times.
1573 * Rotation angle will be 2*PI/theNbTimes.
1574 * \param theObject The object to be rotated.
1575 * \param theAxis The rotation axis.
1576 * \param theNbTimes Quantity of rotations to be done.
1577 * \return New GEOM_Object, containing compound of all the
1578 * shapes, obtained after each rotation.
1580 * Example: see GEOM_TestAll.py
1582 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1583 if TrsfOp.IsDone() == 0:
1584 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1587 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1589 * Rotate the given object around the
1590 * given axis on the given angle a given number
1591 * times and multi-translate each rotation result.
1592 * Translation direction passes through center of gravity
1593 * of rotated shape and its projection on the rotation axis.
1594 * \param theObject The object to be rotated.
1595 * \param theAxis Rotation axis.
1596 * \param theAngle Rotation angle in graduces.
1597 * \param theNbTimes1 Quantity of rotations to be done.
1598 * \param theStep Translation distance.
1599 * \param theNbTimes2 Quantity of translations to be done.
1600 * \return New GEOM_Object, containing compound of all the
1601 * shapes, obtained after each transformation.
1603 * Example: see GEOM_TestAll.py
1605 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1606 if TrsfOp.IsDone() == 0:
1607 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1610 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1612 * The same, as MultiRotate1D(), but axis is given by direction and point
1614 * Example: see GEOM_TestOthers.py
1616 aVec = MakeLine(aPoint,aDir)
1617 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1620 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1622 * The same, as MultiRotate2D(), but axis is given by direction and point
1624 * Example: see GEOM_TestOthers.py
1626 aVec = MakeLine(aPoint,aDir)
1627 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1630 # -----------------------------------------------------------------------------
1632 # -----------------------------------------------------------------------------
1634 def MakeFilletAll(theShape, theR):
1636 * Perform a fillet on all edges of the given shape.
1637 * \param theShape Shape, to perform fillet on.
1638 * \param theR Fillet radius.
1639 * \return New GEOM_Object, containing the result shape.
1641 * Example: see GEOM_TestOthers.py
1643 anObj = LocalOp.MakeFilletAll(theShape, theR)
1644 if LocalOp.IsDone() == 0:
1645 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1648 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1650 * Perform a fillet on the specified edges/faces of the given shape
1651 * \param theShape Shape, to perform fillet on.
1652 * \param theR Fillet radius.
1653 * \param theShapeType Type of shapes in <theListShapes>.
1654 * \param theListShapes Global indices of edges/faces to perform fillet on.
1655 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1656 * \return New GEOM_Object, containing the result shape.
1658 * Example: see GEOM_TestAll.py
1661 if theShapeType == ShapeType["EDGE"]:
1662 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1664 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1665 if LocalOp.IsDone() == 0:
1666 print "MakeFillet : ", LocalOp.GetErrorCode()
1669 def MakeChamferAll(theShape, theD):
1671 * Perform a symmetric chamfer on all edges of the given shape.
1672 * \param theShape Shape, to perform chamfer on.
1673 * \param theD Chamfer size along each face.
1674 * \return New GEOM_Object, containing the result shape.
1676 * Example: see GEOM_TestOthers.py
1678 anObj = LocalOp.MakeChamferAll(theShape, theD)
1679 if LocalOp.IsDone() == 0:
1680 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1683 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1685 * Perform a chamfer on edges, common to the specified faces,
1686 * with distance D1 on the Face1
1687 * \param theShape Shape, to perform chamfer on.
1688 * \param theD1 Chamfer size along \a theFace1.
1689 * \param theD2 Chamfer size along \a theFace2.
1690 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1691 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1692 * \return New GEOM_Object, containing the result shape.
1694 * Example: see GEOM_TestAll.py
1696 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1697 if LocalOp.IsDone() == 0:
1698 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1701 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1703 * Perform a chamfer on all edges of the specified faces,
1704 * with distance D1 on the first specified face (if several for one edge)
1705 * \param theShape Shape, to perform chamfer on.
1706 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1707 * connected to the edge, are in \a theFaces, \a theD1
1708 * will be get along face, which is nearer to \a theFaces beginning.
1709 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1710 * \param theFaces Sequence of global indices of faces of \a theShape.
1711 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1712 * \return New GEOM_Object, containing the result shape.
1714 * Example: see GEOM_TestAll.py
1716 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1717 if LocalOp.IsDone() == 0:
1718 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1721 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1723 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1725 * Example: see GEOM_TestOthers.py
1728 if aShapeType == ShapeType["EDGE"]:
1729 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1731 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1734 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1736 * Perform an Archimde operation on the given shape with given parameters.
1737 * The object presenting the resulting face is returned
1738 * \param theShape Shape to be put in water.
1739 * \param theWeight Weight og the shape.
1740 * \param theWaterDensity Density of the water.
1741 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1742 * \return New GEOM_Object, containing a section of \a theShape
1743 * by a plane, corresponding to water level.
1745 * Example: see GEOM_TestAll.py
1747 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1748 if LocalOp.IsDone() == 0:
1749 print "MakeArchimede : ", LocalOp.GetErrorCode()
1752 # -----------------------------------------------------------------------------
1753 # Information objects
1754 # -----------------------------------------------------------------------------
1756 def PointCoordinates(Point):
1758 * Get point coordinates
1761 * Example: see GEOM_TestMeasures.py
1763 aTuple = MeasuOp.PointCoordinates(Point)
1764 if MeasuOp.IsDone() == 0:
1765 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1768 def BasicProperties(theShape):
1770 * Get summarized length of all wires,
1771 * area of surface and volume of the given shape.
1772 * \param theShape Shape to define properties of.
1773 * \return [theLength, theSurfArea, theVolume]
1774 * theLength: Summarized length of all wires of the given shape.
1775 * theSurfArea: Area of surface of the given shape.
1776 * theVolume: Volume of the given shape.
1778 * Example: see GEOM_TestMeasures.py
1780 aTuple = MeasuOp.GetBasicProperties(theShape)
1781 if MeasuOp.IsDone() == 0:
1782 print "BasicProperties : ", MeasuOp.GetErrorCode()
1785 def BoundingBox(theShape):
1787 * Get parameters of bounding box of the given shape
1788 * \param theShape Shape to obtain bounding box of.
1789 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1790 * Xmin,Xmax: Limits of shape along OX axis.
1791 * Ymin,Ymax: Limits of shape along OY axis.
1792 * Zmin,Zmax: Limits of shape along OZ axis.
1794 * Example: see GEOM_TestMeasures.py
1796 aTuple = MeasuOp.GetBoundingBox(theShape)
1797 if MeasuOp.IsDone() == 0:
1798 print "BoundingBox : ", MeasuOp.GetErrorCode()
1801 def Inertia(theShape):
1803 * Get inertia matrix and moments of inertia of theShape.
1804 * \param theShape Shape to calculate inertia of.
1805 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1806 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1807 * Ix,Iy,Iz: Moments of inertia of the given shape.
1809 * Example: see GEOM_TestMeasures.py
1811 aTuple = MeasuOp.GetInertia(theShape)
1812 if MeasuOp.IsDone() == 0:
1813 print "Inertia : ", MeasuOp.GetErrorCode()
1816 def MinDistance(theShape1, theShape2):
1818 * Get minimal distance between the given shapes.
1819 * \param theShape1,theShape2 Shapes to find minimal distance between.
1820 * \return Value of the minimal distance between the given shapes.
1822 * Example: see GEOM_TestMeasures.py
1824 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1825 if MeasuOp.IsDone() == 0:
1826 print "MinDistance : ", MeasuOp.GetErrorCode()
1829 def Tolerance(theShape):
1831 * Get min and max tolerances of sub-shapes of theShape
1832 * \param theShape Shape, to get tolerances of.
1833 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1834 * FaceMin,FaceMax: Min and max tolerances of the faces.
1835 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1836 * VertMin,VertMax: Min and max tolerances of the vertices.
1838 * Example: see GEOM_TestMeasures.py
1840 aTuple = MeasuOp.GetTolerance(theShape)
1841 if MeasuOp.IsDone() == 0:
1842 print "Tolerance : ", MeasuOp.GetErrorCode()
1845 def WhatIs(theShape):
1847 * Obtain description of the given shape (number of sub-shapes of each type)
1848 * \param theShape Shape to be described.
1849 * \return Description of the given shape.
1851 * Example: see GEOM_TestMeasures.py
1853 aDescr = MeasuOp.WhatIs(theShape)
1854 if MeasuOp.IsDone() == 0:
1855 print "WhatIs : ", MeasuOp.GetErrorCode()
1858 def MakeCDG(theShape):
1860 * Get a point, situated at the centre of mass of theShape.
1861 * \param theShape Shape to define centre of mass of.
1862 * \return New GEOM_Object, containing the created point.
1864 * Example: see GEOM_TestMeasures.py
1866 anObj = MeasuOp.GetCentreOfMass(theShape)
1867 if MeasuOp.IsDone() == 0:
1868 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1871 def CheckShape(theShape):
1873 * Check a topology of the given shape.
1874 * \param theShape Shape to check validity of.
1875 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1876 * If theShape is invalid, prints a description of problem.
1878 * Example: see GEOM_TestMeasures.py
1880 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1881 if MeasuOp.IsDone() == 0:
1882 print "CheckShape : ", MeasuOp.GetErrorCode()
1888 # -----------------------------------------------------------------------------
1889 # Import/Export objects
1890 # -----------------------------------------------------------------------------
1892 def Import(theFileName, theFormatName):
1894 * Import a shape from the BREP or IGES or STEP file
1895 * (depends on given format) with given name.
1896 * \param theFileName The file, containing the shape.
1897 * \param theFormatName Specify format for the file reading.
1898 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1899 * \return New GEOM_Object, containing the imported shape.
1901 * Example: see GEOM_TestOthers.py
1903 anObj = InsertOp.Import(theFileName, theFormatName)
1904 if InsertOp.IsDone() == 0:
1905 print "Import : ", InsertOp.GetErrorCode()
1908 def ImportBREP(theFileName):
1910 * Shortcut to Import() for BREP format
1912 * Example: see GEOM_TestOthers.py
1914 return Import(theFileName, "BREP")
1916 def ImportIGES(theFileName):
1918 * Shortcut to Import() for IGES format
1920 * Example: see GEOM_TestOthers.py
1922 return Import(theFileName, "IGES")
1924 def ImportSTEP(theFileName):
1926 * Shortcut to Import() for STEP format
1928 * Example: see GEOM_TestOthers.py
1930 return Import(theFileName, "STEP")
1932 def Export(theObject, theFileName, theFormatName):
1934 * Export the given shape into a file with given name.
1935 * \param theObject Shape to be stored in the file.
1936 * \param theFileName Name of the file to store the given shape in.
1937 * \param theFormatName Specify format for the shape storage.
1938 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1940 * Example: see GEOM_TestOthers.py
1942 InsertOp.Export(theObject, theFileName, theFormatName)
1943 if InsertOp.IsDone() == 0:
1944 print "Export : ", InsertOp.GetErrorCode()
1946 def ExportBREP(theObject, theFileName):
1948 * Shortcut to Export() for BREP format
1950 * Example: see GEOM_TestOthers.py
1952 return Export(theObject, theFileName, "BREP")
1954 def ExportIGES(theObject, theFileName):
1956 * Shortcut to Export() for IGES format
1958 * Example: see GEOM_TestOthers.py
1960 return Export(theObject, theFileName, "IGES")
1962 def ExportSTEP(theObject, theFileName):
1964 * Shortcut to Export() for STEP format
1966 * Example: see GEOM_TestOthers.py
1968 return Export(theObject, theFileName, "STEP")
1970 # -----------------------------------------------------------------------------
1972 # -----------------------------------------------------------------------------
1974 def MakeQuad(E1, E2, E3, E4):
1976 * Create a quadrangle face from four edges. Order of Edges is not
1977 * important. It is not necessary that edges share the same vertex.
1978 * \param E1,E2,E3,E4 Edges for the face bound.
1979 * \return New GEOM_Object, containing the created face.
1981 * Example: see GEOM_Spanner.py
1983 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1984 if BlocksOp.IsDone() == 0:
1985 print "MakeQuad : ", BlocksOp.GetErrorCode()
1988 def MakeQuad2Edges(E1, E2):
1990 * Create a quadrangle face on two edges.
1991 * The missing edges will be built by creating the shortest ones.
1992 * \param E1,E2 Two opposite edges for the face.
1993 * \return New GEOM_Object, containing the created face.
1995 * Example: see GEOM_Spanner.py
1997 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
1998 if BlocksOp.IsDone() == 0:
1999 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2002 def MakeQuad4Vertices(V1, V2, V3, V4):
2004 * Create a quadrangle face with specified corners.
2005 * The missing edges will be built by creating the shortest ones.
2006 * \param V1,V2,V3,V4 Corner vertices for the face.
2007 * \return New GEOM_Object, containing the created face.
2009 * Example: see GEOM_Spanner.py
2011 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2012 if BlocksOp.IsDone() == 0:
2013 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2016 def MakeHexa(F1, F2, F3, F4, F5, F6):
2018 * Create a hexahedral solid, bounded by the six given faces. Order of
2019 * faces is not important. It is not necessary that Faces share the same edge.
2020 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2021 * \return New GEOM_Object, containing the created solid.
2023 * Example: see GEOM_Spanner.py
2025 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2026 if BlocksOp.IsDone() == 0:
2027 print "MakeHexa : ", BlocksOp.GetErrorCode()
2030 def MakeHexa2Faces(F1, F2):
2032 * Create a hexahedral solid between two given faces.
2033 * The missing faces will be built by creating the smallest ones.
2034 * \param F1,F2 Two opposite faces for the hexahedral solid.
2035 * \return New GEOM_Object, containing the created solid.
2037 * Example: see GEOM_Spanner.py
2039 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2040 if BlocksOp.IsDone() == 0:
2041 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2044 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2046 * Get a vertex, found in the given shape by its coordinates.
2047 * \param theShape Block or a compound of blocks.
2048 * \param theX,theY,theZ Coordinates of the sought vertex.
2049 * \param theEpsilon Maximum allowed distance between the resulting
2050 * vertex and point with the given coordinates.
2051 * \return New GEOM_Object, containing the found vertex.
2053 * Example: see GEOM_TestOthers.py
2055 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2056 if BlocksOp.IsDone() == 0:
2057 print "GetPoint : ", BlocksOp.GetErrorCode()
2060 def GetEdge(theShape, thePoint1, thePoint2):
2062 * Get an edge, found in the given shape by two given vertices.
2063 * \param theShape Block or a compound of blocks.
2064 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2065 * \return New GEOM_Object, containing the found edge.
2067 * Example: see GEOM_Spanner.py
2069 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2070 if BlocksOp.IsDone() == 0:
2071 print "GetEdge : ", BlocksOp.GetErrorCode()
2074 def GetEdgeNearPoint(theShape, thePoint):
2076 * Find an edge of the given shape, which has minimal distance to the given point.
2077 * \param theShape Block or a compound of blocks.
2078 * \param thePoint Point, close to the desired edge.
2079 * \return New GEOM_Object, containing the found edge.
2081 * Example: see GEOM_TestOthers.py
2083 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2084 if BlocksOp.IsDone() == 0:
2085 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2088 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2090 * Returns a face, found in the given shape by four given corner vertices.
2091 * \param theShape Block or a compound of blocks.
2092 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2093 * \return New GEOM_Object, containing the found face.
2095 * Example: see GEOM_Spanner.py
2097 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2098 if BlocksOp.IsDone() == 0:
2099 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2102 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2104 * Get a face of block, found in the given shape by two given edges.
2105 * \param theShape Block or a compound of blocks.
2106 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2107 * \return New GEOM_Object, containing the found face.
2109 * Example: see GEOM_Spanner.py
2111 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2112 if BlocksOp.IsDone() == 0:
2113 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2116 def GetOppositeFace(theBlock, theFace):
2118 * Find a face, opposite to the given one in the given block.
2119 * \param theBlock Must be a hexahedral solid.
2120 * \param theFace Face of \a theBlock, opposite to the desired face.
2121 * \return New GEOM_Object, containing the found face.
2123 * Example: see GEOM_Spanner.py
2125 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2126 if BlocksOp.IsDone() == 0:
2127 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2130 def GetFaceNearPoint(theShape, thePoint):
2132 * Find a face of the given shape, which has minimal distance to the given point.
2133 * \param theShape Block or a compound of blocks.
2134 * \param thePoint Point, close to the desired face.
2135 * \return New GEOM_Object, containing the found face.
2137 * Example: see GEOM_Spanner.py
2139 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2140 if BlocksOp.IsDone() == 0:
2141 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2144 def GetFaceByNormale(theBlock, theVector):
2146 * Find a face of block, whose outside normale has minimal angle with the given vector.
2147 * \param theShape Block or a compound of blocks.
2148 * \param theVector Vector, close to the normale of the desired face.
2149 * \return New GEOM_Object, containing the found face.
2151 * Example: see GEOM_Spanner.py
2153 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2154 if BlocksOp.IsDone() == 0:
2155 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2158 def CheckCompoundOfBlocks(theCompound):
2160 * Check, if the compound of blocks is given.
2161 * To be considered as a compound of blocks, the
2162 * given shape must satisfy the following conditions:
2163 * - Each element of the compound should be a Block (6 faces and 12 edges).
2164 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2165 * - The compound should be connexe.
2166 * - The glue between two quadrangle faces should be applied.
2167 * \param theCompound The compound to check.
2168 * \return TRUE, if the given shape is a compound of blocks.
2169 * If theCompound is not valid, prints all discovered errors.
2171 * Example: see GEOM_Spanner.py
2173 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2174 if BlocksOp.IsDone() == 0:
2175 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2178 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2182 def RemoveExtraEdges(theShape):
2184 * Remove all seam and degenerated edges from \a theShape.
2185 * Unite faces and edges, sharing one surface.
2186 * \param theShape The compound or single solid to remove irregular edges from.
2187 * \return Improved shape.
2189 * Example: see GEOM_TestOthers.py
2191 anObj = BlocksOp.RemoveExtraEdges(theShape)
2192 if BlocksOp.IsDone() == 0:
2193 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2196 def CheckAndImprove(theShape):
2198 * Check, if the given shape is a blocks compound.
2199 * Fix all detected errors.
2200 * \note Single block can be also fixed by this method.
2201 * \param theCompound The compound to check and improve.
2202 * \return Improved compound.
2204 * Example: see GEOM_TestOthers.py
2206 anObj = BlocksOp.CheckAndImprove(theShape)
2207 if BlocksOp.IsDone() == 0:
2208 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2211 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2213 * Get all the blocks, contained in the given compound.
2214 * \param theCompound The compound to explode.
2215 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2216 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2217 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2218 * \return List of GEOM_Objects, containing the retrieved blocks.
2220 * Example: see GEOM_TestOthers.py
2222 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2223 if BlocksOp.IsDone() == 0:
2224 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2227 def GetBlockNearPoint(theCompound, thePoint):
2229 * Find block, containing the given point inside its volume or on boundary.
2230 * \param theCompound Compound, to find block in.
2231 * \param thePoint Point, close to the desired block. If the point lays on
2232 * boundary between some blocks, we return block with nearest center.
2233 * \return New GEOM_Object, containing the found block.
2235 * Example: see GEOM_Spanner.py
2237 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2238 if BlocksOp.IsDone() == 0:
2239 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2242 def GetBlockByParts(theCompound, theParts):
2244 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2245 * \param theCompound Compound, to find block in.
2246 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2247 * \return New GEOM_Object, containing the found block.
2249 * Example: see GEOM_TestOthers.py
2251 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2252 if BlocksOp.IsDone() == 0:
2253 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2256 def GetBlocksByParts(theCompound, theParts):
2258 * Return all blocks, containing all the elements, passed as the parts.
2259 * \param theCompound Compound, to find blocks in.
2260 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2261 * \return List of GEOM_Objects, containing the found blocks.
2263 * Example: see GEOM_Spanner.py
2265 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2266 if BlocksOp.IsDone() == 0:
2267 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2270 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2272 * Multi-transformate block and glue the result.
2273 * Transformation is defined so, as to superpose direction faces.
2274 * \param Block Hexahedral solid to be multi-transformed.
2275 * \param DirFace1 ID of First direction face.
2276 * \param DirFace2 ID of Second direction face.
2277 * \param NbTimes Quantity of transformations to be done.
2278 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2279 * \return New GEOM_Object, containing the result shape.
2281 * Example: see GEOM_Spanner.py
2283 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2284 if BlocksOp.IsDone() == 0:
2285 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2288 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2289 DirFace1V, DirFace2V, NbTimesV):
2291 * Multi-transformate block and glue the result.
2292 * \param Block Hexahedral solid to be multi-transformed.
2293 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2294 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2295 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2296 * \return New GEOM_Object, containing the result shape.
2298 * Example: see GEOM_Spanner.py
2300 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2301 DirFace1V, DirFace2V, NbTimesV)
2302 if BlocksOp.IsDone() == 0:
2303 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2306 def Propagate(theShape):
2308 * Build all possible propagation groups.
2309 * Propagation group is a set of all edges, opposite to one (main)
2310 * edge of this group directly or through other opposite edges.
2311 * Notion of Opposite Edge make sence only on quadrangle face.
2312 * \param theShape Shape to build propagation groups on.
2313 * \return List of GEOM_Objects, each of them is a propagation group.
2315 * Example: see GEOM_TestOthers.py
2317 listChains = BlocksOp.Propagate(theShape)
2318 if BlocksOp.IsDone() == 0:
2319 print "Propagate : ", BlocksOp.GetErrorCode()
2322 # -----------------------------------------------------------------------------
2324 # -----------------------------------------------------------------------------
2326 def CreateGroup(theMainShape, theShapeType):
2328 * Creates a new group which will store sub shapes of theMainShape
2329 * \param theMainShape is a GEOM object on which the group is selected
2330 * \param theShapeType defines a shape type of the group
2331 * \return a newly created GEOM group
2333 * Example: see GEOM_TestOthers.py
2335 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2336 if GroupOp.IsDone() == 0:
2337 print "CreateGroup : ", GroupOp.GetErrorCode()
2340 def AddObject(theGroup, theSubShapeID):
2342 * Adds a sub object with ID theSubShapeId to the group
2343 * \param theGroup is a GEOM group to which the new sub shape is added
2344 * \param theSubShapeID is a sub shape ID in the main object.
2345 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2347 * Example: see GEOM_TestOthers.py
2349 GroupOp.AddObject(theGroup, theSubShapeID)
2350 if GroupOp.IsDone() == 0:
2351 print "AddObject : ", GroupOp.GetErrorCode()
2353 def RemoveObject(theGroup, theSubShapeID):
2355 * Removes a sub object with ID \a theSubShapeId from the group
2356 * \param theGroup is a GEOM group from which the new sub shape is removed
2357 * \param theSubShapeID is a sub shape ID in the main object.
2358 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2360 * Example: see GEOM_TestOthers.py
2362 GroupOp.RemoveObject(theGroup, theSubShapeID)
2363 if GroupOp.IsDone() == 0:
2364 print "RemoveObject : ", GroupOp.GetErrorCode()
2366 def UnionList (theGroup, theSubShapes):
2368 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2369 * \param theGroup is a GEOM group to which the new sub shapes are added.
2370 * \param theSubShapes is a list of sub shapes to be added.
2372 * Example: see GEOM_TestOthers.py
2374 GroupOp.UnionList(theGroup, theSubShapes)
2375 if GroupOp.IsDone() == 0:
2376 print "UnionList : ", GroupOp.GetErrorCode()
2378 def DifferenceList (theGroup, theSubShapes):
2380 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2381 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2382 * \param theSubShapes is a list of sub-shapes to be removed.
2384 * Example: see GEOM_TestOthers.py
2386 GroupOp.DifferenceList(theGroup, theSubShapes)
2387 if GroupOp.IsDone() == 0:
2388 print "DifferenceList : ", GroupOp.GetErrorCode()
2390 def GetObjectIDs(theGroup):
2392 * Returns a list of sub objects ID stored in the group
2393 * \param theGroup is a GEOM group for which a list of IDs is requested
2395 * Example: see GEOM_TestOthers.py
2397 ListIDs = GroupOp.GetObjects(theGroup)
2398 if GroupOp.IsDone() == 0:
2399 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2402 def GetType(theGroup):
2404 * Returns a type of sub objects stored in the group
2405 * \param theGroup is a GEOM group which type is returned.
2407 * Example: see GEOM_TestOthers.py
2409 aType = GroupOp.GetType(theGroup)
2410 if GroupOp.IsDone() == 0:
2411 print "GetType : ", GroupOp.GetErrorCode()
2414 def GetMainShape(theGroup):
2416 * Returns a main shape associated with the group
2417 * \param theGroup is a GEOM group for which a main shape object is requested
2418 * \return a GEOM object which is a main shape for theGroup
2420 * Example: see GEOM_TestOthers.py
2422 anObj = GroupOp.GetMainShape(theGroup)
2423 if GroupOp.IsDone() == 0:
2424 print "GetMainShape : ", GroupOp.GetErrorCode()
2427 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2429 Create group of edges of theShape, whose length is in range [min_length, max_length].
2430 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2433 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2436 Props = BasicProperties(edge)
2437 if min_length <= Props[0] and Props[0] <= max_length:
2438 if (not include_min) and (min_length == Props[0]):
2441 if (not include_max) and (Props[0] == max_length):
2444 edges_in_range.append(edge)
2446 if len(edges_in_range) <= 0:
2447 print "No edges found by given criteria"
2450 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2451 UnionList(group_edges, edges_in_range)
2455 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2457 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2458 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2461 nb_selected = sg.SelectedCount()
2463 print "Select a shape before calling this function, please."
2466 print "Only one shape must be selected"
2469 id_shape = sg.getSelected(0)
2470 shape = IDToObject( id_shape )
2472 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2476 if include_min: left_str = " <= "
2477 if include_max: right_str = " <= "
2479 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2480 + left_str + "length" + right_str + `max_length`)
2482 sg.updateObjBrowser(1)
2488 * Add Path to load python scripts from
2490 if (sys.path.count(Path) < 1):
2491 sys.path.append(Path)