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 //------------------------------------------------------------------------------
39 vtkVectorsVisu::vtkVectorsVisu()
40 :vtkVectorsTensorsVisuBase()
42 _vtkarrowsource = vtkArrowSource::New();
44 _vtklinesource = vtkLineSource ::New();
45 _trans = vtkTransform ::New();
55 _vtklinesource->SetPoint1( point1 );
56 _vtklinesource->SetPoint2( point2 );
59 //------------------------------------------------------------------------------
60 vtkVectorsVisu::~vtkVectorsVisu()
65 //------------------------------------------------------------------------------
66 void vtkVectorsVisu::Process()
72 if (GetOrientation()==-1)
74 _vtkglyph = vtkGlyph3D::New();
76 if ((GetOrientation()>=0) && (GetOrientation()<=2))
78 _vtkglyph = vtkGlyph3D::New();
79 // _vtkglyph = vtkGlyph2D::New();
84 #if VTK_MAJOR_VERSION <= 5
85 _vtkglyph->SetInput( GetDataObject() );
87 _vtkglyph->SetInputData( GetDataObject() );
89 if(GetTypeForm()==1) // source Arrow
91 #if VTK_MAJOR_VERSION <= 5
92 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
94 _vtkarrowsource->Update();
95 _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
97 } else { // source Line
98 #if VTK_MAJOR_VERSION <= 5
99 _vtkglyph->SetSource( _vtklinesource->GetOutput() );
101 _vtklinesource->Update();
102 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );
105 _vtkglyph->SetScaleModeToScaleByVector();
108 if (_externalLut==NULL)
110 _vtkglyph->SetColorModeToColorByVector();
112 _vtkglyph->SetColorModeToColorByScalar();
115 _vtkglyph->SetScaleFactor( GetScaleFactor() );
118 #if VTK_MAJOR_VERSION <= 5
119 _pdm->SetInput( _vtkglyph->GetOutput());
121 _pdm->SetInputData( _vtkglyph->GetOutput());
124 vtkPointData *data = _vtkglyph->GetOutput()->GetPointData();
125 //printf("EED -------------------------------------------\n");
126 //_vtkglyph->GetOutput()->Print(std::cout);
127 //printf("EED -------------------------------------------\n");
128 //data->Print(std::cout);
129 //int i,sizeDa = data->GetNumberOfArrays();
130 //for (i=0;i<sizeDa;i++)
132 // data->GetArray(i)->Print(std::cout);
136 if (_externalLut==NULL)
138 printf("EED vtkVectorsVisu::Process LutEED \n");
139 _pdm->ScalarVisibilityOn();
140 _pdm->SetColorModeToMapScalars();
141 // _pdm->SetColorModeToDefault();
142 // _pdm->SetColorModeToDirectScalars(); // NOT compile
143 _pdm->SetScalarModeToUsePointFieldData();
144 // _pdm->ImmediateModeRenderingOn(); // obsolete
145 _LutEED->SetVectorModeToComponent();
146 //_LutEED->SetVectorModeToRGBColors();
147 //_LutEED->SetVectorModeToMagnitud();
148 // _pdm->SetScalarModeToUsePointFieldData();
149 _pdm->SetLookupTable( _LutEED );
150 _pdm->SelectColorArray( "GlyphVector" );
152 printf("EED vtkVectorsVisu::Process ExternalLut \n");
153 data->SetActiveScalars("angle");
158 _pdm->ScalarVisibilityOn();
159 double scalarRange[2];
162 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
163 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
164 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
165 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
166 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
167 _pdm->SetScalarRange(scalarRange);
168 _pdm->SetColorModeToMapScalars();
169 // _pdm->SetColorModeToDefault();
170 // _pdm->SetColorModeToDirectScalars(); // NOT compile
171 // _pdm->SetScalarModeToUsePointFieldData();
172 _pdm->ImmediateModeRenderingOn(); // obsolete
173 _pdm->SetLookupTable( _externalLut );
174 _pdm->SelectColorArray( "angle" );
179 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
180 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
181 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
182 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
183 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
186 vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
187 int i,size=pointdata->GetNumberOfArrays();
190 vtkDataArray *array=pointdata->GetArray(i);
191 printf(" vtkVectorsVisu::Process array name %d:<%s> size:%d\n", i, array->GetName(), array->GetSize() );
196 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
197 // vSliceMapperVec->SetColorModeToMapScalars();
199 #if VTK_MAJOR_VERSION <= 5
205 // Orientation -1 3D OK
207 // Orientation 0 2D yz
208 if (GetOrientation()==0)
211 _trans->Translate(900,0,0);
212 _actor->SetUserTransform(_trans);
216 // Orientation 1 2D xz
217 if (GetOrientation()==1)
220 _trans->Translate(0,-900,0);
221 _actor->SetUserTransform(_trans);
224 // Orientation 2 2D xy
225 if (GetOrientation()==2)
228 _trans->Translate(0,0,-900);
229 _actor->SetUserTransform(_trans);
232 _actor->SetMapper( _pdm );
233 _actor->GetProperty()->SetOpacity( GetOpacity() );