OctahedronPolygon.hpp   OctahedronPolygon.hpp 
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _OCTAHEDRON_REGION_HPP_ #ifndef _OCTAHEDRON_REGION_HPP_
#define _OCTAHEDRON_REGION_HPP_ #define _OCTAHEDRON_REGION_HPP_
#include <QVector> #include <QVector>
#include <QDebug> #include <QDebug>
#include <QVarLengthArray> #include <QVarLengthArray>
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelVertexArray.hpp"
//! @struct EdgeVertex //! @struct EdgeVertex
//! Describe a vertex composing polygon contours, and whether it belong to an edge or not. //! Describe a vertex composing polygon contours, and whether it belong to an edge or not.
struct EdgeVertex struct EdgeVertex
{ {
EdgeVertex() : edgeFlag(false) {;} EdgeVertex() : edgeFlag(false) {;}
EdgeVertex(bool b) : edgeFlag(b) {;} EdgeVertex(bool b) : edgeFlag(b) {;}
EdgeVertex(const Vec3d& v, bool b) : vertex(v), edgeFlag(b) {;} EdgeVertex(const Vec3d& v, bool b) : vertex(v), edgeFlag(b) {;}
//! The normalized vertex direction. //! The normalized vertex direction.
Vec3d vertex; Vec3d vertex;
skipping to change at line 60 skipping to change at line 59
// Create a SubContour from a list of vertices // Create a SubContour from a list of vertices
SubContour(const QVector<Vec3d>& vertices, bool closed=true); SubContour(const QVector<Vec3d>& vertices, bool closed=true);
SubContour() {;} SubContour() {;}
SubContour(int size, const EdgeVertex& v) : QVector<EdgeVertex>(size , v) {;} SubContour(int size, const EdgeVertex& v) : QVector<EdgeVertex>(size , v) {;}
SubContour reversed() const; SubContour reversed() const;
QString toJSON() const; QString toJSON() const;
}; };
//! @class OctahedronContour //! @class OctahedronContour
//! Manage a non-convex polygon which can extends on more than 180 deg. //! Manage a non-convex polygon which can extends on more than 180 deg.
//! The contours defining the polygon are splitted and projected on the 8 s ides of an Octahedron to enable 2D geometry //! The contours defining the polygon are split and projected on the 8 side s of an Octahedron to enable 2D geometry
//! algorithms to be used. //! algorithms to be used.
class OctahedronPolygon class OctahedronPolygon
{ {
public: public:
OctahedronPolygon() : fillCachedVertexArray(StelVertexArray::Triangl OctahedronPolygon()
es), outlineCachedVertexArray(StelVertexArray::Lines), capN(1,0,0), capD(-2 : capN(1,0,0)
.) , capD(-2.)
{sides.resize(8);} {
sides.resize(8);
}
//! Create the OctahedronContour by splitting the passed SubContour on the 8 sides of the octahedron. //! Create the OctahedronContour by splitting the passed SubContour on the 8 sides of the octahedron.
OctahedronPolygon(const SubContour& subContour); OctahedronPolygon(const SubContour& subContour);
OctahedronPolygon(const QVector<QVector<Vec3d> >& contours); OctahedronPolygon(const QVector<QVector<Vec3d> >& contours);
OctahedronPolygon(const QVector<Vec3d>& contour); OctahedronPolygon(const QVector<Vec3d>& contour);
OctahedronPolygon(const QList<OctahedronPolygon>& octContours); OctahedronPolygon(const QList<OctahedronPolygon>& octContours);
double getArea() const; double getArea() const;
Vec3d getPointInside() const; Vec3d getPointInside() const;
//! Returns the list of triangles resulting from tesselating the con
tours.
StelVertexArray getFillVertexArray() const {return fillCachedVertexA
rray;}
StelVertexArray getOutlineVertexArray() const {return outlineCachedV
ertexArray;}
void getBoundingCap(Vec3d& v, double& d) const {v=capN; d=capD;} void getBoundingCap(Vec3d& v, double& d) const {v=capN; d=capD;}
//! Set this OctahedronContourOctahedronPolygonion of itself with th e given OctahedronContour. //! Set this OctahedronContourOctahedronPolygonion of itself with th e given OctahedronContour.
void inPlaceIntersection(const OctahedronPolygon& mpoly); void inPlaceIntersection(const OctahedronPolygon& mpoly);
//! Set this OctahedronContour as the union of itself with the given OctahedronContour. //! Set this OctahedronContour as the union of itself with the given OctahedronContour.
void inPlaceUnion(const OctahedronPolygon& mpoly); void inPlaceUnion(const OctahedronPolygon& mpoly);
//! Set this OctahedronContour as the subtraction of itself with the given OctahedronContour. //! Set this OctahedronContour as the subtraction of itself with the given OctahedronContour.
void inPlaceSubtraction(const OctahedronPolygon& mpoly); void inPlaceSubtraction(const OctahedronPolygon& mpoly);
bool intersects(const OctahedronPolygon& mpoly) const; bool intersects(const OctahedronPolygon& mpoly) const;
bool contains(const OctahedronPolygon& mpoly) const; bool contains(const OctahedronPolygon& mpoly) const;
bool contains(const Vec3d& p) const; bool contains(const Vec3d& p) const;
bool isEmpty() const; bool isEmpty() const;
static const OctahedronPolygon& getAllSkyOctahedronPolygon(); static const OctahedronPolygon& getAllSkyOctahedronPolygon();
static const OctahedronPolygon& getEmptyOctahedronPolygon() {static static const OctahedronPolygon& getEmptyOctahedronPolygon()
OctahedronPolygon poly; return poly;} {
static OctahedronPolygon poly; return poly;
}
static double sphericalTriangleArea(const Vec3d& v0, const Vec3d& v1 , const Vec3d& v2) static double sphericalTriangleArea(const Vec3d& v0, const Vec3d& v1 , const Vec3d& v2)
{ {
const Vec3d& p1 = v0 ^ v1; const Vec3d& p1 = v0 ^ v1;
const Vec3d& p2 = v1 ^ v2; const Vec3d& p2 = v1 ^ v2;
const Vec3d& p3 = v2 ^ v0; const Vec3d& p3 = v2 ^ v0;
return 2.*M_PI - p1.angle(p2) - p2.angle(p3) - p3.angle(p1); return 2.*M_PI - p1.angle(p2) - p2.angle(p3) - p3.angle(p1);
} }
QString toJson() const; QString toJson() const;
//! Get vertices forming triangles filling out the polygon.
const QVector<Vec3d>& fillVertices() const
{
return fillCachedVertexArray;
}
//! Get vertices forming lines outlining the polygon.
const QVector<Vec3d>& outlineVertices() const
{
return outlineCachedVertexArray;
}
private: private:
// For unit tests // For unit tests
friend class TestStelSphericalGeometry; friend class TestStelSphericalGeometry;
friend QDataStream& operator<<(QDataStream&, const OctahedronPolygon &); friend QDataStream& operator<<(QDataStream&, const OctahedronPolygon &);
friend QDataStream& operator>>(QDataStream&, OctahedronPolygon&); friend QDataStream& operator>>(QDataStream&, OctahedronPolygon&);
friend OctahedronPolygon createAllSkyOctahedronPolygon(); friend OctahedronPolygon createAllSkyOctahedronPolygon();
//! Creates a full Octahedron. //! Creates a full Octahedron.
static OctahedronPolygon createAllSkyOctahedronPolygon(); static OctahedronPolygon createAllSkyOctahedronPolygon();
skipping to change at line 144 skipping to change at line 158
//! Tesselate the contours per side, producing a list of triangles s ubcontours according to the given rule. //! Tesselate the contours per side, producing a list of triangles s ubcontours according to the given rule.
void tesselate(TessWindingRule rule); void tesselate(TessWindingRule rule);
QVector<SubContour> tesselateOneSideLineLoop(struct GLUEStesselator* tess, int sidenb) const; QVector<SubContour> tesselateOneSideLineLoop(struct GLUEStesselator* tess, int sidenb) const;
QVector<Vec3d> tesselateOneSideTriangles(struct GLUEStesselator* tes s, int sidenb) const; QVector<Vec3d> tesselateOneSideTriangles(struct GLUEStesselator* tes s, int sidenb) const;
QVarLengthArray<QVector<SubContour>,8 > sides; QVarLengthArray<QVector<SubContour>,8 > sides;
//! Update the content of both cached vertex arrays. //! Update the content of both cached vertex arrays.
void updateVertexArray(); void updateVertexArray();
StelVertexArray fillCachedVertexArray;
StelVertexArray outlineCachedVertexArray; //! Vertex array storing triangles of the polygon (each 3 vertices b
eing one triangle).
QVector<Vec3d> fillCachedVertexArray;
//! Vertex array storing lines of the polygon outline (each 2 vertic
es being one line).
QVector<Vec3d> outlineCachedVertexArray;
void computeBoundingCap(); void computeBoundingCap();
Vec3d capN; Vec3d capN;
double capD; double capD;
static const Vec3d sideDirections[]; static const Vec3d sideDirections[];
static int getSideNumber(const Vec3d& v) {return v[0]>=0. ? (v[1]>= 0. ? (v[2]>=0.?0:1) : (v[2]>=0.?4:5)) : (v[1]>=0. ? (v[2]>=0.?2:3) : (v [2]>=0.?6:7));} static int getSideNumber(const Vec3d& v) {return v[0]>=0. ? (v[1]>= 0. ? (v[2]>=0.?0:1) : (v[2]>=0.?4:5)) : (v[1]>=0. ? (v[2]>=0.?2:3) : (v [2]>=0.?6:7));}
static bool isTriangleConvexPositive2D(const Vec3d& a, const Vec3d& b, const Vec3d& c); static bool isTriangleConvexPositive2D(const Vec3d& a, const Vec3d& b, const Vec3d& c);
static bool triangleContains2D(const Vec3d& a, const Vec3d& b, const Vec3d& c, const Vec3d& p); static bool triangleContains2D(const Vec3d& a, const Vec3d& b, const Vec3d& c, const Vec3d& p);
static void projectOnOctahedron(QVarLengthArray<QVector<SubContour>, 8 >& inSides); static void projectOnOctahedron(QVarLengthArray<QVector<SubContour>, 8 >& inSides);
 End of changes. 7 change blocks. 
17 lines changed or deleted 31 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/