Intensity series (Grid or Mesh) is array of M x N nodes and you should fill all the nodes. For IntensityMeshSeries X & Y values initialized as 0. Therefore, you are getting broken image as you described, if you are not setting values for remaining nodes.
In your case, either yo need to arrange points differently or use Stencil areas to clip points you don't want to see.
For example, following modification could be done in your code, where polygon is created around mesh and used as stencil:
Code: Select all
PointDouble2D[] polygonPoints = new PointDouble2D[2 * columns + 2 * rows];
int iPoly = 0;
int iColCount = 0;
for (int row = 0; row < rows; row++)
{
double x = minX;
iColCount = rnd.Next(6, columns);
//for (int col = 0; col < iColCount; col++)
for (int col = 0; col < columns; col++)
{
data[col, row].X = x + bendAmplitude * Math.Sin((double)row / 16.0);
data[col, row].Y = y + bendAmplitude * Math.Cos((double)col / 16.0);
if (row == 0 && col < iColCount - 1)
{
// add all 1st row point to polygon before Column to be ignored
polygonPoints[iPoly].X = data[col, row].X;
polygonPoints[iPoly].Y = data[col, row].Y;
iPoly++;
}
x += stepX;
}
y += stepY;
polygonPoints[iPoly].X = data[iColCount - 1, row].X;
polygonPoints[iPoly].Y = data[iColCount - 1, row].Y;
iPoly++;
}
_intensityMesh.Data = data;
// add last row points of IntensityMesh to polygon (starting from column one before ignored)
for (int col = iColCount - 2; col >= 0; col--)
{
polygonPoints[iPoly].X = data[col, rows - 1].X;
polygonPoints[iPoly].Y = data[col, rows - 1].Y;
iPoly++;
}
// add 1st column points of IntensityMesh to polygon
for (int row = rows - 2; row >= 0; row--)
{
polygonPoints[iPoly].X = data[0, row].X;
polygonPoints[iPoly].Y = data[0, row].Y;
iPoly++;
}
PointDouble2D[] newPolygonPoints = new PointDouble2D[iPoly];
Array.Copy(polygonPoints, newPolygonPoints, iPoly);
// Apply circle stencil for Intensity Mesh
StencilArea stencilArea = new StencilArea(_intensityMesh.Stencil);
stencilArea.IgnoreHoles = true;
stencilArea.AddPolygon(newPolygonPoints);
_intensityMesh.Stencil.AdditiveAreas.Add(stencilArea);
Here is the image
- ClippedMesh.png (57.71 KiB) Viewed 7235 times
Please note, that enabling
stencilArea.IgnoreHoles will allow to avoid polygon drawing direction issues (clockwise and anticlockwise may be interpreted differently). In addition, try to avoid adding duplicate points.
Hope this helps.