arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

gliftNrrd.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 9/6/02       Aaron Lefohn    Scientific Computing and Imaging Institute
00003 // School of Computing          University of Utah
00004 //
00005 //  This library is free software; you can redistribute it and/or
00006 //  modify it under the terms of the GNU Lesser General Public
00007 //  License as published by the Free Software Foundation; either
00008 //  version 2.1 of the License, or (at your option) any later version.
00009 //
00010 //  This library is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 //  Lesser General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU Lesser General Public
00016 //  License along with this library; if not, write to the Free Software
00017 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 #ifndef GLIFT_NRRD_H
00020 #define GLIFT_NRRD_H
00021 
00022 #ifdef GLIFT_NRRD
00023 
00024 #include <GL/glew.h>
00025 #include <nrrd.h>
00026 #include <arrayGutz.h>
00027 #include <mathGutz.h>
00028 
00029 namespace glift {
00030 
00031 //////////////////////////////////////////////////////////////////////////
00032 ///
00033 ///@name nrrd2GL 
00034 /// Ensemble of functions that convert nrrd enums to OpenGL enums
00035 ///@{
00036 ///////////////////////////////////////////////////////////////////////
00037 
00038 
00039    // File format enumeration
00040 enum GliftFormat { 
00041    GliftFormatUnknown   = -1,
00042    GliftFormatPGM               = 0,
00043    GliftFormatPPM               = 1,
00044    GliftFormatLast              = 2 
00045 };
00046 
00047 /// Error macro for nrrdExpression
00048 /// - Prevents 'nrrdExpr' from being evaluated if an error has occured
00049 ///   Also sets 'e' to the error state if the current expr produces an error.
00050 /// - 'e' is an 'int'
00051 /// - 'nrrdExpr' is any valid nrrd function call
00052 #define nerr( nrrdExpr, e ) if( !e ) {e |= nrrdExpr;}
00053 
00054 /// Conversion between OpenGL and Nrrd types
00055 GLenum typeN2GL( int nrrdType ); /// Convert a nrrdType to an OpenGL type
00056 GLenum typeGL2N( GLenum glType); /// Convert an OpenGL type to a nrrdType
00057 
00058 // Return GliftFormatPGM, GliftFormatPPM, or GliftFormatUnknown
00059 GliftFormat gliftNrrdTypePNM( Nrrd* nIn );
00060 
00061 // Read just the Nrrd header of 'fileName'
00062 int gliftNrrdLoadHeader( Nrrd* nIn, const char* fileName );
00063 
00064 // Flip the y-axis for data in 'data'
00065 void gliftNrrdFlipYub( gutz::arrayo2ub& data );
00066 
00067 // Tile 3D scalar data only in X and Y
00068 // Result is written to "tiledData"
00069 void gliftNrrdTileDataXYub( const gutz::arrayw3ub& srcData3, const gutz::vec2i& tileSize, 
00070                            gutz::arrayo5ub& tiledData );
00071 
00072 // Untile XY-tiled (5D), 3D data into a standard 3D scalar format
00073 // - Opposite of "gliftNrrdTileDataXYub"
00074 void gliftNrrdUntileXYub( const gutz::arrayw5ub& tiledData, gutz::arrayo3ub& untiledData );
00075 
00076 // Downsample 'scalarVol' to 'resampledVol' with a box filter
00077 //              unu resample -k box -s x(rescale.x) x(rescale.y) x(rescale.z)
00078 //              - Set 'rescale' to 1.0 if you do NOT want the axis resampled. 
00079 //                Otherwise set to scaleFactor for that axis
00080 void gliftNrrdResampleVolBoxf( const gutz::vec3d& rescale, const gutz::arrayw3f& scalarVol, 
00081                               gutz::arrayo3f& resampledVol);
00082 
00083 // Downsample 'scalarVol' to 'resampledVol' with a box filter
00084 //              unu resample -k box -s x(rescale.x) x(rescale.y) x(rescale.z)
00085 //              - Set 'rescale' to 1.0 if you do NOT want the axis resampled. 
00086 //                Otherwise set to scaleFactor for that axis
00087 void gliftNrrdResampleVolBoxub( const gutz::vec3d& rescale, const gutz::arrayw3ub& scalarVol, 
00088                                gutz::arrayo3ub& resampledVol);
00089 
00090 
00091 ///@}
00092 
00093 } /// End of namespace glift
00094 
00095 #endif
00096 
00097 #endif 
00098 

Send questions, comments, and bug reports to:
jmk