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 or list of locations can be empty.
751 # @param thePath - Path shape to extrude the base shape along it.
752 # @param theWithContact - the mode defining that the section is translated to be in
753 # contact with the spine.
754 # @param - WithCorrection - defining that the section is rotated to be
755 # orthogonal to the spine tangent in the correspondent point
756 # @return New GEOM_Object, containing the created solids.
758 # Example: see GEOM_TestAll.py
759 def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
760 theLocations, thePath,
761 theWithContact, theWithCorrection):
762 anObj = PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
763 theLocations, thePath,
764 theWithContact, theWithCorrection)
765 if PrimOp.IsDone() == 0:
766 print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
769 # -----------------------------------------------------------------------------
771 # -----------------------------------------------------------------------------
773 ## Create a linear edge with specified ends.
774 # @param thePnt1 Point for the first end of edge.
775 # @param thePnt2 Point for the second end of edge.
776 # @return New GEOM_Object, containing the created edge.
778 # Example: see GEOM_TestAll.py
779 def MakeEdge(thePnt1, thePnt2):
780 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
781 if ShapesOp.IsDone() == 0:
782 print "MakeEdge : ", ShapesOp.GetErrorCode()
785 ## Create a wire from the set of edges and wires.
786 # @param theEdgesAndWires List of edges and/or wires.
787 # @return New GEOM_Object, containing the created wire.
789 # Example: see GEOM_TestAll.py
790 def MakeWire(theEdgesAndWires):
791 anObj = ShapesOp.MakeWire(theEdgesAndWires)
792 if ShapesOp.IsDone() == 0:
793 print "MakeWire : ", ShapesOp.GetErrorCode()
796 ## Create a face on the given wire.
797 # @param theWire closed Wire or Edge to build the face on.
798 # @param isPlanarWanted If TRUE, only planar face will be built.
799 # If impossible, NULL object will be returned.
800 # @return New GEOM_Object, containing the created face.
802 # Example: see GEOM_TestAll.py
803 def MakeFace(theWire, isPlanarWanted):
804 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
805 if ShapesOp.IsDone() == 0:
806 print "MakeFace : ", ShapesOp.GetErrorCode()
809 ## Create a face on the given wires set.
810 # @param theWires List of closed wires or edges to build the face on.
811 # @param isPlanarWanted If TRUE, only planar face will be built.
812 # If impossible, NULL object will be returned.
813 # @return New GEOM_Object, containing the created face.
815 # Example: see GEOM_TestAll.py
816 def MakeFaceWires(theWires, isPlanarWanted):
817 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
818 if ShapesOp.IsDone() == 0:
819 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
822 ## Shortcut to MakeFaceWires()
824 # Example: see GEOM_TestOthers.py
825 def MakeFaces(theWires, isPlanarWanted):
826 anObj = MakeFaceWires(theWires, isPlanarWanted)
829 ## Create a shell from the set of faces and shells.
830 # @param theFacesAndShells List of faces and/or shells.
831 # @return New GEOM_Object, containing the created shell.
833 # Example: see GEOM_TestAll.py
834 def MakeShell(theFacesAndShells):
835 anObj = ShapesOp.MakeShell(theFacesAndShells)
836 if ShapesOp.IsDone() == 0:
837 print "MakeShell : ", ShapesOp.GetErrorCode()
840 ## Create a solid, bounded by the given shells.
841 # @param theShells Sequence of bounding shells.
842 # @return New GEOM_Object, containing the created solid.
844 # Example: see GEOM_TestAll.py
845 def MakeSolid(theShells):
846 anObj = ShapesOp.MakeSolidShells(theShells)
847 if ShapesOp.IsDone() == 0:
848 print "MakeSolid : ", ShapesOp.GetErrorCode()
851 ## Create a compound of the given shapes.
852 # @param theShapes List of shapes to put in compound.
853 # @return New GEOM_Object, containing the created compound.
855 # Example: see GEOM_TestAll.py
856 def MakeCompound(theShapes):
857 anObj = ShapesOp.MakeCompound(theShapes)
858 if ShapesOp.IsDone() == 0:
859 print "MakeCompound : ", ShapesOp.GetErrorCode()
862 ## Gives quantity of faces in the given shape.
863 # @param theShape Shape to count faces of.
864 # @return Quantity of faces.
866 # Example: see GEOM_TestOthers.py
867 def NumberOfFaces(theShape):
868 nb_faces = ShapesOp.NumberOfFaces(theShape)
869 if ShapesOp.IsDone() == 0:
870 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
873 ## Gives quantity of edges in the given shape.
874 # @param theShape Shape to count edges of.
875 # @return Quantity of edges.
877 # Example: see GEOM_TestOthers.py
878 def NumberOfEdges(theShape):
879 nb_edges = ShapesOp.NumberOfEdges(theShape)
880 if ShapesOp.IsDone() == 0:
881 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
884 ## Reverses an orientation the given shape.
885 # @param theShape Shape to be reversed.
886 # @return The reversed copy of theShape.
888 # Example: see GEOM_TestAll.py
889 def ChangeOrientation(theShape):
890 anObj = ShapesOp.ChangeOrientation(theShape)
891 if ShapesOp.IsDone() == 0:
892 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
895 ## Shortcut to ChangeOrientation()
897 # Example: see GEOM_TestOthers.py
898 def OrientationChange(theShape):
899 anObj = ChangeOrientation(theShape)
902 ## Retrieve all free faces from the given shape.
903 # Free face is a face, which is not shared between two shells of the shape.
904 # @param theShape Shape to find free faces in.
905 # @return List of IDs of all free faces, contained in theShape.
907 # Example: see GEOM_TestOthers.py
908 def GetFreeFacesIDs(theShape):
909 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
910 if ShapesOp.IsDone() == 0:
911 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
914 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
915 # @param theShape1 Shape to find sub-shapes in.
916 # @param theShape2 Shape to find shared sub-shapes with.
917 # @param theShapeType Type of sub-shapes to be retrieved.
918 # @return List of sub-shapes of theShape1, shared with theShape2.
920 # Example: see GEOM_TestOthers.py
921 def GetSharedShapes(theShape1, theShape2, theShapeType):
922 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
923 if ShapesOp.IsDone() == 0:
924 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
927 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
928 # the specified plane by the certain way, defined through \a theState parameter.
929 # @param theShape Shape to find sub-shapes of.
930 # @param theShapeType Type of sub-shapes to be retrieved.
931 # @param theAx1 Vector (or line, or linear edge), specifying normal
932 # direction and location of the plane to find shapes on.
933 # @param theState The state of the subshapes to find. It can be one of
934 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
935 # @return List of all found sub-shapes.
937 # Example: see GEOM_TestOthers.py
938 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
939 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
940 if ShapesOp.IsDone() == 0:
941 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
944 ## Works like the above method, but returns list of sub-shapes indices
946 # Example: see GEOM_TestOthers.py
947 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
948 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
949 if ShapesOp.IsDone() == 0:
950 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
953 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
954 # the specified plane by the certain way, defined through \a theState parameter.
955 # @param theShape Shape to find sub-shapes of.
956 # @param theShapeType Type of sub-shapes to be retrieved.
957 # @param theAx1 Vector (or line, or linear edge), specifying normal
958 # direction of the plane to find shapes on.
959 # @param thePnt Point specifying location of the plane to find shapes on.
960 # @param theState The state of the subshapes to find. It can be one of
961 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
962 # @return List of all found sub-shapes.
964 # Example: see GEOM_TestOthers.py
965 def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
966 aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
967 if ShapesOp.IsDone() == 0:
968 print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
971 ## Works like the above method, but returns list of sub-shapes indices
973 # Example: see GEOM_TestOthers.py
974 def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
975 aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
976 if ShapesOp.IsDone() == 0:
977 print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
980 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
981 # the specified cylinder by the certain way, defined through \a theState parameter.
982 # @param theShape Shape to find sub-shapes of.
983 # @param theShapeType Type of sub-shapes to be retrieved.
984 # @param theAxis Vector (or line, or linear edge), specifying
985 # axis of the cylinder to find shapes on.
986 # @param theRadius Radius of the cylinder to find shapes on.
987 # @param theState The state of the subshapes to find. It can be one of
988 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
989 # @return List of all found sub-shapes.
991 # Example: see GEOM_TestOthers.py
992 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
993 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
994 if ShapesOp.IsDone() == 0:
995 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
998 ## Works like the above method, but returns list of sub-shapes indices
1000 # Example: see GEOM_TestOthers.py
1001 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
1002 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
1003 if ShapesOp.IsDone() == 0:
1004 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
1007 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1008 # the specified sphere by the certain way, defined through \a theState parameter.
1009 # @param theShape Shape to find sub-shapes of.
1010 # @param theShapeType Type of sub-shapes to be retrieved.
1011 # @param theCenter Point, specifying center of the sphere to find shapes on.
1012 # @param theRadius Radius of the sphere to find shapes on.
1013 # @param theState The state of the subshapes to find. It can be one of
1014 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1015 # @return List of all found sub-shapes.
1017 # Example: see GEOM_TestOthers.py
1018 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
1019 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1020 if ShapesOp.IsDone() == 0:
1021 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1024 ## Works like the above method, but returns list of sub-shapes indices
1026 # Example: see GEOM_TestOthers.py
1027 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1028 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1029 if ShapesOp.IsDone() == 0:
1030 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1033 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1034 # the specified quadrangle by the certain way, defined through \a theState parameter.
1035 # @param theShape Shape to find sub-shapes of.
1036 # @param theShapeType Type of sub-shapes to be retrieved.
1037 # @param theTopLeftPoint Point, specifying top left corner of a quadrangle
1038 # @param theTopRigthPoint Point, specifying top right corner of a quadrangle
1039 # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
1040 # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
1041 # @param theState The state of the subshapes to find. It can be one of
1042 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1043 # @return List of all found sub-shapes.
1045 # Example: see GEOM_TestOthers.py
1046 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1047 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1048 if ShapesOp.IsDone() == 0:
1049 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1052 ## Works like the above method, but returns list of sub-shapes indices
1054 # Example: see GEOM_TestOthers.py
1055 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1056 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1057 if ShapesOp.IsDone() == 0:
1058 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1061 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1062 # the specified \a theBox by the certain way, defined through \a theState parameter.
1063 # @param theBox Shape for relative comparing.
1064 # @param theShape Shape to find sub-shapes of.
1065 # @param theShapeType Type of sub-shapes to be retrieved.
1066 # @param theState The state of the subshapes to find. It can be one of
1067 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1068 # @return List of all found sub-shapes.
1070 def GetShapesOnBox(theBox, theShape, theShapeType, theState):
1071 aList = ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
1072 if ShapesOp.IsDone() == 0:
1073 print "GetShapesOnBox : ", ShapesOp.GetErrorCode()
1076 ## Works like the above method, but returns list of sub-shapes indices
1078 def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
1079 aList = ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
1080 if ShapesOp.IsDone() == 0:
1081 print "GetShapesOnBoxIDs : ", ShapesOp.GetErrorCode()
1084 ## Get sub-shape(s) of theShapeWhere, which are
1085 # coincident with \a theShapeWhat or could be a part of it.
1086 # @param theShapeWhere Shape to find sub-shapes of.
1087 # @param theShapeWhat Shape, specifying what to find.
1088 # @return Group of all found sub-shapes or a single found sub-shape.
1090 # Example: see GEOM_TestOthers.py
1091 def GetInPlace(theShapeWhere, theShapeWhat):
1092 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1093 if ShapesOp.IsDone() == 0:
1094 print "GetInPlace : ", ShapesOp.GetErrorCode()
1097 ## Get sub-shape of theShapeWhere, which is
1098 # equal to \a theShapeWhat.
1099 # @param theShapeWhere Shape to find sub-shape of.
1100 # @param theShapeWhat Shape, specifying what to find.
1101 # @return New GEOM_Object for found sub-shape.
1103 def GetSame(theShapeWhere, theShapeWhat):
1104 anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1105 if ShapesOp.IsDone() == 0:
1106 print "GetSame : ", ShapesOp.GetErrorCode()
1109 # -----------------------------------------------------------------------------
1110 # Access to sub-shapes by their unique IDs inside the main shape.
1111 # -----------------------------------------------------------------------------
1113 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1114 # of <aShape>, selected by their unique IDs inside <aShape>
1116 # Example: see GEOM_TestAll.py
1117 def GetSubShape(aShape, ListOfID):
1118 anObj = geom.AddSubShape(aShape,ListOfID)
1121 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1123 # Example: see GEOM_TestAll.py
1124 def GetSubShapeID(aShape, aSubShape):
1125 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1126 if LocalOp.IsDone() == 0:
1127 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1130 # -----------------------------------------------------------------------------
1132 # -----------------------------------------------------------------------------
1134 ## Explode a shape on subshapes of a given type.
1135 # @param theShape Shape to be exploded.
1136 # @param theShapeType Type of sub-shapes to be retrieved.
1137 # @return List of sub-shapes of type theShapeType, contained in theShape.
1139 # Example: see GEOM_TestAll.py
1140 def SubShapeAll(aShape, aType):
1141 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1142 if ShapesOp.IsDone() == 0:
1143 print "MakeExplode : ", ShapesOp.GetErrorCode()
1146 ## Explode a shape on subshapes of a given type.
1147 # @param theShape Shape to be exploded.
1148 # @param theShapeType Type of sub-shapes to be retrieved.
1149 # @return List of IDs of sub-shapes.
1150 def SubShapeAllIDs(aShape, aType):
1151 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1152 if ShapesOp.IsDone() == 0:
1153 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1156 ## Explode a shape on subshapes of a given type.
1157 # Sub-shapes will be sorted by coordinates of their gravity centers.
1158 # @param theShape Shape to be exploded.
1159 # @param theShapeType Type of sub-shapes to be retrieved.
1160 # @return List of sub-shapes of type theShapeType, contained in theShape.
1162 # Example: see GEOM_TestAll.py
1163 def SubShapeAllSorted(aShape, aType):
1164 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1165 if ShapesOp.IsDone() == 0:
1166 print "MakeExplode : ", ShapesOp.GetErrorCode()
1169 ## Explode a shape on subshapes of a given type.
1170 # Sub-shapes will be sorted by coordinates of their gravity centers.
1171 # @param theShape Shape to be exploded.
1172 # @param theShapeType Type of sub-shapes to be retrieved.
1173 # @return List of IDs of sub-shapes.
1174 def SubShapeAllSortedIDs(aShape, aType):
1175 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1176 if ShapesOp.IsDone() == 0:
1177 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1180 ## Obtain a compound of sub-shapes of <aShape>,
1181 # selected by they indices in list of all sub-shapes of type <aType>.
1182 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1184 # Example: see GEOM_TestAll.py
1185 def SubShape(aShape, aType, ListOfInd):
1187 AllShapeList = SubShapeAll(aShape, aType)
1188 for ind in ListOfInd:
1189 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1190 anObj = GetSubShape(aShape, ListOfIDs)
1193 ## Obtain a compound of sub-shapes of <aShape>,
1194 # selected by they indices in sorted list of all sub-shapes of type <aType>.
1195 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1197 # Example: see GEOM_TestAll.py
1198 def SubShapeSorted(aShape, aType, ListOfInd):
1200 AllShapeList = SubShapeAllSorted(aShape, aType)
1201 for ind in ListOfInd:
1202 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1203 anObj = GetSubShape(aShape, ListOfIDs)
1206 # -----------------------------------------------------------------------------
1207 # Healing operations
1208 # -----------------------------------------------------------------------------
1210 ## Apply a sequence of Shape Healing operators to the given object.
1211 # @param theShape Shape to be processed.
1212 # @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1213 # @param theParameters List of names of parameters
1214 # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1215 # @param theValues List of values of parameters, in the same order
1216 # as parameters are listed in \a theParameters list.
1217 # @return New GEOM_Object, containing processed shape.
1219 # Example: see GEOM_TestHealing.py
1220 def ProcessShape(theShape, theOperators, theParameters, theValues):
1221 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1222 if HealOp.IsDone() == 0:
1223 print "ProcessShape : ", HealOp.GetErrorCode()
1226 ## Remove faces from the given object (shape).
1227 # @param theObject Shape to be processed.
1228 # @param theFaces Indices of faces to be removed, if EMPTY then the method
1229 # removes ALL faces of the given object.
1230 # @return New GEOM_Object, containing processed shape.
1232 # Example: see GEOM_TestHealing.py
1233 def SuppressFaces(theObject, theFaces):
1234 anObj = HealOp.SuppressFaces(theObject, theFaces)
1235 if HealOp.IsDone() == 0:
1236 print "SuppressFaces : ", HealOp.GetErrorCode()
1239 ## Sewing of some shapes into single shape.
1241 # Example: see GEOM_TestHealing.py
1242 def MakeSewing(ListShape, theTolerance):
1243 comp = MakeCompound(ListShape)
1244 anObj = Sew(comp, theTolerance)
1247 ## Sewing of the given object.
1248 # @param theObject Shape to be processed.
1249 # @param theTolerance Required tolerance value.
1250 # @return New GEOM_Object, containing processed shape.
1252 # Example: see MakeSewing() above
1253 def Sew(theObject, theTolerance):
1254 anObj = HealOp.Sew(theObject, theTolerance)
1255 if HealOp.IsDone() == 0:
1256 print "Sew : ", HealOp.GetErrorCode()
1259 ## Remove internal wires and edges from the given object (face).
1260 # @param theObject Shape to be processed.
1261 # @param theWires Indices of wires to be removed, if EMPTY then the method
1262 # removes ALL internal wires of the given object.
1263 # @return New GEOM_Object, containing processed shape.
1265 # Example: see GEOM_TestHealing.py
1266 def SuppressInternalWires(theObject, theWires):
1267 anObj = HealOp.RemoveIntWires(theObject, theWires)
1268 if HealOp.IsDone() == 0:
1269 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1272 ## Remove internal closed contours (holes) from the given object.
1273 # @param theObject Shape to be processed.
1274 # @param theWires Indices of wires to be removed, if EMPTY then the method
1275 # removes ALL internal holes of the given object
1276 # @return New GEOM_Object, containing processed shape.
1278 # Example: see GEOM_TestHealing.py
1279 def SuppressHoles(theObject, theWires):
1280 anObj = HealOp.FillHoles(theObject, theWires)
1281 if HealOp.IsDone() == 0:
1282 print "SuppressHoles : ", HealOp.GetErrorCode()
1285 ## Close an open wire.
1286 # @param theObject Shape to be processed.
1287 # @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1288 # if -1, then theObject itself is a wire.
1289 # @param isCommonVertex If TRUE : closure by creation of a common vertex,
1290 # If FALS : closure by creation of an edge between ends.
1291 # @return New GEOM_Object, containing processed shape.
1293 # Example: see GEOM_TestHealing.py
1294 def CloseContour(theObject, theWires, isCommonVertex):
1295 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1296 if HealOp.IsDone() == 0:
1297 print "CloseContour : ", HealOp.GetErrorCode()
1300 ## Addition of a point to a given edge object.
1301 # @param theObject Shape to be processed.
1302 # @param theEdgeIndex Index of edge to be divided within theObject's shape,
1303 # if -1, then theObject itself is the edge.
1304 # @param theValue Value of parameter on edge or length parameter,
1305 # depending on \a isByParameter.
1306 # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1307 # if FALSE : \a theValue is treated as a length parameter [0..1]
1308 # @return New GEOM_Object, containing processed shape.
1310 # Example: see GEOM_TestHealing.py
1311 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1312 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1313 if HealOp.IsDone() == 0:
1314 print "DivideEdge : ", HealOp.GetErrorCode()
1317 ## Change orientation of the given object.
1318 # @param theObject Shape to be processed.
1319 # @update given shape
1320 def ChangeOrientationShell(theObject):
1321 theObject = HealOp.ChangeOrientation(theObject)
1322 if HealOp.IsDone() == 0:
1323 print "ChangeOrientation : ", HealOp.GetErrorCode()
1325 ## Change orientation of the given object.
1326 # @param theObject Shape to be processed.
1327 # @return New GEOM_Object, containing processed shape.
1328 def ChangeOrientationShellCopy(theObject):
1329 anObj = HealOp.ChangeOrientationCopy(theObject)
1330 if HealOp.IsDone() == 0:
1331 print "ChangeOrientation : ", HealOp.GetErrorCode()
1334 ## Get a list of wires (wrapped in GEOM_Object-s),
1335 # that constitute a free boundary of the given shape.
1336 # @param theObject Shape to get free boundary of.
1337 # @return [status, theClosedWires, theOpenWires]
1338 # status: FALSE, if an error(s) occured during the method execution.
1339 # theClosedWires: Closed wires on the free boundary of the given shape.
1340 # theOpenWires: Open wires on the free boundary of the given shape.
1342 # Example: see GEOM_TestHealing.py
1343 def GetFreeBoundary(theObject):
1344 anObj = HealOp.GetFreeBoundary(theObject)
1345 if HealOp.IsDone() == 0:
1346 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1349 # -----------------------------------------------------------------------------
1350 # Create advanced objects
1351 # -----------------------------------------------------------------------------
1353 ## Create a copy of the given object
1355 # Example: see GEOM_TestAll.py
1356 def MakeCopy(theOriginal):
1357 anObj = InsertOp.MakeCopy(theOriginal)
1358 if InsertOp.IsDone() == 0:
1359 print "MakeCopy : ", InsertOp.GetErrorCode()
1362 ## Create a filling from the given compound of contours.
1363 # @param theShape the compound of contours
1364 # @param theMinDeg a minimal degree
1365 # @param theMaxDeg a maximal degree
1366 # @param theTol2D a 2d tolerance
1367 # @param theTol3D a 3d tolerance
1368 # @param theNbIter a number of iteration
1369 # @return New GEOM_Object, containing the created filling surface.
1371 # Example: see GEOM_TestAll.py
1372 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1373 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1374 if PrimOp.IsDone() == 0:
1375 print "MakeFilling : ", PrimOp.GetErrorCode()
1378 ## Replace coincident faces in theShape by one face.
1379 # @param theShape Initial shape.
1380 # @param theTolerance Maximum distance between faces, which can be considered as coincident.
1381 # @return New GEOM_Object, containing a copy of theShape without coincident faces.
1383 # Example: see GEOM_Spanner.py
1384 def MakeGlueFaces(theShape, theTolerance):
1385 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1386 if ShapesOp.IsDone() == 0:
1387 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1390 # -----------------------------------------------------------------------------
1391 # Boolean (Common, Cut, Fuse, Section)
1392 # -----------------------------------------------------------------------------
1394 ## Perform one of boolean operations on two given shapes.
1395 # @param theShape1 First argument for boolean operation.
1396 # @param theShape2 Second argument for boolean operation.
1397 # @param theOperation Indicates the operation to be done:
1398 # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1399 # @return New GEOM_Object, containing the result shape.
1401 # Example: see GEOM_TestAll.py
1402 def MakeBoolean(theShape1, theShape2, theOperation):
1403 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1404 if BoolOp.IsDone() == 0:
1405 print "MakeBoolean : ", BoolOp.GetErrorCode()
1408 ## Shortcut to MakeBoolean(s1, s2, 1)
1410 # Example: see GEOM_TestOthers.py
1411 def MakeCommon(s1, s2):
1412 return MakeBoolean(s1, s2, 1)
1414 ## Shortcut to MakeBoolean(s1, s2, 2)
1416 # Example: see GEOM_TestOthers.py
1417 def MakeCut(s1, s2):
1418 return MakeBoolean(s1, s2, 2)
1420 ## Shortcut to MakeBoolean(s1, s2, 3)
1422 # Example: see GEOM_TestOthers.py
1423 def MakeFuse(s1, s2):
1424 return MakeBoolean(s1, s2, 3)
1426 ## Shortcut to MakeBoolean(s1, s2, 4)
1428 # Example: see GEOM_TestOthers.py
1429 def MakeSection(s1, s2):
1430 return MakeBoolean(s1, s2, 4)
1432 ## Perform partition operation.
1433 # @param ListShapes Shapes to be intersected.
1434 # @param ListTools Shapes to intersect theShapes.
1435 # !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1436 # in order to avoid possible intersection between shapes from
1438 # @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1440 # After implementation new version of PartitionAlgo (October 2006)
1441 # other parameters are ignored by current functionality. They are kept
1442 # in this function only for support old versions.
1443 # Ignored parameters:
1444 # @param ListKeepInside Shapes, outside which the results will be deleted.
1445 # Each shape from theKeepInside must belong to theShapes also.
1446 # @param ListRemoveInside Shapes, inside which the results will be deleted.
1447 # Each shape from theRemoveInside must belong to theShapes also.
1448 # @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1449 # @param ListMaterials Material indices for each shape. Make sence,
1450 # only if theRemoveWebs is TRUE.
1452 # @return New GEOM_Object, containing the result shapes.
1454 # Example: see GEOM_TestAll.py
1455 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1456 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1457 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1458 ListKeepInside, ListRemoveInside,
1459 Limit, RemoveWebs, ListMaterials);
1460 if BoolOp.IsDone() == 0:
1461 print "MakePartition : ", BoolOp.GetErrorCode()
1464 ## Perform partition operation.
1465 # This method may be useful if it is needed to make a partition for
1466 # compound contains nonintersected shapes. Performance will be better
1467 # since intersection between shapes from compound is not performed.
1469 # Description of all parameters as in previous method MakePartition()
1471 # !!!NOTE: Passed compounds (via ListShapes or via ListTools)
1472 # have to consist of nonintersecting shapes.
1474 # @return New GEOM_Object, containing the result shapes.
1476 def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1477 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1478 anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
1479 ListKeepInside, ListRemoveInside,
1480 Limit, RemoveWebs, ListMaterials);
1481 if BoolOp.IsDone() == 0:
1482 print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
1485 ## Shortcut to MakePartition()
1487 # Example: see GEOM_TestOthers.py
1488 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1489 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1490 anObj = MakePartition(ListShapes, ListTools,
1491 ListKeepInside, ListRemoveInside,
1492 Limit, RemoveWebs, ListMaterials);
1495 ## Perform partition of the Shape with the Plane
1496 # @param theShape Shape to be intersected.
1497 # @param thePlane Tool shape, to intersect theShape.
1498 # @return New GEOM_Object, containing the result shape.
1500 # Example: see GEOM_TestAll.py
1501 def MakeHalfPartition(theShape, thePlane):
1502 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1503 if BoolOp.IsDone() == 0:
1504 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1507 # -----------------------------------------------------------------------------
1509 # -----------------------------------------------------------------------------
1511 ## Translate the given object along the vector, specified
1512 # by its end points, creating its copy before the translation.
1513 # @param theObject The object to be translated.
1514 # @param thePoint1 Start point of translation vector.
1515 # @param thePoint2 End point of translation vector.
1516 # @return New GEOM_Object, containing the translated object.
1518 # Example: see GEOM_TestAll.py
1519 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1520 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1521 if TrsfOp.IsDone() == 0:
1522 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1525 ## Translate the given object along the vector, specified
1526 # by its components, creating its copy before the translation.
1527 # @param theObject The object to be translated.
1528 # @param theDX,theDY,theDZ Components of translation vector.
1529 # @return New GEOM_Object, containing the translated object.
1531 # Example: see GEOM_TestAll.py
1532 def MakeTranslation(theObject, theDX, theDY, theDZ):
1533 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1534 if TrsfOp.IsDone() == 0:
1535 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1538 ## Translate the given object along the given vector,
1539 # creating its copy before the translation.
1540 # @param theObject The object to be translated.
1541 # @param theVector The translation vector.
1542 # @return New GEOM_Object, containing the translated object.
1544 # Example: see GEOM_TestAll.py
1545 def MakeTranslationVector(theObject, theVector):
1546 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1547 if TrsfOp.IsDone() == 0:
1548 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1551 ## Rotate the given object around the given axis
1552 # on the given angle, creating its copy before the rotatation.
1553 # @param theObject The object to be rotated.
1554 # @param theAxis Rotation axis.
1555 # @param theAngle Rotation angle in radians.
1556 # @return New GEOM_Object, containing the rotated object.
1558 # Example: see GEOM_TestAll.py
1559 def MakeRotation(theObject, theAxis, theAngle):
1560 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1561 if TrsfOp.IsDone() == 0:
1562 print "RotateCopy : ", TrsfOp.GetErrorCode()
1565 ## Rotate given object around vector perpendicular to plane
1566 # containing three points, creating its copy before the rotatation.
1567 # @param theObject The object to be rotated.
1568 # @param theCentPoint central point - the axis is the vector perpendicular to the plane
1569 # containing the three points.
1570 # @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1571 # @return New GEOM_Object, containing the rotated object.
1573 # Example: see GEOM_TestAll.py
1574 def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
1575 anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1576 if TrsfOp.IsDone() == 0:
1577 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
1580 ## Scale the given object by the factor, creating its copy before the scaling.
1581 # @param theObject The object to be scaled.
1582 # @param thePoint Center point for scaling.
1583 # @param theFactor Scaling factor value.
1584 # @return New GEOM_Object, containing the scaled shape.
1586 # Example: see GEOM_TestAll.py
1587 def MakeScaleTransform(theObject, thePoint, theFactor):
1588 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1589 if TrsfOp.IsDone() == 0:
1590 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1593 ## Create an object, symmetrical
1594 # to the given one relatively the given plane.
1595 # @param theObject The object to be mirrored.
1596 # @param thePlane Plane of symmetry.
1597 # @return New GEOM_Object, containing the mirrored shape.
1599 # Example: see GEOM_TestAll.py
1600 def MakeMirrorByPlane(theObject, thePlane):
1601 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1602 if TrsfOp.IsDone() == 0:
1603 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1606 ## Create an object, symmetrical
1607 # to the given one relatively the given axis.
1608 # @param theObject The object to be mirrored.
1609 # @param theAxis Axis of symmetry.
1610 # @return New GEOM_Object, containing the mirrored shape.
1612 # Example: see GEOM_TestAll.py
1613 def MakeMirrorByAxis(theObject, theAxis):
1614 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1615 if TrsfOp.IsDone() == 0:
1616 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1619 ## Create an object, symmetrical
1620 # to the given one relatively the given point.
1621 # @param theObject The object to be mirrored.
1622 # @param thePoint Point of symmetry.
1623 # @return New GEOM_Object, containing the mirrored shape.
1625 # Example: see GEOM_TestAll.py
1626 def MakeMirrorByPoint(theObject, thePoint):
1627 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1628 if TrsfOp.IsDone() == 0:
1629 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1632 ## Modify the Location of the given object by LCS,
1633 # creating its copy before the setting.
1634 # @param theObject The object to be displaced.
1635 # @param theStartLCS Coordinate system to perform displacement from it.
1636 # If \a theStartLCS is NULL, displacement
1637 # will be performed from global CS.
1638 # If \a theObject itself is used as \a theStartLCS,
1639 # its location will be changed to \a theEndLCS.
1640 # @param theEndLCS Coordinate system to perform displacement to it.
1641 # @return New GEOM_Object, containing the displaced shape.
1643 # Example: see GEOM_TestAll.py
1644 def MakePosition(theObject, theStartLCS, theEndLCS):
1645 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1646 if TrsfOp.IsDone() == 0:
1647 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1650 ## Create new object as offset of the given one.
1651 # @param theObject The base object for the offset.
1652 # @param theOffset Offset value.
1653 # @return New GEOM_Object, containing the offset object.
1655 # Example: see GEOM_TestAll.py
1656 def MakeOffset(theObject, theOffset):
1657 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1658 if TrsfOp.IsDone() == 0:
1659 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1662 # -----------------------------------------------------------------------------
1664 # -----------------------------------------------------------------------------
1666 ## Translate the given object along the given vector a given number times
1667 # @param theObject The object to be translated.
1668 # @param theVector Direction of the translation.
1669 # @param theStep Distance to translate on.
1670 # @param theNbTimes Quantity of translations to be done.
1671 # @return New GEOM_Object, containing compound of all
1672 # the shapes, obtained after each translation.
1674 # Example: see GEOM_TestAll.py
1675 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1676 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1677 if TrsfOp.IsDone() == 0:
1678 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1681 ## Conseqently apply two specified translations to theObject specified number of times.
1682 # @param theObject The object to be translated.
1683 # @param theVector1 Direction of the first translation.
1684 # @param theStep1 Step of the first translation.
1685 # @param theNbTimes1 Quantity of translations to be done along theVector1.
1686 # @param theVector2 Direction of the second translation.
1687 # @param theStep2 Step of the second translation.
1688 # @param theNbTimes2 Quantity of translations to be done along theVector2.
1689 # @return New GEOM_Object, containing compound of all
1690 # the shapes, obtained after each translation.
1692 # Example: see GEOM_TestAll.py
1693 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1694 theVector2, theStep2, theNbTimes2):
1695 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1696 theVector2, theStep2, theNbTimes2)
1697 if TrsfOp.IsDone() == 0:
1698 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1701 ## Rotate the given object around the given axis a given number times.
1702 # Rotation angle will be 2*PI/theNbTimes.
1703 # @param theObject The object to be rotated.
1704 # @param theAxis The rotation axis.
1705 # @param theNbTimes Quantity of rotations to be done.
1706 # @return New GEOM_Object, containing compound of all the
1707 # shapes, obtained after each rotation.
1709 # Example: see GEOM_TestAll.py
1710 def MultiRotate1D(theObject, theAxis, theNbTimes):
1711 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1712 if TrsfOp.IsDone() == 0:
1713 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1716 ## Rotate the given object around the
1717 # given axis on the given angle a given number
1718 # times and multi-translate each rotation result.
1719 # Translation direction passes through center of gravity
1720 # of rotated shape and its projection on the rotation axis.
1721 # @param theObject The object to be rotated.
1722 # @param theAxis Rotation axis.
1723 # @param theAngle Rotation angle in graduces.
1724 # @param theNbTimes1 Quantity of rotations to be done.
1725 # @param theStep Translation distance.
1726 # @param theNbTimes2 Quantity of translations to be done.
1727 # @return New GEOM_Object, containing compound of all the
1728 # shapes, obtained after each transformation.
1730 # Example: see GEOM_TestAll.py
1731 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1732 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1733 if TrsfOp.IsDone() == 0:
1734 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1737 ## The same, as MultiRotate1D(), but axis is given by direction and point
1739 # Example: see GEOM_TestOthers.py
1740 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1741 aVec = MakeLine(aPoint,aDir)
1742 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1745 ## The same, as MultiRotate2D(), but axis is given by direction and point
1747 # Example: see GEOM_TestOthers.py
1748 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1749 aVec = MakeLine(aPoint,aDir)
1750 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1753 # -----------------------------------------------------------------------------
1755 # -----------------------------------------------------------------------------
1757 ## Perform a fillet on all edges of the given shape.
1758 # @param theShape Shape, to perform fillet on.
1759 # @param theR Fillet radius.
1760 # @return New GEOM_Object, containing the result shape.
1762 # Example: see GEOM_TestOthers.py
1763 def MakeFilletAll(theShape, theR):
1764 anObj = LocalOp.MakeFilletAll(theShape, theR)
1765 if LocalOp.IsDone() == 0:
1766 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1769 ## Perform a fillet on the specified edges/faces of the given shape
1770 # @param theShape Shape, to perform fillet on.
1771 # @param theR Fillet radius.
1772 # @param theShapeType Type of shapes in <theListShapes>.
1773 # @param theListShapes Global indices of edges/faces to perform fillet on.
1774 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1775 # @return New GEOM_Object, containing the result shape.
1777 # Example: see GEOM_TestAll.py
1778 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1780 if theShapeType == ShapeType["EDGE"]:
1781 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1783 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1784 if LocalOp.IsDone() == 0:
1785 print "MakeFillet : ", LocalOp.GetErrorCode()
1788 ## Perform a symmetric chamfer on all edges of the given shape.
1789 # @param theShape Shape, to perform chamfer on.
1790 # @param theD Chamfer size along each face.
1791 # @return New GEOM_Object, containing the result shape.
1793 # Example: see GEOM_TestOthers.py
1794 def MakeChamferAll(theShape, theD):
1795 anObj = LocalOp.MakeChamferAll(theShape, theD)
1796 if LocalOp.IsDone() == 0:
1797 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1800 ## Perform a chamfer on edges, common to the specified faces,
1801 # with distance D1 on the Face1
1802 # @param theShape Shape, to perform chamfer on.
1803 # @param theD1 Chamfer size along \a theFace1.
1804 # @param theD2 Chamfer size along \a theFace2.
1805 # @param theFace1,theFace2 Global indices of two faces of \a theShape.
1806 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1807 # @return New GEOM_Object, containing the result shape.
1809 # Example: see GEOM_TestAll.py
1810 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1811 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1812 if LocalOp.IsDone() == 0:
1813 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1816 ## Perform a chamfer on all edges of the specified faces,
1817 # with distance D1 on the first specified face (if several for one edge)
1818 # @param theShape Shape, to perform chamfer on.
1819 # @param theD1 Chamfer size along face from \a theFaces. If both faces,
1820 # connected to the edge, are in \a theFaces, \a theD1
1821 # will be get along face, which is nearer to \a theFaces beginning.
1822 # @param theD2 Chamfer size along another of two faces, connected to the edge.
1823 # @param theFaces Sequence of global indices of faces of \a theShape.
1824 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1825 # @return New GEOM_Object, containing the result shape.
1827 # Example: see GEOM_TestAll.py
1828 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1829 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1830 if LocalOp.IsDone() == 0:
1831 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1834 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1836 # Example: see GEOM_TestOthers.py
1837 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1839 if aShapeType == ShapeType["EDGE"]:
1840 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1842 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1845 ## Perform an Archimde operation on the given shape with given parameters.
1846 # The object presenting the resulting face is returned.
1847 # @param theShape Shape to be put in water.
1848 # @param theWeight Weight og the shape.
1849 # @param theWaterDensity Density of the water.
1850 # @param theMeshDeflection Deflection of the mesh, using to compute the section.
1851 # @return New GEOM_Object, containing a section of \a theShape
1852 # by a plane, corresponding to water level.
1854 # Example: see GEOM_TestAll.py
1855 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1856 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1857 if LocalOp.IsDone() == 0:
1858 print "MakeArchimede : ", LocalOp.GetErrorCode()
1861 # -----------------------------------------------------------------------------
1862 # Information objects
1863 # -----------------------------------------------------------------------------
1865 ## Get point coordinates
1868 # Example: see GEOM_TestMeasures.py
1869 def PointCoordinates(Point):
1870 aTuple = MeasuOp.PointCoordinates(Point)
1871 if MeasuOp.IsDone() == 0:
1872 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1875 ## Get summarized length of all wires,
1876 # area of surface and volume of the given shape.
1877 # @param theShape Shape to define properties of.
1878 # @return [theLength, theSurfArea, theVolume]
1879 # theLength: Summarized length of all wires of the given shape.
1880 # theSurfArea: Area of surface of the given shape.
1881 # theVolume: Volume of the given shape.
1883 # Example: see GEOM_TestMeasures.py
1884 def BasicProperties(theShape):
1885 aTuple = MeasuOp.GetBasicProperties(theShape)
1886 if MeasuOp.IsDone() == 0:
1887 print "BasicProperties : ", MeasuOp.GetErrorCode()
1890 ## Get parameters of bounding box of the given shape
1891 # @param theShape Shape to obtain bounding box of.
1892 # @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1893 # Xmin,Xmax: Limits of shape along OX axis.
1894 # Ymin,Ymax: Limits of shape along OY axis.
1895 # Zmin,Zmax: Limits of shape along OZ axis.
1897 # Example: see GEOM_TestMeasures.py
1898 def BoundingBox(theShape):
1899 aTuple = MeasuOp.GetBoundingBox(theShape)
1900 if MeasuOp.IsDone() == 0:
1901 print "BoundingBox : ", MeasuOp.GetErrorCode()
1904 ## Get inertia matrix and moments of inertia of theShape.
1905 # @param theShape Shape to calculate inertia of.
1906 # @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1907 # I(1-3)(1-3): Components of the inertia matrix of the given shape.
1908 # Ix,Iy,Iz: Moments of inertia of the given shape.
1910 # Example: see GEOM_TestMeasures.py
1911 def Inertia(theShape):
1912 aTuple = MeasuOp.GetInertia(theShape)
1913 if MeasuOp.IsDone() == 0:
1914 print "Inertia : ", MeasuOp.GetErrorCode()
1917 ## Get minimal distance between the given shapes.
1918 # @param theShape1,theShape2 Shapes to find minimal distance between.
1919 # @return Value of the minimal distance between the given shapes.
1921 # Example: see GEOM_TestMeasures.py
1922 def MinDistance(theShape1, theShape2):
1923 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1924 if MeasuOp.IsDone() == 0:
1925 print "MinDistance : ", MeasuOp.GetErrorCode()
1928 ## Get min and max tolerances of sub-shapes of theShape
1929 # @param theShape Shape, to get tolerances of.
1930 # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1931 # FaceMin,FaceMax: Min and max tolerances of the faces.
1932 # EdgeMin,EdgeMax: Min and max tolerances of the edges.
1933 # VertMin,VertMax: Min and max tolerances of the vertices.
1935 # Example: see GEOM_TestMeasures.py
1936 def Tolerance(theShape):
1937 aTuple = MeasuOp.GetTolerance(theShape)
1938 if MeasuOp.IsDone() == 0:
1939 print "Tolerance : ", MeasuOp.GetErrorCode()
1942 ## Obtain description of the given shape (number of sub-shapes of each type)
1943 # @param theShape Shape to be described.
1944 # @return Description of the given shape.
1946 # Example: see GEOM_TestMeasures.py
1947 def WhatIs(theShape):
1948 aDescr = MeasuOp.WhatIs(theShape)
1949 if MeasuOp.IsDone() == 0:
1950 print "WhatIs : ", MeasuOp.GetErrorCode()
1953 ## Get a point, situated at the centre of mass of theShape.
1954 # @param theShape Shape to define centre of mass of.
1955 # @return New GEOM_Object, containing the created point.
1957 # Example: see GEOM_TestMeasures.py
1958 def MakeCDG(theShape):
1959 anObj = MeasuOp.GetCentreOfMass(theShape)
1960 if MeasuOp.IsDone() == 0:
1961 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1964 ## Check a topology of the given shape.
1965 # @param theShape Shape to check validity of.
1966 # @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
1967 # if TRUE, the shape's geometry will be checked also.
1968 # @return TRUE, if the shape "seems to be valid".
1969 # If theShape is invalid, prints a description of problem.
1971 # Example: see GEOM_TestMeasures.py
1972 def CheckShape(theShape, theIsCheckGeom = 0):
1974 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
1976 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1978 if MeasuOp.IsDone() == 0:
1979 print "CheckShape : ", MeasuOp.GetErrorCode()
1985 ## Get position (LCS) of theShape.
1987 # Origin of the LCS is situated at the shape's center of mass.
1988 # Axes of the LCS are obtained from shape's location or,
1989 # if the shape is a planar face, from position of its plane.
1991 # @param theShape Shape to calculate position of.
1992 # @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
1993 # Ox,Oy,Oz: Coordinates of shape's LCS origin.
1994 # Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
1995 # Xx,Xy,Xz: Coordinates of shape's LCS X direction.
1997 # Example: see GEOM_TestMeasures.py
1998 def GetPosition(theShape):
1999 aTuple = MeasuOp.GetPosition(theShape)
2000 if MeasuOp.IsDone() == 0:
2001 print "GetPosition : ", MeasuOp.GetErrorCode()
2004 ## Get kind of theShape.
2006 # @param theShape Shape to get a kind of.
2007 # @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
2008 # and a list of parameters, describing the shape.
2009 # @note Concrete meaning of each value, returned via \a theIntegers
2010 # or \a theDoubles list depends on the kind of the shape.
2011 # The full list of possible outputs is:
2013 # geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices
2014 # geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices
2016 # geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices
2017 # geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices
2019 # geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices
2020 # geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices
2022 # geompy.kind.SPHERE xc yc zc R
2023 # geompy.kind.CYLINDER xb yb zb dx dy dz R H
2024 # geompy.kind.BOX xc yc zc ax ay az
2025 # geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az
2026 # geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2
2027 # geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H
2028 # geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices
2029 # geompy.kind.SOLID nb_faces nb_edges nb_vertices
2031 # geompy.kind.SPHERE2D xc yc zc R
2032 # geompy.kind.CYLINDER2D xb yb zb dx dy dz R H
2033 # geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2
2034 # geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H
2035 # geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R
2036 # geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2
2037 # geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices
2038 # geompy.kind.PLANE xo yo zo dx dy dz
2039 # geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices
2040 # geompy.kind.FACE nb_edges nb_vertices
2042 # geompy.kind.CIRCLE xc yc zc dx dy dz R
2043 # geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2
2044 # geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2
2045 # geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2
2046 # geompy.kind.LINE xo yo zo dx dy dz
2047 # geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2
2048 # geompy.kind.EDGE nb_vertices
2050 # geompy.kind.VERTEX x y z
2052 # Example: see GEOM_TestMeasures.py
2053 def KindOfShape(theShape):
2054 aRoughTuple = MeasuOp.KindOfShape(theShape)
2055 if MeasuOp.IsDone() == 0:
2056 print "KindOfShape : ", MeasuOp.GetErrorCode()
2059 aKind = aRoughTuple[0]
2060 anInts = aRoughTuple[1]
2061 aDbls = aRoughTuple[2]
2063 # Now there is no exception from this rule:
2064 aKindTuple = [aKind] + aDbls + anInts
2066 # If they are we will regroup parameters for such kind of shape.
2068 #if aKind == kind.SOME_KIND:
2069 # # SOME_KIND int int double int double double
2070 # aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
2074 # -----------------------------------------------------------------------------
2075 # Import/Export objects
2076 # -----------------------------------------------------------------------------
2078 ## Import a shape from the BREP or IGES or STEP file
2079 # (depends on given format) with given name.
2080 # @param theFileName The file, containing the shape.
2081 # @param theFormatName Specify format for the file reading.
2082 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2083 # @return New GEOM_Object, containing the imported shape.
2085 # Example: see GEOM_TestOthers.py
2086 def Import(theFileName, theFormatName):
2087 anObj = InsertOp.Import(theFileName, theFormatName)
2088 if InsertOp.IsDone() == 0:
2089 print "Import : ", InsertOp.GetErrorCode()
2092 ## Shortcut to Import() for BREP format
2094 # Example: see GEOM_TestOthers.py
2095 def ImportBREP(theFileName):
2096 return Import(theFileName, "BREP")
2098 ## Shortcut to Import() for IGES format
2100 # Example: see GEOM_TestOthers.py
2101 def ImportIGES(theFileName):
2102 return Import(theFileName, "IGES")
2104 ## Shortcut to Import() for STEP format
2106 # Example: see GEOM_TestOthers.py
2107 def ImportSTEP(theFileName):
2108 return Import(theFileName, "STEP")
2110 ## Export the given shape into a file with given name.
2111 # @param theObject Shape to be stored in the file.
2112 # @param theFileName Name of the file to store the given shape in.
2113 # @param theFormatName Specify format for the shape storage.
2114 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2116 # Example: see GEOM_TestOthers.py
2117 def Export(theObject, theFileName, theFormatName):
2118 InsertOp.Export(theObject, theFileName, theFormatName)
2119 if InsertOp.IsDone() == 0:
2120 print "Export : ", InsertOp.GetErrorCode()
2122 ## Shortcut to Export() for BREP format
2124 # Example: see GEOM_TestOthers.py
2125 def ExportBREP(theObject, theFileName):
2126 return Export(theObject, theFileName, "BREP")
2128 ## Shortcut to Export() for IGES format
2130 # Example: see GEOM_TestOthers.py
2131 def ExportIGES(theObject, theFileName):
2132 return Export(theObject, theFileName, "IGES")
2134 ## Shortcut to Export() for STEP format
2136 # Example: see GEOM_TestOthers.py
2137 def ExportSTEP(theObject, theFileName):
2138 return Export(theObject, theFileName, "STEP")
2140 # -----------------------------------------------------------------------------
2142 # -----------------------------------------------------------------------------
2144 ## Create a quadrangle face from four edges. Order of Edges is not
2145 # important. It is not necessary that edges share the same vertex.
2146 # @param E1,E2,E3,E4 Edges for the face bound.
2147 # @return New GEOM_Object, containing the created face.
2149 # Example: see GEOM_Spanner.py
2150 def MakeQuad(E1, E2, E3, E4):
2151 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2152 if BlocksOp.IsDone() == 0:
2153 print "MakeQuad : ", BlocksOp.GetErrorCode()
2156 ## Create a quadrangle face on two edges.
2157 # The missing edges will be built by creating the shortest ones.
2158 # @param E1,E2 Two opposite edges for the face.
2159 # @return New GEOM_Object, containing the created face.
2161 # Example: see GEOM_Spanner.py
2162 def MakeQuad2Edges(E1, E2):
2163 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2164 if BlocksOp.IsDone() == 0:
2165 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2168 ## Create a quadrangle face with specified corners.
2169 # The missing edges will be built by creating the shortest ones.
2170 # @param V1,V2,V3,V4 Corner vertices for the face.
2171 # @return New GEOM_Object, containing the created face.
2173 # Example: see GEOM_Spanner.py
2174 def MakeQuad4Vertices(V1, V2, V3, V4):
2175 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2176 if BlocksOp.IsDone() == 0:
2177 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2180 ## Create a hexahedral solid, bounded by the six given faces. Order of
2181 # faces is not important. It is not necessary that Faces share the same edge.
2182 # @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2183 # @return New GEOM_Object, containing the created solid.
2185 # Example: see GEOM_Spanner.py
2186 def MakeHexa(F1, F2, F3, F4, F5, F6):
2187 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2188 if BlocksOp.IsDone() == 0:
2189 print "MakeHexa : ", BlocksOp.GetErrorCode()
2192 ## Create a hexahedral solid between two given faces.
2193 # The missing faces will be built by creating the smallest ones.
2194 # @param F1,F2 Two opposite faces for the hexahedral solid.
2195 # @return New GEOM_Object, containing the created solid.
2197 # Example: see GEOM_Spanner.py
2198 def MakeHexa2Faces(F1, F2):
2199 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2200 if BlocksOp.IsDone() == 0:
2201 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2204 ## Get a vertex, found in the given shape by its coordinates.
2205 # @param theShape Block or a compound of blocks.
2206 # @param theX,theY,theZ Coordinates of the sought vertex.
2207 # @param theEpsilon Maximum allowed distance between the resulting
2208 # vertex and point with the given coordinates.
2209 # @return New GEOM_Object, containing the found vertex.
2211 # Example: see GEOM_TestOthers.py
2212 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2213 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2214 if BlocksOp.IsDone() == 0:
2215 print "GetPoint : ", BlocksOp.GetErrorCode()
2218 ## Get an edge, found in the given shape by two given vertices.
2219 # @param theShape Block or a compound of blocks.
2220 # @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2221 # @return New GEOM_Object, containing the found edge.
2223 # Example: see GEOM_Spanner.py
2224 def GetEdge(theShape, thePoint1, thePoint2):
2225 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2226 if BlocksOp.IsDone() == 0:
2227 print "GetEdge : ", BlocksOp.GetErrorCode()
2230 ## Find an edge of the given shape, which has minimal distance to the given point.
2231 # @param theShape Block or a compound of blocks.
2232 # @param thePoint Point, close to the desired edge.
2233 # @return New GEOM_Object, containing the found edge.
2235 # Example: see GEOM_TestOthers.py
2236 def GetEdgeNearPoint(theShape, thePoint):
2237 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2238 if BlocksOp.IsDone() == 0:
2239 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2242 ## Returns a face, found in the given shape by four given corner vertices.
2243 # @param theShape Block or a compound of blocks.
2244 # @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2245 # @return New GEOM_Object, containing the found face.
2247 # Example: see GEOM_Spanner.py
2248 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2249 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2250 if BlocksOp.IsDone() == 0:
2251 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2254 ## Get a face of block, found in the given shape by two given edges.
2255 # @param theShape Block or a compound of blocks.
2256 # @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2257 # @return New GEOM_Object, containing the found face.
2259 # Example: see GEOM_Spanner.py
2260 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2261 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2262 if BlocksOp.IsDone() == 0:
2263 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2266 ## Find a face, opposite to the given one in the given block.
2267 # @param theBlock Must be a hexahedral solid.
2268 # @param theFace Face of \a theBlock, opposite to the desired face.
2269 # @return New GEOM_Object, containing the found face.
2271 # Example: see GEOM_Spanner.py
2272 def GetOppositeFace(theBlock, theFace):
2273 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2274 if BlocksOp.IsDone() == 0:
2275 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2278 ## Find a face of the given shape, which has minimal distance to the given point.
2279 # @param theShape Block or a compound of blocks.
2280 # @param thePoint Point, close to the desired face.
2281 # @return New GEOM_Object, containing the found face.
2283 # Example: see GEOM_Spanner.py
2284 def GetFaceNearPoint(theShape, thePoint):
2285 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2286 if BlocksOp.IsDone() == 0:
2287 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2290 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2291 # @param theShape Block or a compound of blocks.
2292 # @param theVector Vector, close to the normale of the desired face.
2293 # @return New GEOM_Object, containing the found face.
2295 # Example: see GEOM_Spanner.py
2296 def GetFaceByNormale(theBlock, theVector):
2297 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2298 if BlocksOp.IsDone() == 0:
2299 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2302 ## Check, if the compound of blocks is given.
2303 # To be considered as a compound of blocks, the
2304 # given shape must satisfy the following conditions:
2305 # - Each element of the compound should be a Block (6 faces and 12 edges).
2306 # - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2307 # - The compound should be connexe.
2308 # - The glue between two quadrangle faces should be applied.
2309 # @param theCompound The compound to check.
2310 # @return TRUE, if the given shape is a compound of blocks.
2311 # If theCompound is not valid, prints all discovered errors.
2313 # Example: see GEOM_Spanner.py
2314 def CheckCompoundOfBlocks(theCompound):
2315 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2316 if BlocksOp.IsDone() == 0:
2317 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2320 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2324 ## Remove all seam and degenerated edges from \a theShape.
2325 # Unite faces and edges, sharing one surface. It means that
2326 # this faces must have references to one C++ surface object (handle).
2327 # @param theShape The compound or single solid to remove irregular edges from.
2328 # @return Improved shape.
2330 # Example: see GEOM_TestOthers.py
2331 def RemoveExtraEdges(theShape):
2332 anObj = BlocksOp.RemoveExtraEdges(theShape)
2333 if BlocksOp.IsDone() == 0:
2334 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2337 ## Check, if the given shape is a blocks compound.
2338 # Fix all detected errors.
2339 # \note Single block can be also fixed by this method.
2340 # @param theCompound The compound to check and improve.
2341 # @return Improved compound.
2343 # Example: see GEOM_TestOthers.py
2344 def CheckAndImprove(theShape):
2345 anObj = BlocksOp.CheckAndImprove(theShape)
2346 if BlocksOp.IsDone() == 0:
2347 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2350 ## Get all the blocks, contained in the given compound.
2351 # @param theCompound The compound to explode.
2352 # @param theMinNbFaces If solid has lower number of faces, it is not a block.
2353 # @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2354 # \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2355 # @return List of GEOM_Objects, containing the retrieved blocks.
2357 # Example: see GEOM_TestOthers.py
2358 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2359 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2360 if BlocksOp.IsDone() == 0:
2361 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2364 ## Find block, containing the given point inside its volume or on boundary.
2365 # @param theCompound Compound, to find block in.
2366 # @param thePoint Point, close to the desired block. If the point lays on
2367 # boundary between some blocks, we return block with nearest center.
2368 # @return New GEOM_Object, containing the found block.
2370 # Example: see GEOM_Spanner.py
2371 def GetBlockNearPoint(theCompound, thePoint):
2372 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2373 if BlocksOp.IsDone() == 0:
2374 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2377 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2378 # @param theCompound Compound, to find block in.
2379 # @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2380 # @return New GEOM_Object, containing the found block.
2382 # Example: see GEOM_TestOthers.py
2383 def GetBlockByParts(theCompound, theParts):
2384 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2385 if BlocksOp.IsDone() == 0:
2386 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2389 ## Return all blocks, containing all the elements, passed as the parts.
2390 # @param theCompound Compound, to find blocks in.
2391 # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2392 # @return List of GEOM_Objects, containing the found blocks.
2394 # Example: see GEOM_Spanner.py
2395 def GetBlocksByParts(theCompound, theParts):
2396 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2397 if BlocksOp.IsDone() == 0:
2398 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2401 ## Multi-transformate block and glue the result.
2402 # Transformation is defined so, as to superpose direction faces.
2403 # @param Block Hexahedral solid to be multi-transformed.
2404 # @param DirFace1 ID of First direction face.
2405 # @param DirFace2 ID of Second direction face.
2406 # @param NbTimes Quantity of transformations to be done.
2407 # \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2408 # @return New GEOM_Object, containing the result shape.
2410 # Example: see GEOM_Spanner.py
2411 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2412 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2413 if BlocksOp.IsDone() == 0:
2414 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2417 ## Multi-transformate block and glue the result.
2418 # @param Block Hexahedral solid to be multi-transformed.
2419 # @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2420 # @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2421 # @param NbTimesU,NbTimesV Quantity of transformations to be done.
2422 # @return New GEOM_Object, containing the result shape.
2424 # Example: see GEOM_Spanner.py
2425 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2426 DirFace1V, DirFace2V, NbTimesV):
2427 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2428 DirFace1V, DirFace2V, NbTimesV)
2429 if BlocksOp.IsDone() == 0:
2430 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2433 ## Build all possible propagation groups.
2434 # Propagation group is a set of all edges, opposite to one (main)
2435 # edge of this group directly or through other opposite edges.
2436 # Notion of Opposite Edge make sence only on quadrangle face.
2437 # @param theShape Shape to build propagation groups on.
2438 # @return List of GEOM_Objects, each of them is a propagation group.
2440 # Example: see GEOM_TestOthers.py
2441 def Propagate(theShape):
2442 listChains = BlocksOp.Propagate(theShape)
2443 if BlocksOp.IsDone() == 0:
2444 print "Propagate : ", BlocksOp.GetErrorCode()
2447 # -----------------------------------------------------------------------------
2449 # -----------------------------------------------------------------------------
2451 ## Creates a new group which will store sub shapes of theMainShape
2452 # @param theMainShape is a GEOM object on which the group is selected
2453 # @param theShapeType defines a shape type of the group
2454 # @return a newly created GEOM group
2456 # Example: see GEOM_TestOthers.py
2457 def CreateGroup(theMainShape, theShapeType):
2458 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2459 if GroupOp.IsDone() == 0:
2460 print "CreateGroup : ", GroupOp.GetErrorCode()
2463 ## Adds a sub object with ID theSubShapeId to the group
2464 # @param theGroup is a GEOM group to which the new sub shape is added
2465 # @param theSubShapeID is a sub shape ID in the main object.
2466 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2468 # Example: see GEOM_TestOthers.py
2469 def AddObject(theGroup, theSubShapeID):
2470 GroupOp.AddObject(theGroup, theSubShapeID)
2471 if GroupOp.IsDone() == 0:
2472 print "AddObject : ", GroupOp.GetErrorCode()
2474 ## Removes a sub object with ID \a theSubShapeId from the group
2475 # @param theGroup is a GEOM group from which the new sub shape is removed
2476 # @param theSubShapeID is a sub shape ID in the main object.
2477 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2479 # Example: see GEOM_TestOthers.py
2480 def RemoveObject(theGroup, theSubShapeID):
2481 GroupOp.RemoveObject(theGroup, theSubShapeID)
2482 if GroupOp.IsDone() == 0:
2483 print "RemoveObject : ", GroupOp.GetErrorCode()
2485 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2486 # @param theGroup is a GEOM group to which the new sub shapes are added.
2487 # @param theSubShapes is a list of sub shapes to be added.
2489 # Example: see GEOM_TestOthers.py
2490 def UnionList (theGroup, theSubShapes):
2491 GroupOp.UnionList(theGroup, theSubShapes)
2492 if GroupOp.IsDone() == 0:
2493 print "UnionList : ", GroupOp.GetErrorCode()
2495 ## Works like the above method, but argument
2496 # theSubShapes here is a list of sub-shapes indices
2498 # Example: see GEOM_TestOthers.py
2499 def UnionIDs(theGroup, theSubShapes):
2500 GroupOp.UnionIDs(theGroup, theSubShapes)
2501 if GroupOp.IsDone() == 0:
2502 print "UnionIDs : ", GroupOp.GetErrorCode()
2504 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2505 # @param theGroup is a GEOM group from which the sub-shapes are removed.
2506 # @param theSubShapes is a list of sub-shapes to be removed.
2508 # Example: see GEOM_TestOthers.py
2509 def DifferenceList (theGroup, theSubShapes):
2510 GroupOp.DifferenceList(theGroup, theSubShapes)
2511 if GroupOp.IsDone() == 0:
2512 print "DifferenceList : ", GroupOp.GetErrorCode()
2514 ## Works like the above method, but argument
2515 # theSubShapes here is a list of sub-shapes indices
2517 # Example: see GEOM_TestOthers.py
2518 def DifferenceIDs(theGroup, theSubShapes):
2519 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2520 if GroupOp.IsDone() == 0:
2521 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2523 ## Returns a list of sub objects ID stored in the group
2524 # @param theGroup is a GEOM group for which a list of IDs is requested
2526 # Example: see GEOM_TestOthers.py
2527 def GetObjectIDs(theGroup):
2528 ListIDs = GroupOp.GetObjects(theGroup)
2529 if GroupOp.IsDone() == 0:
2530 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2533 ## Returns a type of sub objects stored in the group
2534 # @param theGroup is a GEOM group which type is returned.
2536 # Example: see GEOM_TestOthers.py
2537 def GetType(theGroup):
2538 aType = GroupOp.GetType(theGroup)
2539 if GroupOp.IsDone() == 0:
2540 print "GetType : ", GroupOp.GetErrorCode()
2543 ## Returns a main shape associated with the group
2544 # @param theGroup is a GEOM group for which a main shape object is requested
2545 # @return a GEOM object which is a main shape for theGroup
2547 # Example: see GEOM_TestOthers.py
2548 def GetMainShape(theGroup):
2549 anObj = GroupOp.GetMainShape(theGroup)
2550 if GroupOp.IsDone() == 0:
2551 print "GetMainShape : ", GroupOp.GetErrorCode()
2554 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2555 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2556 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2557 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2560 Props = BasicProperties(edge)
2561 if min_length <= Props[0] and Props[0] <= max_length:
2562 if (not include_min) and (min_length == Props[0]):
2565 if (not include_max) and (Props[0] == max_length):
2568 edges_in_range.append(edge)
2570 if len(edges_in_range) <= 0:
2571 print "No edges found by given criteria"
2574 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2575 UnionList(group_edges, edges_in_range)
2579 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2580 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2581 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2582 nb_selected = sg.SelectedCount()
2584 print "Select a shape before calling this function, please."
2587 print "Only one shape must be selected"
2590 id_shape = sg.getSelected(0)
2591 shape = IDToObject( id_shape )
2593 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2597 if include_min: left_str = " <= "
2598 if include_max: right_str = " <= "
2600 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2601 + left_str + "length" + right_str + `max_length`)
2603 sg.updateObjBrowser(1)
2607 ## Add Path to load python scripts from
2609 if (sys.path.count(Path) < 1):
2610 sys.path.append(Path)