import SALOMEDS
-#O = geompy.MakeVertex(0, 0, 0)
-#OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
-#OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
-#OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
-
-#geompy.addToStudy( O, 'O' )
-#geompy.addToStudy( OX, 'OX' )
-#geompy.addToStudy( OY, 'OY' )
-#geompy.addToStudy( OZ, 'OZ' )
-
-#r1 = 100.0
-#r2 = 50.0
-#h1 = 200.0
-#h2 = 200.0
-
-def demidisk(study, r1, a1, roty=0):
+def demidisk(study, r1, a1, roty=0, solid_thickness=0): # TODO retablir l'épaisseur de solide à 0 par défaut
+ if solid_thickness < 1e-7:
+ with_solid = False
+ else:
+ with_solid = True
+
geompy = geomBuilder.New(study)
O = geompy.MakeVertex(0, 0, 0)
arc1 = geompy.MakeArc(v[1], v7, v[3])
l[0] = geompy.MakeLineTwoPnt(v[1], v[3])
face1 = geompy.MakeFaceWires([arc1, l[0]], 1)
- part1 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
+
+ if with_solid:
+ v0 = geompy.MakeVertex(0, r1 + solid_thickness, 0)
+ l0 = geompy.MakeLineTwoPnt(v[1], v0)
+ l2 = geompy.MakeRotation(l0, OX, a1*math.pi/180.0)
+ l3 = geompy.MakeRotation(l0, OX, math.pi - (a1*math.pi/180.0))
+ face2 = geompy.MakeRevolution(l0, OX, a1*math.pi/180.0)
+ face3 = geompy.MakeRevolution(l2, OX, math.pi - 2*a1*math.pi/180.0)
+ face4 = geompy.MakeRevolution(l3, OX, a1*math.pi/180.0)
+ part0 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
+ compound1 = geompy.MakeCompound([part0, face2, face3, face4])
+ part1 = geompy.MakeGlueEdges(compound1,1e-7)
+ else:
+ part1 = geompy.MakePartition([face1], [l[2], l[4], l[5], l[6], l[7]], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
if roty != 0:
vrot = [ geompy.MakeRotation(vert, OY, roty*math.pi/180.0) for vert in v ]
v1, l1, arc1, part1 = demidisk(study, r1, a1)
v2, l2, arc2, part2 = demidisk(study, r2, a1, 90.0)
- geompy.addToStudy(part1, 'part1')
- geompy.addToStudy(part2, 'part2')
-
# --- extrusion des sections --> demi cylindres de travail, pour en extraire les sections utilisées au niveau du Té
# et enveloppe cylindrique du cylindre principal
demicyl1 = geompy.MakePrismVecH(part1, OX, h1)
demicyl2 = geompy.MakePrismVecH(part2, OZ, h2)
arcextru = geompy.MakePrismVecH(arc1, OX, h1)
-
- geompy.addToStudy(demicyl1, 'demicyl1')
- geompy.addToStudy(demicyl2, 'demicyl2')
- geompy.addToStudy(arcextru, 'arcextru')
+
+ """
+ res = geompy.MakeCompound([demicyl1,demicyl2])
+ return res
+ """
# --- plan de coupe à 45° sur le cylindre principal,
# section à 45° du cylndre principal,
#geompy.addToStudy(plan, "plan%d"%i)
section = geompy.MakeSection(plan, arcextru, True)
secpart = geompy.MakePartition([section], [sect45, sect90], [], [], geompy.ShapeType["EDGE"], 0, [], 0, True)
- #geompy.addToStudy(secpart, "secpart%d"%i)
+ geompy.addToStudy(secpart, "secpart%d"%i)
lsec = geompy.ExtractShapes(secpart, geompy.ShapeType["EDGE"], True)
#print "len(lsec)", len(lsec)
+
+ # TODO : revoir ça dans le cas avec solide
for l in lsec:
pts = geompy.ExtractShapes(l, geompy.ShapeType["VERTEX"], True)
if (((geompy.MinDistance(pts[0], p0) < 0.001) and (geompy.MinDistance(pts[1], p1) < 0.001)) or
((geompy.MinDistance(pts[1], p0) < 0.001) and (geompy.MinDistance(pts[0], p1) < 0.001))):
curv[i+2] =l
- #print "curv_%d OK"%i
+ print "curv_%d OK"%i
break
- for i,l in enumerate(curv):
- geompy.addToStudyInFather(arcextru, l, "curv%d"%i)
+ # RNC : commente temporairement
+ #for i,l in enumerate(curv):
+ # geompy.addToStudyInFather(arcextru, l, "curv%d"%i)
# --- creation des arêtes droites manquantes, des faces et volumes pour les quatre volumes de la jonction
edges[5] = geompy.MakeLineTwoPnt(vord45[5], vord90[5])
edges[6] = curv[2]
edges[7] = curv[3]
- for i,l in enumerate(edges):
- geompy.addToStudy( l, "edge%d"%i)
+ #for i,l in enumerate(edges):
+ # print i
+ # geompy.addToStudy( l, "edge%d"%i)
ed45 = [None for i in range(8)]
ed45[0] = geompy.MakeLineTwoPnt(vord45[0], vord45[2])
# --- extrusion droite des faces de jonction, pour reconstituer les demi cylindres
extru1 = geompy.MakePrismVecH(sect45, OX, h1+10)
- geompy.addToStudy(extru1, "extru1")
base2 = geompy.MakePartition(faci[5:], [], [], [], geompy.ShapeType["FACE"], 0, [], 0, True)
extru2 = geompy.MakePrismVecH(base2, OZ, h2)
- geompy.addToStudy(extru2, "extru2")
# --- partition et coupe
demiDisque = geompy.MakeFaceWires([arc1, l1[0]], 1)
demiCylindre = geompy.MakePrismVecH(demiDisque, OX, h1)
- #geompy.addToStudy(demiCylindre, "demiCylindre")
+
box = geompy.MakeBox(0, -2*(r1+h1), -2*(r1+h1), 2*(r1+h1), 2*(r1+h1), 2*(r1+h1))
rot = geompy.MakeRotation(box, OY, 45*math.pi/180.0)
- #geompy.addToStudy(rot, "rot")
+
garder = geompy.MakeCutList(demiCylindre, [extru2, rot], True)
- geompy.addToStudy(garder, "garder")
raccord = geompy.MakePartition([garder], faci, [], [], geompy.ShapeType["SOLID"], 0, [], 0, True)
assemblage = geompy.MakePartition([raccord, extru1, extru2], [], [], [], geompy.ShapeType["SOLID"], 0, [], 0, True)
- geompy.addToStudy(assemblage, "assemblage")
box = geompy.MakeBox(-1, -(r1+r2), -1, h1, r1+r2, h2)
geompy.addToStudy(box, "box")
final = geompy.MakeCommonList([box, assemblage], True)
+ # --- Partie inférieure
+ v3, l3, arc3, part3 = demidisk(study, r1, a1, 180.0)
+ geompy.addToStudy(part3,"part3")
+ extru3 = geompy.MakePrismVecH(part3, OX, h1)
+ geompy.addToStudy(extru3,"extru3")
+
+ # --- Symétrie
+
+ compound = geompy.MakeCompound([final, extru3])
+ plane = geompy.MakePlane(O,OX,2000)
+ compound_mirrored = geompy.MakeMirrorByPlane(compound, plane)
+ final = geompy.MakeCompound([compound, compound_mirrored])
+
return final
+
+if __name__=="__main__":
+ """For testing purpose"""
+ salome.salome_init()
+ theStudy = salome.myStudy
+ geompy = geomBuilder.New(theStudy)
+ res = build_shape(theStudy, 80, 20, 100, 100)
+ geompy.addToStudy(res, "res")