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 # -----------------------------------------------------------------------------
148 # -----------------------------------------------------------------------------
150 ## Create point by three coordinates.
151 # @param theX The X coordinate of the point.
152 # @param theY The Y coordinate of the point.
153 # @param theZ The Z coordinate of the point.
154 # @return New GEOM_Object, containing the created point.
156 # Example: see GEOM_TestAll.py
157 def MakeVertex(theX, theY, theZ):
158 anObj = BasicOp.MakePointXYZ(theX, theY, theZ)
159 if BasicOp.IsDone() == 0:
160 print "MakePointXYZ : ", BasicOp.GetErrorCode()
163 ## Create a point, distant from the referenced point
164 # on the given distances along the coordinate axes.
165 # @param theReference The referenced point.
166 # @param theX Displacement from the referenced point along OX axis.
167 # @param theY Displacement from the referenced point along OY axis.
168 # @param theZ Displacement from the referenced point along OZ axis.
169 # @return New GEOM_Object, containing the created point.
171 # Example: see GEOM_TestAll.py
172 def MakeVertexWithRef(theReference, theX, theY, theZ):
173 anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
174 if BasicOp.IsDone() == 0:
175 print "MakePointWithReference : ", BasicOp.GetErrorCode()
178 ## Create a point, corresponding to the given parameter on the given curve.
179 # @param theRefCurve The referenced curve.
180 # @param theParameter Value of parameter on the referenced curve.
181 # @return New GEOM_Object, containing the created point.
183 # Example: see GEOM_TestAll.py
184 def MakeVertexOnCurve(theRefCurve, theParameter):
185 anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter)
186 if BasicOp.IsDone() == 0:
187 print "MakePointOnCurve : ", BasicOp.GetErrorCode()
190 ## Create a tangent, corresponding to the given parameter on the given curve.
191 # @param theRefCurve The referenced curve.
192 # @param theParameter Value of parameter on the referenced curve.
193 # @return New GEOM_Object, containing the created tangent.
194 def MakeTangentOnCurve(theRefCurve, theParameter):
195 anObj = BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
196 if BasicOp.IsDone() == 0:
197 print "MakeTangentOnCurve : ", BasicOp.GetErrorCode()
200 ## Create a vector with the given components.
201 # @param theDX X component of the vector.
202 # @param theDY Y component of the vector.
203 # @param theDZ Z component of the vector.
204 # @return New GEOM_Object, containing the created vector.
206 # Example: see GEOM_TestAll.py
207 def MakeVectorDXDYDZ(theDX, theDY, theDZ):
208 anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
209 if BasicOp.IsDone() == 0:
210 print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode()
213 ## Create a vector between two points.
214 # @param thePnt1 Start point for the vector.
215 # @param thePnt2 End point for the vector.
216 # @return New GEOM_Object, containing the created vector.
218 # Example: see GEOM_TestAll.py
219 def MakeVector(thePnt1, thePnt2):
220 anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
221 if BasicOp.IsDone() == 0:
222 print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode()
225 ## Create a line, passing through the given point
226 # and parrallel to the given direction
227 # @param thePnt Point. The resulting line will pass through it.
228 # @param theDir Direction. The resulting line will be parallel to it.
229 # @return New GEOM_Object, containing the created line.
231 # Example: see GEOM_TestAll.py
232 def MakeLine(thePnt, theDir):
233 anObj = BasicOp.MakeLine(thePnt, theDir)
234 if BasicOp.IsDone() == 0:
235 print "MakeLine : ", BasicOp.GetErrorCode()
238 ## Create a line, passing through the given points
239 # @param thePnt1 First of two points, defining the line.
240 # @param thePnt2 Second of two points, defining the line.
241 # @return New GEOM_Object, containing the created line.
243 # Example: see GEOM_TestAll.py
244 def MakeLineTwoPnt(thePnt1, thePnt2):
245 anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
246 if BasicOp.IsDone() == 0:
247 print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
250 ## Create a plane, passing through the given point
251 # and normal to the given vector.
252 # @param thePnt Point, the plane has to pass through.
253 # @param theVec Vector, defining the plane normal direction.
254 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
255 # @return New GEOM_Object, containing the created plane.
257 # Example: see GEOM_TestAll.py
258 def MakePlane(thePnt, theVec, theTrimSize):
259 anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
260 if BasicOp.IsDone() == 0:
261 print "MakePlanePntVec : ", BasicOp.GetErrorCode()
264 ## Create a plane, passing through the three given points
265 # @param thePnt1 First of three points, defining the plane.
266 # @param thePnt2 Second of three points, defining the plane.
267 # @param thePnt3 Fird of three points, defining the plane.
268 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
269 # @return New GEOM_Object, containing the created plane.
271 # Example: see GEOM_TestAll.py
272 def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize):
273 anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
274 if BasicOp.IsDone() == 0:
275 print "MakePlaneThreePnt : ", BasicOp.GetErrorCode()
278 ## Create a plane, similar to the existing one, but with another size of representing face.
279 # @param theFace Referenced plane or LCS(Marker).
280 # @param theTrimSize New half size of a side of quadrangle face, representing the plane.
281 # @return New GEOM_Object, containing the created plane.
283 # Example: see GEOM_TestAll.py
284 def MakePlaneFace(theFace, theTrimSize):
285 anObj = BasicOp.MakePlaneFace(theFace, theTrimSize)
286 if BasicOp.IsDone() == 0:
287 print "MakePlaneFace : ", BasicOp.GetErrorCode()
290 ## Create a local coordinate system.
291 # @param OX,OY,OZ Three coordinates of coordinate system origin.
292 # @param XDX,XDY,XDZ Three components of OX direction
293 # @param YDX,YDY,YDZ Three components of OY direction
294 # @return New GEOM_Object, containing the created coordinate system.
296 # Example: see GEOM_TestAll.py
297 def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
298 anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
299 if BasicOp.IsDone() == 0:
300 print "MakeMarker : ", BasicOp.GetErrorCode()
303 ## Create a local coordinate system.
304 # @param theOrigin Point of coordinate system origin.
305 # @param theXVec Vector of X direction
306 # @param theYVec Vector of Y direction
307 # @return New GEOM_Object, containing the created coordinate system.
308 def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
309 O = PointCoordinates( theOrigin )
311 for vec in [ theXVec, theYVec ]:
312 v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
313 p1 = PointCoordinates( v1 )
314 p2 = PointCoordinates( v2 )
315 for i in range( 0, 3 ):
316 OXOY.append( p2[i] - p1[i] )
318 anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
319 OXOY[0], OXOY[1], OXOY[2],
320 OXOY[3], OXOY[4], OXOY[5], )
321 if BasicOp.IsDone() == 0:
322 print "MakeMarker : ", BasicOp.GetErrorCode()
325 # -----------------------------------------------------------------------------
327 # -----------------------------------------------------------------------------
329 ## Create an arc of circle, passing through three given points.
330 # @param thePnt1 Start point of the arc.
331 # @param thePnt2 Middle point of the arc.
332 # @param thePnt3 End point of the arc.
333 # @return New GEOM_Object, containing the created arc.
335 # Example: see GEOM_TestAll.py
336 def MakeArc(thePnt1, thePnt2, thePnt3):
337 anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
338 if CurvesOp.IsDone() == 0:
339 print "MakeArc : ", CurvesOp.GetErrorCode()
342 ## Create a circle with given center, normal vector and radius.
343 # @param thePnt Circle center.
344 # @param theVec Vector, normal to the plane of the circle.
345 # @param theR Circle radius.
346 # @return New GEOM_Object, containing the created circle.
348 # Example: see GEOM_TestAll.py
349 def MakeCircle(thePnt, theVec, theR):
350 anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
351 if CurvesOp.IsDone() == 0:
352 print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode()
355 ## Create a circle, passing through three given points
356 # @param thePnt1,thePnt2,thePnt3 Points, defining the circle.
357 # @return New GEOM_Object, containing the created circle.
359 # Example: see GEOM_TestAll.py
360 def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3):
361 anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
362 if CurvesOp.IsDone() == 0:
363 print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
366 ## Create an ellipse with given center, normal vector and radiuses.
367 # @param thePnt Ellipse center.
368 # @param theVec Vector, normal to the plane of the ellipse.
369 # @param theRMajor Major ellipse radius.
370 # @param theRMinor Minor ellipse radius.
371 # @return New GEOM_Object, containing the created ellipse.
373 # Example: see GEOM_TestAll.py
374 def MakeEllipse(thePnt, theVec, theRMajor, theRMinor):
375 anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
376 if CurvesOp.IsDone() == 0:
377 print "MakeEllipse : ", CurvesOp.GetErrorCode()
380 ## Create a polyline on the set of points.
381 # @param thePoints Sequence of points for the polyline.
382 # @return New GEOM_Object, containing the created polyline.
384 # Example: see GEOM_TestAll.py
385 def MakePolyline(thePoints):
386 anObj = CurvesOp.MakePolyline(thePoints)
387 if CurvesOp.IsDone() == 0:
388 print "MakePolyline : ", CurvesOp.GetErrorCode()
391 ## Create bezier curve on the set of points.
392 # @param thePoints Sequence of points for the bezier curve.
393 # @return New GEOM_Object, containing the created bezier curve.
395 # Example: see GEOM_TestAll.py
396 def MakeBezier(thePoints):
397 anObj = CurvesOp.MakeSplineBezier(thePoints)
398 if CurvesOp.IsDone() == 0:
399 print "MakeSplineBezier : ", CurvesOp.GetErrorCode()
402 ## Create B-Spline curve on the set of points.
403 # @param thePoints Sequence of points for the B-Spline curve.
404 # @return New GEOM_Object, containing the created B-Spline curve.
406 # Example: see GEOM_TestAll.py
407 def MakeInterpol(thePoints):
408 anObj = CurvesOp.MakeSplineInterpolation(thePoints)
409 if CurvesOp.IsDone() == 0:
410 print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode()
413 ## Create a sketcher (wire or face), following the textual description,
414 # passed through \a theCommand argument. \n
415 # Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
416 # Format of the description string have to be the following:
418 # "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
421 # - x1, y1 are coordinates of the first sketcher point (zero by default),
423 # - "R angle" : Set the direction by angle
424 # - "D dx dy" : Set the direction by DX & DY
427 # - "TT x y" : Create segment by point at X & Y
428 # - "T dx dy" : Create segment by point with DX & DY
429 # - "L length" : Create segment by direction & Length
430 # - "IX x" : Create segment by direction & Intersect. X
431 # - "IY y" : Create segment by direction & Intersect. Y
434 # - "C radius length" : Create arc by direction, radius and length(in degree)
437 # - "WW" : Close Wire (to finish)
438 # - "WF" : Close Wire and build face (to finish)
440 # @param theCommand String, defining the sketcher in local
441 # coordinates of the working plane.
442 # @param theWorkingPlane Nine double values, defining origin,
443 # OZ and OX directions of the working plane.
444 # @return New GEOM_Object, containing the created wire.
446 # Example: see GEOM_TestAll.py
447 def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
448 anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
449 if CurvesOp.IsDone() == 0:
450 print "MakeSketcher : ", CurvesOp.GetErrorCode()
453 ## Create a sketcher (wire or face), following the textual description,
454 # passed through \a theCommand argument. \n
455 # For format of the description string see the previous method.\n
456 # @param theCommand String, defining the sketcher in local
457 # coordinates of the working plane.
458 # @param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
459 # @return New GEOM_Object, containing the created wire.
460 def MakeSketcherOnPlane(theCommand, theWorkingPlane):
461 anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
462 if CurvesOp.IsDone() == 0:
463 print "MakeSketcher : ", CurvesOp.GetErrorCode()
466 # -----------------------------------------------------------------------------
467 # Create 3D Primitives
468 # -----------------------------------------------------------------------------
470 ## Create a box by coordinates of two opposite vertices.
472 # Example: see GEOM_TestAll.py
473 def MakeBox(x1,y1,z1,x2,y2,z2):
474 pnt1 = MakeVertex(x1,y1,z1)
475 pnt2 = MakeVertex(x2,y2,z2)
476 return MakeBoxTwoPnt(pnt1,pnt2)
478 ## Create a box with specified dimensions along the coordinate axes
479 # and with edges, parallel to the coordinate axes.
480 # Center of the box will be at point (DX/2, DY/2, DZ/2).
481 # @param theDX Length of Box edges, parallel to OX axis.
482 # @param theDY Length of Box edges, parallel to OY axis.
483 # @param theDZ Length of Box edges, parallel to OZ axis.
484 # @return New GEOM_Object, containing the created box.
486 # Example: see GEOM_TestAll.py
487 def MakeBoxDXDYDZ(theDX, theDY, theDZ):
488 anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
489 if PrimOp.IsDone() == 0:
490 print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode()
493 ## Create a box with two specified opposite vertices,
494 # and with edges, parallel to the coordinate axes
495 # @param thePnt1 First of two opposite vertices.
496 # @param thePnt2 Second of two opposite vertices.
497 # @return New GEOM_Object, containing the created box.
499 # Example: see GEOM_TestAll.py
500 def MakeBoxTwoPnt(thePnt1, thePnt2):
501 anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
502 if PrimOp.IsDone() == 0:
503 print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode()
506 ## Create a cylinder with given base point, axis, radius and height.
507 # @param thePnt Central point of cylinder base.
508 # @param theAxis Cylinder axis.
509 # @param theR Cylinder radius.
510 # @param theH Cylinder height.
511 # @return New GEOM_Object, containing the created cylinder.
513 # Example: see GEOM_TestAll.py
514 def MakeCylinder(thePnt, theAxis, theR, theH):
515 anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
516 if PrimOp.IsDone() == 0:
517 print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode()
520 ## Create a cylinder with given radius and height at
521 # the origin of coordinate system. Axis of the cylinder
522 # will be collinear to the OZ axis of the coordinate system.
523 # @param theR Cylinder radius.
524 # @param theH Cylinder height.
525 # @return New GEOM_Object, containing the created cylinder.
527 # Example: see GEOM_TestAll.py
528 def MakeCylinderRH(theR, theH):
529 anObj = PrimOp.MakeCylinderRH(theR, theH)
530 if PrimOp.IsDone() == 0:
531 print "MakeCylinderRH : ", PrimOp.GetErrorCode()
534 ## Create a sphere with given center and radius.
535 # @param thePnt Sphere center.
536 # @param theR Sphere radius.
537 # @return New GEOM_Object, containing the created sphere.
539 # Example: see GEOM_TestAll.py
540 def MakeSpherePntR(thePnt, theR):
541 anObj = PrimOp.MakeSpherePntR(thePnt, theR)
542 if PrimOp.IsDone() == 0:
543 print "MakeSpherePntR : ", PrimOp.GetErrorCode()
546 ## Create a sphere with given center and radius.
547 # @param x,y,z Coordinates of sphere center.
548 # @param theR Sphere radius.
549 # @return New GEOM_Object, containing the created sphere.
551 # Example: see GEOM_TestAll.py
552 def MakeSphere(x, y, z, theR):
553 point = MakeVertex(x, y, z)
554 anObj = MakeSpherePntR(point, theR)
557 ## Create a sphere with given radius at the origin of coordinate system.
558 # @param theR Sphere radius.
559 # @return New GEOM_Object, containing the created sphere.
561 # Example: see GEOM_TestAll.py
562 def MakeSphereR(theR):
563 anObj = PrimOp.MakeSphereR(theR)
564 if PrimOp.IsDone() == 0:
565 print "MakeSphereR : ", PrimOp.GetErrorCode()
568 ## Create a cone with given base point, axis, height and radiuses.
569 # @param thePnt Central point of the first cone base.
570 # @param theAxis Cone axis.
571 # @param theR1 Radius of the first cone base.
572 # @param theR2 Radius of the second cone base.
573 # \note If both radiuses are non-zero, the cone will be truncated.
574 # \note If the radiuses are equal, a cylinder will be created instead.
575 # @param theH Cone height.
576 # @return New GEOM_Object, containing the created cone.
578 # Example: see GEOM_TestAll.py
579 def MakeCone(thePnt, theAxis, theR1, theR2, theH):
580 anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
581 if PrimOp.IsDone() == 0:
582 print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode()
585 ## Create a cone with given height and radiuses at
586 # the origin of coordinate system. Axis of the cone will
587 # be collinear to the OZ axis of the coordinate system.
588 # @param theR1 Radius of the first cone base.
589 # @param theR2 Radius of the second cone base.
590 # \note If both radiuses are non-zero, the cone will be truncated.
591 # \note If the radiuses are equal, a cylinder will be created instead.
592 # @param theH Cone height.
593 # @return New GEOM_Object, containing the created cone.
595 # Example: see GEOM_TestAll.py
596 def MakeConeR1R2H(theR1, theR2, theH):
597 anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH)
598 if PrimOp.IsDone() == 0:
599 print "MakeConeR1R2H : ", PrimOp.GetErrorCode()
602 ## Create a torus with given center, normal vector and radiuses.
603 # @param thePnt Torus central point.
604 # @param theVec Torus axis of symmetry.
605 # @param theRMajor Torus major radius.
606 # @param theRMinor Torus minor radius.
607 # @return New GEOM_Object, containing the created torus.
609 # Example: see GEOM_TestAll.py
610 def MakeTorus(thePnt, theVec, theRMajor, theRMinor):
611 anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
612 if PrimOp.IsDone() == 0:
613 print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode()
616 ## Create a torus with given radiuses at the origin of coordinate system.
617 # @param theRMajor Torus major radius.
618 # @param theRMinor Torus minor radius.
619 # @return New GEOM_Object, containing the created torus.
621 # Example: see GEOM_TestAll.py
622 def MakeTorusRR(theRMajor, theRMinor):
623 anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor)
624 if PrimOp.IsDone() == 0:
625 print "MakeTorusRR : ", PrimOp.GetErrorCode()
628 ## Create a shape by extrusion of the base shape along a vector, defined by two points.
629 # @param theBase Base shape to be extruded.
630 # @param thePoint1 First end of extrusion vector.
631 # @param thePoint2 Second end of extrusion vector.
632 # @return New GEOM_Object, containing the created prism.
634 # Example: see GEOM_TestAll.py
635 def MakePrism(theBase, thePoint1, thePoint2):
636 anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
637 if PrimOp.IsDone() == 0:
638 print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
641 ## Create a shape by extrusion of the base shape along the vector,
642 # i.e. all the space, transfixed by the base shape during its translation
643 # along the vector on the given distance.
644 # @param theBase Base shape to be extruded.
645 # @param theVec Direction of extrusion.
646 # @param theH Prism dimension along theVec.
647 # @return New GEOM_Object, containing the created prism.
649 # Example: see GEOM_TestAll.py
650 def MakePrismVecH(theBase, theVec, theH):
651 anObj = PrimOp.MakePrismVecH(theBase, theVec, theH)
652 if PrimOp.IsDone() == 0:
653 print "MakePrismVecH : ", PrimOp.GetErrorCode()
656 ## Create a shape by extrusion of the base shape along
657 # the path shape. The path shape can be a wire or an edge.
658 # @param theBase Base shape to be extruded.
659 # @param thePath Path shape to extrude the base shape along it.
660 # @return New GEOM_Object, containing the created pipe.
662 # Example: see GEOM_TestAll.py
663 def MakePipe(theBase, thePath):
664 anObj = PrimOp.MakePipe(theBase, thePath)
665 if PrimOp.IsDone() == 0:
666 print "MakePipe : ", PrimOp.GetErrorCode()
669 ## Create a shape by revolution of the base shape around the axis
670 # on the given angle, i.e. all the space, transfixed by the base
671 # shape during its rotation around the axis on the given angle.
672 # @param theBase Base shape to be rotated.
673 # @param theAxis Rotation axis.
674 # @param theAngle Rotation angle in radians.
675 # @return New GEOM_Object, containing the created revolution.
677 # Example: see GEOM_TestAll.py
678 def MakeRevolution(theBase, theAxis, theAngle):
679 anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
680 if PrimOp.IsDone() == 0:
681 print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
684 ## Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices.
685 # @param theSeqSections - set of specified sections.
686 # @param theModeSolid - mode defining building solid or shell
687 # @param thePreci - precision 3D used for smoothing by default 1.e-6
688 # @param theRuled - mode defining type of the result surfaces (ruled or smoothed).
689 # @return New GEOM_Object, containing the created shell or solid.
691 # Example: see GEOM_TestAll.py
692 def MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled):
693 anObj = PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled)
694 if PrimOp.IsDone() == 0:
695 print "MakeThruSections : ", PrimOp.GetErrorCode()
698 ## Create a shape by extrusion of the profile shape along
699 # the path shape. The path shape can be a wire or an edge.
700 # the several profiles can be specified in the several locations of path.
701 # @param theSeqBases - list of Bases shape to be extruded.
702 # @param theLocations - list of locations on the path corresponding
703 # specified list of the Bases shapes. Number of locations
704 # should be equal to number of bases or list of locations can be empty.
705 # @param thePath - Path shape to extrude the base shape along it.
706 # @param theWithContact - the mode defining that the section is translated to be in
707 # contact with the spine.
708 # @param - WithCorrection - defining that the section is rotated to be
709 # orthogonal to the spine tangent in the correspondent point
710 # @return New GEOM_Object, containing the created pipe.
712 # Example: see GEOM_TestAll.py
713 def MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection):
714 anObj = PrimOp.MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection)
715 if PrimOp.IsDone() == 0:
716 print "MakePipeWithDifferentSections : ", PrimOp.GetErrorCode()
719 # -----------------------------------------------------------------------------
721 # -----------------------------------------------------------------------------
723 ## Create a linear edge with specified ends.
724 # @param thePnt1 Point for the first end of edge.
725 # @param thePnt2 Point for the second end of edge.
726 # @return New GEOM_Object, containing the created edge.
728 # Example: see GEOM_TestAll.py
729 def MakeEdge(thePnt1, thePnt2):
730 anObj = ShapesOp.MakeEdge(thePnt1, thePnt2)
731 if ShapesOp.IsDone() == 0:
732 print "MakeEdge : ", ShapesOp.GetErrorCode()
735 ## Create a wire from the set of edges and wires.
736 # @param theEdgesAndWires List of edges and/or wires.
737 # @return New GEOM_Object, containing the created wire.
739 # Example: see GEOM_TestAll.py
740 def MakeWire(theEdgesAndWires):
741 anObj = ShapesOp.MakeWire(theEdgesAndWires)
742 if ShapesOp.IsDone() == 0:
743 print "MakeWire : ", ShapesOp.GetErrorCode()
746 ## Create a face on the given wire.
747 # @param theWire closed Wire or Edge to build the face on.
748 # @param isPlanarWanted If TRUE, only planar face will be built.
749 # If impossible, NULL object will be returned.
750 # @return New GEOM_Object, containing the created face.
752 # Example: see GEOM_TestAll.py
753 def MakeFace(theWire, isPlanarWanted):
754 anObj = ShapesOp.MakeFace(theWire, isPlanarWanted)
755 if ShapesOp.IsDone() == 0:
756 print "MakeFace : ", ShapesOp.GetErrorCode()
759 ## Create a face on the given wires set.
760 # @param theWires List of closed wires or edges to build the face on.
761 # @param isPlanarWanted If TRUE, only planar face will be built.
762 # If impossible, NULL object will be returned.
763 # @return New GEOM_Object, containing the created face.
765 # Example: see GEOM_TestAll.py
766 def MakeFaceWires(theWires, isPlanarWanted):
767 anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
768 if ShapesOp.IsDone() == 0:
769 print "MakeFaceWires : ", ShapesOp.GetErrorCode()
772 ## Shortcut to MakeFaceWires()
774 # Example: see GEOM_TestOthers.py
775 def MakeFaces(theWires, isPlanarWanted):
776 anObj = MakeFaceWires(theWires, isPlanarWanted)
779 ## Create a shell from the set of faces and shells.
780 # @param theFacesAndShells List of faces and/or shells.
781 # @return New GEOM_Object, containing the created shell.
783 # Example: see GEOM_TestAll.py
784 def MakeShell(theFacesAndShells):
785 anObj = ShapesOp.MakeShell(theFacesAndShells)
786 if ShapesOp.IsDone() == 0:
787 print "MakeShell : ", ShapesOp.GetErrorCode()
790 ## Create a solid, bounded by the given shells.
791 # @param theShells Sequence of bounding shells.
792 # @return New GEOM_Object, containing the created solid.
794 # Example: see GEOM_TestAll.py
795 def MakeSolid(theShells):
796 anObj = ShapesOp.MakeSolidShells(theShells)
797 if ShapesOp.IsDone() == 0:
798 print "MakeSolid : ", ShapesOp.GetErrorCode()
801 ## Create a compound of the given shapes.
802 # @param theShapes List of shapes to put in compound.
803 # @return New GEOM_Object, containing the created compound.
805 # Example: see GEOM_TestAll.py
806 def MakeCompound(theShapes):
807 anObj = ShapesOp.MakeCompound(theShapes)
808 if ShapesOp.IsDone() == 0:
809 print "MakeCompound : ", ShapesOp.GetErrorCode()
812 ## Gives quantity of faces in the given shape.
813 # @param theShape Shape to count faces of.
814 # @return Quantity of faces.
816 # Example: see GEOM_TestOthers.py
817 def NumberOfFaces(theShape):
818 nb_faces = ShapesOp.NumberOfFaces(theShape)
819 if ShapesOp.IsDone() == 0:
820 print "NumberOfFaces : ", ShapesOp.GetErrorCode()
823 ## Gives quantity of edges in the given shape.
824 # @param theShape Shape to count edges of.
825 # @return Quantity of edges.
827 # Example: see GEOM_TestOthers.py
828 def NumberOfEdges(theShape):
829 nb_edges = ShapesOp.NumberOfEdges(theShape)
830 if ShapesOp.IsDone() == 0:
831 print "NumberOfEdges : ", ShapesOp.GetErrorCode()
834 ## Reverses an orientation the given shape.
835 # @param theShape Shape to be reversed.
836 # @return The reversed copy of theShape.
838 # Example: see GEOM_TestAll.py
839 def ChangeOrientation(theShape):
840 anObj = ShapesOp.ChangeOrientation(theShape)
841 if ShapesOp.IsDone() == 0:
842 print "ChangeOrientation : ", ShapesOp.GetErrorCode()
845 ## Shortcut to ChangeOrientation()
847 # Example: see GEOM_TestOthers.py
848 def OrientationChange(theShape):
849 anObj = ChangeOrientation(theShape)
852 ## Retrieve all free faces from the given shape.
853 # Free face is a face, which is not shared between two shells of the shape.
854 # @param theShape Shape to find free faces in.
855 # @return List of IDs of all free faces, contained in theShape.
857 # Example: see GEOM_TestOthers.py
858 def GetFreeFacesIDs(theShape):
859 anIDs = ShapesOp.GetFreeFacesIDs(theShape)
860 if ShapesOp.IsDone() == 0:
861 print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode()
864 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
865 # @param theShape1 Shape to find sub-shapes in.
866 # @param theShape2 Shape to find shared sub-shapes with.
867 # @param theShapeType Type of sub-shapes to be retrieved.
868 # @return List of sub-shapes of theShape1, shared with theShape2.
870 # Example: see GEOM_TestOthers.py
871 def GetSharedShapes(theShape1, theShape2, theShapeType):
872 aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
873 if ShapesOp.IsDone() == 0:
874 print "GetSharedShapes : ", ShapesOp.GetErrorCode()
877 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
878 # the specified plane by the certain way, defined through \a theState parameter.
879 # @param theShape Shape to find sub-shapes of.
880 # @param theShapeType Type of sub-shapes to be retrieved.
881 # @param theAx1 Vector (or line, or linear edge), specifying normal
882 # direction and location of the plane to find shapes on.
883 # @param theState The state of the subshapes to find. It can be one of
884 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
885 # @return List of all found sub-shapes.
887 # Example: see GEOM_TestOthers.py
888 def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
889 aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
890 if ShapesOp.IsDone() == 0:
891 print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
894 ## Works like the above method, but returns list of sub-shapes indices
896 # Example: see GEOM_TestOthers.py
897 def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
898 aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
899 if ShapesOp.IsDone() == 0:
900 print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
903 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
904 # the specified plane by the certain way, defined through \a theState parameter.
905 # @param theShape Shape to find sub-shapes of.
906 # @param theShapeType Type of sub-shapes to be retrieved.
907 # @param theAx1 Vector (or line, or linear edge), specifying normal
908 # direction of the plane to find shapes on.
909 # @param thePnt Point specifying location of the plane to find shapes on.
910 # @param theState The state of the subshapes to find. It can be one of
911 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
912 # @return List of all found sub-shapes.
914 # Example: see GEOM_TestOthers.py
915 def GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState):
916 aList = ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
917 if ShapesOp.IsDone() == 0:
918 print "GetShapesOnPlaneWithLocation : ", ShapesOp.GetErrorCode()
921 ## Works like the above method, but returns list of sub-shapes indices
923 # Example: see GEOM_TestOthers.py
924 def GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState):
925 aList = ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
926 if ShapesOp.IsDone() == 0:
927 print "GetShapesOnPlaneWithLocationIDs : ", ShapesOp.GetErrorCode()
930 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
931 # the specified cylinder by the certain way, defined through \a theState parameter.
932 # @param theShape Shape to find sub-shapes of.
933 # @param theShapeType Type of sub-shapes to be retrieved.
934 # @param theAxis Vector (or line, or linear edge), specifying
935 # axis of the cylinder to find shapes on.
936 # @param theRadius Radius of the cylinder to find shapes on.
937 # @param theState The state of the subshapes to find. It can be one of
938 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
939 # @return List of all found sub-shapes.
941 # Example: see GEOM_TestOthers.py
942 def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
943 aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
944 if ShapesOp.IsDone() == 0:
945 print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
948 ## Works like the above method, but returns list of sub-shapes indices
950 # Example: see GEOM_TestOthers.py
951 def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
952 aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
953 if ShapesOp.IsDone() == 0:
954 print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
957 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
958 # the specified sphere by the certain way, defined through \a theState parameter.
959 # @param theShape Shape to find sub-shapes of.
960 # @param theShapeType Type of sub-shapes to be retrieved.
961 # @param theCenter Point, specifying center of the sphere to find shapes on.
962 # @param theRadius Radius of the sphere to find shapes on.
963 # @param theState The state of the subshapes to find. It can be one of
964 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
965 # @return List of all found sub-shapes.
967 # Example: see GEOM_TestOthers.py
968 def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
969 aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
970 if ShapesOp.IsDone() == 0:
971 print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
974 ## Works like the above method, but returns list of sub-shapes indices
976 # Example: see GEOM_TestOthers.py
977 def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
978 aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
979 if ShapesOp.IsDone() == 0:
980 print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
983 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
984 # the specified quadrangle by the certain way, defined through \a theState parameter.
985 # @param theShape Shape to find sub-shapes of.
986 # @param theShapeType Type of sub-shapes to be retrieved.
987 # @param theTopLeftPoint Point, specifying top left corner of a quadrangle
988 # @param theTopRigthPoint Point, specifying top right corner of a quadrangle
989 # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
990 # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
991 # @param theState The state of the subshapes to find. It can be one of
992 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
993 # @return List of all found sub-shapes.
995 # Example: see GEOM_TestOthers.py
996 def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
997 aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
998 if ShapesOp.IsDone() == 0:
999 print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
1002 ## Works like the above method, but returns list of sub-shapes indices
1004 # Example: see GEOM_TestOthers.py
1005 def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1006 aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1007 if ShapesOp.IsDone() == 0:
1008 print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
1011 ## Get sub-shape(s) of theShapeWhere, which are
1012 # coincident with \a theShapeWhat or could be a part of it.
1013 # @param theShapeWhere Shape to find sub-shapes of.
1014 # @param theShapeWhat Shape, specifying what to find.
1015 # @return Group of all found sub-shapes or a single found sub-shape.
1017 # Example: see GEOM_TestOthers.py
1018 def GetInPlace(theShapeWhere, theShapeWhat):
1019 anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1020 if ShapesOp.IsDone() == 0:
1021 print "GetInPlace : ", ShapesOp.GetErrorCode()
1024 ## Get sub-shape of theShapeWhere, which is
1025 # equal to \a theShapeWhat.
1026 # @param theShapeWhere Shape to find sub-shape of.
1027 # @param theShapeWhat Shape, specifying what to find.
1028 # @return New GEOM_Object for found sub-shape.
1030 def GetSame(theShapeWhere, theShapeWhat):
1031 anObj = ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1032 if ShapesOp.IsDone() == 0:
1033 print "GetSame : ", ShapesOp.GetErrorCode()
1036 # -----------------------------------------------------------------------------
1037 # Access to sub-shapes by their unique IDs inside the main shape.
1038 # -----------------------------------------------------------------------------
1040 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1041 # of <aShape>, selected by their unique IDs inside <aShape>
1043 # Example: see GEOM_TestAll.py
1044 def GetSubShape(aShape, ListOfID):
1045 anObj = geom.AddSubShape(aShape,ListOfID)
1048 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1050 # Example: see GEOM_TestAll.py
1051 def GetSubShapeID(aShape, aSubShape):
1052 anID = LocalOp.GetSubShapeIndex(aShape, aSubShape)
1053 if LocalOp.IsDone() == 0:
1054 print "GetSubShapeIndex : ", LocalOp.GetErrorCode()
1057 # -----------------------------------------------------------------------------
1059 # -----------------------------------------------------------------------------
1061 ## Explode a shape on subshapes of a given type.
1062 # @param theShape Shape to be exploded.
1063 # @param theShapeType Type of sub-shapes to be retrieved.
1064 # @return List of sub-shapes of type theShapeType, contained in theShape.
1066 # Example: see GEOM_TestAll.py
1067 def SubShapeAll(aShape, aType):
1068 ListObj = ShapesOp.MakeExplode(aShape,aType,0)
1069 if ShapesOp.IsDone() == 0:
1070 print "MakeExplode : ", ShapesOp.GetErrorCode()
1073 ## Explode a shape on subshapes of a given type.
1074 # @param theShape Shape to be exploded.
1075 # @param theShapeType Type of sub-shapes to be retrieved.
1076 # @return List of IDs of sub-shapes.
1077 def SubShapeAllIDs(aShape, aType):
1078 ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0)
1079 if ShapesOp.IsDone() == 0:
1080 print "SubShapeAllIDs : ", ShapesOp.GetErrorCode()
1083 ## Explode a shape on subshapes of a given type.
1084 # Sub-shapes will be sorted by coordinates of their gravity centers.
1085 # @param theShape Shape to be exploded.
1086 # @param theShapeType Type of sub-shapes to be retrieved.
1087 # @return List of sub-shapes of type theShapeType, contained in theShape.
1089 # Example: see GEOM_TestAll.py
1090 def SubShapeAllSorted(aShape, aType):
1091 ListObj = ShapesOp.MakeExplode(aShape,aType,1)
1092 if ShapesOp.IsDone() == 0:
1093 print "MakeExplode : ", ShapesOp.GetErrorCode()
1096 ## Explode a shape on subshapes of a given type.
1097 # Sub-shapes will be sorted by coordinates of their gravity centers.
1098 # @param theShape Shape to be exploded.
1099 # @param theShapeType Type of sub-shapes to be retrieved.
1100 # @return List of IDs of sub-shapes.
1101 def SubShapeAllSortedIDs(aShape, aType):
1102 ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1)
1103 if ShapesOp.IsDone() == 0:
1104 print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode()
1107 ## Obtain a compound of sub-shapes of <aShape>,
1108 # selected by they indices in list of all sub-shapes of type <aType>.
1109 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1111 # Example: see GEOM_TestAll.py
1112 def SubShape(aShape, aType, ListOfInd):
1114 AllShapeList = SubShapeAll(aShape, aType)
1115 for ind in ListOfInd:
1116 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1117 anObj = GetSubShape(aShape, ListOfIDs)
1120 ## Obtain a compound of sub-shapes of <aShape>,
1121 # selected by they indices in sorted list of all sub-shapes of type <aType>.
1122 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1124 # Example: see GEOM_TestAll.py
1125 def SubShapeSorted(aShape, aType, ListOfInd):
1127 AllShapeList = SubShapeAllSorted(aShape, aType)
1128 for ind in ListOfInd:
1129 ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1]))
1130 anObj = GetSubShape(aShape, ListOfIDs)
1133 # -----------------------------------------------------------------------------
1134 # Healing operations
1135 # -----------------------------------------------------------------------------
1137 ## Apply a sequence of Shape Healing operators to the given object.
1138 # @param theShape Shape to be processed.
1139 # @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1140 # @param theParameters List of names of parameters
1141 # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1142 # @param theValues List of values of parameters, in the same order
1143 # as parameters are listed in \a theParameters list.
1144 # @return New GEOM_Object, containing processed shape.
1146 # Example: see GEOM_TestHealing.py
1147 def ProcessShape(theShape, theOperators, theParameters, theValues):
1148 anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1149 if HealOp.IsDone() == 0:
1150 print "ProcessShape : ", HealOp.GetErrorCode()
1153 ## Remove faces from the given object (shape).
1154 # @param theObject Shape to be processed.
1155 # @param theFaces Indices of faces to be removed, if EMPTY then the method
1156 # removes ALL faces of the given object.
1157 # @return New GEOM_Object, containing processed shape.
1159 # Example: see GEOM_TestHealing.py
1160 def SuppressFaces(theObject, theFaces):
1161 anObj = HealOp.SuppressFaces(theObject, theFaces)
1162 if HealOp.IsDone() == 0:
1163 print "SuppressFaces : ", HealOp.GetErrorCode()
1166 ## Sewing of some shapes into single shape.
1168 # Example: see GEOM_TestHealing.py
1169 def MakeSewing(ListShape, theTolerance):
1170 comp = MakeCompound(ListShape)
1171 anObj = Sew(comp, theTolerance)
1174 ## Sewing of the given object.
1175 # @param theObject Shape to be processed.
1176 # @param theTolerance Required tolerance value.
1177 # @return New GEOM_Object, containing processed shape.
1179 # Example: see MakeSewing() above
1180 def Sew(theObject, theTolerance):
1181 anObj = HealOp.Sew(theObject, theTolerance)
1182 if HealOp.IsDone() == 0:
1183 print "Sew : ", HealOp.GetErrorCode()
1186 ## Remove internal wires and edges from the given object (face).
1187 # @param theObject Shape to be processed.
1188 # @param theWires Indices of wires to be removed, if EMPTY then the method
1189 # removes ALL internal wires of the given object.
1190 # @return New GEOM_Object, containing processed shape.
1192 # Example: see GEOM_TestHealing.py
1193 def SuppressInternalWires(theObject, theWires):
1194 anObj = HealOp.RemoveIntWires(theObject, theWires)
1195 if HealOp.IsDone() == 0:
1196 print "SuppressInternalWires : ", HealOp.GetErrorCode()
1199 ## Remove internal closed contours (holes) from the given object.
1200 # @param theObject Shape to be processed.
1201 # @param theWires Indices of wires to be removed, if EMPTY then the method
1202 # removes ALL internal holes of the given object
1203 # @return New GEOM_Object, containing processed shape.
1205 # Example: see GEOM_TestHealing.py
1206 def SuppressHoles(theObject, theWires):
1207 anObj = HealOp.FillHoles(theObject, theWires)
1208 if HealOp.IsDone() == 0:
1209 print "SuppressHoles : ", HealOp.GetErrorCode()
1212 ## Close an open wire.
1213 # @param theObject Shape to be processed.
1214 # @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1215 # if -1, then theObject itself is a wire.
1216 # @param isCommonVertex If TRUE : closure by creation of a common vertex,
1217 # If FALS : closure by creation of an edge between ends.
1218 # @return New GEOM_Object, containing processed shape.
1220 # Example: see GEOM_TestHealing.py
1221 def CloseContour(theObject, theWires, isCommonVertex):
1222 anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex)
1223 if HealOp.IsDone() == 0:
1224 print "CloseContour : ", HealOp.GetErrorCode()
1227 ## Addition of a point to a given edge object.
1228 # @param theObject Shape to be processed.
1229 # @param theEdgeIndex Index of edge to be divided within theObject's shape,
1230 # if -1, then theObject itself is the edge.
1231 # @param theValue Value of parameter on edge or length parameter,
1232 # depending on \a isByParameter.
1233 # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1234 # if FALSE : \a theValue is treated as a length parameter [0..1]
1235 # @return New GEOM_Object, containing processed shape.
1237 # Example: see GEOM_TestHealing.py
1238 def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter):
1239 anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1240 if HealOp.IsDone() == 0:
1241 print "DivideEdge : ", HealOp.GetErrorCode()
1244 ## Change orientation of the given object.
1245 # @param theObject Shape to be processed.
1246 # @update given shape
1247 def ChangeOrientationShell(theObject):
1248 theObject = HealOp.ChangeOrientation(theObject)
1249 if HealOp.IsDone() == 0:
1250 print "ChangeOrientation : ", HealOp.GetErrorCode()
1252 ## Change orientation of the given object.
1253 # @param theObject Shape to be processed.
1254 # @return New GEOM_Object, containing processed shape.
1255 def ChangeOrientationShellCopy(theObject):
1256 anObj = HealOp.ChangeOrientationCopy(theObject)
1257 if HealOp.IsDone() == 0:
1258 print "ChangeOrientation : ", HealOp.GetErrorCode()
1261 ## Get a list of wires (wrapped in GEOM_Object-s),
1262 # that constitute a free boundary of the given shape.
1263 # @param theObject Shape to get free boundary of.
1264 # @return [status, theClosedWires, theOpenWires]
1265 # status: FALSE, if an error(s) occured during the method execution.
1266 # theClosedWires: Closed wires on the free boundary of the given shape.
1267 # theOpenWires: Open wires on the free boundary of the given shape.
1269 # Example: see GEOM_TestHealing.py
1270 def GetFreeBoundary(theObject):
1271 anObj = HealOp.GetFreeBoundary(theObject)
1272 if HealOp.IsDone() == 0:
1273 print "GetFreeBoundaries : ", HealOp.GetErrorCode()
1276 # -----------------------------------------------------------------------------
1277 # Create advanced objects
1278 # -----------------------------------------------------------------------------
1280 ## Create a copy of the given object
1282 # Example: see GEOM_TestAll.py
1283 def MakeCopy(theOriginal):
1284 anObj = InsertOp.MakeCopy(theOriginal)
1285 if InsertOp.IsDone() == 0:
1286 print "MakeCopy : ", InsertOp.GetErrorCode()
1289 ## Create a filling from the given compound of contours.
1290 # @param theShape the compound of contours
1291 # @param theMinDeg a minimal degree
1292 # @param theMaxDeg a maximal degree
1293 # @param theTol2D a 2d tolerance
1294 # @param theTol3D a 3d tolerance
1295 # @param theNbIter a number of iteration
1296 # @return New GEOM_Object, containing the created filling surface.
1298 # Example: see GEOM_TestAll.py
1299 def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter):
1300 anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter)
1301 if PrimOp.IsDone() == 0:
1302 print "MakeFilling : ", PrimOp.GetErrorCode()
1305 ## Replace coincident faces in theShape by one face.
1306 # @param theShape Initial shape.
1307 # @param theTolerance Maximum distance between faces, which can be considered as coincident.
1308 # @return New GEOM_Object, containing a copy of theShape without coincident faces.
1310 # Example: see GEOM_Spanner.py
1311 def MakeGlueFaces(theShape, theTolerance):
1312 anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance)
1313 if ShapesOp.IsDone() == 0:
1314 print "MakeGlueFaces : ", ShapesOp.GetErrorCode()
1317 # -----------------------------------------------------------------------------
1318 # Boolean (Common, Cut, Fuse, Section)
1319 # -----------------------------------------------------------------------------
1321 ## Perform one of boolean operations on two given shapes.
1322 # @param theShape1 First argument for boolean operation.
1323 # @param theShape2 Second argument for boolean operation.
1324 # @param theOperation Indicates the operation to be done:
1325 # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1326 # @return New GEOM_Object, containing the result shape.
1328 # Example: see GEOM_TestAll.py
1329 def MakeBoolean(theShape1, theShape2, theOperation):
1330 anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1331 if BoolOp.IsDone() == 0:
1332 print "MakeBoolean : ", BoolOp.GetErrorCode()
1335 ## Shortcut to MakeBoolean(s1, s2, 1)
1337 # Example: see GEOM_TestOthers.py
1338 def MakeCommon(s1, s2):
1339 return MakeBoolean(s1, s2, 1)
1341 ## Shortcut to MakeBoolean(s1, s2, 2)
1343 # Example: see GEOM_TestOthers.py
1344 def MakeCut(s1, s2):
1345 return MakeBoolean(s1, s2, 2)
1347 ## Shortcut to MakeBoolean(s1, s2, 3)
1349 # Example: see GEOM_TestOthers.py
1350 def MakeFuse(s1, s2):
1351 return MakeBoolean(s1, s2, 3)
1353 ## Shortcut to MakeBoolean(s1, s2, 4)
1355 # Example: see GEOM_TestOthers.py
1356 def MakeSection(s1, s2):
1357 return MakeBoolean(s1, s2, 4)
1359 ## Perform explode of compound
1360 # Auxilary method for MakePartition
1361 def ExplodeCompound(aComp):
1363 shapes = SubShapeAll(aComp,ShapeType["SHAPE"])
1365 for i in range(0,nbss):
1366 if shapes[i].GetShapeType()==GEOM.COMPOUND:
1367 ResListShapes.extend(ExplodeCompound(shapes[i]))
1369 ResListShapes.append(shapes[i])
1372 return ResListShapes
1374 ## Perform partition operation.
1375 # @param ListShapes Shapes to be intersected.
1376 # @param ListTools Shapes to intersect theShapes.
1377 # !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1378 # in order to avoid possible intersection between shapes from
1381 # After implementation new version of PartitionAlgo (October 2006)
1382 # other parameters are ignored by current functionality. They are kept
1383 # in this function only for support old versions.
1384 # Ignored parameters:
1385 # @param ListKeepInside Shapes, outside which the results will be deleted.
1386 # Each shape from theKeepInside must belong to theShapes also.
1387 # @param ListRemoveInside Shapes, inside which the results will be deleted.
1388 # Each shape from theRemoveInside must belong to theShapes also.
1389 # @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1390 # @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1391 # @param ListMaterials Material indices for each shape. Make sence,
1392 # only if theRemoveWebs is TRUE.
1394 # @return New GEOM_Object, containing the result shapes.
1396 # Example: see GEOM_TestAll.py
1397 def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1398 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1401 nbs = len(ListShapes)
1402 for i in range(0,nbs):
1403 if ListShapes[i].GetShapeType()==GEOM.COMPOUND:
1405 NewListShapes.extend(ExplodeCompound(ListShapes[i]))
1406 else: NewListShapes.append(ListShapes[i])
1410 nbs = len(ListTools)
1411 for i in range(0,nbs):
1412 if ListTools[i].GetShapeType()==GEOM.COMPOUND:
1414 NewListTools.extend(ExplodeCompound(ListTools[i]))
1415 else: NewListTools.append(ListTools[i])
1418 return MakePartitionNonSelfIntersectedShape(NewListShapes, NewListTools,
1419 ListKeepInside, ListRemoveInside,
1420 Limit, RemoveWebs, ListMaterials)
1422 ## Perform partition operation.
1423 # This method may be useful if it is needed to make a partition for
1424 # compound contains nonintersected shapes. Performance will be better
1425 # since intersection between shapes from compound is not performed.
1427 # Description of all parameters as in previous method MakePartition()
1429 # !!!NOTE: Compounds from ListShapes can not have intersections with each
1430 # other and compounds from ListTools can not have intersections
1433 # @return New GEOM_Object, containing the result shapes.
1435 def MakePartitionNonSelfIntersectedShape(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1436 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1437 anObj = BoolOp.MakePartition(ListShapes, ListTools,
1438 ListKeepInside, ListRemoveInside,
1439 Limit, RemoveWebs, ListMaterials);
1440 if BoolOp.IsDone() == 0:
1441 print "MakePartition : ", BoolOp.GetErrorCode()
1444 ## Shortcut to MakePartition()
1446 # Example: see GEOM_TestOthers.py
1447 def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1448 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
1449 anObj = MakePartition(ListShapes, ListTools,
1450 ListKeepInside, ListRemoveInside,
1451 Limit, RemoveWebs, ListMaterials);
1454 ## Perform partition of the Shape with the Plane
1455 # @param theShape Shape to be intersected.
1456 # @param thePlane Tool shape, to intersect theShape.
1457 # @return New GEOM_Object, containing the result shape.
1459 # Example: see GEOM_TestAll.py
1460 def MakeHalfPartition(theShape, thePlane):
1461 anObj = BoolOp.MakeHalfPartition(theShape, thePlane)
1462 if BoolOp.IsDone() == 0:
1463 print "MakeHalfPartition : ", BoolOp.GetErrorCode()
1466 # -----------------------------------------------------------------------------
1468 # -----------------------------------------------------------------------------
1470 ## Translate the given object along the vector, specified
1471 # by its end points, creating its copy before the translation.
1472 # @param theObject The object to be translated.
1473 # @param thePoint1 Start point of translation vector.
1474 # @param thePoint2 End point of translation vector.
1475 # @return New GEOM_Object, containing the translated object.
1477 # Example: see GEOM_TestAll.py
1478 def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2):
1479 anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1480 if TrsfOp.IsDone() == 0:
1481 print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode()
1484 ## Translate the given object along the vector, specified
1485 # by its components, creating its copy before the translation.
1486 # @param theObject The object to be translated.
1487 # @param theDX,theDY,theDZ Components of translation vector.
1488 # @return New GEOM_Object, containing the translated object.
1490 # Example: see GEOM_TestAll.py
1491 def MakeTranslation(theObject, theDX, theDY, theDZ):
1492 anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1493 if TrsfOp.IsDone() == 0:
1494 print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode()
1497 ## Translate the given object along the given vector,
1498 # creating its copy before the translation.
1499 # @param theObject The object to be translated.
1500 # @param theVector The translation vector.
1501 # @return New GEOM_Object, containing the translated object.
1503 # Example: see GEOM_TestAll.py
1504 def MakeTranslationVector(theObject, theVector):
1505 anObj = TrsfOp.TranslateVectorCopy(theObject, theVector)
1506 if TrsfOp.IsDone() == 0:
1507 print "TranslateVectorCopy : ", TrsfOp.GetErrorCode()
1510 ## Rotate the given object around the given axis
1511 # on the given angle, creating its copy before the rotatation.
1512 # @param theObject The object to be rotated.
1513 # @param theAxis Rotation axis.
1514 # @param theAngle Rotation angle in radians.
1515 # @return New GEOM_Object, containing the rotated object.
1517 # Example: see GEOM_TestAll.py
1518 def MakeRotation(theObject, theAxis, theAngle):
1519 anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1520 if TrsfOp.IsDone() == 0:
1521 print "RotateCopy : ", TrsfOp.GetErrorCode()
1524 ## Rotate given object around vector perpendicular to plane
1525 # containing three points, creating its copy before the rotatation.
1526 # @param theObject The object to be rotated.
1527 # @param theCentPoint central point - the axis is the vector perpendicular to the plane
1528 # containing the three points.
1529 # @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1530 # @return New GEOM_Object, containing the rotated object.
1532 # Example: see GEOM_TestAll.py
1533 def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
1534 anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1535 if TrsfOp.IsDone() == 0:
1536 print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
1539 ## Scale the given object by the factor, creating its copy before the scaling.
1540 # @param theObject The object to be scaled.
1541 # @param thePoint Center point for scaling.
1542 # @param theFactor Scaling factor value.
1543 # @return New GEOM_Object, containing the scaled shape.
1545 # Example: see GEOM_TestAll.py
1546 def MakeScaleTransform(theObject, thePoint, theFactor):
1547 anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1548 if TrsfOp.IsDone() == 0:
1549 print "ScaleShapeCopy : ", TrsfOp.GetErrorCode()
1552 ## Create an object, symmetrical
1553 # to the given one relatively the given plane.
1554 # @param theObject The object to be mirrored.
1555 # @param thePlane Plane of symmetry.
1556 # @return New GEOM_Object, containing the mirrored shape.
1558 # Example: see GEOM_TestAll.py
1559 def MakeMirrorByPlane(theObject, thePlane):
1560 anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1561 if TrsfOp.IsDone() == 0:
1562 print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode()
1565 ## Create an object, symmetrical
1566 # to the given one relatively the given axis.
1567 # @param theObject The object to be mirrored.
1568 # @param theAxis Axis of symmetry.
1569 # @return New GEOM_Object, containing the mirrored shape.
1571 # Example: see GEOM_TestAll.py
1572 def MakeMirrorByAxis(theObject, theAxis):
1573 anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis)
1574 if TrsfOp.IsDone() == 0:
1575 print "MirrorAxisCopy : ", TrsfOp.GetErrorCode()
1578 ## Create an object, symmetrical
1579 # to the given one relatively the given point.
1580 # @param theObject The object to be mirrored.
1581 # @param thePoint Point of symmetry.
1582 # @return New GEOM_Object, containing the mirrored shape.
1584 # Example: see GEOM_TestAll.py
1585 def MakeMirrorByPoint(theObject, thePoint):
1586 anObj = TrsfOp.MirrorPointCopy(theObject, thePoint)
1587 if TrsfOp.IsDone() == 0:
1588 print "MirrorPointCopy : ", TrsfOp.GetErrorCode()
1591 ## Modify the Location of the given object by LCS,
1592 # creating its copy before the setting.
1593 # @param theObject The object to be displaced.
1594 # @param theStartLCS Coordinate system to perform displacement from it.
1595 # If \a theStartLCS is NULL, displacement
1596 # will be performed from global CS.
1597 # If \a theObject itself is used as \a theStartLCS,
1598 # its location will be changed to \a theEndLCS.
1599 # @param theEndLCS Coordinate system to perform displacement to it.
1600 # @return New GEOM_Object, containing the displaced shape.
1602 # Example: see GEOM_TestAll.py
1603 def MakePosition(theObject, theStartLCS, theEndLCS):
1604 anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1605 if TrsfOp.IsDone() == 0:
1606 print "PositionShapeCopy : ", TrsfOp.GetErrorCode()
1609 ## Create new object as offset of the given one.
1610 # @param theObject The base object for the offset.
1611 # @param theOffset Offset value.
1612 # @return New GEOM_Object, containing the offset object.
1614 # Example: see GEOM_TestAll.py
1615 def MakeOffset(theObject, theOffset):
1616 anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset)
1617 if TrsfOp.IsDone() == 0:
1618 print "OffsetShapeCopy : ", TrsfOp.GetErrorCode()
1621 # -----------------------------------------------------------------------------
1623 # -----------------------------------------------------------------------------
1625 ## Translate the given object along the given vector a given number times
1626 # @param theObject The object to be translated.
1627 # @param theVector Direction of the translation.
1628 # @param theStep Distance to translate on.
1629 # @param theNbTimes Quantity of translations to be done.
1630 # @return New GEOM_Object, containing compound of all
1631 # the shapes, obtained after each translation.
1633 # Example: see GEOM_TestAll.py
1634 def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes):
1635 anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1636 if TrsfOp.IsDone() == 0:
1637 print "MultiTranslate1D : ", TrsfOp.GetErrorCode()
1640 ## Conseqently apply two specified translations to theObject specified number of times.
1641 # @param theObject The object to be translated.
1642 # @param theVector1 Direction of the first translation.
1643 # @param theStep1 Step of the first translation.
1644 # @param theNbTimes1 Quantity of translations to be done along theVector1.
1645 # @param theVector2 Direction of the second translation.
1646 # @param theStep2 Step of the second translation.
1647 # @param theNbTimes2 Quantity of translations to be done along theVector2.
1648 # @return New GEOM_Object, containing compound of all
1649 # the shapes, obtained after each translation.
1651 # Example: see GEOM_TestAll.py
1652 def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1,
1653 theVector2, theStep2, theNbTimes2):
1654 anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1655 theVector2, theStep2, theNbTimes2)
1656 if TrsfOp.IsDone() == 0:
1657 print "MultiTranslate2D : ", TrsfOp.GetErrorCode()
1660 ## Rotate the given object around the given axis a given number times.
1661 # Rotation angle will be 2*PI/theNbTimes.
1662 # @param theObject The object to be rotated.
1663 # @param theAxis The rotation axis.
1664 # @param theNbTimes Quantity of rotations to be done.
1665 # @return New GEOM_Object, containing compound of all the
1666 # shapes, obtained after each rotation.
1668 # Example: see GEOM_TestAll.py
1669 def MultiRotate1D(theObject, theAxis, theNbTimes):
1670 anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1671 if TrsfOp.IsDone() == 0:
1672 print "MultiRotate1D : ", TrsfOp.GetErrorCode()
1675 ## Rotate the given object around the
1676 # given axis on the given angle a given number
1677 # times and multi-translate each rotation result.
1678 # Translation direction passes through center of gravity
1679 # of rotated shape and its projection on the rotation axis.
1680 # @param theObject The object to be rotated.
1681 # @param theAxis Rotation axis.
1682 # @param theAngle Rotation angle in graduces.
1683 # @param theNbTimes1 Quantity of rotations to be done.
1684 # @param theStep Translation distance.
1685 # @param theNbTimes2 Quantity of translations to be done.
1686 # @return New GEOM_Object, containing compound of all the
1687 # shapes, obtained after each transformation.
1689 # Example: see GEOM_TestAll.py
1690 def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1691 anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1692 if TrsfOp.IsDone() == 0:
1693 print "MultiRotate2D : ", TrsfOp.GetErrorCode()
1696 ## The same, as MultiRotate1D(), but axis is given by direction and point
1698 # Example: see GEOM_TestOthers.py
1699 def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
1700 aVec = MakeLine(aPoint,aDir)
1701 anObj = MultiRotate1D(aShape,aVec,aNbTimes)
1704 ## The same, as MultiRotate2D(), but axis is given by direction and point
1706 # Example: see GEOM_TestOthers.py
1707 def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1708 aVec = MakeLine(aPoint,aDir)
1709 anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1712 # -----------------------------------------------------------------------------
1714 # -----------------------------------------------------------------------------
1716 ## Perform a fillet on all edges of the given shape.
1717 # @param theShape Shape, to perform fillet on.
1718 # @param theR Fillet radius.
1719 # @return New GEOM_Object, containing the result shape.
1721 # Example: see GEOM_TestOthers.py
1722 def MakeFilletAll(theShape, theR):
1723 anObj = LocalOp.MakeFilletAll(theShape, theR)
1724 if LocalOp.IsDone() == 0:
1725 print "MakeFilletAll : ", LocalOp.GetErrorCode()
1728 ## Perform a fillet on the specified edges/faces of the given shape
1729 # @param theShape Shape, to perform fillet on.
1730 # @param theR Fillet radius.
1731 # @param theShapeType Type of shapes in <theListShapes>.
1732 # @param theListShapes Global indices of edges/faces to perform fillet on.
1733 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1734 # @return New GEOM_Object, containing the result shape.
1736 # Example: see GEOM_TestAll.py
1737 def MakeFillet(theShape, theR, theShapeType, theListShapes):
1739 if theShapeType == ShapeType["EDGE"]:
1740 anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1742 anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1743 if LocalOp.IsDone() == 0:
1744 print "MakeFillet : ", LocalOp.GetErrorCode()
1747 ## Perform a symmetric chamfer on all edges of the given shape.
1748 # @param theShape Shape, to perform chamfer on.
1749 # @param theD Chamfer size along each face.
1750 # @return New GEOM_Object, containing the result shape.
1752 # Example: see GEOM_TestOthers.py
1753 def MakeChamferAll(theShape, theD):
1754 anObj = LocalOp.MakeChamferAll(theShape, theD)
1755 if LocalOp.IsDone() == 0:
1756 print "MakeChamferAll : ", LocalOp.GetErrorCode()
1759 ## Perform a chamfer on edges, common to the specified faces,
1760 # with distance D1 on the Face1
1761 # @param theShape Shape, to perform chamfer on.
1762 # @param theD1 Chamfer size along \a theFace1.
1763 # @param theD2 Chamfer size along \a theFace2.
1764 # @param theFace1,theFace2 Global indices of two faces of \a theShape.
1765 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1766 # @return New GEOM_Object, containing the result shape.
1768 # Example: see GEOM_TestAll.py
1769 def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2):
1770 anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1771 if LocalOp.IsDone() == 0:
1772 print "MakeChamferEdge : ", LocalOp.GetErrorCode()
1775 ## Perform a chamfer on all edges of the specified faces,
1776 # with distance D1 on the first specified face (if several for one edge)
1777 # @param theShape Shape, to perform chamfer on.
1778 # @param theD1 Chamfer size along face from \a theFaces. If both faces,
1779 # connected to the edge, are in \a theFaces, \a theD1
1780 # will be get along face, which is nearer to \a theFaces beginning.
1781 # @param theD2 Chamfer size along another of two faces, connected to the edge.
1782 # @param theFaces Sequence of global indices of faces of \a theShape.
1783 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1784 # @return New GEOM_Object, containing the result shape.
1786 # Example: see GEOM_TestAll.py
1787 def MakeChamferFaces(theShape, theD1, theD2, theFaces):
1788 anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1789 if LocalOp.IsDone() == 0:
1790 print "MakeChamferFaces : ", LocalOp.GetErrorCode()
1793 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1795 # Example: see GEOM_TestOthers.py
1796 def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
1798 if aShapeType == ShapeType["EDGE"]:
1799 anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1801 anObj = MakeChamferFaces(aShape,d1,d2,ListShape)
1804 ## Perform an Archimde operation on the given shape with given parameters.
1805 # The object presenting the resulting face is returned.
1806 # @param theShape Shape to be put in water.
1807 # @param theWeight Weight og the shape.
1808 # @param theWaterDensity Density of the water.
1809 # @param theMeshDeflection Deflection of the mesh, using to compute the section.
1810 # @return New GEOM_Object, containing a section of \a theShape
1811 # by a plane, corresponding to water level.
1813 # Example: see GEOM_TestAll.py
1814 def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection):
1815 anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1816 if LocalOp.IsDone() == 0:
1817 print "MakeArchimede : ", LocalOp.GetErrorCode()
1820 # -----------------------------------------------------------------------------
1821 # Information objects
1822 # -----------------------------------------------------------------------------
1824 ## Get point coordinates
1827 # Example: see GEOM_TestMeasures.py
1828 def PointCoordinates(Point):
1829 aTuple = MeasuOp.PointCoordinates(Point)
1830 if MeasuOp.IsDone() == 0:
1831 print "PointCoordinates : ", MeasuOp.GetErrorCode()
1834 ## Get summarized length of all wires,
1835 # area of surface and volume of the given shape.
1836 # @param theShape Shape to define properties of.
1837 # @return [theLength, theSurfArea, theVolume]
1838 # theLength: Summarized length of all wires of the given shape.
1839 # theSurfArea: Area of surface of the given shape.
1840 # theVolume: Volume of the given shape.
1842 # Example: see GEOM_TestMeasures.py
1843 def BasicProperties(theShape):
1844 aTuple = MeasuOp.GetBasicProperties(theShape)
1845 if MeasuOp.IsDone() == 0:
1846 print "BasicProperties : ", MeasuOp.GetErrorCode()
1849 ## Get parameters of bounding box of the given shape
1850 # @param theShape Shape to obtain bounding box of.
1851 # @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1852 # Xmin,Xmax: Limits of shape along OX axis.
1853 # Ymin,Ymax: Limits of shape along OY axis.
1854 # Zmin,Zmax: Limits of shape along OZ axis.
1856 # Example: see GEOM_TestMeasures.py
1857 def BoundingBox(theShape):
1858 aTuple = MeasuOp.GetBoundingBox(theShape)
1859 if MeasuOp.IsDone() == 0:
1860 print "BoundingBox : ", MeasuOp.GetErrorCode()
1863 ## Get inertia matrix and moments of inertia of theShape.
1864 # @param theShape Shape to calculate inertia of.
1865 # @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1866 # I(1-3)(1-3): Components of the inertia matrix of the given shape.
1867 # Ix,Iy,Iz: Moments of inertia of the given shape.
1869 # Example: see GEOM_TestMeasures.py
1870 def Inertia(theShape):
1871 aTuple = MeasuOp.GetInertia(theShape)
1872 if MeasuOp.IsDone() == 0:
1873 print "Inertia : ", MeasuOp.GetErrorCode()
1876 ## Get minimal distance between the given shapes.
1877 # @param theShape1,theShape2 Shapes to find minimal distance between.
1878 # @return Value of the minimal distance between the given shapes.
1880 # Example: see GEOM_TestMeasures.py
1881 def MinDistance(theShape1, theShape2):
1882 aTuple = MeasuOp.GetMinDistance(theShape1, theShape2)
1883 if MeasuOp.IsDone() == 0:
1884 print "MinDistance : ", MeasuOp.GetErrorCode()
1887 ## Get min and max tolerances of sub-shapes of theShape
1888 # @param theShape Shape, to get tolerances of.
1889 # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
1890 # FaceMin,FaceMax: Min and max tolerances of the faces.
1891 # EdgeMin,EdgeMax: Min and max tolerances of the edges.
1892 # VertMin,VertMax: Min and max tolerances of the vertices.
1894 # Example: see GEOM_TestMeasures.py
1895 def Tolerance(theShape):
1896 aTuple = MeasuOp.GetTolerance(theShape)
1897 if MeasuOp.IsDone() == 0:
1898 print "Tolerance : ", MeasuOp.GetErrorCode()
1901 ## Obtain description of the given shape (number of sub-shapes of each type)
1902 # @param theShape Shape to be described.
1903 # @return Description of the given shape.
1905 # Example: see GEOM_TestMeasures.py
1906 def WhatIs(theShape):
1907 aDescr = MeasuOp.WhatIs(theShape)
1908 if MeasuOp.IsDone() == 0:
1909 print "WhatIs : ", MeasuOp.GetErrorCode()
1912 ## Get a point, situated at the centre of mass of theShape.
1913 # @param theShape Shape to define centre of mass of.
1914 # @return New GEOM_Object, containing the created point.
1916 # Example: see GEOM_TestMeasures.py
1917 def MakeCDG(theShape):
1918 anObj = MeasuOp.GetCentreOfMass(theShape)
1919 if MeasuOp.IsDone() == 0:
1920 print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
1923 ## Check a topology of the given shape.
1924 # @param theShape Shape to check validity of.
1925 # @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
1926 # if TRUE, the shape's geometry will be checked also.
1927 # @return TRUE, if the shape "seems to be valid".
1928 # If theShape is invalid, prints a description of problem.
1930 # Example: see GEOM_TestMeasures.py
1931 def CheckShape(theShape, theIsCheckGeom = 0):
1933 (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
1935 (IsValid, Status) = MeasuOp.CheckShape(theShape)
1937 if MeasuOp.IsDone() == 0:
1938 print "CheckShape : ", MeasuOp.GetErrorCode()
1944 ## Get position (LCS) of theShape.
1946 # Origin of the LCS is situated at the shape's center of mass.
1947 # Axes of the LCS are obtained from shape's location or,
1948 # if the shape is a planar face, from position of its plane.
1950 # @param theShape Shape to calculate position of.
1951 # @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
1952 # Ox,Oy,Oz: Coordinates of shape's LCS origin.
1953 # Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
1954 # Xx,Xy,Xz: Coordinates of shape's LCS X direction.
1956 # Example: see GEOM_TestMeasures.py
1957 def GetPosition(theShape):
1958 aTuple = MeasuOp.GetPosition(theShape)
1959 if MeasuOp.IsDone() == 0:
1960 print "GetPosition : ", MeasuOp.GetErrorCode()
1963 # -----------------------------------------------------------------------------
1964 # Import/Export objects
1965 # -----------------------------------------------------------------------------
1967 ## Import a shape from the BREP or IGES or STEP file
1968 # (depends on given format) with given name.
1969 # @param theFileName The file, containing the shape.
1970 # @param theFormatName Specify format for the file reading.
1971 # Available formats can be obtained with InsertOp.ImportTranslators() method.
1972 # @return New GEOM_Object, containing the imported shape.
1974 # Example: see GEOM_TestOthers.py
1975 def Import(theFileName, theFormatName):
1976 anObj = InsertOp.Import(theFileName, theFormatName)
1977 if InsertOp.IsDone() == 0:
1978 print "Import : ", InsertOp.GetErrorCode()
1981 ## Shortcut to Import() for BREP format
1983 # Example: see GEOM_TestOthers.py
1984 def ImportBREP(theFileName):
1985 return Import(theFileName, "BREP")
1987 ## Shortcut to Import() for IGES format
1989 # Example: see GEOM_TestOthers.py
1990 def ImportIGES(theFileName):
1991 return Import(theFileName, "IGES")
1993 ## Shortcut to Import() for STEP format
1995 # Example: see GEOM_TestOthers.py
1996 def ImportSTEP(theFileName):
1997 return Import(theFileName, "STEP")
1999 ## Export the given shape into a file with given name.
2000 # @param theObject Shape to be stored in the file.
2001 # @param theFileName Name of the file to store the given shape in.
2002 # @param theFormatName Specify format for the shape storage.
2003 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2005 # Example: see GEOM_TestOthers.py
2006 def Export(theObject, theFileName, theFormatName):
2007 InsertOp.Export(theObject, theFileName, theFormatName)
2008 if InsertOp.IsDone() == 0:
2009 print "Export : ", InsertOp.GetErrorCode()
2011 ## Shortcut to Export() for BREP format
2013 # Example: see GEOM_TestOthers.py
2014 def ExportBREP(theObject, theFileName):
2015 return Export(theObject, theFileName, "BREP")
2017 ## Shortcut to Export() for IGES format
2019 # Example: see GEOM_TestOthers.py
2020 def ExportIGES(theObject, theFileName):
2021 return Export(theObject, theFileName, "IGES")
2023 ## Shortcut to Export() for STEP format
2025 # Example: see GEOM_TestOthers.py
2026 def ExportSTEP(theObject, theFileName):
2027 return Export(theObject, theFileName, "STEP")
2029 # -----------------------------------------------------------------------------
2031 # -----------------------------------------------------------------------------
2033 ## Create a quadrangle face from four edges. Order of Edges is not
2034 # important. It is not necessary that edges share the same vertex.
2035 # @param E1,E2,E3,E4 Edges for the face bound.
2036 # @return New GEOM_Object, containing the created face.
2038 # Example: see GEOM_Spanner.py
2039 def MakeQuad(E1, E2, E3, E4):
2040 anObj = BlocksOp.MakeQuad(E1, E2, E3, E4)
2041 if BlocksOp.IsDone() == 0:
2042 print "MakeQuad : ", BlocksOp.GetErrorCode()
2045 ## Create a quadrangle face on two edges.
2046 # The missing edges will be built by creating the shortest ones.
2047 # @param E1,E2 Two opposite edges for the face.
2048 # @return New GEOM_Object, containing the created face.
2050 # Example: see GEOM_Spanner.py
2051 def MakeQuad2Edges(E1, E2):
2052 anObj = BlocksOp.MakeQuad2Edges(E1, E2)
2053 if BlocksOp.IsDone() == 0:
2054 print "MakeQuad2Edges : ", BlocksOp.GetErrorCode()
2057 ## Create a quadrangle face with specified corners.
2058 # The missing edges will be built by creating the shortest ones.
2059 # @param V1,V2,V3,V4 Corner vertices for the face.
2060 # @return New GEOM_Object, containing the created face.
2062 # Example: see GEOM_Spanner.py
2063 def MakeQuad4Vertices(V1, V2, V3, V4):
2064 anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2065 if BlocksOp.IsDone() == 0:
2066 print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode()
2069 ## Create a hexahedral solid, bounded by the six given faces. Order of
2070 # faces is not important. It is not necessary that Faces share the same edge.
2071 # @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2072 # @return New GEOM_Object, containing the created solid.
2074 # Example: see GEOM_Spanner.py
2075 def MakeHexa(F1, F2, F3, F4, F5, F6):
2076 anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2077 if BlocksOp.IsDone() == 0:
2078 print "MakeHexa : ", BlocksOp.GetErrorCode()
2081 ## Create a hexahedral solid between two given faces.
2082 # The missing faces will be built by creating the smallest ones.
2083 # @param F1,F2 Two opposite faces for the hexahedral solid.
2084 # @return New GEOM_Object, containing the created solid.
2086 # Example: see GEOM_Spanner.py
2087 def MakeHexa2Faces(F1, F2):
2088 anObj = BlocksOp.MakeHexa2Faces(F1, F2)
2089 if BlocksOp.IsDone() == 0:
2090 print "MakeHexa2Faces : ", BlocksOp.GetErrorCode()
2093 ## Get a vertex, found in the given shape by its coordinates.
2094 # @param theShape Block or a compound of blocks.
2095 # @param theX,theY,theZ Coordinates of the sought vertex.
2096 # @param theEpsilon Maximum allowed distance between the resulting
2097 # vertex and point with the given coordinates.
2098 # @return New GEOM_Object, containing the found vertex.
2100 # Example: see GEOM_TestOthers.py
2101 def GetPoint(theShape, theX, theY, theZ, theEpsilon):
2102 anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2103 if BlocksOp.IsDone() == 0:
2104 print "GetPoint : ", BlocksOp.GetErrorCode()
2107 ## Get an edge, found in the given shape by two given vertices.
2108 # @param theShape Block or a compound of blocks.
2109 # @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2110 # @return New GEOM_Object, containing the found edge.
2112 # Example: see GEOM_Spanner.py
2113 def GetEdge(theShape, thePoint1, thePoint2):
2114 anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2115 if BlocksOp.IsDone() == 0:
2116 print "GetEdge : ", BlocksOp.GetErrorCode()
2119 ## Find an edge of the given shape, which has minimal distance to the given point.
2120 # @param theShape Block or a compound of blocks.
2121 # @param thePoint Point, close to the desired edge.
2122 # @return New GEOM_Object, containing the found edge.
2124 # Example: see GEOM_TestOthers.py
2125 def GetEdgeNearPoint(theShape, thePoint):
2126 anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2127 if BlocksOp.IsDone() == 0:
2128 print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode()
2131 ## Returns a face, found in the given shape by four given corner vertices.
2132 # @param theShape Block or a compound of blocks.
2133 # @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2134 # @return New GEOM_Object, containing the found face.
2136 # Example: see GEOM_Spanner.py
2137 def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2138 anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2139 if BlocksOp.IsDone() == 0:
2140 print "GetFaceByPoints : ", BlocksOp.GetErrorCode()
2143 ## Get a face of block, found in the given shape by two given edges.
2144 # @param theShape Block or a compound of blocks.
2145 # @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2146 # @return New GEOM_Object, containing the found face.
2148 # Example: see GEOM_Spanner.py
2149 def GetFaceByEdges(theShape, theEdge1, theEdge2):
2150 anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2151 if BlocksOp.IsDone() == 0:
2152 print "GetFaceByEdges : ", BlocksOp.GetErrorCode()
2155 ## Find a face, opposite to the given one in the given block.
2156 # @param theBlock Must be a hexahedral solid.
2157 # @param theFace Face of \a theBlock, opposite to the desired face.
2158 # @return New GEOM_Object, containing the found face.
2160 # Example: see GEOM_Spanner.py
2161 def GetOppositeFace(theBlock, theFace):
2162 anObj = BlocksOp.GetOppositeFace(theBlock, theFace)
2163 if BlocksOp.IsDone() == 0:
2164 print "GetOppositeFace : ", BlocksOp.GetErrorCode()
2167 ## Find a face of the given shape, which has minimal distance to the given point.
2168 # @param theShape Block or a compound of blocks.
2169 # @param thePoint Point, close to the desired face.
2170 # @return New GEOM_Object, containing the found face.
2172 # Example: see GEOM_Spanner.py
2173 def GetFaceNearPoint(theShape, thePoint):
2174 anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint)
2175 if BlocksOp.IsDone() == 0:
2176 print "GetFaceNearPoint : ", BlocksOp.GetErrorCode()
2179 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2180 # @param theShape Block or a compound of blocks.
2181 # @param theVector Vector, close to the normale of the desired face.
2182 # @return New GEOM_Object, containing the found face.
2184 # Example: see GEOM_Spanner.py
2185 def GetFaceByNormale(theBlock, theVector):
2186 anObj = BlocksOp.GetFaceByNormale(theBlock, theVector)
2187 if BlocksOp.IsDone() == 0:
2188 print "GetFaceByNormale : ", BlocksOp.GetErrorCode()
2191 ## Check, if the compound of blocks is given.
2192 # To be considered as a compound of blocks, the
2193 # given shape must satisfy the following conditions:
2194 # - Each element of the compound should be a Block (6 faces and 12 edges).
2195 # - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2196 # - The compound should be connexe.
2197 # - The glue between two quadrangle faces should be applied.
2198 # @param theCompound The compound to check.
2199 # @return TRUE, if the given shape is a compound of blocks.
2200 # If theCompound is not valid, prints all discovered errors.
2202 # Example: see GEOM_Spanner.py
2203 def CheckCompoundOfBlocks(theCompound):
2204 (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound)
2205 if BlocksOp.IsDone() == 0:
2206 print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode()
2209 Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors)
2213 ## Remove all seam and degenerated edges from \a theShape.
2214 # Unite faces and edges, sharing one surface. It means that
2215 # this faces must have references to one C++ surface object (handle).
2216 # @param theShape The compound or single solid to remove irregular edges from.
2217 # @return Improved shape.
2219 # Example: see GEOM_TestOthers.py
2220 def RemoveExtraEdges(theShape):
2221 anObj = BlocksOp.RemoveExtraEdges(theShape)
2222 if BlocksOp.IsDone() == 0:
2223 print "RemoveExtraEdges : ", BlocksOp.GetErrorCode()
2226 ## Check, if the given shape is a blocks compound.
2227 # Fix all detected errors.
2228 # \note Single block can be also fixed by this method.
2229 # @param theCompound The compound to check and improve.
2230 # @return Improved compound.
2232 # Example: see GEOM_TestOthers.py
2233 def CheckAndImprove(theShape):
2234 anObj = BlocksOp.CheckAndImprove(theShape)
2235 if BlocksOp.IsDone() == 0:
2236 print "CheckAndImprove : ", BlocksOp.GetErrorCode()
2239 ## Get all the blocks, contained in the given compound.
2240 # @param theCompound The compound to explode.
2241 # @param theMinNbFaces If solid has lower number of faces, it is not a block.
2242 # @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2243 # \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2244 # @return List of GEOM_Objects, containing the retrieved blocks.
2246 # Example: see GEOM_TestOthers.py
2247 def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces):
2248 aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2249 if BlocksOp.IsDone() == 0:
2250 print "MakeBlockExplode : ", BlocksOp.GetErrorCode()
2253 ## Find block, containing the given point inside its volume or on boundary.
2254 # @param theCompound Compound, to find block in.
2255 # @param thePoint Point, close to the desired block. If the point lays on
2256 # boundary between some blocks, we return block with nearest center.
2257 # @return New GEOM_Object, containing the found block.
2259 # Example: see GEOM_Spanner.py
2260 def GetBlockNearPoint(theCompound, thePoint):
2261 anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2262 if BlocksOp.IsDone() == 0:
2263 print "GetBlockNearPoint : ", BlocksOp.GetErrorCode()
2266 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2267 # @param theCompound Compound, to find block in.
2268 # @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2269 # @return New GEOM_Object, containing the found block.
2271 # Example: see GEOM_TestOthers.py
2272 def GetBlockByParts(theCompound, theParts):
2273 anObj = BlocksOp.GetBlockByParts(theCompound, theParts)
2274 if BlocksOp.IsDone() == 0:
2275 print "GetBlockByParts : ", BlocksOp.GetErrorCode()
2278 ## Return all blocks, containing all the elements, passed as the parts.
2279 # @param theCompound Compound, to find blocks in.
2280 # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2281 # @return List of GEOM_Objects, containing the found blocks.
2283 # Example: see GEOM_Spanner.py
2284 def GetBlocksByParts(theCompound, theParts):
2285 aList = BlocksOp.GetBlocksByParts(theCompound, theParts)
2286 if BlocksOp.IsDone() == 0:
2287 print "GetBlocksByParts : ", BlocksOp.GetErrorCode()
2290 ## Multi-transformate block and glue the result.
2291 # Transformation is defined so, as to superpose direction faces.
2292 # @param Block Hexahedral solid to be multi-transformed.
2293 # @param DirFace1 ID of First direction face.
2294 # @param DirFace2 ID of Second direction face.
2295 # @param NbTimes Quantity of transformations to be done.
2296 # \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2297 # @return New GEOM_Object, containing the result shape.
2299 # Example: see GEOM_Spanner.py
2300 def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes):
2301 anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2302 if BlocksOp.IsDone() == 0:
2303 print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode()
2306 ## Multi-transformate block and glue the result.
2307 # @param Block Hexahedral solid to be multi-transformed.
2308 # @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2309 # @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2310 # @param NbTimesU,NbTimesV Quantity of transformations to be done.
2311 # @return New GEOM_Object, containing the result shape.
2313 # Example: see GEOM_Spanner.py
2314 def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2315 DirFace1V, DirFace2V, NbTimesV):
2316 anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2317 DirFace1V, DirFace2V, NbTimesV)
2318 if BlocksOp.IsDone() == 0:
2319 print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode()
2322 ## Build all possible propagation groups.
2323 # Propagation group is a set of all edges, opposite to one (main)
2324 # edge of this group directly or through other opposite edges.
2325 # Notion of Opposite Edge make sence only on quadrangle face.
2326 # @param theShape Shape to build propagation groups on.
2327 # @return List of GEOM_Objects, each of them is a propagation group.
2329 # Example: see GEOM_TestOthers.py
2330 def Propagate(theShape):
2331 listChains = BlocksOp.Propagate(theShape)
2332 if BlocksOp.IsDone() == 0:
2333 print "Propagate : ", BlocksOp.GetErrorCode()
2336 # -----------------------------------------------------------------------------
2338 # -----------------------------------------------------------------------------
2340 ## Creates a new group which will store sub shapes of theMainShape
2341 # @param theMainShape is a GEOM object on which the group is selected
2342 # @param theShapeType defines a shape type of the group
2343 # @return a newly created GEOM group
2345 # Example: see GEOM_TestOthers.py
2346 def CreateGroup(theMainShape, theShapeType):
2347 anObj = GroupOp.CreateGroup(theMainShape, theShapeType)
2348 if GroupOp.IsDone() == 0:
2349 print "CreateGroup : ", GroupOp.GetErrorCode()
2352 ## Adds a sub object with ID theSubShapeId to the group
2353 # @param theGroup is a GEOM group to which the new sub shape is added
2354 # @param theSubShapeID is a sub shape ID in the main object.
2355 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2357 # Example: see GEOM_TestOthers.py
2358 def AddObject(theGroup, theSubShapeID):
2359 GroupOp.AddObject(theGroup, theSubShapeID)
2360 if GroupOp.IsDone() == 0:
2361 print "AddObject : ", GroupOp.GetErrorCode()
2363 ## Removes a sub object with ID \a theSubShapeId from the group
2364 # @param theGroup is a GEOM group from which the new sub shape is removed
2365 # @param theSubShapeID is a sub shape ID in the main object.
2366 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2368 # Example: see GEOM_TestOthers.py
2369 def RemoveObject(theGroup, theSubShapeID):
2370 GroupOp.RemoveObject(theGroup, theSubShapeID)
2371 if GroupOp.IsDone() == 0:
2372 print "RemoveObject : ", GroupOp.GetErrorCode()
2374 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2375 # @param theGroup is a GEOM group to which the new sub shapes are added.
2376 # @param theSubShapes is a list of sub shapes to be added.
2378 # Example: see GEOM_TestOthers.py
2379 def UnionList (theGroup, theSubShapes):
2380 GroupOp.UnionList(theGroup, theSubShapes)
2381 if GroupOp.IsDone() == 0:
2382 print "UnionList : ", GroupOp.GetErrorCode()
2384 ## Works like the above method, but argument
2385 # theSubShapes here is a list of sub-shapes indices
2387 # Example: see GEOM_TestOthers.py
2388 def UnionIDs(theGroup, theSubShapes):
2389 GroupOp.UnionIDs(theGroup, theSubShapes)
2390 if GroupOp.IsDone() == 0:
2391 print "UnionIDs : ", GroupOp.GetErrorCode()
2393 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2394 # @param theGroup is a GEOM group from which the sub-shapes are removed.
2395 # @param theSubShapes is a list of sub-shapes to be removed.
2397 # Example: see GEOM_TestOthers.py
2398 def DifferenceList (theGroup, theSubShapes):
2399 GroupOp.DifferenceList(theGroup, theSubShapes)
2400 if GroupOp.IsDone() == 0:
2401 print "DifferenceList : ", GroupOp.GetErrorCode()
2403 ## Works like the above method, but argument
2404 # theSubShapes here is a list of sub-shapes indices
2406 # Example: see GEOM_TestOthers.py
2407 def DifferenceIDs(theGroup, theSubShapes):
2408 GroupOp.DifferenceIDs(theGroup, theSubShapes)
2409 if GroupOp.IsDone() == 0:
2410 print "DifferenceIDs : ", GroupOp.GetErrorCode()
2412 ## Returns a list of sub objects ID stored in the group
2413 # @param theGroup is a GEOM group for which a list of IDs is requested
2415 # Example: see GEOM_TestOthers.py
2416 def GetObjectIDs(theGroup):
2417 ListIDs = GroupOp.GetObjects(theGroup)
2418 if GroupOp.IsDone() == 0:
2419 print "GetObjectIDs : ", GroupOp.GetErrorCode()
2422 ## Returns a type of sub objects stored in the group
2423 # @param theGroup is a GEOM group which type is returned.
2425 # Example: see GEOM_TestOthers.py
2426 def GetType(theGroup):
2427 aType = GroupOp.GetType(theGroup)
2428 if GroupOp.IsDone() == 0:
2429 print "GetType : ", GroupOp.GetErrorCode()
2432 ## Returns a main shape associated with the group
2433 # @param theGroup is a GEOM group for which a main shape object is requested
2434 # @return a GEOM object which is a main shape for theGroup
2436 # Example: see GEOM_TestOthers.py
2437 def GetMainShape(theGroup):
2438 anObj = GroupOp.GetMainShape(theGroup)
2439 if GroupOp.IsDone() == 0:
2440 print "GetMainShape : ", GroupOp.GetErrorCode()
2443 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2444 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2445 def GetEdgesByLength (theShape, min_length, max_length, include_min = 1, include_max = 1):
2446 edges = SubShapeAll(theShape, ShapeType["EDGE"])
2449 Props = BasicProperties(edge)
2450 if min_length <= Props[0] and Props[0] <= max_length:
2451 if (not include_min) and (min_length == Props[0]):
2454 if (not include_max) and (Props[0] == max_length):
2457 edges_in_range.append(edge)
2459 if len(edges_in_range) <= 0:
2460 print "No edges found by given criteria"
2463 group_edges = CreateGroup(theShape, ShapeType["EDGE"])
2464 UnionList(group_edges, edges_in_range)
2468 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2469 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2470 def SelectEdges (min_length, max_length, include_min = 1, include_max = 1):
2471 nb_selected = sg.SelectedCount()
2473 print "Select a shape before calling this function, please."
2476 print "Only one shape must be selected"
2479 id_shape = sg.getSelected(0)
2480 shape = IDToObject( id_shape )
2482 group_edges = GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2486 if include_min: left_str = " <= "
2487 if include_max: right_str = " <= "
2489 addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2490 + left_str + "length" + right_str + `max_length`)
2492 sg.updateObjBrowser(1)
2496 ## Add Path to load python scripts from
2498 if (sys.path.count(Path) < 1):
2499 sys.path.append(Path)