2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #include "bbvtkVecIsoSurfaceExtractor.h"
29 #include "bbvtkPackage.h"
31 #include "vtkProperty.h"
32 #include "vtkLinearTransform.h"
37 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VecIsoSurfaceExtractor)
38 BBTK_BLACK_BOX_IMPLEMENTATION(VecIsoSurfaceExtractor,bbtk::AtomicBlackBox);
40 //-----------------------------------------------------------
41 void VecIsoSurfaceExtractor::bbUserSetDefaultValues()
43 //EED std::cout << "================================VecIsoSurfaceExtractor::bbUserSetDefaultValues()" << std::endl;
44 std::vector<double> colour;
46 colour.push_back(1.0);
47 colour.push_back(0.0);
48 colour.push_back(0.0);
50 colour.push_back(0.0);
51 colour.push_back(0.0);
52 colour.push_back(1.0);
54 colour.push_back(1.0);
55 colour.push_back(1.0);
56 colour.push_back(0.0);
58 colour.push_back(0.0);
59 colour.push_back(1.0);
60 colour.push_back(0.0);
62 colour.push_back(0.0);
63 colour.push_back(1.0);
64 colour.push_back(1.0);
67 colour.push_back(0.5);
68 colour.push_back(0.5);
69 colour.push_back(0.5);
71 bbSetInputColour(colour);
72 bbSetInputTransform(NULL);
75 bbSetInputRenderer(NULL);
76 bbSetInputIsovalue(128);
80 //-----------------------------------------------------------
81 void VecIsoSurfaceExtractor::bbUserInitializeProcessing()
84 // bbSetInputIn(NULL);
85 // bbSetInputInVtkObject(NULL);
86 //EED std::cout << "================================VecIsoSurfaceExtractor::bbUserInitializeProcessing()" << std::endl;
89 //-----------------------------------------------------------
90 void VecIsoSurfaceExtractor::bbUserFinalizeProcessing()
92 //EED std::cout << "================================VecIsoSurfaceExtractor::bbUserFinalizeProcessing()" << std::endl;
93 int i,size = VecMarchingcubes.size();
96 VecMarchingcubes[i]->Delete();
97 VecPolydatamapper[i]->Delete();
98 VecVtkactor[i]->Delete();
100 VecMarchingcubes.clear();
101 VecPolydatamapper.clear();
105 //-----------------------------------------------------------
106 void VecIsoSurfaceExtractor::Process()
108 //EED std::cout <<"================================VecIsoSurfaceExtractor::Process()" << std::endl;
110 vtkMarchingCubes *marchingcubes;
111 vtkPolyDataMapper *polydatamapper;
116 size = VecVtkactor.size();
117 for( i=0 ; i<size ; i++)
119 if (bbGetInputRenderer()!=NULL )
121 bbGetInputRenderer()->RemoveActor( VecVtkactor[i] );
122 VecMarchingcubes[i]->Delete();
123 VecPolydatamapper[i]->Delete();
124 VecVtkactor[i]->Delete();
127 VecMarchingcubes.clear();
128 VecPolydatamapper.clear();
131 size = bbGetInputIn().size();
132 for( i=0 ; i<size ; i++){
133 marchingcubes = vtkMarchingCubes::New();
134 polydatamapper = vtkPolyDataMapper::New();
135 vtkactor = vtkActor::New();
137 //EED 2017-01-01 Migration VTK7
138 #if VTK_MAJOR_VERSION <= 5
139 polydatamapper->SetInput(marchingcubes->GetOutput());
141 polydatamapper->SetInputData(marchingcubes->GetOutput());
144 vtkactor->SetMapper(polydatamapper);
146 polydatamapper->ScalarVisibilityOff();
147 //EED 2020-04-21 vtk8 deprecated
148 // polydatamapper->ImmediateModeRenderingOn();
150 VecMarchingcubes.push_back(marchingcubes);
151 VecPolydatamapper.push_back(polydatamapper);
152 VecVtkactor.push_back(vtkactor);
155 for( i=0 ; i<size ; i++){
156 // Visualisation - result volume
157 marchingcubes=VecMarchingcubes[i];
158 vtkactor=(vtkActor*)VecVtkactor[i];
160 //EED 2017-01-01 Migration VTK7
161 #if VTK_MAJOR_VERSION <= 5
162 marchingcubes->SetInput( bbGetInputIn()[i] );
164 marchingcubes->SetInputData( bbGetInputIn()[i] );
167 marchingcubes->SetValue(0, bbGetInputIsovalue() );
168 marchingcubes->Update();
170 if ( (i*3+1)<(int)(bbGetInputColour().size()) ){
171 r = bbGetInputColour()[0+i*3];
172 g = bbGetInputColour()[1+i*3];
173 b = bbGetInputColour()[2+i*3];
175 r = bbGetInputColour()[0];
176 g = bbGetInputColour()[1];
177 b = bbGetInputColour()[2];
179 vtkactor->GetProperty()->SetColor( r,g,b );
181 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
183 if ( bbGetInputTransform()!=NULL )
185 vtkactor->SetUserTransform( bbGetInputTransform() );
189 if (bbGetInputRenderer()!=NULL )
191 bbGetInputRenderer()->AddActor( vtkactor );
195 bbSetOutputOut( VecVtkactor );
198 // EO namespace bbvtk