void InitTriangleBuffer()
        {
            if (triangleBuffers.Count == 0)
            {
                int count = trianglePoints.Count;

                TimeSeriesLineVertexBuffer11 triangleBuffer = null;

                TimeSeriesLineVertex[] triPointList = null;
                int countLeft = count;
                int index     = 0;
                int counter   = 0;
                foreach (Vector3 point in trianglePoints)
                {
                    if (counter >= 90000 || triangleBuffer == null)
                    {
                        if (triangleBuffer != null)
                        {
                            triangleBuffer.Unlock();
                        }
                        int thisCount = Math.Min(90000, countLeft);

                        countLeft     -= thisCount;
                        triangleBuffer = new TimeSeriesLineVertexBuffer11(thisCount, RenderContext11.PrepDevice);

                        triangleBuffers.Add(triangleBuffer);
                        triangleBufferCounts.Add(thisCount);
                        triPointList = (TimeSeriesLineVertex[])triangleBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)
                        counter      = 0;
                    }

                    triPointList[counter].Position = point;
                    triPointList[counter].Normal   = point;
                    triPointList[counter].Color    = triangleColors[index / 3];
                    triPointList[counter].Tu       = (float)triangleDates[index / 3].StartDate;
                    triPointList[counter].Tv       = (float)triangleDates[index / 3].EndDate;
                    index++;
                    counter++;
                }
                if (triangleBuffer != null)
                {
                    triangleBuffer.Unlock();
                }

                triangleColors.Clear();
                triangleDates.Clear();
                trianglePoints.Clear();

                dataToDraw = true;
            }
        }
        void InitTriangleBuffer()
        {
            if (triangleBuffers.Count == 0)
            {
                int count = trianglePoints.Count;

                TimeSeriesLineVertexBuffer11 triangleBuffer = null;

                TimeSeriesLineVertex[] triPointList = null;
                int countLeft = count;
                int index = 0;
                int counter = 0;
                foreach (Vector3 point in trianglePoints)
                {
                    if (counter >= 90000 || triangleBuffer == null)
                    {
                        if (triangleBuffer != null)
                        {
                            triangleBuffer.Unlock();
                        }
                        int thisCount = Math.Min(90000, countLeft);

                        countLeft -= thisCount;
                        triangleBuffer = new TimeSeriesLineVertexBuffer11(thisCount, RenderContext11.PrepDevice);

                        triangleBuffers.Add(triangleBuffer);
                        triangleBufferCounts.Add(thisCount);
                        triPointList = (TimeSeriesLineVertex[])triangleBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)
                        counter = 0;
                    }

                    triPointList[counter].Position = point;
                    triPointList[counter].Normal = point;
                    triPointList[counter].Color = triangleColors[index / 3];
                    triPointList[counter].Tu = (float)triangleDates[index / 3].StartDate;
                    triPointList[counter].Tv = (float)triangleDates[index / 3].EndDate;
                    index++;
                    counter++;
                }
                if (triangleBuffer != null)
                {
                    triangleBuffer.Unlock();
                }

                triangleColors.Clear();
                triangleDates.Clear();
                trianglePoints.Clear();

                dataToDraw = true;
            }
        }
        void InitLineBuffer()
        {
            if (lineBuffers.Count == 0)
            {
                int count = linePoints.Count;

                TimeSeriesLineVertexBuffer11 lineBuffer = null;

                TimeSeriesLineVertex[] linePointList = null;
                localCenter = new Vector3d();
                if (DepthBuffered)
                {
                    // compute the local center..
                    foreach (Vector3d point in linePoints)
                    {
                        localCenter.Add(point);

                    }
                    localCenter.X /= count;
                    localCenter.Y /= count;
                    localCenter.Z /= count;
                }

                int countLeft = count;
                int index = 0;
                int counter = 0;
                Vector3d temp;

                foreach (Vector3d point in linePoints)
                {
                    if (counter >= 100000 || linePointList == null)
                    {
                        if (lineBuffer != null)
                        {
                            lineBuffer.Unlock();
                        }
                        int thisCount = Math.Min(100000, countLeft);

                        countLeft -= thisCount;
                        lineBuffer = new TimeSeriesLineVertexBuffer11(thisCount, RenderContext11.PrepDevice);

                        linePointList = (TimeSeriesLineVertex[])lineBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)

                        lineBuffers.Add(lineBuffer);
                        lineBufferCounts.Add(thisCount);
                        counter = 0;
                    }

                    temp = point - localCenter;
                    linePointList[counter].Position = temp.Vector311;
                    linePointList[counter].Normal = point.Vector311;
                    linePointList[counter].Tu = (float)lineDates[index / 2].StartDate;
                    linePointList[counter].Tv = (float)lineDates[index / 2].EndDate;
                    linePointList[counter].Color = lineColors[index / 2];
                    index++;
                    counter++;
                }

                lineBuffer.Unlock();

            }
        }
        void InitLineBuffer()
        {
            if (lineBuffers.Count == 0)
            {
                int count = linePoints.Count;

                TimeSeriesLineVertexBuffer11 lineBuffer = null;


                TimeSeriesLineVertex[] linePointList = null;
                localCenter = new Vector3d();
                if (DepthBuffered)
                {
                    // compute the local center..
                    foreach (Vector3d point in linePoints)
                    {
                        localCenter.Add(point);
                    }
                    localCenter.X /= count;
                    localCenter.Y /= count;
                    localCenter.Z /= count;
                }

                int      countLeft = count;
                int      index     = 0;
                int      counter   = 0;
                Vector3d temp;

                foreach (Vector3d point in linePoints)
                {
                    if (counter >= 100000 || linePointList == null)
                    {
                        if (lineBuffer != null)
                        {
                            lineBuffer.Unlock();
                        }
                        int thisCount = Math.Min(100000, countLeft);

                        countLeft -= thisCount;
                        lineBuffer = new TimeSeriesLineVertexBuffer11(thisCount, RenderContext11.PrepDevice);

                        linePointList = (TimeSeriesLineVertex[])lineBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)

                        lineBuffers.Add(lineBuffer);
                        lineBufferCounts.Add(thisCount);
                        counter = 0;
                    }


                    temp = point - localCenter;
                    linePointList[counter].Position = temp.Vector311;
                    linePointList[counter].Normal   = point.Vector311;
                    linePointList[counter].Tu       = (float)lineDates[index / 2].StartDate;
                    linePointList[counter].Tv       = (float)lineDates[index / 2].EndDate;
                    linePointList[counter].Color    = lineColors[index / 2];
                    index++;
                    counter++;
                }

                lineBuffer.Unlock();
            }
        }