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.
126 lines
2.9 KiB
C
126 lines
2.9 KiB
C
|
1 month ago
|
#pragma once
|
||
|
|
#include <vector>
|
||
|
|
#include <list>
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
class AFX_EXT_CLASS CParalSegment
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CParalSegment();
|
||
|
|
CParalSegment(CPoint3D* pt1, CPoint3D* pt2);
|
||
|
|
bool operator == (const CParalSegment& seg) const;
|
||
|
|
CParalSegment& operator = (const CParalSegment& seg);
|
||
|
|
|
||
|
|
bool IsAdjacent(CParalSegment& seg2);
|
||
|
|
|
||
|
|
int CrossPoint(CParalSegment& seg2, CPoint3D& crPt);
|
||
|
|
double Length();
|
||
|
|
CPoint3D* m_ptHead;
|
||
|
|
CPoint3D* m_ptTail;
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
class AFX_EXT_CLASS CParallelLines
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
enum ESIDE{eLeft = 0, eRight = 1};
|
||
|
|
typedef list<CParalSegment> SEGMENTLIST ;
|
||
|
|
public:
|
||
|
|
CParallelLines(void);
|
||
|
|
virtual ~CParallelLines(void);
|
||
|
|
void ClearAll();
|
||
|
|
|
||
|
|
int CreateParallel(vector<CCurve*>& OutCurveList,CCurve& inputCurve,double dist, ESIDE nSide = eLeft);
|
||
|
|
|
||
|
|
bool CreateParallel(CCurve& inputCurve, CCurve& outputCurve, double dist, ESIDE nSide = eLeft);
|
||
|
|
|
||
|
|
void SetZero(double dz) {m_ZERO = fabs(dz); }
|
||
|
|
|
||
|
|
bool GetParalPoint(CPoint3D* pPrePt, CPoint3D* pCurPt, CPoint3D* pAftPt, CPoint3D& tarPt, double dist);
|
||
|
|
|
||
|
|
protected:
|
||
|
|
int ReadPoints(const CCurve& curve);
|
||
|
|
|
||
|
|
bool GetParalPoint(CPoint3D* pPrePt, CPoint3D* pCurPt, CPoint3D* pAftPt, CPoint3D& tarPt);
|
||
|
|
|
||
|
|
virtual bool GetInitParalPoints();
|
||
|
|
|
||
|
|
bool GetDistPoint(CPoint3D& prePt, CPoint3D& curPt, CPoint3D& aftPt,CPoint3D& tarPt);
|
||
|
|
|
||
|
|
bool IsSameDirection(CPoint3D& newpt1,CPoint3D& newpt2,CPoint3D& oldPt1, CPoint3D& oldPt2 );
|
||
|
|
|
||
|
|
void SetSide(ESIDE es);
|
||
|
|
void SetOffset(double offset);
|
||
|
|
|
||
|
|
bool CreateInitialParallel();
|
||
|
|
|
||
|
|
bool CalculateCross();
|
||
|
|
|
||
|
|
bool SegmentCross(SEGMENTLIST& tkseglist, SEGMENTLIST& orgseglist, SEGMENTLIST::iterator& orgiter);
|
||
|
|
|
||
|
|
bool SegmentCrossOrg(SEGMENTLIST& tkseglist, SEGMENTLIST& orgseglist, SEGMENTLIST::iterator& orgiter);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
bool CutoffSegment(SEGMENTLIST& seglist, SEGMENTLIST::iterator& iter, CPoint3D* pPt);
|
||
|
|
|
||
|
|
CCurve* TraceLegalCurve() ;
|
||
|
|
|
||
|
|
CCurve* CreateCurve(SEGMENTLIST& seglst);
|
||
|
|
|
||
|
|
bool CreateCurve(SEGMENTLIST& seglst,CCurve& destCurve );
|
||
|
|
|
||
|
|
bool TraceLegalCurve(CCurve& destCurve) ;
|
||
|
|
|
||
|
|
|
||
|
|
void InterpolateAbnormalZPoints(CCurve& curve,double cz);
|
||
|
|
|
||
|
|
|
||
|
|
void DeleteNearSegments(SEGMENTLIST& seglst, double mindist );
|
||
|
|
|
||
|
|
double PointCurveDistance(CPoint3D& pt);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
protected:
|
||
|
|
vector<CPoint3D> m_InputPoints;
|
||
|
|
vector<CPoint3D> m_ParalPointVec;
|
||
|
|
CCurve* m_pInputCurve;
|
||
|
|
|
||
|
|
ESIDE m_eSide;
|
||
|
|
double m_offset;
|
||
|
|
SEGMENTLIST m_ParalSegLst;
|
||
|
|
SEGMENTLIST m_CuttedSegLst;
|
||
|
|
SEGMENTLIST m_RDirectSegLst;
|
||
|
|
list<CPoint3D> m_CrossPointLst;
|
||
|
|
bool m_bClosed;
|
||
|
|
|
||
|
|
double m_ZERO;
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
class AFX_EXT_CLASS CVariableOffsetCurveGenerator
|
||
|
|
:public CParallelLines
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CVariableOffsetCurveGenerator(void);
|
||
|
|
~CVariableOffsetCurveGenerator(void);
|
||
|
|
|
||
|
|
void ClearOffsetVec();
|
||
|
|
|
||
|
|
int ReadOffsetData(double* offset, int num);
|
||
|
|
|
||
|
|
int ReadInitCurveData(double* x, double* y, int num);
|
||
|
|
|
||
|
|
int ReadInitCurveData(const CCurve& curve );
|
||
|
|
|
||
|
|
bool CreateOffsetCurve(CCurve& OffsetCurve, const ESIDE& side);
|
||
|
|
private:
|
||
|
|
|
||
|
|
virtual bool GetInitParalPoints();
|
||
|
|
|
||
|
|
private:
|
||
|
|
vector<double> m_offsetVec;
|
||
|
|
};
|