StelSphereGeometry.hpp   StelSphereGeometry.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELSPHEREGEOMETRY_HPP_ #ifndef _STELSPHEREGEOMETRY_HPP_
#define _STELSPHEREGEOMETRY_HPP_ #define _STELSPHEREGEOMETRY_HPP_
#include "config.h"
#include "OctahedronPolygon.hpp"
#include "StelVertexArray.hpp"
#include "VecMath.hpp"
#include <QVector>
#include <QVariant>
#include <QDebug> #include <QDebug>
#include <QSharedPointer> #include <QSharedPointer>
#include <QVariant>
#include <QVarLengthArray> #include <QVarLengthArray>
#include <QVector> #include <QDataStream>
#include "OctahedronPolygon.hpp" #include <stdio.h>
#include "renderer/StelVertexBuffer.hpp"
#include "Triplet.hpp"
#include "VecMath.hpp"
class SphericalRegion; class SphericalRegion;
class SphericalPolygon; class SphericalPolygon;
class SphericalConvexPolygon; class SphericalConvexPolygon;
class SphericalCap; class SphericalCap;
class SphericalPoint; class SphericalPoint;
class AllSkySphericalRegion; class AllSkySphericalRegion;
class EmptySphericalRegion; class EmptySphericalRegion;
//! @file StelSphereGeometry.hpp //! @file StelSphereGeometry.hpp
skipping to change at line 146 skipping to change at line 150
{ {
Point = 0, Point = 0,
Cap = 1, Cap = 1,
AllSky = 2, AllSky = 2,
Polygon = 3, Polygon = 3,
ConvexPolygon = 4, ConvexPolygon = 4,
Empty = 5, Empty = 5,
Invalid = 6 Invalid = 6
}; };
//! Parameters specifying how to draw a SphericalRegion. virtual ~SphericalRegion() {;}
//!
//! Passed to e.g. drawFill().
//!
//! Also used to remember previously used draw parameters, which ena
bles
//! vertex buffer caching.
//!
//! This is a builder-style struct. Parameters can be specified like
this:
//!
//! @code
//! // Default parameters. Projector is mandatory, so it is specifie
d in the constructor.
//! SphericalRegion::DrawParams a(someProjectorPointer);
//! // Do not subdivide the region into smaller triangles.
//! SphericalRegion::DrawParams b = SphericalRegion::DrawParams(some
ProjectorPointer)
//! .doNotSubdivide(
);
//! // Do not subdivide and clip the part of the region outside of s
pecified cap.
//! SphericalRegion::DrawParams c = SphericalRegion::DrawParams(some
ProjectorPointer)
//! .doNotSubdivide(
)
//! .clippingCap(som
eSphericalCapPointer);
//! @endcode
//!
//!
struct DrawParams
{
//! Construct DrawParams with default parameters and specifi
ed projector.
//!
//! @param projector Projector to use for drawing.
//!
//! The default parameters are: no clipping cap, subdivide t
he region to
//! follow projection distortions, max distortion 5.0.
DrawParams(class StelProjector* projector)
: projector_(projector)
, clippingCap_(NULL)
, subdivide_(true)
, maxSqDistortion_(5.0)
{}
//! Only used to determine whether to update cached vertex b
uffers.
//!
//! Compares parameters given in a previous drawXXX()
//! call with parameters given in the current call.
//!
//! Projector is ignored - outside code needs to figure out
if projector
//! affects vertex buffer generation. Clipping cap is only a
ssumed to be
//! the same if both previos and current is NULL (which is u
sually the case).
bool operator != (const DrawParams& rhs) const
{
// Projector is ignored, as even if the pointer poin
ts to the same object,
// the objects' state might have changed, making com
parison useless.
// Instead, we only cache in cases when projector is
not used used outside
// Renderer (i.e. not affecting vertex buffers that
get cached) or NULL.
// Clipping caps are only considered equal when NULL
(which is the
// most common case, anyway). There is no opportunit
y for special handling
// like projectors, since, when not NULL, clipping c
aps are always used
// in vertex buffer generation.
return (clippingCap_ == NULL && rhs.clippingCap_ ==
NULL) ||
subdivide_ != rhs.subdivide_ ||
//Fuzzy compare might be better here
maxSqDistortion_ != rhs.maxSqDistortion_;
}
//! If not NULL, used to clip the part of the region outside
the cap.
DrawParams& clippingCap(const SphericalCap* clippingCap)
{
clippingCap_ = clippingCap;
return *this;
}
//! Do not subdivide the region to follow projection distort
ions.
//!
//! Improves drawing speed.
//!
//! You can use this if you think that the region is fully c
ontained in the viewport.
DrawParams& doNotSubdivide()
{
subdivide_ = false;
return *this;
}
//! Specify maximum distortion - we try to subdivide to be w
ithil this limit.
DrawParams& maxSqDistortion(const double maxSqDistortion)
{
maxSqDistortion_ = maxSqDistortion;
return *this;
}
//! Projector to use when drawing.
class StelProjector* projector_;
//! If specified, clips the part of the region outside of ca
p.
const SphericalCap* clippingCap_;
//! Subdivide triangles?
bool subdivide_;
//! Maximum distortion.
double maxSqDistortion_;
};
//! 3D vertex with only a position.
struct PlainVertex
{
Vec3f position;
PlainVertex(const Vec3f& position) : position(position){}
PlainVertex(const Vec3d& pos) : position(pos[0], pos[1], pos
[2]) {}
VERTEX_ATTRIBUTES(Vec3f Position)
};
//! 3D vertex with position and a texture coordinate.
struct TexturedVertex
{
Vec3f position;
Vec2f texCoord;
TexturedVertex(const Vec3f& position, const Vec2f& texCoord)
: position(position) , texCoord(texCoord) {}
TexturedVertex(const Vec3d& pos, const Vec2f& texCoord)
: position(pos[0], pos[1], pos[2]) , texCoord(texCoo
rd) {}
VERTEX_ATTRIBUTES(Vec3f Position, Vec2f TexCoord)
};
//! Default constructor. Inializes with no vertex buffers.
SphericalRegion()
: fillPlainVertexBuffer(NULL)
, previousFillDrawParams(NULL)
{
// Make sure previousFillDrawParams is invalid at start, so
it gets replaced
// at first drawFill() call.
previousFillDrawParams.maxSqDistortion_ = -42.0f;
}
//! Destructor. Cleans up vertex buffers, if any.
virtual ~SphericalRegion()
{
if(NULL != fillPlainVertexBuffer)
{
delete fillPlainVertexBuffer;
}
}
virtual SphericalRegionType getType() const = 0; virtual SphericalRegionType getType() const = 0;
//! Return the octahedron contour representation of the polygon. //! Return the octahedron contour representation of the polygon.
//! It can be used for safe computation of intersection/union in the general case. //! It can be used for safe computation of intersection/union in the general case.
virtual OctahedronPolygon getOctahedronPolygon() const =0; virtual OctahedronPolygon getOctahedronPolygon() const =0;
//! Return the area of the region in steradians. //! Return the area of the region in steradians.
virtual double getArea() const {return getOctahedronPolygon().getAre a();} virtual double getArea() const {return getOctahedronPolygon().getAre a();}
skipping to change at line 317 skipping to change at line 182
virtual SphericalCap getBoundingCap() const; virtual SphericalCap getBoundingCap() const;
//! Return an enlarged version of this SphericalRegion so that any p oint distant of more //! Return an enlarged version of this SphericalRegion so that any p oint distant of more
//! than the given margin now lays within the region. //! than the given margin now lays within the region.
//! The returned region can be larger than the smallest enlarging re gion, therefore returning //! The returned region can be larger than the smallest enlarging re gion, therefore returning
//! false positive on subsequent intersection tests. //! false positive on subsequent intersection tests.
//! The default implementation always return an enlarged bounding Sp hericalCap. //! The default implementation always return an enlarged bounding Sp hericalCap.
//! @param margin the minimum enlargement margin in radian. //! @param margin the minimum enlargement margin in radian.
virtual SphericalRegionP getEnlarged(double margin) const; virtual SphericalRegionP getEnlarged(double margin) const;
//! Get a vector of vertex positions forming the region. //! Return an openGL compatible array to be displayed using vertex a
virtual const QVector<Vec3d>& getFillVertexPositions() const rrays.
{ virtual StelVertexArray getFillVertexArray() const {return getOctahe
return getOctahedronPolygon().fillVertices(); dronPolygon().getFillVertexArray();}
}
//! Get primitive type determining how vertices in vector returned b
y
//! getFillVertexPositions() form triangles.
virtual PrimitiveType getFillPrimitiveType() const
{
return PrimitiveType_Triangles;
}
//! Get the outline of the contours defining the SphericalPolygon. //! Get the outline of the contours defining the SphericalPolygon.
//! @return a list of vertices which define the contours of the poly //! @return a list of vertex which taken 2 by 2 define the contours
gon. of the polygon.
virtual const QVector<Vec3d>& getOutlineVertexPositions() const virtual StelVertexArray getOutlineVertexArray() const {return getOct
{ ahedronPolygon().getOutlineVertexArray();}
// This is a workaround around a compiler bug with Clang (as
of Clang 3.2).
// Returning the reference directly results in an uninitiali
zed
// reference which breaks calling code.
const QVector<Vec3d>& result(getOctahedronPolygon().outlineV
ertices());
return result;
}
//! Get primitive type determining how vertices in vector returned b
y
//! getOutlinePrimitiveType() form lines.
virtual PrimitiveType getOutlinePrimitiveType() const
{
return PrimitiveType_Lines;
}
//! Get the contours defining the SphericalPolygon when combined usi ng a positive winding rule. //! Get the contours defining the SphericalPolygon when combined usi ng a positive winding rule.
//! The default implementation return a list of tesselated triangles derived from the OctahedronPolygon. //! The default implementation return a list of tesselated triangles derived from the OctahedronPolygon.
virtual QVector<QVector<Vec3d > > getSimplifiedContours() const; virtual QVector<QVector<Vec3d > > getSimplifiedContours() const;
//! Serialize the region into a QVariant list matching the JSON form at. //! Serialize the region into a QVariant list matching the JSON form at.
virtual QVariantList toQVariant() const = 0; virtual QVariantList toQVariant() const = 0;
//! Serialize the region. This method must allow as fast as possible serialization and work with deserialize(). //! Serialize the region. This method must allow as fast as possible serialization and work with deserialize().
virtual void serialize(QDataStream& out) const = 0; virtual void serialize(QDataStream& out) const = 0;
skipping to change at line 419 skipping to change at line 260
//! A default potentially very slow implementation is provided for e ach cases. //! A default potentially very slow implementation is provided for e ach cases.
SphericalRegionP getSubtraction(const SphericalRegion* r) const; SphericalRegionP getSubtraction(const SphericalRegion* r) const;
SphericalRegionP getSubtraction(const SphericalRegionP r) const {ret urn getSubtraction(r.data());} SphericalRegionP getSubtraction(const SphericalRegionP r) const {ret urn getSubtraction(r.data());}
virtual SphericalRegionP getSubtraction(const SphericalPolygon& r) c onst; virtual SphericalRegionP getSubtraction(const SphericalPolygon& r) c onst;
virtual SphericalRegionP getSubtraction(const SphericalConvexPolygon & r) const; virtual SphericalRegionP getSubtraction(const SphericalConvexPolygon & r) const;
virtual SphericalRegionP getSubtraction(const SphericalCap& r) const ; virtual SphericalRegionP getSubtraction(const SphericalCap& r) const ;
virtual SphericalRegionP getSubtraction(const SphericalPoint& r) con st; virtual SphericalRegionP getSubtraction(const SphericalPoint& r) con st;
SphericalRegionP getSubtraction(const AllSkySphericalRegion& r) cons t; SphericalRegionP getSubtraction(const AllSkySphericalRegion& r) cons t;
virtual SphericalRegionP getSubtraction(const EmptySphericalRegion& r) const; virtual SphericalRegionP getSubtraction(const EmptySphericalRegion& r) const;
//! Draw the region as triangles (i.e. filling the region).
//!
//! @param renderer Renderer to use for drawing.
//! @param params Drawing parameters (projector, clipping cap, if
any, etc.).
//!
//! @see DrawParams
virtual void drawFill(class StelRenderer* renderer, const DrawParams
& params);
//! Draw the outline of the region.
//!
//! @param renderer Renderer to use for drawing.
//! @param params Drawing parameters (projector, clipping cap, if
any, etc.).
//! Note that maxSqDistortion has no effect here.
//!
//! @see DrawParams
virtual void drawOutline(class StelRenderer* renderer, const DrawPar
ams& params);
protected:
//! Cached plain vertex buffer for drawing.
StelVertexBuffer<PlainVertex>* fillPlainVertexBuffer;
//! Should Renderer draw calls specify a projector?
//!
//! This is true unless we've projected the vertices ourselves (whic
h is the
//! case when we're subdividing the region into smaller triangles.)
bool useProjector;
//! Update the vertex buffer used by drawFill().
//!
//! Called when drawing parameters have changed, or when we cannot c
ache
//! vertices (e.g. when subdividing and this projecting outside Rend
erer).
//!
//! @param renderer Renderer to create vertex buffer.
//! @param params Parameters used for drawing
//! (which also affect vertex generation)
.
//! @param handleDiscontinuity Do we need to ensure that no triangle
s cross a
//! projection discontinuity?
virtual void updateFillVertexBuffer(class StelRenderer* renderer, co
nst DrawParams& params, bool handleDiscontinuity);
//! Drawing part of drawFill() - assumes the buffer/s is/are generat
ed.
//!
//! @param renderer Renderer used for drawing.
//! @param projector Projector to project the vertices
//! (NULL if subdivision is enabled, as in that cas
e
//! the projection is done during buffer generation
)
virtual void drawFillVertexBuffer(class StelRenderer* renderer, clas
s StelProjector* projector);
//! Do we need to update vertex buffer/s used by drawFill()?
//!
//! Might be true if e.g. the region has changed. Note that this is
only
//! one possible reason to update the buffers, drawFill() contains t
he full
//! logic to determine this (e.g. we always update when subdividing
is enabled).
virtual bool needToUpdateFillVertexBuffers() const
{
// Can't determine whether we can cache anything -
// we'd need to know if polygon returned by getOctahedronPol
ygon has changed,
// but since getOctahedronPolygon returns by value, not refe
rence,
// it returns a new octahedronPolygon every time.
//
// If it was by reference, _and_ guaranteed to always point
to the same polygon,
// we might store a flag in the polygon determining if its v
ertex array has
// changed, and use that for caching.
return true;
}
//! Called after updating vertex buffer/s used by drawFill().
virtual void fillVertexBuffersUpdated() {}
private: private:
//! Parameters used for the previous drawFill() call.
DrawParams previousFillDrawParams;
bool containsDefault(const SphericalRegion* r) const; bool containsDefault(const SphericalRegion* r) const;
bool intersectsDefault(const SphericalRegion* r) const; bool intersectsDefault(const SphericalRegion* r) const;
SphericalRegionP getIntersectionDefault(const SphericalRegion* r) co nst; SphericalRegionP getIntersectionDefault(const SphericalRegion* r) co nst;
SphericalRegionP getUnionDefault(const SphericalRegion* r) const; SphericalRegionP getUnionDefault(const SphericalRegion* r) const;
SphericalRegionP getSubtractionDefault(const SphericalRegion* r) con st; SphericalRegionP getSubtractionDefault(const SphericalRegion* r) con st;
}; };
//! @class SphericalCap //! @class SphericalCap
//! A SphericalCap is defined by a direction and an aperture. //! A SphericalCap is defined by a direction and an aperture.
//! It forms a cone from the center of the Coordinate frame with a radius d . //! It forms a cone from the center of the Coordinate frame with a radius d .
//! It is a disc on the sphere, a region above a circle on the unit sphere. //! It is a disc on the sphere, a region above a circle on the unit sphere.
class SphericalCap : public SphericalRegion class SphericalCap : public SphericalRegion
{ {
using SphericalRegion::contains;
public: public:
//! Construct a SphericalCap with a 90 deg aperture and an undefined direction. //! Construct a SphericalCap with a 90 deg aperture and an undefined direction.
SphericalCap() : d(0) {;} SphericalCap() : d(0) {;}
//! Construct a SphericalCap from its direction and assumes a 90 deg aperture. //! Construct a SphericalCap from its direction and assumes a 90 deg aperture.
SphericalCap(double x, double y, double z) : n(x,y,z), d(0) {;} SphericalCap(double x, double y, double z) : n(x,y,z), d(0) {;}
//! Construct a SphericalCap from its direction and aperture. //! Construct a SphericalCap from its direction and aperture.
//! @param an a unit vector indicating the direction. //! @param an a unit vector indicating the direction.
//! @param ar cosinus of the aperture. //! @param ar cosinus of the aperture.
SphericalCap(const Vec3d& an, double ar) : n(an), d(ar) {//n.normali ze(); SphericalCap(const Vec3d& an, double ar) : n(an), d(ar) {//n.normali ze();
Q_ASSERT(d==0 || std::fabs(n.l engthSquared()-1.)<0.0000001);} Q_ASSERT(d==0 || std::fabs(n.l engthSquared()-1.)<0.0000001);}
// TODO:FIXME! GZ reports 2013-03-02: apparently the Q_ASSERT is her e because n should be normalized at this point, but // FIXME: GZ reports 2013-03-02: apparently the Q_ASSERT is here bec ause n should be normalized at this point, but
// for efficiency n.normalize() should not be called at this point. // for efficiency n.normalize() should not be called at this point.
// However, when zooming in a bit in Hammer-Aitoff and Mercator proj ections, this Assertion fires. // However, when zooming in a bit in Hammer-Aitoff and Mercator proj ections, this Assertion fires.
// Atmosphere must be active // Atmosphere must be active
// It may have to do with DSO texture rendering. // It may have to do with DSO texture rendering.
// found at r5863. // found at r5863.
// n.normalize() prevents this for now, but may cost performance. // n.normalize() prevents this for now, but may cost performance.
// AARGH - activating n.normalize() inhibits mouse-identification/se lection of stars! // AARGH - activating n.normalize() inhibits mouse-identification/se lection of stars!
// May be compiler dependent (seen on Win/MinGW), AW cannot confirm it on Linux. // May be compiler dependent (seen on Win/MinGW), AW cannot confirm it on Linux.
//! Copy constructor. //! Copy constructor.
skipping to change at line 545 skipping to change at line 316
//! Return true if the region is empty. //! Return true if the region is empty.
virtual bool isEmpty() const {return d>=1.;} virtual bool isEmpty() const {return d>=1.;}
//! Return a point located inside the SphericalCap. //! Return a point located inside the SphericalCap.
virtual Vec3d getPointInside() const {return n;} virtual Vec3d getPointInside() const {return n;}
//! Return itself. //! Return itself.
virtual SphericalCap getBoundingCap() const {return *this;} virtual SphericalCap getBoundingCap() const {return *this;}
// Contain and intersect // Contain and intersect
bool contains(const Vec3d &v) const virtual bool contains(const Vec3d &v) const {Q_ASSERT(d==0 || std::f
{ abs(v.lengthSquared()-1.)<0.0000002);return (v*n>=d);}
Q_ASSERT(d==0 || std::fabs(v.lengthSquared()-1.)<0.00000021) virtual bool contains(const Vec3f &v) const {Q_ASSERT(d==0 || std::f
; abs(v.lengthSquared()-1.f)<0.000002f);return (v[0]*n[0]+v[1]*n[1]+v[2]*n[2]
return (v*n>=d); >=d);}
}
virtual bool contains(const SphericalConvexPolygon& r) const; virtual bool contains(const SphericalConvexPolygon& r) const;
virtual bool contains(const SphericalCap& h) const virtual bool contains(const SphericalCap& h) const
{ {
const double a = n*h.n-d*h.d; const double a = n*h.n-d*h.d;
return d<=h.d && ( a>=1. || (a>=0. && a*a >= (1.-d*d)*(1.-h. d*h.d))); return d<=h.d && ( a>=1. || (a>=0. && a*a >= (1.-d*d)*(1.-h. d*h.d)));
} }
virtual bool contains(const AllSkySphericalRegion&) const {return d< =-1;} virtual bool contains(const AllSkySphericalRegion&) const {return d< =-1;}
virtual bool intersects(const SphericalPolygon& r) const; virtual bool intersects(const SphericalPolygon& r) const;
virtual bool intersects(const SphericalConvexPolygon& r) const; virtual bool intersects(const SphericalConvexPolygon& r) const;
//! Returns whether a SphericalCap intersects with this one. //! Returns whether a SphericalCap intersects with this one.
skipping to change at line 605 skipping to change at line 373
//! Comparison operator. //! Comparison operator.
bool operator==(const SphericalCap& other) const {return (n==other.n && d==other.d);} bool operator==(const SphericalCap& other) const {return (n==other.n && d==other.d);}
//! Return the list of closed contours defining the polygon boundari es. //! Return the list of closed contours defining the polygon boundari es.
QVector<Vec3d> getClosedOutlineContour() const; QVector<Vec3d> getClosedOutlineContour() const;
//! Return whether the cap intersect with a convex contour defined b y nbVertice. //! Return whether the cap intersect with a convex contour defined b y nbVertice.
bool intersectsConvexContour(const Vec3d* vertice, int nbVertice) co nst; bool intersectsConvexContour(const Vec3d* vertice, int nbVertice) co nst;
//! Does the cap contain the passed triangle? //! Return whether the cap contains the passed triangle.
bool containsTriangle(const Triplet<Vec3d> triangle) const; bool containsTriangle(const Vec3d* vertice) const;
//! Does the cap intersect with the passed triangle? //! Return whether the cap intersect with the passed triangle.
bool intersectsTriangle(const Triplet<Vec3d>& triangle) const; bool intersectsTriangle(const Vec3d* vertice) const;
//! Deserialize the region. This method must allow as fast as possib le deserialization. //! Deserialize the region. This method must allow as fast as possib le deserialization.
static SphericalRegionP deserialize(QDataStream& in); static SphericalRegionP deserialize(QDataStream& in);
//! Return the relative overlap between the areas of the 2 caps, i.e : //! Return the relative overlap between the areas of the 2 caps, i.e :
//! min(intersectionArea/c1.area, intersectionArea/c2.area) //! min(intersectionArea/c1.area, intersectionArea/c2.area)
static double relativeAreaOverlap(const SphericalCap& c1, const Sphe ricalCap& c2); static double relativeAreaOverlap(const SphericalCap& c1, const Sphe ricalCap& c2);
//! Return the relative overlap between the diameter of the 2 caps, i.e: //! Return the relative overlap between the diameter of the 2 caps, i.e:
//! min(intersectionDistance/c1.diameter, intersectionDistance/c2.di ameter) //! min(intersectionDistance/c1.diameter, intersectionDistance/c2.di ameter)
skipping to change at line 706 skipping to change at line 474
}; };
//! @class AllSkySphericalRegion //! @class AllSkySphericalRegion
//! Special SphericalRegion for the whole sphere. //! Special SphericalRegion for the whole sphere.
class AllSkySphericalRegion : public SphericalRegion class AllSkySphericalRegion : public SphericalRegion
{ {
public: public:
virtual ~AllSkySphericalRegion() {;} virtual ~AllSkySphericalRegion() {;}
virtual SphericalRegionType getType() const {return SphericalRegion: :AllSky;} virtual SphericalRegionType getType() const {return SphericalRegion: :AllSky;}
virtual OctahedronPolygon getOctahedronPolygon() const virtual OctahedronPolygon getOctahedronPolygon() const {return Octah
{ edronPolygon::getAllSkyOctahedronPolygon();}
return OctahedronPolygon::getAllSkyOctahedronPolygon();
}
virtual double getArea() const {return 4.*M_PI;} virtual double getArea() const {return 4.*M_PI;}
virtual bool isEmpty() const {return false;} virtual bool isEmpty() const {return false;}
virtual Vec3d getPointInside() const {return Vec3d(1,0,0);} virtual Vec3d getPointInside() const {return Vec3d(1,0,0);}
virtual SphericalCap getBoundingCap() const {return SphericalCap(Vec 3d(1,0,0), -2);} virtual SphericalCap getBoundingCap() const {return SphericalCap(Vec 3d(1,0,0), -2);}
//! Serialize the region into a QVariant map matching the JSON forma t. //! Serialize the region into a QVariant map matching the JSON forma t.
//! The format is ["ALLSKY"] //! The format is ["ALLSKY"]
virtual QVariantList toQVariant() const; virtual QVariantList toQVariant() const;
virtual void serialize(QDataStream&) const {;} virtual void serialize(QDataStream&) const {;}
// Contain and intersect // Contain and intersect
skipping to change at line 735 skipping to change at line 500
virtual bool contains(const AllSkySphericalRegion&) const {return tr ue;} virtual bool contains(const AllSkySphericalRegion&) const {return tr ue;}
virtual bool intersects(const SphericalPolygon&) const {return true; } virtual bool intersects(const SphericalPolygon&) const {return true; }
virtual bool intersects(const SphericalConvexPolygon&) const {return true;} virtual bool intersects(const SphericalConvexPolygon&) const {return true;}
virtual bool intersects(const SphericalCap&) const {return true;} virtual bool intersects(const SphericalCap&) const {return true;}
virtual bool intersects(const SphericalPoint&) const {return true;} virtual bool intersects(const SphericalPoint&) const {return true;}
virtual bool intersects(const AllSkySphericalRegion&) const {return true;} virtual bool intersects(const AllSkySphericalRegion&) const {return true;}
static const SphericalRegionP staticInstance; static const SphericalRegionP staticInstance;
}; };
//! @class AllSkySphericalRegion //! @class EmptySphericalRegion
//! Special SphericalRegion for the whole sphere. //! Special SphericalRegion for --- UMM, WHAT EXACTLY?
class EmptySphericalRegion : public SphericalRegion class EmptySphericalRegion : public SphericalRegion
{ {
public: public:
// Avoid name hiding when overloading the virtual methods. // Avoid name hiding when overloading the virtual methods.
using SphericalRegion::intersects; using SphericalRegion::intersects;
using SphericalRegion::contains; using SphericalRegion::contains;
using SphericalRegion::getIntersection; using SphericalRegion::getIntersection;
using SphericalRegion::getUnion; using SphericalRegion::getUnion;
using SphericalRegion::getSubtraction; using SphericalRegion::getSubtraction;
EmptySphericalRegion() {;} EmptySphericalRegion() {;}
virtual ~EmptySphericalRegion() {;} virtual ~EmptySphericalRegion() {;}
virtual SphericalRegionType getType() const {return SphericalRegion: :Empty;} virtual SphericalRegionType getType() const {return SphericalRegion: :Empty;}
virtual OctahedronPolygon getOctahedronPolygon() const virtual OctahedronPolygon getOctahedronPolygon() const {return Octah
{ edronPolygon::getEmptyOctahedronPolygon();}
return OctahedronPolygon::getEmptyOctahedronPolygon();
}
virtual double getArea() const {return 0.;} virtual double getArea() const {return 0.;}
virtual bool isEmpty() const {return true;} virtual bool isEmpty() const {return true;}
virtual Vec3d getPointInside() const {return Vec3d(1,0,0);} virtual Vec3d getPointInside() const {return Vec3d(1,0,0);}
virtual SphericalCap getBoundingCap() const {return SphericalCap(Vec 3d(1,0,0), 2);} virtual SphericalCap getBoundingCap() const {return SphericalCap(Vec 3d(1,0,0), 2);}
//! Serialize the region into a QVariant map matching the JSON forma t. //! Serialize the region into a QVariant map matching the JSON forma t.
//! The format is ["EMPTY"] //! The format is ["EMPTY"]
virtual QVariantList toQVariant() const; virtual QVariantList toQVariant() const;
virtual void serialize(QDataStream&) const {;} virtual void serialize(QDataStream&) const {;}
// Contain and intersect // Contain and intersect
skipping to change at line 780 skipping to change at line 542
virtual bool contains(const AllSkySphericalRegion&) const {return fa lse;} virtual bool contains(const AllSkySphericalRegion&) const {return fa lse;}
virtual bool intersects(const SphericalPolygon&) const {return false ;} virtual bool intersects(const SphericalPolygon&) const {return false ;}
virtual bool intersects(const SphericalConvexPolygon&) const {return false;} virtual bool intersects(const SphericalConvexPolygon&) const {return false;}
virtual bool intersects(const SphericalCap&) const {return false;} virtual bool intersects(const SphericalCap&) const {return false;}
virtual bool intersects(const SphericalPoint&) const {return false;} virtual bool intersects(const SphericalPoint&) const {return false;}
virtual bool intersects(const AllSkySphericalRegion&) const {return false;} virtual bool intersects(const AllSkySphericalRegion&) const {return false;}
static const SphericalRegionP staticInstance; static const SphericalRegionP staticInstance;
}; };
//! @class SphericalPolygonBase //! @class SphericalPolygon
//! Abstract class defining default implementations for some spherical geom //! Class defining default implementations for some spherical geometry meth
etry methods. ods.
//! All methods are reentrant. //! All methods are reentrant.
class SphericalPolygon : public SphericalRegion class SphericalPolygon : public SphericalRegion
{ {
public: public:
// Avoid name hiding when overloading the virtual methods. // Avoid name hiding when overloading the virtual methods.
using SphericalRegion::intersects; using SphericalRegion::intersects;
using SphericalRegion::contains; using SphericalRegion::contains;
using SphericalRegion::getIntersection; using SphericalRegion::getIntersection;
using SphericalRegion::getUnion; using SphericalRegion::getUnion;
using SphericalRegion::getSubtraction; using SphericalRegion::getSubtraction;
SphericalPolygon() {;} SphericalPolygon() {;}
//! Constructor from a list of contours. //! Constructor from a list of contours.
SphericalPolygon(const QVector<QVector<Vec3d> >& contours) : octahed ronPolygon(contours) {;} SphericalPolygon(const QVector<QVector<Vec3d> >& contours) : octahed ronPolygon(contours) {;}
//! Constructor from one contour. //! Constructor from one contour.
SphericalPolygon(const QVector<Vec3d>& contour) : octahedronPolygon( contour) {;} SphericalPolygon(const QVector<Vec3d>& contour) : octahedronPolygon( contour) {;}
SphericalPolygon(const OctahedronPolygon& octContour) : octahedronPo lygon(octContour) {;} SphericalPolygon(const OctahedronPolygon& octContour) : octahedronPo lygon(octContour) {;}
SphericalPolygon(const QList<OctahedronPolygon>& octContours) : octa hedronPolygon(octContours) {;} SphericalPolygon(const QList<OctahedronPolygon>& octContours) : octa hedronPolygon(octContours) {;}
virtual SphericalRegionType getType() const {return SphericalRegion: :Polygon;} virtual SphericalRegionType getType() const {return SphericalRegion: :Polygon;}
virtual OctahedronPolygon getOctahedronPolygon() const virtual OctahedronPolygon getOctahedronPolygon() const {return octah
{ edronPolygon;}
return octahedronPolygon;
}
//! Serialize the region into a QVariant map matching the JSON forma t. //! Serialize the region into a QVariant map matching the JSON forma t.
//! The format is: //! The format is:
//! @code[[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[ra,dec], [ra,d ec], [ra,dec]],[...]]@endcode //! @code[[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[ra,dec], [ra,d ec], [ra,dec]],[...]]@endcode
//! it is a list of closed contours, with each points defined by ra dec in degree in the ICRS frame. //! it is a list of closed contours, with each points defined by ra dec in degree in the ICRS frame.
virtual QVariantList toQVariant() const; virtual QVariantList toQVariant() const;
virtual void serialize(QDataStream& out) const; virtual void serialize(QDataStream& out) const;
virtual SphericalCap getBoundingCap() const; virtual SphericalCap getBoundingCap() const;
skipping to change at line 843 skipping to change at line 602
virtual SphericalRegionP getUnion(const EmptySphericalRegion&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));} virtual SphericalRegionP getUnion(const EmptySphericalRegion&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
virtual SphericalRegionP getSubtraction(const SphericalPoint&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));} virtual SphericalRegionP getSubtraction(const SphericalPoint&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
virtual SphericalRegionP getSubtraction(const EmptySphericalRegion&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));} virtual SphericalRegionP getSubtraction(const EmptySphericalRegion&) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Methods specific to SphericalPolygon // Methods specific to SphericalPolygon
//! Set the contours defining the SphericalPolygon. //! Set the contours defining the SphericalPolygon.
//! @param contours the list of contours defining the polygon area. The contours are combined using //! @param contours the list of contours defining the polygon area. The contours are combined using
//! the positive winding rule, meaning that the polygon is the union of the positive contours minus the negative ones. //! the positive winding rule, meaning that the polygon is the union of the positive contours minus the negative ones.
void setContours(const QVector<QVector<Vec3d> >& contours) void setContours(const QVector<QVector<Vec3d> >& contours) {octahedr
{ onPolygon = OctahedronPolygon(contours);}
octahedronPolygon = OctahedronPolygon(contours);
}
//! Set a single contour defining the SphericalPolygon. //! Set a single contour defining the SphericalPolygon.
//! @param contour a contour defining the polygon area. //! @param contour a contour defining the polygon area.
void setContour(const QVector<Vec3d>& contour) void setContour(const QVector<Vec3d>& contour) {octahedronPolygon =
{ OctahedronPolygon(contour);}
octahedronPolygon = OctahedronPolygon(contour);
}
//! Return the list of closed contours defining the polygon boundari es. //! Return the list of closed contours defining the polygon boundari es.
QVector<QVector<Vec3d> > getClosedOutlineContours() const {Q_ASSERT( 0); return QVector<QVector<Vec3d> >();} QVector<QVector<Vec3d> > getClosedOutlineContours() const {Q_ASSERT( 0); return QVector<QVector<Vec3d> >();}
//! Deserialize the region. This method must allow as fast as possib le deserialization. //! Deserialize the region. This method must allow as fast as possib le deserialization.
static SphericalRegionP deserialize(QDataStream& in); static SphericalRegionP deserialize(QDataStream& in);
//! Create a new SphericalRegionP which is the union of all the pass ed ones. //! Create a new SphericalRegionP which is the union of all the pass ed ones.
static SphericalRegionP multiUnion(const QList<SphericalRegionP>& re gions, bool optimizeByPreGrouping=false); static SphericalRegionP multiUnion(const QList<SphericalRegionP>& re gions, bool optimizeByPreGrouping=false);
skipping to change at line 884 skipping to change at line 637
{ {
public: public:
// Avoid name hiding when overloading the virtual methods. // Avoid name hiding when overloading the virtual methods.
using SphericalRegion::intersects; using SphericalRegion::intersects;
using SphericalRegion::contains; using SphericalRegion::contains;
//! Default constructor. //! Default constructor.
SphericalConvexPolygon() {;} SphericalConvexPolygon() {;}
//! Constructor from a list of contours. //! Constructor from a list of contours.
SphericalConvexPolygon(const QVector<QVector<Vec3d> >& contours) SphericalConvexPolygon(const QVector<QVector<Vec3d> >& contours) {Q_
: fillVertexBufferNeedsUpdate(true) ASSERT(contours.size()==1); setContour(contours.at(0));}
{
Q_ASSERT(contours.size()==1);
setContour(contours.at(0));
}
//! Constructor from one contour. //! Constructor from one contour.
SphericalConvexPolygon(const QVector<Vec3d>& contour) SphericalConvexPolygon(const QVector<Vec3d>& contour) {setContour(co
: fillVertexBufferNeedsUpdate(true) ntour);}
{
setContour(contour);
}
//! Special constructor for triangle. //! Special constructor for triangle.
SphericalConvexPolygon(const Vec3d &e0,const Vec3d &e1,const Vec3d & SphericalConvexPolygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &
e2) e2) {contour << e0 << e1 << e2; updateBoundingCap();}
: fillVertexBufferNeedsUpdate(true)
{
contour << e0 << e1 << e2; updateBoundingCap();
}
//! Special constructor for quads. //! Special constructor for quads.
SphericalConvexPolygon(const Vec3d &e0,const Vec3d &e1,const Vec3d & SphericalConvexPolygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &
e2, const Vec3d &e3) e2, const Vec3d &e3) {contour << e0 << e1 << e2 << e3; updateBoundingCap()
: fillVertexBufferNeedsUpdate(true) ;}
{
contour << e0 << e1 << e2 << e3; updateBoundingCap();
}
virtual SphericalRegionType getType() const {return SphericalRegion: :ConvexPolygon;} virtual SphericalRegionType getType() const {return SphericalRegion: :ConvexPolygon;}
virtual OctahedronPolygon getOctahedronPolygon() const {return Octah
virtual OctahedronPolygon getOctahedronPolygon() const edronPolygon(contour);}
{ virtual StelVertexArray getFillVertexArray() const {return StelVerte
return OctahedronPolygon(contour); xArray(contour, StelVertexArray::TriangleFan);}
} virtual StelVertexArray getOutlineVertexArray() const {return StelVe
rtexArray(contour, StelVertexArray::LineLoop);}
virtual const QVector<Vec3d>& getFillVertexPositions() const
{
return contour;
}
virtual PrimitiveType getFillPrimitiveType() const
{
return PrimitiveType_TriangleFan;
}
virtual const QVector<Vec3d>& getOutlineVertexPositions() const
{
return contour;
}
virtual PrimitiveType getOutlinePrimitiveType() const
{
return PrimitiveType_LineLoop;
}
virtual double getArea() const; virtual double getArea() const;
virtual bool isEmpty() const {return contour.isEmpty();} virtual bool isEmpty() const {return contour.isEmpty();}
virtual Vec3d getPointInside() const; virtual Vec3d getPointInside() const;
virtual SphericalCap getBoundingCap() const {return cachedBoundingCa p;} virtual SphericalCap getBoundingCap() const {return cachedBoundingCa p;}
QVector<SphericalCap> getBoundingSphericalCaps() const; QVector<SphericalCap> getBoundingSphericalCaps() const;
//! Serialize the region into a QVariant map matching the JSON forma t. //! Serialize the region into a QVariant map matching the JSON forma t.
//! The format is //! The format is
//! @code["CONVEX_POLYGON", [[ra,dec], [ra,dec], [ra,dec], [ra,dec]] ]@endcode //! @code["CONVEX_POLYGON", [[ra,dec], [ra,dec], [ra,dec], [ra,dec]] ]@endcode
//! where the coords are a closed convex contour, with each points d efined by ra dec in degree in the ICRS frame. //! where the coords are a closed convex contour, with each points d efined by ra dec in degree in the ICRS frame.
virtual QVariantList toQVariant() const; virtual QVariantList toQVariant() const;
skipping to change at line 986 skipping to change at line 696
// virtual SphericalRegionP getSubtraction(const SphericalConvexPolygon & r) const; // virtual SphericalRegionP getSubtraction(const SphericalConvexPolygon & r) const;
// virtual SphericalRegionP getSubtraction(const SphericalCap& r) const ; // virtual SphericalRegionP getSubtraction(const SphericalCap& r) const ;
// virtual SphericalRegionP getSubtraction(const SphericalPoint& r) con st; // virtual SphericalRegionP getSubtraction(const SphericalPoint& r) con st;
// virtual SphericalRegionP getSubtraction(const EmptySphericalRegion& r) const; // virtual SphericalRegionP getSubtraction(const EmptySphericalRegion& r) const;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Methods specific to SphericalConvexPolygon // Methods specific to SphericalConvexPolygon
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
//! Set a single contour defining the SphericalPolygon. //! Set a single contour defining the SphericalPolygon.
//! @param acontour a contour defining the polygon area. //! @param acontour a contour defining the polygon area.
void setContour(const QVector<Vec3d>& acontour) void setContour(const QVector<Vec3d>& acontour) {contour=acontour; u
{ pdateBoundingCap();}
contour = acontour;
fillVertexBufferNeedsUpdate = true;
updateBoundingCap();
}
//! Get the single contour defining the SphericalConvexPolygon. //! Get the single contour defining the SphericalConvexPolygon.
const QVector<Vec3d>& getConvexContour() const {return contour;} const QVector<Vec3d>& getConvexContour() const {return contour;}
//! Check if the polygon is valid, i.e. it has no side >180. //! Check if the polygon is valid, i.e. it has no side >180.
bool checkValid() const; bool checkValid() const;
//! Check if the passed contour is convex and valid, i.e. it has no side >180. //! Check if the passed contour is convex and valid, i.e. it has no side >180.
static bool checkValidContour(const QVector<Vec3d>& contour); static bool checkValidContour(const QVector<Vec3d>& contour);
//! Deserialize the region. This method must allow as fast as possib le deserialization. //! Deserialize the region. This method must allow as fast as possib le deserialization.
static SphericalRegionP deserialize(QDataStream& in); static SphericalRegionP deserialize(QDataStream& in);
protected: protected:
//! A list of vertices of the convex contour. //! A list of vertices of the convex contour.
QVector<Vec3d> contour; QVector<Vec3d> contour;
//! Cache the bounding cap. //! Cache the bounding cap.
SphericalCap cachedBoundingCap; SphericalCap cachedBoundingCap;
//! Does the drawFill() vertex buffer need an update?
bool fillVertexBufferNeedsUpdate;
//! Update the bounding cap from the vertex list. //! Update the bounding cap from the vertex list.
void updateBoundingCap(); void updateBoundingCap();
virtual void updateFillVertexBuffer(class StelRenderer* renderer, co
nst DrawParams& params, bool handleDiscontinuity);
virtual void drawFillVertexBuffer(class StelRenderer* renderer, clas
s StelProjector* projector);
virtual bool needToUpdateFillVertexBuffers() const
{
return fillVertexBufferNeedsUpdate;
}
virtual void fillVertexBuffersUpdated()
{
fillVertexBufferNeedsUpdate = false;
}
//! Computes whether the passed points are all outside of at least o ne SphericalCap defining the polygon boundary. //! Computes whether the passed points are all outside of at least o ne SphericalCap defining the polygon boundary.
//! @param thisContour the vertices defining the contour. //! @param thisContour the vertices defining the contour.
//! @param nbThisContour nb of vertice of the contour. //! @param nbThisContour nb of vertice of the contour.
//! @param points the points to test. //! @param points the points to test.
//! @param nbPoints the number of points to test. //! @param nbPoints the number of points to test.
static bool areAllPointsOutsideOneSide(const Vec3d* thisContour, int nbThisContour, const Vec3d* points, int nbPoints); static bool areAllPointsOutsideOneSide(const Vec3d* thisContour, int nbThisContour, const Vec3d* points, int nbPoints);
//! Computes whether the passed points are all outside of at least o ne SphericalCap defining the polygon boundary. //! Computes whether the passed points are all outside of at least o ne SphericalCap defining the polygon boundary.
bool areAllPointsOutsideOneSide(const QVector<Vec3d>& points) const bool areAllPointsOutsideOneSide(const QVector<Vec3d>& points) const
{ {
return areAllPointsOutsideOneSide(contour.constData(), conto ur.size(), points.constData(), points.size()); return areAllPointsOutsideOneSide(contour.constData(), conto ur.size(), points.constData(), points.size());
} }
bool containsConvexContour(const Vec3d* vertice, int nbVertex) const ; bool containsConvexContour(const Vec3d* vertice, int nbVertex) const ;
}; };
//! @class SphericalConvexPolygonSet // ! @class SphericalConvexPolygonSet
//! A special case of SphericalPolygon for which the polygon is composed of // ! A special case of SphericalPolygon for which the polygon is composed o
disjoint convex polygons. f disjoint convex polygons.
//class SphericalConvexPolygonSet : public SphericalRegion //class SphericalConvexPolygonSet : public SphericalRegion
//{ //{
//public: //public:
// // Avoid name hiding when overloading the virtual methods. // // Avoid name hiding when overloading the virtual methods.
// using SphericalRegion::intersects; // using SphericalRegion::intersects;
// using SphericalRegion::contains; // using SphericalRegion::contains;
// //
// //! Default constructor. // //! Default constructor.
// SphericalConvexPolygonSet() {;} // SphericalConvexPolygonSet() {;}
// //
skipping to change at line 1108 skipping to change at line 796
//protected: //protected:
// QVector<SphericalConvexPolygon> contours; // QVector<SphericalConvexPolygon> contours;
// //
// //! Cache the bounding cap. // //! Cache the bounding cap.
// SphericalCap cachedBoundingCap; // SphericalCap cachedBoundingCap;
// //
// //! Update the bounding cap from the vertex list. // //! Update the bounding cap from the vertex list.
// void updateBoundingCap(); // void updateBoundingCap();
//}; //};
//! @class SphericalTexturedPolygon
//! An extension of SphericalPolygon with addition of texture coordinates.
class SphericalTexturedPolygon : public SphericalPolygon
{
public:
//! @struct TextureVertex
//! A container for 3D vertex + associated texture coordinates
struct TextureVertex
{
Vec3d vertex;
Vec2f texCoord;
};
SphericalTexturedPolygon() {;}
//! Constructor from a list of contours.
SphericalTexturedPolygon(const QVector<QVector<TextureVertex> >& con
tours) {Q_UNUSED(contours); Q_ASSERT(0);}
//! Constructor from one contour.
SphericalTexturedPolygon(const QVector<TextureVertex>& contour) {Q_U
NUSED(contour); Q_ASSERT(0);}
//! Return an openGL compatible array of texture coords to be used u
sing vertex arrays.
virtual StelVertexArray getFillVertexArray() const {Q_ASSERT(0); ret
urn StelVertexArray();}
//! Serialize the region into a QVariant map matching the JSON forma
t.
//! The format is:
//! @code["TEXTURED_POLYGON", [[[ra,dec], [ra,dec], [ra,dec], [ra,de
c]], [[ra,dec], [ra,dec], [ra,dec]],[...]],
//! [[[u,v],[u,v],[u,v],[u,v]], [[u,v],[u,v],[u,v]], [...]]]@endcode
//! where the two lists are a list of closed contours, with each poi
nts defined by ra dec in degree in the ICRS frame
//! followed by a list of texture coordinates in the u,v texture spa
ce (between 0 and 1).
//! There must be one texture coordinate for each vertex.
virtual QVariantList toQVariant() const;
virtual void serialize(QDataStream& out) const {Q_UNUSED(out); Q_ASS
ERT(0);}
////////////////////////////////////////////////////////////////////
// Methods specific to SphericalTexturedPolygon
//! Set the contours defining the SphericalPolygon.
//! @param contours the list of contours defining the polygon area u
sing the WindingPositive winding rule.
void setContours(const QVector<QVector<TextureVertex> >& contours) {
Q_UNUSED(contours); Q_ASSERT(0);}
//! Set a single contour defining the SphericalPolygon.
//! @param contour a contour defining the polygon area.
void setContour(const QVector<TextureVertex>& contour) {Q_UNUSED(con
tour); Q_ASSERT(0);}
private:
//! A list of uv textures coordinates corresponding to the triangle
vertices.
//! There should be 1 uv position per vertex.
QVector<Vec2f> textureCoords;
};
Q_DECLARE_TYPEINFO(SphericalTexturedPolygon::TextureVertex, Q_PRIMITIVE_TYP
E);
//! @class SphericalTexturedConvexPolygon //! @class SphericalTexturedConvexPolygon
//! Extension of SphericalConvexPolygon for textured polygon. //! Extension of SphericalConvexPolygon for textured polygon.
class SphericalTexturedConvexPolygon : public SphericalConvexPolygon class SphericalTexturedConvexPolygon : public SphericalConvexPolygon
{ {
public: public:
//! Default constructor. //! Default constructor.
SphericalTexturedConvexPolygon() : fillTexturedVertexBuffer(NULL) SphericalTexturedConvexPolygon() {;}
{
fillVertexBufferNeedsUpdate = true;
}
//! Constructor from one contour. //! Constructor from one contour.
SphericalTexturedConvexPolygon(const QVector<Vec3d>& contour, const SphericalTexturedConvexPolygon(const QVector<Vec3d>& contour, const
QVector<Vec2f>& texCoord) QVector<Vec2f>& texCoord) {setContour(contour, texCoord);}
: fillTexturedVertexBuffer(NULL)
{
setContour(contour, texCoord);
fillVertexBufferNeedsUpdate = true;
}
//! Special constructor for quads. //! Special constructor for quads.
//! Use the 4 textures corners for the 4 vertices. //! Use the 4 textures corners for the 4 vertices.
SphericalTexturedConvexPolygon(const Vec3d &e0,const Vec3d &e1,const SphericalTexturedConvexPolygon(const Vec3d &e0,const Vec3d &e1,const
Vec3d &e2, const Vec3d &e3) Vec3d &e2, const Vec3d &e3) : SphericalConvexPolygon(e0,e1,e2,e3)
: SphericalConvexPolygon(e0,e1,e2,e3)
, fillTexturedVertexBuffer(NULL)
{ {
textureCoords << Vec2f(0.f, 0.f) << Vec2f(1.f, 0.f) << Vec2f (1.f, 1.f) << Vec2f(0.f, 1.f); textureCoords << Vec2f(0.f, 0.f) << Vec2f(1.f, 0.f) << Vec2f (1.f, 1.f) << Vec2f(0.f, 1.f);
fillVertexBufferNeedsUpdate = true;
} }
virtual ~SphericalTexturedConvexPolygon() //! Return an openGL compatible array to be displayed using vertex a
{ rrays.
if(NULL != fillTexturedVertexBuffer) //! This method is not optimized for SphericalConvexPolygon instance
{ s.
delete fillTexturedVertexBuffer; virtual StelVertexArray getFillVertexArray() const {return StelVerte
} xArray(contour, StelVertexArray::TriangleFan, textureCoords);}
}
//! Set a single contour defining the SphericalPolygon. //! Set a single contour defining the SphericalPolygon.
//! @param acontour a contour defining the polygon area. //! @param acontour a contour defining the polygon area.
//! @param texCoord a list of texture coordinates matching the verti ces of the contour. //! @param texCoord a list of texture coordinates matching the verti ces of the contour.
virtual void setContour(const QVector<Vec3d>& acontour, const QVecto virtual void setContour(const QVector<Vec3d>& acontour, const QVecto
r<Vec2f>& texCoord) r<Vec2f>& texCoord) {SphericalConvexPolygon::setContour(acontour); textureC
{ oords=texCoord;}
SphericalConvexPolygon::setContour(acontour);
textureCoords=texCoord;
fillVertexBufferNeedsUpdate = true;
}
//! Serialize the region into a QVariant map matching the JSON forma t. //! Serialize the region into a QVariant map matching the JSON forma t.
//! The format is: //! The format is:
//! @code["TEXTURED_CONVEX_POLYGON", [[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[u,v],[u,v],[u,v],[u,v]]]@endcode //! @code["TEXTURED_CONVEX_POLYGON", [[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[u,v],[u,v],[u,v],[u,v]]]@endcode
//! where the two lists are a closed convex contours, with each poin ts defined by ra dec in degree in the ICRS frame //! where the two lists are a closed convex contours, with each poin ts defined by ra dec in degree in the ICRS frame
//! followed by a list of texture coordinates in the u,v texture spa ce (between 0 and 1). //! followed by a list of texture coordinates in the u,v texture spa ce (between 0 and 1).
//! There must be one texture coordinate for each vertex. //! There must be one texture coordinate for each vertex.
virtual QVariantList toQVariant() const; virtual QVariantList toQVariant() const;
virtual void serialize(QDataStream& out) const {out << contour << te xtureCoords;} virtual void serialize(QDataStream& out) const {out << contour << te xtureCoords;}
protected: protected:
//! A list of uv texture coordinates corresponding to the triangle v ertices. //! A list of uv textures coordinates corresponding to the triangle vertices.
//! There should be 1 uv position per vertex. //! There should be 1 uv position per vertex.
QVector<Vec2f> textureCoords; QVector<Vec2f> textureCoords;
//! Vertex buffer used in our override of drawFill() (using vertices
with texcoords).
StelVertexBuffer<TexturedVertex>* fillTexturedVertexBuffer;
virtual void updateFillVertexBuffer(class StelRenderer* renderer, co
nst DrawParams& params, bool handleDiscontinuity);
virtual void drawFillVertexBuffer(class StelRenderer* renderer, clas
s StelProjector* projector);
}; };
//! Compute the intersection of 2 great circles segments. //! Compute the intersection of 2 great circles segments.
//! @param p1 Start of the first great circle segment.
//! @param p2 End of the first great circle segment.
//! @param p3 Start of the second great circle segment.
//! @param p4 End of the second great circle segment.
//! @param ok is set to false if no intersection was found. //! @param ok is set to false if no intersection was found.
//! @return the intersection point on the sphere (normalized) if ok is true , or undefined of ok is false. //! @return the intersection point on the sphere (normalized) if ok is true , or undefined of ok is false.
Vec3d greatCircleIntersection(const Vec3d& p1, const Vec3d& p2, const Vec3d & p3, const Vec3d& p4, bool& ok); Vec3d greatCircleIntersection(const Vec3d& p1, const Vec3d& p2, const Vec3d & p3, const Vec3d& p4, bool& ok);
//! Compute the intersection of a great circles segment with another great circle. //! Compute the intersection of a great circles segment with another great circle.
//! @param p1 Start of the great circle segment.
//! @param p2 End of the great circle segment.
//! @param nHalfSpace Normal of the plane separating half space to intersec
t with.
//! @param ok is set to false if no intersection was found. //! @param ok is set to false if no intersection was found.
//! @return the intersection point on the sphere (normalized) if ok is true , or undefined of ok is false. //! @return the intersection point on the sphere (normalized) if ok is true , or undefined of ok is false.
Vec3d greatCircleIntersection(const Vec3d& p1, const Vec3d& p2, const Vec3d & nHalfSpace, bool& ok); Vec3d greatCircleIntersection(const Vec3d& p1, const Vec3d& p2, const Vec3d & nHalfSpace, bool& ok);
#endif // _STELSPHEREGEOMETRY_HPP_ #endif // _STELSPHEREGEOMETRY_HPP_
 End of changes. 41 change blocks. 
468 lines changed or deleted 143 lines changed or added

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