From c135f9b390e2750d8248db5903753b94ca549623 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 3 Mar 2011 15:40:11 +0000 Subject: [PATCH] release memory when overlay and fusion images are closed (change NumberOfSlicers by GetNumberOfSlicers) --- vv/vvROIActor.cxx | 8 +- vv/vvSlicer.cxx | 8 - vv/vvSlicer.h | 326 +++++++++++++++---------------- vv/vvSlicerManager.cxx | 44 ++--- vv/vvSlicerManager.h | 2 +- vv/vvSlicerManagerCommand.cxx | 4 +- vv/vvToolBinarize.cxx | 8 +- vv/vvToolCropImage.cxx | 8 +- vv/vvToolRigidReg.cxx | 6 +- vv/vvToolStructureSetManager.cxx | 17 +- vv/vvToolStructureSetManager.h | 4 +- 11 files changed, 211 insertions(+), 224 deletions(-) diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx index 90e507e..253a290 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -147,7 +147,7 @@ void vvROIActor::Initialize(bool IsVisible) { if (mROI->GetImage()) { mImageContour.clear(); mOverlayActors.clear(); - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mImageContour.push_back(new vvImageContour); mImageContour[i]->SetSlicer(mSlicerManager->GetSlicer(i)); mImageContour[i]->SetImage(mROI->GetImage()); @@ -191,7 +191,7 @@ void vvROIActor::Initialize(bool IsVisible) { //------------------------------------------------------------------------------ void vvROIActor::Update() { - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice()); } } @@ -274,12 +274,12 @@ void vvROIActor::SetSelected(bool b) { mIsSelected = b; if (b) { - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mImageContour[i]->SetLineWidth(3.0); mImageContour[i]->ShowActors(); } } else { - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mImageContour[i]->HideActors(); } } diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index af7f066..f287e4d 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -743,8 +743,6 @@ void vvSlicer::UpdateDisplayExtent() mClipBox->SetBounds(bounds); UpdateLandmarks(); } - // DD(mLandActor->GetPosition()[2]); - // DD(Renderer->GetActiveCamera()->GetPosition()[2]); mLandActor->SetPosition(0,0,-1.5); /* if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice) @@ -800,8 +798,6 @@ void vvSlicer::UpdateDisplayExtent() mClipBox->SetBounds(bounds); UpdateLandmarks(); } - // DD(mLandActor->GetPosition()[1]); - //DD(Renderer->GetActiveCamera()->GetPosition()[1]); if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice) mLandActor->SetPosition(0,1.5,0); else @@ -854,8 +850,6 @@ void vvSlicer::UpdateDisplayExtent() mClipBox->SetBounds(bounds); UpdateLandmarks(); } - // DD(mLandActor->GetPosition()[1]); - // DD(Renderer->GetActiveCamera()->GetPosition()[1]); if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice) mLandActor->SetPosition(1.5,0,0); else @@ -1392,5 +1386,3 @@ void vvSlicer::PrintSelf(ostream& os, vtkIndent indent) - - diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index d4ac4dc..a2f77e9 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ + ======================================================================-====*/ #ifndef __vvSlicer_h #define __vvSlicer_h #include @@ -22,10 +22,11 @@ #include "vvLandmarks.h" #include "vvImage.h" -#include "vtkImageViewer2.h" #include "vvMesh.h" -#include +#include "vvMeshActor.h" + #include +#include class vtkActor; class vtkActor2D; @@ -53,174 +54,173 @@ class vtkImageReslice; class vvSlicer: public vtkImageViewer2 { public: - static vvSlicer *New(); - vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2); - void PrintSelf(ostream& os, vtkIndent indent); - - void SetImage(vvImage::Pointer inputImages); - vvImage::Pointer GetImage() { - return mImage; - } - - void SetOverlay(vvImage::Pointer inputOverlay); - vvImage::Pointer GetOverlay() { - return mOverlay; - } - - vtkImageMapToWindowLevelColors* GetOverlayMapper(); - vvBlendImageActor* GetOverlayActor() ; - vtkImageMapToWindowLevelColors* GetFusionMapper() ; - vtkImageActor* GetFusionActor() ; - vtkActor* GetVFActor() ; - vtkCornerAnnotation* GetAnnotation(); + static vvSlicer *New(); + vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2); + void PrintSelf(ostream& os, vtkIndent indent); + + void SetImage(vvImage::Pointer inputImages); + vvImage::Pointer GetImage() { + return mImage; + } + + void SetOverlay(vvImage::Pointer inputOverlay); + vvImage::Pointer GetOverlay() { + return mOverlay; + } + vtkImageMapToWindowLevelColors* GetOverlayMapper(); + vvBlendImageActor* GetOverlayActor() ; + vtkImageMapToWindowLevelColors* GetFusionMapper() ; + vtkImageActor* GetFusionActor() ; + vtkActor* GetVFActor() ; + vtkCornerAnnotation* GetAnnotation(); - void SetFusion(vvImage::Pointer inputFusion); - vvImage::Pointer GetFusion() { - return mFusion; - } - - /**Set an actor's visibility ("overlay, fusion, vf, contour...") - Overlay index is the index of the overlay by type, eg. if there are - 5 contours and we want to activate the 3rd one, pass 2 **/ - void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis); - void RemoveActor(const std::string& actor_type, int overlay_index); - - void SetVF(vvImage::Pointer vf); - vvImage *GetVF() { - return mVF; - } - - void SetLandmarks(vvLandmarks* landmarks); - void SetTSlice(int t); - void SetSliceOrientation(int orientation); - int GetTSlice(); - ///Reimplemented from vtkImageViewer2 to add polydata support - void SetSlice(int s); - int GetTMax() { - return (unsigned int)mImage->GetVTKImages().size() - 1; - } - - void SetOpacity(double s); - void SetRenderWindow(int orientation, vtkRenderWindow * rw); - void SetDisplayMode(bool i); - void FlipHorizontalView(); - void FlipVerticalView(); - void Render(); - ///Sets the camera to fit the image in the window - void ResetCamera(); - - void SetVFSubSampling(int sub); - int GetVFSubSampling() { - return mSubSampling; - } - void SetVFScale(int scale); - void SetVFWidth(int width); - int GetVFScale() { - return mScale; - } - void SetVFLog(int log); - int GetVFLog() { - return mVFLog; - } - - void SetFileName(std::string filename) { - mFileName = filename; - } - std::string GetFileName() { - return mFileName; - } - - double* GetCursorPosition() { - return mCursor; - } - - void SetCurrentPosition(double x, double y, double z, int t); - double* GetCurrentPosition() { - return mCurrent; - } - - void UpdateCursorPosition(); - void SetCursorVisibility(bool s); - bool GetCursorVisibility(); - void SetCursorColor(int r,int g, int b); - - void GetExtremasAroundMousePointer(double & min, double & max); - - void UpdateLandmarks(); - void ForceUpdateDisplayExtent(); - - int* GetDisplayExtent(); - /**Add a polydata to be displayed as a contour over the image - ** the contour can be propagated to a time sequence using a motion field */ - void AddContour(vvMesh::Pointer contours,bool propagate); - ///Toggle temporal superposition of contours - void ToggleContourSuperposition(); - - virtual void SetColorWindow(double s); - virtual void SetColorLevel(double s); + void SetFusion(vvImage::Pointer inputFusion); + vvImage::Pointer GetFusion() { + return mFusion; + } + + /**Set an actor's visibility ("overlay, fusion, vf, contour...") + Overlay index is the index of the overlay by type, eg. if there are + 5 contours and we want to activate the 3rd one, pass 2 **/ + void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis); + void RemoveActor(const std::string& actor_type, int overlay_index); + + void SetVF(vvImage::Pointer vf); + vvImage *GetVF() { + return mVF; + } + + void SetLandmarks(vvLandmarks* landmarks); + void SetTSlice(int t); + void SetSliceOrientation(int orientation); + int GetTSlice(); + ///Reimplemented from vtkImageViewer2 to add polydata support + void SetSlice(int s); + int GetTMax() { + return (unsigned int)mImage->GetVTKImages().size() - 1; + } + + void SetOpacity(double s); + void SetRenderWindow(int orientation, vtkRenderWindow * rw); + void SetDisplayMode(bool i); + void FlipHorizontalView(); + void FlipVerticalView(); + void Render(); + ///Sets the camera to fit the image in the window + void ResetCamera(); + + void SetVFSubSampling(int sub); + int GetVFSubSampling() { + return mSubSampling; + } + void SetVFScale(int scale); + void SetVFWidth(int width); + int GetVFScale() { + return mScale; + } + void SetVFLog(int log); + int GetVFLog() { + return mVFLog; + } + + void SetFileName(std::string filename) { + mFileName = filename; + } + std::string GetFileName() { + return mFileName; + } + + double* GetCursorPosition() { + return mCursor; + } + + void SetCurrentPosition(double x, double y, double z, int t); + double* GetCurrentPosition() { + return mCurrent; + } + + void UpdateCursorPosition(); + void SetCursorVisibility(bool s); + bool GetCursorVisibility(); + void SetCursorColor(int r,int g, int b); + + void GetExtremasAroundMousePointer(double & min, double & max); + + void UpdateLandmarks(); + void ForceUpdateDisplayExtent(); + + int* GetDisplayExtent(); + /**Add a polydata to be displayed as a contour over the image + ** the contour can be propagated to a time sequence using a motion field */ + void AddContour(vvMesh::Pointer contours,bool propagate); + ///Toggle temporal superposition of contours + void ToggleContourSuperposition(); + + virtual void SetColorWindow(double s); + virtual void SetColorLevel(double s); - void EnableReducedExtent(bool b); - void SetReducedExtent(int * ext); + void EnableReducedExtent(bool b); + void SetReducedExtent(int * ext); - void ClipDisplayedExtent(int extent[6], int refExtent[6]); - int GetOrientation(); - int * GetExtent(); + void ClipDisplayedExtent(int extent[6], int refExtent[6]); + int GetOrientation(); + int * GetExtent(); protected: - vvSlicer(); - ~vvSlicer(); - - std::string mFileName; - vvImage::Pointer mImage; - vvImage::Pointer mOverlay; - vvImage::Pointer mFusion; - vvImage::Pointer mVF; - - vvLandmarks* mLandmarks; - - vtkSmartPointer mOverlayMapper; - vtkSmartPointer mOverlayActor; - vtkSmartPointer mFusionMapper; - vtkSmartPointer mFusionActor; - vtkSmartPointer ca; - vtkSmartPointer crossCursor; - vtkSmartPointer pdm; - vtkSmartPointer pdmA; - vtkSmartPointer mArrow; - vtkSmartPointer mAAFilter; - vtkSmartPointer mVOIFilter; - vtkSmartPointer mGlyphFilter; - vtkSmartPointer mVFMapper; - vtkSmartPointer mVFActor; - vtkSmartPointer mLandGlyph; - vtkSmartPointer mCross; - vtkSmartPointer mLandClipper; - vtkSmartPointer mLandMapper; - vtkSmartPointer mLandActor; - vtkSmartPointer mClipBox; - vtkSmartPointer legend; - std::vector mSurfaceCutActors; - - int mCurrentTSlice; - double mCurrent[3]; - double mCursor[4]; - int mSubSampling; - int mScale; - int mVFLog; - int mVFWidth; - bool mUseReducedExtent; - int * mReducedExtent; - int * mInitialExtent; + vvSlicer(); + ~vvSlicer(); + + std::string mFileName; + vvImage::Pointer mImage; + vvImage::Pointer mOverlay; + vvImage::Pointer mFusion; + vvImage::Pointer mVF; + + vvLandmarks* mLandmarks; + + vtkSmartPointer mOverlayMapper; + vtkSmartPointer mOverlayActor; + vtkSmartPointer mFusionMapper; + vtkSmartPointer mFusionActor; + vtkSmartPointer ca; + vtkSmartPointer crossCursor; + vtkSmartPointer pdm; + vtkSmartPointer pdmA; + vtkSmartPointer mArrow; + vtkSmartPointer mAAFilter; + vtkSmartPointer mVOIFilter; + vtkSmartPointer mGlyphFilter; + vtkSmartPointer mVFMapper; + vtkSmartPointer mVFActor; + vtkSmartPointer mLandGlyph; + vtkSmartPointer mCross; + vtkSmartPointer mLandClipper; + vtkSmartPointer mLandMapper; + vtkSmartPointer mLandActor; + vtkSmartPointer mClipBox; + vtkSmartPointer legend; + std::vector mSurfaceCutActors; + + int mCurrentTSlice; + double mCurrent[3]; + double mCursor[4]; + int mSubSampling; + int mScale; + int mVFLog; + int mVFWidth; + bool mUseReducedExtent; + int * mReducedExtent; + int * mInitialExtent; private: - void UpdateOrientation(); - void UpdateDisplayExtent(); - void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]); - void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]); - void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]); - ///Sets the surfaces to be cut on the image slice: update the vtkCutter - void SetContourSlice(); + void UpdateOrientation(); + void UpdateDisplayExtent(); + void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]); + void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]); + void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]); + ///Sets the surfaces to be cut on the image slice: update the vtkCutter + void SetContourSlice(); }; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index f2a63e5..42982b7 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -112,7 +112,6 @@ void vvSlicerManager::SetFilename(std::string filename, int number) mFileName = filename; mFileName = vtksys::SystemTools::GetFilenameName(mFileName); mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName)); - // DD(mBaseFileName); mBaseFileNameNumber = number; for(unsigned int i=0; iGetLastError().size() == 0) { @@ -168,14 +166,12 @@ bool vvSlicerManager::SetImage(std::string filename, LoadedImageType type, int n 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; @@ -214,7 +210,6 @@ bool vvSlicerManager::SetImages(std::vector filenames,LoadedImageTy mReader->Update(type); mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName)); - // DD(mBaseFileName); mBaseFileNameNumber = n; if (mReader->GetLastError().size() == 0) { @@ -228,9 +223,7 @@ bool vvSlicerManager::SetImages(std::vector filenames,LoadedImageTy return false; } if (n!=0) { - // DD(mFileName); mFileName.append("_"+clitk::toString(n)); - // DD(mFileName); } return true; } @@ -320,10 +313,6 @@ bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename) 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; @@ -442,9 +431,6 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer) t++; if (t > mSlicers[0]->GetTMax()) t = 0; - // DD("SetNextTSlice"); - // DD(originating_slicer); - // DD(t); emit UpdateTSlice(originating_slicer,t); } //---------------------------------------------------------------------------- @@ -536,10 +522,6 @@ void vvSlicerManager::SetOpacity(int i, double factor) //---------------------------------------------------------------------------- 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]) @@ -617,8 +599,6 @@ void vvSlicerManager::UpdateViews(int current,int slicer) mSlicers[i]->SetSlice((int)floor(x)); break; } - // DD("UpdateViews::"); - // DD(i); UpdateSlice(i); UpdateTSlice(i); } @@ -743,9 +723,7 @@ double vvSlicerManager::GetColorLevel() //---------------------------------------------------------------------------- void vvSlicerManager::Render() { - // DD("vvSlicerManager::Render"); for ( unsigned int i = 0; i < mSlicers.size(); i++) { - // DD(i); mSlicers[i]->Render(); } } @@ -813,6 +791,16 @@ void vvSlicerManager::ReloadVF() //---------------------------------------------------------------------------- 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); } @@ -830,7 +818,10 @@ void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_ind //---------------------------------------------------------------------------- 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()); @@ -966,9 +957,6 @@ void vvSlicerManager::UpdateWindowLevel() //---------------------------------------------------------------------------- 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; @@ -983,10 +971,6 @@ void vvSlicerManager::UpdateSlice(int slicer) //---------------------------------------------------------------------------- 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 ***********"); diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index ed118f5..4272891 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -87,7 +87,7 @@ class vvSlicerManager : public QObject { void SetSlicerWindow(int i, vtkRenderWindow* RW); void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style); - int NumberOfSlicers() { return mSlicers.size(); } + int GetNumberOfSlicers() { return mSlicers.size(); } vvImage::Pointer GetImage() { return mImage; } vvImage::Pointer GetVF() { return mVF; } int GetType() { return mType; } diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 4247d63..d73bcfc 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -85,7 +85,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1) { - for (int i = 0; i < this->SM->NumberOfSlicers(); i++) { + for (int i = 0; i < this->SM->GetNumberOfSlicers(); i++) { if (this->SM->GetSlicer(i)->GetCursorVisibility()) { this->SM->GetSlicer(i)->SetCursorVisibility(0); this->SM->GetSlicer(i)->Render(); @@ -189,7 +189,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, return; } if (KeyPress == "x") { - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { SM->RemoveActor("overlay",0); SM->SetColorMap(0); SM->Render(); diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index d2f3c6a..83bf04c 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -211,7 +211,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) mBGSlider->SetSingleStep(1); // VTK objects for interactive display - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mImageContour.push_back(new vvImageContour); mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); mImageContour[i]->SetColor(1.0, 0.0, 0.0); @@ -235,7 +235,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) //------------------------------------------------------------------------------ // void vvToolBinarize::LeftButtonReleaseEvent(int slicer) { // DD("LeftButtonReleaseEvent"); -// for(int i=0; iNumberOfSlicers(); i++) { +// for(int i=0; iGetNumberOfSlicers(); i++) { // if (i == slicer); // mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render(); // } @@ -342,7 +342,7 @@ void vvToolBinarize::valueChangedT2(double v) if (mRadioButtonLowerThan->isChecked()) { mThresholdSlider1->SetMaximum(v); if (!mInteractiveDisplayIsEnabled) return; - for(int i=0;iNumberOfSlicers(); i++) { + for(int i=0;iGetNumberOfSlicers(); i++) { mImageContourLower[i]->Update(v); } mCurrentSlicerManager->Render(); @@ -359,7 +359,7 @@ void vvToolBinarize::valueChangedT1(double v) mThresholdSlider2->SetMinimum(v); // int m1 = (int)lrint(v); if (!mInteractiveDisplayIsEnabled) return; - for(int i=0;iNumberOfSlicers(); i++) { + for(int i=0;iGetNumberOfSlicers(); i++) { mImageContour[i]->Update(v); } mCurrentSlicerManager->Render(); diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx index 5190c28..691c32a 100644 --- a/vv/vvToolCropImage.cxx +++ b/vv/vvToolCropImage.cxx @@ -191,7 +191,7 @@ void vvToolCropImage::sliderTMaxValueChanged(int s) { //------------------------------------------------------------------------------ void vvToolCropImage::UpdateExtent() { - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent); mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); mCurrentSlicerManager->GetSlicer(i)->Render(); @@ -229,7 +229,7 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) mInitialExtent = new int[mExtentSize]; mReducedExtent = mCurrentSlicerManager->GetImage()->GetFirstVTKImageData()->GetWholeExtent(); for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true); } @@ -338,7 +338,7 @@ void vvToolCropImage::apply() // filter to retrieve the correct image size for(int i=0; iUpdate(); } catch(clitk::ExceptionObject & e) { - DD(e.what()); + // DD(e.what()); QApplication::restoreOverrideCursor(); close(); } diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index 4d92c67..26c53ca 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -829,7 +829,7 @@ void vvToolRigidReg::CheckDeformableReg() //------------------------------------------------------------------------------ void vvToolRigidReg::SetOverlay(vvImage::Pointer Image) { - for (int i =0; iNumberOfSlicers(); i++) { + for (int i =0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->SetOverlay(Image); mCurrentSlicerManager->GetSlicer(i)->SetActorVisibility("overlay",0,true); mCurrentSlicerManager->SetColorMap(); @@ -841,7 +841,7 @@ void vvToolRigidReg::SetOverlay(vvImage::Pointer Image) //------------------------------------------------------------------------------ void vvToolRigidReg::RemoveOverlay() { - for(int i=0;iNumberOfSlicers();i++) + for(int i=0;iGetNumberOfSlicers();i++) { mInput1->RemoveActor("overlay",0); mInput1->SetColorMap(0); @@ -919,7 +919,7 @@ void vvToolRigidReg::LoadFile() //------------------------------------------------------------------------------ void vvToolRigidReg::Render() { - for (int i=0; iNumberOfSlicers(); i++) { + for (int i=0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); mCurrentSlicerManager->GetSlicer(i)->Render(); } diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index 7c01a82..4f9fedd 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -100,6 +100,13 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, vvToolStructureSetManager::~vvToolStructureSetManager() { m_NumberOfTool--; + // DD(mStructureSetsList.size()); + // DD(mStructureSetActorsList.size()); + for(uint i=0; iSetStructureSet(mStructureSet); mStructureSetActor->SetSlicerManager(mCurrentSlicerManager); // Insert in lists and get index @@ -260,6 +269,7 @@ void vvToolStructureSetManager::OpenBinaryImage() } vvImage::Pointer binaryImage = mReader->GetOutput(); AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value()); + delete mReader; } UpdateImage(); } @@ -275,7 +285,7 @@ void vvToolStructureSetManager::UpdateImage() for(unsigned int i=0; iGetROIActor(mLoadedROIIndex[i])->Update(); } - for(int i=0; iNumberOfSlicers(); i++) { + for(int i=0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->Render(); } } @@ -283,7 +293,8 @@ void vvToolStructureSetManager::UpdateImage() //------------------------------------------------------------------------------ -void vvToolStructureSetManager::AddImage(vvImage::Pointer binaryImage, std::string filename, double BG, bool m_modeBG) +void vvToolStructureSetManager::AddImage(vvImage * binaryImage, std::string filename, + double BG, bool m_modeBG) { // Check current structure set int index; diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h index 4d4cf50..240ca79 100644 --- a/vv/vvToolStructureSetManager.h +++ b/vv/vvToolStructureSetManager.h @@ -47,7 +47,7 @@ class vvToolStructureSetManager: void AddRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidget * w); static vvToolStructureSetManager * AddImage(vvSlicerManager * m, std::string name, vvImage::Pointer image, double BG, bool modeBG=true); - void AddImage(vvImage::Pointer image, std::string filename, double BG, bool modeBG=true); + void AddImage(vvImage * image, std::string filename, double BG, bool modeBG=true); void UpdateImage(); public slots: @@ -76,7 +76,7 @@ protected: bool mIsAllVisibleEnabled; int mNumberOfVisibleROI; int mNumberOfVisibleContourROI; - std::vector mStructureSetsList; + std::vector mStructureSetsList; std::vector mStructureSetActorsList; std::map mMapStructureSetIndexToTreeWidget; std::map mMapROIToTreeWidget; -- 2.47.1