import geompy, smesh, salome

salome.salome_init()

# get wire geometry
filename = "/misc/dn25/salome/eap/salome/misc/tmp/Cable_Total.step"
#filename = "/misc/dn25/salome/eap/salome/misc/tmp/3ft wire.STEP"
wire_shape = geompy.ImportSTEP(filename)
#wire_shape = salome.myStudy.FindObjectByName( "Cable_Total.step_1", "GEOM" )[0].GetObject()
#wire_shape = salome.myStudy.FindObjectByName( "Group_1", "GEOM" )[0].GetObject()

# group EDGEs and FACEs
circular_edges = []
disks_faces    = []
for face in geompy.SubShapeAll( wire_shape, geompy.ShapeType["FACE"]):
    if geompy.NumberOfEdges( face ) <= 2:
        disks_faces.append( face )
        circular_edges.extend( geompy.SubShapeAll( face, geompy.ShapeType["EDGE"]))
# make corresponding compounds
circular_edges = geompy.MakeCompound( circular_edges )
disks_faces    = geompy.MakeCompound( disks_faces )

# meshing

nbSegStraight = 500
nbSegCircular = 15

mesh = smesh.Mesh( wire_shape )
mesh.Segment().NumberOfSegments( nbSegStraight )
mesh.Quadrangle()
#mesh.Prism() # it 
mesh.AddHypothesis( smesh.CreateHypothesis("Prism_3D")) 
mesh.Segment( circular_edges ).NumberOfSegments( nbSegCircular )
mesh.Triangle( disks_faces )

mesh.Compute()

