X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FExperiments%2FInsertNoiseIntoPoints.cxx;fp=plugins%2FExperiments%2FInsertNoiseIntoPoints.cxx;h=0000000000000000000000000000000000000000;hb=861989d728ba025e478329905a11d45bd80143d8;hp=0b98400b4b7a29e5007217990a18071234929f0f;hpb=2b43395480bf95d0b399ded56aa272768bbc074a;p=FrontAlgorithms.git diff --git a/plugins/Experiments/InsertNoiseIntoPoints.cxx b/plugins/Experiments/InsertNoiseIntoPoints.cxx deleted file mode 100644 index 0b98400..0000000 --- a/plugins/Experiments/InsertNoiseIntoPoints.cxx +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -fpaPluginsExperiments::InsertNoiseIntoPoints:: -InsertNoiseIntoPoints( ) - : Superclass( ) -{ - typedef cpInstances::DataObjects::Image _TImage; - typedef cpInstances::DataObjects::Mesh _TMesh; - - this->_ConfigureInput< _TMesh >( "Seeds", true, false ); - this->_ConfigureInput< _TImage >( "DistanceMap", true, false ); - this->_ConfigureOutput< _TMesh >( "Output" ); - this->m_Parameters.ConfigureAsBool( "InsertNoise", false ); - - // Create output data - auto out = this->_CreateVTK< vtkPolyData >( ); - out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) ); - out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) ); - out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) ); - out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) ); - out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) ); - this->GetOutput( "Output" )->SetVTK( out ); -} - -// ------------------------------------------------------------------------- -fpaPluginsExperiments::InsertNoiseIntoPoints:: -~InsertNoiseIntoPoints( ) -{ -} - -// ------------------------------------------------------------------------- -void fpaPluginsExperiments::InsertNoiseIntoPoints:: -_GenerateData( ) -{ - auto dmap = this->GetInputData< vtkImageData >( "DistanceMap" ); - auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - auto out = this->GetOutputData< vtkPolyData >( "Output" ); - - typedef std::uniform_real_distribution< double > _TDist; - std::random_device rd; - std::mt19937 gen( rd( ) ); - for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) - { - double buf[ 3 ], pcoords[ 3 ]; - seeds->GetPoint( i, buf ); - - if( this->m_Parameters.GetBool( "InsertNoise" ) ) - { - int ijk[ 3 ]; - dmap->ComputeStructuredCoordinates( buf, ijk, pcoords ); - double radius = - dmap->GetScalarComponentAsDouble( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 ); - double rad_dis = _TDist( 1e-2, radius * 0.9 )( gen ); - double the_dis = _TDist( 0, 3.14159265359 )( gen ); - double phi_dis = _TDist( 0, 6.28318530718 )( gen ); - buf[ 0 ] += rad_dis * std::sin( the_dis ) * std::cos( phi_dis ); - buf[ 1 ] += rad_dis * std::sin( the_dis ) * std::sin( phi_dis ); - buf[ 2 ] += rad_dis * std::cos( the_dis ); - - } // fi - out->GetPoints( )->InsertNextPoint( buf ); - out->GetVerts( )->InsertNextCell( 1 ); - out->GetVerts( )->InsertCellPoint( i ); - out->Modified( ); - - } // rof -} - -// eof - $RCSfile$