Needs["TetGenLink`"];
TetraMaker[pts_, surface_, TetGenString_?StringQ] :=
Module[{inInst, outInst, coords, surface1, meshElements, facets},
inInst = TetGenCreate[];
TetGenSetPoints[inInst, pts];
facets = Partition[surface, 1];
TetGenSetFacets[inInst, facets];
outInst = TetGenTetrahedralize[inInst, TetGenString];
coords = TetGenGetPoints[outInst]; (* element point *)
surface1 = TetGenGetFaces[outInst]; (* element face *)
meshElements = TetGenGetElements[outInst]; (* element indices *)
{coords, surface1, meshElements}];
TetrahedraVolume =
Compile[{{coords, _Real, 2}, {elements, _Integer, 1}},
Block[{p}, p = coords[[elements]];
1/6*Abs[Det[p[[{1, 2, 3}]] - p[[{2, 3, 4}]]]]],
RuntimeAttributes -> {Listable}, RuntimeOptions -> "Speed"];
{coords1, surface1, meshElements1} = TetraMaker[data01, polysurface1, "pqa.8"];
vb = Total[TetrahedraVolume[coords1, meshElements1]]
Graphics3D[GraphicsComplex[coords1, Polygon[surface1]]]
Error dialog appears when running code below:
{coords2, surface2, meshElements2} = TetraMaker[data02, polysurface2, "pqa.8"];
vb = Total[TetrahedraVolume[coords2, meshElements2]]
Assertion failed!
Program: ... File: M:\Builds\2615350\checkout\Mathematica...\tetgen.cxx Line: 21962
Expression: dir !=COLLOSIONFACE
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)
I am trying to calculate volume. I wonder if both data sets are similar then why does it not work for 2nd data set? Is there any way I can fix this error?

