/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sante) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include "creaVtkStreamLine.h" #include "vtkPointData.h" #include "vtkRenderWindow.h" #include "vtkProperty.h" creaVtkStreamLine::creaVtkStreamLine() { _source = vtkPointSource::New(); _vPointWidget = vtkPointWidget::New(); _streamMapper2 = vtkPolyDataMapper::New(); _streamer = vtkStreamTracer::New(); _tubefilter = vtkTubeFilter::New(); _ribbonfilter = vtkRibbonFilter::New(); } //--------------------------------------------- creaVtkStreamLine::~creaVtkStreamLine() { } //--------------------------------------------- void creaVtkStreamLine::SetSourcePoints( vtkDataSet* sourcepoints) { _sourcePoints = sourcepoints; } //--------------------------------------------- void creaVtkStreamLine::Process() { printf("creaVtkStreamLine::Process Start \n"); if (_active==false) { //bbGetInputPlaneFieldShow _vPointWidget->Off(); } else { //---------------------------Stream Lines----------------------- _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() ); if (_firsttime==true) { _firsttime=false; _vPointWidget->AllOff(); _vPointWidget->PlaceWidget(); _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() ); _source->SetNumberOfPoints(1000); _source->SetRadius(5.0); } //EED1 _vPointWidget->On(); double c[3]; _vPointWidget->GetPosition(c); _source->SetCenter( c ); _source->Update(); _streamer->SetInput( GetDataObject() ); //EED1 _streamer->SetSource( _source->GetOutput() ); _streamer->SetSource( _sourcePoints ); _streamer->SetIntegratorTypeToRungeKutta45(); //EED _streamer->SetMaximumPropagation(500000); _streamer->SetMaximumPropagation(500); //EED _streamer->SetMaximumPropagationUnitToTimeUnit(); _streamer->SetInitialIntegrationStep (0.001); //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit(); _streamer->SetIntegrationDirectionToBoth(); //EED streamer->ComputeVorticityOn (); _streamer->Update(); printf("EED creaVtkStreamLine::Process StreamLine PrintSelf\n"); _streamer->Print(std::cout); printf("EED creaVtkStreamLine::Process StreamLine->GetOutput() PrintSelf\n"); _streamer->GetOutput()->Print(std::cout); //EED 3aout2011 _tubefilter->SetInput(_streamer->GetOutput()); _tubefilter->SetRadius( GetScaleFactor() ); _tubefilter->SetNumberOfSides(12); _tubefilter->SetVaryRadiusToVaryRadiusOff(); _ribbonfilter->SetInput(_streamer->GetOutput()); _ribbonfilter->SetWidth( GetScaleFactor() ); _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 ); _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING" //BORRAME _streamer->GetOutput()->GetScalarRange( range ); if (GetTypeForm()==0) { _streamMapper2->SetInput( _tubefilter->GetOutput() ); } else { _streamMapper2->SetInput( _ribbonfilter->GetOutput() ); } //EED _streamMapper2->SetLookupTable(vGreenToRedLut); vtkPolyData *pd = _streamer->GetOutput(); vtkPointData *pointdata = pd->GetPointData(); // vtkDataArray *da = pointdata->GetArray("Normals"); int i,sizeDa = pointdata->GetNumberOfArrays(); printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa ); for (i=0;iGetArrayName(i) ); } // vtkDataArray *nda = vtkDoubleArray::New(); // nda->DeepCopy(da); // pointdata->AddArray( nda ); // bbGetInputIn()->GetPointData()->AddArray( nda ); //Config 0 (nothing) // _streamMapper2->ScalarVisibilityOff(); //Config 1 (Normals) // _streamMapper2->ScalarVisibilityOn(); // _streamMapper2->SetScalarModeToUsePointFieldData(); // _streamMapper2->SetLookupTable( vLutEED ); // _streamMapper2->SelectColorArray( "Normals" ); //Config 2 Orientation vectors _streamMapper2->ScalarVisibilityOn(); _streamMapper2->SetScalarModeToUsePointFieldData(); _streamMapper2->SetLookupTable( _LutEED ); _streamMapper2->SelectColorArray( "velocity" ); //Config 3 Position // ??????? _actor->SetMapper( _streamMapper2 ); printf("EED lib creaVTK creaVtkStreamLine::Process opacity %f\n", GetOpacity() ); _actor->GetProperty()->SetOpacity( GetOpacity() ); }// _active VisibilityActor(); }