--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2008 - DIGITEO - Jean-Baptiste Silvy
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 3572 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3572
+//
+// <-- Short Description -->
+// When using grayplot, you cannot have different dimensions in entry.
+//
+stacksize(1e8);
+x=1:2000; y=1:1000; m=rand(1000,2000);
+grayplot(x,y,m');
+// used to crash violently
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2008 - DIGITEO - Jean-Baptiste Silvy
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// <-- Non-regression test for bug 3572 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3572
+//
+// <-- Short Description -->
+// When using grayplot, you cannot have different dimensions in entry.
+//
+
+stacksize(1e8);
+
+x=1:2000; y=1:1000; m=rand(1000,2000);
+grayplot(x,y,m');
+
+// used to crash violently
/*---------------------------------------------------------------------------------*/
int GrayplotDecomposer::getNbRow(void)
{
- return pGRAYPLOT_FEATURE(m_pDrawed->getDrawedObject())->nx;
+ return pGRAYPLOT_FEATURE(m_pDrawed->getDrawedObject())->ny;
}
/*---------------------------------------------------------------------------------*/
int GrayplotDecomposer::getNbCol(void)
{
- return pGRAYPLOT_FEATURE(m_pDrawed->getDrawedObject())->ny;
+ return pGRAYPLOT_FEATURE(m_pDrawed->getDrawedObject())->nx;
}
/*---------------------------------------------------------------------------------*/
int GrayplotDecomposer::getNbColors(void)
int colorMapSize = sciGetNumColors(sciGetParentFigure(pGray));
// fill color
- for (int i = 0; i < nbRow - 1; i++)
+ for (int j = 0; j < nbRow - 1; j++)
{
- for (int j = 0; j < nbCol - 1; j++)
+ for (int i = 0; i < nbCol - 1; i++)
{
// current value is the average on the facet
- double curZvalue = getFacetZvalue(ppGray->pvecz, nbRow, i, j);
+ double curZvalue = getFacetZvalue(ppGray->pvecz, nbCol, i, j);
// colors is of size (nx - 1) x (ny -1) and pvecz of size nx x ny.
// a 1 is added here and I don't know why
// scilab data are stored column wise
- colors[j + (nbRow - 1) * i]
+ colors[i + (nbCol - 1) * j]
= 1 + (int) floor( (colorMapSize - 1) * (curZvalue - lowColor) / zRange + 0.5);
}
}
{
// colors is of size (nx - 1) x (ny -1) and pvecz of size nx x ny.
// scilab data are stored column wise
- colors[j + (nbRow - 1) * i] = (int) ppGray->pvecz[i + nbCol * j];
+ colors[j + (nbCol - 1) * i] = (int) ppGray->pvecz[i + nbCol * j];
}
}
}
/*---------------------------------------------------------------------------------*/
-double GrayplotDecomposer::getFacetZvalue(const double zValues[], int nbRow, int i, int j)
+double GrayplotDecomposer::getFacetZvalue(const double zValues[], int nbCol, int i, int j)
{
// mean on the facet
- return 0.25 * ( zValues[i + nbRow * j] + zValues[i + 1 + nbRow * j]
- + zValues[i + 1 + nbRow * (j + 1)] + zValues[i + nbRow * (j + 1)]);
+ return 0.25 * ( zValues[i + nbCol * j] + zValues[i + 1 + nbCol * j]
+ + zValues[i + 1 + nbCol * (j + 1)] + zValues[i + nbCol * (j + 1)]);
}
/*---------------------------------------------------------------------------------*/
}
}
// fill color
- for (int i = 0; i < nbCol - 1; i++)
+ for (int j = 0; j < nbRow - 1; j++)
{
- for (int j = 0; j < nbRow - 1; j++)
+ for (int i = 0; i < nbCol - 1; i++)
{
// scilab data are stored column wise
- colors[j + (nbRow - 1) * i] = (int) ppGray->pvecz[j + (nbRow - 1) * i];
+ colors[i + (nbCol - 1) * j] = (int) ppGray->pvecz[j + (nbRow - 1) * i];
}
}
// rectangles are used to render each pixel
// Using textures would be much faster
- // hower it would not be compatible with GL2PS, so for now we keep th eslow version
+ // hower it would not be compatible with GL2PS, so for now we keep the slow version
startRecordDL();
gl.glBegin(GL.GL_QUADS);
- for (int i = 0; i < nbCol; i++) {
- for (int j = 0; j < nbRow; j++) {
- double[] curColor = getColorMap().getColor(getColorMap().convertScilabToColorMapIndex(colors[j + nbRow * i]));
+ for (int j = 0; j < nbRow; j++) {
+ for (int i = 0; i < nbCol; i++) {
+ double[] curColor = getColorMap().getColor(getColorMap().convertScilabToColorMapIndex(colors[i + nbCol * j]));
gl.glColor3d(curColor[0], curColor[1], curColor[2]);
gl.glVertex3d(xGrid[i], yGrid[j], zCoord);
gl.glVertex3d(xGrid[i], yGrid[j + 1], zCoord);