fn surf2line s1 s2 segs opas =
(
	-- make the initial mesh
	local u_step = 1.0 / segs,
	      n_steps = (segs + 1) as integer,
	      n_verts = 2 * n_steps,
	      n_faces = n_verts - 2,
	      m = mesh numVerts:n_verts numFaces:n_faces

	-- set the vertex positions by stepping parametrically along each spline
	-- vertex numbers alternate from spline-to-spline starting at
	-- beginning of s1
    i=numKnots s1 1
	n1=getKnotPoint s1 1 1
    n2=getKnotPoint s1 1 i
    i=numKnots s2 1
	n3=getKnotPoint s2 1 1
    n4=getKnotPoint s2 1 i

	if distance n1 n3 + distance n2 n4 > distance n1 n4 + distance n2 n3 do reverse s1 1
	m.material=standard opacity:opas diffuse:s1.wirecolor ambient:s1.wirecolor
/*    m.material.diffuse=s1.wirecolor*/
    m.material.shaderByName="metal" 
/*    m.material.twoSided=on */

/*	m.wirecolor=s1.wirecolor*/
	m.parent=s1

	local u = 0
	for i = 1 to n_verts by 2 do
	(
	    setVert m i (lengthinterp s1 u)
		setVert m (i+1) (lengthinterp s2 u)
		u += u_step
		if u > 1. then u=1. 
	)

	-- now set up the faces: (3,2,1)(4,2,3)(5,4,3)(6,4,5)(7,6,5)(8,6,7)...
	-- and edge vis (2,3)(1,3)...
	for i = 1 to n_faces by 2 do
	(
		setFace m i [i+2, i+1, i]
		setEdgeVis m i 2 on; setEdgeVis m i 3 on
		setFace m (i+1) [i+3, i+1, i+2]
		setEdgeVis m (i+1) 1 on; setEdgeVis m (i+1) 3 on
	)

	-- update mesh caches & display, return it
	update m
	m
)

fn surf2l s1 s2 segs op:100 =
(
  surf2line s1 s2 segs op
  surf2line s2 s1 segs op 
)