source: trunk/src/mesh/mesh.h @ 829

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

modified serialization functions

File size: 1.9 KB
Line 
1#ifndef __RP_MESH3D_H__
2#define __RP_MESH3D_H__
3
4#include <string>
5#include "element.h"
6#include "node3d.h"
7#include "util.h"
8
9
10class RpMesh3d {
11public:
12        // constructor
13        RpMesh3d(const char* id, int numNodes, int numElements,
14                        int nodesInElement);
15
16        int numNodes() { return m_numNodes; };
17        int numElements() { return m_numElements; };
18        int elementSize() { return (*m_elemList)[0].numNodes(); };
19        const char* id() { return m_id.c_str(); };
20
21        // want user to set these numbers in constructor
22        //void numNodes(int n) { m_numNodes = n; };
23        //void numElements(int n) { m_numElements = n; };
24        //void id(const char* id) { m_id = id; };
25
26        // add all nodes to mesh
27        RP_ERROR addAllNodes(int numNodes, int* nodesList);
28
29        // add one node to mesh
30        RP_ERROR addNode(int* nodesList);
31
32        // add an element to mesh
33        RP_ERROR addElement(int numNodesInElem, const int* nodes);
34
35        // add all elements to mesh
36        RP_ERROR addAllElements(int numElements, int* elementArray);
37
38        // retrieve nodes
39        void getNode(int nodeSeqNum, int* x, int* y, int* z);
40        RP_ERROR getNode(int nodeSeqNum, RpNode3d& node);
41        RP_ERROR getNodesList(int& num, int* nodesList);
42
43        RpElement getElement(int elemSeqNum);
44        RP_ERROR getElement(int elemSeqNum, int* nodesBuf);
45        RP_ERROR getAllElements(int num, int* buf);
46
47        // serialization
48        char* serialize(int& numbytes);
49        RP_ERROR serialize(char* buf, int buflen);
50        RP_ERROR deserialize(const char* buf);
51
52        void xmlString(std::string& str);
53        void print();
54
55        // erase all nodes and elements, capacity not changed.
56        void erase();
57
58        virtual ~RpMesh3d();
59
60protected:
61        // default constructor
62        RpMesh3d() { };
63
64private:
65        std::string m_id;
66        int m_numNodes;
67        int m_numElements;
68        int m_nodeIndex;
69        int m_elemIndex;
70        vector<RpNode3d> m_nodeList; // list of node objects
71        vector<RpElement> * m_elemList; // ptr to a list of RpElement objects
72
73        int numBytes();
74};
75
76#endif
Note: See TracBrowser for help on using the repository browser.