Last change
on this file since 263 was
239,
checked in by cxsong, 18 years ago
|
an example of us 2d array as input to mesh functions
|
File size:
818 bytes
|
Line | |
---|
1 | #include <string> |
---|
2 | #include "mesh.h" |
---|
3 | |
---|
4 | #define Num_nodes 8 |
---|
5 | #define Num_elements 6 |
---|
6 | |
---|
7 | static int nodes[8][3] = { |
---|
8 | {0,0,0}, |
---|
9 | {1,0,0}, |
---|
10 | {1,1,0}, |
---|
11 | {0,1,0}, |
---|
12 | {0,1,1}, |
---|
13 | {1,1,1}, |
---|
14 | {0,1,1}, |
---|
15 | {0,0,1} |
---|
16 | }; |
---|
17 | |
---|
18 | static int elem[6][4] = { |
---|
19 | {0,1,5,6}, |
---|
20 | {1,2,6,7}, |
---|
21 | {2,3,7,1}, |
---|
22 | {3,4,1,2}, |
---|
23 | {5,6,2,3}, |
---|
24 | {6,7,3,4} |
---|
25 | }; |
---|
26 | |
---|
27 | int main() |
---|
28 | { |
---|
29 | int i, err; |
---|
30 | RpMesh3d * mptr; |
---|
31 | |
---|
32 | mptr = new RpMesh3d("m3d", Num_nodes, Num_elements, 4); |
---|
33 | if (mptr == NULL) |
---|
34 | return 1; |
---|
35 | |
---|
36 | // add nodes to mesh |
---|
37 | err = mptr->addAllNodes(Num_nodes, &(nodes[0][0])); |
---|
38 | if (err != RP_SUCCESS) { |
---|
39 | printf("addAllNodes: err code = %d\n", err); |
---|
40 | return 1; |
---|
41 | } |
---|
42 | |
---|
43 | err = mptr->addAllElements(Num_elements, &(elem[0][0])); |
---|
44 | if (err != RP_SUCCESS) { |
---|
45 | printf("addAllElements: err code = %d\n", err); |
---|
46 | return 1; |
---|
47 | } |
---|
48 | |
---|
49 | string str; |
---|
50 | mptr->xmlString(str); |
---|
51 | printf("%s", str.c_str()); |
---|
52 | |
---|
53 | return 0; |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.