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 /*=========================================================================
30 Module: $RCSfile: bbvtkPolyDataToActor.cxx,v $
32 Date: $Date: 2009/05/28 08:55:44 $
33 Version: $Revision: 1.15 $
34 =========================================================================*/
44 #include "vtkProperty.h"
45 #include "vtkLinearTransform.h"
46 #include "vtkCleanPolyData.h"
47 #include "vtkFieldData.h"
49 #include "bbvtkPolyDataToActor.h"
50 #include "bbvtkPackage.h"
52 #include "vtkRenderWindow.h"
56 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
57 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToActor,bbtk::AtomicBlackBox);
59 void PolyDataToActor::bbUserSetDefaultValues()
62 std::vector<double> colour;
63 colour.push_back(1.0);
64 colour.push_back(1.0);
65 colour.push_back(0.5);
66 bbSetInputColour(colour);
67 bbSetInputActive(true);
69 bbSetInputRenderer(NULL);
70 bbSetInputTransform(NULL);
72 bbSetInputRepresentation(2);
73 bbSetInputLineWidth(1);
74 bbSetInputScalarVisibility(false);
75 polydatamapper = NULL;
78 bbSetInputScalarVisibilityOn_LookupTable(NULL);
79 bbSetInputScalarVisibilityOn_NameColorArray("");
84 //---------------------------------------------------------------------
85 void PolyDataToActor::bbUserInitializeProcessing()
87 polydatamapper = vtkPolyDataMapper::New();
88 vtkactor = vtkActor::New();
89 // polydatamapper->SetInput(marchingcubes->GetOutput());
90 vtkactor->SetMapper(polydatamapper);
92 //EED 2020-04-21 vtk8 deprecated
93 // polydatamapper->ImmediateModeRenderingOn();
96 //---------------------------------------------------------------------
97 void PolyDataToActor::bbUserFinalizeProcessing()
99 if (polydatamapper!=NULL)
101 polydatamapper->Delete();
116 -----------------------------------------------
118 https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ScalarBarActor
119 https://vtk.org/Wiki/VTK/Examples/Cxx/VisualizationAlgorithms/TubesFromSplines
120 https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ElevationBandsWithGlyphs
122 vtkSmartPointer<vtkFloatArray> scalars = vtkSmartPointer<vtkFloatArray>::New();
123 scalars set value ....
124 poly->GetPointData()->SetScalars(scalars); or poly->GetPointData()->SetActiveScalars("<NameArray>");
126 vtkSmartPointer<vtkLookupTable> hueLut = vtkSmartPoint | ^~
127 er<vtkLookupTable>::New();
130 mapper->SetInputData(poly);
131 mapper->ScalarVisibilityOn();
132 mapper->SetScalarModeToUsePointData(); Point of Cell ...
134 default: mapper->SetColorModeToDirectScalars() Busca scalars 3 componentes [R,G,B] float 0..1 or integer 0..255
136 mapper->SetColorModeToMapScalars() El vector scalar solo tiene un componente
137 mapper->SetLookupTable( hueLut );
140 mapper->SelectColorArray("<NameVector>");
142 mapper->SetUseLookupTableScalarRange( true/false ) true:Para compartir lookuptable con otros mappers
144 mapper->SetScalarRange( min, max); Range especifico este mapper
145 mapper->SetScalarRange( tubePolyData->GetScalarRange() );
147 ------------------------------------------
149 mapper->ScalarVisibilityOff(); -> SetScalarModeToDefault()
150 Utiliza el color del actor
152 ----------------------------------------
157 //---------------------------------------------------------------------
159 void PolyDataToActor::DoProcess()
161 bool ok_removeActor=false;
162 if (bbGetInputRenderer()==NULL)
164 printf("EED Warnning! PolyDataToActor::DoProcess missing Renderer.\n");
166 if (bbGetInputActive()==true)
168 if (bbGetInputIn()!=NULL)
170 //EED 2017-01-01 Migration VTK7
171 #if VTK_MAJOR_VERSION <= 5
172 polydatamapper->SetInput( bbGetInputIn() );
174 polydatamapper->SetInputData( bbGetInputIn() );
176 vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
177 if (bbGetInputRepresentation()==0)
179 vtkactor->GetProperty()->SetAmbient(1);
180 vtkactor->GetProperty()->SetDiffuse(1);
181 vtkactor->GetProperty()->SetSpecular(0);
182 printf("EED WARNNING! PolyDataToActor::DoProcess which is the default values of Ambient, Diffuse, Specular for points option? \n");
183 } else if (bbGetInputRepresentation()==1)
185 vtkactor->GetProperty()->SetAmbient(1);
186 vtkactor->GetProperty()->SetDiffuse(1);
187 vtkactor->GetProperty()->SetSpecular(0);
188 } else if (bbGetInputRepresentation()==2)
190 vtkactor->GetProperty()->SetAmbient(0);
191 vtkactor->GetProperty()->SetDiffuse(1);
192 vtkactor->GetProperty()->SetSpecular(0);
194 vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
195 vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
196 bbGetInputColour()[1],
197 bbGetInputColour()[2] );
198 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
199 if ( bbGetInputTransform()!=NULL )
201 vtkactor->SetUserTransform( bbGetInputTransform() );
203 bbSetOutputOut( vtkactor );
205 if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
208 bbGetInputRenderer()->AddActor( vtkactor );
210 if (bbGetInputScalarVisibility()==true )
212 polydatamapper->ScalarVisibilityOn();
213 if (bbGetInputScalarVisibilityOn_LookupTable()!=NULL)
215 // polydatamapper->SetScalarModeToDefault();
216 // polydatamapper->SetScalarModeToUseCellData();
217 // polydatamapper->SetScalarModeToUseCellFieldData();
218 // polydatamapper->SetScalarModeToUseFieldData(); // 1/2 hausdorff->SetTargetDistanceMethodToPointToCell();
219 // polydatamapper->SetScalarModeToUsePointData(); // *
220 polydatamapper->SetScalarModeToUsePointFieldData();
221 polydatamapper->SetColorModeToMapScalars();
222 polydatamapper->SetLookupTable( bbGetInputScalarVisibilityOn_LookupTable() );
223 if (bbGetInputScalarVisibilityOn_NameColorArray()!="")
225 polydatamapper->SelectColorArray( bbGetInputScalarVisibilityOn_NameColorArray().c_str() );
227 if (bbGetInputScalarVisibilityOn_ScalarRange().size()==2)
229 polydatamapper->SetScalarRange( bbGetInputScalarVisibilityOn_ScalarRange()[0] , bbGetInputScalarVisibilityOn_ScalarRange()[1] );
231 } // if ScalarVisibilityOn_LookupTable
233 polydatamapper->ScalarVisibilityOff();
234 } // ScalarVisibility
237 printf("EED Warnning! PolyDataToActor::DoProcess In (PolyData) not defined. \n" );
243 if (ok_removeActor==true)
246 if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
249 bbGetInputRenderer()->RemoveActor( vtkactor );
251 } // if ok_removeActor
255 } // EO namespace bbtk