2 /*=========================================================================
5 Module: $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
7 Date: $Date: 2008/05/09 10:39:47 $
8 Version: $Revision: 1.6 $
10 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
11 l'Image). All rights reserved. See Doc/License.txt or
12 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
14 This software is distributed WITHOUT ANY WARRANTY; without even
15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 PURPOSE. See the above copyright notices for more information.
18 =========================================================================*/
27 #include "vtkProperty.h"
29 #include "bbvtkIsoSurfaceExtractor.h"
30 #include "bbvtkPackage.h"
34 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
35 BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
37 void IsoSurfaceExtractor::bbUserConstructor()
40 std::vector<double> colour;
41 colour.push_back(1.0);
42 colour.push_back(1.0);
43 colour.push_back(0.5);
44 bbSetInputColour(colour);
47 void IsoSurfaceExtractor::bbUserCopyConstructor()
52 void IsoSurfaceExtractor::bbUserDestructor()
54 marchingcubes->Delete();
55 polydatamapper->Delete();
59 void IsoSurfaceExtractor::Init()
64 // bbSetInputInVtkObject(NULL);
65 bbSetInputRenderer(NULL);
66 bbSetInputIsovalue(400);
69 marchingcubes = vtkMarchingCubes::New();
70 polydatamapper = vtkPolyDataMapper::New();
71 vtkactor = vtkActor::New();
73 polydatamapper->SetInput(marchingcubes->GetOutput());
74 vtkactor->SetMapper(polydatamapper);
76 polydatamapper->ScalarVisibilityOff();
77 polydatamapper->ImmediateModeRenderingOn();
80 //---------------------------------------------------------------------
82 void IsoSurfaceExtractor::DoProcess()
84 // bbGetInputIn()->Print(std::cout);
85 // Visualisation - result volume
86 marchingcubes->SetInput( bbGetInputIn() );
87 marchingcubes->SetValue(0, bbGetInputIsovalue() );
88 marchingcubes->Update();
90 vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
91 bbGetInputColour()[1],
92 bbGetInputColour()[2] );
95 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
96 bbSetOutputOut( vtkactor );
99 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
102 bbGetInputRenderer()->AddActor( vtkactor );
105 } // EO namespace bbtk