aimstil  5.0.5
DynImageWrapers.h
Go to the documentation of this file.
1 #ifndef TIL_DYNIMAGEWRAPPERS_H
2 #define TIL_DYNIMAGEWRAPPERS_H
3 
4 // include from TIL library
5 #include "til/til_common.h"
6 #include "til/DynImage.h"
7 #include "til/imageArith.h"
8 #include "til/templateTools.h"
9 
10 // ignore warnings
11 //#pragma warning ( push )
12 //#pragma warning ( disable: C4244 ) // conversion from X to Y, possible loss of data
13 
14 namespace til
15 {
16  // predeclarations
17  //template < class T > class Ptr;
18 
19  /*
20  template < class TTypeCollection, typename T >
21  void
22  mul2(Dyn<TTypeCollection> dyn, T value)
23  {
24  template < typename T >
25  struct Temp
26  {
27  void operator()(){ if (T object = dynamic_cast<T>(m_object)) mul(object}
28  }
29  mpl::for_each<TTypeCollection>(
30  }
31  */
32 /*
33 
34 #define DYNIM_FUNC_WRAP_DYNIM_VALUE(funcname) \
35 template < template <typename> class TImage , typename T> \
36 typename disable_if<is_Image<T> >::type \
37 funcname (DynImage<TImage> & dynim, T value) \
38 { \
39  TIL_DYNIM_BLOCKS( detail::funcname##_iv (pim->image(), static_cast<typename change_precision<T,PixelType>::type>(value)); return;) \
40 }
41 
42  DYNIM_FUNC_WRAP_DYNIM_VALUE(add);
43  DYNIM_FUNC_WRAP_DYNIM_VALUE(sub);
44  DYNIM_FUNC_WRAP_DYNIM_VALUE(mul);
45  DYNIM_FUNC_WRAP_DYNIM_VALUE(div);
46 
47 #undef DYNIM_FUNC_WRAP_DYNIM_VALUE
48 
49 
50 #define DYNIM_FUNC_WRAP_2DYNIM(function) \
51 template < template <typename> class TImage> \
52 void function (DynImage<TImage> & dynim, DynImage<TImage> & dynim2) \
53 { \
54  TIL_DYNIM_BLOCKS( (DynImage_typed<TImage TIL_COMMA PixelType> *pim2 = dynamic_cast<DynImage_typed<TImage TIL_COMMA PixelType>*>(&dynim2) ) ; detail::function##_ii (pim->image(), pim2->image()); return;) \
55 }
56 
57 // TODO: right now, dynim is not const because the dynamic_cast assumes it is const.
58 // Change that (maybe using some boost traits or something).
59 #define DYNIM_FUNC_WRAP_IM_DYNIM(function) \
60 template < template <typename> class TImage , typename TImage2> \
61 typename enable_if<is_Image<TImage2> >::type \
62 function (TImage2 & im2, DynImage<TImage> &dynim) \
63 { \
64  TIL_DYNIM_BLOCKS( detail::function##_ii (im2, pim->image()); return; ) \
65 }
66 
67 #define DYNIM_FUNC_WRAP_DYNIM_IM(function) \
68 template < template <typename> class TImage , typename TImage2> \
69 typename enable_if<is_Image<TImage2> >::type \
70 function (DynImage<TImage> & dynim, const TImage2 & im2) \
71 { \
72  TIL_DYNIM_BLOCKS( detail::function##_ii (pim->image(), im2); return; ) \
73 }
74 
75 #define DYNIM_FUNC_WRAP_TWO_IMAGES(function) \
76  DYNIM_FUNC_WRAP_IM_DYNIM(function) \
77  DYNIM_FUNC_WRAP_DYNIM_IM(function) \
78  DYNIM_FUNC_WRAP_2DYNIM(function)
79 
80 #define TIL_COMMA ,
81 */
82 
83 /*
84  template < template <typename> class TImage , typename TImage2>
85 void mul (TImage2 im2, DynImage<TImage> & dynim)
86 {
87  if(0) {}
88  else if (DynImage_typed<TImage, char> *im = dynamic_cast<DynImage_typed<TImage, char >*>((DynImage<TImage>*)dynim))
89  {
90  typedef char PixelType;
91  mul(im2, im.image()); return;
92  }
93  else { throw std::runtime_error("Unknown dynamic image type"); }
94 }
95 */
96 
97 // Well, we know that at this point, we can't control which type is multiplied by which.
98 #pragma warning ( push )
99 #pragma warning ( disable : 4244 ) // conversion from X to Y, possible loss of data
100 
101  /*
102  DYNIM_FUNC_WRAP_TWO_IMAGES(mul);
103  */
104 
105 #pragma warning ( pop )
106 
107 #undef DYNIM_FUNC_WRAP_TWO_IMAGES
108 #undef DYNIM_FUNC_WRAP_DYNIM_IM
109 #undef DYNIM_FUNC_WRAP_IM_DYNIM
110 #undef DYNIM_FUNC_WRAP_2DYNIM
111 
112 
113 #undef TIL_COMMA
114 
115 } // namespace til
116 
117 //#pragma warning ( pop )
118 
119 
120 #endif
121 
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
General macros, definitions and functions.
Collects template tools used for library implementation.