Field3D
Types.h File Reference

Contains typedefs for the commonly used types in Field3D. More...

#include <vector>
#include <limits>
#include "StdMathLib.h"

Go to the source code of this file.

Classes

struct  Interval
 Represents a single integration interval. The interval is assumed to be inclusive, i.e. [t0,t1]. More...
 

Typedefs

typedef std::vector< IntervalIntervalVec
 

Functions

template<typename From_T , typename To_T >
To_T clampForType (const From_T v)
 

Detailed Description

Contains typedefs for the commonly used types in Field3D.

Definition in file Types.h.

Typedef Documentation

◆ IntervalVec

typedef std::vector<Interval> IntervalVec

Definition at line 87 of file Types.h.

Function Documentation

◆ clampForType()

template<typename From_T , typename To_T >
To_T clampForType ( const From_T  v)

Definition at line 94 of file Types.h.

95 {
96  // Different behavior for integer vs fp types
97  To_T lowestTo;
98  From_T lowest;
99  if (std::numeric_limits<To_T>::is_integer) {
100  lowestTo = std::numeric_limits<To_T>::min();
101  lowest = static_cast<From_T>(lowestTo);
102  } else {
103  lowestTo = -std::numeric_limits<To_T>::max();
104  lowest = static_cast<From_T>(lowestTo);
105  }
106  const To_T highestTo = std::numeric_limits<To_T>::max();
107  const From_T highest = static_cast<From_T>(highestTo);
108  // Perform check
109  if (v < lowest) {
110  return lowest;
111  } else if (v > highest) {
112  return highest;
113  }
114  return v;
115 }

References detail::max(), and detail::min().

detail::max
T max(const T a, const T2 b)
Max operation on mixed types.
Definition: FieldSampler.h:32
detail::min
T min(const T a, const T2 b)
Min operation on mixed types.
Definition: FieldSampler.h:25