00001 //------------------------------------------------------------------------------ 00004 00005 // Last Change: 2004/06/11 00006 // Version: 0.3 00007 00008 #ifndef _NODE_H_ 00009 #define _NODE_H_ 00010 00011 //---------------------------------------------------------------------includes- 00012 #include <vector> 00013 //#include <string> 00014 #include "../src/main.h" 00015 #include "../src/Vector3D.h" 00016 00017 //-----------------------------------------------------------------------usings- 00018 using std::vector; 00019 //using std::string; 00020 00021 //-------------------------------------------------------------------------Node- 00027 00028 class Node 00029 { 00030 protected: 00032 GLuint id_; 00034 char const *caption_; 00036 Vector3D *point_vector_; 00038 GLfloat angular_width_; 00040 GLint ring_number_; 00042 GLfloat ring_radius_; 00044 GLfloat polar_phi_; 00046 GLfloat polar_r_; 00048 GLfloat alpha_; 00050 GLfloat red_; 00052 GLfloat green_; 00054 GLfloat blue_; 00056 GLfloat node_radius_; 00058 vector<Node*> adjacents_; 00062 vector<GLuint> num_leafs_; 00065 GLint last_visitor_; 00068 GLfloat angle_offset_; 00070 bool is_selected_; 00072 GLfloat x_rotation_; 00074 GLfloat y_rotation_; 00076 GLfloat z_rotation_; 00077 00078 public: 00079 //----------------------------------------------------------default constructor- 00083 Node() : 00084 point_vector_(NULL), 00085 last_visitor_(-1), 00086 angle_offset_(0), 00087 x_rotation_(0), 00088 y_rotation_(0), 00089 z_rotation_(0) 00090 { 00091 } 00092 00093 //------------------------------------------------------------------constructor- 00097 Node(Node *copied_node) : 00098 id_(copied_node->getID()), 00099 point_vector_(copied_node->getPointVector()), 00100 last_visitor_(-1), 00101 angle_offset_(0), 00102 x_rotation_(0), 00103 y_rotation_(0), 00104 z_rotation_(0) 00105 { 00106 } 00107 00108 00109 //-------------------------------------------------------------------destructor- 00115 virtual ~Node() 00116 { 00117 if (point_vector_ != NULL) 00118 { 00119 delete point_vector_; 00120 } 00121 } 00122 00123 //---------------------------------------------------------operator overloading- 00129 int operator==(Node &to_compare_node); 00130 00131 //------------------------------------------------------------------------setID- 00136 void setID(GLuint id); 00137 00138 //------------------------------------------------------------------------getID- 00143 GLuint getID(); 00144 00145 //-------------------------------------------------------------------setCaption- 00150 void setCaption(char const *caption); 00151 00152 //-------------------------------------------------------------------getCaption- 00157 char const *getCaption(); 00158 00159 //---------------------------------------------------------------setPointVector- 00165 void setPointVector(Vector3D *point_vector); 00166 00167 //---------------------------------------------------------------getPointVector- 00173 Vector3D *getPointVector() const; 00174 00175 //--------------------------------------------------------------setAngularWidth- 00180 void setAngularWidth(GLfloat angular_width); 00181 00182 //--------------------------------------------------------------getAngularWidth- 00187 GLfloat getAngularWidth(); 00188 00189 //----------------------------------------------------------------------setRing- 00194 void setRing(GLuint num_ring); 00195 00196 //----------------------------------------------------------------------getRing- 00201 GLuint getRing() const; 00202 00203 //-----------------------------------------------------------setOneAdjacentNode- 00208 void setOneAdjacentNode(Node *node); 00209 00210 //--------------------------------------------------------deleteOneAdjacentNode- 00215 void deleteOneAdjacentNode(Node *node); 00216 00217 //-------------------------------------------------------getListOfAdjacentNodes- 00222 vector<Node*> *getListOfAdjacentNodes(); 00223 00224 //----------------------------------------------------------getListOfLeafeNodes- 00229 vector<GLuint> *getListOfLeafeNodes(); 00230 00231 //--------------------------------------------------------------------getDegree- 00236 GLuint getDegree(); 00237 00238 //--------------------------------------------------------------incrNumOfLeafs- 00244 void incrNumOfLeafs(Node *root); 00245 00246 //-----------------------------------------------------------------getNumLeafs- 00253 GLuint getNumLeafs(Node *node); 00254 00255 //------------------------------------------------getTotalNumOfLeafsExceptRoot- 00261 GLuint getTotalNumOfLeafsExceptRoot(Node *root); 00262 00263 //--------------------------------------------------------------------eraseNode- 00269 void eraseNode(Node *node); 00270 00271 //---------------------------------------------------------------------drawNode- 00278 void drawNode(GLUquadricObj *quadric, bool render_mode, bool caption_mode); 00279 00280 //---------------------------------------------------------------------setRadius- 00285 void setRadius(GLfloat ring_radius); 00286 00287 //---------------------------------------------------------------------getRadius- 00292 GLfloat getRadius() const; 00293 00294 //----------------------------------------------------------------setNodeRadius- 00299 void setNodeRadius(GLfloat node_radius); 00300 00301 //----------------------------------------------------------------getNodeRadius- 00306 GLfloat getNodeRadius() const; 00307 00308 //----------------------------------------------------------------------setAngle- 00313 void setAngle(GLfloat polar_phi); 00314 00315 //----------------------------------------------------------------------getAngle- 00320 GLfloat getAngle() const; 00321 00322 //-----------------------------------------------------------------------setRed- 00327 void setRed(GLuint red); 00328 00329 //---------------------------------------------------------------------setGreen- 00334 void setGreen(GLuint green); 00335 00336 //-----------------------------------------------------------------------setBlue- 00341 void setBlue(GLuint blue); 00342 00343 //-----------------------------------------------------------------------getRed- 00348 GLuint getRed(); 00349 00350 //---------------------------------------------------------------------getGreen- 00355 GLuint getGreen(); 00356 00357 //---------------------------------------------------------------------getBlue- 00362 GLuint getBlue(); 00363 00364 //---------------------------------------------------------------setLastVisitor- 00369 void setLastVisitor(GLint last_visitor); 00370 00371 //---------------------------------------------------------------getLastVisitor- 00377 GLint getLastVisitor(); 00378 00379 //------------------------------------------------------------------setSelected- 00384 void setSelected(bool is_selected); 00385 00386 //---------------------------------------------------------------addAngleOffset- 00391 void addAngleOffset(GLfloat additional_angle_offset); 00392 00393 //---------------------------------------------------------------getAngleOffset- 00398 GLfloat getAngleOffset(); 00399 00400 //-----------------------------------------------------------------resetMembers- 00404 void resetMembers(); 00405 00406 //------------------------------------------------------------setRotaionOfScene- 00413 void setSceneRotation(GLfloat x_rotation, GLfloat y_rotation, 00414 GLfloat z_rotation); 00415 }; 00416 00417 00418 #endif // _NODE_H_ 00419 00420 // eof