00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HALFEDGE_H__
00022 #define __HALFEDGE_H__
00023
00024 #include <ostream>
00025 #include "vector3.h"
00026
00027 namespace HE
00028 {
00029 class Vertex;
00030 class Face;
00031
00042 class HalfEdge
00043 {
00044 public:
00046 explicit HalfEdge(Vertex* v, Face* f, HalfEdge* t, HalfEdge* n)
00047 : _dst(v), _face(f), _twin(t), _next(n) {}
00049 explicit HalfEdge(Vertex* v, Face* f)
00050 : _dst(v), _face(f), _twin(0), _next(0) {}
00051
00052
00053 void next(HalfEdge* n) { _next = n; }
00054 void twin(HalfEdge* p) { _twin = p; }
00055 void face(Face* f) { _face = f; }
00056 void dst(Vertex* v) { _dst = v; }
00057
00058
00059 HalfEdge* next() { return _next; }
00060 const HalfEdge* next() const { return _next; }
00061 HalfEdge* prev();
00062 const HalfEdge* prev() const;
00063 HalfEdge* twin() { return _twin; }
00064 const HalfEdge* twin() const { return _twin; }
00065 Face* face() { return _face; }
00066 const Face* face() const { return _face; }
00067 Vertex* dst() { return _dst; }
00068 const Vertex* dst() const { return _dst; }
00069
00071 Vertex* src() { return _twin->dst(); }
00073 const Vertex* src() const { return _twin->dst(); }
00074
00075
00076 Geometry::Vector3Df normal() const;
00077 Geometry::Vector3Df tangent() const;
00078 Geometry::Vector3Df midpoint() const;
00079 float squaredLength() const { return tangent().squaredModule(); }
00080 float length() const { return tangent().module(); }
00081 bool isBoundary() const;
00082
00083 protected:
00084 Vertex* _dst;
00085 Face* _face;
00086 HalfEdge* _twin;
00087 HalfEdge* _next;
00088 };
00089
00091 std::ostream& operator<< (std::ostream& out, const HalfEdge& he);
00092 };
00093
00094 #endif // __HALFEDGE_H__