/* # --------------------------------------------------------------------- # # 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 "creaVtkStreamLineScalarSeg.h" #include "vtkPointData.h" #include "vtkDataArray.h" #include "vtkDoubleArray.h" // ------------------------------------------------------------------------ creaVtkStreamLineScalarSeg::creaVtkStreamLineScalarSeg() { _vtkidlist = vtkIdList::New(); _newvtkpolydata = vtkPolyData::New(); _newvtkcellarray = vtkCellArray::New(); } // ------------------------------------------------------------------------ creaVtkStreamLineScalarSeg::~creaVtkStreamLineScalarSeg() { } // ------------------------------------------------------------------------ void creaVtkStreamLineScalarSeg::SetScalarStreamLinesIn( vtkPolyData* polydata) { _StreamLinesIn = polydata; } // ------------------------------------------------------------------------ void creaVtkStreamLineScalarSeg::SetScalarArrayName( std::string name) { _ScalarArrayName = name; } // ------------------------------------------------------------------------ void creaVtkStreamLineScalarSeg::SetThresholdLower( double value) { _ThresholdLower = value; } // ------------------------------------------------------------------------ void creaVtkStreamLineScalarSeg::SetThresholdUpper( double value ) { _ThresholdUpper = value; } // ------------------------------------------------------------------------ void creaVtkStreamLineScalarSeg::Process() { if (_ScalarArrayName=="") { printf(".\n "); printf(".\n "); printf("BBTK Warnning! ScalarArrayName is empty in creaVtkStreamLineScalarSeg \n"); printf(".\n "); printf(".\n "); } if ((_StreamLinesIn!=NULL) && (_ScalarArrayName!="") ) { int iLine; _newvtkcellarray->Initialize(); vtkCellArray *vtkcellarray = _StreamLinesIn->GetLines(); int nLinesCell = vtkcellarray->GetNumberOfCells(); // int vtkcellarraysize = vtkcellarray->GetSize(); int numberofids; int ii; vtkDataArray *scalarArray = _StreamLinesIn->GetPointData()->GetArray( _ScalarArrayName.c_str() ); vtkDoubleArray *newScalarArray = vtkDoubleArray::New(); newScalarArray->SetName( _ScalarArrayName.c_str() ); newScalarArray->SetNumberOfComponents(1); // FOR EACH LINE double scalarValue; long int iLineNew=0; ii=0; for ( iLine=0 ; iLineGetCell(ii, _vtkidlist ); numberofids = _vtkidlist->GetNumberOfIds(); scalarValue = scalarArray->GetTuple1(iLine); if ( ( scalarValue>=_ThresholdLower ) && ( scalarValue<=_ThresholdUpper ) ) { _newvtkcellarray->InsertNextCell( _vtkidlist ); newScalarArray->InsertTuple1( iLineNew, scalarValue ); iLineNew++; } ii=ii+numberofids+1; } // for iLine _newvtkpolydata->SetPoints( _StreamLinesIn->GetPoints() ); _newvtkpolydata->SetLines( _newvtkcellarray ); int iArrays,arraysSize = _StreamLinesIn->GetPointData()->GetNumberOfArrays(); for ( iArrays=0 ; iArraysGetPointData()->AddArray( _StreamLinesIn->GetPointData()->GetArray(iArrays) ); } _newvtkpolydata->GetPointData()->RemoveArray( _ScalarArrayName.c_str() ); _newvtkpolydata->GetPointData()->AddArray( newScalarArray ); _newvtkpolydata->Update(); _StreamLinesOut = _newvtkpolydata; } // _StreamLinesIn } // ------------------------------------------------------------------------ vtkPolyData* creaVtkStreamLineScalarSeg::GetStreamLinesOut() { return _StreamLinesOut; }