00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
#include <volume_io/internal_volume_io.h>
00016
#include <bicpl/geom.h>
00017
00018
#ifndef lint
00019
static char rcsid[] =
"$Header: /software/source//libraries/bicpl/Geometry/segment_polygons.c,v 1.8 2000/02/06 15:30:17 stever Exp $";
00020
#endif
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 public void remove_invisible_polygons(
00038
polygons_struct *polygons,
00039 Smallest_int visibilities[] )
00040 {
00041
int tmp_n_points, i, n_points, n_items, *indices, *end_indices;
00042
int p, poly, n_indices, size, point_index;
00043
int *new_ids;
00044 Point *points;
00045 Vector *normals;
00046 Colour col;
00047
00048
if( visibilities == NULL )
00049
return;
00050
00051 n_points = 0;
00052 n_items = 0;
00053 n_indices = 0;
00054 indices = NULL;
00055 end_indices = NULL;
00056 points = NULL;
00057 normals = NULL;
00058
00059 ALLOC( new_ids, polygons->
n_points );
00060
00061 for_less( i, 0, polygons->
n_points )
00062 new_ids[i] = -1;
00063
00064 for_less( poly, 0, polygons->
n_items )
00065 {
00066
if( visibilities[poly] )
00067 {
00068 size =
GET_OBJECT_SIZE( *polygons, poly );
00069
00070 for_less( p, 0, size )
00071 {
00072 point_index = polygons->
indices[
00073
POINT_INDEX(polygons->
end_indices,poly,p)];
00074
00075
if( new_ids[point_index] < 0 )
00076 {
00077 new_ids[point_index] = n_points;
00078
00079 tmp_n_points = n_points;
00080
00081 ADD_ELEMENT_TO_ARRAY( points, tmp_n_points,
00082 polygons->
points[point_index], DEFAULT_CHUNK_SIZE );
00083
00084 ADD_ELEMENT_TO_ARRAY( normals, n_points,
00085 polygons->
normals[point_index], DEFAULT_CHUNK_SIZE );
00086 }
00087
00088 ADD_ELEMENT_TO_ARRAY( indices, n_indices,
00089 new_ids[point_index], DEFAULT_CHUNK_SIZE );
00090 }
00091
00092 ADD_ELEMENT_TO_ARRAY( end_indices, n_items,
00093 n_indices, DEFAULT_CHUNK_SIZE );
00094 }
00095 }
00096
00097 FREE( new_ids );
00098
00099 col = polygons->
colours[0];
00100
00101
delete_polygons( polygons );
00102
00103 ALLOC( polygons->
colours, 1 );
00104
00105 polygons->
colour_flag =
ONE_COLOUR;
00106 polygons->
colours[0] = col;
00107 polygons->
n_points = n_points;
00108 polygons->
points = points;
00109 polygons->
normals = normals;
00110 polygons->
n_items = n_items;
00111 polygons->
indices = indices;
00112 polygons->
end_indices = end_indices;
00113 }