testStelSphericalIndex.cpp   testStelSphericalIndex.cpp 
skipping to change at line 31 skipping to change at line 31
#include <QObject> #include <QObject>
#include <QDebug> #include <QDebug>
#include <QTest> #include <QTest>
#include <stdexcept> #include <stdexcept>
#include "StelSphereGeometry.hpp" #include "StelSphereGeometry.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
QTEST_MAIN(TestStelSphericalIndex) QTEST_GUILESS_MAIN(TestStelSphericalIndex)
class TestRegionObject : public StelRegionObject class TestRegionObject : public StelRegionObject
{ {
public: public:
TestRegionObject(SphericalRegionP reg) : region(reg) {;} TestRegionObject(SphericalRegionP reg) : region(reg) {;}
virtual SphericalRegionP getRegion() const {return region;} virtual SphericalRegionP getRegion() const { return region;
}
virtual Vec3d getPointInRegion() const { return Vec3d(0,0,0)
; }
SphericalRegionP region; SphericalRegionP region;
}; };
void TestStelSphericalIndex::initTestCase() void TestStelSphericalIndex::initTestCase()
{ {
} }
struct CountFuncObject struct CountFuncObject
{ {
CountFuncObject() : count(0) {;} CountFuncObject() : count(0) {;}
skipping to change at line 61 skipping to change at line 62
} }
int count; int count;
}; };
void TestStelSphericalIndex::testBase() void TestStelSphericalIndex::testBase()
{ {
StelSphericalIndex grid(10); StelSphericalIndex grid(10);
grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP( new SphericalCap(Vec3d(1,0,0), 0.9))))); grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP( new SphericalCap(Vec3d(1,0,0), 0.9)))));
grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP( new SphericalCap(Vec3d(-1,0,0), 0.99))))); grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP( new SphericalCap(Vec3d(-1,0,0), 0.99)))));
CountFuncObject countFunc; CountFuncObject countFunc;
grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Ve grid.processIntersectingRegions(&(*SphericalRegionP(new SphericalCap
c3d(1,0,0), 0.5)), countFunc); (Vec3d(1,0,0), 0.5))), countFunc);
grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Ve grid.processIntersectingRegions(&(*SphericalRegionP(new SphericalCap
c3d(1,0,0), 0.95)), countFunc); (Vec3d(1,0,0), 0.95))), countFunc);
QVERIFY(countFunc.count==2); QVERIFY(countFunc.count==2);
countFunc.count=0; countFunc.count=0;
grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Ve c3d(0,1,0), 0.99)), countFunc); grid.processIntersectingRegions(&(*SphericalRegionP(new SphericalCap (Vec3d(0,1,0), 0.99))), countFunc);
QVERIFY(countFunc.count==0); QVERIFY(countFunc.count==0);
// Process all // Process all
countFunc.count=0; countFunc.count=0;
grid.processAll(countFunc); grid.processAll(countFunc);
QVERIFY(countFunc.count==2); QVERIFY(countFunc.count==2);
// Clear // Clear
grid.clear(); grid.clear();
countFunc.count=0; countFunc.count=0;
skipping to change at line 95 skipping to change at line 96
bigSquareConvex.setContour(c1); bigSquareConvex.setContour(c1);
// try with many elements // try with many elements
for (int i=0;i<10000;++i) for (int i=0;i<10000;++i)
{ {
grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalCap(Vec3d(1,0,0), 0.99))))); grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalCap(Vec3d(1,0,0), 0.99)))));
grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalPoint(Vec3d(1,0,0)))))); grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalPoint(Vec3d(1,0,0))))));
grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalConvexPolygon(c1))))); grid.insert(StelRegionObjectP(new TestRegionObject(Spherical RegionP(new SphericalConvexPolygon(c1)))));
} }
countFunc.count=0; countFunc.count=0;
grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Ve c3d(1,0,0), 0.5)), countFunc); grid.processIntersectingRegions(&(*SphericalRegionP(new SphericalCap (Vec3d(1,0,0), 0.5))), countFunc);
QVERIFY(countFunc.count==30000); QVERIFY(countFunc.count==30000);
countFunc.count=0; countFunc.count=0;
grid.processIntersectingRegions(SphericalRegionP(new SphericalConvex Polygon(c1)), countFunc); grid.processIntersectingRegions(&(*SphericalRegionP(new SphericalCon vexPolygon(c1))), countFunc);
qDebug() << countFunc.count; qDebug() << countFunc.count;
QVERIFY(countFunc.count==30000); QVERIFY(countFunc.count==30000);
} }
 End of changes. 6 change blocks. 
9 lines changed or deleted 12 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/