Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In this post, the use of TetGen for 3D Voronoi tesselation has been briefly discussed. However there is still no info about the use of TetGen to generate a 3D Voronoi diagram. The TetGen documentation is very brief about this feature, and there is no example how to generate the voronoi diagram shown in the documentation. I found out that one needs to use the "v" switch (in contrary to the documentation which claims this switches on the verbose mode), based on some quotes on the Web. However if I try the Mathematica interface TetGenLink I fail to get any information on the 3D Voronoi diagram. I tried out the following sequence.

First I loaded the TetGen Link and generated 8 3D points to keep the graphical output simple.

Needs["TetGenLink`"];
RandomSeed[12345];
pts = RandomReal[{-1, 1}, {8, 3}];

Then I generated an TetGen Instance

inInst = TetGenCreate[]

To automatically generate an boundary for a potential Voronoi diagram (even if I do not know this would work) I extracted the ConvexHull of the point set and assigned all points and the convex hull faces to the instance

{ptshull2, surfacehull2} = TetGenConvexHull[pts];
TetGenSetPoints[inInst, ptshull2]
TetGenSetFacets[inInst, {#} & /@ surfacehull2]

please note that the face indices have to be enclosed into additional list brackets, otherwise you'll get an TetGen error.

Then I define a Wireframe visualization function to display tetrahedrons.

TetrahedraWireframe[i_] := 
 Line[ Flatten[ 
   i[[All, #]] & /@ {{1, 2}, {2, 3}, {3, 1}, {1, 4}, {2, 4}, {3, 4}}, 1]]

Finally I fire TetGen by doing

outInst = TetGenTetrahedralize[inInst, "v"]

extract the results from the TetGen run by doing

coords = TetGenGetPoints[outInst];
elements = TetGenGetElements[outInst];

And visualize the resulting Tetrahedrons

Graphics3D[{GraphicsComplex[coords, TetrahedraWireframe[elements]], 
PointSize[Large], Point /@ coords, Red, Point /@ pts}]

which yields the following graphical output

Resulting Tetrahedron Mesh

I naively hoped that somehow by using this procedure I would get the Voronoi diagram, but it seems that this is not available in Mathematica. Furthermore the "v" switch does not have any effect it seems.

Any ideas about convincing Mathematica to return the Voronoi diagram are most welcome.

Already upfront: I'm aware that there are other solutions possible, mentioned in the above post, like using mPower to link to QHull for instance. However I would like to use the TetGen link since it is well integrated into Mathematica.

Another option would be to get QHULL integrated into Mathematica in a similiar fashion like TetGen, but for whatever reason this has not been done yet. The mPower approach lacks significant performance (since it is firing qhull through the run command) compared to the speed of the TetGen implementation.

share|improve this question
2  
Do you have access to MATLAB? MATLAB can do this based on QHull and MATLink can integrate the functionality into Mathematica with good performance and very little effort. –  Szabolcs Oct 14 '13 at 20:09
    
@Szabolcs: Thanks for the comment. I know about the very good integration of QHull into MATLAB. Unfortunately my whole setup is based on Mathematica (see mathematica.stackexchange.com/questions/14371/…) and I would need the voronoi mesh to represent three-dimensional grains like this has been done in the NEPER tool(neper.sourceforge.net). Neper does not offer any control over the statistical distribution of the grain sizes, though. Thus I do not want to switch the tool (neither to MATLAB, nor to NEPER). –  Rainer Oct 15 '13 at 6:31
1  
My point was that you don't have to switch the tool because you can call MATLAB directly from Mathematica using MATLink. Here's an example of 2D Voronoi tessellation. Regarding TetGenLink, it seems that with the current version of TetGenLink it is not possible to retrieve the Voronoi data (even though TetGen itself can compute it). –  Szabolcs Oct 15 '13 at 12:29
    
@Szabolcs: Cool Idea! I was not aware of your project. This is rather intriguing: Letting MATLAB and Mathematica work together and take the best of two worlds. I'll check MATLink and will post the results here when available... –  Rainer Oct 15 '13 at 15:36
    
Just as info: I checked back with Wolfram Research Support and they do not have a solution either (but they passed my request forward to their development team :-) ). It looks like there is currently just the way through MATLink. –  Rainer Dec 12 '13 at 5:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.