GeodesicGrid.hpp   StelGeodesicGrid.hpp 
/* /*
GeodesicGrid: a library for dividing the sphere into triangle zones StelGeodesicGrid: a library for dividing the sphere into triangle zones
by subdividing the icosahedron by subdividing the icosahedron
Author and Copyright: Johannes Gajdosik, 2006 Author and Copyright: Johannes Gajdosik, 2006
This library requires a simple Vector library, This library requires a simple Vector library,
which may have different copyright and license, which may have different copyright and license,
for example Vec3d from vecmath.h. for example Vec3d from VecMath.hpp.
In the moment I choose to distribute the library under the GPL, In the moment I choose to distribute the library under the GPL,
later I may choose to additionally distribute it under a more later I may choose to additionally distribute it under a more
relaxed license like the LGPL. If you want to have the library relaxed license like the LGPL. If you want to have the library
under another license, please ask me. under another license, please ask me.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
skipping to change at line 33 skipping to change at line 33
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 library; if not, write to the Free Software along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _GEODESICGRID_HPP_ #ifndef _STELGEODESICGRID_HPP_
#define _GEODESICGRID_HPP_ #define _STELGEODESICGRID_HPP_
#include "SphereGeometry.hpp" #include "StelSphereGeometry.hpp"
class GeodesicSearchResult; class GeodesicSearchResult;
class GeodesicGrid class StelGeodesicGrid
{ {
// Grid of triangles (zones) on the sphere with radius 1, // Grid of triangles (zones) on the sphere with radius 1,
// generated by subdividing the icosahedron. // generated by subdividing the icosahedron.
// level 0: just the icosahedron, 20 zones // level 0: just the icosahedron, 20 zones
// level 1: 80 zones, level 2: 320 zones, ... // level 1: 80 zones, level 2: 320 zones, ...
// Each zone has a unique integer number in the range // Each zone has a unique integer number in the range
// [0,getNrOfZones()-1]. // [0,getNrOfZones()-1].
public: public:
GeodesicGrid(int maxLevel); StelGeodesicGrid(int maxLevel);
~GeodesicGrid(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^level {return (20<<(level<<1));} // 20*4^level
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 //! 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; void getTriangleCorners(int lev, int index, Vec3d& c0, Vec3d& c1, Ve c3d& c2) const;
skipping to change at line 147 skipping to change at line 147
//! 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 StelGeom::ConvexS lastSearchRegion;
}; };
class GeodesicSearchResult class GeodesicSearchResult
{ {
public: public:
GeodesicSearchResult(const GeodesicGrid &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 GeodesicGrid; friend class StelGeodesicGrid;
void search(const StelGeom::ConvexS& convex, int maxSearchLevel); void search(const StelGeom::ConvexS& convex, int maxSearchLevel);
const GeodesicGrid &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:
GeodesicSearchBorderIterator(const GeodesicSearchResult &r,int level ) GeodesicSearchBorderIterator(const GeodesicSearchResult &r,int level )
: r(r),level((level<0)?0:(level>r.grid.getMaxLevel()) : r(r),level((level<0)?0:(level>r.grid.getMaxLevel())
?r.grid.getMaxLevel():level), ?r.grid.getMaxLevel():level),
end(r.zones[GeodesicSearchBorderIterator::level]+ end(r.zones[GeodesicSearchBorderIterator::level]+
GeodesicGrid::nrOfZones(GeodesicSearchBorderIter ator::level)) StelGeodesicGrid::nrOfZones(GeodesicSearchBorder Iterator::level))
{reset();} {reset();}
void reset(void) {index = r.border[level];} void reset(void) {index = r.border[level];}
int next(void) // returns -1 when finished int next(void) // returns -1 when finished
{if (index < end) {return *index++;} return -1;} {if (index < end) {return *index++;} return -1;}
private: private:
const GeodesicSearchResult &r; const GeodesicSearchResult &r;
const int level; const int level;
const int *const end; const int *const end;
const int *index; const int *index;
}; };
skipping to change at line 202 skipping to change at line 202
const GeodesicSearchResult &r; const GeodesicSearchResult &r;
const int maxLevel; const int maxLevel;
int level; int level;
int maxCount; int maxCount;
int *indexP; int *indexP;
int *endP; int *endP;
int index; int index;
int count; int count;
}; };
#endif // _GEODESICGRID_HPP_ #endif // _STELGEODESICGRID_HPP_
 End of changes. 11 change blocks. 
12 lines changed or deleted 12 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/