Voreen - Volume Rendering Engine Voreen - Volume Rendering Engine
Voreen - Volume Rendering Engine Westfälische Wilhelms-Universität Münster
  • About
  • Gallery
  • Download
  • Documentation
  • Publications
  • Community

  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

include/voreen/core/datastructures/volume/volume.h

00001 /**********************************************************************
00002  *                                                                    *
00003  * Voreen - The Volume Rendering Engine                               *
00004  *                                                                    *
00005  * Copyright (C) 2005-2010 The Voreen Team. <http://www.voreen.org>   *
00006  *                                                                    *
00007  * This file is part of the Voreen software package. Voreen is free   *
00008  * software: you can redistribute it and/or modify it under the terms *
00009  * of the GNU General Public License version 2 as published by the    *
00010  * Free Software Foundation.                                          *
00011  *                                                                    *
00012  * Voreen is distributed in the hope that it will be useful,          *
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the       *
00015  * GNU General Public License for more details.                       *
00016  *                                                                    *
00017  * You should have received a copy of the GNU General Public License  *
00018  * in the file "LICENSE.txt" along with this program.                 *
00019  * If not, see <http://www.gnu.org/licenses/>.                        *
00020  *                                                                    *
00021  * The authors reserve all rights not expressly granted herein. For   *
00022  * non-commercial academic use see the license exception specified in *
00023  * the file "LICENSE-academic.txt". To get information about          *
00024  * commercial licensing please contact the authors.                   *
00025  *                                                                    *
00026  **********************************************************************/
00027 
00028 #ifndef VRN_VOLUME_H
00029 #define VRN_VOLUME_H
00030 
00031 // Note: please ensure that no OpenGL dependencies are added to this file
00032 
00033 #include "voreen/core/datastructures/volume/volumemetadata.h"
00034 
00035 namespace voreen {
00036 
00048 class Volume {
00049 public:
00050     enum Filter {
00051         NEAREST,
00052         LINEAR
00053     };
00054 
00062     Volume(const tgt::ivec3& dimensions,
00063            int bitsStored,
00064            const tgt::vec3& spacing = tgt::vec3(1.f));
00065 
00066     virtual ~Volume() {}
00067 
00069     virtual Volume* clone() const throw (std::bad_alloc) = 0;
00070 
00076     virtual Volume* clone(void* data) const throw (std::bad_alloc) = 0;
00077 
00079     virtual tgt::ivec3 getDimensions() const;
00080 
00082     virtual tgt::vec3 getLLF() const;
00083 
00085     virtual tgt::vec3 getURB() const;
00086 
00088     virtual const tgt::vec3* getCubeVertices() const;
00089 
00091     virtual tgt::vec3 getCubeSize() const;
00092 
00094     virtual void setSpacing(const tgt::vec3 spacing);
00095 
00097     virtual tgt::vec3 getSpacing() const;
00098 
00100     virtual size_t getNumVoxels() const;
00101 
00103     virtual size_t getNumBytes() const = 0;
00104 
00106     virtual int getNumChannels() const = 0;
00107 
00109     virtual void setBitsStored(int bits);
00110 
00112     virtual int getBitsStored() const;
00113 
00116     virtual int getBitsAllocated() const = 0;
00117 
00119     virtual int getBytesPerVoxel() const = 0;
00120 
00128     virtual void setTransformation(const tgt::mat4& transformationMatrix);
00129 
00135     virtual const tgt::mat4& getTransformation() const;
00136 
00143     virtual tgt::mat4 getVoxelToWorldMatrix() const;
00144 
00148     VolumeMetaData& meta();
00149 
00153     const VolumeMetaData& meta() const;
00154 
00159     virtual tgt::vec2 elementRange() const = 0;
00160 
00169     virtual float getVoxelFloat(const tgt::ivec3& pos, size_t channel = 0) const = 0;
00170 
00181     virtual float getVoxelFloat(size_t x, size_t y, size_t z, size_t channel = 0) const = 0;
00182 
00191     virtual float getVoxelFloat(size_t index, size_t channel = 0) const = 0;
00192 
00202     virtual void setVoxelFloat(float value, const tgt::ivec3& pos, size_t channel = 0) = 0;
00203 
00215     virtual void setVoxelFloat(float value, size_t x, size_t y, size_t z, size_t channel = 0) = 0;
00216 
00226     virtual void setVoxelFloat(float value, size_t index, size_t channel = 0) = 0;
00227 
00237     virtual float getVoxelFloatLinear(const tgt::vec3& pos, size_t channel = 0) const;
00238 
00240     virtual void clear() = 0;
00241 
00243     virtual void* getData() = 0;
00244 
00245     virtual Volume* createSubset(tgt::ivec3 pos, tgt::ivec3 size) const
00246         throw (std::bad_alloc) = 0;
00247 
00258     virtual void resize(tgt::ivec3 newDims, bool allocMem = true)
00259         throw (std::bad_alloc) = 0;
00260 
00267     virtual Volume* resample(tgt::ivec3 newDims, Filter filter) const
00268         throw (std::bad_alloc) = 0;
00269 
00276     virtual Volume* halfsample() const
00277         throw (std::bad_alloc);
00278 
00285     void convert(const Volume* v);
00286 
00290     template<class T>
00291     inline static typename T::VoxelType* getData(T* v);
00292 
00293     //-------------------------------------------------------------------
00294 protected:
00295     // protected default constructor
00296     Volume() {}
00297     void calculateProperties();
00298 
00299     tgt::ivec3  dimensions_;
00300     size_t      numVoxels_;
00301     int         bitsStored_;
00302     tgt::vec3   spacing_;
00303     tgt::vec3   llf_;
00304     tgt::vec3   urb_;
00305     tgt::vec3   cubeSize_;
00306     tgt::vec3   cubeVertices_[8];
00307 
00308     tgt::mat4 transformationMatrix_;
00309 
00310     VolumeMetaData meta_;
00311 
00312     static const std::string loggerCat_;
00313 };
00314 
00315 
00336 #define VRN_FOR_EACH_VOXEL(INDEX, POS, SIZE) \
00337     for (tgt::ivec3 (INDEX) = (POS); (INDEX).z < (SIZE).z; ++(INDEX).z)\
00338         for ((INDEX).y = (POS).y; (INDEX).y < (SIZE).y; ++(INDEX).y)\
00339             for ((INDEX).x = (POS).x; (INDEX).x < (SIZE).x; ++(INDEX).x)
00340 
00341 } // namespace voreen
00342 
00343 #endif // VRN_VOLUME_H
  • Getting Started
  • Video Tutorials
  • Build Instructions
  • Adding a Module
  • Programming Tutorials
  • API Documentation
  • FAQ
edit