3

I'm trying to write an CAD-like application in WPF(.NET 4.0) that needs to be able to display a lot of 2D points/lines. It will be used to display CAD-plans of entire cities with zoom, pan, rotate and point snapping on mouseover.

Right now I purely use WPF. I read the objects from the CAD file draw them into a StreamGeometry, use it as stroke of a new Path and add it to a Canvas, with several transforms.

My problem is that this solution doesn't scale well enough. It works fine with small CAD-files, but when I want to display like half a city(with houses and land boundaries) it is very very delayed.

I also tried to convert my CAD-file to an image, but - a resolution a 32000x32000 is sometimes not enough - when zooming out the lines are too thin.

In the end I need to be able to place this on a Canvas(2D/3D) as background.

What are my best options here?

Thanks, Niklas

user1193077
  • 31
  • 1
  • 2

3 Answers3

1

wpf is not good for a large 3d models. im afraid it is too slow. Your best bet is direct 3d or openGL

However, even with the speed of direct3d,openGL you will still need to work out how to cull as many polygons/vertices as possible before the rendering of the scene if you are trying to show an entire city.

there is a large amount of information on this (generally under game development) there are a few techniques including frustrum culling, near and far plane culling.

also, since you probably have a static scene you may be able to use binary spacial partitioning.

Anton
  • 7,709
  • 5
  • 31
  • 33
  • Thank you Anton. If I understand these techniques correctly they are for culling points/objects in 3D. But my CAD-files only have 2 (relevant) dimensions(bird's eye view). In my 3D Canvas my "CAD-objects" will only be used as a texture. I know if I cull enough points the performance will increase, but tbh I thought that WPF would already do that in some way. – user1193077 Feb 07 '12 at 17:46
  • Like Anton says, WPF is just not fast. Use OpenGL or DirectX, even if it's "just" 2D, it will be hugely faster. – Wout May 24 '12 at 09:55
0

As I understand the subject is 2D CAD system within WPF. Great! I use it...
OpenGL and DirectX are in infinite loop OnDraw always. The CPU works all the time. WPF/Silverlight 2D is smart model.
Yes, total amount of elements (for example, primitives inherited from Shape) must be not so much. But how many?
I tested own app (Silverlight). WPF will be a bit faster I hope... Here my 2D CAD results. Performance is still great. Each beam consists of multiple primitives.

Usual mode of task

Performance test - see the amount of Beams

Sergey Orlov
  • 491
  • 5
  • 16
  • 2
    You did not share any technical aspect on how you did implement this.. Can you please elaborate what's you have used? Thx – Dan May 08 '14 at 08:19
  • 1
    @EpiGen :) No, no... 90% of the web is about it ("Look how cool I am"). See Media and Media3D namespaces. There are a lot of classes for each detail: Line, Polygone... (put in Canvas) and ModelVisual3D, UIElement3D. Wrap shape's parameters into dependency property for simplicity. – Sergey Orlov Jul 04 '15 at 21:35
  • 1
    @dna2 The single one book about WPF charts and graphics http://www.apress.com/9781430224815 – Sergey Orlov Jul 04 '15 at 22:05
0

Use a VirtualCanvas like this one from Chris Lovett.

SpeedCoder5
  • 8,188
  • 6
  • 33
  • 34