DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Image.h
1 
17 #pragma once
18 
31 #if defined(Image_RECURSES)
32 #error Recursive header files inclusion detected in Image.h
33 #else // defined(Image_RECURSES)
34 
35 #define Image_RECURSES
36 
37 #if !defined Image_h
38 
39 #define Image_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/ConceptUtils.h"
46 #include "DGtal/images/CImage.h"
47 #include "DGtal/kernel/domains/CDomain.h"
48 #include "DGtal/base/CowPtr.h"
49 #include "DGtal/topology/CVertexMap.h"
51 
52 namespace DGtal
53 {
55  // Template class Image
68  template < typename TImageContainer >
69  class Image
70  {
71 
72  // ----------------------- Types ------------------------------
73 
74  public:
75 
79 
81  typedef TImageContainer ImageContainer;
82  typedef typename TImageContainer::Domain Domain;
83  typedef typename TImageContainer::Point Point;
84  typedef typename TImageContainer::Value Value;
85  typedef typename TImageContainer::ConstRange ConstRange;
86  typedef typename TImageContainer::Range Range;
87  typedef typename TImageContainer::OutputIterator OutputIterator;
88 
91 
92  // ----------------------- Standard services ------------------------------
93 
94  public:
95 
99  Image() {
100 #ifdef DEBUG_VERBOSE
101 trace.warning() << "Image Ctor default "<<std::endl;
102 #endif
103 
104  };
105 
110  Image(ImageContainer *anImageContainer):
111  myImagePointer(anImageContainer)
112  {
113 #ifdef DEBUG_VERBOSE
114  trace.warning() << "Image Ctor fromPointer "<<std::endl;
115 #endif
116  }
117 
123  Image(const CowPtr<ImageContainer> &anImageContainerCowPointer):
124  myImagePointer(anImageContainerCowPointer)
125  {
126  #ifdef DEBUG_VERBOSE
127 trace.warning() << "Image Ctor fromCow "<<std::endl;
128 #endif
129  }
130 
136  Image(const ImageContainer &other):
137  myImagePointer(new ImageContainer(other) )
138  {
139 #ifdef DEBUG_VERBOSE
140 trace.warning() << "Image Ctor fromConstRef "<<std::endl;
141 #endif
142  }
143 
144 
150  Image(const Image &other):
152  {
153  #ifdef DEBUG_VERBOSE
154 trace.warning() << "Image copy Ctor "<<std::endl;
155 #endif
156  }
157 
163  Image & operator= ( const Image & other )
164  {
165  #ifdef DEBUG_VERBOSE
166  trace.warning() << "Image assignment "<<std::endl;
167 #endif
168  if (&other != this)
169  {
171  }
172  return *this;
173  }
174 
175 
180  ~Image() {}
181 
182  // ----------------------- Interface --------------------------------------
183  public:
184 
186 
192  const Domain & domain() const
193  {
194  return myImagePointer->domain();
195  }
196 
204  {
205  return myImagePointer->constRange();
206  }
207 
215  {
216  return myImagePointer->range();
217  }
218 
220 
221 
231  Value operator()(const Point & aPoint) const
232  {
233  return myImagePointer->operator()(aPoint);
234  }
235 
236 
238 
247  void setValue(const Point &aPoint, const Value &aValue)
248  {
249  myImagePointer->setValue(aPoint,aValue);
250  }
251 
252 
253 
255 
260  void selfDisplay ( std::ostream & out ) const;
261 
269  bool isValid() const
270  {
271  return (myImagePointer->isValid() );
272  }
273 
274 
279  const ImagePointer getPointer() const
280  {
281  return myImagePointer;
282  }
283 
284  // ------------------------- Protected Datas ------------------------------
285  private:
286  // ------------------------- Private Datas --------------------------------
287  protected:
288 
291 
292 
293  private:
294 
295 
296  // ------------------------- Internals ------------------------------------
297  private:
298 
299  }; // end of class Image
300 
301 
308  template <typename T>
309  std::ostream&
310  operator<< ( std::ostream & out, const Image<T> & object );
311 
312 } // namespace DGtal
313 
314 
316 // Includes inline functions.
317 #include "DGtal/images/Image.ih"
318 
319 // //
321 
322 #endif // !defined Image_h
323 
324 #undef Image_RECURSES
325 #endif // else defined(Image_RECURSES)