-
Notifications
You must be signed in to change notification settings - Fork 0
/
GEN_data.cc
79 lines (57 loc) · 1.48 KB
/
GEN_data.cc
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
75
76
77
78
79
#ifdef SIM
#include <iostream>
#include <map>
#include <stdlib.h>
#include "MeshSim.h"
#include "phParAdapt.h"
#include <string.h>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
// global visibility to all other functions that use this
map<pair<pGEntity,string>,int> GEntityDataContainerInt;
map<pair<pGEntity,string>,double> GEntityDataContainerDbl;
map<pair<pGEntity,string>,void *> GEntityDataContainerPtr;
// replacement for the Simmetrix model attach data functions
///////////////////////////////////////////////////
int
GEN_dataP(pGEntity g, char *str, void** data)
{
pair<pGEntity,string> p(g,string(str));
// use global map
if(GEntityDataContainerPtr.find(p)!=GEntityDataContainerPtr.end()){
memcpy(data, &GEntityDataContainerPtr[p],sizeof(int*));
return 1;
}
return 0;
}
void
GEN_attachDataP(pGEntity g, char *str, void* data)
{
pair<pGEntity,string> p(g,string(str));
// use global map
GEntityDataContainerPtr[p] = data;
}
int
GEN_dataI(pGEntity g, char *str, int* data)
{
pair<pGEntity,string> p(g,string(str));
// use global map
if(GEntityDataContainerInt.find(p)!=GEntityDataContainerInt.end()){
memcpy(data, &GEntityDataContainerInt[p], sizeof(int*));
return 1;
}
return 0;
}
void
GEN_attachDataI(pGEntity g, char *str, int data)
{
pair<pGEntity,string> p(g,string(str));
// use global map
GEntityDataContainerInt[p] = data;
}
#ifdef __cplusplus
}
#endif
#endif