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

volume_slice.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/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 /* ----------------------------- MNI Header ----------------------------------- 00024 @NAME : create_slice_quadmesh 00025 @INPUT : volume 00026 axis_index 00027 voxel_position 00028 x_tess 00029 y_tess 00030 x_min : optional ranges, ignored if x_min > x_max 00031 x_max 00032 y_min : optional ranges, ignored if y_min > y_max 00033 y_max 00034 @OUTPUT : quadmesh 00035 @RETURNS : 00036 @DESCRIPTION: Creates a quadmesh slice corresponding to a slice through 00037 the volume. 00038 @METHOD : 00039 @GLOBALS : 00040 @CALLS : 00041 @CREATED : 1993 David MacDonald 00042 @MODIFIED : 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 /* ----------------------------- MNI Header ----------------------------------- 00109 @NAME : create_slice_3d 00110 @INPUT : volume 00111 origin 00112 normal 00113 @OUTPUT : polygons 00114 @RETURNS : 00115 @DESCRIPTION: Creates a polygon of 3 to 6 points which is the intersection 00116 of an arbitrarily oriented plane with a volume. 00117 @METHOD : 00118 @GLOBALS : 00119 @CALLS : 00120 @CREATED : 1993 David MacDonald 00121 @MODIFIED : 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 }

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