Stellarium 0.12.4
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
SphericalRegion Class Referenceabstract

Abstract class defining a region of the sphere. More...

#include <StelSphereGeometry.hpp>

Classes

struct  DrawParams
 Parameters specifying how to draw a SphericalRegion. More...
 
struct  PlainVertex
 3D vertex with only a position. More...
 
struct  TexturedVertex
 3D vertex with position and a texture coordinate. More...
 

Public Types

enum  SphericalRegionType {
  Point = 0, Cap = 1, AllSky = 2, Polygon = 3,
  ConvexPolygon = 4, Empty = 5, Invalid = 6
}
 define types for all supported regions. More...
 

Public Member Functions

 SphericalRegion ()
 Default constructor. Inializes with no vertex buffers. More...
 
virtual ~SphericalRegion ()
 Destructor. Cleans up vertex buffers, if any. More...
 
virtual SphericalRegionType getType () const =0
 
virtual OctahedronPolygon getOctahedronPolygon () const =0
 Return the octahedron contour representation of the polygon. More...
 
virtual double getArea () const
 Return the area of the region in steradians. More...
 
virtual bool isEmpty () const
 Return true if the region is empty. More...
 
virtual Vec3d getPointInside () const
 Return a point located inside the region. More...
 
virtual QVector< SphericalCapgetBoundingSphericalCaps () const
 Return the list of SphericalCap bounding the ConvexPolygon. More...
 
virtual SphericalCap getBoundingCap () const
 Return a bounding SphericalCap. More...
 
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 const QVector< Vec3d > & getFillVertexPositions () const
 Get a vector of vertex positions forming the region. More...
 
virtual PrimitiveType getFillPrimitiveType () const
 Get primitive type determining how vertices in vector returned by getFillVertexPositions() form triangles. More...
 
virtual const QVector< Vec3d > & getOutlineVertexPositions () const
 Get the outline of the contours defining the SphericalPolygon. More...
 
virtual PrimitiveType getOutlinePrimitiveType () const
 Get primitive type determining how vertices in vector returned by getOutlinePrimitiveType() form lines. More...
 
virtual QVector< QVector< Vec3d > > getSimplifiedContours () const
 Get the contours defining the SphericalPolygon when combined using a positive winding rule. More...
 
virtual QVariantList toQVariant () const =0
 Serialize the region into a QVariant list matching the JSON format. More...
 
virtual void serialize (QDataStream &out) const =0
 Serialize the region. This method must allow as fast as possible serialization and work with deserialize(). 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
 
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
 
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
 
SphericalRegionP getIntersection (const SphericalRegion *r) const
 Return a new SphericalRegion consisting of the intersection of this and the given region. More...
 
SphericalRegionP getIntersection (const SphericalRegionP r) const
 
virtual SphericalRegionP getIntersection (const SphericalPolygon &r) const
 
virtual SphericalRegionP getIntersection (const SphericalConvexPolygon &r) const
 
virtual SphericalRegionP getIntersection (const SphericalCap &r) const
 
virtual SphericalRegionP getIntersection (const SphericalPoint &r) const
 
virtual SphericalRegionP getIntersection (const AllSkySphericalRegion &r) const
 
SphericalRegionP getIntersection (const EmptySphericalRegion &r) const
 
SphericalRegionP getUnion (const SphericalRegion *r) const
 Return a new SphericalRegion consisting of the union of this and the given region. More...
 
SphericalRegionP getUnion (const SphericalRegionP r) const
 
virtual SphericalRegionP getUnion (const SphericalPolygon &r) const
 
virtual SphericalRegionP getUnion (const SphericalConvexPolygon &r) const
 
virtual SphericalRegionP getUnion (const SphericalCap &r) const
 
virtual SphericalRegionP getUnion (const SphericalPoint &r) const
 
SphericalRegionP getUnion (const AllSkySphericalRegion &r) const
 
virtual SphericalRegionP getUnion (const EmptySphericalRegion &r) 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
 
virtual void drawFill (class StelRenderer *renderer, const DrawParams &params)
 Draw the region as triangles (i.e. More...
 
virtual void drawOutline (class StelRenderer *renderer, const DrawParams &params)
 Draw the outline of the region. More...
 

Protected Member Functions

virtual void updateFillVertexBuffer (class StelRenderer *renderer, const DrawParams &params, bool handleDiscontinuity)
 Update the vertex buffer used by drawFill(). More...
 
virtual void drawFillVertexBuffer (class StelRenderer *renderer, class StelProjector *projector)
 Drawing part of drawFill() - assumes the buffer/s is/are generated. More...
 
virtual bool needToUpdateFillVertexBuffers () const
 Do we need to update vertex buffer/s used by drawFill()? More...
 
virtual void fillVertexBuffersUpdated ()
 Called after updating vertex buffer/s used by drawFill(). More...
 

Protected Attributes

StelVertexBuffer< PlainVertex > * fillPlainVertexBuffer
 Cached plain vertex buffer for drawing. More...
 
bool useProjector
 Should Renderer draw calls specify a projector? More...
 

Detailed Description

Abstract class defining a region of the sphere.

It provides default implementation for the general non-convex polygon which can extend on more than 180 deg based on the OctahedronPolygon class. Subclasses provides special faster implementations of many methods.

Definition at line 132 of file StelSphereGeometry.hpp.

Member Enumeration Documentation

define types for all supported regions.

Definition at line 136 of file StelSphereGeometry.hpp.

Constructor & Destructor Documentation

SphericalRegion::SphericalRegion ( )
inline

Default constructor. Inializes with no vertex buffers.

Definition at line 270 of file StelSphereGeometry.hpp.

virtual SphericalRegion::~SphericalRegion ( )
inlinevirtual

Destructor. Cleans up vertex buffers, if any.

Definition at line 280 of file StelSphereGeometry.hpp.

Member Function Documentation

bool SphericalRegion::contains ( const SphericalRegion r) const

Returns whether a SphericalRegion is contained into this region.

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

virtual void SphericalRegion::drawFill ( class StelRenderer renderer,
const DrawParams params 
)
virtual

Draw the region as triangles (i.e.

filling the region).

Parameters
rendererRenderer to use for drawing.
paramsDrawing parameters (projector, clipping cap, if any, etc.).
See Also
DrawParams
virtual void SphericalRegion::drawFillVertexBuffer ( class StelRenderer renderer,
class StelProjector projector 
)
protectedvirtual

Drawing part of drawFill() - assumes the buffer/s is/are generated.

Parameters
rendererRenderer used for drawing.
projectorProjector to project the vertices (NULL if subdivision is enabled, as in that case the projection is done during buffer generation)

Reimplemented in SphericalTexturedConvexPolygon, and SphericalConvexPolygon.

virtual void SphericalRegion::drawOutline ( class StelRenderer renderer,
const DrawParams params 
)
virtual

Draw the outline of the region.

Parameters
rendererRenderer to use for drawing.
paramsDrawing parameters (projector, clipping cap, if any, etc.). Note that maxSqDistortion has no effect here.
See Also
DrawParams
virtual void SphericalRegion::fillVertexBuffersUpdated ( )
inlineprotectedvirtual

Called after updating vertex buffer/s used by drawFill().

Reimplemented in SphericalConvexPolygon.

Definition at line 486 of file StelSphereGeometry.hpp.

virtual double SphericalRegion::getArea ( ) const
inlinevirtual

Return the area of the region in steradians.

Reimplemented in SphericalConvexPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

Definition at line 295 of file StelSphereGeometry.hpp.

virtual SphericalCap SphericalRegion::getBoundingCap ( ) const
virtual

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 in SphericalConvexPolygon, SphericalPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

virtual QVector<SphericalCap> SphericalRegion::getBoundingSphericalCaps ( ) const
virtual

Return the list of SphericalCap bounding the ConvexPolygon.

Reimplemented in SphericalConvexPolygon.

virtual SphericalRegionP SphericalRegion::getEnlarged ( double  margin) const
virtual

Return an enlarged version of this SphericalRegion so that any point distant of more than the given margin now lays within the region.

The returned region can be larger than the smallest enlarging region, therefore returning false positive on subsequent intersection tests. The default implementation always return an enlarged bounding SphericalCap.

Parameters
marginthe minimum enlargement margin in radian.
virtual PrimitiveType SphericalRegion::getFillPrimitiveType ( ) const
inlinevirtual

Get primitive type determining how vertices in vector returned by getFillVertexPositions() form triangles.

Reimplemented in SphericalConvexPolygon.

Definition at line 326 of file StelSphereGeometry.hpp.

virtual const QVector<Vec3d>& SphericalRegion::getFillVertexPositions ( ) const
inlinevirtual

Get a vector of vertex positions forming the region.

Reimplemented in SphericalConvexPolygon.

Definition at line 319 of file StelSphereGeometry.hpp.

SphericalRegionP SphericalRegion::getIntersection ( const SphericalRegion r) const

Return a new SphericalRegion consisting of the intersection of this and the given region.

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

virtual OctahedronPolygon SphericalRegion::getOctahedronPolygon ( ) const
pure virtual

Return the octahedron contour representation of the polygon.

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

Implemented in SphericalConvexPolygon, SphericalPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

virtual PrimitiveType SphericalRegion::getOutlinePrimitiveType ( ) const
inlinevirtual

Get primitive type determining how vertices in vector returned by getOutlinePrimitiveType() form lines.

Reimplemented in SphericalConvexPolygon.

Definition at line 344 of file StelSphereGeometry.hpp.

virtual const QVector<Vec3d>& SphericalRegion::getOutlineVertexPositions ( ) const
inlinevirtual

Get the outline of the contours defining the SphericalPolygon.

Returns
a list of vertices which define the contours of the polygon.

Reimplemented in SphericalConvexPolygon.

Definition at line 333 of file StelSphereGeometry.hpp.

virtual Vec3d SphericalRegion::getPointInside ( ) const
inlinevirtual

Return a point located inside the region.

Reimplemented in SphericalConvexPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

Definition at line 301 of file StelSphereGeometry.hpp.

virtual QVector<QVector<Vec3d > > SphericalRegion::getSimplifiedContours ( ) const
virtual

Get the contours defining the SphericalPolygon when combined using a positive winding rule.

The default implementation return a list of tesselated triangles derived from the OctahedronPolygon.

SphericalRegionP SphericalRegion::getSubtraction ( const SphericalRegion r) const

Return a new SphericalRegion consisting of the subtraction of the given region from this.

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

SphericalRegionP SphericalRegion::getUnion ( const SphericalRegion r) const

Return a new SphericalRegion consisting of the union of this and the given region.

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

bool SphericalRegion::intersects ( const SphericalRegion r) const

Returns whether a SphericalRegion intersects with this region.

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

virtual bool SphericalRegion::isEmpty ( ) const
inlinevirtual

Return true if the region is empty.

Reimplemented in SphericalConvexPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

Definition at line 298 of file StelSphereGeometry.hpp.

virtual bool SphericalRegion::needToUpdateFillVertexBuffers ( ) const
inlineprotectedvirtual

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 the full logic to determine this (e.g. we always update when subdividing is enabled).

Reimplemented in SphericalConvexPolygon.

Definition at line 472 of file StelSphereGeometry.hpp.

virtual void SphericalRegion::serialize ( QDataStream &  out) const
pure virtual

Serialize the region. This method must allow as fast as possible serialization and work with deserialize().

Implemented in SphericalTexturedConvexPolygon, SphericalConvexPolygon, SphericalPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

QByteArray SphericalRegion::toJSON ( ) const

Output a JSON string representing the polygon.

This method is convenient for debugging.

virtual QVariantList SphericalRegion::toQVariant ( ) const
pure virtual

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

Implemented in SphericalTexturedConvexPolygon, SphericalConvexPolygon, SphericalPolygon, EmptySphericalRegion, AllSkySphericalRegion, SphericalPoint, and SphericalCap.

virtual void SphericalRegion::updateFillVertexBuffer ( class StelRenderer renderer,
const DrawParams params,
bool  handleDiscontinuity 
)
protectedvirtual

Update the vertex buffer used by drawFill().

Called when drawing parameters have changed, or when we cannot cache vertices (e.g. when subdividing and this projecting outside Renderer).

Parameters
rendererRenderer to create vertex buffer.
paramsParameters used for drawing (which also affect vertex generation).
handleDiscontinuityDo we need to ensure that no triangles cross a projection discontinuity?

Reimplemented in SphericalTexturedConvexPolygon, and SphericalConvexPolygon.

Member Data Documentation

StelVertexBuffer<PlainVertex>* SphericalRegion::fillPlainVertexBuffer
protected

Cached plain vertex buffer for drawing.

Definition at line 439 of file StelSphereGeometry.hpp.

bool SphericalRegion::useProjector
protected

Should Renderer draw calls specify a projector?

This is true unless we've projected the vertices ourselves (which is the case when we're subdividing the region into smaller triangles.)

Definition at line 445 of file StelSphereGeometry.hpp.


The documentation for this class was generated from the following file: