IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
MeasureSrcMacros.h
Go to the documentation of this file.
1 // MeasureSrcMacros.h:
3 // -------------------
4 //
15 
16 #ifndef __IPSDKBASESHAPEANALYSIS_MEASURESRCMACROS_H__
17 #define __IPSDKBASESHAPEANALYSIS_MEASURESRCMACROS_H__
18 
22 #include <boost/make_shared.hpp>
23 
26 
29 #define IPSDK_IMPLEMENT_INDIVISIBLE_MEASURE(libraryName, namespaceSeq, msrName, version) \
30  IPSDK_IMPLEMENT_SERIAL_WITH_COPY(libraryName, namespaceSeq, BOOST_PP_CAT(msrName, Msr), version) \
31  const BOOST_PP_CAT(msrName, Msr)::MsrParamsConstStorageType& \
32  BOOST_PP_CAT(msrName, Msr)::getMsrParams() const { \
33  if (_pMsrDerivedParams.get() == 0) \
34  _pMsrDerivedParams = boost::static_pointer_cast<MsrParamsConstType>( \
35  getMeasureInfo().getMsrParams()); \
36  return _pMsrDerivedParams; \
37  } \
38  ipsdk::shape::analysis::MeasureResultPtr \
39  BOOST_PP_CAT(msrName, Msr)::startProcessingDerived(const ipsdk::ipUInt64 defaultNbColorPlans, \
40  const ipsdk::ipUInt64 nbEntities, \
41  const bool bForceNbColorPlans, \
42  const bool bWithIgnoredFirstElement) { \
43  boost::shared_ptr<MsrResultType> pMsrResults(boost::make_shared<MsrResultType>()); \
44  ipUInt64 usedNbColorPlans = 1; \
45  if (bForceNbColorPlans == true) \
46  usedNbColorPlans = defaultNbColorPlans; \
47  else { \
48  if (hasColorDependency() == true) \
49  usedNbColorPlans = defaultNbColorPlans; \
50  } \
51  pMsrResults->init(usedNbColorPlans, nbEntities); \
52  return pMsrResults; \
53  } \
54  ipsdk::BoolResult \
55  BOOST_PP_CAT(msrName, Msr)::measureDerived(const ipUInt64 cPlanIdx) { \
56  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
57  MsrResultCollType& resultColl = msrResults.getColl(cPlanIdx); \
58  BoolResult bRes = processMeasure(cPlanIdx, resultColl); \
59  if (bRes == false) \
60  return bRes; \
61  return true; \
62  }
63 
66 #define IPSDK_IMPLEMENT_GENERIC_MEASURE(libraryName, namespaceSeq, msrName, version) \
67  IPSDK_IMPLEMENT_SERIAL_WITH_COPY(libraryName, namespaceSeq, BOOST_PP_CAT(msrName, Msr), version) \
68  const BOOST_PP_CAT(msrName, Msr)::MsrParamsConstStorageType& \
69  BOOST_PP_CAT(msrName, Msr)::getMsrParams() const { \
70  if (_pMsrDerivedParams.get() == 0) \
71  _pMsrDerivedParams = boost::static_pointer_cast<MsrParamsConstType>( \
72  getMeasureInfo().getMsrParams()); \
73  return _pMsrDerivedParams; \
74  } \
75  ipsdk::shape::analysis::MeasureResultPtr \
76  BOOST_PP_CAT(msrName, Msr)::startProcessingDerived(const ipsdk::ipUInt64 defaultNbColorPlans, \
77  const ipsdk::ipUInt64 nbEntities, \
78  const bool bForceNbColorPlans, \
79  const bool bWithIgnoredFirstElement) { \
80  boost::shared_ptr<MsrResultType> pMsrResults(boost::make_shared<MsrResultType>()); \
81  ipUInt64 usedNbColorPlans = 1; \
82  if (bForceNbColorPlans == true) \
83  usedNbColorPlans = defaultNbColorPlans; \
84  else { \
85  if (hasColorDependency() == true) \
86  usedNbColorPlans = defaultNbColorPlans; \
87  } \
88  pMsrResults->init(usedNbColorPlans, nbEntities); \
89  return pMsrResults; \
90  } \
91  ipsdk::BoolResult \
92  BOOST_PP_CAT(msrName, Msr)::measureShapeDerived(const ipUInt64 cPlanIdx, \
93  const ipsdk::ipUInt64 shapeIdx) { \
94  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
95  MsrResultValueType result; \
96  BoolResult bRes = processMeasure(cPlanIdx, shapeIdx, result); \
97  if (bRes == false) \
98  return bRes; \
99  msrResults.getColl(cPlanIdx)[shapeIdx] = result; \
100  return true; \
101  }
102 
105 #define IPSDK_IMPLEMENT_GEOMETRY2D_MEASURE(libraryName, namespaceSeq, msrName, version) \
106  IPSDK_IMPLEMENT_SERIAL_WITH_COPY(libraryName, namespaceSeq, BOOST_PP_CAT(msrName, Msr), version) \
107  const BOOST_PP_CAT(msrName, Msr)::MsrParamsConstStorageType& \
108  BOOST_PP_CAT(msrName, Msr)::getMsrParams() const { \
109  if (_pMsrDerivedParams.get() == 0) \
110  _pMsrDerivedParams = boost::static_pointer_cast<MsrParamsConstType>( \
111  getMeasureInfo().getMsrParams()); \
112  return _pMsrDerivedParams; \
113  } \
114  ipsdk::shape::analysis::MeasureResultPtr \
115  BOOST_PP_CAT(msrName, Msr)::startProcessingDerived(const ipsdk::ipUInt64 defaultNbColorPlans, \
116  const ipsdk::ipUInt64 nbEntities, \
117  const bool bForceNbColorPlans, \
118  const bool bWithIgnoredFirstElement) { \
119  boost::shared_ptr<MsrResultType> pMsrResults(boost::make_shared<MsrResultType>()); \
120  pMsrResults->init(1, nbEntities); \
121  return pMsrResults; \
122  } \
123  ipsdk::BoolResult \
124  BOOST_PP_CAT(msrName, Msr)::measureShapeDerived(const ipsdk::ipUInt64 shapeIdx, \
125  const ipsdk::geom::Shape2d& shape2d) { \
126  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
127  MsrResultValueType result; \
128  BoolResult bRes = processMeasure(shapeIdx, shape2d, result); \
129  if (bRes == false) \
130  return bRes; \
131  msrResults.getColl()[shapeIdx] = result; \
132  return true; \
133  }
134 
137 #define IPSDK_IMPLEMENT_GEOMETRY3D_MEASURE(libraryName, namespaceSeq, msrName, version) \
138  IPSDK_IMPLEMENT_SERIAL_WITH_COPY(libraryName, namespaceSeq, BOOST_PP_CAT(msrName, Msr), version) \
139  const BOOST_PP_CAT(msrName, Msr)::MsrParamsConstStorageType& \
140  BOOST_PP_CAT(msrName, Msr)::getMsrParams() const { \
141  if (_pMsrDerivedParams.get() == 0) \
142  _pMsrDerivedParams = boost::static_pointer_cast<MsrParamsConstType>( \
143  getMeasureInfo().getMsrParams()); \
144  return _pMsrDerivedParams; \
145  } \
146  ipsdk::shape::analysis::MeasureResultPtr \
147  BOOST_PP_CAT(msrName, Msr)::startProcessingDerived(const ipsdk::ipUInt64 defaultNbColorPlans, \
148  const ipsdk::ipUInt64 nbEntities, \
149  const bool bForceNbColorPlans, \
150  const bool bWithIgnoredFirstElement) { \
151  boost::shared_ptr<MsrResultType> pMsrResults(boost::make_shared<MsrResultType>()); \
152  pMsrResults->init(1, nbEntities); \
153  return pMsrResults; \
154  } \
155  ipsdk::BoolResult \
156  BOOST_PP_CAT(msrName, Msr)::measureShapeDerived(const ipsdk::ipUInt64 shapeIdx, \
157  const ipsdk::geom::Shape3d& shape3d) { \
158  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
159  MsrResultValueType result; \
160  BoolResult bRes = processMeasure(shapeIdx, shape3d, result); \
161  if (bRes == false) \
162  return bRes; \
163  msrResults.getColl()[shapeIdx] = result; \
164  return true; \
165  }
166 
169 #define IPSDK_IMPLEMENT_INTENSITY_MEASURE(libraryName, namespaceSeq, msrName, version) \
170  IPSDK_IMPLEMENT_SERIAL_WITH_COPY(libraryName, namespaceSeq, BOOST_PP_CAT(msrName, Msr), version) \
171  const BOOST_PP_CAT(msrName, Msr)::MsrParamsConstStorageType& \
172  BOOST_PP_CAT(msrName, Msr)::getMsrParams() const { \
173  if (_pMsrDerivedParams.get() == 0) \
174  _pMsrDerivedParams = boost::static_pointer_cast<MsrParamsConstType>( \
175  getMeasureInfo().getMsrParams()); \
176  return _pMsrDerivedParams; \
177  } \
178  ipsdk::shape::analysis::MeasureResultPtr \
179  BOOST_PP_CAT(msrName, Msr)::startProcessingDerived(const ipsdk::ipUInt64 defaultNbColorPlans, \
180  const ipsdk::ipUInt64 nbEntities, \
181  const bool bForceNbColorPlans, \
182  const bool bWithIgnoredFirstElement) { \
183  boost::shared_ptr<MsrResultType> pMsrResults(boost::make_shared<MsrResultType>()); \
184  pMsrResults->init(defaultNbColorPlans, nbEntities); \
185  if (nbEntities != 0) { \
186  for (ipsdk::ipUInt64 cPlanIdx = 0; cPlanIdx<defaultNbColorPlans; ++cPlanIdx) \
187  initMsrResults(cPlanIdx, nbEntities, bWithIgnoredFirstElement, pMsrResults->getColl(cPlanIdx)); \
188  } \
189  return pMsrResults; \
190  } \
191  ipsdk::BoolResult \
192  BOOST_PP_CAT(msrName, Msr)::measureShapeDerived(const ipsdk::ipUInt64 cPlanIdx, \
193  const ipsdk::ipUInt64 shapeIdx, \
194  const ipsdk::geom::RowSegments& rowSegments, \
195  const ipsdk::image::eImageBufferType& imageBufferType, \
196  const ipsdk::ipUInt64 rowIdx, \
197  const ipsdk::ipUInt64 zPlanIdx, \
198  const void* pBuf) { \
199  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
200  MsrResultValueType& curMsrResult = msrResults.getColl(cPlanIdx)[shapeIdx]; \
201  switch (imageBufferType.value()) { \
202  case ipsdk::image::eImageBufferType::eIBT_Int8: { \
203  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Int8>::type DataType; \
204  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
205  while (iterSeg != rowSegments.end()) { \
206  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
207  iterSeg->_startX, iterSeg->_endX, \
208  imageBufferType, rowIdx, zPlanIdx, \
209  static_cast<const DataType*>(pBuf), \
210  curMsrResult); \
211  if (bRes == false) \
212  return bRes; \
213  ++iterSeg; \
214  } \
215  return true; \
216  } \
217  case ipsdk::image::eImageBufferType::eIBT_UInt8: { \
218  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_UInt8>::type DataType; \
219  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
220  while (iterSeg != rowSegments.end()) { \
221  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
222  iterSeg->_startX, iterSeg->_endX, \
223  imageBufferType, rowIdx, zPlanIdx, \
224  static_cast<const DataType*>(pBuf), \
225  curMsrResult); \
226  if (bRes == false) \
227  return bRes; \
228  ++iterSeg; \
229  } \
230  return true; \
231  } \
232  case ipsdk::image::eImageBufferType::eIBT_Int16: { \
233  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Int16>::type DataType; \
234  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
235  while (iterSeg != rowSegments.end()) { \
236  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
237  iterSeg->_startX, iterSeg->_endX, \
238  imageBufferType, rowIdx, zPlanIdx, \
239  static_cast<const DataType*>(pBuf), \
240  curMsrResult); \
241  if (bRes == false) \
242  return bRes; \
243  ++iterSeg; \
244  } \
245  return true; \
246  } \
247  case ipsdk::image::eImageBufferType::eIBT_UInt16: { \
248  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_UInt16>::type DataType; \
249  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
250  while (iterSeg != rowSegments.end()) { \
251  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
252  iterSeg->_startX, iterSeg->_endX, \
253  imageBufferType, rowIdx, zPlanIdx, \
254  static_cast<const DataType*>(pBuf), \
255  curMsrResult); \
256  if (bRes == false) \
257  return bRes; \
258  ++iterSeg; \
259  } \
260  return true; \
261  } \
262  case ipsdk::image::eImageBufferType::eIBT_Int32: { \
263  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Int32>::type DataType; \
264  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
265  while (iterSeg != rowSegments.end()) { \
266  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
267  iterSeg->_startX, iterSeg->_endX, \
268  imageBufferType, rowIdx, zPlanIdx, \
269  static_cast<const DataType*>(pBuf), \
270  curMsrResult); \
271  if (bRes == false) \
272  return bRes; \
273  ++iterSeg; \
274  } \
275  return true; \
276  } \
277  case ipsdk::image::eImageBufferType::eIBT_UInt32: { \
278  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_UInt32>::type DataType; \
279  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
280  while (iterSeg != rowSegments.end()) { \
281  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
282  iterSeg->_startX, iterSeg->_endX, \
283  imageBufferType, rowIdx, zPlanIdx, \
284  static_cast<const DataType*>(pBuf), \
285  curMsrResult); \
286  if (bRes == false) \
287  return bRes; \
288  ++iterSeg; \
289  } \
290  return true; \
291  } \
292  case ipsdk::image::eImageBufferType::eIBT_Real32: { \
293  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Real32>::type DataType; \
294  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
295  while (iterSeg != rowSegments.end()) { \
296  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
297  iterSeg->_startX, iterSeg->_endX, \
298  imageBufferType, rowIdx, zPlanIdx, \
299  static_cast<const DataType*>(pBuf), \
300  curMsrResult); \
301  if (bRes == false) \
302  return bRes; \
303  ++iterSeg; \
304  } \
305  return true; \
306  } \
307  case ipsdk::image::eImageBufferType::eIBT_Binary: { \
308  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Binary>::type DataType; \
309  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
310  while (iterSeg != rowSegments.end()) { \
311  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
312  iterSeg->_startX, iterSeg->_endX, \
313  imageBufferType, rowIdx, zPlanIdx, \
314  static_cast<const DataType*>(pBuf), \
315  curMsrResult); \
316  if (bRes == false) \
317  return bRes; \
318  ++iterSeg; \
319  } \
320  return true; \
321  } \
322  case ipsdk::image::eImageBufferType::eIBT_Label16: { \
323  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Label16>::type DataType; \
324  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
325  while (iterSeg != rowSegments.end()) { \
326  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
327  iterSeg->_startX, iterSeg->_endX, \
328  imageBufferType, rowIdx, zPlanIdx, \
329  static_cast<const DataType*>(pBuf), \
330  curMsrResult); \
331  if (bRes == false) \
332  return bRes; \
333  ++iterSeg; \
334  } \
335  return true; \
336  } \
337  case ipsdk::image::eImageBufferType::eIBT_Label32: { \
338  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Label32>::type DataType; \
339  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
340  while (iterSeg != rowSegments.end()) { \
341  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
342  iterSeg->_startX, iterSeg->_endX, \
343  imageBufferType, rowIdx, zPlanIdx, \
344  static_cast<const DataType*>(pBuf), \
345  curMsrResult); \
346  if (bRes == false) \
347  return bRes; \
348  ++iterSeg; \
349  } \
350  return true; \
351  } \
352  case ipsdk::image::eImageBufferType::eIBT_Label8: { \
353  typedef ipsdk::image::ImageType2Buffer<ipsdk::image::eImageBufferType::eIBT_Label8>::type DataType; \
354  ipsdk::geom::RowSegments::const_iterator iterSeg = rowSegments.begin(); \
355  while (iterSeg != rowSegments.end()) { \
356  ipsdk::BoolResult bRes = processMeasure<DataType>(cPlanIdx, shapeIdx, \
357  iterSeg->_startX, iterSeg->_endX, \
358  imageBufferType, rowIdx, zPlanIdx, \
359  static_cast<const DataType*>(pBuf), \
360  curMsrResult); \
361  if (bRes == false) \
362  return bRes; \
363  ++iterSeg; \
364  } \
365  return true; \
366  } \
367  default : { \
368  ipsdk::LogMessageFormater logMsgFormater( \
369  ipsdk::shape::analysis::getIPSDKBaseShapeAnalysisLogMessageManager()); \
370  logMsgFormater[ipsdk::shape::analysis::eMeasureMessage::eInvalidImageBufferType] % \
371  imageBufferType.str(); \
372  return ipsdk::BoolResult(false, logMsgFormater.string()); \
373  } \
374  } \
375  } \
376  ipsdk::BoolResult \
377  BOOST_PP_CAT(msrName, Msr)::collectResultsDerived(const ipsdk::UInt64Vector& resultIndexColl, \
378  const ipsdk::shape::analysis::BaseMeasure& subMeasure) { \
379  MsrResultType& msrResults = static_cast<MsrResultType&>(accessMeasureResult()); \
380  const MsrResultType& subMsrResults = static_cast<const MsrResultType&>(subMeasure.getMeasureResult()); \
381  const ipsdk::ipUInt64 nbColorPlans = getNbColorPlans(); \
382  for (ipsdk::ipUInt64 cPlanIdx = 0; cPlanIdx<nbColorPlans; ++cPlanIdx) { \
383  ipsdk::BoolResult bRes = processResults(cPlanIdx, resultIndexColl, \
384  subMsrResults.getColl(cPlanIdx), msrResults.getColl(cPlanIdx)); \
385  if (bRes == false) \
386  return bRes; \
387  } \
388  return true; \
389  }
390 
393 
394 #endif // __IPSDKBASESHAPEANALYSIS_MEASURESRCMACROS_H__
Log messages description.
Logger api for library IPSDKBaseShapeAnalysis.
Source part of macros set for class serialization.