156 lines
3.9 KiB
C++
156 lines
3.9 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : XArc弧类
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: XArc类声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _XARC_H_
|
|
#define _XARC_H_
|
|
|
|
#ifndef _XCIRCLE_H_
|
|
#include "XCircle.h"
|
|
#endif
|
|
|
|
#ifndef _XSECTOR_H_
|
|
#include "XSector.h"
|
|
#endif
|
|
|
|
#ifndef _XPOINT_H_
|
|
#include "XPoint.h"
|
|
#endif
|
|
|
|
|
|
class Entity;
|
|
class GEOAPI XArc : public XCircle, public XSector
|
|
{
|
|
public :
|
|
XArc();
|
|
XArc(const XArc &src);
|
|
XArc(const Entity &aCircle);
|
|
XArc(const Entity &aArc, ads_matrix mat);
|
|
XArc(const XPoint &spt, const XPoint &ept, ads_real dang);
|
|
XArc(const XPoint &ptStart, const XPoint &pt2, const XPoint &ptEnd);
|
|
XArc(ads_point ptcenter, double dradius, double ptstartAngle, double ptendAngle);
|
|
virtual ~XArc();
|
|
|
|
virtual bool IsKindOf(TEntityId entType) const;
|
|
virtual TEntityId Type() const;
|
|
virtual void CopyFrom(const XEntity* pImpSrc);
|
|
|
|
virtual int Make(const TCHAR *szlay = NULL) const;
|
|
virtual int Modify(const Entity* pEnt) const;
|
|
virtual int GetExtend(ads_point lowPt, ads_point upPt) const;
|
|
virtual int MakeEntity(const Entity* pEnt) const;
|
|
virtual int GetSubArc(const XPoint &ptloc, ads_real dchordLen, XArc &arcRes) const;
|
|
//图形长度,周长
|
|
virtual ads_real GetLength() const;
|
|
|
|
XArc& operator = (const XSector &src);
|
|
XArc& operator = (const XArc &src);
|
|
bool operator == (const XArc &src) const;
|
|
int operator ! () const;
|
|
|
|
virtual int HitTest2d(const XPoint &ptTest) const;
|
|
virtual int OSnap(int nMode, XPoint &ptPick) const;
|
|
|
|
bool Set(const XPoint &spt, const XPoint &ept, ads_real dang);
|
|
bool Set(const XPoint &ptStart, const XPoint &ptOn, const XPoint &ptEnd);
|
|
void SetAngleByPoints(const XPoint &ptStart, const XPoint &ptEnd);
|
|
|
|
void GetStartPoint(XPoint &ptStart) const;
|
|
void GetEndPoint(XPoint &ptEnd) const;
|
|
|
|
void MidPoint(XPoint &ptres) const;
|
|
XPoint MidPoint() const;
|
|
|
|
//求弦长
|
|
ads_real ChordLength() const;
|
|
// 扇形面积
|
|
ads_real Area() const;
|
|
//起点到终点的积分面积
|
|
ads_real PathArea() const;
|
|
|
|
XArc Offset(ads_real dist) const;
|
|
|
|
virtual void TransUCS(ads_matrix mat);
|
|
|
|
//$direction
|
|
ads_real IDirection(int pt) const;
|
|
ads_real ODirection(int pt) const;
|
|
|
|
virtual int Intersection(const XLine* pLine, ads_point ptRp1 = NULL, ads_point ptRp2 = NULL) const;
|
|
virtual int Intersection(const XArc* pArc, ads_point ptRp1 = NULL, ads_point ptRp2 = NULL) const;
|
|
virtual int Intersection(const XCircle* pCir, ads_point ptRp1 = NULL, ads_point ptRp2 = NULL) const;
|
|
|
|
ads_real * SelectNear(ads_point pt1, ads_point pt2) const;
|
|
int PtOnArc(const XPoint &pt) const;
|
|
};
|
|
|
|
|
|
inline XArc& XArc::operator = (const XSector &src)
|
|
{
|
|
m_dstartAngle = src.m_dstartAngle;
|
|
m_dendAngle = src.m_dendAngle;
|
|
return *this;
|
|
}
|
|
|
|
inline XArc& XArc::operator = (const XArc &src)
|
|
{
|
|
if (this != &src)
|
|
{
|
|
m_dstartAngle = src.m_dstartAngle;
|
|
m_dendAngle = src.m_dendAngle;
|
|
m_ptCenter = src.m_ptCenter;
|
|
m_dRadius = src.m_dRadius;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
inline int XArc::operator ! () const
|
|
{
|
|
return (XCircle::operator !() || GetLength() < XGeLib::_DIST_SNAP);
|
|
}
|
|
|
|
inline bool XArc::operator == (const XArc &src) const
|
|
{
|
|
return (XCircle::operator == (src) && XSector::operator == (src));
|
|
}
|
|
|
|
inline XArc XArc::Offset(ads_real dist) const
|
|
{
|
|
ads_real r = m_dRadius + dist;
|
|
if (r < XGeLib::_DIST_SNAP)
|
|
{
|
|
r = 0;
|
|
}
|
|
return XArc(m_ptCenter, r, m_dstartAngle, m_dendAngle);
|
|
}
|
|
|
|
inline ads_real XArc::GetLength() const
|
|
{
|
|
return Bulge() * m_dRadius;
|
|
}
|
|
|
|
inline ads_real XArc::ChordLength() const
|
|
{
|
|
return fabs(2.0 * m_dRadius * sin(Bulge() / 2.0));
|
|
}
|
|
|
|
inline void XArc::MidPoint(XPoint &ptres) const
|
|
{
|
|
ads_polar(m_ptCenter, MidAngle(), m_dRadius, ptres);
|
|
}
|
|
|
|
inline XPoint XArc::MidPoint() const
|
|
{
|
|
XPoint ptres;
|
|
ads_polar(m_ptCenter, MidAngle(), m_dRadius, ptres);
|
|
return ptres;
|
|
}
|
|
|
|
#endif
|