My application is a Win32 program . The surface is defined as a 2D matrix with the size of Hcell-by-Vcell The surface height is defined as the value of the matrix elements, the x and y coordinates as the indecies of the matrix elements.
The matrix is stored in a double precision linear array Surf3d with the size of (Hcell+1)*(Vcell+1)
The surface values are arranged in the linear array as:
Code: Select all
for (r=0;r<Vcell;r++) { // rows
for (c=0;c<Hcell;c++) { // columns
i = r*Hcell + c;
Surf3d[i] = (double)rec[i];
}
}
When I save the Surf3d array and display in Excel using Excel's native surface plot I see a completely acceptable surface.
I my program I try to display using
Code: Select all
/* Initialize DPLOT structure to 0's: */
memset(&DPlot,0,sizeof(DPlot));
/* Fill in members of DPLOT structure */
DPlot.Version = DPLOT_DDE_VERSION;
DPlot.hwnd = (DWORD)hDlg;
DPlot.DataFormat = DATA_3D;
DPlot.MaxCurves = Hcell;
DPlot.MaxPoints = Vcell;
DPlot.NumCurves = 1;
DPlot.Scale = SCALE_LINEARX_LINEARY;
strcpy(DPlot.Title[0],"The surface");
strcpy(DPlot.XAxis,"X");
strcpy(DPlot.YAxis,"Y");
Lighting = 0;
GetDlgItemText(hDlg,IDC_XRANGEEDIT,szText,sizeof(szText));
xhi = atof(szText);
GetDlgItemText(hDlg,IDC_YRANGEEDIT,szText,sizeof(szText));
yhi = atof(szText);
GetDlgItemText(hDlg,IDC_ZLORANGEEDIT,szText,sizeof(szText));
zlo = atof(szText);
GetDlgItemText(hDlg,IDC_ZHIRANGEEDIT,szText,sizeof(szText));
zhi = atof(szText);
xlo = 0.0; ylo=0.0;
//if(Is3DView)
sprintf_s(szExec, 1024,"[Caption(\"Heatbump plot\")]"
"[Contour3D(1)][ContourView(%d,20)][ContourLighting(%d,0.05)]", (int)angle, Lighting);
sprintf_s(line, 1000, "[ContourGrid(0)][ContourAxes(1)][ContourMethod(0)][ContourLevels(20,%.3f, %.3f)]"
"[ContourScales(1,1,%d)][ManualScale(0,0,%.3f, %.3f,%.3f,%.3f)]"
"[FontPoints(1,8)][FontPoints(2,12)][FontPoints(3,12)]"
"[FontPoints(4,10)][FontPoints(5,10)][FontPoints(6,8)][FontPoints(8,10)]"
"[ZAxisLabel(\"Height\")][DocMaximize()]", MinRec, MaxRec, 5, xhi, yhi, zlo, zhi);
strcat(szExec, line);
if (hbmp) {
DeleteObject(hbmp);
hbmp = 0;
}
if (DocNum) dPlot_Command(DocNum, "[FileClose()]");
DocNum = dPlot_Plot8(&DPlot, extents, Surf3d, szExec);
if (DocNum) {
SetBitmapToFrame();
Is3D = 1;
}
free(z);
The surface I am supposed to see in dplot is an inclined plane (as it show up in Excel surface plot) but with the dplot it looks like a plane surface with a warp aling the (i,i) line.
Any idea what could cause this defect?
Peter