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

[meshes3d] bugs in clipConvexPolyhedronByPlane and intersectPlaneMesh #206

Open
joneumann opened this issue Feb 4, 2025 · 3 comments
Open

Comments

@joneumann
Copy link

joneumann commented Feb 4, 2025

matlab version: 23.2.0.2380103 (R2023b) Update 1
matGeom version: bdc8c65

Dear Monsieur Legland,

i tried to revive a code that i wrote ~8 years ago but experienced severals errors, particularly concerning clipConvexPolyhedronByPlane. I tried to go back in history, but since the function has been renamed, the history seems broken somehow.

There, i get an error:

Index exceeds the number of array elements. Index must not exceed 1.

Error in clipConvexPolyhedronByPlane (line 116)
    if minDists(2) < tol

or

Index exceeds the number of array elements. Index must not exceed 1.

Error in clipConvexPolyhedronByPlane (line 99)
        inds(indNews(2)) = Nn + 2;

I looked into this, particulary trying to run the examples, that are in the headers, but they also throw errors.
demo file attached.
I had to change the file extension, because github doesn't let me attach *.m.
I also get 2 errors running the test suite, however, it seems unrelated.

debug_matGeom.txt

Your help is kindly appreciated.

Regards
Johannes Neumann

@oqilipo
Copy link
Contributor

oqilipo commented Feb 4, 2025

Hi joneumann

Try to replace the function by clipMeshByPlane.

Kind regards

@joneumann
Copy link
Author

Dear Oqilipo,

yeah, that does the trick if i triangulate all my polyhedra before i use clipMeshByPlane.
Thank you for the hint.
No general issue with this, i just have to call minConvexHull once more after clipping.
Need to change my code a bit to do that.
But that means support for clipping polyhedra is broken atm, right?

@dlegland
Copy link
Member

dlegland commented Feb 10, 2025

Hi joneuman,

and thank you for detailed report, this always helps!
The functions clipMeshByPlane.m and clipConvexPolyhedronByPlane.m have different development histories, but also different use cases:

  • clipMeshByPlane.m is more recent (and a priori more efficient),
  • clipConvexPolyhedronByPlane.m can handle also non-triangle meshes, but is currently limited to convex meshes (hence the name...)

I think it should be possible to have one function that could manage all cases, but we need to implement it!

I have been checking the tests for clipConvexPolyhedronByPlane.m, but could not get any error... Do you have some minimal working example of the problem?

It seems the function intersectPlaneMesh.m has a a problem, I'll investigate.

Best,
David

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

3 participants