Linux test merged.

This commit is contained in:
Vahagn Khachatryan
2013-02-22 23:48:24 +04:00
parent 16f2ae5f57
commit a730bde647
16 changed files with 747 additions and 269 deletions

View File

@@ -19,7 +19,6 @@
#include <stdio.h>
#include "base/port.h"
#include "base/types.h"
#include "base/constants.h"
#include "base/except.h"
#include "base/rectangle.h"
@@ -149,29 +148,23 @@ namespace base
extern pMultFun multFnTbl[transformTypeMAX*transformTypeMAX];
typedef pod::point<short> (*pModifyFunDblToShort)(const transform &, pod::point<double>);
typedef pod::point<short> (*pModifyFunLongToShort)(const transform &, pod::point<i64>);
typedef pod::point<short> (*pModifyFunLongToShort)(const transform &, pod::point<long>);
typedef pod::point<short> (*pModifyFunIntToShort)(const transform &, pod::point<int>);
typedef pod::point<double> (*pModifyFunDblToDbl)(const transform &, pod::point<double>);
typedef pod::point<int> (*pModifyFunDblToInt)(const transform &, pod::point<double>);
typedef pod::point<int> (*pModifyFunLongToInt)(const transform &, pod::point<i64>);
typedef pod::point<double> (*pModifyFunDblToDbl)(const transform &, pod::point<double>);
typedef pod::point<int> (*pModifyFunLongToInt)(const transform &, pod::point<long>);
typedef pod::point<int> (*pModifyFunIntToInt)(const transform &, pod::point<int>);
typedef pod::point<i64> (*pModifyFunLongToLong)(const transform &, pod::point<i64>);
typedef pod::point<i64> (*pModifyFunLongLongToLongLong)(const transform &, pod::point<i64>);
typedef pod::point<long> (*pModifyFunLongToLong)(const transform &, pod::point<long>);
//
/// Type definition for for transforming a rectangle of type double to
/// another rectangle of type double.
//
typedef pod::rectangle<double> (*pModifyRectFunDblToDbl)(const transform &, const pod::rectangle<double> &);
//
/// Type definition for for transforming a rectangle of type i64 to
/// another rectangle of type i64.
/// Type definition for for transforming a rectangle of type long to
/// another rectangle of type long.
//
typedef pod::rectangle<i64> (*pModifyRectFunLongToLong)(const transform &, const pod::rectangle<i64> &);
typedef pod::rectangle<i64> (*pModifyRectFunLongLongToLongLong)(const transform &, const pod::rectangle<i64> &);
typedef pod::rectangle<long> (*pModifyRectFunLongToLong)(const transform &, const pod::rectangle<long> &);
//
/// Type definition for for transforming a rectangle of type int to
/// another rectangle of type int.
@@ -186,9 +179,7 @@ namespace base
extern pModifyFunLongToInt modifyLongToIntFunTbl[transformTypeMAX];
extern pModifyFunIntToInt modifyIntToIntFunTbl[transformTypeMAX];
extern pModifyFunLongToLong modifyLongToLongFunTbl[transformTypeMAX];
extern pModifyFunLongLongToLongLong modifyLongLongToLongLongFunTbl[transformTypeMAX];
extern pModifyRectFunLongToLong modifyRectLongToLongFunTbl[transformTypeMAX];
extern pModifyRectFunLongLongToLongLong modifyRectLongLongToLongLongFunTbl[transformTypeMAX];
extern pModifyRectFunDblToDbl modifyRectDblToDblFunTbl[transformTypeMAX];
extern pModifyRectFunIntToInt modifyRectIntToIntFunTbl[transformTypeMAX];
@@ -243,7 +234,7 @@ namespace base
typedef pod::point<short> (*pModifyFunLongToShort)(
const transform &T,
pod::point<i64> xy );
pod::point<long> xy );
typedef pod::point<int> (*pModifyFunDblToInt)(
const transform &T,
@@ -255,23 +246,19 @@ namespace base
typedef pod::point<int> (*pModifyFunLongToInt)(
const transform &T,
pod::point<i64> xy );
pod::point<long> xy );
typedef pod::point<i64> (*pModifyFunDblToLong)(
typedef pod::point<long> (*pModifyFunDblToLong)(
const transform &T,
pod::point<double> xy );
typedef pod::point<i64> (*pModifyFunIntToLong)(
typedef pod::point<long> (*pModifyFunIntToLong)(
const transform &T,
pod::point<int> xy );
typedef pod::point<i64> (*pModifyFunLongToLong)(
typedef pod::point<long> (*pModifyFunLongToLong)(
const transform &T,
pod::point<i64> xy );
typedef pod::point<i64> (*pModifyFunLongLongToLongLong)(
const transform &T,
pod::point<i64> xy );
pod::point<long> xy );
typedef pod::point<double> (*pModifyFunDblToDbl)(
const transform &T,
@@ -283,7 +270,7 @@ namespace base
typedef pod::point<double> (*pModifyFunLongToDbl)(
const transform &T,
pod::point<i64> xy );
pod::point<long> xy );
private:
@@ -445,13 +432,6 @@ namespace base
//
/// Initialize the function tables.
//
/*!
Attention please: Since base is (currently) linked statically all
the global variables in transform.h get instantiated multiple times
in Windows (Linux is smarter here), hence all the shared libraries
(that intend to be running on Windows) should consider calling
initFnTables() in their initialization code.
*/
static void initFnTables();
//
@@ -1004,21 +984,21 @@ public:
//
pod::point<int> modifyDblToInt(pod::point<int>) const
{ return pod::point<int>(); }
pod::point<int> modifyDblToInt(pod::point<i64>) const
pod::point<int> modifyDblToInt(pod::point<long>) const
{ return pod::point<int>(); }
pod::point<short> modifyDblToShort(pod::point<int>) const
{ return pod::point<short>(); }
pod::point<short> modifyDblToShort(pod::point<i64>) const
pod::point<short> modifyDblToShort(pod::point<long>) const
{ return pod::point<short>(); }
pod::point<double> modifyDblToDbl(pod::point<int>) const
{ return pod::point<double>(); }
pod::point<int> modifyIntToInt(pod::point<double>) const
{ return pod::point<int>(); }
pod::point<int> modifyIntToInt(pod::point<i64>) const
pod::point<int> modifyIntToInt(pod::point<long>) const
{ return pod::point<int>(); }
pod::point<short> modifyIntToShort(pod::point<double>) const
{ return pod::point<short>(); }
pod::point<short> modifyIntToShort(pod::point<i64>) const
pod::point<short> modifyIntToShort(pod::point<long>) const
{ return pod::point<short>(); }
pod::point<short> modifyLongToShort(pod::point<int>) const
{ return pod::point<short>(); }
@@ -1055,6 +1035,12 @@ public:
{
return (*(modifyDblToDblFunTbl[type]))(*this, p);
}
#ifdef WIN32
pod::point<int64> modify(pod::point<int64> p) const
{
return (*(modifyLongToLongFunTbl[type]))(*this, p);
}
#endif
template<class C>
pod::rectangle<C> modify(pod::rectangle<C> p) const
@@ -1076,7 +1062,7 @@ public:
return (*(modifyIntToShortFunTbl[type]))(*this, p);
}
pod::point<short> modifyLongToShort(pod::point<i64> p) const
pod::point<short> modifyLongToShort(pod::point<long> p) const
{
return (*(modifyLongToShortFunTbl[type]))(*this, p);
}
@@ -1084,7 +1070,7 @@ public:
//
/// Transform longs to ints.
//
pod::point<int> modifyLongToInt(pod::point<i64> p) const
pod::point<int> modifyLongToInt(pod::point<long> p) const
{
return (*(modifyLongToIntFunTbl[type]))(*this, p);
}
@@ -1092,20 +1078,12 @@ public:
//
/// Transform longs to longs.
//
pod::point<i64> modifyLongToLong(pod::point<i64> p) const
pod::point<long> modifyLongToLong(pod::point<long> p) const
{
return (*(modifyLongToLongFunTbl[type]))(*this, p);
}
//
/// Transform longs to longs.
//
pod::point<i64> modifyLongLongToLongLong(pod::point<i64> p) const
{
return (*(modifyLongLongToLongLongFunTbl[type]))(*this, p);
}
pod::point<i64> modify(pod::point<i64> p) const
pod::point<long> modify(pod::point<long> p) const
{
return (*(modifyLongToLongFunTbl[type]))(*this, p);
}
@@ -1120,11 +1098,11 @@ public:
return (*(modifyRectDblToDblFunTbl[type]))(*this, r);
}
pod::rectangle<i64> operator()(const pod::rectangle<i64> & r) const
pod::rectangle<long> operator()(const pod::rectangle<long> & r) const
{
return (*(modifyRectLongToLongFunTbl[type]))(*this, r);
}
pod::rectangle<int> operator()(const pod::rectangle<int> & r) const
{
return (*(modifyRectIntToIntFunTbl[type]))(*this, r);
@@ -1135,7 +1113,7 @@ public:
return (*(modifyDblToDblFunTbl[type]))(*this, p);
}
pod::point<i64> operator()(const pod::point<i64> & p) const
pod::point<long> operator()(const pod::point<long> & p) const
{
return (*(modifyLongToLongFunTbl[type]))(*this, p);
}
@@ -1192,10 +1170,6 @@ public:
/// Print a transform, mainly for debug purpose.
//
void print(FILE *outStream, const char *linePrefix) const;
//
/// Dump transform.
//
void dump( std::ostream& ) const;
}; // class transform
@@ -1314,32 +1288,6 @@ namespace transformTest
}
return r;
}
//
/// Apply the chain to the rectangle r. Round after each
/// resolution change if needed.
//
pod::rectangle<double> apply(const pod::rectangle<double> &r, bool round = true) const
{
pod::point<double> ll = r.getLowerLeft();
pod::point<double> ur = r.getUpperRight();
for (int i = 0; i < chainSize; i++)
{
ll = ll % chain[i];
ur = ur % chain[i];
if (round)
{
ll = pod::point<double>(::round(ll.getX()),
::round(ll.getY()));
ur = pod::point<double>(::round(ur.getX()),
::round(ur.getY()));
}
}
return pod::rectangle<double>(ll, ur);
}
//
/// Dump transform.
//
void dump( std::ostream& ) const;
};
/*!
@@ -1453,39 +1401,6 @@ namespace transformTest
{
return pod::point<double>(p * col1, p * col2) + offset;
}
//
/// Apply the transformation to a double precision rectangle.
/// The result is the bounding rectangle of the transformed corners.
//
pod::rectangle<double> apply(const pod::rectangle<double> &r) const
{
using std::min;
using std::max;
pod::point<double> ll = pod::point<double>(r.getLowerLeft() * col1,
r.getLowerLeft() * col2);
pod::point<double> lr = pod::point<double>(r.getLowerRight() * col1,
r.getLowerRight() * col2);
pod::point<double> ul = pod::point<double>(r.getUpperLeft() * col1,
r.getUpperLeft() * col2);
pod::point<double> ur = pod::point<double>(r.getUpperRight() * col1,
r.getUpperRight() * col2);
double x1 = min(min(ll.getX(), lr.getX()),
min(ul.getX(), ur.getX()));
double y1 = min(min(ll.getY(), lr.getY()),
min(ul.getY(), ur.getY()));
double x2 = max(max(ll.getX(), lr.getX()),
max(ul.getX(), ur.getX()));
double y2 = max(max(ll.getY(), lr.getY()),
max(ul.getY(), ur.getY()));
return pod::rectangle<double>(x1 + offset.getX(), y1 + offset.getY(),
x2 + offset.getX(), y2 + offset.getY());
}
//
/// Dump transform.
//
void dump( std::ostream& os ) const;
};
} // namespace base