volume_pixel_dataset.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------
00012 //---------------------------------------------------
00013 
00014 #include "volume_pixel_dataset.h"
00015 
00016 
00017 
00018 #include <limits>
00019 
00020 namespace imedgine 
00021 {
00022   //---------------------------------------------------
00023   
00024   VolumePixelDataset::VolumePixelDataset(
00025       dataset_type type, dataset_key_type dataset_key, unsigned char num_bytes_per_pixel)
00026   : PixelDataset(type, dataset_key, 3, num_bytes_per_pixel),
00027     transform_(transform_type::New()),
00028     xy_slice_rois_(0),
00029     xz_slice_rois_(0),
00030     yz_slice_rois_(0)
00031   {
00032   }
00033   
00034   //---------------------------------------------------
00035   
00036   VolumePixelDataset::VolumePixelDataset(VolumePixelDataset const& src) 
00037   : PixelDataset(src),
00038     transform_(transform_type::New())
00039   {
00040   }
00041   
00042   //---------------------------------------------------
00043   
00044   VolumePixelDataset::~VolumePixelDataset()
00045   {
00046   }
00047   
00048   //--------------------------------------------------
00049   
00050   void VolumePixelDataset::setTransformationMatrix(matrix_type const& matrix)
00051   {    
00052     PixelDataset::setTransformationMatrix(matrix);
00053     
00054     transform_type::MatrixType new_matrix;
00055 
00056     for (unsigned char row_index = 0; row_index < 3; ++row_index)
00057     {
00058       for (unsigned char col_index = 0; col_index < 3; ++col_index)
00059       {
00060         new_matrix[row_index][col_index] = matrix(row_index, col_index);
00061       }
00062     }
00063     transform_->SetMatrix(new_matrix);
00064   }
00065   
00066   //--------------------------------------------------
00067   
00068   void VolumePixelDataset::setOffsetVector(offset_vector_type const& offset)
00069   {
00070     PixelDataset::setOffsetVector(offset);
00071     
00072     try
00073     {
00074       transform_type::OffsetType new_offset;
00075       
00076       for (unsigned char dim_index = 0; dim_index < 3; ++dim_index)
00077       {
00078        new_offset[dim_index] = offset.at(dim_index); 
00079       }
00080       transform_->SetOffset(new_offset);
00081     }
00082     catch (std::out_of_range const&)
00083     {} 
00084   }
00085   
00086   //--------------------------------------------------
00087     
00088   void VolumePixelDataset::setRegionsOfInterestForSliceXY(
00089       index_type z_index, std::vector<region_of_interest_type> const& regions_of_interest)
00090       throw(IndexOutOfBoundsException)
00091   {
00092     if (z_index >= dataset_size_[Z_DIMENSION])
00093     {
00094       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00095     }
00096     
00097     xy_slice_rois_[z_index] = regions_of_interest;
00098   }
00099     
00100   //--------------------------------------------------
00101 
00102   void VolumePixelDataset::setRegionsOfInterestForSliceXZ(
00103       index_type y_index, std::vector<region_of_interest_type> const& regions_of_interest)
00104       throw(IndexOutOfBoundsException)
00105   {
00106     if (y_index >= dataset_size_[Y_DIMENSION])
00107     {
00108       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00109     }
00110     
00111     xz_slice_rois_[y_index] = regions_of_interest;
00112   }
00113     
00114   //--------------------------------------------------
00115     
00116   void VolumePixelDataset::setRegionsOfInterestForSliceYZ(
00117       index_type x_index, std::vector<region_of_interest_type> const& regions_of_interest)
00118       throw(IndexOutOfBoundsException)
00119   {
00120     if (x_index >= dataset_size_[X_DIMENSION])
00121     {
00122       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00123     }
00124     
00125     yz_slice_rois_[x_index] = regions_of_interest;
00126   }
00127   
00128   //--------------------------------------------------
00129     
00130   std::vector<region_of_interest_type> const&
00131       VolumePixelDataset::getRegionsOfInterestForSliceXY(
00132       index_type z_index) const
00133       throw(IndexOutOfBoundsException)
00134   {
00135     if (z_index >= dataset_size_[Z_DIMENSION])
00136     {
00137       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00138     }
00139     
00140     return(xy_slice_rois_[z_index]);
00141   }
00142     
00143   //--------------------------------------------------
00144     
00145   std::vector<region_of_interest_type> const&
00146       VolumePixelDataset::getRegionsOfInterestForSliceXZ(
00147       index_type y_index) const
00148       throw(IndexOutOfBoundsException)
00149   {
00150     if (y_index >= dataset_size_[Y_DIMENSION])
00151     {
00152       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00153     }
00154     
00155     return(xz_slice_rois_[y_index]);
00156   }
00157     
00158   //--------------------------------------------------
00159 
00160   std::vector<region_of_interest_type> const&
00161       VolumePixelDataset::getRegionsOfInterestForSliceYZ(
00162       index_type x_index) const
00163       throw(IndexOutOfBoundsException)
00164   {
00165     if (x_index >= dataset_size_[X_DIMENSION])
00166     {
00167       throw(IndexOutOfBoundsException("VolumePixelDataset::setRegionsOfInterestForSliceXY"));
00168     }
00169     
00170     return(yz_slice_rois_[x_index]);
00171   }
00172     
00173 } // namespace imedgine

Generated on Sun Aug 13 18:19:39 2006 for iMEDgine by  doxygen 1.4.6