]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkVectorsVisu.cpp
#3100 creaVtk Feature New Normal - Vectors Visu refresh
[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 //------------------------------------------------------------------------------
58 vtkVectorsVisu::~vtkVectorsVisu()
59 {
60 }
61
62 //------------------------------------------------------------------------------
63 void vtkVectorsVisu::Process()
64 {
65      if(_active==true)
66      {
67          _vtkglyph->SetInput( GetDataObject() );  
68                         if(GetTypeForm()==1)                                                            // source Arrow
69                         {
70                  _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
71                         } else {                                                                                                // source Line
72                                 _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
73                         }
74          _vtkglyph->SetScaleModeToScaleByVector();
75          _vtkglyph->SetColorModeToColorByVector();
76          _vtkglyph->SetScaleFactor( GetScaleFactor() );
77          _vtkglyph->Update();
78          _pdm->SetInput( _vtkglyph->GetOutput());
79 vtkPointData    *data   = _vtkglyph->GetOutput()->GetPointData();
80 //printf("EED -------------------------------------------\n");
81 //_vtkglyph->GetOutput()->Print(std::cout);
82 //printf("EED -------------------------------------------\n");
83 //data->Print(std::cout);
84 int i,sizeDa = data->GetNumberOfArrays();
85 for (i=0;i<sizeDa;i++)
86 {
87         data->GetArray(i)->Print(std::cout);
88 }
89
90         _pdm->ScalarVisibilityOn();
91         _pdm->SetColorModeToMapScalars();
92         //_pdm->SetColorModeToDefault();
93         // _pdm->SetColorModeToDirectScalars();  // NOT compile
94         _pdm->SetScalarModeToUsePointFieldData();
95         _pdm->ImmediateModeRenderingOn();
96
97         _LutEED->SetVectorModeToComponent();
98         //_LutEED->SetVectorModeToRGBColors();
99         //_LutEED->SetVectorModeToMagnitud();
100
101
102
103 //         _pdm->SetScalarModeToUsePointFieldData();
104          _pdm->SetLookupTable( _LutEED );
105          _pdm->SelectColorArray( "GlyphVector" );
106
107 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
108 //       vSliceMapperVec->SetColorModeToMapScalars();
109
110          _actor->SetMapper( _pdm );
111          _actor->GetProperty()->SetOpacity( GetOpacity() );
112     }// if _active
113
114     VisibilityActor(); 
115 }
116         
117
118
119
120
121