174 lines
4.5 KiB
C++
174 lines
4.5 KiB
C++
#ifndef __POLYMESHTOOL_H
|
|
#define __POLYMESHTOOL_H
|
|
//输入的XPoly2D(polySrc)应封闭且z值相同
|
|
class XContour: public XPointList {
|
|
public:
|
|
XContour();
|
|
XContour(const XPoly2D& polySrc,int nVertexNum=90);
|
|
XContour(const XContour& src);
|
|
virtual ~XContour();
|
|
|
|
public:
|
|
int m_nVertexNum; //顶点数,初始值90个顶点,且>2
|
|
protected:
|
|
XPoint m_ptWeightCenter;//若用构造函数或者Init()它自动确定重心
|
|
|
|
public:
|
|
virtual void Init(const XPoly2D& polySrc,int nVertexNum=90);
|
|
virtual BOOL IsValid() const;
|
|
void GetAngles(DList<double>& lstAngle) const;
|
|
void GetRadius(DList<double>& lstRadiu) const;
|
|
XPoint GetWeightCenter() const;
|
|
double GetRadius(double dAngle) const;
|
|
double GetPerimeter() const;
|
|
double GetArea() const;
|
|
|
|
protected:
|
|
void Divide(); //以重心为中心按角度均分顶点
|
|
void Divide(const DList<double>& lstOtherAngle);
|
|
void Poly2DToVertexs(const XPoly2D& poly);
|
|
BOOL Intersection(const double dAngleRayLine,
|
|
const XPoint& ptOriginRayLine,
|
|
const XPoint& ptStart,
|
|
const XPoint& ptEnd,
|
|
XPoint& ptResult) const;//射线与线段的交点
|
|
|
|
};
|
|
|
|
//输入的XPoly2D(polySrc)应封闭且z值相同
|
|
class XContour2D: public XContour {
|
|
public:
|
|
XContour2D();
|
|
XContour2D(const XPoly2D& polySrc,
|
|
const XPoint& ptBase,
|
|
int nVertexNum=90,
|
|
const DList<double>& lstOtherAngle=NULL);
|
|
XContour2D(const XContour2D& src);
|
|
virtual ~XContour2D();
|
|
|
|
public:
|
|
XPoint m_ptBase; //基点
|
|
|
|
public:
|
|
virtual void Init(const XPoly2D& polySrc,
|
|
const XPoint& ptBase,
|
|
int nVertexNum=90,
|
|
const DList<double>& lstOtherAngle=NULL);
|
|
virtual BOOL IsValid() const;
|
|
double GetBaseAngle() const;
|
|
double GetBaseRadius() const;
|
|
double GetBaseScale() const;//基点与中心点的距离/该方向上的半径
|
|
|
|
};
|
|
|
|
class XContour3D: public XPointList {
|
|
public:
|
|
XContour3D();
|
|
XContour3D(const DList<XPoint>& src,
|
|
const XPoint& ptBase = XPoint(0,0,0),
|
|
const XPoint& ptCenter = XPoint(0,0,0),
|
|
const XVector3D& vtNormal = XVector3D(0,0,1));
|
|
XContour3D(const XContour2D& src,
|
|
const XVector3D& vtNormal = XVector3D(0,0,1));
|
|
XContour3D(const XContour3D& src);
|
|
virtual ~XContour3D();
|
|
|
|
public:
|
|
XVector3D m_vtNormal;
|
|
XPoint m_ptCenter;
|
|
XPoint m_ptBase;
|
|
|
|
public:
|
|
void Init(const DList<XPoint>& src);
|
|
void ScaleBy(const double dFactor,
|
|
const XPoint& ptBase);
|
|
void RotateBy(const double dAngle,
|
|
const XVector3D& vtAxis,
|
|
const XPoint& ptBase);
|
|
void AttachOn(const XPoint& ptOnPlane,
|
|
const XVector3D& vtPlaneNormal);
|
|
void MoveTo(const XPoint& ptDestine);
|
|
protected:
|
|
void RotateTo(const XPoint &ptPath,const XVector3D& vtDir);
|
|
public:
|
|
XContour3D & operator = (const XContour3D& src);
|
|
|
|
};
|
|
|
|
|
|
class TPolyPath : public XPointList {
|
|
public:
|
|
TPolyPath();
|
|
TPolyPath(const XPoly2D& polySrc,
|
|
BOOL bLineDeviation=FALSE);//初始值:g_nCirDeviation
|
|
TPolyPath(const XPoly2D& polySrc,
|
|
double dDeviation,
|
|
BOOL bLineDeviation=FALSE);
|
|
virtual ~TPolyPath();
|
|
|
|
public:
|
|
double m_dDeviation; //初始值:g_nCirDeviation
|
|
BOOL m_bLineDeviation;//初始值:FALSE
|
|
|
|
public:
|
|
void Init(const XPoly2D& polySrc,BOOL bLineDeviation=FALSE);
|
|
double GetDistAtVertex(int index) const;//Distance from the 1st vertex.
|
|
|
|
};
|
|
|
|
|
|
//************************************************//
|
|
// XPoly2D(polySrc)的在重心上水平线的两边界点 //
|
|
// 初始化后两边界点的y、z值与基点相同 //
|
|
//************************************************//
|
|
|
|
|
|
class XExtendEnd {
|
|
public:
|
|
XExtendEnd();
|
|
XExtendEnd(const XPoly2D& polySrc,
|
|
const XPoint& ptBase=XPoint(0,0,0));
|
|
XExtendEnd(const XExtendEnd& src);
|
|
virtual ~XExtendEnd();
|
|
|
|
public:
|
|
XPoint m_ptBase; //基点
|
|
XPoint m_ptLeft; //左边界点
|
|
XPoint m_ptRight; //右边界点
|
|
|
|
public:
|
|
//初始化后左右点的y、z值等于基点的y、z值
|
|
void Init(const XPoly2D& polySrc,
|
|
const XPoint& ptBase=XPoint(0,0,0));
|
|
double GetDistance() const;
|
|
XPoint GetCenter() const;
|
|
|
|
public:
|
|
void ScaleBy(const double dFactor,
|
|
const XPoint& ptBase,
|
|
BOOL bBaseScale=TRUE);
|
|
void AttachOn(const XPoint& ptOnPath,
|
|
const XVector3D& vtPathNormal);
|
|
void RotateBy(const double dAngle,
|
|
const XVector3D& vtAxis,
|
|
const XPoint& ptBase);
|
|
void MoveTo(const XPoint& ptDestine);
|
|
|
|
};
|
|
|
|
class XTriangleWeiCen: public XTriangle {
|
|
public:
|
|
XTriangleWeiCen(const XPoint &pt1, const XPoint &pt2,
|
|
const XPoint &pt3, int nFlag=0):
|
|
XTriangle(pt1,pt2,pt3,nFlag) {};
|
|
|
|
virtual ~XTriangleWeiCen();
|
|
|
|
public:
|
|
XPoint WeightCenter();
|
|
double Area();
|
|
};
|
|
|
|
XPoint GetWeightCenter(const XPoly2D& poly);
|
|
|
|
#endif |