More generalized code.
MultiImageLayer and FlatLayer now use the same code for arranging nodes, rather than then same logic twice.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "LayerVisualisation.hpp"
|
||||
#include "Range.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
const std::vector<float> &fmri::LayerVisualisation::nodePositions() const
|
||||
{
|
||||
@@ -9,3 +11,30 @@ fmri::LayerVisualisation::LayerVisualisation(size_t numNodes)
|
||||
: nodePositions_(numNodes * 3)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
void fmri::LayerVisualisation::initNodePositions<fmri::LayerVisualisation::Ordering::LINE>(size_t n, float spacing)
|
||||
{
|
||||
nodePositions_.clear();
|
||||
nodePositions_.reserve(3 * n);
|
||||
|
||||
for (auto i : Range(n)) {
|
||||
nodePositions_.push_back(0);
|
||||
nodePositions_.push_back(0);
|
||||
nodePositions_.push_back(-spacing * i);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void fmri::LayerVisualisation::initNodePositions<fmri::LayerVisualisation::Ordering::SQUARE>(size_t n, float spacing)
|
||||
{
|
||||
nodePositions_.clear();
|
||||
nodePositions_.reserve(3 * n);
|
||||
const auto columns = numCols(n);
|
||||
|
||||
for (auto i : Range(n)) {
|
||||
nodePositions_.push_back(0);
|
||||
nodePositions_.push_back(spacing * (i / columns));
|
||||
nodePositions_.push_back(-spacing * (i % columns));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user