# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
#
#
g=None
step = 0
-while step < 50 and g == None:
+sleeping_time = 0.01
+sleeping_time_max = 1.0
+while 1:
g = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+ if g is not None: break
step = step + 1
- time.sleep(4)
+ if step > 100: break
+ time.sleep(sleeping_time)
+ sleeping_time = max(sleeping_time_max, 2*sleeping_time)
+ pass
geom = g._narrow( GEOM.GEOM_Gen )
-myBuilder = myStudy.NewBuilder()
-father = myStudy.FindComponent("GEOM")
-if father is None:
+myBuilder = None
+myStudyId = 0
+father = None
+
+BasicOp = None
+CurvesOp = None
+PrimOp = None
+ShapesOp = None
+HealOp = None
+InsertOp = None
+BoolOp = None
+TrsfOp = None
+LocalOp = None
+MeasuOp = None
+BlocksOp = None
+GroupOp = None
+
+def init_geom(theStudy):
+
+ global myStudy, myBuilder, myStudyId, BasicOp, CurvesOp, PrimOp, ShapesOp, HealOp
+ global InsertOp, BoolOp, TrsfOp, LocalOp, MeasuOp, BlocksOp, GroupOp, father
+
+ myStudy = theStudy
+ myStudyId = myStudy._get_StudyId()
+ myBuilder = myStudy.NewBuilder()
+ father = myStudy.FindComponent("GEOM")
+ if father is None:
father = myBuilder.NewComponent("GEOM")
A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName")
FName = A1._narrow(SALOMEDS.AttributeName)
aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
myBuilder.DefineComponentInstance(father,geom)
+ pass
+
+ # -----------------------------------------------------------------------------
+ # Assign Operations Interfaces
+ # -----------------------------------------------------------------------------
+
+ BasicOp = geom.GetIBasicOperations (myStudyId)
+ CurvesOp = geom.GetICurvesOperations (myStudyId)
+ PrimOp = geom.GetI3DPrimOperations (myStudyId)
+ ShapesOp = geom.GetIShapesOperations (myStudyId)
+ HealOp = geom.GetIHealingOperations (myStudyId)
+ InsertOp = geom.GetIInsertOperations (myStudyId)
+ BoolOp = geom.GetIBooleanOperations (myStudyId)
+ TrsfOp = geom.GetITransformOperations(myStudyId)
+ LocalOp = geom.GetILocalOperations (myStudyId)
+ MeasuOp = geom.GetIMeasureOperations (myStudyId)
+ BlocksOp = geom.GetIBlocksOperations (myStudyId)
+ GroupOp = geom.GetIGroupOperations (myStudyId)
+ pass
+
+init_geom(myStudy)
# * Get name for sub-shape aSubObj of shape aMainObj
#
ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
-# -----------------------------------------------------------------------------
-# Get Operations Interfaces
-# -----------------------------------------------------------------------------
-
-BasicOp = geom.GetIBasicOperations (myStudyId)
-CurvesOp = geom.GetICurvesOperations (myStudyId)
-PrimOp = geom.GetI3DPrimOperations (myStudyId)
-ShapesOp = geom.GetIShapesOperations (myStudyId)
-HealOp = geom.GetIHealingOperations (myStudyId)
-InsertOp = geom.GetIInsertOperations (myStudyId)
-BoolOp = geom.GetIBooleanOperations (myStudyId)
-TrsfOp = geom.GetITransformOperations(myStudyId)
-LocalOp = geom.GetILocalOperations (myStudyId)
-MeasuOp = geom.GetIMeasureOperations (myStudyId)
-BlocksOp = geom.GetIBlocksOperations (myStudyId)
-GroupOp = geom.GetIGroupOperations (myStudyId)
-
# -----------------------------------------------------------------------------
# Basic primitives
# -----------------------------------------------------------------------------
print "MakePointOnCurve : ", BasicOp.GetErrorCode()
return anObj
+def MakeVertexOnLinesIntersection(line1,line2):
+ anObj = BasicOp.MakePointOnLinesIntersection(line1,line2)
+ if BasicOp.IsDone() == 0:
+ print "MakePointOnLinesIntersection : ", BasicOp.GetErrorCode()
+ return anObj
+
def MakeVectorDXDYDZ(dx,dy,dz):
anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz)
if BasicOp.IsDone() == 0:
print "MakeLineTwoPnt : ", BasicOp.GetErrorCode()
return anObj
+def MakeLineTwoFaces(f1, f2):
+ anObj = BasicOp.MakeLineTwoFaces(f1,f2)
+ if BasicOp.IsDone() == 0:
+ print "MakeLineTwoFaces : ", BasicOp.GetErrorCode()
+ return anObj
+
def MakePlane(p1,v1,trimsize):
anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize)
if BasicOp.IsDone() == 0:
print "MakeMarker : ", BasicOp.GetErrorCode()
return anObj
+def MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec):
+ """
+ * Create a local coordinate system.
+ * \param theOrigin Point of coordinate system origin.
+ * \param theXVec Vector of X direction
+ * \param theYVec Vector of Y direction
+ * \return New GEOM_Object, containing the created coordinate system.
+ """
+ O = PointCoordinates( theOrigin )
+ OXOY = []
+ for vec in [ theXVec, theYVec ]:
+ v1, v2 = SubShapeAll( vec, ShapeType["VERTEX"] )
+ p1 = PointCoordinates( v1 )
+ p2 = PointCoordinates( v2 )
+ for i in range( 0, 3 ):
+ OXOY.append( p2[i] - p1[i] )
+ #
+ anObj = BasicOp.MakeMarker( O[0], O[1], O[2],
+ OXOY[0], OXOY[1], OXOY[2],
+ OXOY[3], OXOY[4], OXOY[5], )
+ if BasicOp.IsDone() == 0:
+ print "MakeMarker : ", BasicOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Curves
# -----------------------------------------------------------------------------
print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode()
return anObj
+def MakeCircleCenter2Pnt(p1,p2,p3):
+ anObj = CurvesOp.MakeCircleCenter2Pnt(p1,p2,p3)
+ if CurvesOp.IsDone() == 0:
+ print "MakeCircleCenter2Pnt : ", CurvesOp.GetErrorCode()
+ return anObj
+
def MakeEllipse(p1,v1,radiusMaj,radiusMin):
anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin)
if CurvesOp.IsDone() == 0:
print "MakeSketcher : ", CurvesOp.GetErrorCode()
return anObj
+def MakeSketcherOnPlane(theCommand, theWorkingPlane):
+ """
+ * Create a sketcher (wire or face), following the textual description,
+ * passed through \a theCommand argument. \n
+ * For format of the description string see the previous method.\n
+ * \param theCommand String, defining the sketcher in local
+ * coordinates of the working plane.
+ * \param theWorkingPlane Planar Face of the working plane.
+ * \return New GEOM_Object, containing the created wire.
+ """
+ anObj = CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
+ if CurvesOp.IsDone() == 0:
+ print "MakeSketcher : ", CurvesOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Create 3D Primitives
# -----------------------------------------------------------------------------
print "MakePrismTwoPnt : ", PrimOp.GetErrorCode()
return anObj
+def MakePrism2Ways(baseShape,point1,point2):
+ anObj = PrimOp.MakePrismTwoPnt2Ways(baseShape,point1,point2)
+ if PrimOp.IsDone() == 0:
+ print "MakePrismTwoPnt2Ways : ", PrimOp.GetErrorCode()
+ return anObj
+
def MakePrismVecH(baseShape,vector,height):
anObj = PrimOp.MakePrismVecH(baseShape,vector,height)
if PrimOp.IsDone() == 0:
print "MakePrismVecH : ", PrimOp.GetErrorCode()
return anObj
+def MakePrismVecH2Ways(baseShape,vector,height):
+ anObj = PrimOp.MakePrismVecH2Ways(baseShape,vector,height)
+ if PrimOp.IsDone() == 0:
+ print "MakePrismVecH2Ways : ", PrimOp.GetErrorCode()
+ return anObj
+
def MakePipe(baseShape,pathShape):
anObj = PrimOp.MakePipe(baseShape,pathShape)
if PrimOp.IsDone() == 0:
print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode()
return anObj
+def MakeRevolution2Ways(aShape,axis,angle):
+ anObj = PrimOp.MakeRevolutionAxisAngle2Ways(aShape,axis,angle)
+ if PrimOp.IsDone() == 0:
+ print "MakeRevolutionAxisAngle2Ways : ", PrimOp.GetErrorCode()
+ return anObj
+
# -----------------------------------------------------------------------------
# Create base shapes
# -----------------------------------------------------------------------------
print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
return aList
+def GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState):
+ aList = ShapesOp.GetShapesOnPlaneIDs(theShape, theShapeType, theAx1, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnPlaneIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
if ShapesOp.IsDone() == 0:
print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
return aList
+def GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState):
+ aList = ShapesOp.GetShapesOnCylinderIDs(theShape, theShapeType, theAxis, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnCylinderIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
if ShapesOp.IsDone() == 0:
print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
return aList
+def GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState):
+ aList = ShapesOp.GetShapesOnSphereIDs(theShape, theShapeType, theCenter, theRadius, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnSphereIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
+ aList = ShapesOp.GetShapesOnQuadrangle(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnQuadrangle : ", ShapesOp.GetErrorCode()
+ return aList
+
+def GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState):
+ aList = ShapesOp.GetShapesOnQuadrangleIDs(theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState)
+ if ShapesOp.IsDone() == 0:
+ print "GetShapesOnQuadrangleIDs : ", ShapesOp.GetErrorCode()
+ return aList
+
def GetInPlace(theShapeWhere, theShapeWhat):
anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
if ShapesOp.IsDone() == 0:
return MakeBoolean(s1, s2, 4)
def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
- Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
+ Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+ KeepNonlimitShapes=0):
anObj = BoolOp.MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials);
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes);
if BoolOp.IsDone() == 0:
print "MakePartition : ", BoolOp.GetErrorCode()
return anObj
def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
- Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]):
+ Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+ KeepNonlimitShapes=0):
anObj = MakePartition(ListShapes, ListTools,
ListKeepInside, ListRemoveInside,
- Limit, RemoveWebs, ListMaterials);
+ Limit, RemoveWebs, ListMaterials,
+ KeepNonlimitShapes);
return anObj
def MakeHalfPartition(theShape, thePlane):
print "RotateCopy : ", TrsfOp.GetErrorCode()
return anObj
+def MakeRotationThreePoints(aShape, centpoint, point1, point2):
+ anObj = TrsfOp.RotateThreePointsCopy(aShape, centpoint, point1, point2)
+ if TrsfOp.IsDone() == 0:
+ print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
+ return anObj
+
def MakeScaleTransform(aShape,theCenterofScale,factor):
anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
if TrsfOp.IsDone() == 0:
print "MakeFillet : ", LocalOp.GetErrorCode()
return anObj
+def MakeFilletR1R2(aShape,radius1,radius2,aShapeType,ListShape):
+ anObj = None
+ if aShapeType == ShapeType["EDGE"]:
+ anObj = LocalOp.MakeFilletEdgesR1R2(aShape,radius1,radius2,ListShape)
+ else:
+ anObj = LocalOp.MakeFilletFacesR1R2(aShape,radius1,radius2,ListShape)
+ if LocalOp.IsDone() == 0:
+ print "MakeFilletR1R2 : ", LocalOp.GetErrorCode()
+ return anObj
+
def MakeChamferAll(aShape,d):
anObj = LocalOp.MakeChamferAll(aShape,d)
if LocalOp.IsDone() == 0:
print "MakeChamferEdge : ", LocalOp.GetErrorCode()
return anObj
+def MakeChamferEdgeAD(aShape,d,angle,face1,face2):
+ anObj = LocalOp.MakeChamferEdgeAD(aShape,d,angle,face1,face2)
+ if LocalOp.IsDone() == 0:
+ print "MakeChamferEdgeAD : ", LocalOp.GetErrorCode()
+ return anObj
+
def MakeChamferFaces(aShape,d1,d2,ListShape):
anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape)
if LocalOp.IsDone() == 0:
print "MakeChamferFaces : ", LocalOp.GetErrorCode()
return anObj
+def MakeChamferFacesAD(aShape,d,angle,ListShape):
+ anObj = LocalOp.MakeChamferFacesAD(aShape,d,angle,ListShape)
+ if LocalOp.IsDone() == 0:
+ print "MakeChamferFacesAD : ", LocalOp.GetErrorCode()
+ return anObj
+
+def MakeChamferEdges(aShape,d1,d2,ListShape):
+ anObj = LocalOp.MakeChamferEdges(aShape,d1,d2,ListShape)
+ if LocalOp.IsDone() == 0:
+ print "MakeChamferEdges : ", LocalOp.GetErrorCode()
+ return anObj
+
+def MakeChamferEdgesAD(aShape,d,angle,ListShape):
+ anObj = LocalOp.MakeChamferEdgesAD(aShape,d,angle,ListShape)
+ if LocalOp.IsDone() == 0:
+ print "MakeChamferEdgesAD : ", LocalOp.GetErrorCode()
+ return anObj
+
def MakeChamfer(aShape,d1,d2,aShapeType,ListShape):
anObj = None
if aShapeType == ShapeType["EDGE"]:
print "GetCentreOfMass : ", MeasuOp.GetErrorCode()
return anObj
-def CheckShape(aShape):
- (IsValid, Status) = MeasuOp.CheckShape(aShape)
+def CheckShape(theShape, theIsCheckGeom = 0):
+ if theIsCheckGeom:
+ (IsValid, Status) = MeasuOp.CheckShapeWithGeometry(theShape)
+ else:
+ (IsValid, Status) = MeasuOp.CheckShape(theShape)
+
if MeasuOp.IsDone() == 0:
print "CheckShape : ", MeasuOp.GetErrorCode()
else:
if GroupOp.IsDone() == 0:
print "UnionList : ", GroupOp.GetErrorCode()
+def UnionIDs(theGroup, theSubShapes):
+ GroupOp.UnionIDs(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "UnionIDs : ", GroupOp.GetErrorCode()
+
def DifferenceList (theGroup, theSubShapes):
GroupOp.DifferenceList(theGroup, theSubShapes)
if GroupOp.IsDone() == 0:
print "DifferenceList : ", GroupOp.GetErrorCode()
+def DifferenceIDs(theGroup, theSubShapes):
+ GroupOp.DifferenceIDs(theGroup, theSubShapes)
+ if GroupOp.IsDone() == 0:
+ print "DifferenceIDs : ", GroupOp.GetErrorCode()
+
def GetObjectIDs(Group):
ListIDs = GroupOp.GetObjects(Group)
if GroupOp.IsDone() == 0: