Skip to content

Commit 3e5da88

Browse files
committed
Add CMTUM
1 parent dbe0eeb commit 3e5da88

File tree

9 files changed

+112
-131
lines changed

9 files changed

+112
-131
lines changed

src/Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToIrregularMesh.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ using namespace SCIRun::Core::Algorithms;
4242
using namespace SCIRun::Core::Datatypes;
4343

4444
bool
45-
ConvertMeshToIrregularMeshAlgo::run(FieldHandle input, FieldHandle& output) const
45+
ConvertMeshToIrregularMeshAlgo::runImpl(FieldHandle input, FieldHandle& output) const
4646
{
4747
// Mark that we are starting the algorithm, but do not report progress
4848
ScopedAlgorithmStatusReporter asr(this, "ConvertMeshToIrregularMesh");
@@ -188,17 +188,15 @@ ConvertMeshToIrregularMeshAlgo::run(FieldHandle input, FieldHandle& output) cons
188188
return (true);
189189
}
190190

191-
AlgorithmOutputName ConvertMeshToIrregularMeshAlgo::OutputField("OutputField");
192-
193191
AlgorithmOutput ConvertMeshToIrregularMeshAlgo::run(const AlgorithmInput& input) const
194192
{
195193
auto ifield = input.get<Field>(Variables::InputField);
196194

197195
FieldHandle ofield;
198-
if (!run(ifield, ofield))
196+
if (!runImpl(ifield, ofield))
199197
THROW_ALGORITHM_PROCESSING_ERROR("False returned on legacy run call.");
200198

201199
AlgorithmOutput output;
202-
output[OutputField] = ofield;
200+
output[Variables::OutputField] = ofield;
203201
return output;
204202
}

src/Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToIrregularMesh.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
#define CORE_ALGORITHMS_FIELDS_CONVERTMESHTYPE_CONVERTTOIRREGULARMESH_H 1
3232

3333
#include <Core/Algorithms/Base/AlgorithmBase.h>
34-
35-
// for Windows support
3634
#include <Core/Algorithms/Legacy/Fields/share.h>
3735

3836
namespace SCIRun {
@@ -47,11 +45,9 @@ class SCISHARE ConvertMeshToIrregularMeshAlgo : public AlgorithmBase
4745
{
4846
}
4947

50-
bool run(FieldHandle input, FieldHandle& output) const;
51-
52-
static AlgorithmOutputName OutputField;
48+
bool runImpl(FieldHandle input, FieldHandle& output) const;
5349

54-
virtual AlgorithmOutput run(const AlgorithmInput& input) const;
50+
virtual AlgorithmOutput run(const AlgorithmInput& input) const override;
5551
};
5652

5753
}}}}

src/Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToPointCloudMeshAlgo.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -24,7 +24,7 @@
2424
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2525
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2626
DEALINGS IN THE SOFTWARE.
27-
*/
27+
*/
2828

2929

3030
#ifndef CORE_ALGORITHMS_FIELDS_CONVERTMESHTYPE_CONVERTTOPOINTCLOUDMESH_H
@@ -39,18 +39,21 @@ namespace SCIRun {
3939
namespace Algorithms {
4040
namespace Fields {
4141

42-
class SCISHARE ConvertMeshToPointCloudMeshAlgo : public AlgorithmBase
43-
{
44-
public:
45-
ConvertMeshToPointCloudMeshAlgo();
42+
class SCISHARE ConvertMeshToPointCloudMeshAlgo : public AlgorithmBase
43+
{
44+
public:
45+
ConvertMeshToPointCloudMeshAlgo();
4646

47-
bool runImpl(FieldHandle input, FieldHandle& output) const;
48-
virtual AlgorithmOutput run(const AlgorithmInput& input) const override;
47+
bool runImpl(FieldHandle input, FieldHandle& output) const;
48+
virtual AlgorithmOutput run(const AlgorithmInput& input) const override;
4949

50-
static AlgorithmParameterName Location;
51-
};
50+
static AlgorithmParameterName Location;
51+
};
5252

53-
}}}}
53+
}
54+
}
55+
}
56+
}
5457

5558
#endif
5659

src/Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToUnstructuredMesh.cc

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,30 @@
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

3838
using 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+
}

src/Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToUnstructuredMesh.h

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,29 @@
3030
#ifndef CORE_ALGORITHMS_FIELDS_CONVERTMESHTYPE_CONVERTMESHTOUNSTRUCTUREDMESH_H
3131
#define CORE_ALGORITHMS_FIELDS_CONVERTMESHTYPE_CONVERTMESHTOUNSTRUCTUREDMESH_H 1
3232

33-
// Datatypes that the algorithm uses
34-
#include <Core/Datatypes/Mesh.h>
35-
#include <Core/Datatypes/Field.h>
33+
#include <Core/Algorithms/Base/AlgorithmBase.h>
34+
#include <Core/Algorithms/Legacy/Fields/share.h>
3635

37-
// Base class for algorithm
38-
#include <Core/Algorithms/Util/AlgoBase.h>
36+
namespace SCIRun {
37+
namespace Core {
38+
namespace Algorithms {
39+
namespace Fields {
3940

40-
// for Windows support
41-
#include <Core/Algorithms/Fields/share.h>
41+
class SCISHARE ConvertMeshToUnstructuredMeshAlgo : public AlgorithmBase
42+
{
43+
public:
44+
ConvertMeshToUnstructuredMeshAlgo()
45+
{
46+
}
4247

43-
namespace SCIRunAlgo {
48+
bool runImpl(FieldHandle input, FieldHandle& output) const;
4449

45-
using namespace SCIRun;
50+
virtual AlgorithmOutput run(const AlgorithmInput& input) const override;
51+
};
4652

47-
class SCISHARE ConvertMeshToUnstructuredMeshAlgo : public AlgoBase
48-
{
49-
public:
50-
/// Set defaults
51-
ConvertMeshToUnstructuredMeshAlgo()
52-
{
53+
}
5354
}
55+
}
56+
}
5457

55-
/// run the algorithm
56-
bool run(FieldHandle input, FieldHandle& output);};
57-
58-
} // end namespace SCIRunAlgo
59-
60-
#endif
61-
58+
#endif

src/Core/Algorithms/Legacy/Fields/MeshData/SetMeshNodes.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SetMeshNodesAlgo::run(FieldHandle input, DenseMatrixHandle matrix, FieldHandle&
7575
/// @todo: worth separating out into factory call for mocking purposes? probably not, just keep the concrete dependence
7676
ConvertMeshToIrregularMeshAlgo algo;
7777

78-
if (!algo.run(input,output))
78+
if (!algo.runImpl(input,output))
7979
return (false);
8080
}
8181
else
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"module": {
3+
"name": "ConvertMeshToUnstructuredMesh",
4+
"namespace": "Fields",
5+
"status": "Ported module",
6+
"description": "Converts a mesh to unstructured mesh.",
7+
"header": "Modules/Legacy/Fields/ConvertMeshToUnstructuredMesh.h"
8+
},
9+
"algorithm": {
10+
"name": "ConvertMeshToUnstructuredMeshAlgo",
11+
"namespace": "Fields",
12+
"header": "Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToUnstructuredMesh.h"
13+
},
14+
"UI": {
15+
"name": "N/A",
16+
"header": "N/A"
17+
}
18+
}

src/Modules/Legacy/Fields/ConvertMeshToPointCloud.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
// Include the algorithm
3029
#include <Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToPointCloudMeshAlgo.h>
3130
#include <Core/Datatypes/Legacy/Field/Field.h>
3231
#include <Modules/Legacy/Fields/ConvertMeshToPointCloud.h>
@@ -53,7 +52,6 @@ void ConvertMeshToPointCloud::setStateDefaults()
5352
{
5453
setStateStringFromAlgoOption(ConvertMeshToPointCloudMeshAlgo::Location);
5554
}
56-
5755

5856
void
5957
ConvertMeshToPointCloud::execute()

0 commit comments

Comments
 (0)