Ejemplo n.º 1
0
def main(filename="frame/f.png"):
    print ocl.revision()

    myscreen = camvtk.VTKScreen()
    myscreen.camera.SetPosition(-15, -8, 15)
    myscreen.camera.SetFocalPoint(5, 5, 0)
    # axis arrows
    camvtk.drawArrows(myscreen, center=(-1, -1, 0))

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

    c = ocl.CylCutter(2)  # cutter
    c.length = 3
    print "cutter length=", c.length

    # generate CL-points
    stl = camvtk.STLSurf("../stl/demo.stl")
    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print "STL surface read,", s.size(), "triangles"
    print s.getBounds()
    #exit()
    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.CLPointGridZigZag(minx, dx, maxx, miny, dy, maxy, z)
    print "generated grid with", len(clpoints), " CL-points"
    # batchdropcutter
    bdc = ocl.BatchDropCutter()
    bdc.setSTL(s, 1)
    bdc.setCutter(c)
    for p in clpoints:
        bdc.appendPoint(p)
    t_before = time.time()
    print "threads=", bdc.nthreads
    bdc.dropCutter4()
    t_after = time.time()
    calctime = t_after - t_before
    print " done in ", calctime, " s"
    clpoints = bdc.getCLPoints()

    # filter
    print "filtering. before filter we have", len(clpoints), "cl-points"
    f = ocl.LineCLFilter()
    f.setTolerance(0.001)
    for p in clpoints:
        f.addCLPoint(p)
    f.run()
    clpts = f.getCLPoints()
    print "after filtering we have", len(clpts), "cl-points"

    #exit()

    # stupid init code
    f = ocl.Ocode()
    tree_maxdepth = 8
    f.set_depth(tree_maxdepth)  # depth and scale set here.
    f.set_scale(10)

    # cube
    stockvol = ocl.BoxOCTVolume()
    stockvol.corner = ocl.Point(0, 0, -0.5)
    stockvol.v1 = ocl.Point(10, 0, 0)
    stockvol.v2 = ocl.Point(0, 10, 0)
    stockvol.v3 = ocl.Point(0, 0, 3)
    stockvol.calcBB()
    #cube1.side=10.0
    #cube1.center = ocl.Point(0,0,0)
    #cube1.calcBB()

    t_before = time.time()
    stock = ocl.LinOCT()
    stock.init(3)
    stock.build(stockvol)
    calctime = time.time() - t_before
    print " stock built in ", calctime, " s, stock.size()=", stock.size()

    # draw initial octree
    #tlist = pyocl.octree2trilist(stock)
    #surf = camvtk.STLSurf(triangleList=tlist)
    #myscreen.addActor(surf)

    # draw initial cutter
    #startp = ocl.Point(0,0,0)
    #cyl = camvtk.Cylinder(center=(startp.x,startp.y,startp.z), radius=c.radius,
    #                        height=c.length,
    #                        rotXYZ=(90,0,0), color=camvtk.grey)
    #cyl.SetWireframe()
    #myscreen.addActor(cyl)

    timetext = camvtk.Text()
    timetext.SetPos((myscreen.width - 300, myscreen.height - 30))
    myscreen.addActor(timetext)

    ocltext = camvtk.Text()
    ocltext.SetPos((myscreen.width - 300, myscreen.height - 60))
    myscreen.addActor(ocltext)
    ocltext.SetText("OpenCAMLib")

    octtext = camvtk.Text()
    octtext.SetPos((myscreen.width - 300, myscreen.height - 90))
    myscreen.addActor(octtext)
    octtext.SetText("Octree cutting-simulation")

    infotext = camvtk.Text()
    infotext.SetPos((myscreen.width - 300, myscreen.height - 180))
    myscreen.addActor(infotext)

    Nmoves = len(clpts)
    print Nmoves, "CL-points to process"
    for n in xrange(0, Nmoves - 1):
        timetext.SetText(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))

        #if n<Nmoves-1:
        print n, " to ", n + 1
        startp = clpts[n]  # start of move
        endp = clpts[n + 1]  # end of move

        t_before = time.time()
        sweep = ocl.LinOCT()
        sweep.init(0)
        calctime = time.time() - t_before
        print " sweep-init done in ", calctime, " s, sweep.size()=", sweep.size(
        )

        g1vol = ocl.CylMoveOCTVolume(c, ocl.Point(startp.x, startp.y,
                                                  startp.z),
                                     ocl.Point(endp.x, endp.y, endp.z))

        t_before = time.time()
        sweep.build(g1vol)
        calctime = time.time() - t_before
        print " sweep-build done in ", calctime, " s, sweep.size()=", sweep.size(
        )

        # draw cutter
        cyl1 = camvtk.Cylinder(center=(startp.x, startp.y, startp.z),
                               radius=c.radius,
                               height=c.length,
                               rotXYZ=(90, 0, 0),
                               color=camvtk.lgreen)
        cyl1.SetWireframe()
        #myscreen.addActor(cyl1)
        cyl2 = camvtk.Cylinder(center=(endp.x, endp.y, endp.z),
                               radius=c.radius,
                               height=c.length,
                               rotXYZ=(90, 0, 0),
                               color=camvtk.pink)
        cyl2.SetWireframe()
        #myscreen.addActor(cyl2)

        #camvtk.drawCylCutter(myscreen, c, startp)
        #camvtk.drawCylCutter(myscreen, c, endp)
        myscreen.addActor(
            camvtk.Line(p1=(startp.x, startp.y, startp.z),
                        p2=(endp.x, endp.y, endp.z),
                        color=camvtk.red))
        #camvtk.drawTree2(myscreen,sweep,color=camvtk.red,opacity=0.5)

        t_before = time.time()
        stock.diff(sweep)
        calctime = time.time() - t_before
        print " diff done in ", calctime, " s, stock.size()", stock.size()

        info = "tree-depth:%i \nmove: %i \nstock-nodes: %i \nsweep-nodes: %i" % (
            tree_maxdepth, n, stock.size(), sweep.size())
        infotext.SetText(info)

        if (n % 1 == 0 or n == Nmoves - 2):  # draw only every m:th frame
            # sweep surface
            t_before = time.time()
            #sweep_tlist = pyocl.octree2trilist(sweep)
            sweep_tlist = sweep.get_triangles()
            sweepsurf = camvtk.STLSurf(triangleList=sweep_tlist)
            sweepsurf.SetColor(camvtk.red)
            sweepsurf.SetOpacity(0.1)
            myscreen.addActor(sweepsurf)
            calctime = time.time() - t_before
            print " sweepsurf-render  ", calctime, " s"

            # stock surface
            t_before = time.time()
            #tlist = pyocl.octree2trilist(stock)
            tlist = stock.get_triangles()
            stocksurf = camvtk.STLSurf(triangleList=tlist)
            stocksurf.SetColor(camvtk.cyan)
            stocksurf.SetOpacity(1.0)
            myscreen.addActor(stocksurf)
            calctime = time.time() - t_before
            print " stocksurf-render  ", calctime, " s"

            #time.sleep(1.1)
            # write screenshot to disk
            lwr.SetFileName("frames/cutsim_frame" + ('%03d' % n) + ".png")
            #lwr.SetFileName(filename)

            t_before = time.time()  # time the render process
            myscreen.render()
            w2if.Modified()
            lwr.Write()

            calctime = time.time() - t_before
            print " render  ", calctime, " s"

            #myscreen.render()
            #time.sleep(0.1)

            myscreen.removeActor(sweepsurf)
            if n != (Nmoves - 2):
                myscreen.removeActor(stocksurf)

        #myscreen.removeActor(cyl1)
        #myscreen.removeActor(cyl2)
        #myscreen.render()
        #time.sleep(0.1)

    print " render()...",
    myscreen.render()
    print "done."

    #time.sleep(0.2)

    myscreen.iren.Start()
Ejemplo n.º 2
0
def main(filename="frame/f.png"):  
    print ocl.revision()
          
    myscreen = camvtk.VTKScreen()   
    myscreen.camera.SetPosition(-15, -8, 15)
    myscreen.camera.SetFocalPoint(5,5, 0)   
    # axis arrows
    camvtk.drawArrows(myscreen,center=(0,0,0))

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

    
    c = ocl.CylCutter(3,10) # cutter
    c.length = 3
    print "cutter length=", c.length
    
    cp= ocl.Point(0,0,0)
    max_depth = 9
    root_scale = 3
    t = ocl.Octree(root_scale, max_depth, cp)
    print t
    
    nodes = t.get_leaf_nodes()
    t.init(1)
    #nodes=[]
    s = ocl.SphereOCTVolume()
    s.center = ocl.Point(0,0,0)
    s.radius = 2.6345
    print "build...",
    t.build(s)
    print "done."
    print t
    
    sphere = camvtk.Sphere( center=(s.center.x,s.center.y,s.center.z), radius=s.radius, color=camvtk.cyan)
    sphere.SetOpacity(0.1)
    myscreen.addActor( sphere );
    
    
    nodes = t.get_surface_nodes()
    print "got ", len(nodes)," surface nodes"
   
    points=[]
    for n in nodes:
        #n=nodes[0]
        verts = n.vertices()
        #c = n.center
        #print " node at depth=", n.depth," center=",c
        #myscreen.addActor( camvtk.Sphere( center=(c.x,c.y,c.z), radius=0.1, color=camvtk.yellow ))
        for v in verts:
            #print v
            #myscreen.addActor( camvtk.Sphere( center=(v.x,v.y,v.z), radius=0.1 ))
            #
            points.append(v)
            
    #myscreen.addActor( camvtk.PointCloud( pointlist= points))
    
    tris = t.mc_triangles()
    mc_surf = camvtk.STLSurf( triangleList=tris, color=camvtk.red )
    #mc_surf.SetWireframe()
    myscreen.addActor( mc_surf )
    print " render()...",
    myscreen.render()
    print "done."
    
    
    #time.sleep(0.2)
    
    
    
    myscreen.iren.Start() 
Ejemplo n.º 3
0
import math


def generateRange(zmin, zmax, zNmax):
    dz = (float(zmax) - float(zmin)) / (zNmax - 1)
    zvals = []
    for n in xrange(0, zNmax):
        zvals.append(zmin + n * dz)
    return zvals


if __name__ == "__main__":
    print ocl.revision()
    myscreen = camvtk.VTKScreen()
    #stl = camvtk.STLSurf("../stl/demo.stl")
    stl = camvtk.STLSurf("../stl/gnu_tux_mod.stl")
    myscreen.addActor(stl)
    stl.SetWireframe()
    #stl.SetSurface()
    stl.SetColor(camvtk.cyan)
    polydata = stl.src.GetOutput()
    s = ocl.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print "STL surface read,", s.size(), "triangles"
    bounds = s.getBounds()
    print "STLSurf.Bounds()=", bounds
    cutter = ocl.CylCutter(1.6, 5)
    #cutter = ocl.BallCutter(0.3,5)

    print cutter
    xmin = -1
Ejemplo n.º 4
0
import ocl
import tempfile
import camvtk

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 = 150
if op_cutter_type == 'END':
    cutter = ocl.CylCutter(op_cutter_diameter * 1000, cutter_length)
elif op_cutter_type == 'BALLNOSE':
    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()
wl_height_file = open(tempfile.gettempdir() + '/ocl_wl_heights.txt', 'r')
waterline_heights = []
for line in wl_height_file:
    waterline_heights.append(float(line.split()[0]))
wl_height_file.close()
wl_index = 0
waterline = ocl.Waterline()
Ejemplo n.º 5
0
import ocl
import pyocl
import camvtk
import time
import vtk
import datetime
import math

if __name__ == "__main__":
    print(ocl.version())
    myscreen = camvtk.VTKScreen()

    #stl = camvtk.STLSurf("../stl/gnu_tux_mod.stl")
    stl = camvtk.STLSurf("../stl/mount_rush.stl")
    #stl = camvtk.STLSurf("../stl/pycam-textbox.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 with", s.size(), "triangles read")

    # define a cutter
    length = 5
    cutter = ocl.BallCutter(15.4321, length)
    #cutter = ocl.CylCutter(1.123, length)
    #cutter = ocl.BullCutter(1.123, 0.2, length)
    #cutter = ocl.ConeCutter(0.43, math.pi/7, length)
Ejemplo n.º 6
0
import ocl
import camvtk
import time

if __name__ == "__main__":
    s = ocl.STLSurf()
    print(s)
    myscreen = camvtk.VTKScreen()
    stl = camvtk.STLSurf("../stl/demo.stl")
    print("STL surface read")
    myscreen.addActor(stl)
    stl.SetWireframe()

    polydata = stl.src.GetOutput()
    camvtk.vtkPolyData2OCLSTL(polydata, s)

    print(s)
    myscreen.render()
    myscreen.iren.Start()

    #raw_input("Press Enter to terminate")
def main():
    print ocl.revision()
    myscreen = camvtk.VTKScreen()
    myscreen.camera.SetPosition(-15, -8, 15)
    myscreen.camera.SetFocalPoint(0, 0, 0)
    # axis arrows
    camvtk.drawArrows(myscreen, center=(0, 0, 0))

    s = ocl.SphereOCTVolume()
    s.center = ocl.Point(0, 0, 0)
    s.radius = 2.6345

    sphere = camvtk.Sphere(center=(s.center.x, s.center.y, s.center.z),
                           radius=s.radius,
                           color=camvtk.cyan)
    sphere.SetOpacity(0.1)
    myscreen.addActor(sphere)

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

    # text
    camvtk.drawOCLtext(myscreen)
    octtext = camvtk.Text()
    octtext.SetPos((myscreen.width - 400, myscreen.height - 290))
    myscreen.addActor(octtext)

    cp = ocl.Point(0, 0, 0)
    #depths = [3, 4, 5, 6, 7, 8]
    depths = [4, 5]
    root_scale = 3
    n = 0  # the frame number
    for max_depth in depths:
        t = ocl.Octree(root_scale, max_depth, cp)
        t.init(1)
        print "build...",
        t_before = time.time()
        t.diff_positive(s)
        t_after = time.time()
        build_time = t_after - t_before
        print "done."
        tris = t.mc_triangles()
        infotext = "Octree + Marching-Cubes test\nmax octree-depth:%i \ntriangles: %i \nbuild() time: %f ms" % (
            max_depth, len(tris), build_time * 1e3)
        octtext.SetText(infotext)

        mc_surf = camvtk.STLSurf(triangleList=tris, color=camvtk.red)
        #
        myscreen.addActor(mc_surf)
        print " render()...",
        myscreen.render()
        print "done."
        for m in xrange(0, 180):
            # do a rotating animation
            lwr.SetFileName("frames/mc8_frame" + ('%06d' % n) + ".png")
            myscreen.camera.Azimuth(2)
            myscreen.render()
            w2if.Modified()
            #lwr.Write()

            if m > 90:
                mc_surf.SetWireframe()
            time.sleep(0.02)

            n = n + 1
        myscreen.removeActor(mc_surf)

    myscreen.iren.Start()
    apdc.setMinSampling(0.0008)
    apdc.setPath(path)
    apdc.run()
    return apdc.getCLPoints()


if __name__ == "__main__":
    root = Tkinter.Tk()
    filename = tkFileDialog.askopenfilename(title='Choose an STL file')
    #filename = "data/gnu_tux_mod.stl"

    print "( OpenCAMLib ", ocl.version(), " )"
    #print os.getcwd()
    #filename="gnu_tux_mod.stl"
    #exit()
    stl = camvtk.STLSurf(filename)

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

    angle = math.pi / 4
    diameter = 0.25
    length = 5

    # choose a cutter for the operation:
    #cutter = ocl.BallCutter(diameter, length)
    cutter = ocl.CylCutter(diameter, length)
    #cutter = ocl.BullCutter(diameter, 0.2, length)
    #cutter = ocl.ConeCutter(diameter, angle, length)
Ejemplo n.º 9
0
import ocl as cam
import camvtk
import time
import vtk
import datetime

if __name__ == "__main__":
    myscreen = camvtk.VTKScreen()
    myscreen.setAmbient(1, 1, 1)

    stl = camvtk.STLSurf(filename="demo.stl")
    print "STL surface read"
    myscreen.addActor(stl)
    stl.SetWireframe()
    stl.SetColor((0.5, 0.5, 0.5))
    #stl.SetFlat()
    polydata = stl.src.GetOutput()
    s = cam.STLSurf()
    camvtk.vtkPolyData2OCLSTL(polydata, s)
    print "STLSurf with ", s.size(), " triangles"
    cutterDiameter = 0.6
    cutter = cam.CylCutter(cutterDiameter, 5)
    #print cutter.str()
    #print cc.type
    minx = -1
    dx = 1
    maxx = 11

    miny = -1
    dy = 0.1
    maxy = 11
Ejemplo n.º 10
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()