/** * Common implementation for the search operations. * * @param pt * @param safe * @return * @throws DelaunayError */ private Element searchPointImpl(final DPoint pt, final boolean safe) throws DelaunayError { Element ret = null; if (contains(pt)) { return this; } else { for (DEdge ed : edges) { DPoint op = getOppositePoint(ed); if (ed.isRight(pt) && ed.isLeft(op)) { if (ed.isLocked() && safe) { return null; } else if (ed.getRight() != null) { return ed.getRight().searchPointContainer(pt); } else { ret = ed; } } else if (ed.isLeft(pt) && ed.isRight(op)) { if (ed.isLocked() && safe) { return null; } else if (ed.getLeft() != null) { return ed.getLeft().searchPointContainer(pt); } else { ret = ed; } } } } return ret; }
/** * Check if the point is inside the triangle * * @param aPoint * @return isInside */ public final boolean isInside(DPoint aPoint) { boolean isInside = true; int k = 0; while ((k < PT_NB) && (isInside)) { DEdge theEdge = edges[k]; if (theEdge.getLeft() == this) { if (theEdge.isRight(aPoint)) { isInside = false; } } else { if (theEdge.isLeft(aPoint)) { isInside = false; } } k++; } return isInside; }
/** * This method force the link between this and its edges, and ensure that edges are not pointing * to duplicates of this triangle. */ public final void forceCoherenceWithEdges() { for (DEdge edg : edges) { DTriangle tri = edg.getLeft(); DTriangle tri2 = edg.getRight(); if (equals(tri)) { edg.setLeft(this); } else if (equals(tri2)) { edg.setRight(this); } else { DPoint op = getOppositePoint(edg); if (op != null) { if (edg.isLeft(op)) { edg.setLeft(this); } else { edg.setRight(this); } } } } }