cart: empty [ Login ]

Render DXF in WPF: Lines missing?

1 
John Beefer
6/18/2018 10:01 AM
Hi, I'm investigating this library, it makes a good impression and I would like to buy it, but I have a problem. I have a DXF file, when I render it with the WPF example, it seems that some lines are missing. If I render them with Autodesk TrueView or the WinForms example, the lines are there: I added two screenshots (I marked the missing lines in blue color). The first one is from Autodesk TrueView, the second one is from the WPF example. TrueView: WPF Example: The DXF file I am trying to display using WPF is in the attachments. I would like to know if I am doing something wrong and if it's possible to display the file correctly in a WPF application. I would be very thankful for your support (and would buy your software). Kind regards, John
Wout
6/18/2018 12:38 PM
Hi, Looks like there's a floating point accuracy issue in WPF when the bounds center is far away from the origin. If you translate the drawing to the origin the problem is gone. For application Examples\WpfViewApplicationCS make the following change, replace this:
C# Code:
wpfGraphics.CreateDrawables(model, Matrix4D.Identity);
with:
C# Code:
// Center the drawables around (0, 0) to prevent floating point accuracy problems in case the drawing's // center is far away from the origin. Matrix4D centerTransform = Transformation4D.Translation(Point3D.Zero - bounds.Center); wpfGraphics.CreateDrawables(model, centerTransform); bounds.Transform(centerTransform);
For application Examples\WpfViewApplicationWithLineWidthCorrectionCS make the following change, replace:
C# Code:
graphicsCache.CreateDrawables(model, Matrix4D.Identity);
with:
C# Code:
// Center the drawables around (0, 0) to prevent floating point accuracy problems in case the drawing's // center is far away from the origin. Matrix4D centerTransform = Transformation4D.Translation(Point3D.Zero - bounds.Center); graphicsCache.CreateDrawables(model, centerTransform); bounds.Transform(centerTransform);
By the way, I'm not a fan of WPF, I would recommend using the Win Forms rendering, it's quite a bit faster. - Wout
John Beefer
6/18/2018 2:27 PM
Hi Wout, Thank you very much! It renders correctly now. By the way, I'm not a fan of WPF, I would recommend using the Win Forms rendering, it's quite a bit faster. Are you refering to Windows Forms' GDI rendering? It is not an option for us to use Windows Forms in our application, but it would be possible to pass the GDI handle to a WPF component. Is it that what you are suggesting? Kind regards, John
Wout
6/18/2018 2:59 PM
Well, in case you would have the choice not to use WPF, I would recommend that. But if you must use WPF I would indeed also look into doing GDI+ rendering inside WPF (or host a Win Forms control inside WPF if that's possible, I seem to remember that this was possible). - Wout
1