gradientspace / geometry3Sharp

C# library for 2D/3D geometric computation, mesh algorithms, and so on. Boost license.
http://www.gradientspace.com
Boost Software License 1.0
1.72k stars 390 forks source link

ReduceToTriangleCount error #7

Closed alexhackbai closed 6 years ago

alexhackbai commented 7 years ago

i load my obj model , invoke r.ReduceToTriangleCount(800); error
my obj model Can you look at it? I have sent it to your mail (rms@gradientspace.com) help me thank you

rms80 commented 7 years ago

Ok, well, thanks for sending the file because it helped me make some improvements, but you will probably not be happy with the results...

1) this mesh has some nonmanifold geometry, that is why you were getting the error. Basically once you have nonmanifold geom, the results are undefined. I updated the reducer tutorial with a bit about how to check your mesh for this, using DMesh3.CheckValidity

2) The Reducer can now handle this particular nonmanifold geometry, so it won't throw an error anymore.

3) This mesh has boundaries so you have to turn on the boundary-preservation I mention in the tutorial. Otherwise it will create holes/etc in the result as it tries to reach your target count.

3) The library currently does not supported multiple UVs per vertex. So, when a textured OBJ is loaded, the mesh is split at any UV-seams. As a result this mesh is split all over the place (see below). Combined with the preserve-boundary, this means that basically there are no triangles to collapse, it can't get below 3992 triangles w/o modifying the boundary somewhere.

Basically, the current implementation is meant for simplifying unstructured meshes. You have a highly structured mesh that is already basically a minimal triangulation of the shape. Particularly because of the UV seams/etc. So to automatically simplify further is quite difficult, well beyond what I intend to use this implementation for.

image

alexhackbai commented 7 years ago

thank you very much ,i will always be concerned about and use this project I hope we can be friends, i like this project

       r.SetExternalConstraints(new MeshConstraints());
        MeshConstraintUtil.FixAllBoundaryEdges(r.Constraints, mesh);

        r.ReduceToTriangleCount(300);

I would like to simplify the surface to 300 but i get 3992 Why is this,MeshLab can do it

please help me