1 // This is brl/bbas/bvgl/bvgl_triangle_3d.hxx
2 #ifndef bvgl_triangle_3d_hxx_
3 #define bvgl_triangle_3d_hxx_
4 //:
5 // \file
6
7 #include <iostream>
8 #include <algorithm>
9 #include <cmath>
10 #include "bvgl_triangle_3d.h"
11 #include <vgl/vgl_point_3d.h>
12 #ifdef _MSC_VER
13 # include <vcl_msvc_warnings.h>
14 #endif
15 #include <cassert>
16
17 // Constructors/Destructor---------------------------------------------------
18
19 template <class Type>
bvgl_triangle_3d()20 bvgl_triangle_3d<Type>::bvgl_triangle_3d()
21 {
22 points_[0].set(0,0,0);
23 points_[1].set(0,0,0);
24 points_[2].set(0,0,0);
25 }
26
27 template <class Type>
bvgl_triangle_3d(vgl_point_3d<Type> const & corner1,vgl_point_3d<Type> const & corner2,vgl_point_3d<Type> const & corner3)28 bvgl_triangle_3d<Type>::bvgl_triangle_3d(vgl_point_3d<Type> const& corner1,
29 vgl_point_3d<Type> const& corner2,
30 vgl_point_3d<Type> const& corner3)
31 {
32 points_[0] = corner1;
33 points_[1] = corner2;
34 points_[2] = corner3;
35 }
36
37 template <class Type>
print(std::ostream & s) const38 std::ostream& bvgl_triangle_3d<Type>::print(std::ostream& s) const
39 {
40 return s << "<bvgl_triangle_3d "<< ' ' << points_[0] << ' '
41 << points_[1] << ' '
42 << points_[2] << '>';
43 }
44
45 template <class Type>
write(std::ostream & s) const46 std::ostream& bvgl_triangle_3d<Type>::write(std::ostream& s) const
47 {
48 return s << points_[0] << ' ' << points_[1] << ' ' << points_[2] << '>';
49 }
50
51 template <class Type>
read(std::istream & is)52 std::istream& bvgl_triangle_3d<Type>::read(std::istream& is)
53 {
54 return is >> points_[0] >> points_[1] >> points_[2];
55 }
56
57 //: Write box to stream
58 template <class Type>
operator <<(std::ostream & s,bvgl_triangle_3d<Type> const & p)59 std::ostream& operator<<(std::ostream& s, bvgl_triangle_3d<Type> const& p)
60 {
61 return p.print(s);
62 }
63
64 //: Read box from stream
65 template <class Type>
operator >>(std::istream & is,bvgl_triangle_3d<Type> & p)66 std::istream& operator>>(std::istream& is, bvgl_triangle_3d<Type>& p)
67 {
68 return p.read(is);
69 }
70
71 #undef BVGL_TRIANGLE_3D_INSTANTIATE
72 #define BVGL_TRIANGLE_3D_INSTANTIATE(Type) \
73 template class bvgl_triangle_3d<Type >;\
74 template std::ostream& operator<<(std::ostream&, bvgl_triangle_3d<Type > const& p);\
75 template std::istream& operator>>(std::istream&, bvgl_triangle_3d<Type >& p)
76
77 #endif // bvgl_triangle_3d_hxx_
78