Skip to content

Commit 2501c3a

Browse files
committed
Hook up algo->module
1 parent 2e5dc63 commit 2501c3a

File tree

4 files changed

+54
-84
lines changed

4 files changed

+54
-84
lines changed

src/Core/Algorithms/Factory/HardCodedAlgorithmFactory.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <Core/Algorithms/Legacy/Fields/Mapping/MapFieldDataOntoNodes.h>
3333
#include <Core/Algorithms/Legacy/Fields/Mapping/MapFieldDataOntoElems.h>
3434
#include <Core/Algorithms/Legacy/Fields/Mapping/MapFieldDataFromSourceToDestination.h>
35-
#include <Core/Algorithms/Legacy/Fields/FieldData/BuildMatrixOfSurfaceNormalsAlgo.h>
35+
#include <Core/Algorithms/Legacy/Fields/FieldData/BuildMatrixOfSurfaceNormalsAlgo.h>
3636
#include <Core/Algorithms/Legacy/Fields/MeshDerivatives/GetFieldBoundaryAlgo.h>
3737
#include <Core/Algorithms/Legacy/Fields/DistanceField/CalculateSignedDistanceField.h>
3838
#include <Core/Algorithms/Legacy/Fields/DistanceField/CalculateDistanceField.h>
@@ -43,7 +43,7 @@
4343
#include <Core/Algorithms/Legacy/Fields/MeshData/GetMeshNodes.h>
4444
#include <Core/Algorithms/Legacy/Fields/MeshData/SetMeshNodes.h>
4545
#include <Core/Algorithms/Legacy/Fields/MeshData/FlipSurfaceNormals.h>
46-
#include <Core/Algorithms/Legacy/Fields/RefineMesh/RefineMesh.h>
46+
#include <Core/Algorithms/Legacy/Fields/RefineMesh/RefineMesh.h>
4747
#include <Core/Algorithms/Legacy/Fields/FieldData/GetFieldData.h>
4848
#include <Core/Algorithms/Legacy/Fields/FieldData/SetFieldData.h>
4949
#include <Core/Algorithms/Legacy/Fields/ConvertMeshType/ConvertMeshToIrregularMesh.h>
@@ -55,9 +55,10 @@
5555
#include <Core/Algorithms/Legacy/Fields/SmoothMesh/FairMesh.h>
5656
#include <Core/Algorithms/Legacy/Fields/TransformMesh/ScaleFieldMeshAndData.h>
5757
#include <Core/Algorithms/Legacy/Fields/TransformMesh/ProjectPointsOntoMesh.h>
58-
#include <Core/Algorithms/Legacy/Fields/FieldData/SwapFieldDataWithMatrixEntriesAlgo.h>
59-
#include <Core/Algorithms/Legacy/Fields/FieldData/ConvertIndicesToFieldDataAlgo.h>
58+
#include <Core/Algorithms/Legacy/Fields/FieldData/SwapFieldDataWithMatrixEntriesAlgo.h>
59+
#include <Core/Algorithms/Legacy/Fields/FieldData/ConvertIndicesToFieldDataAlgo.h>
6060
#include <Core/Algorithms/Legacy/Fields/Mapping/BuildMappingMatrixAlgo.h>
61+
#include <Core/Algorithms/Legacy/Fields/StreamLines/GenerateStreamLines.h>
6162
#include <Core/Algorithms/Math/AddKnownsToLinearSystem.h>
6263
#include <Core/Algorithms/Math/LinearSystem/SolveLinearSystemAlgo.h>
6364
#include <Core/Algorithms/Math/ReportMatrixInfo.h>
@@ -124,7 +125,7 @@ void HardCodedAlgorithmFactory::addToMakerMap()
124125
ADD_MODULE_ALGORITHM(GenerateROIStatistics, GenerateROIStatisticsAlgorithm)
125126
ADD_MODULE_ALGORITHM(SetFieldNodes, SetMeshNodesAlgo)
126127
ADD_MODULE_ALGORITHM(ReportFieldInfo, ReportFieldInfoAlgorithm)
127-
ADD_MODULE_ALGORITHM(BuildMatrixOfSurfaceNormals, BuildMatrixOfSurfaceNormalsAlgo)
128+
ADD_MODULE_ALGORITHM(BuildMatrixOfSurfaceNormals, BuildMatrixOfSurfaceNormalsAlgo)
128129
ADD_MODULE_ALGORITHM(ReportMatrixInfo, ReportMatrixInfoAlgorithm)
129130
ADD_MODULE_ALGORITHM(AppendMatrix, AppendMatrixAlgorithm)
130131
ADD_MODULE_ALGORITHM(ReadMatrix, ReadMatrixAlgorithm)
@@ -150,6 +151,7 @@ void HardCodedAlgorithmFactory::addToMakerMap()
150151
ADD_MODULE_ALGORITHM(MapFieldDataFromElemToNode, MapFieldDataFromElemToNodeAlgo)
151152
ADD_MODULE_ALGORITHM(ResampleRegularMesh, ResampleRegularMeshAlgo)
152153
ADD_MODULE_ALGORITHM(FairMesh, FairMeshAlgo)
154+
ADD_MODULE_ALGORITHM(GenerateStreamLines, GenerateStreamLinesAlgo)
153155
ADD_MODULE_ALGORITHM(ScaleFieldMeshAndData, ScaleFieldMeshAndDataAlgo)
154156
ADD_MODULE_ALGORITHM(ConvertFieldBasis, ConvertFieldBasisTypeAlgo)
155157
ADD_MODULE_ALGORITHM(ProjectPointsOntoMesh, ProjectPointsOntoMeshAlgo)
@@ -164,11 +166,11 @@ void HardCodedAlgorithmFactory::addToMakerMap()
164166
ADD_MODULE_ALGORITHM(RefineMesh, RefineMeshAlgo)
165167
ADD_MODULE_ALGORITHM(SetFieldDataToConstantValue, SetFieldDataToConstantValueAlgo)
166168
ADD_MODULE_ALGORITHM(SwapFieldDataWithMatrixEntries, SwapFieldDataWithMatrixEntriesAlgo)
167-
ADD_MODULE_ALGORITHM(FlipSurfaceNormals,FlipSurfaceNormalsAlgo)
168-
ADD_MODULE_ALGORITHM(BuildNoiseColumnMatrix,BuildNoiseColumnMatrixAlgorithm)
169+
ADD_MODULE_ALGORITHM(FlipSurfaceNormals,FlipSurfaceNormalsAlgo)
170+
ADD_MODULE_ALGORITHM(BuildNoiseColumnMatrix,BuildNoiseColumnMatrixAlgorithm)
169171
ADD_MODULE_ALGORITHM(BuildMappingMatrix, BuildMappingMatrixAlgo)
170-
ADD_MODULE_ALGORITHM(ConvertIndicesToFieldData, ConvertIndicesToFieldDataAlgo)
171-
ADD_MODULE_ALGORITHM(ComputeSVD, ComputeSVDAlgo)
172+
ADD_MODULE_ALGORITHM(ConvertIndicesToFieldData, ConvertIndicesToFieldDataAlgo)
173+
ADD_MODULE_ALGORITHM(ComputeSVD, ComputeSVDAlgo)
172174
;
173175
}
174176
}

src/Core/Algorithms/Legacy/Fields/StreamLines/GenerateStreamLines.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ bool GenerateStreamLinesAlgo::runImpl(FieldHandle input, FieldHandle seeds, Fiel
740740
return (success);
741741
}
742742

743-
const AlgorithmInputName GenerateStreamLinesAlgo::VectorField("VectorField");
744-
const AlgorithmInputName GenerateStreamLinesAlgo::Seeds("Seeds");
743+
const AlgorithmInputName GenerateStreamLinesAlgo::VectorField("Vector_Field");
744+
const AlgorithmInputName GenerateStreamLinesAlgo::Seeds("Seed_Points");
745745
const AlgorithmOutputName GenerateStreamLinesAlgo::Streamlines("Streamlines");
746746

747747
AlgorithmOutput GenerateStreamLinesAlgo::run_generic(const AlgorithmInput& input) const

src/Modules/Legacy/Visualization/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#
22
# For more information, please see: http://software.sci.utah.edu
3-
#
3+
#
44
# The MIT License
5-
#
5+
#
66
# Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
# University of Utah.
8-
#
9-
#
8+
#
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
1313
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1414
# and/or sell copies of the Software, and to permit persons to whom the
1515
# Software is furnished to do so, subject to the following conditions:
16-
#
16+
#
1717
# The above copyright notice and this permission notice shall be included
1818
# in all copies or substantial portions of the Software.
19-
#
19+
#
2020
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2121
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2222
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -60,7 +60,7 @@ SET(Modules_Legacy_Visualization_HEADERS
6060
share.h
6161
)
6262

63-
SCIRUN_ADD_LIBRARY(Modules_Legacy_Visualization
63+
SCIRUN_ADD_LIBRARY(Modules_Legacy_Visualization
6464
${Modules_Legacy_Visualization_SRCS}
6565
${Modules_Legacy_Visualization_HEADERS})
6666

@@ -69,7 +69,7 @@ TARGET_LINK_LIBRARIES(Modules_Legacy_Visualization
6969
#Dataflow_Widgets
7070
#Dataflow_GuiInterface
7171
#Dataflow_TkExtensions
72-
#Core_Algorithms_Legacy_Fields
72+
Core_Algorithms_Legacy_Fields
7373
Algorithms_Base
7474
#Core_Algorithms_Visualization
7575
#Core_Algorithms_Geometry

src/Modules/Legacy/Visualization/GenerateStreamLines.cc

Lines changed: 33 additions & 65 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
@@ -31,49 +31,19 @@
3131
// Date : July 2006
3232

3333
#include <Modules/Legacy/Visualization/GenerateStreamLines.h>
34-
//#include <Core/Algorithms/Fields/StreamLines/GenerateStreamLines.h>
34+
#include <Core/Algorithms/Legacy/Fields/StreamLines/GenerateStreamLines.h>
35+
#include <Core/Datatypes/Legacy/Field/Field.h>
3536

3637
using namespace SCIRun::Modules::Visualization;
3738
using namespace SCIRun::Core::Datatypes;
3839
using namespace SCIRun::Dataflow::Networks;
3940
using namespace SCIRun::Core::Algorithms;
41+
using namespace SCIRun::Core::Algorithms::Fields;
4042
using namespace SCIRun;
4143

42-
/*
43-
class GenerateStreamLines : public Module {
44-
public:
45-
GenerateStreamLines(GuiContext* ctx);
46-
virtual ~GenerateStreamLines() {}
47-
48-
virtual void execute();
49-
50-
private:
51-
GuiDouble gui_step_size_;
52-
GuiDouble gui_tolerance_;
53-
GuiInt gui_max_steps_;
54-
GuiInt gui_direction_;
55-
GuiInt gui_value_;
56-
GuiInt gui_remove_colinear_pts_;
57-
GuiInt gui_method_;
58-
GuiInt gui_auto_parameterize_;
59-
60-
SCIRunAlgo::GenerateStreamLinesAlgo algo_;
61-
};
62-
*/
63-
6444
const ModuleLookupInfo GenerateStreamLines::staticInfo_("GenerateStreamLines", "Visualization", "SCIRun");
6545

6646
GenerateStreamLines::GenerateStreamLines() : Module(staticInfo_)
67-
/*
68-
gui_step_size_(get_ctx()->subVar("stepsize"), 0.01),
69-
gui_tolerance_(get_ctx()->subVar("tolerance"), 0.0001),
70-
gui_max_steps_(get_ctx()->subVar("maxsteps"), 2000),
71-
gui_direction_(get_ctx()->subVar("direction"), 1),
72-
gui_value_(get_ctx()->subVar("value"), 1),
73-
gui_remove_colinear_pts_(get_ctx()->subVar("remove-colinear-points"), 1),
74-
gui_method_(get_ctx()->subVar("method"), 4),
75-
gui_auto_parameterize_(get_ctx()->subVar("auto-parameterize"), false)
76-
*/
7747
{
7848
INITIALIZE_PORT(Vector_Field);
7949
INITIALIZE_PORT(Seed_Points);
@@ -82,52 +52,50 @@ gui_step_size_(get_ctx()->subVar("stepsize"), 0.01),
8252

8353
void GenerateStreamLines::setStateDefaults()
8454
{
85-
//TODO
55+
auto state = get_state();
56+
setStateIntFromAlgo(Parameters::StreamlineDirection);
57+
setStateIntFromAlgo(Parameters::StreamlineValue);
58+
setStateIntFromAlgo(Parameters::StreamlineMaxSteps);
59+
setStateDoubleFromAlgo(Parameters::StreamlineStepSize);
60+
setStateDoubleFromAlgo(Parameters::StreamlineTolerance);
61+
setStateStringFromAlgoOption(Parameters::StreamlineMethod); // 4?
62+
setStateBoolFromAlgo(Parameters::AutoParameters);
63+
setStateBoolFromAlgo(Parameters::RemoveColinearPoints);
8664
}
8765

8866
void GenerateStreamLines::execute()
8967
{
90-
/*
91-
FieldHandle input, seeds, output;
92-
93-
get_input_handle( "Vector Field", input, true );
94-
get_input_handle( "Seed Points", seeds, true );
95-
96-
97-
if( inputs_changed_ ||
98-
!oport_cached("Streamlines") ||
99-
gui_tolerance_.changed( true ) ||
100-
gui_step_size_.changed( true ) ||
101-
gui_max_steps_.changed( true ) ||
102-
gui_direction_.changed( true ) ||
103-
gui_value_.changed( true ) ||
104-
gui_remove_colinear_pts_.changed( true ) ||
105-
gui_method_.changed( true ) ||
106-
gui_auto_parameterize_.changed( true ))
68+
auto input = getRequiredInput(Vector_Field);
69+
auto seeds = getRequiredInput(Seed_Points);
70+
71+
if (needToExecute())
10772
{
108-
// Inform module that execution started
10973
update_state(Executing);
11074

111-
algo_.set_scalar("tolerance",gui_tolerance_.get());
112-
algo_.set_scalar("step_size",gui_step_size_.get());
113-
algo_.set_int("max_steps",gui_max_steps_.get());
114-
algo_.set_int("direction",gui_direction_.get());
115-
algo_.set_int("value",gui_value_.get());
116-
algo_.set_bool("remove_colinear_points",gui_remove_colinear_pts_.get());
75+
setAlgoDoubleFromState(Parameters::StreamlineStepSize);
76+
setAlgoDoubleFromState(Parameters::StreamlineTolerance);
77+
setAlgoIntFromState(Parameters::StreamlineDirection);
78+
setAlgoIntFromState(Parameters::StreamlineValue);
79+
setAlgoIntFromState(Parameters::StreamlineMaxSteps);
80+
setAlgoBoolFromState(Parameters::RemoveColinearPoints);
81+
setAlgoBoolFromState(Parameters::AutoParameters);
82+
setAlgoOptionFromState(Parameters::StreamlineMethod);
83+
/*
11784
int method = gui_method_.get();
11885
if (method == 0) algo_.set_option("method","AdamsBashforth");
11986
else if (method == 2) algo_.set_option("method","Heun");
12087
else if (method == 3) algo_.set_option("method","RungeKutta");
12188
else if (method == 4) algo_.set_option("method","RungeKuttaFehlberg");
12289
else if (method == 5) algo_.set_option("method","CellWalk");
123-
algo_.set_bool("auto_parameters",gui_auto_parameterize_.get());
124-
125-
if(!(algo_.run(input,seeds,output))) return;
90+
*/
91+
92+
auto output = algo().run_generic(withInputData((Vector_Field, input)(Seed_Points, seeds)));
93+
94+
#ifdef NEED_ALGO_OUTPUT
12695
gui_tolerance_.set(algo_.get_scalar("tolerance"));
12796
gui_step_size_.set(algo_.get_scalar("step_size"));
128-
get_ctx()->reset();
97+
#endif
12998

130-
send_output_handle( "Streamlines", output, true );
99+
sendOutputFromAlgorithm(Streamlines, output);
131100
}
132-
*/
133101
}

0 commit comments

Comments
 (0)