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
3563bool
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- }
0 commit comments