- if (X >= this->GetInput()->GetWholeExtent()[0] &&
- X <= this->GetInput()->GetWholeExtent()[1] &&
- Y >= this->GetInput()->GetWholeExtent()[2] &&
- Y <= this->GetInput()->GetWholeExtent()[3] &&
- Z >= this->GetInput()->GetWholeExtent()[4] &&
- Z <= this->GetInput()->GetWholeExtent()[5])
- {
- std::stringstream pixel1;
- std::stringstream pixel2;
- std::stringstream pixel3;
- std::stringstream temps;
- pixel1 << (int)X;
- pixel2 << (int)Y;
- pixel3 << (int)Z;
- temps << mCurrentTSlice;
- double value = this->GetInput()->GetScalarComponentAsDouble(
- (int)X,
- (int)Y,
- (int)Z,0);
-
- std::stringstream val;
- val << value;
- worldPos += "data value : " + val.str();
- worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " +
- world3.str() + " " + temps.str();
- worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " +
- pixel3.str() + " " + temps.str();
- }
- ca->SetText(1,worldPos.c_str());
+ vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
+#if VTK_MAJOR_VERSION <= 5
+ voiFilter->SetInput(image);
+#else
+ voiFilter->SetInputData(image);
+#endif
+ voiFilter->SetVOI(iLocalExtents);
+ voiFilter->Update();
+ if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
+ min = 0;
+ max = 0;
+ return;
+ }
+
+ vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
+#if VTK_MAJOR_VERSION <= 5
+ accFilter->SetInput(voiFilter->GetOutput());
+#else
+ accFilter->SetInputConnection(voiFilter->GetOutputPort(0));
+#endif
+ accFilter->Update();
+
+ min = *(accFilter->GetMin());
+ max = *(accFilter->GetMax());
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
+{
+ ix = lrint(X);
+ iy = lrint(Y);
+ iz = lrint(Z);
+#if VTK_MAJOR_VERSION <= 5
+ if (ix < image->GetWholeExtent()[0] ||
+ ix > image->GetWholeExtent()[1] ||
+ iy < image->GetWholeExtent()[2] ||
+ iy > image->GetWholeExtent()[3] ||
+ iz < image->GetWholeExtent()[4] ||
+ iz > image->GetWholeExtent()[5] )
+ return std::numeric_limits<double>::quiet_NaN();
+ image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
+ image->Update();
+#else
+ if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
+ ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
+ iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
+ iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
+ iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
+ iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
+ return std::numeric_limits<double>::quiet_NaN();
+ //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
+ //image->Update();
+#endif
+ return image->GetScalarComponentAsDouble(ix, iy, iz, component);
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+void vvSlicer::Render()
+{
+ if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
+ legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
+ legend->UseOpacityOn();
+ legend->SetVisibility(1);
+ }
+ else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
+ legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
+ legend->UseOpacityOff();
+ legend->SetVisibility(1);
+ } else legend->SetVisibility(0);
+
+ if (ca->GetVisibility()) {
+ std::stringstream worldPos(" ");
+ double pt[3];
+ mConcatenatedTransform->TransformPoint(mCurrent, pt);
+ double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
+ double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
+ double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
+#if VTK_MAJOR_VERSION <= 5
+ if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
+ X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
+ Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
+ Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
+ Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
+ Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
+#else
+ if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
+ X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
+ Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
+ Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
+ Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
+ Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
+#endif
+ int ix, iy, iz;
+ double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
+ if(ImageActor->GetVisibility())
+ worldPos << "data value : " << value << std::endl;
+ worldPos << "mm : " << lrint(mCurrent[0]) << ' '
+ << lrint(mCurrent[1]) << ' '
+ << lrint(mCurrent[2]) << ' '
+ << mCurrentTSlice
+ << std::endl;
+ worldPos << "pixel : " << ix << ' '
+ << iy << ' '
+ << iz << ' '
+ << mCurrentTSlice
+ << std::endl;
+