|
|
#pragma once
|
|
|
#include "TriAdapter.h"
|
|
|
#include "PolygonCreatorBoundary.h"
|
|
|
class CScatteredTrace;
|
|
|
class CScatteredPoint;
|
|
|
class CScatteredEdge;
|
|
|
class CScatteredTriangle;
|
|
|
class CPolygonCreatorLine;
|
|
|
struct SCATTEREDDATAINDEX;
|
|
|
class FACIESPOINT;
|
|
|
|
|
|
void CalculateBorderPosition(int iPointIndex0,int iPointIndex1,double& dPosition);
|
|
|
void CalculateBorderPosition(int iPointIndex0,int iPointIndex1,double& dPosition,double& dIndex0,double& dIndex1);
|
|
|
|
|
|
class CContourPolygon
|
|
|
{
|
|
|
public:
|
|
|
CContourPolygon(CScatteredTrace* pScatteredData);
|
|
|
~CContourPolygon();
|
|
|
//Attributes
|
|
|
private:
|
|
|
CScatteredTrace* m_pScatteredData;
|
|
|
CString m_strName;
|
|
|
CTypedPtrArray<CPtrArray,CPolygonCreatorLine*> m_PolygonCreatorLineArray;
|
|
|
//Operations
|
|
|
public:
|
|
|
void SetScatteredData(CScatteredTrace* pScatteredData);
|
|
|
CScatteredTrace* GetScatteredData();
|
|
|
|
|
|
void SetName(LPCTSTR strName);
|
|
|
CString GetName();
|
|
|
|
|
|
virtual void Clear();
|
|
|
|
|
|
int GetPolygonCreatorLineCount();
|
|
|
CPolygonCreatorLine* GetPolygonCreatorLine(int index);
|
|
|
|
|
|
void AddPolygonCreatorLine(CPolygonCreatorLine* pPolygonCreatorLine);
|
|
|
void DeletePolygonCreatorLine(int index);
|
|
|
|
|
|
};
|
|
|
|
|
|
class CContourPolygonGroup//一个线簇
|
|
|
{
|
|
|
public:
|
|
|
CContourPolygonGroup(CScatteredTrace* pScatteredData);
|
|
|
~CContourPolygonGroup();
|
|
|
//Attributes
|
|
|
private:
|
|
|
CScatteredTrace* m_pScatteredData;
|
|
|
|
|
|
CString m_strName;
|
|
|
double m_dValue;
|
|
|
CTypedPtrArray<CPtrArray,CContourPolygon*> m_PolygonArray;
|
|
|
|
|
|
GDFLOGPEN m_LogPen;
|
|
|
GDFLOGBRUSH m_LogBrush;
|
|
|
//Operations
|
|
|
public:
|
|
|
void SetScatteredData(CScatteredTrace* pScatteredData);
|
|
|
CScatteredTrace* GetScatteredData();
|
|
|
|
|
|
void SetName(LPCTSTR strName);
|
|
|
CString GetName();
|
|
|
|
|
|
void SetValue(double dValue);
|
|
|
double GetValue();
|
|
|
|
|
|
void Clear();
|
|
|
|
|
|
int GetPolygonCount();
|
|
|
CContourPolygon* GetPolygon(int index);
|
|
|
|
|
|
void AddPolygon(CContourPolygon* pPolygon);
|
|
|
|
|
|
void GetLogPen(GDFLOGPEN* pLogPen);
|
|
|
void SetLogPen(GDFLOGPEN* pLogPen);
|
|
|
|
|
|
void GetLogBrush(GDFLOGBRUSH* pLogBrush);
|
|
|
void SetLogBrush(GDFLOGBRUSH* pLogBrush);
|
|
|
|
|
|
};
|
|
|
|
|
|
class CFaciesRgnTracer;
|
|
|
|
|
|
|
|
|
/* 三角形中分割出的小单元,
|
|
|
可能是三角形或四边形或五边形 */
|
|
|
class CContourUnit
|
|
|
{
|
|
|
public:
|
|
|
CContourUnit();
|
|
|
~CContourUnit();
|
|
|
//Attributes
|
|
|
private:
|
|
|
CFaciesRgnTracer* m_pScatteredTracer;
|
|
|
|
|
|
int m_iNextCellIndex;
|
|
|
POLYGONCREATORSEGMENT m_SegmentArray[9]; // 0,1,2保存边界点
|
|
|
BYTE m_byteFlag;
|
|
|
|
|
|
double m_dValue;//值的索引
|
|
|
//Operations
|
|
|
public:
|
|
|
void SetScatteredTracer(CFaciesRgnTracer* pScatteredTracer);
|
|
|
CFaciesRgnTracer* GetScatteredTracer();
|
|
|
|
|
|
int GetNextCellIndex();
|
|
|
void SetNextCellIndex(int iCellIndex);
|
|
|
|
|
|
int SegmentHitTest(double dBorderPosition0,double dPosition0,double dBorderPosition1,double dPosition1);
|
|
|
int SegmentHitTest(double dBorderPosition,double dPosition0,double dPosition1);
|
|
|
|
|
|
POLYGONCREATORSEGMENT* GetSegmentArray();
|
|
|
void GetSegmentArray(POLYGONCREATORSEGMENT* pSegmentArray);
|
|
|
void SetSegmentArray(POLYGONCREATORSEGMENT* pSegmentArray);
|
|
|
|
|
|
BOOL CutOff(double dBorderPosition,double dPosition0,double dBorderPosition1,double dPosition1,CGDFObjectLine* pObject,double dPointIndex0,double dPointIndex1);
|
|
|
|
|
|
BOOL GetFlag();
|
|
|
void SetFlag();
|
|
|
void ClearFlag();
|
|
|
|
|
|
double GetValue();
|
|
|
void SetValue(double dValue);
|
|
|
|
|
|
void operator=(CContourUnit& cell);
|
|
|
|
|
|
CPolygonCreatorLine* GetPolygonCreatorLine();
|
|
|
private:
|
|
|
BOOL BuildBorderSegment(CScatteredEdge* pBorder,double dRelativeIndex0,double dRelativeIndex1,CPolygonCreatorSegment* pSegment);
|
|
|
};
|
|
|
|
|
|
struct SCATTEREDSEGMENT
|
|
|
{
|
|
|
int iTriangleIndex;
|
|
|
BYTE byteBorderIndex;
|
|
|
|
|
|
BYTE byteHeadStep;
|
|
|
BYTE byteEndStep;
|
|
|
|
|
|
int iHeadPointIndex;
|
|
|
int iEndPointIndex;
|
|
|
|
|
|
double dHeadDistance;
|
|
|
double dEndDistance;
|
|
|
};
|
|
|
|
|
|
class CONTOURSTEPVALUE
|
|
|
{
|
|
|
public:
|
|
|
CONTOURSTEPVALUE(){dValue=0.0;strValue[0]=0;LogPen.m_dWidth=0.0;byteEnhanceConnection=0;byteLabel=0;byteLineColorCal=1;byteFillColorCal=1;LogPen.m_dWidth=5.0f;};
|
|
|
double dValue;
|
|
|
TCHAR strValue[128];
|
|
|
GDFLOGPEN LogPen;
|
|
|
GDFLOGBRUSH LogBrush;
|
|
|
|
|
|
BYTE byteEnhanceConnection;
|
|
|
BYTE byteLineColorCal;
|
|
|
BYTE byteLabel;
|
|
|
BYTE byteFillColorCal;
|
|
|
|
|
|
void operator=(CONTOURSTEPVALUE& value);
|
|
|
|
|
|
};
|
|
|
|
|
|
#include "FaciesTypeManager.h"
|
|
|
|
|
|
/*对边界的处理*/
|
|
|
/*如果没有边界,则将三角形的外轮廓做为边界*/
|
|
|
/*如果设置边界,则要同时设置内边界及外边界,内边界可以没有,同时将边界上的点加入离散点中,如果有值,则连同值加入,如果没值,则带空值加入*/
|
|
|
/*在构造三角形前先整理边界,如果在边界上加入新的点,则同时加入到离散点中*/
|
|
|
/*/在追踪等值线或分区线之前要将离散点中的边界点的缺失的值补上*/
|
|
|
class CFaciesRgnTracer
|
|
|
{
|
|
|
public:
|
|
|
CFaciesRgnTracer(CScatteredTrace* pScatteredData=NULL);
|
|
|
~CFaciesRgnTracer();
|
|
|
//Attributes
|
|
|
protected:
|
|
|
struct BUILDDISTANCEBORDER
|
|
|
{//用来构造距离的索引
|
|
|
int iTriangleIndex;
|
|
|
BYTE byteBorderIndex;
|
|
|
double dDistance;
|
|
|
int iPointIndex;
|
|
|
BOOL bCanExtend;
|
|
|
};
|
|
|
|
|
|
CFaciesTypeMgr* m_pFaciesTypeManager;
|
|
|
|
|
|
BOOL m_bLabel;
|
|
|
GDFLOGFONT m_LabelFont;
|
|
|
double m_dLabelDistance;
|
|
|
|
|
|
CTypedPtrArray<CPtrArray,CArray<FACIESPOINT,FACIESPOINT>* > m_BorderArray;
|
|
|
CArray<int,int> m_BorderTypeArray;//0--外边界 1--内边界不闭合 2--内边界闭合
|
|
|
|
|
|
CScatteredTrace* m_pScatteredData;
|
|
|
CTypedPtrArray<CPtrArray,CContourPolygonGroup*> m_PolygonGroupArray;
|
|
|
|
|
|
CArray<int,int> m_FirstCellIndexArray;//每个三角形一个值
|
|
|
CArray<CContourUnit,CContourUnit> m_CellArray;//由三角形分割出的小单元
|
|
|
|
|
|
BYTE m_byteEnhanceConnection;//用于区域追踪时增强连通性 0--不增强连通 1--弱连通 2--中连通 3--强连通 255--无条件连通
|
|
|
double m_dCurrentTraceValue;
|
|
|
|
|
|
int m_iStartTriangleIndex;//用于追踪边界线
|
|
|
BYTE m_byteStartBorderIndex;//用于追踪边界线
|
|
|
int m_iSearchStartStep;//用于搜索线的起点
|
|
|
|
|
|
double m_dStartValue;
|
|
|
double m_dStopValue;
|
|
|
double m_dStepInterval;
|
|
|
CArray<CONTOURSTEPVALUE,CONTOURSTEPVALUE> m_StepValueArray;
|
|
|
|
|
|
int m_iCurrentDataType;
|
|
|
|
|
|
CGDFLayer* m_pContourLineLayer;
|
|
|
CGDFLayer* m_pContourPolygonLayer;
|
|
|
|
|
|
CArray<CScatteredTriangle,CScatteredTriangle> m_TriangleArray;
|
|
|
|
|
|
BOOL m_bProcessBar;
|
|
|
|
|
|
//Operations
|
|
|
public:
|
|
|
void SetScatteredData(CScatteredTrace* pScatteredData);
|
|
|
CScatteredTrace* GetScatteredData();
|
|
|
|
|
|
virtual void Clear();
|
|
|
|
|
|
void SetContourLineLayer(CGDFLayer* pLayer);
|
|
|
void SetContourPolygonLayer(CGDFLayer* pLayer);
|
|
|
|
|
|
CContourPolygonGroup* GetPolygonGroup(int index);
|
|
|
|
|
|
int GetCurrentDataType();
|
|
|
void SetCurrentDataType(int iType);
|
|
|
|
|
|
void AddOutBorder(FACIESPOINT* pPointArray,int count,BOOL bClose);
|
|
|
void AddInnerBorder(FACIESPOINT* pPointArray,int count,BOOL bClose);
|
|
|
|
|
|
int GetTriangleCount();
|
|
|
CScatteredTriangle* GetTriangleArray();
|
|
|
|
|
|
void GetStepValueArray(CArray<CONTOURSTEPVALUE,CONTOURSTEPVALUE>& ValueArray);
|
|
|
int SetStepValueArray(CArray<CONTOURSTEPVALUE,CONTOURSTEPVALUE>& ValueArray);
|
|
|
|
|
|
/*将离散点的值付给三角形的顶点*/
|
|
|
void AddDataValueToTriangle();
|
|
|
|
|
|
/*用新的构网接口构造三角网*/
|
|
|
virtual void CreateTriangle(int iPrecision);//0--低精度 1--中精度 2--高精度
|
|
|
|
|
|
/*增强连通性,考虑较长的通道*/
|
|
|
void EnhanceConnection();
|
|
|
|
|
|
/*增强连通性,只考虑邻近的两个三角形*/
|
|
|
void SimpleEnhanceConnection();
|
|
|
|
|
|
BOOL TryConnectTwoRegion(CArray<int,int>& PointIndexArray0,CArray<int,int>& PointIndexArray1);
|
|
|
BOOL TryConnectTwoRegion(int iPointIndex0,int iPointIndex1);
|
|
|
void EnhanceConnectionSplitTriangleA(int iTriangleIndex,BYTE byteBorderIndex);
|
|
|
void EnhanceConnectionSplitTriangleB(int iTriangleIndex,BYTE byteBorderIndexA,BYTE byteBorderIndexB);
|
|
|
void EnhanceConnectionSplitTriangleC(int iTriangleIndex,BYTE byteBorderIndex);
|
|
|
|
|
|
BOOL GetProcessBar();
|
|
|
void SetProcessBar(BOOL bValue);
|
|
|
|
|
|
protected:
|
|
|
int GetCellCount(int iTriangleIndex);
|
|
|
CContourUnit* NewCell(int iTriangleIndex);
|
|
|
CContourUnit* GetCell(int iTriangleIndex,double dBorderPosition0,double dPosition0,double dBorderPosition1,double dPosition1);
|
|
|
CContourUnit* GetCell(int iTriangleIndex,double dBorderPosition,double dPosition0,double dPosition1);
|
|
|
|
|
|
void CheckLineCloseOrNot();
|
|
|
void BuildPolygon();
|
|
|
|
|
|
CContourPolygonGroup* GetPolygonGroupByValue(double dValue);
|
|
|
|
|
|
int CheckBorderPointArray(FACIESPOINT* pPointArray,int count,BOOL bClose,FACIESPOINT* pNewPointArray);
|
|
|
|
|
|
void ClearContour();
|
|
|
|
|
|
void AddCellNodeToPointArray();//将角点加入离散点序列
|
|
|
|
|
|
int PointInRegion(double x,double y);//点是否在边界内
|
|
|
BOOL PointCrossBorder(double x0,double y0,double x1,double y1);
|
|
|
|
|
|
void TraceNoneValueBoundary();
|
|
|
|
|
|
void ClearTriangleBorderFlag();
|
|
|
|
|
|
void CreateFill();
|
|
|
|
|
|
void BuildTriangleNeighbor();
|
|
|
void CheckTriangleNeighbor();
|
|
|
|
|
|
void CheckPointInRegion();
|
|
|
|
|
|
void CreateTriangleOfPolygon(CArray<CScatteredEdge,CScatteredEdge>& BorderArray);
|
|
|
|
|
|
double CalculateCellWidth();
|
|
|
|
|
|
void CalculateArea();
|
|
|
|
|
|
void CreateColorMark();
|
|
|
|
|
|
//按实际数据建立点的索引
|
|
|
void BuildDistanceIndex(double x,double y,SCATTEREDDATAINDEX* pIndexArray,int iInterpolatePointCount);
|
|
|
|
|
|
//沿三角形边建立点的索引
|
|
|
virtual void BuildDistanceIndex(int iTriangleIndex,BYTE byteNodeIndex,SCATTEREDDATAINDEX* pIndexArray,int iInterpolatePointCount);
|
|
|
|
|
|
//把值付给三角形及邻近的三角形
|
|
|
void SetTriangleValue(int iTriangleIndex,BYTE byteNodeIndex,double dValue);
|
|
|
|
|
|
void CreateBorderLine();
|
|
|
};
|