|
|
|
|
#pragma once
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "point.h"
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <limits>
|
|
|
|
|
#include "geocompute.h"
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
struct Point2D {
|
|
|
|
|
double x, y;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Line2D {
|
|
|
|
|
Point2D p1, p2;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Rectangle2D {
|
|
|
|
|
Point2D vertices[4];
|
|
|
|
|
double area() const {
|
|
|
|
|
double width = std::sqrt(std::pow(vertices[1].x - vertices[0].x, 2) + std::pow(vertices[1].y - vertices[0].y, 2));
|
|
|
|
|
double height = std::sqrt(std::pow(vertices[2].x - vertices[1].x, 2) + std::pow(vertices[2].y - vertices[1].y, 2));
|
|
|
|
|
return width * height;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TopologicalAnalysis
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TopologicalAnalysis(void);
|
|
|
|
|
~TopologicalAnalysis(void);
|
|
|
|
|
|
|
|
|
|
bool isPointInLine(double* point, double* startPoint, double* endPoint,float tolerance=0.001);
|
|
|
|
|
|
|
|
|
|
// <20>жϵ<D0B6><CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int isPointInPolyLine(double* point, vector<double>& lineX,vector<double>& lineY,float tolerance=0.001);
|
|
|
|
|
bool isPointInLine(CPoint1 point, CPoint1 startPoint, CPoint1 endPoint);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߹<EFBFBD><DFB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ߵĽ<DFB5><C4BD><EFBFBD>
|
|
|
|
|
bool GetPointToLineVerticalCross(double* linePt1,double* linePt2,double* pt,double* crossPt);
|
|
|
|
|
|
|
|
|
|
//<2F>жϵ<D0B6><CFB5>Ƿ<EFBFBD><C7B7>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>㷨
|
|
|
|
|
bool isPointInPolygon(CPoint1 point, vector<CPoint1> polygon);
|
|
|
|
|
|
|
|
|
|
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>߶<EFBFBD><DFB6>Ƿ<EFBFBD><C7B7>ཻ
|
|
|
|
|
bool isLineIntersect(CPoint1 line1Start, CPoint1 line1End, CPoint1 line2Start, CPoint1 line2End);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷʽ<C5B7><CABD><EFBFBD><EFBFBD>, δʵ<CEB4><CAB5>
|
|
|
|
|
double getDistance(CPoint1 point1, CPoint1 point2);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>CPoint1<74><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X
|
|
|
|
|
double getMaxX(vector<CPoint1> points);
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool GetBoundingBoxVertices(const vector<double>& polygonX,const vector<double>& polygonY,vector<double>& rectangleX,vector<double>& rectangleY);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>εĽ<CEB5><C4BD><EFBFBD>
|
|
|
|
|
void linePolygonIntersections(const Point2D& linePt1,const Point2D& linePt2,const vector<double>& polygonX,const std::vector<double>& polygonY,std::vector<Point2D>& result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><DFB6>Ƿ<EFBFBD><C7B7>ཻ
|
|
|
|
|
int isLineIntersecting(const Line2D& l1, const Line2D& l2, Point2D& intersection);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|