00001 /* Copyright (C) 2002 Dominic Letourneau (dominic.letourneau@usherbrooke.ca) 00002 00003 This library is free software; you can redistribute it and/or 00004 modify it under the terms of the GNU Lesser General Public 00005 License as published by the Free Software Foundation; either 00006 version 2.1 of the License, or (at your option) any later version. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Lesser General Public License for more details. 00012 00013 You should have received a copy of the GNU Lesser General Public 00014 License along with this library; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 */ 00017 #ifndef _CELL_H_ 00018 #define _CELL_H_ 00019 00020 #include "math.h" 00021 #include <vector> 00022 #include <list> 00023 #include <stdlib.h> 00024 #include <stdio.h> 00025 #include "Object.h" 00026 #include "CPoint.h" 00027 00028 namespace RobotFlow { 00029 00030 /** ImageCell. 00031 00032 A cell is a sequence of connected pixels of the same value (same line). 00033 00034 @author Dominic Letourneau 00035 @version $Revision: 1.5 $ 00036 \begin{verbatim} 00037 Creation : 21/02/2001 00038 Last Modification: $Date: 2005/03/29 15:20:47 $ 00039 \end{verbatim} 00040 */ 00041 class ImageCell : public FD::Object { 00042 00043 public: 00044 00045 /** 00046 Ctor with no args default left/right (x,y) = (0,0) 00047 */ 00048 ImageCell(); 00049 00050 /** 00051 Ctor with left/right coordinates 00052 */ 00053 ImageCell (int x1, int y1, int x2, int y2, int color); 00054 00055 /** 00056 Copy Ctor 00057 @param cpy the ImageCell to copy 00058 */ 00059 ImageCell (const ImageCell &cpy); 00060 00061 /** 00062 Operator == between two ImageCell 00063 @param eq The ImageCell to compare to 00064 @return bool if the ImageCell are identical 00065 */ 00066 bool operator == (const ImageCell &eq); 00067 00068 /** 00069 Operator = between two ImageCell 00070 @param c The ImageCell to equals 00071 @return The ImageCell instance as rvalue 00072 */ 00073 ImageCell& operator = (const ImageCell &c); 00074 00075 /** 00076 Sets the value of the left and right coordinates 00077 @param x1 ulx 00078 @param y1 uly 00079 @param x2 lrx 00080 @param y2 lry 00081 */ 00082 void set_values(int x1,int y1,int x2,int y2); 00083 00084 /** 00085 Gets the value of the left and right coordinates 00086 @param x1 ulx 00087 @param y1 uly 00088 @param x2 lrx 00089 @param y2 lry 00090 */ 00091 void get_values (int &x1, int &y1, int &x2, int &y2); 00092 00093 /** 00094 Gets the center of the ImageCell (x) 00095 @return double the x center of the ImageCell 00096 */ 00097 double center_x(); 00098 00099 /** 00100 Gets the center of the ImageCell (y) 00101 @return double the y center of the ImageCell 00102 */ 00103 double center_y(); 00104 00105 /** 00106 Gets the size of the ImageCell (x length) 00107 @return int the size (x length) 00108 */ 00109 int size(); 00110 00111 /** 00112 Gets the color of the ImageCell 00113 @return int the color number 00114 */ 00115 int get_color(); 00116 00117 /** 00118 Sets the color of the ImageCell 00119 @param color The color of the cell 00120 */ 00121 void set_color(int color); 00122 00123 void printOn(std::ostream &out = std::cout) const; 00124 00125 void readFrom(std::istream &in); 00126 00127 ///The upper left corner 00128 CPoint m_left; 00129 00130 ///The lower right corner 00131 CPoint m_right; 00132 00133 ///The color of the cell 00134 int m_color; 00135 00136 }; 00137 00138 }//namespace RobotFlow 00139 #endif