4

I want to load a mesh file using TetGen library in C++ but I don't know the right procedure or what switches to activate in my code in order to show the Constrained Delaunay mesh.

I tried something basic loading of a dinosaur mesh (from rocq.inria.fr) with default behavior:

tetgenio in, out;
in.firstnumber = 0;
in.load_medit("TetGen\\parasaur1_cut.mesh",0);
tetgenbehavior *b = new tetgenbehavior();
tetrahedralize(b, &in, &out);

The shape is supposed to be like this:

enter image description here

When using TetView it works perfectly. But with my code I got the following result:

dinosaur mesh result

I tried to activate the Piecewise Linear Complex (plc) property for Delaunay Constraint:

b->plc = 1;

and I got just a few parts from the mesh:

a few more parts from dinosaur mesh

Maybe there are more parts but I don't know how to get them.

CrSe
  • 328
  • 1
  • 2
  • 10
  • Where did you get your source mesh? Can you provide a link to it? Does this mesh load correctly in some other program, and if so which one? Have you had success with simpler examples? Etc. This seems a rather large case to study, and it would likely be better to move in smaller steps. – HostileFork says dont trust SE May 11 '15 at 06:45
  • @HostileFork Hey, I tried some .poly and .smesh files from their site and works fine but there are just a few examples. For .mesh fiels I took the files from link suggested in TetGen documentation https://www.rocq.inria.fr/gamma/download/ ( the link changed in time). In TetView these meshes works perfectly. So I know it has to be something on how I load the mesh. – CrSe May 11 '15 at 07:14
  • *"So I know it has to be something on how I load the mesh."* Since TetView is apparently [closed-source and distributed binary-only](http://wias-berlin.de/software/tetgen/tetview.html), there's a lot you might *not* know. Perhaps the version of the TetGen library it was compiled against was older and worked correctly? You might want to contact the author and ask if he would release the TetView source...citing this question as one of those cases where it'd be helpful to be able to make the comparison by stepping through and seeing what's different. – HostileFork says dont trust SE May 11 '15 at 07:51
  • @HostileFork Thanks for your answers. I already send him an email. Hopefully he'll respond. – CrSe May 11 '15 at 08:49
  • In the meantime, you can edit the question to add a more comprehensive [Minimal, Complete, Verifiable Example](http://stackoverflow.com/help/mcve). The closer you can get someone to reproducing and seeing what's on your screen the better. That means an `int main()` and what steps to use to reproduce the visuals. Look for the *simplest case* with the problem, even if you have to hand-generate the mesh that shows correctly in TetView but not in your version. When you break down a problem that clearly, it will often point right at the answer... – HostileFork says dont trust SE May 11 '15 at 10:42

1 Answers1

2

That looks a lot like you might be loading a quad mesh as a triangle mesh or vice versa. One thing is clear, you are getting the floats from the file, since the boundaries of the object look roughly correct. Make certain you are loading a strictly triangle or quad-based mesh. If it is a format that you can load into Blender, I'd recommend loading it, triangulating it, and re-exporting it, just in case a poly snuck into there.

Another possibility is an indexing off by one error. Are you sure you are getting each triangle/quad in the correct order? Which is to say -- make sure you are loading triangles 123 123 123 and NOT 1 231 231 231.

One other possibility, if this format indexes all of the vertices, and then lists the indexes of the vertices, you might be loading all of the vertices correctly, and then getting the indexes of the triangles/quads messed up, as described in the previous two paragraphs. I'm thinking this is the case, since it looks like all of your points are correct, but the lines connecting them are way wrong.

Aiden Koss
  • 121
  • 1
  • 4