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

Some questions about basic knowledge in Easy3D #201

Open
DWR-CMQ opened this issue Dec 30, 2024 · 1 comment
Open

Some questions about basic knowledge in Easy3D #201

DWR-CMQ opened this issue Dec 30, 2024 · 1 comment
Labels
question Further information is requested

Comments

@DWR-CMQ
Copy link

DWR-CMQ commented Dec 30, 2024

Here I go again 😏,I've been looking at the SurfaceMeshSimplification Code recently.There are a few things I don't understand.

  • First, the purpose of the function "remove_edge"
    image
    image
    Let's say the original graph looks like this, and we want to remove the h=1 halfedge
    image
    so, hn = 5, hp=7, o=0, on=2, op=4,vh=V1, vo = V2,
    What I don't understand is what do these two lines of code mean
    image
    On line 911, why is the next halfedge of hp=7 set to hn=5?there is an halfedge h=1 in the middle. 😟
    On line 912, the next halfedge of op=4 is o=0, why is it be set to on=2 on line 912? 😟

  • Second, in the function "collect_garbage"
    image
    Why update halfedge of the information with a hash table,I really don't know the reason 😟

  • Third, it's still in this function "collect_garbage", the vertices, the edges, the faces
    image
    why are we finding the first deleted and last un-deleted, and swap them 😟

@DWR-CMQ DWR-CMQ added the enhancement New feature or request label Dec 30, 2024
@LiangliangNan
Copy link
Owner

I found it would take much time to explain the details. So very brief answers at a higher level below:

(1) How edge collapse works in Easy3d: we move its start vertex into its target vertex. For non-boundary halfedges this function removes one vertex, three edges, and two faces. For boundary halfedges it removes one vertex, two edges and one face. This function is only valid for triangle meshes.

(2) Those are not hash tables but simply per-element properties. We want to keep the original information after the elements are re-ordered, and this information will be used to rebuild the topology.

(3) You should first know that deleting an element (not at the end) from an array is expensive because you will have to move all elements following the deleted one or rebuild the entire array. The most efficient way is to organize all elements you want to keep at the first part of the array and all elements to be deleted at the second part of the array. The reorganization of the elements can be done by the swap. "finding the first deleted and last un-deleted, and swap them" is to ensure the elements are organized in such as way. For example, if you want to delete B from the array of "AABABAAAA", try the swap operation on this string :-).

Halfedge collapses might lead to invalid faces. Call is_collapse_ok(Halfedge) to be sure the collapse is legal.

The removed items are only marked as deleted. You have to call collect_garbage() to finally remove them.

@LiangliangNan LiangliangNan added question Further information is requested and removed enhancement New feature or request labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants