Skip to content

Commit a319751

Browse files
committed
Merge branch 'master' into travisRunTesting
2 parents 41f5bbd + cad89c2 commit a319751

File tree

16 files changed

+588
-31
lines changed

16 files changed

+588
-31
lines changed

src/Core/Algorithms/Legacy/Fields/RegisterWithCorrespondences.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ RegisterWithCorrespondencesAlgo::RegisterWithCorrespondencesAlgo()
5454

5555
AlgorithmOutput RegisterWithCorrespondencesAlgo::run_generic(const AlgorithmInput& input) const
5656
{
57-
std::cout << "ALGO" << std::endl;
5857
auto input_field = input.get<Field>(Variables::InputField);
5958
auto corres1 = input.get<Field>(Correspondences1);
6059
auto corres2 = input.get<Field>(Correspondences2);
@@ -65,15 +64,12 @@ AlgorithmOutput RegisterWithCorrespondencesAlgo::run_generic(const AlgorithmInpu
6564
switch (op)
6665
{
6766
case 0:
68-
std::cout << "runM" << std::endl;
6967
runM(input_field, corres1, corres2, return_field);
7068
break;
7169
case 1:
72-
std::cout << "runA" << std::endl;
7370
runA(input_field, corres1, corres2, return_field);
7471
break;
7572
case 2:
76-
std::cout << "runN" << std::endl;
7773
runN(input_field, corres1, corres2, return_field);
7874
break;
7975
}
@@ -227,10 +223,10 @@ bool RegisterWithCorrespondencesAlgo::runM(FieldHandle input, FieldHandle Cors1,
227223
Bm(3, L1) = 1;
228224

229225
//vertical x,y,z
230-
Bm(L1 + 4) = num_cors1, P.x();
231-
Bm(L1 + 4) = num_cors1 + 1, P.y();
232-
Bm(L1 + 4) = num_cors1 + 2, P.z();
233-
Bm(L1 + 4) = num_cors1 + 3, 1;
226+
Bm(L1 + 4, num_cors1) = P.x();
227+
Bm(L1 + 4, num_cors1 + 1) = P.y();
228+
Bm(L1 + 4, num_cors1 + 2) = P.z();
229+
Bm(L1 + 4, num_cors1 + 3) = 1;
234230
}
235231

236232
for (int L1 = num_cors1; L1 < num_cors1 + 4; ++L1)
@@ -244,7 +240,6 @@ bool RegisterWithCorrespondencesAlgo::runM(FieldHandle input, FieldHandle Cors1,
244240
//put in sigmas
245241
DenseMatrixHandle SMat;
246242
radial_basis_func(icors2, icors2, SMat);
247-
double temp = 0;
248243

249244
for (int i = 0; i < num_cors1; ++i)
250245
{
@@ -754,7 +749,6 @@ bool RegisterWithCorrespondencesAlgo::make_new_pointsA(VMesh* points, VMesh* Cor
754749
Point P, Pp;
755750

756751
points->size(num_pts);
757-
int msz = coefs.size();
758752

759753
for (int i = 0; i < num_pts; ++i)
760754
{

src/Dataflow/Network/Module.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#include <Core/Thread/Mutex.h>
4747
#include <Core/Thread/Interruptible.h>
4848

49+
//TODO remove once method is extracted below
50+
#include <Dataflow/Network/Connection.h>
51+
4952
using namespace SCIRun::Dataflow::Networks;
5053
using namespace SCIRun::Engine::State;
5154
using namespace SCIRun::Core::Logging;
@@ -292,7 +295,7 @@ bool Module::do_execute() throw()
292295
{
293296
error(std::string("MODULE ERROR: std::exception caught: ") + e.what());
294297
}
295-
catch (const boost::thread_interrupted& e)
298+
catch (const boost::thread_interrupted&)
296299
{
297300
error("MODULE ERROR: execution thread interrupted by user.");
298301
threadStopValue = true;
@@ -337,6 +340,7 @@ void Module::set_state(ModuleStateHandle state)
337340
{
338341
state_ = state;
339342
initStateObserver(state_.get());
343+
postStateChangeInternalSignalHookup();
340344
}
341345

342346
AlgorithmBase& Module::algo()
@@ -509,7 +513,9 @@ Module::Builder& Module::Builder::using_func(ModuleMaker create)
509513
Module::Builder& Module::Builder::setStateDefaults()
510514
{
511515
if (module_)
516+
{
512517
module_->setStateDefaults();
518+
}
513519
return *this;
514520
}
515521

@@ -912,3 +918,17 @@ bool Module::isStoppable() const
912918
{
913919
return dynamic_cast<const Core::Thread::Interruptible*>(this) != nullptr;
914920
}
921+
922+
void Module::sendFeedbackUpstreamAlongIncomingConnections(const Variable::Value& info)
923+
{
924+
for (auto& inputPort : inputPorts())
925+
{
926+
if (inputPort->nconnections() > 0)
927+
{
928+
auto connection = inputPort->connection(0); // only one incoming connection for input ports
929+
VariableHandle feedback(new Variable(Name(inputPort->id().toString()), info));
930+
//TODO: extract port method
931+
connection->oport_->sendConnectionFeedback(feedback);
932+
}
933+
}
934+
}

src/Dataflow/Network/Module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ namespace Networks {
259259
size_t add_output_port(OutputPortHandle);
260260
virtual void removeInputPort(const PortId& id);
261261

262+
//For modules that need to initialize some internal state signal/slots, this needs to be called after set_state to reinitialize.
263+
virtual void postStateChangeInternalSignalHookup() {}
264+
void sendFeedbackUpstreamAlongIncomingConnections(const Core::Algorithms::Variable::Value& info);
265+
262266
private:
263267
template <class T>
264268
boost::shared_ptr<T> getRequiredInputAtIndex(const PortId& id);

src/Dataflow/Network/Port.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ size_t Port::nconnections() const
8484
return connections_.size();
8585
}
8686

87-
ModuleId Port::getUnderlyingModuleId() const
87+
ModuleId Port::getUnderlyingModuleId() const
8888
{
8989
return module_->get_id();
9090
}
9191

92-
size_t Port::getIndex() const
92+
size_t Port::getIndex() const
9393
{
9494
return index_;
9595
}
@@ -148,9 +148,9 @@ bool InputPort::hasChanged() const
148148

149149
boost::signals2::connection InputPort::connectDataOnPortHasChanged(const DataOnPortHasChangedSignalType::slot_type& subscriber)
150150
{
151-
return sink()->connectDataHasChanged([this, subscriber] (DatatypeHandle data)
152-
{
153-
subscriber(this->id(), data);
151+
return sink()->connectDataHasChanged([this, subscriber] (DatatypeHandle data)
152+
{
153+
subscriber(this->id(), data);
154154
});
155155
}
156156

@@ -200,3 +200,13 @@ PortDataDescriber OutputPort::getPortDataDescriber() const
200200
{
201201
return [this]() { return source_->describeData(); };
202202
}
203+
204+
boost::signals2::connection OutputPort::connectConnectionFeedbackListener(const ConnectionFeedbackSignalType::slot_type& subscriber)
205+
{
206+
return cxnFeedback_.connect(subscriber);
207+
}
208+
209+
void OutputPort::sendConnectionFeedback(SCIRun::Core::Algorithms::VariableHandle info)
210+
{
211+
cxnFeedback_(info);
212+
}

src/Dataflow/Network/Port.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
#ifndef DATAFLOW_NETWORK_PORT_H
33-
#define DATAFLOW_NETWORK_PORT_H
33+
#define DATAFLOW_NETWORK_PORT_H
3434

3535
#include <string>
3636
#include <vector>
@@ -43,7 +43,7 @@
4343
namespace SCIRun {
4444
namespace Dataflow {
4545
namespace Networks {
46-
46+
4747
class SCISHARE Port : virtual public PortInterface, boost::noncopyable
4848
{
4949
public:
@@ -125,8 +125,11 @@ class SCISHARE OutputPort : public Port, public OutputPortInterface
125125
virtual bool hasData() const override;
126126
virtual void attach(Connection* conn) override;
127127
virtual PortDataDescriber getPortDataDescriber() const override;
128+
virtual boost::signals2::connection connectConnectionFeedbackListener(const ConnectionFeedbackSignalType::slot_type& subscriber) override;
129+
virtual void sendConnectionFeedback(SCIRun::Core::Algorithms::VariableHandle info) override;
128130
private:
129131
DatatypeSourceInterfaceHandle source_;
132+
ConnectionFeedbackSignalType cxnFeedback_;
130133
};
131134

132135
#ifdef WIN32

src/Dataflow/Network/PortInterface.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232

3333

3434
#ifndef DATAFLOW_NETWORK_PORT_INTERFACE_H
35-
#define DATAFLOW_NETWORK_PORT_INTERFACE_H
35+
#define DATAFLOW_NETWORK_PORT_INTERFACE_H
3636

3737
#include <string>
3838
#include <vector>
3939
#include <boost/signals2/signal.hpp>
4040
#include <Dataflow/Network/NetworkFwd.h>
4141
#include <Core/Datatypes/Datatype.h>
42+
#include <Core/Algorithms/Base/Variable.h>
4243
#include <Dataflow/Network/share.h>
4344

4445
namespace SCIRun {
@@ -69,7 +70,7 @@ namespace Networks {
6970
virtual void setIndex(size_t index) = 0;
7071
virtual void setId(const PortId& id) = 0;
7172
};
72-
73+
7374
typedef boost::signals2::signal<void(const PortId&, SCIRun::Core::Datatypes::DatatypeHandle)> DataOnPortHasChangedSignalType;
7475
typedef boost::function<std::string()> PortDataDescriber;
7576

@@ -83,7 +84,9 @@ namespace Networks {
8384
virtual bool hasChanged() const = 0;
8485
virtual boost::signals2::connection connectDataOnPortHasChanged(const DataOnPortHasChangedSignalType::slot_type& subscriber) = 0;
8586
};
86-
87+
88+
typedef boost::signals2::signal<void(SCIRun::Core::Algorithms::VariableHandle)> ConnectionFeedbackSignalType;
89+
8790
class SCISHARE OutputPortInterface : virtual public PortInterface
8891
{
8992
public:
@@ -92,6 +95,8 @@ namespace Networks {
9295
virtual bool hasData() const = 0;
9396
virtual OutputPortInterface* clone() const { return 0; } // TODO
9497
virtual PortDataDescriber getPortDataDescriber() const = 0;
98+
virtual boost::signals2::connection connectConnectionFeedbackListener(const ConnectionFeedbackSignalType::slot_type& subscriber) = 0;
99+
virtual void sendConnectionFeedback(SCIRun::Core::Algorithms::VariableHandle info) = 0;
95100
};
96101

97102
class SCISHARE PortConnectionDeterminer

src/Dataflow/Network/Tests/MockPorts.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace SCIRun {
5454

5555
typedef boost::shared_ptr<MockPortDescription> MockPortDescriptionPtr;
5656

57-
class MockInputPort : public InputPortInterface
57+
class MockInputPort : public InputPortInterface
5858
{
5959
public:
6060
MOCK_METHOD1(attach, void(Connection*));
@@ -79,7 +79,7 @@ namespace SCIRun {
7979

8080
typedef boost::shared_ptr<MockInputPort> MockInputPortPtr;
8181

82-
class MockOutputPort : public OutputPortInterface
82+
class MockOutputPort : public OutputPortInterface
8383
{
8484
public:
8585
MOCK_METHOD1(attach, void(Connection*));
@@ -98,16 +98,16 @@ namespace SCIRun {
9898
MOCK_METHOD1(setIndex, void(size_t));
9999
MOCK_CONST_METHOD0(hasData, bool());
100100
MOCK_CONST_METHOD0(getPortDataDescriber, PortDataDescriber());
101+
MOCK_METHOD1(connectConnectionFeedbackListener, boost::signals2::connection(const ConnectionFeedbackSignalType::slot_type&));
102+
MOCK_METHOD1(sendConnectionFeedback, void(SCIRun::Core::Algorithms::VariableHandle));
101103
};
102104

103105
typedef boost::shared_ptr<MockOutputPort> MockOutputPortPtr;
104106

105107
class MockDatatypeSink : public DatatypeSinkInterface
106108
{
107109
public:
108-
//MOCK_CONST_METHOD0(hasData, bool());
109110
MOCK_CONST_METHOD0(clone, DatatypeSinkInterface*());
110-
//MOCK_METHOD1(setHasData, void(bool));
111111
MOCK_METHOD0(waitForData, void());
112112
MOCK_METHOD0(invalidateProvider, void());
113113
MOCK_METHOD0(receive, Core::Datatypes::DatatypeHandleOption());

0 commit comments

Comments
 (0)