DGtal  1.5.beta
AngleLinearMinimizer.h
1 
17 #pragma once
18 
35 #if defined(AngleLinearMinimizer_RECURSES)
36 #error Recursive header files inclusion detected in AngleLinearMinimizer.h
37 #else // defined(AngleLinearMinimizer_RECURSES)
39 #define AngleLinearMinimizer_RECURSES
40 
41 #if !defined AngleLinearMinimizer_h
43 #define AngleLinearMinimizer_h
44 
46 // Inclusions
47 #include <iostream>
48 #include <vector>
49 #include "DGtal/base/Common.h"
50 #include "DGtal/math/AngleComputer.h"
51 #include "DGtal/arithmetic/ModuloComputer.h"
53 
54 namespace DGtal
55 {
56 
58 // class AngleLinearMinimizer
68 {
69 
70 public:
74  struct ValueInfo
75  {
79  double value;
80 
84  double oldValue;
85 
89  double min;
90 
94  double max;
95 
99  double distToNext;
100 
101  };
102 
103 
104 
105  // ----------------------- Standard services ------------------------------
106 public:
107 
112 
117 
121  void reset();
122 
128  void init( unsigned int nbMax );
129 
130 
134  ValueInfo & rw( unsigned int i );
135 
136 
140  const ValueInfo & ro( unsigned int i ) const;
141 
145  unsigned int maxSize() const;
146 
150  unsigned int size() const;
151 
156  void setSize( unsigned int nb );
157 
164  void setIsCurveOpen( bool is_curve_open = false );
165 
166 
167 
168 
169  // ------------------------- Optimization services --------------------------
170 
171 public:
172 
178  double getEnergy( unsigned int i1, unsigned int i2 ) const;
179 
185  double getFormerEnergy( unsigned int i1, unsigned int i2 ) const;
186 
187 
191  std::vector<double> getGradient() const;
192 
193 
197  std::vector<double> getFormerGradient() const;
198 
208  double optimize();
209 
210 
223  double optimize( unsigned int i1, unsigned int i2 );
224 
225 
229  double sum() const;
230 
231 
232 
236  double max() const;
237 
238 
239 protected:
240 
250  virtual void oneStep( unsigned int i1, unsigned int i2 );
251 
252 
253 public:
262  virtual double lastDelta() const;
263 
264 
265 
266 
267 
268  // --------------- CDrawableWithBoard2D realization -------------------
269  public:
270 
274  std::string className() const;
275 
276  // ----------------------- Interface --------------------------------------
277 public:
278 
279 
284  void selfDisplay ( std::ostream & out ) const;
285 
290  bool isValid() const;
291 
292  // ------------------------- Protected Datas ------------------------------
293 
294 protected:
299 
304 
309  unsigned int mySize;
310 
311 private:
312 
316  unsigned int myMaxSize;
317 
318 
319  // ------------------------- Private Datas --------------------------------
320 private:
324  double mySum;
325 
329  double myMax;
330 
331  // ------------------------- Hidden services ------------------------------
332 
333 
334 
335 private:
349 
350 
351 
352  // ------------------------- Internals ------------------------------------
353 private:
354 
355 }; // end of class AngleLinearMinimizer
356 
357 
358 
359 
364  {
365  public:
370 
375 
376  protected:
377 
386  virtual void oneStep( unsigned int i1, unsigned int i2 );
387 
388 public:
397  virtual double lastDelta() const;
398 
399  // ----------------------- Interface --------------------------------------
400  public:
405  virtual void selfDisplay( std::ostream & aStream ) const;
406 
407  };
408 
409 
410 
415  {
416  private:
417 
421  double myStep;
422 
423  public:
428 
433 
434  protected:
435 
444  virtual void oneStep( unsigned int i1, unsigned int i2 );
445 
446 public:
455  virtual double lastDelta() const;
456 
457  // ----------------------- Interface --------------------------------------
458  public:
463  virtual void selfDisplay( std::ostream & aStream ) const;
464 
465  };
466 
467 
473  {
474  private:
475 
479  double myStep;
480 
481  public:
486 
491 
492  protected:
493 
502  virtual void oneStep( unsigned int i1, unsigned int i2 );
503 
504 public:
513  virtual double lastDelta() const;
514 
515  // ----------------------- Interface --------------------------------------
516  public:
521  virtual void selfDisplay( std::ostream & aStream ) const;
522 
523  };
524 
525 
526 
527 
534 std::ostream&
535 operator<< ( std::ostream & out, const AngleLinearMinimizer & object );
536 
537 
538 } // namespace DGtal
539 
540 
542 // Includes inline functions.
543 #include "DGtal/math/AngleLinearMinimizer.ih"
544 
545 // //
547 
548 #endif // !defined AngleLinearMinimizer_h
549 
550 #undef AngleLinearMinimizer_RECURSES
551 #endif // else defined(AngleLinearMinimizer_RECURSES)
virtual void selfDisplay(std::ostream &aStream) const
virtual void oneStep(unsigned int i1, unsigned int i2)
virtual void oneStep(unsigned int i1, unsigned int i2)
virtual void selfDisplay(std::ostream &aStream) const
virtual void oneStep(unsigned int i1, unsigned int i2)
virtual void selfDisplay(std::ostream &aStream) const
Aim: Used to minimize the angle variation between different angles while taking into accounts min and...
void selfDisplay(std::ostream &out) const
AngleLinearMinimizer(const AngleLinearMinimizer &other)
const ValueInfo & ro(unsigned int i) const
void setSize(unsigned int nb)
std::vector< double > getGradient() const
void setIsCurveOpen(bool is_curve_open=false)
double getFormerEnergy(unsigned int i1, unsigned int i2) const
std::string className() const
unsigned int maxSize() const
virtual void oneStep(unsigned int i1, unsigned int i2)
void init(unsigned int nbMax)
std::vector< double > getFormerGradient() const
ValueInfo & rw(unsigned int i)
unsigned int size() const
AngleLinearMinimizer & operator=(const AngleLinearMinimizer &other)
double optimize(unsigned int i1, unsigned int i2)
virtual double lastDelta() const
double getEnergy(unsigned int i1, unsigned int i2) const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)