1 /*=========================================================================
3 Module: $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
5 Date: $Date: 2009/05/14 15:40:12 $
6 Version: $Revision: 1.13 $
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"
40 #include "vtkLinearTransform.h"
42 #include "bbvtkIsoSurfaceExtractor.h"
43 #include "bbvtkPackage.h"
47 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
48 BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
50 void IsoSurfaceExtractor::bbUserConstructor()
52 printf("EED %p IsoSurfaceExtractor::bbUserConstructor \n", this);
54 std::vector<double> colour;
55 colour.push_back(1.0);
56 colour.push_back(1.0);
57 colour.push_back(0.5);
58 bbSetInputColour(colour);
60 void IsoSurfaceExtractor::bbUserCopyConstructor(bbtk::BlackBox::Pointer from)
65 void IsoSurfaceExtractor::bbUserDestructor()
67 marchingcubes->Delete();
68 polydatamapper->Delete();
72 void IsoSurfaceExtractor::Init()
77 // bbSetInputInVtkObject(NULL);
78 bbSetInputRenderer(NULL);
79 bbSetInputTransform(NULL);
80 bbSetInputIsovalue(400);
83 marchingcubes = vtkMarchingCubes::New();
84 polydatamapper = vtkPolyDataMapper::New();
85 vtkactor = vtkActor::New();
87 polydatamapper->SetInput(marchingcubes->GetOutput());
88 vtkactor->SetMapper(polydatamapper);
90 polydatamapper->ScalarVisibilityOff();
91 polydatamapper->ImmediateModeRenderingOn();
94 //---------------------------------------------------------------------
96 void IsoSurfaceExtractor::DoProcess()
98 printf("EED %p IsoSurfaceExtractor::DoProcess \n", this);
99 marchingcubes->SetInput( bbGetInputIn() );
100 marchingcubes->SetValue(0, bbGetInputIsovalue() );
101 marchingcubes->Update();
103 vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
104 bbGetInputColour()[1],
105 bbGetInputColour()[2] );
108 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
110 if ( bbGetInputTransform()!=NULL )
112 vtkactor->SetUserTransform( bbGetInputTransform() );
115 bbSetOutputOut( vtkactor );
118 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
121 bbGetInputRenderer()->AddActor( vtkactor );
124 } // EO namespace bbtk