private void printError( final String msg, final Record rec, final DistanceReport rep, final FeaturePair fpair) { System.out.println("Error, line " + rec.lineNumber); if (msg != null) System.out.println(msg); System.out.println("Wanted:"); for (final ClosestPointPair testPair : rec.testPairs) System.out.println(pairToStr(testPair)); System.out.println("Got:"); if (rep.numClosePairs() > 0) { final ClosestPointPair[] pairs = rep.getClosePairs(); for (int i = 0; i < rep.numClosePairs(); i++) System.out.println(pairToStr(pairs[i])); } else System.out.println(pairToStr(rep.getClosestPair())); System.out.println("Initial Features: " + fpair.first.getName() + " " + fpair.second.getName()); System.exit(1); }
private void checkVclipResults( final Record rec, final Vector3d offset, final DistanceReport rep, final double retDist, final FeaturePair fpair) { for (int i = 0; i < rec.testPairs.length; i++) { rec.testPairs[i].pnt2.add(rec.basePairs[i].pnt2, offset); rec.testPairs[i].dist = rec.basePairs[i].dist + offset.dot(rec.minNrml); } if (rep.getClosestDistance() != retDist) { final String msg = "dist returned=" + retDist + " closestDistance=" + rep.getClosestDistance(); printError(msg, rec, rep, fpair); } if (rep.numClosePairs() == 0) { final ClosestPointPair cpair = rep.getClosestPair(); boolean expectedCollision = false; for (final ClosestPointPair testPair : rec.testPairs) if (testPair.dist <= 0) { expectedCollision = true; break; } if (expectedCollision) { if (cpair.dist > 0) printError("Expected collision", rec, rep, fpair); } else if (rec.testPairs.length != 1 || !matchPair(rep.getClosestPair(), rec.testPairs[0])) printError(null, rec, rep, fpair); } else { final int n = rep.numClosePairs(); if (n != rec.testPairs.length) printError(null, rec, rep, fpair); final ClosestPointPair[] pairs = new ClosestPointPair[n]; for (int i = 0; i < n; i++) pairs[i] = rep.getClosePairs()[i]; for (int i = 0; i < n; i++) { int j; for (j = 0; j < n; j++) if (pairs[j] != null && matchPair(rec.testPairs[i], pairs[j])) { pairs[j] = null; break; } if (j == n) printError(null, rec, rep, fpair); } } }
private void checkDistanceReport(final DistanceReport rep, final NormalDistPair[] checkpairs) throws Exception { if (rep.numClosePairs() != checkpairs.length) throw new Exception( "Distance report has " + rep.numClosePairs() + " close pairs vs. " + checkpairs.length); final ClosestPointPair[] list = new ClosestPointPair[checkpairs.length]; for (int i = 0; i < list.length; i++) list[i] = rep.getClosePairs()[i]; for (final NormalDistPair checkpair : checkpairs) { int j; for (j = 0; j < list.length; j++) if (list[j] != null && checkpair.check(list[j])) { list[j] = null; break; } if (j == list.length) throw new Exception("close pair " + checkpair.vec + ", d=" + checkpair.d + " not found"); } }