3D Surface plot Zoom/Rotate issues

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
PetexUser
Newbie
Newbie
Posts: 15
Joined: Thu Jul 05, 2018 12:00 am

3D Surface plot Zoom/Rotate issues

Post by PetexUser » Mon Sep 24, 2018 8:44 am

Hi,

There are issues with Zoom/Rotate interactions with 3D Surface plots. Essentially the mesh distorts or breaks apart and eventually asserts .
The code we are using worked fine with the 2011 DotNet version ( and we have tested on more than one machine with different graphics cards)

Version tested: TeeChartNET2018_4.1.2018.05040

I have created a simple bi-variate normal distribution curve to demonstrate the problem (our actual data/code is obviously more complex).
A screenshot is included to demonstrate the actual data.

- In this example I use a rotate tool and set the Chart-3D-3D % to 60% (through the editor)
- Normally we use left mouse button down to start a rotation. Here I am using right button in order to separate effect of rotate vs zoom action. Rotate by itself is fine, stretching the mesh with Zoom area selection followed by rotate appears to cause the problems.

Steps to reproduce
1. Perform a series of zoom (in) and rotate about the distribution shape.
2. Eventually either the Mesh will splinter with vertices drawn (far) into or out of the elevation axis (as though very large or negative values) or the plot will disappear and assert with an overflow error ( leaving the red checked box of doom)

Please note it is not easy to describe the exact zoom/rotate steps required.
Choose a zoom rectangle much larger in one dimension than the other , rotate 45 degrees and repeat is usually enough to trigger the assert

Code snippet follows
=========================

Code: Select all

            Steema.TeeChart.Styles.Surface surfaceSeries1;
            Steema.TeeChart.TChart _chart = chart.Chart();
            chart.Chart().Aspect.View3D = true;
            chart.Chart().Aspect.Orthogonal = false;
            Steema.TeeChart.Tools.Rotate rotate1 = new Steema.TeeChart.Tools.Rotate(_chart.Chart);
        
            rotate1.Button = MouseButtons.Right;
            rotate1.Style = Steema.TeeChart.Tools.RotateStyles.All;

            rotate1.Active = true;
            surfaceSeries1 = new Steema.TeeChart.Styles.Surface();
            surfaceSeries1.Visible = true;

            surfaceSeries1.WireFrame = false;
            surfaceSeries1.Pen.Visible = true;

            surfaceSeries1.Clear();
            surfaceSeries1.ClearPalette();
            surfaceSeries1.IrregularGrid = true;

            // bottom axis - pipe length
            Steema.TeeChart.Axis bottomAxis = chart.Chart().Axes.Bottom;
            bottomAxis.Title.Visible = true;
            bottomAxis.Title.Text = "Pipe length";

            // left axis - property
            Steema.TeeChart.Axis leftAxis = chart.Chart().Axes.Left;
            leftAxis.Title.Visible = true;
            //leftAxis.Title.Text = 

            // depth axis - time
            Steema.TeeChart.Axis depthAxis = chart.Chart().Axes.Depth;
            depthAxis.Title.Visible = true;
            depthAxis.Title.Text = "Time (s)";

            double X;
            double Y;
            double Z;
            double B1;
            double B2;
            double Xbar;
            double Ybar;


            Xbar = Ybar = 10;
            B1 = B2 = 0.01;

            for (int i = -100; i < 100; i++)
            {
                X = (double)i;
                for (int j = -100; j < 100; j++)
                {
                    Y = (double)j;
                    Z= Math.Exp(-1 * B1*(X - Xbar)* (X - Xbar)  -1 * B2*(Y - Ybar)* (Y - Ybar));
                    surfaceSeries1.Add(X, Z, Y);

                }
            }
            chart.Chart().Series.Add(surfaceSeries1);
Assert error:
================
System.OverflowException: Overflow error.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points, FillMode fillMode)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Polygon(Point[] p)
at Steema.TeeChart.Drawing.Graphics3D.PolygonFour()
at Steema.TeeChart.Drawing.Graphics3D.PlaneFour3D(Int32 z0, Int32 z1, Point[] p)
at Steema.TeeChart.Styles.Surface.DrawTheCell(Int32 z0)
at Steema.TeeChart.Styles.Surface.DrawCell(Int32 x, Int32 z)
at Steema.TeeChart.Styles.Surface.DrawAllCells()
at Steema.TeeChart.Styles.Surface.Draw()
at Steema.TeeChart.Styles.Series.DrawSeries()
at Steema.TeeChart.Chart.DoDraw(Graphics3D g, Int32 First, Int32 Last, Int32 Inc)
at Steema.TeeChart.Chart.DrawAllSeries(Graphics3D g)
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Attachments
0.jpg
0.jpg (480.42 KiB) Viewed 27099 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by Christopher » Tue Sep 25, 2018 8:15 am

Hello!

thank you for your detailed report which I have added to our issue-tracking software with id=2093. Unfortunately I have not been able to reproduce the issue here, but I think I have a fairly clear idea as to the cause and as such have made a modification to the source-code. Could I please ask you to download this new build with the possible fix in it from here and let me know if it solves the issue for you?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

PetexUser
Newbie
Newbie
Posts: 15
Joined: Thu Jul 05, 2018 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by PetexUser » Wed Sep 26, 2018 11:20 am

Hi,

Sorry for the delay as I have been experiencing issues (on my side) updating my actual code to test the new dll.

I have tested the evaluation dll on the sample code in my previous post.
There is a clear improvement (with 4.2018.9.25) in successive zoom and rotate rendering of the mesh.
I am unable to re-create the mesh tearing (found in 4.1.2018.5046)

However I am still able to generate the overflow error.

I have also tested our actual application with real data (see the screenshot in last post) and both the Mesh tearing and overflow error still exist ( to a lesser extent).
I am using a gridband, slice line, fast line and rotate tools ( something is still asking for version 4.1.2018.5046) when I display my plot ( I can find no trace of a version reference in my project, license etc)



many thanks

Mark
Attachments
new .png
new .png (42.17 KiB) Viewed 27087 times
Last edited by PetexUser on Wed Sep 26, 2018 3:35 pm, edited 1 time in total.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by Christopher » Wed Sep 26, 2018 1:50 pm

PetexUser wrote:
Wed Sep 26, 2018 11:20 am
I have re-added the reference (pointing to the new dll), checked the project file and the license.licx
and cannot find 4.1.2018.5046 anywhere (all my references show 4.2018.9.25) and the evaluation banner.
Yes, this is a non-official build with the evaluation banner hard-coded in.
PetexUser wrote:
Wed Sep 26, 2018 11:20 am
At runtime when I display the plot it complains about Version=4.1.2018.5046.
This could be because your license.licx file contains the version number of the TeeChart.dll - you can remove that section of it and it should work.
PetexUser wrote:
Wed Sep 26, 2018 11:20 am
I have tested the evaluation dll on the sample code in my previous post.
There is a clear improvement (with 4.2018.9.25) in successive zoom and rotate rendering of the mesh.
I am unable to re-create the mesh tearing (found in 4.1.2018.5046)
Excellent.
PetexUser wrote:
Wed Sep 26, 2018 11:20 am
However I am still able to generate the overflow error.
Okay - could you please paste the stacktrace here so I can see where in the code it's being thrown?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

PetexUser
Newbie
Newbie
Posts: 15
Joined: Thu Jul 05, 2018 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by PetexUser » Fri Sep 28, 2018 12:36 pm

Hi,

Yes I have tried deleting the license file contents and additional version information entries in my VS project files.
I run my application I see the evaluation banner on the 2D plot which leads me to conclude I have built with the evaluation version.
I display the 3D surface plot and a failed to read the assembly 4.1.2018.5046 but I can continue and the 3D plot is displayed
I perform a series of zoom/rotate actions as before ( there is tear up and the asset appears)

************** Exception Text **************
System.OverflowException: Overflow error.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points, FillMode fillMode)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.Polygon(Point[] p)
at Steema.TeeChart.Drawing.Graphics3D.PolygonFour()
at Steema.TeeChart.Drawing.Graphics3D.PlaneFour3D(Int32 z0, Int32 z1, Point[] p)
at Steema.TeeChart.Styles.Surface.(Int32 )
at Steema.TeeChart.Styles.Surface.DrawCell(Int32 x, Int32 z)
at Steema.TeeChart.Styles.Surface.()
at Steema.TeeChart.Styles.Surface.Draw()
at Steema.TeeChart.Styles.Series.DrawSeries()
at Steema.TeeChart.Chart.(Graphics3D , Int32 , Int32 , Int32 )
at Steema.TeeChart.Chart.(Graphics3D )
at Steema.TeeChart.Chart.(Graphics , Boolean )
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3110.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by Christopher » Mon Oct 01, 2018 6:56 am

Hello!

The licenses.licx file can be made version-independent by making sure the contents only contain the following:

Code: Select all

Steema.TeeChart.TChart, TeeChart
With respect to the exception, I'm afraid I'm going to have to ask you to try and identify the precise circumstances in which it is thrown in order that I can reproduce the issue here. I think the best way to achieve this is to identify the Rotation and Elevation at which the code you sent throws the exception, and this can be done by tracking these values at debug time with code such as the following:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Surface surfaceSeries1;
			tChart1.Aspect.View3D = true;
			tChart1.Aspect.Orthogonal = false;
			Steema.TeeChart.Tools.Rotate rotate1 = new Steema.TeeChart.Tools.Rotate(tChart1.Chart);

			rotate1.Button = MouseButtons.Right;
			rotate1.Style = Steema.TeeChart.Tools.RotateStyles.All;

			rotate1.Active = true;
			surfaceSeries1 = new Steema.TeeChart.Styles.Surface();
			surfaceSeries1.Visible = true;

			surfaceSeries1.WireFrame = false;
			surfaceSeries1.Pen.Visible = true;

			surfaceSeries1.Clear();
			surfaceSeries1.ClearPalette();
			surfaceSeries1.IrregularGrid = true;

			// bottom axis - pipe length
			Steema.TeeChart.Axis bottomAxis = tChart1.Axes.Bottom;
			bottomAxis.Title.Visible = true;
			bottomAxis.Title.Text = "Pipe length";

			// left axis - property
			Steema.TeeChart.Axis leftAxis = tChart1.Axes.Left;
			leftAxis.Title.Visible = true;
			//leftAxis.Title.Text =

			// depth axis - time
			Steema.TeeChart.Axis depthAxis = tChart1.Axes.Depth;
			depthAxis.Title.Visible = true;
			depthAxis.Title.Text = "Time (s)";

			double X;
			double Y;
			double Z;
			double B1;
			double B2;
			double Xbar;
			double Ybar;


			Xbar = Ybar = 10;
			B1 = B2 = 0.01;

			for (int i = -100; i < 100; i++)
			{
				X = (double)i;
				for (int j = -100; j < 100; j++)
				{
					Y = (double)j;
					Z = Math.Exp(-1 * B1 * (X - Xbar) * (X - Xbar) - 1 * B2 * (Y - Ybar) * (Y - Ybar));
					surfaceSeries1.Add(X, Z, Y);

				}
			}
			tChart1.Series.Add(surfaceSeries1);

			tChart1.BeforeDraw += TChart1_BeforeDraw;
		}

		private void TChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Steema.TeeChart.Utils.WriteLine("Rotation", tChart1.Aspect.Rotation);
			Steema.TeeChart.Utils.WriteLine("Elevation", tChart1.Aspect.Elevation);
		}
In this way you can manipulate the chart until the error is thrown and then read these two values - adding these two values (or values very close to them) back into the InitializeChart() code should be able to directly reproduce the issue.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

PetexUser
Newbie
Newbie
Posts: 15
Joined: Thu Jul 05, 2018 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by PetexUser » Fri Oct 12, 2018 1:38 pm

Hi,

Here are the results using the BeforeDraw event up to the Zoom/Rotate overflow.
Hope this helps.

kindest regards

Test data

windows\dwm\dwmapi\attribute.cpp(92)\dwmapi.dll!71833CF4: (caller: 718890ED) ReturnHr(52) tid(1234) 80070006 The handle is invalid.
Rotation 16 Elevation 276 Zoom 100
Rotation 345 Elevation 280 Zoom 100
The thread 0x4108 has exited with code 0 (0x0).
The thread 0x7c6c has exited with code 0 (0x0).
Rotation 345 Elevation 280 Zoom 100
Rotation 345 Elevation 280 Zoom 100
Rotation 316 Elevation 297 Zoom 100
Rotation 316 Elevation 298 Zoom 100
Rotation 300 Elevation 324 Zoom 100
Rotation 299 Elevation 327 Zoom 100
Rotation 297 Elevation 331 Zoom 100
Rotation 294 Elevation 350 Zoom 100
Rotation 294 Elevation 350 Zoom 100
Rotation 294 Elevation 350 Zoom 100
Rotation 294 Elevation 350 Zoom 100
Rotation 266 Elevation 360 Zoom 100
Rotation 266 Elevation 360 Zoom 100
Rotation 250 Elevation 360 Zoom 100
Rotation 250 Elevation 360 Zoom 100
Rotation 274 Elevation 357 Zoom 100
Rotation 274 Elevation 357 Zoom 100
Rotation 279 Elevation 360 Zoom 100
Rotation 279 Elevation 360 Zoom 100
Rotation 279 Elevation 360 Zoom 100
Rotation 279 Elevation 360 Zoom 100
Rotation 252 Elevation 360 Zoom 100
Rotation 251 Elevation 360 Zoom 100
An unhandled exception of type 'System.OverflowException' occurred in System.Drawing.dll
Additional information: Overflow error.

c.f. with Actual data

windows\dwm\dwmapi\attribute.cpp(92)\dwmapi.dll!71833CF4: (caller: 718890ED) ReturnHr(115) tid(e2c) 80070006 The handle is invalid.
Rotation 255 Elevation 360 Zoom 66
An unhandled exception of type 'System.OverflowException' occurred in System.Drawing.dll
Additional information: Overflow error.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by Christopher » Mon Oct 15, 2018 8:11 am

Hello,
PetexUser wrote:
Fri Oct 12, 2018 1:38 pm
Here are the results using the BeforeDraw event up to the Zoom/Rotate overflow.
Hope this helps.
many thanks for this. I've fed the last values of elevation and rotation (276, 16) before the error was thrown into the latest version of TeeChart.dll and still I can't get the Chart to throw the error. Neither is an error thrown for (elevation:280, rotation:345) or any values near these. Please find here the solution I used - if you were to download this project, do a "Restore NuGet packages" and run it you can see what I mean. Are you able to reproduce your problem using this project? If so, which values of elevation and rotation are reported just before the error is thrown?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

PetexUser
Newbie
Newbie
Posts: 15
Joined: Thu Jul 05, 2018 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by PetexUser » Wed Oct 17, 2018 9:32 am

Hi,

I appreciate that the intermittent nature of the problem makes it hard to reproduce and we may have to reach an impasse.
I cannot reproduce the problem by entering the elevation and rotation value that caused a previous error to be thrown.
I can however make your demo app throw the error by repeatedly zooming and rotating (sometimes it requires a dozen or more steps).

Note - The only change I have made to your project is to change the target framework to (.NET 4.71 to match ours ) I appreciate the TeeChart Dll is built on 4.62.
Thank you for all your efforts to track this
Attachments
OverflowException.png
OverflowException.png (102.35 KiB) Viewed 27027 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: 3D Surface plot Zoom/Rotate issues

Post by Christopher » Fri Oct 19, 2018 9:38 am

Hi,

I'm very sorry, but I am still unable to reproduce this here. It really is most frustrating not being able to solve this one for you at this time. I've spent a good hour zooming and rotating the chart, and have had another good look at the source code, but have not been able to reproduce the issue nor produce an idea of how it might be happening. My apologies. If you are ever able to reproduce this issue using a particular set of values for elevation/rotation/zoom do please let me know.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply