mFileName = filename;
mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
- // DD(mBaseFileName);
mBaseFileNameNumber = number;
for(unsigned int i=0; i<mSlicers.size(); i++) {
SetFilename(filename, n);
// mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
//mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
- // DD(mBaseFileName);
//mBaseFileNameNumber = n;
if (mReader->GetLastError().size() == 0) {
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
mSlicers[i]->SetFileName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
mSlicers[i]->SetImage(mReader->GetOutput());
- // DD(mSlicers[i]->GetFileName());
}
} else {
mLastError = mReader->GetLastError();
return false;
}
// if (n!=0) {
- // // DD(mFileName);
// mFileName.append("_"+clitk::toString(n));
// }
return true;
mReader->Update(type);
mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
- // DD(mBaseFileName);
mBaseFileNameNumber = n;
if (mReader->GetLastError().size() == 0) {
return false;
}
if (n!=0) {
- // DD(mFileName);
mFileName.append("_"+clitk::toString(n));
- // DD(mFileName);
}
return true;
}
return false;
}
if (vf->GetNumberOfDimensions() == 4) {
- // DD(vf->GetSpacing()[3]);
- // DD(mImage->GetSpacing()[3]);
- // DD(vf->GetOrigin()[3]);
- // DD(mImage->GetOrigin()[3]);
if (vf->GetSpacing()[3] != mImage->GetSpacing()[3]) {
mLastError = "Sorry, vector field time spacing cannot be different from time spacing of the reference image.";
return false;
t++;
if (t > mSlicers[0]->GetTMax())
t = 0;
- // DD("SetNextTSlice");
- // DD(originating_slicer);
- // DD(t);
emit UpdateTSlice(originating_slicer,t);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicerManager::UpdateViews(int current,int slicer)
{
- // DD("UpdateViews");
- // DD(current);
- // DD(slicer);
-
double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
/mSlicers[slicer]->GetInput()->GetSpacing()[0];
double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
mSlicers[i]->SetSlice((int)floor(x));
break;
}
- // DD("UpdateViews::");
- // DD(i);
UpdateSlice(i);
UpdateTSlice(i);
}
//----------------------------------------------------------------------------
void vvSlicerManager::Render()
{
- // DD("vvSlicerManager::Render");
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
- // DD(i);
mSlicers[i]->Render();
}
}
//----------------------------------------------------------------------------
void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_index)
{
+ if (actor_type =="overlay") {
+ delete mOverlayReader;
+ mOverlayReader = NULL;
+ }
+
+ if (actor_type =="fusion") {
+ delete mFusionReader;
+ mFusionReader = NULL;
+ }
+
for (unsigned int i = 0; i < mSlicers.size(); i++) {
mSlicers[i]->RemoveActor(actor_type,overlay_index);
}
//----------------------------------------------------------------------------
void vvSlicerManager::RemoveActors()
{
- ///This method leaks a few objects. See RemoveActor for what a correct implementation would look like
+ ///This method leaks a few objects. See RemoveActor for what a
+ ///correct implementation would look like
+ //DS -> probably due to the reader (now released in the
+ //RemoveActor() function. (I hope)
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
mSlicers[i]->SetDisplayMode(0);
mSlicers[i]->GetRenderer()->RemoveActor(mSlicers[i]->GetImageActor());
Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
- value = mSlicers[slicer]->GetInput()->GetScalarComponentAsDouble(
- (int)floor(X),
- (int)floor(Y),
- (int)floor(Z),0);
+ value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
+
if (mSlicers[slicer]->GetVFActor() && mSlicers[slicer]->GetVFActor()->GetVisibility()) {
displayVec = 1;
unsigned int currentTime = mSlicers[slicer]->GetTSlice();
double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0];
double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1];
double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2];
- xVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),0);
- yVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),1);
- zVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),2);
+ xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0);
+ yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1);
+ zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2);
valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);
}
}
Yover <= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[3] &&
Zover >= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[4] &&
Zover <= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[5]) {
- valueOver = static_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput())->
- GetScalarComponentAsDouble(
- (int)floor(Xover),
- (int)floor(Yover),
- (int)floor(Zover),0);
+ valueOver = this->GetScalarComponentAsDouble(static_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput()), Xover, Yover, Zover);
}
}
if (mSlicers[slicer]->GetFusionActor() && mSlicers[slicer]->GetFusionActor()->GetVisibility()) {
Yfus <= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[3] &&
Zfus >= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[4] &&
Zfus <= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[5]) {
- valueFus = static_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput())->
- GetScalarComponentAsDouble(
- (int)floor(Xfus),
- (int)floor(Yfus),
- (int)floor(Zfus),0);
+ valueFus = this->GetScalarComponentAsDouble(static_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput()), Xfus, Yfus, Zfus);
}
}
emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),
//----------------------------------------------------------------------------
void vvSlicerManager::UpdateSlice(int slicer)
{
- // DD("vvSlicerManager::UpdateSlice emit UpdateSlice");
- // DD(slicer);
- // DD(mSlicers[slicer]->GetSlice());
if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
//DD("============= NOTHING");
return;
//----------------------------------------------------------------------------
void vvSlicerManager::UpdateTSlice(int slicer)
{
- // DD("vvSlicerManager::UpdateTSlice emit UpdateTSlice");
- // DD(slicer);
- // DD(mSlicers[slicer]->GetTSlice());
- // DD(mSlicers[slicer]->GetSlice());
if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
if (mPreviousTSlice[slicer] == mSlicers[slicer]->GetTSlice()) {
// DD("************** NOTHING ***********");
level = 0;
break;
case 2:
- window = 350;
- level = 60;
+ window = 400;
+ level = 20;
break;
case 3:
window = 1500;
y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3] &&
z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4] &&
z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]) {
- double value = mSlicers[0]->GetInput()->GetScalarComponentAsDouble(
- (int)x_index,
- (int)y_index,
- (int)z_index,0);
+ double value = this->GetScalarComponentAsDouble(mSlicers[0]->GetInput(), x_index, y_index, z_index);
this->GetLandmarks()->AddLandmark(x,y,z,t,value);
emit LandmarkAdded();
}
}
//----------------------------------------------------------------------------
-
//----------------------------------------------------------------------------
void vvSlicerManager::NextImage(int slicer)
{
}
//----------------------------------------------------------------------------
-
//----------------------------------------------------------------------------
void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice)
{
}
//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+double vvSlicerManager::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component)
+{
+ int ix, iy, iz;
+ return mSlicers[0]->GetScalarComponentAsDouble(image, X, Y, Z, ix, iy, iz, component);
+}
+//----------------------------------------------------------------------------