Debian Codegraph @

examples/python/waterline/waterline_6_weave2.py

raw
1 from opencamlib import ocl, camvtk
2 import time
3
4 def waterline_time(zheights, diam, length,s,sampling):
5 t_total = time.time()
6 for zh in zheights:
7 cutter = ocl.BallCutter( diam , length )
8 wl = ocl.Waterline()
9 wl.setSTL(s)
10 wl.setCutter(cutter)
11 wl.setZ(zh)
12 wl.setSampling(sampling)
13 wl.setThreads(1)
14
15 wl.run()
16
17 cutter_loops = wl.getLoops()
18 for l in cutter_loops:
19 loops.append(l)
20 timeTotal = time.time()-t_total
21 print(" ALL Waterlines done in ", timeTotal ," s")
22 return timeTotal
23
24
25 if __name__ == "__main__":
26 print(ocl.version())
27 a = ocl.Point(0,1,0.3)
28 b = ocl.Point(1,0.5,0.3)
29 c = ocl.Point(0,0,0)
30 t = ocl.Triangle(b,c,a)
31 s = ocl.STLSurf()
32 s.addTriangle(t) # a one-triangle STLSurf
33
34 # alternatively, run on the tux model
35 stl = camvtk.STLSurf("../../../stl/gnu_tux_mod.stl")
36 #myscreen.addActor(stl)
37 #stl.SetWireframe() # render tux as wireframe
38 #stl.SetSurface() # render tux as surface
39 #stl.SetColor(camvtk.cyan)
40 polydata = stl.src.GetOutput()
41 s = ocl.STLSurf()
42 camvtk.vtkPolyData2OCLSTL(polydata, s)
43
44 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
45 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 ]
46 zheights=[ -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.28]
47 zheights=[ 1.75145 ]
48 diam = 0.6 # run the thing for all these cutter diameters
49 length = 5
50 loops = []
51 cutter = ocl.CylCutter( 1 , 1 )
52 sampling=0.005
53 waterline_time(zheights, diam, length,s,sampling)
54