1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 # Author : Paul RASCLE, EDF
37 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 geom = g._narrow( GEOM.GEOM_Gen )
39 myBuilder = myStudy.NewBuilder()
41 father = myStudy.FindComponent("GEOM")
43 father = myBuilder.NewComponent("GEOM")
44 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
45 FName = A1._narrow(SALOMEDS.AttributeName)
46 FName.SetValue("Geometry")
47 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
48 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
49 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
50 myBuilder.DefineComponentInstance(father,geom)
52 gg = ImportComponentGUI("GEOM")
54 def SubShapeName(aSubObj, aMainObj):
56 * Get name for sub-shape aSubObj of shape aMainObj
58 * Example: see GEOM_TestAll.py
60 aSubId = orb.object_to_string(aSubObj)
61 aMainId = orb.object_to_string(aMainObj)
62 index = gg.getIndexTopology(aSubId, aMainId)
63 name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
66 def addToStudy(aShape, aName):
68 * Publish in study aShape with name aName
70 * Example: see GEOM_TestAll.py
73 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
75 print "addToStudy() failed"
77 return aShape.GetStudyEntry()
79 def addToStudyInFather(aFather, aShape, aName):
81 * Publish in study aShape with name aName as sub-object of previously published aFather
83 * Example: see GEOM_TestAll.py
86 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
88 print "addToStudyInFather() failed"
90 return aShape.GetStudyEntry()
92 # -----------------------------------------------------------------------------
93 # enumeration ShapeType as a dictionary
94 # -----------------------------------------------------------------------------
96 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
98 # -----------------------------------------------------------------------------
99 # Get Operations Interfaces
100 # -----------------------------------------------------------------------------
102 BasicOp = geom.GetIBasicOperations (myStudyId)
103 CurvesOp = geom.GetICurvesOperations (myStudyId)
104 PrimOp = geom.GetI3DPrimOperations (myStudyId)
105 ShapesOp = geom.GetIShapesOperations (myStudyId)
106 HealOp = geom.GetIHealingOperations (myStudyId)
107 InsertOp = geom.GetIInsertOperations (myStudyId)
108 BoolOp = geom.GetIBooleanOperations (myStudyId)
109 TrsfOp = geom.GetITransformOperations(myStudyId)
110 LocalOp = geom.GetILocalOperations (myStudyId)
111 MeasuOp = geom.GetIMeasureOperations (myStudyId)
112 BlocksOp = geom.GetIBlocksOperations (myStudyId)
113 GroupOp = geom.GetIGroupOperations (myStudyId)
115 # -----------------------------------------------------------------------------
117 # -----------------------------------------------------------------------------
119 def MakeVertex(theX, theY, theZ):
121 * Create point by three coordinates.
122 * \param theX The X coordinate of the point.
123 * \param theY The Y coordinate of the point.
124 * \param theZ The Z coordinate of the point.
125 * \return New GEOM_Object, containing the created point.
127 * Example: see GEOM_TestAll.py
129 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
130 if BasicOp.IsDone() == 0:
131 print "MakePointXYZ : ", BasicOp.GetErrorCode()
134 def MakeVertexWithRef(theReference, theX, theY, theZ):
136 * Create a point, distant from the referenced point
137 * on the given distances along the coordinate axes.
138 * \param theReference The referenced point.
139 * \param theX Displacement from the referenced point along OX axis.
140 * \param theY Displacement from the referenced point along OY axis.
141 * \param theZ Displacement from the referenced point along OZ axis.
142 * \return New GEOM_Object, containing the created point.
144 * Example: see GEOM_TestAll.py
146 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
147 if BasicOp.IsDone() == 0:
148 print "MakePointWithReference : ", BasicOp.GetErrorCode()
151 def MakeVertexOnCurve(theRefCurve, theParameter):
153 * Create a point, corresponding to the given parameter on the given curve.
154 * \param theRefCurve The referenced curve.
155 * \param theParameter Value of parameter on the referenced curve.
156 * \return New GEOM_Object, containing the created point.
158 * Example: see GEOM_TestAll.py
160 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
161 if BasicOp.IsDone() == 0:
162 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
165 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
167 * Create a vector with the given components.
168 * \param theDX X component of the vector.
169 * \param theDY Y component of the vector.
170 * \param theDZ Z component of the vector.
171 * \return New GEOM_Object, containing the created vector.
173 * Example: see GEOM_TestAll.py
175 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
176 if BasicOp.IsDone() == 0:
177 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
180 def MakeVector(thePnt1, thePnt2):
182 * Create a vector between two points.
183 * \param thePnt1 Start point for the vector.
184 * \param thePnt2 End point for the vector.
185 * \return New GEOM_Object, containing the created vector.
187 * Example: see GEOM_TestAll.py
189 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
190 if BasicOp.IsDone() == 0:
191 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
194 def MakeLine(thePnt, theDir):
196 * Create a line, passing through the given point
197 * and parrallel to the given direction
198 * \param thePnt Point. The resulting line will pass through it.
199 * \param theDir Direction. The resulting line will be parallel to it.
200 * \return New GEOM_Object, containing the created line.
202 * Example: see GEOM_TestAll.py
204 anObj = BasicOp.MakeLine(thePnt, theDir)
205 if BasicOp.IsDone() == 0:
206 print "MakeLine : ", BasicOp.GetErrorCode()
209 def MakeLineTwoPnt(thePnt1, thePnt2):
211 * Create a line, passing through the given points
212 * \param thePnt1 First of two points, defining the line.
213 * \param thePnt2 Second of two points, defining the line.
214 * \return New GEOM_Object, containing the created line.
216 * Example: see GEOM_TestAll.py
218 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
219 if BasicOp.IsDone() == 0:
220 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
223 def MakePlane(thePnt, theVec, theTrimSize):
225 * Create a plane, passing through the given point
226 * and normal to the given vector.
227 * \param thePnt Point, the plane has to pass through.
228 * \param theVec Vector, defining the plane normal direction.
229 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
230 * \return New GEOM_Object, containing the created plane.
232 * Example: see GEOM_TestAll.py
234 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
235 if BasicOp.IsDone() == 0:
236 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
239 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
241 * Create a plane, passing through the three given points
242 * \param thePnt1 First of three points, defining the plane.
243 * \param thePnt2 Second of three points, defining the plane.
244 * \param thePnt3 Fird of three points, defining the plane.
245 * \param theTrimSize Half size of a side of quadrangle face, representing the plane.
246 * \return New GEOM_Object, containing the created plane.
248 * Example: see GEOM_TestAll.py
250 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
251 if BasicOp.IsDone() == 0:
252 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
255 def MakePlaneFace(theFace, theTrimSize):
257 * Create a plane, similar to the existing one, but with another size of representing face.
258 * \param theFace Referenced plane.
259 * \param theTrimSize New half size of a side of quadrangle face, representing the plane.
260 * \return New GEOM_Object, containing the created plane.
262 * Example: see GEOM_TestAll.py
264 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
265 if BasicOp.IsDone() == 0:
266 print "MakePlaneFace : ", BasicOp.GetErrorCode()
269 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
271 * Create a local coordinate system.
272 * \param OX,OY,OZ Three coordinates of coordinate system origin.
273 * \param XDX,XDY,XDZ Three components of OX direction
274 * \param YDX,YDY,YDZ Three components of OY direction
275 * \return New GEOM_Object, containing the created coordinate system.
277 * Example: see GEOM_TestAll.py
279 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
280 if BasicOp.IsDone() == 0:
281 print "MakeMarker : ", BasicOp.GetErrorCode()
284 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
286 * Create a local coordinate system.
287 * \param theOrigin Point of coordinate system origin.
288 * \param theXVec Vector of X direction
289 * \param theYVec Vector of Y direction
290 * \return New GEOM_Object, containing the created coordinate system.
292 O = PointCoordinates( theOrigin )
294 for vec in [ theXVec, theYVec ]:
295 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
296 p1 = PointCoordinates( v1 )
297 p2 = PointCoordinates( v2 )
298 for i in range( 0, 3 ):
299 OXOY.append( p2[i] - p1[i] )
301 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
302 OXOY[0], OXOY[1], OXOY[2],
303 OXOY[3], OXOY[4], OXOY[5], )
304 if BasicOp.IsDone() == 0:
305 print "MakeMarker : ", BasicOp.GetErrorCode()
308 # -----------------------------------------------------------------------------
310 # -----------------------------------------------------------------------------
312 def MakeArc(thePnt1, thePnt2, thePnt3):
314 * Create an arc of circle, passing through three given points.
315 * \param thePnt1 Start point of the arc.
316 * \param thePnt2 Middle point of the arc.
317 * \param thePnt3 End point of the arc.
318 * \return New GEOM_Object, containing the created arc.
320 * Example: see GEOM_TestAll.py
322 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
323 if CurvesOp.IsDone() == 0:
324 print "MakeArc : ", CurvesOp.GetErrorCode()
327 def MakeCircle(thePnt, theVec, theR):
329 * Create a circle with given center, normal vector and radius.
330 * \param thePnt Circle center.
331 * \param theVec Vector, normal to the plane of the circle.
332 * \param theR Circle radius.
333 * \return New GEOM_Object, containing the created circle.
335 * Example: see GEOM_TestAll.py
337 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
338 if CurvesOp.IsDone() == 0:
339 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
342 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
344 * Create a circle, passing through three given points
345 * \param thePnt1,thePnt2,thePnt3 Points, defining the circle.
346 * \return New GEOM_Object, containing the created circle.
348 * Example: see GEOM_TestAll.py
350 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
351 if CurvesOp.IsDone() == 0:
352 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
355 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
357 * Create an ellipse with given center, normal vector and radiuses.
358 * \param thePnt Ellipse center.
359 * \param theVec Vector, normal to the plane of the ellipse.
360 * \param theRMajor Major ellipse radius.
361 * \param theRMinor Minor ellipse radius.
362 * \return New GEOM_Object, containing the created ellipse.
364 * Example: see GEOM_TestAll.py
366 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
367 if CurvesOp.IsDone() == 0:
368 print "MakeEllipse : ", CurvesOp.GetErrorCode()
371 def MakePolyline(thePoints):
373 * Create a polyline on the set of points.
374 * \param thePoints Sequence of points for the polyline.
375 * \return New GEOM_Object, containing the created polyline.
377 * Example: see GEOM_TestAll.py
379 anObj = CurvesOp.MakePolyline(thePoints)
380 if CurvesOp.IsDone() == 0:
381 print "MakePolyline : ", CurvesOp.GetErrorCode()
384 def MakeBezier(thePoints):
386 * Create bezier curve on the set of points.
387 * \param thePoints Sequence of points for the bezier curve.
388 * \return New GEOM_Object, containing the created bezier curve.
390 * Example: see GEOM_TestAll.py
392 anObj = CurvesOp.MakeSplineBezier(thePoints)
393 if CurvesOp.IsDone() == 0:
394 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
397 def MakeInterpol(thePoints):
399 * Create B-Spline curve on the set of points.
400 * \param thePoints Sequence of points for the B-Spline curve.
401 * \return New GEOM_Object, containing the created B-Spline curve.
403 * Example: see GEOM_TestAll.py
405 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
406 if CurvesOp.IsDone() == 0:
407 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
410 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
412 * Create a sketcher (wire or face), following the textual description,
413 * passed through \a theCommand argument. \n
414 * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
415 * Format of the description string have to be the following:
417 * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
420 * - x1, y1 are coordinates of the first sketcher point (zero by default),
422 * - "R angle" : Set the direction by angle
423 * - "D dx dy" : Set the direction by DX & DY
426 * - "TT x y" : Create segment by point at X & Y
427 * - "T dx dy" : Create segment by point with DX & DY
428 * - "L length" : Create segment by direction & Length
429 * - "IX x" : Create segment by direction & Intersect. X
430 * - "IY y" : Create segment by direction & Intersect. Y
433 * - "C radius length" : Create arc by direction, radius and length(in degree)
436 * - "WW" : Close Wire (to finish)
437 * - "WF" : Close Wire and build face (to finish)
439 * \param theCommand String, defining the sketcher in local
440 * coordinates of the working plane.
441 * \param theWorkingPlane Nine double values, defining origin,
442 * OZ and OX directions of the working plane.
443 * \return New GEOM_Object, containing the created wire.
445 * Example: see GEOM_TestAll.py
447 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
448 if CurvesOp.IsDone() == 0:
449 print "MakeSketcher : ", CurvesOp.GetErrorCode()
452 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
454 * Create a sketcher (wire or face), following the textual description,
455 * passed through \a theCommand argument. \n
456 * For format of the description string see the previous method.\n
457 * \param theCommand String, defining the sketcher in local
458 * coordinates of the working plane.
459 * \param theWorkingPlane Planar Face of the working plane.
460 * \return New GEOM_Object, containing the created wire.
462 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
463 if CurvesOp.IsDone() == 0:
464 print "MakeSketcher : ", CurvesOp.GetErrorCode()
467 # -----------------------------------------------------------------------------
468 # Create 3D Primitives
469 # -----------------------------------------------------------------------------
471 def MakeBox(x1,y1,z1,x2,y2,z2):
473 * Create a box by coordinates of two opposite vertices.
475 * Example: see GEOM_TestAll.py
477 pnt1 = MakeVertex(x1,y1,z1)
478 pnt2 = MakeVertex(x2,y2,z2)
479 return MakeBoxTwoPnt(pnt1,pnt2)
481 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
483 * Create a box with specified dimensions along the coordinate axes
484 * and with edges, parallel to the coordinate axes.
485 * Center of the box will be at point (DX/2, DY/2, DZ/2).
486 * \param theDX Length of Box edges, parallel to OX axis.
487 * \param theDY Length of Box edges, parallel to OY axis.
488 * \param theDZ Length of Box edges, parallel to OZ axis.
489 * \return New GEOM_Object, containing the created box.
491 * Example: see GEOM_TestAll.py
493 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
494 if PrimOp.IsDone() == 0:
495 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
498 def MakeBoxTwoPnt(thePnt1, thePnt2):
500 * Create a box with two specified opposite vertices,
501 * and with edges, parallel to the coordinate axes
502 * \param thePnt1 First of two opposite vertices.
503 * \param thePnt2 Second of two opposite vertices.
504 * \return New GEOM_Object, containing the created box.
506 * Example: see GEOM_TestAll.py
508 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
509 if PrimOp.IsDone() == 0:
510 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
513 def MakeCylinder(thePnt, theAxis, theR, theH):
515 * Create a cylinder with given base point, axis, radius and height.
516 * \param thePnt Central point of cylinder base.
517 * \param theAxis Cylinder axis.
518 * \param theR Cylinder radius.
519 * \param theH Cylinder height.
520 * \return New GEOM_Object, containing the created cylinder.
522 * Example: see GEOM_TestAll.py
524 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
525 if PrimOp.IsDone() == 0:
526 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
529 def MakeCylinderRH(theR, theH):
531 * Create a cylinder with given radius and height at
532 * the origin of coordinate system. Axis of the cylinder
533 * will be collinear to the OZ axis of the coordinate system.
534 * \param theR Cylinder radius.
535 * \param theH Cylinder height.
536 * \return New GEOM_Object, containing the created cylinder.
538 * Example: see GEOM_TestAll.py
540 anObj = PrimOp.MakeCylinderRH(theR, theH)
541 if PrimOp.IsDone() == 0:
542 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
545 def MakeSpherePntR(thePnt, theR):
547 * Create a sphere with given center and radius.
548 * \param thePnt Sphere center.
549 * \param theR Sphere radius.
550 * \return New GEOM_Object, containing the created sphere.
552 * Example: see GEOM_TestAll.py
554 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
555 if PrimOp.IsDone() == 0:
556 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
559 def MakeSphere(x, y, z, theR):
561 * Create a sphere with given center and radius.
562 * \param x,y,z Coordinates of sphere center.
563 * \param theR Sphere radius.
564 * \return New GEOM_Object, containing the created sphere.
566 * Example: see GEOM_TestAll.py
568 point = MakeVertex(x, y, z)
569 anObj = MakeSpherePntR(point, theR)
572 def MakeSphereR(theR):
574 * Create a sphere with given radius at the origin of coordinate system.
575 * \param theR Sphere radius.
576 * \return New GEOM_Object, containing the created sphere.
578 * Example: see GEOM_TestAll.py
580 anObj = PrimOp.MakeSphereR(theR)
581 if PrimOp.IsDone() == 0:
582 print "MakeSphereR : ", PrimOp.GetErrorCode()
585 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
587 * Create a cone with given base point, axis, height and radiuses.
588 * \param thePnt Central point of the first cone base.
589 * \param theAxis Cone axis.
590 * \param theR1 Radius of the first cone base.
591 * \param theR2 Radius of the second cone base.
592 * \note If both radiuses are non-zero, the cone will be truncated.
593 * \note If the radiuses are equal, a cylinder will be created instead.
594 * \param theH Cone height.
595 * \return New GEOM_Object, containing the created cone.
597 * Example: see GEOM_TestAll.py
599 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
600 if PrimOp.IsDone() == 0:
601 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
604 def MakeConeR1R2H(theR1, theR2, theH):
606 * Create a cone with given height and radiuses at
607 * the origin of coordinate system. Axis of the cone will
608 * be collinear to the OZ axis of the coordinate system.
609 * \param theR1 Radius of the first cone base.
610 * \param theR2 Radius of the second cone base.
611 * \note If both radiuses are non-zero, the cone will be truncated.
612 * \note If the radiuses are equal, a cylinder will be created instead.
613 * \param theH Cone height.
614 * \return New GEOM_Object, containing the created cone.
616 * Example: see GEOM_TestAll.py
618 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
619 if PrimOp.IsDone() == 0:
620 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
623 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
625 * Create a torus with given center, normal vector and radiuses.
626 * \param thePnt Torus central point.
627 * \param theVec Torus axis of symmetry.
628 * \param theRMajor Torus major radius.
629 * \param theRMinor Torus minor radius.
630 * \return New GEOM_Object, containing the created torus.
632 * Example: see GEOM_TestAll.py
634 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
635 if PrimOp.IsDone() == 0:
636 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
639 def MakeTorusRR(theRMajor, theRMinor):
641 * Create a torus with given radiuses at the origin of coordinate system.
642 * \param theRMajor Torus major radius.
643 * \param theRMinor Torus minor radius.
644 * \return New GEOM_Object, containing the created torus.
646 * Example: see GEOM_TestAll.py
648 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
649 if PrimOp.IsDone() == 0:
650 print "MakeTorusRR : ", PrimOp.GetErrorCode()
653 def MakePrism(theBase, thePoint1, thePoint2):
655 * Create a shape by extrusion of the base shape along a vector, defined by two points.
656 * \param theBase Base shape to be extruded.
657 * \param thePoint1 First end of extrusion vector.
658 * \param thePoint2 Second end of extrusion vector.
659 * \return New GEOM_Object, containing the created prism.
661 * Example: see GEOM_TestAll.py
663 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
664 if PrimOp.IsDone() == 0:
665 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
668 def MakePrismVecH(theBase, theVec, theH):
670 * Create a shape by extrusion of the base shape along the vector,
671 * i.e. all the space, transfixed by the base shape during its translation
672 * along the vector on the given distance.
673 * \param theBase Base shape to be extruded.
674 * \param theVec Direction of extrusion.
675 * \param theH Prism dimension along theVec.
676 * \return New GEOM_Object, containing the created prism.
678 * Example: see GEOM_TestAll.py
680 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
681 if PrimOp.IsDone() == 0:
682 print "MakePrismVecH : ", PrimOp.GetErrorCode()
685 def MakePipe(theBase, thePath):
687 * Create a shape by extrusion of the base shape along
688 * the path shape. The path shape can be a wire or an edge.
689 * \param theBase Base shape to be extruded.
690 * \param thePath Path shape to extrude the base shape along it.
691 * \return New GEOM_Object, containing the created pipe.
693 * Example: see GEOM_TestAll.py
695 anObj = PrimOp.MakePipe(theBase, thePath)
696 if PrimOp.IsDone() == 0:
697 print "MakePipe : ", PrimOp.GetErrorCode()
700 def MakeRevolution(theBase, theAxis, theAngle):
702 * Create a shape by revolution of the base shape around the axis
703 * on the given angle, i.e. all the space, transfixed by the base
704 * shape during its rotation around the axis on the given angle.
705 * \param theBase Base shape to be rotated.
706 * \param theAxis Rotation axis.
707 * \param theAngle Rotation angle in radians.
708 * \return New GEOM_Object, containing the created revolution.
710 * Example: see GEOM_TestAll.py
712 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
713 if PrimOp.IsDone() == 0:
714 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
717 # -----------------------------------------------------------------------------
719 # -----------------------------------------------------------------------------
721 def MakeEdge(thePnt1, thePnt2):
723 * Create a linear edge with specified ends.
724 * \param thePnt1 Point for the first end of edge.
725 * \param thePnt2 Point for the second end of edge.
726 * \return New GEOM_Object, containing the created edge.
728 * Example: see GEOM_TestAll.py
730 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
731 if ShapesOp.IsDone() == 0:
732 print "MakeEdge : ", ShapesOp.GetErrorCode()
735 def MakeWire(theEdgesAndWires):
737 * Create a wire from the set of edges and wires.
738 * \param theEdgesAndWires List of edges and/or wires.
739 * \return New GEOM_Object, containing the created wire.
741 * Example: see GEOM_TestAll.py
743 anObj = ShapesOp.MakeWire(theEdgesAndWires)
744 if ShapesOp.IsDone() == 0:
745 print "MakeWire : ", ShapesOp.GetErrorCode()
748 def MakeFace(theWire, isPlanarWanted):
750 * Create a face on the given wire.
751 * \param theWire Wire to build the face on.
752 * \param isPlanarWanted If TRUE, only planar face will be built.
753 * If impossible, NULL object will be returned.
754 * \return New GEOM_Object, containing the created face.
756 * Example: see GEOM_TestAll.py
758 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
759 if ShapesOp.IsDone() == 0:
760 print "MakeFace : ", ShapesOp.GetErrorCode()
763 def MakeFaceWires(theWires, isPlanarWanted):
765 * Create a face on the given wires set.
766 * \param theWires List of wires to build the face on.
767 * \param isPlanarWanted If TRUE, only planar face will be built.
768 * If impossible, NULL object will be returned.
769 * \return New GEOM_Object, containing the created face.
771 * Example: see GEOM_TestAll.py
773 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
774 if ShapesOp.IsDone() == 0:
775 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
778 def MakeFaces(theWires, isPlanarWanted):
780 * Shortcut to MakeFaceWires()
782 * Example: see GEOM_TestOthers.py
784 anObj = MakeFaceWires(theWires, isPlanarWanted)
787 def MakeShell(theFacesAndShells):
789 * Create a shell from the set of faces and shells.
790 * \param theFacesAndShells List of faces and/or shells.
791 * \return New GEOM_Object, containing the created shell.
793 * Example: see GEOM_TestAll.py
795 anObj = ShapesOp.MakeShell(theFacesAndShells)
796 if ShapesOp.IsDone() == 0:
797 print "MakeShell : ", ShapesOp.GetErrorCode()
800 def MakeSolid(theShells):
802 * Create a solid, bounded by the given shells.
803 * \param theShells Sequence of bounding shells.
804 * \return New GEOM_Object, containing the created solid.
806 * Example: see GEOM_TestAll.py
808 anObj = ShapesOp.MakeSolidShells(theShells)
809 if ShapesOp.IsDone() == 0:
810 print "MakeSolid : ", ShapesOp.GetErrorCode()
813 def MakeCompound(theShapes):
815 * Create a compound of the given shapes.
816 * \param theShapes List of shapes to put in compound.
817 * \return New GEOM_Object, containing the created compound.
819 * Example: see GEOM_TestAll.py
821 anObj = ShapesOp.MakeCompound(theShapes)
822 if ShapesOp.IsDone() == 0:
823 print "MakeCompound : ", ShapesOp.GetErrorCode()
826 def NumberOfFaces(theShape):
828 * Gives quantity of faces in the given shape.
829 * \param theShape Shape to count faces of.
830 * \return Quantity of faces.
832 * Example: see GEOM_TestOthers.py
834 nb_faces = ShapesOp.NumberOfFaces(theShape)
835 if ShapesOp.IsDone() == 0:
836 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
839 def NumberOfEdges(theShape):
841 * Gives quantity of edges in the given shape.
842 * \param theShape Shape to count edges of.
843 * \return Quantity of edges.
845 * Example: see GEOM_TestOthers.py
847 nb_edges = ShapesOp.NumberOfEdges(theShape)
848 if ShapesOp.IsDone() == 0:
849 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
852 def ChangeOrientation(theShape):
854 * Reverses an orientation the given shape.
855 * \param theShape Shape to be reversed.
856 * \return The reversed copy of theShape.
858 * Example: see GEOM_TestAll.py
860 anObj = ShapesOp.ChangeOrientation(theShape)
861 if ShapesOp.IsDone() == 0:
862 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
865 def OrientationChange(theShape):
867 * Shortcut to ChangeOrientation()
869 * Example: see GEOM_TestOthers.py
871 anObj = ChangeOrientation(theShape)
874 def GetFreeFacesIDs(theShape):
876 * Retrieve all free faces from the given shape.
877 * Free face is a face, which is not shared between two shells of the shape.
878 * \param theShape Shape to find free faces in.
879 * \return List of IDs of all free faces, contained in theShape.
881 * Example: see GEOM_TestOthers.py
883 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
884 if ShapesOp.IsDone() == 0:
885 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
888 def GetSharedShapes(theShape1, theShape2, theShapeType):
890 * Get all sub-shapes of theShape1 of the given type, shared with theShape2.
891 * \param theShape1 Shape to find sub-shapes in.
892 * \param theShape2 Shape to find shared sub-shapes with.
893 * \param theShapeType Type of sub-shapes to be retrieved.
894 * \return List of sub-shapes of theShape1, shared with theShape2.
896 * Example: see GEOM_TestOthers.py
898 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
899 if ShapesOp.IsDone() == 0:
900 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
903 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
905 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
906 * the specified plane by the certain way, defined through \a theState parameter.
907 * \param theShape Shape to find sub-shapes of.
908 * \param theShapeType Type of sub-shapes to be retrieved.
909 * \param theAx1 Vector (or line, or linear edge), specifying normal
910 * direction and location of the plane to find shapes on.
911 * \param theState The state of the subshapes to find. It can be one of
912 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
913 * \return List of all found sub-shapes.
915 * Example: see GEOM_TestOthers.py
917 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
918 if ShapesOp.IsDone() == 0:
919 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
922 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
924 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
925 * the specified cylinder by the certain way, defined through \a theState parameter.
926 * \param theShape Shape to find sub-shapes of.
927 * \param theShapeType Type of sub-shapes to be retrieved.
928 * \param theAxis Vector (or line, or linear edge), specifying
929 * axis of the cylinder to find shapes on.
930 * \param theRadius Radius of the cylinder to find shapes on.
931 * \param theState The state of the subshapes to find. It can be one of
932 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
933 * \return List of all found sub-shapes.
935 * Example: see GEOM_TestOthers.py
937 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
938 if ShapesOp.IsDone() == 0:
939 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
942 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
944 * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
945 * the specified sphere by the certain way, defined through \a theState parameter.
946 * \param theShape Shape to find sub-shapes of.
947 * \param theShapeType Type of sub-shapes to be retrieved.
948 * \param theCenter Point, specifying center of the sphere to find shapes on.
949 * \param theRadius Radius of the sphere to find shapes on.
950 * \param theState The state of the subshapes to find. It can be one of
951 * ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
952 * \return List of all found sub-shapes.
954 * Example: see GEOM_TestOthers.py
956 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
957 if ShapesOp.IsDone() == 0:
958 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
961 def GetInPlace(theShapeWhere, theShapeWhat):
963 * Get sub-shape(s) of theShapeWhere, which are
964 * coincident with \a theShapeWhat or could be a part of it.
965 * \param theShapeWhere Shape to find sub-shapes of.
966 * \param theShapeWhat Shape, specifying what to find.
967 * \return Group of all found sub-shapes or a single found sub-shape.
969 * Example: see GEOM_TestOthers.py
971 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
972 if ShapesOp.IsDone() == 0:
973 print "GetInPlace : ", ShapesOp.GetErrorCode()
976 # -----------------------------------------------------------------------------
977 # Access to sub-shapes by their unique IDs inside the main shape.
978 # -----------------------------------------------------------------------------
980 def GetSubShape(aShape, ListOfID):
982 * Obtain a composite sub-shape of <aShape>, composed from sub-shapes
983 * of <aShape>, selected by their unique IDs inside <aShape>
985 * Example: see GEOM_TestAll.py
987 anObj = geom.AddSubShape(aShape,ListOfID)
990 def GetSubShapeID(aShape, aSubShape):
992 * Obtain unique ID of sub-shape <aSubShape> inside <aShape>
994 * Example: see GEOM_TestAll.py
996 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
997 if LocalOp.IsDone() == 0:
998 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1001 # -----------------------------------------------------------------------------
1003 # -----------------------------------------------------------------------------
1005 def SubShapeAll(aShape, aType):
1007 * Explode a shape on subshapes of a given type.
1008 * \param theShape Shape to be exploded.
1009 * \param theShapeType Type of sub-shapes to be retrieved.
1010 * \return List of sub-shapes of type theShapeType, contained in theShape.
1012 * Example: see GEOM_TestAll.py
1014 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1015 if ShapesOp.IsDone() == 0:
1016 print "MakeExplode : ", ShapesOp.GetErrorCode()
1019 def SubShapeAllIDs(aShape, aType):
1021 * Explode a shape on subshapes of a given type.
1022 * \param theShape Shape to be exploded.
1023 * \param theShapeType Type of sub-shapes to be retrieved.
1024 * \return List of IDs of sub-shapes.
1026 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1027 if ShapesOp.IsDone() == 0:
1028 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1031 def SubShapeAllSorted(aShape, aType):
1033 * Explode a shape on subshapes of a given type.
1034 * Sub-shapes will be sorted by coordinates of their gravity centers.
1035 * \param theShape Shape to be exploded.
1036 * \param theShapeType Type of sub-shapes to be retrieved.
1037 * \return List of sub-shapes of type theShapeType, contained in theShape.
1039 * Example: see GEOM_TestAll.py
1041 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1042 if ShapesOp.IsDone() == 0:
1043 print "MakeExplode : ", ShapesOp.GetErrorCode()
1046 def SubShapeAllSortedIDs(aShape, aType):
1048 * Explode a shape on subshapes of a given type.
1049 * Sub-shapes will be sorted by coordinates of their gravity centers.
1050 * \param theShape Shape to be exploded.
1051 * \param theShapeType Type of sub-shapes to be retrieved.
1052 * \return List of IDs of sub-shapes.
1054 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1055 if ShapesOp.IsDone() == 0:
1056 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1059 def SubShape(aShape, aType, ListOfInd):
1061 * Obtain a compound of sub-shapes of <aShape>,
1062 * selected by they indices in list of all sub-shapes of type <aType>.
1063 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1065 * Example: see GEOM_TestAll.py
1068 AllShapeList = SubShapeAll(aShape, aType)
1069 for ind in ListOfInd:
1070 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1071 anObj = GetSubShape(aShape, ListOfIDs)
1074 def SubShapeSorted(aShape, aType, ListOfInd):
1076 * Obtain a compound of sub-shapes of <aShape>,
1077 * selected by they indices in sorted list of all sub-shapes of type <aType>.
1078 * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1080 * Example: see GEOM_TestAll.py
1083 AllShapeList = SubShapeAllSorted(aShape, aType)
1084 for ind in ListOfInd:
1085 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1086 anObj = GetSubShape(aShape, ListOfIDs)
1089 # -----------------------------------------------------------------------------
1090 # Healing operations
1091 # -----------------------------------------------------------------------------
1093 def ProcessShape(theShape, theOperators, theParameters, theValues):
1095 * Apply a sequence of Shape Healing operators to the given object.
1096 * \param theShape Shape to be processed.
1097 * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1098 * \param theParameters List of names of parameters
1099 * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1100 * \param theValues List of values of parameters, in the same order
1101 * as parameters are listed in \a theParameters list.
1102 * \return New GEOM_Object, containing processed shape.
1104 * Example: see GEOM_TestHealing.py
1106 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1107 if HealOp.IsDone() == 0:
1108 print "ProcessShape : ", HealOp.GetErrorCode()
1111 def SuppressFaces(theObject, theFaces):
1113 * Remove faces from the given object (shape).
1114 * \param theObject Shape to be processed.
1115 * \param theFaces Indices of faces to be removed, if EMPTY then the method
1116 * removes ALL faces of the given object.
1117 * \return New GEOM_Object, containing processed shape.
1119 * Example: see GEOM_TestHealing.py
1121 anObj = HealOp.SuppressFaces(theObject, theFaces)
1122 if HealOp.IsDone() == 0:
1123 print "SuppressFaces : ", HealOp.GetErrorCode()
1126 def MakeSewing(ListShape, theTolerance):
1128 * Sewing of some shapes into single shape.
1130 * Example: see GEOM_TestHealing.py
1132 comp = MakeCompound(ListShape)
1133 anObj = Sew(comp, theTolerance)
1136 def Sew(theObject, theTolerance):
1138 * Sewing of the given object.
1139 * \param theObject Shape to be processed.
1140 * \param theTolerance Required tolerance value.
1141 * \return New GEOM_Object, containing processed shape.
1143 * Example: see MakeSewing() above
1145 anObj = HealOp.Sew(theObject, theTolerance)
1146 if HealOp.IsDone() == 0:
1147 print "Sew : ", HealOp.GetErrorCode()
1150 def SuppressInternalWires(theObject, theWires):
1152 * Remove internal wires and edges from the given object (face).
1153 * \param theObject Shape to be processed.
1154 * \param theWires Indices of wires to be removed, if EMPTY then the method
1155 * removes ALL internal wires of the given object.
1156 * \return New GEOM_Object, containing processed shape.
1158 * Example: see GEOM_TestHealing.py
1160 anObj = HealOp.RemoveIntWires(theObject, theWires)
1161 if HealOp.IsDone() == 0:
1162 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1165 def SuppressHoles(theObject, theWires):
1167 * Remove internal closed contours (holes) from the given object.
1168 * \param theObject Shape to be processed.
1169 * \param theWires Indices of wires to be removed, if EMPTY then the method
1170 * removes ALL internal holes of the given object
1171 * \return New GEOM_Object, containing processed shape.
1173 * Example: see GEOM_TestHealing.py
1175 anObj = HealOp.FillHoles(theObject, theWires)
1176 if HealOp.IsDone() == 0:
1177 print "SuppressHoles : ", HealOp.GetErrorCode()
1180 def CloseContour(theObject, theWires, isCommonVertex):
1182 * Close an open wire.
1183 * \param theObject Shape to be processed.
1184 * \param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1185 * if -1, then theObject itself is a wire.
1186 * \param isCommonVertex If TRUE : closure by creation of a common vertex,
1187 * If FALS : closure by creation of an edge between ends.
1188 * \return New GEOM_Object, containing processed shape.
1190 * Example: see GEOM_TestHealing.py
1192 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1193 if HealOp.IsDone() == 0:
1194 print "CloseContour : ", HealOp.GetErrorCode()
1197 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1199 * Addition of a point to a given edge object.
1200 * \param theObject Shape to be processed.
1201 * \param theEdgeIndex Index of edge to be divided within theObject's shape,
1202 * if -1, then theObject itself is the edge.
1203 * \param theValue Value of parameter on edge or length parameter,
1204 * depending on \a isByParameter.
1205 * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1206 * if FALSE : \a theValue is treated as a length parameter [0..1]
1207 * \return New GEOM_Object, containing processed shape.
1209 * Example: see GEOM_TestHealing.py
1211 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1212 if HealOp.IsDone() == 0:
1213 print "DivideEdge : ", HealOp.GetErrorCode()
1216 def GetFreeBoundary(theObject):
1218 * Get a list of wires (wrapped in GEOM_Object-s),
1219 * that constitute a free boundary of the given shape.
1220 * \param theObject Shape to get free boundary of.
1221 * \return [status, theClosedWires, theOpenWires]
1222 * status: FALSE, if an error(s) occured during the method execution.
1223 * theClosedWires: Closed wires on the free boundary of the given shape.
1224 * theOpenWires: Open wires on the free boundary of the given shape.
1226 * Example: see GEOM_TestHealing.py
1228 anObj = HealOp.GetFreeBoundary(theObject)
1229 if HealOp.IsDone() == 0:
1230 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1233 # -----------------------------------------------------------------------------
1234 # Create advanced objects
1235 # -----------------------------------------------------------------------------
1237 def MakeCopy(theOriginal):
1239 * Create a copy of the given object
1241 * Example: see GEOM_TestAll.py
1243 anObj = InsertOp.MakeCopy(theOriginal)
1244 if InsertOp.IsDone() == 0:
1245 print "MakeCopy : ", InsertOp.GetErrorCode()
1248 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1250 * Create a filling from the given compound of contours.
1251 * \param theShape the compound of contours
1252 * \param theMinDeg a minimal degree
1253 * \param theMaxDeg a maximal degree
1254 * \param theTol2D a 2d tolerance
1255 * \param theTol3D a 3d tolerance
1256 * \param theNbIter a number of iteration
1257 * \return New GEOM_Object, containing the created filling surface.
1259 * Example: see GEOM_TestAll.py
1261 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1262 if PrimOp.IsDone() == 0:
1263 print "MakeFilling : ", PrimOp.GetErrorCode()
1266 def MakeGlueFaces(theShape, theTolerance):
1268 * Replace coincident faces in theShape by one face.
1269 * \param theShape Initial shape.
1270 * \param theTolerance Maximum distance between faces, which can be considered as coincident.
1271 * \return New GEOM_Object, containing a copy of theShape without coincident faces.
1273 * Example: see GEOM_Spanner.py
1275 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1276 if ShapesOp.IsDone() == 0:
1277 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1280 # -----------------------------------------------------------------------------
1281 # Boolean (Common, Cut, Fuse, Section)
1282 # -----------------------------------------------------------------------------
1284 def MakeBoolean(theShape1, theShape2, theOperation):
1286 * Perform one of boolean operations on two given shapes.
1287 * \param theShape1 First argument for boolean operation.
1288 * \param theShape2 Second argument for boolean operation.
1289 * \param theOperation Indicates the operation to be done:
1290 * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1291 * \return New GEOM_Object, containing the result shape.
1293 * Example: see GEOM_TestAll.py
1295 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1296 if BoolOp.IsDone() == 0:
1297 print "MakeBoolean : ", BoolOp.GetErrorCode()
1300 def MakeCommon(s1, s2):
1302 * Shortcut to MakeBoolean(s1, s2, 1)
1304 * Example: see GEOM_TestOthers.py
1306 return MakeBoolean(s1, s2, 1)
1308 def MakeCut(s1, s2):
1310 * Shortcut to MakeBoolean(s1, s2, 2)
1312 * Example: see GEOM_TestOthers.py
1314 return MakeBoolean(s1, s2, 2)
1316 def MakeFuse(s1, s2):
1318 * Shortcut to MakeBoolean(s1, s2, 3)
1320 * Example: see GEOM_TestOthers.py
1322 return MakeBoolean(s1, s2, 3)
1324 def MakeSection(s1, s2):
1326 * Shortcut to MakeBoolean(s1, s2, 4)
1328 * Example: see GEOM_TestOthers.py
1330 return MakeBoolean(s1, s2, 4)
1332 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1333 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1335 * Perform partition operation.
1336 * \param ListShapes Shapes to be intersected.
1337 * \param ListTools Shapes to intersect theShapes.
1338 * \param ListKeepInside Shapes, outside which the results will be deleted.
1339 * Each shape from theKeepInside must belong to theShapes also.
1340 * \param ListRemoveInside Shapes, inside which the results will be deleted.
1341 * Each shape from theRemoveInside must belong to theShapes also.
1342 * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1343 * \param RemoveWebs If TRUE, perform Glue 3D algorithm.
1344 * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE.
1345 * \return New GEOM_Object, containing the result shapes.
1347 * Example: see GEOM_TestAll.py
1349 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1350 ListKeepInside, ListRemoveInside,
1351 Limit, RemoveWebs, ListMaterials);
1352 if BoolOp.IsDone() == 0:
1353 print "MakePartition : ", BoolOp.GetErrorCode()
1356 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1357 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1359 * Shortcut to MakePartition()
1361 * Example: see GEOM_TestOthers.py
1363 anObj = MakePartition(ListShapes, ListTools,
1364 ListKeepInside, ListRemoveInside,
1365 Limit, RemoveWebs, ListMaterials);
1368 def MakeHalfPartition(theShape, thePlane):
1370 * Perform partition of the Shape with the Plane
1371 * \param theShape Shape to be intersected.
1372 * \param thePlane Tool shape, to intersect theShape.
1373 * \return New GEOM_Object, containing the result shape.
1375 * Example: see GEOM_TestAll.py
1377 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1378 if BoolOp.IsDone() == 0:
1379 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1382 # -----------------------------------------------------------------------------
1384 # -----------------------------------------------------------------------------
1386 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1388 * Translate the given object along the vector, specified
1389 * by its end points, creating its copy before the translation.
1390 * \param theObject The object to be translated.
1391 * \param thePoint1 Start point of translation vector.
1392 * \param thePoint2 End point of translation vector.
1393 * \return New GEOM_Object, containing the translated object.
1395 * Example: see GEOM_TestAll.py
1397 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1398 if TrsfOp.IsDone() == 0:
1399 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1402 def MakeTranslation(theObject, theDX, theDY, theDZ):
1404 * Translate the given object along the vector, specified
1405 * by its components, creating its copy before the translation.
1406 * \param theObject The object to be translated.
1407 * \param theDX,theDY,theDZ Components of translation vector.
1408 * \return New GEOM_Object, containing the translated object.
1410 * Example: see GEOM_TestAll.py
1412 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1413 if TrsfOp.IsDone() == 0:
1414 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1417 def MakeTranslationVector(theObject, theVector):
1419 * Translate the given object along the given vector,
1420 * creating its copy before the translation.
1421 * \param theObject The object to be translated.
1422 * \param theVector The translation vector.
1423 * \return New GEOM_Object, containing the translated object.
1425 * Example: see GEOM_TestAll.py
1427 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1428 if TrsfOp.IsDone() == 0:
1429 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1432 def MakeRotation(theObject, theAxis, theAngle):
1434 * Rotate the given object around the given axis
1435 * on the given angle, creating its copy before the rotatation.
1436 * \param theObject The object to be rotated.
1437 * \param theAxis Rotation axis.
1438 * \param theAngle Rotation angle in radians.
1439 * \return New GEOM_Object, containing the rotated object.
1441 * Example: see GEOM_TestAll.py
1443 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1444 if TrsfOp.IsDone() == 0:
1445 print "RotateCopy : ", TrsfOp.GetErrorCode()
1448 def MakeScaleTransform(theObject, thePoint, theFactor):
1450 * Scale the given object by the factor, creating its copy before the scaling.
1451 * \param theObject The object to be scaled.
1452 * \param thePoint Center point for scaling.
1453 * \param theFactor Scaling factor value.
1454 * \return New GEOM_Object, containing the scaled shape.
1456 * Example: see GEOM_TestAll.py
1458 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1459 if TrsfOp.IsDone() == 0:
1460 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1463 def MakeMirrorByPlane(theObject, thePlane):
1465 * Create an object, symmetrical
1466 * to the given one relatively the given plane.
1467 * \param theObject The object to be mirrored.
1468 * \param thePlane Plane of symmetry.
1469 * \return New GEOM_Object, containing the mirrored shape.
1471 * Example: see GEOM_TestAll.py
1473 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1474 if TrsfOp.IsDone() == 0:
1475 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1478 def MakeMirrorByAxis(theObject, theAxis):
1480 * Create an object, symmetrical
1481 * to the given one relatively the given axis.
1482 * \param theObject The object to be mirrored.
1483 * \param theAxis Axis of symmetry.
1484 * \return New GEOM_Object, containing the mirrored shape.
1486 * Example: see GEOM_TestAll.py
1488 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1489 if TrsfOp.IsDone() == 0:
1490 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1493 def MakeMirrorByPoint(theObject, thePoint):
1495 * Create an object, symmetrical
1496 * to the given one relatively the given point.
1497 * \param theObject The object to be mirrored.
1498 * \param thePoint Point of symmetry.
1499 * \return New GEOM_Object, containing the mirrored shape.
1501 * Example: see GEOM_TestAll.py
1503 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1504 if TrsfOp.IsDone() == 0:
1505 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1508 def MakePosition(theObject, theStartLCS, theEndLCS):
1510 * Modify the Location of the given object by LCS
1511 * creating its copy before the setting
1513 * Example: see GEOM_TestAll.py
1515 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1516 if TrsfOp.IsDone() == 0:
1517 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1520 def MakeOffset(theObject, theOffset):
1522 * Create new object as offset of the given one.
1523 * \param theObject The base object for the offset.
1524 * \param theOffset Offset value.
1525 * \return New GEOM_Object, containing the offset object.
1527 * Example: see GEOM_TestAll.py
1529 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1530 if TrsfOp.IsDone() == 0:
1531 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1534 # -----------------------------------------------------------------------------
1536 # -----------------------------------------------------------------------------
1538 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1540 * Translate the given object along the given vector a given number times
1541 * \param theObject The object to be translated.
1542 * \param theVector Direction of the translation.
1543 * \param theStep Distance to translate on.
1544 * \param theNbTimes Quantity of translations to be done.
1545 * \return New GEOM_Object, containing compound of all
1546 * the shapes, obtained after each translation.
1548 * Example: see GEOM_TestAll.py
1550 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1551 if TrsfOp.IsDone() == 0:
1552 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1555 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1556 theVector2, theStep2, theNbTimes2):
1558 * Conseqently apply two specified translations to theObject specified number of times.
1559 * \param theObject The object to be translated.
1560 * \param theVector1 Direction of the first translation.
1561 * \param theStep1 Step of the first translation.
1562 * \param theNbTimes1 Quantity of translations to be done along theVector1.
1563 * \param theVector2 Direction of the second translation.
1564 * \param theStep2 Step of the second translation.
1565 * \param theNbTimes2 Quantity of translations to be done along theVector2.
1566 * \return New GEOM_Object, containing compound of all
1567 * the shapes, obtained after each translation.
1569 * Example: see GEOM_TestAll.py
1571 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1572 theVector2, theStep2, theNbTimes2)
1573 if TrsfOp.IsDone() == 0:
1574 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1577 def MultiRotate1D(theObject, theAxis, theNbTimes):
1579 * Rotate the given object around the given axis a given number times.
1580 * Rotation angle will be 2*PI/theNbTimes.
1581 * \param theObject The object to be rotated.
1582 * \param theAxis The rotation axis.
1583 * \param theNbTimes Quantity of rotations to be done.
1584 * \return New GEOM_Object, containing compound of all the
1585 * shapes, obtained after each rotation.
1587 * Example: see GEOM_TestAll.py
1589 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1590 if TrsfOp.IsDone() == 0:
1591 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1594 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1596 * Rotate the given object around the
1597 * given axis on the given angle a given number
1598 * times and multi-translate each rotation result.
1599 * Translation direction passes through center of gravity
1600 * of rotated shape and its projection on the rotation axis.
1601 * \param theObject The object to be rotated.
1602 * \param theAxis Rotation axis.
1603 * \param theAngle Rotation angle in graduces.
1604 * \param theNbTimes1 Quantity of rotations to be done.
1605 * \param theStep Translation distance.
1606 * \param theNbTimes2 Quantity of translations to be done.
1607 * \return New GEOM_Object, containing compound of all the
1608 * shapes, obtained after each transformation.
1610 * Example: see GEOM_TestAll.py
1612 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1613 if TrsfOp.IsDone() == 0:
1614 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1617 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1619 * The same, as MultiRotate1D(), but axis is given by direction and point
1621 * Example: see GEOM_TestOthers.py
1623 aVec = MakeLine(aPoint,aDir)
1624 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1627 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1629 * The same, as MultiRotate2D(), but axis is given by direction and point
1631 * Example: see GEOM_TestOthers.py
1633 aVec = MakeLine(aPoint,aDir)
1634 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1637 # -----------------------------------------------------------------------------
1639 # -----------------------------------------------------------------------------
1641 def MakeFilletAll(theShape, theR):
1643 * Perform a fillet on all edges of the given shape.
1644 * \param theShape Shape, to perform fillet on.
1645 * \param theR Fillet radius.
1646 * \return New GEOM_Object, containing the result shape.
1648 * Example: see GEOM_TestOthers.py
1650 anObj = LocalOp.MakeFilletAll(theShape, theR)
1651 if LocalOp.IsDone() == 0:
1652 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1655 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1657 * Perform a fillet on the specified edges/faces of the given shape
1658 * \param theShape Shape, to perform fillet on.
1659 * \param theR Fillet radius.
1660 * \param theShapeType Type of shapes in <theListShapes>.
1661 * \param theListShapes Global indices of edges/faces to perform fillet on.
1662 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1663 * \return New GEOM_Object, containing the result shape.
1665 * Example: see GEOM_TestAll.py
1668 if theShapeType == ShapeType["EDGE"]:
1669 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1671 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1672 if LocalOp.IsDone() == 0:
1673 print "MakeFillet : ", LocalOp.GetErrorCode()
1676 def MakeChamferAll(theShape, theD):
1678 * Perform a symmetric chamfer on all edges of the given shape.
1679 * \param theShape Shape, to perform chamfer on.
1680 * \param theD Chamfer size along each face.
1681 * \return New GEOM_Object, containing the result shape.
1683 * Example: see GEOM_TestOthers.py
1685 anObj = LocalOp.MakeChamferAll(theShape, theD)
1686 if LocalOp.IsDone() == 0:
1687 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1690 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1692 * Perform a chamfer on edges, common to the specified faces,
1693 * with distance D1 on the Face1
1694 * \param theShape Shape, to perform chamfer on.
1695 * \param theD1 Chamfer size along \a theFace1.
1696 * \param theD2 Chamfer size along \a theFace2.
1697 * \param theFace1,theFace2 Global indices of two faces of \a theShape.
1698 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1699 * \return New GEOM_Object, containing the result shape.
1701 * Example: see GEOM_TestAll.py
1703 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1704 if LocalOp.IsDone() == 0:
1705 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1708 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1710 * Perform a chamfer on all edges of the specified faces,
1711 * with distance D1 on the first specified face (if several for one edge)
1712 * \param theShape Shape, to perform chamfer on.
1713 * \param theD1 Chamfer size along face from \a theFaces. If both faces,
1714 * connected to the edge, are in \a theFaces, \a theD1
1715 * will be get along face, which is nearer to \a theFaces beginning.
1716 * \param theD2 Chamfer size along another of two faces, connected to the edge.
1717 * \param theFaces Sequence of global indices of faces of \a theShape.
1718 * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1719 * \return New GEOM_Object, containing the result shape.
1721 * Example: see GEOM_TestAll.py
1723 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1724 if LocalOp.IsDone() == 0:
1725 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1728 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1730 * Shortcut to MakeChamferEdge() and MakeChamferFaces()
1732 * Example: see GEOM_TestOthers.py
1735 if aShapeType == ShapeType["EDGE"]:
1736 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1738 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1741 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1743 * Perform an Archimde operation on the given shape with given parameters.
1744 * The object presenting the resulting face is returned
1745 * \param theShape Shape to be put in water.
1746 * \param theWeight Weight og the shape.
1747 * \param theWaterDensity Density of the water.
1748 * \param theMeshDeflection Deflection of the mesh, using to compute the section.
1749 * \return New GEOM_Object, containing a section of \a theShape
1750 * by a plane, corresponding to water level.
1752 * Example: see GEOM_TestAll.py
1754 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1755 if LocalOp.IsDone() == 0:
1756 print "MakeArchimede : ", LocalOp.GetErrorCode()
1759 # -----------------------------------------------------------------------------
1760 # Information objects
1761 # -----------------------------------------------------------------------------
1763 def PointCoordinates(Point):
1765 * Get point coordinates
1768 * Example: see GEOM_TestMeasures.py
1770 aTuple = MeasuOp.PointCoordinates(Point)
1771 if MeasuOp.IsDone() == 0:
1772 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1775 def BasicProperties(theShape):
1777 * Get summarized length of all wires,
1778 * area of surface and volume of the given shape.
1779 * \param theShape Shape to define properties of.
1780 * \return [theLength, theSurfArea, theVolume]
1781 * theLength: Summarized length of all wires of the given shape.
1782 * theSurfArea: Area of surface of the given shape.
1783 * theVolume: Volume of the given shape.
1785 * Example: see GEOM_TestMeasures.py
1787 aTuple = MeasuOp.GetBasicProperties(theShape)
1788 if MeasuOp.IsDone() == 0:
1789 print "BasicProperties : ", MeasuOp.GetErrorCode()
1792 def BoundingBox(theShape):
1794 * Get parameters of bounding box of the given shape
1795 * \param theShape Shape to obtain bounding box of.
1796 * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1797 * Xmin,Xmax: Limits of shape along OX axis.
1798 * Ymin,Ymax: Limits of shape along OY axis.
1799 * Zmin,Zmax: Limits of shape along OZ axis.
1801 * Example: see GEOM_TestMeasures.py
1803 aTuple = MeasuOp.GetBoundingBox(theShape)
1804 if MeasuOp.IsDone() == 0:
1805 print "BoundingBox : ", MeasuOp.GetErrorCode()
1808 def Inertia(theShape):
1810 * Get inertia matrix and moments of inertia of theShape.
1811 * \param theShape Shape to calculate inertia of.
1812 * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1813 * I(1-3)(1-3): Components of the inertia matrix of the given shape.
1814 * Ix,Iy,Iz: Moments of inertia of the given shape.
1816 * Example: see GEOM_TestMeasures.py
1818 aTuple = MeasuOp.GetInertia(theShape)
1819 if MeasuOp.IsDone() == 0:
1820 print "Inertia : ", MeasuOp.GetErrorCode()
1823 def MinDistance(theShape1, theShape2):
1825 * Get minimal distance between the given shapes.
1826 * \param theShape1,theShape2 Shapes to find minimal distance between.
1827 * \return Value of the minimal distance between the given shapes.
1829 * Example: see GEOM_TestMeasures.py
1831 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1832 if MeasuOp.IsDone() == 0:
1833 print "MinDistance : ", MeasuOp.GetErrorCode()
1836 def Tolerance(theShape):
1838 * Get min and max tolerances of sub-shapes of theShape
1839 * \param theShape Shape, to get tolerances of.
1840 * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1841 * FaceMin,FaceMax: Min and max tolerances of the faces.
1842 * EdgeMin,EdgeMax: Min and max tolerances of the edges.
1843 * VertMin,VertMax: Min and max tolerances of the vertices.
1845 * Example: see GEOM_TestMeasures.py
1847 aTuple = MeasuOp.GetTolerance(theShape)
1848 if MeasuOp.IsDone() == 0:
1849 print "Tolerance : ", MeasuOp.GetErrorCode()
1852 def WhatIs(theShape):
1854 * Obtain description of the given shape (number of sub-shapes of each type)
1855 * \param theShape Shape to be described.
1856 * \return Description of the given shape.
1858 * Example: see GEOM_TestMeasures.py
1860 aDescr = MeasuOp.WhatIs(theShape)
1861 if MeasuOp.IsDone() == 0:
1862 print "WhatIs : ", MeasuOp.GetErrorCode()
1865 def MakeCDG(theShape):
1867 * Get a point, situated at the centre of mass of theShape.
1868 * \param theShape Shape to define centre of mass of.
1869 * \return New GEOM_Object, containing the created point.
1871 * Example: see GEOM_TestMeasures.py
1873 anObj = MeasuOp.GetCentreOfMass(theShape)
1874 if MeasuOp.IsDone() == 0:
1875 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1878 def CheckShape(theShape):
1880 * Check a topology of the given shape.
1881 * \param theShape Shape to check validity of.
1882 * \return TRUE, if the shape "seems to be valid" from the topological point of view.
1883 * If theShape is invalid, prints a description of problem.
1885 * Example: see GEOM_TestMeasures.py
1887 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1888 if MeasuOp.IsDone() == 0:
1889 print "CheckShape : ", MeasuOp.GetErrorCode()
1895 # -----------------------------------------------------------------------------
1896 # Import/Export objects
1897 # -----------------------------------------------------------------------------
1899 def Import(theFileName, theFormatName):
1901 * Import a shape from the BREP or IGES or STEP file
1902 * (depends on given format) with given name.
1903 * \param theFileName The file, containing the shape.
1904 * \param theFormatName Specify format for the file reading.
1905 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1906 * \return New GEOM_Object, containing the imported shape.
1908 * Example: see GEOM_TestOthers.py
1910 anObj = InsertOp.Import(theFileName, theFormatName)
1911 if InsertOp.IsDone() == 0:
1912 print "Import : ", InsertOp.GetErrorCode()
1915 def ImportBREP(theFileName):
1917 * Shortcut to Import() for BREP format
1919 * Example: see GEOM_TestOthers.py
1921 return Import(theFileName, "BREP")
1923 def ImportIGES(theFileName):
1925 * Shortcut to Import() for IGES format
1927 * Example: see GEOM_TestOthers.py
1929 return Import(theFileName, "IGES")
1931 def ImportSTEP(theFileName):
1933 * Shortcut to Import() for STEP format
1935 * Example: see GEOM_TestOthers.py
1937 return Import(theFileName, "STEP")
1939 def Export(theObject, theFileName, theFormatName):
1941 * Export the given shape into a file with given name.
1942 * \param theObject Shape to be stored in the file.
1943 * \param theFileName Name of the file to store the given shape in.
1944 * \param theFormatName Specify format for the shape storage.
1945 * Available formats can be obtained with InsertOp.ImportTranslators() method.
1947 * Example: see GEOM_TestOthers.py
1949 InsertOp.Export(theObject, theFileName, theFormatName)
1950 if InsertOp.IsDone() == 0:
1951 print "Export : ", InsertOp.GetErrorCode()
1953 def ExportBREP(theObject, theFileName):
1955 * Shortcut to Export() for BREP format
1957 * Example: see GEOM_TestOthers.py
1959 return Export(theObject, theFileName, "BREP")
1961 def ExportIGES(theObject, theFileName):
1963 * Shortcut to Export() for IGES format
1965 * Example: see GEOM_TestOthers.py
1967 return Export(theObject, theFileName, "IGES")
1969 def ExportSTEP(theObject, theFileName):
1971 * Shortcut to Export() for STEP format
1973 * Example: see GEOM_TestOthers.py
1975 return Export(theObject, theFileName, "STEP")
1977 # -----------------------------------------------------------------------------
1979 # -----------------------------------------------------------------------------
1981 def MakeQuad(E1, E2, E3, E4):
1983 * Create a quadrangle face from four edges. Order of Edges is not
1984 * important. It is not necessary that edges share the same vertex.
1985 * \param E1,E2,E3,E4 Edges for the face bound.
1986 * \return New GEOM_Object, containing the created face.
1988 * Example: see GEOM_Spanner.py
1990 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
1991 if BlocksOp.IsDone() == 0:
1992 print "MakeQuad : ", BlocksOp.GetErrorCode()
1995 def MakeQuad2Edges(E1, E2):
1997 * Create a quadrangle face on two edges.
1998 * The missing edges will be built by creating the shortest ones.
1999 * \param E1,E2 Two opposite edges for the face.
2000 * \return New GEOM_Object, containing the created face.
2002 * Example: see GEOM_Spanner.py
2004 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2005 if BlocksOp.IsDone() == 0:
2006 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2009 def MakeQuad4Vertices(V1, V2, V3, V4):
2011 * Create a quadrangle face with specified corners.
2012 * The missing edges will be built by creating the shortest ones.
2013 * \param V1,V2,V3,V4 Corner vertices for the face.
2014 * \return New GEOM_Object, containing the created face.
2016 * Example: see GEOM_Spanner.py
2018 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2019 if BlocksOp.IsDone() == 0:
2020 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2023 def MakeHexa(F1, F2, F3, F4, F5, F6):
2025 * Create a hexahedral solid, bounded by the six given faces. Order of
2026 * faces is not important. It is not necessary that Faces share the same edge.
2027 * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2028 * \return New GEOM_Object, containing the created solid.
2030 * Example: see GEOM_Spanner.py
2032 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2033 if BlocksOp.IsDone() == 0:
2034 print "MakeHexa : ", BlocksOp.GetErrorCode()
2037 def MakeHexa2Faces(F1, F2):
2039 * Create a hexahedral solid between two given faces.
2040 * The missing faces will be built by creating the smallest ones.
2041 * \param F1,F2 Two opposite faces for the hexahedral solid.
2042 * \return New GEOM_Object, containing the created solid.
2044 * Example: see GEOM_Spanner.py
2046 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2047 if BlocksOp.IsDone() == 0:
2048 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2051 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2053 * Get a vertex, found in the given shape by its coordinates.
2054 * \param theShape Block or a compound of blocks.
2055 * \param theX,theY,theZ Coordinates of the sought vertex.
2056 * \param theEpsilon Maximum allowed distance between the resulting
2057 * vertex and point with the given coordinates.
2058 * \return New GEOM_Object, containing the found vertex.
2060 * Example: see GEOM_TestOthers.py
2062 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2063 if BlocksOp.IsDone() == 0:
2064 print "GetPoint : ", BlocksOp.GetErrorCode()
2067 def GetEdge(theShape, thePoint1, thePoint2):
2069 * Get an edge, found in the given shape by two given vertices.
2070 * \param theShape Block or a compound of blocks.
2071 * \param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2072 * \return New GEOM_Object, containing the found edge.
2074 * Example: see GEOM_Spanner.py
2076 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2077 if BlocksOp.IsDone() == 0:
2078 print "GetEdge : ", BlocksOp.GetErrorCode()
2081 def GetEdgeNearPoint(theShape, thePoint):
2083 * Find an edge of the given shape, which has minimal distance to the given point.
2084 * \param theShape Block or a compound of blocks.
2085 * \param thePoint Point, close to the desired edge.
2086 * \return New GEOM_Object, containing the found edge.
2088 * Example: see GEOM_TestOthers.py
2090 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2091 if BlocksOp.IsDone() == 0:
2092 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2095 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2097 * Returns a face, found in the given shape by four given corner vertices.
2098 * \param theShape Block or a compound of blocks.
2099 * \param thePoint1-thePoint4 Points, close to the corners of the desired face.
2100 * \return New GEOM_Object, containing the found face.
2102 * Example: see GEOM_Spanner.py
2104 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2105 if BlocksOp.IsDone() == 0:
2106 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2109 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2111 * Get a face of block, found in the given shape by two given edges.
2112 * \param theShape Block or a compound of blocks.
2113 * \param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2114 * \return New GEOM_Object, containing the found face.
2116 * Example: see GEOM_Spanner.py
2118 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2119 if BlocksOp.IsDone() == 0:
2120 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2123 def GetOppositeFace(theBlock, theFace):
2125 * Find a face, opposite to the given one in the given block.
2126 * \param theBlock Must be a hexahedral solid.
2127 * \param theFace Face of \a theBlock, opposite to the desired face.
2128 * \return New GEOM_Object, containing the found face.
2130 * Example: see GEOM_Spanner.py
2132 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2133 if BlocksOp.IsDone() == 0:
2134 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2137 def GetFaceNearPoint(theShape, thePoint):
2139 * Find a face of the given shape, which has minimal distance to the given point.
2140 * \param theShape Block or a compound of blocks.
2141 * \param thePoint Point, close to the desired face.
2142 * \return New GEOM_Object, containing the found face.
2144 * Example: see GEOM_Spanner.py
2146 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2147 if BlocksOp.IsDone() == 0:
2148 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2151 def GetFaceByNormale(theBlock, theVector):
2153 * Find a face of block, whose outside normale has minimal angle with the given vector.
2154 * \param theShape Block or a compound of blocks.
2155 * \param theVector Vector, close to the normale of the desired face.
2156 * \return New GEOM_Object, containing the found face.
2158 * Example: see GEOM_Spanner.py
2160 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2161 if BlocksOp.IsDone() == 0:
2162 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2165 def CheckCompoundOfBlocks(theCompound):
2167 * Check, if the compound of blocks is given.
2168 * To be considered as a compound of blocks, the
2169 * given shape must satisfy the following conditions:
2170 * - Each element of the compound should be a Block (6 faces and 12 edges).
2171 * - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2172 * - The compound should be connexe.
2173 * - The glue between two quadrangle faces should be applied.
2174 * \param theCompound The compound to check.
2175 * \return TRUE, if the given shape is a compound of blocks.
2176 * If theCompound is not valid, prints all discovered errors.
2178 * Example: see GEOM_Spanner.py
2180 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2181 if BlocksOp.IsDone() == 0:
2182 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2185 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2189 def RemoveExtraEdges(theShape):
2191 * Remove all seam and degenerated edges from \a theShape.
2192 * Unite faces and edges, sharing one surface.
2193 * \param theShape The compound or single solid to remove irregular edges from.
2194 * \return Improved shape.
2196 * Example: see GEOM_TestOthers.py
2198 anObj = BlocksOp.RemoveExtraEdges(theShape)
2199 if BlocksOp.IsDone() == 0:
2200 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2203 def CheckAndImprove(theShape):
2205 * Check, if the given shape is a blocks compound.
2206 * Fix all detected errors.
2207 * \note Single block can be also fixed by this method.
2208 * \param theCompound The compound to check and improve.
2209 * \return Improved compound.
2211 * Example: see GEOM_TestOthers.py
2213 anObj = BlocksOp.CheckAndImprove(theShape)
2214 if BlocksOp.IsDone() == 0:
2215 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2218 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2220 * Get all the blocks, contained in the given compound.
2221 * \param theCompound The compound to explode.
2222 * \param theMinNbFaces If solid has lower number of faces, it is not a block.
2223 * \param theMaxNbFaces If solid has higher number of faces, it is not a block.
2224 * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2225 * \return List of GEOM_Objects, containing the retrieved blocks.
2227 * Example: see GEOM_TestOthers.py
2229 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2230 if BlocksOp.IsDone() == 0:
2231 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2234 def GetBlockNearPoint(theCompound, thePoint):
2236 * Find block, containing the given point inside its volume or on boundary.
2237 * \param theCompound Compound, to find block in.
2238 * \param thePoint Point, close to the desired block. If the point lays on
2239 * boundary between some blocks, we return block with nearest center.
2240 * \return New GEOM_Object, containing the found block.
2242 * Example: see GEOM_Spanner.py
2244 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2245 if BlocksOp.IsDone() == 0:
2246 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2249 def GetBlockByParts(theCompound, theParts):
2251 * Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2252 * \param theCompound Compound, to find block in.
2253 * \param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2254 * \return New GEOM_Object, containing the found block.
2256 * Example: see GEOM_TestOthers.py
2258 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2259 if BlocksOp.IsDone() == 0:
2260 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2263 def GetBlocksByParts(theCompound, theParts):
2265 * Return all blocks, containing all the elements, passed as the parts.
2266 * \param theCompound Compound, to find blocks in.
2267 * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2268 * \return List of GEOM_Objects, containing the found blocks.
2270 * Example: see GEOM_Spanner.py
2272 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2273 if BlocksOp.IsDone() == 0:
2274 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2277 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2279 * Multi-transformate block and glue the result.
2280 * Transformation is defined so, as to superpose direction faces.
2281 * \param Block Hexahedral solid to be multi-transformed.
2282 * \param DirFace1 ID of First direction face.
2283 * \param DirFace2 ID of Second direction face.
2284 * \param NbTimes Quantity of transformations to be done.
2285 * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2286 * \return New GEOM_Object, containing the result shape.
2288 * Example: see GEOM_Spanner.py
2290 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2291 if BlocksOp.IsDone() == 0:
2292 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2295 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2296 DirFace1V, DirFace2V, NbTimesV):
2298 * Multi-transformate block and glue the result.
2299 * \param Block Hexahedral solid to be multi-transformed.
2300 * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2301 * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2302 * \param NbTimesU,NbTimesV Quantity of transformations to be done.
2303 * \return New GEOM_Object, containing the result shape.
2305 * Example: see GEOM_Spanner.py
2307 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2308 DirFace1V, DirFace2V, NbTimesV)
2309 if BlocksOp.IsDone() == 0:
2310 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2313 def Propagate(theShape):
2315 * Build all possible propagation groups.
2316 * Propagation group is a set of all edges, opposite to one (main)
2317 * edge of this group directly or through other opposite edges.
2318 * Notion of Opposite Edge make sence only on quadrangle face.
2319 * \param theShape Shape to build propagation groups on.
2320 * \return List of GEOM_Objects, each of them is a propagation group.
2322 * Example: see GEOM_TestOthers.py
2324 listChains = BlocksOp.Propagate(theShape)
2325 if BlocksOp.IsDone() == 0:
2326 print "Propagate : ", BlocksOp.GetErrorCode()
2329 # -----------------------------------------------------------------------------
2331 # -----------------------------------------------------------------------------
2333 def CreateGroup(theMainShape, theShapeType):
2335 * Creates a new group which will store sub shapes of theMainShape
2336 * \param theMainShape is a GEOM object on which the group is selected
2337 * \param theShapeType defines a shape type of the group
2338 * \return a newly created GEOM group
2340 * Example: see GEOM_TestOthers.py
2342 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2343 if GroupOp.IsDone() == 0:
2344 print "CreateGroup : ", GroupOp.GetErrorCode()
2347 def AddObject(theGroup, theSubShapeID):
2349 * Adds a sub object with ID theSubShapeId to the group
2350 * \param theGroup is a GEOM group to which the new sub shape is added
2351 * \param theSubShapeID is a sub shape ID in the main object.
2352 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2354 * Example: see GEOM_TestOthers.py
2356 GroupOp.AddObject(theGroup, theSubShapeID)
2357 if GroupOp.IsDone() == 0:
2358 print "AddObject : ", GroupOp.GetErrorCode()
2360 def RemoveObject(theGroup, theSubShapeID):
2362 * Removes a sub object with ID \a theSubShapeId from the group
2363 * \param theGroup is a GEOM group from which the new sub shape is removed
2364 * \param theSubShapeID is a sub shape ID in the main object.
2365 * \note Use method GetSubShapeID() to get an unique ID of the sub shape
2367 * Example: see GEOM_TestOthers.py
2369 GroupOp.RemoveObject(theGroup, theSubShapeID)
2370 if GroupOp.IsDone() == 0:
2371 print "RemoveObject : ", GroupOp.GetErrorCode()
2373 def UnionList (theGroup, theSubShapes):
2375 * Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2376 * \param theGroup is a GEOM group to which the new sub shapes are added.
2377 * \param theSubShapes is a list of sub shapes to be added.
2379 * Example: see GEOM_TestOthers.py
2381 GroupOp.UnionList(theGroup, theSubShapes)
2382 if GroupOp.IsDone() == 0:
2383 print "UnionList : ", GroupOp.GetErrorCode()
2385 def DifferenceList (theGroup, theSubShapes):
2387 * Removes from the group all the given shapes. No errors, if some shapes are not included.
2388 * \param theGroup is a GEOM group from which the sub-shapes are removed.
2389 * \param theSubShapes is a list of sub-shapes to be removed.
2391 * Example: see GEOM_TestOthers.py
2393 GroupOp.DifferenceList(theGroup, theSubShapes)
2394 if GroupOp.IsDone() == 0:
2395 print "DifferenceList : ", GroupOp.GetErrorCode()
2397 def GetObjectIDs(theGroup):
2399 * Returns a list of sub objects ID stored in the group
2400 * \param theGroup is a GEOM group for which a list of IDs is requested
2402 * Example: see GEOM_TestOthers.py
2404 ListIDs = GroupOp.GetObjects(theGroup)
2405 if GroupOp.IsDone() == 0:
2406 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2409 def GetType(theGroup):
2411 * Returns a type of sub objects stored in the group
2412 * \param theGroup is a GEOM group which type is returned.
2414 * Example: see GEOM_TestOthers.py
2416 aType = GroupOp.GetType(theGroup)
2417 if GroupOp.IsDone() == 0:
2418 print "GetType : ", GroupOp.GetErrorCode()
2421 def GetMainShape(theGroup):
2423 * Returns a main shape associated with the group
2424 * \param theGroup is a GEOM group for which a main shape object is requested
2425 * \return a GEOM object which is a main shape for theGroup
2427 * Example: see GEOM_TestOthers.py
2429 anObj = GroupOp.GetMainShape(theGroup)
2430 if GroupOp.IsDone() == 0:
2431 print "GetMainShape : ", GroupOp.GetErrorCode()
2434 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2436 Create group of edges of theShape, whose length is in range [min_length, max_length].
2437 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2440 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2443 Props = BasicProperties(edge)
2444 if min_length <= Props[0] and Props[0] <= max_length:
2445 if (not include_min) and (min_length == Props[0]):
2448 if (not include_max) and (Props[0] == max_length):
2451 edges_in_range.append(edge)
2453 if len(edges_in_range) <= 0:
2454 print "No edges found by given criteria"
2457 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2458 UnionList(group_edges, edges_in_range)
2462 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2464 Create group of edges of selected shape, whose length is in range [min_length, max_length].
2465 If include_min/max == 0, edges with length == min/max_length will not be included in result.
2468 nb_selected = sg.SelectedCount()
2470 print "Select a shape before calling this function, please."
2473 print "Only one shape must be selected"
2476 id_shape = sg.getSelected(0)
2477 shape = IDToObject( id_shape )
2479 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2483 if include_min: left_str = " <= "
2484 if include_max: right_str = " <= "
2486 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2487 + left_str + "length" + right_str + `max_length`)
2489 sg.updateObjBrowser(1)
2495 * Add Path to load python scripts from
2497 if (sys.path.count(Path) < 1):
2498 sys.path.append(Path)