| 1 |
from opencamlib import ocl, camvtk |
| 2 |
import issue20data |
| 3 |
|
| 4 |
if __name__ == "__main__": |
| 5 |
s = ocl.STLSurf() |
| 6 |
triangles = issue20data.trilist |
| 7 |
|
| 8 |
for t in triangles: |
| 9 |
s.addTriangle(t) |
| 10 |
|
| 11 |
print(ocl.version() ) |
| 12 |
# define a cutter |
| 13 |
length = 10 |
| 14 |
cutter = ocl.CylCutter(3, length) |
| 15 |
#cutter = ocl.BallCutter(3, length) |
| 16 |
#cutter = ocl.BullCutter(3,0.5, length) |
| 17 |
|
| 18 |
pdf = ocl.PathDropCutter() # create a pdf-object for the surface s |
| 19 |
pdf.setSTL(s) |
| 20 |
pdf.setCutter(cutter) # set the cutter |
| 21 |
pdf.minimumZ = -1 # set the minimum Z-coordinate, or |
| 22 |
# "floor" for drop-cutter |
| 23 |
|
| 24 |
path = ocl.Path() # create an empty path object |
| 25 |
# add a line to the path |
| 26 |
path.append(ocl.Line(ocl.Point(0, 0.098, 0), ocl.Point(4, 0.098, 0))) |
| 27 |
|
| 28 |
# set the path for pdf |
| 29 |
pdf.setPath( path ) |
| 30 |
|
| 31 |
pdf.run() # run drop-cutter on the path |
| 32 |
|
| 33 |
clp = pdf.getCLPoints() # get the cl-points from pdf |
| 34 |
|
| 35 |
|
| 36 |
print('first point ', clp[0], ' ( z should be at z5 )') |
| 37 |
|
| 38 |
# visualize things with VTK |
| 39 |
myscreen = camvtk.VTKScreen() |
| 40 |
myscreen.addActor( camvtk.PointCloud( pointlist=clp ) ) |
| 41 |
#myscreen.addActor( camvtk.PointCloud( pointlist=ccp, collist=ccp ) ) |
| 42 |
su = camvtk.STLSurf(filename=None, triangleList=triangles ) |
| 43 |
su.SetWireframe() |
| 44 |
myscreen.addActor(su) |
| 45 |
myscreen.render() |
| 46 |
myscreen.iren.Start() |