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 "vtkTensorsVisu.h"
30 #include "vtkProperty.h"
32 //------------------------------------------------------------------------
33 vtkTensorsVisu::vtkTensorsVisu() : vtkVectorsTensorsVisuBase()
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();
44 //------------------------------------------------------------------------
45 vtkTensorsVisu::~vtkTensorsVisu()
50 //------------------------------------------------------------------------
51 void vtkTensorsVisu::Process()
53 printf("EED vtkTensorsVisu::Process Start\n");
57 // std::string source="sphere";
58 std::string source="superquadratic";
61 tg->SetSource(ss->GetOutput());
62 } else if(source=="cube") {
63 tg->SetSource(cs->GetOutput());
64 }else if(source=="superquadratic") {
65 superquadratic->SetThetaResolution(20);
66 superquadratic->SetPhiResolution(20);
67 tg->SetSource(superquadratic->GetOutput());
72 tg->SetInput( GetDataObject() );
74 // tg->SetScaling(25);
76 tg->SetScaleFactor( GetScaleFactor() );
79 // //tg->SetScaleFactor(2);
80 // tg->SetScaleFactor(scale_factor);
83 //The normals are needed to generate the right colors and if
84 // not used some of the glyphs are black.
85 pdn->SetInput(tg->GetOutput());
89 //EED================================
90 //pdm->SetInput( tg->GetOutput());
91 //pdm->SetScalarRange( range );
93 //vtkPolyData *pd = tg->GetOutput();
94 //vtkPointData *pointdata = pd->GetPointData();
95 //vtkDataArray *da = pointdata->GetVectors();
97 //vtkDataArray *nda = vtkFloatArray::New();
100 //pointdata->AddArray( nda );
101 //reader->GetOutput()->GetPointData()->AddArray( nda );
103 //pdm->SetInput(pdn->GetOutput());
104 //pdm->ScalarVisibilityOn();
105 //pdm->SetLookupTable(vLutEED);
106 //pdm->SetColorModeToMapScalars();
107 //pdm->SelectColorArray("color");
108 //pdm->SetScalarModeToUsePointFieldData();
109 //pdm->ImmediateModeRenderingOn();
110 //=====================================
112 _pdm->SetInput( pdn->GetOutput() );
113 _pdm->ImmediateModeRenderingOn();
115 _pdm->ScalarVisibilityOn();
116 _pdm->SetScalarModeToUsePointFieldData();
119 //EED _pdm->Update();
121 _actor->SetMapper( _pdm );
122 _actor->GetProperty()->SetOpacity( GetOpacity() );
125 // tg->ExtractEigenvaluesOn();
126 tg->SetColorModeToEigenvalues();
128 _pdm->SetLookupTable( _LutEED );
129 _pdm->SelectColorArray( "Normals" );
132 //int tcg = tg->GetColorGlyphs();
133 // tg->SetColorGlyphs(10);
134 // tg->SetColorModeToScalars();
135 //tg->ThreeGlyphsOn();
138 //vtkDataArray* da = vtkDataArray::New();
139 pd = tg->GetOutput();
141 pod = pd->GetPointData();
143 //EED1 if(pod->GetScalars())
145 //EED1 _pdm->SetScalarRange(pod->GetScalars()->GetRange());
147 //pdm->SelectColorArray("GlyphVector");
149 //EED _pdm->Update();
153 tg->Print( std::cout );
154 printf("EED vtkTensorsVisu::Process ------------------------------------------\n");
155 pd->Print( std::cout );
159 vtkPolyData *pd = pdn->GetOutput();
160 vtkPointData *pointdata = pd->GetPointData();
163 printf("EED vtkTensorsVisu::Process XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx\n");
164 pointdata->Print( std::cout );
167 int aa = pd->GetNumberOfPieces ();
168 int bb = pd->GetNumberOfVerts ();
169 int cc = pd->GetNumberOfLines ();
170 int dd = pd->GetNumberOfPolys ();
171 int ee = pd->GetNumberOfStrips ();
172 int ff = pd->GetNumberOfCells();
174 printf("EED vtkTensorsVisu::Process %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
176 vtkPolyData *ttt = (vtkPolyData *)GetDataObject();
177 int numPnts = ttt->GetNumberOfPoints();
178 printf("EED vtkTensorsVisu::Process numPnts %d \n", numPnts );
181 vtkIdType numSourcePts, numSourceCells;
182 vtkPoints *sourcePts;
183 sourcePts = tg->GetSource()->GetPoints();
184 numSourcePts = sourcePts->GetNumberOfPoints();
185 numSourceCells = tg->GetSource()->GetNumberOfCells();
186 printf("EED vtkTensorsVisu::Process numSourcePts %d numSourceCells %d\n", numSourcePts, numSourceCells);
190 int i,sizeDa = pointdata->GetNumberOfArrays();
191 printf("EED vtkTensorsVisu::Process sizeDa %d \n", sizeDa );
192 for (i=0;i<sizeDa;i++)
194 int faces = pointdata->GetArray(i)->GetSize() / numPnts;
195 printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d %d \n", i, pointdata->GetArrayName(i) , pointdata->GetArray(i)->GetSize(), faces );
205 printf("EED vtkTensorsVisu::Process End.\n");