-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisAtomSubSample.cpp
195 lines (162 loc) · 4.23 KB
/
VisAtomSubSample.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* This is a class used for in VisAtom, a visualiztion tool for
atomistic simulations.
AUTHOR: Qing HOU
INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University
HISTROTY: First version: 1998
LAST MODIFICATION: 2013
*/
#include <math.h>
#include <stdio.h>
#include "VisAtomDataSheet.h"
#include "VisAtomVisualizingPolicy.h"
#include "VisAtomSubSample.h"
void VisAtomSubSample::Clear()
{
this->m_group.clear();
while(!this->m_region.isEmpty())
{
VisAtomRegionData*p = this->m_region[0];
delete p;
this->m_region.removeAt(0);
}
this->m_dataregion.clear();
this->m_datacol.clear();
this->m_datacol.clear();
while(!this->m_vispolicy.isEmpty())
{
VisAtomVisualizingPolicy*p = this->m_vispolicy[0];
delete p;
this->m_vispolicy.removeAt(0);
}
return;
}
VisAtomSubSample::~VisAtomSubSample()
{
Clear();
}
VisAtomSubSample::VisAtomSubSample()
{
this->m_statu = VisAtomSubSample::SUBSAMPLE_VISIABLE;
VisAtomVisualizingPolicy*p;
//create the first default visualization policy
p = new VisAtomVisualizingPolicy();
p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE);
p->SetColorByDefaultTable(0);
this->m_vispolicy.append(p);
//create the secod visualization policy
p = new VisAtomVisualizingPolicy();
p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_MAP);
this->m_vispolicy.append(p);
this->m_curvispolicy = 0;
this->m_pData = NULL;
return;
}
VisAtomSubSample::VisAtomSubSample(int atype)
{
this->m_statu = VisAtomSubSample::SUBSAMPLE_VISIABLE;
//create the first default visualization policy
VisAtomVisualizingPolicy*p;
p = new VisAtomVisualizingPolicy();
p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE);
p->SetColorByDefaultTable(atype-1);
this->m_vispolicy.append(p);
//create the secod visualization policy
p = new VisAtomVisualizingPolicy();
p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_MAP);
this->m_vispolicy.append(p);
this->m_group.append(atype);
this->m_curvispolicy = 0;
this->m_pData = NULL;
return;
}
bool VisAtomSubSample::CheckMembership(int atype, float x, float y, float z, float scalar)
{
int i, count;
int ingroup, inregion, inscalar;
//check if belong to one of the groups
ingroup = 1;
if(!this->m_group.isEmpty())
{
ingroup = 0;
for(i=0; i<this->m_group.count(); i++)
{
if(atype == this->m_group[i])
{
ingroup = 1;
break;
}
}
}
//check if belong to one of the regions
inregion = 1;
if(!this->m_region.isEmpty())
{
inregion = 0;
for(i=0; i<this->m_region.count(); i++)
{
//checking
}
}
//check if belong to one of the scarlar regions
inscalar = 1;
if(!this->m_dataregion.isEmpty())
{
inscalar = 0;
for(i=0; i<this->m_dataregion.count(); i++)
{
//checking
}
}
//***
return ingroup&&inregion&&inscalar;
}
int VisAtomSubSample::GetNumberofAtoms()
{
int i,j, num, col, row;
float*type, *x, *y, *z;
float*scalar;
if(!m_pData) return 0;
row = m_pData->GetNumRow();
//get type
col = m_pData->GetTypeCol();
if(col >=0) type = m_pData->GetData(col);
else type = NULL;
//get position
col = m_pData->GetPosXCol();
x = m_pData->GetData(col);
col = m_pData->GetPosYCol();
y = m_pData->GetData(col);
col = m_pData->GetPosZCol();
z = m_pData->GetData(col);
num = 0;
if(VisAtomVisualizingPolicy::GetScalarCol() >=0)
{
scalar = m_pData->GetData(VisAtomVisualizingPolicy::GetScalarCol());
if(type)
{ for(i=0; i<row; i++)
if(this->CheckMembership((int)(type[i]+0.000001), x[i], y[i], z[i], scalar[i])) num++;
}
else
{
for(i=0; i<row; i++)
if(this->CheckMembership(1, x[i], y[i], z[i], scalar[i])) num++;
}
}
else
if(type)
{
for(i=0; i<row; i++)
if(this->CheckMembership((int)(type[i]+0.000001), x[i], y[i], z[i])) num++;
}
else
{
for(i=0; i<row; i++)
if(this->CheckMembership(1, x[i], y[i], z[i])) num++;
}
return num;
}
void VisAtomSubSample::AddVisualPolicy(VisAtomVisualizingPolicy*policy)
{
VisAtomVisualizingPolicy*p = new VisAtomVisualizingPolicy(policy);
this->m_vispolicy.append(p);
}