STIR 6.4.0
ProjMatrixByDensel.inl
Go to the documentation of this file.
1//
2//
13/*
14 Copyright (C) 2000- 2002, IRSL
15 See STIR/LICENSE.txt for details
16*/
17
19#include "stir/Succeeded.h"
20
21START_NAMESPACE_STIR
22
23void
25{
26 // set to empty
27 probabilities.erase();
28
29 // find basic densel
30 Densel basic_densel = densel;
31
32 unique_ptr<SymmetryOperation> symm_ptr = get_symmetries_ptr()->find_symmetry_operation_from_basic_densel(basic_densel);
33
34 probabilities.set_densel(basic_densel);
35
36 // check if in cache
37 if (get_cached_proj_matrix_elems_for_one_densel(probabilities) == Succeeded::no)
38
39 {
40 // call 'calculate' just for the basic densel
42#ifndef NDEBUG
43 probabilities.check_state();
44#endif
46 }
47
48 // now transform to original densel
49 symm_ptr->transform_proj_matrix_elems_for_one_densel(probabilities);
50}
51
61ProjMatrixByDensel::CacheKey
62ProjMatrixByDensel::cache_key(const Densel& densel)
63{
64 assert(densel[1] >= 0);
65 assert(densel[1] < (1 << 10));
66 assert(densel[2] >= 0);
67 assert(densel[2] < (1 << 10));
68 assert(densel[3] >= 0);
69 assert(densel[3] < (1 << 10));
70 return (CacheKey)((static_cast<unsigned int>(densel[1]) << 20) | (static_cast<unsigned int>(densel[2]) << 10)
71 | (static_cast<unsigned int>(densel[3])));
72}
73
75void
77{
78 if (cache_disabled)
79 return;
80
81 // insert probabilities into the collection
82 cache_collection.insert(MapProjMatrixElemsForOneDensel::value_type(cache_key(probabilities.get_densel()), probabilities));
83}
84
85END_NAMESPACE_STIR
Declaration of class stir::Succeeded.
Declaration of 2 classes: stir::SymmetryOperation and stir::TrivialSymmetryOperation.
Succeeded get_cached_proj_matrix_elems_for_one_densel(ProjMatrixElemsForOneDensel &) const
The method that tries to get data from the cache.
Definition ProjMatrixByDensel.cxx:31
void cache_proj_matrix_elems_for_one_densel(const ProjMatrixElemsForOneDensel &) const
The method to store data in the cache.
Definition ProjMatrixByDensel.inl:76
virtual const DataSymmetriesForDensels * get_symmetries_ptr() const =0
get a pointer to an object encoding all symmetries that are used by this ProjMatrixByDensel
virtual void calculate_proj_matrix_elems_for_one_densel(ProjMatrixElemsForOneDensel &) const =0
This method needs to be implemented in the derived class.
void get_proj_matrix_elems_for_one_densel(ProjMatrixElemsForOneDensel &, const Densel &) const
The main method for getting a column of the matrix.
Definition ProjMatrixByDensel.inl:24
This stores the non-zero projection matrix elements for every 'voxel'.
Definition ProjMatrixElemsForOneDensel.h:60
void erase()
reset lor to 0 length
Definition ProjMatrixElemsForOneDensel.cxx:50
Succeeded check_state() const
check if each voxel occurs only once
Definition ProjMatrixElemsForOneDensel.cxx:89
void set_densel(const Densel &)
and set the Densel coordinates
Definition ProjMatrixElemsForOneDensel.inl:32
const Densel & get_densel() const
get the Densel coordinates corresponding to this row
Definition ProjMatrixElemsForOneDensel.inl:26
Coordinate3D< int > Densel
a typedef used for an element of a DiscretisedDensity
Definition Densel.h:36