/* # --------------------------------------------------------------------- # # 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" #include "vtkPolyDataWriter.h" creaVtkStreamLine::creaVtkStreamLine() { // _source = vtkPointSource::New(); // _vPointWidget = vtkPointWidget::New(); _streamMapper2 = vtkPolyDataMapper::New(); _tubefilter = vtkTubeFilter::New(); _ribbonfilter = vtkRibbonFilter::New(); } //--------------------------------------------- creaVtkStreamLine::~creaVtkStreamLine() { } //--------------------------------------------- void creaVtkStreamLine::SetPolyData( vtkPolyData* polydata) { _polydata = polydata; } //--------------------------------------------- void creaVtkStreamLine::Process() { printf("EED creaVtkStreamLine::Process Start \n"); if (_polydata!=NULL) { if (_active==true) { /* //---------------------------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(); // _streamer->Print(std::cout); // _streamer->GetOutput()->Print(std::cout); //EED 3aout2011 _tubefilter->SetInput( _streamer->GetOutput() ); _ribbonfilter->SetInput(_streamer->GetOutput()); */ _polydata->Modified(); printf("EED creaVtkStreamLine::Process 0 %p \n", _polydata); if (GetTypeForm()==0) { printf("EED creaVtkStreamLine::Process 1 \n"); _tubefilter->SetInput( _polydata ); _tubefilter->SetRadius( GetScaleFactor() ); _tubefilter->SetNumberOfSides(12); _tubefilter->SetVaryRadiusToVaryRadiusOff(); _tubefilter->Modified(); _tubefilter->Update(); _streamMapper2->SetInput( _tubefilter->GetOutput() ); } if (GetTypeForm()==1) { printf("EED creaVtkStreamLine::Process 2 \n"); _ribbonfilter->SetInput( _polydata ); _ribbonfilter->SetWidth( GetScaleFactor() ); _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 ); _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING" _ribbonfilter->Modified(); _ribbonfilter->Update(); _streamMapper2->SetInput( _ribbonfilter->GetOutput() ); } if (GetTypeForm()==2) { printf("EED creaVtkStreamLine::Process 3 \n"); _streamMapper2->SetInput( _polydata ); } printf("EED creaVtkStreamLine::Process 4 \n"); //EED _streamMapper2->SetLookupTable(vGreenToRedLut); /* vtkDoubleArray* _velocity = vtkDoubleArray::New(); _velocity->SetName("velocity"); // ... fill the colors array for (int ivelocity=0; ivelocity<=4000; ivelocity++ ) { _velocity->InsertTuple3 (ivelocity, 1, 0, 0); } _polydata->GetPointData()->AddArray(_velocity); */ printf("EED creaVtkStreamLine::Process A \n" ); vtkPointData *data = _polydata->GetPointData(); printf("EED -------------------------------------------\n"); _polydata->Print(std::cout); printf("EED -------------------------------------------\n"); data->Print(std::cout); printf("EED -------------------------------------------\n"); // vtkFieldData *data = _polydata->GetFieldData(); // vtkDataArray *da = pointdata->GetArray("Normals"); int i,sizeDa = data->GetNumberOfArrays(); printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa ); for (i=0;iGetArrayName(i) ); data->GetArray(i)->Print(std::cout); printf("EED -------------------------------------------\n"); } /* //EED vtkPolyDataWriter *writer3 = vtkPolyDataWriter::New(); writer3->SetFileName( "/home/davila/Borrame/streamline-eed-c.vtk" ); writer3->SetInput( _polydata ); writer3->Write(); */ // 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( _LutEED ); // _streamMapper2->SelectColorArray( "Normals" ); //Config 2 Orientation vectors _streamMapper2->ScalarVisibilityOn(); _streamMapper2->SetScalarModeToUsePointFieldData(); _streamMapper2->SetLookupTable( _LutEED ); if (_colorlaw==0) { _LutEED->SetVectorModeToRGBColors(); _streamMapper2->SelectColorArray( "creaColorDirection" ); } if (_colorlaw==1) { // _LutEED->SetVectorModeToMagnitude(); vtkLookupTable *lookuptable = vtkLookupTable::New(); _streamMapper2->SetLookupTable( lookuptable ); _streamMapper2->SelectColorArray( "creaMagnitud" ); } if (_colorlaw==2) { _streamMapper2->SelectColorArray( "xx" ); _actor->GetProperty()->SetColor(_colorR,_colorG,_colorB); } /* _vtkglyph->SetInput( GetDataObject() ); _vtkglyph->SetSource( _vtkarrowsource->GetOutput() ); _vtkglyph->SetScaleModeToScaleByVector(); _vtkglyph->SetColorModeToColorByVector(); _vtkglyph->SetScaleFactor( GetScaleFactor() ); _vtkglyph->Update(); _pdm->SetInput( _vtkglyph->GetOutput()); _pdm->SetScalarModeToUsePointFieldData(); _pdm->SetLookupTable( _LutEED ); _pdm->SelectColorArray( "GlyphVector" ); */ //Config 3 Position // ??????? _actor->SetMapper( _streamMapper2 ); _actor->GetProperty()->SetOpacity( GetOpacity() ); }// _active VisibilityActor(); } // polydata printf("EED creaVtkStreamLine::Process End \n"); }