![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 #include <tulip/ForEach.h> 00020 00021 template<typename PropType, typename RealType, typename VectorType, unsigned int SIZE> 00022 VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::VectorPropertyAnimation(tlp::Graph *graph, PropType *start, PropType *end, 00023 PropType *out, tlp::BooleanProperty *selection, int frameCount, bool computeNodes, bool computeEdges,QObject* parent) : 00024 CachedPropertyAnimation<PropType, RealType, RealType> (graph, start, end, out, selection, frameCount, computeNodes, computeEdges,parent) { 00025 00026 assert(frameCount > 1); 00027 00028 if (this->_computeNodes) { 00029 tlp::node n; 00030 forEach(n, this->_graph->getNodes()) { 00031 if (this->_selection && !this->_selection->getNodeValue(n)) 00032 continue; 00033 00034 std::pair<PropVector, PropVector> values(PropVector(this->_start->getNodeValue(n)), PropVector(this->_end->getNodeValue(n))); 00035 00036 if (steps.find(values) == steps.end()) { 00037 tlp::Vector<double, SIZE> stepsVector; 00038 00039 for (unsigned int i = 0; i < SIZE; ++i) 00040 stepsVector[i] = ((double)values.second[i] - (double)values.first[i]) * 1. / (frameCount - 1); 00041 00042 steps[values] = stepsVector; 00043 } 00044 } 00045 } 00046 00047 if (this->_computeEdges) { 00048 tlp::edge e; 00049 forEach(e, this->_graph->getEdges()) { 00050 if (this->_selection && !this->_selection->getEdgeValue(e)) 00051 continue; 00052 00053 std::pair<PropVector, PropVector> values(PropVector(this->_start->getEdgeValue(e)), PropVector(this->_end->getEdgeValue(e))); 00054 00055 if (steps.find(values) == steps.end()) { 00056 tlp::Vector<double, SIZE> stepsVector; 00057 00058 for (unsigned int i = 0; i < SIZE; ++i) 00059 stepsVector[i] = ((double) (values.second[i] - (double)values.first[i])) * 1. / (frameCount - 1); 00060 00061 steps[values] = stepsVector; 00062 } 00063 } 00064 } 00065 } 00066 00067 template<typename PropType, typename RealType, typename VectorType, unsigned int SIZE> 00068 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getNodeFrameValue(const RealType &startValue, const RealType &endValue, 00069 int frame) { 00070 PropVector result((PropVector)startValue); 00071 std::pair<PropVector, PropVector> values(result, (PropVector) endValue); 00072 tlp::Vector<double, SIZE> stepVal(steps[values]); 00073 00074 for (unsigned i=0; i < SIZE; ++i) 00075 result[i] += stepVal[i] * frame; 00076 00077 return RealType(result); 00078 } 00079 00080 template<typename PropType, typename RealType, typename VectorType, unsigned int SIZE> 00081 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getEdgeFrameValue(const RealType &startValue, const RealType &endValue, 00082 int frame) { 00083 return getNodeFrameValue(startValue, endValue, frame); 00084 }