StemModel.hpp
1 #pragma once
2 
3 #include <opals/config.hpp>
4 #include <opals/Vector.hpp>
5 #include <opals/String.hpp>
6 #include <opals/Array.hpp>
7 #include <opals/DBHModel.hpp>
8 #include <opals/CustomOptionType.hpp>
9 #include <DM/IAddInfo.hpp>
10 #include <DM/IFilter.hpp>
11 
12 namespace opals {
13 
14  /** \brief A stem entry object represents the results of a single model fit
15 
16  ModuleDBH fits a cylinder or a cone to points of a stem sections and stores the
17  within this class. Following parameters are stored in the object:
18 
19  - traceId of the current fit: 0 for initial fit, positive numbers while forward tracing and negative numbers while backward tracing)
20  - point coordinates of representative adjusted point
21  - adjusted axis vector
22  - adjusted radius at the representative point
23  - convergence angle which is only set for cone fits: it is the angle between the cone generatrix and the cone axis.
24  The value is set positive if the cone radius is decreasing when advancing in axis direction and
25  negative if it is increasing.
26  - radial deviation based on inlier points
27  - offset vector from the approximate point to the adjusted axis
28  - delta radius: correction of approximate radius value
29  - redundancy of adjustment
30  - nObs : number of adjustment observations
31  - nUsed : number of used inlier observations
32  - model fitting type : cone or cylinder
33 
34  \author jo
35  \date 11.03.2020
36  */
37 
38  class OPALS_API StemEntry
39  {
40  public:
41  StemEntry();
42  ~StemEntry();
43 
44  void reset();
45 
46  bool isSetTraceId() const;
47  bool isSetPointX() const;
48  bool isSetPointY() const;
49  bool isSetPointZ() const;
50  bool isSetAxisX() const;
51  bool isSetAxisY() const;
52  bool isSetAxisZ() const;
53  bool isSetRadius() const;
54  bool isSetConvergenceAngle() const;
55  bool isSetRadialDeviation() const;
56  bool isSetOffsetX() const;
57  bool isSetOffsetY() const;
58  bool isSetOffsetZ() const;
59  bool isSetDeltaRadius() const;
60  bool isSetNrObs() const;
61  bool isSetNrUsed() const;
62  bool isSetRedundancy() const;
63  bool isSetFittingType() const;
64 
65  int64_t getTraceId() const;
66  Array<double, 3> getPoint() const;
67  double getPointX() const;
68  double getPointY() const;
69  double getPointZ() const;
70  Array<double, 3> getAxis() const;
71  double getAxisX() const;
72  double getAxisY() const;
73  double getAxisZ() const;
74  double getRadius() const;
75  double getConvergenceAngle() const;
76  double getRadialDeviation() const;
77  Array<double, 3> getOffset() const;
78  double getOffsetX() const;
79  double getOffsetY() const;
80  double getOffsetZ() const;
81  double getDeltaRadius() const;
82  unsigned getNrObs() const;
83  unsigned getNrUsed() const;
84  unsigned getRedundancy() const;
85  DBHModel getFittingType() const;
86 
87  void setTraceId(const int64_t& id);
88  void setPoint(const double &x, const double &y, const double &z);
89  void setPointX(const double &x);
90  void setPointY(const double &y);
91  void setPointZ(const double &z);
92  void setAxis(const double &ax, const double &ay, const double &az);
93  void setAxisX(const double &ax);
94  void setAxisY(const double &ay);
95  void setAxisZ(const double &az);
96  void setRadius(const double &r);
97  void setConvergenceAngle(const double &angle);
98  void setRadialDeviation(const double &d);
99  void setOffset(const double &ox, const double &oy, const double &oz);
100  void setOffsetX(const double &ox);
101  void setOffsetY(const double &oy);
102  void setOffsetZ(const double &oz);
103  void setDeltaRadius(const double &dr);
104  void setNrObs(const unsigned &nObs);
105  void setNrUsed(const unsigned &nUsed);
106  void setRedundancy(const unsigned &red);
107  void setFittingType(const DBHModel &t);
108 
109  String logStemEntry() const; ///< for xml output
110 
111  protected:
112  int64_t _traceId;
113  double _ptX, _ptY, _ptZ;
114  double _axisX, _axisY, _axisZ;
115  double _radius;
116  double _convergenceAngle;
117  double _radialDev;
118  double _offsetX, _offsetY, _offsetZ;
119  double _deltaRadius;
120  unsigned _nObs, _nUsed;
121  unsigned _redundancy;
122 
123  DBHModel _fittingType;
124  };
125 
126  /// \class StemModel
127  /// A StemModel object stores a vector of fitted stem objects.
128  /** ModuleDBH creates this object for each input stem and attaches all corresponding model fits to it. Furthermore, some administrative information is stored:
129  - stem ID of the input stem approximation;
130  - optional pass through transfer attribute object that was provided by the user;
131  - optional stem based filter object; */
132  class OPALS_API StemModel : public CustomOptionType<StemModel>
133  {
134  public:
136 
137  StemModel();
138  ~StemModel();
139 
140  void reset();
141 
142  bool isSetStemId() const;
143  bool isSetEntries() const;
144  bool isSetTransferInfo() const;
145  bool isSetDataFilter() const;
146 
147  int64_t getStemId() const;
148  EntryVector getEntries() const;
149  DM::AddInfoHandle getTransferInfo() const;
150  DM::FilterHandle getDataFilter() const;
151 
152  void setStemId(const int64_t &id);
153  void setEntries(const EntryVector &entries);
154  void setTransferInfo(const DM::AddInfoHandle &info);
155  void setDataFilter(const DM::FilterHandle &filter);
156 
157  void setData(const int64_t &id, const StemEntry& entry, const DM::AddInfoHandle &info = DM::AddInfoHandle());
158 
159  String logStemModel() const; ///< for xml output
160 
161  static bool exportsPythonType();
162  static const char * help(bool);
163  static const char * syntax();
164 
165  protected:
166  int64_t _stemId;
167  EntryVector _entries;
168  DM::AddInfoHandle _transferInfo;
169  DM::FilterHandle _filter;
170  };
171 
172 }
173 
Base class for all custom parameter types.
Definition: CustomOptionType.hpp:39
A stem entry object represents the results of a single model fit.
Definition: StemModel.hpp:38
Contains the public interface of OPALS.
Definition: AbsValueOrQuantile.hpp:8
@ info
Some progress that may be interesting in everyday-use.
Definition: StemModel.hpp:132
Smart pointer class using reference counting with support for DM objects (see ObjectBase)
Definition: Handle.hpp:75
DBHModel
Specifying DBH geometry fitting model.
Definition: DBHModel.hpp:8
A dynamic character string whose interface conforms to STL's std::string.
Definition: String.hpp:35