资源简介
Contour.cpp 2002/7/31 12:30 C++ Source 10 KB
Contour.h 2002/7/31 12:45 C/C++ Header 5 KB
GLContour.cpp 2002/1/9 17:56 C++ Source 1 KB
GLContour.h 2002/7/31 12:16 C/C++ Header 2 KB
ListContour.cpp 2002/7/31 12:48 C++ Source 14 KB
ListContour.h 2002/7/31 12:42 C/C++ Header 3 KB
代码片段和文件信息
// Contour.cpp: implementation of the CContour class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “stdlib.h“
#include “math.h“
#include “Contour.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
double TestFunction(double xdouble y)
{
return 0.5*(cos(x+3.14/4)+sin(y+3.14/4));
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CContour::CContour()
{
m_iColFir=m_iRowFir=32;
m_iColSec=m_iRowSec=256;
m_dDx=m_dDy=0;
m_pFieldFcn=NULL;
m_pLimits[0]=m_pLimits[2]=0;
m_pLimits[1]=m_pLimits[3]=5.;
m_ppFnData=NULL;
// temporary stuff
m_pFieldFcn=TestFunction;
m_vPlanes.resize(20);
for (UINT i=0;i {
m_vPlanes[i]=(i-m_vPlanes.size()/2.0)*0.1;
}
}
CContour::~CContour()
{
CleanMemory();
}
void CContour::InitMemory()
{
if (!m_ppFnData)
{
m_ppFnData=new CFnStr*[m_iColSec+1];
for (int i=0;i {
m_ppFnData[i]=NULL;
}
}
}
void CContour::CleanMemory()
{
if (m_ppFnData)
{
int i;
for (i=0;i {
if (m_ppFnData[i])
delete[] (m_ppFnData[i]);
}
delete[] m_ppFnData;
m_ppFnData=NULL;
}
}
void CContour::Generate()
{
int i j;
int x3 x4 y3 y4 x y oldx3 xlow;
const int cols=m_iColSec+1;
const int rows=m_iRowSec+1;
double xoffyoff;
// Initialize memroy if needed
InitMemory();
m_dDx = (m_pLimits[1]-m_pLimits[0])/(double)(m_iColSec);
xoff = m_pLimits[0];
m_dDy = (m_pLimits[3]-m_pLimits[2])/(double)(m_iRowSec);
yoff = m_pLimits[2];
xlow = 0;
oldx3 = 0;
x3 = (cols-1)/m_iRowFir;
x4 = ( 2*(cols-1) )/m_iRowFir;
for (x = oldx3; x <= x4; x++)
{ /* allocate new columns needed
*/
if (x >= cols)
break;
if (m_ppFnData[x]==NULL)
m_ppFnData[x] = new CFnStr[rows];
for (y = 0; y < rows; y++)
FnctData(xy)->m_sTopLen = -1;
}
y4 = 0;
for (j = 0; j < m_iColFir; j++)
{
y3 = y4;
y4 = ((j+1)*(rows-1))/m_iColFir;
Cntr1(oldx3 x3 y3 y4);
}
for (i = 1; i < m_iRowFir; i++)
{
y4 = 0;
for (j = 0; j < m_iColFir; j++)
{
y3 = y4;
y4 = ((j+1)*(rows-1))/m_iColFir;
Cntr1(x3 x4 y3 y4);
}
y4 = 0;
for (j = 0; j < m_iColFir; j++)
{
y3 = y4;
y4 = ((j+1)*(rows-1))/m_iColFir;
Pass2(oldx3x3y3y4);
}
if (i < (m_iRowFir-1))
{ /* re-use columns no longer needed */
oldx3 = x3;
x3 = x4;
x4 = ((i+2)*(cols-1))/m_iRowFir;
for (x = x3+1; x <= x4; x++)
{
if (xlow < oldx3)
{
if (m_ppFnData[x])
delete[] m_ppFnData[x];
m_ppFnData[x] = m_ppFnData[xlow];
m_ppFnData[ xlow++ ] = NULL;
}
else
if (m_ppFnData[x]==NULL)
m_ppFnData[x] = new CFnStr[rows];
for (y = 0;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9959 2002-07-31 12:30 contour_src\Contour.cpp
文件 4394 2002-07-31 12:45 contour_src\Contour.h
文件 569 2002-01-09 17:56 contour_src\GLContour.cpp
文件 1295 2002-07-31 12:16 contour_src\GLContour.h
文件 14206 2002-07-31 12:48 contour_src\ListContour.cpp
文件 2147 2002-07-31 12:42 contour_src\ListContour.h
目录 0 2017-10-21 20:49 contour_src
----------- --------- ---------- ----- ----
32570 7
- 上一篇:c++简单线程池的实现
- 下一篇:C语言实现FFT(快速傅里叶变换)
评论
共有 条评论