DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
COBANaivePlane.h
1 
17 #pragma once
18 
33 #if defined(COBANaivePlane_RECURSES)
34 #error Recursive header files inclusion detected in COBANaivePlane.h
35 #else // defined(COBANaivePlane_RECURSES)
36 
37 #define COBANaivePlane_RECURSES
38 
39 #if !defined COBANaivePlane_h
40 
41 #define COBANaivePlane_h
42 
44 // Inclusions
45 #include <iostream>
46 #include <set>
47 #include "DGtal/base/Common.h"
48 #include "DGtal/kernel/CInteger.h"
49 #include "DGtal/kernel/CSpace.h"
50 #include "DGtal/kernel/SpaceND.h"
51 #include "DGtal/kernel/PointVector.h"
52 #include "DGtal/arithmetic/IntegerComputer.h"
53 #include "DGtal/arithmetic/LatticePolytope2D.h"
55 
56 namespace DGtal
57 {
58 
60  // template class COBANaivePlane
126  template < typename TSpace,
127  typename TInternalInteger >
129  {
130 
133  BOOST_STATIC_ASSERT(( TSpace::dimension == 3 ));
134 
135  // ----------------------- public types ------------------------------
136  public:
137  typedef TSpace Space;
138  typedef typename Space::Point Point;
139  typedef std::set< Point > PointSet;
140  typedef typename PointSet::size_type Size;
141  typedef typename PointSet::const_iterator ConstIterator;
142  typedef typename PointSet::iterator Iterator;
143  typedef TInternalInteger InternalInteger;
145 
146  // ----------------------- std public types ------------------------------
147  public:
148  typedef typename PointSet::const_iterator const_iterator;
149  typedef typename PointSet::const_pointer const_pointer;
150  typedef typename PointSet::const_reference const_reference;
151  typedef typename PointSet::value_type value_type;
152  typedef typename PointSet::difference_type difference_type;
153  typedef typename PointSet::size_type size_type;
154 
155  // ----------------------- internal types ------------------------------
156  private:
162 
168  struct State {
176  };
177 
178  // ----------------------- Standard services ------------------------------
179  public:
180 
184  ~COBANaivePlane();
185 
190  COBANaivePlane();
191 
196  COBANaivePlane ( const COBANaivePlane & other );
197 
203  COBANaivePlane & operator= ( const COBANaivePlane & other );
204 
208  MyIntegerComputer & ic() const;
209 
214  void clear();
215 
235  void init( Dimension axis, InternalInteger diameter,
238 
242  Size complexity() const;
243 
244  //-------------------- model of ForwardContainer -----------------------------
245  public:
246 
250  Size size() const;
251 
255  bool empty() const;
256 
260  ConstIterator begin() const;
261 
265  ConstIterator end() const;
266 
272  Size max_size() const;
273 
278  Size maxSize() const;
279 
280 
281  //-------------------- model of CPointPredicate -----------------------------
282  public:
283 
293  bool operator()( const Point & p ) const;
294 
295  //-------------------- model of CIncrementalPrimitiveComputer -----------------------------
296  public:
297 
307  bool extendAsIs( const Point & p );
308 
319  bool extend( const Point & p );
320 
331  bool isExtendable( const Point & p ) const;
332 
333  //-------------------- model of CAdditivePrimitiveComputer -----------------------------
334  public:
335 
349  template <typename TInputIterator>
350  bool extend( TInputIterator it, TInputIterator itE );
351 
366  template <typename TInputIterator>
367  bool isExtendable( TInputIterator it, TInputIterator itE ) const;
368 
369  //-------------------- Parameters services -----------------------------
370  public:
371 
378  template <typename Vector3D>
379  void getNormal( Vector3D & normal ) const;
380 
387  template <typename Vector3D>
388  void getUnitNormal( Vector3D & normal ) const;
389 
397  void getBounds( double & min, double & max ) const;
398 
405  const Point & minimalPoint() const;
406 
413  const Point & maximalPoint() const;
414 
415  // ----------------------- Interface --------------------------------------
416  public:
417 
422  void selfDisplay ( std::ostream & out ) const;
423 
428  bool isValid() const;
429 
430  // ------------------------- Private Datas --------------------------------
431  private:
436  State myState;
440  mutable State _state;
442  // ------------------------- Hidden services ------------------------------
443  protected:
444 
445 
446  // ------------------------- Internals ------------------------------------
447  private:
448 
457  void computeCentroidAndNormal( State & state ) const;
458 
472  void doubleCut( InternalPoint2 & grad, State & state ) const;
473 
487  template <typename TInputIterator>
488  void computeMinMax( State & state, TInputIterator itB, TInputIterator itE ) const;
489 
507  template <typename TInputIterator>
508  bool updateMinMax( State & state, TInputIterator itB, TInputIterator itE ) const;
509 
519  bool checkPlaneWidth( const State & state ) const;
520 
528  void computeGradient( InternalPoint2 & grad, const State & state ) const;
529 
530  }; // end of class COBANaivePlane
531 
532 
539  template <typename TSpace, typename TInternalInteger>
540  std::ostream&
541  operator<< ( std::ostream & out, const COBANaivePlane<TSpace, TInternalInteger> & object );
542 
543 } // namespace DGtal
544 
545 
547 // Includes inline functions.
548 #include "DGtal/geometry/surfaces/COBANaivePlane.ih"
549 
550 // //
552 
553 #endif // !defined COBANaivePlane_h
554 
555 #undef COBANaivePlane_RECURSES
556 #endif // else defined(COBANaivePlane_RECURSES)