📄 allcontour.cpp
字号:
// AllContour.cpp: implementation of the CAllContour class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "ct.h"
#include "AllContour.h"
#include "OneContour.h"
#include <math.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAllContour::CAllContour()
{
contourcount_ = 0;
}
CAllContour::~CAllContour()
{
delete []contour_;
}
void CAllContour::Initial(CTriangulate *T) // 接受一个三角网并寻找一个合理的基准值和增量
{
SearchMaxMinZ(T);
// 为basez和incz寻找一个较合理的基准值和增量
startz_ = minz_;
incz_ = (maxz_ - minz_) / 15;
endz_ = maxz_;
Initial(T, startz_, endz_, incz_);
}
/*
接受一个三角网并指定基准值和增量,
同时确定等值线的数量并分配内存。
*/
void CAllContour::Initial(CTriangulate *T, double basez, double incz)
{
SearchMaxMinZ(T);
startz_ = minz_ + fmod(fabs(minz_ - startz_), incz);
incz_ = incz;
endz_ = maxz_;
Initial(T, startz_, endz_, incz_);
}
void CAllContour::CreateAllContour()
{
for ( int i = 0; i < contourcount_; i++)
{
contour_[i].Initial(t_, startz_ + i * incz_, 0);
contour_[i].CreateContour();
}
}
int CAllContour::GetContourCount()
{
return contourcount_;
}
COneContour* CAllContour::GetContour()
{
return contour_;
}
// 查找三角网中z值的最大最小值
void CAllContour::SearchMaxMinZ(CTriangulate *T)
{
XYZ *pv = T->GetVertex();
int vcount = T->GetVertexCount();
// search zvalue's maxium and minium of vertex
minz_ = pv[0].z;
maxz_ = minz_;
for ( int i = 1; i < vcount; i++)
{
if (pv[i].z > maxz_) maxz_ = pv[i].z;
if (pv[i].z < minz_) minz_ = pv[i].z;
}
}
void CAllContour::Initial(CTriangulate *T, double startZ, double endZ, double incZ)
{
SearchMaxMinZ(T);
if ( startZ < minz_ || endZ > maxz_ )
{
AfxMessageBox("起始值和终止值应该在Z值的最大最小值之间。",0,0);
return;
}
t_ = T;
startz_ = startZ;
endz_ = endZ;
incz_ = incZ;
// 统计contour_的大小并分配内存
double tmpsum = startz_;
while( tmpsum < endz_ ) // 统计循环次数
{
contourcount_++;
tmpsum += incz_;
}
contour_ = new COneContour[contourcount_];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -