DGtal  0.9.2
SpatialCubicalSubdivision.h
1 
17 #pragma once
18 
31 #if defined(SpatialCubicalSubdivision_RECURSES)
32 #error Recursive header files inclusion detected in SpatialCubicalSubdivision.h
33 #else // defined(SpatialCubicalSubdivision_RECURSES)
34 
35 #define SpatialCubicalSubdivision_RECURSES
36 
37 #if !defined SpatialCubicalSubdivision_h
38 
39 #define SpatialCubicalSubdivision_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/Clone.h"
47 #include "DGtal/images/ImageContainerBySTLVector.h"
49 
50 namespace DGtal
51 {
52 
54  // template class SpatialCubicalSubdivision
71  template <typename TSpace>
73  {
75  public:
76  typedef TSpace Space;
77  typedef typename Space::Point Point;
78  typedef typename Space::Vector Vector;
79  typedef typename Point::Coordinate Coordinate;
81  typedef std::vector<Point> Storage;
84 
85  // ----------------------- Standard services ------------------------------
86  public:
87 
92 
98 
106  SpatialCubicalSubdivision( Point lo, Point up, Coordinate size );
107 
109  const Domain& domain() const;
110 
112  const Domain& binDomain() const;
113 
118  Point bin( Point p ) const;
119 
124  Point lowest( Point b ) const;
125 
130  Point uppermost( Point b ) const;
131 
139  void push( const Point& p );
140 
150  template <typename PointConstIterator>
151  void push( PointConstIterator it, PointConstIterator itE );
152 
163  template <typename PointPredicate>
164  void getPoints( std::vector<Point> & pts,
165  Point bin_lo, Point bin_up, const PointPredicate & pred ) const;
166 
175  void getPoints( std::vector<Point> & pts,
176  Point bin_lo, Point bin_up ) const;
177 
178  // ----------------------- Interface --------------------------------------
179  public:
180 
185  void selfDisplay ( std::ostream & out ) const;
186 
191  bool isValid() const;
192 
193  // ------------------------- Protected Datas ------------------------------
194  protected:
195 
197  Domain myDomain;
199  Coordinate mySize;
202  StorageArray myArray;
203  // ------------------------- Private Datas --------------------------------
204  private:
206  Point myDiag;
207 
208  // ------------------------- Hidden services ------------------------------
209  protected:
210 
211  // ------------------------- Internals ------------------------------------
212  private:
213 
221 
222  }; // end of class SpatialCubicalSubdivision
223 
224 
231  template <typename TSpace>
232  std::ostream&
233  operator<< ( std::ostream & out, const SpatialCubicalSubdivision<TSpace> & object );
234 
235 } // namespace DGtal
236 
237 
239 // Includes inline functions.
240 #include "DGtal/geometry/tools/SpatialCubicalSubdivision.ih"
241 
242 // //
244 
245 #endif // !defined SpatialCubicalSubdivision_h
246 
247 #undef SpatialCubicalSubdivision_RECURSES
248 #endif // else defined(SpatialCubicalSubdivision_RECURSES)
Point myDiag
a precomputed point to improve performance of uppermost() method.
Component Coordinate
Type for Point elements.
Definition: PointVector.h:158
Domain myDomain
the rectangular domain representing the useful points of the space.
SpatialCubicalSubdivision(const SpatialCubicalSubdivision &other)
const Domain & binDomain() const
Coordinate mySize
the edge size of each bin.
SpatialCubicalSubdivision & operator=(const SpatialCubicalSubdivision &other)
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Point bin(Point p) const
Point lowest(Point b) const
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Definition: CSpace.h:105
void selfDisplay(std::ostream &out) const
Aim: This class is a data structure that subdivides a rectangular domains into cubical domains of siz...
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
Point uppermost(Point b) const
DGtal is the top-level namespace which contains all DGtal functions and types.
void getPoints(std::vector< Point > &pts, Point bin_lo, Point bin_up, const PointPredicate &pred) const
ImageContainerBySTLVector< Domain, Storage * > StorageArray
const Domain & domain() const