20 #ifndef _OCTAHEDRON_REGION_HPP_
21 #define _OCTAHEDRON_REGION_HPP_
25 #include <QVarLengthArray>
26 #include "VecMath.hpp"
42 Q_DECLARE_TYPEINFO(
EdgeVertex, Q_PRIMITIVE_TYPE);
51 SubContour(
const QVector<Vec3d>& vertices,
bool closed=
true);
55 QString toJSON()
const;
78 double getArea()
const;
80 Vec3d getPointInside()
const;
82 void getBoundingCap(
Vec3d& v,
double& d)
const {v=capN; d=capD;}
94 bool contains(
const Vec3d& p)
const;
103 static double sphericalTriangleArea(
const Vec3d& v0,
const Vec3d& v1,
const Vec3d& v2)
105 const Vec3d& p1 = v0 ^ v1;
106 const Vec3d& p2 = v1 ^ v2;
107 const Vec3d& p3 = v2 ^ v0;
108 return 2.*M_PI - p1.angle(p2) - p2.angle(p3) - p3.angle(p1);
111 QString toJson()
const;
116 return fillCachedVertexArray;
122 return outlineCachedVertexArray;
140 void appendSubContour(
const SubContour& contour);
148 bool sideContains2D(
const Vec3d& p,
int sideNb)
const;
151 void tesselate(TessWindingRule rule);
153 QVector<SubContour> tesselateOneSideLineLoop(
struct GLUEStesselator* tess,
int sidenb)
const;
154 QVector<Vec3d> tesselateOneSideTriangles(
struct GLUEStesselator* tess,
int sidenb)
const;
155 QVarLengthArray<QVector<SubContour>,8 > sides;
158 void updateVertexArray();
161 QVector<Vec3d> fillCachedVertexArray;
163 QVector<Vec3d> outlineCachedVertexArray;
165 void computeBoundingCap();
169 static const Vec3d sideDirections[];
170 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));}
171 static bool isTriangleConvexPositive2D(
const Vec3d& a,
const Vec3d& b,
const Vec3d& c);
174 static void projectOnOctahedron(QVarLengthArray<QVector<SubContour>,8 >& inSides);
175 static void splitContourByPlan(
int onLine,
const SubContour& contour, QVector<SubContour> result[2]);
182 #endif // _OCTAHEDRON_REGION_HPP_