point cloud

This commit is contained in:
Andrey Tkachenko 2014-07-25 18:44:11 +04:00
parent a7c102324c
commit 826af318d3
11 changed files with 120 additions and 25 deletions

View File

@ -3,3 +3,13 @@
SvCurve::SvCurve() SvCurve::SvCurve()
{ {
} }
void SvCurve::addPoint(SvPoint *point)
{
m_points.push_back(point);
}
SvCurve *SvCurve::cut(SvPoint *point)
{
}

View File

@ -1,26 +1,33 @@
#ifndef SVCURVE_H #ifndef SVCURVE_H
#define SVCURVE_H #define SVCURVE_H
#include <QColor>
#include "svdefs.h" #include "svdefs.h"
#include "svpoint.h" #include "svpoint.h"
#include "svsimplepoint.h" #include "svsimplepoint.h"
class SvPoint; class SvPoint;
class SvFigure;
class SvCurve class SvCurve
{ {
protected: protected:
SvPoint *m_ends; SvFigure *m_inner;
SvPoint *m_points; SvFigure *m_outer;
SvSimplePoint *m_keyPoints;
QColor m_leftColor;
QColor m_rightColor;
QList<SvPoint*> m_points;
SvSimplePoint *m_keyPoints;
private:
SvCurve();
public: public:
SvCurve(); SvPoint* head() {return m_points.first(); }
SvPoint* tail() {return m_points.last(); }
SvPoint* tail() {return m_points.last(); }
void setInner(SvFigure *figure) {m_inner = figure; }
void setOuter(SvFigure *figure) {m_outer = figure; }
void addPoint(SvPoint *point);
SvCurve *cut(SvPoint *point);
}; };
#endif // SVCURVE_H #endif // SVCURVE_H

View File

@ -3,7 +3,7 @@
#include <QDebug> #include <QDebug>
typedef unsigned int SvFrameId; typedef unsigned int SvPointId;
typedef unsigned int uint; typedef unsigned int uint;
#include "svpointcloud.h" #include "svpointcloud.h"

View File

@ -1,5 +1,37 @@
#include "svfigure.h" #include "svfigure.h"
SvFigure::SvFigure() SvFigure::SvFigure(SvCurve *curve)
{ {
addCurve(curve);
}
SvCurve *SvFigure::findCurveByPoint()
{
foreach(SvCurve* curve, m_curves) {
if (curve->hasPoint(point)) {
return curve;
}
}
return 0;
}
SvFigure SvFigure::split(SvPoint *point)
{
SvCurve *curve = findCurveByPoint(point);
SvFigure figure;
if (curve) {
figure.addCurve(curve->cut(point));
SvCurve *item = m_curves.last();
while(item != curve) {
figure.addCurve(item);
m_curves.removeLast();
item = m_curves.last();
}
}
return figure;
} }

View File

@ -7,11 +7,15 @@
class SvFigure class SvFigure
{ {
protected: protected:
SvPoint *ends; QColor m_color;
QList<SvCurve*> m_curves;
public: public:
SvFigure(); SvFigure(SvCurve *curve);
void addCurve(SvCurve *curve){m_curves.pop_back(curve); }
SvCurve *findCurveByPoint();
SvFigure split(SvPoint *point);
}; };
#endif // SVFIGURE_H #endif // SVFIGURE_H

View File

@ -35,8 +35,9 @@ int SvKernel::rgbDiff(QRgb left, QRgb right)
return dsign * (abs(rightDiff - leftDiff)>>2) + diff /*+ (hsvDiff > 5 ? dsign * 10 : 0)*/; return dsign * (abs(rightDiff - leftDiff)>>2) + diff /*+ (hsvDiff > 5 ? dsign * 10 : 0)*/;
} }
void SvKernel::exec(SvPointCloud *pcl, SvImage *image, int line) void SvKernel::exec(SvPointCloud *pc, SvImage *image, int line)
{ {
SvPoint p;
QRgb vtop, top, right, bottom, vbottom, _xy, xy; QRgb vtop, top, right, bottom, vbottom, _xy, xy;
int __dX, _dX, dX, dX_, int __dX, _dX, dX, dX_,
@ -88,8 +89,12 @@ void SvKernel::exec(SvPointCloud *pcl, SvImage *image, int line)
} }
if (value > 0) { if (value > 0) {
p.setX(x - 1);
p.setY(line - 1);
p.setHorizontalValue(value);
p.setVerticalValue(value);
//m_result->putGrayPixel(x - 1, line - 1, value); pc->addPoint(p);
} }
__dX = _dX; __dX = _dX;

View File

@ -10,7 +10,7 @@ class SvKernel
public: public:
SvKernel(); SvKernel();
virtual ~SvKernel(); virtual ~SvKernel();
void exec(SvPointCloud *pcl, SvImage *image, int line); void exec(SvPointCloud *pc, SvImage *image, int line);
int rgbDiff(QRgb left, QRgb right); int rgbDiff(QRgb left, QRgb right);
}; };

View File

@ -2,4 +2,15 @@
SvPoint::SvPoint() SvPoint::SvPoint()
{ {
}
SvPoint::SvPoint(SvPoint &point)
{
}
void SvPoint::addCurve(SvCurve *curve)
{
m_curves[m_curveCount++] = curve;
} }

View File

@ -8,6 +8,7 @@ class SvCurve;
class SvPoint: public SvSimplePoint class SvPoint: public SvSimplePoint
{ {
public: public:
enum Sides { enum Sides {
TOP, TOP,
@ -24,11 +25,18 @@ public:
}; };
protected: protected:
SvCurve* m_curves; uint m_id;
FlowType m_type; uint m_curveCount;
SvCurve *m_curves[8];
FlowType m_type;
public: public:
SvPoint(); SvPoint();
SvPoint(SvPoint &point);
void addCurve(SvCurve *curve);
uint curveCount() {return m_curveCount; }
SvCurve *curve(uint index) {return m_curves[index]; }
}; };
#endif // SVPOINT_H #endif // SVPOINT_H

View File

@ -5,23 +5,29 @@ SvPointCloud::SvPointCloud(uint width, uint height)
m_pointFiledHeight = height; m_pointFiledHeight = height;
m_pointFiledWidth = width; m_pointFiledWidth = width;
m_pointField = new SvPoint* [height]; m_pointField = new SvPoint**[height]();
for (uint y = 0; y < height; y++) { for (uint y = 0; y < height; y++) {
m_pointField[y] = new SvPoint[width]; m_pointField[y] = new SvPoint*[width]();
} }
} }
SvPointCloud::~SvPointCloud() SvPointCloud::~SvPointCloud()
{ {
for (uint y = 0; y < m_pointFiledHeight; y++) { for (uint y = 0; y < m_pointFiledHeight; y++) {
for (uint x = 0; x < m_pointFiledWidth; x++) {
if (m_pointField[y][x]) {
delete m_pointField[y][x];
}
}
delete[] m_pointField[y]; delete[] m_pointField[y];
} }
delete[] m_pointField; delete[] m_pointField;
} }
void SvPointCloud::addPoint(SvFrameId frame, SvPoint point) void SvPointCloud::addPoint(SvPoint point)
{ {
m_pointField[point.y()][point.x()] = point; m_pointField[point.y()][point.x()] = new SvPoint(point);
} }

View File

@ -1,6 +1,8 @@
#ifndef SVPOINTCLOUD_H #ifndef SVPOINTCLOUD_H
#define SVPOINTCLOUD_H #define SVPOINTCLOUD_H
#include <QObject>
#include "svdefs.h" #include "svdefs.h"
#include "svpoint.h" #include "svpoint.h"
#include "svcurve.h" #include "svcurve.h"
@ -11,12 +13,19 @@ class SvCurve;
class SvFigure; class SvFigure;
class SvObject; class SvObject;
class SvPointCloud class SvPointCloud: public QObject
{ {
Q_OBJECT
friend class SvCurve;
friend class SvPoint;
friend class SvFigure;
friend class SvObject;
protected: protected:
uint m_pointFiledHeight; uint m_pointFiledHeight;
uint m_pointFiledWidth; uint m_pointFiledWidth;
SvPoint** m_pointField; SvPoint*** m_pointField;
QList<SvCurve*> m_curves; QList<SvCurve*> m_curves;
QList<SvFigure*> m_figures; QList<SvFigure*> m_figures;
QList<SvObject*> m_objects; QList<SvObject*> m_objects;
@ -25,8 +34,11 @@ public:
SvPointCloud(uint width, uint height); SvPointCloud(uint width, uint height);
~SvPointCloud(); ~SvPointCloud();
void addPoint(SvFrameId frame, SvPoint point); SvCurve *createCurve();
SvFigure *createFigure();
SvObject *createObject();
void addPoint(SvPoint point);
}; };
#endif // SVPOINTCLOUD_H #endif // SVPOINTCLOUD_H