00001 // This is core/vpdl/vpdt/vpdt_field_traits.h 00002 #ifndef vpdt_field_traits_h_ 00003 #define vpdt_field_traits_h_ 00004 //: 00005 // \file 00006 // \author Matthew Leotta 00007 // \brief specialized template trait classes for properties of a field type 00008 // \date March 5, 2009 00009 // 00010 // Each type of object upon which you define a field for a probability 00011 // distribution requires a field traits class. The field traits determine 00012 // the dimension, scalar type, field type, vector type, matrix type, etc to be used. 00013 // 00014 // \verbatim 00015 // Modifications 00016 // None 00017 // \endverbatim 00018 00019 #include <vnl/vnl_vector.h> 00020 #include <vnl/vnl_matrix.h> 00021 #include <vnl/vnl_vector_fixed.h> 00022 #include <vnl/vnl_matrix_fixed.h> 00023 #include <vcl_cassert.h> 00024 00025 00026 //: The field traits class (scalar) 00027 // The default is to treat it as a 1-d (scalar) field 00028 template <class T> 00029 struct vpdt_field_traits 00030 { 00031 //: The compile time dimension of the field 00032 static const unsigned int dimension = 1; 00033 //: The type used for scalar operations 00034 typedef T scalar_type; 00035 //: the data type to represent a point in the field 00036 typedef T field_type; 00037 //: the data type used for vectors (difference between points) 00038 typedef T vector_type; 00039 //: the data type used for square matrices 00040 typedef T matrix_type; 00041 00042 //: use this to disambiguate templates 00043 typedef void type_is_scalar; 00044 }; 00045 00046 00047 //: The field traits class (vnl_vector_fixed) 00048 // This specialization is for fixed length vnl vectors 00049 template <class T, unsigned int n> 00050 struct vpdt_field_traits<vnl_vector_fixed<T,n> > 00051 { 00052 //: The compile time dimension of the field 00053 static const unsigned int dimension = n; 00054 //: The type used for scalar operations 00055 typedef T scalar_type; 00056 //: the data type to represent a point in the field 00057 typedef vnl_vector_fixed<T,n> field_type; 00058 //: the data type used for vectors (difference between points) 00059 typedef vnl_vector_fixed<T,n> vector_type; 00060 //: the data type used for square matrices 00061 typedef vnl_matrix_fixed<T,n,n> matrix_type; 00062 00063 //: use this to disambiguate templates 00064 typedef void type_is_vector; 00065 }; 00066 00067 00068 //: The field traits class (vnl_vector) 00069 // This specialization is for variable length vnl vectors 00070 // \note dimension of 0 indicates variable dimension at run time 00071 template <class T> 00072 struct vpdt_field_traits<vnl_vector<T> > 00073 { 00074 //: The compile time dimension of the field 00075 static const unsigned int dimension = 0; 00076 //: The type used for scalar operations 00077 typedef T scalar_type; 00078 //: the data type to represent a point in the field 00079 typedef vnl_vector<T> field_type; 00080 //: the data type used for vectors (difference between points) 00081 typedef vnl_vector<T> vector_type; 00082 //: the data type used for square matrices 00083 typedef vnl_matrix<T> matrix_type; 00084 00085 //: use this to disambiguate templates 00086 typedef void type_is_vector; 00087 }; 00088 00089 00090 00091 #endif // vpdt_field_traits_h_