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"
36 //------------------------------------------------------------------------------
37 vtkVectorsVisu::vtkVectorsVisu()
38 :vtkVectorsTensorsVisuBase()
40 _vtkarrowsource = vtkArrowSource::New();
42 _vtklinesource = vtkLineSource ::New();
43 _trans = vtkTransform ::New();
53 _vtklinesource->SetPoint1( point1 );
54 _vtklinesource->SetPoint2( point2 );
57 //------------------------------------------------------------------------------
58 vtkVectorsVisu::~vtkVectorsVisu()
63 //------------------------------------------------------------------------------
64 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();
82 #if VTK_MAJOR_VERSION <= 5
83 _vtkglyph->SetInput( GetDataObject() );
85 _vtkglyph->SetInputData( GetDataObject() );
87 if(GetTypeForm()==1) // source Arrow
89 #if VTK_MAJOR_VERSION <= 5
90 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
92 _vtkarrowsource->Update();
93 _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
95 } else { // source Line
96 #if VTK_MAJOR_VERSION <= 5
97 _vtkglyph->SetSource( _vtklinesource->GetOutput() );
99 _vtklinesource->Update();
100 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );
103 _vtkglyph->SetScaleModeToScaleByVector();
104 _vtkglyph->SetColorModeToColorByVector();
105 _vtkglyph->SetScaleFactor( GetScaleFactor() );
108 #if VTK_MAJOR_VERSION <= 5
109 _pdm->SetInput( _vtkglyph->GetOutput());
111 _pdm->SetInputData( _vtkglyph->GetOutput());
114 vtkPointData *data = _vtkglyph->GetOutput()->GetPointData();
115 //printf("EED -------------------------------------------\n");
116 //_vtkglyph->GetOutput()->Print(std::cout);
117 //printf("EED -------------------------------------------\n");
118 //data->Print(std::cout);
119 //int i,sizeDa = data->GetNumberOfArrays();
120 //for (i=0;i<sizeDa;i++)
122 // data->GetArray(i)->Print(std::cout);
125 _pdm->ScalarVisibilityOn();
126 _pdm->SetColorModeToMapScalars();
127 //_pdm->SetColorModeToDefault();
128 // _pdm->SetColorModeToDirectScalars(); // NOT compile
129 _pdm->SetScalarModeToUsePointFieldData();
130 _pdm->ImmediateModeRenderingOn();
132 _LutEED->SetVectorModeToComponent();
133 //_LutEED->SetVectorModeToRGBColors();
134 //_LutEED->SetVectorModeToMagnitud();
136 // _pdm->SetScalarModeToUsePointFieldData();
137 _pdm->SetLookupTable( _LutEED );
138 _pdm->SelectColorArray( "GlyphVector" );
140 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
141 // vSliceMapperVec->SetColorModeToMapScalars();
143 #if VTK_MAJOR_VERSION <= 5
149 // Orientation -1 3D OK
151 // Orientation 0 2D yz
152 if (GetOrientation()==0)
155 _trans->Translate(900,0,0);
156 _actor->SetUserTransform(_trans);
160 // Orientation 1 2D xz
161 if (GetOrientation()==1)
164 _trans->Translate(0,-900,0);
165 _actor->SetUserTransform(_trans);
168 // Orientation 2 2D xy
169 if (GetOrientation()==2)
172 _trans->Translate(0,0,-900);
173 _actor->SetUserTransform(_trans);
176 _actor->SetMapper( _pdm );
177 _actor->GetProperty()->SetOpacity( GetOpacity() );