Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkParticleGrid.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _PARTICLEGRID
18 #define _PARTICLEGRID
19 
20 // MITK
21 #include <MitkFiberTrackingExports.h>
22 #include <mitkParticle.h>
23 
24 // ITK
25 #include <itkImage.h>
26 
27 namespace mitk
28 {
29 
33 class MITKFIBERTRACKING_EXPORT ParticleGrid
34 {
35 
36 public:
37 
38  typedef itk::Image< float, 3 > ItkFloatImageType;
39 
40  int m_NumParticles; // number of particles
41  int m_NumConnections; // number of connections
42  int m_NumCellOverflows; // number of cell overflows
44 
45  ParticleGrid(ItkFloatImageType* image, float particleLength, int cellCapacity);
46  ~ParticleGrid();
47 
48  Particle* GetParticle(int ID);
49 
50  Particle* NewParticle(vnl_vector_fixed<float, 3> R);
51  bool TryUpdateGrid(int k);
52  void RemoveParticle(int k);
53 
54  void ComputeNeighbors(vnl_vector_fixed<float, 3> &R);
55  Particle* GetNextNeighbor();
56 
57  void CreateConnection(Particle *P1,int ep1, Particle *P2, int ep2);
58  void DestroyConnection(Particle *P1,int ep1, Particle *P2, int ep2);
59  void DestroyConnection(Particle *P1,int ep1);
60 
61  bool CheckConsistency();
62  void ResetGrid();
63 
64 protected:
65 
66  bool ReallocateGrid();
67 
68  std::vector< Particle* > m_Grid; // the grid
69  std::vector< Particle > m_Particles; // particle container
70  std::vector< int > m_OccupationCount; // number of particles per grid cell
71 
72  int m_ContainerCapacity; // maximal number of particles
73 
74  vnl_vector_fixed< int, 3 > m_GridSize; // grid dimensions
75  vnl_vector_fixed< float, 3 > m_GridScale; // scaling factor for grid
76 
77  int m_CellCapacity; // particle capacity of single cell in grid
78 
79  struct NeighborTracker // to run over the neighbors
80  {
81  std::vector< int > cellidx;
82  std::vector< int > cellidx_c;
83  int cellcnt;
84  int pcnt;
85  } m_NeighbourTracker;
86 
87 };
88 
89 class MITKFIBERTRACKING_EXPORT Track
90 {
91 public:
92  std::vector< EndPoint > track;
93  float m_Energy;
95  int m_Length;
96 
98  {
99  track.resize(1000);
100  }
101 
102  ~Track(){}
103 
104  void clear()
105  {
106  m_Length = 0;
107  m_Energy = 0;
108  m_Probability = 1;
109  }
110 
111  bool isequal(Track& t)
112  {
113  for (int i = 0; i < m_Length;i++)
114  {
115  if (track[i].p != t.track[i].p || track[i].ep != t.track[i].ep)
116  return false;
117  }
118  return true;
119  }
120 };
121 
122 }
123 
124 #endif
A particle is the basic element of the Gibbs fiber tractography method.
Definition: mitkParticle.h:30
Contains and manages particles.
std::vector< EndPoint > track
std::vector< Particle > m_Particles
bool isequal(Track &t)
DataCollection - Class to facilitate loading/accessing structured data.
vnl_vector_fixed< float, 3 > m_GridScale
std::vector< int > m_OccupationCount
const std::string ID
vnl_vector_fixed< int, 3 > m_GridSize
std::vector< Particle * > m_Grid
itk::Image< float, 3 > ItkFloatImageType