31 #define _CRT_SECURE_NO_DEPRECATE
39 #define HB_MAGIC_COLOR 999
40 #define HB_MAGIC_PAINTER_BIT 0x40000000
77 printf(
"Hedges: %d\n",
int(
hb_hedges.size()));
80 double l_inc = 50.0/((double)
hb_hedges.size());
81 double l_count = 0.001;
83 for (
unsigned int i=0; i<
hb_hedges.size(); i++ ) {
85 if ( l_count > 1.0 ) {
122 while ( l_color > l_min ) {
141 for (
int j=0; j<
hb_size; j++ ) {
143 printf(
"Oh dear!\n");
149 sprintf( ffname,
"test%02d.ppm", i);
163 for (
unsigned int i=0; i<
m_elems.size(); i++ ) {
164 if (
m_elems[i]->GetArea() < 0.9 &&
168 printf(
"Warning: Polygon %6d of type %s came up with area %3.2f!\n",
206 if ( l_val >= 0 && l_val <
HB_MAGIC ) {
228 static LE* l_curr_ele = NULL;
251 bool l_found =
false;
255 for (
int l_y=0; l_y<
hb_height; l_y++ ) {
256 for (
int l_x=0; l_x<
hb_width; l_x++ ) {
278 for (
unsigned int i=0; i<
m_elems.size(); i++ ) {
291 for (
int i=0; i<
hb_size; i++ ) {
303 if (
hb_map[l_coord] < 0 )
316 if (
hb_map[l_coord] < 0 ) {
317 hb_map[l_coord] = a_orig_poly_number;
341 bool l_has_neighbour =
false;
351 l_has_neighbour =
true;
358 l_has_neighbour =
true;
365 l_has_neighbour =
true;
373 l_has_neighbour =
true;
380 l_has_neighbour =
true;
389 l_has_neighbour =
true;
396 l_has_neighbour =
true;
403 l_has_neighbour =
true;
408 return l_has_neighbour;
420 if (
hb_map[ l_coord ] == a_poly_num ) {
440 hb_map[ l_coord ] = a_color;
453 int a_neighbour_color )
455 bool l_neighbour_has_color =
false;
461 if ( a_x >= 0 && a_y >= 0 &&
463 l_neighbour_has_color =
true;
469 l_neighbour_has_color =
true;
476 l_neighbour_has_color =
true;
484 l_neighbour_has_color =
true;
491 l_neighbour_has_color =
true;
503 l_neighbour_has_color =
true;
509 l_neighbour_has_color =
true;
516 l_neighbour_has_color =
true;
521 return l_neighbour_has_color;
532 bool l_at_least_one =
false;
538 l_at_least_one =
true;
543 return l_at_least_one;
558 if ( a_x >= 0 && a_y >= 0 ) {
632 double l_up = 10000.0 - l_hb;
634 double l_length = (double)(random( (
int)l_hb )) * 0.0001 *
636 double l_hb_remain = 0.0;
637 double l_up_remain = 0.0;
648 if ( l_length >= 1.0 ) {
660 l_hb_remain = l_length;
661 l_length = (double)(random( (
int)l_up )) * 0.0001 *
665 l_up_remain = l_length;
666 l_length = (double)(random( (
int)l_hb )) * 0.0001 *
695 if (
hb_map[ l_coord ] == a_color ) {
699 hb_map[ l_coord ] = l_max;
706 hb_map[ l_coord ] = -a_color;
717 for (
int i=0; i<
hb_size; i++ ) {
727 #define SV_UINT32 unsigned int
729 #define SV_UINT8 unsigned char
733 const unsigned int hb_dump_colors [
tole_Foobar] = {
772 void Landscape::hb_dump_map(
int a_beginx,
int a_width,
773 int a_beginy,
int a_height,
775 bool a_high_numbers )
780 if ( linebuffer == NULL ) {
781 printf(
"hb_dump_color_map(): Out of memory!\n",
786 FILE* l_file = fopen( a_filename,
"w" );
788 printf(
"hb_dump_color_map(): Unable to open file for writing: %s\n",
793 fprintf( l_file,
"P6\n%d %d %d\n",
798 for (
int line=a_beginy; line< a_beginy + a_height; line++ ) {
800 for (
int column=a_beginx; column < a_beginx + a_width; column++ ) {
801 int localcolor = hb_dump_color( column, line, a_high_numbers );
802 linebuffer [ i++ ] = localcolor & 0xff;
803 linebuffer [ i++ ] = (localcolor >> 8) & 0xff;
804 linebuffer [ i++ ] = (localcolor >> 16) & 0xff;
806 fwrite( linebuffer,
sizeof(
SV_UINT8), linesize, l_file );
814 inline int Landscape::hb_dump_color(
int a_x,
int a_y,
815 bool a_high_numbers )
827 [l_map_val]]->GetElementType() ];
830 return 0x00ffffff - 32*l_map_val;