critical_point.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef __mia_3d_criticalpoint_h
22 #define __mia_3d_criticalpoint_h
23 
24 #include <list>
25 
26 #include <mia/3d/matrix.hh>
27 
29 
45 public:
46 
48  typedef std::vector< C3DCriticalPoint > List;
49 
56 
64  C3DCriticalPoint(const C3DFVector& x0_);
72  C3DCriticalPoint(float x,float y, float z);
73 
79 
85 
87  const C3DFVector get_point()const;
88 
90  const C3DFMatrix get_a()const;
91 
93  float get_gamma()const;
94 
97 
99  C3DFMatrix& get_a();
100 
105  void set_gamma(float gamma_);
106 
112  C3DFVector at(const C3DFVector& x) const;
113 
114  C3DFVector at_alt(const C3DFVector& x) const;
115 
119  bool operator ==(const C3DCriticalPoint& cp) const;
120 #ifdef UGLY_HACK
121  bool operator < (const C3DCriticalPoint& cp) const;
122 #endif
123 
124 
125 private:
126  float gamma;
127  C3DFVector x0;
128  C3DFMatrix A;
129 };
130 
133 
134 
135 typedef std::complex<float> fcomplex;
137 
147  C3DFVector location;
148 
149 
151  C3DFMatrix portrait;
152 
154  float eval1;
156  float eval2;
158  float eval3;
159 
161  C3DFVector evec1;
162 
164  C3DFVector evec2;
165 
167  C3DFVector evec3;
168 
169 public:
171  enum EVType {ev_zero,
181 
186  C3DCriticalPointEigen(const C3DFVector& l, const C3DFMatrix& m);
187 
199  C3DCriticalPointEigen(const C3DFVector& location_,
200  const C3DFMatrix& portrait_,
201  float eval1,float eval2,float eval3,
202  const C3DFVector& evec1,const C3DFVector& evec2, const C3DFVector& evec3,
203  EVType type);
204 
205 
207  EVType get_type()const;
208 
210  float get_eval1()const;
214  float get_eval2()const;
218  float get_eval3()const;
219 
223  float get_real_eval2()const;
227  float get_real_eval3()const;
228 
232  fcomplex get_complex_eval2()const;
233 
238 
241  const C3DFMatrix get_portrait()const;
242 
245  const C3DFVector get_location()const;
246 
249  const C3DFVector get_evect1()const;
250 
254  const C3DFVector get_evect2()const;
258  const C3DFVector get_evect3()const;
259 
260 
261  const C3DFVector get_real_evect2()const;
262  const C3DFVector get_real_evect3()const;
263  const C3DCVector get_complex_evect2()const;
264  const C3DCVector get_complex_evect3()const;
265 
266 
267 private:
268  EVType type;
269  bool estimate();
270 };
271 
272 typedef std::vector< C3DCriticalPointEigen > C3DCriticalPointEigenList;
273 
275 {
276  return type;
277 }
279 {
280  return eval1;
281 }
283 {
284  return eval2;
285 }
287 {
288  return eval3;
289 }
290 
292 {
293  assert(type != ev_complex);
294  return eval2;
295 }
297 {
298  assert(type != ev_complex);
299  return eval3;
300 }
302 {
303  assert(type == ev_complex);
304  return fcomplex(eval2,eval3);
305 }
307 {
308  assert(type == ev_complex);
309  return fcomplex(eval2,-eval3);
310 }
311 
313 {
314  return evec1;
315 }
317 {
318  return evec2;
319 }
321 {
322  return evec3;
323 }
325 {
326  assert(type != ev_complex);
327  return evec2;
328 }
330 {
331  assert(type != ev_complex);
332  return evec3;
333 }
335 {
336  assert(type == ev_complex);
337  return C3DCVector(fcomplex(evec2.x,evec3.x),
338  fcomplex(evec2.y,evec3.y),
339  fcomplex(evec2.z,evec3.z));
340 }
342 {
343  assert(type == ev_complex);
344  return C3DCVector(fcomplex(evec2.x,-evec3.x),
345  fcomplex(evec2.y,-evec3.y),
346  fcomplex(evec2.z,-evec3.z));
347 }
348 
350 {
351  return location;
352 }
353 
354 
356 {
357  return portrait;
358 }
359 
360 
361 //template implementation
362 
363 
365 {
366  return x0;
367 }
368 
370 {
371  return A;
372 }
373 
375 {
376  return x0;
377 }
378 
380 {
381  return A;
382 }
383 
384 inline float C3DCriticalPoint::get_gamma()const
385 {
386  return gamma;
387 }
388 
389 inline void C3DCriticalPoint::set_gamma(float _gamma)
390 {
391  gamma = _gamma;
392 }
393 
394 
396 {
397  return gamma==cp.gamma && A == cp.A && x0 == cp.x0;
398 }
399 
400 #ifdef UGLY_HACK
402 {
403  // we shouldn't need this ...
404  return x0 < cp.x0;
405 }
406 #endif
407 
408 #endif
409