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()
70 if (GetOrientation()==-1)
72 _vtkglyph = vtkGlyph3D::New();
74 if ((GetOrientation()>=0) && (GetOrientation()<=2))
76 _vtkglyph = vtkGlyph3D::New();
77 // _vtkglyph = vtkGlyph2D::New();
85 if (GetDataObject()!=NULL)
87 #if VTK_MAJOR_VERSION <= 5
88 _vtkglyph->SetInput( GetDataObject() );
90 _vtkglyph->SetInputData( GetDataObject() );
92 if(GetTypeForm()==1) // source Arrow
94 #if VTK_MAJOR_VERSION <= 5
95 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
97 _vtkarrowsource->Update();
98 _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
100 } else { // source Line
101 #if VTK_MAJOR_VERSION <= 5
102 _vtkglyph->SetSource( _vtklinesource->GetOutput() );
104 _vtklinesource->Update();
105 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );
108 _vtkglyph->SetScaleModeToScaleByVector();
111 if (_externalLut==NULL)
113 _vtkglyph->SetColorModeToColorByVector();
115 _vtkglyph->SetColorModeToColorByScalar();
118 _vtkglyph->SetScaleFactor( GetScaleFactor() );
121 #if VTK_MAJOR_VERSION <= 5
122 _pdm->SetInput( _vtkglyph->GetOutput());
124 _pdm->SetInputData( _vtkglyph->GetOutput());
127 vtkPointData *data = _vtkglyph->GetOutput()->GetPointData();
128 //printf("EED -------------------------------------------\n");
129 //_vtkglyph->GetOutput()->Print(std::cout);
130 //printf("EED -------------------------------------------\n");
131 //data->Print(std::cout);
132 //int i,sizeDa = data->GetNumberOfArrays();
133 //for (i=0;i<sizeDa;i++)
135 // data->GetArray(i)->Print(std::cout);
138 if (_externalLut==NULL)
140 _pdm->ScalarVisibilityOn();
141 _pdm->SetColorModeToMapScalars();
142 // _pdm->SetColorModeToDefault();
143 // _pdm->SetColorModeToDirectScalars(); // NOT compile
144 _pdm->SetScalarModeToUsePointFieldData();
145 // _pdm->ImmediateModeRenderingOn(); // obsolete
146 _LutEED->SetVectorModeToComponent();
147 //_LutEED->SetVectorModeToRGBColors();
148 //_LutEED->SetVectorModeToMagnitud();
149 // _pdm->SetScalarModeToUsePointFieldData();
150 _pdm->SetLookupTable( _LutEED );
151 _pdm->SelectColorArray( "GlyphVector" );
153 data->SetActiveScalars("angle");
155 _pdm->ScalarVisibilityOn();
156 double scalarRange[2];
159 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
160 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
161 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
162 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
163 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
164 _pdm->SetScalarRange(scalarRange);
165 _pdm->SetColorModeToMapScalars();
166 // _pdm->SetColorModeToDefault();
167 // _pdm->SetColorModeToDirectScalars(); // NOT compile
168 // _pdm->SetScalarModeToUsePointFieldData();
169 _pdm->ImmediateModeRenderingOn(); // obsolete
170 _pdm->SetLookupTable( _externalLut );
171 _pdm->SelectColorArray( "angle" );
174 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
175 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
176 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
177 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
178 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
182 vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
183 int i,size=pointdata->GetNumberOfArrays();
186 vtkDataArray *array=pointdata->GetArray(i);
187 printf(" vtkVectorsVisu::Process array name %d:<%s> size:%d\n", i, array->GetName(), array->GetSize() );
192 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
193 // vSliceMapperVec->SetColorModeToMapScalars();
195 #if VTK_MAJOR_VERSION <= 5
201 // Orientation -1 3D OK
203 // Orientation 0 2D yz
204 if (GetOrientation()==0)
207 _trans->Translate(900,0,0);
208 _actor->SetUserTransform(_trans);
210 // Orientation 1 2D xz
211 if (GetOrientation()==1)
214 _trans->Translate(0,-900,0);
215 _actor->SetUserTransform(_trans);
217 // Orientation 2 2D xy
218 if (GetOrientation()==2)
221 _trans->Translate(0,0,-900);
222 _actor->SetUserTransform(_trans);
225 _actor->SetMapper( _pdm );
226 _actor->GetProperty()->SetOpacity( GetOpacity() );
228 printf("EED Warnning! vtkVectorsVisu::Process GetDataObject() is EMPTY\n");
229 }// if GetDataObject()!=NULL
232 _vtkglyph->SetInputData( NULL );