]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkTensorsVisu.cpp
046b0a5bbd5c35bf1bf1342175c7b54da34b7d7b
[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         superquadratic  = vtkSuperquadricSource::New();
37         cs                                      = vtkCubeSource::New(); 
38         tg                                      = vtkTensorGlyph::New();
39         pdn                                     = vtkPolyDataNormals::New();
40         pd                                      = vtkPolyData::New();
41         pod                                     = vtkPointData::New();
42 }
43
44 //------------------------------------------------------------------------
45 vtkTensorsVisu::~vtkTensorsVisu()
46 {
47 }
48
49
50 //------------------------------------------------------------------------
51 void vtkTensorsVisu::Process()
52 {
53 printf("EED vtkTensorsVisu::Process Start\n");
54
55
56   if (_active==true)
57   {
58
59         if(GetTypeForm()==2)                                                            // source superquadratic
60         {
61                 superquadratic->SetThetaResolution(20);
62                 superquadratic->SetPhiResolution(20);
63                 tg->SetSource(superquadratic->GetOutput());
64         } else if(GetTypeForm()==1) {                                   // source sphere
65                 tg->SetSource(ss->GetOutput());
66         } else {                                                                                                // source cube
67                 tg->SetSource(cs->GetOutput());         
68         }
69
70
71         tg->SetInput( GetDataObject() );
72         //              tg->ScalingOn();
73         //              tg->SetScaling(25);
74         //if(isfromcal)
75         tg->SetScaleFactor( GetScaleFactor() );
76         tg->ScalingOn(  );      
77         //else
78         //      //tg->SetScaleFactor(2);
79         //      tg->SetScaleFactor(scale_factor);
80 //EED   tg->Update();
81
82         //The normals are needed to generate the right colors and if
83         // not used some of the glyphs are black.
84         pdn->SetInput(tg->GetOutput());
85 //EED   pdn->Update();
86
87
88         //EED================================
89         //pdm->SetInput( tg->GetOutput());
90         //pdm->SetScalarRange( range );
91
92         //vtkPolyData           *pd                     = tg->GetOutput();
93         //vtkPointData  *pointdata      = pd->GetPointData();
94         //vtkDataArray  *da                     = pointdata->GetVectors();
95
96         //vtkDataArray *nda = vtkFloatArray::New();
97         //nda->DeepCopy(da);
98
99         //pointdata->AddArray( nda );
100         //reader->GetOutput()->GetPointData()->AddArray( nda );
101
102         //pdm->SetInput(pdn->GetOutput());
103         //pdm->ScalarVisibilityOn();
104         //pdm->SetLookupTable(vLutEED);
105         //pdm->SetColorModeToMapScalars();
106         //pdm->SelectColorArray("color");
107         //pdm->SetScalarModeToUsePointFieldData();
108         //pdm->ImmediateModeRenderingOn();
109         //=====================================
110
111         _pdm->SetInput( pdn->GetOutput() );
112         _pdm->ImmediateModeRenderingOn();
113
114    _pdm->ScalarVisibilityOn();
115    _pdm->SetScalarModeToUsePointFieldData();
116
117
118 //EED   _pdm->Update();
119
120         _actor->SetMapper( _pdm );
121    _actor->GetProperty()->SetOpacity( GetOpacity() );
122
123         tg->ColorGlyphsOn();
124 //      tg->ExtractEigenvaluesOn();
125         tg->SetColorModeToEigenvalues();
126
127         _pdm->SetLookupTable( _LutEED );
128    _pdm->SelectColorArray( "Normals" );
129
130
131         //int tcg = tg->GetColorGlyphs();
132 //      tg->SetColorGlyphs(10);
133 //      tg->SetColorModeToScalars();
134         //tg->ThreeGlyphsOn();
135
136
137         //vtkDataArray* da = vtkDataArray::New();
138         pd = tg->GetOutput();
139         pd->Update();
140         pod = pd->GetPointData();
141         pod->Update();
142 //EED1  if(pod->GetScalars())
143 //EED1  {
144 //EED1          _pdm->SetScalarRange(pod->GetScalars()->GetRange());
145 //EED1  }
146         //pdm->SelectColorArray("GlyphVector");
147
148 //EED   _pdm->Update(); 
149
150
151
152                         tg->Print( std::cout );
153                 printf("EED vtkTensorsVisu::Process  ------------------------------------------\n");
154                         pd->Print( std::cout );
155
156
157         tg->Update();
158                         vtkPolyData     *pd             = pdn->GetOutput();
159                         vtkPointData    *pointdata      = pd->GetPointData();
160
161
162                 printf("EED vtkTensorsVisu::Process  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx\n");
163                         pointdata->Print( std::cout );
164                         
165
166                         int aa = pd->GetNumberOfPieces ();
167                         int bb = pd->GetNumberOfVerts ();
168                         int cc = pd->GetNumberOfLines ();
169                         int dd = pd->GetNumberOfPolys ();
170                         int ee = pd->GetNumberOfStrips ();
171                         int ff = pd->GetNumberOfCells();
172
173                 printf("EED vtkTensorsVisu::Process  %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
174
175                         vtkPolyData *ttt = (vtkPolyData *)GetDataObject();
176                         int numPnts = ttt->GetNumberOfPoints();
177                         printf("EED vtkTensorsVisu::Process  numPnts %d \n", numPnts );
178
179
180                         vtkIdType numSourcePts, numSourceCells;
181                         vtkPoints *sourcePts;
182                         sourcePts = tg->GetSource()->GetPoints();
183                         numSourcePts = sourcePts->GetNumberOfPoints();
184                         numSourceCells = tg->GetSource()->GetNumberOfCells();
185                         printf("EED vtkTensorsVisu::Process  numSourcePts %d   numSourceCells %d\n", numSourcePts, numSourceCells);
186
187
188
189                         int i,sizeDa = pointdata->GetNumberOfArrays();
190                         printf("EED vtkTensorsVisu::Process  sizeDa %d \n", sizeDa );
191                         for (i=0;i<sizeDa;i++)
192                         {
193                                 int faces = pointdata->GetArray(i)->GetSize() / numPnts;
194                                 printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d   %d \n", i, pointdata->GetArrayName(i) , pointdata->GetArray(i)->GetSize(), faces );
195                         }
196
197
198
199
200   } // _active
201
202     VisibilityActor(); 
203
204 printf("EED vtkTensorsVisu::Process End.\n");
205 }
206