Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

segment_polygons.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 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 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : remove_invisible_polygons 00024 @INPUT : polygons 00025 visibilities 00026 @OUTPUT : 00027 @RETURNS : 00028 @DESCRIPTION: Removes any polygon that is not marked as visible from the 00029 polygons. 00030 @METHOD : 00031 @GLOBALS : 00032 @CALLS : 00033 @CREATED : 1993 David MacDonald 00034 @MODIFIED : 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 }

Generated on Wed Jul 28 09:10:58 2004 for BICPL by doxygen 1.3.7