]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkTensorsVisu.cpp
53f55174ca22e1b81b76a2a52bdaa8bae0bc21fe
[creaVtk.git] / lib / creaVtk / vtkTensorsVisu.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 "vtkTensorsVisu.h"
29
30 #include "vtkProperty.h"
31
32 //------------------------------------------------------------------------
33 vtkTensorsVisu::vtkTensorsVisu() : vtkVectorsTensorsVisuBase()
34 {
35         ss              = vtkSphereSource::New();
36         cs              = vtkCubeSource::New(); 
37         tg              = vtkTensorGlyph::New();
38         pdn             = vtkPolyDataNormals::New();
39         pd              = vtkPolyData::New();
40         pod             = vtkPointData::New();
41 }
42
43 //------------------------------------------------------------------------
44 vtkTensorsVisu::~vtkTensorsVisu()
45 {
46 }
47
48
49 //------------------------------------------------------------------------
50 void vtkTensorsVisu::Process()
51 {
52 printf("EED vtkTensorsVisu::Process Start\n");
53
54
55   if (_active==true){
56         std::string source="sphere";
57         if(source=="sphere")
58         {
59                 tg->SetSource(ss->GetOutput());
60         }
61         else if(source=="cube")
62         {
63                 tg->SetSource(ss->GetOutput());
64         }
65         else{}
66
67
68         tg->SetInput( GetDataObject() );
69         //              tg->ScalingOn();
70         //              tg->SetScaling(25);
71         //if(isfromcal)
72         tg->SetScaleFactor( GetScaleFactor() );
73         tg->ScalingOn(  );      
74         //else
75         //      //tg->SetScaleFactor(2);
76         //      tg->SetScaleFactor(scale_factor);
77 //EED   tg->Update();
78
79         //The normals are needed to generate the right colors and if
80         // not used some of the glyphs are black.
81         pdn->SetInput(tg->GetOutput());
82 //EED   pdn->Update();
83
84
85         //EED================================
86         //pdm->SetInput( tg->GetOutput());
87         //pdm->SetScalarRange( range );
88
89         //vtkPolyData           *pd                     = tg->GetOutput();
90         //vtkPointData  *pointdata      = pd->GetPointData();
91         //vtkDataArray  *da                     = pointdata->GetVectors();
92
93         //vtkDataArray *nda = vtkFloatArray::New();
94         //nda->DeepCopy(da);
95
96         //pointdata->AddArray( nda );
97         //reader->GetOutput()->GetPointData()->AddArray( nda );
98
99         //pdm->SetInput(pdn->GetOutput());
100         //pdm->ScalarVisibilityOn();
101         //pdm->SetLookupTable(vLutEED);
102         //pdm->SetColorModeToMapScalars();
103         //pdm->SelectColorArray("color");
104         //pdm->SetScalarModeToUsePointFieldData();
105         //pdm->ImmediateModeRenderingOn();
106         //=====================================
107
108         _pdm->SetInput( pdn->GetOutput() );
109         _pdm->ImmediateModeRenderingOn();
110
111          _pdm->ScalarVisibilityOn();
112          _pdm->SetScalarModeToUsePointFieldData();
113
114
115 //EED   _pdm->Update();
116
117         _actor->SetMapper( _pdm );
118         _actor->GetProperty()->SetOpacity( GetOpacity() );
119
120         tg->ColorGlyphsOn();
121         tg->ExtractEigenvaluesOn();
122         tg->SetColorModeToEigenvalues();
123
124          _pdm->SetLookupTable( _LutEED );
125          _pdm->SelectColorArray( "Normals" );
126
127
128         //int tcg = tg->GetColorGlyphs();
129 //      tg->SetColorGlyphs(10);
130         //tg->SetColorModeToScalars();
131         //tg->ThreeGlyphsOn();
132
133
134         //vtkDataArray* da = vtkDataArray::New();
135         pd = tg->GetOutput();
136         pd->Update();
137         pod = pd->GetPointData();
138         pod->Update();
139 //EED1  if(pod->GetScalars())
140 //EED1  {
141 //EED1          _pdm->SetScalarRange(pod->GetScalars()->GetRange());
142 //EED1  }
143         //pdm->SelectColorArray("GlyphVector");
144
145 //EED   _pdm->Update(); 
146
147
148
149         tg->Update();
150                         vtkPolyData     *pd             = pdn->GetOutput();
151                         vtkPointData    *pointdata      = pd->GetPointData();
152                         
153                         int i,sizeDa = pointdata->GetNumberOfArrays();
154                         printf("EED vtkTensorsVisu::Process  sizeDa %d \n", sizeDa );
155                         for (i=0;i<sizeDa;i++)
156                         {
157                                 printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d \n", i, pointdata->GetArrayName(i) , pointdata->GetArray(i)->GetSize() );
158                         }
159
160
161
162
163   } // _active
164
165     VisibilityActor(); 
166
167 printf("EED vtkTensorsVisu::Process End.\n");
168 }
169