source: trunk/src/mesh/grid2d.h @ 218

Last change on this file since 218 was 184, checked in by cxsong, 18 years ago

added array access funciton

File size: 995 bytes
Line 
1#ifndef __GRID2D_H__
2#define __GRID2D_H__
3
4//
5// class for 2D grid (x1 y1 x2 y2 ...)
6//
7
8#include <vector>
9#include "util.h"
10
11class RpGrid2d {
12public:
13        // constructors
14        RpGrid2d();
15        RpGrid2d(int npoints);
16        RpGrid2d(double* xval, double* yval, int npoints);
17        RpGrid2d(double** data, int npoints);
18        RpGrid2d(const char* buf); // instantiate with byte stream
19
20        // return number of points in grid
21        int numPoints() { return m_data.size() / 2; }
22        double* data(); // access data array
23
24        // change the size of the grid after grid is constructed
25        void resize(int npoints) { m_data.resize(npoints*2); }
26
27        void addPoint(double xval, double yval);
28
29        // serialize data
30        char * serialize(RP_ENCODE_ALG eflag=RP_NO_ENCODING,
31                         RP_COMPRESSION cflag=RP_NO_COMPRESSION);
32
33        int deserialize(const char* buf);
34
35        // destructor
36        virtual ~RpGrid2d() { };
37
38        // TODO
39        //virtual int xmlPut() { };
40        //virtual int xmlGet() { };
41
42private:
43        vector<double> m_data; // array of doubles
44};
45
46#endif
Note: See TracBrowser for help on using the repository browser.