Commit 5ebf1985 authored by lode_leroy's avatar lode_leroy

update tests

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@49 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent dd10fa15
......@@ -17,16 +17,19 @@ from pycam.Exporters.SimpleGCodeExporter import SimpleGCodeExporter
if __name__ == "__main__":
c = SphericalCutter(1, Point(0,0,7))
#c = SphericalCutter(1, Point(0,0,7))
#c = CylindricalCutter(1, Point(0,0,7))
#c = ToroidalCutter(1, 0.25, Point(0,0,7))
c = ToroidalCutter(1, 0.1, Point(0,0,7))
print "c=", c
model = TestModel()
#model = TestModel()
model = Model()
model.append(Triangle(Point(-3,-4,1),Point(-3,4,1),Point(3,0,1)))
if True:
samples = 20
lines = 20
samples = 50
lines = 50
x0 = -7.0
x1 = +7.0
y0 = -7.0
......@@ -39,9 +42,5 @@ if __name__ == "__main__":
pathlist = pg.GenerateToolPath(x0, x1, y0, y1, z0, z1, dx, dy, 0)
g = SimpleGCodeExporter("cutter2.nc", "mm", x1, y1, z1, 100, 7000)
g.AddPathList(pathlist)
g.close()
ShowTestScene(model, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Gui.Visualization import Visualization
from pycam.Simulation.ZBuffer import ZBuffer
from pycam.Importers.TestModel import TestModel
from pycam.Geometry.Triangle import Triangle
from pycam.Geometry.Point import Point
from pycam.Cutters.SphericalCutter import SphericalCutter
from OpenGL.GL import *
model = TestModel()
zbuffer = ZBuffer(-5,+5,30, -5,+5,30, 1,5)
#zbuffer.add_wave()
#zbuffer.add_triangle(Triangle(Point(-4,0,0),Point(3,5,2),Point(4,-3,4)))
c = SphericalCutter(0.25)
p = Point(-5,-5,1)
c.moveto(p)
zbuffer.add_triangles(model.triangles())
#zbuffer.add_cutter(c)
def DrawScene():
size=1
# axes
glBegin(GL_LINES)
glColor3f(1,0,0)
glVertex3f(0,0,0)
glVertex3f(size,0,0)
glEnd()
glBegin(GL_LINES)
glColor3f(0,1,0)
glVertex3f(0,0,0)
glVertex3f(0,size,0)
glEnd()
glBegin(GL_LINES)
glColor3f(0,0,1)
glVertex3f(0,0,0)
glVertex3f(0,0,size)
glEnd()
glColor3f(1,1,1)
c.to_OpenGL()
glColor3f(0.9,0.8,0.7)
# glMaterial(GL_FRONT_AND_BACK, GL_AMBIENT, (0.9, 0.8, 0.7, 0.2))
# glMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE, (0.8, 0.8, 0.8, 0.2))
glMaterial(GL_FRONT_AND_BACK, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
glMaterial(GL_FRONT_AND_BACK, GL_SHININESS, (0.5))
zbuffer.to_OpenGL()
dy = 0.1
dx = 0.23
dz = -0.01
def HandleKey(key, x, y):
global dx,dy,dz
p.x += dx
if p.x>5 or p.x<-5:
dx = -dx
p.x += dx * 2
p.y += dy
if p.y>5 or p.y<-5:
dy = -dy
p.y += dy * 2
p.z += dz
c.moveto(p)
zbuffer.add_cutter(c)
Visualization("VisualizationTest", DrawScene, handleKey = HandleKey)
......@@ -43,7 +43,7 @@ if __name__ == "__main__":
#c = ToroidalCutter(1, 0.25, Point(-2.2,0.2,6))
#c = ToroidalCutter(1, 0.25, Point(-1.7,0.5,6))
dir = Point(1,0,0)
c = ToroidalCutter(1, 0.25, Point(-10,0.1,1.9))
c = ToroidalCutter(1, 0.4, Point(-10,0.1,1.9))
print "c=", c
t = Triangle(Point(-2,0,2), Point(2,1,3), Point(2,-1,4))
print "t=", t
......@@ -56,7 +56,7 @@ if __name__ == "__main__":
print "cl=", cl_p
print "d=", d_p
if False:
if True:
p = t.p1
(cl_v,ccp_v,cp_v,d_v) = c.intersect_torus_point(dir,p)
print "ccp=", ccp_v
......@@ -72,16 +72,22 @@ if __name__ == "__main__":
print "cl=", cl_e
print "d=", d_e
if False:
e = Line(t.p1,t.p2)
(cl_e,d_e) = c.intersect_torus_edge(dir,e)
print "cl=", cl_e
print "d=", d_e
if False:
(cl,d) = c.intersect(dir,t)
print "cl=", cl
if False:
samples = 50
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
if True:
samples = 100
x0 = -3.0
x1 = +3.0
y0 = -3.0
y1 = +3.0
z = 10
pathlist = []
for i in range(0,samples):
......@@ -90,17 +96,22 @@ if __name__ == "__main__":
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x,y,z))
cl = c.drop(t)
#cl = c.drop(t)
(cl,d) = c.intersect(Point(0,0,-1), t)
#(cl,d) = c.intersect_torus_triangle(Point(0,0,-1), t)
#(cl,d) = c.intersect_torus_vertex(Point(0,0,-1), t.p1)
#(cl,d) = c.intersect_torus_edge(Point(0,0,-1), Line(t.p1,t.p2))
if cl:
#p.append(cl.sub(Point(0,0,-1).mul(d)))
p.append(cl)
else:
p.append(Point(x,y,0))
#else:
#p.append(Point(x,y,0))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
if True:
samples = 100
if False:
samples = 300
layers = 10
x0 = -5.0
x1 = +5.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment