コード例 #1
0
def loop_waterline(zh, cutter,s):
    range=2
    Nmax = 200
    yvals = [float(n-float(Nmax)/2)/Nmax*range for n in xrange(0,Nmax+1)]
    xvals = [float(n-float(Nmax)/2)/Nmax*range for n in xrange(0,Nmax+1)]
    bpc = ocl.BatchPushCutter()
    bpc.setXDirection()
    bpc.setSTL(s)
    bpc.setCutter(cutter)
    for y in yvals:
        f1 = ocl.Point(-range,y,zh) # start point of fiber
        f2 = ocl.Point(+range,y,zh)  # end point of fiber
        f =  ocl.Fiber( f1, f2)
        bpc.appendFiber(f)
    for x in xvals:
        f1 = ocl.Point(x,-range,zh) # start point of fiber
        f2 = ocl.Point(x,+range,zh)  # end point of fiber
        f =  ocl.Fiber( f1, f2)
        bpc.appendFiber(f)
    bpc.run()
    clpoints = bpc.getCLPoints()
    fibers = bpc.getFibers()
    w = ocl.Weave()
    print "Weave...",
    for f in fibers:
        w.addFiber(f)
    print "build()...",
    w.build()
    print "face_traverse()...",
    w.face_traverse()
    print "done."
    return w.getLoops()
コード例 #2
0
def waterline(cutter, s, zh, tol=0.1):
    bpc = ocl.BatchPushCutter()
    bpc.setSTL(s)
    bpc.setCutter(cutter)
    bounds = s.getBounds()
    xmin = bounds[0] - 2 * cutter.getRadius()
    xmax = bounds[1] + 2 * cutter.getRadius()
    ymin = bounds[2] - 2 * cutter.getRadius()
    ymax = bounds[3] + 2 * cutter.getRadius()
    Nx = int((xmax - xmin) / tol)
    Ny = int((ymax - ymin) / tol)
    xvals = generateRange(xmin, xmax, Nx)
    yvals = generateRange(ymin, ymax, Ny)
    for y in yvals:
        f1 = ocl.Point(xmin, y, zh)  # start point of fiber
        f2 = ocl.Point(xmax, y, zh)  # end point of fiber
        f = ocl.Fiber(f1, f2)
        bpc.appendFiber(f)
    for x in xvals:
        f1 = ocl.Point(x, ymin, zh)  # start point of fiber
        f2 = ocl.Point(x, ymax, zh)  # end point of fiber
        f = ocl.Fiber(f1, f2)
        bpc.appendFiber(f)
    bpc.run()
    fibers = bpc.getFibers()  # get fibers
    w = ocl.Weave()
    for f in fibers:
        w.addFiber(f)

    print " build()...",
    w.build()
    print "done"
    print " split()...",
    subw = w.get_components()
    print "done. graph has", len(subw), "sub-weaves"
    m = 0
    loops = []
    for sw in subw:
        print m, " face_traverse...",
        t_before = time.time()
        sw.face_traverse()
        t_after = time.time()
        calctime = t_after - t_before
        print "done in ", calctime, " s."
        sw_loops = sw.getLoops()
        for lop in sw_loops:
            loops.append(lop)
        m = m + 1
    return loops
コード例 #3
0
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    
    cutter = ocl.CylCutter(0.3, 5)
    #cutter = ocl.BallCutter(0.4, 5)
    #cutter = ocl.BullCutter(0.4, 0.1, 5)
    
    print("fiber...")
    fiber_range=30
    Nmax = 400
    yvals = [float(n-float(Nmax)/2)/Nmax*float(fiber_range) for n in range(0,Nmax+1)]
    xvals = [float(n-float(Nmax)/2)/Nmax*float(fiber_range) for n in range(0,Nmax+1)]

    zvals=[ 1.6523]


    bpc_x = ocl.BatchPushCutter()
    bpc_y = ocl.BatchPushCutter()
    bpc_x.setXDirection()
    bpc_y.setYDirection()
    bpc_x.setSTL(s)
    bpc_y.setSTL(s)
    bpc_x.setCutter(cutter)
    bpc_y.setCutter(cutter)
    # create fibers
    for zh in zvals:
        for y in yvals:
            f1 = ocl.Point(-15.5,y,zh) # start point of fiber
            f2 = ocl.Point(15.5,y,zh)  # end point of fiber
            f =  ocl.Fiber( f1, f2)
            bpc_x.appendFiber(f)
        for x in xvals:
コード例 #4
0
    yvals = [
        float(n - float(Nmax) / 2) / Nmax * range for n in xrange(0, Nmax + 1)
    ]
    xvals = [
        float(n - float(Nmax) / 2) / Nmax * range for n in xrange(0, Nmax + 1)
    ]
    zmin = -0.1
    zmax = 0.5
    zNmax = 20
    dz = (zmax - zmin) / (zNmax - 1)
    zvals = []
    zvals.append(0.2)
    for n in xrange(0, zNmax):
        zvals.append(zmin + n * dz)

    bpc = ocl.BatchPushCutter()
    bpc.setSTL(s)
    bpc.setCutter(cutter)
    # create fibers
    for zh in zvals:
        for y in yvals:
            f1 = ocl.Point(-0.5, y, zh)  # start point of fiber
            f2 = ocl.Point(1.5, y, zh)  # end point of fiber
            f = ocl.Fiber(f1, f2)
            bpc.appendFiber(f)
        for x in xvals:
            f1 = ocl.Point(x, -0.5, zh)  # start point of fiber
            f2 = ocl.Point(x, 1.5, zh)  # end point of fiber
            f = ocl.Fiber(f1, f2)
            bpc.appendFiber(f)
コード例 #5
0
 print(cutter)
 xmin = -1
 xmax = 15
 N = 100
 ymin = -1
 ymax = 15
 yvals = generateRange(ymin, ymax, N)
 xvals = generateRange(xmin, xmax, N)
 #print xvals
 zmin = -0.1
 zmax = 2.75
 zNmax = 5
 zvals = generateRange(zmin, zmax, zNmax)
 print(" calculating waterlines at ", len(zvals), " different z-heights")
 #print zvals
 bpcx = ocl.BatchPushCutter()
 bpcy = ocl.BatchPushCutter()
 bpcx.setXDirection()
 bpcy.setYDirection()
 bpcx.setSTL(s)
 bpcy.setSTL(s)
 bpcx.setCutter(cutter)
 bpcy.setCutter(cutter)
 # create fibers
 nfibers = 0
 for zh in zvals:
     for y in yvals:
         f1 = ocl.Point(xmin, y, zh)  # start point of fiber
         f2 = ocl.Point(xmax, y, zh)  # end point of fiber
         f = ocl.Fiber(f1, f2)
         bpcx.appendFiber(f)
コード例 #6
0
def getWeaveRAM(Nmax,weave2_flag):
    #stl = camvtk.STLSurf("../stl/demo.stl")
    stl = camvtk.STLSurf("../../stl/gnu_tux_mod.stl")
    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    cutter = ocl.CylCutter(0.3, 5)
    fiber_range=30
    #Nmax = 400
    yvals = [float(n-float(Nmax)/2)/Nmax*float(fiber_range) for n in range(0,Nmax+1)]
    xvals = [float(n-float(Nmax)/2)/Nmax*float(fiber_range) for n in range(0,Nmax+1)]
    zvals=[ 1.6523]
    bpc_x = ocl.BatchPushCutter()
    bpc_y = ocl.BatchPushCutter()
    bpc_x.setXDirection()
    bpc_y.setYDirection()
    bpc_x.setSTL(s)
    bpc_y.setSTL(s)
    bpc_x.setCutter(cutter)
    bpc_y.setCutter(cutter)
    # create fibers
    for zh in zvals:
        for y in yvals:
            f1 = ocl.Point(-15.5,y,zh) # start point of fiber
            f2 = ocl.Point(15.5,y,zh)  # end point of fiber
            f =  ocl.Fiber( f1, f2)
            bpc_x.appendFiber(f)
        for x in xvals:
            f1 = ocl.Point(x,-15.5,zh) # start point of fiber
            f2 = ocl.Point(x,15.5,zh)  # end point of fiber
            f =  ocl.Fiber( f1, f2)
            bpc_y.appendFiber(f)
            
    # run
    bpc_x.run()
    bpc_y.run()
    xfibers = bpc_x.getFibers()
    yfibers = bpc_y.getFibers()
    fibers = xfibers+yfibers
    print(" got ",len(xfibers)," xfibers")
    print(" got ",len(yfibers)," yfibers")
    fibercount = len(xfibers) + len(yfibers)
    print("rendering fibers and CL-points.")
    w = ocl.Weave()
    print("push fibers to Weave...",)
    for f in fibers:
        w.addFiber(f)
    print("done.")
    print("Weave build()...",)
    mem1 = procmemory.memory()
    if weave2_flag==1:
        w.build2()
    else:
        w.build()
    mem2 = procmemory.memory()
    #print "after ", float(mem2)/float(1024*1024), " MB"
    megabytes = float(mem2-mem1)/float(1024*1024)
    megabytes2 = float(mem2)/float(1024*1024)
    verts = w.numVertices()
    print(" before: ", float(mem1)/float(1024*1024))
    print("  after: ", float(mem2)/float(1024*1024))
    print(" build() memory: ",megabytes," MB")
    print("done")
    print("face_traverse...")
    w.face_traverse()
    print("done.")
    w_clpts = w.getCLVertices()
    w_ipts = w.getINTVertices()
    w_edges = w.getEdges()
    w_loop = w.getLoops()


    print(" got: ", len(w_edges), " edges")
    print(" got: ", len(w_loop), " loops")
    out=[]
    out.append(fibercount)
    out.append(verts)
    return out