#include <vtkExtractVOI.h>
#include <vtkSphereSource.h>
#include <vtkCutter.h>
-#include <vtkPlane.h>
#include <vtkAssignAttribute.h>
+#include <vtkImageAccumulate.h>
vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
vtkStandardNewMacro(vvSlicer);
+//------------------------------------------------------------------------------
vvSlicer::vvSlicer()
{
mImage = NULL;
mCurrentTSlice = 0;
+ mUseReducedExtent = false;
mCurrent[0] = -VTK_DOUBLE_MAX;
mCurrent[1] = -VTK_DOUBLE_MAX;
text += "F5 = horizontal flip; F6 = vertical flip\n\n";
text += "0,1,2,3,4,5 : preset windowing\n";
text += "6,7,8,9 : preset colormap\n";
+ text += "z : local windowing\n";
text += "r : reset view\n";
text += "l : reload image\n";
text += "f : fly to mouse position\n";
this->WindowLevel = vvImageMapToWLColors::New();
this->InstallPipeline();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper() {
return mOverlayMapper.GetPointer();
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
vtkImageActor* vvSlicer::GetOverlayActor() {
return mOverlayActor.GetPointer();
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper() {
return mFusionMapper.GetPointer();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
vtkImageActor* vvSlicer::GetFusionActor() {
return mFusionActor.GetPointer();
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
vtkActor* vvSlicer::GetVFActor() {
return mVFActor.GetPointer();
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
vtkCornerAnnotation* vvSlicer::GetAnnotation() {
return ca.GetPointer();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvSlicer::EnableReducedExtent(bool b) {
+ mUseReducedExtent = b;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvSlicer::SetReducedExtent(int * ext) {
+ mReducedExtent = ext;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
{
SetContourSlice();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::ToggleContourSuperposition()
{
for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
i!=mSurfaceCutActors.end();i++)
(*i)->ToggleSuperposition();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetCursorColor(int r,int g, int b)
{
pdmA->GetProperty()->SetColor(r,g,b);
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
void vvSlicer::SetCursorVisibility(bool s)
{
pdmA->SetVisibility(s);
}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
bool vvSlicer::GetCursorVisibility()
{
return pdmA->GetVisibility();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
vvSlicer::~vvSlicer()
{
for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
i!=mSurfaceCutActors.end();i++)
delete (*i);
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
{
mCurrent[0] = x;
mCurrent[2] = z;
mCurrentTSlice = t;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetImage(vvImage::Pointer image)
{
if (image->GetVTKImages().size())
ca->SetText(0,mFileName.c_str());
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetOverlay(vvImage::Pointer overlay)
{
if (overlay->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetFusion(vvImage::Pointer fusion)
{
if (fusion->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
{
if (actor_type == "vector")
this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
UpdateDisplayExtent();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVF(vvImage::Pointer vf)
{
if (vf->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
{
mLandmarks = landmarks;
this->GetRenderer()->AddActor(mLandActor);
}
}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//FIXME: this function leaks memory, we should fix it someday :)
void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
{
mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFSubSampling(int sub)
{
if (mVOIFilter)
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFScale(int scale)
{
mScale = scale;
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFLog(int log)
{
mVFLog = log;
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetTSlice(int t)
{
if (t < 0)
(*i)->SetTimeSlice(mCurrentTSlice);
UpdateDisplayExtent();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
int vvSlicer::GetTSlice()
{
return mCurrentTSlice;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetSliceOrientation(int orientation)
{
//if 2D image, force to watch in Axial View
return;
}
input->UpdateInformation();
- int *w_ext = input->GetWholeExtent();
+ int *w_ext;// = input->GetWholeExtent();
+
+ if (mUseReducedExtent) {
+ w_ext = mReducedExtent;
+ }
+ else w_ext = input->GetWholeExtent();
switch (this->SliceOrientation)
{
}
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6])
{
vtkImageData* image=this->GetInput();
ClipDisplayedExtent(vfExtent,mVOIFilter->GetInput()->GetWholeExtent());
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6])
{
vtkImageData* image=this->GetInput();
mOverlay->GetSpacing()[2];
ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int fusExtent[6])
{
vtkImageData* image=this->GetInput();
mFusion->GetSpacing()[2];
ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
{
bool out = false;
extent[i+1] = refExtent[i];
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::UpdateOrientation()
{
// Set the camera position
}
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetOpacity(double s)
{
this->GetImageActor()->SetOpacity(s);
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
{
this->Superclass::SetRenderWindow(rw);
SetSliceOrientation(2-(orientation%3));
ResetCamera();
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ResetCamera()
{
if (this->GetInput())
this->GetRenderer()->GetActiveCamera()->SetParallelScale(bmax/2);
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetDisplayMode(bool i)
{
this->GetImageActor()->SetVisibility(i);
}
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+// Returns the min an the max value in a 41x41 region around the mouse pointer
+void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
+{
+ double fLocalExtents[6];
+ int iLocalExtents[6];
+ for(int i=0; i<3; i++)
+ {
+ //Define corners of an area on the screen
+ if(SliceOrientation != i)
+ {
+ fLocalExtents[i*2 ] = mCurrent[i]-20;
+ fLocalExtents[i*2+1] = mCurrent[i]+20;
+ }
+ else
+ {
+ fLocalExtents[i*2 ] = mCurrent[i];
+ fLocalExtents[i*2+1] = mCurrent[i];
+ }
+
+ //Convert to image pixel coordinates
+ fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
+ fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
+
+ //Round
+ iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
+ iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
+ }
+
+ ClipDisplayedExtent(iLocalExtents, this->GetInput()->GetExtent());
+
+ vtkSmartPointer<vtkExtractVOI> voiFilter = vtkExtractVOI::New();
+ voiFilter->SetInput(this->GetInput());
+ voiFilter->SetVOI(iLocalExtents);
+
+ vtkSmartPointer<vtkImageAccumulate> accFilter = vtkImageAccumulate::New();
+ accFilter->SetInput(voiFilter->GetOutput());
+ accFilter->Update();
+
+ min = *(accFilter->GetMin());
+ max = *(accFilter->GetMax());
+}
+//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicer::Render()
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();
+ 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());
}
}
//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
void vvSlicer::UpdateLandmarks()
{