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/vols.h>
00017
00018
#ifndef lint
00019
static char rcsid[] =
"$Header: /software/source//libraries/bicpl/Volumes/col_code_points.c,v 1.8 2000/02/06 15:30:53 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
00042 private void colour_code_points(
00043
colour_coding_struct *colour_coding,
00044 Volume volume,
00045
int continuity,
00046 Colour_flags *colour_flag,
00047 Colour *colours[],
00048
int n_points,
00049 Point points[] )
00050 {
00051
int i;
00052 Real val;
00053
00054
if( *colour_flag !=
PER_VERTEX_COLOURS )
00055 {
00056
if( n_points > 0 )
00057 {
00058 REALLOC( *colours, n_points );
00059 }
00060
else
00061 {
00062 FREE( *colours );
00063 }
00064 *colour_flag =
PER_VERTEX_COLOURS;
00065 }
00066
00067 for_less( i, 0, n_points )
00068 {
00069 (
void) evaluate_volume_in_world( volume,
00070 (Real) Point_x(points[i]),
00071 (Real) Point_y(points[i]),
00072 (Real) Point_z(points[i]), continuity,
FALSE,
00073 get_volume_real_min(volume),
00074 &val, (Real *) NULL,
00075 (Real *) NULL, (Real *) NULL,
00076 (Real *) NULL, (Real *) NULL,
00077 (Real *) NULL, (Real *) NULL,
00078 (Real *) NULL, (Real *) NULL );
00079
00080 (*colours)[i] =
get_colour_code( colour_coding, val );
00081 }
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 public void colour_code_object(
00100 Volume volume,
00101
int continuity,
00102
colour_coding_struct *colour_coding,
00103
object_struct *object )
00104 {
00105
polygons_struct *polygons;
00106
quadmesh_struct *quadmesh;
00107
lines_struct *lines;
00108
00109
switch( object->
object_type )
00110 {
00111
case POLYGONS:
00112 polygons =
get_polygons_ptr( object );
00113
colour_code_points( colour_coding, volume, continuity,
00114 &polygons->
colour_flag, &polygons->
colours,
00115 polygons->
n_points, polygons->
points );
00116
break;
00117
00118
case QUADMESH:
00119 quadmesh =
get_quadmesh_ptr( object );
00120
colour_code_points( colour_coding, volume, continuity,
00121 &quadmesh->
colour_flag, &quadmesh->
colours,
00122 quadmesh->
m * quadmesh->
n,
00123 quadmesh->
points );
00124
break;
00125
00126
case LINES:
00127 lines =
get_lines_ptr( object );
00128
colour_code_points( colour_coding, volume, continuity,
00129 &lines->
colour_flag, &lines->
colours,
00130 lines->
n_points, lines->
points );
00131
break;
00132
default:
00133 print_error(
"colour_code_object: object type %d not handled.\n",
00134 object->
object_type );
00135 }
00136 }