diff --git a/src/ActivityAnimation.cpp b/src/ActivityAnimation.cpp index 10ed5b8..5a3b6d6 100644 --- a/src/ActivityAnimation.cpp +++ b/src/ActivityAnimation.cpp @@ -16,11 +16,11 @@ static inline float correct_timescale(float original) ActivityAnimation::ActivityAnimation(std::size_t count, const float *aPos, const float *bPos, const float xDist) : bufferLength(3 * count), - startingPos(new float[bufferLength]), - delta(new float[bufferLength]), - offset(new float[count]) + startingPos(bufferLength), + delta(bufferLength), + offset(bufferLength) { - memcpy(startingPos.get(), aPos, sizeof(aPos[0]) * bufferLength); + memcpy(startingPos.data(), aPos, sizeof(aPos[0]) * bufferLength); for (auto i : Range(bufferLength)) { delta[i] = bPos[i] - aPos[i]; } @@ -38,12 +38,12 @@ void ActivityAnimation::draw(float timeScale) const std::unique_ptr vertexBuffer(new float[bufferLength]); for (auto i : Range(bufferLength)) { - vertexBuffer[i] = startingPos[i] + correct_timescale(offset[i/3] + timeScale) * delta[i]; + vertexBuffer[i] = startingPos[i] + timeScale * delta[i]; } glColor3f(1, 1, 1); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertexBuffer.get()); - glDrawArrays(GL_POINTS, bufferLength / 3, bufferLength); + glDrawArrays(GL_POINTS, 0, bufferLength / 3); glDisableClientState(GL_VERTEX_ARRAY); } diff --git a/src/ActivityAnimation.hpp b/src/ActivityAnimation.hpp index bad3051..d3b5eef 100644 --- a/src/ActivityAnimation.hpp +++ b/src/ActivityAnimation.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace fmri { @@ -13,8 +14,8 @@ namespace fmri private: std::size_t bufferLength; - std::unique_ptr startingPos; - std::unique_ptr delta; - std::unique_ptr offset; + std::vector startingPos; + std::vector delta; + std::vector offset; }; } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ae15114..347fd3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,6 +82,9 @@ static void render() glPushMatrix(); renderLayerName(dataSet[i]); rendererData.layerVisualisations[i]->render(); + if (i < rendererData.animations.size() && rendererData.animations[i]) { + rendererData.animations[i]->draw(rendererData.animationStep); + } glPopMatrix(); glTranslatef(-10, 0, 0); diff --git a/src/visualisations.cpp b/src/visualisations.cpp index aef4b96..7c819ce 100644 --- a/src/visualisations.cpp +++ b/src/visualisations.cpp @@ -39,8 +39,10 @@ computeActivityStrengths(const LayerData &prevState, const LayerInfo &layer) const auto shape = layer.parameters()[0]->shape(); auto weights = layer.parameters()[0]->cpu_data(); + const auto numEntries = accumulate(shape.begin(), shape.end(), 1u, multiplies()); + result.reserve(numEntries); - for (auto i : Range(accumulate(shape.begin(), shape.end(), 1, multiplies()))) { + for (auto i : Range(numEntries)) { result.emplace_back(weights[i] * data[i % shape[0]], make_pair(i % shape[0], i / shape[0])); } @@ -80,6 +82,5 @@ fmri::ActivityAnimation *fmri::getActivityAnimation(const fmri::LayerData &prevS memcpy(endingPositions.get() + 3 * i, curPositions.data() + 3 * entries[i].second.second, 3 * sizeof(float)); } - // TODO: actually do something return new ActivityAnimation(entries.size(), startingPositions.get(), endingPositions.get(), 2.0); }