|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件 Curve.h
|
|
|
//主要功能:
|
|
|
// 基础类库
|
|
|
//程序编写: 2005-12-07
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// Curve.h: interface for the CCurve class.
|
|
|
//
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#if !defined(AFX_CURVE_H__427CDE34_A3CE_4E56_8CE6_7162AB7707DC__INCLUDED_)
|
|
|
#define AFX_CURVE_H__427CDE34_A3CE_4E56_8CE6_7162AB7707DC__INCLUDED_
|
|
|
|
|
|
#if _MSC_VER > 1000
|
|
|
#pragma once
|
|
|
#endif // _MSC_VER > 1000
|
|
|
|
|
|
#include "afxtempl.h"
|
|
|
#include "Vector.h"
|
|
|
#include "Point2D.h"
|
|
|
|
|
|
#include "CrossPoint.h"
|
|
|
|
|
|
//曲线类型
|
|
|
#define PLINE_NODRAW 0x00000001 //'E'
|
|
|
#define PLINE_W 0x00000002 //'W'
|
|
|
#define PLINE_VIRTUAL 0x00000004 //'V'
|
|
|
#define PLINE_DESIGN 0x00000008 //'D'
|
|
|
#define PLINE_MIDLE 0x00000010 //'M'
|
|
|
//
|
|
|
#define PLINE_SOLID 0x00000020 //'S'
|
|
|
#define PLINE_CLOSE 0x00000040 //'C'
|
|
|
#define PLINE_BEZIER 0x00000080 //'B'
|
|
|
#define PLINE_SPLINE 0x00000100 //'P' //三次样条光滑
|
|
|
#define PLINE_OFFSET 0x00000200 //'O'
|
|
|
#define PLINE_TRANSPARENT 0x00000400 //'T' //透明
|
|
|
#define PLINE_WAVE 0x00000800 //'A' //波浪线
|
|
|
#define PLINE_TRANSPARENT_VALUE 0x00001000 //'H' // 'H' 透明度
|
|
|
#define PLINE_WAVE_SOLID (PLINE_WAVE|PLINE_SOLID) //AS //波浪线+充填
|
|
|
#define PLINE_BS (PLINE_BEZIER|PLINE_SOLID) //'B'*256+'S'
|
|
|
#define PLINE_BC (PLINE_BEZIER|PLINE_CLOSE) //'B'*256+'C'
|
|
|
#define PLINE_SPLINES (PLINE_SPLINE|PLINE_SOLID) //'P'*256+'S' //三次样条光滑+充填+闭合
|
|
|
#define PLINE_SPLINEC (PLINE_SPLINE|PLINE_CLOSE) //'P'*256+'C' //三次样条光滑+闭合
|
|
|
#define PLINE_OFFSET_SOLID (PLINE_OFFSET|PLINE_SOLID) //'O'*256+'S'
|
|
|
#define PLINE_OFFSET_SOLID_B (PLINE_OFFSET|PLINE_SOLID|PLINE_BEZIER) //'O'*256+'S'+'B'
|
|
|
#define PLINE_OFFSET_B (PLINE_OFFSET|PLINE_BEZIER) //'O'*256+'B'
|
|
|
#define PLINE_TS (PLINE_TRANSPARENT|PLINE_SOLID) //'T'*256+'S' //充填透明
|
|
|
#define PLINE_HS (PLINE_TRANSPARENT_VALUE|PLINE_SOLID) //'H'*256+'S' //充填透明度
|
|
|
#define PLINE_TBS (PLINE_TRANSPARENT|PLINE_BS) //'T'*256+'B'+'S' //B样条平滑充填透明
|
|
|
#define PLINE_T_SPLINES (PLINE_TRANSPARENT|PLINE_SPLINES) //'T'*256+'P'+'S' //S样条平滑充填透明
|
|
|
#define PLINE_TB (PLINE_TRANSPARENT|PLINE_BEZIER) //'T'*256+'B' //平滑透明
|
|
|
#define PLINE_TC (PLINE_TRANSPARENT|PLINE_CLOSE) //'T'*256+'C' //闭合透明
|
|
|
#define PLINE_T_WAVE_S (PLINE_TRANSPARENT|PLINE_WAVE_SOLID) //TAS //波浪线+充填+透明
|
|
|
|
|
|
namespace NBase
|
|
|
{
|
|
|
|
|
|
#define CCrossList CList<CCrossPoint,CCrossPoint>
|
|
|
typedef CList<POSITION, POSITION> CPositionList;
|
|
|
|
|
|
class AFX_EXT_CLASS CCurve : public CVector
|
|
|
{
|
|
|
public:
|
|
|
CCurve();
|
|
|
CCurve(int num);
|
|
|
virtual ~CCurve();
|
|
|
|
|
|
int Create(int num);
|
|
|
int CreateCurveFromRect(CRect8* pRect);
|
|
|
int CreateCurveFromRect(CRect8* pRect, int iBevel);
|
|
|
//szRountd.cx为圆角处的弧宽,szRountd.cy为弧高
|
|
|
int CreateCurveFromRoundRect(CRect8* pRect, CSize8 szRountd);
|
|
|
//根据椭圆参数生成曲线,生成角度步长angleStep,type=0:Arc,1:Chord, 2:Pie
|
|
|
int CreateCurveFromEllipse(CPoint2D centerPoint, CSize8 szRadius, double angleStep,
|
|
|
double arc1=0.0, double arc2=360.0, int type=0);
|
|
|
virtual void Clear(void);
|
|
|
|
|
|
virtual void Offset(double dx, double dy);
|
|
|
virtual void ScaleCoor(double xs, double ys, double dx, double dy);
|
|
|
virtual void Rotate(double xs,double ys,double angle);
|
|
|
virtual BOOL SetPoints(CPointList &dp, int nnPoint, BOOL IsAutoLocation=TRUE);
|
|
|
|
|
|
int Read(CString name, long offset);
|
|
|
int Read(CFile &fr,double m_z);
|
|
|
void Write(CFile &fw,double l1,double l2);
|
|
|
void Write(CFile &fw);
|
|
|
void Write(int i, CFile &fw, int nn, int m_digit);
|
|
|
void Write(FILE* &fw);
|
|
|
void WriteNode(CFile& fw, int index);
|
|
|
|
|
|
BOOL IsClosed(); //是否是首尾闭合
|
|
|
void SetToClose();
|
|
|
BOOL IsScope(); // 是否认为是区域,否,认为是线
|
|
|
int Cross(CCurve &c2, CCrossList &xy);
|
|
|
int Trim(CCurve &m_curve,CFile &fw);
|
|
|
int FindIndex(double xx, double yy, double err);//查找最近的节点
|
|
|
|
|
|
BOOL LocationIsInRange(double l0);
|
|
|
int IsInside(double xm,double ym); //点是否在曲线内
|
|
|
int IsInside(CCurve& curve); //判断curve是否在当前曲线内部,全部在内返回1,全部不在内返回0,部分在部分不在返回-1
|
|
|
BOOL IsInRange(CRect8& range);
|
|
|
|
|
|
int CrossLine(double *linex, double *liney, CCrossList &m_cross);
|
|
|
void Reversal();
|
|
|
void GetLocation();
|
|
|
void GetLocation3D();
|
|
|
BOOL Extend(double extendLength, int sel);//延伸曲线,sel=0延伸头,sel=1延伸尾
|
|
|
void Expand(double distance); // 外扩或内缩
|
|
|
void EncryptNode(int nMode, double step, BOOL bInteger); // 节点加密
|
|
|
int RemoveSamePoint(double dMinDistance); //移除曲线中相同的节点,返回清除点的个数
|
|
|
int RedundantPoint(double dMinDistance); //冗余节点,返回冗余点的个数
|
|
|
|
|
|
//bReverse为是否反向获得曲线点数据, bAddHead是否将点利用AddHead插入到列表对,否则利用AddTail插入到列表尾
|
|
|
void GetPoint(CPointList &dp, BOOL bReverse=FALSE, BOOL bAddHead=FALSE);
|
|
|
BOOL GetPoint(int nIndex, dfPoint& dp);
|
|
|
BOOL SetPoint(int nIndex, dfPoint& dp);
|
|
|
int GetCurve (double l1,double l2,CPointList &dp,int bDoubleHeadTail=1,BOOL bNoLineValue=FALSE );
|
|
|
int GetCurveOther(double l1, double l2, CPointList &dp, int bDoubleHeadTail=1, BOOL bNoLineValue=FALSE);
|
|
|
int GetCoordinate(double m_location,double &x,double &y,double &z);
|
|
|
int GetCoordinate(double m_location, CPoint3D& pt);
|
|
|
void GetRange(double& xmin, double& ymin, double& xmax, double& ymax);
|
|
|
|
|
|
void operator+=(double t);
|
|
|
void operator=(CCurve& t);
|
|
|
double Length(void);
|
|
|
double Area(void);
|
|
|
double xend(void);
|
|
|
double yend(void);
|
|
|
double lend(void);
|
|
|
/** @brief 点到曲线的距离,l0为垂足的桩号*/
|
|
|
double PointDistance(double x0, double y0, double& l0);
|
|
|
|
|
|
int SetName(LPCTSTR lpString);
|
|
|
CString GetName(void);
|
|
|
|
|
|
int GetBXY(double *pX,double *pY,int isClose);
|
|
|
void CurveToBezier(CPointList &bp,double sd,int isClose);
|
|
|
void CurveToSpline(CPointList &dp,double sd,int isClose, BOOL bRemoveRepeat=TRUE);
|
|
|
int CurveToWave(CPointList &bp, double T, double A, double dnum); //T=采样周期,A=振幅,dnum=一周期内采样点个数
|
|
|
double CompareCurve(CCurve& curve, double error);
|
|
|
|
|
|
int nPoint; //每个点属性值个数,x y z l 等
|
|
|
int m_type;
|
|
|
int ReturnPoint; //逆断层上下盘连接索引号 -1表示为正断层
|
|
|
double *y,*z,*l;
|
|
|
char *name;
|
|
|
|
|
|
protected:
|
|
|
void _ClearDC(CPtrList &dc);
|
|
|
int _CrossVC(double xm,int num,double *x,double *y,double *ycross);
|
|
|
int _CrossVSort(double xm,int num,double *x,double *y,double *ycross);
|
|
|
int GetOneValue(CPtrList &dc1);
|
|
|
|
|
|
//断层统计部分
|
|
|
public:
|
|
|
/** @brief 得到闭合曲线的延伸长度*/
|
|
|
double GetClosureLength();
|
|
|
/** 得到闭合曲线的延伸长度,已知宽度*/
|
|
|
double GetClosureLength(double width);
|
|
|
/** 得到曲线所有线段与x轴夹角的平均值,即曲线走向*/
|
|
|
double GetAverageAngle();
|
|
|
/** 得到曲线XY平面上宽度*/
|
|
|
bool GetClosureWidth(double& maxWid, double& minWid,double& aveWid);
|
|
|
/** 得到曲线Z高度差*/
|
|
|
bool GetClosureDZ(double& maxDZ, double& minDZ, double& aveDZ);
|
|
|
|
|
|
//点线距离3D
|
|
|
public:
|
|
|
/** @brief 该曲线到某三维点的最短距离*/
|
|
|
double PointDistance3D(double x0, double y0, double z0);
|
|
|
/** @brief 曲线之间的平均距离*/
|
|
|
double CurveDistance3D(CCurve& curve);
|
|
|
};
|
|
|
};
|
|
|
|
|
|
AFX_INLINE CString CCurve::GetName(void)
|
|
|
{
|
|
|
if(name!=NULL)return CString(name);
|
|
|
return _T("");
|
|
|
}
|
|
|
|
|
|
extern "C" AFX_EXT_API void WINAPI ReduceCurveRedundant(CCurve& m_input, CCurve& m_output, double error);
|
|
|
extern "C" AFX_EXT_API void WINAPI ReduceCurveRedundant3D(CCurve& m_input, CCurve& m_output, double error, int IsZ);
|
|
|
|
|
|
#endif // !defined(AFX_CURVE_H__427CDE34_A3CE_4E56_8CE6_7162AB7707DC__INCLUDED_)
|