14 #ifndef ossimCommon_HEADER 15 #define ossimCommon_HEADER 1 19 #define ossimREQUIRE(expr) 20 #define ossimENSURE(expr) 21 #define ossimCHECK(expr) 22 #define ossimSTATIC_CHECK(expr,msg) 55 {
return std::fabs(
x -
y) <= tolerance; }
60 {
return x >= a &&
x <= b; }
65 {
return x > a &&
x < b; }
77 #if defined(WIN32) || defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(__MWERKS__) 78 inline bool isnan(
const float& v) {
return _isnan(v); }
79 inline bool isnan(
const double& v) {
return _isnan(v); }
80 #elif defined(sun) || defined(__sun) 81 # if defined(__SVR4) || defined(__svr4__) 83 inline bool isnan(
const float& v) {
return ( ::
isnan(v) ); }
84 inline bool isnan(
const double& v) {
return ( ::
isnan(v) ); }
87 inline bool isnan(
const float& v) {
return ( ::
isnan(v) ); }
88 inline bool isnan(
const double& v) {
return ( ::
isnan(v) ); }
135 inline double nan() {
return nanValue.bits.floatname; }
138 inline T
abs(
const T& value)
146 template <
class S,
class T>
149 {
return x*(end - begin) + begin; }
155 {
return begin == end ? (
ossim::isnan(
x) ?
x : T(0)) : (
x - begin)/(end - begin); }
157 template <
class S,
class T>
162 const T a1 = S(2)*(middle - begin);
163 const T a2 = S(2)*(end - middle) - a1;
164 return x*((
x - S(0.5))*a2 + a1) + begin;
189 return std::fmod(
x - z, b - a) + z;
206 return (a < b) ? a : b;
218 return (a < b) ? a : b;
231 return (a < b) ? a : b;
239 return (a < b) ? b : a;
247 return (a < b) ? b : a;
255 return (a < b) ? b : a;
270 template <
class IntType>
271 IntType
gcd(IntType
n, IntType m)
311 return gcd(m,
n % m);
314 template <
class IntType>
315 IntType
lcm(IntType
n, IntType m)
322 if (
n == zero || m == zero) {
342 const T table[] = {T(0), T(1), T(-1)};
343 return table[((x < T(0)) << 1) | (x > T(0))];
360 template <
class R,
class F>
364 R result =
static_cast<R
>((
x < F(0)) ? std::ceil(
x - F(0.5)) : std::floor(
x + F(0.5)));
384 T s = std::sqrt(b*b - T(4)*a*c);
386 return std::pair<T, T>((-b + s)/twoA, (-b - s)/twoA);
392 { memset(&var, z,
sizeof(T)); }
397 {
ossimSTATIC_CHECK(
false, YOU_PROBABLY_WANT_TO_MEMCLEAR_WHAT_THE_POINTER_POINTS_TO_NOT_THE_POINTER_ITSELF); }
437 const NEWMAT::Matrix& rotation );
441 const NEWMAT::Matrix& lsrMatrix,
442 const NEWMAT::Matrix& rotationalMatrix);
446 const char* whitespace,
448 std::vector<std::string>& tokens,
bool& unbalancedQuotes);
456 const std::vector<ossimDpt>& pointList,
459 const std::vector<ossimIpt>& pointList,
460 char separator =
' ');
462 const std::vector<ossimGpt>& pointList,
463 char seaprator =
' ');
485 const std::vector<T>& valuesList)
489 if(!valuesList.empty())
493 for(idx = 0; idx <
size; ++idx)
495 out << valuesList[idx] <<
",";
497 out << valuesList[
size];
500 result =
"("+out.str()+
")";
514 const std::vector<ossim_uint8>& valuesList);
517 const std::vector<ossim_float64>& valuesList);
520 const std::vector<ossim_float32>& valuesList);
523 const std::vector<ossimString>& valuesList);
541 bool returnValue =
true;
547 while( (c!=
')') && (c!=
'\n') && (in.good()) )
555 result.push_back(static_cast<T>(value.
toDouble()));
658 std::string& result );
IntFloatBitCoercion(ossim_float64 x)
OSSIM_DLL ossim_uint32 computeLevels(const ossimIrect &rect)
Computes the number of decimation levels to get to the overview stop dimension.
OSSIM_DLL ossim_int64 getTime()
Gets the current time.
ossim_float64 max< ossim_float64 >(ossim_float64 a, ossim_float64 b)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
OSSIM_DLL void toStringList(ossimString &resultStringOfPoints, const std::vector< ossimDpt > &pointList, char separator=' ')
Will take a vector of ossimDpt and convert to a string list separated by spaces For example: (45...
std::pair< T, T > quadraticRoots(T a, T b, T c)
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
T inverseLerp(T x, T begin, T end)
double nan()
Method to return ieee floating point double precision NAN.
This code was derived from https://gist.github.com/mshockwave.
bool inOpenInterval(T x, T a, T b)
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
void toSimpleStringList(ossimString &result, const std::vector< T > &valuesList)
This will output a vector of values inst a string.
OSSIM_DLL ossimByteOrder byteOrder()
ossim_float32 sgn< ossim_float32 >(ossim_float32 x)
OSSIM_DLL ossim_uint32 getActualBitsPerPixel(ossimScalarType scalarType)
Get actual bits per pixel for a given scalar type.
OSSIM_DLL bool extractSimpleValues(std::vector< ossimString > &values, const ossimString &stringOfPoints)
Generic function to extract a list of values into a vector of string where the string of points is of...
ossim_float32 min< ossim_float32 >(ossim_float32 a, ossim_float32 b)
bool isnan(const double &v)
OSSIM_DLL ossim_uint32 getNumberOfThreads()
Get the number threads to use from ossimPreferences or ossim::Thread.
OSSIM_DLL std::string convertHtmlSpecialCharactersToNormalCharacter(const std::string &src)
bool inInterval(T x, T a, T b)
bool toSimpleVector(std::vector< T > &result, const ossimString &stringOfPoints)
double radiansToDegrees(double x)
void push_back(char c)
Equivalent to insert(end(), c).
#define ossimSTATIC_CHECK(expr, msg)
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
OSSIM_DLL bool isSigned(ossimScalarType scalarType)
OSSIM_DLL std::istream & skipws(std::istream &in)
IntFloatBitCoercion(ossim_int64 x)
OSSIM_DLL void toVector(std::vector< ossimDpt > &result, const ossimString &stringOfPoints)
Will take a string list separated by spaces and convert to a vector of ossimDpts. ...
#define ossimENSURE(expr)
double degreesToRadians(double x)
OSSIM_DLL void getFormattedTime(const std::string &format, bool gmtFlag, std::string &result)
Gets the current time.
os2<< "> n<< " > nendobj n
OSSIM_DLL double defaultNull(ossimScalarType scalarType)
T quaderp(S x, T begin, T middle, T end)
unsigned int ossim_uint32
void memClear(T &var, int z=0)
double atan2d(double y, double x)
OSSIM_DLL bool matrixToHpr(ossim_float64 hpr[3], const NEWMAT::Matrix &rotation)
Heading pitch roll extraction from a matrix.
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
Class lets us see bit patterns of floats.
OSSIM_DLL void lexQuotedTokens(const std::string &str, ossim_uint32 start, const char *whitespace, const char *quotes, std::vector< std::string > &tokens, bool &unbalancedQuotes)
double ft2mtrs(double feet)
OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType)
Get bits per pixel for a given scalar type.
std::basic_istream< char > istream
Base class for char input streams.
T lerp(S x, T begin, T end)
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
double usft2mtrs(double feet)
IntType lcm(IntType n, IntType m)
int gcd< int >(int n, int m)
#define ossimREQUIRE(expr)
double mtrs2usft(double meters)
std::basic_istringstream< char > istringstream
Class for char input memory streams.
double mtrs2ft(double meters)
OSSIM_DLL bool isWhiteSpace(int c)
OSSIM_DLL_DATA(const IntFloatBitCoercion) nanValue
Declaration of nan part of nan() declared here for inline ossim::nan().
ossim_float32 max< ossim_float32 >(ossim_float32 a, ossim_float32 b)
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
IntType gcd(IntType n, IntType m)
ossim_float64 min< ossim_float64 >(ossim_float64 a, ossim_float64 b)