private void explicitFaceCheck(QuickHull3D.Hull hull, int[][] checkFaces) { int[][] faceIndices = hull.GetFaces(); Assert.AreEqual(faceIndices.Length, checkFaces.Length, $"Error: {faceIndices.Length} faces vs. {checkFaces.Length}"); // translate face indices back into original indices Point3d[] pnts = hull.GetVertices(); int[] vtxIndices = hull.GetVertexPointIndices(); for (int j = 0; j < faceIndices.Length; j++) { int[] idxs = faceIndices[j]; for (int k = 0; k < idxs.Length; k++) { idxs[k] = vtxIndices[idxs[k]]; } } for (int i = 0; i < checkFaces.Length; i++) { int[] cf = checkFaces[i]; int j; for (j = 0; j < faceIndices.Length; j++) { if (faceIndices[j] != null) { if (faceIndicesEqual(cf, faceIndices[j])) { faceIndices[j] = null; break; } } } Assert.AreNotEqual(j, faceIndices.Length, $"Error: face {string.Join(" ", cf)} not found"); } }
private double[] addDegeneracy(int type, double[] coords, QuickHull3D.Hull hull) { int numv = coords.Length / 3; int[][] faces = hull.GetFaces(); double[] coordsx = new double[coords.Length + faces.Length * 3]; for (int i = 0; i < coords.Length; i++) { coordsx[i] = coords[i]; } double[] lam = new double[3]; double eps = hull.DistanceTolerance; for (int i = 0; i < faces.Length; i++) { // random point on an edge lam[0] = rand.NextDouble(); lam[1] = 1 - lam[0]; lam[2] = 0.0; if (type == VERTEX_DEGENERACY && (i % 2 == 0)) { lam[0] = 1.0; lam[1] = lam[2] = 0; } for (int j = 0; j < 3; j++) { int vtxi = faces[i][j]; for (int k = 0; k < 3; k++) { coordsx[numv * 3 + k] += lam[j] * coords[vtxi * 3 + k] + epsScale * eps * (rand.NextDouble() - 0.5); } } numv++; } shuffleCoords(coordsx); return(coordsx); }