]> Creatis software - FrontAlgorithms.git/blob - plugins/Experiments/InsertNoiseIntoPoints.cxx
d81b6f17f017dc70fa8d1ca9181440fe23e28dbb
[FrontAlgorithms.git] / plugins / Experiments / InsertNoiseIntoPoints.cxx
1 #include <Experiments/InsertNoiseIntoPoints.h>
2 #include <cpInstances/Image.h>
3
4 #include <random>
5 #include <vtkImageData.h>
6 #include <vtkPolyData.h>
7 #error http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution
8 // -------------------------------------------------------------------------
9 fpaPluginsExperiments::InsertNoiseIntoPoints::
10 InsertNoiseIntoPoints( )
11   : Superclass( )
12 {
13   typedef cpInstances::Image _TImage;
14   typedef cpPlugins::BaseObjects::DataObject _TData;
15
16   this->_ConfigureInput< _TData >( "Seeds", true, false );
17   this->_ConfigureInput< _TImage >( "DistanceMap", true, false );
18   this->_ConfigureOutput< _TData >( "Output" );
19   this->m_Parameters.ConfigureAsUint( "NumberOfSamples", 0 );
20 }
21
22 // -------------------------------------------------------------------------
23 fpaPluginsExperiments::InsertNoiseIntoPoints::
24 ~InsertNoiseIntoPoints( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void fpaPluginsExperiments::InsertNoiseIntoPoints::
30 _GenerateData( )
31 {
32   auto dmap = this->GetInputData< vtkImageData >( "DistanceMap" );
33   auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
34   for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
35   {
36     double buf[ 3 ], pcoords[ 3 ];
37     seeds->GetPoint( i, buf );
38     int ijk[ 3 ];
39     dmap->ComputeStructuredCoordinates( buf, ijk, pcoords );
40     double radius =
41       dmap->GetScalarComponentAsDouble( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 );
42
43   } // rof
44
45   /* TODO
46      cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 )
47      this->_Error( "Invalid input image." );
48   */
49 }
50
51 // -------------------------------------------------------------------------
52 /* TODO
53    template< class _TImage >
54    void fpaPluginsExperiments::InsertNoiseIntoPoints::
55    _GD0( _TImage* image )
56    {
57    typedef fpa::Image::InsertNoiseIntoPoints< _TImage > _TFilter;
58    auto filter = this->_CreateITK< _TFilter >( );
59    filter->SetInput( image );
60
61    if( seeds != NULL )
62    {
63    typename _TImage::PointType pnt;
64    typename _TImage::IndexType idx;
65    unsigned int dim =
66    ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
67
68    for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
69    {
70    double buf[ 3 ];
71    seeds->GetPoint( i, buf );
72    pnt.Fill( 0 );
73    for( unsigned int d = 0; d < dim; ++d )
74    pnt[ d ] = buf[ d ];
75
76    if( image->TransformPhysicalPointToIndex( pnt, idx ) )
77    filter->AddSeed( idx, 0 );
78
79    } // rof
80
81    } // fi
82
83    filter->Update( );
84    this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
85    this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
86    }
87 */
88
89 // eof - $RCSfile$