Require bind.tcl
Require Class/basicCurveFromSurface

basicCurveFromSurface Subclass CurveFromSurface {
  Var "domain {[basicCurveFromSurface get domain]}"
  Method <Domain> {domain} {set [var domain] $domain}
  ClassVar "Domain-template {{[basicCurveFromSurface get domain]}}"

  Var "param {[basicCurveFromSurface get param]}" cfunction f-xy
  Var "frame [basicCurveFromSurface get frame]"
  Method <Function> {param curve script args} {
    global errorCode errorInfo
    if [set code [catch [list _bind(Rest) {} {{frame ""} {absolute ""}} \
        $args [Self method <Function>]] err]] \
	{return -code $code -errorcode $errorCode -errorinfo $errorInfo $err}
    if {[llength $param] != 1} {Error "Function must be of one variable"}
    set [var param] $param
    set [var f-xy] $curve
    set [var cfunction] $script
    if {$frame != ""} {set [var frame] 1} else {set [var frame] 0}
  }
  ClassVar [list "Function-template" \
    "{t} {\n  let (x,y) = (t,t^2)\n} {\n  let (x,y,z) = (.1,0,0)\n} -frame"]

  ClassVar {script-templates {Domain Function}}

  Method ScriptBegin {} {
    Vars domain param cfunction f-xy frame
    Parent ScriptBegin
    set domain [Parent get domain]
    set param [Parent get param]
    set cfunction {}
    set f-xy
    set frame [Parent get frame]
  }
}

CurveFromSurface Register
