/*------------------------------------------------------------------------------ * Copyright (c) 2023 by Bai Bing (seread@163.com) * See COPYING file for copying and redistribution conditions. * * Alians IT Studio. *----------------------------------------------------------------------------*/ #pragma once #include "_Define.h" #include "ASPoint.h" namespace ais { template class AIS_EXPORT Edge { public: PT points[2]; size_t hash{0}; Edge() = default; Edge(const PT &p0, const PT &p1) { points[0] = p0; points[1] = p1; get_hash(); } inline size_t get_hash() { if (hash != 0) return hash; bool flag = points[0] < points[1]; auto h0 = flag ? points[0].hash() : points[1].hash(); auto h1 = flag ? points[1].hash() : points[0].hash(); hash = h0 ^ (h1 << 1); return hash; } bool operator==(const Edge &rhs) const { return (points[0] == rhs.points[0] && points[1] == rhs.points[1]) || (points[0] == rhs.points[1] && points[1] == rhs.points[0]); } }; } // namespace ais