Skip to content

Commit 4769456

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into issues_A
2 parents 34a1db3 + 3b70aef commit 4769456

File tree

13 files changed

+3857
-81
lines changed

13 files changed

+3857
-81
lines changed

src/Core/Algorithms/Legacy/Fields/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ SET(Core_Algorithms_Legacy_Fields_HEADERS
9999
RegisterWithCorrespondences.h
100100
SampleField/GeneratePointSamplesFromField.h
101101
DistanceField/CalculateIsInsideField.h
102+
MeshData/GetMeshQualityFieldAlgo.h
102103
)
103104

104105
SET(Core_Algorithms_Legacy_Fields_SRCS
@@ -180,7 +181,7 @@ SET(Core_Algorithms_Legacy_Fields_SRCS
180181
Mapping/ApplyMappingMatrix.cc
181182
#MeshData/GetSurfaceNodeNormals.cc
182183
#MeshData/GetSurfaceElemNormals.cc
183-
#MeshData/GetMeshQualityField.cc
184+
MeshData/GetMeshQualityFieldAlgo.cc
184185
#MeshDerivatives/CalculateMeshConnector.cc
185186
#MeshDerivatives/CalculateMeshCenter.cc
186187
#MeshDerivatives/GetCentroids.cc

src/Core/Algorithms/Legacy/Fields/MeshData/GetMeshQualityField.cc renamed to src/Core/Algorithms/Legacy/Fields/MeshData/GetMeshQualityFieldAlgo.cc

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,49 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
#include <Core/Algorithms/Fields/MeshData/GetMeshQualityField.h>
30-
#include <Core/Datatypes/Field.h>
31-
#include <Core/Datatypes/FieldInformation.h>
29+
#include <Core/Algorithms/Legacy/Fields/MeshData/GetMeshQualityFieldAlgo.h>
30+
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
31+
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
32+
#include <Core/Algorithms/Base/AlgorithmPreconditions.h>
33+
#include <Core/Datatypes/Legacy/Field/VField.h>
34+
#include <Core/Datatypes/Legacy/Field/VMesh.h>
3235

33-
namespace SCIRunAlgo {
36+
using namespace SCIRun;
37+
using namespace SCIRun::Core::Datatypes;
38+
using namespace SCIRun::Core::Algorithms;
39+
using namespace SCIRun::Core::Algorithms::Fields;
40+
41+
ALGORITHM_PARAMETER_DEF(Fields,Metric);
42+
43+
GetMeshQualityFieldAlgo::GetMeshQualityFieldAlgo()
44+
{
45+
addOption(Parameters::Metric,"scaled_jacobian","scaled_jacobian|jacobian|volume|insc_circ_ratio");
46+
}
47+
48+
AlgorithmOutput GetMeshQualityFieldAlgo::run(const AlgorithmInput& input) const
49+
{
50+
auto input_field = input.get<Field>(Variables::InputField);
51+
52+
FieldHandle output_field;
53+
54+
if (!run(input_field, output_field))
55+
THROW_ALGORITHM_PROCESSING_ERROR("False returned on legacy run call.");
56+
57+
AlgorithmOutput output;
58+
output[Variables::OutputField] = output_field;
59+
60+
return output;
61+
}
3462

3563
bool
36-
GetMeshQualityFieldAlgo::run(FieldHandle input, FieldHandle& output)
64+
GetMeshQualityFieldAlgo::run(FieldHandle input, FieldHandle& output) const
3765
{
38-
algo_start("GetMeshQualityField");
39-
std::string metric = get_option("metric");
66+
std::string Metric = getOption(Parameters::Metric);
4067

41-
if (input.get_rep() == 0)
68+
if (!input)
4269
{
4370
error("No input field");
44-
algo_end(); return (false);
71+
return false;
4572
}
4673

4774
FieldInformation fi(input);
@@ -50,40 +77,40 @@ GetMeshQualityFieldAlgo::run(FieldHandle input, FieldHandle& output)
5077

5178
output = CreateField(fi,input->mesh());
5279

53-
if (output.get_rep() == 0)
80+
if (!output)
5481
{
5582
error("Could not create output field");
56-
algo_end(); return (false);
83+
return false;
5784
}
5885

5986
VField* ofield = output->vfield();
6087
VMesh* imesh = input->vmesh();
6188

62-
if (metric == "scaled_jacobian")
89+
if (Metric == "scaled_jacobian")
6390
{
6491
VMesh::Elem::size_type num_values = imesh->num_elems();
6592
for (VMesh::Elem::index_type j=0; j<num_values; j++)
6693
{
6794
ofield->set_value(imesh->scaled_jacobian_metric(j),j);
6895
}
6996
}
70-
else if (metric == "jacobian")
97+
else if (Metric == "jacobian")
7198
{
7299
VMesh::Elem::size_type num_values = imesh->num_elems();
73100
for (VMesh::Elem::index_type j=0; j<num_values; j++)
74101
{
75102
ofield->set_value(imesh->jacobian_metric(j),j);
76103
}
77104
}
78-
else if (metric == "volume")
105+
else if (Metric == "volume")
79106
{
80107
VMesh::Elem::size_type num_values = imesh->num_elems();
81108
for (VMesh::Elem::index_type j=0; j<num_values; j++)
82109
{
83110
ofield->set_value(imesh->volume_metric(j),j);
84111
}
85112
}
86-
else if (metric == "insc_circ_ratio")
113+
else if (Metric == "insc_circ_ratio")
87114
{
88115
VMesh::Elem::size_type num_values = imesh->num_elems();
89116
for (VMesh::Elem::index_type j=0; j<num_values; j++)
@@ -92,9 +119,6 @@ GetMeshQualityFieldAlgo::run(FieldHandle input, FieldHandle& output)
92119
}
93120
}
94121

95-
algo_end();
96-
return (true);
122+
return true;
97123
}
98124

99-
100-
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#ifndef CORE_ALGORITHMS_LEGACY_FIELDS_MESHDATA_GETMESHQUALITYFIELD_H
30+
#define CORE_ALGORITHMS_LEGACY_FIELDS_MESHDATA_GETMESHQUALITYFIELD_H 1
31+
32+
//Base class for algorithm
33+
#include <Core/Algorithms/Base/AlgorithmBase.h>
34+
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
35+
36+
//For Windows support
37+
#include <Core/Algorithms/Legacy/Fields/share.h>
38+
39+
namespace SCIRun {
40+
namespace Core {
41+
namespace Algorithms {
42+
namespace Fields {
43+
44+
ALGORITHM_PARAMETER_DECL(Metric);
45+
46+
class SCISHARE GetMeshQualityFieldAlgo : public AlgorithmBase
47+
{
48+
public:
49+
/// Set defaults
50+
GetMeshQualityFieldAlgo();
51+
52+
///Run the algorithm
53+
bool run(FieldHandle input, FieldHandle& output) const;
54+
virtual AlgorithmOutput run(const AlgorithmInput& input) const;
55+
};
56+
57+
}}}}
58+
59+
#endif

0 commit comments

Comments
 (0)