#pragma once #include "XJPoint2D.h" #include #include #include #include typedef std::vector Polyline2d; typedef std::vector 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::max)(); maxx = 0; miny = (std::numeric_limits::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 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& paths); void AddEdges(std::set& edges, uint64_t col); unsigned int PathCount() { return static_cast(m_paths.size()); } void Clear(); std::list& GetPlines() { return m_plines; } std::vector& 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 m_plines; std::vector m_paths; bool m_bDirty; };