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.

80 lines
1.5 KiB
C++

#pragma once
//#include "clipper2\clipper.engine.h"
//#include "clipper2\clipper.core.h"
#include "clipper2\clipper.h"
//#include "clipper2\clipper.rectclip.h"
//#include "clipper2\clipper.rectclip.h"
//#include "clipper2\RectClipLines.h"
using namespace std;
using namespace Clipper2Lib;
class AFX_EXT_CLASS Envelope {
public:
Envelope();
Envelope(int64_t x1, int64_t x2, int64_t y1, int64_t y2);
Envelope(Point64& p1, Point64& p2);
bool Intersects(Envelope& other);
void Init(Point64& p1, Point64& p2);
void Init(int64_t x1, int64_t x2, int64_t y1, int64_t y2);
public:
/**
* the minimum x-coordinate
*/
double MinX;
/*
* the maximum x-coordinate
*/
double MaxX;
/*
* the minimum y-coordinate
*/
double MinY;
/*
* the maximum y-coordinate
*/
double MaxY;
};
struct LineSegment {
Point64 ptStart;
Point64 ptEnd;
Envelope Range;
LineSegment(Point64& start, Point64& end) {
if (start.x < end.x)
{
ptStart = start;
ptEnd = end;
}
else {
ptStart = end;
ptEnd = start;
}
Range.Init(ptStart, ptEnd);
}
};
class AFX_EXT_CLASS CIntersectionUtil
{
public:
CIntersectionUtil(void);
~CIntersectionUtil(void);
void SetSourceLines(const Paths64* subjects);
bool Intersects(LineSegment& clip);
private:
const Paths64* m_pSourceLines;
vector <LineSegment> m_Segments;
/*vector <LineSegment> m_SegmentsR;*/
void PrepareData();
static bool SegmentSort(LineSegment& seg1, LineSegment& seg2);
static bool SegmentSortR(LineSegment& seg1, LineSegment& seg2);
};