在Python(或C++)中将一个实体减法扫过另一个实体
我正在尝试编写一个简单的程序,让我可以使用带有特定切割头的铣机在木板上进行一系列连续切割。我正在尝试找到一个几何库,它能够通过扫描其他 3D 实体来减法修改 3D 形状或实体。
具体来说,我希望能够定义一个矩形实体(木板),然后定义一个位轮廓形状,并在矩形实体上进行切割(有时在直线上,有时在圆弧上)。有谁知道有什么可以做到这一点?
I'm trying to put together a simple program that will let me visualize a series of consecutive cuts on a wood panel using a router with a particular cutting head. I'm trying to find a geometry library that is capable of subtractively modifying 3D shapes or solids by sweeping other 3D solids through them.
Specifically, I'd like to be able to define a rectangular solid (the wood panel) and then define a bit profile shape, and take cuts through the rectangular solid (sometimes on a straight line, sometimes on a circular arc). Does anyone know of anything that will do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
虽然不完全是一个库,但实现此目的的一种方法可能是在大多数库都支持的 2D 到 3D 挤出功能的基础上构建。执行此操作的暂定算法可能是:
该算法似乎可能充满了边缘情况,但到目前为止我还没有想到任何情况。我想知道为什么,如果这么简单,为什么没有更多的软件包已经这样做了。
While not exactly a library, one way of doing this might be to build on top of the 2D-to-3D extrusion ability that most of these libraries do support. A tentative algorithm for doing this might be:
That algorithm seems like it might be fraught with edge cases, but I haven't been able to think of any so far. I'm wondering why, if it's this simple, there aren't more packages already doing it.
我们正在使用 sgCore
非常强大且简单的库。
We are using sgCore
Very powerful and simple library.
CGAL 看起来它可能能够使用 3D Minkowski 和。 (请参阅页面下方的“滑行”部分。)
到目前为止,我可以看到使用 Minkowski 和的唯一限制是,如果通过 3D 路径扫描对象,您似乎无法以同时。 (我对此可能是错的。)例如,如果您尝试在旋转圆柱体的外表面上使用刳刨机或铣刀模拟切割路径(例如第四个或第五个),则在扫描时旋转会很有用。铣床上的轴旋转工作台。但最初的问题是关于沿着 2D 路径扫描 3D 对象,模拟在木块等平面上的切割,所以这个限制对我来说可能很重要,但对 OP 来说并不重要。
CGAL 由 OpenSCAD 使用。 OpenSCAD 有一个 minkowski() 原语,它似乎使用 CGAL 3D Minkowski 功能。 OpenSCAD也许能够提供快速的可行性测试以及长期的刀具路径可视化解决方案。 (上次我看这个时我不这么认为,但这可能是 OpenSCAD 的旧版本。)
CGAL 是 C++,开源,双重许可。到目前为止,我发现了两个 python 绑定:
CGAL looks like it might be able to do 3D sweeps, using 3D Minkowski Sums. (See the "Glide" section further down the page.)
The only limitation I can see so far with using Minkowski sums is that, if sweeping an object through a 3D path, you don't seem to be able to rotate the object at the same time. (I could be wrong about this.) Rotating while sweeping would be useful, for instance, if you are trying to simulate cutting a path using a router or milling bit on the outside surface of a rotating cylinder, such as for a 4th or 5th axis rotary table on a milling machine. But the original question was about sweeping 3D objects along 2D paths, simulating cuts on a plane such as a block of wood, so this limitation might be important to me but not to OP.
CGAL is used by OpenSCAD. OpenSCAD has a minkowski() primitive that appears to use the CGAL 3D Minkowski feature. OpenSCAD might be able to provide a quick feasibility test as well as maybe a long-term toolpath visualization solution. (The last time I looked at this I didn't think so, but that may have been an older version of OpenSCAD.)
CGAL is C++, open source, dual licensed. So far I've found two python bindings:
HeeksCAD 可能会为您完成这项工作。 http://code.google.com/p/heekscad/
HeeksCAD might do the job for you. http://code.google.com/p/heekscad/
采用 C++ 方式,如果您有 Direct3D/OpenGL 经验,您可以使用 TetGen 和 GTS 将一些东西放在一起。
警告:学习曲线非常长。
更新:我最近尝试了Carve CSG,并对结果感到满意,所以远的。您可以轻松地减去木板上的切口以获得您想要的结果。
Going the C++ way, if you have Direct3D/OpenGL experience, you could muck around with TetGen and GTS to put something together.
WARNING: Very Long learning curve.
UPDATE: I have experimenting with Carve CSG recently and am happy with the results so far. You could easily subtract the cut from the wood panel to get the results you want.
打开级联
Open Cascade
pythonOCC 也是一个有趣的选择!
pythonOCC is an interesting option too!
也许 FreeCAD 的 Python 级别可以满足您的需求正在请求。
Maybe FreeCAD's Python level can supply what you're requesting.