34 m_GridSize[0] = image->GetLargestPossibleRegion().GetSize()[0]*image->GetSpacing()[0]/cellSize +1;
35 m_GridSize[1] = image->GetLargestPossibleRegion().GetSize()[1]*image->GetSpacing()[1]/cellSize +1;
36 m_GridSize[2] = image->GetLargestPossibleRegion().GetSize()[2]*image->GetSpacing()[2]/cellSize +1;
46 throw std::bad_alloc();
49 m_Grid.resize(gridSize,
nullptr);
57 std::cout <<
"ParticleGrid: allocated " << (
sizeof(
Particle)*m_ContainerCapacity +
sizeof(
Particle*)*m_GridSize[0]*m_GridSize[1]*m_GridSize[2])/1048576 <<
"mb for " << m_ContainerCapacity/1000 <<
"k particles." << std::endl;
100 for (
int i = m_ContainerCapacity; i < new_capacity; i++)
103 m_ContainerCapacity = new_capacity;
135 int yint = int(R[1]*m_GridScale[1]);
140 int zint = int(R[2]*m_GridScale[2]);
156 m_OccupationCount[idx]++;
196 m_Grid[grdindex]->gridindex = grdindex;
197 m_OccupationCount[cellidx]--;
202 m_OccupationCount[idx]++;
232 m_Grid[gridIndex]->gridindex = gridIndex;
268 float yfrac = R[1]*m_GridScale[1];
269 float zfrac = R[2]*m_GridScale[2];
270 int xint = int(xfrac);
271 int yint = int(yfrac);
272 int zint = int(zfrac);
275 if (xfrac-xint > 0.5) dx = 1;
276 if (xint <= 0) { xint = 0; dx = 1; }
281 if (yfrac-yint > 0.5) dy = 1;
282 if (yint <= 0) {yint = 0; dy = 1; }
287 if (zfrac-zint > 0.5) dz = 1;
288 if (zint <= 0) {zint = 0; dz = 1; }
381 if (P2->
mID == P1->
ID)
396 std::cout <<
"Particle ID error!" << std::endl;
405 std::cout <<
"Connection inconsistent!" << std::endl;
414 std::cout <<
"Connection inconsistent!" << std::endl;
void CreateConnection(Particle *P1, int ep1, Particle *P2, int ep2)
A particle is the basic element of the Gibbs fiber tractography method.
void ComputeNeighbors(vnl_vector_fixed< float, 3 > &R)
std::vector< Particle > m_Particles
DataCollection - Class to facilitate loading/accessing structured data.
vnl_vector_fixed< float, 3 > m_GridScale
ParticleGrid(ItkFloatImageType *image, float particleLength, int cellCapacity)
std::vector< int > cellidx
vnl_vector_fixed< float, 3 > & GetPos()
Particle * GetParticle(int ID)
std::vector< int > m_OccupationCount
void RemoveParticle(int k)
std::vector< int > cellidx_c
void DestroyConnection(Particle *P1, int ep1, Particle *P2, int ep2)
vnl_vector_fixed< int, 3 > m_GridSize
std::vector< Particle * > m_Grid
Particle * GetNextNeighbor()
Particle * NewParticle(vnl_vector_fixed< float, 3 > R)
bool TryUpdateGrid(int k)
struct mitk::ParticleGrid::NeighborTracker m_NeighbourTracker
itk::Image< float, 3 > ItkFloatImageType