1 /*=========================================================================
3 Module: $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
5 Date: $Date: 2008/11/20 17:41:48 $
6 Version: $Revision: 1.8 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
39 #include "vtkProperty.h"
41 #include "bbvtkIsoSurfaceExtractor.h"
42 #include "bbvtkPackage.h"
46 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
47 BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
49 void IsoSurfaceExtractor::bbUserConstructor()
52 std::vector<double> colour;
53 colour.push_back(1.0);
54 colour.push_back(1.0);
55 colour.push_back(0.5);
56 bbSetInputColour(colour);
57 bbSetInputTransform(NULL);
59 void IsoSurfaceExtractor::bbUserCopyConstructor()
64 void IsoSurfaceExtractor::bbUserDestructor()
66 marchingcubes->Delete();
67 polydatamapper->Delete();
71 void IsoSurfaceExtractor::Init()
76 // bbSetInputInVtkObject(NULL);
77 bbSetInputRenderer(NULL);
78 bbSetInputIsovalue(400);
81 marchingcubes = vtkMarchingCubes::New();
82 polydatamapper = vtkPolyDataMapper::New();
83 vtkactor = vtkActor::New();
85 polydatamapper->SetInput(marchingcubes->GetOutput());
86 vtkactor->SetMapper(polydatamapper);
88 polydatamapper->ScalarVisibilityOff();
89 polydatamapper->ImmediateModeRenderingOn();
92 //---------------------------------------------------------------------
94 void IsoSurfaceExtractor::DoProcess()
96 // bbGetInputIn()->Print(std::cout);
97 // Visualisation - result volume
98 marchingcubes->SetInput( bbGetInputIn() );
99 marchingcubes->SetValue(0, bbGetInputIsovalue() );
100 marchingcubes->Update();
102 vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
103 bbGetInputColour()[1],
104 bbGetInputColour()[2] );
107 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
109 if ( bbGetInputTransform()!=NULL )
111 vtkactor->SetUserTransform( bbGetInputTransform() );
114 bbSetOutputOut( vtkactor );
117 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
120 bbGetInputRenderer()->AddActor( vtkactor );
123 } // EO namespace bbtk