SanityCheck method

void SanityCheck()

Implementation

void SanityCheck() {
  if (pointsOnly) {
    assert(faces3.length == 0);
    assert(faces4.length == 0);
    return;
  }
  int maxIndexFace3 = -1;
  for (Face3 f in faces3) {
    if (f.a > maxIndexFace3) maxIndexFace3 = f.a;
    if (f.b > maxIndexFace3) maxIndexFace3 = f.b;
    if (f.c > maxIndexFace3) maxIndexFace3 = f.c;
  }

  int maxIndexFace4 = -1;
  for (Face4 f in faces4) {
    if (f.a > maxIndexFace4) maxIndexFace4 = f.a;
    if (f.b > maxIndexFace4) maxIndexFace4 = f.b;
    if (f.c > maxIndexFace4) maxIndexFace4 = f.c;
    if (f.d > maxIndexFace4) maxIndexFace4 = f.d;
  }

  final int n = vertices.length;
  assert(n >= 0);
  assert(maxIndexFace3 < n, "${maxIndexFace3} vs $n");
  assert(maxIndexFace4 < n, "${maxIndexFace4} vs $n");

  for (String canonical in attributes.keys) {
    assert(attributes[canonical]!.length == vertices.length,
        "bad attribute ${canonical}");
  }
}