views:

2425

answers:

4

I'm looking for a good 3D Mesh library

  • Should be able to read popular formats (OFF, OBJ...)
  • Should support both half-edge structure and a triangle soup
  • Should be tolerant to faults and illegal meshes.
  • Basic geometric operations - intersections, normal calculation, etc'
  • Most importantly - Should not be convoluted with endless template and inheritance hierarchies.

I've tried both CGAL and OpenMesh but both fail miserably in the last point.

Specifically CGAL which is impossible to follow even with the most advanced code analysis tools.

So far I'm seriously considering to pull my own.

My preference is C++ but I'm open to other options.

+6  A: 

May I ask why the last point is a requirement?

Libraries written for public consumption are designed to be as generic as possible so that it is usable by the widest possible audience. In C++, this is often best done using templates. It would suck tremendously if found a good library, only to discover it was useless for your purposes because it used floats instead of doubles.

CGAL, for example, appears to have adopted the well-known and well-tested STL paradigm of writing generic and extensible C++ libraries. This does indeed make it difficult to follow with code analysis tools; I doubt they're much good at following STL headers either.

But are you trying to use the library or modify it? Either way, they seem to have some extremely high-quality documentation (e.g. Kernel Manual) that should make it relatively simple to figure out what you need to do, without having to resort to reading their code.

Disclaimer: I know this isn't what you're asking for. But I don't think what you're looking for exists. It is extraordinarily rare to find open source code with documentation as good as what I've seen scanning through CGAL. I would strongly suggest that you take another look at it.

HappyDude
+1  A: 

First, some general comments about you requirements:

  • reading OBJ or OFF files is very easy. You could implement it yourself, on top of a library providing the more geometric features, in a few minutes. On the other hand, the geometric part of such libraries is so much more tricky that you should certainly focus on your requirements which really deal with the geometric algorithms, and try to find something which suits your needs. Then, of course, if there is a tie, start considering this interface issue.
  • in terms of geometric operations, you ask for intersection. Do you mean primitives intersection ? (for which good and simple algorithms can be found and implemented) or computation of the intersection of two meshes ? or collision detection ? (which are delicate questions, with no simple answer)
  • if you are more specific, from a higher level point of view, about the kind of tools you want to build, then people will be able to direct you to the right tool. Your requirements are too low-level.

As far as I understand your question, it seems to me that you do not clearly see the point of libraries like CGAL and OpenMesh. Such libraries may not provide all the higher level tools you need, but their aim is to provide you (especially in the CGAL case) all the geometric framework upon which you can build a geometric application. Such geometric frameworks are very delicate to design, especially because of the robustness issue, which is very specific to computational geometry. And without such a framework, building a robust application is an horrendous effort.

If you do not find a library which suits your need, you should seriously consider using a library such as CGAL as the underlying framework for your development. It will prevent the appearance of the robustness related problems, that you will typically only start noticing late in your development process, when changing the underlying framework will be painful. As an aside, CGAL has an extensive documentation, and a very active users' mailing-list.

If you do not know about robustness issues in geometry software, have a look at this page: robustness issues

Camille
+2  A: 

vcg http://vcg.sf.net

happy
That actually looks pretty decent
shoosh
A: 

Maybe trimesh2? http://www.cs.princeton.edu/gfx/proj/trimesh2/

Meekohi