#pragma once #include #include 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 SEGMENTLIST ; public: CParallelLines(void); virtual ~CParallelLines(void); void ClearAll(); int CreateParallel(vector& 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 m_InputPoints; vector m_ParalPointVec; CCurve* m_pInputCurve; ESIDE m_eSide; double m_offset; SEGMENTLIST m_ParalSegLst; SEGMENTLIST m_CuttedSegLst; SEGMENTLIST m_RDirectSegLst; list 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 m_offsetVec; };