00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <culebrillas.h>
00026
00027 bool Culebrilla::addPoint(const QPointF &point, const int frameNumber)
00028 {
00029
00030 if (frameNumber <= lastFrameNumber)
00031 {
00032 std::cout << "ERROR!" << std::endl;
00033 return false;
00034 }
00035
00036
00037 if (norm2(points[lastFrameNumber] - point) < minPointDistance)
00038 return false;
00039
00040 points.insert(lastFrameNumber = frameNumber, point);
00041
00042 return true;
00043 }
00044
00045 const QPointF Culebrilla::getPointAtFrame(const int frame) const
00046 {
00047 foreach (int key, points.keys())
00048 if (frame <= key)
00049 return points[key];
00050
00051 return points[lastFrameNumber];
00052 }
00053
00055
00056 const QList< QList<QPointF> > CulebrillaContainer::getCulebrillasAsPolylines() const
00057 {
00058 QList< QList<QPointF> > result;
00059
00060 foreach (Culebrilla culebrilla, getCulebrillas())
00061 result.append(culebrilla.getPointList());
00062
00063 return result;
00064 }
00065
00066 void CulebrillaContainer::addMatching(const QPointF sourcePoint, const QPointF destinationPoint)
00067 {
00068
00069
00070
00071 Culebrilla C;
00072 if (lastMatchingPoints.contains(sourcePoint))
00073 C = lastMatchingPoints[sourcePoint];
00074 else
00075 C = Culebrilla(sourcePoint, actualFrameNumber-1, minPointDistance);
00076
00077
00078 C.addPoint(destinationPoint, actualFrameNumber);
00079
00080
00081 newMatchingPoints.insert(destinationPoint, C);
00082 }
00083
00084 void CulebrillaContainer::step()
00085 {
00086
00087
00088
00089
00090 lastMatchingPoints = newMatchingPoints;
00091
00092
00093 newMatchingPoints.clear();
00094
00095
00096 actualFrameNumber++;
00097 }