在Python(或C++)中将一个实体减法扫过另一个实体

发布于 2024-08-28 12:08:29 字数 181 浏览 8 评论 0原文

我正在尝试编写一个简单的程序,让我可以使用带有特定切割头的铣机在木板上进行一系列连续切割。我正在尝试找到一个几何库,它能够通过扫描其他 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

辞旧 2024-09-04 12:08:39

虽然不完全是一个库,但实现此目的的一种方法可能是在大多数库都支持的 2D 到 3D 挤出功能的基础上构建。执行此操作的暂定算法可能是:

  1. 获取 2D 形状的钻头轮廓(您可能已经有了这个)。
  2. 沿着作为刀具路径的直线或圆弧挤出该轮廓,创建作为切削形状的 3D 实体。
  3. 在每个顶点(例如,直线路径与弯曲路径连接的位置),对钻头轮廓进行“旋转拉伸”或“旋转拉伸”以生成角半径 - 大多数库也应该支持此操作。
  4. 从 2 开始重复,直到完成所有刀具路径。
  5. 对 (工件 - set_of_toolpaths) 进行 CSG 布尔减法。

该算法似乎可能充满了边缘情况,但到目前为止我还没有想到任何情况。我想知道为什么,如果这么简单,为什么没有更多的软件包已经这样做了。

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:

  1. Get bit profile as a 2D shape (you're likely to have this already).
  2. Extrude that profile along the line or arc that is the toolpath, creating a 3D solid that is the shape of the cut.
  3. At each vertex (say, where a straight path joins a curved one), do a "rotate extrude" or "revolve extrude" of the bit profile to generate the corner radius -- most libraries should support this operation as well.
  4. Repeat from 2 until done with all toolpaths.
  5. Do a CSG boolean subtraction of (workpiece - set_of_toolpaths).

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.

世界等同你 2024-09-04 12:08:38

我们正在使用 sgCore

非常强大且简单的库。

We are using sgCore

Very powerful and simple library.

无需解释 2024-09-04 12:08:38

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:

柠檬心 2024-09-04 12:08:37

HeeksCAD 可能会为您完成这项工作。 http://code.google.com/p/heekscad/

HeeksCAD might do the job for you. http://code.google.com/p/heekscad/

許願樹丅啲祈禱 2024-09-04 12:08:37

采用 C++ 方式,如果您有 Direct3D/OpenGL 经验,您可以使用 TetGenGTS 将一些东西放在一起。

警告:学习曲线非常长。

更新:我最近尝试了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.

放飞的风筝 2024-09-04 12:08:35

pythonOCC 也是一个有趣的选择!

pythonOCC is an interesting option too!

云雾 2024-09-04 12:08:35

也许 FreeCAD 的 Python 级别可以满足您的需求正在请求。

Maybe FreeCAD's Python level can supply what you're requesting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文