You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
2.6 KiB
C++
162 lines
2.6 KiB
C++
#pragma once
|
|
#include "XJPoint2D.h"
|
|
#include <vector>
|
|
#include <list>
|
|
#include <set>
|
|
#include <string>
|
|
|
|
typedef std::vector<Point2D> Polyline2d;
|
|
typedef std::vector<int64_t> IntPolyline2d;
|
|
|
|
struct IdxPoint
|
|
{
|
|
IdxPoint(uint64_t x, uint64_t y)
|
|
{
|
|
ix = x;
|
|
iy = y;
|
|
}
|
|
uint64_t ix;
|
|
uint64_t iy;
|
|
};
|
|
|
|
class XJ_ALGO_EXPORT BBox
|
|
{
|
|
public:
|
|
BBox()
|
|
{
|
|
minx = (std::numeric_limits<uint64_t>::max)();
|
|
maxx = 0;
|
|
miny = (std::numeric_limits<uint64_t>::max)();
|
|
maxy = 0;
|
|
}
|
|
|
|
void Set(uint64_t minX, uint64_t maxX, uint64_t minY, uint64_t maxY)
|
|
{
|
|
minx = minX;
|
|
maxx = maxX;
|
|
miny = minY;
|
|
maxy = maxY;
|
|
}
|
|
|
|
void Expand(const BBox& bb)
|
|
{
|
|
if (bb.minx < minx)
|
|
minx = bb.minx;
|
|
|
|
if (bb.miny < miny)
|
|
miny = bb.miny;
|
|
|
|
if (bb.maxx > maxx)
|
|
maxx = bb.maxx;
|
|
|
|
if (bb.maxy > maxy)
|
|
maxy = bb.maxy;
|
|
}
|
|
|
|
void Expand(uint64_t ix, uint64_t iy)
|
|
{
|
|
if (ix < minx)
|
|
minx = ix;
|
|
|
|
if (iy < miny)
|
|
miny = iy;
|
|
|
|
if (ix > maxx)
|
|
maxx = ix;
|
|
|
|
if (iy > maxy)
|
|
maxy = iy;
|
|
}
|
|
|
|
bool Overlap(const BBox& bb) const
|
|
{
|
|
if (bb.maxx < minx)
|
|
return false;
|
|
|
|
if (bb.maxy < miny)
|
|
return false;
|
|
|
|
if (bb.minx > maxx)
|
|
return false;
|
|
|
|
if (bb.miny > maxy)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
uint64_t minx;
|
|
uint64_t maxx;
|
|
uint64_t miny;
|
|
uint64_t maxy;
|
|
};
|
|
|
|
class PolyLine
|
|
{
|
|
public:
|
|
void UpdateBox(uint64_t col)
|
|
{
|
|
BBox bb;
|
|
for (auto it = m_intPath.begin(); it != m_intPath.end(); it++)
|
|
{
|
|
uint64_t ix = (abs(*it) - 1) % col;
|
|
uint64_t iy = (abs(*it) - 1) / col;
|
|
bb.Expand(ix, iy);
|
|
}
|
|
m_box = bb;
|
|
}
|
|
IntPolyline2d m_intPath;
|
|
BBox m_box;
|
|
bool m_bDirty;
|
|
};
|
|
|
|
class Isopleth
|
|
{
|
|
public:
|
|
typedef std::pair<int64_t, int64_t> edge;
|
|
|
|
bool operator < (const Isopleth& a) const
|
|
{
|
|
return m_value < a.m_value;
|
|
}
|
|
|
|
Isopleth(void);
|
|
virtual ~Isopleth(void);
|
|
|
|
//Ãû³Æ¡¢±êʶ
|
|
void SetName(const std::string& name) { m_name = name; }
|
|
const std::string& GetName() const { return m_name; }
|
|
|
|
void SetValue(double val);
|
|
|
|
double GetValue() const;
|
|
|
|
void AddPath(const Polyline2d& path);
|
|
void AddPaths(const std::vector<Polyline2d>& paths);
|
|
|
|
void AddEdges(std::set<edge>& edges, uint64_t col);
|
|
|
|
unsigned int PathCount() { return static_cast<unsigned int>(m_paths.size()); }
|
|
|
|
void Clear();
|
|
|
|
std::list<PolyLine>& GetPlines() { return m_plines; }
|
|
|
|
std::vector<Polyline2d>& GetPaths() { return m_paths; }
|
|
|
|
//Õâ¸öͼ²ãµÈÖµÏßÊÇ·ñ¸üÐÂ
|
|
void SetDirty(bool flag = true) { m_bDirty = flag; }
|
|
bool IsDirty() const { return m_bDirty; }
|
|
private:
|
|
std::string m_name;
|
|
double m_value;
|
|
std::list<PolyLine> m_plines;
|
|
std::vector<Polyline2d> m_paths;
|
|
bool m_bDirty;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|