Files
envi-code/SourceCode/Code2026/tg_shs/inc/subgeo/TGPLine2D.h
T
2026-09-28 15:28:50 +08:00

157 lines
4.1 KiB
C++

//-------------------------------------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TGPLine2D 类
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TGPLine2D 声明
// = Maintainers:
//
//-------------------------------------------------------------------------------------------------------+
#ifndef _TGPLINE2D_H_
#define _TGPLINE2D_H_
#ifndef _TGMLINE2D_H_
#include "TGMLine2D.h"
#endif
#ifndef _TGPOINT_H_
#include "TGPoint.h"
#endif
#ifndef _TPGECIRCLE2D_H_
#include "TPGeCircle2D.h"
#endif
#ifndef _TPGEARC2D_H_
#include "TPGeArc2D.h"
#endif
#ifndef _TARRAY_H_
#include "TArray.h"
#endif
#ifndef _TTABLE_H_
#include "TTable.h"
#endif
#ifndef _TPGELINE2D_H_
#include "TPGeLine2D.h"
#endif
#ifndef _TPGECURVE2D_H_
#include "TPGeCurve2D.h"
#endif
#ifndef _TWFLAG_H_
#include "TWFlag.h"
#endif
#ifndef _TGOBJECTLIST_H_
#include "TGObjectList.h"
#endif
#ifndef _TPGEGLINERAY2D_H_
#include "TPGeGLineRay2D.h"
#endif
#ifndef _TPGEGLINESEG2D_H_
#include "TPGeGLineSeg2D.h"
#endif
class GEOAPI TGPLine2D : public TGMLine2D
{
DECLARE_RUN_TIME_CLASS(TGPLine2D)
public:
//contruct
TGPLine2D(long vertexNum=0,bool bClosed=false);
TGPLine2D(const TArray<TGPoint>& vertexs,bool bClosed=false);
TGPLine2D(const TTable<TGPoint>& vertexs,bool bClosed=false);
TGPLine2D(const TArray<TGPoint>& vertexs,const TArray<double>& angles,bool bClosed=false);
TGPLine2D(const TTable<TGPoint>& vertexs,const TTable<double>& angles,bool bClosed=false);
TGPLine2D(const TGMLine2D& mLine);
TGPLine2D(const TPGeCircle2D& cir);
TGPLine2D(const TPGeArc2D& arc);
virtual ~TGPLine2D();
//override TGMLine2D
virtual void SetVertexNum(long num,bool bCopy=false);
//消除相邻重合点,如使之有效返回true
virtual bool RemoveDupPoint();
virtual bool OffsetSeg(long i,double offset);
//override TPGeCurve2D
//参数区间为各段参数区间之和,即[0,GetSegNum()],弧段参数规范到[0,1]
virtual void Pa2Pt(double pa,TGPoint& pt) const;
virtual void Pt2Pa(const TGPoint& pt,double& pa) const;
virtual void Reverse();
virtual void GetTangent(double pa,TPGeLine2D& line) const;
//只有相邻段有且只有一点交(封闭且段数为2时,有两点交)
virtual bool IsSelfCross() const;
virtual double Integration(double pa0,double pa1) const;
//如果paDist>0,paDist为弧度间隔,不是曲线参数间隔!
virtual TGMLine2D* MLinearize(double paDist=0) const;
virtual TGMLine2D* PLinearize(double paDist=0) const;
virtual TPGeCurve2D* GetSubCurve(double pa0,double pa1) const;
virtual bool Offset(double offset);
//override TGObject
//节点数大于1,无相邻重合点,所有包络角在(-PI2,PI2)区间
virtual bool IsValid() const;
//分解为TPGeGLineSeg2D或TPGeArc2D
virtual bool Explode(TGObjectList& res) const;
virtual TGObject * Clone() const;
virtual GRelation HitTest(const TGPoint& pt) const;
virtual bool IsInclude(const TGObject& obj) const;
virtual bool GetExtend2D(TPGeExtend2D& ext) const;
//edit
double& operator ()(long i);
void SetClosed(bool bClosed=true,double angle=0);
//query
double GetBulge(long i) const;
bool IsArc(long i) const;
void GetSegment(long i,TPGeArc2D& seg) const;
void GetSegment(long i,TPGeLine2D& seg) const;
//外部释放
TPGeCurve2D* GetSegment(long i) const;
bool IsArcExist() const;
//operate
void QuickCut(const TPGeGLine2D& line,TGObjectList& left,TGObjectList& right,TGObjectList& mid) const;
void QuickCut(const TPGeGLineRay2D& line,TGObjectList& left,TGObjectList& right,TGObjectList& mid) const;
void QuickCut(const TPGeGLineSeg2D& seg,TGObjectList& left,TGObjectList& right,TGObjectList& mid) const;
protected:
//包络角(-PI2,PI2)
TArray<double> bulges;
};
inline void TGPLine2D::GetSegment(long i,TPGeArc2D& seg) const
{
seg.Init(points.GetAt(i),points.GetAt((i+1)%points.GetLength()),GetBulge(i));
}
inline TPGeCurve2D* TGPLine2D::GetSegment(long i) const
{
if(IsArc(i))
{
return new TPGeArc2D(points.GetAt(i),points.GetAt((i+1)%points.GetLength()),GetBulge(i));
}
else
{
return new TPGeGLineSeg2D(points.GetAt(i),points.GetAt((i+1)%points.GetLength()));
}
}
#endif