Skip to content

Commit 216c6e2

Browse files
committed
Finish algo
1 parent d8a327f commit 216c6e2

File tree

3 files changed

+75
-85
lines changed

3 files changed

+75
-85
lines changed

src/Modules/Legacy/Forward/CalcTMP.cc

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,10 @@ using namespace SCIRun;
3434
using namespace SCIRun::Core::Datatypes;
3535
using namespace SCIRun::Modules::Forward;
3636
using namespace SCIRun::Dataflow::Networks;
37-
//using namespace SCIRun::Core::Algorithms::Forward;
37+
using namespace SCIRun::Core::Algorithms::Forward;
3838

3939
const ModuleLookupInfo CalcTMP::staticInfo_("CalcTMP", "Forward", "SCIRun");
4040

41-
/*
42-
class CalcTMP : public Module, public CalcTMPAlgo {
43-
public:
44-
CalcTMP(GuiContext*);
45-
virtual ~CalcTMP() {}
46-
47-
virtual void execute();
48-
49-
private:
50-
//SCIRunAlgo::CalcTMPAlgo algo_;
51-
CalcTMPAlgo algo_;
52-
};
53-
*/
54-
5541
CalcTMP::CalcTMP()
5642
: Module(staticInfo_, false)
5743
{
@@ -63,7 +49,6 @@ CalcTMP::CalcTMP()
6349
INITIALIZE_PORT(Repolarization_Slope);
6450
INITIALIZE_PORT(Rest_Potential);
6551
INITIALIZE_PORT(TMPs);
66-
//algo_.set_progress_reporter(this);
6752
}
6853

6954

@@ -82,7 +67,9 @@ void CalcTMP::execute()
8267
if (needToExecute())
8368
{
8469
const int numSamples = 500;
85-
BioPSE::CalcTMPAlgo algo;
70+
//TODO: algo hookup
71+
CalcTMPAlgo algo;
72+
algo.setLogger(getLogger());
8673
algo.calc_TMPs(amplitudes,
8774
deps,
8875
depslopes,

src/Modules/Legacy/Forward/CalcTMPAlgo.cc

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
#include <Core/Datatypes/MatrixTypeConversions.h>
4242
#include <Core/Datatypes/DenseMatrix.h>
4343

44-
namespace BioPSE {
45-
4644
using namespace SCIRun;
4745
using namespace SCIRun::Core::Datatypes;
46+
using namespace SCIRun::Core::Algorithms::Forward;
4847

4948
bool CalcTMPAlgo::calc_single_TMP(
5049
const double amplitude,
@@ -161,20 +160,20 @@ bool CalcTMPAlgo::calc_all_TMPs(
161160
DenseMatrix mat(1, TMP_values.ncols());
162161
for(index_type node = 0; node < nnodes; ++node)
163162
{
164-
if (!calc_single_TMP(amplitudes.get(node,0),
165-
deps.get(node,0),
166-
depslopes.get(node,0),
167-
platslopes.get(node,0),
168-
reps.get(node,0),
169-
repslopes.get(node,0),
170-
rests.get(node,0),
163+
if (!calc_single_TMP(amplitudes(node,0),
164+
deps(node,0),
165+
depslopes(node,0),
166+
platslopes(node,0),
167+
reps(node,0),
168+
repslopes(node,0),
169+
rests(node,0),
171170
mat))
172171
{
173172
return false;
174173
}
175174
for(index_type t = 0; t < TMP_values.ncols(); ++t)
176175
{
177-
TMP_values.put(node, t, mat.get(0, t));
176+
TMP_values(node, t) = mat(0, t);
178177
}
179178
}
180179

@@ -205,20 +204,15 @@ bool CalcTMPAlgo::calc_TMPs(MatrixHandle amplitudes,
205204

206205
output.reset(new DenseMatrix(amplitudes->nrows(), nsamples));
207206

207+
//TODO: refactor algo to take DenseMatrix directly from module
208208
DenseMatrixHandle ampDense(matrix_cast::as_dense(amplitudes));
209-
210-
return calc_all_TMPs(*ampDense,
211-
*ampDense,*ampDense,*ampDense,*ampDense,*ampDense,*ampDense,
212-
//
213-
// *(deps->dense()),
214-
// *(depslopes->dense()),
215-
// *(platslopes->dense()),
216-
// *(reps->dense()),
217-
// *(repslopes->dense()),
218-
// *(rests->dense()),
219-
220-
*output);
209+
DenseMatrixHandle depsDense(matrix_cast::as_dense(deps));
210+
DenseMatrixHandle depslopesDense(matrix_cast::as_dense(depslopes));
211+
DenseMatrixHandle platslopesDense(matrix_cast::as_dense(platslopes));
212+
DenseMatrixHandle repsDense(matrix_cast::as_dense(reps));
213+
DenseMatrixHandle repslopesDense(matrix_cast::as_dense(repslopes));
214+
DenseMatrixHandle restsDense(matrix_cast::as_dense(rests));
215+
216+
return calc_all_TMPs(*ampDense, *depsDense, *depslopesDense, *platslopesDense, *repsDense, *repslopesDense, *restsDense,
217+
*output);
221218
}
222-
223-
224-
} // end namespace BioPSE

src/Modules/Legacy/Forward/CalcTMPAlgo.h

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,58 @@
4444
#include <Core/Algorithms/Base/AlgorithmBase.h>
4545
#include <Modules/Legacy/Forward/share.h>
4646

47-
namespace BioPSE {
48-
49-
50-
class SCISHARE CalcTMPAlgo : public SCIRun::Core::Algorithms::AlgorithmBase
47+
namespace SCIRun
5148
{
52-
public:
53-
54-
// assumes TMP_values is sized to 1 x nsamples
55-
bool calc_single_TMP(const double amplitude,
56-
const double dep,
57-
const double depslope,
58-
const double platslope,
59-
const double rep,
60-
const double repslope,
61-
const double rest,
62-
SCIRun::Core::Datatypes::DenseMatrix& TMP_values);
63-
64-
// assumes TMP_values is already sized to nnodes x nsamples
65-
bool calc_all_TMPs(const SCIRun::Core::Datatypes::DenseMatrix& amplitudes,
66-
const SCIRun::Core::Datatypes::DenseMatrix& deps,
67-
const SCIRun::Core::Datatypes::DenseMatrix& depslopes,
68-
const SCIRun::Core::Datatypes::DenseMatrix& platslopes,
69-
const SCIRun::Core::Datatypes::DenseMatrix& reps,
70-
const SCIRun::Core::Datatypes::DenseMatrix& repslopes,
71-
const SCIRun::Core::Datatypes::DenseMatrix& rests,
72-
SCIRun::Core::Datatypes::DenseMatrix& TMP_values);
73-
74-
75-
// normal entry case
76-
bool calc_TMPs(SCIRun::Core::Datatypes::MatrixHandle amplitudes,
77-
SCIRun::Core::Datatypes::MatrixHandle deps,
78-
SCIRun::Core::Datatypes::MatrixHandle depslopes,
79-
SCIRun::Core::Datatypes::MatrixHandle platslopes,
80-
SCIRun::Core::Datatypes::MatrixHandle reps,
81-
SCIRun::Core::Datatypes::MatrixHandle repslopes,
82-
SCIRun::Core::Datatypes::MatrixHandle rests,
83-
unsigned int nsamples,
84-
SCIRun::Core::Datatypes::DenseMatrixHandle& output);
85-
86-
virtual SCIRun::Core::Algorithms::AlgorithmOutput run_generic(const SCIRun::Core::Algorithms::AlgorithmInput&) const override { throw "todo"; }
87-
};
88-
89-
90-
} // end namespace BioPSE
49+
namespace Core
50+
{
51+
namespace Algorithms
52+
{
53+
namespace Forward
54+
{
55+
56+
class SCISHARE CalcTMPAlgo : public AlgorithmBase
57+
{
58+
public:
59+
60+
// assumes TMP_values is sized to 1 x nsamples
61+
bool calc_single_TMP(const double amplitude,
62+
const double dep,
63+
const double depslope,
64+
const double platslope,
65+
const double rep,
66+
const double repslope,
67+
const double rest,
68+
Datatypes::DenseMatrix& TMP_values);
69+
70+
// assumes TMP_values is already sized to nnodes x nsamples
71+
bool calc_all_TMPs(const Datatypes::DenseMatrix& amplitudes,
72+
const Datatypes::DenseMatrix& deps,
73+
const Datatypes::DenseMatrix& depslopes,
74+
const Datatypes::DenseMatrix& platslopes,
75+
const Datatypes::DenseMatrix& reps,
76+
const Datatypes::DenseMatrix& repslopes,
77+
const Datatypes::DenseMatrix& rests,
78+
Datatypes::DenseMatrix& TMP_values);
79+
80+
81+
// normal entry case
82+
bool calc_TMPs(Datatypes::MatrixHandle amplitudes,
83+
Datatypes::MatrixHandle deps,
84+
Datatypes::MatrixHandle depslopes,
85+
Datatypes::MatrixHandle platslopes,
86+
Datatypes::MatrixHandle reps,
87+
Datatypes::MatrixHandle repslopes,
88+
Datatypes::MatrixHandle rests,
89+
unsigned int nsamples,
90+
Datatypes::DenseMatrixHandle& output);
91+
92+
virtual AlgorithmOutput run_generic(const AlgorithmInput&) const override { throw "todo next lunch"; }
93+
};
94+
95+
96+
}
97+
}
98+
}
99+
}
91100

92101
#endif

0 commit comments

Comments
 (0)