STIR 6.4.0
ProjMatrixElemsForOneBinValue.inl
Go to the documentation of this file.
1//
2//
14/*
15 Copyright (C) 2000 PARAPET partners
16 Copyright (C) 2000- 2009, Hammersmith Imanet Ltd
17 This file is part of STIR.
18
19 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
20
21 See STIR/LICENSE.txt for details
22*/
23
24#include "stir/Coordinate3D.h"
25
26// for SHRT_MAX etc
27#ifndef NDEBUG
28# include <climits>
29#endif
30
31START_NAMESPACE_STIR
32
33ProjMatrixElemsForOneBinValue::ProjMatrixElemsForOneBinValue(const BasicCoordinate<3, int>& coords, const float ivalue)
34 : c3(static_cast<short>(coords[3])),
35 c2(static_cast<short>(coords[2])),
36 c1(static_cast<short>(coords[1])),
37 value(ivalue)
38{
39 assert(coords[3] <= SHRT_MAX);
40 assert(coords[3] >= SHRT_MIN);
41 assert(coords[2] <= SHRT_MAX);
42 assert(coords[2] >= SHRT_MIN);
43 assert(coords[1] <= SHRT_MAX);
44 assert(coords[1] >= SHRT_MIN);
45}
46
47ProjMatrixElemsForOneBinValue::ProjMatrixElemsForOneBinValue()
48 : c3(0),
49 c2(0),
50 c1(0),
51 value(0)
52{}
53
54BasicCoordinate<3, int>
56{
57 return Coordinate3D<int>(c1, c2, c3);
58}
59
60int
62{
63 return static_cast<int>(c1);
64}
65
66int
68{
69 return static_cast<int>(c2);
70}
71
72int
74{
75 return static_cast<int>(c3);
76}
77
78float
80{
81 return value;
82}
83
85ProjMatrixElemsForOneBinValue::operator+=(const ProjMatrixElemsForOneBinValue& el2)
86{
87 assert(get_coords() == el2.get_coords());
88 value += el2.value;
89 return *this;
90}
91
94{
95 value += d;
96 return *this;
97}
98
101{
102 value *= d;
103 return *this;
104}
105
108{
109 value /= d;
110 return *this;
111}
112
113bool
114ProjMatrixElemsForOneBinValue::coordinates_equal(const ProjMatrixElemsForOneBinValue& el1,
115 const ProjMatrixElemsForOneBinValue& el2)
116{
117 return el1.c3 == el2.c3 && el1.c2 == el2.c2 && el1.c1 == el2.c1;
118}
119
120bool
121ProjMatrixElemsForOneBinValue::coordinates_less(const ProjMatrixElemsForOneBinValue& el1,
122 const ProjMatrixElemsForOneBinValue& el2)
123{
124 return el1.c1 < el2.c1 || (el1.c1 == el2.c1 && (el1.c2 < el2.c2 || (el1.c2 == el2.c2 && el1.c3 < el2.c3)));
125}
126
127bool
128operator==(const ProjMatrixElemsForOneBinValue& el1, const ProjMatrixElemsForOneBinValue& el2)
129{
130 return el1.c3 == el2.c3 && el1.c2 == el2.c2 && el1.c1 == el2.c1 && el1.value == el2.value;
131}
132
133bool
134operator<(const ProjMatrixElemsForOneBinValue& el1, const ProjMatrixElemsForOneBinValue& el2)
135{
136 return el1.c1 < el2.c1
137 || (el1.c1 == el2.c1
138 && (el1.c2 < el2.c2 || (el1.c2 == el2.c2 && (el1.c3 < el2.c3 || (el1.c3 == el2.c3 && el1.value < el2.value)))));
139}
140
141END_NAMESPACE_STIR
defines the stir::Coordinate3D<coordT> class
a templated class for 3-dimensional coordinates.
Definition Coordinate3D.h:43
Stores voxel coordinates and the value of the matrix element.
Definition ProjMatrixElemsForOneBinValue.h:47
float get_value() const
Get the value of the matrix element.
Definition ProjMatrixElemsForOneBinValue.inl:79
ProjMatrixElemsForOneBinValue & operator/=(const float d)
Divides the value of with a float.
Definition ProjMatrixElemsForOneBinValue.inl:107
ProjMatrixElemsForOneBinValue & operator*=(const float d)
Multiplies the value of with a float.
Definition ProjMatrixElemsForOneBinValue.inl:100
BasicCoordinate< 3, int > get_coords() const
get the coordinates
Definition ProjMatrixElemsForOneBinValue.inl:55
friend bool operator<(const ProjMatrixElemsForOneBinValue &el1, const ProjMatrixElemsForOneBinValue &el2)
Checks lexicographical order of the coordinates and the value.
Definition ProjMatrixElemsForOneBinValue.inl:134
ProjMatrixElemsForOneBinValue & operator+=(const ProjMatrixElemsForOneBinValue &el2)
Adds el2.get_value() to the value of the current object.
Definition ProjMatrixElemsForOneBinValue.inl:85
static bool coordinates_equal(const ProjMatrixElemsForOneBinValue &el1, const ProjMatrixElemsForOneBinValue &el2)
Checks if the coordinates are equal.
Definition ProjMatrixElemsForOneBinValue.inl:114
int coord3() const
In effect the same as get_coords()[3] (but faster)
Definition ProjMatrixElemsForOneBinValue.inl:73
int coord1() const
In effect the same as get_coords()[1] (but faster)
Definition ProjMatrixElemsForOneBinValue.inl:61
friend bool operator==(const ProjMatrixElemsForOneBinValue &el1, const ProjMatrixElemsForOneBinValue &el2)
Checks coordinates and value are equal.
Definition ProjMatrixElemsForOneBinValue.inl:128
static bool coordinates_less(const ProjMatrixElemsForOneBinValue &el1, const ProjMatrixElemsForOneBinValue &el2)
Checks lexicographical order of the coordinates.
Definition ProjMatrixElemsForOneBinValue.inl:121
int coord2() const
In effect the same as get_coords()[2] (but faster)
Definition ProjMatrixElemsForOneBinValue.inl:67