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 "creaVtkStreamLine.h"
30 #include "vtkPointData.h"
31 #include "vtkRenderWindow.h"
32 #include "vtkProperty.h"
34 creaVtkStreamLine::creaVtkStreamLine()
36 _source = vtkPointSource::New();
37 _vPointWidget = vtkPointWidget::New();
38 _streamMapper2 = vtkPolyDataMapper::New();
39 _streamer = vtkStreamTracer::New();
41 _tubefilter = vtkTubeFilter::New();
42 _ribbonfilter = vtkRibbonFilter::New();
46 //---------------------------------------------
47 creaVtkStreamLine::~creaVtkStreamLine()
51 //---------------------------------------------
52 void creaVtkStreamLine::SetSourcePoints( vtkDataSet* sourcepoints)
54 _sourcePoints = sourcepoints;
57 //---------------------------------------------
58 void creaVtkStreamLine::Process()
61 printf("creaVtkStreamLine::Process Start \n");
63 { //bbGetInputPlaneFieldShow
66 //---------------------------Stream Lines-----------------------
67 _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() );
71 _vPointWidget->AllOff();
72 _vPointWidget->PlaceWidget();
73 _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
74 _source->SetNumberOfPoints(1000);
75 _source->SetRadius(5.0);
77 //EED1 _vPointWidget->On();
81 _vPointWidget->GetPosition(c);
82 _source->SetCenter( c );
85 _streamer->SetInput( GetDataObject() );
87 //EED1 _streamer->SetSource( _source->GetOutput() );
88 _streamer->SetSource( _sourcePoints );
90 _streamer->SetIntegratorTypeToRungeKutta45();
92 //EED _streamer->SetMaximumPropagation(500000);
93 _streamer->SetMaximumPropagation(500);
94 //EED _streamer->SetMaximumPropagationUnitToTimeUnit();
96 _streamer->SetInitialIntegrationStep (0.001);
97 //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
99 _streamer->SetIntegrationDirectionToBoth();
100 //EED streamer->ComputeVorticityOn ();
102 printf("EED creaVtkStreamLine::Process StreamLine PrintSelf\n");
103 _streamer->Print(std::cout);
105 printf("EED creaVtkStreamLine::Process StreamLine->GetOutput() PrintSelf\n");
106 _streamer->GetOutput()->Print(std::cout);
110 _tubefilter->SetInput(_streamer->GetOutput());
111 _tubefilter->SetRadius( GetScaleFactor() );
112 _tubefilter->SetNumberOfSides(12);
113 _tubefilter->SetVaryRadiusToVaryRadiusOff();
115 _ribbonfilter->SetInput(_streamer->GetOutput());
116 _ribbonfilter->SetWidth( GetScaleFactor() );
117 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
118 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
120 //BORRAME _streamer->GetOutput()->GetScalarRange( range );
121 if (GetTypeForm()==0) {
122 _streamMapper2->SetInput( _tubefilter->GetOutput() );
124 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
126 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
129 vtkPolyData *pd = _streamer->GetOutput();
130 vtkPointData *pointdata = pd->GetPointData();
131 // vtkDataArray *da = pointdata->GetArray("Normals");
133 int i,sizeDa = pointdata->GetNumberOfArrays();
134 printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
135 for (i=0;i<sizeDa;i++)
137 printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, pointdata->GetArrayName(i) );
140 // vtkDataArray *nda = vtkDoubleArray::New();
141 // nda->DeepCopy(da);
142 // pointdata->AddArray( nda );
143 // bbGetInputIn()->GetPointData()->AddArray( nda );
149 // _streamMapper2->ScalarVisibilityOff();
153 // _streamMapper2->ScalarVisibilityOn();
154 // _streamMapper2->SetScalarModeToUsePointFieldData();
155 // _streamMapper2->SetLookupTable( vLutEED );
156 // _streamMapper2->SelectColorArray( "Normals" );
159 //Config 2 Orientation vectors
160 _streamMapper2->ScalarVisibilityOn();
161 _streamMapper2->SetScalarModeToUsePointFieldData();
162 _streamMapper2->SetLookupTable( _LutEED );
163 _streamMapper2->SelectColorArray( "velocity" );
171 _actor->SetMapper( _streamMapper2 );
173 printf("EED lib creaVTK creaVtkStreamLine::Process opacity %f\n", GetOpacity() );
174 _actor->GetProperty()->SetOpacity( GetOpacity() );