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

curvature.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/curvature.c,v 1.21 2002/11/27 22:48:11 stever Exp $"; 00020 #endif 00021 00022 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : get_polygon_vertex_curvatures 00024 @INPUT : polygons 00025 smoothing_distance 00026 low_threshold 00027 @OUTPUT : curvatures 00028 @RETURNS : 00029 @DESCRIPTION: Computes the curvatures at each vertex of the polygon, using 00030 1 of two methods. If smoothing distance is zero, computes 00031 instantaneous curvature in terms of a fractional relative 00032 curvature. If non-zero, returns +/- angle in degrees of the 00033 smoothed curvature. 00034 @METHOD : 00035 @GLOBALS : 00036 @CALLS : 00037 @CREATED : 1994 David MacDonald 00038 @MODIFIED : 00039 ---------------------------------------------------------------------------- */ 00040 00041 public void get_polygon_vertex_curvatures( 00042 polygons_struct *polygons, 00043 int n_neighbours[], 00044 int *neighbours[], 00045 Real smoothing_distance, 00046 Real low_threshold, 00047 Real curvatures[] ) 00048 { 00049 int size, point_index, vertex_index, poly; 00050 Real curvature, base_length; 00051 Smallest_int *point_done; 00052 Point centroid; 00053 Vector normal; 00054 float *distances; 00055 BOOLEAN initialized; 00056 progress_struct progress; 00057 00058 compute_polygon_normals( polygons ); 00059 00060 ALLOC( point_done, polygons->n_points ); 00061 00062 for_less( point_index, 0, polygons->n_points ) 00063 point_done[point_index] = FALSE; 00064 00065 if( smoothing_distance > 0.0 ) 00066 { 00067 ALLOC( distances, polygons->n_points ); 00068 initialized = FALSE; 00069 } 00070 00071 initialize_progress_report( &progress, FALSE, polygons->n_items, 00072 "Computing Curvatures" ); 00073 00074 for_less( poly, 0, polygons->n_items ) 00075 { 00076 size = GET_OBJECT_SIZE( *polygons, poly ); 00077 00078 for_less( vertex_index, 0, size ) 00079 { 00080 point_index = polygons->indices[ 00081 POINT_INDEX(polygons->end_indices,poly,vertex_index)]; 00082 00083 if( !point_done[point_index] ) 00084 { 00085 point_done[point_index] = TRUE; 00086 00087 if( smoothing_distance <= 0.0 ) 00088 { 00089 compute_points_centroid_and_normal( polygons, point_index, 00090 n_neighbours[point_index], 00091 neighbours[point_index], 00092 &centroid, &normal, &base_length, 00093 &curvature ); 00094 00095 } 00096 else 00097 { 00098 /* There is some state being carried around in 00099 the "distances" list. Negative numbers are being 00100 used as markers in some manner. 00101 */ 00102 curvature = get_smooth_surface_curvature( polygons, 00103 n_neighbours, neighbours, 00104 poly, vertex_index, 00105 initialized, distances, smoothing_distance ); 00106 00107 initialized = TRUE; 00108 } 00109 00110 if( FABS( curvature ) < low_threshold ) 00111 curvature = 0.0; 00112 00113 curvatures[point_index] = curvature; 00114 } 00115 } 00116 00117 update_progress_report( &progress, poly + 1 ); 00118 } 00119 00120 terminate_progress_report( &progress ); 00121 00122 if( smoothing_distance > 0.0 ) 00123 FREE( distances ); 00124 }

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