Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hollow out 3D meshes by this tool? #53

Closed
Megidd opened this issue Oct 25, 2022 · 3 comments
Closed

Hollow out 3D meshes by this tool? #53

Megidd opened this issue Oct 25, 2022 · 3 comments

Comments

@Megidd
Copy link
Contributor

Megidd commented Oct 25, 2022

Background

There is a Go source code already available. The source code imports 3D STL surface meshes and stores the index and vertex buffers corresponding to the 3D STL surface mesh.

It's desired to hollow out the imported 3D STL surface meshes by a thickness. To do so, this algorithm might be possible:

  1. Represent the original 3D surface mesh by signed distance field - SDF.
  2. Extract an iso-surface from SDF.
    1. Marching Cube algorithm to extract the iso-surface from SDF.
    2. A negative offset/distance is the threshold passed to marching cube algorithm.
    3. Negative offset means the new iso-surface would be inside SDF.
    4. The offset/distance is actually the thickness of the hollowing process.
  3. Flip the normal vectors of the new internal iso-surface.
    1. This step is trivial.
  4. Merge new internal iso-surface with the original external surface mesh.
    1. This step is trivial.

Question

It's noticed that this package may contain the necessary code for steps 1 and 2 above. Is it right? Is it possible to hollow out 3D STL surface meshes by this package? Can anyone provide a boilerplate code to do so?

@deadsy
Copy link
Owner

deadsy commented Oct 25, 2022

The function you are looking for is sdf.Offset3D()
You can see an example of it's use in ./examples/offset_box.
Note that the "hollowing out" operation just occurs on the SDF. It has nothing to do with the source being an STL.

Pseudo code is something like:

s0 := ImportSTL("file.stl)
s1 = Offset3D(s0, thickness)
s2 := Difference3D(s0, s1)
Render(s2)

@Megidd
Copy link
Contributor Author

Megidd commented Oct 26, 2022

Thanks @deadsy I'm going to try it. Probably I'll be back with some questions 🙂

@Megidd
Copy link
Contributor Author

Megidd commented Oct 27, 2022

Conclusion

PR #54 introduces an example to carve out the inside of the input STL surface mesh. The corresponding comments of PR #54 should be noted.

So, steps 1 and 2 of this algorithm can be done by this package:

  1. Represent the original 3D surface mesh by signed distance field - SDF.
  2. Extract an internal iso-surface from SDF. It's inside the original surface mesh.
  3. Flip the normal vectors of the new internal iso-surface.
  4. Merge new internal iso-surface with the original external surface mesh.

Steps 3 and 4 are trivial.

@Megidd Megidd closed this as completed Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants