|
|
|
|
@@ -24,7 +24,7 @@
|
|
|
|
|
#include "ExtendMedicalImageProperties.h"
|
|
|
|
|
#include "util/ColorMapReader.h"
|
|
|
|
|
#include "vtkMath.h"
|
|
|
|
|
|
|
|
|
|
#include "vtkImageStack.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -44,11 +44,16 @@ void infinitiViewer::SetFusionInputData(vtkImageData* data)
|
|
|
|
|
if (!this->GetInput()) return;
|
|
|
|
|
if (!simpleFusionableCheck(data, this->GetInput())) return;
|
|
|
|
|
if (!this->FusionMapper) {
|
|
|
|
|
this->FusionMapper = vtkImageSliceMapper::New();
|
|
|
|
|
auto m = vtkImageSliceMapper::New();
|
|
|
|
|
// m->SetBaseImageMapper(ImageMapper);
|
|
|
|
|
this->FusionMapper = m;
|
|
|
|
|
this->FusionMapper->SliceAtFocalPointOn();
|
|
|
|
|
this->FusionMapper->SliceFacesCameraOn();
|
|
|
|
|
|
|
|
|
|
FusionMapper->SetInputData(data);
|
|
|
|
|
this->FusionActor = vtkImageSlice::New();
|
|
|
|
|
//must set fusion image slice layer to 1 to make main image is active layer of image stack
|
|
|
|
|
FusionActor->GetProperty()->SetLayerNumber(1);
|
|
|
|
|
FusionActor->SetPickable(false);
|
|
|
|
|
FusionActor->SetMapper(FusionMapper);
|
|
|
|
|
}
|
|
|
|
|
@@ -286,7 +291,9 @@ void infinitiViewer::RemoveFusionActor()
|
|
|
|
|
void infinitiViewer::RemoveFusionData()
|
|
|
|
|
{
|
|
|
|
|
if (!FusionMapper) return;
|
|
|
|
|
if (Renderer->HasViewProp(FusionActor)) Renderer->RemoveViewProp(FusionActor);
|
|
|
|
|
if (ImageStack->HasImage(FusionActor)) {
|
|
|
|
|
ImageStack->RemoveImage(FusionActor);
|
|
|
|
|
}
|
|
|
|
|
FusionMapper->Delete();
|
|
|
|
|
FusionMapper = nullptr;
|
|
|
|
|
FusionActor->Delete();
|
|
|
|
|
@@ -303,12 +310,14 @@ infinitiViewer::infinitiViewer()
|
|
|
|
|
{
|
|
|
|
|
this->RenderWindow = nullptr;
|
|
|
|
|
this->Renderer = nullptr;
|
|
|
|
|
this->ImageStack = vtkImageStack::New();
|
|
|
|
|
this->ImageActor = vtkImageSlice::New();
|
|
|
|
|
this->ImageMapper = vtkImageSliceMapper::New();
|
|
|
|
|
this->ImageMapper->SliceAtFocalPointOn();
|
|
|
|
|
this->ImageMapper->SliceFacesCameraOn();
|
|
|
|
|
|
|
|
|
|
this->ImageActor->SetPickable(true);
|
|
|
|
|
this->ImageActor->SetMapper(this->ImageMapper);
|
|
|
|
|
ImageStack->AddImage(ImageActor);
|
|
|
|
|
this->FusionActor = nullptr;
|
|
|
|
|
this->FusionMapper = nullptr;
|
|
|
|
|
this->Interactor = nullptr;
|
|
|
|
|
@@ -595,7 +604,12 @@ void infinitiViewer::SetSlice(int slice)
|
|
|
|
|
|
|
|
|
|
double npv = origin[this->SliceOrientation] + this->Slice * spacing[this->SliceOrientation];
|
|
|
|
|
camera->SetDistance(fabs(npv - pos[this->SliceOrientation]));
|
|
|
|
|
if (Fusion && FusionMapper){
|
|
|
|
|
FusionMapper->SetClippingPlanes(ImageMapper->GetClippingPlanes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->Render();
|
|
|
|
|
|
|
|
|
|
this->InvokeEvent(infinitiViewerEvents::SlicedEvent, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -611,6 +625,37 @@ void infinitiViewer::ChangeSlice(vtkObject *, unsigned long eventid, void *calld
|
|
|
|
|
SetSlice(newSlice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkPoints> infinitiViewer::GetSliceBoundPoints(){
|
|
|
|
|
double bounds[6] ={.0, .0, .0, .0, .0, .0};
|
|
|
|
|
ImageMapper->GetBounds(bounds);
|
|
|
|
|
vtkCamera* camera = this->Renderer->GetActiveCamera();
|
|
|
|
|
double fpt[3] = {.0, .0, .0};
|
|
|
|
|
camera->GetFocalPoint(fpt);
|
|
|
|
|
bounds[SliceOrientation*2] = fpt[SliceOrientation];
|
|
|
|
|
vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();
|
|
|
|
|
//只取4个点
|
|
|
|
|
pts->InsertNextPoint(bounds[0],bounds[2],bounds[4]);
|
|
|
|
|
if (SliceOrientation!=1){
|
|
|
|
|
pts->InsertNextPoint(bounds[0],bounds[3],bounds[4]);
|
|
|
|
|
if (SliceOrientation!=2) {
|
|
|
|
|
pts->InsertNextPoint(bounds[0], bounds[3], bounds[5]);
|
|
|
|
|
pts->InsertNextPoint(bounds[0], bounds[2], bounds[5]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (SliceOrientation!=0){
|
|
|
|
|
if (SliceOrientation!=1){
|
|
|
|
|
pts->InsertNextPoint(bounds[1],bounds[3],bounds[4]);
|
|
|
|
|
pts->InsertNextPoint(bounds[1],bounds[2],bounds[4]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
pts->InsertNextPoint(bounds[1],bounds[2],bounds[4]);
|
|
|
|
|
pts->InsertNextPoint(bounds[1],bounds[2],bounds[5]);
|
|
|
|
|
pts->InsertNextPoint(bounds[0],bounds[2],bounds[5]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void infinitiViewer::SetZoomScale(double scale) {
|
|
|
|
|
if (Renderer)
|
|
|
|
|
{
|
|
|
|
|
@@ -751,13 +796,14 @@ void infinitiViewer::InstallPipeline()
|
|
|
|
|
|
|
|
|
|
if (this->Renderer && this->ImageActor)
|
|
|
|
|
{
|
|
|
|
|
this->Renderer->AddViewProp(this->ImageActor);
|
|
|
|
|
this->Renderer->AddViewProp(this->ImageStack);
|
|
|
|
|
// this->Renderer->AddViewProp(this->ImageActor);
|
|
|
|
|
this->Renderer->GetActiveCamera()->SetParallelProjection(1);
|
|
|
|
|
this->Renderer->SetBackground(0.0, 0.0, 0.0);
|
|
|
|
|
}
|
|
|
|
|
if (this->Renderer && this->FusionActor && Fusion)
|
|
|
|
|
{
|
|
|
|
|
this->Renderer->AddViewProp(this->FusionActor);
|
|
|
|
|
this->ImageStack->AddImage(this->FusionActor);
|
|
|
|
|
}
|
|
|
|
|
if (this->Renderer && this->cornerAnnotation)
|
|
|
|
|
{
|
|
|
|
|
@@ -933,12 +979,16 @@ void infinitiViewer::Render()
|
|
|
|
|
}
|
|
|
|
|
if (this->GetInput())
|
|
|
|
|
{
|
|
|
|
|
if (Fusion && FusionActor && !this->Renderer->HasViewProp(FusionActor)) {
|
|
|
|
|
this->Renderer->AddActor(FusionActor);
|
|
|
|
|
if (Fusion && FusionActor && !this->ImageStack->HasImage(FusionActor)) {
|
|
|
|
|
// this->Renderer->AddActor(FusionActor);
|
|
|
|
|
|
|
|
|
|
this->ImageStack->AddImage(FusionActor);
|
|
|
|
|
}
|
|
|
|
|
if (!Fusion && FusionActor && this->Renderer->HasViewProp(FusionActor))
|
|
|
|
|
if (!Fusion && FusionActor && this->ImageStack->HasImage(FusionActor))
|
|
|
|
|
{
|
|
|
|
|
this->Renderer->RemoveViewProp(FusionActor);
|
|
|
|
|
// this->Renderer->RemoveViewProp(FusionActor);
|
|
|
|
|
this->ImageStack->RemoveImage(FusionActor);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this->LoadMeasures();
|
|
|
|
|
this->RenderWindow->Render();
|
|
|
|
|
|