实施Marching Cube算法?

发布于 2024-07-19 00:49:30 字数 387 浏览 3 评论 0原文

从我的上一个问题:行进立方体问题

但是,我仍然不清楚:

  1. 如何创建假想的立方体/体素来检查顶点是否位于等值面下方?
  2. 我如何知道哪个顶点位于等值面下方?
  3. 每个立方体/体素如何确定要使用哪个立方体索引/表面?
  4. 如何使用triTable中的数据绘制曲面?

假设我有一个苹果的点云数据。
我该如何继续?

熟悉 Marching Cube 的人可以帮助我吗?
我只知道C++和opengl。(c有点超出我的能力)

From My last question: Marching Cube Question

However, i am still unclear as in:

  1. how to create imaginary cube/voxel to check if a vertex is below the isosurface?
  2. how do i know which vertex is below the isosurface?
  3. how does each cube/voxel determines which cubeindex/surface to use?
  4. how draw surface using the data in triTable?

Let's say i have a point cloud data of an apple.
how do i proceed?

can anybody that are familiar with Marching Cube help me?
i only know C++ and opengl.(c is a little bit out of my hand)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

窝囊感情。 2024-07-26 00:49:30

首先,等值面可以用两种方式表示。 一种方法是将等值和每点标量作为来自外部源的数据集。 这就是核磁共振扫描的工作原理。 第二种方法是创建一个隐式函数 F(),它将一个点/顶点作为其参数并返回一个新标量。 考虑这个函数:

float computeScalar(const Vector3<float>& v)
{
    return std::sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}

它将计算标量场中每个点从该点到原点的距离。 如果等值是半径,您就找到了表示球体的方法。
这是因为 |v| <= R 对于球体内部或位于其内部的所有点都成立。 只需找出哪些顶点在球体内部,哪些顶点在球体外部即可。 您需要使用小于或大于运算符,因为卷将空间一分为二。 当您知道立方体中的哪些点被分类为内部和外部时,您还知道等值面与哪些边相交。 您最终可以得到从没有三角形到五个三角形的所有内容。 网格顶点的位置可以通过在相交的边上进行插值来找到实际的交点来计算。


如果您想用标量字段表示一个苹果,您要么需要获取源数据集以插入到您的应用程序中,要么使用相当复杂的隐式函数。 我建议首先使用简单的几何基元(例如球体和环面),然后从那里进行扩展。

First of all, the isosurface can be represented in two ways. One way is to have the isovalue and per-point scalars as a dataset from an external source. That's how MRI scans work. The second approach is to make an implicit function F() which takes a point/vertex as its parameter and returns a new scalar. Consider this function:

float computeScalar(const Vector3<float>& v)
{
    return std::sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}

Which would compute the distance from the point and to the origin for every point in your scalar field. If the isovalue is the radius, you just figured a way to represent a sphere.
This is because |v| <= R is true for all points inside a sphere, or which lives on its interior. Just figure out which vertices are inside the sphere and which ones are on the outside. You want to use the less or greater-than operators because a volume divides the space in two. When you know which points in your cube are classified as inside and outside, you also know which edges the isosurface intersects. You can end up with everything from no triangles to five triangles. The position of the mesh vertices can be computed by interpolating across the intersected edges to find the actual intersection point.


If you want to represent say an apple with scalar fields, you would either need to get the source data set to plug in to your application, or use a pretty complex implicit function. I recommend getting simple geometric primitives like spheres and tori to work first, and then expand from there.

顾挽 2024-07-26 00:49:30

1)这取决于yoru的实现。 您需要有一个数据结构,可以在其中查找体素或立方体每个角(顶点)的值。 这可以是 3D 图像(即:OpenGL 中的 3D 纹理),也可以是自定义的数组数据结构,或者您希望的任何其他格式。

2)你需要检查立方体的顶点。 对此有不同的优化,但一般来说,从第一个角开始,只检查立方体所有 8 个角的值。

3) 大多数(快速)算法都会创建一个位掩码,用作静态选项数组的查找表。 对此只有这么多可能的选择。

4) 一旦你从 triTable 中制作了三角形,你就可以使用 OpenGL 来渲染它们。

假设我有一个苹果的点云数据。 我该如何继续?

这不适用于行进立方体。 行进立方体需要体素数据,因此您需要使用某种算法将数据点云放入立方体中。 高斯泼溅是这里的一个选项。

通常,如果您使用点云工作并且想要查看表面,则应该查看表面重建算法而不是行进立方体。

如果您想了解更多信息,我强烈建议您阅读一些有关可视化技术的书籍。 Kitware 人员提供的一个很好的工具包 - 可视化工具包

您可能想看看 VTK。 它具有 Marching Cubes 的 C++ 实现,并且完全开源。

1) It depends on yoru implementation. You'll need to have a data structure where you can lookup the values at each corner (vertex) of the voxel or cube. This can be a 3d image (ie: an 3D texture in OpenGL), or it can be a customized array data structure, or any other format you wish.

2) You need to check the vertices of the cube. There are different optimizations on this, but in general, start with the first corner, and just check the values of all 8 corners of the cube.

3) Most (fast) algorithms create a bitmask to use as a lookup table into a static array of options. There are only so many possible options for this.

4) Once you've made the triangles from the triTable, you can use OpenGL to render them.

Let's say i have a point cloud data of an apple. how do i proceed?

This isn't going to work with marching cubes. Marching cubes requires voxel data, so you'd need to use some algorithm to put the point cloud of data into a cubic volume. Gaussian Splatting is an option here.

Normally, if you are working from a point cloud, and want to see the surface, you should look at surface reconstruction algorithms instead of marching cubes.

If you want to learn more, I'd highly recommend reading some books on visualization techniques. A good one is from the Kitware folks - The Visualization Toolkit.

You might want to take a look at VTK. It has a C++ implementation of Marching Cubes, and is fully open sourced.

半岛未凉 2024-07-26 00:49:30

根据要求,这里是一些实现 Marching Cubes 算法的示例代码(使用 JavaScript/Three.js 作为图形):

http://stemkoski.github.com/Three.js/Marching-Cubes.html

有关该理论的更多详细信息,您应该查看

http://paulbourke.net/geometry/polygonise/

As requested, here is some sample code implementing the Marching Cubes algorithm (using JavaScript/Three.js for the graphics):

http://stemkoski.github.com/Three.js/Marching-Cubes.html

For more details on the theory, you should check out the article at

http://paulbourke.net/geometry/polygonise/

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