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

Preserve structure after remeshing #20

Open
Nicolaus93 opened this issue Jul 2, 2024 · 3 comments
Open

Preserve structure after remeshing #20

Nicolaus93 opened this issue Jul 2, 2024 · 3 comments

Comments

@Nicolaus93
Copy link

Hi again,

I have the following problem. I have different meshes that I want to read and then merge, remesh using graphite/geogram.
The different meshes have been split from one original single mesh. Think for example of a cube, then I have 6 different faces.
Is there a way to preserve the original (exterior) edges when remeshing? This is roughly what I've been trying:

def gompy_append(nb_points=100):
    scene_graph = gom.create(classname='OGF::SceneGraph', interpreter=gom)
    scene_graph.clear()

    faces = [scene_graph.load_object(f"/tmp/cube_face_{i}.obj") for i in range(6)]

    # merge only some faces of the cube
    for i in range(1, 4):
        f = faces[i]
        f.I.Surface.remesh_smooth(nb_points=nb_points, tri_shape_adapt=2.0, adjust=True)
        remesh = scene_graph.resolve('remesh')
        faces[0].I.Mesh.append(remesh)

    ps.init()
    ps.register_surface_mesh(
        "merge",
        np.asarray(faces[0].I.Editor.find_attribute('vertices.point')),
        np.asarray(faces[0].I.Editor.get_triangles()),
    )
    ps.show()

If you try to increase the number of points, the quality of the final result will improve.
However, I would like to know if there's a way to reproduce the original structure after merging all the faces.
If I skip the remesh step, then just merging the faces gives back the original single mesh.

image

@BrunoLevy
Copy link
Owner

Hello !
If the different parts of the mesh are planar, what you need is a constrained Delaunay triangulation, to make sure that the border of each part is preserved.
It exists in geogram, CDT_2d, unfortunately, there is no Python/gompy binding yet for it (you'll need to deep-dive into the C++).
You will need also a way of generating the additional points, for instance CVT.
Another possibility is to use Jonathan Shewchuk's Triangle program. It does both constrained Delaunay triangulation and point insertion. To use it in a Python program, you will need to write the polygonal contour of your part into a file, spawn triangle, then read the result back (but it may be easier than diving into geogram C++ classes).

@Nicolaus93
Copy link
Author

Thank you for the detailed answer!
Then I'm looking forward to the python bindings for geogram even more 😄
But I might try to give a shot to the original geogram in C++

@Nicolaus93
Copy link
Author

Nicolaus93 commented Jul 3, 2024

It seems there's a python wrapper also for Triangle https://rufat.be/triangle/
For constrained Delaunay triangulation, I believe an example is described here https://rufat.be/triangle/delaunay.html

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