示例#1
0
文件: Face.java 项目: tintor/Archive
  void checkConsistency() {
    // do a sanity check on the face
    HalfEdge hedge = he0;
    double maxd = 0;
    int numv = 0;

    if (numVerts < 3) {
      throw new InternalErrorException("degenerate face: " + getVertexString());
    }
    do {
      HalfEdge hedgeOpp = hedge.getOpposite();
      if (hedgeOpp == null) {
        throw new InternalErrorException(
            "face "
                + getVertexString()
                + ": "
                + "unreflected half edge "
                + hedge.getVertexString());
      } else if (hedgeOpp.getOpposite() != hedge) {
        throw new InternalErrorException(
            "face "
                + getVertexString()
                + ": "
                + "opposite half edge "
                + hedgeOpp.getVertexString()
                + " has opposite "
                + hedgeOpp.getOpposite().getVertexString());
      }
      if (hedgeOpp.head() != hedge.tail() || hedge.head() != hedgeOpp.tail()) {
        throw new InternalErrorException(
            "face "
                + getVertexString()
                + ": "
                + "half edge "
                + hedge.getVertexString()
                + " reflected by "
                + hedgeOpp.getVertexString());
      }
      Face oppFace = hedgeOpp.face;
      if (oppFace == null) {
        throw new InternalErrorException(
            "face "
                + getVertexString()
                + ": "
                + "no face on half edge "
                + hedgeOpp.getVertexString());
      } else if (oppFace.mark == DELETED) {
        throw new InternalErrorException(
            "face "
                + getVertexString()
                + ": "
                + "opposite face "
                + oppFace.getVertexString()
                + " not on hull");
      }
      double d = Math.abs(distanceToPlane(hedge.head().pnt));
      if (d > maxd) {
        maxd = d;
      }
      numv++;
      hedge = hedge.next;
    } while (hedge != he0);

    if (numv != numVerts) {
      throw new InternalErrorException(
          "face " + getVertexString() + " numVerts=" + numVerts + " should be " + numv);
    }
  }