-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodeinfo.cpp
executable file
·74 lines (65 loc) · 1.66 KB
/
nodeinfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<iostream>
#include<assert.h>
#include "nodeinfo.h"
#include "objSegmentUtil.h"
using std::cout;
stNodePos* CreateNodeArray( unsigned long numItems)
{
stNodePos *ptr;
unsigned long i;
// if (numItems < 0)
// return (0);
ptr = new stNodePos[numItems];
if(ptr == NULL)
{
cout << "cannot allocate space for node Array\n";
}
for(i=0;i<numItems;i++)
{
ptr[i].numOfAdjPos=0;
ptr[i].adjPosList=NULL;
}
return ptr;
}
stNodePos* GetCurNode( stNodePos nodeList[], unsigned long index )
{
// if ( index < 0 )
// return (0);
return ( &nodeList[index]);
}
stNodeData* CreateDataArray(unsigned long numItems)
{
// if (numItems < 0) return(0);
stNodeData *ptr;
ptr = new stNodeData[numItems];
assert(ptr);
return ptr;
}
stNodeData* GetCurNodeData ( stNodeData dataList[], unsigned long index )
{
return ( &dataList[index]);
}
int AddCellToNodeList( stNodePos nodeList[], unsigned long index, unsigned long cellId)
{
stNodePos *curNodePtr;
stCellIndex *indexPtr, *cellListPtr;
if((curNodePtr = &nodeList[index])==NULL)
cout << "in addCellToPosList, posPtr is NULL\n";
cellListPtr = curNodePtr->list;
indexPtr = new stCellIndex;
if(indexPtr==NULL)
{
cout << "in addCellToPosList, new error\n";
return 0;
}
indexPtr->index = cellId;
indexPtr->next = cellListPtr;
curNodePtr->list = indexPtr;
return METHOD_SUCCESS;
}
stCellIndex* GetIncidentCells( stNodePos nodeList[], unsigned long index )
{
stNodePos * ptr;
ptr = &(nodeList[index]);
return (ptr->list);
}