StelSphereGeometry.hpp   StelSphereGeometry.hpp 
skipping to change at line 140 skipping to change at line 140
{ {
public: public:
//! @enum SphericalRegionType define types for all supported regions . //! @enum SphericalRegionType define types for all supported regions .
enum SphericalRegionType enum SphericalRegionType
{ {
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
}; };
virtual ~SphericalRegion() {;} virtual ~SphericalRegion() {;}
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;
skipping to change at line 202 skipping to change at line 203
//! Returns whether a SphericalRegion is contained into this region. //! Returns whether a SphericalRegion is contained into this region.
//! A default potentially very slow implementation is provided for e ach cases. //! A default potentially very slow implementation is provided for e ach cases.
bool contains(const SphericalRegion* r) const; bool contains(const SphericalRegion* r) const;
bool contains(const SphericalRegionP r) const {return contains(r.dat a());} bool contains(const SphericalRegionP r) const {return contains(r.dat a());}
virtual bool contains(const Vec3d& p) const {return getOctahedronPol ygon().contains(p);} virtual bool contains(const Vec3d& p) const {return getOctahedronPol ygon().contains(p);}
virtual bool contains(const SphericalPolygon& r) const; virtual bool contains(const SphericalPolygon& r) const;
virtual bool contains(const SphericalConvexPolygon& r) const; virtual bool contains(const SphericalConvexPolygon& r) const;
virtual bool contains(const SphericalCap& r) const; virtual bool contains(const SphericalCap& r) const;
virtual bool contains(const SphericalPoint& r) const; virtual bool contains(const SphericalPoint& r) const;
virtual bool contains(const AllSkySphericalRegion& r) const; virtual bool contains(const AllSkySphericalRegion& r) const;
bool contains(const EmptySphericalRegion& r) const {return false;} bool contains(const EmptySphericalRegion&) const {return false;}
//! Returns whether a SphericalRegion intersects with this region. //! Returns whether a SphericalRegion intersects with this region.
//! A default potentially very slow implementation is provided for e ach cases. //! A default potentially very slow implementation is provided for e ach cases.
bool intersects(const SphericalRegion* r) const; bool intersects(const SphericalRegion* r) const;
bool intersects(const SphericalRegionP r) const {return intersects(r .data());} bool intersects(const SphericalRegionP r) const {return intersects(r .data());}
bool intersects(const Vec3d& p) const {return contains(p);} bool intersects(const Vec3d& p) const {return contains(p);}
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;
virtual bool intersects(const SphericalCap& r) const; virtual bool intersects(const SphericalCap& r) const;
virtual bool intersects(const SphericalPoint& r) const; virtual bool intersects(const SphericalPoint& r) const;
virtual bool intersects(const AllSkySphericalRegion& r) const; virtual bool intersects(const AllSkySphericalRegion& r) const;
bool intersects(const EmptySphericalRegion& r) const {return false;} bool intersects(const EmptySphericalRegion&) const {return false;}
//! Return a new SphericalRegion consisting of the intersection of t his and the given region. //! Return a new SphericalRegion consisting of the intersection of t his and the given region.
//! 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 getIntersection(const SphericalRegion* r) const; SphericalRegionP getIntersection(const SphericalRegion* r) const;
SphericalRegionP getIntersection(const SphericalRegionP r) const {re turn getIntersection(r.data());} SphericalRegionP getIntersection(const SphericalRegionP r) const {re turn getIntersection(r.data());}
virtual SphericalRegionP getIntersection(const SphericalPolygon& r) const; virtual SphericalRegionP getIntersection(const SphericalPolygon& r) const;
virtual SphericalRegionP getIntersection(const SphericalConvexPolygo n& r) const; virtual SphericalRegionP getIntersection(const SphericalConvexPolygo n& r) const;
virtual SphericalRegionP getIntersection(const SphericalCap& r) cons t; virtual SphericalRegionP getIntersection(const SphericalCap& r) cons t;
virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst; virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst;
virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & r) const; virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & r) const;
skipping to change at line 295 skipping to change at line 296
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
virtual bool contains(const Vec3d &v) const {Q_ASSERT(d==0 || std::f abs(v.lengthSquared()-1.)<0.0000001);return (v*n>=d);} virtual bool contains(const Vec3d &v) const {Q_ASSERT(d==0 || std::f abs(v.lengthSquared()-1.)<0.0000001);return (v*n>=d);}
virtual bool contains(const Vec3f &v) const {Q_ASSERT(d==0 || std::f abs(v.lengthSquared()-1.f)<0.0000001f);return (v[0]*n[0]+v[1]*n[1]+v[2]*n[2 ]>=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& r) 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.
//! I managed to make it without sqrt or acos, so it is very fast! //! I managed to make it without sqrt or acos, so it is very fast!
//! @see http://f4bien.blogspot.com/2009/05/spherical-geometry-optim isations.html for detailed explanations. //! @see http://f4bien.blogspot.com/2009/05/spherical-geometry-optim isations.html for detailed explanations.
virtual bool intersects(const SphericalCap& h) const virtual bool intersects(const SphericalCap& h) const
{ {
const double a = d*h.d - n*h.n; const double a = d*h.d - n*h.n;
return d+h.d<=0. || a<=0. || (a<=1. && a*a <= (1.-d*d)*(1.-h .d*h.d)); return d+h.d<=0. || a<=0. || (a<=1. && a*a <= (1.-d*d)*(1.-h .d*h.d));
} }
virtual bool intersects(const AllSkySphericalRegion& poly) const {re turn d<=1.;} virtual bool intersects(const AllSkySphericalRegion&) const {return d<=1.;}
//! 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 {"type": "CAP", "center": [ra, dec], "radius": rad ius}, with ra dec in degree in ICRS frame //! The format is {"type": "CAP", "center": [ra, dec], "radius": rad ius}, with ra dec in degree in ICRS frame
//! and radius in degree (between 0 and 180 deg) //! and radius in degree (between 0 and 180 deg)
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {out << n << d;} virtual void serialize(QDataStream& out) const {out << n << d;}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Methods specific to SphericalCap // Methods specific to SphericalCap
skipping to change at line 425 skipping to change at line 427
virtual bool isEmpty() const {return false;} virtual bool isEmpty() const {return false;}
virtual Vec3d getPointInside() const {return n;} virtual Vec3d getPointInside() const {return n;}
virtual SphericalCap getBoundingCap() const {return SphericalCap(n, 1);} virtual SphericalCap getBoundingCap() const {return SphericalCap(n, 1);}
//! 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 {"type": "POINT", "pos": [ra, dec]}, with ra dec i n degree in ICRS frame. //! The format is {"type": "POINT", "pos": [ra, dec]}, with ra dec i n degree in ICRS frame.
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {out << n;} virtual void serialize(QDataStream& out) const {out << n;}
// Contain and intersect // Contain and intersect
virtual bool contains(const Vec3d& p) const {return n==p;} virtual bool contains(const Vec3d& p) const {return n==p;}
virtual bool contains(const SphericalPolygon& r) const {return false virtual bool contains(const SphericalPolygon&) const {return false;}
;} virtual bool contains(const SphericalConvexPolygon&) const {return f
virtual bool contains(const SphericalConvexPolygon& r) const {return alse;}
false;} virtual bool contains(const SphericalCap&) const {return false;}
virtual bool contains(const SphericalCap& c) const {return false;}
virtual bool contains(const SphericalPoint& r) const {return n==r.n; } virtual bool contains(const SphericalPoint& r) const {return n==r.n; }
virtual bool contains(const AllSkySphericalRegion& r) const {return virtual bool contains(const AllSkySphericalRegion&) const {return fa
false;} lse;}
virtual bool intersects(const SphericalPolygon& r) const; virtual bool intersects(const SphericalPolygon&) const;
virtual bool intersects(const SphericalConvexPolygon& r) const; virtual bool intersects(const SphericalConvexPolygon&) const;
virtual bool intersects(const SphericalCap& r) const {return r.conta ins(n);} virtual bool intersects(const SphericalCap& r) const {return r.conta ins(n);}
virtual bool intersects(const SphericalPoint& r) const {return n==r. n;} virtual bool intersects(const SphericalPoint& r) const {return n==r. n;}
virtual bool intersects(const AllSkySphericalRegion& r) const {retur n true;} virtual bool intersects(const AllSkySphericalRegion&) const {return true;}
//! 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);
//! The unit vector of the point direction. //! The unit vector of the point direction.
Vec3d n; Vec3d n;
}; };
//! @class AllSkySphericalRegion //! @class AllSkySphericalRegion
//! Special SphericalRegion for the whole sphere. //! Special SphericalRegion for the whole sphere.
skipping to change at line 459 skipping to change at line 461
virtual SphericalRegionType getType() const {return SphericalRegion: :AllSky;} virtual SphericalRegionType getType() const {return SphericalRegion: :AllSky;}
virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon::getAllSkyOctahedronPolygon();} virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon::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 {"type": "ALLSKY"} //! The format is {"type": "ALLSKY"}
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {;} virtual void serialize(QDataStream&) const {;}
// Contain and intersect // Contain and intersect
virtual bool contains(const Vec3d& p) const {return true;} virtual bool contains(const Vec3d&) const {return true;}
virtual bool contains(const SphericalPolygon& r) const {return true; virtual bool contains(const SphericalPolygon&) const {return true;}
} virtual bool contains(const SphericalConvexPolygon&) const {return t
virtual bool contains(const SphericalConvexPolygon& r) const {return rue;}
true;} virtual bool contains(const SphericalCap&) const {return true;}
virtual bool contains(const SphericalCap& r) const {return true;} virtual bool contains(const SphericalPoint&) const {return true;}
virtual bool contains(const SphericalPoint& r) const {return true;} virtual bool contains(const AllSkySphericalRegion&) const {return tr
virtual bool contains(const AllSkySphericalRegion& r) const {return ue;}
true;} virtual bool intersects(const SphericalPolygon&) const {return true;
virtual bool intersects(const SphericalPolygon& r) const {return tru }
e;} virtual bool intersects(const SphericalConvexPolygon&) const {return
virtual bool intersects(const SphericalConvexPolygon& r) const {retu true;}
rn true;} virtual bool intersects(const SphericalCap&) const {return true;}
virtual bool intersects(const SphericalCap& r) const {return true;} virtual bool intersects(const SphericalPoint&) const {return true;}
virtual bool intersects(const SphericalPoint& r) const {return true; virtual bool intersects(const AllSkySphericalRegion&) const {return
} true;}
virtual bool intersects(const AllSkySphericalRegion& r) const {retur
n true;}
static const SphericalRegionP staticInstance; static const SphericalRegionP staticInstance;
}; };
//! @class AllSkySphericalRegion //! @class AllSkySphericalRegion
//! Special SphericalRegion for the whole sphere. //! Special SphericalRegion for the whole sphere.
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.
skipping to change at line 501 skipping to change at line 503
virtual SphericalRegionType getType() const {return SphericalRegion: :Empty;} virtual SphericalRegionType getType() const {return SphericalRegion: :Empty;}
virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon::getEmptyOctahedronPolygon();} virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon::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 {"type": "EMPTY"} //! The format is {"type": "EMPTY"}
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {;} virtual void serialize(QDataStream&) const {;}
// Contain and intersect // Contain and intersect
virtual bool contains(const Vec3d& p) const {return false;} virtual bool contains(const Vec3d&) const {return false;}
virtual bool contains(const SphericalPolygon& r) const {return false virtual bool contains(const SphericalPolygon&) const {return false;}
;} virtual bool contains(const SphericalConvexPolygon&) const {return f
virtual bool contains(const SphericalConvexPolygon& r) const {return alse;}
false;} virtual bool contains(const SphericalCap&) const {return false;}
virtual bool contains(const SphericalCap& r) const {return false;} virtual bool contains(const SphericalPoint&) const {return false;}
virtual bool contains(const SphericalPoint& r) const {return false;} virtual bool contains(const AllSkySphericalRegion&) const {return fa
virtual bool contains(const AllSkySphericalRegion& r) const {return lse;}
false;} virtual bool intersects(const SphericalPolygon&) const {return false
virtual bool intersects(const SphericalPolygon& r) const {return fal ;}
se;} virtual bool intersects(const SphericalConvexPolygon&) const {return
virtual bool intersects(const SphericalConvexPolygon& r) const {retu false;}
rn false;} virtual bool intersects(const SphericalCap&) const {return false;}
virtual bool intersects(const SphericalCap& r) const {return false;} virtual bool intersects(const SphericalPoint&) const {return false;}
virtual bool intersects(const SphericalPoint& r) const {return false virtual bool intersects(const AllSkySphericalRegion&) const {return
;} false;}
virtual bool intersects(const AllSkySphericalRegion& r) const {retur
n false;}
static const SphericalRegionP staticInstance; static const SphericalRegionP staticInstance;
}; };
//! @class SphericalPolygonBase //! @class SphericalPolygonBase
//! Abstract class defining default implementations for some spherical geom etry methods. //! Abstract class defining default implementations for some spherical geom etry methods.
//! All methods are reentrant. //! All methods are reentrant.
class SphericalPolygon : public SphericalRegion class SphericalPolygon : public SphericalRegion
{ {
public: public:
skipping to change at line 545 skipping to change at line 547
//! 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 {return octah edronPolygon;} virtual OctahedronPolygon getOctahedronPolygon() const {return octah edronPolygon;}
//! 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 {"worldCoords": [[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]]} @endcode //! @code["worldCoords": [[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]]]@endcode
//! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame. //! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame.
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const; virtual void serialize(QDataStream& out) const;
virtual SphericalCap getBoundingCap() const; virtual SphericalCap getBoundingCap() const;
virtual bool contains(const Vec3d& p) const {return octahedronPolygo n.contains(p);} virtual bool contains(const Vec3d& p) const {return octahedronPolygo n.contains(p);}
virtual bool contains(const SphericalPolygon& r) const {return octah edronPolygon.contains(r.octahedronPolygon);} virtual bool contains(const SphericalPolygon& r) const {return octah edronPolygon.contains(r.octahedronPolygon);}
virtual bool contains(const SphericalConvexPolygon& r) const; virtual bool contains(const SphericalConvexPolygon& r) const;
virtual bool contains(const SphericalCap& r) const {return octahedro nPolygon.contains(r.getOctahedronPolygon());} virtual bool contains(const SphericalCap& r) const {return octahedro nPolygon.contains(r.getOctahedronPolygon());}
virtual bool contains(const SphericalPoint& r) const {return octahed ronPolygon.contains(r.n);} virtual bool contains(const SphericalPoint& r) const {return octahed ronPolygon.contains(r.n);}
virtual bool contains(const AllSkySphericalRegion& r) const {return octahedronPolygon.contains(r.getOctahedronPolygon());} virtual bool contains(const AllSkySphericalRegion& r) const {return octahedronPolygon.contains(r.getOctahedronPolygon());}
virtual bool intersects(const SphericalPolygon& r) const {return oct ahedronPolygon.intersects(r.octahedronPolygon);} virtual bool intersects(const SphericalPolygon& r) const {return oct ahedronPolygon.intersects(r.octahedronPolygon);}
virtual bool intersects(const SphericalConvexPolygon& r) const; virtual bool intersects(const SphericalConvexPolygon& r) const;
virtual bool intersects(const SphericalCap& r) const {return r.inter sects(*this);} virtual bool intersects(const SphericalCap& r) const {return r.inter sects(*this);}
virtual bool intersects(const SphericalPoint& r) const {return octah edronPolygon.contains(r.n);} virtual bool intersects(const SphericalPoint& r) const {return octah edronPolygon.contains(r.n);}
virtual bool intersects(const AllSkySphericalRegion& r) const {retur n !isEmpty();} virtual bool intersects(const AllSkySphericalRegion&) const {return !isEmpty();}
virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst {return contains(r.n) ? SphericalRegionP(new SphericalPoint(r)) : Empty SphericalRegion::staticInstance;} virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst {return contains(r.n) ? SphericalRegionP(new SphericalPoint(r)) : Empty SphericalRegion::staticInstance;}
virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & r) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon) );} virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & ) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon)) ;}
virtual SphericalRegionP getUnion(const SphericalPoint& r) const {re virtual SphericalRegionP getUnion(const SphericalPoint&) const {retu
turn SphericalRegionP(new SphericalPolygon(octahedronPolygon));} rn SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
virtual SphericalRegionP getUnion(const EmptySphericalRegion& r) con virtual SphericalRegionP getUnion(const EmptySphericalRegion&) const
st {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));} {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
virtual SphericalRegionP getSubtraction(const SphericalPoint& r) con virtual SphericalRegionP getSubtraction(const SphericalPoint&) const
st {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));} {return SphericalRegionP(new SphericalPolygon(octahedronPolygon));}
virtual SphericalRegionP getSubtraction(const EmptySphericalRegion& virtual SphericalRegionP getSubtraction(const EmptySphericalRegion&)
r) const {return SphericalRegionP(new SphericalPolygon(octahedronPolygon)); 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) {octahedr onPolygon = OctahedronPolygon(contours);} void setContours(const QVector<QVector<Vec3d> >& contours) {octahedr onPolygon = OctahedronPolygon(contours);}
//! Set a single contour defining the SphericalPolygon. //! Set a single contour defining the SphericalPolygon.
//! @param contours a contour defining the polygon area. //! @param contour a contour defining the polygon area.
void setContour(const QVector<Vec3d>& contour) {octahedronPolygon = OctahedronPolygon(contour);} void setContour(const QVector<Vec3d>& 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); static SphericalRegionP multiUnion(const QList<SphericalRegionP>& re gions);
skipping to change at line 630 skipping to change at line 632
virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon(contour);} virtual OctahedronPolygon getOctahedronPolygon() const {return Octah edronPolygon(contour);}
virtual StelVertexArray getFillVertexArray() const {return StelVerte xArray(contour, StelVertexArray::TriangleFan);} virtual StelVertexArray getFillVertexArray() const {return StelVerte xArray(contour, StelVertexArray::TriangleFan);}
virtual StelVertexArray getOutlineVertexArray() const {return StelVe rtexArray(contour, StelVertexArray::LineLoop);} virtual StelVertexArray getOutlineVertexArray() const {return StelVe rtexArray(contour, StelVertexArray::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 {"type": "CVXPOLYGON", "worldCoords": [[[ra,dec], [ra,dec] , [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]]} @endcode //! @code{"type": "CVXPOLYGON", "worldCoords": [[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]]}@endcode
//! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame. //! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame.
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {out << contour;} virtual void serialize(QDataStream& out) const {out << contour;}
// Contain and intersect // Contain and intersect
virtual bool contains(const Vec3d& p) const; virtual bool contains(const Vec3d& p) const;
virtual bool contains(const SphericalPolygon& r) const; virtual bool contains(const SphericalPolygon& r) const;
virtual bool contains(const SphericalConvexPolygon& r) const; virtual bool contains(const SphericalConvexPolygon& r) const;
virtual bool contains(const SphericalCap& r) const; virtual bool contains(const SphericalCap& r) const;
virtual bool contains(const SphericalPoint& r) const {return contain s(r.n);} virtual bool contains(const SphericalPoint& r) const {return contain s(r.n);}
virtual bool contains(const AllSkySphericalRegion& r) const {return false;} virtual bool contains(const AllSkySphericalRegion&) const {return fa lse;}
virtual bool intersects(const SphericalCap& r) const {if (!cachedBou ndingCap.intersects(r)) return false; return r.intersects(*this);} virtual bool intersects(const SphericalCap& r) const {if (!cachedBou ndingCap.intersects(r)) return false; return r.intersects(*this);}
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;
virtual bool intersects(const SphericalPoint& r) const {return conta ins(r.n);} virtual bool intersects(const SphericalPoint& r) const {return conta ins(r.n);}
virtual bool intersects(const AllSkySphericalRegion& r) const {retur n true;} virtual bool intersects(const AllSkySphericalRegion&) const {return true;}
////////////////////////// TODO ////////////////////////// TODO
// virtual SphericalRegionP getIntersection(const SphericalPolygon& r) const; // virtual SphericalRegionP getIntersection(const SphericalPolygon& r) const;
// virtual SphericalRegionP getIntersection(const SphericalConvexPolygo n& r) const; // virtual SphericalRegionP getIntersection(const SphericalConvexPolygo n& r) const;
// virtual SphericalRegionP getIntersection(const SphericalCap& r) cons t; // virtual SphericalRegionP getIntersection(const SphericalCap& r) cons t;
// virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst; // virtual SphericalRegionP getIntersection(const SphericalPoint& r) co nst;
// virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & r) const; // virtual SphericalRegionP getIntersection(const AllSkySphericalRegion & r) const;
// virtual SphericalRegionP getUnion(const SphericalPolygon& r) const; // virtual SphericalRegionP getUnion(const SphericalPolygon& r) const;
// virtual SphericalRegionP getUnion(const SphericalConvexPolygon& r) c onst; // virtual SphericalRegionP getUnion(const SphericalConvexPolygon& r) c onst;
// virtual SphericalRegionP getUnion(const SphericalCap& r) const; // virtual SphericalRegionP getUnion(const SphericalCap& r) const;
skipping to change at line 698 skipping to change at line 700
//! 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();
//! 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 points 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 ;
}; };
skipping to change at line 725 skipping to change at line 727
//! @struct TextureVertex //! @struct TextureVertex
//! A container for 3D vertex + associated texture coordinates //! A container for 3D vertex + associated texture coordinates
struct TextureVertex struct TextureVertex
{ {
Vec3d vertex; Vec3d vertex;
Vec2f texCoord; Vec2f texCoord;
}; };
SphericalTexturedPolygon() {;} SphericalTexturedPolygon() {;}
//! Constructor from a list of contours. //! Constructor from a list of contours.
SphericalTexturedPolygon(const QVector<QVector<TextureVertex> >& con tours) {Q_ASSERT(0);} SphericalTexturedPolygon(const QVector<QVector<TextureVertex> >& con tours) {Q_UNUSED(contours); Q_ASSERT(0);}
//! Constructor from one contour. //! Constructor from one contour.
SphericalTexturedPolygon(const QVector<TextureVertex>& contour) {Q_A SSERT(0);} 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. //! 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();} virtual StelVertexArray getFillVertexArray() const {Q_ASSERT(0); ret urn StelVertexArray();}
//! 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 {"worldCoords": [[[ra,dec], [ra,dec], [ra,dec], [ra,dec]], //! @code{"worldCoords": [[[ra,dec], [ra,dec], [ra,dec], [ra,dec]],
[[ra,dec], [ra,dec], [ra,dec]],[...]], [[ra,dec], [ra,dec], [ra,dec]],[...]],
//! "textureCoords": [[[u,v],[u,v],[u,v],[u,v]], [[u,v],[u,v],[u,v]] //! "textureCoords": [[[u,v],[u,v],[u,v],[u,v]], [[u,v],[u,v],[u,v]]
, [...]]} , [...]]
//! }@endcode //! }@endcode
//! textureCoords is a list of texture coordinates in the u,v textur e space (between 0 and 1). //! textureCoords is a list of texture coordinates in the u,v textur e space (between 0 and 1).
//! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame. //! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame.
//! There must be one texture coordinate for each vertex. //! There must be one texture coordinate for each vertex.
virtual QVariantMap toQVariant() const; virtual QVariantMap toQVariant() const;
virtual void serialize(QDataStream& out) const {Q_ASSERT(0);} virtual void serialize(QDataStream& out) const {Q_UNUSED(out); Q_ASS ERT(0);}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Methods specific to SphericalTexturedPolygon // Methods specific to SphericalTexturedPolygon
//! Set the contours defining the SphericalPolygon. //! Set the contours defining the SphericalPolygon.
//! @param contours the list of contours defining the polygon area. //! @param contours the list of contours defining the polygon area u
//! @param windingRule the winding rule to use. Default value is Win sing the WindingPositive winding rule.
dingPositive, meaning that the void setContours(const QVector<QVector<TextureVertex> >& contours) {
//! polygon is the union of the positive contours minus the negative Q_UNUSED(contours); Q_ASSERT(0);}
ones.
void setContours(const QVector<QVector<TextureVertex> >& contours) {
Q_ASSERT(0);}
//! 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<TextureVertex>& contour) {Q_ASSERT(0); } void setContour(const QVector<TextureVertex>& contour) {Q_UNUSED(con tour); Q_ASSERT(0);}
private: private:
//! A list of uv textures coordinates corresponding to the triangle vertices. //! 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;
}; };
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() {;} SphericalTexturedConvexPolygon() {;}
//! Constructor from one contour. //! Constructor from one contour.
SphericalTexturedConvexPolygon(const QVector<Vec3d>& contour, const QVector<Vec2f>& texCoord) {setContour(contour, texCoord);} SphericalTexturedConvexPolygon(const QVector<Vec3d>& contour, const QVector<Vec2f>& texCoord) {setContour(contour, texCoord);}
skipping to change at line 789 skipping to change at line 791
//! This method is not optimized for SphericalConvexPolygon instance s. //! This method is not optimized for SphericalConvexPolygon instance s.
virtual StelVertexArray getFillVertexArray() const {return StelVerte xArray(contour, StelVertexArray::TriangleFan, textureCoords);} 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 r<Vec2f>& texCoord) {SphericalConvexPolygon::setContour(acontour); textureC oords=texCoord;} virtual void setContour(const QVector<Vec3d>& acontour, const QVecto r<Vec2f>& texCoord) {SphericalConvexPolygon::setContour(acontour); textureC oords=texCoord;}
//! 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 {"type": "CVXPOLYGON", "worldCoords": [[[ra,dec], [ra,dec] //! @code{"type": "CVXPOLYGON", "worldCoords": [[[ra,dec], [ra,dec],
, [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]], [ra,dec], [ra,dec]], [[ra,dec], [ra,dec], [ra,dec]],[...]],
//! "textureCoords": [[[u,v],[u,v],[u,v],[u,v]], [[u,v],[u,v],[u,v]] //! "textureCoords": [[[u,v],[u,v],[u,v],[u,v]], [[u,v],[u,v],[u,v]]
, [...]]} , [...]]
//! }@endcode //! }@endcode
//! textureCoords is a list of texture coordinates in the u,v textur e space (between 0 and 1). //! textureCoords is a list of texture coordinates in the u,v textur e space (between 0 and 1).
//! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame. //! worldCoords is a list of closed contours, with each points defin ed by ra dec in degree in the ICRS frame.
//! There must be one texture coordinate for each vertex. //! There must be one texture coordinate for each vertex.
virtual QVariantMap toQVariant() const; virtual QVariantMap 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 textures coordinates corresponding to the triangle vertices. //! A list of uv textures coordinates corresponding to the triangle vertices.
 End of changes. 31 change blocks. 
89 lines changed or deleted 85 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/