contrib/brl/bbas/bvgl/bvgl_triangle_3d.h
Go to the documentation of this file.
00001 // This is brl/bbas/bvgl/bvgl_triangle_3d.h
00002 #ifndef bvgl_triangle_h_
00003 #define bvgl_triangle_h_
00004 //:
00005 // \file
00006 // \brief simple 3d triangle
00007 // \author Jan 30, 2012 Andrew Miller
00008 //
00009 
00010 #include <vgl/vgl_point_3d.h>
00011 #include <vcl_vector.h>
00012 #include <vcl_iosfwd.h>
00013 
00014 template <class Type>
00015 class bvgl_triangle_3d
00016 {
00017  public:
00018 
00019   //: Default constructor (creates empty triangle)
00020   bvgl_triangle_3d();
00021 
00022   //: Construct using two corner points
00023   bvgl_triangle_3d( vgl_point_3d<Type> const& corner1,
00024                     vgl_point_3d<Type> const& corner2,
00025                     vgl_point_3d<Type> const& corner3);
00026 
00027   //: access points
00028   vgl_point_3d<Type>        operator[](int index) { return points_[index]; }
00029   //: access points
00030   vgl_point_3d<Type> const& operator[](int index) const { return points_[index]; }
00031 
00032   // ----- IO --------
00033 
00034   //: Write "<vgl_box_3d x0,y0,z0 to x1,y1,z1>" to stream
00035   vcl_ostream& print(vcl_ostream&) const;
00036 
00037   //: Write "x0 y0 z0 x1 y1 z1(endl)" to stream
00038   vcl_ostream& write(vcl_ostream&) const;
00039 
00040   //: Read x0,y0,z0,x1,y1,z1 from stream
00041   vcl_istream& read(vcl_istream&);
00042 
00043  private:
00044   vgl_point_3d<Type> points_[3];
00045 };
00046 
00047 template <class Type>
00048 vcl_ostream&  operator<<(vcl_ostream& s, bvgl_triangle_3d<Type> const& p);
00049 
00050 //: Read box from stream
00051 template <class Type>
00052 vcl_istream&  operator>>(vcl_istream& is,  bvgl_triangle_3d<Type>& p);
00053 
00054 #define BVGL_TRIANGLE_3D(T) extern "please include bbas/bvgl/bvgl_triangle_3d.txx first"
00055 
00056 #endif // bvgl_triangle_h_