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/curvature.c,v 1.21 2002/11/27 22:48:11 stever Exp $";
00020
#endif
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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 ¢roid, &normal, &base_length,
00093 &curvature );
00094
00095 }
00096
else
00097 {
00098
00099
00100
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 }