Stellarium  HEAD
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
SphericalConvexPolygon Class Reference

A special case of SphericalPolygon for which the polygon is convex. More...

#include <StelSphereGeometry.hpp>

Public Member Functions

 SphericalConvexPolygon ()
 Default constructor.
 
 SphericalConvexPolygon (const QVector< QVector< Vec3d > > &contours)
 Constructor from a list of contours.
 
 SphericalConvexPolygon (const QVector< Vec3d > &contour)
 Constructor from one contour.
 
 SphericalConvexPolygon (const Vec3d &e0, const Vec3d &e1, const Vec3d &e2)
 Special constructor for triangle.
 
 SphericalConvexPolygon (const Vec3d &e0, const Vec3d &e1, const Vec3d &e2, const Vec3d &e3)
 Special constructor for quads.
 
SphericalRegionType getType () const override
 
OctahedronPolygon getOctahedronPolygon () const override
 Return the octahedron contour representation of the polygon. More...
 
StelVertexArray getFillVertexArray (const Vec3d &observerVelocityForAberration) override
 Return an OpenGL compatible array to be displayed using vertex arrays. More...
 
StelVertexArray getFillVertexArray () const override
 Return an OpenGL compatible array to be displayed using vertex arrays.
 
StelVertexArray getOutlineVertexArray () const override
 Get the outline of the contours defining the SphericalPolygon. More...
 
StelVertexArray getOutlineVertexArray (Vec3d observerVelocityForAberration) override
 Get the outline of the contours defining the SphericalPolygon. More...
 
double getArea () const override
 Return the area of the region in steradians.
 
bool isEmpty () const override
 Return true if the region is empty.
 
Vec3d getPointInside () const override
 Return a point located inside the region.
 
SphericalCap getBoundingCap () const override
 Return a bounding SphericalCap. More...
 
QVector< SphericalCapgetBoundingSphericalCaps () const override
 Return the list of SphericalCap bounding the ConvexPolygon.
 
QVariantList toQVariant () const override
 Serialize the region into a QVariant map matching the JSON format. More...
 
void serialize (QDataStream &out) const override
 Serialize the region. This method must allow as fast as possible serialization and work with deserialize().
 
bool contains (const Vec3d &p) const override
 
bool contains (const SphericalPolygon &r) const override
 
bool contains (const SphericalConvexPolygon &r) const override
 
bool contains (const SphericalCap &r) const override
 
bool contains (const SphericalPoint &r) const override
 
bool contains (const AllSkySphericalRegion &) const override
 
bool intersects (const SphericalCap &r) const override
 
bool intersects (const SphericalPolygon &r) const override
 
bool intersects (const SphericalConvexPolygon &r) const override
 
bool intersects (const SphericalPoint &r) const override
 
bool intersects (const AllSkySphericalRegion &) const override
 
void setContour (const QVector< Vec3d > &acontour)
 Set a single contour defining the SphericalPolygon. More...
 
const QVector< Vec3d > & getConvexContour () const
 Get the single contour defining the SphericalConvexPolygon.
 
bool checkValid () const
 Check if the polygon is valid, i.e. it has no side >180.
 
bool intersects (const SphericalRegion *r) const
 Returns whether a SphericalRegion intersects with this region. More...
 
bool intersects (const SphericalRegionP r) const
 
bool intersects (const Vec3d &p) const
 
virtual bool intersects (const SphericalPolygon &r) const
 
virtual bool intersects (const SphericalConvexPolygon &r) const
 
virtual bool intersects (const SphericalCap &r) const
 
virtual bool intersects (const SphericalPoint &r) const
 
virtual bool intersects (const AllSkySphericalRegion &r) const
 
bool intersects (const EmptySphericalRegion &) const
 
bool contains (const SphericalRegion *r) const
 Returns whether a SphericalRegion is contained into this region. More...
 
bool contains (const SphericalRegionP r) const
 
virtual bool contains (const Vec3d &p) const
 
virtual bool contains (const SphericalPolygon &r) const
 
virtual bool contains (const SphericalConvexPolygon &r) const
 
virtual bool contains (const SphericalCap &r) const
 
virtual bool contains (const SphericalPoint &r) const
 
virtual bool contains (const AllSkySphericalRegion &r) const
 
bool contains (const EmptySphericalRegion &) const
 
- Public Member Functions inherited from SphericalRegion
virtual SphericalRegionP getEnlarged (double margin) const
 Return an enlarged version of this SphericalRegion so that any point distant of more than the given margin now lays within the region. More...
 
virtual QVector< QVector< Vec3d > > getSimplifiedContours () const
 Get the contours defining the SphericalPolygon when combined using a positive winding rule. More...
 
QByteArray toJSON () const
 Output a JSON string representing the polygon. More...
 
bool contains (const SphericalRegion *r) const
 Returns whether a SphericalRegion is contained into this region. More...
 
bool contains (const SphericalRegionP r) const
 
bool contains (const EmptySphericalRegion &) const
 
bool intersects (const SphericalRegion *r) const
 Returns whether a SphericalRegion intersects with this region. More...
 
bool intersects (const SphericalRegionP r) const
 
bool intersects (const Vec3d &p) const
 
bool intersects (const EmptySphericalRegion &) const
 
SphericalRegionP getSubtraction (const SphericalRegion *r) const
 Return a new SphericalRegion consisting of the subtraction of the given region from this. More...
 
SphericalRegionP getSubtraction (const SphericalRegionP r) const
 
virtual SphericalRegionP getSubtraction (const SphericalPolygon &r) const
 
virtual SphericalRegionP getSubtraction (const SphericalConvexPolygon &r) const
 
virtual SphericalRegionP getSubtraction (const SphericalCap &r) const
 
virtual SphericalRegionP getSubtraction (const SphericalPoint &r) const
 
SphericalRegionP getSubtraction (const AllSkySphericalRegion &r) const
 
virtual SphericalRegionP getSubtraction (const EmptySphericalRegion &r) const
 

Static Public Member Functions

static bool checkValidContour (const QVector< Vec3d > &contour)
 Check if the passed contour is convex and valid, i.e. it has no side >180.
 
static SphericalRegionP deserialize (QDataStream &in)
 Deserialize the region. This method must allow as fast as possible deserialization.
 

Protected Member Functions

void updateBoundingCap ()
 Update the bounding cap from the vertex list.
 
bool areAllPointsOutsideOneSide (const QVector< Vec3d > &points) const
 Computes whether the passed points are all outside of at least one SphericalCap defining the polygon boundary.
 
bool containsConvexContour (const Vec3d *vertice, int nbVertex) const
 

Static Protected Member Functions

static bool areAllPointsOutsideOneSide (const Vec3d *thisContour, int nbThisContour, const Vec3d *points, int nbPoints)
 Computes whether the passed points are all outside of at least one SphericalCap defining the polygon boundary. More...
 

Protected Attributes

QVector< Vec3dcontour
 A list of vertices of the convex contour.
 
QVector< Vec3daberratedContour
 A list of vertices, built on the fly from the contour when aberration is required.
 
SphericalCap cachedBoundingCap
 Cache the bounding cap.
 

Additional Inherited Members

- Public Types inherited from SphericalRegion
enum  SphericalRegionType {
  Point = 0 , Cap = 1 , AllSky = 2 , Polygon = 3 ,
  ConvexPolygon = 4 , Empty = 5 , Invalid = 6
}
 define types for all supported regions.
 

Detailed Description

A special case of SphericalPolygon for which the polygon is convex.

Member Function Documentation

◆ areAllPointsOutsideOneSide()

static bool SphericalConvexPolygon::areAllPointsOutsideOneSide ( const Vec3d thisContour,
int  nbThisContour,
const Vec3d points,
int  nbPoints 
)
staticprotected

Computes whether the passed points are all outside of at least one SphericalCap defining the polygon boundary.

Parameters
thisContourthe vertices defining the contour.
nbThisContournb of vertice of the contour.
pointsthe points to test.
nbPointsthe number of points to test.

◆ contains()

bool SphericalRegion::contains

Returns whether a SphericalRegion is contained into this region.

A default potentially very slow implementation is provided for each case.

◆ getBoundingCap()

SphericalCap SphericalConvexPolygon::getBoundingCap ( ) const
inlineoverridevirtual

Return a bounding SphericalCap.

This method is heavily used and therefore needs to be very fast. The returned SphericalCap doesn't have to be the smallest one, but smaller is better.

Reimplemented from SphericalRegion.

◆ getFillVertexArray()

StelVertexArray SphericalConvexPolygon::getFillVertexArray ( const Vec3d observerVelocityForAberration)
overridevirtual

Return an OpenGL compatible array to be displayed using vertex arrays.

Note
Presumably these general polygons of the base class don't describe geometry that may undergo aberration, so the observerVelocity must be zero. Implementation in derived classes should show aberration correction.

Reimplemented from SphericalRegion.

Reimplemented in SphericalTexturedConvexPolygon.

◆ getOctahedronPolygon()

OctahedronPolygon SphericalConvexPolygon::getOctahedronPolygon ( ) const
inlineoverridevirtual

Return the octahedron contour representation of the polygon.

It can be used for safe computation of intersection/union in the general case.

Implements SphericalRegion.

◆ getOutlineVertexArray() [1/2]

StelVertexArray SphericalConvexPolygon::getOutlineVertexArray ( ) const
overridevirtual

Get the outline of the contours defining the SphericalPolygon.

Returns
a list of vertex which taken 2 by 2 define the contours of the polygon.

Reimplemented from SphericalRegion.

◆ getOutlineVertexArray() [2/2]

StelVertexArray SphericalConvexPolygon::getOutlineVertexArray ( Vec3d  observerVelocityForAberration)
overridevirtual

Get the outline of the contours defining the SphericalPolygon.

Note
Presumably these general polygons of the base class don't describe geometry that may undergo aberration, so the observerVelocity must be zero. Implementation in derived classes should show aberration correction.

Reimplemented from SphericalRegion.

◆ intersects()

bool SphericalRegion::intersects

Returns whether a SphericalRegion intersects with this region.

A default potentially very slow implementation is provided for each case.

◆ setContour()

void SphericalConvexPolygon::setContour ( const QVector< Vec3d > &  acontour)
inline

Set a single contour defining the SphericalPolygon.

Parameters
acontoura contour defining the polygon area.

◆ toQVariant()

QVariantList SphericalConvexPolygon::toQVariant ( ) const
overridevirtual

Serialize the region into a QVariant map matching the JSON format.

The format is

["CONVEX_POLYGON", [[ra,dec], [ra,dec], [ra,dec], [ra,dec]]]

where the coords are a closed convex contour, with each points defined by ra dec in degree in the ICRS frame.

Implements SphericalRegion.

Reimplemented in SphericalTexturedConvexPolygon.