-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate_ellipsoids.c
55 lines (44 loc) · 1.58 KB
/
create_ellipsoids.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bicpl.h>
int main(
int argc,
char *argv[] )
{
FILE *file;
Status status;
char *input_filename, *output_filename;
int n_triangles, n_objects;
Point centre;
object_struct *object, **object_list;
polygons_struct *polygons;
Real x, y, z, rx, ry, rz;
status = OK;
initialize_argument_processing( argc, argv );
if( !get_string_argument( "", &input_filename ) ||
!get_string_argument( "", &output_filename ) )
{
(void) fprintf( stderr,
"Usage: input_filename output_filename [n_triangles]\n" );
return( 1 );
}
(void) get_int_argument( 128, &n_triangles );
if( open_file( input_filename, READ_FILE, ASCII_FORMAT, &file ) != OK )
return( 1 );
n_objects = 0;
while( input_real( file, &x ) == OK &&
input_real( file, &y ) == OK &&
input_real( file, &z ) == OK &&
input_real( file, &rx ) == OK &&
input_real( file, &ry ) == OK &&
input_real( file, &rz ) == OK )
{
object = create_object( POLYGONS );
polygons = get_polygons_ptr(object);
fill_Point( centre, x, y, z );
create_tetrahedral_sphere( ¢re, rx, ry, rz, n_triangles, polygons );
compute_polygon_normals( polygons );
ADD_ELEMENT_TO_ARRAY( object_list, n_objects, object, 10 );
}
status = output_graphics_file( output_filename, BINARY_FORMAT, n_objects,
object_list );
return( status != OK );
}