1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # Author : Paul RASCLE, EDF
40 g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
41 geom = g._narrow( GEOM.GEOM_Gen )
42 #gg = ImportComponentGUI("GEOM")
45 #SRN: modified on Mar 18, 2005
64 def init_geom(theStudy):
66 global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
67 global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
70 myStudyId = myStudy._get_StudyId()
71 myBuilder = myStudy.NewBuilder()
72 father = myStudy.FindComponent("GEOM")
74 father = myBuilder.NewComponent("GEOM")
75 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
76 FName = A1._narrow(SALOMEDS.AttributeName)
77 FName.SetValue("Geometry")
78 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap")
79 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
80 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
81 myBuilder.DefineComponentInstance(father,geom)
84 # -----------------------------------------------------------------------------
85 # Assign Operations Interfaces
86 # -----------------------------------------------------------------------------
88 BasicOp = geom.GetIBasicOperations (myStudyId)
89 CurvesOp = geom.GetICurvesOperations (myStudyId)
90 PrimOp = geom.GetI3DPrimOperations (myStudyId)
91 ShapesOp = geom.GetIShapesOperations (myStudyId)
92 HealOp = geom.GetIHealingOperations (myStudyId)
93 InsertOp = geom.GetIInsertOperations (myStudyId)
94 BoolOp = geom.GetIBooleanOperations (myStudyId)
95 TrsfOp = geom.GetITransformOperations(myStudyId)
96 LocalOp = geom.GetILocalOperations (myStudyId)
97 MeasuOp = geom.GetIMeasureOperations (myStudyId)
98 BlocksOp = geom.GetIBlocksOperations (myStudyId)
99 GroupOp = geom.GetIGroupOperations (myStudyId)
104 #SRN: end of modifications
106 ## Get name for sub-shape aSubObj of shape aMainObj
108 # Example: see GEOM_TestAll.py
109 def SubShapeName(aSubObj, aMainObj):
110 #aSubId = orb.object_to_string(aSubObj)
111 #aMainId = orb.object_to_string(aMainObj)
112 #index = gg.getIndexTopology(aSubId, aMainId)
113 #name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
114 index = ShapesOp.GetTopologyIndex(aMainObj, aSubObj)
115 name = ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index)
118 ## Publish in study aShape with name aName
120 # Example: see GEOM_TestAll.py
121 def addToStudy(aShape, aName):
123 aSObject = geom.AddInStudy(myStudy, aShape, aName, None)
125 print "addToStudy() failed"
127 return aShape.GetStudyEntry()
129 ## Publish in study aShape with name aName as sub-object of previously published aFather
131 # Example: see GEOM_TestAll.py
132 def addToStudyInFather(aFather, aShape, aName):
134 aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather)
136 print "addToStudyInFather() failed"
138 return aShape.GetStudyEntry()
140 # -----------------------------------------------------------------------------
141 # enumeration ShapeType as a dictionary
142 # -----------------------------------------------------------------------------
144 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
146 # -----------------------------------------------------------------------------
147 # enumeration shape_kind
148 # -----------------------------------------------------------------------------
150 kind = GEOM.GEOM_IKindOfShape
157 # -----------------------------------------------------------------------------
159 # -----------------------------------------------------------------------------
161 ## Create point by three coordinates.
162 # @param theX The X coordinate of the point.
163 # @param theY The Y coordinate of the point.
164 # @param theZ The Z coordinate of the point.
165 # @return New GEOM_Object, containing the created point.
167 # Example: see GEOM_TestAll.py
168 def MakeVertex(theX, theY, theZ):
169 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
170 if BasicOp.IsDone() == 0:
171 print "MakePointXYZ : ", BasicOp.GetErrorCode()
174 ## Create a point, distant from the referenced point
175 # on the given distances along the coordinate axes.
176 # @param theReference The referenced point.
177 # @param theX Displacement from the referenced point along OX axis.
178 # @param theY Displacement from the referenced point along OY axis.
179 # @param theZ Displacement from the referenced point along OZ axis.
180 # @return New GEOM_Object, containing the created point.
182 # Example: see GEOM_TestAll.py
183 def MakeVertexWithRef(theReference, theX, theY, theZ):
184 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
185 if BasicOp.IsDone() == 0:
186 print "MakePointWithReference : ", BasicOp.GetErrorCode()
189 ## Create a point, corresponding to the given parameter on the given curve.
190 # @param theRefCurve The referenced curve.
191 # @param theParameter Value of parameter on the referenced curve.
192 # @return New GEOM_Object, containing the created point.
194 # Example: see GEOM_TestAll.py
195 def MakeVertexOnCurve(theRefCurve, theParameter):
196 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
197 if BasicOp.IsDone() == 0:
198 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
201 ## Create a tangent, corresponding to the given parameter on the given curve.
202 # @param theRefCurve The referenced curve.
203 # @param theParameter Value of parameter on the referenced curve.
204 # @return New GEOM_Object, containing the created tangent.
205 def MakeTangentOnCurve(theRefCurve, theParameter):
206 anObj = BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
207 if BasicOp.IsDone() == 0:
208 print "MakeTangentOnCurve : ", BasicOp.GetErrorCode()
211 ## Create a vector with the given components.
212 # @param theDX X component of the vector.
213 # @param theDY Y component of the vector.
214 # @param theDZ Z component of the vector.
215 # @return New GEOM_Object, containing the created vector.
217 # Example: see GEOM_TestAll.py
218 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
219 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
220 if BasicOp.IsDone() == 0:
221 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
224 ## Create a vector between two points.
225 # @param thePnt1 Start point for the vector.
226 # @param thePnt2 End point for the vector.
227 # @return New GEOM_Object, containing the created vector.
229 # Example: see GEOM_TestAll.py
230 def MakeVector(thePnt1, thePnt2):
231 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
232 if BasicOp.IsDone() == 0:
233 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
236 ## Create a line, passing through the given point
237 # and parrallel to the given direction
238 # @param thePnt Point. The resulting line will pass through it.
239 # @param theDir Direction. The resulting line will be parallel to it.
240 # @return New GEOM_Object, containing the created line.
242 # Example: see GEOM_TestAll.py
243 def MakeLine(thePnt, theDir):
244 anObj = BasicOp.MakeLine(thePnt, theDir)
245 if BasicOp.IsDone() == 0:
246 print "MakeLine : ", BasicOp.GetErrorCode()
249 ## Create a line, passing through the given points
250 # @param thePnt1 First of two points, defining the line.
251 # @param thePnt2 Second of two points, defining the line.
252 # @return New GEOM_Object, containing the created line.
254 # Example: see GEOM_TestAll.py
255 def MakeLineTwoPnt(thePnt1, thePnt2):
256 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
257 if BasicOp.IsDone() == 0:
258 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
261 ## Create a plane, passing through the given point
262 # and normal to the given vector.
263 # @param thePnt Point, the plane has to pass through.
264 # @param theVec Vector, defining the plane normal direction.
265 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
266 # @return New GEOM_Object, containing the created plane.
268 # Example: see GEOM_TestAll.py
269 def MakePlane(thePnt, theVec, theTrimSize):
270 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
271 if BasicOp.IsDone() == 0:
272 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
275 ## Create a plane, passing through the three given points
276 # @param thePnt1 First of three points, defining the plane.
277 # @param thePnt2 Second of three points, defining the plane.
278 # @param thePnt3 Fird of three points, defining the plane.
279 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
280 # @return New GEOM_Object, containing the created plane.
282 # Example: see GEOM_TestAll.py
283 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
284 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
285 if BasicOp.IsDone() == 0:
286 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
289 ## Create a plane, similar to the existing one, but with another size of representing face.
290 # @param theFace Referenced plane or LCS(Marker).
291 # @param theTrimSize New half size of a side of quadrangle face, representing the plane.
292 # @return New GEOM_Object, containing the created plane.
294 # Example: see GEOM_TestAll.py
295 def MakePlaneFace(theFace, theTrimSize):
296 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
297 if BasicOp.IsDone() == 0:
298 print "MakePlaneFace : ", BasicOp.GetErrorCode()
301 ## Create a local coordinate system.
302 # @param OX,OY,OZ Three coordinates of coordinate system origin.
303 # @param XDX,XDY,XDZ Three components of OX direction
304 # @param YDX,YDY,YDZ Three components of OY direction
305 # @return New GEOM_Object, containing the created coordinate system.
307 # Example: see GEOM_TestAll.py
308 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
309 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
310 if BasicOp.IsDone() == 0:
311 print "MakeMarker : ", BasicOp.GetErrorCode()
314 ## Create a local coordinate system.
315 # @param theOrigin Point of coordinate system origin.
316 # @param theXVec Vector of X direction
317 # @param theYVec Vector of Y direction
318 # @return New GEOM_Object, containing the created coordinate system.
319 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
320 O = PointCoordinates( theOrigin )
322 for vec in [ theXVec, theYVec ]:
323 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
324 p1 = PointCoordinates( v1 )
325 p2 = PointCoordinates( v2 )
326 for i in range( 0, 3 ):
327 OXOY.append( p2[i] - p1[i] )
329 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
330 OXOY[0], OXOY[1], OXOY[2],
331 OXOY[3], OXOY[4], OXOY[5], )
332 if BasicOp.IsDone() == 0:
333 print "MakeMarker : ", BasicOp.GetErrorCode()
336 # -----------------------------------------------------------------------------
338 # -----------------------------------------------------------------------------
340 ## Create an arc of circle, passing through three given points.
341 # @param thePnt1 Start point of the arc.
342 # @param thePnt2 Middle point of the arc.
343 # @param thePnt3 End point of the arc.
344 # @return New GEOM_Object, containing the created arc.
346 # Example: see GEOM_TestAll.py
347 def MakeArc(thePnt1, thePnt2, thePnt3):
348 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
349 if CurvesOp.IsDone() == 0:
350 print "MakeArc : ", CurvesOp.GetErrorCode()
353 ## Create an arc of circle from a center and 2 points.
354 # @param thePnt1 Center of the arc
355 # @param thePnt2 Start point of the arc. (Gives also the radius of the arc)
356 # @param thePnt3 End point of the arc (Gives also a direction)
357 # @return New GEOM_Object, containing the created arc.
359 # Example: see GEOM_TestAll.py
360 def MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense):
361 anObj = CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense)
362 if CurvesOp.IsDone() == 0:
363 print "MakeArcCenter : ", CurvesOp.GetErrorCode()
366 ## Create a circle with given center, normal vector and radius.
367 # @param thePnt Circle center.
368 # @param theVec Vector, normal to the plane of the circle.
369 # @param theR Circle radius.
370 # @return New GEOM_Object, containing the created circle.
372 # Example: see GEOM_TestAll.py
373 def MakeCircle(thePnt, theVec, theR):
374 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
375 if CurvesOp.IsDone() == 0:
376 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
379 ## Create a circle, passing through three given points
380 # @param thePnt1,thePnt2,thePnt3 Points, defining the circle.
381 # @return New GEOM_Object, containing the created circle.
383 # Example: see GEOM_TestAll.py
384 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
385 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
386 if CurvesOp.IsDone() == 0:
387 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
390 ## Create an ellipse with given center, normal vector and radiuses.
391 # @param thePnt Ellipse center.
392 # @param theVec Vector, normal to the plane of the ellipse.
393 # @param theRMajor Major ellipse radius.
394 # @param theRMinor Minor ellipse radius.
395 # @return New GEOM_Object, containing the created ellipse.
397 # Example: see GEOM_TestAll.py
398 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
399 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
400 if CurvesOp.IsDone() == 0:
401 print "MakeEllipse : ", CurvesOp.GetErrorCode()
404 ## Create a polyline on the set of points.
405 # @param thePoints Sequence of points for the polyline.
406 # @return New GEOM_Object, containing the created polyline.
408 # Example: see GEOM_TestAll.py
409 def MakePolyline(thePoints):
410 anObj = CurvesOp.MakePolyline(thePoints)
411 if CurvesOp.IsDone() == 0:
412 print "MakePolyline : ", CurvesOp.GetErrorCode()
415 ## Create bezier curve on the set of points.
416 # @param thePoints Sequence of points for the bezier curve.
417 # @return New GEOM_Object, containing the created bezier curve.
419 # Example: see GEOM_TestAll.py
420 def MakeBezier(thePoints):
421 anObj = CurvesOp.MakeSplineBezier(thePoints)
422 if CurvesOp.IsDone() == 0:
423 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
426 ## Create B-Spline curve on the set of points.
427 # @param thePoints Sequence of points for the B-Spline curve.
428 # @return New GEOM_Object, containing the created B-Spline curve.
430 # Example: see GEOM_TestAll.py
431 def MakeInterpol(thePoints):
432 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
433 if CurvesOp.IsDone() == 0:
434 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
437 ## Create a sketcher (wire or face), following the textual description,
438 # passed through \a theCommand argument. \n
439 # Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
440 # Format of the description string have to be the following:
442 # "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
445 # - x1, y1 are coordinates of the first sketcher point (zero by default),
447 # - "R angle" : Set the direction by angle
448 # - "D dx dy" : Set the direction by DX & DY
451 # - "TT x y" : Create segment by point at X & Y
452 # - "T dx dy" : Create segment by point with DX & DY
453 # - "L length" : Create segment by direction & Length
454 # - "IX x" : Create segment by direction & Intersect. X
455 # - "IY y" : Create segment by direction & Intersect. Y
458 # - "C radius length" : Create arc by direction, radius and length(in degree)
461 # - "WW" : Close Wire (to finish)
462 # - "WF" : Close Wire and build face (to finish)
464 # @param theCommand String, defining the sketcher in local
465 # coordinates of the working plane.
466 # @param theWorkingPlane Nine double values, defining origin,
467 # OZ and OX directions of the working plane.
468 # @return New GEOM_Object, containing the created wire.
470 # Example: see GEOM_TestAll.py
471 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
472 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
473 if CurvesOp.IsDone() == 0:
474 print "MakeSketcher : ", CurvesOp.GetErrorCode()
477 ## Create a sketcher (wire or face), following the textual description,
478 # passed through \a theCommand argument. \n
479 # For format of the description string see the previous method.\n
480 # @param theCommand String, defining the sketcher in local
481 # coordinates of the working plane.
482 # @param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
483 # @return New GEOM_Object, containing the created wire.
484 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
485 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
486 if CurvesOp.IsDone() == 0:
487 print "MakeSketcher : ", CurvesOp.GetErrorCode()
490 # -----------------------------------------------------------------------------
491 # Create 3D Primitives
492 # -----------------------------------------------------------------------------
494 ## Create a box by coordinates of two opposite vertices.
496 # Example: see GEOM_TestAll.py
497 def MakeBox(x1,y1,z1,x2,y2,z2):
498 pnt1 = MakeVertex(x1,y1,z1)
499 pnt2 = MakeVertex(x2,y2,z2)
500 return MakeBoxTwoPnt(pnt1,pnt2)
502 ## Create a box with specified dimensions along the coordinate axes
503 # and with edges, parallel to the coordinate axes.
504 # Center of the box will be at point (DX/2, DY/2, DZ/2).
505 # @param theDX Length of Box edges, parallel to OX axis.
506 # @param theDY Length of Box edges, parallel to OY axis.
507 # @param theDZ Length of Box edges, parallel to OZ axis.
508 # @return New GEOM_Object, containing the created box.
510 # Example: see GEOM_TestAll.py
511 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
512 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
513 if PrimOp.IsDone() == 0:
514 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
517 ## Create a box with two specified opposite vertices,
518 # and with edges, parallel to the coordinate axes
519 # @param thePnt1 First of two opposite vertices.
520 # @param thePnt2 Second of two opposite vertices.
521 # @return New GEOM_Object, containing the created box.
523 # Example: see GEOM_TestAll.py
524 def MakeBoxTwoPnt(thePnt1, thePnt2):
525 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
526 if PrimOp.IsDone() == 0:
527 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
530 ## Create a cylinder with given base point, axis, radius and height.
531 # @param thePnt Central point of cylinder base.
532 # @param theAxis Cylinder axis.
533 # @param theR Cylinder radius.
534 # @param theH Cylinder height.
535 # @return New GEOM_Object, containing the created cylinder.
537 # Example: see GEOM_TestAll.py
538 def MakeCylinder(thePnt, theAxis, theR, theH):
539 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
540 if PrimOp.IsDone() == 0:
541 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
544 ## Create a cylinder with given radius and height at
545 # the origin of coordinate system. Axis of the cylinder
546 # will be collinear to the OZ axis of the coordinate system.
547 # @param theR Cylinder radius.
548 # @param theH Cylinder height.
549 # @return New GEOM_Object, containing the created cylinder.
551 # Example: see GEOM_TestAll.py
552 def MakeCylinderRH(theR, theH):
553 anObj = PrimOp.MakeCylinderRH(theR, theH)
554 if PrimOp.IsDone() == 0:
555 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
558 ## Create a sphere with given center and radius.
559 # @param thePnt Sphere center.
560 # @param theR Sphere radius.
561 # @return New GEOM_Object, containing the created sphere.
563 # Example: see GEOM_TestAll.py
564 def MakeSpherePntR(thePnt, theR):
565 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
566 if PrimOp.IsDone() == 0:
567 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
570 ## Create a sphere with given center and radius.
571 # @param x,y,z Coordinates of sphere center.
572 # @param theR Sphere radius.
573 # @return New GEOM_Object, containing the created sphere.
575 # Example: see GEOM_TestAll.py
576 def MakeSphere(x, y, z, theR):
577 point = MakeVertex(x, y, z)
578 anObj = MakeSpherePntR(point, theR)
581 ## Create a sphere with given radius at the origin of coordinate system.
582 # @param theR Sphere radius.
583 # @return New GEOM_Object, containing the created sphere.
585 # Example: see GEOM_TestAll.py
586 def MakeSphereR(theR):
587 anObj = PrimOp.MakeSphereR(theR)
588 if PrimOp.IsDone() == 0:
589 print "MakeSphereR : ", PrimOp.GetErrorCode()
592 ## Create a cone with given base point, axis, height and radiuses.
593 # @param thePnt Central point of the first cone base.
594 # @param theAxis Cone axis.
595 # @param theR1 Radius of the first cone base.
596 # @param theR2 Radius of the second cone base.
597 # \note If both radiuses are non-zero, the cone will be truncated.
598 # \note If the radiuses are equal, a cylinder will be created instead.
599 # @param theH Cone height.
600 # @return New GEOM_Object, containing the created cone.
602 # Example: see GEOM_TestAll.py
603 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
604 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
605 if PrimOp.IsDone() == 0:
606 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
609 ## Create a cone with given height and radiuses at
610 # the origin of coordinate system. Axis of the cone will
611 # be collinear to the OZ axis of the coordinate system.
612 # @param theR1 Radius of the first cone base.
613 # @param theR2 Radius of the second cone base.
614 # \note If both radiuses are non-zero, the cone will be truncated.
615 # \note If the radiuses are equal, a cylinder will be created instead.
616 # @param theH Cone height.
617 # @return New GEOM_Object, containing the created cone.
619 # Example: see GEOM_TestAll.py
620 def MakeConeR1R2H(theR1, theR2, theH):
621 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
622 if PrimOp.IsDone() == 0:
623 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
626 ## Create a torus with given center, normal vector and radiuses.
627 # @param thePnt Torus central point.
628 # @param theVec Torus axis of symmetry.
629 # @param theRMajor Torus major radius.
630 # @param theRMinor Torus minor radius.
631 # @return New GEOM_Object, containing the created torus.
633 # Example: see GEOM_TestAll.py
634 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
635 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
636 if PrimOp.IsDone() == 0:
637 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
640 ## Create a torus with given radiuses at the origin of coordinate system.
641 # @param theRMajor Torus major radius.
642 # @param theRMinor Torus minor radius.
643 # @return New GEOM_Object, containing the created torus.
645 # Example: see GEOM_TestAll.py
646 def MakeTorusRR(theRMajor, theRMinor):
647 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
648 if PrimOp.IsDone() == 0:
649 print "MakeTorusRR : ", PrimOp.GetErrorCode()
652 ## Create a shape by extrusion of the base shape along a vector, defined by two points.
653 # @param theBase Base shape to be extruded.
654 # @param thePoint1 First end of extrusion vector.
655 # @param thePoint2 Second end of extrusion vector.
656 # @return New GEOM_Object, containing the created prism.
658 # Example: see GEOM_TestAll.py
659 def MakePrism(theBase, thePoint1, thePoint2):
660 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
661 if PrimOp.IsDone() == 0:
662 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
665 ## Create a shape by extrusion of the base shape along the vector,
666 # i.e. all the space, transfixed by the base shape during its translation
667 # along the vector on the given distance.
668 # @param theBase Base shape to be extruded.
669 # @param theVec Direction of extrusion.
670 # @param theH Prism dimension along theVec.
671 # @return New GEOM_Object, containing the created prism.
673 # Example: see GEOM_TestAll.py
674 def MakePrismVecH(theBase, theVec, theH):
675 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
676 if PrimOp.IsDone() == 0:
677 print "MakePrismVecH : ", PrimOp.GetErrorCode()
680 ## Create a shape by extrusion of the base shape along
681 # the path shape. The path shape can be a wire or an edge.
682 # @param theBase Base shape to be extruded.
683 # @param thePath Path shape to extrude the base shape along it.
684 # @return New GEOM_Object, containing the created pipe.
686 # Example: see GEOM_TestAll.py
687 def MakePipe(theBase, thePath):
688 anObj = PrimOp.MakePipe(theBase, thePath)
689 if PrimOp.IsDone() == 0:
690 print "MakePipe : ", PrimOp.GetErrorCode()
693 ## Create a shape by revolution of the base shape around the axis
694 # on the given angle, i.e. all the space, transfixed by the base
695 # shape during its rotation around the axis on the given angle.
696 # @param theBase Base shape to be rotated.
697 # @param theAxis Rotation axis.
698 # @param theAngle Rotation angle in radians.
699 # @return New GEOM_Object, containing the created revolution.
701 # Example: see GEOM_TestAll.py
702 def MakeRevolution(theBase, theAxis, theAngle):
703 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
704 if PrimOp.IsDone() == 0:
705 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
708 ## Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices.
709 # @param theSeqSections - set of specified sections.
710 # @param theModeSolid - mode defining building solid or shell
711 # @param thePreci - precision 3D used for smoothing by default 1.e-6
712 # @param theRuled - mode defining type of the result surfaces (ruled or smoothed).
713 # @return New GEOM_Object, containing the created shell or solid.
715 # Example: see GEOM_TestAll.py
716 def MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled):
717 anObj = PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled)
718 if PrimOp.IsDone() == 0:
719 print "MakeThruSections : ", PrimOp.GetErrorCode()
722 ## Create a shape by extrusion of the profile shape along
723 # the path shape. The path shape can be a wire or an edge.
724 # the several profiles can be specified in the several locations of path.
725 # @param theSeqBases - list of Bases shape to be extruded.
726 # @param theLocations - list of locations on the path corresponding
727 # specified list of the Bases shapes. Number of locations
728 # should be equal to number of bases or list of locations can be empty.
729 # @param thePath - Path shape to extrude the base shape along it.
730 # @param theWithContact - the mode defining that the section is translated to be in
731 # contact with the spine.
732 # @param - WithCorrection - defining that the section is rotated to be
733 # orthogonal to the spine tangent in the correspondent point
734 # @return New GEOM_Object, containing the created pipe.
736 # Example: see GEOM_TestAll.py
737 def MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection):
738 anObj = PrimOp.MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection)
739 if PrimOp.IsDone() == 0:
740 print "MakePipeWithDifferentSections : ", PrimOp.GetErrorCode()
743 ## Create a shape by extrusion of the profile shape along
744 # the path shape. The path shape can be a shell or a face.
745 # the several profiles can be specified in the several locations of path.
746 # @param theSeqBases - list of Bases shape to be extruded.
747 # @param theSeqSubBases - list of corresponding subshapes of section shapes.
748 # @param theLocations - list of locations on the path corresponding
749 # specified list of the Bases shapes. Number of locations
750 # should be equal to number of bases. First and last
751 # locations must be coincided with first and last vertexes
752 # of path correspondingly.
753 # @param thePath - Path shape to extrude the base shape along it.
754 # @param theWithContact - the mode defining that the section is translated to be in
755 # contact with the spine.
756 # @param - WithCorrection - defining that the section is rotated to be
757 # orthogonal to the spine tangent in the correspondent point
758 # @return New GEOM_Object, containing the created solids.
760 # Example: see GEOM_TestAll.py
761 def MakePipeWithShellSections(theSeqBases, theSeqSubBases,
762 theLocations, thePath,
763 theWithContact, theWithCorrection):
764 anObj = PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
765 theLocations, thePath,
766 theWithContact, theWithCorrection)
767 if PrimOp.IsDone() == 0:
768 print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
771 def MakePipeWithShellSectionsBySteps(theSeqBases, theSeqSubBases,
772 theLocations, thePath,
773 theWithContact, theWithCorrection):
775 nbsect = len(theSeqBases)
776 nbsubsect = len(theSeqSubBases)
777 #print "nbsect = ",nbsect
778 for i in range(1,nbsect):
780 tmpSeqBases = [ theSeqBases[i-1], theSeqBases[i] ]
781 tmpLocations = [ theLocations[i-1], theLocations[i] ]
783 if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ]
784 anObj = PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases,
785 tmpLocations, thePath,
786 theWithContact, theWithCorrection)
787 if PrimOp.IsDone() == 0:
788 print "Problems with pipe creation between ",i," and ",i+1," sections"
789 print "MakePipeWithShellSections : ", PrimOp.GetErrorCode()
792 print "Pipe between ",i," and ",i+1," sections is OK"
797 resc = MakeCompound(res)
798 #resc = MakeSewing(res, 0.001)
803 ## Create solids between given sections
804 # @param theSeqBases - list of sections (shell or face).
805 # @param theLocations - list of corresponding vertexes
806 # @return New GEOM_Object, containing the created solids.
808 # Example: see GEOM_TestAll.py
809 def MakePipeShellsWithoutPath(theSeqBases, theLocations):
810 anObj = PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations)
811 if PrimOp.IsDone() == 0:
812 print "MakePipeShellsWithoutPath : ", PrimOp.GetErrorCode()
816 # -----------------------------------------------------------------------------
818 # -----------------------------------------------------------------------------
820 ## Create a linear edge with specified ends.
821 # @param thePnt1 Point for the first end of edge.
822 # @param thePnt2 Point for the second end of edge.
823 # @return New GEOM_Object, containing the created edge.
825 # Example: see GEOM_TestAll.py
826 def MakeEdge(thePnt1, thePnt2):
827 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
828 if ShapesOp.IsDone() == 0:
829 print "MakeEdge : ", ShapesOp.GetErrorCode()
832 ## Create a wire from the set of edges and wires.
833 # @param theEdgesAndWires List of edges and/or wires.
834 # @return New GEOM_Object, containing the created wire.
836 # Example: see GEOM_TestAll.py
837 def MakeWire(theEdgesAndWires):
838 anObj = ShapesOp.MakeWire(theEdgesAndWires)
839 if ShapesOp.IsDone() == 0:
840 print "MakeWire : ", ShapesOp.GetErrorCode()
843 ## Create a face on the given wire.
844 # @param theWire closed Wire or Edge to build the face on.
845 # @param isPlanarWanted If TRUE, only planar face will be built.
846 # If impossible, NULL object will be returned.
847 # @return New GEOM_Object, containing the created face.
849 # Example: see GEOM_TestAll.py
850 def MakeFace(theWire, isPlanarWanted):
851 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
852 if ShapesOp.IsDone() == 0:
853 print "MakeFace : ", ShapesOp.GetErrorCode()
856 ## Create a face on the given wires set.
857 # @param theWires List of closed wires or edges to build the face on.
858 # @param isPlanarWanted If TRUE, only planar face will be built.
859 # If impossible, NULL object will be returned.
860 # @return New GEOM_Object, containing the created face.
862 # Example: see GEOM_TestAll.py
863 def MakeFaceWires(theWires, isPlanarWanted):
864 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
865 if ShapesOp.IsDone() == 0:
866 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
869 ## Shortcut to MakeFaceWires()
871 # Example: see GEOM_TestOthers.py
872 def MakeFaces(theWires, isPlanarWanted):
873 anObj = MakeFaceWires(theWires, isPlanarWanted)
876 ## Create a shell from the set of faces and shells.
877 # @param theFacesAndShells List of faces and/or shells.
878 # @return New GEOM_Object, containing the created shell.
880 # Example: see GEOM_TestAll.py
881 def MakeShell(theFacesAndShells):
882 anObj = ShapesOp.MakeShell(theFacesAndShells)
883 if ShapesOp.IsDone() == 0:
884 print "MakeShell : ", ShapesOp.GetErrorCode()
887 ## Create a solid, bounded by the given shells.
888 # @param theShells Sequence of bounding shells.
889 # @return New GEOM_Object, containing the created solid.
891 # Example: see GEOM_TestAll.py
892 def MakeSolid(theShells):
893 anObj = ShapesOp.MakeSolidShells(theShells)
894 if ShapesOp.IsDone() == 0:
895 print "MakeSolid : ", ShapesOp.GetErrorCode()
898 ## Create a compound of the given shapes.
899 # @param theShapes List of shapes to put in compound.
900 # @return New GEOM_Object, containing the created compound.
902 # Example: see GEOM_TestAll.py
903 def MakeCompound(theShapes):
904 anObj = ShapesOp.MakeCompound(theShapes)
905 if ShapesOp.IsDone() == 0:
906 print "MakeCompound : ", ShapesOp.GetErrorCode()
909 ## Gives quantity of faces in the given shape.
910 # @param theShape Shape to count faces of.
911 # @return Quantity of faces.
913 # Example: see GEOM_TestOthers.py
914 def NumberOfFaces(theShape):
915 nb_faces = ShapesOp.NumberOfFaces(theShape)
916 if ShapesOp.IsDone() == 0:
917 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
920 ## Gives quantity of edges in the given shape.
921 # @param theShape Shape to count edges of.
922 # @return Quantity of edges.
924 # Example: see GEOM_TestOthers.py
925 def NumberOfEdges(theShape):
926 nb_edges = ShapesOp.NumberOfEdges(theShape)
927 if ShapesOp.IsDone() == 0:
928 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
931 ## Reverses an orientation the given shape.
932 # @param theShape Shape to be reversed.
933 # @return The reversed copy of theShape.
935 # Example: see GEOM_TestAll.py
936 def ChangeOrientation(theShape):
937 anObj = ShapesOp.ChangeOrientation(theShape)
938 if ShapesOp.IsDone() == 0:
939 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
942 ## Shortcut to ChangeOrientation()
944 # Example: see GEOM_TestOthers.py
945 def OrientationChange(theShape):
946 anObj = ChangeOrientation(theShape)
949 ## Retrieve all free faces from the given shape.
950 # Free face is a face, which is not shared between two shells of the shape.
951 # @param theShape Shape to find free faces in.
952 # @return List of IDs of all free faces, contained in theShape.
954 # Example: see GEOM_TestOthers.py
955 def GetFreeFacesIDs(theShape):
956 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
957 if ShapesOp.IsDone() == 0:
958 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
961 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
962 # @param theShape1 Shape to find sub-shapes in.
963 # @param theShape2 Shape to find shared sub-shapes with.
964 # @param theShapeType Type of sub-shapes to be retrieved.
965 # @return List of sub-shapes of theShape1, shared with theShape2.
967 # Example: see GEOM_TestOthers.py
968 def GetSharedShapes(theShape1, theShape2, theShapeType):
969 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
970 if ShapesOp.IsDone() == 0:
971 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
974 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
975 # the specified plane by the certain way, defined through \a theState parameter.
976 # @param theShape Shape to find sub-shapes of.
977 # @param theShapeType Type of sub-shapes to be retrieved.
978 # @param theAx1 Vector (or line, or linear edge), specifying normal
979 # direction and location of the plane to find shapes on.
980 # @param theState The state of the subshapes to find. It can be one of
981 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
982 # @return List of all found sub-shapes.
984 # Example: see GEOM_TestOthers.py
985 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
986 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
987 if ShapesOp.IsDone() == 0:
988 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
991 ## Works like the above method, but returns list of sub-shapes indices
993 # Example: see GEOM_TestOthers.py
994 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
995 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
996 if ShapesOp.IsDone() == 0:
997 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
1000 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1001 # the specified plane by the certain way, defined through \a theState parameter.
1002 # @param theShape Shape to find sub-shapes of.
1003 # @param theShapeType Type of sub-shapes to be retrieved.
1004 # @param theAx1 Vector (or line, or linear edge), specifying normal
1005 # direction of the plane to find shapes on.
1006 # @param thePnt Point specifying location of the plane to find shapes on.
1007 # @param theState The state of the subshapes to find. It can be one of
1008 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1009 # @return List of all found sub-shapes.
1011 # Example: see GEOM_TestOthers.py
1012 def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
1013 aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
1014 if ShapesOp.IsDone() == 0:
1015 print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
1018 ## Works like the above method, but returns list of sub-shapes indices
1020 # Example: see GEOM_TestOthers.py
1021 def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
1022 aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
1023 if ShapesOp.IsDone() == 0:
1024 print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
1027 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1028 # the specified cylinder by the certain way, defined through \a theState parameter.
1029 # @param theShape Shape to find sub-shapes of.
1030 # @param theShapeType Type of sub-shapes to be retrieved.
1031 # @param theAxis Vector (or line, or linear edge), specifying
1032 # axis of the cylinder to find shapes on.
1033 # @param theRadius Radius of the cylinder to find shapes on.
1034 # @param theState The state of the subshapes to find. It can be one of
1035 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1036 # @return List of all found sub-shapes.
1038 # Example: see GEOM_TestOthers.py
1039 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
1040 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
1041 if ShapesOp.IsDone() == 0:
1042 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
1045 ## Works like the above method, but returns list of sub-shapes indices
1047 # Example: see GEOM_TestOthers.py
1048 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
1049 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
1050 if ShapesOp.IsDone() == 0:
1051 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
1054 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1055 # the specified sphere by the certain way, defined through \a theState parameter.
1056 # @param theShape Shape to find sub-shapes of.
1057 # @param theShapeType Type of sub-shapes to be retrieved.
1058 # @param theCenter Point, specifying center of the sphere to find shapes on.
1059 # @param theRadius Radius of the sphere to find shapes on.
1060 # @param theState The state of the subshapes to find. It can be one of
1061 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1062 # @return List of all found sub-shapes.
1064 # Example: see GEOM_TestOthers.py
1065 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
1066 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1067 if ShapesOp.IsDone() == 0:
1068 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
1071 ## Works like the above method, but returns list of sub-shapes indices
1073 # Example: see GEOM_TestOthers.py
1074 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
1075 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1076 if ShapesOp.IsDone() == 0:
1077 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
1080 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1081 # the specified quadrangle by the certain way, defined through \a theState parameter.
1082 # @param theShape Shape to find sub-shapes of.
1083 # @param theShapeType Type of sub-shapes to be retrieved.
1084 # @param theTopLeftPoint Point, specifying top left corner of a quadrangle
1085 # @param theTopRigthPoint Point, specifying top right corner of a quadrangle
1086 # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
1087 # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
1088 # @param theState The state of the subshapes to find. It can be one of
1089 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1090 # @return List of all found sub-shapes.
1092 # Example: see GEOM_TestOthers.py
1093 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1094 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1095 if ShapesOp.IsDone() == 0:
1096 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1099 ## Works like the above method, but returns list of sub-shapes indices
1101 # Example: see GEOM_TestOthers.py
1102 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1103 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1104 if ShapesOp.IsDone() == 0:
1105 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1108 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1109 # the specified \a theBox by the certain way, defined through \a theState parameter.
1110 # @param theBox Shape for relative comparing.
1111 # @param theShape Shape to find sub-shapes of.
1112 # @param theShapeType Type of sub-shapes to be retrieved.
1113 # @param theState The state of the subshapes to find. It can be one of
1114 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1115 # @return List of all found sub-shapes.
1117 def GetShapesOnBox(theBox, theShape, theShapeType, theState):
1118 aList = ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
1119 if ShapesOp.IsDone() == 0:
1120 print "GetShapesOnBox : ", ShapesOp.GetErrorCode()
1123 ## Works like the above method, but returns list of sub-shapes indices
1125 def GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState):
1126 aList = ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
1127 if ShapesOp.IsDone() == 0:
1128 print "GetShapesOnBoxIDs : ", ShapesOp.GetErrorCode()
1131 ## Get sub-shape(s) of theShapeWhere, which are
1132 # coincident with \a theShapeWhat or could be a part of it.
1133 # @param theShapeWhere Shape to find sub-shapes of.
1134 # @param theShapeWhat Shape, specifying what to find (must be in the
1135 # building history of the ShapeWhere).
1136 # @return Group of all found sub-shapes or a single found sub-shape.
1138 # Example: see GEOM_TestOthers.py
1139 def GetInPlace(theShapeWhere, theShapeWhat):
1140 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1141 if ShapesOp.IsDone() == 0:
1142 print "GetInPlace : ", ShapesOp.GetErrorCode()
1145 ## Get sub-shape(s) of \a theShapeWhere, which are
1146 # coincident with \a theShapeWhat or could be a part of it.
1148 # Implementation of this method is based on a saved history of an operation,
1149 # produced \a theShapeWhere. The \a theShapeWhat must be among this operation's
1150 # arguments (an argument shape or a sub-shape of an argument shape).
1151 # The operation could be the Partition or one of boolean operations,
1152 # performed on simple shapes (not on compounds).
1154 # @param theShapeWhere Shape to find sub-shapes of.
1155 # @param theShapeWhat Shape, specifying what to find (must be in the
1156 # building history of the ShapeWhere).
1157 # @return Group of all found sub-shapes or a single found sub-shape.
1159 # Example: see GEOM_TestOthers.py
1160 def GetInPlaceByHistory(theShapeWhere, theShapeWhat):
1161 anObj = ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat)
1162 if ShapesOp.IsDone() == 0:
1163 print "GetInPlace : ", ShapesOp.GetErrorCode()
1166 ## Get sub-shape of theShapeWhere, which is
1167 # equal to \a theShapeWhat.
1168 # @param theShapeWhere Shape to find sub-shape of.
1169 # @param theShapeWhat Shape, specifying what to find
1170 # (must be usual shape).
1171 # @return New GEOM_Object for found sub-shape.
1173 def GetSame(theShapeWhere, theShapeWhat):
1174 anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1175 if ShapesOp.IsDone() == 0:
1176 print "GetSame : ", ShapesOp.GetErrorCode()
1179 # -----------------------------------------------------------------------------
1180 # Access to sub-shapes by their unique IDs inside the main shape.
1181 # -----------------------------------------------------------------------------
1183 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1184 # of <aShape>, selected by their unique IDs inside <aShape>
1186 # Example: see GEOM_TestAll.py
1187 def GetSubShape(aShape, ListOfID):
1188 anObj = geom.AddSubShape(aShape,ListOfID)
1191 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1193 # Example: see GEOM_TestAll.py
1194 def GetSubShapeID(aShape, aSubShape):
1195 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1196 if LocalOp.IsDone() == 0:
1197 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1200 # -----------------------------------------------------------------------------
1202 # -----------------------------------------------------------------------------
1204 ## Explode a shape on subshapes of a given type.
1205 # @param theShape Shape to be exploded.
1206 # @param theShapeType Type of sub-shapes to be retrieved.
1207 # @return List of sub-shapes of type theShapeType, contained in theShape.
1209 # Example: see GEOM_TestAll.py
1210 def SubShapeAll(aShape, aType):
1211 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1212 if ShapesOp.IsDone() == 0:
1213 print "MakeExplode : ", ShapesOp.GetErrorCode()
1216 ## Explode a shape on subshapes of a given type.
1217 # @param theShape Shape to be exploded.
1218 # @param theShapeType Type of sub-shapes to be retrieved.
1219 # @return List of IDs of sub-shapes.
1220 def SubShapeAllIDs(aShape, aType):
1221 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1222 if ShapesOp.IsDone() == 0:
1223 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1226 ## Explode a shape on subshapes of a given type.
1227 # Sub-shapes will be sorted by coordinates of their gravity centers.
1228 # @param theShape Shape to be exploded.
1229 # @param theShapeType Type of sub-shapes to be retrieved.
1230 # @return List of sub-shapes of type theShapeType, contained in theShape.
1232 # Example: see GEOM_TestAll.py
1233 def SubShapeAllSorted(aShape, aType):
1234 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1235 if ShapesOp.IsDone() == 0:
1236 print "MakeExplode : ", ShapesOp.GetErrorCode()
1239 ## Explode a shape on subshapes of a given type.
1240 # Sub-shapes will be sorted by coordinates of their gravity centers.
1241 # @param theShape Shape to be exploded.
1242 # @param theShapeType Type of sub-shapes to be retrieved.
1243 # @return List of IDs of sub-shapes.
1244 def SubShapeAllSortedIDs(aShape, aType):
1245 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1246 if ShapesOp.IsDone() == 0:
1247 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1250 ## Obtain a compound of sub-shapes of <aShape>,
1251 # selected by they indices in list of all sub-shapes of type <aType>.
1252 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1254 # Example: see GEOM_TestAll.py
1255 def SubShape(aShape, aType, ListOfInd):
1257 AllShapeList = SubShapeAll(aShape, aType)
1258 for ind in ListOfInd:
1259 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1260 anObj = GetSubShape(aShape, ListOfIDs)
1263 ## Obtain a compound of sub-shapes of <aShape>,
1264 # selected by they indices in sorted list of all sub-shapes of type <aType>.
1265 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1267 # Example: see GEOM_TestAll.py
1268 def SubShapeSorted(aShape, aType, ListOfInd):
1270 AllShapeList = SubShapeAllSorted(aShape, aType)
1271 for ind in ListOfInd:
1272 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1273 anObj = GetSubShape(aShape, ListOfIDs)
1276 # -----------------------------------------------------------------------------
1277 # Healing operations
1278 # -----------------------------------------------------------------------------
1280 ## Apply a sequence of Shape Healing operators to the given object.
1281 # @param theShape Shape to be processed.
1282 # @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1283 # @param theParameters List of names of parameters
1284 # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1285 # @param theValues List of values of parameters, in the same order
1286 # as parameters are listed in \a theParameters list.
1287 # @return New GEOM_Object, containing processed shape.
1289 # Example: see GEOM_TestHealing.py
1290 def ProcessShape(theShape, theOperators, theParameters, theValues):
1291 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1292 if HealOp.IsDone() == 0:
1293 print "ProcessShape : ", HealOp.GetErrorCode()
1296 ## Remove faces from the given object (shape).
1297 # @param theObject Shape to be processed.
1298 # @param theFaces Indices of faces to be removed, if EMPTY then the method
1299 # removes ALL faces of the given object.
1300 # @return New GEOM_Object, containing processed shape.
1302 # Example: see GEOM_TestHealing.py
1303 def SuppressFaces(theObject, theFaces):
1304 anObj = HealOp.SuppressFaces(theObject, theFaces)
1305 if HealOp.IsDone() == 0:
1306 print "SuppressFaces : ", HealOp.GetErrorCode()
1309 ## Sewing of some shapes into single shape.
1311 # Example: see GEOM_TestHealing.py
1312 def MakeSewing(ListShape, theTolerance):
1313 comp = MakeCompound(ListShape)
1314 anObj = Sew(comp, theTolerance)
1317 ## Sewing of the given object.
1318 # @param theObject Shape to be processed.
1319 # @param theTolerance Required tolerance value.
1320 # @return New GEOM_Object, containing processed shape.
1322 # Example: see MakeSewing() above
1323 def Sew(theObject, theTolerance):
1324 anObj = HealOp.Sew(theObject, theTolerance)
1325 if HealOp.IsDone() == 0:
1326 print "Sew : ", HealOp.GetErrorCode()
1329 ## Remove internal wires and edges from the given object (face).
1330 # @param theObject Shape to be processed.
1331 # @param theWires Indices of wires to be removed, if EMPTY then the method
1332 # removes ALL internal wires of the given object.
1333 # @return New GEOM_Object, containing processed shape.
1335 # Example: see GEOM_TestHealing.py
1336 def SuppressInternalWires(theObject, theWires):
1337 anObj = HealOp.RemoveIntWires(theObject, theWires)
1338 if HealOp.IsDone() == 0:
1339 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1342 ## Remove internal closed contours (holes) from the given object.
1343 # @param theObject Shape to be processed.
1344 # @param theWires Indices of wires to be removed, if EMPTY then the method
1345 # removes ALL internal holes of the given object
1346 # @return New GEOM_Object, containing processed shape.
1348 # Example: see GEOM_TestHealing.py
1349 def SuppressHoles(theObject, theWires):
1350 anObj = HealOp.FillHoles(theObject, theWires)
1351 if HealOp.IsDone() == 0:
1352 print "SuppressHoles : ", HealOp.GetErrorCode()
1355 ## Close an open wire.
1356 # @param theObject Shape to be processed.
1357 # @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1358 # if -1, then theObject itself is a wire.
1359 # @param isCommonVertex If TRUE : closure by creation of a common vertex,
1360 # If FALS : closure by creation of an edge between ends.
1361 # @return New GEOM_Object, containing processed shape.
1363 # Example: see GEOM_TestHealing.py
1364 def CloseContour(theObject, theWires, isCommonVertex):
1365 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1366 if HealOp.IsDone() == 0:
1367 print "CloseContour : ", HealOp.GetErrorCode()
1370 ## Addition of a point to a given edge object.
1371 # @param theObject Shape to be processed.
1372 # @param theEdgeIndex Index of edge to be divided within theObject's shape,
1373 # if -1, then theObject itself is the edge.
1374 # @param theValue Value of parameter on edge or length parameter,
1375 # depending on \a isByParameter.
1376 # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1377 # if FALSE : \a theValue is treated as a length parameter [0..1]
1378 # @return New GEOM_Object, containing processed shape.
1380 # Example: see GEOM_TestHealing.py
1381 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1382 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1383 if HealOp.IsDone() == 0:
1384 print "DivideEdge : ", HealOp.GetErrorCode()
1387 ## Change orientation of the given object.
1388 # @param theObject Shape to be processed.
1389 # @update given shape
1390 def ChangeOrientationShell(theObject):
1391 theObject = HealOp.ChangeOrientation(theObject)
1392 if HealOp.IsDone() == 0:
1393 print "ChangeOrientation : ", HealOp.GetErrorCode()
1395 ## Change orientation of the given object.
1396 # @param theObject Shape to be processed.
1397 # @return New GEOM_Object, containing processed shape.
1398 def ChangeOrientationShellCopy(theObject):
1399 anObj = HealOp.ChangeOrientationCopy(theObject)
1400 if HealOp.IsDone() == 0:
1401 print "ChangeOrientation : ", HealOp.GetErrorCode()
1404 ## Get a list of wires (wrapped in GEOM_Object-s),
1405 # that constitute a free boundary of the given shape.
1406 # @param theObject Shape to get free boundary of.
1407 # @return [status, theClosedWires, theOpenWires]
1408 # status: FALSE, if an error(s) occured during the method execution.
1409 # theClosedWires: Closed wires on the free boundary of the given shape.
1410 # theOpenWires: Open wires on the free boundary of the given shape.
1412 # Example: see GEOM_TestHealing.py
1413 def GetFreeBoundary(theObject):
1414 anObj = HealOp.GetFreeBoundary(theObject)
1415 if HealOp.IsDone() == 0:
1416 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1419 # -----------------------------------------------------------------------------
1420 # Create advanced objects
1421 # -----------------------------------------------------------------------------
1423 ## Create a copy of the given object
1425 # Example: see GEOM_TestAll.py
1426 def MakeCopy(theOriginal):
1427 anObj = InsertOp.MakeCopy(theOriginal)
1428 if InsertOp.IsDone() == 0:
1429 print "MakeCopy : ", InsertOp.GetErrorCode()
1432 ## Create a filling from the given compound of contours.
1433 # @param theShape the compound of contours
1434 # @param theMinDeg a minimal degree
1435 # @param theMaxDeg a maximal degree
1436 # @param theTol2D a 2d tolerance
1437 # @param theTol3D a 3d tolerance
1438 # @param theNbIter a number of iteration
1439 # @return New GEOM_Object, containing the created filling surface.
1441 # Example: see GEOM_TestAll.py
1442 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1443 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1444 if PrimOp.IsDone() == 0:
1445 print "MakeFilling : ", PrimOp.GetErrorCode()
1448 ## Replace coincident faces in theShape by one face.
1449 # @param theShape Initial shape.
1450 # @param theTolerance Maximum distance between faces, which can be considered as coincident.
1451 # @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
1452 # @return New GEOM_Object, containing a copy of theShape without coincident faces.
1454 # Example: see GEOM_Spanner.py
1455 def MakeGlueFaces(theShape, theTolerance, doKeepNonSolids=True):
1456 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
1457 if ShapesOp.IsDone() == 0:
1458 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1462 ## Find coincident faces in theShape for possible gluing.
1463 # @param theShape Initial shape.
1464 # @param theTolerance Maximum distance between faces,
1465 # which can be considered as coincident.
1468 # Example: see GEOM_Spanner.py
1469 def GetGlueFaces(theShape, theTolerance):
1470 anObj = ShapesOp.GetGlueFaces(theShape, theTolerance)
1471 if ShapesOp.IsDone() == 0:
1472 print "GetGlueFaces : ", ShapesOp.GetErrorCode()
1476 ## Replace coincident faces in theShape by one face
1477 # in compliance with given list of faces
1478 # @param theShape Initial shape.
1479 # @param theTolerance Maximum distance between faces,
1480 # which can be considered as coincident.
1481 # @param theFaces List of faces for gluing.
1482 # @param doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes.
1483 # @return New GEOM_Object, containing a copy of theShape
1484 # without some faces.
1486 # Example: see GEOM_Spanner.py
1487 def MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids=True):
1488 anObj = ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
1489 if ShapesOp.IsDone() == 0:
1490 print "MakeGlueFacesByList : ", ShapesOp.GetErrorCode()
1494 # -----------------------------------------------------------------------------
1495 # Boolean (Common, Cut, Fuse, Section)
1496 # -----------------------------------------------------------------------------
1498 ## Perform one of boolean operations on two given shapes.
1499 # @param theShape1 First argument for boolean operation.
1500 # @param theShape2 Second argument for boolean operation.
1501 # @param theOperation Indicates the operation to be done:
1502 # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1503 # @return New GEOM_Object, containing the result shape.
1505 # Example: see GEOM_TestAll.py
1506 def MakeBoolean(theShape1, theShape2, theOperation):
1507 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1508 if BoolOp.IsDone() == 0:
1509 print "MakeBoolean : ", BoolOp.GetErrorCode()
1512 ## Shortcut to MakeBoolean(s1, s2, 1)
1514 # Example: see GEOM_TestOthers.py
1515 def MakeCommon(s1, s2):
1516 return MakeBoolean(s1, s2, 1)
1518 ## Shortcut to MakeBoolean(s1, s2, 2)
1520 # Example: see GEOM_TestOthers.py
1521 def MakeCut(s1, s2):
1522 return MakeBoolean(s1, s2, 2)
1524 ## Shortcut to MakeBoolean(s1, s2, 3)
1526 # Example: see GEOM_TestOthers.py
1527 def MakeFuse(s1, s2):
1528 return MakeBoolean(s1, s2, 3)
1530 ## Shortcut to MakeBoolean(s1, s2, 4)
1532 # Example: see GEOM_TestOthers.py
1533 def MakeSection(s1, s2):
1534 return MakeBoolean(s1, s2, 4)
1536 ## Perform partition operation.
1537 # @param ListShapes Shapes to be intersected.
1538 # @param ListTools Shapes to intersect theShapes.
1539 # !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1540 # in order to avoid possible intersection between shapes from
1542 # @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1543 # @param KeepNonlimitShapes: if this parameter == 0 - only shapes with
1544 # type <= Limit are kept in the result,
1545 # else - shapes with type > Limit are kept
1546 # also (if they exist)
1548 # After implementation new version of PartitionAlgo (October 2006)
1549 # other parameters are ignored by current functionality. They are kept
1550 # in this function only for support old versions.
1551 # Ignored parameters:
1552 # @param ListKeepInside Shapes, outside which the results will be deleted.
1553 # Each shape from theKeepInside must belong to theShapes also.
1554 # @param ListRemoveInside Shapes, inside which the results will be deleted.
1555 # Each shape from theRemoveInside must belong to theShapes also.
1556 # @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1557 # @param ListMaterials Material indices for each shape. Make sence,
1558 # only if theRemoveWebs is TRUE.
1560 # @return New GEOM_Object, containing the result shapes.
1562 # Example: see GEOM_TestAll.py
1563 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1564 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1565 KeepNonlimitShapes=0):
1566 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1567 ListKeepInside, ListRemoveInside,
1568 Limit, RemoveWebs, ListMaterials,
1569 KeepNonlimitShapes);
1570 if BoolOp.IsDone() == 0:
1571 print "MakePartition : ", BoolOp.GetErrorCode()
1574 ## Perform partition operation.
1575 # This method may be useful if it is needed to make a partition for
1576 # compound contains nonintersected shapes. Performance will be better
1577 # since intersection between shapes from compound is not performed.
1579 # Description of all parameters as in previous method MakePartition()
1581 # !!!NOTE: Passed compounds (via ListShapes or via ListTools)
1582 # have to consist of nonintersecting shapes.
1584 # @return New GEOM_Object, containing the result shapes.
1586 def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[],
1587 ListKeepInside=[], ListRemoveInside=[],
1588 Limit=ShapeType["SHAPE"], RemoveWebs=0,
1589 ListMaterials=[], KeepNonlimitShapes=0):
1590 anObj = BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
1591 ListKeepInside, ListRemoveInside,
1592 Limit, RemoveWebs, ListMaterials,
1593 KeepNonlimitShapes);
1594 if BoolOp.IsDone() == 0:
1595 print "MakePartitionNonSelfIntersectedShape : ", BoolOp.GetErrorCode()
1598 ## Shortcut to MakePartition()
1600 # Example: see GEOM_TestOthers.py
1601 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1602 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1603 KeepNonlimitShapes=0):
1604 anObj = MakePartition(ListShapes, ListTools,
1605 ListKeepInside, ListRemoveInside,
1606 Limit, RemoveWebs, ListMaterials,
1607 KeepNonlimitShapes);
1610 ## Perform partition of the Shape with the Plane
1611 # @param theShape Shape to be intersected.
1612 # @param thePlane Tool shape, to intersect theShape.
1613 # @return New GEOM_Object, containing the result shape.
1615 # Example: see GEOM_TestAll.py
1616 def MakeHalfPartition(theShape, thePlane):
1617 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1618 if BoolOp.IsDone() == 0:
1619 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1622 # -----------------------------------------------------------------------------
1624 # -----------------------------------------------------------------------------
1626 ## Translate the given object along the vector, specified
1627 # by its end points, creating its copy before the translation.
1628 # @param theObject The object to be translated.
1629 # @param thePoint1 Start point of translation vector.
1630 # @param thePoint2 End point of translation vector.
1631 # @return New GEOM_Object, containing the translated object.
1633 # Example: see GEOM_TestAll.py
1634 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1635 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1636 if TrsfOp.IsDone() == 0:
1637 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1640 ## Translate the given object along the vector, specified
1641 # by its components, creating its copy before the translation.
1642 # @param theObject The object to be translated.
1643 # @param theDX,theDY,theDZ Components of translation vector.
1644 # @return New GEOM_Object, containing the translated object.
1646 # Example: see GEOM_TestAll.py
1647 def MakeTranslation(theObject, theDX, theDY, theDZ):
1648 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1649 if TrsfOp.IsDone() == 0:
1650 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1653 ## Translate the given object along the given vector,
1654 # creating its copy before the translation.
1655 # @param theObject The object to be translated.
1656 # @param theVector The translation vector.
1657 # @return New GEOM_Object, containing the translated object.
1659 # Example: see GEOM_TestAll.py
1660 def MakeTranslationVector(theObject, theVector):
1661 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1662 if TrsfOp.IsDone() == 0:
1663 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1666 ## Rotate the given object around the given axis
1667 # on the given angle, creating its copy before the rotatation.
1668 # @param theObject The object to be rotated.
1669 # @param theAxis Rotation axis.
1670 # @param theAngle Rotation angle in radians.
1671 # @return New GEOM_Object, containing the rotated object.
1673 # Example: see GEOM_TestAll.py
1674 def MakeRotation(theObject, theAxis, theAngle):
1675 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1676 if TrsfOp.IsDone() == 0:
1677 print "RotateCopy : ", TrsfOp.GetErrorCode()
1680 ## Rotate given object around vector perpendicular to plane
1681 # containing three points, creating its copy before the rotatation.
1682 # @param theObject The object to be rotated.
1683 # @param theCentPoint central point - the axis is the vector perpendicular to the plane
1684 # containing the three points.
1685 # @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1686 # @return New GEOM_Object, containing the rotated object.
1688 # Example: see GEOM_TestAll.py
1689 def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
1690 anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1691 if TrsfOp.IsDone() == 0:
1692 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
1695 ## Scale the given object by the factor, creating its copy before the scaling.
1696 # @param theObject The object to be scaled.
1697 # @param thePoint Center point for scaling.
1698 # @param theFactor Scaling factor value.
1699 # @return New GEOM_Object, containing the scaled shape.
1701 # Example: see GEOM_TestAll.py
1702 def MakeScaleTransform(theObject, thePoint, theFactor):
1703 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1704 if TrsfOp.IsDone() == 0:
1705 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1708 ## Create an object, symmetrical
1709 # to the given one relatively the given plane.
1710 # @param theObject The object to be mirrored.
1711 # @param thePlane Plane of symmetry.
1712 # @return New GEOM_Object, containing the mirrored shape.
1714 # Example: see GEOM_TestAll.py
1715 def MakeMirrorByPlane(theObject, thePlane):
1716 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1717 if TrsfOp.IsDone() == 0:
1718 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1721 ## Create an object, symmetrical
1722 # to the given one relatively the given axis.
1723 # @param theObject The object to be mirrored.
1724 # @param theAxis Axis of symmetry.
1725 # @return New GEOM_Object, containing the mirrored shape.
1727 # Example: see GEOM_TestAll.py
1728 def MakeMirrorByAxis(theObject, theAxis):
1729 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1730 if TrsfOp.IsDone() == 0:
1731 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1734 ## Create an object, symmetrical
1735 # to the given one relatively the given point.
1736 # @param theObject The object to be mirrored.
1737 # @param thePoint Point of symmetry.
1738 # @return New GEOM_Object, containing the mirrored shape.
1740 # Example: see GEOM_TestAll.py
1741 def MakeMirrorByPoint(theObject, thePoint):
1742 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1743 if TrsfOp.IsDone() == 0:
1744 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1747 ## Modify the Location of the given object by LCS,
1748 # creating its copy before the setting.
1749 # @param theObject The object to be displaced.
1750 # @param theStartLCS Coordinate system to perform displacement from it.
1751 # If \a theStartLCS is NULL, displacement
1752 # will be performed from global CS.
1753 # If \a theObject itself is used as \a theStartLCS,
1754 # its location will be changed to \a theEndLCS.
1755 # @param theEndLCS Coordinate system to perform displacement to it.
1756 # @return New GEOM_Object, containing the displaced shape.
1758 # Example: see GEOM_TestAll.py
1759 def MakePosition(theObject, theStartLCS, theEndLCS):
1760 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1761 if TrsfOp.IsDone() == 0:
1762 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1765 ## Create new object as offset of the given one.
1766 # @param theObject The base object for the offset.
1767 # @param theOffset Offset value.
1768 # @return New GEOM_Object, containing the offset object.
1770 # Example: see GEOM_TestAll.py
1771 def MakeOffset(theObject, theOffset):
1772 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1773 if TrsfOp.IsDone() == 0:
1774 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1777 # -----------------------------------------------------------------------------
1779 # -----------------------------------------------------------------------------
1781 ## Translate the given object along the given vector a given number times
1782 # @param theObject The object to be translated.
1783 # @param theVector Direction of the translation.
1784 # @param theStep Distance to translate on.
1785 # @param theNbTimes Quantity of translations to be done.
1786 # @return New GEOM_Object, containing compound of all
1787 # the shapes, obtained after each translation.
1789 # Example: see GEOM_TestAll.py
1790 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1791 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1792 if TrsfOp.IsDone() == 0:
1793 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1796 ## Conseqently apply two specified translations to theObject specified number of times.
1797 # @param theObject The object to be translated.
1798 # @param theVector1 Direction of the first translation.
1799 # @param theStep1 Step of the first translation.
1800 # @param theNbTimes1 Quantity of translations to be done along theVector1.
1801 # @param theVector2 Direction of the second translation.
1802 # @param theStep2 Step of the second translation.
1803 # @param theNbTimes2 Quantity of translations to be done along theVector2.
1804 # @return New GEOM_Object, containing compound of all
1805 # the shapes, obtained after each translation.
1807 # Example: see GEOM_TestAll.py
1808 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1809 theVector2, theStep2, theNbTimes2):
1810 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1811 theVector2, theStep2, theNbTimes2)
1812 if TrsfOp.IsDone() == 0:
1813 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1816 ## Rotate the given object around the given axis a given number times.
1817 # Rotation angle will be 2*PI/theNbTimes.
1818 # @param theObject The object to be rotated.
1819 # @param theAxis The rotation axis.
1820 # @param theNbTimes Quantity of rotations to be done.
1821 # @return New GEOM_Object, containing compound of all the
1822 # shapes, obtained after each rotation.
1824 # Example: see GEOM_TestAll.py
1825 def MultiRotate1D(theObject, theAxis, theNbTimes):
1826 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1827 if TrsfOp.IsDone() == 0:
1828 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1831 ## Rotate the given object around the
1832 # given axis on the given angle a given number
1833 # times and multi-translate each rotation result.
1834 # Translation direction passes through center of gravity
1835 # of rotated shape and its projection on the rotation axis.
1836 # @param theObject The object to be rotated.
1837 # @param theAxis Rotation axis.
1838 # @param theAngle Rotation angle in graduces.
1839 # @param theNbTimes1 Quantity of rotations to be done.
1840 # @param theStep Translation distance.
1841 # @param theNbTimes2 Quantity of translations to be done.
1842 # @return New GEOM_Object, containing compound of all the
1843 # shapes, obtained after each transformation.
1845 # Example: see GEOM_TestAll.py
1846 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1847 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1848 if TrsfOp.IsDone() == 0:
1849 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1852 ## The same, as MultiRotate1D(), but axis is given by direction and point
1854 # Example: see GEOM_TestOthers.py
1855 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1856 aVec = MakeLine(aPoint,aDir)
1857 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1860 ## The same, as MultiRotate2D(), but axis is given by direction and point
1862 # Example: see GEOM_TestOthers.py
1863 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1864 aVec = MakeLine(aPoint,aDir)
1865 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1868 # -----------------------------------------------------------------------------
1870 # -----------------------------------------------------------------------------
1872 ## Perform a fillet on all edges of the given shape.
1873 # @param theShape Shape, to perform fillet on.
1874 # @param theR Fillet radius.
1875 # @return New GEOM_Object, containing the result shape.
1877 # Example: see GEOM_TestOthers.py
1878 def MakeFilletAll(theShape, theR):
1879 anObj = LocalOp.MakeFilletAll(theShape, theR)
1880 if LocalOp.IsDone() == 0:
1881 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1884 ## Perform a fillet on the specified edges/faces of the given shape
1885 # @param theShape Shape, to perform fillet on.
1886 # @param theR Fillet radius.
1887 # @param theShapeType Type of shapes in <theListShapes>.
1888 # @param theListShapes Global indices of edges/faces to perform fillet on.
1889 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1890 # @return New GEOM_Object, containing the result shape.
1892 # Example: see GEOM_TestAll.py
1893 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1895 if theShapeType == ShapeType["EDGE"]:
1896 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1898 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1899 if LocalOp.IsDone() == 0:
1900 print "MakeFillet : ", LocalOp.GetErrorCode()
1903 ## Perform a symmetric chamfer on all edges of the given shape.
1904 # @param theShape Shape, to perform chamfer on.
1905 # @param theD Chamfer size along each face.
1906 # @return New GEOM_Object, containing the result shape.
1908 # Example: see GEOM_TestOthers.py
1909 def MakeChamferAll(theShape, theD):
1910 anObj = LocalOp.MakeChamferAll(theShape, theD)
1911 if LocalOp.IsDone() == 0:
1912 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1915 ## Perform a chamfer on edges, common to the specified faces,
1916 # with distance D1 on the Face1
1917 # @param theShape Shape, to perform chamfer on.
1918 # @param theD1 Chamfer size along \a theFace1.
1919 # @param theD2 Chamfer size along \a theFace2.
1920 # @param theFace1,theFace2 Global indices of two faces of \a theShape.
1921 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1922 # @return New GEOM_Object, containing the result shape.
1924 # Example: see GEOM_TestAll.py
1925 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1926 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1927 if LocalOp.IsDone() == 0:
1928 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1931 ## Perform a chamfer on all edges of the specified faces,
1932 # with distance D1 on the first specified face (if several for one edge)
1933 # @param theShape Shape, to perform chamfer on.
1934 # @param theD1 Chamfer size along face from \a theFaces. If both faces,
1935 # connected to the edge, are in \a theFaces, \a theD1
1936 # will be get along face, which is nearer to \a theFaces beginning.
1937 # @param theD2 Chamfer size along another of two faces, connected to the edge.
1938 # @param theFaces Sequence of global indices of faces of \a theShape.
1939 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1940 # @return New GEOM_Object, containing the result shape.
1942 # Example: see GEOM_TestAll.py
1943 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1944 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1945 if LocalOp.IsDone() == 0:
1946 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1949 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1951 # Example: see GEOM_TestOthers.py
1952 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1954 if aShapeType == ShapeType["EDGE"]:
1955 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1957 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1960 ## Perform an Archimde operation on the given shape with given parameters.
1961 # The object presenting the resulting face is returned.
1962 # @param theShape Shape to be put in water.
1963 # @param theWeight Weight og the shape.
1964 # @param theWaterDensity Density of the water.
1965 # @param theMeshDeflection Deflection of the mesh, using to compute the section.
1966 # @return New GEOM_Object, containing a section of \a theShape
1967 # by a plane, corresponding to water level.
1969 # Example: see GEOM_TestAll.py
1970 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1971 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1972 if LocalOp.IsDone() == 0:
1973 print "MakeArchimede : ", LocalOp.GetErrorCode()
1976 # -----------------------------------------------------------------------------
1977 # Information objects
1978 # -----------------------------------------------------------------------------
1980 ## Get point coordinates
1983 # Example: see GEOM_TestMeasures.py
1984 def PointCoordinates(Point):
1985 aTuple = MeasuOp.PointCoordinates(Point)
1986 if MeasuOp.IsDone() == 0:
1987 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1990 ## Get summarized length of all wires,
1991 # area of surface and volume of the given shape.
1992 # @param theShape Shape to define properties of.
1993 # @return [theLength, theSurfArea, theVolume]
1994 # theLength: Summarized length of all wires of the given shape.
1995 # theSurfArea: Area of surface of the given shape.
1996 # theVolume: Volume of the given shape.
1998 # Example: see GEOM_TestMeasures.py
1999 def BasicProperties(theShape):
2000 aTuple = MeasuOp.GetBasicProperties(theShape)
2001 if MeasuOp.IsDone() == 0:
2002 print "BasicProperties : ", MeasuOp.GetErrorCode()
2005 ## Get parameters of bounding box of the given shape
2006 # @param theShape Shape to obtain bounding box of.
2007 # @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
2008 # Xmin,Xmax: Limits of shape along OX axis.
2009 # Ymin,Ymax: Limits of shape along OY axis.
2010 # Zmin,Zmax: Limits of shape along OZ axis.
2012 # Example: see GEOM_TestMeasures.py
2013 def BoundingBox(theShape):
2014 aTuple = MeasuOp.GetBoundingBox(theShape)
2015 if MeasuOp.IsDone() == 0:
2016 print "BoundingBox : ", MeasuOp.GetErrorCode()
2019 ## Get inertia matrix and moments of inertia of theShape.
2020 # @param theShape Shape to calculate inertia of.
2021 # @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
2022 # I(1-3)(1-3): Components of the inertia matrix of the given shape.
2023 # Ix,Iy,Iz: Moments of inertia of the given shape.
2025 # Example: see GEOM_TestMeasures.py
2026 def Inertia(theShape):
2027 aTuple = MeasuOp.GetInertia(theShape)
2028 if MeasuOp.IsDone() == 0:
2029 print "Inertia : ", MeasuOp.GetErrorCode()
2032 ## Get minimal distance between the given shapes.
2033 # @param theShape1,theShape2 Shapes to find minimal distance between.
2034 # @return Value of the minimal distance between the given shapes.
2036 # Example: see GEOM_TestMeasures.py
2037 def MinDistance(theShape1, theShape2):
2038 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
2039 if MeasuOp.IsDone() == 0:
2040 print "MinDistance : ", MeasuOp.GetErrorCode()
2043 ## Get min and max tolerances of sub-shapes of theShape
2044 # @param theShape Shape, to get tolerances of.
2045 # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
2046 # FaceMin,FaceMax: Min and max tolerances of the faces.
2047 # EdgeMin,EdgeMax: Min and max tolerances of the edges.
2048 # VertMin,VertMax: Min and max tolerances of the vertices.
2050 # Example: see GEOM_TestMeasures.py
2051 def Tolerance(theShape):
2052 aTuple = MeasuOp.GetTolerance(theShape)
2053 if MeasuOp.IsDone() == 0:
2054 print "Tolerance : ", MeasuOp.GetErrorCode()
2057 ## Obtain description of the given shape (number of sub-shapes of each type)
2058 # @param theShape Shape to be described.
2059 # @return Description of the given shape.
2061 # Example: see GEOM_TestMeasures.py
2062 def WhatIs(theShape):
2063 aDescr = MeasuOp.WhatIs(theShape)
2064 if MeasuOp.IsDone() == 0:
2065 print "WhatIs : ", MeasuOp.GetErrorCode()
2068 ## Get a point, situated at the centre of mass of theShape.
2069 # @param theShape Shape to define centre of mass of.
2070 # @return New GEOM_Object, containing the created point.
2072 # Example: see GEOM_TestMeasures.py
2073 def MakeCDG(theShape):
2074 anObj = MeasuOp.GetCentreOfMass(theShape)
2075 if MeasuOp.IsDone() == 0:
2076 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
2079 ## Check a topology of the given shape.
2080 # @param theShape Shape to check validity of.
2081 # @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
2082 # if TRUE, the shape's geometry will be checked also.
2083 # @return TRUE, if the shape "seems to be valid".
2084 # If theShape is invalid, prints a description of problem.
2086 # Example: see GEOM_TestMeasures.py
2087 def CheckShape(theShape, theIsCheckGeom = 0):
2089 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
2091 (IsValid, Status) = MeasuOp.CheckShape(theShape)
2093 if MeasuOp.IsDone() == 0:
2094 print "CheckShape : ", MeasuOp.GetErrorCode()
2100 ## Get position (LCS) of theShape.
2102 # Origin of the LCS is situated at the shape's center of mass.
2103 # Axes of the LCS are obtained from shape's location or,
2104 # if the shape is a planar face, from position of its plane.
2106 # @param theShape Shape to calculate position of.
2107 # @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
2108 # Ox,Oy,Oz: Coordinates of shape's LCS origin.
2109 # Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
2110 # Xx,Xy,Xz: Coordinates of shape's LCS X direction.
2112 # Example: see GEOM_TestMeasures.py
2113 def GetPosition(theShape):
2114 aTuple = MeasuOp.GetPosition(theShape)
2115 if MeasuOp.IsDone() == 0:
2116 print "GetPosition : ", MeasuOp.GetErrorCode()
2119 ## Get kind of theShape.
2121 # @param theShape Shape to get a kind of.
2122 # @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
2123 # and a list of parameters, describing the shape.
2124 # @note Concrete meaning of each value, returned via \a theIntegers
2125 # or \a theDoubles list depends on the kind of the shape.
2126 # The full list of possible outputs is:
2128 # geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices
2129 # geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices
2131 # geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices
2132 # geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices
2134 # geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices
2135 # geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices
2137 # geompy.kind.SPHERE xc yc zc R
2138 # geompy.kind.CYLINDER xb yb zb dx dy dz R H
2139 # geompy.kind.BOX xc yc zc ax ay az
2140 # geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az
2141 # geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2
2142 # geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H
2143 # geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices
2144 # geompy.kind.SOLID nb_faces nb_edges nb_vertices
2146 # geompy.kind.SPHERE2D xc yc zc R
2147 # geompy.kind.CYLINDER2D xb yb zb dx dy dz R H
2148 # geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2
2149 # geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H
2150 # geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R
2151 # geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2
2152 # geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices
2153 # geompy.kind.PLANE xo yo zo dx dy dz
2154 # geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices
2155 # geompy.kind.FACE nb_edges nb_vertices
2157 # geompy.kind.CIRCLE xc yc zc dx dy dz R
2158 # geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2
2159 # geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2
2160 # geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2
2161 # geompy.kind.LINE xo yo zo dx dy dz
2162 # geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2
2163 # geompy.kind.EDGE nb_vertices
2165 # geompy.kind.VERTEX x y z
2167 # Example: see GEOM_TestMeasures.py
2168 def KindOfShape(theShape):
2169 aRoughTuple = MeasuOp.KindOfShape(theShape)
2170 if MeasuOp.IsDone() == 0:
2171 print "KindOfShape : ", MeasuOp.GetErrorCode()
2174 aKind = aRoughTuple[0]
2175 anInts = aRoughTuple[1]
2176 aDbls = aRoughTuple[2]
2178 # Now there is no exception from this rule:
2179 aKindTuple = [aKind] + aDbls + anInts
2181 # If they are we will regroup parameters for such kind of shape.
2183 #if aKind == kind.SOME_KIND:
2184 # # SOME_KIND int int double int double double
2185 # aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
2189 # -----------------------------------------------------------------------------
2190 # Import/Export objects
2191 # -----------------------------------------------------------------------------
2193 ## Import a shape from the BREP or IGES or STEP file
2194 # (depends on given format) with given name.
2195 # @param theFileName The file, containing the shape.
2196 # @param theFormatName Specify format for the file reading.
2197 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2198 # @return New GEOM_Object, containing the imported shape.
2200 # Example: see GEOM_TestOthers.py
2201 def Import(theFileName, theFormatName):
2202 anObj = InsertOp.Import(theFileName, theFormatName)
2203 if InsertOp.IsDone() == 0:
2204 print "Import : ", InsertOp.GetErrorCode()
2207 ## Shortcut to Import() for BREP format
2209 # Example: see GEOM_TestOthers.py
2210 def ImportBREP(theFileName):
2211 return Import(theFileName, "BREP")
2213 ## Shortcut to Import() for IGES format
2215 # Example: see GEOM_TestOthers.py
2216 def ImportIGES(theFileName):
2217 return Import(theFileName, "IGES")
2219 ## Shortcut to Import() for STEP format
2221 # Example: see GEOM_TestOthers.py
2222 def ImportSTEP(theFileName):
2223 return Import(theFileName, "STEP")
2225 ## Export the given shape into a file with given name.
2226 # @param theObject Shape to be stored in the file.
2227 # @param theFileName Name of the file to store the given shape in.
2228 # @param theFormatName Specify format for the shape storage.
2229 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2231 # Example: see GEOM_TestOthers.py
2232 def Export(theObject, theFileName, theFormatName):
2233 InsertOp.Export(theObject, theFileName, theFormatName)
2234 if InsertOp.IsDone() == 0:
2235 print "Export : ", InsertOp.GetErrorCode()
2237 ## Shortcut to Export() for BREP format
2239 # Example: see GEOM_TestOthers.py
2240 def ExportBREP(theObject, theFileName):
2241 return Export(theObject, theFileName, "BREP")
2243 ## Shortcut to Export() for IGES format
2245 # Example: see GEOM_TestOthers.py
2246 def ExportIGES(theObject, theFileName):
2247 return Export(theObject, theFileName, "IGES")
2249 ## Shortcut to Export() for STEP format
2251 # Example: see GEOM_TestOthers.py
2252 def ExportSTEP(theObject, theFileName):
2253 return Export(theObject, theFileName, "STEP")
2255 # -----------------------------------------------------------------------------
2257 # -----------------------------------------------------------------------------
2259 ## Create a quadrangle face from four edges. Order of Edges is not
2260 # important. It is not necessary that edges share the same vertex.
2261 # @param E1,E2,E3,E4 Edges for the face bound.
2262 # @return New GEOM_Object, containing the created face.
2264 # Example: see GEOM_Spanner.py
2265 def MakeQuad(E1, E2, E3, E4):
2266 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2267 if BlocksOp.IsDone() == 0:
2268 print "MakeQuad : ", BlocksOp.GetErrorCode()
2271 ## Create a quadrangle face on two edges.
2272 # The missing edges will be built by creating the shortest ones.
2273 # @param E1,E2 Two opposite edges for the face.
2274 # @return New GEOM_Object, containing the created face.
2276 # Example: see GEOM_Spanner.py
2277 def MakeQuad2Edges(E1, E2):
2278 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2279 if BlocksOp.IsDone() == 0:
2280 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2283 ## Create a quadrangle face with specified corners.
2284 # The missing edges will be built by creating the shortest ones.
2285 # @param V1,V2,V3,V4 Corner vertices for the face.
2286 # @return New GEOM_Object, containing the created face.
2288 # Example: see GEOM_Spanner.py
2289 def MakeQuad4Vertices(V1, V2, V3, V4):
2290 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2291 if BlocksOp.IsDone() == 0:
2292 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2295 ## Create a hexahedral solid, bounded by the six given faces. Order of
2296 # faces is not important. It is not necessary that Faces share the same edge.
2297 # @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2298 # @return New GEOM_Object, containing the created solid.
2300 # Example: see GEOM_Spanner.py
2301 def MakeHexa(F1, F2, F3, F4, F5, F6):
2302 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2303 if BlocksOp.IsDone() == 0:
2304 print "MakeHexa : ", BlocksOp.GetErrorCode()
2307 ## Create a hexahedral solid between two given faces.
2308 # The missing faces will be built by creating the smallest ones.
2309 # @param F1,F2 Two opposite faces for the hexahedral solid.
2310 # @return New GEOM_Object, containing the created solid.
2312 # Example: see GEOM_Spanner.py
2313 def MakeHexa2Faces(F1, F2):
2314 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2315 if BlocksOp.IsDone() == 0:
2316 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2319 ## Get a vertex, found in the given shape by its coordinates.
2320 # @param theShape Block or a compound of blocks.
2321 # @param theX,theY,theZ Coordinates of the sought vertex.
2322 # @param theEpsilon Maximum allowed distance between the resulting
2323 # vertex and point with the given coordinates.
2324 # @return New GEOM_Object, containing the found vertex.
2326 # Example: see GEOM_TestOthers.py
2327 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2328 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2329 if BlocksOp.IsDone() == 0:
2330 print "GetPoint : ", BlocksOp.GetErrorCode()
2333 ## Get an edge, found in the given shape by two given vertices.
2334 # @param theShape Block or a compound of blocks.
2335 # @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2336 # @return New GEOM_Object, containing the found edge.
2338 # Example: see GEOM_Spanner.py
2339 def GetEdge(theShape, thePoint1, thePoint2):
2340 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2341 if BlocksOp.IsDone() == 0:
2342 print "GetEdge : ", BlocksOp.GetErrorCode()
2345 ## Find an edge of the given shape, which has minimal distance to the given point.
2346 # @param theShape Block or a compound of blocks.
2347 # @param thePoint Point, close to the desired edge.
2348 # @return New GEOM_Object, containing the found edge.
2350 # Example: see GEOM_TestOthers.py
2351 def GetEdgeNearPoint(theShape, thePoint):
2352 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2353 if BlocksOp.IsDone() == 0:
2354 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2357 ## Returns a face, found in the given shape by four given corner vertices.
2358 # @param theShape Block or a compound of blocks.
2359 # @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2360 # @return New GEOM_Object, containing the found face.
2362 # Example: see GEOM_Spanner.py
2363 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2364 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2365 if BlocksOp.IsDone() == 0:
2366 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2369 ## Get a face of block, found in the given shape by two given edges.
2370 # @param theShape Block or a compound of blocks.
2371 # @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2372 # @return New GEOM_Object, containing the found face.
2374 # Example: see GEOM_Spanner.py
2375 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2376 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2377 if BlocksOp.IsDone() == 0:
2378 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2381 ## Find a face, opposite to the given one in the given block.
2382 # @param theBlock Must be a hexahedral solid.
2383 # @param theFace Face of \a theBlock, opposite to the desired face.
2384 # @return New GEOM_Object, containing the found face.
2386 # Example: see GEOM_Spanner.py
2387 def GetOppositeFace(theBlock, theFace):
2388 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2389 if BlocksOp.IsDone() == 0:
2390 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2393 ## Find a face of the given shape, which has minimal distance to the given point.
2394 # @param theShape Block or a compound of blocks.
2395 # @param thePoint Point, close to the desired face.
2396 # @return New GEOM_Object, containing the found face.
2398 # Example: see GEOM_Spanner.py
2399 def GetFaceNearPoint(theShape, thePoint):
2400 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2401 if BlocksOp.IsDone() == 0:
2402 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2405 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2406 # @param theShape Block or a compound of blocks.
2407 # @param theVector Vector, close to the normale of the desired face.
2408 # @return New GEOM_Object, containing the found face.
2410 # Example: see GEOM_Spanner.py
2411 def GetFaceByNormale(theBlock, theVector):
2412 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2413 if BlocksOp.IsDone() == 0:
2414 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2417 ## Check, if the compound of blocks is given.
2418 # To be considered as a compound of blocks, the
2419 # given shape must satisfy the following conditions:
2420 # - Each element of the compound should be a Block (6 faces and 12 edges).
2421 # - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2422 # - The compound should be connexe.
2423 # - The glue between two quadrangle faces should be applied.
2424 # @param theCompound The compound to check.
2425 # @return TRUE, if the given shape is a compound of blocks.
2426 # If theCompound is not valid, prints all discovered errors.
2428 # Example: see GEOM_Spanner.py
2429 def CheckCompoundOfBlocks(theCompound):
2430 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2431 if BlocksOp.IsDone() == 0:
2432 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2435 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2439 ## Remove all seam and degenerated edges from \a theShape.
2440 # Unite faces and edges, sharing one surface. It means that
2441 # this faces must have references to one C++ surface object (handle).
2442 # @param theShape The compound or single solid to remove irregular edges from.
2443 # @return Improved shape.
2445 # Example: see GEOM_TestOthers.py
2446 def RemoveExtraEdges(theShape):
2447 anObj = BlocksOp.RemoveExtraEdges(theShape)
2448 if BlocksOp.IsDone() == 0:
2449 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2452 ## Check, if the given shape is a blocks compound.
2453 # Fix all detected errors.
2454 # \note Single block can be also fixed by this method.
2455 # @param theCompound The compound to check and improve.
2456 # @return Improved compound.
2458 # Example: see GEOM_TestOthers.py
2459 def CheckAndImprove(theShape):
2460 anObj = BlocksOp.CheckAndImprove(theShape)
2461 if BlocksOp.IsDone() == 0:
2462 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2465 ## Get all the blocks, contained in the given compound.
2466 # @param theCompound The compound to explode.
2467 # @param theMinNbFaces If solid has lower number of faces, it is not a block.
2468 # @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2469 # \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2470 # @return List of GEOM_Objects, containing the retrieved blocks.
2472 # Example: see GEOM_TestOthers.py
2473 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2474 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2475 if BlocksOp.IsDone() == 0:
2476 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2479 ## Find block, containing the given point inside its volume or on boundary.
2480 # @param theCompound Compound, to find block in.
2481 # @param thePoint Point, close to the desired block. If the point lays on
2482 # boundary between some blocks, we return block with nearest center.
2483 # @return New GEOM_Object, containing the found block.
2485 # Example: see GEOM_Spanner.py
2486 def GetBlockNearPoint(theCompound, thePoint):
2487 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2488 if BlocksOp.IsDone() == 0:
2489 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2492 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2493 # @param theCompound Compound, to find block in.
2494 # @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2495 # @return New GEOM_Object, containing the found block.
2497 # Example: see GEOM_TestOthers.py
2498 def GetBlockByParts(theCompound, theParts):
2499 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2500 if BlocksOp.IsDone() == 0:
2501 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2504 ## Return all blocks, containing all the elements, passed as the parts.
2505 # @param theCompound Compound, to find blocks in.
2506 # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2507 # @return List of GEOM_Objects, containing the found blocks.
2509 # Example: see GEOM_Spanner.py
2510 def GetBlocksByParts(theCompound, theParts):
2511 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2512 if BlocksOp.IsDone() == 0:
2513 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2516 ## Multi-transformate block and glue the result.
2517 # Transformation is defined so, as to superpose direction faces.
2518 # @param Block Hexahedral solid to be multi-transformed.
2519 # @param DirFace1 ID of First direction face.
2520 # @param DirFace2 ID of Second direction face.
2521 # @param NbTimes Quantity of transformations to be done.
2522 # \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2523 # @return New GEOM_Object, containing the result shape.
2525 # Example: see GEOM_Spanner.py
2526 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2527 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2528 if BlocksOp.IsDone() == 0:
2529 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2532 ## Multi-transformate block and glue the result.
2533 # @param Block Hexahedral solid to be multi-transformed.
2534 # @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2535 # @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2536 # @param NbTimesU,NbTimesV Quantity of transformations to be done.
2537 # @return New GEOM_Object, containing the result shape.
2539 # Example: see GEOM_Spanner.py
2540 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2541 DirFace1V, DirFace2V, NbTimesV):
2542 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2543 DirFace1V, DirFace2V, NbTimesV)
2544 if BlocksOp.IsDone() == 0:
2545 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2548 ## Build all possible propagation groups.
2549 # Propagation group is a set of all edges, opposite to one (main)
2550 # edge of this group directly or through other opposite edges.
2551 # Notion of Opposite Edge make sence only on quadrangle face.
2552 # @param theShape Shape to build propagation groups on.
2553 # @return List of GEOM_Objects, each of them is a propagation group.
2555 # Example: see GEOM_TestOthers.py
2556 def Propagate(theShape):
2557 listChains = BlocksOp.Propagate(theShape)
2558 if BlocksOp.IsDone() == 0:
2559 print "Propagate : ", BlocksOp.GetErrorCode()
2562 # -----------------------------------------------------------------------------
2564 # -----------------------------------------------------------------------------
2566 ## Creates a new group which will store sub shapes of theMainShape
2567 # @param theMainShape is a GEOM object on which the group is selected
2568 # @param theShapeType defines a shape type of the group
2569 # @return a newly created GEOM group
2571 # Example: see GEOM_TestOthers.py
2572 def CreateGroup(theMainShape, theShapeType):
2573 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2574 if GroupOp.IsDone() == 0:
2575 print "CreateGroup : ", GroupOp.GetErrorCode()
2578 ## Adds a sub object with ID theSubShapeId to the group
2579 # @param theGroup is a GEOM group to which the new sub shape is added
2580 # @param theSubShapeID is a sub shape ID in the main object.
2581 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2583 # Example: see GEOM_TestOthers.py
2584 def AddObject(theGroup, theSubShapeID):
2585 GroupOp.AddObject(theGroup, theSubShapeID)
2586 if GroupOp.IsDone() == 0:
2587 print "AddObject : ", GroupOp.GetErrorCode()
2589 ## Removes a sub object with ID \a theSubShapeId from the group
2590 # @param theGroup is a GEOM group from which the new sub shape is removed
2591 # @param theSubShapeID is a sub shape ID in the main object.
2592 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2594 # Example: see GEOM_TestOthers.py
2595 def RemoveObject(theGroup, theSubShapeID):
2596 GroupOp.RemoveObject(theGroup, theSubShapeID)
2597 if GroupOp.IsDone() == 0:
2598 print "RemoveObject : ", GroupOp.GetErrorCode()
2600 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2601 # @param theGroup is a GEOM group to which the new sub shapes are added.
2602 # @param theSubShapes is a list of sub shapes to be added.
2604 # Example: see GEOM_TestOthers.py
2605 def UnionList (theGroup, theSubShapes):
2606 GroupOp.UnionList(theGroup, theSubShapes)
2607 if GroupOp.IsDone() == 0:
2608 print "UnionList : ", GroupOp.GetErrorCode()
2610 ## Works like the above method, but argument
2611 # theSubShapes here is a list of sub-shapes indices
2613 # Example: see GEOM_TestOthers.py
2614 def UnionIDs(theGroup, theSubShapes):
2615 GroupOp.UnionIDs(theGroup, theSubShapes)
2616 if GroupOp.IsDone() == 0:
2617 print "UnionIDs : ", GroupOp.GetErrorCode()
2619 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2620 # @param theGroup is a GEOM group from which the sub-shapes are removed.
2621 # @param theSubShapes is a list of sub-shapes to be removed.
2623 # Example: see GEOM_TestOthers.py
2624 def DifferenceList (theGroup, theSubShapes):
2625 GroupOp.DifferenceList(theGroup, theSubShapes)
2626 if GroupOp.IsDone() == 0:
2627 print "DifferenceList : ", GroupOp.GetErrorCode()
2629 ## Works like the above method, but argument
2630 # theSubShapes here is a list of sub-shapes indices
2632 # Example: see GEOM_TestOthers.py
2633 def DifferenceIDs(theGroup, theSubShapes):
2634 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2635 if GroupOp.IsDone() == 0:
2636 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2638 ## Returns a list of sub objects ID stored in the group
2639 # @param theGroup is a GEOM group for which a list of IDs is requested
2641 # Example: see GEOM_TestOthers.py
2642 def GetObjectIDs(theGroup):
2643 ListIDs = GroupOp.GetObjects(theGroup)
2644 if GroupOp.IsDone() == 0:
2645 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2648 ## Returns a type of sub objects stored in the group
2649 # @param theGroup is a GEOM group which type is returned.
2651 # Example: see GEOM_TestOthers.py
2652 def GetType(theGroup):
2653 aType = GroupOp.GetType(theGroup)
2654 if GroupOp.IsDone() == 0:
2655 print "GetType : ", GroupOp.GetErrorCode()
2658 ## Returns a main shape associated with the group
2659 # @param theGroup is a GEOM group for which a main shape object is requested
2660 # @return a GEOM object which is a main shape for theGroup
2662 # Example: see GEOM_TestOthers.py
2663 def GetMainShape(theGroup):
2664 anObj = GroupOp.GetMainShape(theGroup)
2665 if GroupOp.IsDone() == 0:
2666 print "GetMainShape : ", GroupOp.GetErrorCode()
2669 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2670 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2671 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2672 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2675 Props = BasicProperties(edge)
2676 if min_length <= Props[0] and Props[0] <= max_length:
2677 if (not include_min) and (min_length == Props[0]):
2680 if (not include_max) and (Props[0] == max_length):
2683 edges_in_range.append(edge)
2685 if len(edges_in_range) <= 0:
2686 print "No edges found by given criteria"
2689 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2690 UnionList(group_edges, edges_in_range)
2694 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2695 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2696 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2697 nb_selected = sg.SelectedCount()
2699 print "Select a shape before calling this function, please."
2702 print "Only one shape must be selected"
2705 id_shape = sg.getSelected(0)
2706 shape = IDToObject( id_shape )
2708 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2712 if include_min: left_str = " <= "
2713 if include_max: right_str = " <= "
2715 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2716 + left_str + "length" + right_str + `max_length`)
2718 sg.updateObjBrowser(1)
2722 ## Add Path to load python scripts from
2724 if (sys.path.count(Path) < 1):
2725 sys.path.append(Path)