// ============================================================================ // // Copyright (c) 1997 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------------- // // release : // release_date : // // file : Triangulation_face_base_2.h // source : $RCSfile$ // revision : $Revision$ // revision_date : $Date$ // author(s) : Mariette Yvinec // // coordinator : Mariette Yvinec // // ============================================================================ #ifndef CGAL_TRIANGULATION_FACE_BASE_2_H #define CGAL_TRIANGULATION_FACE_BASE_2_H #include #include #include CGAL_BEGIN_NAMESPACE template < class Gt > class Triangulation_face_base_2 { public: typedef Triangulation_face_base_2 Face_base; private: void* V[3]; void* N[3]; public: Triangulation_face_base_2(); Triangulation_face_base_2(void* v0, void* v1, void* v2); Triangulation_face_base_2(void* v0, void* v1, void* v2, void* n0, void* n1, void* n2); void* vertex(int i) const; bool has_vertex(const void* v) const; bool has_vertex(const void* v, int& i) const ; int vertex_index(const void* v) const ; void* neighbor(int i) const ; bool has_neighbor(const void* n) const; bool has_neighbor(const void* n, int& i) const; int face_index(const void* n) const; void set_vertex(int i, void* v); void set_vertices(); void set_vertices(void* v0, void* v1, void* v2); void set_neighbor(int i, void* n) ; void set_neighbors(); void set_neighbors(void* n0, void* n1, void* n2); void reorient(); void ccw_permute(); void cw_permute(); int dimension() const; //the following trivial is_valid to allow // the user of derived face base classes // to add their own purpose checking bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const {return true;} }; template Triangulation_face_base_2 :: Triangulation_face_base_2() { set_vertices(); set_neighbors(); } template Triangulation_face_base_2 :: Triangulation_face_base_2( void* v0, void* v1, void* v2) { set_vertices(v0, v1, v2); set_neighbors(); } template Triangulation_face_base_2 :: Triangulation_face_base_2(void* v0, void* v1, void* v2, void* n0, void* n1, void* n2) { set_vertices(v0, v1, v2); set_neighbors(n0, n1, n2); } template inline void* Triangulation_face_base_2 :: vertex(int i) const { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); return V[i]; } template inline bool Triangulation_face_base_2 :: has_vertex(const void* v) const { return (V[0] == v) || (V[1] == v) || (V[2]== v); } template inline bool Triangulation_face_base_2 :: has_vertex(const void* v, int& i) const { if (v == V[0]) { i = 0; return true; } if (v == V[1]) { i = 1; return true; } if (v == V[2]) { i = 2; return true; } return false; } template inline int Triangulation_face_base_2 :: vertex_index(const void* v) const { if (v == V[0]) return 0; if (v == V[1]) return 1; CGAL_triangulation_assertion( v == V[2] ); return 2; } template inline void* Triangulation_face_base_2 :: neighbor(int i) const { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); return N[i]; } template inline bool Triangulation_face_base_2 :: has_neighbor(const void* n) const { return (N[0] == n) || (N[1] == n) || (N[2] == n); } template inline bool Triangulation_face_base_2 :: has_neighbor(const void* n, int& i) const { if(n == N[0]){ i = 0; return true; } if(n == N[1]){ i = 1; return true; } if(n == N[2]){ i = 2; return true; } return false; } template inline int Triangulation_face_base_2 :: face_index(const void* n) const { if (n == N[0]) return 0; if (n == N[1]) return 1; CGAL_triangulation_assertion( n == N[2] ); return 2; } template inline void Triangulation_face_base_2 :: set_vertex(int i, void* v) { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); V[i] = v; } template inline void Triangulation_face_base_2 :: set_neighbor(int i, void* n) { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); N[i] = n; } template inline void Triangulation_face_base_2 :: set_vertices() { V[0] = V[1] = V[2] = NULL; } template inline void Triangulation_face_base_2 :: set_vertices(void* v0, void* v1, void* v2) { V[0] = v0; V[1] = v1; V[2] = v2; } template inline void Triangulation_face_base_2 :: set_neighbors() { N[0] = N[1] = N[2] = NULL; } template inline void Triangulation_face_base_2 :: set_neighbors(void* n0,void* n1, void* n2) { N[0] = n0; N[1] = n1; N[2] = n2; } template void Triangulation_face_base_2 :: reorient() { //exchange the vertices 0 and 1 set_vertices (V[1],V[0],V[2]); set_neighbors(N[1],N[0],N[2]); } template inline void Triangulation_face_base_2 :: ccw_permute() { set_vertices (V[2],V[0],V[1]); set_neighbors(N[2],N[0],N[1]); } template inline void Triangulation_face_base_2 :: cw_permute() { set_vertices (V[1],V[2],V[0]); set_neighbors(N[1],N[2],N[0]); } template < class Gt> inline int Triangulation_face_base_2 :: dimension() const { if (V[2] != NULL) {return 2;} else return( V[1] != NULL ? 1 : 0); } CGAL_END_NAMESPACE #endif //CGAL_TRIANGULATION_FACE_BASE_2_H