#ifndef __RCPPANTSR_H
#define __RCPPANTSR_H
#include "itkMacro.h"
#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkVector.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "vnl/vnl_vector_ref.h"
#include "itkTransform.h"
#include "itkAffineTransform.h"
#include <RcppCommon.h>
// From advice @ http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.pdf
inline SEXP exception_to_r_condition( const itk::ExceptionObject & ex )
{
//std::string ex_class = demangle( typeid(ex).name() ) ;
std::string ex_msg = ex.what() ;
std::string ex_class = "ITK";
Rcpp::Shield<SEXP> cppstack( rcpp_get_stack_trace() );
Rcpp::Shield<SEXP> call( get_last_call() );
Rcpp::Shield<SEXP> classes( get_exception_classes(ex_class) );
Rcpp::Shield<SEXP> condition( make_condition( ex_msg, call, cppstack, classes) );
rcpp_set_stack_trace( R_NilValue ) ;
return condition ;
}
inline void forward_exception_to_r( const itk::ExceptionObject & ex )
{
SEXP stop_sym = Rf_install( "stop" ) ;
Rcpp::Shield<SEXP> condition( exception_to_r_condition(ex) );
Rcpp::Shield<SEXP> expr( Rf_lang2( stop_sym , condition ) ) ;
Rf_eval( expr, R_GlobalEnv ) ;
}
namespace Rcpp {
// These are used to get header info only for both itk::Image and itk::VectorImage
template <> inline itk::ImageBase<2>::Pointer as( SEXP itkImageR );
template <> inline itk::ImageBase<3>::Pointer as( SEXP itkImageR );
template <> inline itk::ImageBase<4>::Pointer as( SEXP itkImageR );
// itk::Image to antsImage
#include <RcppANTsR/RcppANTsR_ImageBaseDef.h>
#include <RcppANTsR/RcppANTsR_ImageDef.h>
#include <RcppANTsR/RcppANTsR_VectorImageDef.h>
#include <RcppANTsR/RcppANTsR_ImageIteratorDef.h>
#include <RcppANTsR/RcppANTsR_TransformDef.h>
/*
template <> inline SEXP wrap( const itk::Image<double,2>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<double,3>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<double,4>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<float,2>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<float,3>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<float,4>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned int,2>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned int,3>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned int,4>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned char,2>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned char,3>::Pointer &image );
template <> inline SEXP wrap( const itk::Image<unsigned char,4>::Pointer &image );
// antsImage to itk::Image
template <> inline itk::Image<double,2>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<double,3>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<double,4>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<float,2>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<float,3>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<float,4>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned int,2>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned int,3>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned int,4>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned char,2>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned char,3>::Pointer as( SEXP itkImageR );
template <> inline itk::Image<unsigned char,4>::Pointer as( SEXP itkImageR );
*/
// itk::VectorImage to antsImage
template <> inline SEXP wrap( const itk::VectorImage<double,2>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<double,3>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<double,4>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<float,2>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<float,3>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<float,4>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned int,2>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned int,3>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned int,4>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned char,2>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned char,3>::Pointer &image );
template <> inline SEXP wrap( const itk::VectorImage<unsigned char,4>::Pointer &image );
// antsImage to itk::VectorImage
template <> inline itk::VectorImage<double,2>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<double,3>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<double,4>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<float,2>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<float,3>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<float,4>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned char,2>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned char,3>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned char,4>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned int,2>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned int,3>::Pointer as( SEXP itkImageR );
template <> inline itk::VectorImage<unsigned int,4>::Pointer as( SEXP itkImageR );
// itkIterator to antsrImageIterator
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<double,2> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<double,3> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<double,4> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<float,2> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<float,3> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<float,4> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned int,2> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned int,3> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned int,4> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned char,2> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned char,3> > & iterator );
template <> inline SEXP wrap( const itk::ImageRegionIteratorWithIndex< itk::Image<unsigned char,4> > & iterator );
// antsrImageIterator to itkIterator
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<double,2> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<double,3> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<double,4> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<float,2> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<float,3> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<float,4> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<unsigned int,2> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< itk::Image<unsigned int,3> > as( SEXP itkImageIteratorR );
template <> inline itk::ImageRegionIteratorWithIndex< i