PointSamples.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_PointSamples_H
21 #define MIRTK_PointSamples_H
22 
23 #include "mirtk/PointSet.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Auxiliary class for generation of point samples
31  */
32 class PointSamples : public PointSet
33 {
34  mirtkObjectMacro(PointSamples);
35 
36  /// Random number generator
37  void *_RandomNumberGenerator;
38 
39 public:
40 
41  // ---------------------------------------------------------------------------
42  // Construction/destruction
43 
44  /// Constructor
45  ///
46  /// \param[in] n Number of point samples.
47  /// \param[in] seed Seed of random number generator. Pass a negative value to
48  /// use the current timestamp as seed value.
49  PointSamples(int n = 0, int seed = 0);
50 
51  /// Destructor
52  virtual ~PointSamples();
53 
54  // ---------------------------------------------------------------------------
55  // Regular grid sampling
56 
57  /// Sample axes-aligned uniform grid
58  void SampleGrid(const Point &p1, const Point &p2,
59  int nx, int ny, int nz);
60 
61  /// Sample axes-aligned uniform grid
62  void SampleGrid(const Point &p1, const Point &p2,
63  double dx, double dy, double dz);
64 
65  /// Sample axes-aligned uniform grid
66  void SampleGrid(double x1, double y1, double z1,
67  double x2, double y2, double z2,
68  int nx, int ny, int nz);
69 
70  /// Sample axes-aligned uniform grid
71  void SampleGrid(double x1, double y1, double z1,
72  double x2, double y2, double z2,
73  double dx, double dy, double dz);
74 
75  // ---------------------------------------------------------------------------
76  // Uniform spherical distribution
77 
78  /// Add uniform spherical point samples
79  void SampleSphere(double r = 1.0);
80 
81  /// Add uniform spherical point samples
82  ///
83  /// \param[in] c Center in each dimension.
84  /// \param[in] r Radius in each dimension.
85  void SampleSphere(double c, double r);
86 
87  /// Add uniform spherical point samples
88  ///
89  /// \param[in] c Center point.
90  /// \param[in] r Radius in each dimension.
91  void SampleSphere(const Point & c, double r = 1.0);
92 
93  /// Add uniform spherical point samples
94  ///
95  /// \param[in] c Center point.
96  /// \param[in] rx Radius in x direction.
97  /// \param[in] ry Radius in x direction.
98  /// \param[in] rz Radius in x direction.
99  void SampleSphere(const Point & c, double rx, double ry, double rz);
100 
101  /// Add uniform spherical point samples
102  ///
103  /// \param[in] cx Center in x direction.
104  /// \param[in] cy Center in y direction.
105  /// \param[in] cz Center in z direction.
106  /// \param[in] r Radius in each dimension.
107  void SampleSphere(double cx, double cy, double cz, double r);
108 
109  /// Add uniform spherical point samples
110  ///
111  /// \param[in] cx Center in x direction.
112  /// \param[in] cy Center in y direction.
113  /// \param[in] cz Center in z direction.
114  /// \param[in] rx Radius in x direction.
115  /// \param[in] ry Radius in x direction.
116  /// \param[in] rz Radius in x direction.
117  void SampleSphere(double cx, double cy, double cz,
118  double rx, double ry, double rz);
119 
120  // ---------------------------------------------------------------------------
121  // Regular spherical samples
122 
123  /// Add regular spherical point samples
124  void SampleRegularSphere(double r = 1.0);
125 
126  /// Add regular spherical point samples
127  ///
128  /// \param[in] c Center in each dimension.
129  /// \param[in] r Radius in each dimension.
130  void SampleRegularSphere(double c, double r);
131 
132  /// Add regular spherical point samples
133  ///
134  /// \param[in] c Center point.
135  /// \param[in] r Radius in each dimension.
136  void SampleRegularSphere(const Point & c, double r = 1.0);
137 
138  /// Add regular spherical point samples
139  ///
140  /// \param[in] c Center point.
141  /// \param[in] rx Radius in x direction.
142  /// \param[in] ry Radius in x direction.
143  /// \param[in] rz Radius in x direction.
144  void SampleRegularSphere(const Point & c, double rx, double ry, double rz);
145 
146  /// Add regular spherical point samples
147  ///
148  /// \param[in] cx Center in x direction.
149  /// \param[in] cy Center in y direction.
150  /// \param[in] cz Center in z direction.
151  /// \param[in] r Radius in each dimension.
152  void SampleRegularSphere(double cx, double cy, double cz, double r);
153 
154  /// Add regular spherical point samples
155  ///
156  /// \param[in] cx Center in x direction.
157  /// \param[in] cy Center in y direction.
158  /// \param[in] cz Center in z direction.
159  /// \param[in] rx Radius in x direction.
160  /// \param[in] ry Radius in x direction.
161  /// \param[in] rz Radius in x direction.
162  void SampleRegularSphere(double cx, double cy, double cz,
163  double rx, double ry, double rz);
164 
165  // ---------------------------------------------------------------------------
166  // Regular spherical sampling of half sphere
167 
168  /// Add regular spherical point samples
169  void SampleRegularHalfSphere(double r = 1.0);
170 
171  /// Add regular spherical point samples
172  ///
173  /// \param[in] c Center in each dimension.
174  /// \param[in] r Radius in each dimension.
175  void SampleRegularHalfSphere(double c, double r);
176 
177  /// Add regular spherical point samples
178  ///
179  /// \param[in] c Center point.
180  /// \param[in] r Radius in each dimension.
181  void SampleRegularHalfSphere(const Point & c, double r = 1.0);
182 
183  /// Add regular spherical point samples
184  ///
185  /// \param[in] c Center point.
186  /// \param[in] rx Radius in x direction.
187  /// \param[in] ry Radius in x direction.
188  /// \param[in] rz Radius in x direction.
189  void SampleRegularHalfSphere(const Point & c, double rx, double ry, double rz);
190 
191  /// Add regular spherical point samples
192  ///
193  /// \param[in] cx Center in x direction.
194  /// \param[in] cy Center in y direction.
195  /// \param[in] cz Center in z direction.
196  /// \param[in] r Radius in each dimension.
197  void SampleRegularHalfSphere(double cx, double cy, double cz, double r);
198 
199  /// Add regular spherical point samples
200  ///
201  /// \param[in] cx Center in x direction.
202  /// \param[in] cy Center in y direction.
203  /// \param[in] cz Center in z direction.
204  /// \param[in] rx Radius in x direction.
205  /// \param[in] ry Radius in x direction.
206  /// \param[in] rz Radius in x direction.
207  void SampleRegularHalfSphere(double cx, double cy, double cz,
208  double rx, double ry, double rz);
209 
210  // ---------------------------------------------------------------------------
211  // Normal distribution
212 
213  /// Add normally distributed point samples
214  ///
215  /// \param[in] s Standard deviation in each dimension.
216  void SampleGaussian(double s = 1.0);
217 
218  /// Add normally distributed point samples
219  ///
220  /// \param[in] m Mean in each dimension.
221  /// \param[in] s Standard deviation in each dimension.
222  void SampleGaussian(double m, double s);
223 
224  /// Add normally distributed point samples
225  ///
226  /// \param[in] mx Mean in x direction.
227  /// \param[in] my Mean in y direction.
228  /// \param[in] mz Mean in z direction.
229  /// \param[in] s Standard deviation in each dimension.
230  void SampleGaussian(double mx, double my, double mz, double s);
231 
232  /// Add normally distributed point samples
233  ///
234  /// \param[in] m Mean of normal distribution.
235  /// \param[in] s Standard deviation in each dimension.
236  void SampleGaussian(const Point & m, double s);
237 
238  /// Add normally distributed point samples
239  ///
240  /// \param[in] m Mean of normal distribution.
241  /// \param[in] sx Standard deviation in x direction.
242  /// \param[in] sy Standard deviation in y direction.
243  /// \param[in] sz Standard deviation in z direction.
244  void SampleGaussian(const Point & m, double sx, double sy, double sz);
245 
246  /// Add normally distributed point samples
247  ///
248  /// \param[in] mx Mean in x direction.
249  /// \param[in] my Mean in y direction.
250  /// \param[in] mz Mean in z direction.
251  /// \param[in] sx Standard deviation in x direction.
252  /// \param[in] sy Standard deviation in y direction.
253  /// \param[in] sz Standard deviation in z direction.
254  void SampleGaussian(double mx, double my, double mz,
255  double sx, double sy, double sz);
256 
257 };
258 
259 
260 } // namespace mirtk
261 
262 #endif // MIRTK_PointSamples_H
void SampleRegularSphere(double r=1.0)
Add regular spherical point samples.
PointSamples(int n=0, int seed=0)
void SampleSphere(double r=1.0)
Add uniform spherical point samples.
void SampleRegularHalfSphere(double r=1.0)
Add regular spherical point samples.
void SampleGaussian(double s=1.0)
virtual ~PointSamples()
Destructor.
Definition: IOConfig.h:41
void SampleGrid(const Point &p1, const Point &p2, int nx, int ny, int nz)
Sample axes-aligned uniform grid.