8#ifndef META_OCEAN_CV_CALIBRATION_METRIC_SIZE_H
9#define META_OCEAN_CV_CALIBRATION_METRIC_SIZE_H
92 inline std::string
value(
const UnitType unitType,
const unsigned int precision)
const;
98 inline bool isNull()
const;
248 template <UnitType TSourceUnit, UnitType TTargetUnit>
249 static double convert(
const double sourceValue);
258 template <UnitType TSourceUnit>
259 static double convert(
const double sourceValue,
const UnitType targetUnit);
345 ocean_assert(
value.isValid());
383inline double MetricSize::convert<MetricSize::UT_MILLIMETER, MetricSize::UT_INCH>(
const double sourceValue)
385 return sourceValue / 25.4;
389inline double MetricSize::convert<MetricSize::UT_INCH, MetricSize::UT_MILLIMETER>(
const double sourceValue)
391 return sourceValue * 25.4;
394template <MetricSize::UnitType TSourceUnit, MetricSize::UnitType TTargetUnit>
397 static_assert(TSourceUnit == TTargetUnit,
"Missing specialization for either TSourceUnit or TTargetUnit");
404inline double MetricSize::convert<MetricSize::UT_MILLIMETER>(
const double sourceValue,
const UnitType targetUnit)
406 ocean_assert(targetUnit != UT_INVALID);
414 return convert<UT_MILLIMETER, UT_MILLIMETER>(sourceValue);
417 return convert<UT_MILLIMETER, UT_INCH>(sourceValue);
420 ocean_assert(
false &&
"Invalid unit type!");
425inline double MetricSize::convert<MetricSize::UT_INCH>(
const double sourceValue,
const UnitType targetUnit)
427 ocean_assert(targetUnit != UT_INVALID);
435 return convert<UT_INCH, UT_MILLIMETER>(sourceValue);
438 return convert<UT_INCH, UT_INCH>(sourceValue);
441 ocean_assert(
false &&
"Invalid unit type!");
445template <MetricSize::UnitType TSourceUnit>
448 static_assert(oceanFalse<TSourceUnit>(),
"Missing specialization");
This class implements an object holding a metric size like width, height, length, or thickness.
Definition MetricSize.h:32
MetricSize & operator*=(const double factor)
Multiplies and assigns this metric object with a scalar factor.
Definition MetricSize.h:320
bool operator<(const MetricSize &value) const
Returns whether this metric size object is smaller than a second one.
Definition MetricSize.h:352
MetricSize operator-(const MetricSize &value) const
Subtracts two metric size objects.
Definition MetricSize.h:303
bool operator>(const MetricSize &value) const
Returns whether this metric size object is greater than a second one.
Definition MetricSize.h:362
PaperType
Definition of different paper types.
Definition MetricSize.h:52
@ PT_INVALID
An invalid paper type.
Definition MetricSize.h:54
@ PT_LETTER
The paper is a letter.
Definition MetricSize.h:60
@ PT_TABLOID
The paper is a tabloid aka ledger.
Definition MetricSize.h:62
@ PT_DIN_A3
The paper is a DIN A3.
Definition MetricSize.h:56
@ PT_DIN_A4
The paper is a DIN A4.
Definition MetricSize.h:58
static std::string translateUnitType(const UnitType unitType)
Returns the string of a unit type.
bool isNull() const
Returns whether the size value is zero.
Definition MetricSize.h:281
MetricSize & operator-=(const MetricSize &value)
Subtracts and assigns two metric size objects.
Definition MetricSize.h:308
bool isValid() const
Returns whether this size object holds a valid value.
Definition MetricSize.h:286
MetricSize(const double value, const UnitType unitType)
Creates a new metric size object.
double valueMillimeter_
The metric size in millimeter, with range (-infinity, infinity).
Definition MetricSize.h:273
static std::string translatePaperType(const PaperType paperType)
Translates the paper type value to a readable string.
double value(const UnitType unitType) const
Returns the size value in a specific unit.
MetricSize & operator+=(const MetricSize &value)
Adds and assigns two metric size objects.
Definition MetricSize.h:296
MetricSize operator/(const double factor) const
Divides this metric size object by a scalar factor.
Definition MetricSize.h:327
bool operator<=(const MetricSize &value) const
Returns whether this metric size object is smaller or equal than a second one.
Definition MetricSize.h:357
bool operator!=(const MetricSize &value) const
Returns whether two metric size objects do not hold the same size values.
Definition MetricSize.h:377
static bool determinePaperSize(const PaperType paperType, MetricSize &width, MetricSize &height)
Returns the metric width and height of a paper.
MetricSize operator+(const MetricSize &value) const
Adds two metric size objects.
Definition MetricSize.h:291
MetricSize operator*(const double factor) const
Multiplies this metric size object with a scalar factor.
Definition MetricSize.h:315
bool operator==(const MetricSize &value) const
Returns whether two metric size objects hold the same size values.
Definition MetricSize.h:372
static double convert(const double sourceValue)
Converts the size value from one unit to another unit.
Definition MetricSize.h:395
bool operator>=(const MetricSize &value) const
Returns whether this metric size object is greater or equal than a second one.
Definition MetricSize.h:367
static double convert(const UnitType sourceUnit, const double sourceValue, const UnitType targetUnit)
Converts the metric size defined in one unit to another unit.
MetricSize()=default
Creates a new object creating an invalid metric size.
static PaperType translatePaperType(const std::string &paperType)
Translates the string of a paper type to a paper type value.
MetricSize & operator/=(const double factor)
Divides and assigns this metric size object by a scalar factor.
Definition MetricSize.h:334
UnitType
Definition of different unit types.
Definition MetricSize.h:39
@ UT_MILLIMETER
Millimeter as unit.
Definition MetricSize.h:43
@ UT_INVALID
An invalid unit type.
Definition MetricSize.h:41
@ UT_INCH
Inch as unit.
Definition MetricSize.h:45
static constexpr T minValue()
Returns the min scalar value.
Definition Numeric.h:3253
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition Numeric.h:2389
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2090
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2240
static bool isNotEqual(const T first, const T second)
Returns whether two values are not equal up to a small epsilon.
Definition Numeric.h:2616
static std::string toAString(const char value)
Converts a value to a string with 8bit character.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15