source: trunk/src/mesh/node2d.h @ 339

Last change on this file since 339 was 249, checked in by cxsong, 18 years ago

modified serialization functions

File size: 1013 bytes
Line 
1#ifndef __RP_NODE2D_H__
2#define __RP_NODE2D_H__
3
4#include <iostream>
5#include <vector>
6#include "util.h"
7
8//
9// define a 2-d node (x, y)
10//
11class RpNode2d {
12public:
13        // constructors
14        RpNode2d() { };
15
16        RpNode2d(int id): m_id(id)
17        { };
18
19        RpNode2d(int id, int x, int y):
20                m_id(id),
21                m_x(x),
22                m_y(y)
23        { };
24
25        // assign value to coordinate[index]
26        void set(int id, int x, int y) { m_id = id; m_x = x; m_y = y; };
27        void set(int id, int* val) { m_id = id; m_x = val[0]; m_y = val[1]; };
28        void set(int x, int y) { m_x = x; m_y = y; };
29
30        // get node coordinates
31        void get(int& xval, int& yval)
32        { xval = m_x; yval = m_y; };
33
34        void get(int * val) { val[0] = m_x; val[1] = m_y; };
35
36        int id() { return m_id; };
37        void id(int id) { m_id = id; };
38
39        char* serialize();
40        RP_ERROR serialize(char* buf);
41        RP_ERROR deserialize(const char* buf);
42
43        void erase() {
44                m_id = 0; m_x = m_y = 0;
45        };
46
47        void print();
48
49        virtual ~RpNode2d() { };
50
51private:
52        int m_id;
53        int m_x;
54        int m_y;
55};
56
57#endif
Note: See TracBrowser for help on using the repository browser.