contrib/oul/ouml/polygon_mesh.h
Go to the documentation of this file.
00001 // This is oul/ouml/polygon_mesh.h
00002 // Copyright (c) 2001 Brendan McCane University of Otago, Dunedin, New
00003 // Zealand Reproduction rights limited as described in the COPYRIGHT file.
00004 #ifndef OTAGO_polygon_mesh__h_INCLUDED
00005 #define OTAGO_polygon_mesh__h_INCLUDED
00006 //:
00007 // \file
00008 // \brief a class for polygon meshes
00009 //
00010 //----------------------------------------------------------------------
00011 
00012 #include <vgl/vgl_point_3d.h>
00013 #include <vnl/vnl_vector_fixed.h>
00014 #include <vcl_vector.h>
00015 #include <vcl_iosfwd.h>
00016 
00017 class PolygonMesh
00018 {
00019  public:
00020   typedef vgl_point_3d<double> DPoint ;
00021   typedef vnl_vector_fixed<double, 3> DVector3D;
00022   typedef vcl_vector<int> Face; // a face is a list of vertices
00023   typedef vcl_vector<DPoint> Polygon;
00024  private:
00025   vcl_vector<DPoint> vertex_list;
00026   vcl_vector<Face> face_list;
00027 
00028  public:
00029   PolygonMesh(int num_vertices=100, int num_faces=100):
00030     vertex_list(num_vertices), face_list(num_faces){}
00031   int add_vertex(DPoint &pt);
00032   int set_vertex(int index, DPoint &pt);
00033   int add_face(Face &fc);
00034   int set_face(int index, Face &fc);
00035   DPoint get_vertex(int index);
00036   Polygon get_face(int index);
00037   DVector3D get_face_normal(int face_index,
00038                             int vertex_index);
00039   bool read_file(char *filename);
00040   inline int num_faces() const {return face_list.size();}
00041   inline int num_vertices() const {return vertex_list.size();}
00042 };
00043 
00044 vcl_ostream &operator <<(vcl_ostream &os, PolygonMesh &pmesh);
00045 // add these when I can access iostream docs
00046 vcl_istream &operator >>(vcl_istream &is, PolygonMesh &pmesh);
00047 
00048 #endif // OTAGO_polygon_mesh__h_INCLUDED