]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkVectorsVisu.cpp
3223 creaVtk Feature New Normal - vtk8itk4wx3-mingw64
[creaVtk.git] / lib / creaVtk / vtkVectorsVisu.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sante)
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
9 #
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.
16 #
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
21 #  liability.
22 #
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 # ------------------------------------------------------------------------
26 */
27
28 #include "vtkVectorsVisu.h"
29
30 #include "vtkProperty.h"
31
32 //Borrame
33 #include "vtkPointData.h"
34
35
36 //------------------------------------------------------------------------------
37 vtkVectorsVisu::vtkVectorsVisu()
38   :vtkVectorsTensorsVisuBase()
39 {
40         _vtkarrowsource         = vtkArrowSource::New();
41         _vtkglyph                       = vtkGlyph3D::New();
42         _vtklinesource          = vtkLineSource::New();
43
44         double point1[3];
45         double point2[3];
46         point1[0]=1;
47         point1[1]=0;
48         point1[2]=0;
49         point2[0]=-1;
50         point2[1]=0;
51         point2[2]=0;
52         _vtklinesource->SetPoint1( point1 );
53         _vtklinesource->SetPoint2( point2 );
54 }
55
56 //------------------------------------------------------------------------------
57 vtkVectorsVisu::~vtkVectorsVisu()
58 {
59 }
60
61
62 //------------------------------------------------------------------------------
63 void vtkVectorsVisu::Process()
64 {
65      if(_active==true)
66      {
67 #if VTK_MAJOR_VERSION <= 5
68          _vtkglyph->SetInput( GetDataObject() );  
69 #else
70          _vtkglyph->SetInputData( GetDataObject() );  
71 #endif
72                         if(GetTypeForm()==1)                                                            // source Arrow
73                         {
74 #if VTK_MAJOR_VERSION <= 5
75                         _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
76 #else
77                                 _vtkarrowsource->Update();
78                         _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
79 #endif
80                         } else {                                                                                                // source Line
81 #if VTK_MAJOR_VERSION <= 5
82                                 _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
83 #else
84                                 _vtklinesource->Update();
85                                 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
86 #endif
87                         }
88          _vtkglyph->SetScaleModeToScaleByVector();
89          _vtkglyph->SetColorModeToColorByVector();
90          _vtkglyph->SetScaleFactor( GetScaleFactor() );
91                 _vtkglyph->Update();
92
93 #if VTK_MAJOR_VERSION <= 5
94          _pdm->SetInput( _vtkglyph->GetOutput());
95 #else
96          _pdm->SetInputData( _vtkglyph->GetOutput());
97 #endif
98
99 vtkPointData    *data   = _vtkglyph->GetOutput()->GetPointData();
100 //printf("EED -------------------------------------------\n");
101 //_vtkglyph->GetOutput()->Print(std::cout);
102 //printf("EED -------------------------------------------\n");
103 //data->Print(std::cout);
104 int i,sizeDa = data->GetNumberOfArrays();
105 for (i=0;i<sizeDa;i++)
106 {
107         data->GetArray(i)->Print(std::cout);
108 }
109
110         _pdm->ScalarVisibilityOn();
111         _pdm->SetColorModeToMapScalars();
112         //_pdm->SetColorModeToDefault();
113         // _pdm->SetColorModeToDirectScalars();  // NOT compile
114         _pdm->SetScalarModeToUsePointFieldData();
115         _pdm->ImmediateModeRenderingOn();
116
117         _LutEED->SetVectorModeToComponent();
118         //_LutEED->SetVectorModeToRGBColors();
119         //_LutEED->SetVectorModeToMagnitud();
120
121 //         _pdm->SetScalarModeToUsePointFieldData();
122          _pdm->SetLookupTable( _LutEED );
123          _pdm->SelectColorArray( "GlyphVector" );
124
125 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
126 //       vSliceMapperVec->SetColorModeToMapScalars();
127
128 #if VTK_MAJOR_VERSION <= 5
129                 // ..
130 #else
131          _pdm->Update();
132 #endif
133          _actor->SetMapper( _pdm );
134          _actor->GetProperty()->SetOpacity( GetOpacity() );
135     }// if _active
136
137     VisibilityActor(); 
138 }
139