00001 // This is gel/vsol/vsol_rectangle_3d.h 00002 #ifndef vsol_rectangle_3d_h_ 00003 #define vsol_rectangle_3d_h_ 00004 //***************************************************************************** 00005 //: 00006 // \file 00007 // \brief Rectangle in 3D space 00008 // 00009 // The 3 vertices are to be defined in counterclockwise order, 00010 // with a 90 degree corner between v1-v2 and v1-v3. 00011 // 00012 // \author François BERTEL 00013 // \date 2000-05-08 00014 // 00015 // \verbatim 00016 // Modifications 00017 // 2000-05-08 François BERTEL Creation 00018 // 2000-06-17 Peter Vanroose Implemented all operator==()s and type info 00019 // 2001-07-03 Peter Vanroose Replaced vnl_double_3 by vgl_vector_3d 00020 // 2004-05-14 Peter Vanroose Added describe() 00021 // 2004-09-06 Peter Vanroose Added Binary I/O 00022 // \endverbatim 00023 //***************************************************************************** 00024 00025 #include <vsol/vsol_polygon_3d.h> 00026 #include <vsol/vsol_point_3d_sptr.h> 00027 #include <vgl/vgl_fwd.h> 00028 #include <vcl_iosfwd.h> 00029 00030 class vsol_rectangle_3d : public vsol_polygon_3d 00031 { 00032 public: 00033 //*************************************************************************** 00034 // Initialization 00035 //*************************************************************************** 00036 00037 //--------------------------------------------------------------------------- 00038 //: Constructor from 3 points. 00039 // `new_p0' is the origin of the rectangle. `new_p1' defines the abscissa 00040 // axis and the width. `new_p2' defines the ordinate axis and the height. 00041 // REQUIRE: valid_vertices(new_p0,new_p1,new_p2) 00042 //--------------------------------------------------------------------------- 00043 vsol_rectangle_3d(vsol_point_3d_sptr const& new_p0, 00044 vsol_point_3d_sptr const& new_p1, 00045 vsol_point_3d_sptr const& new_p2); 00046 00047 //--------------------------------------------------------------------------- 00048 //: Copy constructor 00049 //--------------------------------------------------------------------------- 00050 vsol_rectangle_3d(vsol_rectangle_3d const& other); 00051 00052 //--------------------------------------------------------------------------- 00053 //: Destructor 00054 //--------------------------------------------------------------------------- 00055 virtual ~vsol_rectangle_3d(); 00056 00057 //--------------------------------------------------------------------------- 00058 //: Clone `this': creation of a new object and initialization 00059 // See Prototype pattern 00060 //--------------------------------------------------------------------------- 00061 virtual vsol_spatial_object_3d* clone(void) const; 00062 00063 //*************************************************************************** 00064 // Access 00065 //*************************************************************************** 00066 00067 //--------------------------------------------------------------------------- 00068 //: Return the first vertex 00069 //--------------------------------------------------------------------------- 00070 vsol_point_3d_sptr p0(void) const; 00071 00072 //--------------------------------------------------------------------------- 00073 //: Return the second vertex 00074 //--------------------------------------------------------------------------- 00075 vsol_point_3d_sptr p1(void) const; 00076 00077 //--------------------------------------------------------------------------- 00078 //: Return the third vertex 00079 //--------------------------------------------------------------------------- 00080 vsol_point_3d_sptr p2(void) const; 00081 00082 //--------------------------------------------------------------------------- 00083 //: Return the last vertex 00084 //--------------------------------------------------------------------------- 00085 vsol_point_3d_sptr p3(void) const; 00086 00087 //*************************************************************************** 00088 // Comparison 00089 //*************************************************************************** 00090 00091 //--------------------------------------------------------------------------- 00092 //: Has `this' the same points than `other' in the same order ? 00093 //--------------------------------------------------------------------------- 00094 virtual bool operator==(vsol_rectangle_3d const& other) const; 00095 inline bool operator!=(vsol_rectangle_3d const& other)const{return !operator==(other);} 00096 virtual bool operator==(vsol_polygon_3d const& other) const; // virtual of vsol_polygon_3d 00097 virtual bool operator==(vsol_spatial_object_3d const& obj) const; // virtual of vsol_spatial_object_3d 00098 00099 //*************************************************************************** 00100 // Status report 00101 //*************************************************************************** 00102 00103 //--------------------------------------------------------------------------- 00104 //: Return the width 00105 //--------------------------------------------------------------------------- 00106 double width(void) const; 00107 00108 //--------------------------------------------------------------------------- 00109 //: Return the height 00110 //--------------------------------------------------------------------------- 00111 double height(void) const; 00112 00113 //--------------------------------------------------------------------------- 00114 //: Return the area of `this' 00115 //--------------------------------------------------------------------------- 00116 virtual double area(void) const; 00117 00118 //--------------------------------------------------------------------------- 00119 //: Are `new_vertices' valid to build a rectangle ? 00120 //--------------------------------------------------------------------------- 00121 virtual bool valid_vertices(const vcl_vector<vsol_point_3d_sptr> new_vertices) const; 00122 00123 //*************************************************************************** 00124 // Basic operations 00125 //*************************************************************************** 00126 00127 //--------------------------------------------------------------------------- 00128 //: Is `p' in `this' ? 00129 //--------------------------------------------------------------------------- 00130 virtual bool in(vsol_point_3d_sptr const& p) const; 00131 00132 //--------------------------------------------------------------------------- 00133 //: Return the unit normal vector at point `p'. Have to be deleted manually 00134 // REQUIRE: in(p) 00135 //--------------------------------------------------------------------------- 00136 virtual vgl_vector_3d<double> normal_at_point(vsol_point_3d_sptr const& p) const; 00137 00138 // ==== Binary IO methods ====== 00139 00140 //: Binary save self to stream. 00141 void b_write(vsl_b_ostream &os) const; 00142 00143 //: Binary load self from stream. 00144 void b_read(vsl_b_istream &is); 00145 00146 //: Return IO version number; 00147 short version() const; 00148 00149 //: Print an ascii summary to the stream 00150 void print_summary(vcl_ostream &os) const; 00151 00152 //: Return a platform independent string identifying the class 00153 virtual vcl_string is_a() const { return "vsol_rectangle_3d"; } 00154 00155 //: Return true if the argument matches the string identifying the class or any parent class 00156 virtual bool is_class(const vcl_string& cls) const 00157 { return cls==is_a() || vsol_polygon_3d::is_class(cls); } 00158 00159 //--------------------------------------------------------------------------- 00160 //: output description to stream 00161 //--------------------------------------------------------------------------- 00162 void describe(vcl_ostream &strm, int blanking=0) const; 00163 }; 00164 00165 #endif // vsol_rectangle_3d_h_