Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
GridCurve.h
1
16
17#pragma once
18
33
34#if defined(GridCurve_RECURSES)
35#error Recursive header files inclusion detected in GridCurve.h
36#else // defined(GridCurve_RECURSES)
38#define GridCurve_RECURSES
39
40#if !defined GridCurve_h
42#define GridCurve_h
43
45// Inclusions
46#include <iostream>
47#include <sstream>
48#include <vector>
49#include <iterator>
50#include <cstddef>
51#include <utility>
52
53#include "DGtal/base/Common.h"
54#include "DGtal/io/readers/PointListReader.h"
55#include "DGtal/base/ConstAlias.h"
56
57#include "DGtal/base/BasicFunctors.h"
58#include "DGtal/base/Circulator.h"
59#include "DGtal/base/ConstRangeAdapter.h"
60#include "DGtal/base/ConstIteratorAdapter.h"
61
62#include "DGtal/topology/CCellularGridSpaceND.h"
63#include "DGtal/topology/KhalimskySpaceND.h"
64#include "DGtal/topology/SCellsFunctors.h"
65#include "DGtal/topology/CanonicSCellEmbedder.h"
66
68
69namespace DGtal
70{
71
72
73
75 // class GridCurve
77
170
171 template <typename TKSpace = KhalimskySpaceND<2> >
173 {
174
175 public:
176 typedef TKSpace KSpace;
178
179 typedef typename KSpace::Point Point;
180 typedef typename KSpace::Point Vector;
181
182 typedef typename KSpace::SCell SCell;
183 typedef typename std::vector<SCell> Storage;
184
185 // ----------------------- Standard services ------------------------------
186 public:
187
192
198
204
209 GridCurve( const GridCurve & other );
210
216 GridCurve & operator=( const GridCurve & other );
217
218 // ----------------------- common ------------------------------
219
223 std::string className() const;
224
229 void selfDisplay ( std::ostream & out ) const;
230
235 bool isValid() const;
236
237 // ----------------------- streams ------------------------------
238
243 bool initFromVectorStream(std::istream & in );
244
249 void writeVectorToStream( std::ostream & out );
250
251 // ----------------------- Initializations ------------------------------
252
258 bool initFromPointsVector( const std::vector<Point>& aVectorOfPoints );
259
265 template <typename TIterator>
266 bool initFromPointsRange( const TIterator& itb, const TIterator& ite );
267
273 bool initFromSCellsVector( const std::vector<SCell>& aVectorOfSCells );
274
280 template <typename TIterator>
281 bool initFromSCellsRange( const TIterator& itb, const TIterator& ite );
282
283
284 // ----------------------- open/closed ------------------------------
285
286
295 bool isClosed() const;
296
301 bool isOpen() const;
302
303 // ----------------------- container interface ------------------------------
304
305 typedef typename Storage::const_iterator const_iterator;
306 typedef typename Storage::const_iterator ConstIterator;
307 typedef typename Storage::const_reverse_iterator const_reverse_iterator;
308 typedef typename Storage::const_reverse_iterator ConstReverseIterator;
309
314
319
324
329
333 SCell back() const;
334
341 void push_back(const SCell& aSCell);
342
347 void pushBack(const SCell& aSCell);
348
352 typename Storage::size_type size() const;
353
354 // ------------------------- private Datas --------------------------------
355 private:
365
370
371
372 // ------------------------- Public Datas --------------------------------
373 public:
374
375
376
377 // ------------------------- Internal --------------------------------
378 private:
379
386 SCell PointVectorTo1SCell(const Point& aPoint, const Vector& aVector);
392 bool isInside(const SCell& aSCell) const;
393
394
395
396 // ------------------------- inner classes --------------------------------
397
398 public:
399
401
403
408 return SCellsRange(mySCells.begin(), mySCells.end(), new functors::Identity() );
409 }
410
412
414
421
423
425 typename KSpace::Space::RealPoint > MidPointsRange;
426
433
435
437 std::pair<Point,Vector> > ArrowsRange;
438
445
447
450
457
459
462
469
471
473 std::pair<Point, Point> > IncidentPointsRange;
474
481
482
484
489 return CodesRange( mySCells.begin(), mySCells.end(), new functors::SCellToCode<KSpace>(*myKPtr) );
490 }
491
492 }; // end of class GridCurve
493
494
495
502 template<typename TKSpace>
503 std::ostream&
504 operator<< ( std::ostream & out, const GridCurve<TKSpace> & object );
505
506
507} // namespace DGtal
508
509
511// Includes inline functions/methods.
512#include "DGtal/geometry/curves/GridCurve.ih"
513
514// //
516
517#endif // !defined GridCurve_h
518
519#undef GridCurve_RECURSES
520#endif // else defined(GridCurve_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition ConstAlias.h:187
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition GridCurve.h:173
bool initFromPointsVector(const std::vector< Point > &aVectorOfPoints)
SCell PointVectorTo1SCell(const Point &aPoint, const Vector &aVector)
Storage::const_reverse_iterator ConstReverseIterator
Definition GridCurve.h:308
ConstRangeAdapter< typename Storage::const_iterator, functors::Identity, SCell > SCellsRange
Definition GridCurve.h:402
SCell back() const
ConstIterator begin() const
Storage::const_reverse_iterator const_reverse_iterator
Definition GridCurve.h:307
SCellsRange getSCellsRange() const
Definition GridCurve.h:407
MidPointsRange getMidPointsRange() const
Definition GridCurve.h:430
std::string className() const
bool initFromVectorStream(std::istream &in)
void selfDisplay(std::ostream &out) const
PointsRange getPointsRange() const
Definition GridCurve.h:418
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToCode< KSpace >, char > CodesRange
Definition GridCurve.h:483
ConstRangeAdapter< typename Storage::const_iterator, CanonicSCellEmbedder< KSpace >, typename KSpace::Space::RealPoint > MidPointsRange
Definition GridCurve.h:425
KSpace::Point Vector
Definition GridCurve.h:180
void pushBack(const SCell &aSCell)
Storage::const_iterator const_iterator
Definition GridCurve.h:305
ConstReverseIterator rbegin() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToPoint< KSpace >, Point > PointsRange
Definition GridCurve.h:413
const KSpace * myKPtr
Definition GridCurve.h:359
std::vector< SCell > Storage
Definition GridCurve.h:183
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToInnerPoint< KSpace >, Point > InnerPointsRange
Definition GridCurve.h:449
IncidentPointsRange getIncidentPointsRange() const
Definition GridCurve.h:478
KSpace::SCell SCell
Definition GridCurve.h:182
bool initFromSCellsVector(const std::vector< SCell > &aVectorOfSCells)
GridCurve(ConstAlias< KSpace > aKSpace)
void writeVectorToStream(std::ostream &out)
ArrowsRange getArrowsRange() const
Definition GridCurve.h:442
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
Definition GridCurve.h:473
ConstIterator end() const
OuterPointsRange getOuterPointsRange() const
Definition GridCurve.h:466
bool isOpen() const
bool isInside(const SCell &aSCell) const
bool initFromPointsRange(const TIterator &itb, const TIterator &ite)
Storage::size_type size() const
InnerPointsRange getInnerPointsRange() const
Definition GridCurve.h:454
GridCurve(const GridCurve &other)
bool initFromSCellsRange(const TIterator &itb, const TIterator &ite)
KSpace::Point Point
Definition GridCurve.h:179
ConstReverseIterator rend() const
GridCurve & operator=(const GridCurve &other)
GridCurve::CodesRange getCodesRange() const
Definition GridCurve.h:488
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToArrow< KSpace >, std::pair< Point, Vector > > ArrowsRange
Definition GridCurve.h:437
Storage::const_iterator ConstIterator
Definition GridCurve.h:306
bool isValid() const
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< KSpace >))
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToOuterPoint< KSpace >, Point > OuterPointsRange
Definition GridCurve.h:461
bool isClosed() const
void push_back(const SCell &aSCell)
PointVector< dim, Integer > Point
SignedKhalimskyCell< dim, Integer > SCell
Aim: transforms a signed cell into an arrow, ie. a pair point-vector.
Aim: transforms a 2d signed cell, basically a linel, into a code (0,1,2 or 3),.
Aim: transforms a signed cell c into a pair of points corresponding to the signed cells of greater di...
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
Aim: transforms a scell into a point.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
Aim: Define a simple default functor that just returns its argument.
const Point aPoint(3, 4)