20 template <
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
21 VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::VectorPropertyAnimation(
22 tlp::Graph *graph, PropType *start, PropType *end, PropType *out,
25 : CachedPropertyAnimation<PropType, RealType, RealType>(
26 graph, start, end, out, selection, frameCount, computeNodes, computeEdges, parent) {
28 assert(frameCount > 1);
30 if (this->_computeNodes) {
31 for (
auto n : this->_graph->nodes()) {
32 if (this->_selection && !this->_selection->getNodeValue(n))
35 std::pair<PropVector, PropVector> values(PropVector(this->_start->getNodeValue(n)),
36 PropVector(this->_end->getNodeValue(n)));
38 if (steps.find(values) == steps.end()) {
39 tlp::Vector<double, SIZE> stepsVector;
41 for (
unsigned int i = 0; i < SIZE; ++i)
43 (
double(values.second[i]) - double(values.first[i])) * 1. / (frameCount - 1);
45 steps[values] = stepsVector;
50 if (this->_computeEdges) {
51 for (
auto e : this->_graph->edges()) {
52 if (this->_selection && !this->_selection->getEdgeValue(e))
55 std::pair<PropVector, PropVector> values(PropVector(this->_start->getEdgeValue(e)),
56 PropVector(this->_end->getEdgeValue(e)));
58 if (steps.find(values) == steps.end()) {
59 tlp::Vector<double, SIZE> stepsVector;
61 for (
unsigned int i = 0; i < SIZE; ++i)
63 (
double((values.second[i]) -
double(values.first[i]))) * 1. / (frameCount - 1);
65 steps[values] = stepsVector;
71 template <
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
72 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getNodeFrameValue(
73 const RealType &startValue,
const RealType &endValue,
int frame) {
74 PropVector result(static_cast<PropVector>(startValue));
75 std::pair<PropVector, PropVector> values(result, static_cast<PropVector>(endValue));
76 tlp::Vector<double, SIZE> stepVal(steps[values]);
78 for (
unsigned i = 0; i < SIZE; ++i)
79 result[i] += stepVal[i] * frame;
81 return RealType(result);
84 template <
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
85 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getEdgeFrameValue(
86 const RealType &startValue,
const RealType &endValue,
int frame) {
87 return getNodeFrameValue(startValue, endValue, frame);
A graph property that maps a boolean value to graph elements.