Esempio n. 1
0
def cutting_tool(diameter, corner_radius, length):
    cutter = ocl.CylCutter(1.0, length)  # dummy cutter
    if corner_radius == 0.0:
        cutter = ocl.CylCutter(diameter, length)
    elif corner_radius > diameter / 2 - 0.000000001:
        cutter = ocl.BallCutter(diameter, length)
    else:
        cutter = ocl.BullCutter(diameter, corner_radius, length)

    return (cutter)
Esempio n. 2
0
 def OCLDefinition(self, surface):
     import ocl
     if self.type == TOOL_TYPE_BALLENDMILL:
         return ocl.BallCutter(self.diameter + surface.material_allowance * 2, 1000)
     elif self.type == TOOL_TYPE_CHAMFER or self.type == TOOL_TYPE_ENGRAVER:
         return ocl.CylConeCutter(self.flat_radius * 2 + surface.material_allowance, self.diameter + surface.material_allowance * 2, self.cutting_edge_angle * math.pi/360)
     else:
         if self.corner_radius > 0.000000001:
             return ocl.BullCutter(self.diameter + surface.material_allowance * 2, self.corner_radius, 1000)
         else:
             return ocl.CylCutter(self.diameter + surface.material_allowance * 2, 1000)
Esempio n. 3
0
def ocl_sample(operation, chunks):

    oclSTL = get_oclSTL(operation)

    op_cutter_type = operation.cutter_type
    op_cutter_diameter = operation.cutter_diameter
    op_minz = operation.minz
    if op_cutter_type == "VCARVE":
        op_cutter_tip_angle = operation['cutter_tip_angle']

    cutter = None
    cutter_length = 5

    if op_cutter_type == 'END':
        cutter = ocl.CylCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'BALLNOSE':
        cutter = ocl.BallCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'VCARVE':
        cutter = ocl.ConeCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000,
            op_cutter_tip_angle, cutter_length)
    elif op_cutter_type == 'BALLCONE':
        angle = math.degrees(
            math.atan((op_cutter_diameter / 2) - operation.ball_radius) /
            (operation.ball_cone_flute - operation.ball_radius))
        print("BallCone angle:" + str(angle))
        cutter = ocl.BallConeCutter(
            (operation.ball_radius + operation.skin) * 2000,
            (op_cutter_diameter + operation.skin * 2) * 1000,
            math.radians(angle))
    elif op_cutter_type == 'BULLNOSE':
        cutter = ocl.BullCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000,
            operaton.bull_corner_radius * 1000, cutter_length)
    else:
        print("Cutter unsupported: {0}\n".format(op_cutter_type))
        quit()

    bdc = ocl.BatchDropCutter()
    bdc.setSTL(oclSTL)
    bdc.setCutter(cutter)

    for chunk in chunks:
        for coord in chunk.points:
            bdc.appendPoint(
                ocl.CLPoint(coord[0] * 1000, coord[1] * 1000, op_minz * 1000))

    bdc.run()

    cl_points = bdc.getCLPoints()

    return cl_points
Esempio n. 4
0
def oclGetWaterline(operation, chunks):
    layers = oclWaterlineLayerHeights(operation)
    oclSTL = get_oclSTL(operation)

    cutter_props = operation.getOpCuttingTool()

    op_cutter_type = cutter_props.cutter_type
    op_cutter_diameter = cutter_props.cutter_diameter
    op_minz = operation.minz
    if op_cutter_type == "VCARVE":
        op_cutter_tip_angle = cutter_props.cutter_tip_angle

    cutter = None
    cutter_length = 150  #TODO: automatically determine necessary cutter length depending on object size

    if op_cutter_type == 'END':
        cutter = ocl.CylCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'BALLNOSE':
        cutter = ocl.BallCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'VCARVE':
        cutter = ocl.ConeCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000,
            op_cutter_tip_angle, cutter_length)
    else:
        print("Cutter unsupported: {0}\n".format(op_cutter_type))
        quit()

    waterline = ocl.Waterline()
    waterline.setSTL(oclSTL)
    waterline.setCutter(cutter)
    waterline.setSampling(0.1)  #TODO: add sampling setting to UI
    for height in layers:
        print(str(height) + '\n')
        waterline.reset()
        waterline.setZ(height * OCL_SCALE)
        waterline.run2()
        wl_loops = waterline.getLoops()
        for l in wl_loops:
            chunks.append(camPathChunk(inpoints=[]))
            for p in l:
                chunks[-1].points.append(
                    (p.x / OCL_SCALE, p.y / OCL_SCALE, p.z / OCL_SCALE))
            chunks[-1].append(chunks[-1].points[0])
            chunks[-1].closed = True
            chunks[-1].poly = sgeometry.Polygon(chunks[-1].points)
Esempio n. 5
0
def ocl_sample(operation, chunks):

    oclSTL = get_oclSTL(operation)

    op_cutter_type = operation.cutter_type
    op_cutter_diameter = operation.cutter_diameter
    op_minz = operation.minz
    op_cutter_tip_angle = math.radians(operation.cutter_tip_angle)/2
    if op_cutter_type == "VCARVE": 
        cutter_length = (op_cutter_diameter/math.tan(op_cutter_tip_angle))/2
    else:
     cutter_length = 10

    cutter = None

    if op_cutter_type == 'END':
        cutter = ocl.CylCutter((op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'BALLNOSE':
        cutter = ocl.BallCutter((op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'VCARVE':
        cutter = ocl.ConeCutter((op_cutter_diameter + operation.skin * 2) * 1000, op_cutter_tip_angle, cutter_length)
    elif op_cutter_type =='CYLCONE':
        cutter = ocl.CylConeCutter((operation.cylcone_diameter/2+operation.skin)*2000,(op_cutter_diameter + operation.skin * 2) * 1000, op_cutter_tip_angle)
    elif op_cutter_type == 'BALLCONE':
        cutter = ocl.BallConeCutter((operation.ball_radius + operation.skin) * 2000,
                                    (op_cutter_diameter + operation.skin * 2) * 1000, op_cutter_tip_angle)
    elif op_cutter_type =='BULLNOSE':
        cutter = ocl.BullCutter((op_cutter_diameter + operation.skin * 2) * 1000,operation.bull_corner_radius*1000, cutter_length)
    else:
        print("Cutter unsupported: {0}\n".format(op_cutter_type))
        quit()

    bdc = ocl.BatchDropCutter()
    bdc.setSTL(oclSTL)
    bdc.setCutter(cutter)

    for chunk in chunks:
        for coord in chunk.points:
            bdc.appendPoint(ocl.CLPoint(coord[0] * 1000, coord[1] * 1000, op_minz * 1000))

    bdc.run()

    cl_points = bdc.getCLPoints()

    return cl_points
Esempio n. 6
0
def waterline_time(zheights, diam, length, s, sampling):
    t_total = time.time()
    for zh in zheights:
        cutter = ocl.BallCutter(diam, length)
        wl = ocl.Waterline()
        wl.setSTL(s)
        wl.setCutter(cutter)
        wl.setZ(zh)
        wl.setSampling(sampling)
        wl.setThreads(1)

        wl.run()

        cutter_loops = wl.getLoops()
        for l in cutter_loops:
            loops.append(l)
    timeTotal = time.time() - t_total
    print " ALL Waterlines done in ", timeTotal, " s"
    return timeTotal
Esempio n. 7
0
def ocl_sample(operation, chunks):

    oclSTL = get_oclSTL(operation)
    cutter_props = operation.getOpCuttingTool()

    op_cutter_type = cutter_props.cutter_type
    op_cutter_diameter = cutter_props.cutter_diameter
    op_minz = operation.minz
    if op_cutter_type == "VCARVE":
        op_cutter_tip_angle = cutter_props.cutter_tip_angle

    cutter = None
    cutter_length = 5

    if op_cutter_type == 'END':
        cutter = ocl.CylCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'BALLNOSE':
        cutter = ocl.BallCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000, cutter_length)
    elif op_cutter_type == 'VCARVE':
        cutter = ocl.ConeCutter(
            (op_cutter_diameter + operation.skin * 2) * 1000,
            op_cutter_tip_angle, cutter_length)
    else:
        print("Cutter unsupported: {0}\n".format(op_cutter_type))
        quit()

    # add BullCutter
    bdc = ocl.BatchDropCutter()
    bdc.setSTL(oclSTL)
    bdc.setCutter(cutter)

    for chunk in chunks:
        for coord in chunk.points:
            bdc.appendPoint(
                ocl.CLPoint(coord[0] * 1000, coord[1] * 1000, op_minz * 1000))

    bdc.run()

    cl_points = bdc.getCLPoints()

    return cl_points
Esempio n. 8
0
def main():
    print ocl.revision()
    myscreen = camvtk.VTKScreen()
    myscreen.camera.SetPosition(-8, -4, 25)
    myscreen.camera.SetFocalPoint(4.5, 6, 0)
    # axis arrows
    camvtk.drawArrows(myscreen, center=(-1, -1, 0))
    camvtk.drawOCLtext(myscreen)

    octtext = camvtk.Text()
    octtext.SetPos((70, myscreen.height - 600))
    myscreen.addActor(octtext)

    cltext = camvtk.Text()
    cltext.SetPos((70, myscreen.height - 100))
    myscreen.addActor(cltext)

    stl = camvtk.STLSurf("../../stl/gnu_tux_mod.stl")
    #myscreen.addActor(stl)
    #stl.SetWireframe()
    stl.SetColor((0.5, 0.5, 0.5))

    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print "STL surface read,", s.size(), "triangles"

    #angle = math.pi/4
    radius = 0.4
    length = 10
    cutter = ocl.BallCutter(2 * radius, length)
    #cutter = ocl.CylCutter(2*radius, length)

    # generate CL-points
    minx = 0
    dx = 0.1 / 0.2
    maxx = 9
    miny = 0
    dy = cutter.getRadius() / 1.5
    maxy = 12
    z = -1
    # this generates a list of CL-points in a grid
    clpoints = pyocl.CLPointGrid(minx, dx, maxx, miny, dy, maxy, z)
    # batchdropcutter
    bdc = ocl.BatchDropCutter()
    bdc.bucketSize = 10
    bdc.setSTL(s)
    bdc.setCutter(cutter)
    #bdc.setThreads(1)  # explicitly setting one thread is better for debugging
    for p in clpoints:
        bdc.appendPoint(p)

    t_before = time.time()
    bdc.run()

    t_after = time.time()
    calctime = t_after - t_before
    print " BDC4 done in ", calctime, " s"
    dropcutter_time = calctime
    clpoints = bdc.getCLPoints()

    #camvtk.drawCLPointCloud(myscreen, clpoints)
    print " clpts= ", len(clpoints)
    myscreen.render()
    #myscreen.iren.Start()
    #exit()

    s = ocl.BallCutterVolume()
    #s = ocl.CylCutterVolume()
    #s.center = ocl.Point(-2.50,-0.6,0)
    s.radius = cutter.getRadius()
    s.length = cutter.getLength()

    # screenshot writer
    w2if = vtk.vtkWindowToImageFilter()
    w2if.SetInput(myscreen.renWin)
    lwr = vtk.vtkPNGWriter()
    lwr.SetInput(w2if.GetOutput())

    cp = ocl.Point(5, 5, -6)  # center of octree
    #depths = [3, 4, 5, 6, 7, 8]
    max_depth = 7
    root_scale = 10
    t = ocl.Octree(root_scale, max_depth, cp)
    t.init(5)
    n = 0  # the frame number

    stockbox = ocl.PlaneVolume(1, 0, 0.1)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 0, 8.9)
    t.diff_negative(stockbox)

    stockbox = ocl.PlaneVolume(1, 1, 0.1)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 1, 11.9)
    t.diff_negative(stockbox)

    stockbox = ocl.PlaneVolume(1, 2, -0.5)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 2, 3)
    t.diff_negative(stockbox)

    mc = ocl.MarchingCubes()

    print "stock mc()...",
    tris = mc.mc_tree(t)  # t.mc_triangles()
    print " mc() got ", len(tris), " triangles"
    mc_surf = camvtk.STLSurf(triangleList=tris, color=camvtk.red)
    mc_surf.SetColor(camvtk.cyan)
    print "stock STLSurf()...",
    myscreen.addActor(mc_surf)
    print "done."

    myscreen.render()
    #myscreen.iren.Start()
    #exit()
    myscreen.removeActor(mc_surf)
    renderinterleave = 10
    step_time = 0
    while (n < len(clpoints)):
        cl = ocl.Point(clpoints[n].x, clpoints[n].y, clpoints[n].z)
        s.setPos(cl)
        #myscreen.addActor( camvtk.Point( center=(cl.x,cl.y,cl.z), color=camvtk.yellow))
        print n, ": diff...",
        t_before = time.time()
        t.diff_negative(s)
        t_after = time.time()
        build_time = t_after - t_before
        #print "done in ", build_time," s"
        step_time = step_time + build_time
        n = n + 1
        if ((n % renderinterleave) == 0):
            infotext = "Octree max_depth=%i \nCL-point %i of %i \ndiff()-time: %f ms/CL-point" % (
                max_depth, n, len(clpoints),
                1e3 * step_time / renderinterleave)
            octtext.SetText(infotext)
            postext = "X: %f\nY: %f\nZ: %f" % (cl.x, cl.y, cl.z)
            cltext.SetText(postext)

            cactors = camvtk.drawBallCutter(myscreen, cutter, cl)
            print cactors
            t_before = time.time()
            print "mc()...",
            tris = mc.mc_tree(t)  #.mc_triangles()
            t_after = time.time()
            mc_time = t_after - t_before
            print "done in ", mc_time, " s"
            print " mc() got ", len(tris), " triangles"
            mc_surf = camvtk.STLSurf(triangleList=tris, color=camvtk.red)
            #mc_surf.SetWireframe()
            mc_surf.SetColor(camvtk.cyan)
            print " STLSurf()...",
            myscreen.addActor(mc_surf)
            print "done."

            print " render()...",
            myscreen.render()
            myscreen.camera.Azimuth(0.5)
            lwr.SetFileName("frames/cutsim_d9_frame" + ('%06d' % n) + ".png")
            w2if.Modified()
            lwr.Write()

            print "done."
            myscreen.removeActor(mc_surf)
            for c in cactors:
                myscreen.removeActor(c)
            step_time = 0

        #lwr.SetFileName("frames/mc8_frame"+ ('%06d' % n)+".png")
        #myscreen.camera.Azimuth( 2 )
        #myscreen.render()
        #w2if.Modified()
        #lwr.Write()

        #mc_surf.SetWireframe()
        #print "sleep...",
        #time.sleep(1.02)
        #print "done."

        # move forward
        #theta = n*dtheta
        #sp1 = ocl.Point(s.center)
        #s.center =  ocl.Point( 1.7*math.cos(theta),1.3*math.sin(theta),thetalift*theta)
        #sp2 = ocl.Point(s.center)
        #print "line from ",sp1," to ",sp2
        #if n is not nmax:
        #    myscreen.addActor( camvtk.Line( p1=(sp1.x,sp1.y,sp1.z),p2=(sp2.x,sp2.y,sp2.z), color=camvtk.red ) )
        #print "center moved to", s.center

    print " clpts= ", len(clpoints)
    print "All done."
    myscreen.iren.Start()
Esempio n. 9
0
def main():
    print(ocl.revision())
    myscreen = camvtk.VTKScreen()
    myscreen.camera.SetPosition(-8, -4, 25)
    myscreen.camera.SetFocalPoint(4.5, 6, 0)
    # axis arrows
    camvtk.drawArrows(myscreen, center=(-1, -1, 0))
    camvtk.drawOCLtext(myscreen)

    octtext = camvtk.Text()
    octtext.SetPos((70, myscreen.height - 600))
    myscreen.addActor(octtext)

    cltext = camvtk.Text()
    cltext.SetPos((70, myscreen.height - 100))
    myscreen.addActor(cltext)

    stl = camvtk.STLSurf("../../stl/gnu_tux_mod.stl")
    #myscreen.addActor(stl)
    #stl.SetWireframe()
    stl.SetColor((0.5, 0.5, 0.5))

    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print("STL surface read,", s.size(), "triangles")

    #angle = math.pi/4
    radius = 0.4
    length = 5
    cutter = ocl.BallCutter(2 * radius, length)
    #cutter = ocl.CylCutter(2*radius, length)

    # generate CL-points
    minx = 0
    dx = 0.1 / 0.4
    maxx = 9
    miny = 0
    dy = cutter.getRadius() / 1.5
    maxy = 12
    z = -1
    # this generates a list of CL-points in a grid
    clpoints = pyocl.CLPointGrid(minx, dx, maxx, miny, dy, maxy, z)
    # batchdropcutter
    bdc = ocl.BatchDropCutter()
    bdc.bucketSize = 7
    bdc.setSTL(s)
    bdc.setCutter(cutter)
    #bdc.setThreads(1)  # explicitly setting one thread is better for debugging
    for p in clpoints:
        bdc.appendPoint(p)

    t_before = time.time()
    bdc.run()
    t_after = time.time()
    calctime = t_after - t_before
    print(" BDC4 done in ", calctime, " s")
    dropcutter_time = calctime
    clpoints = bdc.getCLPoints()

    #camvtk.drawCLPointCloud(myscreen, clpoints)
    print(" clpts= ", len(clpoints))
    myscreen.render()
    #myscreen.iren.Start()
    #exit()

    s = ocl.BallCutterVolume()
    #s = ocl.CylCutterVolume()
    #s.center = ocl.Point(-2.50,-0.6,0)
    s.radius = cutter.getRadius()
    s.length = cutter.getLength()

    # screenshot writer
    w2if = vtk.vtkWindowToImageFilter()
    w2if.SetInput(myscreen.renWin)
    lwr = vtk.vtkPNGWriter()
    lwr.SetInput(w2if.GetOutput())

    cp = ocl.Point(5, 5, -3)  # center of octree
    #depths = [3, 4, 5, 6, 7, 8]
    max_depth = 7
    root_scale = 7
    t = ocl.Octree(root_scale, max_depth, cp)
    t.init(5)
    n = 0  # the frame number

    stockbox = ocl.PlaneVolume(1, 0, 0.1)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 0, 8.9)
    t.diff_negative(stockbox)

    stockbox = ocl.PlaneVolume(1, 1, 0.1)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 1, 11.9)
    t.diff_negative(stockbox)

    stockbox = ocl.PlaneVolume(1, 2, -0.5)
    t.diff_negative(stockbox)
    stockbox = ocl.PlaneVolume(0, 2, 3)
    t.diff_negative(stockbox)

    mc = ocl.MarchingCubes()

    print("mc()...", )
    tris = mc.mc_tree(t)  #.mc_triangles()
    print(" mc() got ", len(tris), " triangles")
    mc_surf = camvtk.STLSurf(triangleList=tris, color=camvtk.red)
    mc_surf.SetColor(camvtk.cyan)
    print(" STLSurf()...", )
    myscreen.addActor(mc_surf)
    print("done.")
    cl = ocl.Point(0, 0, 5)
    cactors = camvtk.drawBallCutter(myscreen, cutter, cl)
    myscreen.render()
    #myscreen.iren.Start()
    #exit()
    myscreen.removeActor(mc_surf)
    renderinterleave = len(clpoints) / 100
    step_time = 0
    #render_time = 0
    while (n < len(clpoints)):
        cl = ocl.Point(clpoints[n].x, clpoints[n].y, clpoints[n].z)
        s.setPos(cl)  # move the cutter
        t_before = time.time()
        t.diff_negative(s)  # subtract cutter from stock
        t_after = time.time()
        build_time = t_after - t_before
        step_time = step_time + build_time

        n = n + 1
        if n < (len(clpoints) - renderinterleave):
            myscreen.removeActor(mc_surf)
            for c in cactors:
                myscreen.removeActor(c)
        if ((n % renderinterleave) == 0):

            cactors = camvtk.drawBallCutter(myscreen, cutter, cl)
            t_before = time.time()
            print("mc()...", )
            tris = mc.mc_tree(t)  #.mc_triangles()
            mc_time = time.time() - t_before
            print("done in ", mc_time, " s")
            print(" mc() got ", len(tris), " triangles")
            print(" STLSurf()...", )

            t_before = time.time()
            mc_surf = camvtk.STLSurf(triangleList=tris, color=camvtk.red)
            #mc_surf.SetWireframe()
            mc_surf.SetColor(camvtk.cyan)
            myscreen.addActor(mc_surf)
            print("done.")
            print(" render()...", )
            myscreen.render()
            render_time = time.time() - t_before
            myscreen.camera.Azimuth(0.1)
            lwr.SetFileName("frames/cutsim_d10_frame" + ('%06d' % n) + ".png")
            w2if.Modified()

            call_ms = step_time / renderinterleave
            print(renderinterleave, " diff() calls in", step_time, " = ",
                  call_ms, " ms/call")
            infotext = "Octree max_depth=%i \nCL-point %i of %i \n%i CL-pts/frame\ndiff()-time:  %1.3f s/CL-point\nmc()-time:  %1.3f s/frame\nrender()-time:  %1.3f s/frame\n%i Triangles" % (
                max_depth, n, len(clpoints), renderinterleave, call_ms,
                mc_time, render_time, len(tris))
            octtext.SetText(infotext)
            postext = "X: %f\nY: %f\nZ: %f" % (cl.x, cl.y, cl.z)
            cltext.SetText(postext)

            #lwr.Write() # uncomment to actually write files to disk

            print("done.")

            step_time = 0

        #lwr.SetFileName("frames/mc8_frame"+ ('%06d' % n)+".png")
        #myscreen.camera.Azimuth( 2 )
        #myscreen.render()
        #w2if.Modified()
        #lwr.Write()

        #mc_surf.SetWireframe()
        #print "sleep...",
        #time.sleep(1.02)
        #print "done."

    print(" clpts= ", len(clpoints))
    print("All done.")
    myscreen.iren.Start()
Esempio n. 10
0
stl = camvtk.STLSurf(tempfile.gettempdir() + "/model0.stl")
stl_polydata = stl.src.GetOutput()
stl_surf = ocl.STLSurf()
camvtk.vtkPolyData2OCLSTL(stl_polydata, stl_surf)
csv_file = open(tempfile.gettempdir() + '/ocl_settings.txt', 'r')
op_cutter_type = csv_file.readline().split()[0]
op_cutter_diameter = float(csv_file.readline())
op_minz = float(csv_file.readline())
csv_file.close()

cutter_length = 5
if op_cutter_type == 'END':
    cutter = ocl.CylCutter(op_cutter_diameter * 1000, cutter_length)
elif op_cutter_type == 'BALL':
    cutter = ocl.BallCutter(op_cutter_diameter * 1000, cutter_length)
elif op_cutter_type == 'VCARVE':
    cutter = ocl.ConeCutter(op_cutter_diameter * 1000, 1, cutter_length)
else:
    print "Cutter unsupported: " + op_cutter_type + '\n'
    quit()
#add BullCutter
bdc = ocl.BatchDropCutter()
bdc.setSTL(stl_surf)
bdc.setCutter(cutter)

csv_file = open(tempfile.gettempdir() + '/ocl_chunks.txt', 'r')
for text_line in csv_file:
    sample_point = [float(coord) for coord in text_line.split()]
    bdc.appendPoint(
        ocl.CLPoint(sample_point[0] * 1000, sample_point[1] * 1000,
if __name__ == "__main__":
    print ocl.revision()
    myscreen = camvtk.VTKScreen()

    #stl = camvtk.STLSurf("../stl/gnu_tux_mod.stl")
    stl = camvtk.STLSurf("../stl/demo.stl")
    myscreen.addActor(stl)
    stl.SetWireframe()
    stl.SetColor((0.5, 0.5, 0.5))

    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print "STL surface read,", s.size(), "triangles"
    length = 5
    cutter = ocl.BallCutter(1.4321, length)
    #cutter = ocl.CylCutter(1.123, length)
    #cutter = ocl.BullCutter(1.123, 0.2, length)
    print cutter

    minx = 0
    dx = 0.1 / 6
    maxx = 10
    miny = 0
    dy = 1
    maxy = 10
    z = -17
    # this generates a list of CL-points in a grid
    clpoints = pyocl.CLPointGrid(minx, dx, maxx, miny, dy, maxy, z)
    print "generated grid with", len(clpoints), " CL-points"
Esempio n. 12
0
    b = ocl.Point(0, 1, 0)
    myscreen.addActor(camvtk.Point(center=(b.x, b.y, b.z), color=(1, 0, 1)))
    c = ocl.Point(0, 0, 0.0)
    myscreen.addActor(camvtk.Point(center=(c.x, c.y, c.z), color=(1, 0, 1)))

    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(c.x, c.y, c.z)))
    myscreen.addActor(camvtk.Line(p1=(c.x, c.y, c.z), p2=(b.x, b.y, b.z)))
    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(b.x, b.y, b.z)))

    t = ocl.Triangle(b, c, a)
    radius1 = 1
    angle = math.pi / 4
    length = 10
    #cutter = ocl.ConeCutter(0.37, angle)

    cutter = ocl.BallCutter(0.532, length)
    #cutter = ocl.CylCutter(0.3, length)
    #cutter = ocl.BullCutter(0.7,0.1, length)

    # these cutters do not have offsets yet (?)
    #cutter =  ocl.CylConeCutter(0.2,0.5,math.pi/9)
    #cutter = ocl.BallConeCutter(0.4,0.6,math.pi/9)
    #cutter = ocl.BullConeCutter(0.4,0.1,0.7,math.pi/6)
    #cutter = ocl.ConeConeCutter(0.4,math.pi/3,0.7,math.pi/6)
    #cutter = ocl.ConeCutter(0.4, math.pi/3)
    print cutter
    offset = 0.1
    c2 = cutter.offsetCutter(offset)
    print c2

    minx = -0.5
Esempio n. 13
0
    a = ocl.Point(0, 1, 0.3)
    myscreen.addActor(camvtk.Point(center=(a.x, a.y, a.z), color=(1, 0, 1)))
    b = ocl.Point(1, 0.5, 0.3)
    myscreen.addActor(camvtk.Point(center=(b.x, b.y, b.z), color=(1, 0, 1)))
    c = ocl.Point(0, 0, 0)
    myscreen.addActor(camvtk.Point(center=(c.x, c.y, c.z), color=(1, 0, 1)))
    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(c.x, c.y, c.z)))
    myscreen.addActor(camvtk.Line(p1=(c.x, c.y, c.z), p2=(b.x, b.y, b.z)))
    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(b.x, b.y, b.z)))
    t = ocl.Triangle(b, c, a)
    s = ocl.STLSurf()
    s.addTriangle(t)  # a one-triangle STLSurf
    length = 10
    #cutter = ocl.CylCutter(0.3, length)
    cutter = ocl.BallCutter(0.3, length)

    print "fiber..."
    range = 4
    Nmax = 100
    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 = []
 camvtk.drawOCLtext(myscreen)
 
 a = ocl.Point(0,1,0.2)
 b = ocl.Point(1,0.5,0.0)    
 c = ocl.Point(0.1,0.1,0.0)
 myscreen.addActor(camvtk.Point(center=(a.x,a.y,a.z), color=(1,0,1)))
 myscreen.addActor(camvtk.Point(center=(b.x,b.y,b.z), color=(1,0,1)))
 myscreen.addActor(camvtk.Point(center=(c.x,c.y,c.z), color=(1,0,1)))
 myscreen.addActor( camvtk.Line(p1=(a.x,a.y,a.z),p2=(c.x,c.y,c.z)) )
 myscreen.addActor( camvtk.Line(p1=(c.x,c.y,c.z),p2=(b.x,b.y,b.z)) )
 myscreen.addActor( camvtk.Line(p1=(a.x,a.y,a.z),p2=(b.x,b.y,b.z)) )
 t = ocl.Triangle(b,c,a)
 angle = math.pi/4
 diameter=0.3
 length=5
 cutter1 = ocl.BallCutter(diameter, length)
 cutter2 = ocl.CylCutter(diameter, length)
 cutter3 = ocl.BullCutter(diameter, diameter/4, length)
 cutter4 = ocl.ConeCutter(diameter, angle, length)
 #cutter = cutter.offsetCutter( 0.1 )
 
 
 range=2
 Nmax = 50
 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.25
 zNmax =5
 dz = (zmax-zmin)/(zNmax-1)
 zvals=[]
Esempio n. 15
0
    stlfile = "../../stl/gnu_tux_mod.stl"
    surface = STLSurfaceSource(stlfile)

    t_before = time.time()

    zheights = [
        0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6
    ]
    #zheights=[float(1.0)] # for faster computation, calculate only one waterline

    wl = ocl.Waterline()  # total time 14 seconds on i7 CPU
    #wl = ocl.AdaptiveWaterline() # this is slower, ca 60 seconds on i7 CPU
    wl.setSTL(surface)
    diam = 0.5
    length = 10
    cutter = ocl.BallCutter(
        diam, length)  # any ocl MillingCutter class should work here
    wl.setCutter(cutter)
    wl.setSampling(
        0.0314
    )  # this should be smaller than the smallest details in the STL file
    # AdaptiveWaterline() also has settings for minimum sampling interval (see c++ code)
    all_loops = []
    for zh in zheights:
        print "calculating Waterline at z= ", zh
        wl.reset()
        wl.setZ(zh)  # height for this waterline
        wl.run()
        all_loops.append(wl.getLoops())
    t_after = time.time()
    calctime = t_after - t_before
    print " TOTAL Waterline time is: ", calctime, " s"
Esempio n. 16
0
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print("STL surface read,", s.size(), "triangles")
    
    
    far = 20
    # far = 0.000002 generator 52 face_count crash
    # far = 0.000010 crashes at n=192
    
    camPos = 2* far
    myscreen.camera.SetPosition(camPos/1000, camPos/1000, camPos) 
    myscreen.camera.SetClippingRange(-2*camPos,2*camPos)
    myscreen.camera.SetFocalPoint(0.051, 0, 0)
    
    cls = ocl.CutterLocationSurface(10)
    
    cutter = ocl.BallCutter(2,10)
    cls.setCutter(cutter)
    cls.setSampling(1)
    cls.setMinSampling(0.1)
    cls.setSTL(s)
    
    drawDiagram(myscreen, cls)
    #vd = ocl.VoronoiDiagram(far,1200)
    
    #vod = VD(myscreen,vd,scale)
    #vod.setAll(vd)
    #drawFarCircle(myscreen, scale*vd.getFarRadius(), camvtk.orange)
    

        
    print("PYTHON All DONE.")
Esempio n. 17
0
import ocl
#help(ocl)

#
c = ocl.BallCutter(1, 2)
print c.__doc__
print ocl.version()
help(ocl.BallCutter(4, 5))
Esempio n. 18
0
import ocl
import math

print ocl.revision()

# cylinder
c = ocl.CylCutter(2.345, 5)
d = c.offsetCutter(0.1)
print c
print "offset: ",d
print

# ball
c = ocl.BallCutter(2.345, 6)
d = c.offsetCutter(0.1)
print c
print "offset: ",d
print

# bull
c = ocl.BullCutter(2.345, 0.123, 6)
d = c.offsetCutter(0.1)
print c
print "offset: ",d
print

# cone
c = ocl.ConeCutter(2.345, math.pi/6)
d = c.offsetCutter(0.1)
print c
print "offset: ",d
Esempio n. 19
0
    def _waterline(self, obj, s, bb):
        import ocl
        from PathScripts.PathUtils import depth_params, fmt
        import time

        def drawLoops(loops):
            nloop = 0
            waterlinestring = ""
            waterlinestring += "(waterline begin)"
            for loop in loops:
                p = loop[0]
                loopstring = "(loop begin)" + "\n"
                loopstring += "G0 Z" + str(obj.SafeHeight.Value) + "\n"
                loopstring += "G0 X" + \
                    str(fmt(p.x)) + " Y" + str(fmt(p.y)) + "\n"
                loopstring += "G1 Z" + str(fmt(p.z)) + "\n"
                for p in loop[1:]:
                    loopstring += "G1 X" + \
                        str(fmt(p.x)) + " Y" + str(fmt(p.y)) + \
                        " Z" + str(fmt(p.z)) + "\n"
                    zheight = p.z
                p = loop[0]
                loopstring += "G1 X" + \
                    str(fmt(p.x)) + " Y" + str(fmt(p.y)) + \
                    " Z" + str(fmt(zheight)) + "\n"
                loopstring += "(loop end)" + "\n"
                print "    loop ", nloop, " with ", len(loop), " points"
                nloop = nloop + 1
                waterlinestring += loopstring
            waterlinestring += "(waterline end)" + "\n"
            return waterlinestring

        depthparams = depth_params(obj.ClearanceHeight.Value, obj.SafeHeight.Value,
                                   obj.StartDepth.Value, obj.StepDown, obj.FinishDepth.Value, obj.FinalDepth.Value)
        # stlfile = "../../stl/gnu_tux_mod.stl"
        # surface = STLSurfaceSource(stlfile)
        surface = s

        t_before = time.time()
        zheights = depthparams.get_depths()
        wl = ocl.Waterline()
        # wl = ocl.AdaptiveWaterline() # this is slower, ca 60 seconds on i7
        # CPU
        wl.setSTL(surface)
        diam = 0.5
        length = 10.0
        # any ocl MillingCutter class should work here
        cutter = ocl.BallCutter(diam, length)
        wl.setCutter(cutter)
        # this should be smaller than the smallest details in the STL file
        wl.setSampling(obj.SampleInterval)
        # AdaptiveWaterline() also has settings for minimum sampling interval
        # (see c++ code)
        all_loops = []
        for zh in zheights:
            print "calculating Waterline at z= ", zh
            wl.reset()
            wl.setZ(zh)  # height for this waterline
            wl.run()
            all_loops.append(wl.getLoops())
        t_after = time.time()
        calctime = t_after - t_before
        n = 0
        output = ""
        for loops in all_loops:  # at each z-height, we may get many loops
            print "  %d/%d:" % (n, len(all_loops))
            output += drawLoops(loops)
            n = n + 1
        print "(" + str(calctime) + ")"
        return output
Esempio n. 20
0
    def _waterline(self, obj, s, bb):
        import time
        import ocl

        def drawLoops(loops):
            nloop = 0
            pp = []
            pp.append(Path.Command("(waterline begin)"))

            for loop in loops:
                p = loop[0]
                pp.append(Path.Command("(loop begin)"))
                pp.append(Path.Command('G0', {"Z": obj.SafeHeight.Value, 'F': self.vertRapid}))
                pp.append(Path.Command('G0', {'X': p.x, "Y": p.y, 'F': self.horizRapid}))
                pp.append(Path.Command('G1', {"Z": p.z, 'F': self.vertFeed}))

                for p in loop[1:]:
                    pp.append(Path.Command('G1', {'X': p.x, "Y": p.y, "Z": p.z, 'F': self.horizFeed}))
                    # zheight = p.z
                p = loop[0]
                pp.append(Path.Command('G1', {'X': p.x, "Y": p.y, "Z": p.z, 'F': self.horizFeed}))
                pp.append(Path.Command("(loop end)"))

                print("    loop ", nloop, " with ", len(loop), " points")
                nloop = nloop + 1
            pp.append(Path.Command("(waterline end)"))

            return pp

        depthparams = PathUtils.depth_params(obj.ClearanceHeight.Value, obj.SafeHeight.Value,
                                   obj.StartDepth.Value, obj.StepDown, obj.FinishDepth.Value, obj.FinalDepth.Value)

        t_before = time.time()
        zheights = [i for i in depthparams]

        wl = ocl.Waterline()
        wl.setSTL(s)

        if obj.ToolController.Tool.ToolType == 'BallEndMill':
            cutter = ocl.BallCutter(obj.ToolController.Tool.Diameter, 5)  # TODO: 5 represents cutting edge height. Should be replaced with the data from toolcontroller?
        else:
            cutter = ocl.CylCutter(obj.ToolController.Tool.Diameter, 5)

        wl.setCutter(cutter)
        # this should be smaller than the smallest details in the STL file
        wl.setSampling(obj.SampleInterval)
        # AdaptiveWaterline() also has settings for minimum sampling interval
        # (see c++ code)
        all_loops = []
        print ("zheights: {}".format(zheights))
        for zh in zheights:
            print("calculating Waterline at z= ", zh)
            wl.reset()
            wl.setZ(zh)  # height for this waterline
            wl.run()
            all_loops.append(wl.getLoops())
        t_after = time.time()
        calctime = t_after - t_before
        n = 0
        output = []
        for loops in all_loops:  # at each z-height, we may get many loops
            print("  %d/%d:" % (n, len(all_loops)))
            output.extend(drawLoops(loops))
            n = n + 1
        print("(" + str(calctime) + ")")
        return output
     
 #zheights=[]
 """
 zheights.append(0.29)
 zheights.append(0.28)
 zheights.append(0.27)
 zheights.append(0.26)
 zheights.append(0.25)
 """
 #zheights=[ -0.35,  -0.25,  -0.15,  -0.05, 0.05,  0.15,   0.25]
 #zheights=[ 0.1]
 
 length = 10
 diam = 0.6
 cutter1 = ocl.CylCutter( diam , length )
 cutter2 = ocl.BallCutter( diam , length )
 cutter3 = ocl.BullCutter( diam , diam/5, length )
 cutter4 = ocl.ConeCutter( diam , math.pi/5, length )
 cutter5 =  ocl.CylConeCutter(diam/float(3),diam,math.pi/float(9))
 
 for zh in zheights:
     loops = calcWaterline(zh, cutter5, s)
     drawLoops(myscreen, loops[0], camvtk.red)
     
     #loops = calcWaterline(zh, cutter2, s)
     #drawLoops(myscreen, loops[0], camvtk.green)
     #loops = calcWaterline(zh, cutter3, s)
     #drawLoops(myscreen, loops[0], camvtk.yellow)
     
     #loops = calcWaterline(zh, cutter4, s)
     #drawLoops(myscreen, loops[0], camvtk.pink)
Esempio n. 22
0
    def _dropcutter(self, obj, s, bb):
        import ocl
        import time
        if obj.ToolController.Tool.ToolType == 'BallEndMill':
            cutter = ocl.BallCutter(obj.ToolController.Tool.Diameter, 5)  # TODO: 5 represents cutting edge height. Should be replaced with the data from toolcontroller?
        else:
            cutter = ocl.CylCutter(obj.ToolController.Tool.Diameter, 5)

        pdc = ocl.PathDropCutter()   # create a pdc
        pdc.setSTL(s)
        pdc.setCutter(cutter)
        pdc.setZ(obj.FinalDepth.Value + obj.DepthOffset.Value)  # set minimumZ
        pdc.setSampling(obj.SampleInterval)

        # the max and min XY area of the operation
        xmin = bb.XMin - obj.DropCutterExtraOffset.x
        xmax = bb.XMax + obj.DropCutterExtraOffset.x
        ymin = bb.YMin - obj.DropCutterExtraOffset.y
        ymax = bb.YMax + obj.DropCutterExtraOffset.y

        path = ocl.Path()                   # create an empty path object

        if obj.DropCutterDir == 'Y':
            Ny = int(bb.YLength / (cutter.getDiameter() * (obj.StepOver / 100.0)))
            dy = float(ymax - ymin) / Ny  # the y step-over

            # add Line objects to the path in this loop
            for n in xrange(0, Ny):
                y = ymin + n * dy
                p1 = ocl.Point(xmin, y, 0)   # start-point of line
                p2 = ocl.Point(xmax, y, 0)   # end-point of line
                if (n % 2 == 0):  # even
                    l = ocl.Line(p1, p2)     # line-object
                else:  # odd
                    l = ocl.Line(p2, p1)     # line-object

                path.append(l)        # add the line to the path
        else:
            Nx = int(bb.XLength / (cutter.getDiameter() * (obj.StepOver / 100.0)))
            dx = float(xmax - xmin) / Nx  # the y step-over

            # add Line objects to the path in this loop
            for n in xrange(0, Nx):
                x = xmin + n * dx
                p1 = ocl.Point(x, ymin, 0)   # start-point of line
                p2 = ocl.Point(x, ymax, 0)   # end-point of line
                if (n % 2 == 0):  # even
                    l = ocl.Line(p1, p2)     # line-object
                else:  # odd
                    l = ocl.Line(p2, p1)     # line-object

                path.append(l)        # add the line to the path

        pdc.setPath(path)

        # run drop-cutter on the path
        t_before = time.time()
        pdc.run()
        t_after = time.time()
        print("calculation took ", t_after - t_before, " s")

        # retrieve the points
        clp = pdc.getCLPoints()
        print("points received: " + str(len(clp)))

        # generate the path commands
        output = []
        output.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
        output.append(Path.Command('G0', {'X': clp[0].x, "Y": clp[0].y, 'F': self.horizRapid}))
        output.append(Path.Command('G1', {'Z': clp[0].z, 'F': self.vertFeed}))

        for c in clp:
            output.append(Path.Command('G1', {'X': c.x, "Y": c.y, "Z": c.z, 'F': self.horizFeed}))

        return output
Esempio n. 23
0
def zigzag(filepath,
           tool_diameter=3.0,
           corner_radius=0.0,
           step_over=1.0,
           x0=-10.0,
           x1=10.0,
           y0=-10.0,
           y1=10.0,
           direction='X',
           mat_allowance=0.0,
           style=0,
           clearance=5.0,
           rapid_safety_space=2.0,
           start_depth=0.0,
           step_down=2.0,
           final_depth=-10.0,
           units=1.0):
    mm = True
    if math.fabs(units) > 0.000000001:
        # ocl works in mm, so convert all values to mm
        mm = False
        tool_diameter *= units
        corner_radius *= units
        step_over *= units
        x0 *= units
        x1 *= units
        y0 *= units
        y1 *= units
        mat_allowance *= units
        clearance *= units
        rapid_safety_space *= units
        start_depth *= units
        step_down *= units
        final_depth *= units
        # read the stl file, we know it is an ascii file because HeeksCNC made it
        s = STLSurfFromFile(filepath)
    cutter = ocl.CylCutter(1.0, 1.0)  # a dummy-cutter for now
    if corner_radius == 0.0:
        cutter = ocl.CylCutter(tool_diameter + mat_allowance, 100.0)
    elif corner_radius > tool_diameter / 2 - 0.000000001:
        cutter = ocl.BallCutter(tool_diameter + mat_allowance, 100.0)
    else:
        cutter = ocl.BullCutter(tool_diameter + mat_allowance, corner_radius,
                                100.0)
    if final_depth > start_depth:
        raise 'final_depth > start_depth'
    height = start_depth - final_depth
    zsteps = int(height / math.fabs(step_down) + 0.999999)
    zstep_down = height / zsteps
    incremental_rapid_to = rapid_safety_space - start_depth
    if incremental_rapid_to < 0: incremental_rapid_to = 0.1
    dcf = ocl.PathDropCutter()
    dcf.setSTL(s)
    dcf.setCutter(cutter)
    for k in range(0, zsteps):
        z1 = start_depth - k * zstep_down
        z0 = start_depth - (k + 1) * zstep_down
        dcf.setZ(z0)
        steps = int((y1 - y0) / step_over) + 1
        if direction == 'Y': steps = int((x1 - x0) / step_over) + 1
        sub_step_over = (y1 - y0) / steps
        if direction == 'Y': sub_step_over = (x1 - x0) / steps
        rapid_to = z1 + incremental_rapid_to
        path = ocl.Path()
        for i in range(0, steps + 1):
            odd_numbered_pass = (i % 2 == 1)
            u = y0 + float(i) * sub_step_over
            if direction == 'Y': u = x0 + float(i) * sub_step_over
            if style == 0:  # one way
                if direction == 'Y':
                    path.append(
                        ocl.Line(ocl.Point(u, y0, 0), ocl.Point(u, y1, 0)))
                else:
                    path.append(
                        ocl.Line(ocl.Point(x0, u, 0), ocl.Point(x1, u, 0)))
                cut_path(path, dcf, z1, mat_allowance, mm, units, rapid_to,
                         incremental_rapid_to)
                path = ocl.Path()
                if mm:
                    rapid(z=clearance)
                else:
                    rapid(z=clearance / units)

            else:  # back and forth
                if direction == 'Y':
                    if odd_numbered_pass:
                        path.append(
                            ocl.Line(ocl.Point(u, y1, 0), ocl.Point(u, y0, 0)))
                        if i < steps:
                            path.append(
                                ocl.Line(
                                    ocl.Point(u, y0, 0),
                                    ocl.Point(u + sub_step_over, y0,
                                              0)))  # feed across to next pass
                    else:
                        path.append(
                            ocl.Line(ocl.Point(u, y0, 0), ocl.Point(u, y1, 0)))
                        if i < steps:
                            path.append(
                                ocl.Line(
                                    ocl.Point(u, y1, 0),
                                    ocl.Point(u + sub_step_over, y1,
                                              0)))  # feed across to next pass
                else:  # 'X'
                    if odd_numbered_pass:
                        path.append(
                            ocl.Line(ocl.Point(x1, u, 0), ocl.Point(x0, u, 0)))
                        if i < steps:
                            path.append(
                                ocl.Line(
                                    ocl.Point(x0, u, 0),
                                    ocl.Point(x0, u + sub_step_over,
                                              0)))  # feed across to next pass
                    else:
                        path.append(
                            ocl.Line(ocl.Point(x0, u, 0), ocl.Point(x1, u, 0)))
                        if i < steps:
                            path.append(
                                ocl.Line(
                                    ocl.Point(x1, u, 0),
                                    ocl.Point(x1, u + sub_step_over,
                                              0)))  # feed across to next pass

        if style != 0:  # back and forth
            cut_path(path, dcf, z1, mat_allowance, mm, units, rapid_to,
                     incremental_rapid_to)
            if mm:
                rapid(z=clearance)
            else:
                rapid(z=clearance / units)
Esempio n. 24
0
def drawScreen(a, b, c, filename, write_flag):
    print(ocl.version())
    myscreen = camvtk.VTKScreen()
    #a = ocl.Point(0,1,0.3)
    myscreen.addActor(camvtk.Point(center=(a.x, a.y, a.z), color=(1, 0, 1)))
    #b = ocl.Point(1,0.5,0.3)
    myscreen.addActor(camvtk.Point(center=(b.x, b.y, b.z), color=(1, 0, 1)))
    #c = ocl.Point(-0.1,0.3,0.0)
    myscreen.addActor(camvtk.Point(center=(c.x, c.y, c.z), color=(1, 0, 1)))
    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(c.x, c.y, c.z)))
    myscreen.addActor(camvtk.Line(p1=(c.x, c.y, c.z), p2=(b.x, b.y, b.z)))
    myscreen.addActor(camvtk.Line(p1=(a.x, a.y, a.z), p2=(b.x, b.y, b.z)))
    t = ocl.Triangle(b, c, a)
    s = ocl.STLSurf()
    s.addTriangle(t)  # a one-triangle STLSurf
    zheights = [
        -0.3, -0.2, -0.1, -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.26, 0.27,
        0.28, 0.29
    ]  # the z-coordinates for the waterlines
    zheights = [
        -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, -0.05, 0.0, 0.05, 0.1,
        0.15, 0.2, 0.28
    ]
    zheights = [
        -0.35, -0.3, -0.25, -0.2, -0.15, -0.1, -0.05, 0.0, 0.05, 0.1, 0.15,
        0.2, 0.25, 0.28
    ]

    zheights = []
    Nmax = 20
    zmin = -0.5
    zmax = -0.05
    dz = (zmax - zmin) / float(Nmax - 1)
    z = zmin
    for n in range(Nmax):
        zheights.append(z)
        z = z + dz

    zheights = []
    zheights.append(-0.25)
    #zheights=[ -0.35,  -0.25,  -0.15,  -0.05, 0.05,  0.15,   0.25]
    #zheights=[ 0.1]

    length = 10
    diam = 0.6
    cutter1 = ocl.CylCutter(diam, length)
    cutter2 = ocl.BallCutter(diam, length)
    cutter3 = ocl.BullCutter(diam, diam / 5, length)
    cutter4 = ocl.ConeCutter(diam, math.pi / 5, length)

    for zh in zheights:
        #loops = calcWaterline(zh, cutter1, s)
        #drawLoops(myscreen, loops[0], camvtk.yellow)

        #loops = calcWaterline(zh, cutter2, s)
        #drawLoops(myscreen, loops[0], camvtk.green)
        #loops = calcWaterline(zh, cutter3, s)
        #drawLoops(myscreen, loops[0], camvtk.yellow)

        loops = calcWaterline(zh, cutter4, s)
        drawLoops(myscreen, loops[0], camvtk.pink)

        #for f in loops[1]:
        #    drawFiber(myscreen, f, camvtk.red)
        #for f in loops[2]:
        #    drawFiber(myscreen, f, camvtk.lblue)

    print("done.")
    myscreen.camera.SetPosition(1, -1, 3)
    myscreen.camera.SetFocalPoint(0.5, 0.5, 0)
    camvtk.drawArrows(myscreen, center=(-0.5, -0.5, -0.5))
    camvtk.drawOCLtext(myscreen)
    myscreen.render()
    """
    w2if = vtk.vtkWindowToImageFilter()
    w2if.SetInput(myscreen.renWin)
    lwr = vtk.vtkPNGWriter()
    lwr.SetInput( w2if.GetOutput() )
    w2if.Modified()
    lwr.SetFileName(filename)
    if write_flag:
        lwr.Write()
        print("wrote ",filename)
    """

    time.sleep(1)