| 1 |
from opencamlib import ocl, pyocl, camvtk |
| 2 |
import math |
| 3 |
|
| 4 |
if __name__ == "__main__": |
| 5 |
print(ocl.version()) |
| 6 |
myscreen = camvtk.VTKScreen() |
| 7 |
|
| 8 |
a=ocl.Point(1,0.6,0.1) |
| 9 |
myscreen.addActor(camvtk.Point(center=(a.x,a.y,a.z), color=(1,0,1))) |
| 10 |
b=ocl.Point(0,1,0) |
| 11 |
myscreen.addActor(camvtk.Point(center=(b.x,b.y,b.z), color=(1,0,1))) |
| 12 |
c=ocl.Point(0,0,0.0) |
| 13 |
myscreen.addActor(camvtk.Point(center=(c.x,c.y,c.z), color=(1,0,1))) |
| 14 |
|
| 15 |
myscreen.addActor( camvtk.Line(p1=(a.x,a.y,a.z),p2=(c.x,c.y,c.z)) ) |
| 16 |
myscreen.addActor( camvtk.Line(p1=(c.x,c.y,c.z),p2=(b.x,b.y,b.z)) ) |
| 17 |
myscreen.addActor( camvtk.Line(p1=(a.x,a.y,a.z),p2=(b.x,b.y,b.z)) ) |
| 18 |
|
| 19 |
t = ocl.Triangle(b,c,a) |
| 20 |
radius1=1 |
| 21 |
angle = math.pi/4 |
| 22 |
#cutter = ocl.ConeCutter(0.37, angle) |
| 23 |
#cutter = ocl.BallCutter(0.532) |
| 24 |
#cutter = ocl.CylCutter(0.3) |
| 25 |
#cutter = ocl.BullCutter(1,0.2) |
| 26 |
|
| 27 |
#cutter = ocl.CylConeCutter(0.2,0.5,math.pi/9) |
| 28 |
#cutter = ocl.BallConeCutter(0.4,0.6,math.pi/9) |
| 29 |
cutter = ocl.BullConeCutter(0.4,0.1,0.7,math.pi/6) |
| 30 |
#cutter = ocl.ConeConeCutter(0.4,math.pi/3,0.7,math.pi/6) |
| 31 |
#cutter = ocl.ConeCutter(0.4, math.pi/3) |
| 32 |
print(cutter) |
| 33 |
|
| 34 |
#print cc.type |
| 35 |
minx=-0.5 |
| 36 |
dx=0.0051 |
| 37 |
maxx=1.5 |
| 38 |
miny=-0.7 |
| 39 |
dy=dx |
| 40 |
maxy=1.5 |
| 41 |
z=-1.8 |
| 42 |
clpoints = pyocl.CLPointGrid(minx,dx,maxx,miny,dy,maxy,z) |
| 43 |
nv=0 |
| 44 |
nn=0 |
| 45 |
ne=0 |
| 46 |
nf=0 |
| 47 |
print(len(clpoints), "cl-points to evaluate") |
| 48 |
n=0 |
| 49 |
|
| 50 |
for cl in clpoints: |
| 51 |
cutter.vertexDrop(cl,t) |
| 52 |
cutter.edgeDrop(cl,t) |
| 53 |
cutter.facetDrop(cl,t) |
| 54 |
#cutter.dropCutter(cl,t) |
| 55 |
n=n+1 |
| 56 |
if (n % int(len(clpoints)/10)) == 0: |
| 57 |
print(n/int(len(clpoints)/10), " ",) |
| 58 |
|
| 59 |
print("done.") |
| 60 |
print("rendering...") |
| 61 |
print(" len(clpoints)=", len(clpoints)) |
| 62 |
|
| 63 |
camvtk.drawCLPointCloud(myscreen, clpoints) |
| 64 |
print("done.") |
| 65 |
origo = camvtk.Sphere(center=(0,0,0) , radius=0.1, color=camvtk.blue) |
| 66 |
origo.SetOpacity(0.2) |
| 67 |
myscreen.addActor( origo ) |
| 68 |
|
| 69 |
myscreen.camera.SetPosition(0.5, 3, 2) |
| 70 |
myscreen.camera.SetFocalPoint(0.5, 0.5, 0) |
| 71 |
myscreen.render() |
| 72 |
myscreen.iren.Start() |
| 73 |
#raw_input("Press Enter to terminate") |