WPF 中的 2D CAD 应用程序 [英] 2D CAD application in WPF
问题描述
我正在尝试在 WPF(.NET 4.0) 中编写一个类似 CAD 的应用程序,它需要能够显示大量的 2D 点/线.它将用于在鼠标悬停时通过缩放、平移、旋转和点捕捉来显示整个城市的 CAD 计划.
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.
现在我纯粹使用 WPF.我从 CAD 文件中读取对象,将它们绘制到 StreamGeometry 中,将其用作新路径的笔划并将其添加到 Canvas,并进行多次变换.
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.
我的问题是这个解决方案的扩展性不够好.它适用于小型 CAD 文件,但当我想显示半个城市(带有房屋和土地边界)时,它会非常非常延迟.
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.
我也尝试将我的 CAD 文件转换为图像,但是- 32000x32000 的分辨率有时是不够的- 缩小时线条太细.
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.
最后,我需要能够将它放在画布(2D/3D)上作为背景.
In the end I need to be able to place this on a Canvas(2D/3D) as background.
我在这里的最佳选择是什么?
What are my best options here?
谢谢,尼古拉斯
推荐答案
wpf 不适用于大型 3d 模型.恐怕太慢了.您最好的选择是直接 3d 或 openGL
wpf is not good for a large 3d models. im afraid it is too slow. Your best bet is direct 3d or openGL
但是,即使以 direct3d、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.
这篇关于WPF 中的 2D CAD 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!