20 #ifndef _OCTAHEDRON_REGION_HPP_ 21 #define _OCTAHEDRON_REGION_HPP_ 23 #include "StelVertexArray.hpp" 24 #include "VecMath.hpp" 28 #include <QVarLengthArray> 43 Q_DECLARE_TYPEINFO(
EdgeVertex, Q_PRIMITIVE_TYPE);
52 SubContour(
const QVector<Vec3d>& vertices,
bool closed=
true);
56 QString toJSON()
const;
66 OctahedronPolygon() : fillCachedVertexArray(StelVertexArray::Triangles), outlineCachedVertexArray(StelVertexArray::Lines), capN(1,0,0), capD(-2.)
75 double getArea()
const;
77 Vec3d getPointInside()
const;
81 StelVertexArray getOutlineVertexArray()
const {
return outlineCachedVertexArray;}
83 void getBoundingCap(
Vec3d& v,
double& d)
const {v=capN; d=capD;}
95 bool contains(
const Vec3d& p)
const;
101 static double sphericalTriangleArea(
const Vec3d& v0,
const Vec3d& v1,
const Vec3d& v2)
103 const Vec3d& p1 = v0 ^ v1;
104 const Vec3d& p2 = v1 ^ v2;
105 const Vec3d& p3 = v2 ^ v0;
106 return 2.*M_PI - p1.angle(p2) - p2.angle(p3) - p3.angle(p1);
109 QString toJson()
const;
126 void appendSubContour(
const SubContour& contour);
134 bool sideContains2D(
const Vec3d& p,
int sideNb)
const;
137 void tesselate(TessWindingRule rule);
139 QVector<SubContour> tesselateOneSideLineLoop(
struct GLUEStesselator* tess,
int sidenb)
const;
140 QVector<Vec3d> tesselateOneSideTriangles(
struct GLUEStesselator* tess,
int sidenb)
const;
141 QVarLengthArray<QVector<SubContour>,8 > sides;
144 void updateVertexArray();
147 void computeBoundingCap();
151 static const Vec3d sideDirections[];
152 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));}
153 static bool isTriangleConvexPositive2D(
const Vec3d& a,
const Vec3d& b,
const Vec3d& c);
156 static void projectOnOctahedron(QVarLengthArray<QVector<SubContour>,8 >& inSides);
157 static void splitContourByPlan(
int onLine,
const SubContour& contour, QVector<SubContour> result[2]);
164 #endif // _OCTAHEDRON_REGION_HPP_ Describe a vertex composing polygon contours, and whether it belong to an edge or not...
Vec3d vertex
The normalized vertex direction.
Manage a non-convex polygon which can extends on more than 180 deg.
StelVertexArray getFillVertexArray() const
Returns the list of triangles resulting from tesselating the contours.
bool edgeFlag
Set to true if the vertex is part of at least one edge segment, i.e. it lays on the boundary of the p...
QDataStream & operator<<(QDataStream &out, const SphericalRegionP ®ion)
Serialize the passed SphericalRegionP into a binary blob.
QDataStream & operator>>(QDataStream &in, SphericalRegionP ®ion)
Load the SphericalRegionP from a binary blob.