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 #include "vtkVectorsVisu.h"
30 #include "vtkProperty.h"
33 #include "vtkPointData.h"
34 #include "vtkArrayData.h"
35 #include "vtkDataObject.h"
36 #include <vtkPointData.h>
38 #include <vtkAppendPolyData.h>
40 //------------------------------------------------------------------------------
41 vtkVectorsVisu::vtkVectorsVisu()
42 :vtkVectorsTensorsVisuBase()
44 _vtkarrowsource = vtkArrowSource::New();
46 _vtklineGlyphPolyData = NULL;
47 _trans = vtkTransform ::New();
49 double sizeCross = 0.05;
60 vtkLineSource *vtklinesource1 = vtkLineSource ::New();
61 vtklinesource1->SetPoint1( point1 );
62 vtklinesource1->SetPoint2( point2 );
63 vtklinesource1->Update();
66 point1[1] = sizeCross;
69 point2[1] = -sizeCross;
71 vtkLineSource *vtklinesource2 = vtkLineSource ::New();
72 vtklinesource2->SetPoint1( point1 );
73 vtklinesource2->SetPoint2( point2 );
74 vtklinesource2->Update();
78 point1[2] = sizeCross;
81 point2[2] = -sizeCross;
82 vtkLineSource *vtklinesource3 = vtkLineSource ::New();
83 vtklinesource3->SetPoint1( point1 );
84 vtklinesource3->SetPoint2( point2 );
85 vtklinesource3->Update();
88 vtkAppendPolyData *appendPolyData = vtkAppendPolyData::New();
89 appendPolyData->AddInputData( vtklinesource1->GetOutput() );
90 appendPolyData->AddInputData( vtklinesource2->GetOutput() );
91 appendPolyData->AddInputData( vtklinesource3->GetOutput() );
92 appendPolyData->Update();
93 _vtklineGlyphPolyData = appendPolyData->GetOutput();
96 //------------------------------------------------------------------------------
97 vtkVectorsVisu::~vtkVectorsVisu()
102 //------------------------------------------------------------------------------
103 void vtkVectorsVisu::Process()
107 if (GetOrientation()==-1)
109 _vtkglyph = vtkGlyph3D::New();
111 if ((GetOrientation()>=0) && (GetOrientation()<=2))
113 _vtkglyph = vtkGlyph3D::New();
114 // _vtkglyph = vtkGlyph2D::New();
122 if (GetDataObject()!=NULL)
124 #if VTK_MAJOR_VERSION <= 5
125 _vtkglyph->SetInput( GetDataObject() );
127 _vtkglyph->SetInputData( GetDataObject() );
129 if(GetTypeForm()==1) // source Arrow
131 #if VTK_MAJOR_VERSION <= 5
132 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
134 _vtkarrowsource->Update();
135 _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
137 } else { // source Line
138 #if VTK_MAJOR_VERSION <= 5
139 _vtkglyph->SetSource( _vtklineGlyphPolyData );
141 _vtkglyph->SetSourceData( _vtklineGlyphPolyData );
144 _vtkglyph->SetScaleModeToScaleByVector();
147 if (_externalLut==NULL)
149 _vtkglyph->SetColorModeToColorByVector();
151 _vtkglyph->SetColorModeToColorByScalar();
154 _vtkglyph->SetScaleFactor( GetScaleFactor() );
157 #if VTK_MAJOR_VERSION <= 5
158 _pdm->SetInput( _vtkglyph->GetOutput());
160 _pdm->SetInputData( _vtkglyph->GetOutput());
163 vtkPointData *data = _vtkglyph->GetOutput()->GetPointData();
164 //printf("EED -------------------------------------------\n");
165 //_vtkglyph->GetOutput()->Print(std::cout);
166 //printf("EED -------------------------------------------\n");
167 //data->Print(std::cout);
168 //int i,sizeDa = data->GetNumberOfArrays();
169 //for (i=0;i<sizeDa;i++)
171 // data->GetArray(i)->Print(std::cout);
174 if (_externalLut==NULL)
176 _pdm->ScalarVisibilityOn();
177 _pdm->SetColorModeToMapScalars();
178 // _pdm->SetColorModeToDefault();
179 // _pdm->SetColorModeToDirectScalars(); // NOT compile
180 _pdm->SetScalarModeToUsePointFieldData();
181 // _pdm->ImmediateModeRenderingOn(); // obsolete
182 _LutEED->SetVectorModeToComponent();
183 //_LutEED->SetVectorModeToRGBColors();
184 //_LutEED->SetVectorModeToMagnitud();
185 // _pdm->SetScalarModeToUsePointFieldData();
186 _pdm->SetLookupTable( _LutEED );
187 _pdm->SelectColorArray( "GlyphVector" );
189 data->SetActiveScalars("angle");
191 _pdm->ScalarVisibilityOn();
192 double scalarRange[2];
195 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
196 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
197 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
198 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
199 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
200 _pdm->SetScalarRange(scalarRange);
201 _pdm->SetColorModeToMapScalars();
202 // _pdm->SetColorModeToDefault();
203 // _pdm->SetColorModeToDirectScalars(); // NOT compile
204 // _pdm->SetScalarModeToUsePointFieldData();
205 // _pdm->ImmediateModeRenderingOn(); // obsolete
206 _pdm->SetLookupTable( _externalLut );
207 _pdm->SelectColorArray( "angle" );
210 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
211 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
212 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
213 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
214 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
218 vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
219 int i,size=pointdata->GetNumberOfArrays();
222 vtkDataArray *array=pointdata->GetArray(i);
223 printf(" vtkVectorsVisu::Process array name %d:<%s> size:%d\n", i, array->GetName(), array->GetSize() );
228 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
229 // vSliceMapperVec->SetColorModeToMapScalars();
231 #if VTK_MAJOR_VERSION <= 5
237 // Orientation -1 3D OK
239 // Orientation 0 2D yz
240 if (GetOrientation()==0)
243 _trans->Translate(900,0,0);
244 _actor->SetUserTransform(_trans);
246 // Orientation 1 2D xz
247 if (GetOrientation()==1)
250 _trans->Translate(0,-900,0);
251 _actor->SetUserTransform(_trans);
253 // Orientation 2 2D xy
254 if (GetOrientation()==2)
257 _trans->Translate(0,0,-900);
258 _actor->SetUserTransform(_trans);
261 _actor->SetMapper( _pdm );
262 _actor->GetProperty()->SetOpacity( GetOpacity() );
264 printf("EED Warnning! vtkVectorsVisu::Process GetDataObject() is EMPTY\n");
265 }// if GetDataObject()!=NULL
267 _pdm->ScalarVisibilityOn();
268 _pdm->SetColorModeToMapScalars();
269 //_pdm->SetColorModeToDefault();
270 // _pdm->SetColorModeToDirectScalars(); // NOT compile
271 _pdm->SetScalarModeToUsePointFieldData();
273 //EED2021-09-03 Deprecated. Removed in vtk 8.1
274 // _pdm->ImmediateModeRenderingOn();
276 _LutEED->SetVectorModeToComponent();
277 //_LutEED->SetVectorModeToRGBColors();
278 //_LutEED->SetVectorModeToMagnitud();
280 // _pdm->SetScalarModeToUsePointFieldData();
281 _pdm->SetLookupTable( _LutEED );
282 _pdm->SelectColorArray( "GlyphVector" );
284 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
285 // vSliceMapperVec->SetColorModeToMapScalars();
287 #if VTK_MAJOR_VERSION <= 5
292 _actor->SetMapper( _pdm );
293 _actor->GetProperty()->SetOpacity( GetOpacity() );
295 _vtkglyph->SetInputData( NULL );