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

Bug in minConvexHull ? #27

Open
oqilipo opened this issue Aug 9, 2017 · 9 comments
Open

Bug in minConvexHull ? #27

oqilipo opened this issue Aug 9, 2017 · 9 comments
Assignees

Comments

@oqilipo
Copy link
Contributor

oqilipo commented Aug 9, 2017

Hi

I've tried minConvexHull, but I get a mesh with edges with two faces on one side.
Here is the test case:
test_minConvexHull.zip
One of the bad edges is marked in red here:
minconvexhull

Thanks in advance

@dlegland
Copy link
Member

hi,

not really a bug, but the output of minConvexHull does not impose faces to have consistent orientation. This would be interesting, however...
I think this can easily be added, as the result is convex. I check it...

@dlegland dlegland self-assigned this Aug 10, 2017
@dlegland
Copy link
Member

Hi,

I have just made a commit that should solve the problem. You can check result of face orientation with the following:
pfaces = minConvexHull(vertices);
pFacesNormals = faceNormal(vertices, pfaces);
pFacesCenters = faceCentroids(vertices, pfaces);
figure; drawMesh(vertices, pfaces); title('min convex hull')
axis equal; view(3);
hold on ; drawVector3d(pFacesCenters, pFacesNormals)

Hope this solves the problem?

@oqilipo
Copy link
Contributor Author

oqilipo commented Aug 11, 2017

Thank you,

I will evalute it and give feedback.

@oqilipo
Copy link
Contributor Author

oqilipo commented Sep 12, 2017

There is still an error, if you remove the last vertex of the testVertices.mat from above :

load('testVertices')
% Delete last vertex
vertices(end,:)=[];
% Check if all vertices are unique
assert(length(vertices)==length(unique(vertices,'rows')))
% Convex hull
faces = minConvexHull(vertices);
% Triangulate
faces = triangulateFaces(faces);
% Visualization
figure('Color','w'); view(3); axis equal tight
patch('Vertices',vertices,'Faces',faces,'FaceColor','none')
% Edges
edges = meshEdges(faces);
% Edge faces
edgeFaces = meshEdgeFaces(vertices, edges, faces);
Error using meshEdgeFaces/processFace (line 69)
Two faces were found on left side of edge 1100

Thanks in advance

@dlegland
Copy link
Member

Hi,
thanks for reporting. I will investigate this ASAP...

@dlegland
Copy link
Member

Hi,
I just had a look, and could not reproduce the bug...
Is it still up to date?

@oqilipo
Copy link
Contributor Author

oqilipo commented May 17, 2019

I'll check it

@oqilipo
Copy link
Contributor Author

oqilipo commented May 21, 2019

Seems to work.

However, one should be aware that unreferenced vertices can remain:

load('testVertices')
mesh.vertices=vertices;
% Delete last vertex
mesh.vertices(end,:)=[];
% Check if all vertices are unique
assert(length(mesh.vertices)==length(unique(mesh.vertices,'rows')))
% Convex hull
mesh.faces = minConvexHull(mesh.vertices);
% Triangulate
mesh.faces = triangulateFaces(mesh.faces);
% Stats
disp(['No of components: ' num2str(numel(splitMesh(mesh)))])
trimmedMesh=trimMesh(mesh);
disp(['No of unreferenced vertices: ' num2str(size(mesh.vertices,1)-size(trimmedMesh.vertices,1))])
disp(['No of components of the trimmed mesh: ' num2str(numel(splitMesh(trimmedMesh)))])
No of components: 3
No of unreferenced vertices: 3
No of components of the trimmed mesh: 1

@dlegland
Copy link
Member

Hi,
thanks for checking!
I agree, the function can be more informative about deletion of vertices. I'll check it.

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