Skip to content

Commit

Permalink
BUG: Remove phase correction hack in a method that was the cause of #…
Browse files Browse the repository at this point in the history
…3010.

The phaseNumber parameter was only used from a method that was never
called and has been entirely removed.
  • Loading branch information
Woundorf committed Jul 27, 2022
1 parent 80ae902 commit 08ba0db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
33 changes: 1 addition & 32 deletions starviewer/src/core/volumepixeldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ VolumePixelDataIterator VolumePixelData::getIterator()
return VolumePixelDataIterator(this);
}

bool VolumePixelData::computeCoordinateIndex(const double coordinate[3], int index[3], int phaseNumber)
bool VolumePixelData::computeCoordinateIndex(const double coordinate[3], int index[3])
{
if (!this->getVtkData())
{
Expand All @@ -163,15 +163,6 @@ bool VolumePixelData::computeCoordinateIndex(const double coordinate[3], int ind
index[i] = qRound((coordinate[i] - origin[i]) / spacing[i]);
}

// Apply phase correction (Safety check, phaseNumber and numberOfPhases must be coherent to apply it)
if (MathTools::isInsideRange(phaseNumber, 0, m_numberOfPhases - 1))
{
// HACK Aquest càlcul és necessari per pal·liar la manca de coneixement de la fase
// TODO Cal resoldre això d'una forma més elegant, el qual comporta un redisseny del tractament de fases i volums
// Calculem l'índex correcte en cas que tinguem fases
index[2] = index[2] * m_numberOfPhases + phaseNumber;
}

int *extent = this->getVtkData()->GetExtent();
bool inside = index[0] >= extent[0] && index[0] <= extent[1] &&
index[1] >= extent[2] && index[1] <= extent[3] &&
Expand All @@ -180,28 +171,6 @@ bool VolumePixelData::computeCoordinateIndex(const double coordinate[3], int ind
return inside;
}

Voxel VolumePixelData::getVoxelValue(double coordinate[3], int phaseNumber)
{
if (!this->getVtkData())
{
DEBUG_LOG("Dades VTK nul·les!");

return Voxel();
}

int voxelIndex[3];
bool inside = this->computeCoordinateIndex(coordinate, voxelIndex, phaseNumber);

if (inside)
{
return getVoxelValue(voxelIndex);
}
else
{
return Voxel();
}
}

Voxel VolumePixelData::getVoxelValue(int index[3])
{
int extent[6];
Expand Down
9 changes: 1 addition & 8 deletions starviewer/src/core/volumepixeldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ class VolumePixelData {
/// Si la coordenada està dins del volum retorna true, false altrament.
/// TODO S'espera que la coordenada sigui dins del món VTK!
/// Caldria determinar si ha de ser així o hauria de ser DICOM o en un altre sistema.
/// HACK El paràmetre phaseNumber és necessari per poder calcular l'índex correcte dins del volum corresponent a la fase actual
bool computeCoordinateIndex(const double coordinate[3], int index[3], int phaseNumber = 0);

/// Donada una coordenada de món, ens dóna el valor del vòxel corresponent.
/// TODO S'espera que la coordenada sigui dins del món VTK!
/// Caldria determinar si ha de ser així o hauria de ser DICOM o en un altre sistema.
/// HACK El paràmetre phaseNumber és necessari per poder calcular l'índex correcte dins del volum corresponent a la fase actual
Voxel getVoxelValue(double coordinate[3], int phaseNumber = 0);
bool computeCoordinateIndex(const double coordinate[3], int index[3]);

/// Returns the voxel corresponding to the given index. If index is out of range, a default constructed value will be returned.
Voxel getVoxelValue(int index[3]);
Expand Down

0 comments on commit 08ba0db

Please sign in to comment.