#include "vvImageContour.h"
#include "vvImage.h"
+#include <vtkVersion.h>
#include <vtkImageActor.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
SetPreserveMemoryModeEnabled(true);
mPreviousOrientation = -1;
mDepth = 1.0;
+ mSlice = 0;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
vvImageContour::~vvImageContour()
{
- for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) {
- mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
+ mSquaresActorList.clear();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::RemoveActors()
+{
+ for (unsigned int i = 0; i < mSquaresActorList.size(); i++) {
+ if (mSlicer != 0) {
+ if (mSlicer!= NULL) {
+ if (mSlicer->GetRenderer() != NULL) {
+ if (mSquaresActorList[i] != NULL) {
+ mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
+ }
+ }
+ }
+ }
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvImageContour::SetImage(vvImage * image) {
+void vvImageContour::SetImage(vvImage::Pointer image) {
for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) {
+#if VTK_MAJOR_VERSION <= 5
mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]);
+#else
+ mClipperList[numImage]->SetInputData(image->GetVTKImages()[numImage]);
+#endif
}
mHiddenImageIsUsed = true;
mHiddenImage = image;
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvImageContour::SetDepth(double d)
+{
+ mDepth = d;
+ // Move the actor to be visible
+ double position[3] = {0, 0, 0};
+ int orientation = ComputeCurrentOrientation();
+ position[orientation] = -mDepth;
+
+ for(unsigned int i=0; i<mSquaresActorList.size(); i++)
+ mSquaresActorList[i]->SetPosition(position);
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvImageContour::Update(double value) {
if (!mSlicer) return;
vtkSmartPointer<vtkMarchingSquares> squares = vtkSmartPointer<vtkMarchingSquares>::New();
vtkSmartPointer<vtkPolyDataMapper> squaresMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- if (mHiddenImageIsUsed)
+ if (mHiddenImageIsUsed) {
+#if VTK_MAJOR_VERSION <= 5
clipper->SetInput(mHiddenImage->GetVTKImages()[0]);
- else
+#else
+ clipper->SetInputData(mHiddenImage->GetVTKImages()[0]);
+#endif
+ } else {
+#if VTK_MAJOR_VERSION <= 5
clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
-
+#else
+ clipper->SetInputData(mSlicer->GetImage()->GetVTKImages()[numImage]);
+#endif
+ }
+
+#if VTK_MAJOR_VERSION <= 5
squares->SetInput(clipper->GetOutput());
squaresMapper->SetInput(squares->GetOutput());
+#else
+ squares->SetInputData(clipper->GetOutput());
+ squaresMapper->SetInputData(squares->GetOutput());
+#endif
squaresMapper->ScalarVisibilityOff();
squaresActor->SetMapper(squaresMapper);
squaresActor->GetProperty()->SetColor(1.0,0,0);
if (mHiddenImageIsUsed) delete extent2;
// Move the actor to be visible
- double position[3] = {0, 0, 0};
- position[orientation] = -mDepth;
- actor->SetPosition(position);
+ SetDepth(mDepth);
+ // double position[3] = {0, 0, 0};
+ // DD(mDepth);
+ // position[orientation] = -mDepth;
+ // actor->SetPosition(position);
mapper->Update();
}