IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
BaseMeasureInfo.h
1 // BaseMeasureInfo.h:
3 // ------------------
4 //
14 
15 #ifndef __IPSDKBASESHAPEANALYSIS_BASEMEASUREINFO_H__
16 #define __IPSDKBASESHAPEANALYSIS_BASEMEASUREINFO_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::shape::analysis::BaseMeasureInfo::_measureName' : class 'std::basic_string<_Elem,_Traits,_Alloc>' needs to have dll-interface to be used by clients of class 'ipsdk::shape::analysis::BaseMeasureInfo'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
25 #include <IPSDKBaseData/ToolTip/BaseToolTip.h>
27 #include <IPSDKSerialization/Engine/BaseSerializationObject.h>
28 #include <IPSDKUtil/Tools/ProcessingResult.h>
29 #include <boost/enable_shared_from_this.hpp>
30 #include <boost/optional.hpp>
31 
32 namespace ipsdk {
33 namespace shape {
34 namespace analysis {
35 
38 
40  public BaseToolTip,
41  public boost::enable_shared_from_this<BaseMeasureInfo>
42 {
43  // declare serial class
45 
46  // friend class for protected members access
47  friend class MeasureInfoFactory;
48 
49 protected:
52 
53 public:
55  virtual ~BaseMeasureInfo() = 0;
56 
57 // methods
58 public:
60  virtual const std::string& getDefaultName() const = 0;
61 
63  bool isInit() const;
64 
70  const std::string& getMeasureName() const;
71 
75  bool is2dMode() const;
76 
77  //------------------------------------------------
80  //------------------------------------------------
81 
83  virtual eMsrProcessingPolicy getMsrProcessingPolicy() const = 0;
84 
86  eMsrVolumePolicy getMsrVolumePolicy() const;
87 
89  bool is2dMsr() const;
90 
92  bool is3dMsr() const;
93 
95  virtual bool requiresInputImage() const {return false;}
96 
98  virtual eMsrShapeRequirements getMsrShapeRequirements() const = 0;
99 
101  inline bool requiresRowIntersections() const;
102 
104  inline bool requiresBoundaryApproximation() const;
106 
107  //------------------------------------------------
110  //------------------------------------------------
111 
116  const GeometricCalibrationConstPtr& getGeometricCalibration() const;
117 
119  virtual eMsrUnitFormat getMsrUnitFormat() const = 0;
120 
124  std::string getMsrUnitStr() const;
126 
127  //------------------------------------------------
130  //------------------------------------------------
131 
135  MeasureConfigConstPtr getMsrConfig() const;
136 
141  bool hasDefaultConfig() const;
143 
144  //------------------------------------------------
147  //------------------------------------------------
148 
151  virtual DataItemPtr createDefaultParams() const {return DataItemPtr();}
152 
157  bool hasDefaultParams() const;
158 
162  bool hasParams(const MeasureConfigConstPtr& pConfig,
163  const DataItemConstPtr& pParams) const;
164 
169  DataItemConstPtr getMsrParams() const;
171 
172  //--------------------------------------------------
176  //--------------------------------------------------
177 
182  bool dependsOnNamedMsr(const std::string& dependencyName) const;
183 
188  bool dependsOn(const std::string& dependencyDefaultName) const;
189 
194  bool dependsOn(const std::string& dependencyDefaultName,
195  const MeasureConfigConstPtr& pDependencyConfig,
196  const DataItemConstPtr& pDependencyParams) const;
197 
202  MeasureConfigConstPtr getDependencyConfig(const std::string& dependencyName) const;
203 
208  DataItemConstPtr getDependencyParams(const std::string& dependencyName) const;
209 
213  const DependencyMap& getDependencies() const;
215 
219  MeasurePtr createMeasure() const;
220 
221 protected:
224  virtual MeasurePtr createMeasureDerived() const = 0;
225 
227  virtual BoolResult validateMsrParams(const bool b2dMsrMode, const DataItemConstPtr& pMeasureParams) const {return true;}
228 
230  virtual void initDerived() = 0;
231 
234  virtual std::string computeCustomMsrUnitStr(const std::string& baseUnitStr) const {return std::string();}
235 
237  virtual void createDependencies(const bool b2dMsrMode) = 0;
238 
240  virtual void createCustomDependencies(const bool b2dMsrMode) {}
241 
246  void addDependency(const std::string& dependencyDefaultName);
247 
255  void addDependency(const std::string& dependencyName,
256  const std::string& dependencyDefaultName,
257  const MeasureConfigConstPtr& pDependencyConfig,
258  const DataItemConstPtr& pDependencyParams);
259 
264  void addNamedMsrDependency(const std::string& dependencyName);
265 
266 private:
275  BoolResult init(const std::string& measureName,
276  const bool b2dMsrMode,
277  const GeometricCalibrationConstPtr& pGlobalGeometricCalibration,
278  const MeasureConfigConstPtr& pMeasureConfig = MeasureConfigConstPtr(),
279  const DataItemConstPtr& pMeasureParams = DataItemPtr());
280 
281 // attributes
282 private:
284  std::string _measureName;
285 
287  bool _b2dMsrMode;
288 
290  GeometricCalibrationConstPtr _pGeometricCalibration;
291 
293  MeasureConfigConstPtr _pMeasureConfig;
294 
296  DataItemPtr _pMeasureParams;
297 
300  DependencyMap _dependencies;
301 };
302 
305 
306 inline bool
308 {
309  return _measureName.empty() == false;
310 }
311 
312 inline bool
314 {
315  const eMsrShapeRequirements& msrShapeRequirements = getMsrShapeRequirements();
316  return msrShapeRequirements == eMsrShapeRequirements::eMSR_RequireShapeRowIntersect ||
317  msrShapeRequirements == eMsrShapeRequirements::eMSR_RequireShapeAll;
318 }
319 
320 inline bool
322 {
323  const eMsrShapeRequirements& msrShapeRequirements = getMsrShapeRequirements();
324  return msrShapeRequirements == eMsrShapeRequirements::eMSR_RequireShapeBoundaryApprox ||
325  msrShapeRequirements == eMsrShapeRequirements::eMSR_RequireShapeAll;
326 }
327 
330 
331 } // end of namespace analysis
332 } // end of namespace shape
333 } // end of namespace ipsdk
334 
335 #pragma warning (pop)
336 
337 #endif // __IPSDKBASESHAPEANALYSIS_BASEMEASUREINFO_H__
Predefined types for geometric calibration management.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
virtual void createCustomDependencies(const bool b2dMsrMode)
method allowing to retrieve custom dependencies informations
Definition: BaseMeasureInfo.h:240
boost::shared_ptr< BaseMeasure > MeasurePtr
shared pointer to shape measure object
Definition: MeasureTypes.h:65
boost::shared_ptr< const MeasureConfig > MeasureConfigConstPtr
shared pointer to const MeasureConfig object
Definition: MeasureConfigTypes.h:89
boost::shared_ptr< const BaseDataItem > DataItemConstPtr
shared pointer to const DataItem
Definition: DataItemTypes.h:149
boost::shared_ptr< const ipsdk::GeometricCalibration > GeometricCalibrationConstPtr
shared pointer to const ipsdk::GeometricCalibration
Definition: GeometricCalibrationTypes.h:31
measure requires boundary approximation data from shape
Definition: MeasureInfoTypes.h:92
measure requires row intersection data from shape
Definition: MeasureInfoTypes.h:90
#define IPSDK_DECLARE_ABSTRACT_SERIAL_WITHOUT_COPY(libraryName, className)
macro enabling serialization on abstract class
Definition: SerializationHdrMacro.h:97
eMsrVolumePolicy
Enumerate describing measure volume policy.
Definition: MeasureInfoTypes.h:60
Definition of import/export macro for library.
#define IPSDKBASESHAPEANALYSIS_API
Import/Export macro for library IPSDKBaseShapeAnalysis.
Definition: IPSDKBaseShapeAnalysisExports.h:25
virtual BoolResult validateMsrParams(const bool b2dMsrMode, const DataItemConstPtr &pMeasureParams) const
method allowing to validate measure parameters in derived class
Definition: BaseMeasureInfo.h:227
boost::shared_ptr< BaseDataItem > DataItemPtr
shared pointer to DataItem
Definition: DataItemTypes.h:146
Factory singleton allowing dynamic creation of registred measure information class.
Definition: MeasureInfoFactory.h:39
virtual std::string computeCustomMsrUnitStr(const std::string &baseUnitStr) const
Definition: BaseMeasureInfo.h:234
eMsrUnitFormat
Enumerate describing unit format associated to measure.
Definition: MeasureInfoTypes.h:102
eMsrShapeRequirements
Enumerate describing shape data requirement for measure computation.
Definition: MeasureInfoTypes.h:86
eMsrProcessingPolicy
Enumerate describing measure processing policy.
Definition: MeasureInfoTypes.h:42
virtual bool requiresInputImage() const
check whether measure requires input image
Definition: BaseMeasureInfo.h:95
bool requiresRowIntersections() const
check whether measure requires shape row intersection
Definition: BaseMeasureInfo.h:313
virtual eMsrShapeRequirements getMsrShapeRequirements() const =0
retrieve shape data requirements associated to measure
measure requires row intersection and boundary approximation data from shape
Definition: MeasureInfoTypes.h:94
virtual DataItemPtr createDefaultParams() const
Definition: BaseMeasureInfo.h:151
Base class for shape analysis measurement informations.
Definition: BaseMeasureInfo.h:39
Predefined types for measures management.
std::map< std::string, OptMeasureId > DependencyMap
collection of measure dependencies
Definition: MeasureInfoTypes.h:185
bool isInit() const
check for object initialization
Definition: BaseMeasureInfo.h:307
Base class for objects with name and tool tip informations.
Definition: BaseToolTip.h:27
Base class for serializable class.
Definition: BaseSerializationObject.h:33
bool requiresBoundaryApproximation() const
check whether measure requires shape boundary approximation
Definition: BaseMeasureInfo.h:321