From a30ca94a35cdfc9a3d6837b98c48bf3c377b340e Mon Sep 17 00:00:00 2001 From: davila Date: Wed, 27 Aug 2014 09:35:20 +0200 Subject: [PATCH] #2446 creaVtk Feature New Normal - Stream Tracer, Stream Line (interface, widget) --- .../src/bbcreaVtkStreamTracer.cxx | 80 ++++++++++++ bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.h | 59 +++++++++ lib/creaVtk/creaVtkStreamTracer.cpp | 116 ++++++++++++++++++ lib/creaVtk/creaVtkStreamTracer.h | 83 +++++++++++++ 4 files changed, 338 insertions(+) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.h create mode 100644 lib/creaVtk/creaVtkStreamTracer.cpp create mode 100644 lib/creaVtk/creaVtkStreamTracer.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.cxx new file mode 100644 index 0000000..45fdd21 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkStreamTracer.cxx @@ -0,0 +1,80 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaVtkStreamTracer.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,StreamTracer) +BBTK_BLACK_BOX_IMPLEMENTATION(StreamTracer,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void StreamTracer::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + +// bbSetOutputOut( bbGetInputIn() ); +// std::cout << "Output value = " <GetOutput() )",vtkDataSet*,""); + BBTK_OUTPUT(StreamTracer,Out,"vtkPolyData output",vtkPolyData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(StreamTracer); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkStreamTracer_h_INCLUDED__ + diff --git a/lib/creaVtk/creaVtkStreamTracer.cpp b/lib/creaVtk/creaVtkStreamTracer.cpp new file mode 100644 index 0000000..ba22dee --- /dev/null +++ b/lib/creaVtk/creaVtkStreamTracer.cpp @@ -0,0 +1,116 @@ +/* +# --------------------------------------------------------------------- +# +# 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 "creaVtkStreamTracer.h" + +//----------------------------------------------------------------------------- +creaVtkStreamTracer::creaVtkStreamTracer() +{ + _source = vtkPointSource::New(); + _streamer = vtkStreamTracer::New(); +} + +//----------------------------------------------------------------------------- +creaVtkStreamTracer::~creaVtkStreamTracer() +{ +} + + +//------------------------------------------------------------------------ +void creaVtkStreamTracer::SetActive(bool active) +{ + _active = active; +} + +//------------------------------------------------------------------------ +void creaVtkStreamTracer::SetDataObject(vtkDataObject* dataobject) +{ + _dataobject = dataobject; +} + +//--------------------------------------------- +vtkPolyData* creaVtkStreamTracer::GetPolyData() +{ + return _streamer->GetOutput(); +} + +//--------------------------------------------- +void creaVtkStreamTracer::SetSourcePoints( vtkDataSet* sourcepoints) +{ + _sourcePoints = sourcepoints; +} + +//----------------------------------------------------------------------------- +void creaVtkStreamTracer::Process() +{ + if (_active==true) + { +// 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( _dataobject ); +//EED1 _streamer->SetSource( _source->GetOutput() ); + _streamer->SetSource( _sourcePoints ); + _streamer->SetIntegratorTypeToRungeKutta45(); + _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); + + } // active +} + + + +//--------------------------------------------- +//Method template +//--------------------------------------------- +/* +void creaVtkStreamTracer::FunctionName(int& parameterA) +{ + parameterA = 2 * parameterA; + return; +} +*/ diff --git a/lib/creaVtk/creaVtkStreamTracer.h b/lib/creaVtk/creaVtkStreamTracer.h new file mode 100644 index 0000000..918337a --- /dev/null +++ b/lib/creaVtk/creaVtkStreamTracer.h @@ -0,0 +1,83 @@ +/* +# --------------------------------------------------------------------- +# +# 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. +# ------------------------------------------------------------------------ +*/ + +#ifndef _CREAVTKSTREAMTRACER_H_ +#define _CREAVTKSTREAMTRACER_H_ + +//--------------------------------------------- +// Class Name: creaVtkStreamTracer +// [classdescription] +//--------------------------------------------- + +#include "vtkDataSet.h" +#include "vtkPointSource.h" +#include "vtkPointWidget.h" +#include "vtkStreamTracer.h" + +class creaVtkStreamTracer +{ + +//--------------------------------------------- +//Methods and attributes exposed to other classes +//--------------------------------------------- +public : + creaVtkStreamTracer(); + ~creaVtkStreamTracer(); + + void SetActive(bool active); + void SetDataObject(vtkDataObject* dataobject); + void SetSourcePoints(vtkDataSet* sourcepoints); + void Process(); + + vtkPolyData* GetPolyData(); + +//--Method template---------------------------- +// void FunctionName(int& parameterA); + + +//--------------------------------------------- +//Methods and attributes exposed only to classes +//that are derived from this class +//--------------------------------------------- +protected: + +//--------------------------------------------- +//Methods and attributes only visible by this class +//--------------------------------------------- +private: + + bool _active; + vtkDataObject *_dataobject; + vtkDataSet *_sourcePoints; + vtkPointSource *_source; + vtkStreamTracer *_streamer; + + +}; + +//-end of _CREAVTKSTREAMTRACER_H_------------------------------------------------------ +#endif -- 2.47.1