Skip to content

Commit 03c718c

Browse files
committed
CalculateDistanceToFieldBoundary
1 parent 59c19c2 commit 03c718c

12 files changed

+228
-127
lines changed

src/Core/Algorithms/Factory/HardCodedAlgorithmFactory.cc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ using namespace SCIRun::Core::Algorithms::BrainStimulator;
8080
using namespace SCIRun::Core::Algorithms::Math;
8181
using namespace boost::assign;
8282

83-
/// @todo: add unit test
83+
/// @todo: add unit test
8484

85-
HardCodedAlgorithmFactory::HardCodedAlgorithmFactory()
85+
HardCodedAlgorithmFactory::HardCodedAlgorithmFactory()
8686
{
8787
addToMakerMap();
8888
addToMakerMap2();
@@ -102,10 +102,10 @@ void HardCodedAlgorithmFactory::addToMakerMap()
102102
ADD_MODULE_ALGORITHM(ConvertQuadSurfToTriSurf, ConvertMeshToTriSurfMeshAlgo)
103103
ADD_MODULE_ALGORITHM(AlignMeshBoundingBoxes, AlignMeshBoundingBoxesAlgo)
104104
ADD_MODULE_ALGORITHM(GetFieldNodes, GetMeshNodesAlgo) /// @todo: interesting case of module/algo name mismatch. Could be a problem if I want to make this factory more generic
105-
ADD_MODULE_ALGORITHM(ElectrodeCoilSetup, ElectrodeCoilSetupAlgorithm)
106-
ADD_MODULE_ALGORITHM(SetConductivitiesToTetMesh, SetConductivitiesToTetMeshAlgorithm)
107-
ADD_MODULE_ALGORITHM(SetupRHSforTDCSandTMS, SetupRHSforTDCSandTMSAlgorithm)
108-
ADD_MODULE_ALGORITHM(GenerateROIStatistics, GenerateROIStatisticsAlgorithm)
105+
ADD_MODULE_ALGORITHM(ElectrodeCoilSetup, ElectrodeCoilSetupAlgorithm)
106+
ADD_MODULE_ALGORITHM(SetConductivitiesToTetMesh, SetConductivitiesToTetMeshAlgorithm)
107+
ADD_MODULE_ALGORITHM(SetupRHSforTDCSandTMS, SetupRHSforTDCSandTMSAlgorithm)
108+
ADD_MODULE_ALGORITHM(GenerateROIStatistics, GenerateROIStatisticsAlgorithm)
109109
ADD_MODULE_ALGORITHM(SetFieldNodes, SetMeshNodesAlgo)
110110
ADD_MODULE_ALGORITHM(ReportFieldInfo, ReportFieldInfoAlgorithm)
111111
ADD_MODULE_ALGORITHM(ReportMatrixInfo, ReportMatrixInfoAlgorithm)
@@ -116,26 +116,27 @@ void HardCodedAlgorithmFactory::addToMakerMap()
116116
ADD_MODULE_ALGORITHM(EvaluateLinearAlgebraBinary, EvaluateLinearAlgebraBinaryAlgorithm)
117117
ADD_MODULE_ALGORITHM(ConvertMeshToIrregularMesh, ConvertMeshToIrregularMeshAlgo)
118118
ADD_MODULE_ALGORITHM(ReadMesh, TextToTriSurfFieldAlgorithm)
119-
ADD_MODULE_ALGORITHM(AddKnownsToLinearSystem, AddKnownsToLinearSystemAlgo)
120-
ADD_MODULE_ALGORITHM(CalculateVectorMagnitudes, CalculateVectorMagnitudesAlgo)
119+
ADD_MODULE_ALGORITHM(AddKnownsToLinearSystem, AddKnownsToLinearSystemAlgo)
120+
ADD_MODULE_ALGORITHM(CalculateVectorMagnitudes, CalculateVectorMagnitudesAlgo)
121121
ADD_MODULE_ALGORITHM(BuildFEMatrix, BuildFEMatrixAlgo)
122122
ADD_MODULE_ALGORITHM(GetDomainBoundary, GetDomainBoundaryAlgo)
123-
ADD_MODULE_ALGORITHM(InterfaceWithCleaver, InterfaceWithCleaverAlgorithm)
123+
ADD_MODULE_ALGORITHM(InterfaceWithCleaver, InterfaceWithCleaverAlgorithm)
124124
ADD_MODULE_ALGORITHM(GetFieldData, GetFieldDataAlgo)
125125
ADD_MODULE_ALGORITHM(SetFieldData, SetFieldDataAlgo)
126126
ADD_MODULE_ALGORITHM(JoinFields, JoinFieldsAlgo)
127127
ADD_MODULE_ALGORITHM(SplitFieldByDomain, SplitFieldByDomainAlgo)
128-
ADD_MODULE_ALGORITHM(ApplyMappingMatrix, ApplyMappingMatrixAlgo)
129-
ADD_MODULE_ALGORITHM(SelectSubMatrix, SelectSubMatrixAlgorithm)
130-
ADD_MODULE_ALGORITHM(ConvertMatrixType, ConvertMatrixTypeAlgorithm)
131-
ADD_MODULE_ALGORITHM(MapFieldDataFromNodeToElem, MapFieldDataFromNodeToElemAlgo)
128+
ADD_MODULE_ALGORITHM(ApplyMappingMatrix, ApplyMappingMatrixAlgo)
129+
ADD_MODULE_ALGORITHM(SelectSubMatrix, SelectSubMatrixAlgorithm)
130+
ADD_MODULE_ALGORITHM(ConvertMatrixType, ConvertMatrixTypeAlgorithm)
131+
ADD_MODULE_ALGORITHM(MapFieldDataFromNodeToElem, MapFieldDataFromNodeToElemAlgo)
132132
ADD_MODULE_ALGORITHM(MapFieldDataFromElemToNode, MapFieldDataFromElemToNodeAlgo)
133133
ADD_MODULE_ALGORITHM(ResampleRegularMesh, ResampleRegularMeshAlgo)
134134
ADD_MODULE_ALGORITHM(FairMesh, FairMeshAlgo)
135135
ADD_MODULE_ALGORITHM(ScaleFieldMeshAndData, ScaleFieldMeshAndDataAlgo)
136136
ADD_MODULE_ALGORITHM(ConvertFieldBasis, ConvertFieldBasisTypeAlgo)
137137
ADD_MODULE_ALGORITHM(ProjectPointsOntoMesh, ProjectPointsOntoMeshAlgo)
138138
ADD_MODULE_ALGORITHM(CalculateDistanceToField, CalculateDistanceFieldAlgo)
139+
ADD_MODULE_ALGORITHM(CalculateDistanceToFieldBoundary, CalculateDistanceFieldAlgo)
139140
;
140141
}
141142
}

src/Interface/Modules/Factory/ModuleDialogFactory.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <Interface/Modules/Fields/FairMeshDialog.h>
6161
#include <Interface/Modules/Fields/ProjectPointsOntoMeshDialog.h>
6262
#include <Interface/Modules/Fields/CalculateDistanceToFieldDialog.h>
63+
#include <Interface/Modules/Fields/CalculateDistanceToFieldBoundaryDialog.h>
6364
#include <Interface/Modules/Visualization/MatrixAsVectorFieldDialog.h>
6465
#include <Interface/Modules/Visualization/ShowStringDialog.h>
6566
#include <Interface/Modules/Visualization/ShowFieldDialog.h>
@@ -127,6 +128,7 @@ void ModuleDialogFactory::addDialogsToMakerMap1()
127128
ADD_MODULE_DIALOG(FairMesh, FairMeshDialog)
128129
ADD_MODULE_DIALOG(ProjectPointsOntoMesh, ProjectPointsOntoMeshDialog)
129130
ADD_MODULE_DIALOG(CalculateDistanceToField, CalculateDistanceToFieldDialog)
131+
ADD_MODULE_DIALOG(CalculateDistanceToFieldBoundary, CalculateDistanceToFieldBoundaryDialog)
130132
;
131133
}
132134

src/Interface/Modules/Fields/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SET(Interface_Modules_Fields_FORMS
4343
resampleregularmesh.ui #TODO: fix case
4444
ProjectPointsOntoMesh.ui
4545
calculatedistancetofield.ui #TODO: fix case
46+
calculatedistancetofieldboundary.ui #TODO: fix case
4647
)
4748

4849
SET(Interface_Modules_Fields_HEADERS
@@ -61,6 +62,7 @@ SET(Interface_Modules_Fields_HEADERS
6162
ResampleRegularMeshDialog.h
6263
ProjectPointsOntoMeshDialog.h
6364
CalculateDistanceToFieldDialog.h
65+
CalculateDistanceToFieldBoundaryDialog.h
6466
share.h
6567
)
6668

@@ -80,6 +82,7 @@ SET(Interface_Modules_Fields_SOURCES
8082
ResampleRegularMeshDialog.cc
8183
ProjectPointsOntoMeshDialog.cc
8284
CalculateDistanceToFieldDialog.cc
85+
CalculateDistanceToFieldBoundaryDialog.cc
8386
)
8487

8588
QT4_WRAP_UI(Interface_Modules_Fields_FORMS_HEADERS ${Interface_Modules_Fields_FORMS})
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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/CalculateDistanceToFieldBoundaryDialog.h>
30+
#include <Core/Algorithms/Legacy/Fields/DistanceField/CalculateDistanceField.h>
31+
32+
using namespace SCIRun::Gui;
33+
using namespace SCIRun::Dataflow::Networks;
34+
using namespace SCIRun::Core::Algorithms::Fields;
35+
36+
CalculateDistanceToFieldBoundaryDialog::CalculateDistanceToFieldBoundaryDialog(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(truncateDistanceCheckBox_, Parameters::Truncate);
45+
addDoubleSpinBoxManager(truncateDoubleSpinBox_, Parameters::TruncateDistance);
46+
addComboBoxManager(basisTypeComboBox_, Parameters::BasisType);
47+
addComboBoxManager(dataTypeComboBox_, Parameters::OutputFieldDatatype);
48+
}
49+
50+
void CalculateDistanceToFieldBoundaryDialog::pull()
51+
{
52+
pull_newVersionToReplaceOld();
53+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#ifndef INTERFACE_MODULES_CALCULATE_DISTANCE_TO_FIELD_BOUNDARY_H
30+
#define INTERFACE_MODULES_CALCULATE_DISTANCE_TO_FIELD_BOUNDARY_H
31+
32+
#include "Interface/Modules/Fields/ui_calculatedistancetofieldboundary.h"
33+
#include <Interface/Modules/Base/ModuleDialogGeneric.h>
34+
#include <Interface/Modules/Fields/share.h>
35+
36+
namespace SCIRun {
37+
namespace Gui {
38+
39+
class SCISHARE CalculateDistanceToFieldBoundaryDialog : public ModuleDialogGeneric,
40+
public Ui::CalculateDistanceToFieldBoundary
41+
{
42+
Q_OBJECT
43+
44+
public:
45+
CalculateDistanceToFieldBoundaryDialog(const std::string& name,
46+
SCIRun::Dataflow::Networks::ModuleStateHandle state,
47+
QWidget* parent = 0);
48+
virtual void pull();
49+
};
50+
51+
}
52+
}
53+
54+
#endif

src/Interface/Modules/Fields/calculatedistancetofield.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>318</width>
9+
<width>418</width>
1010
<height>123</height>
1111
</rect>
1212
</property>
@@ -18,8 +18,8 @@
1818
<rect>
1919
<x>18</x>
2020
<y>20</y>
21-
<width>300</width>
22-
<height>79</height>
21+
<width>387</width>
22+
<height>91</height>
2323
</rect>
2424
</property>
2525
<layout class="QGridLayout" name="gridLayout">

src/Interface/Modules/Fields/calculatedistancetofieldboundary.ui

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ui version="4.0">
3-
<class>CalculateDistanceToField</class>
4-
<widget class="QDialog" name="CalculateDistanceToField">
3+
<class>CalculateDistanceToFieldBoundary</class>
4+
<widget class="QDialog" name="CalculateDistanceToFieldBoundary">
55
<property name="geometry">
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>318</width>
9+
<width>418</width>
1010
<height>123</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>CalculateDistanceToField</string>
14+
<string>CalculateDistanceToFieldBoundary</string>
1515
</property>
1616
<widget class="QWidget" name="layoutWidget">
1717
<property name="geometry">
1818
<rect>
1919
<x>18</x>
2020
<y>20</y>
21-
<width>283</width>
22-
<height>79</height>
21+
<width>387</width>
22+
<height>91</height>
2323
</rect>
2424
</property>
2525
<layout class="QGridLayout" name="gridLayout">
@@ -120,9 +120,15 @@
120120
</widget>
121121
</item>
122122
<item row="2" column="2">
123-
<widget class="QLineEdit" name="truncateLineEdit_">
124-
<property name="text">
125-
<string>1.0</string>
123+
<widget class="QDoubleSpinBox" name="truncateDoubleSpinBox_">
124+
<property name="enabled">
125+
<bool>false</bool>
126+
</property>
127+
<property name="decimals">
128+
<number>7</number>
129+
</property>
130+
<property name="maximum">
131+
<double>1000000000.000000000000000</double>
126132
</property>
127133
</widget>
128134
</item>
@@ -131,5 +137,22 @@
131137
</widget>
132138
<layoutdefault spacing="6" margin="11"/>
133139
<resources/>
134-
<connections/>
140+
<connections>
141+
<connection>
142+
<sender>truncateDistanceCheckBox_</sender>
143+
<signal>toggled(bool)</signal>
144+
<receiver>truncateDoubleSpinBox_</receiver>
145+
<slot>setEnabled(bool)</slot>
146+
<hints>
147+
<hint type="sourcelabel">
148+
<x>102</x>
149+
<y>85</y>
150+
</hint>
151+
<hint type="destinationlabel">
152+
<x>254</x>
153+
<y>85</y>
154+
</hint>
155+
</hints>
156+
</connection>
157+
</connections>
135158
</ui>

src/Modules/Factory/ModuleFactoryImpl1.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ DEALINGS IN THE SOFTWARE.
6767
#include <Modules/Legacy/Fields/ScaleFieldMeshAndData.h>
6868
#include <Modules/Legacy/Fields/ProjectPointsOntoMesh.h>
6969
#include <Modules/Legacy/Fields/CalculateDistanceToField.h>
70+
#include <Modules/Legacy/Fields/CalculateDistanceToFieldBoundary.h>
7071
#include <Modules/Legacy/Math/SolveMinNormLeastSqSystem.h>
7172
#include <Modules/DataIO/ReadMatrix.h>
7273
#include <Modules/DataIO/WriteMatrix.h>
@@ -134,6 +135,7 @@ void ModuleDescriptionLookup::addEssentialModules()
134135
addModuleDesc<ScaleFieldMeshAndData>("NOT WORKING YET--Real ported module", "...");
135136
addModuleDesc<ProjectPointsOntoMesh>("Real ported module", "...");
136137
addModuleDesc<CalculateDistanceToField>("Real ported module", "...");
138+
addModuleDesc<CalculateDistanceToFieldBoundary>("Real ported module", "...");
137139
}
138140

139141
void ModuleDescriptionLookup::addBundleModules()

src/Modules/Legacy/Fields/CalculateDistanceToField.cc

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 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
@@ -29,23 +29,11 @@
2929
#include <Modules/Legacy/Fields/CalculateDistanceToField.h>
3030

3131
#include <Core/Datatypes/Legacy/Field/Field.h>
32-
#include <Core/Datatypes/Matrix.h>
3332

3433
#include <Core/Algorithms/Legacy/Fields/DistanceField/CalculateDistanceField.h>
3534

36-
/// @class CalculateDistanceToField
37-
/// @brief Calculate the distance field to a mesh.
38-
39-
// class CalculateDistanceToField : public Module
40-
// {
41-
// private:
42-
// GuiInt gui_truncate_;
43-
// GuiDouble gui_truncate_distance_;
44-
// GuiString gui_datatype_;
45-
// GuiString gui_basistype_;
46-
//
47-
// SCIRunAlgo::CalculateDistanceFieldAlgo algo_;
48-
// };
35+
/// @class CalculateDistanceToField
36+
/// @brief Calculate the distance field to a mesh.
4937

5038
using namespace SCIRun::Modules::Fields;
5139
using namespace SCIRun::Core::Algorithms;
@@ -55,7 +43,7 @@ using namespace SCIRun::Core::Datatypes;
5543
using namespace SCIRun;
5644

5745

58-
ModuleLookupInfo CalculateDistanceToField::staticInfo_("CalculateDistanceToField", "ChangeFieldData", "SCIRun");
46+
const ModuleLookupInfo CalculateDistanceToField::staticInfo_("CalculateDistanceToField", "ChangeFieldData", "SCIRun");
5947

6048
CalculateDistanceToField::CalculateDistanceToField() : Module(staticInfo_)
6149
{
@@ -78,9 +66,9 @@ CalculateDistanceToField::execute()
7866
{
7967
auto input = getRequiredInput(InputField);
8068
auto object = getRequiredInput(ObjectField);
81-
69+
8270
bool value_connected = oport_connected(ValueField);
83-
71+
8472
// if (inputs_changed_ || !oport_cached("DistanceField") ||
8573
// (!oport_cached("ValueField") && value_connected) ||
8674
// gui_truncate_.changed() || gui_truncate_distance_.changed())
@@ -92,17 +80,17 @@ CalculateDistanceToField::execute()
9280
setAlgoDoubleFromState(Parameters::TruncateDistance);
9381
setAlgoOptionFromState(Parameters::BasisType);
9482
setAlgoOptionFromState(Parameters::OutputFieldDatatype);
95-
83+
9684
auto inputs = make_input((InputField, input)(ObjectField, object));
9785

9886
algo().set(Parameters::OutputValueField, value_connected);
9987
auto output = algo().run_generic(inputs);
10088

101-
sendOutputFromAlgorithm(DistanceField, output);
89+
sendOutputFromAlgorithm(DistanceField, output);
10290

10391
if (value_connected)
10492
{
105-
sendOutputFromAlgorithm(ValueField, output);
93+
sendOutputFromAlgorithm(ValueField, output);
10694
}
10795
}
10896
}

0 commit comments

Comments
 (0)