swig/Examples/ocaml/shapes/example.c
Art Yerkes e0dca0ec65 shapes example: slight correction to depth map.
makedebugtop: include swig.cmo
Lib: factored out more common code, slightly reorganized class type.
     added director define and exceptions.
     std_string: length from the original ocaml string (no longer depends on
      null termination)
     ocamldec.swg/ocaml.swg: added caml_string_len
Examples/Makefile.in: quiet about checking out files.
Ocaml.cxx:
     Fixed abstract director test case.
     Include/exclude director.swg based on directors being enabled.
Final edits for 1.3.20, barring bugs being discovered.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5477 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-12-04 06:15:07 +00:00

50 lines
1.3 KiB
C

/* File : example.c */
#include <stdio.h>
#include "example.h"
shape::shape() { }
shape::~shape() { }
bool shape::cover( double x, double y ) { return false; }
void draw_shape_coverage( shape *s, int div_x, int div_y ) {
double i,j;
for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
if( s->cover( j,i ) ) putchar( 'x' ); else putchar( ' ' );
}
printf( "\n" );
}
}
void draw_depth_map( volume *v, int div_x, int div_y ) {
double i,j;
char depth_map_chars[] = "#*+o;:,. ";
double lowbound, highbound;
double current = 0.0;
bool bounds_set = false;
for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
current = v->depth( j,i );
if( !bounds_set ) {
lowbound = current; highbound = current; bounds_set = true;
}
if( current < lowbound ) lowbound = current;
if( current > highbound ) highbound = current;
}
}
for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
current = ((v->depth( j,i ) - lowbound) /
(highbound - lowbound)) * 8;
putchar(depth_map_chars[(int)current]);
}
putchar('\n');
}
}
double volume::depth( double x, double y ) { return 0.0; }