-#include <Experiments/InsertNoiseIntoPoints.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Mesh.h>
-
-#include <random>
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
-
-// -------------------------------------------------------------------------
-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$