#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/3D/Mesh/Tri.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2002, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL3D_TRI_HEADER #define RAVL3D_TRI_HEADER 1 ///////////////////////////////////////////////////////////////////////////////////////// //! rcsid="$Id: Tri.hh,v 1.7 2002/07/01 16:21:22 craftit Exp $" //! docentry="Ravl.3D.Mesh" //! lib=Ravl3D //! author="Charles Galambos" //! file="Ravl/3D/Mesh/Tri.hh" #include "Ravl/3D/Vertex.hh" namespace Ravl3DN { #if RAVL_VISUALCPP_NAMESPACE_BUG using namespace RavlN; using RavlN::TFVectorC; using RavlN::Vector2dC; using RavlN::ByteT; #endif //! userlevel=Normal //: Triangle in TriMesh. // Tri's must be associated with a tri set, in the parent // triset goes out of scope the behavour of a tri from // it is undefined. class TriC { public: TriC() { colour[0] = 196; colour[1] = 196; colour[2] = 196; } //: Default constructor. TriC(const TFVectorC &v) : vertices(v) { colour[0] = 196; colour[1] = 196; colour[2] = 196; } //: Construct from another vector. TriC(VertexC &v0,VertexC &v1,VertexC &v2) { vertices[0] = &v0; vertices[1] = &v1; vertices[2] = &v2; colour[0] = 196; colour[1] = 196; colour[2] = 196; } //: Construct from vertices. void Flip(void); //: Flips the triangle. // Reverse the order of the vertices in the triangle. VertexC &Vertex(UIntT ind) { RavlAssert(ind < 3); return *(vertices[ind]); } //: Access vertex. const VertexC &Vertex(UIntT ind) const { return *(vertices[ind]); } //: Access vertex. const Vector3dC &operator[](UIntT ind) const { return vertices[ind]->Position(); } //: Access position of vertex. Vector3dC &operator[](UIntT ind) { return vertices[ind]->Position(); } //: Access position of vertex. const Vector3dC &FaceNormal() const { return normal; } //: Unit normal orthogonal to triangle plane Vector3dC &FaceNormal() { return normal; } //: Unit normal orthogonal to triangle plane Vector3dC &Normal(UIntT n) { return vertices[n]->Normal(); } //: Access normal for a vertex. const Vector3dC Normal(UIntT n) const { return vertices[n]->Normal(); } //: Access normal for a vertex. Vector3dC &Position(UIntT n) { return vertices[n]->Position(); } //: Access normal for a vertex. const Vector3dC Position(UIntT n) const { return vertices[n]->Position(); } //: Access normal for a vertex. void UpdateFaceNormal(); //: Update the face normal. VertexC *&VertexPtr(UIntT n) { return vertices[n]; } //: Access vertex pointer. // Advanced users only. VertexC *VertexPtr(UIntT n) const { return vertices[n]; } //: Access vertex pointer. // Advanced users only. TFVectorC &TextureCoords() { return texture; } //: Access texture co-ordinates. const TFVectorC &TextureCoords() const { return texture; } //: Access texture co-ordinates. TFVectorC &Colour() { return colour; } //: Colour of face. const TFVectorC &Colour() const { return colour; } //: Colour of face. protected: TFVectorC vertices; TFVectorC texture; Vector3dC normal; TFVectorC colour; }; } #endif