StelGeodesicGrid.hpp   StelGeodesicGrid.hpp 
skipping to change at line 40 skipping to change at line 40
*/ */
#ifndef _STELGEODESICGRID_HPP_ #ifndef _STELGEODESICGRID_HPP_
#define _STELGEODESICGRID_HPP_ #define _STELGEODESICGRID_HPP_
#include "StelSphereGeometry.hpp" #include "StelSphereGeometry.hpp"
class GeodesicSearchResult; class GeodesicSearchResult;
//! @class StelGeodesicGrid
//! Grid of triangles (zones) on the sphere with radius 1, generated by sub
dividing the icosahedron.
//! level 0: just the icosahedron, 20 zones
//! level 1: 80 zones, level 2: 320 zones, ...
//! Each zone has a unique integer number in the range [0,getNrOfZones()-1]
.
class StelGeodesicGrid class StelGeodesicGrid
{ {
// Grid of triangles (zones) on the sphere with radius 1,
// generated by subdividing the icosahedron.
// level 0: just the icosahedron, 20 zones
// level 1: 80 zones, level 2: 320 zones, ...
// Each zone has a unique integer number in the range
// [0,getNrOfZones()-1].
public: public:
StelGeodesicGrid(int maxLevel); StelGeodesicGrid(int maxLevel);
~StelGeodesicGrid(void); ~StelGeodesicGrid(void);
int getMaxLevel(void) const {return maxLevel;} int getMaxLevel(void) const {return maxLevel;}
static int nrOfZones(int level) static int nrOfZones(int level) {return (20<<(level<<1));} // 20*4^l
{return (20<<(level<<1));} // 20*4^level evel
int getNrOfZones(void) const {return nrOfZones(maxLevel);} int getNrOfZones(void) const {return nrOfZones(maxLevel);}
//! Return the position of the 3 corners for the triangle at the giv
en level and index
void getTriangleCorners(int lev, int index, Vec3d& c0, Vec3d& c1, Ve
c3d& c2) const;
//! Return the index of the partner triangle with which to form a pa
ralelogram
int getPartnerTriangle(int lev, int index) const;
typedef void (VisitFunc)(int lev,int index, typedef void (VisitFunc)(int lev,int index,
const Vec3d &c0, const Vec3d &c0,
const Vec3d &c1, const Vec3d &c1,
const Vec3d &c2, const Vec3d &c2,
void *context); void *context);
void visitTriangles(int maxVisitLevel, VisitFunc *func,void *context ) const; void visitTriangles(int maxVisitLevel, VisitFunc *func,void *context ) const;
//! Find the zone number in which a given point lies. //! Find the zone number in which a given point lies.
//! prerequisite: v*v==1 //! prerequisite: v*v==1
//! When the point lies on the border of two or more zones, //! When the point lies on the border of two or more zones,
//! one such zone is returned (always the same one, //! one such zone is returned (always the same one,
//! because the algorithm is deterministic). //! because the algorithm is deterministic).
int searchZone(const Vec3d &v,int searchLevel) const; int getZoneNumberForPoint(const Vec3d &v,int searchLevel) const;
//! Return the position of the 3 corners for the triangle at the giv
en level and index
void getTriangleCorners(int lev, int index, Vec3d& c0, Vec3d& c1, Ve
c3d& c2) const;
//! Return the index of the partner triangle with which to form a pa
rallelogram
int getPartnerTriangle(int lev, int index) const;
//! Return a search result matching the given spatial region
//! The result is cached, meaning that it is very fast to search the
same region consecutively
//! @return a GeodesicSearchResult instance which must be used with
GeodesicSearchBorderIterator and GeodesicSearchInsideIterator
const GeodesicSearchResult* search(const QVector<SphericalCap>& conv
ex, int maxSearchLevel) const;
private:
friend class GeodesicSearchResult;
//! Find all zones that lie fully(inside) or partly(border) //! Find all zones that lie fully(inside) or partly(border)
//! in the intersection of the given half spaces. //! in the intersection of the given half spaces.
//! The result is accurate when (0,0,0) lies on the border of //! The result is accurate when (0,0,0) lies on the border of
//! each half space. If this is not the case, //! each half space. If this is not the case,
//! the result may be inaccurate, because it is assumed, that //! the result may be inaccurate, because it is assumed, that
//! a zone lies in a half space when its 3 corners lie in this half space. //! a zone lies in a half space when its 3 corners lie in this half space.
//! inside[l] points to the begin of an integer array of size nrOfZo nes(l), //! inside[l] points to the begin of an integer array of size nrOfZo nes(l),
//! border[l] points to one after the end of the same integer array. //! border[l] points to one after the end of the same integer array.
//! The array will be filled from the beginning with the inside zone numbers //! The array will be filled from the beginning with the inside zone numbers
//! and from the end with the border zone numbers of the given level l //! and from the end with the border zone numbers of the given level l
//! for 0<=l<=getMaxLevel(). //! for 0<=l<=getMaxLevel().
//! inside[l] will not contain zones that are already contained //! inside[l] will not contain zones that are already contained
//! in inside[l1] for some l1 < l. //! in inside[l1] for some l1 < l.
//! In order to restrict search depth set maxSearchLevel < maxLevel, //! In order to restrict search depth set maxSearchLevel < maxLevel,
//! for full search depth set maxSearchLevel = maxLevel, //! for full search depth set maxSearchLevel = maxLevel,
void searchZones(const StelGeom::ConvexS& convex, void searchZones(const QVector<SphericalCap>& convex,
int **inside,int **border,int maxSearchLevel) const int **inside,int **border,int maxSe
; archLevel) const;
//! Return a search result matching the given spatial region
//! The result is cached, meaning that it is very fast to search the
same region consecutively
//! @return a GeodesicSearchResult instance which must be used with
GeodesicSearchBorderIterator and GeodesicSearchInsideIterator
const GeodesicSearchResult* search(const StelGeom::ConvexS& convex,
int maxSearchLevel) const;
//! Convenience function returning a search result matching the give
n spatial region
//! The result is cached, meaning that it is very fast to search the
same region consecutively
//! @return a GeodesicSearchResult instance which must be used with
GeodesicSearchBorderIterator and GeodesicSearchInsideIterator
const GeodesicSearchResult* search(const Vec3d &e0,const Vec3d &e1,c
onst Vec3d &e2,const Vec3d &e3,int maxSearchLevel) const;
private:
const Vec3d& getTriangleCorner(int lev, int index, int cornerNumber) const; const Vec3d& getTriangleCorner(int lev, int index, int cornerNumber) const;
void initTriangle(int lev,int index, void initTriangle(int lev,int index,
const Vec3d &c0, const Vec3d &c0,
const Vec3d &c1, const Vec3d &c1,
const Vec3d &c2); const Vec3d &c2);
void visitTriangles(int lev,int index, void visitTriangles(int lev,int index,
const Vec3d &c0, const Vec3d &c0,
const Vec3d &c1, const Vec3d &c1,
const Vec3d &c2, const Vec3d &c2,
int maxVisitLevel, int maxVisitLevel,
VisitFunc *func, VisitFunc *func,
void *context) const; void *context) const;
void searchZones(int lev,int index, void searchZones(int lev,int index,
const StelGeom::ConvexS& convex, const QVector<SphericalCap>& convex,
const int *indexOfUsedHalfSpaces, const int *indexOfUsedSphericalCaps,
const int halfSpacesUsed, const int halfSpacesUsed,
const bool *corner0_inside, const bool *corner0_inside,
const bool *corner1_inside, const bool *corner1_inside,
const bool *corner2_inside, const bool *corner2_inside,
int **inside,int **border,int maxSearchLevel) const ; int **inside,int **border,int maxSearchLevel) const ;
const int maxLevel; const int maxLevel;
struct Triangle struct Triangle
{ {
Vec3d e0,e1,e2; // Seitenmittelpunkte Vec3d e0,e1,e2; // Seitenmittelpunkte
}; };
Triangle **triangles; Triangle **triangles;
// 20*(4^0+4^1+...+4^n)=20*(4*(4^n)-1)/3 triangles total // 20*(4^0+4^1+...+4^n)=20*(4*(4^n)-1)/3 triangles total
// 2+10*4^n corners // 2+10*4^n corners
//! A cached search result used to avoid doing twice the same search //! A cached search result used to avoid doing twice the same search
mutable GeodesicSearchResult* cacheSearchResult; mutable GeodesicSearchResult* cacheSearchResult;
mutable int lastMaxSearchlevel; mutable int lastMaxSearchlevel;
mutable StelGeom::ConvexS lastSearchRegion; mutable QVector<SphericalCap> lastSearchRegion;
}; };
class GeodesicSearchResult class GeodesicSearchResult
{ {
public: public:
GeodesicSearchResult(const StelGeodesicGrid &grid); GeodesicSearchResult(const StelGeodesicGrid &grid);
~GeodesicSearchResult(void); ~GeodesicSearchResult(void);
void print(void) const; void print(void) const;
private: private:
friend class GeodesicSearchInsideIterator; friend class GeodesicSearchInsideIterator;
friend class GeodesicSearchBorderIterator; friend class GeodesicSearchBorderIterator;
friend class StelGeodesicGrid; friend class StelGeodesicGrid;
void search(const StelGeom::ConvexS& convex, int maxSearchLevel); void search(const QVector<SphericalCap>& convex, int maxSearchLevel) ;
const StelGeodesicGrid &grid; const StelGeodesicGrid &grid;
int **const zones; int **const zones;
int **const inside; int **const inside;
int **const border; int **const border;
}; };
class GeodesicSearchBorderIterator class GeodesicSearchBorderIterator
{ {
public: public:
 End of changes. 11 change blocks. 
43 lines changed or deleted 37 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/