1 /*=========================================================================
4 Module: $RCSfile: vvImageContour.cxx,v $
6 Date: $Date: 2010/02/07 09:24:46 $
7 Version: $Revision: 1.1 $
8 Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS http://www.creatis.insa-lyon.fr
14 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, version 3 of the License.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 =========================================================================*/
28 #include "vvImageContour.h"
30 //------------------------------------------------------------------------------
31 vvImageContour::vvImageContour() {
32 mClipper = vtkImageClip::New();
33 mSquares = vtkMarchingSquares::New();
34 mSquaresMapper = vtkPolyDataMapper::New();
35 mSquaresActor = vtkActor::New();
37 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
41 vvImageContour::~vvImageContour() {
44 //------------------------------------------------------------------------------
47 //------------------------------------------------------------------------------
48 void vvImageContour::setSlicer(vvSlicer * slicer) {
50 mClipper->SetInput(slicer->GetImage()->GetFirstVTKImageData());
51 mSquares->SetInput(mClipper->GetOutput());
52 mSquaresMapper->SetInput(mSquares->GetOutput());
53 mSquaresMapper->ScalarVisibilityOff();
54 mSquaresActor->SetMapper(mSquaresMapper);
55 mSquaresActor->GetProperty()->SetColor(1.0,0,0);
56 mSquaresActor->SetPickable(0);
57 mSlicer->GetRenderer()->AddActor(mSquaresActor1);
60 //------------------------------------------------------------------------------
63 //------------------------------------------------------------------------------
64 void vvImageContour::update() {
65 int slice = mSlicer->GetSlice();
66 int tslice = mCurrentSliceManager->GetSlicer(0)->GetTSlice();
70 // mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput());
72 int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
73 mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],
74 extent[3],extent[4],extent[5]);
76 for (i = 0; i < 6;i = i+2) {
77 if (extent[i] == extent[i+1]) {
85 if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice)
87 mSquaresActor->SetPosition(1,0,0);
88 // mSquaresActor2->SetPosition(1,0,0);
92 mSquaresActor->SetPosition(-1,0,0);
93 // mSquaresActor2->SetPosition(-1,0,0);
97 if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice)
99 mSquaresActor->SetPosition(0,1,0);
100 // mSquaresActor2->SetPosition(0,1,0);
104 mSquaresActor->SetPosition(0,-1,0);
105 // mSquaresActor2->SetPosition(0,-1,0);
109 if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
111 mSquaresActor->SetPosition(0,0,1);
112 // mSquaresActor2->SetPosition(0,0,1);
116 mSquaresActor->SetPosition(0,0,-1);
117 // mSquaresActor2->SetPosition(0,0,-1);
122 // mSquares2->Update();
124 //------------------------------------------------------------------------------