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");
59 if(GetTypeForm()==2) // source superquadratic
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());
71 tg->SetInput( GetDataObject() );
73 // tg->SetScaling(25);
75 tg->SetScaleFactor( GetScaleFactor() );
78 // //tg->SetScaleFactor(2);
79 // tg->SetScaleFactor(scale_factor);
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());
88 //EED================================
89 //pdm->SetInput( tg->GetOutput());
90 //pdm->SetScalarRange( range );
92 //vtkPolyData *pd = tg->GetOutput();
93 //vtkPointData *pointdata = pd->GetPointData();
94 //vtkDataArray *da = pointdata->GetVectors();
96 //vtkDataArray *nda = vtkFloatArray::New();
99 //pointdata->AddArray( nda );
100 //reader->GetOutput()->GetPointData()->AddArray( nda );
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 //=====================================
111 _pdm->SetInput( pdn->GetOutput() );
112 _pdm->ImmediateModeRenderingOn();
114 _pdm->ScalarVisibilityOn();
115 _pdm->SetScalarModeToUsePointFieldData();
118 //EED _pdm->Update();
120 _actor->SetMapper( _pdm );
121 _actor->GetProperty()->SetOpacity( GetOpacity() );
124 // tg->ExtractEigenvaluesOn();
125 tg->SetColorModeToEigenvalues();
127 _pdm->SetLookupTable( _LutEED );
128 _pdm->SelectColorArray( "Normals" );
131 //int tcg = tg->GetColorGlyphs();
132 // tg->SetColorGlyphs(10);
133 // tg->SetColorModeToScalars();
134 //tg->ThreeGlyphsOn();
137 //vtkDataArray* da = vtkDataArray::New();
138 pd = tg->GetOutput();
140 pod = pd->GetPointData();
142 //EED1 if(pod->GetScalars())
144 //EED1 _pdm->SetScalarRange(pod->GetScalars()->GetRange());
146 //pdm->SelectColorArray("GlyphVector");
148 //EED _pdm->Update();
152 tg->Print( std::cout );
153 printf("EED vtkTensorsVisu::Process ------------------------------------------\n");
154 pd->Print( std::cout );
158 vtkPolyData *pd = pdn->GetOutput();
159 vtkPointData *pointdata = pd->GetPointData();
162 printf("EED vtkTensorsVisu::Process XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx\n");
163 pointdata->Print( std::cout );
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();
173 printf("EED vtkTensorsVisu::Process %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
175 vtkPolyData *ttt = (vtkPolyData *)GetDataObject();
176 int numPnts = ttt->GetNumberOfPoints();
177 printf("EED vtkTensorsVisu::Process numPnts %d \n", numPnts );
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);
189 int i,sizeDa = pointdata->GetNumberOfArrays();
190 printf("EED vtkTensorsVisu::Process sizeDa %d \n", sizeDa );
191 for (i=0;i<sizeDa;i++)
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 );
204 printf("EED vtkTensorsVisu::Process End.\n");