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
#include <bicpl/geom.h>
00018
00019
#ifndef lint
00020
static char rcsid[] =
"$Header: /software/source//libraries/bicpl/Geometry/volume_slice.c,v 1.11 2000/02/06 15:30:20 stever Exp $";
00021
#endif
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 public void create_slice_quadmesh(
00046 Volume volume,
00047
int axis_index,
00048 Real voxel_position,
00049
int x_tess,
00050
int y_tess,
00051 Real x_min,
00052 Real x_max,
00053 Real y_min,
00054 Real y_max,
00055
quadmesh_struct *quadmesh )
00056 {
00057 Point point;
00058 Vector normal;
00059 Real x_w, y_w, z_w;
00060
int sizes[N_DIMENSIONS];
00061 Real voxel[N_DIMENSIONS];
00062
int x,
y, x_axis, y_axis;
00063 Surfprop spr;
00064
00065 x_axis = (axis_index + 1) % N_DIMENSIONS;
00066 y_axis = (axis_index + 2) % N_DIMENSIONS;
00067 get_volume_sizes( volume, sizes );
00068
00069
if( x_tess <= 1 )
00070 x_tess = MAX( 2, sizes[x_axis] );
00071
if( y_tess <= 1 )
00072 y_tess = MAX( 2, sizes[y_axis] );
00073
00074
get_default_surfprop( &spr );
00075
initialize_quadmesh( quadmesh,
WHITE, &spr, x_tess, y_tess );
00076
00077 voxel[axis_index] = voxel_position;
00078
00079 fill_Vector( normal, 0.0, 0.0, 0.0 );
00080 Vector_coord( normal, axis_index ) = 1.0f;
00081
00082
if( x_min >= x_max )
00083 {
00084 x_min = 0.0;
00085 x_max = (Real) (sizes[x_axis] - 1);
00086 }
00087
00088
if( y_min >= y_max )
00089 {
00090 y_min = 0.0;
00091 y_max = (Real) (sizes[y_axis] - 1);
00092 }
00093
00094 for_less( x, 0, x_tess )
00095 {
00096 voxel[x_axis] = x_min + (x_max - x_min) * (Real) x / (Real) (x_tess-1);
00097 for_less(
y, 0, y_tess )
00098 {
00099 voxel[y_axis] = y_min + (y_max - y_min) * (Real)
y/(Real)(y_tess-1);
00100
00101 convert_voxel_to_world( volume, voxel, &x_w, &y_w, &z_w );
00102 fill_Point( point, x_w, y_w, z_w );
00103
set_quadmesh_point( quadmesh, x,
y, &point, &normal );
00104 }
00105 }
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 public void create_slice_3d(
00125 Volume volume,
00126 Point *origin,
00127 Vector *normal,
00128
polygons_struct *polygons )
00129 {
00130
int i, n_points;
00131 Point point;
00132 Real xw, yw, zw;
00133 Real voxel[MAX_DIMENSIONS];
00134 Real origin_voxel[MAX_DIMENSIONS];
00135 Real y_axis[MAX_DIMENSIONS];
00136 Real x_axis[MAX_DIMENSIONS];
00137 Real outline[6][MAX_DIMENSIONS];
00138 Vector v1, v2;
00139
00140 create_two_orthogonal_vectors( normal, &v1, &v2 );
00141
00142 convert_world_vector_to_voxel( volume,
00143 (Real) Vector_x(v1),
00144 (Real) Vector_y(v1),
00145 (Real) Vector_z(v1),
00146 x_axis );
00147 convert_world_vector_to_voxel( volume,
00148 (Real) Vector_x(v2),
00149 (Real) Vector_y(v2),
00150 (Real) Vector_z(v2),
00151 y_axis );
00152
00153 convert_world_to_voxel( volume,
00154 (Real) Point_x(*origin), (Real) Point_y(*origin),
00155 (Real) Point_z(*origin), origin_voxel );
00156
00157 n_points =
get_volume_cross_section( volume, origin_voxel, x_axis, y_axis,
00158 outline );
00159
00160
initialize_polygons( polygons,
WHITE, NULL );
00161
00162 for_less( i, 0, n_points )
00163 {
00164 voxel[0] = outline[i][0];
00165 voxel[1] = outline[i][1];
00166 voxel[2] = outline[i][2];
00167
00168 convert_voxel_to_world( volume, voxel, &xw, &yw, &zw );
00169
00170 fill_Point( point, xw, yw, zw );
00171
00172
add_point_to_polygon( polygons, &point, normal );
00173 }
00174 }