2727*/
2828
2929// Get all the class definitions.
30- #include < Core/Algorithms/Fields/ConvertMeshType/ConvertMeshToUnstructuredMesh.h>
31- #include < Core/Datatypes/FieldInformation.h>
32-
33- // As we already included DynamicAlgorithm.h in the header we do not need to
34- // include it again here.
35-
36- namespace SCIRunAlgo {
30+ #include < Core/Algorithms/Legacy/ Fields/ConvertMeshType/ConvertMeshToUnstructuredMesh.h>
31+ #include < Core/Datatypes/Legacy/Field/ FieldInformation.h>
32+ # include < Core/Datatypes/Legacy/Field/VMesh.h >
33+ # include < Core/Datatypes/Legacy/Field/VField.h >
34+ # include < Core/Datatypes/PropertyManagerExtensions.h >
35+ # include < Core/Algorithms/Base/AlgorithmPreconditions.h >
36+ # include < Core/Algorithms/Base/AlgorithmVariableNames.h >
3737
3838using namespace SCIRun ;
39+ using namespace SCIRun ::Core::Algorithms::Fields;
40+ using namespace SCIRun ::Core::Geometry;
41+ using namespace SCIRun ::Core::Utility;
42+ using namespace SCIRun ::Core::Algorithms;
43+ using namespace SCIRun ::Core::Datatypes;
3944
40- // Implementation of the actual access point to the algorithm
41-
42- bool
43- ConvertMeshToUnstructuredMeshAlgo::
44- run (FieldHandle input, FieldHandle& output)
45+ bool ConvertMeshToUnstructuredMeshAlgo::runImpl (FieldHandle input, FieldHandle& output) const
4546{
46- // Mark that we are starting the algorithm, but do not report progress
47- algo_start (" ConvertMeshToUnstructuredMesh" );
48-
49- // Step 0:
50- // Safety test:
51- // Test whether we received actually a field. A handle can point to no object.
52- // Using a null handle will cause the program to crash. Hence it is a good
53- // policy to check all incoming handles and to see whether they point to actual
54- // objects.
55-
56- // Handle: the function get_rep() returns the pointer contained in the handle
57- if (input.get_rep () == 0 )
47+ ScopedAlgorithmStatusReporter asr (this , " ConvertMeshToUnstructuredMesh" );
48+
49+ // Null check
50+ if (!input)
5851 {
59- // If we encounter a null pointer we return an error message and return to
60- // the program to deal with this error.
6152 error (" No input field" );
62- algo_end (); return (false );
53+ return (false );
6354 }
6455
6556 // Step 1: determine the type of the input fields and determine what type the
@@ -91,7 +82,7 @@ run(FieldHandle input, FieldHandle& output)
9182 if (fi.is_nonlinear ())
9283 {
9384 error (" This function has not yet been defined for non-linear elements" );
94- algo_end (); return (false );
85+ return (false );
9586 }
9687
9788 // If the mesh is already unstructured, we only need to copy the input to the
@@ -102,7 +93,7 @@ run(FieldHandle input, FieldHandle& output)
10293 remark (" Mesh already is unstructured; copying input to output" );
10394 // Copy input to output (output is a reference to the input)
10495 output = input;
105- algo_end (); return (true );
96+ return (true );
10697 }
10798
10899 // Define the output type of the data
@@ -121,19 +112,19 @@ run(FieldHandle input, FieldHandle& output)
121112 else
122113 {
123114 error (" No unstructure method available for mesh: " + fi.get_mesh_type ());
124- algo_end (); return (false );
115+ return (false );
125116 }
126117
127118 // Create a new output field
128119 output = CreateField (fo);
129120
130- if (output. get_rep () == 0 )
121+ if (! output)
131122 {
132123 // Error reporting:
133124 // we forward the specific message to the ProgressReporter and return a
134125 // false to indicate that an error has occured.
135126 error (" Could not obtain input field" );
136- algo_end (); return (false );
127+ return (false );
137128 }
138129
139130 // Get the virtual interface of the objects
@@ -169,16 +160,23 @@ run(FieldHandle input, FieldHandle& output)
169160 omesh->add_elem (nodes);
170161 }
171162
172- // Resize the data
173- // and copy the data
174163 ofield->resize_values ();
175164 ofield->copy_values (ifield);
176165
177- // / Copy properties of the property manager
178- output->copy_properties (input.get_rep ());
166+ CopyProperties (*input, *output);
179167
180- // Success:
181- algo_end (); return (true );
168+ return (true );
182169}
183170
184- } // End namespace SCIRunAlgo
171+ AlgorithmOutput ConvertMeshToUnstructuredMeshAlgo::run (const AlgorithmInput& input) const
172+ {
173+ auto ifield = input.get <Field>(Variables::InputField);
174+
175+ FieldHandle ofield;
176+ if (!runImpl (ifield, ofield))
177+ THROW_ALGORITHM_PROCESSING_ERROR (" False returned on legacy run call." );
178+
179+ AlgorithmOutput output;
180+ output[Variables::OutputField] = ofield;
181+ return output;
182+ }
0 commit comments