STIR 6.4.0
Utah.h
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2000- 2007, Hammersmith Imanet Ltd
5 This file is part of STIR.
6
7 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
8
9 See STIR/LICENSE.txt for details
10*/
11#ifndef __stir_phantoms_Utah_H__
12#define __stir_phantoms_Utah_H__
23
26
27START_NAMESPACE_STIR
28
43{
44public:
50 inline Utah_phantom();
51
52 inline const shared_ptr<Shape3D>& get_A_ptr() const { return A_ptr; }
53
54 inline const shared_ptr<Shape3D>& get_B_ptr() const { return B_ptr; }
55
57 inline const shared_ptr<Shape3D>& get_full_B_ptr() const { return full_B_ptr; }
58
59 inline const shared_ptr<Shape3D>& get_C_ptr() const { return C_ptr; }
60
62 inline const shared_ptr<Shape3D>& get_full_C_ptr() const { return full_C_ptr; }
63
64 inline const shared_ptr<Shape3D>& get_D_ptr() const { return D_ptr; }
65
66 inline const shared_ptr<Shape3D>& get_E_ptr() const { return E_ptr; }
67
74 inline shared_ptr<Shape3D> make_inside_B_ptr(const float fraction) const;
75
82 inline shared_ptr<Shape3D> make_inside_C_ptr(const float fraction) const;
83
84 inline void translate(const CartesianCoordinate3D<float>& direction);
85 inline void scale(const CartesianCoordinate3D<float>& scale3D);
86
87private:
88 shared_ptr<Shape3D> A_ptr;
89 shared_ptr<Shape3D> B_ptr;
90 shared_ptr<Shape3D> full_B_ptr;
91 shared_ptr<Shape3D> C_ptr;
92 shared_ptr<Shape3D> full_C_ptr;
93 shared_ptr<Shape3D> D_ptr;
94 shared_ptr<Shape3D> E_ptr;
95};
96
98{
99 // EllipsoidalCylinder (Lcyl,Rcyl_a,Rcyl_b,
100 // CartesianCoordinate3D<float>(zc,yc,xc),
101 // alpha,beta,gamma)
102
103 A_ptr = new EllipsoidalCylinder(100, 100, 100, CartesianCoordinate3D<float>(-50, 0, 0));
104 full_B_ptr = new EllipsoidalCylinder(150, 80, 80, CartesianCoordinate3D<float>(75, 0, 0));
105 full_C_ptr = new EllipsoidalCylinder(150, 100, 100, CartesianCoordinate3D<float>(75, 0, 0));
106 D_ptr = new EllipsoidalCylinder(105, 22.5, 22.5, CartesianCoordinate3D<float>(52.5, 0, -47.5));
107 E_ptr = new EllipsoidalCylinder(55, 22.5, 22.5, CartesianCoordinate3D<float>(27.5, 0, 47.5));
108
109 // CombinedShape3D< logical_and_not<bool> > C( &FullC,&FullB);
110 C_ptr = new CombinedShape3D<logical_and_not<bool>>(full_C_ptr, full_B_ptr);
111 shared_ptr<Shape3D> full_B_notD_ptr = new CombinedShape3D<logical_and_not<bool>>(full_B_ptr, D_ptr);
112 B_ptr = new CombinedShape3D<logical_and_not<bool>>(full_B_notD_ptr, E_ptr);
113}
114
115shared_ptr<Shape3D>
116Utah_phantom::make_inside_B_ptr(const float fraction) const
117{
118 // first get a new copy of full_B
119 shared_ptr<Shape3D> small_full_B_ptr = get_full_B_ptr()->clone();
120 // make it smaller
121 small_full_B_ptr->scale_around_origin(CartesianCoordinate3D<float>(1.F, fraction, fraction));
122
123 // the same for D
124 shared_ptr<Shape3D> large_D_ptr = get_D_ptr()->clone();
125 large_D_ptr->scale_around_origin(CartesianCoordinate3D<float>(1.F, 1 / fraction, 1 / fraction));
126 // and E
127 shared_ptr<Shape3D> large_E_ptr = get_E_ptr()->clone();
128 large_E_ptr->scale_around_origin(CartesianCoordinate3D<float>(1.F, 1 / fraction, 1 / fraction));
129
130 // combine the whole thing
131 shared_ptr<Shape3D> small_full_B_notD_ptr = new CombinedShape3D<logical_and_not<bool>>(small_full_B_ptr, large_D_ptr);
132 return new CombinedShape3D<logical_and_not<bool>>(small_full_B_notD_ptr, large_E_ptr);
133}
134
135shared_ptr<Shape3D>
136Utah_phantom::make_inside_C_ptr(const float fraction) const
137{
138 shared_ptr<Shape3D> small_full_C_ptr = get_full_C_ptr()->clone();
139 small_full_C_ptr->scale_around_origin(CartesianCoordinate3D<float>(1.F, fraction, fraction));
140 shared_ptr<Shape3D> large_full_B_ptr = get_full_B_ptr()->clone();
141 large_full_B_ptr->scale_around_origin(CartesianCoordinate3D<float>(1.F, 1 / fraction, 1 / fraction));
142 return new CombinedShape3D<logical_and_not<bool>>(small_full_C_ptr, large_full_B_ptr);
143}
144void
145Utah_phantom::translate(const CartesianCoordinate3D<float>& direction)
146{
147 A_ptr->translate(direction);
148 B_ptr->translate(direction);
149 full_B_ptr->translate(direction);
150 C_ptr->translate(direction);
151 full_C_ptr->translate(direction);
152 D_ptr->translate(direction);
153 E_ptr->translate(direction);
154}
155
156void
157Utah_phantom::scale(const CartesianCoordinate3D<float>& scale3D)
158{
159 A_ptr->scale(scale3D);
160 B_ptr->scale(scale3D);
161 full_B_ptr->scale(scale3D);
162 C_ptr->scale(scale3D);
163 full_C_ptr->scale(scale3D);
164 D_ptr->scale(scale3D);
165 E_ptr->scale(scale3D);
166}
167
168END_NAMESPACE_STIR
169
170#endif
Declaration of class stir::CombinedShape3D.
Declaration of class stir::EllipsoidalCylinder.
a templated class for 3-dimensional coordinates.
Definition CartesianCoordinate3D.h:53
A class that allows combining several shapes using logical operations.
Definition CombinedShape3D.h:49
void translate(const CartesianCoordinate3D< float > &direction)
translate the whole shape by shifting its origin
Definition CombinedShape3D.inl:52
Three-dimensional ellipsoidal cylinder.
Definition EllipsoidalCylinder.h:68
shared_ptr< Shape3D > make_inside_B_ptr(const float fraction) const
make a region inside B when fraction<1.
Definition Utah.h:116
shared_ptr< Shape3D > make_inside_C_ptr(const float fraction) const
make a region inside C when fraction<1.
Definition Utah.h:136
const shared_ptr< Shape3D > & get_full_B_ptr() const
get B without holes
Definition Utah.h:57
const shared_ptr< Shape3D > & get_full_C_ptr() const
get C without hole
Definition Utah.h:62
Utah_phantom()
Construct a Utah phantom.
Definition Utah.h:97