Skip to content

Commit 51ec17a

Browse files
committed
Throw exception for node-centered data (for now)
1 parent a9fe5aa commit 51ec17a

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

src/Core/Algorithms/Legacy/Fields/FieldData/SmoothVecFieldMedianAlgo.cc

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ bool SmoothVecFieldMedianAlgo::runImpl(FieldHandle input, FieldHandle& output) c
6868
return false;
6969
}
7070

71+
if (!fi.is_constantdata())
72+
{
73+
THROW_ALGORITHM_PROCESSING_ERROR("The data needs to be on the cells of the mesh");
74+
}
75+
7176
output = CreateField(fi, input->mesh());
7277

7378
if (!output)
@@ -79,21 +84,19 @@ bool SmoothVecFieldMedianAlgo::runImpl(FieldHandle input, FieldHandle& output) c
7984
VField* ifield = input->vfield();
8085
VField* ofield = output->vfield();
8186
VMesh* imesh = input->vmesh();
82-
VMesh::Elem::index_type a, b;
83-
Vector v0, v1, v2, v3;
84-
std::vector<double> angles, original;
85-
int middle = 0, myloc = 0;
86-
bool not_on_list = false;
87-
double gdot = 0, m1 = 0, m2 = 0, angle = 0;
8887

8988
if (ifield->is_vector())
9089
{
91-
VField::size_type num_values = ifield->num_values();
90+
Vector v0, v1, v2, v3;
91+
92+
int myloc = 0;
93+
bool not_on_list = false;
94+
auto num_values = ifield->num_values();
9295

9396
imesh->synchronize(Mesh::ELEM_NEIGHBORS_E);
9497

9598
int cnt = 0;
96-
99+
97100
for (VMesh::Elem::index_type idx = 0; idx < num_values; idx++)
98101
{
99102
//calculate neighborhoods
@@ -143,12 +146,11 @@ bool SmoothVecFieldMedianAlgo::runImpl(FieldHandle input, FieldHandle& output) c
143146
}
144147
}
145148

146-
angles.clear();
147-
original.clear();
149+
std::vector<double> angles, original;
148150
ifield->get_value(v0, idx);
149151
for (size_t q = 0; q < Nlist.size(); q++)
150152
{
151-
a = Nlist[q];
153+
auto a = Nlist[q];
152154
ifield->get_value(v1, a);
153155
if (v0.length()*v1.length() == 0)
154156
{
@@ -157,17 +159,17 @@ bool SmoothVecFieldMedianAlgo::runImpl(FieldHandle input, FieldHandle& output) c
157159
}
158160
else
159161
{
160-
gdot = Dot(v0, v1);
161-
m1 = v0.length();
162-
m2 = v1.length();
163-
angle = (gdot / (m1*m2));
162+
auto gdot = Dot(v0, v1);
163+
auto m1 = v0.length();
164+
auto m2 = v1.length();
165+
auto angle = (gdot / (m1*m2));
164166
angles.push_back(angle);
165167
original.push_back(angle);
166168
}
167169
}
168170

169171
sort(angles.begin(), angles.end());
170-
middle = (int)((angles.size() + 1) / 2);
172+
auto middle = (int)((angles.size() + 1) / 2);
171173
for (size_t k = 0; k < original.size(); k++)
172174
{
173175
if (original[k] == angles[middle])
@@ -177,16 +179,16 @@ bool SmoothVecFieldMedianAlgo::runImpl(FieldHandle input, FieldHandle& output) c
177179
}
178180
}
179181

180-
b = Nlist[myloc];
182+
auto b = Nlist[myloc];
181183
ifield->get_value(v2, b);
182184

183185
ofield->set_value(v2, idx);
184186

185-
cnt++;
186-
if (cnt == 200)
187-
{
188-
cnt = 0;
189-
update_progress_max(idx, num_values);
187+
cnt++;
188+
if (cnt == 200)
189+
{
190+
cnt = 0;
191+
update_progress_max(idx, num_values);
190192
}
191193
}
192194
}
@@ -204,4 +206,4 @@ AlgorithmOutput SmoothVecFieldMedianAlgo::run(const AlgorithmInput& input) const
204206
AlgorithmOutput output;
205207
output[Variables::OutputField] = outputField;
206208
return output;
207-
}
209+
}

0 commit comments

Comments
 (0)