1 #include "bbvtkVecIsoSurfaceExtractor.h"
2 #include "bbvtkPackage.h"
4 #include "vtkProperty.h"
5 #include "vtkLinearTransform.h"
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VecIsoSurfaceExtractor)
11 BBTK_BLACK_BOX_IMPLEMENTATION(VecIsoSurfaceExtractor,bbtk::AtomicBlackBox);
13 //-----------------------------------------------------------
14 void VecIsoSurfaceExtractor::bbUserSetDefaultValues()
16 std::vector<double> colour;
18 colour.push_back(1.0);
19 colour.push_back(0.0);
20 colour.push_back(0.0);
22 colour.push_back(0.0);
23 colour.push_back(0.0);
24 colour.push_back(1.0);
26 colour.push_back(1.0);
27 colour.push_back(1.0);
28 colour.push_back(0.0);
30 colour.push_back(0.0);
31 colour.push_back(1.0);
32 colour.push_back(0.0);
34 colour.push_back(0.0);
35 colour.push_back(1.0);
36 colour.push_back(1.0);
39 colour.push_back(0.5);
40 colour.push_back(0.5);
41 colour.push_back(0.5);
43 bbSetInputColour(colour);
44 bbSetInputTransform(NULL);
47 bbSetInputRenderer(NULL);
48 bbSetInputIsovalue(128);
52 //-----------------------------------------------------------
53 void VecIsoSurfaceExtractor::bbUserInitializeProcessing()
55 // bbSetInputIn(NULL);
56 // bbSetInputInVtkObject(NULL);
60 //-----------------------------------------------------------
61 void VecIsoSurfaceExtractor::bbUserFinalizeProcessing()
63 int i,size = VecMarchingcubes.size();
66 VecMarchingcubes[i]->Delete();
67 VecPolydatamapper[i]->Delete();
68 VecVtkactor[i]->Delete();
70 VecMarchingcubes.clear();
71 VecPolydatamapper.clear();
75 //-----------------------------------------------------------
76 void VecIsoSurfaceExtractor::Process()
79 vtkMarchingCubes *marchingcubes;
80 vtkPolyDataMapper *polydatamapper;
85 size = VecVtkactor.size();
86 for( i=0 ; i<size ; i++)
88 if (bbGetInputRenderer()!=NULL )
90 bbGetInputRenderer()->RemoveActor( VecVtkactor[i] );
91 VecMarchingcubes[i]->Delete();
92 VecPolydatamapper[i]->Delete();
93 VecVtkactor[i]->Delete();
96 VecMarchingcubes.clear();
97 VecPolydatamapper.clear();
101 size = bbGetInputIn().size();
102 for( i=0 ; i<size ; i++){
103 marchingcubes = vtkMarchingCubes::New();
104 polydatamapper = vtkPolyDataMapper::New();
105 vtkactor = vtkActor::New();
107 polydatamapper->SetInput(marchingcubes->GetOutput());
108 vtkactor->SetMapper(polydatamapper);
110 polydatamapper->ScalarVisibilityOff();
111 polydatamapper->ImmediateModeRenderingOn();
113 VecMarchingcubes.push_back(marchingcubes);
114 VecPolydatamapper.push_back(polydatamapper);
115 VecVtkactor.push_back(vtkactor);
119 for( i=0 ; i<size ; i++){
120 // Visualisation - result volume
121 marchingcubes=VecMarchingcubes[i];
122 vtkactor=(vtkActor*)VecVtkactor[i];
124 marchingcubes->SetInput( bbGetInputIn()[i] );
125 marchingcubes->SetValue(0, bbGetInputIsovalue() );
126 marchingcubes->Update();
128 if ( (i*3+1)<(int)(bbGetInputColour().size()) ){
129 r = bbGetInputColour()[0+i*3];
130 g = bbGetInputColour()[1+i*3];
131 b = bbGetInputColour()[2+i*3];
133 r = bbGetInputColour()[0];
134 g = bbGetInputColour()[1];
135 b = bbGetInputColour()[2];
137 vtkactor->GetProperty()->SetColor( r,g,b );
139 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
141 if ( bbGetInputTransform()!=NULL )
143 vtkactor->SetUserTransform( bbGetInputTransform() );
147 if (bbGetInputRenderer()!=NULL )
149 bbGetInputRenderer()->AddActor( vtkactor );
153 bbSetOutputOut( VecVtkactor );
158 // EO namespace bbvtk