void EvaluateTetrahedron(Vector3 aP, Vector3 bP, Vector3 cP, Vector3 dP, bool a, bool b, bool c, bool d) { Vector3 abP = (aP + bP) / 2; Vector3 acP = (aP + cP) / 2; Vector3 adP = (aP + dP) / 2; Vector3 bdP = (bP + dP) / 2; Vector3 bcP = (bP + cP) / 2; Vector3 cdP = (cP + dP) / 2; THCase tCase = FindTetraCase(a, b, c, d); switch (tCase) { case THCase.NOT: break; case THCase.A: CreateTriangle(adP, bdP, cdP); break; case THCase.B: CreateTriangle(acP, cdP, bcP); break; case THCase.C: CreateTriangle(abP, bcP, bdP); break; case THCase.D: CreateTriangle(abP, acP, adP); break; case THCase.E: CreateQuad(acP, adP, bdP, bcP); break; case THCase.F: CreateQuad(abP, bcP, cdP, adP); break; case THCase.G: CreateQuad(abP, bdP, cdP, acP); break; default: break; } }
THCase FindTetraCase(bool a, bool b, bool c, bool d) { THCase tCase = THCase.NOT; if ((a && b && c && d) || (!a && !b && !c && !d)) { return(tCase); } //find the correct case for the bools if ((!a && !b && !c) && d || (a && b && c) && !d) { tCase = THCase.A; return(tCase); } if ((!a && !b) && c && !d || (a && b) && !c && d) { tCase = THCase.B; return(tCase); } if (!a && b && (!c && !d) || a && !b && (c && d)) { tCase = THCase.C; return(tCase); } if (!a && (b && c && d) || a && (!b && !c && !d)) { tCase = THCase.D; return(tCase); } if ((!a && !b) && (c && d) || (a && b) && (!c && !d)) { tCase = THCase.E; return(tCase); } if (!a && b && !c && d || a && !b && c && !d) { tCase = THCase.F; return(tCase); } if (!a && (b && c) && !d || a && (!b && !c) && d) { tCase = THCase.G; return(tCase); } return(tCase); }