StelSphereGeometry.hpp   StelSphereGeometry.hpp
skipping to change at line 73 skipping to change at line 73
double d; double d;
}; };
//! @class Polygon //! @class Polygon
//! A polygon is defined by a set of connected points. //! A polygon is defined by a set of connected points.
//! The last point is connected to the first one //! The last point is connected to the first one
class Polygon : public std::vector<Vec3d> class Polygon : public std::vector<Vec3d>
{ {
public: public:
//! Default contructor //! Default contructor
Polygon(int size) {} Polygon(int asize = 0) : std::vector<Vec3d>(asize) {}
//! Special constructor for 3 points polygon //! Special constructor for 3 points polygon
Polygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2); Polygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2);
//! Special constructor for 4 points polygon //! Special constructor for 4 points polygon
Polygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2, const Vec3d &e 3); Polygon(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2, const Vec3d &e 3);
}; };
template<class T> template<class T>
bool intersect(const Polygon& p, const T& o) bool intersect(const Polygon& p, const T& o)
{ {
return intersect(o, p); return intersect(o, p);
skipping to change at line 96 skipping to change at line 96
//! @class ConvexS //! @class ConvexS
//! A Convex is defined by several HalfSpaces defining a convex region. //! A Convex is defined by several HalfSpaces defining a convex region.
//! A Convex region is not necessarily a ConvexPolygon, it can for example be a single HalfSpace. //! A Convex region is not necessarily a ConvexPolygon, it can for example be a single HalfSpace.
//! Because in X11, Convex is \#defined as an int in X11/X.h: (\#define Con vex 2) we needed to use another name (ConvexS). //! Because in X11, Convex is \#defined as an int in X11/X.h: (\#define Con vex 2) we needed to use another name (ConvexS).
class ConvexS : public std::vector<HalfSpace> class ConvexS : public std::vector<HalfSpace>
{ {
public: public:
//! copy constructor //! copy constructor
ConvexS(const ConvexS& c) : std::vector<HalfSpace>(c) {} ConvexS(const ConvexS& c) : std::vector<HalfSpace>(c) {}
//! Default constructor //! Default constructor
ConvexS(int size) {} ConvexS(int asize = 0) : std::vector<HalfSpace>(asize) {}
//! Special constructor for 3 halfspaces convex //! Special constructor for 3 halfspaces convex
ConvexS(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2); ConvexS(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2);
//! Special constructor for 4 halfspaces convex //! Special constructor for 4 halfspaces convex
ConvexS(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2, const Vec3d &e 3); ConvexS(const Vec3d &e0,const Vec3d &e1,const Vec3d &e2, const Vec3d &e 3);
//! Tell whether the points of the passed Polygon are all outside of at least one HalfSpace //! Tell whether the points of the passed Polygon are all outside of at least one HalfSpace
bool areAllPointsOutsideOneSide(const Polygon& poly) const bool areAllPointsOutsideOneSide(const Polygon& poly) const
{ {
for (const_iterator iter=begin();iter!=end();++iter) for (const_iterator iter=begin();iter!=end();++iter)
{ {
skipping to change at line 120 skipping to change at line 120
allOutside = allOutside && !iter->contains(* v); allOutside = allOutside && !iter->contains(* v);
} }
if (allOutside) if (allOutside)
return true; return true;
} }
return false; return false;
} }
}; };
//! @class ConvexPolygon //! @class ConvexPolygon
//! A special case of ConvexS for which all HalfSpace have a/2. //! A special case of ConvexS for which all HalfSpace have an aperture of P I/2.
//! The operator [] behave as for a Polygon, i.e. return the vertex positio ns. //! The operator [] behave as for a Polygon, i.e. return the vertex positio ns.
//! To acces the HalfSpaces, use the asConvex() method. //! To acces the HalfSpaces, use the asConvex() method.
class ConvexPolygon : public ConvexS, public Polygon class ConvexPolygon : public ConvexS, public Polygon
{ {
public: public:
//! Default constructor //! Default constructor
ConvexPolygon() {} ConvexPolygon() {}
//! Special constructor for 3 points //! Special constructor for 3 points
skipping to change at line 171 skipping to change at line 171
Polygon& asPolygon() {return static_cast<Polygon&>(*this);} Polygon& asPolygon() {return static_cast<Polygon&>(*this);}
//! Same with const //! Same with const
const Polygon& asPolygon() const {return static_cast<const Polygon&> (*this);} const Polygon& asPolygon() const {return static_cast<const Polygon&> (*this);}
//! Cast to Convex in case of ambiguity //! Cast to Convex in case of ambiguity
ConvexS& asConvex() {return static_cast<ConvexS&>(*this);} ConvexS& asConvex() {return static_cast<ConvexS&>(*this);}
//! Same with const //! Same with const
const ConvexS& asConvex() const {return static_cast<const ConvexS&>( *this);} const ConvexS& asConvex() const {return static_cast<const ConvexS&>( *this);}
//! Check if the polygon is valid, i.e. it has no side >180 etc
bool checkValid() const;
//! Special case for degenerated polygons (>180 deg), assume full sk
y, i.e. intersect and contains is always true.
static ConvexPolygon fullSky();
}; };
//! We rewrite the intersect for ConvexPolygon //! We rewrite the intersect for ConvexPolygon
inline bool intersect(const ConvexPolygon& cp1, const ConvexPolygon& cp2) inline bool intersect(const ConvexPolygon& cp1, const ConvexPolygon& cp2)
{ {
const ConvexS& c1 = cp1; const ConvexS& c1 = cp1;
const ConvexS& c2 = cp2; const ConvexS& c2 = cp2;
return !c1.areAllPointsOutsideOneSide(cp2) && !c2.areAllPointsOutsid eOneSide(cp1); return !c1.areAllPointsOutsideOneSide(cp2) && !c2.areAllPointsOutsid eOneSide(cp1);
} }
//! @class Disk //! @class Disk
//! A Disk is defined by a single HalfSpace //! A Disk is defined by a single HalfSpace
struct Disk : HalfSpace struct Disk : HalfSpace
{ {
//! Constructor //! Constructor
//! @param n a unit vector indicating the the disk center //! @param n a unit vector indicating the the disk center
//! @param r the disk radius in radian //! @param r the disk radius in radian
Disk(const Vec3d& n, std::cos(r)) Disk(const Vec3d& an, double r) : HalfSpace(an, std::cos(r))
{} {}
}; };
//! We rewrite the intersect for ConvexPolygon //! We rewrite the intersect for ConvexPolygon
inline bool intersect(const ConvexS& cp1, const ConvexPolygon& cp2) inline bool intersect(const ConvexS& cp1, const ConvexPolygon& cp2)
{ {
Q_ASSERT(0); Q_ASSERT(0);
// TODO // TODO
return false; return false;
} }
End of changes. 5 change blocks.
4 lines changed or deleted 11 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/