+ var nan_count = 0;
+ var nan_point_count = 0;
+ var nan_face_count = 0;
+ for (var i = 0; i < this.points.length/3; i++) {
+ var nan_in_face = false;
+ for (var j = 0; j < 3; j++) {
+ var nan_in_point = false;
+ for (var k = 0; k < 3; k++) {
+ if (isNaN(this.points[i*3+j][k])) {
+ nan_count++;
+ nan_in_point = true;
+ nan_in_face = true;
+ }
+ }
+ if (nan_in_point) nan_point_count ++;
+ }
+ if (nan_in_face) nan_face_count ++;
+ }
+ if (nan_count != 0) {
+ alert(nan_count + " NaNs in " + nan_point_count + " points in " + nan_face_count + " faces (" + (100 * nan_face_count / (this.points.length/3)) + "% of faces).");
+ }
+
+ // Remove degenerate faces
+ var degenerate_face_count = 0;
+ for (var i = 0; i < this.points.length/3; i++) {
+ if (this.is_degenerate(this.points[i*3+0],
+ this.points[i*3+1],
+ this.points[i*3+2])) {
+ this.points.splice(i*3, 3);
+ i--;
+ degenerate_face_count ++;
+ }
+ }
+ if (degenerate_face_count != 0) {
+ console.log("Removed " + degenerate_face_count + " degenerate faces");
+ }