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
39 # -----------------------------------------------------------------------------
40 # enumeration ShapeType as a dictionary
41 # -----------------------------------------------------------------------------
43 ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
45 # -----------------------------------------------------------------------------
46 # Raise an Error Function if Operation is Failed
47 # -----------------------------------------------------------------------------
48 def RaiseIfFailed (Method_name, Operation):
49 #NPAL18017#if Operation.IsDone() == 0:
50 if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY":
51 raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
53 # -----------------------------------------------------------------------------
54 # enumeration shape_kind
55 # -----------------------------------------------------------------------------
57 kind = GEOM.GEOM_IKindOfShape
65 class geompyDC(GEOM._objref_GEOM_Gen):
67 GEOM._objref_GEOM_Gen.__init__(self)
86 def init_geom(self,theStudy):
87 self.myStudy = theStudy
88 self.myStudyId = self.myStudy._get_StudyId()
89 self.myBuilder = self.myStudy.NewBuilder()
90 self.father = self.myStudy.FindComponent("GEOM")
91 if self.father is None:
92 self.father = self.myBuilder.NewComponent("GEOM")
93 A1 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributeName")
94 FName = A1._narrow(SALOMEDS.AttributeName)
95 FName.SetValue("Geometry")
96 A2 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributePixMap")
97 aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
98 aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
99 self.myBuilder.DefineComponentInstance(self.father,self)
101 self.BasicOp = self.GetIBasicOperations (self.myStudyId)
102 self.CurvesOp = self.GetICurvesOperations (self.myStudyId)
103 self.PrimOp = self.GetI3DPrimOperations (self.myStudyId)
104 self.ShapesOp = self.GetIShapesOperations (self.myStudyId)
105 self.HealOp = self.GetIHealingOperations (self.myStudyId)
106 self.InsertOp = self.GetIInsertOperations (self.myStudyId)
107 self.BoolOp = self.GetIBooleanOperations (self.myStudyId)
108 self.TrsfOp = self.GetITransformOperations(self.myStudyId)
109 self.LocalOp = self.GetILocalOperations (self.myStudyId)
110 self.MeasuOp = self.GetIMeasureOperations (self.myStudyId)
111 self.BlocksOp = self.GetIBlocksOperations (self.myStudyId)
112 self.GroupOp = self.GetIGroupOperations (self.myStudyId)
115 ## Get name for sub-shape aSubObj of shape aMainObj
117 # Example: see GEOM_TestAll.py
118 def SubShapeName(self,aSubObj, aMainObj):
119 #aSubId = orb.object_to_string(aSubObj)
120 #aMainId = orb.object_to_string(aMainObj)
121 #index = gg.getIndexTopology(aSubId, aMainId)
122 #name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
123 index = self.ShapesOp.GetTopologyIndex(aMainObj, aSubObj)
124 name = self.ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index)
127 ## Publish in study aShape with name aName
129 # Example: see GEOM_TestAll.py
130 def addToStudy(self,aShape, aName):
132 aSObject = self.AddInStudy(self.myStudy, aShape, aName, None)
134 print "addToStudy() failed"
136 return aShape.GetStudyEntry()
138 ## Publish in study aShape with name aName as sub-object of previously published aFather
140 # Example: see GEOM_TestAll.py
141 def addToStudyInFather(self,aFather, aShape, aName):
143 aSObject = self.AddInStudy(myStudy, aShape, aName, aFather)
145 print "addToStudyInFather() failed"
147 return aShape.GetStudyEntry()
149 # -----------------------------------------------------------------------------
151 # -----------------------------------------------------------------------------
153 ## Create point by three coordinates.
154 # @param theX The X coordinate of the point.
155 # @param theY The Y coordinate of the point.
156 # @param theZ The Z coordinate of the point.
157 # @return New GEOM_Object, containing the created point.
159 # Example: see GEOM_TestAll.py
160 def MakeVertex(self,theX, theY, theZ):
161 anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ)
162 RaiseIfFailed("MakePointXYZ", self.BasicOp)
165 ## Create a point, distant from the referenced point
166 # on the given distances along the coordinate axes.
167 # @param theReference The referenced point.
168 # @param theX Displacement from the referenced point along OX axis.
169 # @param theY Displacement from the referenced point along OY axis.
170 # @param theZ Displacement from the referenced point along OZ axis.
171 # @return New GEOM_Object, containing the created point.
173 # Example: see GEOM_TestAll.py
174 def MakeVertexWithRef(self,theReference, theX, theY, theZ):
175 anObj = self.BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
176 RaiseIfFailed("MakePointWithReference", self.BasicOp)
179 ## Create a point, corresponding to the given parameter on the given curve.
180 # @param theRefCurve The referenced curve.
181 # @param theParameter Value of parameter on the referenced curve.
182 # @return New GEOM_Object, containing the created point.
184 # Example: see GEOM_TestAll.py
185 def MakeVertexOnCurve(self,theRefCurve, theParameter):
186 anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter)
187 RaiseIfFailed("MakePointOnCurve", self.BasicOp)
190 ## Create a point on intersection of two lines.
191 # @param theRefLine1, theRefLine2 The referenced lines.
192 # @return New GEOM_Object, containing the created point.
194 # Example: see GEOM_TestAll.py
195 def MakeVertexOnLinesIntersection(self, theRefLine1, theRefLine2):
196 anObj = self.BasicOp.MakePointOnLinesIntersection(theRefLine1, theRefLine2)
197 RaiseIfFailed("MakePointOnLinesIntersection", self.BasicOp)
200 ## Create a tangent, corresponding to the given parameter on the given curve.
201 # @param theRefCurve The referenced curve.
202 # @param theParameter Value of parameter on the referenced curve.
203 # @return New GEOM_Object, containing the created tangent.
204 def MakeTangentOnCurve(self,theRefCurve, theParameter):
205 anObj = self.BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
206 RaiseIfFailed("MakeTangentOnCurve", self.BasicOp)
209 ## Create a vector with the given components.
210 # @param theDX X component of the vector.
211 # @param theDY Y component of the vector.
212 # @param theDZ Z component of the vector.
213 # @return New GEOM_Object, containing the created vector.
215 # Example: see GEOM_TestAll.py
216 def MakeVectorDXDYDZ(self,theDX, theDY, theDZ):
217 anObj = self.BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ)
218 RaiseIfFailed("MakeVectorDXDYDZ", self.BasicOp)
221 ## Create a vector between two points.
222 # @param thePnt1 Start point for the vector.
223 # @param thePnt2 End point for the vector.
224 # @return New GEOM_Object, containing the created vector.
226 # Example: see GEOM_TestAll.py
227 def MakeVector(self,thePnt1, thePnt2):
228 anObj = self.BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2)
229 RaiseIfFailed("MakeVectorTwoPnt", self.BasicOp)
232 ## Create a line, passing through the given point
233 # and parrallel to the given direction
234 # @param thePnt Point. The resulting line will pass through it.
235 # @param theDir Direction. The resulting line will be parallel to it.
236 # @return New GEOM_Object, containing the created line.
238 # Example: see GEOM_TestAll.py
239 def MakeLine(self,thePnt, theDir):
240 anObj = self.BasicOp.MakeLine(thePnt, theDir)
241 RaiseIfFailed("MakeLine", self.BasicOp)
244 ## Create a line, passing through the given points
245 # @param thePnt1 First of two points, defining the line.
246 # @param thePnt2 Second of two points, defining the line.
247 # @return New GEOM_Object, containing the created line.
249 # Example: see GEOM_TestAll.py
250 def MakeLineTwoPnt(self,thePnt1, thePnt2):
251 anObj = self.BasicOp.MakeLineTwoPnt(thePnt1, thePnt2)
252 RaiseIfFailed("MakeLineTwoPnt", self.BasicOp)
255 ## Create a line on two faces intersection.
256 # @param theFace1 First of two faces, defining the line.
257 # @param theFace2 Second of two faces, defining the line.
258 # @return New GEOM_Object, containing the created line.
260 # Example: see GEOM_TestAll.py
261 def MakeLineTwoFaces(self, theFace1, theFace2):
262 anObj = self.BasicOp.MakeLineTwoFaces(theFace1, theFace2)
263 RaiseIfFailed("MakeLineTwoFaces", self.BasicOp)
266 ## Create a plane, passing through the given point
267 # and normal to the given vector.
268 # @param thePnt Point, the plane has to pass through.
269 # @param theVec Vector, defining the plane normal direction.
270 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
271 # @return New GEOM_Object, containing the created plane.
273 # Example: see GEOM_TestAll.py
274 def MakePlane(self,thePnt, theVec, theTrimSize):
275 anObj = self.BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize)
276 RaiseIfFailed("MakePlanePntVec", self.BasicOp)
279 ## Create a plane, passing through the three given points
280 # @param thePnt1 First of three points, defining the plane.
281 # @param thePnt2 Second of three points, defining the plane.
282 # @param thePnt3 Fird of three points, defining the plane.
283 # @param theTrimSize Half size of a side of quadrangle face, representing the plane.
284 # @return New GEOM_Object, containing the created plane.
286 # Example: see GEOM_TestAll.py
287 def MakePlaneThreePnt(self,thePnt1, thePnt2, thePnt3, theTrimSize):
288 anObj = self.BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize)
289 RaiseIfFailed("MakePlaneThreePnt", self.BasicOp)
292 ## Create a plane, similar to the existing one, but with another size of representing face.
293 # @param theFace Referenced plane or LCS(Marker).
294 # @param theTrimSize New half size of a side of quadrangle face, representing the plane.
295 # @return New GEOM_Object, containing the created plane.
297 # Example: see GEOM_TestAll.py
298 def MakePlaneFace(self,theFace, theTrimSize):
299 anObj = self.BasicOp.MakePlaneFace(theFace, theTrimSize)
300 RaiseIfFailed("MakePlaneFace", self.BasicOp)
303 ## Create a local coordinate system.
304 # @param OX,OY,OZ Three coordinates of coordinate system origin.
305 # @param XDX,XDY,XDZ Three components of OX direction
306 # @param YDX,YDY,YDZ Three components of OY direction
307 # @return New GEOM_Object, containing the created coordinate system.
309 # Example: see GEOM_TestAll.py
310 def MakeMarker(self,OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ):
311 anObj = self.BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ)
312 RaiseIfFailed("MakeMarker", self.BasicOp)
315 ## Create a local coordinate system.
316 # @param theOrigin Point of coordinate system origin.
317 # @param theXVec Vector of X direction
318 # @param theYVec Vector of Y direction
319 # @return New GEOM_Object, containing the created coordinate system.
320 def MakeMarkerPntTwoVec(self,theOrigin, theXVec, theYVec):
321 O = self.PointCoordinates( theOrigin )
323 for vec in [ theXVec, theYVec ]:
324 v1, v2 = self.SubShapeAll( vec, ShapeType["VERTEX"] )
325 p1 = self.PointCoordinates( v1 )
326 p2 = self.PointCoordinates( v2 )
327 for i in range( 0, 3 ):
328 OXOY.append( p2[i] - p1[i] )
330 anObj = self.BasicOp.MakeMarker( O[0], O[1], O[2],
331 OXOY[0], OXOY[1], OXOY[2],
332 OXOY[3], OXOY[4], OXOY[5], )
333 RaiseIfFailed("MakeMarker", self.BasicOp)
336 # -----------------------------------------------------------------------------
338 # -----------------------------------------------------------------------------
340 ## Create an arc of circle, passing through three given points.
341 # @param thePnt1 Start point of the arc.
342 # @param thePnt2 Middle point of the arc.
343 # @param thePnt3 End point of the arc.
344 # @return New GEOM_Object, containing the created arc.
346 # Example: see GEOM_TestAll.py
347 def MakeArc(self,thePnt1, thePnt2, thePnt3):
348 anObj = self.CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3)
349 RaiseIfFailed("MakeArc", self.CurvesOp)
352 ## Create an arc of circle from a center and 2 points.
353 # @param thePnt1 Center of the arc
354 # @param thePnt2 Start point of the arc. (Gives also the radius of the arc)
355 # @param thePnt3 End point of the arc (Gives also a direction)
356 # @return New GEOM_Object, containing the created arc.
358 # Example: see GEOM_TestAll.py
359 def MakeArcCenter(self,thePnt1, thePnt2, thePnt3,theSense):
360 anObj = self.CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3,theSense)
361 RaiseIfFailed("MakeArcCenter", self.CurvesOp)
364 ## Create a circle with given center, normal vector and radius.
365 # @param thePnt Circle center.
366 # @param theVec Vector, normal to the plane of the circle.
367 # @param theR Circle radius.
368 # @return New GEOM_Object, containing the created circle.
370 # Example: see GEOM_TestAll.py
371 def MakeCircle(self,thePnt, theVec, theR):
372 anObj = self.CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR)
373 RaiseIfFailed("MakeCirclePntVecR", self.CurvesOp)
376 ## Create a circle, passing through three given points
377 # @param thePnt1,thePnt2,thePnt3 Points, defining the circle.
378 # @return New GEOM_Object, containing the created circle.
380 # Example: see GEOM_TestAll.py
381 def MakeCircleThreePnt(self,thePnt1, thePnt2, thePnt3):
382 anObj = self.CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3)
383 RaiseIfFailed("MakeCircleThreePnt", self.CurvesOp)
386 ## Create a circle, with given point1 as center,
387 # passing through the point2 as radius and laying in the plane,
388 # defined by all three given points.
389 # @param thePnt1,thePnt2,thePnt3 Points, defining the circle.
390 # @return New GEOM_Object, containing the created circle.
392 # Example: see GEOM_example6.py
393 def MakeCircleCenter2Pnt(self,thePnt1, thePnt2, thePnt3):
394 anObj = self.CurvesOp.MakeCircleCenter2Pnt(thePnt1, thePnt2, thePnt3)
395 RaiseIfFailed("MakeCircleCenter2Pnt", self.CurvesOp)
398 ## Create an ellipse with given center, normal vector and radiuses.
399 # @param thePnt Ellipse center.
400 # @param theVec Vector, normal to the plane of the ellipse.
401 # @param theRMajor Major ellipse radius.
402 # @param theRMinor Minor ellipse radius.
403 # @return New GEOM_Object, containing the created ellipse.
405 # Example: see GEOM_TestAll.py
406 def MakeEllipse(self,thePnt, theVec, theRMajor, theRMinor):
407 anObj = self.CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
408 RaiseIfFailed("MakeEllipse", self.CurvesOp)
411 ## Create a polyline on the set of points.
412 # @param thePoints Sequence of points for the polyline.
413 # @return New GEOM_Object, containing the created polyline.
415 # Example: see GEOM_TestAll.py
416 def MakePolyline(self,thePoints):
417 anObj = self.CurvesOp.MakePolyline(thePoints)
418 RaiseIfFailed("MakePolyline", self.CurvesOp)
421 ## Create bezier curve on the set of points.
422 # @param thePoints Sequence of points for the bezier curve.
423 # @return New GEOM_Object, containing the created bezier curve.
425 # Example: see GEOM_TestAll.py
426 def MakeBezier(self,thePoints):
427 anObj = self.CurvesOp.MakeSplineBezier(thePoints)
428 RaiseIfFailed("MakeSplineBezier", self.CurvesOp)
431 ## Create B-Spline curve on the set of points.
432 # @param thePoints Sequence of points for the B-Spline curve.
433 # @return New GEOM_Object, containing the created B-Spline curve.
435 # Example: see GEOM_TestAll.py
436 def MakeInterpol(self,thePoints):
437 anObj = self.CurvesOp.MakeSplineInterpolation(thePoints)
438 RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
441 ## Create a sketcher (wire or face), following the textual description,
442 # passed through \a theCommand argument. \n
443 # Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
444 # Format of the description string have to be the following:
446 # "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
449 # - x1, y1 are coordinates of the first sketcher point (zero by default),
451 # - "R angle" : Set the direction by angle
452 # - "D dx dy" : Set the direction by DX & DY
455 # - "TT x y" : Create segment by point at X & Y
456 # - "T dx dy" : Create segment by point with DX & DY
457 # - "L length" : Create segment by direction & Length
458 # - "IX x" : Create segment by direction & Intersect. X
459 # - "IY y" : Create segment by direction & Intersect. Y
462 # - "C radius length" : Create arc by direction, radius and length(in degree)
465 # - "WW" : Close Wire (to finish)
466 # - "WF" : Close Wire and build face (to finish)
468 # @param theCommand String, defining the sketcher in local
469 # coordinates of the working plane.
470 # @param theWorkingPlane Nine double values, defining origin,
471 # OZ and OX directions of the working plane.
472 # @return New GEOM_Object, containing the created wire.
474 # Example: see GEOM_TestAll.py
475 def MakeSketcher(self,theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]):
476 anObj = self.CurvesOp.MakeSketcher(theCommand, theWorkingPlane)
477 RaiseIfFailed("MakeSketcher", self.CurvesOp)
480 ## Create a sketcher (wire or face), following the textual description,
481 # passed through \a theCommand argument. \n
482 # For format of the description string see the previous method.\n
483 # @param theCommand String, defining the sketcher in local
484 # coordinates of the working plane.
485 # @param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
486 # @return New GEOM_Object, containing the created wire.
487 def MakeSketcherOnPlane(self,theCommand, theWorkingPlane):
488 anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
489 RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp)
492 # -----------------------------------------------------------------------------
493 # Create 3D Primitives
494 # -----------------------------------------------------------------------------
496 ## Create a box by coordinates of two opposite vertices.
498 # Example: see GEOM_TestAll.py
499 def MakeBox(self,x1,y1,z1,x2,y2,z2):
500 pnt1 = self.MakeVertex(x1,y1,z1)
501 pnt2 = self.MakeVertex(x2,y2,z2)
502 return self.MakeBoxTwoPnt(pnt1,pnt2)
504 ## Create a box with specified dimensions along the coordinate axes
505 # and with edges, parallel to the coordinate axes.
506 # Center of the box will be at point (DX/2, DY/2, DZ/2).
507 # @param theDX Length of Box edges, parallel to OX axis.
508 # @param theDY Length of Box edges, parallel to OY axis.
509 # @param theDZ Length of Box edges, parallel to OZ axis.
510 # @return New GEOM_Object, containing the created box.
512 # Example: see GEOM_TestAll.py
513 def MakeBoxDXDYDZ(self,theDX, theDY, theDZ):
514 anObj = self.PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
515 RaiseIfFailed("MakeBoxDXDYDZ", self.PrimOp)
518 ## Create a box with two specified opposite vertices,
519 # and with edges, parallel to the coordinate axes
520 # @param thePnt1 First of two opposite vertices.
521 # @param thePnt2 Second of two opposite vertices.
522 # @return New GEOM_Object, containing the created box.
524 # Example: see GEOM_TestAll.py
525 def MakeBoxTwoPnt(self,thePnt1, thePnt2):
526 anObj = self.PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2)
527 RaiseIfFailed("MakeBoxTwoPnt", self.PrimOp)
530 ## Create a cylinder with given base point, axis, radius and height.
531 # @param thePnt Central point of cylinder base.
532 # @param theAxis Cylinder axis.
533 # @param theR Cylinder radius.
534 # @param theH Cylinder height.
535 # @return New GEOM_Object, containing the created cylinder.
537 # Example: see GEOM_TestAll.py
538 def MakeCylinder(self,thePnt, theAxis, theR, theH):
539 anObj = self.PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH)
540 RaiseIfFailed("MakeCylinderPntVecRH", self.PrimOp)
543 ## Create a cylinder with given radius and height at
544 # the origin of coordinate system. Axis of the cylinder
545 # will be collinear to the OZ axis of the coordinate system.
546 # @param theR Cylinder radius.
547 # @param theH Cylinder height.
548 # @return New GEOM_Object, containing the created cylinder.
550 # Example: see GEOM_TestAll.py
551 def MakeCylinderRH(self,theR, theH):
552 anObj = self.PrimOp.MakeCylinderRH(theR, theH)
553 RaiseIfFailed("MakeCylinderRH", self.PrimOp)
556 ## Create a sphere with given center and radius.
557 # @param thePnt Sphere center.
558 # @param theR Sphere radius.
559 # @return New GEOM_Object, containing the created sphere.
561 # Example: see GEOM_TestAll.py
562 def MakeSpherePntR(self,thePnt, theR):
563 anObj = self.PrimOp.MakeSpherePntR(thePnt, theR)
564 RaiseIfFailed("MakeSpherePntR", self.PrimOp)
567 ## Create a sphere with given center and radius.
568 # @param x,y,z Coordinates of sphere center.
569 # @param theR Sphere radius.
570 # @return New GEOM_Object, containing the created sphere.
572 # Example: see GEOM_TestAll.py
573 def MakeSphere(self,x, y, z, theR):
574 point = self.MakeVertex(x, y, z)
575 anObj = self.MakeSpherePntR(point, theR)
578 ## Create a sphere with given radius at the origin of coordinate system.
579 # @param theR Sphere radius.
580 # @return New GEOM_Object, containing the created sphere.
582 # Example: see GEOM_TestAll.py
583 def MakeSphereR(self,theR):
584 anObj = self.PrimOp.MakeSphereR(theR)
585 RaiseIfFailed("MakeSphereR", self.PrimOp)
588 ## Create a cone with given base point, axis, height and radiuses.
589 # @param thePnt Central point of the first cone base.
590 # @param theAxis Cone axis.
591 # @param theR1 Radius of the first cone base.
592 # @param theR2 Radius of the second cone base.
593 # \note If both radiuses are non-zero, the cone will be truncated.
594 # \note If the radiuses are equal, a cylinder will be created instead.
595 # @param theH Cone height.
596 # @return New GEOM_Object, containing the created cone.
598 # Example: see GEOM_TestAll.py
599 def MakeCone(self,thePnt, theAxis, theR1, theR2, theH):
600 anObj = self.PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH)
601 RaiseIfFailed("MakeConePntVecR1R2H", self.PrimOp)
604 ## Create a cone with given height and radiuses at
605 # the origin of coordinate system. Axis of the cone will
606 # be collinear to the OZ axis of the coordinate system.
607 # @param theR1 Radius of the first cone base.
608 # @param theR2 Radius of the second cone base.
609 # \note If both radiuses are non-zero, the cone will be truncated.
610 # \note If the radiuses are equal, a cylinder will be created instead.
611 # @param theH Cone height.
612 # @return New GEOM_Object, containing the created cone.
614 # Example: see GEOM_TestAll.py
615 def MakeConeR1R2H(self,theR1, theR2, theH):
616 anObj = self.PrimOp.MakeConeR1R2H(theR1, theR2, theH)
617 RaiseIfFailed("MakeConeR1R2H", self.PrimOp)
620 ## Create a torus with given center, normal vector and radiuses.
621 # @param thePnt Torus central point.
622 # @param theVec Torus axis of symmetry.
623 # @param theRMajor Torus major radius.
624 # @param theRMinor Torus minor radius.
625 # @return New GEOM_Object, containing the created torus.
627 # Example: see GEOM_TestAll.py
628 def MakeTorus(self,thePnt, theVec, theRMajor, theRMinor):
629 anObj = self.PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor)
630 RaiseIfFailed("MakeTorusPntVecRR", self.PrimOp)
633 ## Create a torus with given radiuses at the origin of coordinate system.
634 # @param theRMajor Torus major radius.
635 # @param theRMinor Torus minor radius.
636 # @return New GEOM_Object, containing the created torus.
638 # Example: see GEOM_TestAll.py
639 def MakeTorusRR(self,theRMajor, theRMinor):
640 anObj = self.PrimOp.MakeTorusRR(theRMajor, theRMinor)
641 RaiseIfFailed("MakeTorusRR", self.PrimOp)
644 ## Create a shape by extrusion of the base shape along a vector, defined by two points.
645 # @param theBase Base shape to be extruded.
646 # @param thePoint1 First end of extrusion vector.
647 # @param thePoint2 Second end of extrusion vector.
648 # @return New GEOM_Object, containing the created prism.
650 # Example: see GEOM_TestAll.py
651 def MakePrism(self,theBase, thePoint1, thePoint2):
652 anObj = self.PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2)
653 RaiseIfFailed("MakePrismTwoPnt", self.PrimOp)
656 ## Create a shape by extrusion of the base shape along the vector,
657 # i.e. all the space, transfixed by the base shape during its translation
658 # along the vector on the given distance.
659 # @param theBase Base shape to be extruded.
660 # @param theVec Direction of extrusion.
661 # @param theH Prism dimension along theVec.
662 # @return New GEOM_Object, containing the created prism.
664 # Example: see GEOM_TestAll.py
665 def MakePrismVecH(self,theBase, theVec, theH):
666 anObj = self.PrimOp.MakePrismVecH(theBase, theVec, theH)
667 RaiseIfFailed("MakePrismVecH", self.PrimOp)
670 ## Create a shape by extrusion of the base shape along
671 # the path shape. The path shape can be a wire or an edge.
672 # @param theBase Base shape to be extruded.
673 # @param thePath Path shape to extrude the base shape along it.
674 # @return New GEOM_Object, containing the created pipe.
676 # Example: see GEOM_TestAll.py
677 def MakePipe(self,theBase, thePath):
678 anObj = self.PrimOp.MakePipe(theBase, thePath)
679 RaiseIfFailed("MakePipe", self.PrimOp)
682 ## Create a shape by revolution of the base shape around the axis
683 # on the given angle, i.e. all the space, transfixed by the base
684 # shape during its rotation around the axis on the given angle.
685 # @param theBase Base shape to be rotated.
686 # @param theAxis Rotation axis.
687 # @param theAngle Rotation angle in radians.
688 # @return New GEOM_Object, containing the created revolution.
690 # Example: see GEOM_TestAll.py
691 def MakeRevolution(self,theBase, theAxis, theAngle):
692 anObj = self.PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle)
693 RaiseIfFailed("MakeRevolutionAxisAngle", self.PrimOp)
696 ## Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices.
697 # @param theSeqSections - set of specified sections.
698 # @param theModeSolid - mode defining building solid or shell
699 # @param thePreci - precision 3D used for smoothing by default 1.e-6
700 # @param theRuled - mode defining type of the result surfaces (ruled or smoothed).
701 # @return New GEOM_Object, containing the created shell or solid.
703 # Example: see GEOM_TestAll.py
704 def MakeThruSections(self,theSeqSections,theModeSolid,thePreci,theRuled):
705 anObj = self.PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled)
706 RaiseIfFailed("MakeThruSections", self.PrimOp)
709 ## Create a shape by extrusion of the profile shape along
710 # the path shape. The path shape can be a wire or an edge.
711 # the several profiles can be specified in the several locations of path.
712 # @param theSeqBases - list of Bases shape to be extruded.
713 # @param theLocations - list of locations on the path corresponding
714 # specified list of the Bases shapes. Number of locations
715 # should be equal to number of bases or list of locations can be empty.
716 # @param thePath - Path shape to extrude the base shape along it.
717 # @param theWithContact - the mode defining that the section is translated to be in
718 # contact with the spine.
719 # @param - WithCorrection - defining that the section is rotated to be
720 # orthogonal to the spine tangent in the correspondent point
721 # @return New GEOM_Object, containing the created pipe.
723 def MakePipeWithDifferentSections(self, theSeqBases,
724 theLocations, thePath,
725 theWithContact, theWithCorrection):
726 anObj = self.PrimOp.MakePipeWithDifferentSections(theSeqBases,
727 theLocations, thePath,
728 theWithContact, theWithCorrection)
729 RaiseIfFailed("MakePipeWithDifferentSections", self.PrimOp)
732 ## Create a shape by extrusion of the profile shape along
733 # the path shape. The path shape can be a shell or a face.
734 # the several profiles can be specified in the several locations of path.
735 # @param theSeqBases - list of Bases shape to be extruded.
736 # @param theSeqSubBases - list of corresponding subshapes of section shapes.
737 # @param theLocations - list of locations on the path corresponding
738 # specified list of the Bases shapes. Number of locations
739 # should be equal to number of bases. First and last
740 # locations must be coincided with first and last vertexes
741 # of path correspondingly.
742 # @param thePath - Path shape to extrude the base shape along it.
743 # @param theWithContact - the mode defining that the section is translated to be in
744 # contact with the spine.
745 # @param - WithCorrection - defining that the section is rotated to be
746 # orthogonal to the spine tangent in the correspondent point
747 # @return New GEOM_Object, containing the created solids.
749 def MakePipeWithShellSections(self,theSeqBases, theSeqSubBases,
750 theLocations, thePath,
751 theWithContact, theWithCorrection):
752 anObj = self.PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases,
753 theLocations, thePath,
754 theWithContact, theWithCorrection)
755 RaiseIfFailed("MakePipeWithShellSections", self.PrimOp)
758 def MakePipeWithShellSectionsBySteps(self, theSeqBases, theSeqSubBases,
759 theLocations, thePath,
760 theWithContact, theWithCorrection):
762 nbsect = len(theSeqBases)
763 nbsubsect = len(theSeqSubBases)
764 #print "nbsect = ",nbsect
765 for i in range(1,nbsect):
767 tmpSeqBases = [ theSeqBases[i-1], theSeqBases[i] ]
768 tmpLocations = [ theLocations[i-1], theLocations[i] ]
770 if nbsubsect>0: tmpSeqSubBases = [ theSeqSubBases[i-1], theSeqSubBases[i] ]
771 anObj = self.PrimOp.MakePipeWithShellSections(tmpSeqBases, tmpSeqSubBases,
772 tmpLocations, thePath,
773 theWithContact, theWithCorrection)
774 if self.PrimOp.IsDone() == 0:
775 print "Problems with pipe creation between ",i," and ",i+1," sections"
776 RaiseIfFailed("MakePipeWithShellSections", self.PrimOp)
779 print "Pipe between ",i," and ",i+1," sections is OK"
784 resc = self.MakeCompound(res)
785 #resc = self.MakeSewing(res, 0.001)
789 ## Create solids between given sections
790 # @param theSeqBases - list of sections (shell or face).
791 # @param theLocations - list of corresponding vertexes
792 # @return New GEOM_Object, containing the created solids.
794 def MakePipeShellsWithoutPath(self, theSeqBases, theLocations):
795 anObj = self.PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations)
796 RaiseIfFailed("MakePipeShellsWithoutPath", self.PrimOp)
800 # -----------------------------------------------------------------------------
802 # -----------------------------------------------------------------------------
804 ## Create a linear edge with specified ends.
805 # @param thePnt1 Point for the first end of edge.
806 # @param thePnt2 Point for the second end of edge.
807 # @return New GEOM_Object, containing the created edge.
809 # Example: see GEOM_TestAll.py
810 def MakeEdge(self,thePnt1, thePnt2):
811 anObj = self.ShapesOp.MakeEdge(thePnt1, thePnt2)
812 RaiseIfFailed("MakeEdge", self.ShapesOp)
815 ## Create a wire from the set of edges and wires.
816 # @param theEdgesAndWires List of edges and/or wires.
817 # @return New GEOM_Object, containing the created wire.
819 # Example: see GEOM_TestAll.py
820 def MakeWire(self,theEdgesAndWires):
821 anObj = self.ShapesOp.MakeWire(theEdgesAndWires)
822 RaiseIfFailed("MakeWire", self.ShapesOp)
825 ## Create a face on the given wire.
826 # @param theWire closed Wire or Edge to build the face on.
827 # @param isPlanarWanted If TRUE, only planar face will be built.
828 # If impossible, NULL object will be returned.
829 # @return New GEOM_Object, containing the created face.
831 # Example: see GEOM_TestAll.py
832 def MakeFace(self,theWire, isPlanarWanted):
833 anObj = self.ShapesOp.MakeFace(theWire, isPlanarWanted)
834 RaiseIfFailed("MakeFace", self.ShapesOp)
837 ## Create a face on the given wires set.
838 # @param theWires List of closed wires or edges to build the face on.
839 # @param isPlanarWanted If TRUE, only planar face will be built.
840 # If impossible, NULL object will be returned.
841 # @return New GEOM_Object, containing the created face.
843 # Example: see GEOM_TestAll.py
844 def MakeFaceWires(self,theWires, isPlanarWanted):
845 anObj = self.ShapesOp.MakeFaceWires(theWires, isPlanarWanted)
846 RaiseIfFailed("MakeFaceWires", self.ShapesOp)
849 ## Shortcut to MakeFaceWires()
851 # Example: see GEOM_TestOthers.py
852 def MakeFaces(self,theWires, isPlanarWanted):
853 anObj = self.MakeFaceWires(theWires, isPlanarWanted)
856 ## Create a shell from the set of faces and shells.
857 # @param theFacesAndShells List of faces and/or shells.
858 # @return New GEOM_Object, containing the created shell.
860 # Example: see GEOM_TestAll.py
861 def MakeShell(self,theFacesAndShells):
862 anObj = self.ShapesOp.MakeShell(theFacesAndShells)
863 RaiseIfFailed("MakeShell", self.ShapesOp)
866 ## Create a solid, bounded by the given shells.
867 # @param theShells Sequence of bounding shells.
868 # @return New GEOM_Object, containing the created solid.
870 # Example: see GEOM_TestAll.py
871 def MakeSolid(self,theShells):
872 anObj = self.ShapesOp.MakeSolidShells(theShells)
873 RaiseIfFailed("MakeSolidShells", self.ShapesOp)
876 ## Create a compound of the given shapes.
877 # @param theShapes List of shapes to put in compound.
878 # @return New GEOM_Object, containing the created compound.
880 # Example: see GEOM_TestAll.py
881 def MakeCompound(self,theShapes):
882 anObj = self.ShapesOp.MakeCompound(theShapes)
883 RaiseIfFailed("MakeCompound", self.ShapesOp)
886 ## Gives quantity of faces in the given shape.
887 # @param theShape Shape to count faces of.
888 # @return Quantity of faces.
890 # Example: see GEOM_TestOthers.py
891 def NumberOfFaces(self,theShape):
892 nb_faces = self.ShapesOp.NumberOfFaces(theShape)
893 RaiseIfFailed("NumberOfFaces", self.ShapesOp)
896 ## Gives quantity of edges in the given shape.
897 # @param theShape Shape to count edges of.
898 # @return Quantity of edges.
900 # Example: see GEOM_TestOthers.py
901 def NumberOfEdges(self,theShape):
902 nb_edges = self.ShapesOp.NumberOfEdges(theShape)
903 RaiseIfFailed("NumberOfEdges", self.ShapesOp)
906 ## Reverses an orientation the given shape.
907 # @param theShape Shape to be reversed.
908 # @return The reversed copy of theShape.
910 # Example: see GEOM_TestAll.py
911 def ChangeOrientation(self,theShape):
912 anObj = self.ShapesOp.ChangeOrientation(theShape)
913 RaiseIfFailed("ChangeOrientation", self.ShapesOp)
916 ## Shortcut to ChangeOrientation()
918 # Example: see GEOM_TestOthers.py
919 def OrientationChange(self,theShape):
920 anObj = self.ChangeOrientation(theShape)
923 ## Retrieve all free faces from the given shape.
924 # Free face is a face, which is not shared between two shells of the shape.
925 # @param theShape Shape to find free faces in.
926 # @return List of IDs of all free faces, contained in theShape.
928 # Example: see GEOM_TestOthers.py
929 def GetFreeFacesIDs(self,theShape):
930 anIDs = self.ShapesOp.GetFreeFacesIDs(theShape)
931 RaiseIfFailed("GetFreeFacesIDs", self.ShapesOp)
934 ## Get all sub-shapes of theShape1 of the given type, shared with theShape2.
935 # @param theShape1 Shape to find sub-shapes in.
936 # @param theShape2 Shape to find shared sub-shapes with.
937 # @param theShapeType Type of sub-shapes to be retrieved.
938 # @return List of sub-shapes of theShape1, shared with theShape2.
940 # Example: see GEOM_TestOthers.py
941 def GetSharedShapes(self,theShape1, theShape2, theShapeType):
942 aList = self.ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType)
943 RaiseIfFailed("GetSharedShapes", self.ShapesOp)
946 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
947 # the specified plane by the certain way, defined through \a theState parameter.
948 # @param theShape Shape to find sub-shapes of.
949 # @param theShapeType Type of sub-shapes to be retrieved.
950 # @param theAx1 Vector (or line, or linear edge), specifying normal
951 # direction and location of the plane to find shapes on.
952 # @param theState The state of the subshapes to find. It can be one of
953 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
954 # @return List of all found sub-shapes.
956 # Example: see GEOM_TestOthers.py
957 def GetShapesOnPlane(self,theShape, theShapeType, theAx1, theState):
958 aList = self.ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
959 RaiseIfFailed("GetShapesOnPlane", self.ShapesOp)
962 ## Works like the above method, but returns list of sub-shapes indices
964 # Example: see GEOM_TestOthers.py
965 def GetShapesOnPlaneIDs(self,theShape, theShapeType, theAx1, theState):
966 aList = self.ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
967 RaiseIfFailed("GetShapesOnPlaneIDs", self.ShapesOp)
970 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
971 # the specified plane by the certain way, defined through \a theState parameter.
972 # @param theShape Shape to find sub-shapes of.
973 # @param theShapeType Type of sub-shapes to be retrieved.
974 # @param theAx1 Vector (or line, or linear edge), specifying normal
975 # direction of the plane to find shapes on.
976 # @param thePnt Point specifying location of the plane to find shapes on.
977 # @param theState The state of the subshapes to find. It can be one of
978 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
979 # @return List of all found sub-shapes.
981 # Example: see GEOM_TestOthers.py
982 def GetShapesOnPlaneWithLocation(self,theShape, theShapeType, theAx1, thePnt, theState):
983 aList = self.ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState)
984 RaiseIfFailed("GetShapesOnPlaneWithLocation", self.ShapesOp)
987 ## Works like the above method, but returns list of sub-shapes indices
989 # Example: see GEOM_TestOthers.py
990 def GetShapesOnPlaneWithLocationIDs(self,theShape, theShapeType, theAx1, thePnt, theState):
991 aList = self.ShapesOp.GetShapesOnPlaneWithLocationIDs(theShape, theShapeType, theAx1, thePnt, theState)
992 RaiseIfFailed("GetShapesOnPlaneWithLocationIDs", self.ShapesOp)
995 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
996 # the specified cylinder by the certain way, defined through \a theState parameter.
997 # @param theShape Shape to find sub-shapes of.
998 # @param theShapeType Type of sub-shapes to be retrieved.
999 # @param theAxis Vector (or line, or linear edge), specifying
1000 # axis of the cylinder to find shapes on.
1001 # @param theRadius Radius of the cylinder to find shapes on.
1002 # @param theState The state of the subshapes to find. It can be one of
1003 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1004 # @return List of all found sub-shapes.
1006 # Example: see GEOM_TestOthers.py
1007 def GetShapesOnCylinder(self,theShape, theShapeType, theAxis, theRadius, theState):
1008 aList = self.ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
1009 RaiseIfFailed("GetShapesOnCylinder", self.ShapesOp)
1012 ## Works like the above method, but returns list of sub-shapes indices
1014 # Example: see GEOM_TestOthers.py
1015 def GetShapesOnCylinderIDs(self,theShape, theShapeType, theAxis, theRadius, theState):
1016 aList = self.ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
1017 RaiseIfFailed("GetShapesOnCylinderIDs", self.ShapesOp)
1020 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1021 # the specified sphere by the certain way, defined through \a theState parameter.
1022 # @param theShape Shape to find sub-shapes of.
1023 # @param theShapeType Type of sub-shapes to be retrieved.
1024 # @param theCenter Point, specifying center of the sphere to find shapes on.
1025 # @param theRadius Radius of the sphere to find shapes on.
1026 # @param theState The state of the subshapes to find. It can be one of
1027 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1028 # @return List of all found sub-shapes.
1030 # Example: see GEOM_TestOthers.py
1031 def GetShapesOnSphere(self,theShape, theShapeType, theCenter, theRadius, theState):
1032 aList = self.ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
1033 RaiseIfFailed("GetShapesOnSphere", self.ShapesOp)
1036 ## Works like the above method, but returns list of sub-shapes indices
1038 # Example: see GEOM_TestOthers.py
1039 def GetShapesOnSphereIDs(self,theShape, theShapeType, theCenter, theRadius, theState):
1040 aList = self.ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
1041 RaiseIfFailed("GetShapesOnSphereIDs", self.ShapesOp)
1044 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1045 # the specified quadrangle by the certain way, defined through \a theState parameter.
1046 # @param theShape Shape to find sub-shapes of.
1047 # @param theShapeType Type of sub-shapes to be retrieved.
1048 # @param theTopLeftPoint Point, specifying top left corner of a quadrangle
1049 # @param theTopRigthPoint Point, specifying top right corner of a quadrangle
1050 # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle
1051 # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle
1052 # @param theState The state of the subshapes to find. It can be one of
1053 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1054 # @return List of all found sub-shapes.
1056 # Example: see GEOM_TestOthers.py
1057 def GetShapesOnQuadrangle(self,theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1058 aList = self.ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1059 RaiseIfFailed("GetShapesOnQuadrangle", self.ShapesOp)
1062 ## Works like the above method, but returns list of sub-shapes indices
1064 # Example: see GEOM_TestOthers.py
1065 def GetShapesOnQuadrangleIDs(self,theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
1066 aList = self.ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
1067 RaiseIfFailed("GetShapesOnQuadrangleIDs", self.ShapesOp)
1070 ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
1071 # the specified \a theBox by the certain way, defined through \a theState parameter.
1072 # @param theBox Shape for relative comparing.
1073 # @param theShape Shape to find sub-shapes of.
1074 # @param theShapeType Type of sub-shapes to be retrieved.
1075 # @param theState The state of the subshapes to find. It can be one of
1076 # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
1077 # @return List of all found sub-shapes.
1079 def GetShapesOnBox(self,theBox, theShape, theShapeType, theState):
1080 aList = self.ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState)
1081 RaiseIfFailed("GetShapesOnBox", self.ShapesOp)
1084 ## Works like the above method, but returns list of sub-shapes indices
1086 def GetShapesOnBoxIDs(self,theBox, theShape, theShapeType, theState):
1087 aList = self.ShapesOp.GetShapesOnBoxIDs(theBox, theShape, theShapeType, theState)
1088 RaiseIfFailed("GetShapesOnBoxIDs", self.ShapesOp)
1091 ## Get sub-shape(s) of theShapeWhere, which are
1092 # coincident with \a theShapeWhat or could be a part of it.
1093 # @param theShapeWhere Shape to find sub-shapes of.
1094 # @param theShapeWhat Shape, specifying what to find.
1095 # @return Group of all found sub-shapes or a single found sub-shape.
1097 # Example: see GEOM_TestOthers.py
1098 def GetInPlace(self,theShapeWhere, theShapeWhat):
1099 anObj = self.ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
1100 RaiseIfFailed("GetInPlace", self.ShapesOp)
1103 ## Get sub-shape(s) of \a theShapeWhere, which are
1104 # coincident with \a theShapeWhat or could be a part of it.
1106 # Implementation of this method is based on a saved history of an operation,
1107 # produced \a theShapeWhere. The \a theShapeWhat must be among this operation's
1108 # arguments (an argument shape or a sub-shape of an argument shape).
1109 # The operation could be the Partition or one of boolean operations,
1110 # performed on simple shapes (not on compounds).
1112 # @param theShapeWhere Shape to find sub-shapes of.
1113 # @param theShapeWhat Shape, specifying what to find (must be in the
1114 # building history of the ShapeWhere).
1115 # @return Group of all found sub-shapes or a single found sub-shape.
1117 # Example: see GEOM_TestOthers.py
1118 def GetInPlaceByHistory(self, theShapeWhere, theShapeWhat):
1119 anObj = self.ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat)
1120 RaiseIfFailed("GetInPlaceByHistory", self.ShapesOp)
1123 ## Get sub-shape of theShapeWhere, which is
1124 # equal to \a theShapeWhat.
1125 # @param theShapeWhere Shape to find sub-shape of.
1126 # @param theShapeWhat Shape, specifying what to find.
1127 # @return New GEOM_Object for found sub-shape.
1129 def GetSame(self,theShapeWhere, theShapeWhat):
1130 anObj = self.ShapesOp.GetSame(theShapeWhere, theShapeWhat)
1131 RaiseIfFailed("GetSame", self.ShapesOp)
1134 # -----------------------------------------------------------------------------
1135 # Access to sub-shapes by their unique IDs inside the main shape.
1136 # -----------------------------------------------------------------------------
1138 ## Obtain a composite sub-shape of <aShape>, composed from sub-shapes
1139 # of <aShape>, selected by their unique IDs inside <aShape>
1141 # Example: see GEOM_TestAll.py
1142 def GetSubShape(self,aShape, ListOfID):
1143 anObj = self.AddSubShape(aShape,ListOfID)
1146 ## Obtain unique ID of sub-shape <aSubShape> inside <aShape>
1148 # Example: see GEOM_TestAll.py
1149 def GetSubShapeID(self,aShape, aSubShape):
1150 anID = self.LocalOp.GetSubShapeIndex(aShape, aSubShape)
1151 RaiseIfFailed("GetSubShapeIndex", self.LocalOp)
1154 # -----------------------------------------------------------------------------
1156 # -----------------------------------------------------------------------------
1158 ## Explode a shape on subshapes of a given type.
1159 # @param theShape Shape to be exploded.
1160 # @param theShapeType Type of sub-shapes to be retrieved.
1161 # @return List of sub-shapes of type theShapeType, contained in theShape.
1163 # Example: see GEOM_TestAll.py
1164 def SubShapeAll(self,aShape, aType):
1165 ListObj = self.ShapesOp.MakeExplode(aShape,aType,0)
1166 RaiseIfFailed("MakeExplode", self.ShapesOp)
1169 ## Explode a shape on subshapes of a given type.
1170 # @param theShape Shape to be exploded.
1171 # @param theShapeType Type of sub-shapes to be retrieved.
1172 # @return List of IDs of sub-shapes.
1173 def SubShapeAllIDs(self,aShape, aType):
1174 ListObj = self.ShapesOp.SubShapeAllIDs(aShape,aType,0)
1175 RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
1178 ## Explode a shape on subshapes of a given type.
1179 # Sub-shapes will be sorted by coordinates of their gravity centers.
1180 # @param theShape Shape to be exploded.
1181 # @param theShapeType Type of sub-shapes to be retrieved.
1182 # @return List of sub-shapes of type theShapeType, contained in theShape.
1184 # Example: see GEOM_TestAll.py
1185 def SubShapeAllSorted(self,aShape, aType):
1186 ListObj = self.ShapesOp.MakeExplode(aShape,aType,1)
1187 RaiseIfFailed("MakeExplode", self.ShapesOp)
1190 ## Explode a shape on subshapes of a given type.
1191 # Sub-shapes will be sorted by coordinates of their gravity centers.
1192 # @param theShape Shape to be exploded.
1193 # @param theShapeType Type of sub-shapes to be retrieved.
1194 # @return List of IDs of sub-shapes.
1195 def SubShapeAllSortedIDs(self,aShape, aType):
1196 ListIDs = self.ShapesOp.SubShapeAllIDs(aShape,aType,1)
1197 RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
1200 ## Obtain a compound of sub-shapes of <aShape>,
1201 # selected by they indices in list of all sub-shapes of type <aType>.
1202 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1204 # Example: see GEOM_TestAll.py
1205 def SubShape(self,aShape, aType, ListOfInd):
1207 AllShapeList = self.SubShapeAll(aShape, aType)
1208 for ind in ListOfInd:
1209 ListOfIDs.append(self.GetSubShapeID(aShape, AllShapeList[ind - 1]))
1210 anObj = self.GetSubShape(aShape, ListOfIDs)
1213 ## Obtain a compound of sub-shapes of <aShape>,
1214 # selected by they indices in sorted list of all sub-shapes of type <aType>.
1215 # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type]
1217 # Example: see GEOM_TestAll.py
1218 def SubShapeSorted(self,aShape, aType, ListOfInd):
1220 AllShapeList = self.SubShapeAllSorted(aShape, aType)
1221 for ind in ListOfInd:
1222 ListOfIDs.append(self.GetSubShapeID(aShape, AllShapeList[ind - 1]))
1223 anObj = self.GetSubShape(aShape, ListOfIDs)
1226 # -----------------------------------------------------------------------------
1227 # Healing operations
1228 # -----------------------------------------------------------------------------
1230 ## Apply a sequence of Shape Healing operators to the given object.
1231 # @param theShape Shape to be processed.
1232 # @param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.).
1233 # @param theParameters List of names of parameters
1234 # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.).
1235 # @param theValues List of values of parameters, in the same order
1236 # as parameters are listed in \a theParameters list.
1237 # @return New GEOM_Object, containing processed shape.
1239 # Example: see GEOM_TestHealing.py
1240 def ProcessShape(self,theShape, theOperators, theParameters, theValues):
1241 anObj = self.HealOp.ProcessShape(theShape, theOperators, theParameters, theValues)
1242 RaiseIfFailed("ProcessShape", self.HealOp)
1245 ## Remove faces from the given object (shape).
1246 # @param theObject Shape to be processed.
1247 # @param theFaces Indices of faces to be removed, if EMPTY then the method
1248 # removes ALL faces of the given object.
1249 # @return New GEOM_Object, containing processed shape.
1251 # Example: see GEOM_TestHealing.py
1252 def SuppressFaces(self,theObject, theFaces):
1253 anObj = self.HealOp.SuppressFaces(theObject, theFaces)
1254 RaiseIfFailed("SuppressFaces", self.HealOp)
1257 ## Sewing of some shapes into single shape.
1259 # Example: see GEOM_TestHealing.py
1260 def MakeSewing(self,ListShape, theTolerance):
1261 comp = self.MakeCompound(ListShape)
1262 anObj = self.Sew(comp, theTolerance)
1265 ## Sewing of the given object.
1266 # @param theObject Shape to be processed.
1267 # @param theTolerance Required tolerance value.
1268 # @return New GEOM_Object, containing processed shape.
1270 # Example: see MakeSewing() above
1271 def Sew(self,theObject, theTolerance):
1272 anObj = self.HealOp.Sew(theObject, theTolerance)
1273 RaiseIfFailed("Sew", self.HealOp)
1276 ## Remove internal wires and edges from the given object (face).
1277 # @param theObject Shape to be processed.
1278 # @param theWires Indices of wires to be removed, if EMPTY then the method
1279 # removes ALL internal wires of the given object.
1280 # @return New GEOM_Object, containing processed shape.
1282 # Example: see GEOM_TestHealing.py
1283 def SuppressInternalWires(self,theObject, theWires):
1284 anObj = self.HealOp.RemoveIntWires(theObject, theWires)
1285 RaiseIfFailed("RemoveIntWires", self.HealOp)
1288 ## Remove internal closed contours (holes) from the given object.
1289 # @param theObject Shape to be processed.
1290 # @param theWires Indices of wires to be removed, if EMPTY then the method
1291 # removes ALL internal holes of the given object
1292 # @return New GEOM_Object, containing processed shape.
1294 # Example: see GEOM_TestHealing.py
1295 def SuppressHoles(self,theObject, theWires):
1296 anObj = self.HealOp.FillHoles(theObject, theWires)
1297 RaiseIfFailed("FillHoles", self.HealOp)
1300 ## Close an open wire.
1301 # @param theObject Shape to be processed.
1302 # @param theWires Indexes of edge(s) and wire(s) to be closed within <VAR>theObject</VAR>'s shape,
1303 # if -1, then theObject itself is a wire.
1304 # @param isCommonVertex If TRUE : closure by creation of a common vertex,
1305 # If FALS : closure by creation of an edge between ends.
1306 # @return New GEOM_Object, containing processed shape.
1308 # Example: see GEOM_TestHealing.py
1309 def CloseContour(self,theObject, theWires, isCommonVertex):
1310 anObj = self.HealOp.CloseContour(theObject, theWires, isCommonVertex)
1311 RaiseIfFailed("CloseContour", self.HealOp)
1314 ## Addition of a point to a given edge object.
1315 # @param theObject Shape to be processed.
1316 # @param theEdgeIndex Index of edge to be divided within theObject's shape,
1317 # if -1, then theObject itself is the edge.
1318 # @param theValue Value of parameter on edge or length parameter,
1319 # depending on \a isByParameter.
1320 # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1],
1321 # if FALSE : \a theValue is treated as a length parameter [0..1]
1322 # @return New GEOM_Object, containing processed shape.
1324 # Example: see GEOM_TestHealing.py
1325 def DivideEdge(self,theObject, theEdgeIndex, theValue, isByParameter):
1326 anObj = self.HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter)
1327 RaiseIfFailed("DivideEdge", self.HealOp)
1330 ## Change orientation of the given object.
1331 # @param theObject Shape to be processed.
1332 # @update given shape
1333 def ChangeOrientationShell(self,theObject):
1334 theObject = self.HealOp.ChangeOrientation(theObject)
1335 RaiseIfFailed("ChangeOrientation", self.HealOp)
1338 ## Change orientation of the given object.
1339 # @param theObject Shape to be processed.
1340 # @return New GEOM_Object, containing processed shape.
1341 def ChangeOrientationShellCopy(self,theObject):
1342 anObj = self.HealOp.ChangeOrientationCopy(theObject)
1343 RaiseIfFailed("ChangeOrientationCopy", self.HealOp)
1346 ## Get a list of wires (wrapped in GEOM_Object-s),
1347 # that constitute a free boundary of the given shape.
1348 # @param theObject Shape to get free boundary of.
1349 # @return [status, theClosedWires, theOpenWires]
1350 # status: FALSE, if an error(s) occured during the method execution.
1351 # theClosedWires: Closed wires on the free boundary of the given shape.
1352 # theOpenWires: Open wires on the free boundary of the given shape.
1354 # Example: see GEOM_TestHealing.py
1355 def GetFreeBoundary(self,theObject):
1356 anObj = self.HealOp.GetFreeBoundary(theObject)
1357 RaiseIfFailed("GetFreeBoundary", self.HealOp)
1360 # -----------------------------------------------------------------------------
1361 # Create advanced objects
1362 # -----------------------------------------------------------------------------
1364 ## Create a copy of the given object
1366 # Example: see GEOM_TestAll.py
1367 def MakeCopy(self,theOriginal):
1368 anObj = self.InsertOp.MakeCopy(theOriginal)
1369 RaiseIfFailed("MakeCopy", self.InsertOp)
1372 ## Create a filling from the given compound of contours.
1373 # @param theShape the compound of contours
1374 # @param theMinDeg a minimal degree
1375 # @param theMaxDeg a maximal degree
1376 # @param theTol2D a 2d tolerance
1377 # @param theTol3D a 3d tolerance
1378 # @param theNbIter a number of iteration
1379 # @return New GEOM_Object, containing the created filling surface.
1381 # Example: see GEOM_TestAll.py
1382 def MakeFilling(self,theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, isApprox=0):
1383 anObj = self.PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, isApprox)
1384 RaiseIfFailed("MakeFilling", self.PrimOp)
1387 ## Replace coincident faces in theShape by one face.
1388 # @param theShape Initial shape.
1389 # @param theTolerance Maximum distance between faces, which can be considered as coincident.
1390 # @param doKeepNonSolids If FALSE, only solids will present in the result,
1391 # otherwise all initial shapes.
1392 # @return New GEOM_Object, containing a copy of theShape without coincident faces.
1394 # Example: see GEOM_Spanner.py
1395 def MakeGlueFaces(self, theShape, theTolerance, doKeepNonSolids=True):
1396 anObj = self.ShapesOp.MakeGlueFaces(theShape, theTolerance, doKeepNonSolids)
1398 raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode()
1402 ## Find coincident faces in theShape for possible gluing.
1403 # @param theShape Initial shape.
1404 # @param theTolerance Maximum distance between faces,
1405 # which can be considered as coincident.
1408 # Example: see GEOM_Spanner.py
1409 def GetGlueFaces(self, theShape, theTolerance):
1410 anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance)
1411 RaiseIfFailed("GetGlueFaces", self.ShapesOp)
1415 ## Replace coincident faces in theShape by one face
1416 # in compliance with given list of faces
1417 # @param theShape Initial shape.
1418 # @param theTolerance Maximum distance between faces,
1419 # which can be considered as coincident.
1420 # @param theFaces List of faces for gluing.
1421 # @param doKeepNonSolids If FALSE, only solids will present in the result,
1422 # otherwise all initial shapes.
1423 # @return New GEOM_Object, containing a copy of theShape
1424 # without some faces.
1426 # Example: see GEOM_Spanner.py
1427 def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, doKeepNonSolids=True):
1428 anObj = self.ShapesOp.MakeGlueFacesByList(theShape, theTolerance, theFaces, doKeepNonSolids)
1430 raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode()
1434 # -----------------------------------------------------------------------------
1435 # Boolean (Common, Cut, Fuse, Section)
1436 # -----------------------------------------------------------------------------
1438 ## Perform one of boolean operations on two given shapes.
1439 # @param theShape1 First argument for boolean operation.
1440 # @param theShape2 Second argument for boolean operation.
1441 # @param theOperation Indicates the operation to be done:
1442 # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section.
1443 # @return New GEOM_Object, containing the result shape.
1445 # Example: see GEOM_TestAll.py
1446 def MakeBoolean(self,theShape1, theShape2, theOperation):
1447 anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation)
1448 RaiseIfFailed("MakeBoolean", self.BoolOp)
1451 ## Shortcut to MakeBoolean(s1, s2, 1)
1453 # Example: see GEOM_TestOthers.py
1454 def MakeCommon(self, s1, s2):
1455 return self.MakeBoolean(s1, s2, 1)
1457 ## Shortcut to MakeBoolean(s1, s2, 2)
1459 # Example: see GEOM_TestOthers.py
1460 def MakeCut(self, s1, s2):
1461 return self.MakeBoolean(s1, s2, 2)
1463 ## Shortcut to MakeBoolean(s1, s2, 3)
1465 # Example: see GEOM_TestOthers.py
1466 def MakeFuse(self, s1, s2):
1467 return self.MakeBoolean(s1, s2, 3)
1469 ## Shortcut to MakeBoolean(s1, s2, 4)
1471 # Example: see GEOM_TestOthers.py
1472 def MakeSection(self, s1, s2):
1473 return self.MakeBoolean(s1, s2, 4)
1475 ## Perform partition operation.
1476 # @param ListShapes Shapes to be intersected.
1477 # @param ListTools Shapes to intersect theShapes.
1478 # !!!NOTE: Each compound from ListShapes and ListTools will be exploded
1479 # in order to avoid possible intersection between shapes from
1481 # @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
1482 # @param KeepNonlimitShapes: if this parameter == 0 - only shapes with
1483 # type <= Limit are kept in the result,
1484 # else - shapes with type > Limit are kept
1485 # also (if they exist)
1487 # After implementation new version of PartitionAlgo (October 2006)
1488 # other parameters are ignored by current functionality. They are kept
1489 # in this function only for support old versions.
1490 # Ignored parameters:
1491 # @param ListKeepInside Shapes, outside which the results will be deleted.
1492 # Each shape from theKeepInside must belong to theShapes also.
1493 # @param ListRemoveInside Shapes, inside which the results will be deleted.
1494 # Each shape from theRemoveInside must belong to theShapes also.
1495 # @param RemoveWebs If TRUE, perform Glue 3D algorithm.
1496 # @param ListMaterials Material indices for each shape. Make sence,
1497 # only if theRemoveWebs is TRUE.
1499 # @return New GEOM_Object, containing the result shapes.
1501 # Example: see GEOM_TestAll.py
1502 def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1503 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1504 KeepNonlimitShapes=0):
1505 anObj = self.BoolOp.MakePartition(ListShapes, ListTools,
1506 ListKeepInside, ListRemoveInside,
1507 Limit, RemoveWebs, ListMaterials,
1508 KeepNonlimitShapes);
1509 RaiseIfFailed("MakePartition", self.BoolOp)
1512 ## Perform partition operation.
1513 # This method may be useful if it is needed to make a partition for
1514 # compound contains nonintersected shapes. Performance will be better
1515 # since intersection between shapes from compound is not performed.
1517 # Description of all parameters as in previous method MakePartition()
1519 # !!!NOTE: Passed compounds (via ListShapes or via ListTools)
1520 # have to consist of nonintersecting shapes.
1522 # @return New GEOM_Object, containing the result shapes.
1524 def MakePartitionNonSelfIntersectedShape(self, ListShapes, ListTools=[],
1525 ListKeepInside=[], ListRemoveInside=[],
1526 Limit=ShapeType["SHAPE"], RemoveWebs=0,
1527 ListMaterials=[], KeepNonlimitShapes=0):
1528 anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
1529 ListKeepInside, ListRemoveInside,
1530 Limit, RemoveWebs, ListMaterials,
1531 KeepNonlimitShapes);
1532 RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp)
1535 ## Shortcut to MakePartition()
1537 # Example: see GEOM_TestOthers.py
1538 def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
1539 Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
1540 KeepNonlimitShapes=0):
1541 anObj = self.MakePartition(ListShapes, ListTools,
1542 ListKeepInside, ListRemoveInside,
1543 Limit, RemoveWebs, ListMaterials,
1544 KeepNonlimitShapes);
1547 ## Perform partition of the Shape with the Plane
1548 # @param theShape Shape to be intersected.
1549 # @param thePlane Tool shape, to intersect theShape.
1550 # @return New GEOM_Object, containing the result shape.
1552 # Example: see GEOM_TestAll.py
1553 def MakeHalfPartition(self,theShape, thePlane):
1554 anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane)
1555 RaiseIfFailed("MakeHalfPartition", self.BoolOp)
1558 # -----------------------------------------------------------------------------
1560 # -----------------------------------------------------------------------------
1562 ## Translate the given object along the vector, specified
1563 # by its end points, creating its copy before the translation.
1564 # @param theObject The object to be translated.
1565 # @param thePoint1 Start point of translation vector.
1566 # @param thePoint2 End point of translation vector.
1567 # @return New GEOM_Object, containing the translated object.
1569 # Example: see GEOM_TestAll.py
1570 def MakeTranslationTwoPoints(self,theObject, thePoint1, thePoint2):
1571 anObj = self.TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2)
1572 RaiseIfFailed("TranslateTwoPointsCopy", self.TrsfOp)
1575 ## Translate the given object along the vector, specified
1576 # by its components, creating its copy before the translation.
1577 # @param theObject The object to be translated.
1578 # @param theDX,theDY,theDZ Components of translation vector.
1579 # @return New GEOM_Object, containing the translated object.
1581 # Example: see GEOM_TestAll.py
1582 def MakeTranslation(self,theObject, theDX, theDY, theDZ):
1583 anObj = self.TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ)
1584 RaiseIfFailed("TranslateDXDYDZ", self.TrsfOp)
1587 ## Translate the given object along the given vector,
1588 # creating its copy before the translation.
1589 # @param theObject The object to be translated.
1590 # @param theVector The translation vector.
1591 # @return New GEOM_Object, containing the translated object.
1593 # Example: see GEOM_TestAll.py
1594 def MakeTranslationVector(self,theObject, theVector):
1595 anObj = self.TrsfOp.TranslateVectorCopy(theObject, theVector)
1596 RaiseIfFailed("TranslateVectorCopy", self.TrsfOp)
1599 ## Rotate the given object around the given axis
1600 # on the given angle, creating its copy before the rotatation.
1601 # @param theObject The object to be rotated.
1602 # @param theAxis Rotation axis.
1603 # @param theAngle Rotation angle in radians.
1604 # @return New GEOM_Object, containing the rotated object.
1606 # Example: see GEOM_TestAll.py
1607 def MakeRotation(self,theObject, theAxis, theAngle):
1608 anObj = self.TrsfOp.RotateCopy(theObject, theAxis, theAngle)
1609 RaiseIfFailed("RotateCopy", self.TrsfOp)
1612 ## Rotate given object around vector perpendicular to plane
1613 # containing three points, creating its copy before the rotatation.
1614 # @param theObject The object to be rotated.
1615 # @param theCentPoint central point - the axis is the vector perpendicular to the plane
1616 # containing the three points.
1617 # @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
1618 # @return New GEOM_Object, containing the rotated object.
1620 # Example: see GEOM_TestAll.py
1621 def MakeRotationThreePoints(self,theObject, theCentPoint, thePoint1, thePoint2):
1622 anObj = self.TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
1623 RaiseIfFailed("RotateThreePointsCopy", self.TrsfOp)
1626 ## Scale the given object by the factor, creating its copy before the scaling.
1627 # @param theObject The object to be scaled.
1628 # @param thePoint Center point for scaling.
1629 # @param theFactor Scaling factor value.
1630 # @return New GEOM_Object, containing the scaled shape.
1632 # Example: see GEOM_TestAll.py
1633 def MakeScaleTransform(self,theObject, thePoint, theFactor):
1634 anObj = self.TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
1635 RaiseIfFailed("ScaleShapeCopy", self.TrsfOp)
1638 ## Create an object, symmetrical
1639 # to the given one relatively the given plane.
1640 # @param theObject The object to be mirrored.
1641 # @param thePlane Plane of symmetry.
1642 # @return New GEOM_Object, containing the mirrored shape.
1644 # Example: see GEOM_TestAll.py
1645 def MakeMirrorByPlane(self,theObject, thePlane):
1646 anObj = self.TrsfOp.MirrorPlaneCopy(theObject, thePlane)
1647 RaiseIfFailed("MirrorPlaneCopy", self.TrsfOp)
1650 ## Create an object, symmetrical
1651 # to the given one relatively the given axis.
1652 # @param theObject The object to be mirrored.
1653 # @param theAxis Axis of symmetry.
1654 # @return New GEOM_Object, containing the mirrored shape.
1656 # Example: see GEOM_TestAll.py
1657 def MakeMirrorByAxis(self,theObject, theAxis):
1658 anObj = self.TrsfOp.MirrorAxisCopy(theObject, theAxis)
1659 RaiseIfFailed("MirrorAxisCopy", self.TrsfOp)
1662 ## Create an object, symmetrical
1663 # to the given one relatively the given point.
1664 # @param theObject The object to be mirrored.
1665 # @param thePoint Point of symmetry.
1666 # @return New GEOM_Object, containing the mirrored shape.
1668 # Example: see GEOM_TestAll.py
1669 def MakeMirrorByPoint(self,theObject, thePoint):
1670 anObj = self.TrsfOp.MirrorPointCopy(theObject, thePoint)
1671 RaiseIfFailed("MirrorPointCopy", self.TrsfOp)
1674 ## Modify the Location of the given object by LCS,
1675 # creating its copy before the setting.
1676 # @param theObject The object to be displaced.
1677 # @param theStartLCS Coordinate system to perform displacement from it.
1678 # If \a theStartLCS is NULL, displacement
1679 # will be performed from global CS.
1680 # If \a theObject itself is used as \a theStartLCS,
1681 # its location will be changed to \a theEndLCS.
1682 # @param theEndLCS Coordinate system to perform displacement to it.
1683 # @return New GEOM_Object, containing the displaced shape.
1685 # Example: see GEOM_TestAll.py
1686 def MakePosition(self,theObject, theStartLCS, theEndLCS):
1687 anObj = self.TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS)
1688 RaiseIfFailed("PositionShapeCopy", self.TrsfOp)
1691 ## Create new object as offset of the given one.
1692 # @param theObject The base object for the offset.
1693 # @param theOffset Offset value.
1694 # @return New GEOM_Object, containing the offset object.
1696 # Example: see GEOM_TestAll.py
1697 def MakeOffset(self,theObject, theOffset):
1698 anObj = self.TrsfOp.OffsetShapeCopy(theObject, theOffset)
1699 RaiseIfFailed("OffsetShapeCopy", self.TrsfOp)
1702 # -----------------------------------------------------------------------------
1704 # -----------------------------------------------------------------------------
1706 ## Translate the given object along the given vector a given number times
1707 # @param theObject The object to be translated.
1708 # @param theVector Direction of the translation.
1709 # @param theStep Distance to translate on.
1710 # @param theNbTimes Quantity of translations to be done.
1711 # @return New GEOM_Object, containing compound of all
1712 # the shapes, obtained after each translation.
1714 # Example: see GEOM_TestAll.py
1715 def MakeMultiTranslation1D(self,theObject, theVector, theStep, theNbTimes):
1716 anObj = self.TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes)
1717 RaiseIfFailed("MultiTranslate1D", self.TrsfOp)
1720 ## Conseqently apply two specified translations to theObject specified number of times.
1721 # @param theObject The object to be translated.
1722 # @param theVector1 Direction of the first translation.
1723 # @param theStep1 Step of the first translation.
1724 # @param theNbTimes1 Quantity of translations to be done along theVector1.
1725 # @param theVector2 Direction of the second translation.
1726 # @param theStep2 Step of the second translation.
1727 # @param theNbTimes2 Quantity of translations to be done along theVector2.
1728 # @return New GEOM_Object, containing compound of all
1729 # the shapes, obtained after each translation.
1731 # Example: see GEOM_TestAll.py
1732 def MakeMultiTranslation2D(self,theObject, theVector1, theStep1, theNbTimes1,
1733 theVector2, theStep2, theNbTimes2):
1734 anObj = self.TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1,
1735 theVector2, theStep2, theNbTimes2)
1736 RaiseIfFailed("MultiTranslate2D", self.TrsfOp)
1739 ## Rotate the given object around the given axis a given number times.
1740 # Rotation angle will be 2*PI/theNbTimes.
1741 # @param theObject The object to be rotated.
1742 # @param theAxis The rotation axis.
1743 # @param theNbTimes Quantity of rotations to be done.
1744 # @return New GEOM_Object, containing compound of all the
1745 # shapes, obtained after each rotation.
1747 # Example: see GEOM_TestAll.py
1748 def MultiRotate1D(self,theObject, theAxis, theNbTimes):
1749 anObj = self.TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes)
1750 RaiseIfFailed("MultiRotate1D", self.TrsfOp)
1753 ## Rotate the given object around the
1754 # given axis on the given angle a given number
1755 # times and multi-translate each rotation result.
1756 # Translation direction passes through center of gravity
1757 # of rotated shape and its projection on the rotation axis.
1758 # @param theObject The object to be rotated.
1759 # @param theAxis Rotation axis.
1760 # @param theAngle Rotation angle in graduces.
1761 # @param theNbTimes1 Quantity of rotations to be done.
1762 # @param theStep Translation distance.
1763 # @param theNbTimes2 Quantity of translations to be done.
1764 # @return New GEOM_Object, containing compound of all the
1765 # shapes, obtained after each transformation.
1767 # Example: see GEOM_TestAll.py
1768 def MultiRotate2D(self,theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2):
1769 anObj = self.TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
1770 RaiseIfFailed("MultiRotate2D", self.TrsfOp)
1773 ## The same, as MultiRotate1D(), but axis is given by direction and point
1775 # Example: see GEOM_TestOthers.py
1776 def MakeMultiRotation1D(self,aShape,aDir,aPoint,aNbTimes):
1777 aVec = self.MakeLine(aPoint,aDir)
1778 anObj = self.MultiRotate1D(aShape,aVec,aNbTimes)
1781 ## The same, as MultiRotate2D(), but axis is given by direction and point
1783 # Example: see GEOM_TestOthers.py
1784 def MakeMultiRotation2D(self,aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
1785 aVec = self.MakeLine(aPoint,aDir)
1786 anObj = self.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2)
1789 # -----------------------------------------------------------------------------
1791 # -----------------------------------------------------------------------------
1793 ## Perform a fillet on all edges of the given shape.
1794 # @param theShape Shape, to perform fillet on.
1795 # @param theR Fillet radius.
1796 # @return New GEOM_Object, containing the result shape.
1798 # Example: see GEOM_TestOthers.py
1799 def MakeFilletAll(self,theShape, theR):
1800 anObj = self.LocalOp.MakeFilletAll(theShape, theR)
1801 RaiseIfFailed("MakeFilletAll", self.LocalOp)
1804 ## Perform a fillet on the specified edges/faces of the given shape
1805 # @param theShape Shape, to perform fillet on.
1806 # @param theR Fillet radius.
1807 # @param theShapeType Type of shapes in <theListShapes>.
1808 # @param theListShapes Global indices of edges/faces to perform fillet on.
1809 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1810 # @return New GEOM_Object, containing the result shape.
1812 # Example: see GEOM_TestAll.py
1813 def MakeFillet(self,theShape, theR, theShapeType, theListShapes):
1815 if theShapeType == ShapeType["EDGE"]:
1816 anObj = self.LocalOp.MakeFilletEdges(theShape, theR, theListShapes)
1817 RaiseIfFailed("MakeFilletEdges", self.LocalOp)
1819 anObj = self.LocalOp.MakeFilletFaces(theShape, theR, theListShapes)
1820 RaiseIfFailed("MakeFilletFaces", self.LocalOp)
1823 ## The same that MakeFillet but with two Fillet Radius R1 and R2
1824 def MakeFilletR1R2(self, theShape, theR1, theR2, theShapeType, theListShapes):
1826 if theShapeType == ShapeType["EDGE"]:
1827 anObj = self.LocalOp.MakeFilletEdgesR1R2(theShape, theR1, theR2, theListShapes)
1828 RaiseIfFailed("MakeFilletEdgesR1R2", self.LocalOp)
1830 anObj = self.LocalOp.MakeFilletFacesR1R2(theShape, theR1, theR2, theListShapes)
1831 RaiseIfFailed("MakeFilletFacesR1R2", self.LocalOp)
1834 ## Perform a symmetric chamfer on all edges of the given shape.
1835 # @param theShape Shape, to perform chamfer on.
1836 # @param theD Chamfer size along each face.
1837 # @return New GEOM_Object, containing the result shape.
1839 # Example: see GEOM_TestOthers.py
1840 def MakeChamferAll(self,theShape, theD):
1841 anObj = self.LocalOp.MakeChamferAll(theShape, theD)
1842 RaiseIfFailed("MakeChamferAll", self.LocalOp)
1845 ## Perform a chamfer on edges, common to the specified faces,
1846 # with distance D1 on the Face1
1847 # @param theShape Shape, to perform chamfer on.
1848 # @param theD1 Chamfer size along \a theFace1.
1849 # @param theD2 Chamfer size along \a theFace2.
1850 # @param theFace1,theFace2 Global indices of two faces of \a theShape.
1851 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1852 # @return New GEOM_Object, containing the result shape.
1854 # Example: see GEOM_TestAll.py
1855 def MakeChamferEdge(self,theShape, theD1, theD2, theFace1, theFace2):
1856 anObj = self.LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2)
1857 RaiseIfFailed("MakeChamferEdge", self.LocalOp)
1860 ## The Same that MakeChamferEdge but with params theD is chamfer lenght and
1861 # theAngle is Angle of chamfer (angle in radians)
1862 def MakeChamferEdgeAD(self, theShape, theD, theAngle, theFace1, theFace2):
1863 anObj = self.LocalOp.MakeChamferEdgeAD(theShape, theD, theAngle, theFace1, theFace2)
1864 RaiseIfFailed("MakeChamferEdgeAD", self.LocalOp)
1867 ## Perform a chamfer on all edges of the specified faces,
1868 # with distance D1 on the first specified face (if several for one edge)
1869 # @param theShape Shape, to perform chamfer on.
1870 # @param theD1 Chamfer size along face from \a theFaces. If both faces,
1871 # connected to the edge, are in \a theFaces, \a theD1
1872 # will be get along face, which is nearer to \a theFaces beginning.
1873 # @param theD2 Chamfer size along another of two faces, connected to the edge.
1874 # @param theFaces Sequence of global indices of faces of \a theShape.
1875 # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID().
1876 # @return New GEOM_Object, containing the result shape.
1878 # Example: see GEOM_TestAll.py
1879 def MakeChamferFaces(self,theShape, theD1, theD2, theFaces):
1880 anObj = self.LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces)
1881 RaiseIfFailed("MakeChamferFaces", self.LocalOp)
1884 ## The Same that MakeChamferFaces but with params theD is chamfer lenght and
1885 # theAngle is Angle of chamfer (angle in radians)
1886 def MakeChamferFacesAD(self, theShape, theD, theAngle, theFaces):
1887 anObj = self.LocalOp.MakeChamferFacesAD(theShape, theD, theAngle, theFaces)
1888 RaiseIfFailed("MakeChamferFacesAD", self.LocalOp)
1891 ## Perform a chamfer on edges,
1892 # with distance D1 on the first specified face (if several for one edge)
1893 # @param theShape Shape, to perform chamfer on.
1894 # @param theD1 and theD2 Chamfer size
1895 # @param theEdges Sequence of edges of \a theShape.
1896 # @return New GEOM_Object, containing the result shape.
1899 def MakeChamferEdges(self, theShape, theD1, theD2, theEdges):
1900 anObj = self.LocalOp.MakeChamferEdges(theShape, theD1, theD2, theEdges)
1901 RaiseIfFailed("MakeChamferEdges", self.LocalOp)
1904 ## The Same that MakeChamferEdges but with params theD is chamfer lenght and
1905 # theAngle is Angle of chamfer (angle in radians)
1906 def MakeChamferEdgesAD(self, theShape, theD, theAngle, theEdges):
1907 anObj = self.LocalOp.MakeChamferEdgesAD(theShape, theD, theAngle, theEdges)
1908 RaiseIfFailed("MakeChamferEdgesAD", self.LocalOp)
1911 ## Shortcut to MakeChamferEdge() and MakeChamferFaces()
1913 # Example: see GEOM_TestOthers.py
1914 def MakeChamfer(self,aShape,d1,d2,aShapeType,ListShape):
1916 if aShapeType == ShapeType["EDGE"]:
1917 anObj = self.MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1])
1919 anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape)
1922 ## Perform an Archimde operation on the given shape with given parameters.
1923 # The object presenting the resulting face is returned.
1924 # @param theShape Shape to be put in water.
1925 # @param theWeight Weight og the shape.
1926 # @param theWaterDensity Density of the water.
1927 # @param theMeshDeflection Deflection of the mesh, using to compute the section.
1928 # @return New GEOM_Object, containing a section of \a theShape
1929 # by a plane, corresponding to water level.
1931 # Example: see GEOM_TestAll.py
1932 def Archimede(self,theShape, theWeight, theWaterDensity, theMeshDeflection):
1933 anObj = self.LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection)
1934 RaiseIfFailed("MakeArchimede", self.LocalOp)
1937 # -----------------------------------------------------------------------------
1938 # Information objects
1939 # -----------------------------------------------------------------------------
1941 ## Get point coordinates
1944 # Example: see GEOM_TestMeasures.py
1945 def PointCoordinates(self,Point):
1946 aTuple = self.MeasuOp.PointCoordinates(Point)
1947 RaiseIfFailed("PointCoordinates", self.MeasuOp)
1950 ## Get summarized length of all wires,
1951 # area of surface and volume of the given shape.
1952 # @param theShape Shape to define properties of.
1953 # @return [theLength, theSurfArea, theVolume]
1954 # theLength: Summarized length of all wires of the given shape.
1955 # theSurfArea: Area of surface of the given shape.
1956 # theVolume: Volume of the given shape.
1958 # Example: see GEOM_TestMeasures.py
1959 def BasicProperties(self,theShape):
1960 aTuple = self.MeasuOp.GetBasicProperties(theShape)
1961 RaiseIfFailed("GetBasicProperties", self.MeasuOp)
1964 ## Get parameters of bounding box of the given shape
1965 # @param theShape Shape to obtain bounding box of.
1966 # @return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax]
1967 # Xmin,Xmax: Limits of shape along OX axis.
1968 # Ymin,Ymax: Limits of shape along OY axis.
1969 # Zmin,Zmax: Limits of shape along OZ axis.
1971 # Example: see GEOM_TestMeasures.py
1972 def BoundingBox(self,theShape):
1973 aTuple = self.MeasuOp.GetBoundingBox(theShape)
1974 RaiseIfFailed("GetBoundingBox", self.MeasuOp)
1977 ## Get inertia matrix and moments of inertia of theShape.
1978 # @param theShape Shape to calculate inertia of.
1979 # @return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz]
1980 # I(1-3)(1-3): Components of the inertia matrix of the given shape.
1981 # Ix,Iy,Iz: Moments of inertia of the given shape.
1983 # Example: see GEOM_TestMeasures.py
1984 def Inertia(self,theShape):
1985 aTuple = self.MeasuOp.GetInertia(theShape)
1986 RaiseIfFailed("GetInertia", self.MeasuOp)
1989 ## Get minimal distance between the given shapes.
1990 # @param theShape1,theShape2 Shapes to find minimal distance between.
1991 # @return Value of the minimal distance between the given shapes.
1993 # Example: see GEOM_TestMeasures.py
1994 def MinDistance(self, theShape1, theShape2):
1995 aTuple = self.MeasuOp.GetMinDistance(theShape1, theShape2)
1996 RaiseIfFailed("GetMinDistance", self.MeasuOp)
1999 ## Get minimal distance between the given shapes.
2000 # @param theShape1,theShape2 Shapes to find minimal distance between.
2001 # @return Value of the minimal distance between the given shapes.
2003 # Example: see GEOM_TestMeasures.py
2004 def MinDistanceComponents(self, theShape1, theShape2):
2005 aTuple = self.MeasuOp.GetMinDistance(theShape1, theShape2)
2006 RaiseIfFailed("GetMinDistance", self.MeasuOp)
2007 aRes = [aTuple[0], aTuple[4] - aTuple[1], aTuple[5] - aTuple[2], aTuple[6] - aTuple[3]]
2010 ## Get angle between the given shapes.
2011 # @param theShape1,theShape2 Lines or linear edges to find angle between.
2012 # @return Value of the angle between the given shapes.
2014 # Example: see GEOM_TestMeasures.py
2015 def GetAngle(self, theShape1, theShape2):
2016 anAngle = self.MeasuOp.GetAngle(theShape1, theShape2)
2017 RaiseIfFailed("GetAngle", self.MeasuOp)
2020 ## Get min and max tolerances of sub-shapes of theShape
2021 # @param theShape Shape, to get tolerances of.
2022 # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]
2023 # FaceMin,FaceMax: Min and max tolerances of the faces.
2024 # EdgeMin,EdgeMax: Min and max tolerances of the edges.
2025 # VertMin,VertMax: Min and max tolerances of the vertices.
2027 # Example: see GEOM_TestMeasures.py
2028 def Tolerance(self,theShape):
2029 aTuple = self.MeasuOp.GetTolerance(theShape)
2030 RaiseIfFailed("GetTolerance", self.MeasuOp)
2033 ## Obtain description of the given shape (number of sub-shapes of each type)
2034 # @param theShape Shape to be described.
2035 # @return Description of the given shape.
2037 # Example: see GEOM_TestMeasures.py
2038 def WhatIs(self,theShape):
2039 aDescr = self.MeasuOp.WhatIs(theShape)
2040 RaiseIfFailed("WhatIs", self.MeasuOp)
2043 ## Get a point, situated at the centre of mass of theShape.
2044 # @param theShape Shape to define centre of mass of.
2045 # @return New GEOM_Object, containing the created point.
2047 # Example: see GEOM_TestMeasures.py
2048 def MakeCDG(self,theShape):
2049 anObj = self.MeasuOp.GetCentreOfMass(theShape)
2050 RaiseIfFailed("GetCentreOfMass", self.MeasuOp)
2053 ## Get a normale to the given face. If the point is not given,
2054 # the normale is calculated at the center of mass.
2055 # @param theFace Face to define normale of.
2056 # @param theOptionalPoint Point to compute the normale at.
2057 # @return New GEOM_Object, containing the created vector.
2059 # Example: see GEOM_TestMeasures.py
2060 def GetNormal(self, theFace, theOptionalPoint = None):
2061 anObj = self.MeasuOp.GetNormal(theFace, theOptionalPoint)
2062 RaiseIfFailed("GetNormal", self.MeasuOp)
2065 ## Check a topology of the given shape.
2066 # @param theShape Shape to check validity of.
2067 # @param theIsCheckGeom If FALSE, only the shape's topology will be checked,
2068 # if TRUE, the shape's geometry will be checked also.
2069 # @return TRUE, if the shape "seems to be valid".
2070 # If theShape is invalid, prints a description of problem.
2072 # Example: see GEOM_TestMeasures.py
2073 def CheckShape(self,theShape, theIsCheckGeom = 0):
2075 (IsValid, Status) = self.MeasuOp.CheckShapeWithGeometry(theShape)
2076 RaiseIfFailed("CheckShapeWithGeometry", self.MeasuOp)
2078 (IsValid, Status) = self.MeasuOp.CheckShape(theShape)
2079 RaiseIfFailed("CheckShape", self.MeasuOp)
2084 ## Get position (LCS) of theShape.
2086 # Origin of the LCS is situated at the shape's center of mass.
2087 # Axes of the LCS are obtained from shape's location or,
2088 # if the shape is a planar face, from position of its plane.
2090 # @param theShape Shape to calculate position of.
2091 # @return [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz].
2092 # Ox,Oy,Oz: Coordinates of shape's LCS origin.
2093 # Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction.
2094 # Xx,Xy,Xz: Coordinates of shape's LCS X direction.
2096 # Example: see GEOM_TestMeasures.py
2097 def GetPosition(self,theShape):
2098 aTuple = self.MeasuOp.GetPosition(theShape)
2099 RaiseIfFailed("GetPosition", self.MeasuOp)
2102 ## Get kind of theShape.
2104 # @param theShape Shape to get a kind of.
2105 # @return Returns a kind of shape in terms of <VAR>GEOM_IKindOfShape.shape_kind</VAR> enumeration
2106 # and a list of parameters, describing the shape.
2107 # @note Concrete meaning of each value, returned via \a theIntegers
2108 # or \a theDoubles list depends on the kind of the shape.
2109 # The full list of possible outputs is:
2111 # geompy.kind.COMPOUND nb_solids nb_faces nb_edges nb_vertices
2112 # geompy.kind.COMPSOLID nb_solids nb_faces nb_edges nb_vertices
2114 # geompy.kind.SHELL geompy.info.CLOSED nb_faces nb_edges nb_vertices
2115 # geompy.kind.SHELL geompy.info.UNCLOSED nb_faces nb_edges nb_vertices
2117 # geompy.kind.WIRE geompy.info.CLOSED nb_edges nb_vertices
2118 # geompy.kind.WIRE geompy.info.UNCLOSED nb_edges nb_vertices
2120 # geompy.kind.SPHERE xc yc zc R
2121 # geompy.kind.CYLINDER xb yb zb dx dy dz R H
2122 # geompy.kind.BOX xc yc zc ax ay az
2123 # geompy.kind.ROTATED_BOX xc yc zc zx zy zz xx xy xz ax ay az
2124 # geompy.kind.TORUS xc yc zc dx dy dz R_1 R_2
2125 # geompy.kind.CONE xb yb zb dx dy dz R_1 R_2 H
2126 # geompy.kind.POLYHEDRON nb_faces nb_edges nb_vertices
2127 # geompy.kind.SOLID nb_faces nb_edges nb_vertices
2129 # geompy.kind.SPHERE2D xc yc zc R
2130 # geompy.kind.CYLINDER2D xb yb zb dx dy dz R H
2131 # geompy.kind.TORUS2D xc yc zc dx dy dz R_1 R_2
2132 # geompy.kind.CONE2D xc yc zc dx dy dz R_1 R_2 H
2133 # geompy.kind.DISK_CIRCLE xc yc zc dx dy dz R
2134 # geompy.kind.DISK_ELLIPSE xc yc zc dx dy dz R_1 R_2
2135 # geompy.kind.POLYGON xo yo zo dx dy dz nb_edges nb_vertices
2136 # geompy.kind.PLANE xo yo zo dx dy dz
2137 # geompy.kind.PLANAR xo yo zo dx dy dz nb_edges nb_vertices
2138 # geompy.kind.FACE nb_edges nb_vertices
2140 # geompy.kind.CIRCLE xc yc zc dx dy dz R
2141 # geompy.kind.ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2
2142 # geompy.kind.ELLIPSE xc yc zc dx dy dz R_1 R_2
2143 # geompy.kind.ARC_ELLIPSE xc yc zc dx dy dz R_1 R_2 x1 y1 z1 x2 y2 z2
2144 # geompy.kind.LINE xo yo zo dx dy dz
2145 # geompy.kind.SEGMENT x1 y1 z1 x2 y2 z2
2146 # geompy.kind.EDGE nb_vertices
2148 # geompy.kind.VERTEX x y z
2150 # Example: see GEOM_TestMeasures.py
2151 def KindOfShape(self,theShape):
2152 aRoughTuple = self.MeasuOp.KindOfShape(theShape)
2153 RaiseIfFailed("KindOfShape", self.MeasuOp)
2155 aKind = aRoughTuple[0]
2156 anInts = aRoughTuple[1]
2157 aDbls = aRoughTuple[2]
2159 # Now there is no exception from this rule:
2160 aKindTuple = [aKind] + aDbls + anInts
2162 # If they are we will regroup parameters for such kind of shape.
2164 #if aKind == kind.SOME_KIND:
2165 # # SOME_KIND int int double int double double
2166 # aKindTuple = [aKind, anInts[0], anInts[1], aDbls[0], anInts[2], aDbls[1], aDbls[2]]
2170 # -----------------------------------------------------------------------------
2171 # Import/Export objects
2172 # -----------------------------------------------------------------------------
2174 ## Import a shape from the BREP or IGES or STEP file
2175 # (depends on given format) with given name.
2176 # @param theFileName The file, containing the shape.
2177 # @param theFormatName Specify format for the file reading.
2178 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2179 # @return New GEOM_Object, containing the imported shape.
2181 # Example: see GEOM_TestOthers.py
2182 def Import(self,theFileName, theFormatName):
2183 anObj = self.InsertOp.Import(theFileName, theFormatName)
2184 RaiseIfFailed("Import", self.InsertOp)
2187 ## Shortcut to Import() for BREP format
2189 # Example: see GEOM_TestOthers.py
2190 def ImportBREP(self,theFileName):
2191 return self.Import(theFileName, "BREP")
2193 ## Shortcut to Import() for IGES format
2195 # Example: see GEOM_TestOthers.py
2196 def ImportIGES(self,theFileName):
2197 return self.Import(theFileName, "IGES")
2199 ## Shortcut to Import() for STEP format
2201 # Example: see GEOM_TestOthers.py
2202 def ImportSTEP(self,theFileName):
2203 return self.Import(theFileName, "STEP")
2205 ## Export the given shape into a file with given name.
2206 # @param theObject Shape to be stored in the file.
2207 # @param theFileName Name of the file to store the given shape in.
2208 # @param theFormatName Specify format for the shape storage.
2209 # Available formats can be obtained with InsertOp.ImportTranslators() method.
2211 # Example: see GEOM_TestOthers.py
2212 def Export(self,theObject, theFileName, theFormatName):
2213 self.InsertOp.Export(theObject, theFileName, theFormatName)
2214 if self.InsertOp.IsDone() == 0:
2215 raise RuntimeError, "Export : " + self.InsertOp.GetErrorCode()
2219 ## Shortcut to Export() for BREP format
2221 # Example: see GEOM_TestOthers.py
2222 def ExportBREP(self,theObject, theFileName):
2223 return self.Export(theObject, theFileName, "BREP")
2225 ## Shortcut to Export() for IGES format
2227 # Example: see GEOM_TestOthers.py
2228 def ExportIGES(self,theObject, theFileName):
2229 return self.Export(theObject, theFileName, "IGES")
2231 ## Shortcut to Export() for STEP format
2233 # Example: see GEOM_TestOthers.py
2234 def ExportSTEP(self,theObject, theFileName):
2235 return self.Export(theObject, theFileName, "STEP")
2237 # -----------------------------------------------------------------------------
2239 # -----------------------------------------------------------------------------
2241 ## Create a quadrangle face from four edges. Order of Edges is not
2242 # important. It is not necessary that edges share the same vertex.
2243 # @param E1,E2,E3,E4 Edges for the face bound.
2244 # @return New GEOM_Object, containing the created face.
2246 # Example: see GEOM_Spanner.py
2247 def MakeQuad(self,E1, E2, E3, E4):
2248 anObj = self.BlocksOp.MakeQuad(E1, E2, E3, E4)
2249 RaiseIfFailed("MakeQuad", self.BlocksOp)
2252 ## Create a quadrangle face on two edges.
2253 # The missing edges will be built by creating the shortest ones.
2254 # @param E1,E2 Two opposite edges for the face.
2255 # @return New GEOM_Object, containing the created face.
2257 # Example: see GEOM_Spanner.py
2258 def MakeQuad2Edges(self,E1, E2):
2259 anObj = self.BlocksOp.MakeQuad2Edges(E1, E2)
2260 RaiseIfFailed("MakeQuad2Edges", self.BlocksOp)
2263 ## Create a quadrangle face with specified corners.
2264 # The missing edges will be built by creating the shortest ones.
2265 # @param V1,V2,V3,V4 Corner vertices for the face.
2266 # @return New GEOM_Object, containing the created face.
2268 # Example: see GEOM_Spanner.py
2269 def MakeQuad4Vertices(self,V1, V2, V3, V4):
2270 anObj = self.BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4)
2271 RaiseIfFailed("MakeQuad4Vertices", self.BlocksOp)
2274 ## Create a hexahedral solid, bounded by the six given faces. Order of
2275 # faces is not important. It is not necessary that Faces share the same edge.
2276 # @param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid.
2277 # @return New GEOM_Object, containing the created solid.
2279 # Example: see GEOM_Spanner.py
2280 def MakeHexa(self,F1, F2, F3, F4, F5, F6):
2281 anObj = self.BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6)
2282 RaiseIfFailed("MakeHexa", self.BlocksOp)
2285 ## Create a hexahedral solid between two given faces.
2286 # The missing faces will be built by creating the smallest ones.
2287 # @param F1,F2 Two opposite faces for the hexahedral solid.
2288 # @return New GEOM_Object, containing the created solid.
2290 # Example: see GEOM_Spanner.py
2291 def MakeHexa2Faces(self,F1, F2):
2292 anObj = self.BlocksOp.MakeHexa2Faces(F1, F2)
2293 RaiseIfFailed("MakeHexa2Faces", self.BlocksOp)
2296 ## Get a vertex, found in the given shape by its coordinates.
2297 # @param theShape Block or a compound of blocks.
2298 # @param theX,theY,theZ Coordinates of the sought vertex.
2299 # @param theEpsilon Maximum allowed distance between the resulting
2300 # vertex and point with the given coordinates.
2301 # @return New GEOM_Object, containing the found vertex.
2303 # Example: see GEOM_TestOthers.py
2304 def GetPoint(self,theShape, theX, theY, theZ, theEpsilon):
2305 anObj = self.BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
2306 RaiseIfFailed("GetPoint", self.BlocksOp)
2309 ## Get an edge, found in the given shape by two given vertices.
2310 # @param theShape Block or a compound of blocks.
2311 # @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
2312 # @return New GEOM_Object, containing the found edge.
2314 # Example: see GEOM_Spanner.py
2315 def GetEdge(self,theShape, thePoint1, thePoint2):
2316 anObj = self.BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
2317 RaiseIfFailed("GetEdge", self.BlocksOp)
2320 ## Find an edge of the given shape, which has minimal distance to the given point.
2321 # @param theShape Block or a compound of blocks.
2322 # @param thePoint Point, close to the desired edge.
2323 # @return New GEOM_Object, containing the found edge.
2325 # Example: see GEOM_TestOthers.py
2326 def GetEdgeNearPoint(self,theShape, thePoint):
2327 anObj = self.BlocksOp.GetEdgeNearPoint(theShape, thePoint)
2328 RaiseIfFailed("GetEdgeNearPoint", self.BlocksOp)
2331 ## Returns a face, found in the given shape by four given corner vertices.
2332 # @param theShape Block or a compound of blocks.
2333 # @param thePoint1-thePoint4 Points, close to the corners of the desired face.
2334 # @return New GEOM_Object, containing the found face.
2336 # Example: see GEOM_Spanner.py
2337 def GetFaceByPoints(self,theShape, thePoint1, thePoint2, thePoint3, thePoint4):
2338 anObj = self.BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4)
2339 RaiseIfFailed("GetFaceByPoints", self.BlocksOp)
2342 ## Get a face of block, found in the given shape by two given edges.
2343 # @param theShape Block or a compound of blocks.
2344 # @param theEdge1,theEdge2 Edges, close to the edges of the desired face.
2345 # @return New GEOM_Object, containing the found face.
2347 # Example: see GEOM_Spanner.py
2348 def GetFaceByEdges(self,theShape, theEdge1, theEdge2):
2349 anObj = self.BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2)
2350 RaiseIfFailed("GetFaceByEdges", self.BlocksOp)
2353 ## Find a face, opposite to the given one in the given block.
2354 # @param theBlock Must be a hexahedral solid.
2355 # @param theFace Face of \a theBlock, opposite to the desired face.
2356 # @return New GEOM_Object, containing the found face.
2358 # Example: see GEOM_Spanner.py
2359 def GetOppositeFace(self,theBlock, theFace):
2360 anObj = self.BlocksOp.GetOppositeFace(theBlock, theFace)
2361 RaiseIfFailed("GetOppositeFace", self.BlocksOp)
2364 ## Find a face of the given shape, which has minimal distance to the given point.
2365 # @param theShape Block or a compound of blocks.
2366 # @param thePoint Point, close to the desired face.
2367 # @return New GEOM_Object, containing the found face.
2369 # Example: see GEOM_Spanner.py
2370 def GetFaceNearPoint(self,theShape, thePoint):
2371 anObj = self.BlocksOp.GetFaceNearPoint(theShape, thePoint)
2372 RaiseIfFailed("GetFaceNearPoint", self.BlocksOp)
2375 ## Find a face of block, whose outside normale has minimal angle with the given vector.
2376 # @param theShape Block or a compound of blocks.
2377 # @param theVector Vector, close to the normale of the desired face.
2378 # @return New GEOM_Object, containing the found face.
2380 # Example: see GEOM_Spanner.py
2381 def GetFaceByNormale(self,theBlock, theVector):
2382 anObj = self.BlocksOp.GetFaceByNormale(theBlock, theVector)
2383 RaiseIfFailed("GetFaceByNormale", self.BlocksOp)
2386 ## Check, if the compound of blocks is given.
2387 # To be considered as a compound of blocks, the
2388 # given shape must satisfy the following conditions:
2389 # - Each element of the compound should be a Block (6 faces and 12 edges).
2390 # - A connection between two Blocks should be an entire quadrangle face or an entire edge.
2391 # - The compound should be connexe.
2392 # - The glue between two quadrangle faces should be applied.
2393 # @param theCompound The compound to check.
2394 # @return TRUE, if the given shape is a compound of blocks.
2395 # If theCompound is not valid, prints all discovered errors.
2397 # Example: see GEOM_Spanner.py
2398 def CheckCompoundOfBlocks(self,theCompound):
2399 (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound)
2400 RaiseIfFailed("CheckCompoundOfBlocks", self.BlocksOp)
2402 Descr = self.BlocksOp.PrintBCErrors(theCompound, BCErrors)
2406 ## Remove all seam and degenerated edges from \a theShape.
2407 # Unite faces and edges, sharing one surface. It means that
2408 # this faces must have references to one C++ surface object (handle).
2409 # @param theShape The compound or single solid to remove irregular edges from.
2410 # @return Improved shape.
2412 # Example: see GEOM_TestOthers.py
2413 def RemoveExtraEdges(self,theShape):
2414 anObj = self.BlocksOp.RemoveExtraEdges(theShape)
2415 RaiseIfFailed("RemoveExtraEdges", self.BlocksOp)
2418 ## Check, if the given shape is a blocks compound.
2419 # Fix all detected errors.
2420 # \note Single block can be also fixed by this method.
2421 # @param theCompound The compound to check and improve.
2422 # @return Improved compound.
2424 # Example: see GEOM_TestOthers.py
2425 def CheckAndImprove(self,theShape):
2426 anObj = self.BlocksOp.CheckAndImprove(theShape)
2427 RaiseIfFailed("CheckAndImprove", self.BlocksOp)
2430 ## Get all the blocks, contained in the given compound.
2431 # @param theCompound The compound to explode.
2432 # @param theMinNbFaces If solid has lower number of faces, it is not a block.
2433 # @param theMaxNbFaces If solid has higher number of faces, it is not a block.
2434 # \note If theMaxNbFaces = 0, the maximum number of faces is not restricted.
2435 # @return List of GEOM_Objects, containing the retrieved blocks.
2437 # Example: see GEOM_TestOthers.py
2438 def MakeBlockExplode(self,theCompound, theMinNbFaces, theMaxNbFaces):
2439 aList = self.BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces)
2440 RaiseIfFailed("ExplodeCompoundOfBlocks", self.BlocksOp)
2443 ## Find block, containing the given point inside its volume or on boundary.
2444 # @param theCompound Compound, to find block in.
2445 # @param thePoint Point, close to the desired block. If the point lays on
2446 # boundary between some blocks, we return block with nearest center.
2447 # @return New GEOM_Object, containing the found block.
2449 # Example: see GEOM_Spanner.py
2450 def GetBlockNearPoint(self,theCompound, thePoint):
2451 anObj = self.BlocksOp.GetBlockNearPoint(theCompound, thePoint)
2452 RaiseIfFailed("GetBlockNearPoint", self.BlocksOp)
2455 ## Find block, containing all the elements, passed as the parts, or maximum quantity of them.
2456 # @param theCompound Compound, to find block in.
2457 # @param theParts List of faces and/or edges and/or vertices to be parts of the found block.
2458 # @return New GEOM_Object, containing the found block.
2460 # Example: see GEOM_TestOthers.py
2461 def GetBlockByParts(self,theCompound, theParts):
2462 anObj = self.BlocksOp.GetBlockByParts(theCompound, theParts)
2463 RaiseIfFailed("GetBlockByParts", self.BlocksOp)
2466 ## Return all blocks, containing all the elements, passed as the parts.
2467 # @param theCompound Compound, to find blocks in.
2468 # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks.
2469 # @return List of GEOM_Objects, containing the found blocks.
2471 # Example: see GEOM_Spanner.py
2472 def GetBlocksByParts(self,theCompound, theParts):
2473 aList = self.BlocksOp.GetBlocksByParts(theCompound, theParts)
2474 RaiseIfFailed("GetBlocksByParts", self.BlocksOp)
2477 ## Multi-transformate block and glue the result.
2478 # Transformation is defined so, as to superpose direction faces.
2479 # @param Block Hexahedral solid to be multi-transformed.
2480 # @param DirFace1 ID of First direction face.
2481 # @param DirFace2 ID of Second direction face.
2482 # @param NbTimes Quantity of transformations to be done.
2483 # \note Unique ID of sub-shape can be obtained, using method GetSubShapeID().
2484 # @return New GEOM_Object, containing the result shape.
2486 # Example: see GEOM_Spanner.py
2487 def MakeMultiTransformation1D(self,Block, DirFace1, DirFace2, NbTimes):
2488 anObj = self.BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes)
2489 RaiseIfFailed("MakeMultiTransformation1D", self.BlocksOp)
2492 ## Multi-transformate block and glue the result.
2493 # @param Block Hexahedral solid to be multi-transformed.
2494 # @param DirFace1U,DirFace2U IDs of Direction faces for the first transformation.
2495 # @param DirFace1V,DirFace2V IDs of Direction faces for the second transformation.
2496 # @param NbTimesU,NbTimesV Quantity of transformations to be done.
2497 # @return New GEOM_Object, containing the result shape.
2499 # Example: see GEOM_Spanner.py
2500 def MakeMultiTransformation2D(self,Block, DirFace1U, DirFace2U, NbTimesU,
2501 DirFace1V, DirFace2V, NbTimesV):
2502 anObj = self.BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU,
2503 DirFace1V, DirFace2V, NbTimesV)
2504 RaiseIfFailed("MakeMultiTransformation2D", self.BlocksOp)
2507 ## Build all possible propagation groups.
2508 # Propagation group is a set of all edges, opposite to one (main)
2509 # edge of this group directly or through other opposite edges.
2510 # Notion of Opposite Edge make sence only on quadrangle face.
2511 # @param theShape Shape to build propagation groups on.
2512 # @return List of GEOM_Objects, each of them is a propagation group.
2514 # Example: see GEOM_TestOthers.py
2515 def Propagate(self,theShape):
2516 listChains = self.BlocksOp.Propagate(theShape)
2517 RaiseIfFailed("Propagate", self.BlocksOp)
2520 # -----------------------------------------------------------------------------
2522 # -----------------------------------------------------------------------------
2524 ## Creates a new group which will store sub shapes of theMainShape
2525 # @param theMainShape is a GEOM object on which the group is selected
2526 # @param theShapeType defines a shape type of the group
2527 # @return a newly created GEOM group
2529 # Example: see GEOM_TestOthers.py
2530 def CreateGroup(self,theMainShape, theShapeType):
2531 anObj = self.GroupOp.CreateGroup(theMainShape, theShapeType)
2532 RaiseIfFailed("CreateGroup", self.GroupOp)
2535 ## Adds a sub object with ID theSubShapeId to the group
2536 # @param theGroup is a GEOM group to which the new sub shape is added
2537 # @param theSubShapeID is a sub shape ID in the main object.
2538 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2540 # Example: see GEOM_TestOthers.py
2541 def AddObject(self,theGroup, theSubShapeID):
2542 self.GroupOp.AddObject(theGroup, theSubShapeID)
2543 RaiseIfFailed("AddObject", self.GroupOp)
2546 ## Removes a sub object with ID \a theSubShapeId from the group
2547 # @param theGroup is a GEOM group from which the new sub shape is removed
2548 # @param theSubShapeID is a sub shape ID in the main object.
2549 # \note Use method GetSubShapeID() to get an unique ID of the sub shape
2551 # Example: see GEOM_TestOthers.py
2552 def RemoveObject(self,theGroup, theSubShapeID):
2553 self.GroupOp.RemoveObject(theGroup, theSubShapeID)
2554 RaiseIfFailed("RemoveObject", self.GroupOp)
2557 ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
2558 # @param theGroup is a GEOM group to which the new sub shapes are added.
2559 # @param theSubShapes is a list of sub shapes to be added.
2561 # Example: see GEOM_TestOthers.py
2562 def UnionList (self,theGroup, theSubShapes):
2563 self.GroupOp.UnionList(theGroup, theSubShapes)
2564 RaiseIfFailed("UnionList", self.GroupOp)
2567 ## Works like the above method, but argument
2568 # theSubShapes here is a list of sub-shapes indices
2570 # Example: see GEOM_TestOthers.py
2571 def UnionIDs(self,theGroup, theSubShapes):
2572 self.GroupOp.UnionIDs(theGroup, theSubShapes)
2573 RaiseIfFailed("UnionIDs", self.GroupOp)
2576 ## Removes from the group all the given shapes. No errors, if some shapes are not included.
2577 # @param theGroup is a GEOM group from which the sub-shapes are removed.
2578 # @param theSubShapes is a list of sub-shapes to be removed.
2580 # Example: see GEOM_TestOthers.py
2581 def DifferenceList (self,theGroup, theSubShapes):
2582 self.GroupOp.DifferenceList(theGroup, theSubShapes)
2583 RaiseIfFailed("DifferenceList", self.GroupOp)
2586 ## Works like the above method, but argument
2587 # theSubShapes here is a list of sub-shapes indices
2589 # Example: see GEOM_TestOthers.py
2590 def DifferenceIDs(self,theGroup, theSubShapes):
2591 self.GroupOp.DifferenceIDs(theGroup, theSubShapes)
2592 RaiseIfFailed("DifferenceIDs", self.GroupOp)
2595 ## Returns a list of sub objects ID stored in the group
2596 # @param theGroup is a GEOM group for which a list of IDs is requested
2598 # Example: see GEOM_TestOthers.py
2599 def GetObjectIDs(self,theGroup):
2600 ListIDs = self.GroupOp.GetObjects(theGroup)
2601 RaiseIfFailed("GetObjects", self.GroupOp)
2604 ## Returns a type of sub objects stored in the group
2605 # @param theGroup is a GEOM group which type is returned.
2607 # Example: see GEOM_TestOthers.py
2608 def GetType(self,theGroup):
2609 aType = self.GroupOp.GetType(theGroup)
2610 RaiseIfFailed("GetType", self.GroupOp)
2613 ## Returns a main shape associated with the group
2614 # @param theGroup is a GEOM group for which a main shape object is requested
2615 # @return a GEOM object which is a main shape for theGroup
2617 # Example: see GEOM_TestOthers.py
2618 def GetMainShape(self,theGroup):
2619 anObj = self.GroupOp.GetMainShape(theGroup)
2620 RaiseIfFailed("GetMainShape", self.GroupOp)
2623 ## Create group of edges of theShape, whose length is in range [min_length, max_length].
2624 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2625 def GetEdgesByLength (self,theShape, min_length, max_length, include_min = 1, include_max = 1):
2626 edges = self.SubShapeAll(theShape, ShapeType["EDGE"])
2629 Props = self.BasicProperties(edge)
2630 if min_length <= Props[0] and Props[0] <= max_length:
2631 if (not include_min) and (min_length == Props[0]):
2634 if (not include_max) and (Props[0] == max_length):
2637 edges_in_range.append(edge)
2639 if len(edges_in_range) <= 0:
2640 print "No edges found by given criteria"
2643 group_edges = self.CreateGroup(theShape, ShapeType["EDGE"])
2644 self.UnionList(group_edges, edges_in_range)
2648 ## Create group of edges of selected shape, whose length is in range [min_length, max_length].
2649 # If include_min/max == 0, edges with length == min/max_length will not be included in result.
2650 def SelectEdges (self,min_length, max_length, include_min = 1, include_max = 1):
2651 nb_selected = sg.SelectedCount()
2653 print "Select a shape before calling this function, please."
2656 print "Only one shape must be selected"
2659 id_shape = sg.getSelected(0)
2660 shape = IDToObject( id_shape )
2662 group_edges = self.GetEdgesByLength(shape, min_length, max_length, include_min, include_max)
2666 if include_min: left_str = " <= "
2667 if include_max: right_str = " <= "
2669 self.addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
2670 + left_str + "length" + right_str + `max_length`)
2672 sg.updateObjBrowser(1)
2676 ## Add Path to load python scripts from
2677 def addPath(self,Path):
2678 if (sys.path.count(Path) < 1):
2679 sys.path.append(Path)
2682 #Register the new proxy for GEOM_Gen
2683 omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC)