summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/mapsgl/frustum.cpp68
-rw-r--r--src/location/mapsgl/frustum_p.h4
-rw-r--r--src/location/mapsgl/map.cpp1
-rw-r--r--src/location/mapsgl/map3d/map3d.pri26
-rw-r--r--src/location/mapsgl/map3d/map3d_p.cpp213
-rw-r--r--src/location/mapsgl/map3d/map3d_p.h88
-rw-r--r--src/location/mapsgl/map3d/projection3d_p.cpp128
-rw-r--r--src/location/mapsgl/map3d/projection3d_p.h74
-rw-r--r--src/location/mapsgl/map3d/sphere.cpp1234
-rw-r--r--src/location/mapsgl/map3d/sphere_p.h177
-rw-r--r--src/location/mapsgl/map3d/spheregeometry.cpp208
-rw-r--r--src/location/mapsgl/map3d/spheregeometry_p.h96
-rw-r--r--src/location/mapsgl/map3d/viewport.cpp126
-rw-r--r--src/location/mapsgl/map3d/viewport_p.h106
-rw-r--r--src/location/mapsgl/map3d/viewportcamera.cpp166
-rw-r--r--src/location/mapsgl/map3d/viewportcamera_p.h111
-rw-r--r--src/location/mapsgl/map3d/viewporttiles.cpp424
-rw-r--r--src/location/mapsgl/map3d/viewporttiles_p.h82
-rw-r--r--src/location/mapsgl/map3d/viewporttiles_p_p.h95
-rw-r--r--src/location/mapsgl/map3d/viewporttilesnew.cpp103
-rw-r--r--src/location/mapsgl/map3d/viewporttilesnew_p.h68
-rw-r--r--src/location/mapsgl/map3d/viewporttilesold.cpp690
-rw-r--r--src/location/mapsgl/map3d/viewporttilesold_p.h108
-rw-r--r--src/location/mapsgl/mapsgl.pri1
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/sphere/sphere.pro8
-rw-r--r--tests/auto/sphere/tst_sphere.cpp1543
27 files changed, 0 insertions, 5952 deletions
diff --git a/src/location/mapsgl/frustum.cpp b/src/location/mapsgl/frustum.cpp
index a667ab47..99ff0fa8 100644
--- a/src/location/mapsgl/frustum.cpp
+++ b/src/location/mapsgl/frustum.cpp
@@ -40,8 +40,6 @@
****************************************************************************/
#include "frustum_p.h"
-#include "viewportcamera_p.h"
-
#include <Qt3D/qglcamera.h>
#include <cmath>
@@ -117,72 +115,6 @@ void Frustum::update(const QGLCamera *camera, double aspectRatio, bool updatePla
planeHash_.insert(Frustum::Planes(Frustum::Bottom), pb);
}
-void Frustum::update(const ViewportCamera &camera)
-{
- if (camera.aspectRatio() > 1.0) {
- double fov = atan2(camera.viewSize().height() , (2 * camera.nearPlane()));
-
- hn_ = 2 * tan(fov) * camera.nearPlane();
- wn_ = hn_ * camera.aspectRatio();
-
- hf_ = 2 * tan(fov) * camera.farPlane();
- wf_ = hf_ * camera.aspectRatio();
- } else {
- double fov = atan2(camera.viewSize().width() , (2 * camera.nearPlane()));
-
- wn_ = 2 * tan(fov) * camera.nearPlane();
- hn_ = wn_ / camera.aspectRatio();
-
- wf_ = 2 * tan(fov) * camera.farPlane();
- hf_ = wf_ / camera.aspectRatio();
- }
-
- QVector3D p = camera.eye();
- QVector3D d = camera.center() - camera.eye();
- d.normalize();
-
- QVector3D up = camera.up();
- up.normalize();
-
- QVector3D right = QVector3D::normal(d, up);
-
- cf_ = p + d * camera.farPlane();
- tlf_ = cf_ + (up * hf_ / 2) - (right * wf_ / 2);
- trf_ = cf_ + (up * hf_ / 2) + (right * wf_ / 2);
- blf_ = cf_ - (up * hf_ / 2) - (right * wf_ / 2);
- brf_ = cf_ - (up * hf_ / 2) + (right * wf_ / 2);
-
- cn_ = p + d * camera.nearPlane();
- tln_ = cn_ + (up * hn_ / 2) - (right * wn_ / 2);
- trn_ = cn_ + (up * hn_ / 2) + (right * wn_ / 2);
- bln_ = cn_ - (up * hn_ / 2) - (right * wn_ / 2);
- brn_ = cn_ - (up * hn_ / 2) + (right * wn_ / 2);
-
- QPlane3D pn = QPlane3D(bln_, tln_, brn_);
- pn.setNormal(pn.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Near), pn);
-
- QPlane3D pf = QPlane3D(blf_, brf_, tlf_);
- pf.setNormal(pf.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Far), pf);
-
- QPlane3D pl = QPlane3D(blf_, tlf_, bln_);
- pl.setNormal(pl.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Left), pl);
-
- QPlane3D pr = QPlane3D(brf_, brn_, trf_);
- pr.setNormal(pr.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Right), pr);
-
- QPlane3D pt = QPlane3D(tlf_, trf_, tln_);
- pt.setNormal(pt.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Top), pt);
-
- QPlane3D pb = QPlane3D(blf_, bln_, brf_);
- pb.setNormal(pb.normal().normalized());
- planeHash_.insert(Frustum::Planes(Frustum::Bottom), pb);
-}
-
bool Frustum::contains(const QVector3D &center, double radius) const
{
if (planeHash_.isEmpty())
diff --git a/src/location/mapsgl/frustum_p.h b/src/location/mapsgl/frustum_p.h
index 7f778894..504ead1f 100644
--- a/src/location/mapsgl/frustum_p.h
+++ b/src/location/mapsgl/frustum_p.h
@@ -57,8 +57,6 @@
#include <Qt3D/qplane3d.h>
-class ViewportCamera;
-
class QGLCamera;
class Q_AUTOTEST_EXPORT Frustum
@@ -85,8 +83,6 @@ public:
Frustum();
- void update(const ViewportCamera &camera);
-
void update(const QGLCamera *camera, double aspectRatio, bool updatePlanes = false);
bool contains(const QVector3D &center, double radius) const;
diff --git a/src/location/mapsgl/map.cpp b/src/location/mapsgl/map.cpp
index 9915ddf6..ec46f0b2 100644
--- a/src/location/mapsgl/map.cpp
+++ b/src/location/mapsgl/map.cpp
@@ -41,7 +41,6 @@
#include "map.h"
#include "map_p.h"
#include "map2d_p.h"
-#include "map3d_p.h"
#include "tilecache.h"
#include "mapsphere_p.h"
diff --git a/src/location/mapsgl/map3d/map3d.pri b/src/location/mapsgl/map3d/map3d.pri
deleted file mode 100644
index dd53928e..00000000
--- a/src/location/mapsgl/map3d/map3d.pri
+++ /dev/null
@@ -1,26 +0,0 @@
-
-INCLUDEPATH += mapsgl/map3d
-
-SOURCES += \
- mapsgl/map3d/projection3d_p.cpp \
- mapsgl/map3d/map3d_p.cpp \
- mapsgl/map3d/sphere.cpp \
- mapsgl/map3d/spheregeometry.cpp \
- mapsgl/map3d/viewport.cpp \
- mapsgl/map3d/viewportcamera.cpp \
- mapsgl/map3d/viewporttiles.cpp \
- mapsgl/map3d/viewporttilesold.cpp \
- mapsgl/map3d/viewporttilesnew.cpp
-
-PRIVATE_HEADERS += \
- mapsgl/map3d/projection3d_p.h \
- mapsgl/map3d/map3d_p.h \
- mapsgl/map3d/sphere_p.h \
- mapsgl/map3d/spheregeometry_p.h \
- mapsgl/map3d/viewport_p.h \
- mapsgl/map3d/viewportcamera_p.h \
- mapsgl/map3d/viewporttiles_p.h \
- mapsgl/map3d/viewporttiles_p_p.h \
- mapsgl/map3d/viewporttilesold_p.h \
- mapsgl/map3d/viewporttilesnew_p.h
-
diff --git a/src/location/mapsgl/map3d/map3d_p.cpp b/src/location/mapsgl/map3d/map3d_p.cpp
deleted file mode 100644
index 398a0313..00000000
--- a/src/location/mapsgl/map3d/map3d_p.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "map3d_p.h"
-#include "projection3d_p.h"
-
-#include "tile.h"
-
-#include <qgeometrydata.h>
-#include <qglbuilder.h>
-#include <Qt3D/qglcamera.h>
-
-#include <cmath>
-
-Map3DPrivate::Map3DPrivate(Map *parent, TileCache *cache, double radius)
- : MapPrivate(parent, cache),
- minZoom_(6),
- radius_(radius)
-{
- Projection3D* p = new Projection3D(radius_);
- setProjection(QSharedPointer<Projection>(p));
- viewport_.setProjection(p);
-}
-
-Map3DPrivate::~Map3DPrivate()
-{
-}
-
-QRect Map3DPrivate::specToRect(const TileSpec &tileSpec) const
-{
- return QRect();
-}
-
-QGeometryData Map3DPrivate::generateTileGeometryData(int x, int y, int tileZoom, int geomZoom) const
-{
- int z = 1 << geomZoom;
-
- double x1 = x * 1.0 / z;
- double x2 = ((x + 1) % z) * 1.0 / z;
- if (x2 == 0.0)
- x2 = 1.0;
- double y1 = y * 1.0 / z;
- double y2 = (y + 1) * 1.0 / z;
-
- QSharedPointer<Projection> p = projection();
-
- QVector3D tl = p->mercatorToPoint(QVector2D(x1, y1));
- QVector3D tr = p->mercatorToPoint(QVector2D(x2, y1));
- QVector3D bl = p->mercatorToPoint(QVector2D(x1, y2));
- QVector3D br = p->mercatorToPoint(QVector2D(x2, y2));
-
- int dz = 1 << (geomZoom - tileZoom);
-
- int tx1 = x % dz;
- int ty1 = y % dz;
-
- ty1 = dz - ty1;
-
- int tx2 = (x + 1) % dz;
- if (tx2 == 0)
- tx2 = dz;
-
- int ty2 = (y + 1) % dz;
- if (ty2 == 0)
- ty2 = dz;
-
- ty2 = dz - ty2;
-
- QGeometryData g;
-
- g.appendVertex(tl);
- g.appendNormal(tl / radius_);
- g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty1 * 1.0 / dz));
-
- g.appendVertex(bl);
- g.appendNormal(bl / radius_);
- g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty2 * 1.0 / dz));
-
- g.appendVertex(br);
- g.appendNormal(br / radius_);
- g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty2 * 1.0 / dz));
-
- g.appendVertex(tr);
- g.appendNormal(tr / radius_);
- g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty1 * 1.0 / dz));
-
- return g;
-}
-
-QGLSceneNode* Map3DPrivate::createTileSpecNode(const TileSpec &tileSpec)
-{
- int tileZoom = tileSpec.zoom();
- int geomZoom = qMax(minZoom_, tileZoom);
-
- int dz = 1 << (geomZoom - tileZoom);
-
- int x1 = tileSpec.x() * dz;
- int y1 = tileSpec.y() * dz;
-
- QGLBuilder builder;
-
- for (int x = 0; x < dz; ++x) {
- for (int y = 0; y < dz; ++y) {
- builder.addQuads(generateTileGeometryData(x1 + x, y1 + y, tileZoom, geomZoom));
- }
- }
-
- return builder.finalizedSceneNode();
-}
-
-void Map3DPrivate::updateGlCamera(QGLCamera* glCamera)
-{
- CameraData camera = cameraData();
-
- double altitude = radius_ * camera.distance();
-
- QSharedPointer<Projection> p = projection();
-
- QGeoCoordinate coord = camera.center();
- coord.setAltitude(0.0);
- QVector3D center = p->coordToPoint(coord);
- coord.setAltitude(altitude);
- QVector3D eye = p->coordToPoint(coord);
-
- QVector3D view = eye - center;
- QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
- QVector3D up = QVector3D::normal(side, view);
-
- QMatrix4x4 mBearing;
- mBearing.rotate(-1.0 * camera.bearing(), view);
- up = mBearing * up;
-
- QVector3D side2 = QVector3D::normal(up, view);
- QMatrix4x4 mTilt;
- mTilt.rotate(camera.tilt(), side2);
- eye = (mTilt * view) + center;
-
- view = eye - center;
- side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
- up = QVector3D::normal(view, side2);
-
- QMatrix4x4 mRoll;
- mRoll.rotate(camera.roll(), view);
- up = mRoll * up;
-
- double nearPlane = 1.0;
- double farPlane = 2.0 * altitude;
-
- glCamera->setCenter(center);
- glCamera->setEye(eye);
- glCamera->setUpVector(up);
- glCamera->setNearPlane(nearPlane);
- glCamera->setFarPlane(farPlane);
-}
-
-void Map3DPrivate::updateFrustum(Frustum &frustum)
-{
- frustum.update(glCamera(), cameraData().aspectRatio());
- viewport_.setCameraData(cameraData());
-}
-
-QList<TileSpec> Map3DPrivate::updateVisibleTiles()
-{
- return viewport_.visibleTiles();
-}
-
-QGeoCoordinate Map3DPrivate::screenPositionToCoordinate(const QPointF &/*pos*/) const
-{
- return QGeoCoordinate();
-}
-
-QPointF Map3DPrivate::coordinateToScreenPosition(const QGeoCoordinate &/*coordinate*/) const
-{
- return QPointF();
-}
diff --git a/src/location/mapsgl/map3d/map3d_p.h b/src/location/mapsgl/map3d/map3d_p.h
deleted file mode 100644
index 8d5ce1dc..00000000
--- a/src/location/mapsgl/map3d/map3d_p.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef MAP3D_P_H
-#define MAP3D_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "map_p.h"
-#include "viewport_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeometryData;
-
-class Map3DPrivate : public MapPrivate
-{
-public:
- Map3DPrivate(Map *parent, TileCache *cache, double radius);
- virtual ~Map3DPrivate();
-
- virtual QRect specToRect(const TileSpec &tileSpec) const;
- virtual QGLSceneNode* createTileSpecNode(const TileSpec &tileSpec);
-
- virtual void updateGlCamera(QGLCamera* glCamera);
- virtual void updateFrustum(Frustum &frustum);
- virtual QList<TileSpec> updateVisibleTiles();
-
- virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
- virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
-
-private:
- QGeometryData generateTileGeometryData(int x, int y, int tileZoom, int geomZoom) const;
-
- int minZoom_;
- double radius_;
- Viewport viewport_;
-};
-
-QT_END_NAMESPACE
-
-#endif // MAP3D_P_H
diff --git a/src/location/mapsgl/map3d/projection3d_p.cpp b/src/location/mapsgl/map3d/projection3d_p.cpp
deleted file mode 100644
index 458b3a3d..00000000
--- a/src/location/mapsgl/map3d/projection3d_p.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "projection3d_p.h"
-
-#include "qgeocoordinate.h"
-
-#include <QVector2D>
-#include <QVector3D>
-#include <QMatrix4x4>
-#include <qnumeric.h>
-
-#include <cmath>
-
-Projection3D::Projection3D(double radius)
- : radius_(radius) {}
-
-Projection3D::~Projection3D() {}
-
-double Projection3D::radius() const
-{
- return radius_;
-}
-
-QVector3D Projection3D::coordToPoint(const QGeoCoordinate &coord) const
-{
- double r = radius_ + coord.altitude();
-
- const double pi = M_PI;
- double lonRad = pi * -1.0 * (coord.longitude() + 90.0) / 180.0;
- double latRad = pi * (90.0 - coord.latitude()) / 180.0;
-
- return QVector3D(r * cos(lonRad) * sin(latRad),
- r * cos(latRad),
- r * sin(lonRad) * sin(latRad));
-}
-
-QGeoCoordinate Projection3D::pointToCoord(const QVector3D &point) const
-{
- const double pi = M_PI;
-
- double alt = point.length();
- double lat = 180.0 * acos(point.y() / alt) / pi;
- double lon = 270.0 - (180.0 * atan2(point.z(), point.x()) / pi);
-
- if (lon < -180.0)
- lon += 360.0;
- if (lon >= 180.0)
- lon -= 360.0;
-
- return QGeoCoordinate(90.0 - lat, lon, alt);
-}
-
-QGeoCoordinate Projection3D::interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress)
-{
- if (start == end) {
- if (progress < 0.5) {
- return start;
- } else {
- return end;
- }
- }
-
- QGeoCoordinate s2 = start;
- s2.setAltitude(0.0);
- QGeoCoordinate e2 = end;
- e2.setAltitude(0.0);
- QVector3D s = coordToPoint(s2).normalized();
- QVector3D e = coordToPoint(e2).normalized();
-
- double dot = QVector3D::dotProduct(s, e);
- const double pi = M_PI;
- double angle = 180.0 * acos(dot) / pi;
- if (qFuzzyCompare(qAbs(dot), 1.0) || qIsNaN(angle)) { // qIsNan is extra check, fuzzy compare is sometimes too 'loose'
- if (progress < 0.5) {
- return start;
- } else {
- return end;
- }
- }
-
- QVector3D axis = QVector3D::crossProduct(s, e);
- QMatrix4x4 mRot;
- mRot.rotate(angle * progress, axis);
- QVector3D p = mRot * s;
-
- QGeoCoordinate result = pointToCoord(p);
- result.setAltitude((1.0 - progress) * start.altitude() + progress * end.altitude());
- return result;
-}
-
diff --git a/src/location/mapsgl/map3d/projection3d_p.h b/src/location/mapsgl/map3d/projection3d_p.h
deleted file mode 100644
index d272a1cf..00000000
--- a/src/location/mapsgl/map3d/projection3d_p.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef PROJECTION3D_P_H
-#define PROJECTION3D_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "projection_p.h"
-
-class Q_AUTOTEST_EXPORT Projection3D : public Projection
-{
-public:
- Projection3D(double radius);
- virtual ~Projection3D();
-
- double radius() const;
-
- virtual QVector3D coordToPoint(const QGeoCoordinate &coord) const;
- virtual QGeoCoordinate pointToCoord(const QVector3D &point) const;
-
- virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress);
-
-private:
- double radius_;
-};
-
-#endif // PROJECTION3D_P_H
diff --git a/src/location/mapsgl/map3d/sphere.cpp b/src/location/mapsgl/map3d/sphere.cpp
deleted file mode 100644
index 9df3ee60..00000000
--- a/src/location/mapsgl/map3d/sphere.cpp
+++ /dev/null
@@ -1,1234 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "sphere_p.h"
-
-#include <cmath>
-
-Arc::Arc() {}
-
-Arc::Arc(const QPlane3D &plane, double sphereRadius, const QVector3D &start, const QVector3D &end)
- : plane_(plane),
- sphereRadius_(sphereRadius),
- start_(start),
- end_(end)
-{
- QVector3D origin;
- double dist = plane.distanceTo(origin);
- center_ = -1.0 * dist * plane.normal().normalized();
- radius_ = sqrt(sphereRadius_ * sphereRadius_ - dist * dist);
-}
-
-void Arc::setPlane(const QPlane3D &plane)
-{
- plane_ = plane;
- QVector3D origin;
- double dist = plane.distanceTo(origin);
- center_ = -1.0 * dist * plane.normal().normalized();
- radius_ = sqrt(sphereRadius_ * sphereRadius_ - dist * dist);
-}
-
-bool Arc::operator ==(const Arc &rhs)
-{
- return (qFuzzyCompare(sphereRadius_, rhs.sphereRadius_)
- && qFuzzyCompare(radius_, rhs.radius_)
- && qFuzzyCompare(plane_, rhs.plane_)
- && qFuzzyCompare(center_, rhs.center_)
- && qFuzzyCompare(start_, rhs.start_)
- && qFuzzyCompare(end_, rhs.end_));
-}
-
-QPlane3D Arc::plane() const
-{
- return plane_;
-}
-
-QVector3D Arc::center() const
-{
- return center_;
-}
-
-double Arc::sphereRadius() const
-{
- return sphereRadius_;
-}
-
-double Arc::radius() const
-{
- return radius_;
-}
-
-void Arc::setStart(const QVector3D &start)
-{
- start_ = start;
-}
-
-QVector3D Arc::start() const
-{
- return start_;
-}
-
-void Arc::setEnd(const QVector3D &end)
-{
- end_ = end;
-}
-
-QVector3D Arc::end() const
-{
- return end_;
-}
-
-QVector3D Arc::interpolate(double n) const
-{
- QVector3D a = start_ - center_;
- QVector3D b = end_ - center_;
-
- a *= (1 - n);
- b *= n;
-
- a += b;
-
- a.normalize();
- a *= radius_;
- a += center_;
-
- return a;
-}
-
-QPair<QVector3D, QVector3D> Arc::intersect2(const QPlane3D &plane) const
-{
- QVector3D n1 = plane_.normal();
- QVector3D n2 = plane.normal();
- double h1 = QVector3D::dotProduct(n1, plane_.origin());
- double h2 = QVector3D::dotProduct(n2, plane.origin());
-
- double dot = QVector3D::dotProduct(n1, n2);
-
- if (dot == 1.0)
- return QPair<QVector3D, QVector3D>(start_, QVector3D());
- if (dot == -1.0)
- return QPair<QVector3D, QVector3D>(QVector3D(), QVector3D());
-
- QVector3D b = QVector3D::crossProduct(n1, n2);
-
- double c1 = h1 - h2 * dot;
- double c2 = h2 - h1 * dot;
- double den = 1 - dot * dot;
-
- n1 *= c1;
- n2 *= c2;
-
- n1 += n2;
- n1 /= den;
-
- double r2 = sphereRadius_ * sphereRadius_;
-
- QVector3D a = n1;
-
-// QPair<double, double> f = quadraticResults(b.lengthSquared(), 2 * QVector3D::dotProduct(a, b), a.lengthSquared() - r2, false);
-// qWarning() << "f " << f.first << f.second;
-
- if (r2 >= a.lengthSquared()) {
- double alpha = sqrt(r2 - a.lengthSquared()) / b.length();
- QVector3D v1 = b;
- v1 *= alpha;
- v1 += a;
- QVector3D v2 = b;
- v2 *= -1.0 * alpha;
- v2 += a;
-
-
- // TODO
- // need a more robust method to determine whether v1, v2 are between start and end
- // needs to be computationally cheap
- double se = QVector3D::dotProduct(start_, end_);
- bool hasV1 = ((se <= QVector3D::dotProduct(start_, v1)) && (se <= QVector3D::dotProduct(v1, end_)));
- bool hasV2 = ((se <= QVector3D::dotProduct(start_, v2)) && (se <= QVector3D::dotProduct(v2, end_)));
-
- if (hasV1) {
- if (hasV2 && !qFuzzyCompare(v1, v2)) {
- if ((v1 - start_).lengthSquared() > (v2 - start_).lengthSquared())
- qSwap(v1, v2);
- return QPair<QVector3D, QVector3D>(v1, v2);
- } else {
- return QPair<QVector3D, QVector3D>(v1, QVector3D());
- }
- } else if (hasV2) {
- return QPair<QVector3D, QVector3D>(v2, QVector3D());
- }
- }
-
- return QPair<QVector3D, QVector3D>(QVector3D(), QVector3D());
-}
-
-QPair<QVector3D, QVector3D> Arc::intersects(const QPlane3D &plane) const
-{
-// return intersect2(plane);
-
- QVector3D va = start_ - center_;
- QVector3D vb = end_ - center_;
-
- QVector3D n = plane.normal();
-
- double na = QVector3D::dotProduct(n, va);
- double nb = QVector3D::dotProduct(n, vb);
- double nab = na - nb;
- double no = QVector3D::dotProduct(n, plane.origin());
- double nc = QVector3D::dotProduct(n, center_);
- double ab = QVector3D::dotProduct(va, vb);
- double r2 = radius_ * radius_;
- double rab = 1 - (ab / r2);
-
- double noc = no - nc;
- noc *= noc;
-
-
- double a = nab * nab - 2 * noc * rab;
- double b = 2 * (noc * rab - na * nab);
- double c = na * na - noc;
-
- QPair<double, double> factors = quadraticResults(a, b, c);
-
- double f1 = factors.first;
- QVector3D v1;
- bool hasV1 = false;
-
- double f2 = factors.second;
- QVector3D v2;
- bool hasV2 = false;
-
- if (f1 != -1.0) {
- v1 = interpolate(f1);
- if (qAbs(plane.distanceTo(v1) / sphereRadius_) < 1e-6) {
- hasV1 = true;
- } else {
- v1 = QVector3D();
- }
- }
-
- if (f2 != -1.0) {
- v2 = interpolate(f2);
- if (qAbs(plane.distanceTo(v2) / sphereRadius_) < 1e-6) {
- hasV2 = true;
- if (!hasV1) {
- v1 = v2;
- v2 = QVector3D();
- }
- } else {
- v2 = QVector3D();
- }
- }
-
- return QPair<QVector3D, QVector3D>(v1, v2);
-}
-
-QPair<double, double> Arc::xIntersectFactor(double x) const
-{
- return intersects(start_.x(), end_.x(), center_.x(), x);
-}
-
-QPair<double, double> Arc::yIntersectFactor(double y) const
-{
- return intersects(start_.y(), end_.y(), center_.y(), y);
-}
-
-QPair<double, double> Arc::tIntersectFactor(double x, double z) const
-{
- double t;
- double ax;
- double az;
- double bx;
- double bz;
- double cx;
- double cz;
-
- // TODO deal with x = y = 0
-
- if (qAbs(x) <= qAbs(z)) {
- t = x / z;
- ax = start_.x() - center_.x();
- az = start_.z() - center_.z();
- bx = end_.x() - center_.x();
- bz = end_.z() - center_.z();
- cx = center_.x();
- cz = center_.z();
- } else {
- t = z / x;
- ax = start_.z() - center_.z();
- az = start_.x() - center_.x();
- bx = end_.z() - center_.z();
- bz = end_.x() - center_.x();
- cx = center_.z();
- cz = center_.x();
- }
-
-
- double r2 = radius_ * radius_;
- double dot = QVector3D::dotProduct(start_ - center_, end_ - center_);
- double dc = (cx - t * cz);
- dc *= dc;
-
- double ta = t * az - ax;
- double tb = t * bz - bx;
- double tab = ta - tb;
-
- double a = r2 * tab * tab + 2 * (dot - r2) * dc;
- double b = 2 * (-1 * r2 * ta * tab + (r2 - dot) * dc);
- double c = r2 * ta * ta - r2 * dc;
-
- QPair<double, double> factors = quadraticResults(a, b, c);
-
- // Need to check that the signs match
-
- bool xNeg = (x < 0.0);
- bool zNeg = (z < 0.0);
-
- double f1 = factors.first;
- bool f1Valid = false;
- if (f1 != -1.0) {
- QVector3D r = interpolate(f1);
- bool rxNeg = (r.x() < 0.0);
- bool rzNeg = (r.z() < 0.0);
- if ((xNeg == rxNeg) && (zNeg == rzNeg)) {
- f1Valid = true;
- } else {
- f1 = -1.0;
- }
- }
-
- double f2 = factors.second;
- if (f2 != -1.0) {
- QVector3D r = interpolate(f2);
- bool rxNeg = (r.x() < 0.0);
- bool rzNeg = (r.z() < 0.0);
- if ((xNeg == rxNeg) && (zNeg == rzNeg)) {
- if (!f1Valid) {
- f1 = f2;
- f2 = -1.0;
- }
- } else {
- f2 = -1.0;
- }
- }
-
- return QPair<double, double>(f1, f2);
-}
-
-QPair<double, double> Arc::intersects(double startValue, double endValue, double centerValue, double target) const
-{
- double r2 = radius_ * radius_;
- double dc = (target - centerValue) * (target - centerValue);
- double dot = QVector3D::dotProduct(start_ - center_, end_ - center_);
-
- double a = 2 * (r2 - dot) * dc - r2 * (startValue - endValue) * (startValue - endValue);
- double b = 2 * (dot - r2) * dc - 2 * r2 * (startValue - centerValue) * (endValue - startValue);
- double c = r2 * (dc - (startValue - centerValue) * (startValue - centerValue));
-
- return quadraticResults(a, b, c);
-}
-
-QPair<double, double> Arc::quadraticResults(double a, double b, double c, bool clip)
-{
- if (a == 0.0)
- return QPair<double, double>(-1.0, -1.0);
-
- double s = b * b - 4 * a * c;
-
- if (s < 0.0)
- return QPair<double, double>(-1.0, -1.0);
-
- double s2 = sqrt(s);
-
- double n1 = (-b + s2) / (2 * a);
- double n2 = (-b - s2) / (2 * a);
-
- if (clip) {
- if ((n1 < 0.0) || (n1 > 1.0))
- n1 = -1.0;
- if ((n2 < 0.0) || (n2 > 1.0))
- n2 = -1.0;
-
- if (n1 != -1.0) {
- if ((n2 != -1.0) && (n1 != n2)) {
- if (n2 < n1)
- qSwap(n1, n2);
- return QPair<double, double>(n1, n2);
- } else {
- return QPair<double, double>(n1, -1.0);
- }
- } else if (n2 != -1.0) {
- return QPair<double, double>(n2, -1.0);
- } else {
- return QPair<double, double>(-1.0, -1.0);
- }
- } else {
- if (n2 < n1)
- qSwap(n1, n2);
- return QPair<double, double>(n1, n2);
- }
-}
-
-bool Arc::belowPlane(const QPlane3D &plane) const
-{
- double ds = plane.distanceTo(start_) / sphereRadius_;
- double de = plane.distanceTo(end_) / sphereRadius_;
-
- if ((ds > 1e-6) || (de > 1e-6))
- return false;
-
- return ((ds < -1e-6) || (de < -1e-6));
-}
-
-bool PatchData::operator == (const PatchData &rhs)
-{
- return (qFuzzyCompare(point,rhs.point) && qFuzzyCompare(plane, rhs.plane));
-}
-
-SpherePatch::SpherePatch(double radius, const QList<Arc> arcs, bool roundUp, bool planar)
- : radius_(radius),
- roundUp_(roundUp),
- planar_(planar),
- debug_(true)
-{
- data_.reserve(arcs.size());
- for (int i = 0; i < arcs.size(); ++i) {
- PatchData d;
- d.point = arcs.at(i).start();
- d.plane = arcs.at(i).plane();
- d.intersectIndex = -1;
- d.done = false;
- data_ << d;
- }
-}
-
-SpherePatch::SpherePatch(double radius, const QList<PatchData> &data, bool roundUp, bool planar)
- : data_(data),
- radius_(radius),
- roundUp_(roundUp),
- planar_(planar),
- debug_(true)
-{
- int size = data_.size();
-
- for (int i = 0; i < size; ++i) {
- data_[i].intersectIndex = -1;
- data_[i].done = false;
- }
-}
-
-bool SpherePatch::operator ==(const SpherePatch &rhs)
-{
- // TODO need to be able to handle rotations of the arc list
- // TODO should also handle list in reverse order and with start/end
- // in the opposite order
- return (qFuzzyCompare(radius_, rhs.radius_)
- && (data_ == rhs.data_)
- && (roundUp_ == rhs.roundUp_));
-}
-
-bool SpherePatch::isomorphic(const SpherePatch &rhs)
-{
- if (radius_ != rhs.radius_)
- return false;
- if (roundUp_ != rhs.roundUp_)
- return false;
- if (data_.size() != rhs.data_.size())
- return false;
- if (data_.size() == 0)
- return true;
-
- int index = -1;
- int size = data_.size();
- PatchData d1 = data_.at(0);
- for (int i = 0; i < size; ++i) {
- if (d1 == rhs.data_[i]) {
- index = i;
- break;
- }
- }
-
- if (index == -1)
- return false;
-
- for (int i1 = 0; i1 < size; ++i1) {
- int i2 = (i1 + index) % size;
- if (!(data_[i1] == rhs.data_[i2]))
- return false;
- }
-
- return true;
-}
-
-int SpherePatch::arcCount() const
-{
- return data_.size();
-}
-
-Arc SpherePatch::arc(int index) const
-{
- if (index < 0 || index >= data_.size())
- return Arc();
-
- int size = data_.size();
- int index2 = (index + 1) % size;
-
- return Arc(data_.at(index).plane, radius_, data_.at(index).point, data_.at(index2).point);
-}
-
-void SpherePatch::setRoundUpTiles(bool roundUp)
-{
- roundUp_ = roundUp;
-}
-
-bool SpherePatch::roundUpTiles() const
-{
- return roundUp_;
-}
-
-bool SpherePatch::containsPoint(const QVector3D &point) const
-{
- int size = data_.size();
-
- for (int i = 0; i < size; ++i) {
- if (data_.at(i).plane.distanceTo(point) < 0.0)
- return false;
- }
-
- return true;
-}
-
-bool SpherePatch::inFrontOfPlane(const QPlane3D &plane) const
-{
- int size = data_.size();
-
- for (int i1 = 0; i1 < size; ++i1) {
- if (plane.distanceTo(data_.at(i1).point) < 0)
- return false;
- }
-
- return true;
-}
-
-bool SpherePatch::behindPlane(const QPlane3D &plane) const
-{
- int size = data_.size();
-
- for (int i1 = 0; i1 < size; ++i1) {
- if (plane.distanceTo(data_.at(i1).point) > 0)
- return false;
- }
-
- return true;
-}
-
-QList<SpherePatch> SpherePatch::intersect(const QPlane3D &plane)
-{
- QList<SpherePatch> results;
-
- /*
- We need these tests to rule out several cases that would
- otherwise leave us with two arcs defining the patch.
-
- We want to save that case for when the plane / sphere
- circle intersects one arc of this patch at two points.
-
- If it's a small circle we end up with two arcs between
- two points (but the arcs are on different planes.
-
- If it's a bigger circle there may be some additional
- points on the intersecting plane to make the interpolation
- unambiguous
- */
-
- QVector3D origin;
- double dist = plane.distanceTo(origin);
- if (dist > radius_) {
- if (debug_)
- qWarning() << "keeping (outside radius)";
- results << *this;
- return results;
- } else if (dist < -1 * radius_) {
- if (debug_)
- qWarning() << "removing (outside radius)";
- return results;
- }
-
- // co-planar
- QPlane3D negPlane = plane;
- negPlane.setNormal(negPlane.normal() * -1.0);
- int size = data_.size();
- for (int i = 0; i < size; ++i) {
- if (data_[i].plane == plane) {
- if (debug_)
- qWarning() << "keeping (co-planar)";
- results << *this;
- return results;
- } else if (data_[i].plane == negPlane) {
- if (debug_)
- qWarning() << "removing (co-planar)";
- return results;
- }
- }
-
- Arc intersectArc(plane, radius_);
- bool contains = containsPoint(intersectArc.center());
-// if (!contains) {
-// if (behindPlane(plane)) {
-// if (debug_)
-// qWarning() << "removing (intersection in different patch)";
-// return results;
-// } else if (inFrontOfPlane(plane)) {
-// if (debug_)
-// qWarning() << "keeping (intersection in different patch)";
-// results << *this;
-// return results;
-// }
-// }
-
- /*
- for each pair of points
- add first point if above or on plane
- add intersection points if not start or end point
- */
-
- SpherePatch newPatch(radius_, QList<PatchData>(), roundUp_);
-
- int arcIntersectCount = 0;
- int doubleIntersectCount = 0;
-
- QList<int> intersections = split(newPatch, plane, arcIntersectCount, doubleIntersectCount);
-
- if (debug_) {
- qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
- for (int i = 0; i < newPatch.data_.size(); ++i)
- qWarning() << " " << newPatch.data_.at(i).point << newPatch.data_.at(i).plane << newPatch.data_.at(i).intersectIndex;
- for (int i = 0; i < intersections.size(); ++i)
- qWarning() << " " << intersections.at(i);
- }
-
-
- if ((arcIntersectCount == 0) || ((arcIntersectCount == 1) && (newPatch.data_.size() == 1))) {
- if (contains)
- return noIntersectPatches(plane);
- if (debug_)
- qWarning() << "keeping (center point in different patch)";
-// results << *this;
-
- if (behindPlane(plane)) {
- if (debug_)
- qWarning() << "removing (intersection in different patch)";
- return results;
- } else if (inFrontOfPlane(plane)) {
- if (debug_)
- qWarning() << "keeping (intersection in different patch)";
- results << *this;
- return results;
- }
-
- return results;
- }
-
- //qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
-
- if ((intersections.length() == 2) && (doubleIntersectCount == 1))
- handleCircleEdgeIntersection(newPatch, plane, intersections);
-
- arrangeIntersections(newPatch, plane, intersections);
-
- if (debug_) {
- qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
- for (int i = 0; i < newPatch.data_.size(); ++i)
- qWarning() << " " << newPatch.data_.at(i).point << newPatch.data_.at(i).plane << newPatch.data_.at(i).intersectIndex;
- for (int i = 0; i < intersections.size(); ++i)
- qWarning() << " " << intersections.at(i);
- }
-
- return divide(newPatch, plane, intersections);
-}
-
-QList<int> SpherePatch::split(SpherePatch &patch, const QPlane3D &plane, int &arcCount, int &doubleCount)
-{
- QList<int> intersections;
-
- arcCount = 0;
- doubleCount = 0;
-
- int size = data_.size();
-
- for (int i1 = 0; i1 < size; ++i1) {
- int i2 = (i1 + 1) % size;
-
- PatchData d1 = data_.at(i1);
- PatchData d2 = data_.at(i2);
-
- QVector3D p1 = d1.point;
- QVector3D p2 = d2.point;
-
- Arc a = Arc(d1.plane, radius_, p1, p2);
-
- QPair<QVector3D, QVector3D> intersectPoints = a.intersects(plane);
- QVector3D origin;
-
- if (intersectPoints.first != origin)
- ++arcCount;
-
- if (intersectPoints.second != origin)
- ++doubleCount;
-
- if (debug_)
- qWarning() << "intersects "
- << intersectPoints.first
- << intersectPoints.second
- << "(" << p1 << ", " << p2 << ")";
-
- double dist = plane.distanceTo(p1);
-
- if ((dist / radius_ > -1e-6) && (dist <= 2.0 * radius_)) {
- patch.data_ << d1;
-
- int lastIndex = patch.data_.size() - 1;
-
- if (intersectPoints.first != origin) {
- if (qFuzzyCompare(intersectPoints.first, p1) && (intersections.isEmpty() || !(intersections.last() == lastIndex))) {
- intersections << lastIndex;
- }
- }
-
- if (intersectPoints.second != origin) {
- if (qFuzzyCompare(intersectPoints.second, p1) && (intersections.isEmpty() || !(intersections.last() == lastIndex))) {
- intersections << lastIndex;
- }
- }
-
- } else {
- if (debug_)
- qWarning() << "point " << p1 << " below plane";
- }
-
- if (intersectPoints.first != origin) {
- if (!qFuzzyCompare(intersectPoints.first, p1) && !qFuzzyCompare(intersectPoints.first, p2)) {
- PatchData d = d1;
- d.point = intersectPoints.first;
- patch.data_ << d;
- intersections << patch.data_.size() - 1;
- if (debug_)
- qWarning() << "adding " << intersectPoints.first << " as intersect";
- }
- }
-
- if (intersectPoints.second != origin) {
- if (!qFuzzyCompare(intersectPoints.second, p1) && !qFuzzyCompare(intersectPoints.second, p2)) {
- PatchData d = d1;
- d.point = intersectPoints.second;
- patch.data_ << d;
- intersections << patch.data_.size() - 1;
- if (debug_)
- qWarning() << "adding " << intersectPoints.second << " as intersect";
- }
- }
- }
-
- return intersections;
-}
-
-void SpherePatch::handleCircleEdgeIntersection(SpherePatch &patch, const QPlane3D &plane, QList<int> &intersections)
-{
- QList<QVector3D> newPoints;
-
- Arc a(plane, radius_);
-
- QVector3D p1 = patch.data_.at(intersections.at(0)).point;
- QVector3D p2 = patch.data_.at(intersections.at(1)).point;
-
- bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
-
- if (rhplane)
- intersections.removeFirst();
- else
- intersections.removeLast();
-
- QVector3D up = p1 - p2;
- up.normalize();
- up *= a.radius();
-
- QVector3D right = QVector3D::crossProduct(plane.normal(), up);
- right.normalize();
- right *= a.radius();
-
- QVector3D down = -1 * up;
-
- QVector3D left = -1 * right;
-
- up += a.center();
- right += a.center();
- down += a.center();
- left += a.center();
-
- if (containsPoint(up) && !qFuzzyCompare(up, p1) && !qFuzzyCompare(up, p2))
- newPoints << up;
- if (containsPoint(right) && !qFuzzyCompare(right, p1) && !qFuzzyCompare(right, p2))
- newPoints << right;
- if (containsPoint(down) && !qFuzzyCompare(down, p1) && !qFuzzyCompare(down, p2))
- newPoints << down;
- if (containsPoint(left) && !qFuzzyCompare(left, p1) && !qFuzzyCompare(left, p2))
- newPoints << left;
-
- int index = intersections.at(0) + 1;
-
- while (!newPoints.isEmpty()) {
- int minIndex = 0;
- QVector3D p = patch.data_.at(index - 1).point;
- double minDist = (newPoints.at(0) - p).lengthSquared();
- for (int j = 1; j < newPoints.size(); ++j) {
- double d = (newPoints.at(j) - p).lengthSquared();
- if (d < minDist) {
- minIndex = j;
- minDist = d;
- }
- }
-
- PatchData d;
- d.point = newPoints.takeAt(minIndex);
- d.plane = plane;
- d.intersectIndex = -1;
- d.done = false;
- patch.data_.insert(index, d);
-
- intersections << index;
- ++index;
- }
-}
-
-void SpherePatch::arrangeIntersections(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections)
-{
- bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
-
- int modifier = 1;
- if (!rhplane)
- modifier = -1;
-
- if (!rhplane) {
- int intersectSize = intersections.size();
- int dataSize = patch.data_.size();
-
- for (int i1 = 0; i1 < intersectSize; ++i1) {
- int i2 = (i1 + modifier) % intersectSize;
- if (i2 < 0)
- i2 += intersectSize;
- int index1 = intersections.at(i1);
- int index2 = intersections.at(i2);
- if (index1 != index2) {
- patch.data_[index1].intersectIndex = index2;
-
- if (planar_) {
- int i3 = (index1 + 1) % dataSize;
- if (i3 < 0)
- i3 += dataSize;
- if (i3 == index2)
- patch.data_[index1].plane = plane;
- }
- }
- }
- }
-}
-
-void SpherePatch::setupPlanes(QList<PatchData> &data, const QPlane3D &plane)
-{
- int ndSize = data.size();
-
- if (!planar_) {
- for (int i1 = 0; i1 < ndSize; ++i1) {
- int i2 = (i1 + 1) % ndSize;
-// if (!qFuzzyCompare(data.at(i1).plane, data.at(i2).plane)) {
- if (qAbs(data.at(i1).plane.distanceTo(data.at(i2).point) / radius_) > 1e-6) {
- data[i1].plane = plane;
- }
-// }
- }
- }
-}
-
-QList<SpherePatch> SpherePatch::divide(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections)
-{
- QList<SpherePatch> results;
-
- int size = patch.data_.size();
-
- bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
-
- if ((patch.data_.size() > 1) && rhplane) {
- setupPlanes(patch.data_, plane);
- results << SpherePatch(radius_, patch.data_, roundUp_);
- } else if (size != intersections.size()) {
- int size = patch.data_.size();
- for (int i = 0; i < size; ++i) {
- PatchData d1 = patch.data_.at(i);
- if ((d1.intersectIndex == -1) && !d1.done) {
-
- bool followingIntersect = false;
- QList<PatchData> newData;
-
- newData << d1;
-
- int j = (i + 1) % size;
-
- int count = 0;
- while ((j != i) && (count != size)) {
- ++count;
-
- PatchData d2 = patch.data_.at(j);
- newData << d2;
-
- int next = (j + 1) % size;
-
- // if ([this point is not an intersection])
- if (d2.intersectIndex == -1) {
- patch.data_[j].done = true;
- } else {
- if (followingIntersect) {
- // followingIntersect = [intersect exists and is adjacent]
- followingIntersect = (d2.intersectIndex == next);
- } else {
- next = d2.intersectIndex;
- followingIntersect = true;
- }
- }
-
- j = next;
- }
-
- if (count == size + 1) {
- qWarning() << "GAAAAH!!";
- }
-
- if (newData.size() > 1) {
- setupPlanes(newData, plane);
- SpherePatch sp = SpherePatch(radius_, newData, roundUp_);
- results << sp;
- }
- }
- }
- }
-
- return results;
-}
-
-QList<SpherePatch> SpherePatch::noIntersectPatches(const QPlane3D &plane) const
-{
- QList<SpherePatch> results;
-
- Arc a(plane, radius_);
-
- bool allBigger = true;
- bool allSmaller = true;
-
- int size = data_.size();
-
- for (int i = 0; i < size; ++i) {
- double dist = (data_.at(i).point - a.center()).length();
- double r = (dist - a.radius()) / radius_;
-
- if (r < -1e-6)
- allSmaller = false;
- if (r > 1e-6)
- allBigger = false;
- }
-
- if (allBigger) {
- if (plane.distanceTo(data_.at(0).point) / radius_ > 0.0)
- results << *this;
- return results;
- }
-
- QList<QVector3D> points;
-
- const double pi = 3.14159265358;
- double angle = asin(a.radius() / radius_) * 180.0 / pi;
- QVector3D center = a.center().normalized() * radius_;
-
- for (int i = 0; i < size; ++i) {
- QVector3D axis = QVector3D::crossProduct(center, data_.at(i).point);
- QMatrix4x4 r;
- r.rotate(angle, axis);
- points << r * center;
- }
-
- double dist = plane.distanceTo(QVector3D());
- if (dist > 0.0) {
- // circle shaped hole
-
- for (int i1 = 0; i1 < size; ++i1) {
- int i2 = (i1 + 1) % size;
-
- QVector3D start = data_.at(i1).point;
- QVector3D end = data_.at(i2).point;
-
- QList<PatchData> data;
-
- PatchData d1;
- d1.point = start;
- d1.plane = data_.at(i1).plane;
- data << d1;
-
- PatchData d2;
- d2.point = end;
- d2.plane = QPlane3D(center, QVector3D::normal(center, end));
- data << d2;
-
- PatchData d3;
- d3.point = points.at(i2);
- d3.plane = plane;
- data << d3;
-
- PatchData d4;
- d4.point = points.at(i1);
- d4.plane = QPlane3D(center, QVector3D::normal(center, start));
- data << d4;
-
- results << SpherePatch(radius_, data, roundUp_);
- }
-
- } else if (dist < 0.0) {
- // solo circle
-
- QList<PatchData> data;
- for (int i = 0; i < size; ++i) {
- PatchData d;
- d.point = points.at(i);
- d.plane = plane;
- data << d;
- }
-
- results << SpherePatch(radius_, data, roundUp_, true);
- }
-
- return results;
-}
-
-Sphere::Sphere(double radius, const QList<SpherePatch> &patches)
- : radius_(radius),
- patches_(patches) {}
-
-Sphere::Sphere(double radius)
- : radius_(radius)
-{
- QVector3D origin;
-
- patches_.reserve(8);
-
- QVector3D pxv = QVector3D(radius_, 0.0, 0.0);
- QVector3D nxv = QVector3D(-1.0 * radius_, 0.0, 0.0);
- QVector3D pyv = QVector3D(0.0, radius_, 0.0);
- QVector3D nyv = QVector3D(0.0, -1.0 * radius_, 0.0);
- QVector3D pzv = QVector3D(0.0, 0.0, radius_);
- QVector3D nzv = QVector3D(0.0, 0.0, -1.0 * radius_);
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D nxp = QPlane3D(origin, QVector3D(-1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D nyp = QPlane3D(origin, QVector3D(0.0, -1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
- QPlane3D nzp = QPlane3D(origin, QVector3D(0.0, 0.0, -1.0));
-
- PatchData d;
-
- QList<PatchData> data;
- data.reserve(3);
- data << d;
- data << d;
- data << d;
-
- data[0].point = pxv;
- data[0].plane = pzp;
- data[1].point = pyv;
- data[1].plane = pxp;
- data[2].point = pzv;
- data[2].plane = pyp;
-
- SpherePatch patch000(radius, data, false);
- patches_ << patch000;
-
- data[0].point = pxv;
- data[0].plane = pyp;
- data[1].point = nzv;
- data[1].plane = pxp;
- data[2].point = pyv;
- data[2].plane = nzp;
-
- SpherePatch patch001(radius_, data, false);
- patches_ << patch001;
-
- data[0].point = pxv;
- data[0].plane = nyp;
- data[1].point = pzv;
- data[1].plane = pxp;
- data[2].point = nyv;
- data[2].plane = pzp;
-
- SpherePatch patch010(radius_, data, false);
- patches_ << patch010;
-
- data[0].point = pxv;
- data[0].plane = nzp;
- data[1].point = nyv;
- data[1].plane = pxp;
- data[2].point = nzv;
- data[2].plane = nyp;
-
- SpherePatch patch011(radius_, data, false);
- patches_ << patch011;
-
- data[0].point = nxv;
- data[0].plane = pyp;
- data[1].point = pzv;
- data[1].plane = nxp;
- data[2].point = pyv;
- data[2].plane = nzp;
-
- SpherePatch patch100(radius_, data, false);
- patches_ << patch100;
-
- data[0].point = nxv;
- data[0].plane = nzp;
- data[1].point = pyv;
- data[1].plane = nxp;
- data[2].point = nzv;
- data[2].plane = pyp;
-
- SpherePatch patch101(radius_, data, false);
- patches_ << patch101;
-
- data[0].point = nxv;
- data[0].plane = pzp;
- data[1].point = nyv;
- data[1].plane = nxp;
- data[2].point = pzv;
- data[2].plane = nyp;
-
- SpherePatch patch110(radius_, data, true);
- patches_ << patch110;
-
- data[0].point = nxv;
- data[0].plane = nyp;
- data[1].point = nyv;
- data[1].plane = nxp;
- data[2].point = nzv;
- data[2].plane = nzp;
-
- SpherePatch patch111(radius_, data, true);
- patches_ << patch111;
-}
-
-bool Sphere::operator ==(const Sphere &rhs)
-{
- // TODO either make canonical ordering for patches
- // or do order-independent comparison of the patches
- return (qFuzzyCompare(radius_, rhs.radius_)
- && (patches_ == rhs.patches_));
-}
-
-bool Sphere::isomorphic (const Sphere &rhs)
-{
- if (radius_ != rhs.radius_)
- return false;
- if (patches_.size() != rhs.patches_.size())
- return false;
-
- int size = patches_.size();
-
- if (size == 0)
- return true;
-
- for (int i = 0; i < size; ++i)
- if (!patches_[i].isomorphic(rhs.patches_.at(i)))
- return false;
-
- return true;
-}
-
-QList<SpherePatch> Sphere::patches() const
-{
- return patches_;
-}
-
-void Sphere::intersect(const QPlane3D &plane)
-{
- int size = patches_.size();
-
- QList<SpherePatch> newPatches;
-
- QPlane3D p = plane;
- p.setNormal(p.normal().normalized());
-
- for (int i = 0; i < size; ++i)
- newPatches.append(patches_[i].intersect(p));
-
- patches_ = newPatches;
-}
-
-QDebug operator << (QDebug dbg, const Arc &arc)
-{
- dbg << " Arc [plane: " << arc.plane() << ", start: " << arc.start() << ", end: " << arc.end() << "]\n";
- return dbg;
-}
-
-QDebug operator << (QDebug dbg, const SpherePatch &patch)
-{
- dbg << " Patch [\n";
-
- int arcCount = patch.arcCount();
- for (int i = 0; i < arcCount; ++i)
- dbg << patch.arc(i);
-
- dbg << " ]\n";
- return dbg;
-}
-
-QDebug operator << (QDebug dbg, const Sphere &sphere)
-{
- dbg << "Sphere [\n";
-
- QList<SpherePatch> patches = sphere.patches();
- for (int i = 0; i < patches.size(); ++i)
- dbg << patches.at(i);
-
- dbg << "]\n";
- return dbg;
-}
diff --git a/src/location/mapsgl/map3d/sphere_p.h b/src/location/mapsgl/map3d/sphere_p.h
deleted file mode 100644
index 5d2fb5f0..00000000
--- a/src/location/mapsgl/map3d/sphere_p.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef SPHERE_P_H
-#define SPHERE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QVector3D>
-#include <QPair>
-#include <qplane3d.h>
-#include <QDebug>
-
-class Q_AUTOTEST_EXPORT Arc {
-public:
- Arc();
- Arc(const QPlane3D &plane,
- double sphereRadius,
- const QVector3D &start = QVector3D(),
- const QVector3D &end = QVector3D());
-
- bool operator == (const Arc &rhs);
-
- void setPlane(const QPlane3D &plane);
- QPlane3D plane() const;
-
- QVector3D center() const;
- double radius() const;
- double sphereRadius() const;
-
- void setStart(const QVector3D &start);
- QVector3D start() const;
-
- void setEnd(const QVector3D &end);
- QVector3D end() const;
-
- QVector3D interpolate(double n) const;
- QPair<QVector3D, QVector3D> intersects(const QPlane3D &plane) const;
-
- QPair<double, double> xIntersectFactor(double x) const;
- QPair<double, double> yIntersectFactor(double y) const;
- QPair<double, double> tIntersectFactor(double x, double y) const;
-
- bool belowPlane(const QPlane3D &plane) const;
-
-private:
- QPair<double, double> intersects(double start, double end, double center, double target) const;
- static QPair<double, double> quadraticResults(double a, double b, double c, bool clip = true);
-
- QPair<QVector3D, QVector3D> intersect2(const QPlane3D &plane) const;
-
- QPlane3D plane_;
- double sphereRadius_;
- QVector3D center_;
- double radius_;
- QVector3D start_;
- QVector3D end_;
-};
-
-QDebug operator << (QDebug dbg, const Arc &arc);
-
-struct PatchData {
- QVector3D point;
- QPlane3D plane;
- int intersectIndex;
- bool done;
-
- bool operator == (const PatchData &rhs);
-};
-
-class Q_AUTOTEST_EXPORT SpherePatch {
-public:
- SpherePatch(double radius, const QList<Arc> arcs, bool roundUp = false, bool planar = false);
- SpherePatch(double radius, const QList<PatchData> &data, bool roundUp, bool planar = false);
-
- bool operator == (const SpherePatch &rhs);
- bool isomorphic(const SpherePatch &rhs);
-
- int arcCount() const;
- Arc arc(int index) const;
-
- void setRoundUpTiles(bool roundUp);
- bool roundUpTiles() const;
-
- QList<SpherePatch> intersect(const QPlane3D &plane);
-
-private:
- bool inFrontOfPlane(const QPlane3D &plane) const;
- bool behindPlane(const QPlane3D &plane) const;
- bool containsPoint(const QVector3D &point) const;
-
- QList<int> split(SpherePatch &patch, const QPlane3D &plane, int &arcCount, int &doubleCount);
- void handleCircleEdgeIntersection(SpherePatch &patch, const QPlane3D &plane, QList<int> &intersections);
- QList<SpherePatch> noIntersectPatches(const QPlane3D &plane) const;
- void arrangeIntersections(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections);
- void setupPlanes(QList<PatchData> &data, const QPlane3D &plane);
- QList<SpherePatch> divide(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections);
-
- QList<PatchData> data_;
-// QList<int> intersections_;
-
- double radius_;
- //QList<Arc> arcs_;
- bool roundUp_;
- bool planar_;
- bool debug_;
-};
-
-QDebug operator << (QDebug dbg, const SpherePatch &patch);
-
-class Q_AUTOTEST_EXPORT Sphere {
-public:
- Sphere(double radius = 20000.0);
- Sphere(double radius, const QList<SpherePatch> &patches);
-
- bool operator == (const Sphere &rhs);
- bool isomorphic (const Sphere &rhs);
-
- QList<SpherePatch> patches() const;
-
- void intersect(const QPlane3D &plane);
-
-private:
- double radius_;
- QList<SpherePatch> patches_;
-};
-
-Q_AUTOTEST_EXPORT QDebug operator << (QDebug dbg, const Sphere &sphere);
-
-
-#endif // SPHERE_P_H
diff --git a/src/location/mapsgl/map3d/spheregeometry.cpp b/src/location/mapsgl/map3d/spheregeometry.cpp
deleted file mode 100644
index 50f50a90..00000000
--- a/src/location/mapsgl/map3d/spheregeometry.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "spheregeometry_p.h"
-
-#include "qgeocoordinate.h"
-
-#include <QVector2D>
-#include <QVector3D>
-#include <cmath>
-
-#include <QDebug>
-
-SphereGeometry::SphereGeometry()
- : radius_(20000.0),
- zoomLevel_(4) {}
-
-SphereGeometry::SphereGeometry(double radius, int zoomLevel)
- : radius_(radius),
- zoomLevel_(zoomLevel) {}
-
-void SphereGeometry::setRadius(double radius)
-{
- radius_ = radius;
-}
-
-double SphereGeometry::radius() const
-{
- return radius_;
-}
-
-//void SphereGeometry::setZoomLevel(int zoomLevel)
-//{
-// zoomLevel_ = zoomLevel;
-//}
-
-//int SphereGeometry::zoomLevel() const
-//{
-// return zoomLevel_;
-//}
-
-bool SphereGeometry::operator == (const SphereGeometry &rhs) const
-{
- return ((radius_ == rhs.radius_) && (zoomLevel_ == rhs.zoomLevel_));
-}
-
-QVector3D SphereGeometry::coordToPoint(const QGeoCoordinate &coord) const
-{
- double r = radius_ + coord.altitude();
-
- const double pi = 3.14159265358;
- double lonRad = pi * -1.0 * (coord.longitude() + 90.0) / 180.0;
- double latRad = pi * (90.0 - coord.latitude()) / 180.0;
-
- return QVector3D(r * cos(lonRad) * sin(latRad),
- r * cos(latRad),
- r * sin(lonRad) * sin(latRad));
-}
-
-QVector3D SphereGeometry::coordToPoint(double lat, double lon, double alt) const
-{
- double r = radius_ + alt;
-
- const double pi = 3.14159265358;
- double lonRad = pi * -1.0 * (lon + 90.0) / 180.0;
- double latRad = pi * (90.0 - lat) / 180.0;
-
- return QVector3D(r * cos(lonRad) * sin(latRad),
- r * cos(latRad),
- r * sin(lonRad) * sin(latRad));
-}
-
-qreal realmod(const qreal a, const qreal b)
-{
- quint64 div = static_cast<quint64>(a / b);
- return a - static_cast<qreal>(div) * b;
-}
-
-QVector3D SphereGeometry::mercatorToPoint(double fx, double fy) const
-{
- const double pi = 3.14159265358;
-
- if (fy < 0.0)
- fy = 0.0;
- else if (fy > 1.0)
- fy = 1.0;
-
- double lat;
-
- if (fy == 0.0)
- lat = 90.0;
- else if (fy == 1.0)
- lat = -90.0;
- else
- lat = (180.0 / pi) * (2.0 * atan(exp(pi * (1.0 - 2.0 * fy))) - (pi / 2.0));
-
- double lng;
- if (fx >= 0) {
- lng = realmod(fx, 1.0);
- } else {
- lng = realmod(1.0 - realmod(-1.0 * fx, 1.0), 1.0);
- }
-
- lng = lng * 360.0 - 180.0;
-
- return coordToPoint(lat, lng);
-}
-
-QVector3D SphereGeometry::pointToCoord(const QVector3D &point) const
-{
- const double pi = 3.14159265358;
-
- double alt = point.length();
- double lat = 180.0 * acos(point.y() / alt) / pi;
- double lon = 270.0 - (180.0 * atan2(point.z(), point.x()) / pi);
-
- if (lon < -180.0)
- lon += 360.0;
- if (lon >= 180.0)
- lon -= 360.0;
-
- return QVector3D(90.0 - lat, lon, alt);
-}
-
-QVector2D SphereGeometry::coordToMercator(const QVector2D &coord) const
-{
- const double pi = 3.14159265358;
-
- double lon = coord.y() / 360.0 + 0.5;
-
- double lat = coord.x();
- lat = 0.5 - (log(tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
- lat = qMax(0.0, lat);
- lat = qMin(1.0, lat);
-
- return QVector2D(lon, lat);
-}
-
-QVector2D SphereGeometry::pointToMercator(const QVector3D &point) const
-{
- return coordToMercator(pointToCoord(point).toVector2D());
-}
-
-QVector2D SphereGeometry::coordToTile(const QVector2D &coord, int zoom, bool roundUp) const
-{
- QVector2D p = coordToMercator(coord);
-
- int z = 1 << zoom;
- int x = 0;
- int y = 0;
-
- if (p.y() == 1.0)
- y = z - 1;
- else
- y = static_cast<int>(z * p.y()) % z;
-
- if ((qAbs(p.x()) < 1e-6) || (qAbs(p.x() - 1) < 1e-6))
- if (roundUp)
- x = z - 1;
- else
- x = 0;
- else
- x = static_cast<int>(z * p.x()) % z;
-
- return QVector2D(x, y);
-}
-
-QVector2D SphereGeometry::pointToTile(const QVector3D &point, int zoom, bool roundUp) const
-{
- return coordToTile(pointToCoord(point).toVector2D(), zoom, roundUp);
-}
diff --git a/src/location/mapsgl/map3d/spheregeometry_p.h b/src/location/mapsgl/map3d/spheregeometry_p.h
deleted file mode 100644
index b7043a9e..00000000
--- a/src/location/mapsgl/map3d/spheregeometry_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef SPHEREGEOMETRY_P_H
-#define SPHEREGEOMETRY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtLocation/qlocationglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QVector2D;
-class QVector3D;
-
-class Q_LOCATION_EXPORT SphereGeometry
-{
-public:
- SphereGeometry();
- SphereGeometry(double radius, int zoomLevel);
-
- void setRadius(double radius);
- double radius() const;
-
-// void setZoomLevel(int zoomLevel);
-// int zoomLevel() const;
-
- bool operator == (const SphereGeometry &rhs) const;
-
- QVector3D coordToPoint(const QGeoCoordinate &coord) const;
- QVector3D coordToPoint(double lat, double lon, double alt = 0.0) const;
- QVector3D mercatorToPoint(double fx, double fy) const;
-
- QVector3D pointToCoord(const QVector3D &point) const;
-
- QVector2D coordToMercator(const QVector2D &coord) const;
- QVector2D pointToMercator(const QVector3D &point) const;
-
- QVector2D coordToTile(const QVector2D &coord, int zoom, bool roundUp = false) const;
- QVector2D pointToTile(const QVector3D &point, int zoom, bool roundUp = false) const;
-
-private:
- double radius_;
- int zoomLevel_;
-};
-
-QT_END_NAMESPACE
-
-#endif // SPHEREGEOMETRY_P_H
diff --git a/src/location/mapsgl/map3d/viewport.cpp b/src/location/mapsgl/map3d/viewport.cpp
deleted file mode 100644
index 16dd17e5..00000000
--- a/src/location/mapsgl/map3d/viewport.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "viewport_p.h"
-
-#include "sphere_p.h"
-
-#include <QLinkedList>
-#include <QPair>
-#include <QMutableLinkedListIterator>
-
-#include <qglscenenode.h>
-#include <qglbuilder.h>
-#include <qglmaterial.h>
-#include <qglsphere.h>
-
-#include <cmath>
-
-QT_BEGIN_NAMESPACE
-
-Viewport::Viewport()
- : viewportTiles_(ViewportTiles(1))
-{
-// viewportTiles_.setSphere(sphere_);
-}
-
-Viewport::~Viewport()
-{
-}
-
-void Viewport::setProjection(Projection3D *projection)
-{
- viewportCamera_.setProjection(projection);
-}
-
-void Viewport::setZoomLevel(int zoomLevel)
-{
- viewportTiles_.setZoomLevel(zoomLevel);
-}
-
-int Viewport::zoomLevel() const
-{
- return viewportTiles_.zoomLevel();
-}
-
-//void Viewport::setSphere(const SphereGeometry& sphere)
-//{
-// if (sphere_ == sphere)
-// return;
-
-// sphere_ = sphere;
-// viewportTiles_.setSphere(sphere_);
-
-// calculateVisibleTiles();
-//}
-
-//SphereGeometry Viewport::sphere() const
-//{
-// return sphere_;
-//}
-
-/*
- Updates the internal QGLCamera, the frustum, and then updates the
- list of visible tiles.
-*/
-void Viewport::setCameraData(const CameraData &cameraData)
-{
- viewportTiles_.setZoomLevel(cameraData.zoomLevel());
- viewportCamera_.setCameraData(cameraData);
-
- calculateVisibleTiles();
-}
-
-QGLCamera* Viewport::camera() const
-{
- return viewportCamera_.toGLCamera();
-}
-
-QList<TileSpec> Viewport::visibleTiles() const
-{
- return visibleTiles_;
-}
-
-void Viewport::calculateVisibleTiles()
-{
- visibleTiles_ = viewportTiles_.visibleTiles(viewportCamera_);
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/mapsgl/map3d/viewport_p.h b/src/location/mapsgl/map3d/viewport_p.h
deleted file mode 100644
index f936ce28..00000000
--- a/src/location/mapsgl/map3d/viewport_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORT_P_H
-#define VIEWPORT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "spheregeometry_p.h"
-#include "cameradata.h"
-#include "tilespec.h"
-#include "frustum_p.h"
-
-#include "viewportcamera_p.h"
-#include "viewporttiles_p.h"
-
-#include <QList>
-#include <QVector2D>
-#include <QVector3D>
-#include <Qt3D/qplane3d.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLCamera;
-class QGLSceneNode;
-
-class Arc;
-
-class Projection3D;
-
-class Q_LOCATION_EXPORT Viewport
-{
-public:
- Viewport();
- ~Viewport();
-
- void setProjection(Projection3D *projection);
-
- void setZoomLevel(int zoomLevel);
- int zoomLevel() const;
-
- void setCameraData(const CameraData &cameraData);
-
- QGLCamera* camera() const;
-
- QList<TileSpec> visibleTiles() const;
-
-private:
- void calculateVisibleTiles();
-
- ViewportCamera viewportCamera_;
- ViewportTiles viewportTiles_;
-
- QList<TileSpec> visibleTiles_;
-};
-
-QT_END_NAMESPACE
-
-#endif // VIEWPORT_P_H
-
diff --git a/src/location/mapsgl/map3d/viewportcamera.cpp b/src/location/mapsgl/map3d/viewportcamera.cpp
deleted file mode 100644
index 612e47ec..00000000
--- a/src/location/mapsgl/map3d/viewportcamera.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "viewportcamera_p.h"
-
-#include "cameradata.h"
-
-#include "projection3d_p.h"
-
-#include <qglcamera.h>
-
-ViewportCamera::ViewportCamera()
- : camera_(new QGLCamera()){}
-
-ViewportCamera::~ViewportCamera()
-{
- delete camera_;
-}
-
-void ViewportCamera::setProjection(Projection3D *projection)
-{
- projection_ = projection;
-}
-
-//void ViewportCamera::setSphere(const SphereGeometry &sphere)
-//{
-// sphere_ = sphere;
-//}
-
-void ViewportCamera::setCameraData(const CameraData &cameraData)
-{
-// sphere_.setZoomLevel(cameraData.zoomLevel());
- double altitude = projection_->radius() * cameraData.distance();
-
- QGeoCoordinate coord = cameraData.center();
- coord.setAltitude(0.0);
- center_ = projection_->coordToPoint(coord);
- coord.setAltitude(altitude);
- eye_ = projection_->coordToPoint(coord);
-
- QVector3D view = eye_ - center_;
- QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
- up_ = QVector3D::normal(side, view);
-
- QMatrix4x4 mBearing;
- mBearing.rotate(-1.0 * cameraData.bearing(), view);
- up_ = mBearing * up_;
-
- QVector3D side2 = QVector3D::normal(up_, view);
- QMatrix4x4 mTilt;
- mTilt.rotate(cameraData.tilt(), side2);
- eye_ = (mTilt * view) + center_;
-
- view = eye_ - center_;
- side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
- up_ = QVector3D::normal(view, side2);
-
- QMatrix4x4 mRoll;
- mRoll.rotate(cameraData.roll(), view);
- up_ = mRoll * up_;
-
- nearPlane_ = 1.0;
- farPlane_ = 2.0 * altitude;
-
- viewSize_ = camera_->viewSize();
- aspectRatio_ = cameraData.aspectRatio();
-
- updateGLCamera();
- updateFrustum();
-}
-
-void ViewportCamera::updateGLCamera()
-{
- camera_->setCenter(center_);
- camera_->setEye(eye_);
- camera_->setUpVector(up_);
- camera_->setNearPlane(nearPlane_);
- camera_->setFarPlane(farPlane_);
-}
-
-void ViewportCamera::updateFrustum()
-{
- frustum_.update(*this);
-}
-
-QVector3D ViewportCamera::center() const
-{
- return center_;
-}
-
-QVector3D ViewportCamera::eye() const
-{
- return eye_;
-}
-
-QVector3D ViewportCamera::up() const
-{
- return up_;
-}
-
-QSizeF ViewportCamera::viewSize() const
-{
- return viewSize_;
-}
-
-double ViewportCamera::aspectRatio() const
-{
- return aspectRatio_;
-}
-
-double ViewportCamera::nearPlane() const
-{
- return nearPlane_;
-}
-
-double ViewportCamera::farPlane() const
-{
- return farPlane_;
-}
-
-QGLCamera* ViewportCamera::toGLCamera() const
-{
- return camera_;
-}
-
-Frustum ViewportCamera::toFrustum() const
-{
- return frustum_;
-}
diff --git a/src/location/mapsgl/map3d/viewportcamera_p.h b/src/location/mapsgl/map3d/viewportcamera_p.h
deleted file mode 100644
index 0b8055ee..00000000
--- a/src/location/mapsgl/map3d/viewportcamera_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORTCAMERA_P_H
-#define VIEWPORTCAMERA_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QSizeF>
-#include <QVector3D>
-
-#include "spheregeometry_p.h"
-#include "cameradata.h"
-#include "frustum_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Projection3D;
-
-class QGLCamera;
-
-class Q_AUTOTEST_EXPORT ViewportCamera {
-public:
- ViewportCamera();
- ~ViewportCamera();
-
- void setProjection(Projection3D *projection);
-
-// void setSphere(const SphereGeometry &sphere);
-
- void setCameraData(const CameraData &cameraData);
-
- QVector3D center() const;
- QVector3D eye() const;
- QVector3D up() const;
- QSizeF viewSize() const;
- double aspectRatio() const;
- double nearPlane() const;
- double farPlane() const;
-
- QGLCamera* toGLCamera() const;
- Frustum toFrustum() const;
-
-private:
- void updateGLCamera();
- void updateFrustum();
-
-// SphereGeometry sphere_;
- Projection3D *projection_;
-
- QVector3D center_;
- QVector3D eye_;
- QVector3D up_;
- QSizeF viewSize_;
- double aspectRatio_;
- double nearPlane_;
- double farPlane_;
-
- QGLCamera* camera_;
- Frustum frustum_;
-};
-
-QT_END_NAMESPACE
-
-#endif // VIEWPORTCAMERA_P_H
diff --git a/src/location/mapsgl/map3d/viewporttiles.cpp b/src/location/mapsgl/map3d/viewporttiles.cpp
deleted file mode 100644
index 61260d06..00000000
--- a/src/location/mapsgl/map3d/viewporttiles.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "viewporttiles_p.h"
-#include "viewporttiles_p_p.h"
-
-#include "viewporttilesold_p.h"
-#include "viewporttilesnew_p.h"
-
-#include "tilespec.h"
-#include "cameradata.h"
-#include "spheregeometry_p.h"
-#include "sphere_p.h"
-
-#include <QVector2D>
-#include <QVector>
-
-ViewportTiles::ViewportTiles(int codePath)
-{
- if (codePath == 1) {
- d_ptr = new ViewportTilesPrivateOld();
- } else {
- d_ptr = new ViewportTilesPrivateNew();
- }
-}
-
-ViewportTiles::~ViewportTiles()
-{
- delete d_ptr;
-}
-
-void ViewportTiles::setZoomLevel(int zoomLevel)
-{
- d_ptr->setZoomLevel(zoomLevel);
-}
-
-int ViewportTiles::zoomLevel() const
-{
- return d_ptr->zoomLevel();
-}
-
-void ViewportTiles::setSphere(const SphereGeometry &sphere)
-{
- d_ptr->setSphere(sphere);
-}
-
-QList<TileSpec> ViewportTiles::visibleTiles(const ViewportCamera &viewportCamera) const
-{
- return d_ptr->visibleTiles(viewportCamera);
-}
-
-ViewportTilesPrivate::ViewportTilesPrivate()
-{
-}
-
-ViewportTilesPrivate::~ViewportTilesPrivate()
-{
-}
-
-void ViewportTilesPrivate::setZoomLevel(int zoomLevel)
-{
- zoomLevel_ = zoomLevel;
-}
-
-int ViewportTilesPrivate::zoomLevel() const
-{
- return zoomLevel_;
-}
-
-void ViewportTilesPrivate::setSphere(const SphereGeometry &sphere)
-{
- sphere_ = sphere;
-}
-
-SphereGeometry ViewportTilesPrivate::sphere() const
-{
- return sphere_;
-}
-
-bool sorter(const QPair<double, int> &v1, const QPair<double, int> &v2)
-{
- return v1.first < v2.first;
-}
-
-struct TileMap2
-{
- int minY;
- int maxY;
- QHash<int, QPair<int, int> > range;
-
- void adjust(int tileX, int tileY);
-};
-
-void TileMap2::adjust(int tileX, int tileY)
-{
- if (minY == -1)
- minY = tileY;
- if (maxY == -1)
- maxY = tileY;
-
- minY = qMin(minY, tileY);
- maxY = qMax(maxY, tileY);
-
- if (range.contains(tileY)) {
- QPair<int,int> r = range[tileY];
- range[tileY] = QPair<int, int>(qMin(r.first, tileX), qMax(r.second, tileX));
- } else {
- range[tileY] = QPair<int, int>(tileX, tileX);
- }
-}
-
-/*
- This function returns the tiles that are touched by the line
- running from start to end at zoom level zoom.
-
- We first determine the tiles that the start and end points are in,
- and from that we determine the minumum and maximum tile x and tile y values.
-
- Between the minimum and maximum y values we calculate the points at which
- the line intersects the tile boundaries.
-
- The tile y value is entirely determined by the y value of the point, and
- we do some algebra to find the the point of intersection for a give tile y value.
-
- For each intersection we store the fraction of the way along the
- line from start-end the intersection occurs and what the new tile y value
- should be. These are stored in a QList<<QPair<double, int> >
-
- There is a slight difference between the case of ascending and
- descending y values and which tile value should be stored, which is accounted for.
-
- We do something similar for the x values, although in this case the ratio of
- the x and z values determines where the line of intersection is.
-
- We have to treat x > z and x < z as special cases to avoid dividing by zero.
-
- We sort both QList<<QPair<double, int> > by the double value and initialise tileX
- and tileY to the tile values of the starting point.
-
- We then look at the double values at the start of both lists. If one is smaller than
- the other we take it from the list, update tileX or tileY appropriately, and add it to
- the list of resulting tiles. If both values are equal we need to add (tileX, newTileY),
- (newTileX, tileY) and (newTileX, newTileY) to the results.
-
- If either of the lists is exhausted we can just add anything that remains in the other list.
-*/
-void ViewportTilesPrivate::tilesFromArc(const Arc &arc, bool roundUp, TileMap2 &map) const
-{
- QVector3D start = arc.start();
- QVector3D end = arc.end();
-
- int zpow2 = 1 << zoomLevel_;
-
- QVector2D t1 = sphere().pointToTile(start, zoomLevel_, roundUp);
- QVector2D t2 = sphere().pointToTile(end, zoomLevel_, roundUp);
-
- QVector<QPair<double, int> > yVals(qAbs(t1.y() - t2.y()) + 2);
- int yIndex = -1;
-
- yVals[++yIndex] = QPair<double, int>(0.0, t1.y());
- yVals[++yIndex] = QPair<double, int>(1.0, t2.y());
-
- int yStep = t2.y() - t1.y();
-
- if (yStep != 0) {
-
- yStep /= qAbs(yStep);
-
- int yAdjust = 0;
-
- int startY = t1.y();
- int endY = t2.y();
- if (yStep < 0) {
- yAdjust = -1;
- } else {
- ++startY;
- ++endY;
- }
-
- for (int y = startY; y != endY; y += yStep) {
- QVector3D p = sphere().mercatorToPoint(zpow2 / 2.0, y * 1.0 / zpow2);
- QPair<double, double> factors = arc.yIntersectFactor(p.y());
-
- bool found = false;
- double tf;
-
- if (factors.first != -1.0) {
- found = true;
- tf = factors.first;
-
- if (factors.second != -1.0) {
- double e1 = qAbs(p.y() - arc.interpolate(factors.first).y());
- double e2 = qAbs(p.y() - arc.interpolate(factors.second).y());
- if (e2 < e1)
- tf = factors.second;
- }
- }
-
- if (found) {
- yVals[++yIndex] = QPair<double, int>(tf, y + yAdjust);
-// qWarning() << "y " << y << " factor " << tf << te;
-// } else {
-// qWarning() << " no y solution for " << y;
- }
- }
-
- }
-
- yVals.resize(yIndex + 1);
- qSort(yVals.begin(), yVals.end(), sorter);
-
- QVector<QPair<double, int> > xVals(qAbs(t1.x() - t2.x()) + 2);
- int xIndex = -1;
-
- xVals[++xIndex] = QPair<double, int>(0.0, t1.x());
- xVals[++xIndex] = QPair<double, int>(1.0, t2.x());
-
- int xStep = t2.x() - t1.x();
-
- if (xStep != 0) {
-
- xStep /= qAbs(xStep);
-
- int xAdjust = 0;
-
- int startX = t1.x();
- int endX = t2.x();
- if (xStep < 0) {
- xAdjust = -1;
- } else {
- ++startX;
- ++endX;
- }
-
- for (int x = startX; x != endX; x += xStep) {
- QVector3D p = sphere().mercatorToPoint(x * 1.0 / zpow2, zpow2 / 2.0);
- QPair<double, double> factors = arc.tIntersectFactor(p.x(), p.z());
-
- double t;
- if (qAbs(p.x()) < qAbs(p.z()))
- t = p.x() / p.z();
- else
- t = p.z() / p.x();
-
- bool found = false;
- double tf;
-
- if (factors.first != -1.0) {
- found = true;
- tf = factors.first;
-
- if (factors.second != -1.0) {
- QVector3D v = arc.interpolate(factors.first);
- double e1 = 0.0;
- if (qAbs(v.x()) < qAbs(v.z()))
- e1 = qAbs(t - v.x() / v.z());
- else
- e1 = qAbs(t - v.z() / v.x());
-
- v = arc.interpolate(factors.second);
-
- double e2 = 0.0;
- if (qAbs(v.x()) < qAbs(v.z()))
- e2 = qAbs(t - v.x() / v.z());
- else
- e2 = qAbs(t - v.z() / v.x());
-
- if (e2 < e1)
- tf = factors.second;
- }
- }
-
- if (found) {
- xVals[++xIndex] = QPair<double, int>(tf, x + xAdjust);
-// qWarning() << "x " << x << " factor " << tf << te;
-// } else {
-// qWarning() << " no x solution for " << x;
- }
- }
- }
-
- xVals.resize(xIndex + 1);
- qSort(xVals.begin(), xVals.end(), sorter);
-
- int tileX = t1.x();
- int tileY = t1.y();
-
- int ySize = yVals.size();
- int xSize = xVals.size();
- yIndex = 0;
- xIndex = 0;
-
- map.adjust(tileX, tileY);
-
- while ((xIndex != xSize) && (yIndex != ySize)) {
- QPair<double, int> x = xVals.at(xIndex);
- QPair<double, int> y = yVals.at(yIndex);
- if (x.first < y.first) {
- tileX = xVals.at(xIndex++).second;
- map.adjust(tileX, tileY);
- } else if (x.first > y.first) {
- tileY = yVals.at(yIndex++).second;
- map.adjust(tileX, tileY);
- } else {
- int tileX2 = xVals.at(xIndex++).second;
- int tileY2 = yVals.at(yIndex++).second;
- map.adjust(tileX, tileY2);
- map.adjust(tileX2, tileY);
- tileX = tileX2;
- tileY = tileY2;
- map.adjust(tileX, tileY);
- }
- }
-
- for (int x = xIndex; x < xSize; ++x) {
- tileX = xVals.at(x).second;
- map.adjust(tileX, tileY);
- }
-
- for (int y = yIndex; y < ySize; ++y) {
- tileY = yVals.at(y).second;
- map.adjust(tileX, tileY);
- }
-}
-
-/*
- This function takes a list of points at which the view frustum intersects the world sphere,
- and returns the list of visible tiles that are bounded by that list of points.
-
- It is assumed that the polygon described by the list of points doesn't cross the dateline
- or contain a pole. The visibleTiles(int zoom) function takes care of that.
-
- The tiles along the line for each of the points are gathered, and from that we can
- determine which tiles are contained in the polygon.
-
- The minumum and maximum tile y values are found by a linear scan, after which we
- determine the minimum and maximum x values for each of the y values. We request all of the
- tile with that y value which have an x value between the minimum and maximum x values (inclusive).
-*/
-QList<TileSpec> ViewportTilesPrivate::tilesFromSpherePatch(const SpherePatch &patch) const
-{
- QList<TileSpec> results;
-
- int numArcs = patch.arcCount();
-
- if (numArcs == 0)
- return results;
-
- TileMap2 map;
- map.minY = -1;
- map.maxY = -1;
-
- for (int i = 0; i < numArcs; ++i) {
- tilesFromArc(patch.arc(i), patch.roundUpTiles(), map);
- }
-
- int minY = map.minY;
- int maxY = map.maxY;
-
-
- for (int y = minY; y <= maxY; ++y) {
- if (!map.range.contains(y))
- continue;
- int minX = map.range[y].first;
- int maxX = map.range[y].second;
- for (int x = minX; x <= maxX; ++x) {
- results << TileSpec(0, zoomLevel_, x, y);
- }
- }
-
- return results;
-}
-
-QList<TileSpec> ViewportTilesPrivate::tilesFromSphere(const Sphere &sphere) const
-{
- QList<TileSpec> tiles;
-
-// qWarning() << "sphere";
-// qWarning() << sphere;
-
- int numPatches = sphere.patches().size();
- for (int i = 0; i < numPatches; ++i) {
- tiles.append(tilesFromSpherePatch(sphere.patches().at(i)));
- }
-
- return tiles;
-}
diff --git a/src/location/mapsgl/map3d/viewporttiles_p.h b/src/location/mapsgl/map3d/viewporttiles_p.h
deleted file mode 100644
index 710f5540..00000000
--- a/src/location/mapsgl/map3d/viewporttiles_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORTTILES_P_H
-#define VIEWPORTTILES_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-
-class ViewportTilesPrivate;
-class SphereGeometry;
-class TileSpec;
-class ViewportCamera;
-
-class ViewportTiles {
-public:
- ViewportTiles(int codePath = 1);
- ~ViewportTiles();
-
- void setZoomLevel(int zoomLevel);
- int zoomLevel() const;
-
- void setSphere(const SphereGeometry &sphere);
-
- QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
-
-private:
- ViewportTilesPrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // VIEWPORTTILES_P_H
diff --git a/src/location/mapsgl/map3d/viewporttiles_p_p.h b/src/location/mapsgl/map3d/viewporttiles_p_p.h
deleted file mode 100644
index 94c00761..00000000
--- a/src/location/mapsgl/map3d/viewporttiles_p_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORTTILES_P_P_H
-#define VIEWPORTTILES_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QList>
-
-#include "spheregeometry_p.h"
-#include "tilespec.h"
-
-QT_BEGIN_NAMESPACE
-
-class ViewportCamera;
-
-class Sphere;
-class SpherePatch;
-class Arc;
-
-struct TileMap2;
-
-class ViewportTilesPrivate {
-public:
- ViewportTilesPrivate();
- virtual ~ViewportTilesPrivate();
-
- void setZoomLevel(int zoomLevel);
- int zoomLevel() const;
-
- void setSphere(const SphereGeometry &sphere);
- SphereGeometry sphere() const;
-
- virtual QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const = 0;
-
- QList<TileSpec> tilesFromSphere(const Sphere &sphere) const;
-
-private:
- QList<TileSpec> tilesFromSpherePatch(const SpherePatch &patch) const;
- void tilesFromArc(const Arc &arc, bool roundUp, TileMap2 &map) const;
-
- int zoomLevel_;
- SphereGeometry sphere_;
-};
-
-QT_END_NAMESPACE
-
-#endif // VIEWPORTTILES_P_P_H
diff --git a/src/location/mapsgl/map3d/viewporttilesnew.cpp b/src/location/mapsgl/map3d/viewporttilesnew.cpp
deleted file mode 100644
index 034051e6..00000000
--- a/src/location/mapsgl/map3d/viewporttilesnew.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "viewporttilesnew_p.h"
-
-#include "viewportcamera_p.h"
-
-#include "sphere_p.h"
-
-QT_BEGIN_NAMESPACE
-
-ViewportTilesPrivateNew::ViewportTilesPrivateNew()
- : debug_(false) {}
-
-ViewportTilesPrivateNew::~ViewportTilesPrivateNew() {}
-
-QList<TileSpec> ViewportTilesPrivateNew::visibleTiles(const ViewportCamera &viewportCamera) const
-{
- Frustum frustum = viewportCamera.toFrustum();
-
- Sphere sphere = Sphere(this->sphere().radius());
-
- if (debug_)
- qWarning() << "sphere " << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Far));
-
- if (debug_)
- qWarning() << "sphere (far)" << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Left));
-
- if (debug_)
- qWarning() << "sphere (left)" << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Top));
-
- if (debug_)
- qWarning() << "sphere (top)" << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Right));
-
- if (debug_)
- qWarning() << "sphere (right)" << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Bottom));
-
- if (debug_)
- qWarning() << "sphere (bottom)" << sphere;
-
- sphere.intersect(frustum.plane(Frustum::Near));
-
- if (debug_)
- qWarning() << "sphere (near)" << sphere;
-
- QList<TileSpec> tiles = tilesFromSphere(sphere);
-
- if (debug_) {
- for (int i = 0; i < tiles.size(); ++i)
- qWarning() << " " << tiles.at(i).x() << tiles.at(i).y();
- }
-
- return tiles;
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/mapsgl/map3d/viewporttilesnew_p.h b/src/location/mapsgl/map3d/viewporttilesnew_p.h
deleted file mode 100644
index d201995e..00000000
--- a/src/location/mapsgl/map3d/viewporttilesnew_p.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORTTILESNEW_P_H
-#define VIEWPORTTILESNEW_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "viewporttiles_p_p.h"
-
-class ViewportTilesPrivateNew : public ViewportTilesPrivate {
-public:
- ViewportTilesPrivateNew();
- ~ViewportTilesPrivateNew();
-
- QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
-
-private:
- bool debug_;
-};
-
-#endif // VIEWPORTTILESNEW_P_H
diff --git a/src/location/mapsgl/map3d/viewporttilesold.cpp b/src/location/mapsgl/map3d/viewporttilesold.cpp
deleted file mode 100644
index cba4bfd9..00000000
--- a/src/location/mapsgl/map3d/viewporttilesold.cpp
+++ /dev/null
@@ -1,690 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "viewporttilesold_p.h"
-
-#include "sphere_p.h"
-#include "tilespec.h"
-#include "viewportcamera_p.h"
-
-#include <QLinkedList>
-#include <QVector2D>
-
-#include <cmath>
-
-ViewportTilesPrivateOld::ViewportTilesPrivateOld() {}
-
-ViewportTilesPrivateOld::~ViewportTilesPrivateOld() {}
-
-QList<TileSpec> ViewportTilesPrivateOld::visibleTiles(const ViewportCamera &viewportCamera) const
-{
- Frustum frustum = viewportCamera.toFrustum();
-
- int lineIntersections = 0;
-
- QList<Arc> points = pointIntersections(frustum, &lineIntersections);
-
- if (lineIntersections < 3) {
- return visibleTilesFromPlanes(viewportCamera);
- }
-
- return tilesFromSphere(sphereFromArcs(points));
-}
-
-Sphere ViewportTilesPrivateOld::sphereFromArcs(QList<Arc> &arcs) const
-{
- QList<int> zeroIndices = addDatelineCrossings(arcs);
-
- int zeroes = zeroIndices.size();
-
- if (zeroes == 0) {
- QList<SpherePatch> patches;
- patches << SpherePatch(sphere().radius(), arcs, false);
- return Sphere(sphere().radius(), patches);
- } else if (zeroes == 1) {
- return sphereForPole(arcs, zeroIndices.at(0));
- } else if (zeroes == 2) {
- return sphereForDateline(arcs, zeroIndices.at(0), zeroIndices.at(1));
- } else {
- qWarning() << "zeroes: " << zeroes;
- return Sphere(sphere().radius());
- }
-}
-
-/*
- We assume we a have a polygon with a pole in the middle, and a point on the dateline.
-
- We split the polygon into two, and then add copies of each point shifted up into the
- tile in the first or last row of tiles (for the north or south pole respectively) in
- reverse order.
-
- This is pretty buggy at present.
-*/
-Sphere ViewportTilesPrivateOld::sphereForPole(const QList<Arc> &arcs, int zeroIndex1) const
-{
-// QVector3D northPole = QVector3D(0, sphere().radius(), 0);
-// QVector3D southPole = QVector3D(0, -1.0 * sphere().radius(), 0);
-
-// qWarning() << "north";
-// for (int i = 0; i < size; ++i) {
-// qWarning() << " " << arcs.at(i).plane().distanceTo(northPole);
-// }
-
-// qWarning() << "south";
-// for (int i = 0; i < size; ++i) {
-// qWarning() << " " << arcs.at(i).plane().distanceTo(southPole);
-// }
-
- int size = arcs.size();
- double y = 0.0;
- for (int i = 0; i < size; ++i) {
- y += arcs.at(i).start().y();
- }
-
- int z = 1 << zoomLevel();
- double newY = 0.5 / z;
- if (y < 0.0)
- newY = (z - 0.5) / z;
-
- QPlane3D datelinePlane(QVector3D(0.0, 0.0, 0.0),
- QVector3D(0.0, 0.0, 1.0));
-
- double topY = sphere().mercatorToPoint(0, newY).y();
-
- QPlane3D topPlane(QVector3D(0.0, topY, 0.0),
- QVector3D(0.0, -1.0, 0.0));
-
- QList<SpherePatch> patches;
-
- QList<Arc> patch1;
-
- for (int i = zeroIndex1; i < zeroIndex1 + size; ++i) {
- int index = i % size;
- patch1 << arcs.at(index);
- }
-
- QList<Arc> patch2;
-
- for (int i = zeroIndex1; i < zeroIndex1 + size; ++i) {
- int index = size - (i % size) - 1;
-
- QVector2D start = sphere().pointToMercator(arcs.at(index).end());
- QVector2D end = sphere().pointToMercator(arcs.at(index).start());
-
- QVector3D start2 = sphere().mercatorToPoint(start.x(), newY);
- QVector3D end2 = sphere().mercatorToPoint(end.x(), newY);
-
- Arc a = Arc(topPlane, sphere().radius(), start2, end2);
-
- patch2 << a;
- }
-
- Arc endCap1 = Arc(datelinePlane, sphere().radius(), patch1.last().end(), patch2.first().start());
- Arc endCap2 = Arc(datelinePlane, sphere().radius(), patch2.last().end(), patch1.first().start());
-
- QList<Arc> patch;
-
- patch.append(patch1);
- patch.append(endCap1);
- patch.append(patch2);
- patch.append(endCap2);
-
- patches << SpherePatch(sphere().radius(), patch, false);
-
- return Sphere(sphere().radius(), patches);
-}
-
-// This assumes that addDatelineCrossings has already been called, in which
-// case the polygon points will have points on the dateline instead of lines
-// crossing the dateline.
-
-// In that case we just need to split the polygon into two - one before the dateline
-// and one after the dateline - and add the visible tiles for both polygons.
-Sphere ViewportTilesPrivateOld::sphereForDateline(const QList<Arc> &arcs, int zeroIndex1, int zeroIndex2) const
-{
- QList<SpherePatch> patches;
-
- int size = arcs.size();
-
- QList<Arc> lines1;
- bool roundUp1 = false;
- for (int i = zeroIndex1; i < zeroIndex2; ++i) {
- Arc v = arcs.at(i);
- if ((i != zeroIndex1) && (v.start().x() < 0))
- roundUp1 = true;
- lines1.append(v);
- }
-
- QPlane3D datelinePlane(QVector3D(0.0, 0.0, 0.0),
- QVector3D(0.0, 0.0, 1.0));
-
- lines1 << Arc(datelinePlane, sphere().radius(), lines1.last().end(), lines1.first().start());
-
- patches << SpherePatch(sphere().radius(), lines1, roundUp1);
-
- QList<Arc> lines2;
- bool roundUp2 = false;
- for (int i = zeroIndex2; i < zeroIndex1 + size; ++i) {
- int index = i % size;
- Arc v = arcs.at(index);
- if ((i != zeroIndex2) && (v.start().x() < 0))
- roundUp2 = true;
- lines2.append(v);
- }
-
- lines2 << Arc(datelinePlane, sphere().radius(), lines2.last().end(), lines2.first().start());
-
- patches << SpherePatch(sphere().radius(), lines2, roundUp2);
-
- return Sphere(sphere().radius(), patches);
-}
-
-QList<int> ViewportTilesPrivateOld::addDatelineCrossings(QList<Arc> &points) const
-{
- QList<int> results;
-
- for (int i = 0; i < points.size(); ++i) {
- Arc p = points.at(i);
- QPair<double, double> factors = p.xIntersectFactor(0.0);
-
- bool found = false;
- double tf;
- double te = 0.0;
-
- if ((factors.first > 0.0) && (factors.first < 1.0)) {
- QVector3D v = p.interpolate(factors.first);
- if ((qAbs(v.x()) / sphere().radius() < 1e-6) && (v.z() >= 0.0)) {
- found = true;
- tf = factors.first;
- te = qAbs(v.x());
- }
- }
-
- if ((factors.second > 0.0) && (factors.second < 1.0)) {
- QVector3D v = p.interpolate(factors.second);
- if ((qAbs(v.x()) / sphere().radius() < 1e-6) && (v.z() >= 0.0)) {
- if (!found || (qAbs(v.x()) < te)) {
- found = true;
- tf = factors.second;
- }
- }
- }
-
-// for (int j = 0; j < factors.size(); ++j) {
-// double n = factors.at(j);
-// if ((n == 0.0) || (n == 1.0))
-// continue;
-
-// QVector3D v = p.interpolate(n);
-
-// double relativeError = qAbs(v.x() / sphere().radius());
-
-//// qWarning() << " checked " << i << n << v.x() << v.z() << relativeError;
-
-// if ((relativeError < 1e-6) && (v.z() >= 0)) {
-// double e = qAbs(v.x());
-// if (!found || (e < te)) {
-// tf = n;
-// te = e;
-// found = true;
-// }
-// }
-// }
-
- if (found) {
- QVector3D v = p.interpolate(tf);
-
- qWarning() << " found " << tf << v.x() << v.z();
-
- Arc q = p;
- p.setEnd(v);
- points[i] = p;
- q.setStart(v);
- points.insert(i + 1, q);
- ++i;
- results << i;
- }
- }
-
- return results;
-
-// QVector3D s = points.at(i)
-// QVector3D e = points.at((i + 1) % points.size());
-// if ((s.x() != 0.0) && (e.x() != 0) && (s.x() != e.x())) {
-// double n = s.x() / (s.x() - e.x());
-// QVector3D v = (1.0 - n) * s + n * e;
-// if ((v.z() >= 0.0) && (0.0 <= n) && (n <= 1.0))
-// points.insert(i + 1, v);
-// }
-}
-
-bool ViewportTilesPrivateOld::LengthSorter::operator()(const IntersectionPoint &lhs, const IntersectionPoint &rhs)
-{
- bool lPlane = (lhs.planes & base.planes);
- bool rPlane = (rhs.planes & base.planes);
- if (lPlane == rPlane)
- return (lhs.point - base.point).lengthSquared() < (rhs.point - base.point).lengthSquared();
- else
- return lPlane;
-}
-
-/*
- We find all of the points of intersection between the earth sphere and
- the lines along the edges of the view frustum.
-
- We then sort them so that form a polygon. The last point becomes
- the first result. We then sort the points by distance^2 from the last
- result, and the nearest point becomes the last result.
-*/
-QList<Arc> ViewportTilesPrivateOld::pointIntersections(const Frustum &frustum, int *linesIntersected) const
-{
- QList<ViewportTilesPrivateOld::IntersectionPoint> points;
-
- if (linesIntersected)
- *linesIntersected = 0;
-
- double radius = sphere().radius();
-
- QList<ViewportTilesPrivateOld::IntersectionPoint> v;
-
- v = lineIntersectsSphere(radius,
- frustum.topLeftNear(),
- frustum.topLeftFar(),
- Frustum::TopLeftNear,
- Frustum::TopLeftFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.topRightNear(),
- frustum.topRightFar(),
- Frustum::TopRightNear,
- Frustum::TopRightFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomRightNear(),
- frustum.bottomRightFar(),
- Frustum::BottomRightNear,
- Frustum::BottomRightFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomLeftNear(),
- frustum.bottomLeftFar(),
- Frustum::BottomLeftNear,
- Frustum::BottomLeftFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.topLeftFar(),
- frustum.topRightFar(),
- Frustum::TopLeftFar,
- Frustum::TopRightFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.topRightFar(),
- frustum.bottomRightFar(),
- Frustum::TopRightFar,
- Frustum::BottomRightFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomRightFar(),
- frustum.bottomLeftFar(),
- Frustum::BottomRightFar,
- Frustum::BottomLeftFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomLeftFar(),
- frustum.topLeftFar(),
- Frustum::BottomLeftFar,
- Frustum::TopLeftFar);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.topLeftNear(),
- frustum.topRightNear(),
- Frustum::TopLeftNear,
- Frustum::TopRightNear);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.topRightNear(),
- frustum.bottomRightNear(),
- Frustum::TopRightNear,
- Frustum::BottomRightNear);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomRightNear(),
- frustum.bottomLeftNear(),
- Frustum::BottomRightNear,
- Frustum::BottomLeftNear);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- v = lineIntersectsSphere(radius,
- frustum.bottomLeftNear(),
- frustum.topLeftNear(),
- Frustum::BottomLeftNear,
- Frustum::TopLeftNear);
- if (linesIntersected && !v.isEmpty())
- ++(*linesIntersected);
- points.append(v);
-
- QList<Arc> results;
-
- if (points.isEmpty())
- return results;
-
- LengthSorter sorter;
- sorter.base = points.first();
- qSort(points.begin(), points.end(), sorter);
- for (int i = points.size() - 1; i > 0; --i) {
- if (points.at(i).point == points.at(i - 1).point)
- points.removeAt(i);
- }
-
- QList<ViewportTilesPrivateOld::IntersectionPoint>::iterator i;
- for (i = points.begin(); i != points.end(); ++i) {
- sorter.base = *i;
- if (i + 1 != points.end())
- qSort(i + 1, points.end(), sorter);
- }
-
- QVector3D origin;
-
-
- int size = points.size();
- for (int i = 0; i < size; ++i) {
- ViewportTilesPrivateOld::IntersectionPoint a = points.at(i);
- ViewportTilesPrivateOld::IntersectionPoint b = points.at((i + 1) % size);
-
-
- QPlane3D plane = frustum.plane(a.planes & b.planes);
- if (plane.origin() != origin)
- results << Arc(plane, sphere().radius(), a.point, b.point);
-
-// if (plane.origin() == origin) {
-// result.center = origin;
-// result.radius = sphere_.radius();
-// } else {
-// results << Arc(plane, sphere_.radius(), a.point, b.point);
-// result.center = -1.0 * plane.distanceTo(origin) * plane.normal().normalized();
-// result.radius = sqrt(sphere_.radius() * sphere_.radius() - result.center().lengthSquared());
-// }
-// result.setStart(a.point);
-// result.setEnd(b.point);
-
-// results << result;
- }
-
- return results;
-}
-
-/*
- This returns the points along the line from start to end that intersect a sphere with radius \a radius.
-
- It returns the intersection in order of proximity to start.
-*/
-QList<ViewportTilesPrivateOld::IntersectionPoint> ViewportTilesPrivateOld::lineIntersectsSphere(double radius,
- const QVector3D &start,
- const QVector3D &end,
- Frustum::Planes planesStart,
- Frustum::Planes planesEnd)
-{
- QVector3D v = end - start;
-
- double maxN = v.length();
-
- v.normalize();
-
- double b = 2 * QVector3D::dotProduct(start, v);
- double c = start.lengthSquared() - (radius * radius);
-
- double s = (b * b) - (4 * c);
-
- if (s < 0)
- return QList<ViewportTilesPrivateOld::IntersectionPoint>();
-
- double s2 = sqrt(s);
-
- double n1 = -1.0 * (b - s2) / 2.0;
- if (n1 > maxN)
- n1 = -1.0;
- if (n1 < 0)
- n1 = -1.0;
-
- double n2 = -1.0 * (b + s2) / 2.0;
- if (n2 > maxN)
- n2 = -1.0;
- if (n2 < 0)
- n2 = -1.0;
-
- if (n1 < 0.0) {
- if (n2 >= 0)
- n1 = n2;
- } else if (n2 < 0) {
- n2 = n1;
- } else {
- if (n2 < n1)
- qSwap(n1, n2);
- }
-
- QList<ViewportTilesPrivateOld::IntersectionPoint> results;
-
- if (n1 != -1.0) {
- ViewportTilesPrivateOld::IntersectionPoint r1;
-
- r1.point = interpolate(start, end, n1);
-
- if (r1.point == start)
- r1.planes = planesStart;
- else if (r1.point == end)
- r1.planes = planesEnd;
- else
- r1.planes = (planesStart & planesEnd);
- results << r1;
-
- if ((n2 != -1.0) && (n2 != n1)) {
- ViewportTilesPrivateOld::IntersectionPoint r2;
-
- r2.point = interpolate(start, end, n2);
-
- if (r2.point == start)
- r2.planes = planesStart;
- else if (r2.point == end)
- r2.planes = planesEnd;
- else
- r2.planes = (planesStart & planesEnd);
- results << r2;
- }
- }
-
- return results;
-}
-
-QVector3D ViewportTilesPrivateOld::interpolate(const QVector3D &start, const QVector3D &end, double n)
-{
- QVector3D v = end - start;
- v.normalize();
- return start + n * v;
-}
-
-QPair<QVector3D, double> ViewportTilesPrivateOld::tileInfo(const TileSpec &spec) const
-{
- int z = 1 << spec.zoom();
-
- double xl = spec.x() * 1.0 / z;
- double xc = (spec.x() + 0.5) / z;
- double xr = ((spec.x() + 1) % z * 1.0) / z;
- double yt = (spec.y() * 1.0) / z;
- double yc = (spec.y() + 0.5) / z;
- double yb = ((spec.y() + 1) * 1.0) / z;
-
- QVector3D tl = sphere().mercatorToPoint(xl, yt);
- QVector3D br = sphere().mercatorToPoint(xr, yb);
- QVector3D c = sphere().mercatorToPoint(xc, yc);
-
- double r = sqrt(qMax((tl - c).lengthSquared(), (br - c).lengthSquared()));
-
- return QPair<QVector3D, double>(c, 2 * r);
-}
-
-/*
- This is the least good of the functions in here.
-
- It's used when we don't have enough of a frustum intersect to determine which
- tiles to fetch analytically.
-
- It treats tiles as spheres and then determines if the sphere is inside
- the frustum. If it is, it considers the neighbours of the tile.
-
- There are smarter ways to do this via plane intersection (hence the
- function name). I'll revisit this soon.
-*/
-QList<TileSpec> ViewportTilesPrivateOld::visibleTilesFromPlanes(const ViewportCamera &viewportCamera) const
-{
- QList<TileSpec> results;
-
- QVector3D center = viewportCamera.center();
- QVector3D eye = viewportCamera.eye();
-
- QVector3D v = center - eye;
- v.normalize();
-
- QVector2D t = sphere().pointToTile(center, zoomLevel());
-
- QLinkedList<TileSpec> queue;
- QSet<TileSpec> queued;
- QSet<TileSpec> done;
-
- int zoom = zoomLevel();
-
- queue << TileSpec(0, zoom, t.x(), t.y());
- queued << TileSpec(0, zoom, t.x(), t.y());
-
- int z = 1 << zoom;
-
- Frustum frustum = viewportCamera.toFrustum();
-
- while (!queue.isEmpty()) {
- TileSpec spec = queue.takeLast();
- QPair<QVector3D, double> info = tileInfo(spec);
- if (frustum.contains(info.first, info.second) && (QVector3D::dotProduct(v, info.first - eye) > 0)) {
- results << spec;
-
- QList<TileSpec> tiles;
-
- int xp = spec.x() - 1;
- if (xp < 0)
- xp = z - 1;
- int xn = (spec.x() + 1) % z;
-
- tiles << TileSpec(0, zoom, xp, spec.y());
- tiles << TileSpec(0, zoom, xn, spec.y());
-
- if (spec.y() == 0) {
- int x2 = (spec.x() + z / 2) % z;
- int xp2 = ((spec.x() + z / 2 - 1) % z);
- if (xp2 < 0)
- xp2 += z;
- int xn2 = ((spec.x() + z / 2 + 1) % z);
- tiles << TileSpec(0, zoom, xp2, spec.y());
- tiles << TileSpec(0, zoom, x2, spec.y());
- tiles << TileSpec(0, zoom, xn2, spec.y());
- } else {
- tiles << TileSpec(0, zoom, xp, spec.y() - 1);
- tiles << TileSpec(0, zoom, spec.x(), spec.y() - 1);
- tiles << TileSpec(0, zoom, xn, spec.y() - 1);
- }
-
- if (spec.y() == (z - 1)) {
- int x2 = (spec.x() + z / 2) % z;
- int xp2 = ((spec.x() + z / 2 - 1) % z);
- if (xp2 < 0)
- xp2 += z;
- int xn2 = ((spec.x() + z / 2 + 1) % z);
- tiles << TileSpec(0, zoom, xp2, spec.y());
- tiles << TileSpec(0, zoom, x2, spec.y());
- tiles << TileSpec(0, zoom, xn2, spec.y());
- } else {
- tiles << TileSpec(0, zoom, xp, spec.y() + 1);
- tiles << TileSpec(0, zoom, t.x(), spec.y() + 1);
- tiles << TileSpec(0, zoom, xn, spec.y() + 1);
- }
-
- for (int i = 0; i < tiles.size(); ++i) {
- TileSpec ts = tiles.at(i);
- if (!done.contains(ts) && !queued.contains(ts)) {
- queue << ts;
- queued << ts;
- }
- }
- }
- done << spec;
- queued.remove(spec);
- }
-
- return results;
-}
diff --git a/src/location/mapsgl/map3d/viewporttilesold_p.h b/src/location/mapsgl/map3d/viewporttilesold_p.h
deleted file mode 100644
index 6adb0253..00000000
--- a/src/location/mapsgl/map3d/viewporttilesold_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef VIEWPORTTILESOLD_P_H
-#define VIEWPORTTILESOLD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "viewporttiles_p_p.h"
-
-#include "frustum_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class ViewportCamera;
-
-class Arc;
-
-class ViewportTilesPrivateOld : public ViewportTilesPrivate {
-public:
- ViewportTilesPrivateOld();
- ~ViewportTilesPrivateOld();
-
- QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
-
-private:
- void calculateVisibleTiles();
-
- class IntersectionPoint {
- public:
- Frustum::Planes planes;
- QVector3D point;
- bool operator == (const IntersectionPoint &rhs) const {
- return ((planes == rhs.planes) && (point == rhs.point));
- }
- };
-
- class LengthSorter {
- public:
- IntersectionPoint base;
- bool operator()(const IntersectionPoint &lhs, const IntersectionPoint &rhs);
- };
-
- QList<Arc> pointIntersections(const Frustum &frustum, int *linesIntersected = 0) const;
-
- Sphere sphereFromArcs(QList<Arc> &arcs) const;
-
- Sphere sphereForPole(const QList<Arc> &Arcs, int zeroIndex1) const;
- Sphere sphereForDateline(const QList<Arc> &arcs, int zeroIndex1, int zeroIndex2) const;
-
- static QList<IntersectionPoint> lineIntersectsSphere(double radius, const QVector3D &start, const QVector3D &end, Frustum::Planes planesStart, Frustum::Planes planesEnd);
- static QVector3D interpolate(const QVector3D &start, const QVector3D &end, double n);
-
- QList<int> addDatelineCrossings(QList<Arc> &points) const;
-
- QPair<QVector3D, double> tileInfo(const TileSpec &spec) const;
- QList<TileSpec> visibleTilesFromPlanes(const ViewportCamera &viewportCamera) const;
-};
-
-QT_END_NAMESPACE
-
-#endif // VIEWPORTTILESOLD_P_H
diff --git a/src/location/mapsgl/mapsgl.pri b/src/location/mapsgl/mapsgl.pri
index 240d7ede..046090ff 100644
--- a/src/location/mapsgl/mapsgl.pri
+++ b/src/location/mapsgl/mapsgl.pri
@@ -4,7 +4,6 @@ INCLUDEPATH += mapsgl
QT += network qt3d
include(map2d/map2d.pri)
-include(map3d/map3d.pri)
SOURCES += \
mapsgl/cameradata.cpp \
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6f265098..8f23e753 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -31,13 +31,9 @@ SUBDIRS += geotestplugin \
qplacesupplier \
qplacesearchresult \
declarative \
- sphere \
qmlinterface \
maptype
contains(config_test_jsondb, yes) {
SUBDIRS += qplacemanager_jsondb
}
-
-!contains(QT_CONFIG,private_tests):SUBDIRS -= \
- sphere
diff --git a/tests/auto/sphere/sphere.pro b/tests/auto/sphere/sphere.pro
deleted file mode 100644
index 3e015e39..00000000
--- a/tests/auto/sphere/sphere.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_sphere
-
-QT += location testlib qt3d
-
-INCLUDEPATH = ../../../src/location/mapsgl
-
-SOURCES += tst_sphere.cpp
diff --git a/tests/auto/sphere/tst_sphere.cpp b/tests/auto/sphere/tst_sphere.cpp
deleted file mode 100644
index dc9aa098..00000000
--- a/tests/auto/sphere/tst_sphere.cpp
+++ /dev/null
@@ -1,1543 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QObject>
-#include <QtTest/QtTest>
-
-#include "../../../src/location/mapsgl/map3d/sphere_p.h"
-#include "../../../src/location/mapsgl/map3d/viewportcamera_p.h"
-#include "../../../src/location/mapsgl/frustum_p.h"
-#include "../../../src/location/mapsgl/map3d/projection3d_p.h"
-
-#include <QMetaType>
-
-#include <cmath>
-
-Q_DECLARE_METATYPE(Sphere)
-
-class tst_Sphere : public QObject
-{
- Q_OBJECT
-
-public:
- tst_Sphere() {
-
- }
-
-public slots:
- void initTestCase();
-
-private slots:
- void x_plane();
- void x_plane_data();
-
- void xy_plane_straight();
- void xy_plane_straight_data();
-
- void xy_plane_skew();
- void xy_plane_skew_data();
-
- void xyz_plane();
- void xyz_plane_data();
-
- void camera();
-
-private:
- Sphere emptySphere(double radius) const;
- Sphere basicSphere(double radius) const;
-
- bool test(const QPlane3D &plane, const Sphere &sphereOut);
-
- QList<QPlane3D> planes() const;
- Sphere planeTest(const QList<QPlane3D> &planes, const QList<int> &planeIndices) const;
-};
-
-void tst_Sphere::initTestCase()
-{
-#if defined(Q_OS_LINUX)
- QSKIP("Fails on Linux - see QTBUG-22634");
-#endif
-}
-
-Sphere tst_Sphere::emptySphere(double radius) const
-{
- return Sphere(radius, QList<SpherePatch>());
-}
-
-Sphere tst_Sphere::basicSphere(double radius) const
-{
- QList<Arc> arcs1In;
-
- QVector3D origin;
-
- QVector3D pxv = QVector3D(radius, 0.0, 0.0);
- QVector3D pyv = QVector3D(0.0, radius, 0.0);
- QVector3D pzv = QVector3D(0.0, 0.0, radius);
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
-
- arcs1In << Arc(pzp, radius, pxv, pyv);
- arcs1In << Arc(pxp, radius, pyv, pzv);
- arcs1In << Arc(pyp, radius, pzv, pxv);
-
- SpherePatch patch1In(radius, arcs1In);
-
- QList<SpherePatch> patchesIn;
-
- patchesIn << patch1In;
-
- Sphere sphereIn(radius, patchesIn);
-
- return sphereIn;
-}
-
-bool tst_Sphere::test(const QPlane3D &plane, const Sphere &sphereOut)
-{
- Sphere sphereIn = basicSphere(20000.0);
-
- sphereIn.intersect(plane);
-
- if (sphereIn == sphereOut) {
- return true;
- } else {
- qWarning() << sphereIn;
- qWarning() << sphereOut;
-
- return false;
- }
-}
-
-void tst_Sphere::x_plane()
-{
- QFETCH(QPlane3D, plane);
- QFETCH(Sphere, sphereOut);
-
- QVERIFY(test(plane, sphereOut));
-}
-
-void tst_Sphere::x_plane_data()
-{
- QTest::addColumn<QPlane3D>("plane");
- QTest::addColumn<Sphere>("sphereOut");
-
- double radius = 20000.0;
-
- QVector3D origin;
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
-
- Sphere empty = emptySphere(radius);
- Sphere basic = basicSphere(radius);
-
- double factor = radius * 0.0;
- double factor2 = sqrt((radius * radius) - (factor * factor));
-
- QTest::newRow("positive x forward 0.0")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("positive x backward 0.0")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << empty;
-
- QTest::newRow("negative x forward 0.0")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x backward 0.0")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << empty;
-
-
- factor = radius * 0.5;
- factor2 = sqrt((radius * radius) - (factor * factor));
-
- QPlane3D pxf050_plane = QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0));
-
- QList<Arc> pxf050_patch0_arcs;
- pxf050_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(factor, factor2, 0));
- pxf050_patch0_arcs << Arc(pxf050_plane, radius,
- QVector3D(factor, factor2, 0),
- QVector3D(factor, 0, factor2));
- pxf050_patch0_arcs << Arc(pyp, radius,
- QVector3D(factor, 0, factor2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxf050_patches;
- pxf050_patches << SpherePatch(radius, pxf050_patch0_arcs);
-
- Sphere pxf050 = Sphere(radius, pxf050_patches);
-
- QTest::newRow("positive x forward 0.5")
- << pxf050_plane
- << pxf050;
-
- QPlane3D pxb050_plane = QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0));
-
- QList<Arc> pxb050_patch0_arcs;
- pxb050_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxb050_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(factor, 0, factor2));
- pxb050_patch0_arcs << Arc(pxb050_plane, radius,
- QVector3D(factor, 0, factor2),
- QVector3D(factor, factor2, 0));
- pxb050_patch0_arcs << Arc(pzp, radius,
- QVector3D(factor, factor2, 0),
- QVector3D(0, radius, 0));
-
-
- QList<SpherePatch> pxb050_patches;
- pxb050_patches << SpherePatch(radius, pxb050_patch0_arcs);
-
- Sphere pxb050 = Sphere(radius, pxb050_patches);
-
- QTest::newRow("positive x backward 0.5")
- << pxb050_plane
- << pxb050;
-
- QTest::newRow("negative x forward 0.5")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x backward 0.5")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << empty;
-
-
- factor = radius * 1.0;
-
-
- QTest::newRow("positive x forward 1.0")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << empty;
-
- QTest::newRow("positive x backward 1.0")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x forward 1.0")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x backward 1.0")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << empty;
-
-
- factor = radius * 1.25;
-
- QTest::newRow("positive x forward 1.25")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << empty;
-
- QTest::newRow("positive x backward 1.25")
- << QPlane3D(QVector3D(factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x forward 1.25")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(1.0, 0.0, 0.0))
- << basic;
-
- QTest::newRow("negative x backward 1.25")
- << QPlane3D(QVector3D(-1.0 * factor, 0.0, 0.0), QVector3D(-1.0, 0.0, 0.0))
- << empty;
-}
-
-void tst_Sphere::xy_plane_straight()
-{
- QFETCH(QPlane3D, plane);
- QFETCH(Sphere, sphereOut);
-
- QVERIFY(test(plane, sphereOut));
-}
-
-void tst_Sphere::xy_plane_straight_data()
-{
- QTest::addColumn<QPlane3D>("plane");
- QTest::addColumn<Sphere>("sphereOut");
-
- double radius = 20000.0;
-
- QVector3D origin;
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
-
- Sphere empty = emptySphere(radius);
- Sphere basic = basicSphere(radius);
-
- double factor1 = radius * 0.0;
- double factor2 = radius * 0.0;
-
- QPlane3D pxpyf_000_000_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("positive x positive y forward 0.0 0.0")
- << pxpyf_000_000_plane
- << basic;
-
- QPlane3D pxpyb_000_000_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("positive x positive y backward 0.0 0.0")
- << pxpyb_000_000_plane
- << empty;
-
- QPlane3D pxnyf_000_000_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- double f1 = radius / sqrt(2);
- double f2 = radius / sqrt(2);
-
- QList<Arc> pxnyf_000_000_patch0_arcs;
- pxnyf_000_000_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f1, f2, 0));
- pxnyf_000_000_patch0_arcs << Arc(pxnyf_000_000_plane, radius,
- QVector3D(f1, f2, 0),
- QVector3D(0, 0, radius));
- pxnyf_000_000_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
-
-
- QList<SpherePatch> pxnyf_000_000_patches;
- pxnyf_000_000_patches << SpherePatch(radius, pxnyf_000_000_patch0_arcs);
-
- Sphere pxnyf_000_000 = Sphere(radius, pxnyf_000_000_patches);
-
- QTest::newRow("positive x negative y forward 0.0 0.0")
- << pxnyf_000_000_plane
- << pxnyf_000_000;
-
- QPlane3D pxnyb_000_000_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QList<Arc> pxnyb_000_000_patch0_arcs;
- pxnyb_000_000_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxnyb_000_000_patch0_arcs << Arc(pxnyb_000_000_plane, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, f2, 0));
- pxnyb_000_000_patch0_arcs << Arc(pzp, radius,
- QVector3D(f1, f2, 0),
- QVector3D(0, radius, 0));
-
-
- QList<SpherePatch> pxnyb_000_000_patches;
- pxnyb_000_000_patches << SpherePatch(radius, pxnyb_000_000_patch0_arcs);
-
- Sphere pxnyb_000_000(radius, pxnyb_000_000_patches);
-
- QTest::newRow("positive x negative y backward 0.0 0.0")
- << pxnyb_000_000_plane
- << pxnyb_000_000;
-
- QPlane3D nxpyf_000_000_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QList<Arc> nxpyf_000_000_patch0_arcs;
- nxpyf_000_000_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f1, f2, 0));
- nxpyf_000_000_patch0_arcs << Arc(nxpyf_000_000_plane, radius,
- QVector3D(f1, f2, 0),
- QVector3D(0, 0, radius));
- nxpyf_000_000_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> nxpyf_000_000_patches;
- nxpyf_000_000_patches << SpherePatch(radius, nxpyf_000_000_patch0_arcs);
-
- Sphere nxpyf_000_000 = Sphere(radius, nxpyf_000_000_patches);
-
- QTest::newRow("negative x positive y forward 0.0 0.0")
- << nxpyf_000_000_plane
- << nxpyf_000_000;
-
- QPlane3D nxpyb_000_000_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QList<Arc> nxpyb_000_000_patch0_arcs;
- nxpyb_000_000_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- nxpyb_000_000_patch0_arcs << Arc(nxpyb_000_000_plane, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, f2, 0));
- nxpyb_000_000_patch0_arcs << Arc(pzp, radius,
- QVector3D(f1, f2, 0),
- QVector3D(0, radius, 0));
-
- QList<SpherePatch> nxpyb_000_000_patches;
- nxpyb_000_000_patches << SpherePatch(radius, nxpyb_000_000_patch0_arcs);
-
- Sphere nxpyb_000_000(radius, nxpyb_000_000_patches);
-
- QTest::newRow("negative x positive y backward 0.0 0.0")
- << nxpyb_000_000_plane
- << nxpyb_000_000;
-
- QPlane3D nxnyf_000_000_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.0 0.0")
- << nxnyf_000_000_plane
- << basic;
-
- QPlane3D nxnyb_000_000_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.0 0.0")
- << nxnyb_000_000_plane
- << empty;
-
- factor1 = radius * 0.25;
- factor2 = radius * 0.25;
-
- QPlane3D pxpyf_025_025_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- f1 = radius / 2.0;
- f2 = radius * sqrt(3) / 2.0;
-
- QList<Arc> pxpyf_025_025_patch0_arcs;
- pxpyf_025_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(0, radius, 0));
- pxpyf_025_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, f1, f2));
- pxpyf_025_025_patch0_arcs << Arc(pxpyf_025_025_plane, radius,
- QVector3D(0, f1, f2),
- QVector3D(f1, 0, f2));
- pxpyf_025_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(f1, 0, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxpyf_025_025_patches;
- pxpyf_025_025_patches << SpherePatch(radius, pxpyf_025_025_patch0_arcs);
-
- Sphere pxpyf_025_025(radius, pxpyf_025_025_patches);
-
- QTest::newRow("positive x positive y forward 0.25 0.25")
- << pxpyf_025_025_plane
- << pxpyf_025_025;
-
- QPlane3D pxpyb_025_025_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QList<Arc> pxpyb_025_025_patch0_arcs;
- pxpyb_025_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, 0, f2));
- pxpyb_025_025_patch0_arcs << Arc(pxpyb_025_025_plane, radius,
- QVector3D(f1, 0, f2),
- QVector3D(0, f1, f2));
- pxpyb_025_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, f1, f2),
- QVector3D(0, 0, radius));
-
- QList<SpherePatch> pxpyb_025_025_patches;
- pxpyb_025_025_patches << SpherePatch(radius, pxpyb_025_025_patch0_arcs);
-
- Sphere pxpyb_025_025(radius, pxpyb_025_025_patches);
-
- QTest::newRow("positive x positive y backward 0.25 0.25")
- << pxpyb_025_025_plane
- << pxpyb_025_025;
-
- QPlane3D pxnyf_025_025_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- /*
- f3 = positive intersection of x = y + 0.5 * r and x^2 + y^2 = r^2
- f4 = f3 - 0.5 * r
- */
-
- double f3 = radius * (1.0 + sqrt(7)) / 4.0;
- double f4 = f3 - radius / 2.0;
-
- QList<Arc> pxnyf_025_025_patch0_arcs;
- pxnyf_025_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f3, f4, 0));
- pxnyf_025_025_patch0_arcs << Arc(pxnyf_025_025_plane, radius,
- QVector3D(f3, f4, 0),
- QVector3D(f1, 0, f2));
- pxnyf_025_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(f1, 0, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxnyf_025_025_patches;
- pxnyf_025_025_patches << SpherePatch(radius, pxnyf_025_025_patch0_arcs);
-
- Sphere pxnyf_025_025(radius, pxnyf_025_025_patches);
-
- QTest::newRow("positive x negative y forward 0.25 0.25")
- << pxnyf_025_025_plane
- << pxnyf_025_025;
-
- QPlane3D pxnyb_025_025_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QList<Arc> pxnyb_025_025_patch0_arcs;
- pxnyb_025_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxnyb_025_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, 0, f2));
- pxnyb_025_025_patch0_arcs << Arc(pxnyb_025_025_plane, radius,
- QVector3D(f1, 0, f2),
- QVector3D(f3, f4, 0));
- pxnyb_025_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(f3, f4, 0),
- QVector3D(0, radius, 0));
-
- QList<SpherePatch> pxnyb_025_025_patches;
- pxnyb_025_025_patches << SpherePatch(radius, pxnyb_025_025_patch0_arcs);
-
- Sphere pxnyb_025_025(radius, pxnyb_025_025_patches);
-
- QTest::newRow("positive x negative y backward 0.25 0.25")
- << pxnyb_025_025_plane
- << pxnyb_025_025;
-
- QPlane3D nxpyf_025_025_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QList<Arc> nxpyf_025_025_patch0_arcs;
- nxpyf_025_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f4, f3, 0));
- nxpyf_025_025_patch0_arcs << Arc(nxpyf_025_025_plane, radius,
- QVector3D(f4, f3, 0),
- QVector3D(0, f1, f2));
- nxpyf_025_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, f1, f2),
- QVector3D(0, 0, radius));
- nxpyf_025_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> nxpyf_025_025_patches;
- nxpyf_025_025_patches << SpherePatch(radius, nxpyf_025_025_patch0_arcs);
-
- Sphere nxpyf_025_025(radius, nxpyf_025_025_patches);
-
- QTest::newRow("negative x positive y forward 0.25 0.25")
- << nxpyf_025_025_plane
- << nxpyf_025_025;
-
- QPlane3D nxpyb_025_025_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QList<Arc> nxpyb_025_025_patch0_arcs;
- nxpyb_025_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(f4, f3, 0),
- QVector3D(0, radius, 0));
- nxpyb_025_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, f1, f2));
- nxpyb_025_025_patch0_arcs << Arc(nxpyb_025_025_plane, radius,
- QVector3D(0, f1, f2),
- QVector3D(f4, f3, 0));
-
- QList<SpherePatch> nxpyb_025_025_patches;
- nxpyb_025_025_patches << SpherePatch(radius, nxpyb_025_025_patch0_arcs);
-
- Sphere nxpyb_025_025(radius, nxpyb_025_025_patches);
-
- QTest::newRow("negative x positive y backward 0.25 0.25")
- << nxpyb_025_025_plane
- << nxpyb_025_025;
-
- QPlane3D nxnyf_025_025_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.25 0.25")
- << nxnyf_025_025_plane
- << basic;
-
- QPlane3D nxnyb_025_025_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.25 0.25")
- << nxnyb_025_025_plane
- << empty;
-
- factor1 = radius * 0.5;
- factor2 = radius * 0.5;
-
- f1 = radius * 0.5;
- f2 = radius / sqrt(2);
-
- QPlane3D pxpyf_050_050_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QList<Arc> pxpyf_050_050_patch0_arcs;
- pxpyf_050_050_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(0, radius, 0));
- pxpyf_050_050_patch0_arcs << Arc(pxpyf_050_050_plane, radius,
- QVector3D(0, radius, 0),
- QVector3D(f1, f1, f2));
- pxpyf_050_050_patch0_arcs << Arc(pxpyf_050_050_plane, radius,
- QVector3D(f1, f1, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxpyf_050_050_patches;
- pxpyf_050_050_patches << SpherePatch(radius, pxpyf_050_050_patch0_arcs);
-
- Sphere pxpyf_050_050(radius, pxpyf_050_050_patches);
-
- QTest::newRow("positive x positive y forward 0.5 0.5")
- << pxpyf_050_050_plane
- << pxpyf_050_050;
-
- QPlane3D pxpyb_050_050_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QList<Arc> pxpyb_050_050_patch0_arcs;
- pxpyb_050_050_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxpyb_050_050_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
- pxpyb_050_050_patch0_arcs << Arc(pxpyb_050_050_plane, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f1, f1, f2));
- pxpyb_050_050_patch0_arcs << Arc(pxpyb_050_050_plane, radius,
- QVector3D(f1, f1, f2),
- QVector3D(0, radius, 0));
-
- QList<SpherePatch> pxpyb_050_050_patches;
- pxpyb_050_050_patches << SpherePatch(radius, pxpyb_050_050_patch0_arcs);
-
- Sphere pxpyb_050_050(radius, pxpyb_050_050_patches);
-
- QTest::newRow("positive x positive y backward 0.5 0.5")
- << pxpyb_050_050_plane
- << pxpyb_050_050;
-
- QPlane3D pxnyf_050_050_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y forward 0.5 0.5")
- << pxnyf_050_050_plane
- << empty;
-
- QPlane3D pxnyb_050_050_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y backward 0.5 0.5")
- << pxnyb_050_050_plane
- << basic;
-
- QPlane3D nxpyf_050_050_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y forward 0.5 0.5")
- << nxpyf_050_050_plane
- << basic;
-
- QPlane3D nxpyb_050_050_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y backward 0.5 0.5")
- << nxpyb_050_050_plane
- << empty;
-
- QPlane3D nxnyf_050_050_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.5 0.5")
- << nxnyf_050_050_plane
- << basic;
-
- QPlane3D nxnyb_050_050_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.5 0.5")
- << nxnyb_050_050_plane
- << empty;
-
- factor1 = radius * 0.6;
- factor2 = radius * 0.6;
-
- f1 = radius * 0.6;
- f2 = f1 * sqrt(7.0 / 9.0);
- f3 = f1 + f2 / sqrt(2);
- f4 = f1 - f2 / sqrt(2);
-
- QPlane3D pxpyf_060_060_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QList<Arc> pxpyf_060_060_patch0_arcs;
- pxpyf_060_060_patch0_arcs << Arc(pzp, radius,
- QVector3D(f3, f4, 0),
- QVector3D(f4, f3, 0));
- pxpyf_060_060_patch0_arcs << Arc(pxpyf_060_060_plane, radius,
- QVector3D(f4, f3, 0),
- QVector3D(f1, f1, f2));
- pxpyf_060_060_patch0_arcs << Arc(pxpyf_060_060_plane, radius,
- QVector3D(f1, f1, f2),
- QVector3D(f3, f4, 0));
-
- QList<SpherePatch> pxpyf_060_060_patches;
- pxpyf_060_060_patches << SpherePatch(radius, pxpyf_060_060_patch0_arcs);
-
- Sphere pxpyf_060_060(radius, pxpyf_060_060_patches);
-
- QTest::newRow("positive x positive y forward 0.6 0.6")
- << pxpyf_060_060_plane
- << pxpyf_060_060;
-
- QPlane3D pxpyb_060_060_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QList<Arc> pxpyb_060_060_patch0_arcs;
- pxpyb_060_060_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f3, f4, 0));
- pxpyb_060_060_patch0_arcs << Arc(pxpyb_060_060_plane, radius,
- QVector3D(f3, f4, 0),
- QVector3D(f1, f1, f2));
- pxpyb_060_060_patch0_arcs << Arc(pxpyb_060_060_plane, radius,
- QVector3D(f1, f1, f2),
- QVector3D(f4, f3, 0));
- pxpyb_060_060_patch0_arcs << Arc(pzp, radius,
- QVector3D(f4, f3, 0),
- QVector3D(0, radius, 0));
- pxpyb_060_060_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxpyb_060_060_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxpyb_060_060_patches;
- pxpyb_060_060_patches << SpherePatch(radius, pxpyb_060_060_patch0_arcs);
-
- Sphere pxpyb_060_060(radius, pxpyb_060_060_patches);
-
- QTest::newRow("positive x positive y backward 0.6 0.6")
- << pxpyb_060_060_plane
- << pxpyb_060_060;
-
- QPlane3D pxnyf_060_060_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y forward 0.6 0.6")
- << pxnyf_060_060_plane
- << empty;
-
- QPlane3D pxnyb_060_060_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y backward 0.6 0.6")
- << pxnyb_060_060_plane
- << basic;
-
- QPlane3D nxpyf_060_060_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y forward 0.6 0.6")
- << nxpyf_060_060_plane
- << basic;
-
- QPlane3D nxpyb_060_060_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y backward 0.6 0.6")
- << nxpyb_060_060_plane
- << empty;
-
- QPlane3D nxnyf_060_060_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.6 0.6")
- << nxnyf_060_060_plane
- << basic;
-
- QPlane3D nxnyb_060_060_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.6 0.6")
- << nxnyb_060_060_plane
- << empty;
-
- factor1 = radius * 0.75;
- factor2 = radius * 0.75;
-
- QPlane3D pxpyf_075_075_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("positive x positive y forward 0.75 0.75")
- << pxpyf_075_075_plane
- << empty;
-
- QPlane3D pxpyb_075_075_plane = QPlane3D(QVector3D(factor1, factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("positive x positive y backward 0.75 0.75")
- << pxpyb_075_075_plane
- << basic;
-
- QPlane3D pxnyf_075_075_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y forward 0.75 0.75")
- << pxnyf_075_075_plane
- << empty;
-
- QPlane3D pxnyb_075_075_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("positive x negative y backward 0.75 0.75")
- << pxnyb_075_075_plane
- << basic;
-
- QPlane3D nxpyf_075_075_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y forward 0.75 0.75")
- << nxpyf_075_075_plane
- << basic;
-
- QPlane3D nxpyb_075_075_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0), QVector3D(-1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x positive y backward 0.75 0.75")
- << nxpyb_075_075_plane
- << empty;
-
- QPlane3D nxnyf_075_075_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(1.0, 1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.75 0.75")
- << nxnyf_075_075_plane
- << basic;
-
- QPlane3D nxnyb_075_075_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0), QVector3D(-1.0, -1.0, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.75 0.75")
- << nxnyb_075_075_plane
- << empty;
-}
-
-void tst_Sphere::xy_plane_skew()
-{
- QFETCH(QPlane3D, plane);
- QFETCH(Sphere, sphereOut);
-
- QVERIFY(test(plane, sphereOut));
-}
-
-void tst_Sphere::xy_plane_skew_data()
-{
- QTest::addColumn<QPlane3D>("plane");
- QTest::addColumn<Sphere>("sphereOut");
-
- double radius = 20000.0;
-
- QVector3D origin;
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
-
- Sphere empty = emptySphere(radius);
- Sphere basic = basicSphere(radius);
-
- double factor1 = radius * 0.25;
- double factor2 = radius * 0.5;
-
- double f1 = radius * 0.5;
- double f2 = radius * sqrt(3) / 2.0;
- double f3 = radius * 0.8;
- double f4 = radius * 0.6;
-
- QPlane3D pxpyf_025_050_plane = QPlane3D(QVector3D(factor1, factor2, 0.0),
- QVector3D(0.5, 0.25, 0.0).normalized());
-
- QList<Arc> pxpyf_025_050_patch0_arcs;
- pxpyf_025_050_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(0, radius, 0));
- pxpyf_025_050_patch0_arcs << Arc(pxpyf_025_050_plane, radius,
- QVector3D(0, radius, 0),
- QVector3D(f1, 0, f2));
- pxpyf_025_050_patch0_arcs << Arc(pyp, radius,
- QVector3D(f1, 0, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxpyf_025_050_patches;
- pxpyf_025_050_patches << SpherePatch(radius, pxpyf_025_050_patch0_arcs);
-
- Sphere pxpyf_025_050(radius, pxpyf_025_050_patches);
-
- QTest::newRow("positive x positive y forward 0.25 0.5")
- << pxpyf_025_050_plane
- << pxpyf_025_050;
-
- QPlane3D pxpyb_025_050_plane = QPlane3D(QVector3D(factor1, factor2, 0.0),
- QVector3D(-0.5, -0.25, 0.0).normalized());
-
- QList<Arc> pxpyb_025_050_patch0_arcs;
- pxpyb_025_050_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, 0, f2));
- pxpyb_025_050_patch0_arcs << Arc(pxpyb_025_050_plane, radius,
- QVector3D(f1, 0, f2),
- QVector3D(0, radius, 0));
- pxpyb_025_050_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
-
-
- QList<SpherePatch> pxpyb_025_050_patches;
- pxpyb_025_050_patches << SpherePatch(radius, pxpyb_025_050_patch0_arcs);
-
- Sphere pxpyb_025_050(radius, pxpyb_025_050_patches);
-
- QTest::newRow("positive x positive y backward 0.25 0.5")
- << pxpyb_025_050_plane
- << pxpyb_025_050;
-
- QPlane3D pxnyf_025_050_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0),
- QVector3D(-0.5, 0.25, 0.0).normalized());
-
- QList<Arc> pxnyf_025_050_patch0_arcs;
- pxnyf_025_050_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, 0, radius));
- pxnyf_025_050_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(f1, 0, f2));
- pxnyf_025_050_patch0_arcs << Arc(pxnyf_025_050_plane, radius,
- QVector3D(f1, 0, f2),
- QVector3D(f3, f4, 0));
- pxnyf_025_050_patch0_arcs << Arc(pzp, radius,
- QVector3D(f3, f4, 0),
- QVector3D(0, radius, 0));
-
- QList<SpherePatch> pxnyf_025_050_patches;
- pxnyf_025_050_patches << SpherePatch(radius, pxnyf_025_050_patch0_arcs);
-
- Sphere pxnyf_025_050(radius, pxnyf_025_050_patches);
-
- QTest::newRow("positive x negative y forward 0.25 0.5")
- << pxnyf_025_050_plane
- << pxnyf_025_050;
-
- QPlane3D pxnyb_025_050_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0),
- QVector3D(0.5, -0.25, 0.0).normalized());
-
- QList<Arc> pxnyb_025_050_patch0_arcs;
- pxnyb_025_050_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f3, f4, 0));
- pxnyb_025_050_patch0_arcs << Arc(pxnyb_025_050_plane, radius,
- QVector3D(f3, f4, 0),
- QVector3D(f1, 0, f2));
- pxnyb_025_050_patch0_arcs << Arc(pyp, radius,
- QVector3D(f1, 0, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxnyb_025_050_patches;
- pxnyb_025_050_patches << SpherePatch(radius, pxnyb_025_050_patch0_arcs);
-
- Sphere pxnyb_025_050(radius, pxnyb_025_050_patches);
-
- QTest::newRow("positive x negative y backward 0.25 0.5")
- << pxnyb_025_050_plane
- << pxnyb_025_050;
-
- QPlane3D nxpyf_025_050_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0),
- QVector3D(0.5, -0.25, 0.0).normalized());
-
- QTest::newRow("negative x positive y forward 0.25 0.5")
- << nxpyf_025_050_plane
- << basic;
-
- QPlane3D nxpyb_025_050_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0),
- QVector3D(-0.5, 0.25, 0.0).normalized());
-
- QTest::newRow("negative x positive y backward 0.25 0.5")
- << nxpyb_025_050_plane
- << empty;
-
- QPlane3D nxnyf_025_050_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0),
- QVector3D(0.5, 0.25, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.25 0.5")
- << nxnyf_025_050_plane
- << basic;
-
- QPlane3D nxnyb_025_050_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0),
- QVector3D(-0.5, -0.25, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.25 0.5")
- << nxnyb_025_050_plane
- << empty;
-
- factor1 = radius * 0.5;
- factor2 = radius * 0.25;
-
- QPlane3D pxpyf_050_025_plane = QPlane3D(QVector3D(factor1, factor2, 0.0),
- QVector3D(0.25, 0.5, 0.0).normalized());
-
- QList<Arc> pxpyf_050_025_patch0_arcs;
- pxpyf_050_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(0, radius, 0));
- pxpyf_050_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, f1, f2));
- pxpyf_050_025_patch0_arcs << Arc(pxpyf_050_025_plane, radius,
- QVector3D(0, f1, f2),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> pxpyf_050_025_patches;
- pxpyf_050_025_patches << SpherePatch(radius, pxpyf_050_025_patch0_arcs);
-
- Sphere pxpyf_050_025(radius, pxpyf_050_025_patches);
-
- QTest::newRow("positive x positive y forward 0.5 0.25")
- << pxpyf_050_025_plane
- << pxpyf_050_025;
-
- QPlane3D pxpyb_050_025_plane = QPlane3D(QVector3D(factor1, factor2, 0.0),
- QVector3D(-0.25, -0.5, 0.0).normalized());
-
- QList<Arc> pxpyb_050_025_patch0_arcs;
- pxpyb_050_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
- pxpyb_050_025_patch0_arcs << Arc(pxpyb_050_025_plane, radius,
- QVector3D(radius, 0, 0),
- QVector3D(0, f1, f2));
- pxpyb_050_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, f1, f2),
- QVector3D(0, 0, radius));
-
- QList<SpherePatch> pxpyb_050_025_patches;
- pxpyb_050_025_patches << SpherePatch(radius, pxpyb_050_025_patch0_arcs);
-
- Sphere pxpyb_050_025(radius, pxpyb_050_025_patches);
-
- QTest::newRow("positive x positive y backward 0.5 0.25")
- << pxpyb_050_025_plane
- << pxpyb_050_025;
-
- QPlane3D pxnyf_050_025_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0),
- QVector3D(-0.25, 0.5, 0.0).normalized());
-
- QTest::newRow("positive x negative y forward 0.5 0.25")
- << pxnyf_050_025_plane
- << basic;
-
- QPlane3D pxnyb_050_025_plane = QPlane3D(QVector3D(factor1, -1.0 * factor2, 0.0),
- QVector3D(0.25, -0.5, 0.0).normalized());
-
- QTest::newRow("positive x negative y backward 0.5 0.25")
- << pxnyb_050_025_plane
- << empty;
-
- QPlane3D nxpyf_050_025_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0),
- QVector3D(0.25, -0.5, 0.0).normalized());
-
- QList<Arc> nxpyf_050_025_patch0_arcs;
- nxpyf_050_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f4, f3, 0));
- nxpyf_050_025_patch0_arcs << Arc(nxpyf_050_025_plane, radius,
- QVector3D(f4, f3, 0),
- QVector3D(0, f1, f2));
- nxpyf_050_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, f1, f2),
- QVector3D(0, 0, radius));
- nxpyf_050_025_patch0_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(radius, 0, 0));
-
- QList<SpherePatch> nxpyf_050_025_patches;
- nxpyf_050_025_patches << SpherePatch(radius, nxpyf_050_025_patch0_arcs);
-
- Sphere nxpyf_050_025(radius, nxpyf_050_025_patches);
-
- QTest::newRow("negative x positive y forward 0.5 0.25")
- << nxpyf_050_025_plane
- << nxpyf_050_025;
-
- QPlane3D nxpyb_050_025_plane = QPlane3D(QVector3D(-1.0 * factor1, factor2, 0.0),
- QVector3D(-0.25, 0.5, 0.0).normalized());
-
- QList<Arc> nxpyb_050_025_patch0_arcs;
- nxpyb_050_025_patch0_arcs << Arc(pzp, radius,
- QVector3D(f4, f3, 0),
- QVector3D(0, radius, 0));
- nxpyb_050_025_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, f1, f2));
- nxpyb_050_025_patch0_arcs << Arc(nxpyb_050_025_plane, radius,
- QVector3D(0, f1, f2),
- QVector3D(f4, f3, 0));
-
- QList<SpherePatch> nxpyb_050_025_patches;
- nxpyb_050_025_patches << SpherePatch(radius, nxpyb_050_025_patch0_arcs);
-
- Sphere nxpyb_050_025(radius, nxpyb_050_025_patches);
-
- QTest::newRow("negative x positive y backward 0.5 0.25")
- << nxpyb_050_025_plane
- << nxpyb_050_025;
-
- QPlane3D nxnyf_050_025_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0),
- QVector3D(0.25, 0.5, 0.0).normalized());
-
- QTest::newRow("negative x negative y forward 0.5 0.25")
- << nxnyf_050_025_plane
- << basic;
-
- QPlane3D nxnyb_050_025_plane = QPlane3D(QVector3D(-1.0 * factor1, -1.0 * factor2, 0.0),
- QVector3D(-0.25, -0.5, 0.0).normalized());
-
- QTest::newRow("negative x negative y backward 0.5 0.25")
- << nxnyb_050_025_plane
- << empty;
-}
-
-void tst_Sphere::xyz_plane()
-{
- QFETCH(QPlane3D, plane);
- QFETCH(Sphere, sphereOut);
-
- QVERIFY(test(plane, sphereOut));
-}
-
-void tst_Sphere::xyz_plane_data()
-{
- QTest::addColumn<QPlane3D>("plane");
- QTest::addColumn<Sphere>("sphereOut");
-
- double radius = 20000.0;
-
- QVector3D origin;
-
- QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
- QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
- QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
-
- Sphere empty = emptySphere(radius);
- Sphere basic = basicSphere(radius);
-
- double factor1 = radius * 0.0;
- double factor2 = radius * 0.0;
- double factor3 = radius * 0.0;
-
- QPlane3D pxpypzf_000 = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QTest::newRow("positive x positive y positive z forward 0.0")
- << pxpypzf_000
- << basic;
-
- QPlane3D pxpypzb_000 = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QTest::newRow("positive x positive y positive z backward 0.0")
- << pxpypzb_000
- << empty;
-
- factor1 = radius * 0.25;
- factor2 = radius * 0.25;
- factor3 = radius * 0.25;
-
- QPlane3D pxpypzf_025 = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QTest::newRow("positive x positive y positive z forward 0.25")
- << pxpypzf_025
- << basic;
-
- QPlane3D pxpypzb_025 = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QTest::newRow("positive x positive y positive z backward 0.25")
- << pxpypzb_025
- << empty;
-
- factor1 = radius / 3.0;
- factor2 = radius / 3.0;
- factor3 = radius / 3.0;
-
- QPlane3D pxpypzf_033_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QTest::newRow("positive x positive y positive z forward 0.33")
- << pxpypzf_033_plane
- << basic;
-
- QPlane3D pxpypzb_033_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QTest::newRow("positive x positive y positive z backward 0.33")
- << pxpypzb_033_plane
- << empty;
-
- factor1 = radius * 0.4;
- factor2 = radius * 0.4;
- factor3 = radius * 0.4;
-
- QPlane3D pxpypzf_040_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- double f1 = 19483.3;
- double f2 = 4516.69;
-
- QList<Arc> pxpypzf_040_patch0_arcs;
- pxpypzf_040_patch0_arcs << Arc(pzp, radius,
- QVector3D(f1, f2, 0),
- QVector3D(f2, f1, 0));
- pxpypzf_040_patch0_arcs << Arc(pxpypzf_040_plane, radius,
- QVector3D(f2, f1, 0),
- QVector3D(0, f1, f2));
- pxpypzf_040_patch0_arcs << Arc(pxp, radius,
- QVector3D(0, f1, f2),
- QVector3D(0, f2, f1));
- pxpypzf_040_patch0_arcs << Arc(pxpypzf_040_plane, radius,
- QVector3D(0, f2, f1),
- QVector3D(f2, 0, f1));
- pxpypzf_040_patch0_arcs << Arc(pyp, radius,
- QVector3D(f2, 0, f1),
- QVector3D(f1, 0, f2));
- pxpypzf_040_patch0_arcs << Arc(pxpypzf_040_plane, radius,
- QVector3D(f1, 0, f2),
- QVector3D(f1, f2, 0));
-
- QList<SpherePatch> pxpypzf_040_patches;
- pxpypzf_040_patches << SpherePatch(radius, pxpypzf_040_patch0_arcs);
-
- Sphere pxpypzf_040(radius, pxpypzf_040_patches);
-
- QTest::newRow("positive x positive y positive z forward 0.4")
- << pxpypzf_040_plane
- << pxpypzf_040;
-
- QPlane3D pxpypzb_040_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QList<Arc> pxpypzb_040_patch0_arcs;
- pxpypzb_040_patch0_arcs << Arc(pzp, radius,
- QVector3D(radius, 0, 0),
- QVector3D(f1, f2, 0));
- pxpypzb_040_patch0_arcs << Arc(pxpypzb_040_plane, radius,
- QVector3D(f1, f2, 0),
- QVector3D(f1, 0, f2));
- pxpypzb_040_patch0_arcs << Arc(pyp, radius,
- QVector3D(f1, 0, f2),
- QVector3D(radius, 0, 0));
-
- QList<Arc> pxpypzb_040_patch1_arcs;
- pxpypzb_040_patch1_arcs << Arc(pxp, radius,
- QVector3D(0, radius, 0),
- QVector3D(0, f1, f2));
- pxpypzb_040_patch1_arcs << Arc(pxpypzb_040_plane, radius,
- QVector3D(0, f1, f2),
- QVector3D(f2, f1, 0));
- pxpypzb_040_patch1_arcs << Arc(pzp, radius,
- QVector3D(f2, f1, 0),
- QVector3D(0, radius, 0));
-
- QList<Arc> pxpypzb_040_patch2_arcs;
- pxpypzb_040_patch2_arcs << Arc(pyp, radius,
- QVector3D(0, 0, radius),
- QVector3D(f2, 0, f1));
- pxpypzb_040_patch2_arcs << Arc(pxpypzb_040_plane, radius,
- QVector3D(f2, 0, f1),
- QVector3D(0, f2, f1));
- pxpypzb_040_patch2_arcs << Arc(pxp, radius,
- QVector3D(0, f2, f1),
- QVector3D(0, 0, radius));
-
- QList<SpherePatch> pxpypzb_040_patches;
-
- pxpypzb_040_patches << SpherePatch(radius, pxpypzb_040_patch0_arcs);
- pxpypzb_040_patches << SpherePatch(radius, pxpypzb_040_patch1_arcs);
- pxpypzb_040_patches << SpherePatch(radius, pxpypzb_040_patch2_arcs);
-
- Sphere pxpypzb_040(radius, pxpypzb_040_patches);
-
- QTest::newRow("positive x positive y positive z backward 0.4")
- << pxpypzb_040_plane
- << pxpypzb_040;
-
- factor1 = radius * 0.5;
- factor2 = radius * 0.5;
- factor3 = radius * 0.5;
-
- f1 = 18165.0;
- f2 = 5917.52;
-
- QPlane3D pxpypzf_050_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QList<Arc> pxpypzf_050_patch0_arcs;
- pxpypzf_050_patch0_arcs << Arc(pxpypzf_050_plane, radius,
- QVector3D(f1, f2, f2),
- QVector3D(f2, f1, f2));
- pxpypzf_050_patch0_arcs << Arc(pxpypzf_050_plane, radius,
- QVector3D(f2, f1, f2),
- QVector3D(f2, f2, f1));
- pxpypzf_050_patch0_arcs << Arc(pxpypzf_050_plane, radius,
- QVector3D(f2, f2, f1),
- QVector3D(f1, f2, f2));
-
- QList<SpherePatch> pxpypzf_050_patches;
- pxpypzf_050_patches << SpherePatch(radius, pxpypzf_050_patch0_arcs);
-
- Sphere pxpypzf_050(radius, pxpypzf_050_patches);
-
- QTest::newRow("positive x positive y positive z forward 0.5")
- << pxpypzf_050_plane
- << pxpypzf_050;
-
- QPlane3D pxpypzb_050_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
-// QList<Arc> pxpypzb_050_patch0_arcs;
-// pxpypzb_050_patch0_arcs << Arc(pzp, radius,
-// QVector3D(radius, 0, 0),
-// QVector3D(f1, f2, 0));
-// pxpypzb_050_patch0_arcs << Arc(pxpypzb_050_plane, radius,
-// QVector3D(f1, f2, 0),
-// QVector3D(f1, 0, f2));
-// pxpypzb_050_patch0_arcs << Arc(pyp, radius,
-// QVector3D(f1, 0, f2),
-// QVector3D(radius, 0, 0));
-
-// QList<Arc> pxpypzb_050_patch1_arcs;
-// pxpypzb_050_patch1_arcs << Arc(pxp, radius,
-// QVector3D(0, radius, 0),
-// QVector3D(0, f1, f2));
-// pxpypzb_050_patch1_arcs << Arc(pxpypzb_050_plane, radius,
-// QVector3D(0, f1, f2),
-// QVector3D(f2, f1, 0));
-// pxpypzb_050_patch1_arcs << Arc(pzp, radius,
-// QVector3D(f2, f1, 0),
-// QVector3D(0, radius, 0));
-
-// QList<Arc> pxpypzb_050_patch2_arcs;
-// pxpypzb_050_patch2_arcs << Arc(pyp, radius,
-// QVector3D(0, 0, radius),
-// QVector3D(f2, 0, f1));
-// pxpypzb_050_patch2_arcs << Arc(pxpypzb_050_plane, radius,
-// QVector3D(f2, 0, 1),
-// QVector3D(0, f2, f1));
-// pxpypzb_050_patch2_arcs << Arc(pxp, radius,
-// QVector3D(0, f2, f1),
-// QVector3D(0, 0, radius));
-
- QList<SpherePatch> pxpypzb_050_patches;
-
-// pxpypzb_050_patches << SpherePatch(radius, pxpypzb_050_patch0_arcs);
-// pxpypzb_050_patches << SpherePatch(radius, pxpypzb_050_patch1_arcs);
-// pxpypzb_050_patches << SpherePatch(radius, pxpypzb_050_patch2_arcs);
-
- Sphere pxpypzb_050(radius, pxpypzb_050_patches);
-
- QTest::newRow("positive x positive y positive z backward 0.5")
- << pxpypzb_050_plane
- << pxpypzb_050;
-
-
- factor1 = radius / sqrt(3.0);
- factor2 = radius / sqrt(3.0);
- factor3 = radius / sqrt(3.0);
-
- QPlane3D pxpypzf_057_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QTest::newRow("positive x positive y positive z forward 0.57")
- << pxpypzf_057_plane
- << empty;
-
- QPlane3D pxpypzb_057_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QTest::newRow("positive x positive y positive z backward 0.57")
- << pxpypzb_057_plane
- << basic;
-
- factor1 = radius * 0.6;
- factor2 = radius * 0.6;
- factor3 = radius * 0.6;
-
- QPlane3D pxpypzf_060_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(1.0, 1.0, 1.0).normalized());
-
- QTest::newRow("positive x positive y positive z forward 0.6")
- << pxpypzf_060_plane
- << empty;
-
- QPlane3D pxpypzb_060_plane = QPlane3D(QVector3D(factor1, factor2, factor3),
- QVector3D(-1.0, -1.0, -1.0).normalized());
-
- QTest::newRow("positive x positive y positive z backward 0.6")
- << pxpypzb_060_plane
- << basic;
-}
-
-QList<QPlane3D> tst_Sphere::planes() const
-{
- CameraData cameraData;
-
- ViewportCamera cam;
- cam.setProjection(new Projection3D(20000.0));
- cam.setCameraData(cameraData);
- Frustum f = cam.toFrustum();
-
- QList<QPlane3D> planes;
- planes << f.plane(Frustum::Near);
- planes << f.plane(Frustum::Far);
- planes << f.plane(Frustum::Top);
- planes << f.plane(Frustum::Bottom);
- planes << f.plane(Frustum::Left);
- planes << f.plane(Frustum::Right);
-
- return planes;
-}
-
-Sphere tst_Sphere::planeTest(const QList<QPlane3D> &planes, const QList<int> &planeIndices) const
-{
- Sphere sphere;
-
- for (int i = 0; i < planeIndices.size(); ++i) {
- sphere.intersect(planes.at(planeIndices.at(i)));
- }
-
- return sphere;
-}
-
-void tst_Sphere::camera()
-{
- QList<QPlane3D> p = planes();
- // 2-tuples
-// for (int i = 0; i < 5; ++i) {
-// for (int j = i + 1; j < 6; ++j) {
-// QList<int> i1;
-// i1 << i << j;
-
-// Sphere s1 = planeTest(p, i1);
-
-// QList<int> i2;
-// i2 << j << i;
-
-// Sphere s2 = planeTest(p, i2);
-
-// if (!s1.isomorphic(s2)) {
-// QList<SpherePatch> p1 = s1.patches();
-// QList<SpherePatch> p2 = s2.patches();
-// if (p1.size() != p2.size()) {
-// qWarning() << i << j << "sizes different";
-// } else {
-// int s = p1.size();
-// for (int k = 0; k < s; ++k) {
-// if (!p1[k].isomorphic(p2[k])) {
-// qWarning() << i << j << k;
-//// QList<SpherePatch> l1a;
-//// l1a << p1[k];
-//// Sphere sphere1a(20000.0, l1a);
-//// qWarning() << sphere1a;
-
-//// QList<SpherePatch> l2a;
-//// l2a << p2[k];
-//// Sphere sphere2a(20000.0, l2a);
-//// qWarning() << sphere2a;
-// }
-// //qWarning() << k << (p1[k].isomorphic(p2[k]));
-// }
-// }
-// }
-// }
-// }
-
- /*
- intersect(...)
- 1 2 0
- 1 3 0
- 1 4 0
- 1 5 0
- 3 4 7
-
- intersect2(...)
- 1 2 0
- 1 3 0
- 1 4 0
- 1 5 0
- +2 4 7
- 3 4 7
- +3 4 8
- */
-
- int plane1 = 1;
- int plane2 = 2;
- int patch = 0;
-
- qWarning() << " ****** ";
-
- Sphere sphere1;
- sphere1.intersect(p.at(plane1));
- SpherePatch patch1 = sphere1.patches().at(patch);
-
- qWarning() << " ****** ";
- QList<SpherePatch> l1a;
- l1a << patch1;
- Sphere sphere1a(20000.0, l1a);
- qWarning() << sphere1a;
- qWarning() << " ****** ";
-
- l1a = patch1.intersect(p.at(plane2));
-
- qWarning() << " ****** ";
- Sphere sphere1b(20000.0, l1a);
- qWarning() << sphere1b;
- qWarning() << " ****** ";
-
- Sphere sphere2;
- sphere2.intersect(p.at(plane2));
- SpherePatch patch2 = sphere2.patches().at(patch);
-
- qWarning() << " ****** ";
- QList<SpherePatch> l2a;
- l2a << patch2;
- Sphere sphere2a(20000.0, l2a);
- qWarning() << sphere2a;
- qWarning() << " ****** ";
-
- l2a = patch2.intersect(p.at(plane1));
-
- qWarning() << " ****** ";
- Sphere sphere2b(20000.0, l2a);
- qWarning() << sphere2b;
- qWarning() << " ****** ";
-}
-
-QTEST_MAIN(tst_Sphere)
-#include "tst_sphere.moc"
-