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 _pdm->ScalarVisibilityOn();
139 _pdm->SetColorModeToMapScalars();
140 // _pdm->SetColorModeToDefault();
141 // _pdm->SetColorModeToDirectScalars(); // NOT compile
142 _pdm->SetScalarModeToUsePointFieldData();
143 // _pdm->ImmediateModeRenderingOn(); // obsolete
144 _LutEED->SetVectorModeToComponent();
145 //_LutEED->SetVectorModeToRGBColors();
146 //_LutEED->SetVectorModeToMagnitud();
147 // _pdm->SetScalarModeToUsePointFieldData();
148 _pdm->SetLookupTable( _LutEED );
149 _pdm->SelectColorArray( "GlyphVector" );
151 data->SetActiveScalars("angle");
153 _pdm->ScalarVisibilityOn();
154 double scalarRange[2];
157 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
158 printf("EED warnnning ..... vtkVectorsVisu::Process clean scalar Range ......\n");
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 _pdm->SetScalarRange(scalarRange);
163 _pdm->SetColorModeToMapScalars();
164 // _pdm->SetColorModeToDefault();
165 // _pdm->SetColorModeToDirectScalars(); // NOT compile
166 // _pdm->SetScalarModeToUsePointFieldData();
167 _pdm->ImmediateModeRenderingOn(); // obsolete
168 _pdm->SetLookupTable( _externalLut );
169 _pdm->SelectColorArray( "angle" );
172 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
173 printf("EED warnnning ..... vtkVectorsVisu::Process Clean angle ......\n");
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");
180 vtkPointData *pointdata=_vtkglyph->GetOutput()->GetPointData();
181 int i,size=pointdata->GetNumberOfArrays();
184 vtkDataArray *array=pointdata->GetArray(i);
185 printf(" vtkVectorsVisu::Process array name %d:<%s> size:%d\n", i, array->GetName(), array->GetSize() );
190 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
191 // vSliceMapperVec->SetColorModeToMapScalars();
193 #if VTK_MAJOR_VERSION <= 5
199 // Orientation -1 3D OK
201 // Orientation 0 2D yz
202 if (GetOrientation()==0)
205 _trans->Translate(900,0,0);
206 _actor->SetUserTransform(_trans);
210 // Orientation 1 2D xz
211 if (GetOrientation()==1)
214 _trans->Translate(0,-900,0);
215 _actor->SetUserTransform(_trans);
218 // Orientation 2 2D xy
219 if (GetOrientation()==2)
222 _trans->Translate(0,0,-900);
223 _actor->SetUserTransform(_trans);
226 _actor->SetMapper( _pdm );
227 _actor->GetProperty()->SetOpacity( GetOpacity() );