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

Dual Mesh and Clip Vertices nodes failing to work together #4542

Closed
Marcus-Richmond opened this issue Jun 24, 2022 · 10 comments · Fixed by #4545
Closed

Dual Mesh and Clip Vertices nodes failing to work together #4542

Marcus-Richmond opened this issue Jun 24, 2022 · 10 comments · Fixed by #4545
Labels

Comments

@Marcus-Richmond
Copy link

Problem statement

As part of a node setup, I would like to use the Dual Mesh node connected to the Clip Vertices node, like this:

image

The following error is from the Debug print node: [ERROR] sverchok.utils.sv_bmesh_utils:541 : faces.new(...): found the same (BMVert) used multiple times

After looking here: #3989, I tried using the following code and mesh clean node, but without any luck:

exec node
image

mesh clean
image
(I tried the various options with the mesh clean node, but didn't resolve the error)

The Clip Vertices node still works without the Dual Mesh node however:
image

Seems like without edges being input into the Clip Vertices node, this node returns this error. I tried another setup where the Clip Vertices node was only being passed verts/polygons and no edges:
image

Again, looking at #3989, I see the discussion is about duplicate faces, but none of these node setups appear to be creating duplicate faces.

Sverchok version

Sverchok 1.1.0 with Blender 3.1.2

@Durman
Copy link
Collaborator

Durman commented Jun 24, 2022

This is certainly a bug because the example below should work according to the node documentation.

image

@Durman
Copy link
Collaborator

Durman commented Jun 24, 2022

The problem is that this line is not called when edges are not provided.

bm.edges.index_update()

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2022

weirdly enough that bm.edges.index_update() seems to have been always dependent on the presence of edges input, and somehow it now bugs out. (earliest version i can find https://github.com/nortikin/sverchok/blob/df942c23e73d6e093cf1d2306e3c10ee6e5bbecd/utils/sv_bmesh_utils.py)

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2022

also, kind of awkward that the cross section node outputs "faces" from an "edges" socket (Seen https://user-images.githubusercontent.com/59568811/175453632-39e0c2d2-1c59-4240-981c-7a2b2169a11d.png )

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2022

the error is emanating from truncate_vertices

  File "C:\Users\zeffi\Desktop\scripts\addons_contrib\sverchok\utils\sv_bmesh_utils.py", line 541, in truncate_vertices
    new_bm_add_face(new_face)
ValueError: faces.new(...): found the same (BMVert) used multiple times

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2022

maybe we dedent bm.edges.index_update() in bmesh_from_pydata ? @Durman

@Durman
Copy link
Collaborator

Durman commented Jun 25, 2022

I thought about adding extra property to the function because calling index_update method might be expensive (not sure how much)

def bmesh_from_pydata(..., edge_update=False):
    ...
    if has_element(edges) or edge_update:
        bm.edges.index_update()
    ...

It should not impact on existing usage of the function, especially if to catch the has_element function result.

@zeffii
Copy link
Collaborator

zeffii commented Jun 26, 2022

i thought about that too, for the same reasons, but i doubt the computational penalty is dramatic. i'll test and change if necessary

@zeffii
Copy link
Collaborator

zeffii commented Jun 26, 2022

a uvsphere 300*300 = 89700 is number of faces,

always index edges

89700
bmesh_from_pydata: 177.67 ms

index edges on demand

index_edges=True (which i think is a more descriptive name, index is also a verb)

89700
bmesh_from_pydata: 109.94 ms

@zeffii
Copy link
Collaborator

zeffii commented Jun 26, 2022

indexing edges is now an explicit switch in the bmesh_from_pydata function call. @Durman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants