231 lines
5.9 KiB
C++
231 lines
5.9 KiB
C++
//-----------------------------------------------------------------------------+
|
||||
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|||
|
|
// = FileName : TGGePoly2D
|
|||
|
|
// = Version : ver2.0
|
|||
|
|
// = Author : wlw
|
|||
|
|
// = CreateDate : 2002-09-09
|
|||
|
|
// = Description: TGGePoly2D类声明
|
|||
|
|
// = Maintainers:
|
|||
|
|
//
|
|||
|
|
//-----------------------------------------------------------------------------+
|
|||
|
|
#ifndef _TGGEPOLY2D_H_
|
|||
|
|
#define _TGGEPOLY2D_H_
|
|||
|
|
|
|||
|
|
#ifndef _TENTITYSET_H_
|
|||
|
|
#include "TEntitySet.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TGGELINE_H_
|
|||
|
|
#include "TGGeLine.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TGGEARC_H_
|
|||
|
|
#include "TGGeArc.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TGGECURVESEGMENT_H_
|
|||
|
|
#include "TGGeCurveSegment.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
#ifndef _TGGEDIRECTIONCURVE_H_
|
|||
|
|
#include "TGGeDirectionCurve.h"
|
|||
|
|
#endif
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef _TADSGEPOINT3D_H_
|
|||
|
|
#include "TADSGePoint3d.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TGGEPOLY_H_
|
|||
|
|
#include "TGGePoly.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TDPTRLIST_H_
|
|||
|
|
#include "TDPtrList.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef _TADSGEPOINTLIST_H_
|
|||
|
|
#include "TADSGePointList.h"
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
class TGGePoly3D;
|
|||
|
|
class TGGeCurveSegment;
|
|||
|
|
class TGGeDirectionCurve;
|
|||
|
|
class GEOAPI TGGePoly2D : public TADSGePointList, public TGGeCurve
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
TGGePoly2D();
|
|||
|
|
TGGePoly2D(const TEntitySet& entPline);
|
|||
|
|
TGGePoly2D(int nflg);
|
|||
|
|
TGGePoly2D(const TGGePoly2D & src);
|
|||
|
|
|
|||
|
|
virtual ~TGGePoly2D();
|
|||
|
|
|
|||
|
|
virtual bool IsKindOf(TEntityId entType) const;
|
|||
|
|
virtual TEntityId Type() const;
|
|||
|
|
|
|||
|
|
// add by xlc on 110413
|
|||
|
|
virtual double GetLength()const; //曲线长度
|
|||
|
|
|
|||
|
|
virtual double Area() const;
|
|||
|
|
virtual void Reset();
|
|||
|
|
virtual bool SetAcDbCurve(AcDbCurve* pCurve);
|
|||
|
|
|
|||
|
|
virtual AcDbCurve* AsAcDbCurve()const;
|
|||
|
|
virtual AcDbRegion *AsRegion() const;
|
|||
|
|
virtual void CopyFrom(const TGGeEntity* pSrc);
|
|||
|
|
|
|||
|
|
virtual int Nth(int nIndex, TGGeLine &xline, TGGeArc &xarc, AcDb::Visibility *pVal = NULL) const;
|
|||
|
|
virtual int Nth(int nIndex, TGGeCurveSegment & cvCurve, AcDb::Visibility *pVal = NULL) const;
|
|||
|
|
virtual int Nth(int nIndex, TGGeDirectionCurve &curve, AcDb::Visibility *pVal = NULL) const;
|
|||
|
|
|
|||
|
|
virtual int Reverse();
|
|||
|
|
virtual int Compress(bool bUnionCurve = true);
|
|||
|
|
|
|||
|
|
virtual int Make(LPCTSTR szLay = NULL) const;
|
|||
|
|
virtual int MakeSegments(LPCTSTR szLay = NULL) const;
|
|||
|
|
virtual int MakeSegment(int nIndex, LPCTSTR szLay = NULL) const;
|
|||
|
|
|
|||
|
|
virtual void TransformBy(const AcGeMatrix3d &mat);
|
|||
|
|
virtual void RemoveNode(long nIndex);
|
|||
|
|
virtual void InsertNodeAt(int nIndex, const TADSGePoint3d &pt, double dBulge = 0.0, AcDb::Visibility eVal = AcDb::kVisible);
|
|||
|
|
virtual void InsertNodeAt(const TADSGePoint3d &ptOn, AcDb::Visibility eVal = AcDb::kVisible);
|
|||
|
|
virtual void AppendNode(const TADSGePoint3d &pt, ads_real dBulge = 0.0, AcDb::Visibility eVal = AcDb::kVisible);
|
|||
|
|
|
|||
|
|
int operator ! () const;
|
|||
|
|
TGGePoly2D& operator = (const TGGePoly2D &src);
|
|||
|
|
|
|||
|
|
void SetFlag(int nFlag);
|
|||
|
|
int GetFlag() const;
|
|||
|
|
|
|||
|
|
void AppendBugle(ads_real dBugle);
|
|||
|
|
void RemoveBugle(int nIndex);
|
|||
|
|
|
|||
|
|
double GetBulge(int nIndex) const;
|
|||
|
|
void SetBulge(int nIndex, double dBugle);
|
|||
|
|
|
|||
|
|
int SetBulges(const TDPtrList<double>& ardbulges);
|
|||
|
|
int GetBulges(TDPtrList<double>& ardbulges);
|
|||
|
|
TDPtrList<double>& GetBulges();
|
|||
|
|
|
|||
|
|
|
|||
|
|
ads_real Distance3d(int nIndex) const;
|
|||
|
|
ads_real Distance3d() const;
|
|||
|
|
ads_real Distance2d(int nIndex) const;
|
|||
|
|
ads_real Distance2d() const;
|
|||
|
|
|
|||
|
|
// 求路径面积有正负之分,不闭合时为路径与X轴之间的区域面积,正负无实际意义
|
|||
|
|
// 闭合时,路径围成的面积,为正表示曲线是顺时针方向的
|
|||
|
|
ads_real PathArea() const;
|
|||
|
|
|
|||
|
|
double PathDistance2d(TADSGePoint3d ptHit) const;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//是否自交
|
|||
|
|
BOOL IsSelfIntersect() const;
|
|||
|
|
int IsValid(int nIndex) const;
|
|||
|
|
|
|||
|
|
int IsClosed() const;
|
|||
|
|
bool SetClosed();
|
|||
|
|
|
|||
|
|
int HasArcSegment() const;
|
|||
|
|
|
|||
|
|
int TotalSegments() const;
|
|||
|
|
|
|||
|
|
int Polar2d(ads_real dis, TADSGePoint3d &ptRes, ads_real *dDrt = NULL) const;
|
|||
|
|
int Polar3d(ads_real dis, TADSGePoint3d &ptRes, TVector3D & vt) const;
|
|||
|
|
|
|||
|
|
//取得封闭PLINE内的一点或外的一点
|
|||
|
|
TADSGePoint3d GetPoint(int nIOFlag, ads_real dist);
|
|||
|
|
TADSGePoint3d GetInsidePoint();
|
|||
|
|
|
|||
|
|
int AppendSegment(const TGGeCurveSegment &cvCurve, int bMinus = 0, int bFinal = 0);
|
|||
|
|
// 消除路径的重合点,bUnionCurve为true时合并共线点
|
|||
|
|
|
|||
|
|
// 路径偏移,各段分别偏移,再求交点,构成偏移线
|
|||
|
|
int Offset(ads_real nDist, TGGePoly2D &destPoly) const;
|
|||
|
|
// 路径偏移,各顶点计算偏移,再求顶点的圆心角(弧段),构成偏移线
|
|||
|
|
int QuickOffset(ads_real nDist, TGGePoly2D &destPoly) const;
|
|||
|
|
|
|||
|
|
int MapToPolygon1(TGGePoly &pts, double dDeviation);
|
|||
|
|
int MapToPolygon(TGGePoly &pts, int nCirDiv = 30);
|
|||
|
|
|
|||
|
|
resbuf *Fence(int nCirDiv = 30);
|
|||
|
|
resbuf *Polygon(int nCirDiv = 30);
|
|||
|
|
|
|||
|
|
int AsOpenPoly1(TGGePoly &pts, double dDeviation) const;
|
|||
|
|
int AsOpenPoly(TGGePoly &pts, int nCirDiv = 30) const;
|
|||
|
|
|
|||
|
|
//离散化
|
|||
|
|
void Disperse1(TGGePoly2D &polydestPoly, double dDeviation) const;
|
|||
|
|
void Disperse(TGGePoly2D &polydestPoly, int nCirDiv = 30) const;
|
|||
|
|
|
|||
|
|
int CreatePface(int cirDivSegs, const TCHAR *szLay = NULL);
|
|||
|
|
|
|||
|
|
int GetExtend(ads_point lowPt, ads_point upPt) const;
|
|||
|
|
|
|||
|
|
//返回值nRet,
|
|||
|
|
//nRet>0时表示的是输入点在第几个顶点上
|
|||
|
|
//nRet<0时|nRet|表示的是输入点在第几条边上
|
|||
|
|
//nRet=0表示不在线上
|
|||
|
|
int HitTestOnCurve(const TADSGePoint3d &ptTest, double dTol = TchGeLib::_DIST_SNAP) const;
|
|||
|
|
|
|||
|
|
void SetPointListAt(int nIndex, const TADSGePoint3d& pt);
|
|||
|
|
|
|||
|
|
TADSGePoint3d* GetPointListAt(int nIndex);
|
|||
|
|
const TADSGePoint3d& GetPointListAt(int nIndex) const;
|
|||
|
|
|
|||
|
|
void RemovePointListAt(int nIndex);
|
|||
|
|
void AppendPointListAt(TADSGePoint3d* pPt);
|
|||
|
|
|
|||
|
|
TGGePoly3D PlaneToWcs(const AcGeVector3d& normal)const;
|
|||
|
|
|
|||
|
|
bool IsRegionInclude(const TGGePoly2D& poly)const;
|
|||
|
|
bool IsRegionOverlap(const TGGePoly2D& poly)const;
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
int m_nFlag;
|
|||
|
|
TDPtrList<double> m_ardbulges;
|
|||
|
|
};
|
|||
|
|
/*
|
|||
|
|
inline int TGGePoly2D::operator !() const
|
|||
|
|
{
|
|||
|
|
return (Length() < 2 ? 1 : 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline int TGGePoly2D::IsValid(int nIndex) const
|
|||
|
|
{
|
|||
|
|
int nLen = Length();
|
|||
|
|
if (nIndex < 0 || nIndex >= nLen)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!(GetFlag() & 1) && nIndex == nLen - 1)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline int TGGePoly2D::IsClosed() const
|
|||
|
|
{
|
|||
|
|
return ((GetFlag() & 0x01) ? 1 : 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline int TGGePoly2D::TotalSegments() const
|
|||
|
|
{
|
|||
|
|
int nLen = Length();
|
|||
|
|
return (GetFlag() & 1) ? nLen : nLen - 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline double TGGePoly2D::Area() const
|
|||
|
|
{
|
|||
|
|
return fabs(PathArea());
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
#endif
|