Skip to content

Commit 79c27b4

Browse files
added the necessary files
1 parent 34a1d4c commit 79c27b4

File tree

11 files changed

+447
-4
lines changed

11 files changed

+447
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SET(Core_Algorithms_Legacy_Fields_HEADERS
3535
FieldData/BuildMatrixOfSurfaceNormalsAlgo.h
3636
#Mapping/ApplyMappingMatrix.h
3737
#FieldData/CalculateFieldDataMetric.h
38-
#FieldData/ConvertIndicesToFieldData.h
38+
FieldData/ConvertIndicesToFieldDataAlgo.h
3939
FieldData/CalculateGradientsAlgo.h
4040
FieldData/CalculateVectorMagnitudesAlgo.h
4141
#FieldData/ConvertMappingMatrixToFieldData.h
@@ -116,7 +116,7 @@ SET(Core_Algorithms_Legacy_Fields_SRCS
116116
#FieldData/ConvertFieldDataType.cc
117117
FieldData/ConvertFieldBasisType.cc
118118
FieldData/SwapFieldDataWithMatrixEntriesAlgo.cc
119-
#FieldData/ConvertIndicesToFieldData.cc
119+
FieldData/ConvertIndicesToFieldDataAlgo.cc
120120
#FieldData/GetFieldData.cc
121121
#FieldData/ConvertMappingMatrixToFieldData.cc
122122
FieldData/SetFieldData.cc
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2009 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+
#include <Core/Algorithms/Legacy/Fields/FieldData/ConvertIndicesToFieldDataAlgo.h>
30+
#include <Core/Datatypes/Legacy/Field/Field.h>
31+
#include <Core/Datatypes/Legacy/Field/VField.h>
32+
#include <Core/Datatypes/Matrix.h>
33+
#include <Core/Datatypes/MatrixTypeConversions.h>
34+
#include <Core/Datatypes/SparseRowMatrix.h>
35+
#include <Core/Datatypes/DatatypeFwd.h>
36+
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
37+
38+
#include <Core/Algorithms/Legacy/Fields/FieldData/GetFieldData.h>
39+
#include <Core/Algorithms/Legacy/Fields/FieldData/SetFieldData.h>
40+
41+
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
42+
#include <Core/Algorithms/Base/AlgorithmPreconditions.h>
43+
44+
using namespace SCIRun::Core::Algorithms;
45+
using namespace SCIRun::Core::Algorithms::Fields;
46+
using namespace SCIRun::Core::Algorithms::Fields::Parameters;
47+
using namespace SCIRun::Core::Datatypes;
48+
using namespace SCIRun;
49+
50+
ALGORITHM_PARAMETER_DEF(Fields, PreserveScalar)
51+
52+
ConvertIndicesToFieldDataAlgo::ConvertIndicesToFieldDataAlgo()
53+
{
54+
addParameter(Parameters::PreserveScalar, false);
55+
}
56+
57+
bool
58+
ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input_field, MatrixHandle input_matrix, FieldHandle& output_field, MatrixHandle& output_matrix) const
59+
{
60+
ScopedAlgorithmStatusReporter r(this, "SwapFieldDataWithMatrixEntriesAlgo");
61+
62+
if (!input_field)
63+
{
64+
error("No input field");
65+
return (false);
66+
}
67+
68+
FieldInformation fi(input_field);
69+
GetFieldDataAlgo get_algo_;
70+
SetFieldDataAlgo set_algo_;
71+
72+
const bool preserve_scalar = get(Parameters::PreserveScalar).toBool();
73+
output_field = CreateField(fi);
74+
75+
if (input_matrix)
76+
{
77+
output_matrix = get_algo_.run(input_field);
78+
}
79+
FieldHandle field_output_handle;
80+
81+
if (input_matrix)
82+
{
83+
if (preserve_scalar)
84+
{
85+
set_algo_.set_option(set_algo_.keepTypeCheckBox, fi.get_data_type());
86+
}
87+
size_type numVal = 0;
88+
auto denseInput = matrix_convert::to_dense(input_matrix);
89+
if (set_algo_.verify_input_data(input_field, denseInput, numVal, fi))
90+
{
91+
output_field = set_algo_.run(input_field, denseInput);
92+
}
93+
else
94+
{
95+
THROW_ALGORITHM_INPUT_ERROR("Matrix dimensions do not match any of the fields dimensions");
96+
CopyProperties(*input_field, *output_field);
97+
}
98+
}
99+
else
100+
{
101+
warning("No input matrix passing the field through");
102+
output_field = input_field;
103+
}
104+
105+
AlgorithmOutput output;
106+
output[Variables::OutputField] = output_field;
107+
108+
return true;
109+
}
110+
111+
bool
112+
ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input, MatrixHandle input_matrix, FieldHandle& output) const
113+
{
114+
MatrixHandle dummy;
115+
return runImpl(input, input_matrix, output, dummy);
116+
}
117+
118+
AlgorithmOutput ConvertIndicesToFieldDataAlgo::run_generic(const AlgorithmInput& input) const
119+
{
120+
auto field = input.get<Field>(Variables::InputField);
121+
auto inputmatrix = input.get<Matrix>(Variables::InputMatrix);
122+
123+
FieldHandle output_field;
124+
if (!runImpl(field, inputmatrix, output_field))
125+
THROW_ALGORITHM_PROCESSING_ERROR("False returned on legacy run call.");
126+
127+
AlgorithmOutput output;
128+
output[Variables::OutputField] = output_field;
129+
return output;
130+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2009 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+
30+
#ifndef CORE_ALGORITHMS_FIELDS_FIELDDATA_CONVERTINDICESTOFIELDDATAALGO_H
31+
#define CORE_ALGORITHMS_FIELDS_FIELDDATA_CONVERTINDICESTOFIELDDATAALGO_H 1
32+
33+
#include <Core/Algorithms/Base/AlgorithmBase.h>
34+
#include <Core/Algorithms/Legacy/Fields/share.h>
35+
36+
namespace SCIRun {
37+
namespace Core {
38+
namespace Algorithms {
39+
namespace Fields {
40+
41+
ALGORITHM_PARAMETER_DECL(PreserveScalar);
42+
43+
class SCISHARE ConvertIndicesToFieldDataAlgo : public AlgorithmBase
44+
{
45+
public:
46+
ConvertIndicesToFieldDataAlgo();
47+
48+
bool runImpl(FieldHandle input_field,
49+
Datatypes::MatrixHandle input_matrix,
50+
FieldHandle& output_field,
51+
Datatypes::MatrixHandle& output_matrix)const;
52+
53+
bool runImpl(FieldHandle input, Datatypes::MatrixHandle input_matrix, FieldHandle& output) const;
54+
55+
virtual AlgorithmOutput run_generic(const AlgorithmInput& input) const override;
56+
};
57+
}
58+
}
59+
}
60+
}
61+
62+
#endif
63+

src/Interface/Modules/Fields/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ SET(Interface_Modules_Fields_FORMS
5656
ConvertFieldBasis.ui
5757
swapfielddatawithmatrixentries.ui
5858
EditMeshBoundingBox.ui
59+
ConvertIndicesToFieldData.ui
5960
)
6061

6162
SET(Interface_Modules_Fields_HEADERS
@@ -87,6 +88,7 @@ SET(Interface_Modules_Fields_HEADERS
8788
share.h
8889
SwapFieldDataWithMatrixEntriesDialog.h
8990
EditMeshBoundingBoxDialog.h
91+
ConvertIndicesToFieldDataDialog.h
9092
)
9193

9294
SET(Interface_Modules_Fields_SOURCES
@@ -117,6 +119,7 @@ SET(Interface_Modules_Fields_SOURCES
117119
SwapFieldDataWithMatrixEntriesDialog.cc
118120
RefineMeshDialog.cc
119121
EditMeshBoundingBoxDialog.cc
122+
ConvertIndicesToFieldDataDialog.cc
120123
)
121124

122125
IF(WITH_TETGEN)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>Dialog</class>
4+
<widget class="QDialog" name="Dialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>233</width>
10+
<height>40</height>
11+
</rect>
12+
</property>
13+
<property name="minimumSize">
14+
<size>
15+
<width>233</width>
16+
<height>40</height>
17+
</size>
18+
</property>
19+
<property name="windowTitle">
20+
<string>Dialog</string>
21+
</property>
22+
<layout class="QVBoxLayout" name="verticalLayout">
23+
<item>
24+
<layout class="QHBoxLayout" name="horizontalLayout">
25+
<item>
26+
<widget class="QLabel" name="dataTypeLabel_">
27+
<property name="text">
28+
<string>Data type output field:</string>
29+
</property>
30+
</widget>
31+
</item>
32+
<item>
33+
<widget class="QComboBox" name="dataTypeComboBox_">
34+
<item>
35+
<property name="text">
36+
<string>double</string>
37+
</property>
38+
</item>
39+
<item>
40+
<property name="text">
41+
<string>float</string>
42+
</property>
43+
</item>
44+
<item>
45+
<property name="text">
46+
<string>char</string>
47+
</property>
48+
</item>
49+
<item>
50+
<property name="text">
51+
<string>unsigned char</string>
52+
</property>
53+
</item>
54+
<item>
55+
<property name="text">
56+
<string>short</string>
57+
</property>
58+
</item>
59+
<item>
60+
<property name="text">
61+
<string>unsigned short</string>
62+
</property>
63+
</item>
64+
<item>
65+
<property name="text">
66+
<string>int</string>
67+
</property>
68+
</item>
69+
<item>
70+
<property name="text">
71+
<string>unsigned int</string>
72+
</property>
73+
</item>
74+
</widget>
75+
</item>
76+
</layout>
77+
</item>
78+
</layout>
79+
</widget>
80+
<resources/>
81+
<connections/>
82+
</ui>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2012 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
License for the specific language governing rights and limitations under
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+
#include <Interface/Modules/Fields/ConvertIndicesToFieldDataDialog.h>
30+
#include <Core/Algorithms/Legacy/Fields/FieldData/ConvertIndicesToFieldDataDialog.h>
31+
32+
using namespace SCIRun::Gui;
33+
using namespace SCIRun::Dataflow::Networks;
34+
using namespace SCIRun::Core::Algorithms::Fields;
35+
36+
ConvertIndicesToFieldDataDialog::ConvertIndicesToFieldDataDialog(const std::string& name, ModuleStateHandle state,
37+
QWidget* parent /* = 0 */)
38+
: ModuleDialogGeneric(state, parent)
39+
{
40+
setupUi(this);
41+
setWindowTitle(QString::fromStdString(name));
42+
fixSize();
43+
44+
addCheckBoxManager( dataTypeComboBox_, ConvertIndicesToFieldDataDialog::);
45+
}
46+
47+
void ConvertIndicesToFieldDataDialog::pull()
48+
{
49+
pull_newVersionToReplaceOld();
50+
}

0 commit comments

Comments
 (0)