Added noarg item to example to show director default constructor.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5203 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Art Yerkes 2003-10-25 06:19:26 +00:00
commit 476fcbf76a
4 changed files with 69 additions and 2 deletions

View file

@ -35,11 +35,42 @@ let triangle_class pts ob meth args =
pts (get_float x_arg) (get_float y_arg))
| _ -> raise (Failure "cover needs two double arguments."))
| _ -> (invoke ob) meth args ;;
let dist (ax,ay) (bx,by) =
let dx = ax -. bx and dy = ay -. by in
sqrt ((dx *. dx) +. (dy *. dy))
let waveplot_depth events distance pt =
(List.fold_left (+.) 0.0
(List.map
(fun (x,y,d) ->
let t = dist pt (x,y) in
((sin t) /. t) *. d)
events)) +. distance
let waveplot_class events distance ob meth args =
match meth with
"depth" ->
(match args with
C_list [ x_arg ; y_arg ] ->
let xa = get_float x_arg and ya = get_float y_arg in
C_double
(waveplot_depth events distance
(get_float x_arg,get_float y_arg))
| _ -> raise (Failure "cover needs two double arguments."))
| _ -> (invoke ob) meth args ;;
let triangle =
new_derived_object
new_shape
(triangle_class ((0.0,0.0),(0.5,1.0),(1.0,0.6)))
C_void ;;
let waveplot =
new_derived_object
new_volume
(waveplot_class [ 0.01,0.01,3.0 ; 1.01,-2.01,1.5 ] 5.0)
C_void ;;
let _ = _draw_shape_coverage (C_list [ triangle ; C_int 60 ; C_int 20 ]) ;;
let _ = _draw_depth_map (C_list [ waveplot ; C_int 60 ; C_int 20 ]) ;;