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.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # Author : Paul RASCLE, EDF
40 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
41 geom = g._narrow( GEOM.GEOM_Gen )
42 #gg = ImportComponentGUI("GEOM")
45 #SRN: modified on Mar 18, 2005
64 def init_geom(theStudy):
66 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
67 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
70 myStudyId = myStudy._get_StudyId()
71 myBuilder = myStudy.NewBuilder()
72 father = myStudy.FindComponent("GEOM")
74 father = myBuilder.NewComponent("GEOM")
75 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
76 FName = A1._narrow(SALOMEDS.AttributeName)
77 FName.SetValue("Geometry")
78 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
79 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
80 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
81 myBuilder.DefineComponentInstance(father,geom)
84 # -----------------------------------------------------------------------------
85 # Assign Operations Interfaces
86 # -----------------------------------------------------------------------------
88 BasicOp = geom.GetIBasicOperations (myStudyId)
89 CurvesOp = geom.GetICurvesOperations (myStudyId)
90 PrimOp = geom.GetI3DPrimOperations (myStudyId)
91 ShapesOp = geom.GetIShapesOperations (myStudyId)
92 HealOp = geom.GetIHealingOperations (myStudyId)
93 InsertOp = geom.GetIInsertOperations (myStudyId)
94 BoolOp = geom.GetIBooleanOperations (myStudyId)
95 TrsfOp = geom.GetITransformOperations(myStudyId)
96 LocalOp = geom.GetILocalOperations (myStudyId)
97 MeasuOp = geom.GetIMeasureOperations (myStudyId)
98 BlocksOp = geom.GetIBlocksOperations (myStudyId)
99 GroupOp = geom.GetIGroupOperations (myStudyId)
104 #SRN: end of modifications
106 ## Get name for sub-shape aSubObj of shape aMainObj
108 # Example: see GEOM_TestAll.py
109 def SubShapeName(aSubObj, aMainObj):
110 #aSubId = orb.object_to_string(aSubObj)
111 #aMainId = orb.object_to_string(aMainObj)
112 #index = gg.getIndexTopology(aSubId, aMainId)
113 #name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
114 index = ShapesOp.GetTopologyIndex(aMainObj, aSubObj)
115 name = ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index)
118 ## Publish in study aShape with name aName
120 # Example: see GEOM_TestAll.py
121 def addToStudy(aShape, aName):
123 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
125 print "addToStudy() failed"
127 return aShape.GetStudyEntry()
129 ## Publish in study aShape with name aName as sub-object of previously published aFather
131 # Example: see GEOM_TestAll.py
132 def addToStudyInFather(aFather, aShape, aName):
134 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
136 print "addToStudyInFather() failed"
138 return aShape.GetStudyEntry()
140 # -----------------------------------------------------------------------------
141 # enumeration ShapeType as a dictionary
142 # -----------------------------------------------------------------------------
144 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
146 # -----------------------------------------------------------------------------
147 # enumeration shape_kind
148 # -----------------------------------------------------------------------------
150 kind = GEOM.GEOM_IKindOfShape
157 # -----------------------------------------------------------------------------
159 # -----------------------------------------------------------------------------
161 ## Create point by three coordinates.
162 # @param theX The X coordinate of the point.
163 # @param theY The Y coordinate of the point.
164 # @param theZ The Z coordinate of the point.
165 # @return New GEOM_Object, containing the created point.
167 # Example: see GEOM_TestAll.py
168 def MakeVertex(theX, theY, theZ):
169 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
170 if BasicOp.IsDone() == 0:
171 print "MakePointXYZ : ", BasicOp.GetErrorCode()
174 ## Create a point, distant from the referenced point
175 # on the given distances along the coordinate axes.
176 # @param theReference The referenced point.
177 # @param theX Displacement from the referenced point along OX axis.
178 # @param theY Displacement from the referenced point along OY axis.
179 # @param theZ Displacement from the referenced point along OZ axis.
180 # @return New GEOM_Object, containing the created point.
182 # Example: see GEOM_TestAll.py
183 def MakeVertexWithRef(theReference, theX, theY, theZ):
184 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
185 if BasicOp.IsDone() == 0:
186 print "MakePointWithReference : ", BasicOp.GetErrorCode()
189 ## Create a point, corresponding to the given parameter on the given curve.
190 # @param theRefCurve The referenced curve.
191 # @param theParameter Value of parameter on the referenced curve.
192 # @return New GEOM_Object, containing the created point.
194 # Example: see GEOM_TestAll.py
195 def MakeVertexOnCurve(theRefCurve, theParameter):
196 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
197 if BasicOp.IsDone() == 0:
198 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
201 ## Create a tangent, corresponding to the given parameter on the given curve.
202 # @param theRefCurve The referenced curve.
203 # @param theParameter Value of parameter on the referenced curve.
204 # @return New GEOM_Object, containing the created tangent.
205 def MakeTangentOnCurve(theRefCurve, theParameter):
206 anObj = BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
207 if BasicOp.IsDone() == 0:
208 print "MakeTangentOnCurve : ", BasicOp.GetErrorCode()
211 ## Create a vector with the given components.
212 # @param theDX X component of the vector.
213 # @param theDY Y component of the vector.
214 # @param theDZ Z component of the vector.
215 # @return New GEOM_Object, containing the created vector.
217 # Example: see GEOM_TestAll.py
218 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
219 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
220 if BasicOp.IsDone() == 0:
221 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
224 ## Create a vector between two points.
225 # @param thePnt1 Start point for the vector.
226 # @param thePnt2 End point for the vector.
227 # @return New GEOM_Object, containing the created vector.
229 # Example: see GEOM_TestAll.py
230 def MakeVector(thePnt1, thePnt2):
231 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
232 if BasicOp.IsDone() == 0:
233 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
236 ## Create a line, passing through the given point
237 # and parrallel to the given direction
238 # @param thePnt Point. The resulting line will pass through it.
239 # @param theDir Direction. The resulting line will be parallel to it.
240 # @return New GEOM_Object, containing the created line.
242 # Example: see GEOM_TestAll.py
243 def MakeLine(thePnt, theDir):
244 anObj = BasicOp.MakeLine(thePnt, theDir)
245 if BasicOp.IsDone() == 0:
246 print "MakeLine : ", BasicOp.GetErrorCode()
249 ## Create a line, passing through the given points
250 # @param thePnt1 First of two points, defining the line.
251 # @param thePnt2 Second of two points, defining the line.
252 # @return New GEOM_Object, containing the created line.
254 # Example: see GEOM_TestAll.py
255 def MakeLineTwoPnt(thePnt1, thePnt2):
256 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
257 if BasicOp.IsDone() == 0:
258 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
261 ## Create a plane, passing through the given point
262 # and normal to the given vector.
263 # @param thePnt Point, the plane has to pass through.
264 # @param theVec Vector, defining the plane normal direction.
265 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
266 # @return New GEOM_Object, containing the created plane.
268 # Example: see GEOM_TestAll.py
269 def MakePlane(thePnt, theVec, theTrimSize):
270 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
271 if BasicOp.IsDone() == 0:
272 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
275 ## Create a plane, passing through the three given points
276 # @param thePnt1 First of three points, defining the plane.
277 # @param thePnt2 Second of three points, defining the plane.
278 # @param thePnt3 Fird of three points, defining the plane.
279 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
280 # @return New GEOM_Object, containing the created plane.
282 # Example: see GEOM_TestAll.py
283 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
284 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
285 if BasicOp.IsDone() == 0:
286 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
289 ## Create a plane, similar to the existing one, but with another size of representing face.
290 # @param theFace Referenced plane or LCS(Marker).
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
295 def MakePlaneFace(theFace, theTrimSize):
296 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
297 if BasicOp.IsDone() == 0:
298 print "MakePlaneFace : ", BasicOp.GetErrorCode()
301 ## Create a local coordinate system.
302 # @param OX,OY,OZ Three coordinates of coordinate system origin.
303 # @param XDX,XDY,XDZ Three components of OX direction
304 # @param YDX,YDY,YDZ Three components of OY direction
305 # @return New GEOM_Object, containing the created coordinate system.
307 # Example: see GEOM_TestAll.py
308 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
309 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
310 if BasicOp.IsDone() == 0:
311 print "MakeMarker : ", BasicOp.GetErrorCode()
314 ## Create a local coordinate system.
315 # @param theOrigin Point of coordinate system origin.
316 # @param theXVec Vector of X direction
317 # @param theYVec Vector of Y direction
318 # @return New GEOM_Object, containing the created coordinate system.
319 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
320 O = PointCoordinates( theOrigin )
322 for vec in [ theXVec, theYVec ]:
323 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
324 p1 = PointCoordinates( v1 )
325 p2 = PointCoordinates( v2 )
326 for i in range( 0, 3 ):
327 OXOY.append( p2[i] - p1[i] )
329 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
330 OXOY[0], OXOY[1], OXOY[2],
331 OXOY[3], OXOY[4], OXOY[5], )
332 if BasicOp.IsDone() == 0:
333 print "MakeMarker : ", BasicOp.GetErrorCode()
336 # -----------------------------------------------------------------------------
338 # -----------------------------------------------------------------------------
340 ## Create an arc of circle, passing through three given points.
341 # @param thePnt1 Start point of the arc.
342 # @param thePnt2 Middle point of the arc.
343 # @param thePnt3 End point of the arc.
344 # @return New GEOM_Object, containing the created arc.
346 # Example: see GEOM_TestAll.py
347 def MakeArc(thePnt1, thePnt2, thePnt3):
348 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
349 if CurvesOp.IsDone() == 0:
350 print "MakeArc : ", CurvesOp.GetErrorCode()
353 ## Create an arc of circle from a center and 2 points.
354 # @param thePnt1 Center of the arc
355 # @param thePnt2 Start point of the arc. (Gives also the radius of the arc)
356 # @param thePnt3 End point of the arc (Gives also a direction)
357 # @return New GEOM_Object, containing the created arc.
359 # Example: see GEOM_TestAll.py
360 def MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense):
361 anObj = CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense)
362 if CurvesOp.IsDone() == 0:
363 print "MakeArcCenter : ", CurvesOp.GetErrorCode()
366 ## Create a circle with given center, normal vector and radius.
367 # @param thePnt Circle center.
368 # @param theVec Vector, normal to the plane of the circle.
369 # @param theR Circle radius.
370 # @return New GEOM_Object, containing the created circle.
372 # Example: see GEOM_TestAll.py
373 def MakeCircle(thePnt, theVec, theR):
374 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
375 if CurvesOp.IsDone() == 0:
376 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
379 ## Create a circle, passing through three given points
380 # @param thePnt1,thePnt2,thePnt3 Points, defining the circle.
381 # @return New GEOM_Object, containing the created circle.
383 # Example: see GEOM_TestAll.py
384 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
385 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
386 if CurvesOp.IsDone() == 0:
387 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
390 ## Create an ellipse with given center, normal vector and radiuses.
391 # @param thePnt Ellipse center.
392 # @param theVec Vector, normal to the plane of the ellipse.
393 # @param theRMajor Major ellipse radius.
394 # @param theRMinor Minor ellipse radius.
395 # @return New GEOM_Object, containing the created ellipse.
397 # Example: see GEOM_TestAll.py
398 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
399 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
400 if CurvesOp.IsDone() == 0:
401 print "MakeEllipse : ", CurvesOp.GetErrorCode()
404 ## Create a polyline on the set of points.
405 # @param thePoints Sequence of points for the polyline.
406 # @return New GEOM_Object, containing the created polyline.
408 # Example: see GEOM_TestAll.py
409 def MakePolyline(thePoints):
410 anObj = CurvesOp.MakePolyline(thePoints)
411 if CurvesOp.IsDone() == 0:
412 print "MakePolyline : ", CurvesOp.GetErrorCode()
415 ## Create bezier curve on the set of points.
416 # @param thePoints Sequence of points for the bezier curve.
417 # @return New GEOM_Object, containing the created bezier curve.
419 # Example: see GEOM_TestAll.py
420 def MakeBezier(thePoints):
421 anObj = CurvesOp.MakeSplineBezier(thePoints)
422 if CurvesOp.IsDone() == 0:
423 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
426 ## Create B-Spline curve on the set of points.
427 # @param thePoints Sequence of points for the B-Spline curve.
428 # @return New GEOM_Object, containing the created B-Spline curve.
430 # Example: see GEOM_TestAll.py
431 def MakeInterpol(thePoints):
432 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
433 if CurvesOp.IsDone() == 0:
434 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
437 ## Create a sketcher (wire or face), following the textual description,
438 # passed through \a theCommand argument. \n
439 # Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
440 # Format of the description string have to be the following:
442 # "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
445 # - x1, y1 are coordinates of the first sketcher point (zero by default),
447 # - "R angle" : Set the direction by angle
448 # - "D dx dy" : Set the direction by DX & DY
451 # - "TT x y" : Create segment by point at X & Y
452 # - "T dx dy" : Create segment by point with DX & DY
453 # - "L length" : Create segment by direction & Length
454 # - "IX x" : Create segment by direction & Intersect. X
455 # - "IY y" : Create segment by direction & Intersect. Y
458 # - "C radius length" : Create arc by direction, radius and length(in degree)
461 # - "WW" : Close Wire (to finish)
462 # - "WF" : Close Wire and build face (to finish)
464 # @param theCommand String, defining the sketcher in local
465 # coordinates of the working plane.
466 # @param theWorkingPlane Nine double values, defining origin,
467 # OZ and OX directions of the working plane.
468 # @return New GEOM_Object, containing the created wire.
470 # Example: see GEOM_TestAll.py
471 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
472 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
473 if CurvesOp.IsDone() == 0:
474 print "MakeSketcher : ", CurvesOp.GetErrorCode()
477 ## Create a sketcher (wire or face), following the textual description,
478 # passed through \a theCommand argument. \n
479 # For format of the description string see the previous method.\n
480 # @param theCommand String, defining the sketcher in local
481 # coordinates of the working plane.
482 # @param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
483 # @return New GEOM_Object, containing the created wire.
484 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
485 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
486 if CurvesOp.IsDone() == 0:
487 print "MakeSketcher : ", CurvesOp.GetErrorCode()
490 # -----------------------------------------------------------------------------
491 # Create 3D Primitives
492 # -----------------------------------------------------------------------------
494 ## Create a box by coordinates of two opposite vertices.
496 # Example: see GEOM_TestAll.py
497 def MakeBox(x1,y1,z1,x2,y2,z2):
498 pnt1 = MakeVertex(x1,y1,z1)
499 pnt2 = MakeVertex(x2,y2,z2)
500 return MakeBoxTwoPnt(pnt1,pnt2)
502 ## Create a box with specified dimensions along the coordinate axes
503 # and with edges, parallel to the coordinate axes.
504 # Center of the box will be at point (DX/2, DY/2, DZ/2).
505 # @param theDX Length of Box edges, parallel to OX axis.
506 # @param theDY Length of Box edges, parallel to OY axis.
507 # @param theDZ Length of Box edges, parallel to OZ axis.
508 # @return New GEOM_Object, containing the created box.
510 # Example: see GEOM_TestAll.py
511 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
512 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
513 if PrimOp.IsDone() == 0:
514 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
517 ## Create a box with two specified opposite vertices,
518 # and with edges, parallel to the coordinate axes
519 # @param thePnt1 First of two opposite vertices.
520 # @param thePnt2 Second of two opposite vertices.
521 # @return New GEOM_Object, containing the created box.
523 # Example: see GEOM_TestAll.py
524 def MakeBoxTwoPnt(thePnt1, thePnt2):
525 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
526 if PrimOp.IsDone() == 0:
527 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
530 ## Create a cylinder with given base point, axis, radius and height.
531 # @param thePnt Central point of cylinder base.
532 # @param theAxis Cylinder axis.
533 # @param theR Cylinder radius.
534 # @param theH Cylinder height.
535 # @return New GEOM_Object, containing the created cylinder.
537 # Example: see GEOM_TestAll.py
538 def MakeCylinder(thePnt, theAxis, theR, theH):
539 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
540 if PrimOp.IsDone() == 0:
541 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
544 ## Create a cylinder with given radius and height at
545 # the origin of coordinate system. Axis of the cylinder
546 # will be collinear to the OZ axis of the coordinate system.
547 # @param theR Cylinder radius.
548 # @param theH Cylinder height.
549 # @return New GEOM_Object, containing the created cylinder.
551 # Example: see GEOM_TestAll.py
552 def MakeCylinderRH(theR, theH):
553 anObj = PrimOp.MakeCylinderRH(theR, theH)
554 if PrimOp.IsDone() == 0:
555 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
558 ## Create a sphere with given center and radius.
559 # @param thePnt Sphere center.
560 # @param theR Sphere radius.
561 # @return New GEOM_Object, containing the created sphere.
563 # Example: see GEOM_TestAll.py
564 def MakeSpherePntR(thePnt, theR):
565 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
566 if PrimOp.IsDone() == 0:
567 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
570 ## Create a sphere with given center and radius.
571 # @param x,y,z Coordinates of sphere center.
572 # @param theR Sphere radius.
573 # @return New GEOM_Object, containing the created sphere.
575 # Example: see GEOM_TestAll.py
576 def MakeSphere(x, y, z, theR):
577 point = MakeVertex(x, y, z)
578 anObj = MakeSpherePntR(point, theR)
581 ## Create a sphere with given radius at the origin of coordinate system.
582 # @param theR Sphere radius.
583 # @return New GEOM_Object, containing the created sphere.
585 # Example: see GEOM_TestAll.py
586 def MakeSphereR(theR):
587 anObj = PrimOp.MakeSphereR(theR)
588 if PrimOp.IsDone() == 0:
589 print "MakeSphereR : ", PrimOp.GetErrorCode()
592 ## Create a cone with given base point, axis, height and radiuses.
593 # @param thePnt Central point of the first cone base.
594 # @param theAxis Cone axis.
595 # @param theR1 Radius of the first cone base.
596 # @param theR2 Radius of the second cone base.
597 # \note If both radiuses are non-zero, the cone will be truncated.
598 # \note If the radiuses are equal, a cylinder will be created instead.
599 # @param theH Cone height.
600 # @return New GEOM_Object, containing the created cone.
602 # Example: see GEOM_TestAll.py
603 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
604 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
605 if PrimOp.IsDone() == 0:
606 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
609 ## Create a cone with given height and radiuses at
610 # the origin of coordinate system. Axis of the cone will
611 # be collinear to the OZ axis of the coordinate system.
612 # @param theR1 Radius of the first cone base.
613 # @param theR2 Radius of the second cone base.
614 # \note If both radiuses are non-zero, the cone will be truncated.
615 # \note If the radiuses are equal, a cylinder will be created instead.
616 # @param theH Cone height.
617 # @return New GEOM_Object, containing the created cone.
619 # Example: see GEOM_TestAll.py
620 def MakeConeR1R2H(theR1, theR2, theH):
621 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
622 if PrimOp.IsDone() == 0:
623 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
626 ## Create a torus with given center, normal vector and radiuses.
627 # @param thePnt Torus central point.
628 # @param theVec Torus axis of symmetry.
629 # @param theRMajor Torus major radius.
630 # @param theRMinor Torus minor radius.
631 # @return New GEOM_Object, containing the created torus.
633 # Example: see GEOM_TestAll.py
634 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
635 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
636 if PrimOp.IsDone() == 0:
637 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
640 ## Create a torus with given radiuses at the origin of coordinate system.
641 # @param theRMajor Torus major radius.
642 # @param theRMinor Torus minor radius.
643 # @return New GEOM_Object, containing the created torus.
645 # Example: see GEOM_TestAll.py
646 def MakeTorusRR(theRMajor, theRMinor):
647 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
648 if PrimOp.IsDone() == 0:
649 print "MakeTorusRR : ", PrimOp.GetErrorCode()
652 ## Create a shape by extrusion of the base shape along a vector, defined by two points.
653 # @param theBase Base shape to be extruded.
654 # @param thePoint1 First end of extrusion vector.
655 # @param thePoint2 Second end of extrusion vector.
656 # @return New GEOM_Object, containing the created prism.
658 # Example: see GEOM_TestAll.py
659 def MakePrism(theBase, thePoint1, thePoint2):
660 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
661 if PrimOp.IsDone() == 0:
662 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
665 ## Create a shape by extrusion of the base shape along the vector,
666 # i.e. all the space, transfixed by the base shape during its translation
667 # along the vector on the given distance.
668 # @param theBase Base shape to be extruded.
669 # @param theVec Direction of extrusion.
670 # @param theH Prism dimension along theVec.
671 # @return New GEOM_Object, containing the created prism.
673 # Example: see GEOM_TestAll.py
674 def MakePrismVecH(theBase, theVec, theH):
675 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
676 if PrimOp.IsDone() == 0:
677 print "MakePrismVecH : ", PrimOp.GetErrorCode()
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
687 def MakePipe(theBase, thePath):
688 anObj = PrimOp.MakePipe(theBase, thePath)
689 if PrimOp.IsDone() == 0:
690 print "MakePipe : ", PrimOp.GetErrorCode()
693 ## Create a shape by revolution of the base shape around the axis
694 # on the given angle, i.e. all the space, transfixed by the base
695 # shape during its rotation around the axis on the given angle.
696 # @param theBase Base shape to be rotated.
697 # @param theAxis Rotation axis.
698 # @param theAngle Rotation angle in radians.
699 # @return New GEOM_Object, containing the created revolution.
701 # Example: see GEOM_TestAll.py
702 def MakeRevolution(theBase, theAxis, theAngle):
703 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
704 if PrimOp.IsDone() == 0:
705 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
708 ## Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices.
709 # @param theSeqSections - set of specified sections.
710 # @param theModeSolid - mode defining building solid or shell
711 # @param thePreci - precision 3D used for smoothing by default 1.e-6
712 # @param theRuled - mode defining type of the result surfaces (ruled or smoothed).
713 # @return New GEOM_Object, containing the created shell or solid.
715 # Example: see GEOM_TestAll.py
716 def MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled):
717 anObj = PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled)
718 if PrimOp.IsDone() == 0:
719 print "MakeThruSections : ", PrimOp.GetErrorCode()
722 ## Create a shape by extrusion of the profile shape along
723 # the path shape. The path shape can be a wire or an edge.
724 # the several profiles can be specified in the several locations of path.
725 # @param theSeqBases - list of Bases shape to be extruded.
726 # @param theLocations - list of locations on the path corresponding
727 # specified list of the Bases shapes. Number of locations
728 # should be equal to number of bases or list of locations can be empty.
729 # @param thePath - Path shape to extrude the base shape along it.
730 # @param theWithContact - the mode defining that the section is translated to be in
731 # contact with the spine.
732 # @param - WithCorrection - defining that the section is rotated to be
733 # orthogonal to the spine tangent in the correspondent point
734 # @return New GEOM_Object, containing the created pipe.
736 # Example: see GEOM_TestAll.py
737 def MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection):
738 anObj = PrimOp.MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection)
739 if PrimOp.IsDone() == 0:
740 print "MakePipeWithDifferentSections : ", PrimOp.GetErrorCode()
743 ## Create a shape by extrusion of the profile shape along
744 # the path shape. The path shape can be a shell or a face.
745 # the several profiles can be specified in the several locations of path.
746 # @param theSeqBases - list of Bases shape to be extruded.
747 # @param theSeqSubBases - list of corresponding subshapes of section shapes.
748 # @param theLocations - list of locations on the path corresponding
749 # specified list of the Bases shapes. Number of locations
750 # should be equal to number of bases. First and last
751 # locations must be coincided with first and last vertexes
752 # of path correspondingly.
753 # @param thePath - Path shape to extrude the base shape along it.
754 # @param theWithContact - the mode defining that the section is translated to be in
755 # contact with the spine.
756 # @param - WithCorrection - defining that the section is rotated to be
757 # orthogonal to the spine tangent in the correspondent point
758 # @return New GEOM_Object, containing the created solids.
760 # Example: see GEOM_TestAll.py
761 def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
762 theLocations, thePath,
763 theWithContact, theWithCorrection):
764 anObj = PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
765 theLocations, thePath,
766 theWithContact, theWithCorrection)
767 if PrimOp.IsDone() == 0:
768 print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
771 # -----------------------------------------------------------------------------
773 # -----------------------------------------------------------------------------
775 ## Create a linear edge with specified ends.
776 # @param thePnt1 Point for the first end of edge.
777 # @param thePnt2 Point for the second end of edge.
778 # @return New GEOM_Object, containing the created edge.
780 # Example: see GEOM_TestAll.py
781 def MakeEdge(thePnt1, thePnt2):
782 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
783 if ShapesOp.IsDone() == 0:
784 print "MakeEdge : ", ShapesOp.GetErrorCode()
787 ## Create a wire from the set of edges and wires.
788 # @param theEdgesAndWires List of edges and/or wires.
789 # @return New GEOM_Object, containing the created wire.
791 # Example: see GEOM_TestAll.py
792 def MakeWire(theEdgesAndWires):
793 anObj = ShapesOp.MakeWire(theEdgesAndWires)
794 if ShapesOp.IsDone() == 0:
795 print "MakeWire : ", ShapesOp.GetErrorCode()
798 ## Create a face on the given wire.
799 # @param theWire closed Wire or Edge to build the face on.
800 # @param isPlanarWanted If TRUE, only planar face will be built.
801 # If impossible, NULL object will be returned.
802 # @return New GEOM_Object, containing the created face.
804 # Example: see GEOM_TestAll.py
805 def MakeFace(theWire, isPlanarWanted):
806 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
807 if ShapesOp.IsDone() == 0:
808 print "MakeFace : ", ShapesOp.GetErrorCode()
811 ## Create a face on the given wires set.
812 # @param theWires List of closed wires or edges to build the face on.
813 # @param isPlanarWanted If TRUE, only planar face will be built.
814 # If impossible, NULL object will be returned.
815 # @return New GEOM_Object, containing the created face.
817 # Example: see GEOM_TestAll.py
818 def MakeFaceWires(theWires, isPlanarWanted):
819 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
820 if ShapesOp.IsDone() == 0:
821 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
824 ## Shortcut to MakeFaceWires()
826 # Example: see GEOM_TestOthers.py
827 def MakeFaces(theWires, isPlanarWanted):
828 anObj = MakeFaceWires(theWires, isPlanarWanted)
831 ## Create a shell from the set of faces and shells.
832 # @param theFacesAndShells List of faces and/or shells.
833 # @return New GEOM_Object, containing the created shell.
835 # Example: see GEOM_TestAll.py
836 def MakeShell(theFacesAndShells):
837 anObj = ShapesOp.MakeShell(theFacesAndShells)
838 if ShapesOp.IsDone() == 0:
839 print "MakeShell : ", ShapesOp.GetErrorCode()
842 ## Create a solid, bounded by the given shells.
843 # @param theShells Sequence of bounding shells.
844 # @return New GEOM_Object, containing the created solid.
846 # Example: see GEOM_TestAll.py
847 def MakeSolid(theShells):
848 anObj = ShapesOp.MakeSolidShells(theShells)
849 if ShapesOp.IsDone() == 0:
850 print "MakeSolid : ", ShapesOp.GetErrorCode()
853 ## Create a compound of the given shapes.
854 # @param theShapes List of shapes to put in compound.
855 # @return New GEOM_Object, containing the created compound.
857 # Example: see GEOM_TestAll.py
858 def MakeCompound(theShapes):
859 anObj = ShapesOp.MakeCompound(theShapes)
860 if ShapesOp.IsDone() == 0:
861 print "MakeCompound : ", ShapesOp.GetErrorCode()
864 ## Gives quantity of faces in the given shape.
865 # @param theShape Shape to count faces of.
866 # @return Quantity of faces.
868 # Example: see GEOM_TestOthers.py
869 def NumberOfFaces(theShape):
870 nb_faces = ShapesOp.NumberOfFaces(theShape)
871 if ShapesOp.IsDone() == 0:
872 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
875 ## Gives quantity of edges in the given shape.
876 # @param theShape Shape to count edges of.
877 # @return Quantity of edges.
879 # Example: see GEOM_TestOthers.py
880 def NumberOfEdges(theShape):
881 nb_edges = ShapesOp.NumberOfEdges(theShape)
882 if ShapesOp.IsDone() == 0:
883 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
886 ## Reverses an orientation the given shape.
887 # @param theShape Shape to be reversed.
888 # @return The reversed copy of theShape.
890 # Example: see GEOM_TestAll.py
891 def ChangeOrientation(theShape):
892 anObj = ShapesOp.ChangeOrientation(theShape)
893 if ShapesOp.IsDone() == 0:
894 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
897 ## Shortcut to ChangeOrientation()
899 # Example: see GEOM_TestOthers.py
900 def OrientationChange(theShape):
901 anObj = ChangeOrientation(theShape)
904 ## Retrieve all free faces from the given shape.
905 # Free face is a face, which is not shared between two shells of the shape.
906 # @param theShape Shape to find free faces in.
907 # @return List of IDs of all free faces, contained in theShape.
909 # Example: see GEOM_TestOthers.py
910 def GetFreeFacesIDs(theShape):
911 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
912 if ShapesOp.IsDone() == 0:
913 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
916 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
917 # @param theShape1 Shape to find sub-shapes in.
918 # @param theShape2 Shape to find shared sub-shapes with.
919 # @param theShapeType Type of sub-shapes to be retrieved.
920 # @return List of sub-shapes of theShape1, shared with theShape2.
922 # Example: see GEOM_TestOthers.py
923 def GetSharedShapes(theShape1, theShape2, theShapeType):
924 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
925 if ShapesOp.IsDone() == 0:
926 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
929 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
930 # the specified plane by the certain way, defined through \a theState parameter.
931 # @param theShape Shape to find sub-shapes of.
932 # @param theShapeType Type of sub-shapes to be retrieved.
933 # @param theAx1 Vector (or line, or linear edge), specifying normal
934 # direction and location of the plane to find shapes on.
935 # @param theState The state of the subshapes to find. It can be one of
936 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
937 # @return List of all found sub-shapes.
939 # Example: see GEOM_TestOthers.py
940 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
941 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
942 if ShapesOp.IsDone() == 0:
943 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
946 ## Works like the above method, but returns list of sub-shapes indices
948 # Example: see GEOM_TestOthers.py
949 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
950 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
951 if ShapesOp.IsDone() == 0:
952 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
955 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
956 # the specified plane by the certain way, defined through \a theState parameter.
957 # @param theShape Shape to find sub-shapes of.
958 # @param theShapeType Type of sub-shapes to be retrieved.
959 # @param theAx1 Vector (or line, or linear edge), specifying normal
960 # direction of the plane to find shapes on.
961 # @param thePnt Point specifying location of the plane to find shapes on.
962 # @param theState The state of the subshapes to find. It can be one of
963 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
964 # @return List of all found sub-shapes.
966 # Example: see GEOM_TestOthers.py
967 def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
968 aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
969 if ShapesOp.IsDone() == 0:
970 print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
973 ## Works like the above method, but returns list of sub-shapes indices
975 # Example: see GEOM_TestOthers.py
976 def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
977 aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
978 if ShapesOp.IsDone() == 0:
979 print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
982 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
983 # the specified cylinder by the certain way, defined through \a theState parameter.
984 # @param theShape Shape to find sub-shapes of.
985 # @param theShapeType Type of sub-shapes to be retrieved.
986 # @param theAxis Vector (or line, or linear edge), specifying
987 # axis of the cylinder to find shapes on.
988 # @param theRadius Radius of the cylinder to find shapes on.
989 # @param theState The state of the subshapes to find. It can be one of
990 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
991 # @return List of all found sub-shapes.
993 # Example: see GEOM_TestOthers.py
994 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
995 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
996 if ShapesOp.IsDone() == 0:
997 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
1000 ## Works like the above method, but returns list of sub-shapes indices
1002 # Example: see GEOM_TestOthers.py
1003 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
1004 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
1005 if ShapesOp.IsDone() == 0:
1006 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
1009 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1010 # the specified sphere by the certain way, defined through \a theState parameter.
1011 # @param theShape Shape to find sub-shapes of.
1012 # @param theShapeType Type of sub-shapes to be retrieved.
1013 # @param theCenter Point, specifying center of the sphere to find shapes on.
1014 # @param theRadius Radius of the sphere to find shapes on.
1015 # @param theState The state of the subshapes to find. It can be one of
1016 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1017 # @return List of all found sub-shapes.
1019 # Example: see GEOM_TestOthers.py
1020 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
1021 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1022 if ShapesOp.IsDone() == 0:
1023 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1026 ## Works like the above method, but returns list of sub-shapes indices
1028 # Example: see GEOM_TestOthers.py
1029 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1030 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1031 if ShapesOp.IsDone() == 0:
1032 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1035 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1036 # the specified quadrangle by the certain way, defined through \a theState parameter.
1037 # @param theShape Shape to find sub-shapes of.
1038 # @param theShapeType Type of sub-shapes to be retrieved.
1039 # @param theTopLeftPoint Point, specifying top left corner of a quadrangle
1040 # @param theTopRigthPoint Point, specifying top right corner of a quadrangle
1041 # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
1042 # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
1043 # @param theState The state of the subshapes to find. It can be one of
1044 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1045 # @return List of all found sub-shapes.
1047 # Example: see GEOM_TestOthers.py
1048 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1049 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1050 if ShapesOp.IsDone() == 0:
1051 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1054 ## Works like the above method, but returns list of sub-shapes indices
1056 # Example: see GEOM_TestOthers.py
1057 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1058 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1059 if ShapesOp.IsDone() == 0:
1060 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1063 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1064 # the specified \a theBox by the certain way, defined through \a theState parameter.
1065 # @param theBox Shape for relative comparing.
1066 # @param theShape Shape to find sub-shapes of.
1067 # @param theShapeType Type of sub-shapes to be retrieved.
1068 # @param theState The state of the subshapes to find. It can be one of
1069 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1070 # @return List of all found sub-shapes.
1072 def GetShapesOnBox(theBox, theShape, theShapeType, theState):
1073 aList = ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
1074 if ShapesOp.IsDone() == 0:
1075 print "GetShapesOnBox : ", ShapesOp.GetErrorCode()
1078 ## Works like the above method, but returns list of sub-shapes indices
1080 def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
1081 aList = ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
1082 if ShapesOp.IsDone() == 0:
1083 print "GetShapesOnBoxIDs : ", ShapesOp.GetErrorCode()
1086 ## Get sub-shape(s) of theShapeWhere, which are
1087 # coincident with \a theShapeWhat or could be a part of it.
1088 # @param theShapeWhere Shape to find sub-shapes of.
1089 # @param theShapeWhat Shape, specifying what to find (must be in the
1090 # building history of the ShapeWhere).
1091 # @return Group of all found sub-shapes or a single found sub-shape.
1093 # Example: see GEOM_TestOthers.py
1094 def GetInPlace(theShapeWhere, theShapeWhat):
1095 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1096 if ShapesOp.IsDone() == 0:
1097 print "GetInPlace : ", ShapesOp.GetErrorCode()
1100 ## Get sub-shape(s) of \a theShapeWhere, which are
1101 # coincident with \a theShapeWhat or could be a part of it.
1103 # Implementation of this method is based on a saved history of an operation,
1104 # produced \a theShapeWhere. The \a theShapeWhat must be among this operation's
1105 # arguments (an argument shape or a sub-shape of an argument shape).
1106 # The operation could be the Partition or one of boolean operations,
1107 # performed on simple shapes (not on compounds).
1109 # @param theShapeWhere Shape to find sub-shapes of.
1110 # @param theShapeWhat Shape, specifying what to find (must be in the
1111 # building history of the ShapeWhere).
1112 # @return Group of all found sub-shapes or a single found sub-shape.
1114 # Example: see GEOM_TestOthers.py
1115 def GetInPlaceByHistory(theShapeWhere, theShapeWhat):
1116 anObj = ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat)
1117 if ShapesOp.IsDone() == 0:
1118 print "GetInPlace : ", ShapesOp.GetErrorCode()
1121 ## Get sub-shape of theShapeWhere, which is
1122 # equal to \a theShapeWhat.
1123 # @param theShapeWhere Shape to find sub-shape of.
1124 # @param theShapeWhat Shape, specifying what to find
1125 # (must be usual shape).
1126 # @return New GEOM_Object for found sub-shape.
1128 def GetSame(theShapeWhere, theShapeWhat):
1129 anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1130 if ShapesOp.IsDone() == 0:
1131 print "GetSame : ", ShapesOp.GetErrorCode()
1134 # -----------------------------------------------------------------------------
1135 # Access to sub-shapes by their unique IDs inside the main shape.
1136 # -----------------------------------------------------------------------------
1138 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1139 # of <aShape>, selected by their unique IDs inside <aShape>
1141 # Example: see GEOM_TestAll.py
1142 def GetSubShape(aShape, ListOfID):
1143 anObj = geom.AddSubShape(aShape,ListOfID)
1146 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1148 # Example: see GEOM_TestAll.py
1149 def GetSubShapeID(aShape, aSubShape):
1150 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1151 if LocalOp.IsDone() == 0:
1152 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1155 # -----------------------------------------------------------------------------
1157 # -----------------------------------------------------------------------------
1159 ## Explode a shape on subshapes of a given type.
1160 # @param theShape Shape to be exploded.
1161 # @param theShapeType Type of sub-shapes to be retrieved.
1162 # @return List of sub-shapes of type theShapeType, contained in theShape.
1164 # Example: see GEOM_TestAll.py
1165 def SubShapeAll(aShape, aType):
1166 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1167 if ShapesOp.IsDone() == 0:
1168 print "MakeExplode : ", ShapesOp.GetErrorCode()
1171 ## Explode a shape on subshapes of a given type.
1172 # @param theShape Shape to be exploded.
1173 # @param theShapeType Type of sub-shapes to be retrieved.
1174 # @return List of IDs of sub-shapes.
1175 def SubShapeAllIDs(aShape, aType):
1176 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1177 if ShapesOp.IsDone() == 0:
1178 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1181 ## Explode a shape on subshapes of a given type.
1182 # Sub-shapes will be sorted by coordinates of their gravity centers.
1183 # @param theShape Shape to be exploded.
1184 # @param theShapeType Type of sub-shapes to be retrieved.
1185 # @return List of sub-shapes of type theShapeType, contained in theShape.
1187 # Example: see GEOM_TestAll.py
1188 def SubShapeAllSorted(aShape, aType):
1189 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1190 if ShapesOp.IsDone() == 0:
1191 print "MakeExplode : ", ShapesOp.GetErrorCode()
1194 ## Explode a shape on subshapes of a given type.
1195 # Sub-shapes will be sorted by coordinates of their gravity centers.
1196 # @param theShape Shape to be exploded.
1197 # @param theShapeType Type of sub-shapes to be retrieved.
1198 # @return List of IDs of sub-shapes.
1199 def SubShapeAllSortedIDs(aShape, aType):
1200 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1201 if ShapesOp.IsDone() == 0:
1202 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1205 ## Obtain a compound of sub-shapes of <aShape>,
1206 # selected by they indices in list of all sub-shapes of type <aType>.
1207 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1209 # Example: see GEOM_TestAll.py
1210 def SubShape(aShape, aType, ListOfInd):
1212 AllShapeList = SubShapeAll(aShape, aType)
1213 for ind in ListOfInd:
1214 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1215 anObj = GetSubShape(aShape, ListOfIDs)
1218 ## Obtain a compound of sub-shapes of <aShape>,
1219 # selected by they indices in sorted list of all sub-shapes of type <aType>.
1220 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1222 # Example: see GEOM_TestAll.py
1223 def SubShapeSorted(aShape, aType, ListOfInd):
1225 AllShapeList = SubShapeAllSorted(aShape, aType)
1226 for ind in ListOfInd:
1227 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1228 anObj = GetSubShape(aShape, ListOfIDs)
1231 # -----------------------------------------------------------------------------
1232 # Healing operations
1233 # -----------------------------------------------------------------------------
1235 ## Apply a sequence of Shape Healing operators to the given object.
1236 # @param theShape Shape to be processed.
1237 # @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1238 # @param theParameters List of names of parameters
1239 # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1240 # @param theValues List of values of parameters, in the same order
1241 # as parameters are listed in \a theParameters list.
1242 # @return New GEOM_Object, containing processed shape.
1244 # Example: see GEOM_TestHealing.py
1245 def ProcessShape(theShape, theOperators, theParameters, theValues):
1246 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1247 if HealOp.IsDone() == 0:
1248 print "ProcessShape : ", HealOp.GetErrorCode()
1251 ## Remove faces from the given object (shape).
1252 # @param theObject Shape to be processed.
1253 # @param theFaces Indices of faces to be removed, if EMPTY then the method
1254 # removes ALL faces of the given object.
1255 # @return New GEOM_Object, containing processed shape.
1257 # Example: see GEOM_TestHealing.py
1258 def SuppressFaces(theObject, theFaces):
1259 anObj = HealOp.SuppressFaces(theObject, theFaces)
1260 if HealOp.IsDone() == 0:
1261 print "SuppressFaces : ", HealOp.GetErrorCode()
1264 ## Sewing of some shapes into single shape.
1266 # Example: see GEOM_TestHealing.py
1267 def MakeSewing(ListShape, theTolerance):
1268 comp = MakeCompound(ListShape)
1269 anObj = Sew(comp, theTolerance)
1272 ## Sewing of the given object.
1273 # @param theObject Shape to be processed.
1274 # @param theTolerance Required tolerance value.
1275 # @return New GEOM_Object, containing processed shape.
1277 # Example: see MakeSewing() above
1278 def Sew(theObject, theTolerance):
1279 anObj = HealOp.Sew(theObject, theTolerance)
1280 if HealOp.IsDone() == 0:
1281 print "Sew : ", HealOp.GetErrorCode()
1284 ## Remove internal wires and edges from the given object (face).
1285 # @param theObject Shape to be processed.
1286 # @param theWires Indices of wires to be removed, if EMPTY then the method
1287 # removes ALL internal wires of the given object.
1288 # @return New GEOM_Object, containing processed shape.
1290 # Example: see GEOM_TestHealing.py
1291 def SuppressInternalWires(theObject, theWires):
1292 anObj = HealOp.RemoveIntWires(theObject, theWires)
1293 if HealOp.IsDone() == 0:
1294 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1297 ## Remove internal closed contours (holes) from the given object.
1298 # @param theObject Shape to be processed.
1299 # @param theWires Indices of wires to be removed, if EMPTY then the method
1300 # removes ALL internal holes of the given object
1301 # @return New GEOM_Object, containing processed shape.
1303 # Example: see GEOM_TestHealing.py
1304 def SuppressHoles(theObject, theWires):
1305 anObj = HealOp.FillHoles(theObject, theWires)
1306 if HealOp.IsDone() == 0:
1307 print "SuppressHoles : ", HealOp.GetErrorCode()
1310 ## Close an open wire.
1311 # @param theObject Shape to be processed.
1312 # @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1313 # if -1, then theObject itself is a wire.
1314 # @param isCommonVertex If TRUE : closure by creation of a common vertex,
1315 # If FALS : closure by creation of an edge between ends.
1316 # @return New GEOM_Object, containing processed shape.
1318 # Example: see GEOM_TestHealing.py
1319 def CloseContour(theObject, theWires, isCommonVertex):
1320 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1321 if HealOp.IsDone() == 0:
1322 print "CloseContour : ", HealOp.GetErrorCode()
1325 ## Addition of a point to a given edge object.
1326 # @param theObject Shape to be processed.
1327 # @param theEdgeIndex Index of edge to be divided within theObject's shape,
1328 # if -1, then theObject itself is the edge.
1329 # @param theValue Value of parameter on edge or length parameter,
1330 # depending on \a isByParameter.
1331 # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1332 # if FALSE : \a theValue is treated as a length parameter [0..1]
1333 # @return New GEOM_Object, containing processed shape.
1335 # Example: see GEOM_TestHealing.py
1336 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1337 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1338 if HealOp.IsDone() == 0:
1339 print "DivideEdge : ", HealOp.GetErrorCode()
1342 ## Change orientation of the given object.
1343 # @param theObject Shape to be processed.
1344 # @update given shape
1345 def ChangeOrientationShell(theObject):
1346 theObject = HealOp.ChangeOrientation(theObject)
1347 if HealOp.IsDone() == 0:
1348 print "ChangeOrientation : ", HealOp.GetErrorCode()
1350 ## Change orientation of the given object.
1351 # @param theObject Shape to be processed.
1352 # @return New GEOM_Object, containing processed shape.
1353 def ChangeOrientationShellCopy(theObject):
1354 anObj = HealOp.ChangeOrientationCopy(theObject)
1355 if HealOp.IsDone() == 0:
1356 print "ChangeOrientation : ", HealOp.GetErrorCode()
1359 ## Get a list of wires (wrapped in GEOM_Object-s),
1360 # that constitute a free boundary of the given shape.
1361 # @param theObject Shape to get free boundary of.
1362 # @return [status, theClosedWires, theOpenWires]
1363 # status: FALSE, if an error(s) occured during the method execution.
1364 # theClosedWires: Closed wires on the free boundary of the given shape.
1365 # theOpenWires: Open wires on the free boundary of the given shape.
1367 # Example: see GEOM_TestHealing.py
1368 def GetFreeBoundary(theObject):
1369 anObj = HealOp.GetFreeBoundary(theObject)
1370 if HealOp.IsDone() == 0:
1371 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1374 # -----------------------------------------------------------------------------
1375 # Create advanced objects
1376 # -----------------------------------------------------------------------------
1378 ## Create a copy of the given object
1380 # Example: see GEOM_TestAll.py
1381 def MakeCopy(theOriginal):
1382 anObj = InsertOp.MakeCopy(theOriginal)
1383 if InsertOp.IsDone() == 0:
1384 print "MakeCopy : ", InsertOp.GetErrorCode()
1387 ## Create a filling from the given compound of contours.
1388 # @param theShape the compound of contours
1389 # @param theMinDeg a minimal degree
1390 # @param theMaxDeg a maximal degree
1391 # @param theTol2D a 2d tolerance
1392 # @param theTol3D a 3d tolerance
1393 # @param theNbIter a number of iteration
1394 # @return New GEOM_Object, containing the created filling surface.
1396 # Example: see GEOM_TestAll.py
1397 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1398 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1399 if PrimOp.IsDone() == 0:
1400 print "MakeFilling : ", PrimOp.GetErrorCode()
1403 ## Replace coincident faces in theShape by one face.
1404 # @param theShape Initial shape.
1405 # @param theTolerance Maximum distance between faces, which can be considered as coincident.
1406 # @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
1407 # @return New GEOM_Object, containing a copy of theShape without coincident faces.
1409 # Example: see GEOM_Spanner.py
1410 def MakeGlueFaces(theShape, theTolerance, doKeepNonSolids=True):
1411 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
1412 if ShapesOp.IsDone() == 0:
1413 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1417 ## Find coincident faces in theShape for possible gluing.
1418 # @param theShape Initial shape.
1419 # @param theTolerance Maximum distance between faces,
1420 # which can be considered as coincident.
1423 # Example: see GEOM_Spanner.py
1424 def GetGlueFaces(theShape, theTolerance):
1425 anObj = ShapesOp.GetGlueFaces(theShape, theTolerance)
1426 if ShapesOp.IsDone() == 0:
1427 print "GetGlueFaces : ", ShapesOp.GetErrorCode()
1431 ## Replace coincident faces in theShape by one face
1432 # in compliance with given list of faces
1433 # @param theShape Initial shape.
1434 # @param theTolerance Maximum distance between faces,
1435 # which can be considered as coincident.
1436 # @param theFaces List of faces for gluing.
1437 # @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
1438 # @return New GEOM_Object, containing a copy of theShape
1439 # without some faces.
1441 # Example: see GEOM_Spanner.py
1442 def MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids=True):
1443 anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
1444 if ShapesOp.IsDone() == 0:
1445 print "MakeGlueFacesByList : ", ShapesOp.GetErrorCode()
1449 # -----------------------------------------------------------------------------
1450 # Boolean (Common, Cut, Fuse, Section)
1451 # -----------------------------------------------------------------------------
1453 ## Perform one of boolean operations on two given shapes.
1454 # @param theShape1 First argument for boolean operation.
1455 # @param theShape2 Second argument for boolean operation.
1456 # @param theOperation Indicates the operation to be done:
1457 # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1458 # @return New GEOM_Object, containing the result shape.
1460 # Example: see GEOM_TestAll.py
1461 def MakeBoolean(theShape1, theShape2, theOperation):
1462 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1463 if BoolOp.IsDone() == 0:
1464 print "MakeBoolean : ", BoolOp.GetErrorCode()
1467 ## Shortcut to MakeBoolean(s1, s2, 1)
1469 # Example: see GEOM_TestOthers.py
1470 def MakeCommon(s1, s2):
1471 return MakeBoolean(s1, s2, 1)
1473 ## Shortcut to MakeBoolean(s1, s2, 2)
1475 # Example: see GEOM_TestOthers.py
1476 def MakeCut(s1, s2):
1477 return MakeBoolean(s1, s2, 2)
1479 ## Shortcut to MakeBoolean(s1, s2, 3)
1481 # Example: see GEOM_TestOthers.py
1482 def MakeFuse(s1, s2):
1483 return MakeBoolean(s1, s2, 3)
1485 ## Shortcut to MakeBoolean(s1, s2, 4)
1487 # Example: see GEOM_TestOthers.py
1488 def MakeSection(s1, s2):
1489 return MakeBoolean(s1, s2, 4)
1491 ## Perform partition operation.
1492 # @param ListShapes Shapes to be intersected.
1493 # @param ListTools Shapes to intersect theShapes.
1494 # !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1495 # in order to avoid possible intersection between shapes from
1497 # @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1498 # @param KeepNonlimitShapes: if this parameter == 0 - only shapes with
1499 # type <= Limit are kept in the result,
1500 # else - shapes with type > Limit are kept
1501 # also (if they exist)
1503 # After implementation new version of PartitionAlgo (October 2006)
1504 # other parameters are ignored by current functionality. They are kept
1505 # in this function only for support old versions.
1506 # Ignored parameters:
1507 # @param ListKeepInside Shapes, outside which the results will be deleted.
1508 # Each shape from theKeepInside must belong to theShapes also.
1509 # @param ListRemoveInside Shapes, inside which the results will be deleted.
1510 # Each shape from theRemoveInside must belong to theShapes also.
1511 # @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1512 # @param ListMaterials Material indices for each shape. Make sence,
1513 # only if theRemoveWebs is TRUE.
1515 # @return New GEOM_Object, containing the result shapes.
1517 # Example: see GEOM_TestAll.py
1518 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1519 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1520 KeepNonlimitShapes=0):
1521 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1522 ListKeepInside, ListRemoveInside,
1523 Limit, RemoveWebs, ListMaterials,
1524 KeepNonlimitShapes);
1525 if BoolOp.IsDone() == 0:
1526 print "MakePartition : ", BoolOp.GetErrorCode()
1529 ## Perform partition operation.
1530 # This method may be useful if it is needed to make a partition for
1531 # compound contains nonintersected shapes. Performance will be better
1532 # since intersection between shapes from compound is not performed.
1534 # Description of all parameters as in previous method MakePartition()
1536 # !!!NOTE: Passed compounds (via ListShapes or via ListTools)
1537 # have to consist of nonintersecting shapes.
1539 # @return New GEOM_Object, containing the result shapes.
1541 def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[],
1542 ListKeepInside=[], ListRemoveInside=[],
1543 Limit=ShapeType["SHAPE"], RemoveWebs=0,
1544 ListMaterials=[], KeepNonlimitShapes=0):
1545 anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
1546 ListKeepInside, ListRemoveInside,
1547 Limit, RemoveWebs, ListMaterials,
1548 KeepNonlimitShapes);
1549 if BoolOp.IsDone() == 0:
1550 print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
1553 ## Shortcut to MakePartition()
1555 # Example: see GEOM_TestOthers.py
1556 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1557 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1558 KeepNonlimitShapes=0):
1559 anObj = MakePartition(ListShapes, ListTools,
1560 ListKeepInside, ListRemoveInside,
1561 Limit, RemoveWebs, ListMaterials,
1562 KeepNonlimitShapes);
1565 ## Perform partition of the Shape with the Plane
1566 # @param theShape Shape to be intersected.
1567 # @param thePlane Tool shape, to intersect theShape.
1568 # @return New GEOM_Object, containing the result shape.
1570 # Example: see GEOM_TestAll.py
1571 def MakeHalfPartition(theShape, thePlane):
1572 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1573 if BoolOp.IsDone() == 0:
1574 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1577 # -----------------------------------------------------------------------------
1579 # -----------------------------------------------------------------------------
1581 ## Translate the given object along the vector, specified
1582 # by its end points, creating its copy before the translation.
1583 # @param theObject The object to be translated.
1584 # @param thePoint1 Start point of translation vector.
1585 # @param thePoint2 End point of translation vector.
1586 # @return New GEOM_Object, containing the translated object.
1588 # Example: see GEOM_TestAll.py
1589 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1590 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1591 if TrsfOp.IsDone() == 0:
1592 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1595 ## Translate the given object along the vector, specified
1596 # by its components, creating its copy before the translation.
1597 # @param theObject The object to be translated.
1598 # @param theDX,theDY,theDZ Components of translation vector.
1599 # @return New GEOM_Object, containing the translated object.
1601 # Example: see GEOM_TestAll.py
1602 def MakeTranslation(theObject, theDX, theDY, theDZ):
1603 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1604 if TrsfOp.IsDone() == 0:
1605 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1608 ## Translate the given object along the given vector,
1609 # creating its copy before the translation.
1610 # @param theObject The object to be translated.
1611 # @param theVector The translation vector.
1612 # @return New GEOM_Object, containing the translated object.
1614 # Example: see GEOM_TestAll.py
1615 def MakeTranslationVector(theObject, theVector):
1616 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1617 if TrsfOp.IsDone() == 0:
1618 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1621 ## Rotate the given object around the given axis
1622 # on the given angle, creating its copy before the rotatation.
1623 # @param theObject The object to be rotated.
1624 # @param theAxis Rotation axis.
1625 # @param theAngle Rotation angle in radians.
1626 # @return New GEOM_Object, containing the rotated object.
1628 # Example: see GEOM_TestAll.py
1629 def MakeRotation(theObject, theAxis, theAngle):
1630 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1631 if TrsfOp.IsDone() == 0:
1632 print "RotateCopy : ", TrsfOp.GetErrorCode()
1635 ## Rotate given object around vector perpendicular to plane
1636 # containing three points, creating its copy before the rotatation.
1637 # @param theObject The object to be rotated.
1638 # @param theCentPoint central point - the axis is the vector perpendicular to the plane
1639 # containing the three points.
1640 # @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1641 # @return New GEOM_Object, containing the rotated object.
1643 # Example: see GEOM_TestAll.py
1644 def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
1645 anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1646 if TrsfOp.IsDone() == 0:
1647 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
1650 ## Scale the given object by the factor, creating its copy before the scaling.
1651 # @param theObject The object to be scaled.
1652 # @param thePoint Center point for scaling.
1653 # @param theFactor Scaling factor value.
1654 # @return New GEOM_Object, containing the scaled shape.
1656 # Example: see GEOM_TestAll.py
1657 def MakeScaleTransform(theObject, thePoint, theFactor):
1658 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1659 if TrsfOp.IsDone() == 0:
1660 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1663 ## Create an object, symmetrical
1664 # to the given one relatively the given plane.
1665 # @param theObject The object to be mirrored.
1666 # @param thePlane Plane of symmetry.
1667 # @return New GEOM_Object, containing the mirrored shape.
1669 # Example: see GEOM_TestAll.py
1670 def MakeMirrorByPlane(theObject, thePlane):
1671 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1672 if TrsfOp.IsDone() == 0:
1673 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1676 ## Create an object, symmetrical
1677 # to the given one relatively the given axis.
1678 # @param theObject The object to be mirrored.
1679 # @param theAxis Axis of symmetry.
1680 # @return New GEOM_Object, containing the mirrored shape.
1682 # Example: see GEOM_TestAll.py
1683 def MakeMirrorByAxis(theObject, theAxis):
1684 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1685 if TrsfOp.IsDone() == 0:
1686 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1689 ## Create an object, symmetrical
1690 # to the given one relatively the given point.
1691 # @param theObject The object to be mirrored.
1692 # @param thePoint Point of symmetry.
1693 # @return New GEOM_Object, containing the mirrored shape.
1695 # Example: see GEOM_TestAll.py
1696 def MakeMirrorByPoint(theObject, thePoint):
1697 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1698 if TrsfOp.IsDone() == 0:
1699 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1702 ## Modify the Location of the given object by LCS,
1703 # creating its copy before the setting.
1704 # @param theObject The object to be displaced.
1705 # @param theStartLCS Coordinate system to perform displacement from it.
1706 # If \a theStartLCS is NULL, displacement
1707 # will be performed from global CS.
1708 # If \a theObject itself is used as \a theStartLCS,
1709 # its location will be changed to \a theEndLCS.
1710 # @param theEndLCS Coordinate system to perform displacement to it.
1711 # @return New GEOM_Object, containing the displaced shape.
1713 # Example: see GEOM_TestAll.py
1714 def MakePosition(theObject, theStartLCS, theEndLCS):
1715 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1716 if TrsfOp.IsDone() == 0:
1717 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1720 ## Create new object as offset of the given one.
1721 # @param theObject The base object for the offset.
1722 # @param theOffset Offset value.
1723 # @return New GEOM_Object, containing the offset object.
1725 # Example: see GEOM_TestAll.py
1726 def MakeOffset(theObject, theOffset):
1727 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1728 if TrsfOp.IsDone() == 0:
1729 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1732 # -----------------------------------------------------------------------------
1734 # -----------------------------------------------------------------------------
1736 ## Translate the given object along the given vector a given number times
1737 # @param theObject The object to be translated.
1738 # @param theVector Direction of the translation.
1739 # @param theStep Distance to translate on.
1740 # @param theNbTimes Quantity of translations to be done.
1741 # @return New GEOM_Object, containing compound of all
1742 # the shapes, obtained after each translation.
1744 # Example: see GEOM_TestAll.py
1745 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1746 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1747 if TrsfOp.IsDone() == 0:
1748 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1751 ## Conseqently apply two specified translations to theObject specified number of times.
1752 # @param theObject The object to be translated.
1753 # @param theVector1 Direction of the first translation.
1754 # @param theStep1 Step of the first translation.
1755 # @param theNbTimes1 Quantity of translations to be done along theVector1.
1756 # @param theVector2 Direction of the second translation.
1757 # @param theStep2 Step of the second translation.
1758 # @param theNbTimes2 Quantity of translations to be done along theVector2.
1759 # @return New GEOM_Object, containing compound of all
1760 # the shapes, obtained after each translation.
1762 # Example: see GEOM_TestAll.py
1763 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1764 theVector2, theStep2, theNbTimes2):
1765 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1766 theVector2, theStep2, theNbTimes2)
1767 if TrsfOp.IsDone() == 0:
1768 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1771 ## Rotate the given object around the given axis a given number times.
1772 # Rotation angle will be 2*PI/theNbTimes.
1773 # @param theObject The object to be rotated.
1774 # @param theAxis The rotation axis.
1775 # @param theNbTimes Quantity of rotations to be done.
1776 # @return New GEOM_Object, containing compound of all the
1777 # shapes, obtained after each rotation.
1779 # Example: see GEOM_TestAll.py
1780 def MultiRotate1D(theObject, theAxis, theNbTimes):
1781 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1782 if TrsfOp.IsDone() == 0:
1783 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1786 ## Rotate the given object around the
1787 # given axis on the given angle a given number
1788 # times and multi-translate each rotation result.
1789 # Translation direction passes through center of gravity
1790 # of rotated shape and its projection on the rotation axis.
1791 # @param theObject The object to be rotated.
1792 # @param theAxis Rotation axis.
1793 # @param theAngle Rotation angle in graduces.
1794 # @param theNbTimes1 Quantity of rotations to be done.
1795 # @param theStep Translation distance.
1796 # @param theNbTimes2 Quantity of translations to be done.
1797 # @return New GEOM_Object, containing compound of all the
1798 # shapes, obtained after each transformation.
1800 # Example: see GEOM_TestAll.py
1801 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1802 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1803 if TrsfOp.IsDone() == 0:
1804 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1807 ## The same, as MultiRotate1D(), but axis is given by direction and point
1809 # Example: see GEOM_TestOthers.py
1810 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1811 aVec = MakeLine(aPoint,aDir)
1812 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1815 ## The same, as MultiRotate2D(), but axis is given by direction and point
1817 # Example: see GEOM_TestOthers.py
1818 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1819 aVec = MakeLine(aPoint,aDir)
1820 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1823 # -----------------------------------------------------------------------------
1825 # -----------------------------------------------------------------------------
1827 ## Perform a fillet on all edges of the given shape.
1828 # @param theShape Shape, to perform fillet on.
1829 # @param theR Fillet radius.
1830 # @return New GEOM_Object, containing the result shape.
1832 # Example: see GEOM_TestOthers.py
1833 def MakeFilletAll(theShape, theR):
1834 anObj = LocalOp.MakeFilletAll(theShape, theR)
1835 if LocalOp.IsDone() == 0:
1836 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1839 ## Perform a fillet on the specified edges/faces of the given shape
1840 # @param theShape Shape, to perform fillet on.
1841 # @param theR Fillet radius.
1842 # @param theShapeType Type of shapes in <theListShapes>.
1843 # @param theListShapes Global indices of edges/faces to perform fillet on.
1844 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1845 # @return New GEOM_Object, containing the result shape.
1847 # Example: see GEOM_TestAll.py
1848 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1850 if theShapeType == ShapeType["EDGE"]:
1851 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1853 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1854 if LocalOp.IsDone() == 0:
1855 print "MakeFillet : ", LocalOp.GetErrorCode()
1858 ## Perform a symmetric chamfer on all edges of the given shape.
1859 # @param theShape Shape, to perform chamfer on.
1860 # @param theD Chamfer size along each face.
1861 # @return New GEOM_Object, containing the result shape.
1863 # Example: see GEOM_TestOthers.py
1864 def MakeChamferAll(theShape, theD):
1865 anObj = LocalOp.MakeChamferAll(theShape, theD)
1866 if LocalOp.IsDone() == 0:
1867 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1870 ## Perform a chamfer on edges, common to the specified faces,
1871 # with distance D1 on the Face1
1872 # @param theShape Shape, to perform chamfer on.
1873 # @param theD1 Chamfer size along \a theFace1.
1874 # @param theD2 Chamfer size along \a theFace2.
1875 # @param theFace1,theFace2 Global indices of two faces of \a theShape.
1876 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1877 # @return New GEOM_Object, containing the result shape.
1879 # Example: see GEOM_TestAll.py
1880 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1881 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1882 if LocalOp.IsDone() == 0:
1883 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1886 ## Perform a chamfer on all edges of the specified faces,
1887 # with distance D1 on the first specified face (if several for one edge)
1888 # @param theShape Shape, to perform chamfer on.
1889 # @param theD1 Chamfer size along face from \a theFaces. If both faces,
1890 # connected to the edge, are in \a theFaces, \a theD1
1891 # will be get along face, which is nearer to \a theFaces beginning.
1892 # @param theD2 Chamfer size along another of two faces, connected to the edge.
1893 # @param theFaces Sequence of global indices of faces of \a theShape.
1894 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1895 # @return New GEOM_Object, containing the result shape.
1897 # Example: see GEOM_TestAll.py
1898 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1899 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1900 if LocalOp.IsDone() == 0:
1901 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1904 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1906 # Example: see GEOM_TestOthers.py
1907 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1909 if aShapeType == ShapeType["EDGE"]:
1910 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1912 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1915 ## Perform an Archimde operation on the given shape with given parameters.
1916 # The object presenting the resulting face is returned.
1917 # @param theShape Shape to be put in water.
1918 # @param theWeight Weight og the shape.
1919 # @param theWaterDensity Density of the water.
1920 # @param theMeshDeflection Deflection of the mesh, using to compute the section.
1921 # @return New GEOM_Object, containing a section of \a theShape
1922 # by a plane, corresponding to water level.
1924 # Example: see GEOM_TestAll.py
1925 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1926 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1927 if LocalOp.IsDone() == 0:
1928 print "MakeArchimede : ", LocalOp.GetErrorCode()
1931 # -----------------------------------------------------------------------------
1932 # Information objects
1933 # -----------------------------------------------------------------------------
1935 ## Get point coordinates
1938 # Example: see GEOM_TestMeasures.py
1939 def PointCoordinates(Point):
1940 aTuple = MeasuOp.PointCoordinates(Point)
1941 if MeasuOp.IsDone() == 0:
1942 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1945 ## Get summarized length of all wires,
1946 # area of surface and volume of the given shape.
1947 # @param theShape Shape to define properties of.
1948 # @return [theLength, theSurfArea, theVolume]
1949 # theLength: Summarized length of all wires of the given shape.
1950 # theSurfArea: Area of surface of the given shape.
1951 # theVolume: Volume of the given shape.
1953 # Example: see GEOM_TestMeasures.py
1954 def BasicProperties(theShape):
1955 aTuple = MeasuOp.GetBasicProperties(theShape)
1956 if MeasuOp.IsDone() == 0:
1957 print "BasicProperties : ", MeasuOp.GetErrorCode()
1960 ## Get parameters of bounding box of the given shape
1961 # @param theShape Shape to obtain bounding box of.
1962 # @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1963 # Xmin,Xmax: Limits of shape along OX axis.
1964 # Ymin,Ymax: Limits of shape along OY axis.
1965 # Zmin,Zmax: Limits of shape along OZ axis.
1967 # Example: see GEOM_TestMeasures.py
1968 def BoundingBox(theShape):
1969 aTuple = MeasuOp.GetBoundingBox(theShape)
1970 if MeasuOp.IsDone() == 0:
1971 print "BoundingBox : ", MeasuOp.GetErrorCode()
1974 ## Get inertia matrix and moments of inertia of theShape.
1975 # @param theShape Shape to calculate inertia of.
1976 # @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1977 # I(1-3)(1-3): Components of the inertia matrix of the given shape.
1978 # Ix,Iy,Iz: Moments of inertia of the given shape.
1980 # Example: see GEOM_TestMeasures.py
1981 def Inertia(theShape):
1982 aTuple = MeasuOp.GetInertia(theShape)
1983 if MeasuOp.IsDone() == 0:
1984 print "Inertia : ", MeasuOp.GetErrorCode()
1987 ## Get minimal distance between the given shapes.
1988 # @param theShape1,theShape2 Shapes to find minimal distance between.
1989 # @return Value of the minimal distance between the given shapes.
1991 # Example: see GEOM_TestMeasures.py
1992 def MinDistance(theShape1, theShape2):
1993 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1994 if MeasuOp.IsDone() == 0:
1995 print "MinDistance : ", MeasuOp.GetErrorCode()
1998 ## Get min and max tolerances of sub-shapes of theShape
1999 # @param theShape Shape, to get tolerances of.
2000 # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
2001 # FaceMin,FaceMax: Min and max tolerances of the faces.
2002 # EdgeMin,EdgeMax: Min and max tolerances of the edges.
2003 # VertMin,VertMax: Min and max tolerances of the vertices.
2005 # Example: see GEOM_TestMeasures.py
2006 def Tolerance(theShape):
2007 aTuple = MeasuOp.GetTolerance(theShape)
2008 if MeasuOp.IsDone() == 0:
2009 print "Tolerance : ", MeasuOp.GetErrorCode()
2012 ## Obtain description of the given shape (number of sub-shapes of each type)
2013 # @param theShape Shape to be described.
2014 # @return Description of the given shape.
2016 # Example: see GEOM_TestMeasures.py
2017 def WhatIs(theShape):
2018 aDescr = MeasuOp.WhatIs(theShape)
2019 if MeasuOp.IsDone() == 0:
2020 print "WhatIs : ", MeasuOp.GetErrorCode()
2023 ## Get a point, situated at the centre of mass of theShape.
2024 # @param theShape Shape to define centre of mass of.
2025 # @return New GEOM_Object, containing the created point.
2027 # Example: see GEOM_TestMeasures.py
2028 def MakeCDG(theShape):
2029 anObj = MeasuOp.GetCentreOfMass(theShape)
2030 if MeasuOp.IsDone() == 0:
2031 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
2034 ## Check a topology of the given shape.
2035 # @param theShape Shape to check validity of.
2036 # @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
2037 # if TRUE, the shape's geometry will be checked also.
2038 # @return TRUE, if the shape "seems to be valid".
2039 # If theShape is invalid, prints a description of problem.
2041 # Example: see GEOM_TestMeasures.py
2042 def CheckShape(theShape, theIsCheckGeom = 0):
2044 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
2046 (IsValid, Status) = MeasuOp.CheckShape(theShape)
2048 if MeasuOp.IsDone() == 0:
2049 print "CheckShape : ", MeasuOp.GetErrorCode()
2055 ## Get position (LCS) of theShape.
2057 # Origin of the LCS is situated at the shape's center of mass.
2058 # Axes of the LCS are obtained from shape's location or,
2059 # if the shape is a planar face, from position of its plane.
2061 # @param theShape Shape to calculate position of.
2062 # @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
2063 # Ox,Oy,Oz: Coordinates of shape's LCS origin.
2064 # Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
2065 # Xx,Xy,Xz: Coordinates of shape's LCS X direction.
2067 # Example: see GEOM_TestMeasures.py
2068 def GetPosition(theShape):
2069 aTuple = MeasuOp.GetPosition(theShape)
2070 if MeasuOp.IsDone() == 0:
2071 print "GetPosition : ", MeasuOp.GetErrorCode()
2074 ## Get kind of theShape.
2076 # @param theShape Shape to get a kind of.
2077 # @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
2078 # and a list of parameters, describing the shape.
2079 # @note Concrete meaning of each value, returned via \a theIntegers
2080 # or \a theDoubles list depends on the kind of the shape.
2081 # The full list of possible outputs is:
2083 # geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices
2084 # geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices
2086 # geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices
2087 # geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices
2089 # geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices
2090 # geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices
2092 # geompy.kind.SPHERE xc yc zc R
2093 # geompy.kind.CYLINDER xb yb zb dx dy dz R H
2094 # geompy.kind.BOX xc yc zc ax ay az
2095 # geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az
2096 # geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2
2097 # geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H
2098 # geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices
2099 # geompy.kind.SOLID nb_faces nb_edges nb_vertices
2101 # geompy.kind.SPHERE2D xc yc zc R
2102 # geompy.kind.CYLINDER2D xb yb zb dx dy dz R H
2103 # geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2
2104 # geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H
2105 # geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R
2106 # geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2
2107 # geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices
2108 # geompy.kind.PLANE xo yo zo dx dy dz
2109 # geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices
2110 # geompy.kind.FACE nb_edges nb_vertices
2112 # geompy.kind.CIRCLE xc yc zc dx dy dz R
2113 # geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2
2114 # geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2
2115 # geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2
2116 # geompy.kind.LINE xo yo zo dx dy dz
2117 # geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2
2118 # geompy.kind.EDGE nb_vertices
2120 # geompy.kind.VERTEX x y z
2122 # Example: see GEOM_TestMeasures.py
2123 def KindOfShape(theShape):
2124 aRoughTuple = MeasuOp.KindOfShape(theShape)
2125 if MeasuOp.IsDone() == 0:
2126 print "KindOfShape : ", MeasuOp.GetErrorCode()
2129 aKind = aRoughTuple[0]
2130 anInts = aRoughTuple[1]
2131 aDbls = aRoughTuple[2]
2133 # Now there is no exception from this rule:
2134 aKindTuple = [aKind] + aDbls + anInts
2136 # If they are we will regroup parameters for such kind of shape.
2138 #if aKind == kind.SOME_KIND:
2139 # # SOME_KIND int int double int double double
2140 # aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
2144 # -----------------------------------------------------------------------------
2145 # Import/Export objects
2146 # -----------------------------------------------------------------------------
2148 ## Import a shape from the BREP or IGES or STEP file
2149 # (depends on given format) with given name.
2150 # @param theFileName The file, containing the shape.
2151 # @param theFormatName Specify format for the file reading.
2152 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2153 # @return New GEOM_Object, containing the imported shape.
2155 # Example: see GEOM_TestOthers.py
2156 def Import(theFileName, theFormatName):
2157 anObj = InsertOp.Import(theFileName, theFormatName)
2158 if InsertOp.IsDone() == 0:
2159 print "Import : ", InsertOp.GetErrorCode()
2162 ## Shortcut to Import() for BREP format
2164 # Example: see GEOM_TestOthers.py
2165 def ImportBREP(theFileName):
2166 return Import(theFileName, "BREP")
2168 ## Shortcut to Import() for IGES format
2170 # Example: see GEOM_TestOthers.py
2171 def ImportIGES(theFileName):
2172 return Import(theFileName, "IGES")
2174 ## Shortcut to Import() for STEP format
2176 # Example: see GEOM_TestOthers.py
2177 def ImportSTEP(theFileName):
2178 return Import(theFileName, "STEP")
2180 ## Export the given shape into a file with given name.
2181 # @param theObject Shape to be stored in the file.
2182 # @param theFileName Name of the file to store the given shape in.
2183 # @param theFormatName Specify format for the shape storage.
2184 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2186 # Example: see GEOM_TestOthers.py
2187 def Export(theObject, theFileName, theFormatName):
2188 InsertOp.Export(theObject, theFileName, theFormatName)
2189 if InsertOp.IsDone() == 0:
2190 print "Export : ", InsertOp.GetErrorCode()
2192 ## Shortcut to Export() for BREP format
2194 # Example: see GEOM_TestOthers.py
2195 def ExportBREP(theObject, theFileName):
2196 return Export(theObject, theFileName, "BREP")
2198 ## Shortcut to Export() for IGES format
2200 # Example: see GEOM_TestOthers.py
2201 def ExportIGES(theObject, theFileName):
2202 return Export(theObject, theFileName, "IGES")
2204 ## Shortcut to Export() for STEP format
2206 # Example: see GEOM_TestOthers.py
2207 def ExportSTEP(theObject, theFileName):
2208 return Export(theObject, theFileName, "STEP")
2210 # -----------------------------------------------------------------------------
2212 # -----------------------------------------------------------------------------
2214 ## Create a quadrangle face from four edges. Order of Edges is not
2215 # important. It is not necessary that edges share the same vertex.
2216 # @param E1,E2,E3,E4 Edges for the face bound.
2217 # @return New GEOM_Object, containing the created face.
2219 # Example: see GEOM_Spanner.py
2220 def MakeQuad(E1, E2, E3, E4):
2221 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2222 if BlocksOp.IsDone() == 0:
2223 print "MakeQuad : ", BlocksOp.GetErrorCode()
2226 ## Create a quadrangle face on two edges.
2227 # The missing edges will be built by creating the shortest ones.
2228 # @param E1,E2 Two opposite edges for the face.
2229 # @return New GEOM_Object, containing the created face.
2231 # Example: see GEOM_Spanner.py
2232 def MakeQuad2Edges(E1, E2):
2233 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2234 if BlocksOp.IsDone() == 0:
2235 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2238 ## Create a quadrangle face with specified corners.
2239 # The missing edges will be built by creating the shortest ones.
2240 # @param V1,V2,V3,V4 Corner vertices for the face.
2241 # @return New GEOM_Object, containing the created face.
2243 # Example: see GEOM_Spanner.py
2244 def MakeQuad4Vertices(V1, V2, V3, V4):
2245 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2246 if BlocksOp.IsDone() == 0:
2247 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2250 ## Create a hexahedral solid, bounded by the six given faces. Order of
2251 # faces is not important. It is not necessary that Faces share the same edge.
2252 # @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2253 # @return New GEOM_Object, containing the created solid.
2255 # Example: see GEOM_Spanner.py
2256 def MakeHexa(F1, F2, F3, F4, F5, F6):
2257 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2258 if BlocksOp.IsDone() == 0:
2259 print "MakeHexa : ", BlocksOp.GetErrorCode()
2262 ## Create a hexahedral solid between two given faces.
2263 # The missing faces will be built by creating the smallest ones.
2264 # @param F1,F2 Two opposite faces for the hexahedral solid.
2265 # @return New GEOM_Object, containing the created solid.
2267 # Example: see GEOM_Spanner.py
2268 def MakeHexa2Faces(F1, F2):
2269 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2270 if BlocksOp.IsDone() == 0:
2271 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2274 ## Get a vertex, found in the given shape by its coordinates.
2275 # @param theShape Block or a compound of blocks.
2276 # @param theX,theY,theZ Coordinates of the sought vertex.
2277 # @param theEpsilon Maximum allowed distance between the resulting
2278 # vertex and point with the given coordinates.
2279 # @return New GEOM_Object, containing the found vertex.
2281 # Example: see GEOM_TestOthers.py
2282 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2283 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2284 if BlocksOp.IsDone() == 0:
2285 print "GetPoint : ", BlocksOp.GetErrorCode()
2288 ## Get an edge, found in the given shape by two given vertices.
2289 # @param theShape Block or a compound of blocks.
2290 # @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2291 # @return New GEOM_Object, containing the found edge.
2293 # Example: see GEOM_Spanner.py
2294 def GetEdge(theShape, thePoint1, thePoint2):
2295 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2296 if BlocksOp.IsDone() == 0:
2297 print "GetEdge : ", BlocksOp.GetErrorCode()
2300 ## Find an edge of the given shape, which has minimal distance to the given point.
2301 # @param theShape Block or a compound of blocks.
2302 # @param thePoint Point, close to the desired edge.
2303 # @return New GEOM_Object, containing the found edge.
2305 # Example: see GEOM_TestOthers.py
2306 def GetEdgeNearPoint(theShape, thePoint):
2307 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2308 if BlocksOp.IsDone() == 0:
2309 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2312 ## Returns a face, found in the given shape by four given corner vertices.
2313 # @param theShape Block or a compound of blocks.
2314 # @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2315 # @return New GEOM_Object, containing the found face.
2317 # Example: see GEOM_Spanner.py
2318 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2319 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2320 if BlocksOp.IsDone() == 0:
2321 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2324 ## Get a face of block, found in the given shape by two given edges.
2325 # @param theShape Block or a compound of blocks.
2326 # @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2327 # @return New GEOM_Object, containing the found face.
2329 # Example: see GEOM_Spanner.py
2330 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2331 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2332 if BlocksOp.IsDone() == 0:
2333 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2336 ## Find a face, opposite to the given one in the given block.
2337 # @param theBlock Must be a hexahedral solid.
2338 # @param theFace Face of \a theBlock, opposite to the desired face.
2339 # @return New GEOM_Object, containing the found face.
2341 # Example: see GEOM_Spanner.py
2342 def GetOppositeFace(theBlock, theFace):
2343 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2344 if BlocksOp.IsDone() == 0:
2345 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2348 ## Find a face of the given shape, which has minimal distance to the given point.
2349 # @param theShape Block or a compound of blocks.
2350 # @param thePoint Point, close to the desired face.
2351 # @return New GEOM_Object, containing the found face.
2353 # Example: see GEOM_Spanner.py
2354 def GetFaceNearPoint(theShape, thePoint):
2355 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2356 if BlocksOp.IsDone() == 0:
2357 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2360 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2361 # @param theShape Block or a compound of blocks.
2362 # @param theVector Vector, close to the normale of the desired face.
2363 # @return New GEOM_Object, containing the found face.
2365 # Example: see GEOM_Spanner.py
2366 def GetFaceByNormale(theBlock, theVector):
2367 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2368 if BlocksOp.IsDone() == 0:
2369 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2372 ## Check, if the compound of blocks is given.
2373 # To be considered as a compound of blocks, the
2374 # given shape must satisfy the following conditions:
2375 # - Each element of the compound should be a Block (6 faces and 12 edges).
2376 # - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2377 # - The compound should be connexe.
2378 # - The glue between two quadrangle faces should be applied.
2379 # @param theCompound The compound to check.
2380 # @return TRUE, if the given shape is a compound of blocks.
2381 # If theCompound is not valid, prints all discovered errors.
2383 # Example: see GEOM_Spanner.py
2384 def CheckCompoundOfBlocks(theCompound):
2385 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2386 if BlocksOp.IsDone() == 0:
2387 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2390 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2394 ## Remove all seam and degenerated edges from \a theShape.
2395 # Unite faces and edges, sharing one surface. It means that
2396 # this faces must have references to one C++ surface object (handle).
2397 # @param theShape The compound or single solid to remove irregular edges from.
2398 # @return Improved shape.
2400 # Example: see GEOM_TestOthers.py
2401 def RemoveExtraEdges(theShape):
2402 anObj = BlocksOp.RemoveExtraEdges(theShape)
2403 if BlocksOp.IsDone() == 0:
2404 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2407 ## Check, if the given shape is a blocks compound.
2408 # Fix all detected errors.
2409 # \note Single block can be also fixed by this method.
2410 # @param theCompound The compound to check and improve.
2411 # @return Improved compound.
2413 # Example: see GEOM_TestOthers.py
2414 def CheckAndImprove(theShape):
2415 anObj = BlocksOp.CheckAndImprove(theShape)
2416 if BlocksOp.IsDone() == 0:
2417 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2420 ## Get all the blocks, contained in the given compound.
2421 # @param theCompound The compound to explode.
2422 # @param theMinNbFaces If solid has lower number of faces, it is not a block.
2423 # @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2424 # \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2425 # @return List of GEOM_Objects, containing the retrieved blocks.
2427 # Example: see GEOM_TestOthers.py
2428 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2429 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2430 if BlocksOp.IsDone() == 0:
2431 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2434 ## Find block, containing the given point inside its volume or on boundary.
2435 # @param theCompound Compound, to find block in.
2436 # @param thePoint Point, close to the desired block. If the point lays on
2437 # boundary between some blocks, we return block with nearest center.
2438 # @return New GEOM_Object, containing the found block.
2440 # Example: see GEOM_Spanner.py
2441 def GetBlockNearPoint(theCompound, thePoint):
2442 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2443 if BlocksOp.IsDone() == 0:
2444 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2447 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2448 # @param theCompound Compound, to find block in.
2449 # @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2450 # @return New GEOM_Object, containing the found block.
2452 # Example: see GEOM_TestOthers.py
2453 def GetBlockByParts(theCompound, theParts):
2454 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2455 if BlocksOp.IsDone() == 0:
2456 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2459 ## Return all blocks, containing all the elements, passed as the parts.
2460 # @param theCompound Compound, to find blocks in.
2461 # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2462 # @return List of GEOM_Objects, containing the found blocks.
2464 # Example: see GEOM_Spanner.py
2465 def GetBlocksByParts(theCompound, theParts):
2466 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2467 if BlocksOp.IsDone() == 0:
2468 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2471 ## Multi-transformate block and glue the result.
2472 # Transformation is defined so, as to superpose direction faces.
2473 # @param Block Hexahedral solid to be multi-transformed.
2474 # @param DirFace1 ID of First direction face.
2475 # @param DirFace2 ID of Second direction face.
2476 # @param NbTimes Quantity of transformations to be done.
2477 # \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2478 # @return New GEOM_Object, containing the result shape.
2480 # Example: see GEOM_Spanner.py
2481 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2482 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2483 if BlocksOp.IsDone() == 0:
2484 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2487 ## Multi-transformate block and glue the result.
2488 # @param Block Hexahedral solid to be multi-transformed.
2489 # @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2490 # @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2491 # @param NbTimesU,NbTimesV Quantity of transformations to be done.
2492 # @return New GEOM_Object, containing the result shape.
2494 # Example: see GEOM_Spanner.py
2495 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2496 DirFace1V, DirFace2V, NbTimesV):
2497 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2498 DirFace1V, DirFace2V, NbTimesV)
2499 if BlocksOp.IsDone() == 0:
2500 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2503 ## Build all possible propagation groups.
2504 # Propagation group is a set of all edges, opposite to one (main)
2505 # edge of this group directly or through other opposite edges.
2506 # Notion of Opposite Edge make sence only on quadrangle face.
2507 # @param theShape Shape to build propagation groups on.
2508 # @return List of GEOM_Objects, each of them is a propagation group.
2510 # Example: see GEOM_TestOthers.py
2511 def Propagate(theShape):
2512 listChains = BlocksOp.Propagate(theShape)
2513 if BlocksOp.IsDone() == 0:
2514 print "Propagate : ", BlocksOp.GetErrorCode()
2517 # -----------------------------------------------------------------------------
2519 # -----------------------------------------------------------------------------
2521 ## Creates a new group which will store sub shapes of theMainShape
2522 # @param theMainShape is a GEOM object on which the group is selected
2523 # @param theShapeType defines a shape type of the group
2524 # @return a newly created GEOM group
2526 # Example: see GEOM_TestOthers.py
2527 def CreateGroup(theMainShape, theShapeType):
2528 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2529 if GroupOp.IsDone() == 0:
2530 print "CreateGroup : ", GroupOp.GetErrorCode()
2533 ## Adds a sub object with ID theSubShapeId to the group
2534 # @param theGroup is a GEOM group to which the new sub shape is added
2535 # @param theSubShapeID is a sub shape ID in the main object.
2536 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2538 # Example: see GEOM_TestOthers.py
2539 def AddObject(theGroup, theSubShapeID):
2540 GroupOp.AddObject(theGroup, theSubShapeID)
2541 if GroupOp.IsDone() == 0:
2542 print "AddObject : ", GroupOp.GetErrorCode()
2544 ## Removes a sub object with ID \a theSubShapeId from the group
2545 # @param theGroup is a GEOM group from which the new sub shape is removed
2546 # @param theSubShapeID is a sub shape ID in the main object.
2547 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2549 # Example: see GEOM_TestOthers.py
2550 def RemoveObject(theGroup, theSubShapeID):
2551 GroupOp.RemoveObject(theGroup, theSubShapeID)
2552 if GroupOp.IsDone() == 0:
2553 print "RemoveObject : ", GroupOp.GetErrorCode()
2555 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2556 # @param theGroup is a GEOM group to which the new sub shapes are added.
2557 # @param theSubShapes is a list of sub shapes to be added.
2559 # Example: see GEOM_TestOthers.py
2560 def UnionList (theGroup, theSubShapes):
2561 GroupOp.UnionList(theGroup, theSubShapes)
2562 if GroupOp.IsDone() == 0:
2563 print "UnionList : ", GroupOp.GetErrorCode()
2565 ## Works like the above method, but argument
2566 # theSubShapes here is a list of sub-shapes indices
2568 # Example: see GEOM_TestOthers.py
2569 def UnionIDs(theGroup, theSubShapes):
2570 GroupOp.UnionIDs(theGroup, theSubShapes)
2571 if GroupOp.IsDone() == 0:
2572 print "UnionIDs : ", GroupOp.GetErrorCode()
2574 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2575 # @param theGroup is a GEOM group from which the sub-shapes are removed.
2576 # @param theSubShapes is a list of sub-shapes to be removed.
2578 # Example: see GEOM_TestOthers.py
2579 def DifferenceList (theGroup, theSubShapes):
2580 GroupOp.DifferenceList(theGroup, theSubShapes)
2581 if GroupOp.IsDone() == 0:
2582 print "DifferenceList : ", GroupOp.GetErrorCode()
2584 ## Works like the above method, but argument
2585 # theSubShapes here is a list of sub-shapes indices
2587 # Example: see GEOM_TestOthers.py
2588 def DifferenceIDs(theGroup, theSubShapes):
2589 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2590 if GroupOp.IsDone() == 0:
2591 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2593 ## Returns a list of sub objects ID stored in the group
2594 # @param theGroup is a GEOM group for which a list of IDs is requested
2596 # Example: see GEOM_TestOthers.py
2597 def GetObjectIDs(theGroup):
2598 ListIDs = GroupOp.GetObjects(theGroup)
2599 if GroupOp.IsDone() == 0:
2600 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2603 ## Returns a type of sub objects stored in the group
2604 # @param theGroup is a GEOM group which type is returned.
2606 # Example: see GEOM_TestOthers.py
2607 def GetType(theGroup):
2608 aType = GroupOp.GetType(theGroup)
2609 if GroupOp.IsDone() == 0:
2610 print "GetType : ", GroupOp.GetErrorCode()
2613 ## Returns a main shape associated with the group
2614 # @param theGroup is a GEOM group for which a main shape object is requested
2615 # @return a GEOM object which is a main shape for theGroup
2617 # Example: see GEOM_TestOthers.py
2618 def GetMainShape(theGroup):
2619 anObj = GroupOp.GetMainShape(theGroup)
2620 if GroupOp.IsDone() == 0:
2621 print "GetMainShape : ", GroupOp.GetErrorCode()
2624 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2625 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2626 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2627 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2630 Props = BasicProperties(edge)
2631 if min_length <= Props[0] and Props[0] <= max_length:
2632 if (not include_min) and (min_length == Props[0]):
2635 if (not include_max) and (Props[0] == max_length):
2638 edges_in_range.append(edge)
2640 if len(edges_in_range) <= 0:
2641 print "No edges found by given criteria"
2644 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2645 UnionList(group_edges, edges_in_range)
2649 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2650 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2651 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2652 nb_selected = sg.SelectedCount()
2654 print "Select a shape before calling this function, please."
2657 print "Only one shape must be selected"
2660 id_shape = sg.getSelected(0)
2661 shape = IDToObject( id_shape )
2663 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2667 if include_min: left_str = " <= "
2668 if include_max: right_str = " <= "
2670 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2671 + left_str + "length" + right_str + `max_length`)
2673 sg.updateObjBrowser(1)
2677 ## Add Path to load python scripts from
2679 if (sys.path.count(Path) < 1):
2680 sys.path.append(Path)