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 = vtkGlyph2D::New();
81 #if VTK_MAJOR_VERSION <= 5
82 _vtkglyph->SetInput( GetDataObject() );
84 _vtkglyph->SetInputData( GetDataObject() );
86 if(GetTypeForm()==1) // source Arrow
88 #if VTK_MAJOR_VERSION <= 5
89 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
91 _vtkarrowsource->Update();
92 _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
94 } else { // source Line
95 #if VTK_MAJOR_VERSION <= 5
96 _vtkglyph->SetSource( _vtklinesource->GetOutput() );
98 _vtklinesource->Update();
99 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );
102 _vtkglyph->SetScaleModeToScaleByVector();
103 _vtkglyph->SetColorModeToColorByVector();
104 _vtkglyph->SetScaleFactor( GetScaleFactor() );
107 #if VTK_MAJOR_VERSION <= 5
108 _pdm->SetInput( _vtkglyph->GetOutput());
110 _pdm->SetInputData( _vtkglyph->GetOutput());
113 vtkPointData *data = _vtkglyph->GetOutput()->GetPointData();
114 //printf("EED -------------------------------------------\n");
115 //_vtkglyph->GetOutput()->Print(std::cout);
116 //printf("EED -------------------------------------------\n");
117 //data->Print(std::cout);
118 //int i,sizeDa = data->GetNumberOfArrays();
119 //for (i=0;i<sizeDa;i++)
121 // data->GetArray(i)->Print(std::cout);
124 _pdm->ScalarVisibilityOn();
125 _pdm->SetColorModeToMapScalars();
126 //_pdm->SetColorModeToDefault();
127 // _pdm->SetColorModeToDirectScalars(); // NOT compile
128 _pdm->SetScalarModeToUsePointFieldData();
129 _pdm->ImmediateModeRenderingOn();
131 _LutEED->SetVectorModeToComponent();
132 //_LutEED->SetVectorModeToRGBColors();
133 //_LutEED->SetVectorModeToMagnitud();
135 // _pdm->SetScalarModeToUsePointFieldData();
136 _pdm->SetLookupTable( _LutEED );
137 _pdm->SelectColorArray( "GlyphVector" );
139 // vSliceMapperVec->SetLookupTable( vGreenToRedLut );
140 // vSliceMapperVec->SetColorModeToMapScalars();
142 #if VTK_MAJOR_VERSION <= 5
148 // Orientation -1 3D OK
149 // Orientation 2 2D xy OK
151 // Orientation 0 2D yz
152 if (GetOrientation()==0)
155 _trans->Translate(900,0,0);
156 _trans->RotateWXYZ(-90,0,1,0);
157 _actor->SetUserTransform(_trans);
160 // Orientation 1 2D xz
161 if (GetOrientation()==1)
164 _trans->RotateWXYZ(90,1,0,0);
165 _actor->SetUserTransform(_trans);
168 _actor->SetMapper( _pdm );
169 _actor->GetProperty()->SetOpacity( GetOpacity() );