2D CAD application in WPF

醉酒当歌 提交于 2019-12-07 17:09:18

问题


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


回答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.




回答2:


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.




回答3:


Use a VirtualCanvas like this one from Chris Lovett.



来源:https://stackoverflow.com/questions/9167654/2d-cad-application-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!