/***************************************************************************** * Copyright 2005 Kevin Hobbs * * * * This file is part of Balloon. * * * * Balloon is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * Balloon is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Balloon; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *****************************************************************************/ #include #include #include #include #include "mesh.h" #include "utility.h" #include "balloon.h" #define NDIMS 3 int main (void) { size_t i, j; const double x0[NDIMS] = {0.0, 0.0, 0.0}; const double s0[NDIMS] = {0.5, 0.5, 0.5}; double x[NDIMS]; double y; double s[NDIMS]; int status; size_t id = 0; struct point * * balloon; struct point * p1; struct point * p2; struct point * p3; const gsl_rng_type * T; gsl_rng * r; gsl_rng_env_setup(); T = gsl_rng_default; r = gsl_rng_alloc (T); balloon = init_balloon(x0, s0, NDIMS, &id, r); for ( j = 0; j < id; j++) { printf("%lu ", balloon[j]->id); for ( i = 0; i < NDIMS; i++) printf("%g ", balloon[j]->x_in[i]); printf("\n"); } while (( long_segment(balloon, id, s0, NDIMS, &p1, &p2) == STILL_LONG) && (id < 2000)) { balloon = xrealloc(balloon, sizeof( struct point * ) * (id + 1) ); p3 = new_empty_point(NDIMS, id); balloon[id] = p3; id++; insert_point(p1, p2, p3); mid_point( p1, p2, x, NDIMS); status = in_out( x, &y, NDIMS ); if ( status == FUNCTION_INSIDE ) { for ( i = 0; i < NDIMS; i++) p3 -> x_in[i] = x[i]; p3 -> y_in = y; direction(p3, s, NDIMS); } if ( status == FUNCTION_OUTSIDE) { for ( i = 0; i < NDIMS; i++) { p3 -> x_in[i] = x0[i]; s[i] = x[i]; } } inflate(p3, s, s0, NDIMS, r); printf("%lu ", balloon[id-1]->id); for ( i = 0; i < NDIMS; i++) printf("%g ", p3->x_in[i]); printf("\n"); } return 0; }