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 if(GetTypeForm()==2) // source superquadratic
59 superquadratic->SetThetaResolution(20);
60 superquadratic->SetPhiResolution(20);
61 tg->SetSource(superquadratic->GetOutput());
62 } else if(GetTypeForm()==1) { // source sphere
63 tg->SetSource(ss->GetOutput());
64 } else { // source cube
65 tg->SetSource(cs->GetOutput());
69 tg->SetInput( GetDataObject() );
71 // tg->SetScaling(25);
73 tg->SetScaleFactor( GetScaleFactor() );
76 // //tg->SetScaleFactor(2);
77 // tg->SetScaleFactor(scale_factor);
80 //The normals are needed to generate the right colors and if
81 // not used some of the glyphs are black.
82 pdn->SetInput(tg->GetOutput());
86 //EED================================
87 //pdm->SetInput( tg->GetOutput());
88 //pdm->SetScalarRange( range );
90 //vtkPolyData *pd = tg->GetOutput();
91 //vtkPointData *pointdata = pd->GetPointData();
92 //vtkDataArray *da = pointdata->GetVectors();
94 //vtkDataArray *nda = vtkFloatArray::New();
97 //pointdata->AddArray( nda );
98 //reader->GetOutput()->GetPointData()->AddArray( nda );
100 //pdm->SetInput(pdn->GetOutput());
101 //pdm->ScalarVisibilityOn();
102 //pdm->SetLookupTable(vLutEED);
103 //pdm->SetColorModeToMapScalars();
104 //pdm->SelectColorArray("color");
105 //pdm->SetScalarModeToUsePointFieldData();
106 //pdm->ImmediateModeRenderingOn();
107 //=====================================
109 _pdm->SetInput( pdn->GetOutput() );
110 _pdm->ImmediateModeRenderingOn();
112 _pdm->ScalarVisibilityOn();
113 _pdm->SetScalarModeToUsePointFieldData();
116 //EED _pdm->Update();
118 _actor->SetMapper( _pdm );
119 _actor->GetProperty()->SetOpacity( GetOpacity() );
122 // tg->ExtractEigenvaluesOn();
123 tg->SetColorModeToEigenvalues();
125 _pdm->SetLookupTable( _LutEED );
126 _pdm->SelectColorArray( "Normals" );
129 //int tcg = tg->GetColorGlyphs();
130 // tg->SetColorGlyphs(10);
131 // tg->SetColorModeToScalars();
132 //tg->ThreeGlyphsOn();
135 //vtkDataArray* da = vtkDataArray::New();
136 pd = tg->GetOutput();
138 pod = pd->GetPointData();
140 //EED1 if(pod->GetScalars())
142 //EED1 _pdm->SetScalarRange(pod->GetScalars()->GetRange());
144 //pdm->SelectColorArray("GlyphVector");
146 //EED _pdm->Update();
149 //EED1 tg->Print( std::cout );
150 //EED1 printf("EED vtkTensorsVisu::Process ------------------------------------------\n");
151 //EED1 pd->Print( std::cout );
155 vtkPolyData *pd = pdn->GetOutput();
156 vtkPointData *pointdata = pd->GetPointData();
159 //EED1 printf("EED vtkTensorsVisu::Process XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx\n");
160 //EED1 pointdata->Print( std::cout );
163 int aa = pd->GetNumberOfPieces ();
164 int bb = pd->GetNumberOfVerts ();
165 int cc = pd->GetNumberOfLines ();
166 int dd = pd->GetNumberOfPolys ();
167 int ee = pd->GetNumberOfStrips ();
168 int ff = pd->GetNumberOfCells();
170 printf("EED vtkTensorsVisu::Process %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
172 vtkPolyData *ttt = (vtkPolyData *)GetDataObject();
173 int numPnts = ttt->GetNumberOfPoints();
174 printf("EED vtkTensorsVisu::Process numPnts %d \n", numPnts );
177 vtkIdType numSourcePts, numSourceCells;
178 vtkPoints *sourcePts;
179 sourcePts = tg->GetSource()->GetPoints();
180 numSourcePts = sourcePts->GetNumberOfPoints();
181 numSourceCells = tg->GetSource()->GetNumberOfCells();
182 printf("EED vtkTensorsVisu::Process numSourcePts %d numSourceCells %d\n", numSourcePts, numSourceCells);
186 int i,sizeDa = pointdata->GetNumberOfArrays();
187 printf("EED vtkTensorsVisu::Process sizeDa %d \n", sizeDa );
188 for (i=0;i<sizeDa;i++)
190 int faces = pointdata->GetArray(i)->GetSize() / numPnts;
191 printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d %d \n", i, pointdata->GetArrayName(i) , pointdata->GetArray(i)->GetSize(), faces );
201 printf("EED vtkTensorsVisu::Process End.\n");