testStelSphereGeometry.cpp   testStelSphereGeometry.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "config.h"
#include "tests/testStelSphereGeometry.hpp"
#include <QObject> #include <QObject>
#include <QtDebug> #include <QtDebug>
#include <QtTest> #include <QBuffer>
#include <QTest>
#include <stdexcept> #include <stdexcept>
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelSphereGeometry.hpp" #include "StelSphereGeometry.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "tests/testStelSphereGeometry.hpp"
QTEST_MAIN(TestStelSphericalGeometry) QTEST_MAIN(TestStelSphericalGeometry)
void TestStelSphericalGeometry::initTestCase() void TestStelSphericalGeometry::initTestCase()
{ {
// Testing code for new polygon code // Testing code for new polygon code
QVector<QVector<Vec3d> > contours; QVector<QVector<Vec3d> > contours;
QVector<Vec3d> c1(4); QVector<Vec3d> c1(4);
StelUtils::spheToRect(-0.5, -0.5, c1[3]); StelUtils::spheToRect(-0.5, -0.5, c1[3]);
StelUtils::spheToRect(0.5, -0.5, c1[2]); StelUtils::spheToRect(0.5, -0.5, c1[2]);
StelUtils::spheToRect(0.5, 0.5, c1[1]); StelUtils::spheToRect(0.5, 0.5, c1[1]);
skipping to change at line 368 skipping to change at line 371
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
QString msg("Exception while loading: "); QString msg("Exception while loading: ");
msg+=e.what(); msg+=e.what();
QFAIL(qPrintable(msg)); QFAIL(qPrintable(msg));
} }
QVERIFY(reg->getType()==SphericalRegion::Polygon); QVERIFY(reg->getType()==SphericalRegion::Polygon);
qDebug() << reg->getArea()*180./M_PI*180/M_PI; qDebug() << reg->getArea()*180./M_PI*180/M_PI;
QVERIFY(reg->getOutlinePrimitiveType()==PrimitiveType_Lines && //StelVertexArray vertexAr = reg->getOutlineVertexArray();
reg->getOutlineVertexPositions().size()%2==0); //QVERIFY(vertexAr.primitiveType==StelVertexArray::Lines && vertexAr
.vertex.size()%2==0);
} }
void TestStelSphericalGeometry::benchmarkContains() void TestStelSphericalGeometry::benchmarkContains()
{ {
Vec3d v0, v1; Vec3d v0, v1;
StelUtils::spheToRect(0., 0., v0); StelUtils::spheToRect(0., 0., v0);
StelUtils::spheToRect(0.3, 0.3, v1); StelUtils::spheToRect(0.3, 0.3, v1);
QBENCHMARK { QBENCHMARK {
holySquare.contains(v1); holySquare.contains(v1);
skipping to change at line 417 skipping to change at line 420
QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(0,0,0))); QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(0,0,0)));
QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(1,0,0))); QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(1,0,0)));
QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(1,1,0))); QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1, 0,0), Vec3d(1,1,0), Vec3d(1,1,0)));
QVERIFY(OctahedronPolygon::isTriangleConvexPositive2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0))); QVERIFY(OctahedronPolygon::isTriangleConvexPositive2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0)));
SubContour contour(smallSquareConvex.getConvexContour()); SubContour contour(smallSquareConvex.getConvexContour());
OctahedronPolygon splittedSub(contour); OctahedronPolygon splittedSub(contour);
QCOMPARE(splittedSub.getArea(), smallSquareConvex.getArea()); QCOMPARE(splittedSub.getArea(), smallSquareConvex.getArea());
QVector<Vec3d> va = northPoleSquare.getOutlineVertexPositions(); //QVector<Vec3d> va = northPoleSquare.getOutlineVertexArray().vertex
QCOMPARE(va.size(),16); ;
va = southPoleSquare.getOutlineVertexPositions(); //QCOMPARE(va.size(),16);
QCOMPARE(va.size(),16); //va = southPoleSquare.getOutlineVertexArray().vertex;
//QCOMPARE(va.size(),16);
// Copy // Copy
OctahedronPolygon splittedSubCopy; OctahedronPolygon splittedSubCopy;
splittedSubCopy = splittedSub; splittedSubCopy = splittedSub;
QCOMPARE(splittedSub.getArea(), splittedSubCopy.getArea()); QCOMPARE(splittedSub.getArea(), splittedSubCopy.getArea());
double oldArea = splittedSubCopy.getArea(); double oldArea = splittedSubCopy.getArea();
splittedSub = OctahedronPolygon(); splittedSub = OctahedronPolygon();
QCOMPARE(splittedSub.getArea(), 0.); QCOMPARE(splittedSub.getArea(), 0.);
QCOMPARE(splittedSubCopy.getArea(), oldArea); QCOMPARE(splittedSubCopy.getArea(), oldArea);
 End of changes. 5 change blocks. 
9 lines changed or deleted 14 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/