110#define DETAIL_MR_UNIT_ENUMS(X) X(NoUnit) X(LengthUnit) X(AngleUnit) X(PixelSizeUnit) X(RatioUnit) X(TimeUnit) X(MovementSpeedUnit) X(AreaUnit) X(VolumeUnit) X(InvLengthUnit)
115#pragma clang diagnostic push
116#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
118#define DETAIL_MR_UNIT_VALUE_TYPES(X, ...) \
119 X(float ,__VA_ARGS__) X(double ,__VA_ARGS__) X(long double ,__VA_ARGS__) \
120 X(signed char ,__VA_ARGS__) X(unsigned char ,__VA_ARGS__) \
121 X(short ,__VA_ARGS__) X(unsigned short ,__VA_ARGS__) \
122 X(int ,__VA_ARGS__) X(unsigned int ,__VA_ARGS__) \
123 X(long ,__VA_ARGS__) X(unsigned long ,__VA_ARGS__) \
124 X(long long ,__VA_ARGS__) X(unsigned long long ,__VA_ARGS__)
126#pragma clang diagnostic pop
132 #define MR_X(E) || std::same_as<T, E>
157#define MR_X(E) template <> [[nodiscard]] MRMESH_API MR_BIND_IGNORE const UnitInfo& getUnitInfo( E unit );
174namespace detail::Units
176 template <
typename T>
177 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
179 template <
typename T>
186template <UnitEnum E,
typename T>
193 if constexpr ( std::is_same_v<T, ReturnType> )
195 if ( !needConversion )
201 for (
int i = 0; i < VectorTraits<T>::size; i++ )
206 bool needElemConversion = needConversion;
207 if constexpr ( std::is_floating_point_v<typename VectorTraits<T>::BaseType> )
209 if ( needElemConversion &&
212 target >= std::numeric_limits<typename VectorTraits<T>::BaseType>::max()
215 needElemConversion =
false;
218 if ( needElemConversion )
226template <UnitEnum E,
typename T>
#define MR_X(E)
Definition MRUnitInfo.h:157
#define DETAIL_MR_UNIT_ENUMS(X)
Definition MRUnitInfo.h:110
Definition MRUnitInfo.h:131
Definition MRUnitInfo.h:177
std::conditional_t< std::is_integral_v< typename VectorTraits< T >::BaseType >, typename VectorTraits< T >::template ChangeBaseType< float >, T > MakeFloatingPoint
Definition MRUnitInfo.h:180
Definition MRCameraOrientationPlugin.h:8
PixelSizeUnit
Definition MRUnitInfo.h:40
const UnitInfo & getUnitInfo(E unit)=delete
NoUnit
Definition MRUnitInfo.h:14
bool unitsAreEquivalent(E a, E b)
Definition MRUnitInfo.h:163
LengthUnit
Definition MRUnitInfo.h:20
RatioUnit
Definition MRUnitInfo.h:47
MovementSpeedUnit
Definition MRUnitInfo.h:63
detail::Units::MakeFloatingPoint< T > convertUnits(E from, E to, const T &value)
Definition MRUnitInfo.h:187
VolumeUnit
Definition MRUnitInfo.h:87
AreaUnit
Definition MRUnitInfo.h:75
TimeUnit
Definition MRUnitInfo.h:55
InvLengthUnit
Definition MRUnitInfo.h:99
AngleUnit
Definition MRUnitInfo.h:32
Definition MRUnitInfo.h:140
std::string_view unitSuffix
Definition MRUnitInfo.h:149
std::string_view prettyName
Definition MRUnitInfo.h:145
float conversionFactor
Definition MRUnitInfo.h:143
Definition MRMesh/MRVectorTraits.h:15
static constexpr auto && getElem(int i, U &&value)
Definition MRMesh/MRVectorTraits.h:29
T BaseType
Definition MRMesh/MRVectorTraits.h:18