public AdvancingFrontNode( TriangulationPoint point ) { this.point = point; value = point.getX(); key = Double.valueOf( value ); // XXX: BST }
private static boolean isShallow( DTSweepContext tcx, AdvancingFrontNode node ) { double height; if( tcx.basin.leftHighest ) { height = tcx.basin.leftNode.getPoint().getY() - node.getPoint().getY(); } else { height = tcx.basin.rightNode.getPoint().getY() - node.getPoint().getY(); } if( tcx.basin.width > height ) { return true; } return false; }
/** * Start sweeping the Y-sorted point set from bottom to top * * @param tcx */ private static void sweep( DTSweepContext tcx ) { List<TriangulationPoint> points; TriangulationPoint point; AdvancingFrontNode node; points = tcx.getPoints(); for( int i=1; i<points.size(); i++ ) { point = points.get(i); node = pointEvent( tcx, point ); if( point.hasEdges() ) { for( DTSweepConstraint e : point.getEdges() ) { if( tcx.isDebugEnabled() ) { tcx.getDebugContext().setActiveConstraint( e ); } edgeEvent( tcx, e, node ); } } tcx.update( null ); } }
@SuppressWarnings("unchecked") @Override public void prepareTriangulation( TriangulationContext tcx ) { super.prepareTriangulation( tcx ); if( _constrainedPointList != null ) { HashMap<TriangulationPoint, TriangulationPoint> uniquePts = new HashMap<TriangulationPoint, TriangulationPoint>(_points.size()); // Enforce same coordinates means same instance of TriangulationPoint TriangulationPoint.mergeInstances(uniquePts, _points); TriangulationPoint.mergeInstances(uniquePts, _constrainedPointList); TriangulationPoint p1,p2; Iterator iterator = _constrainedPointList.iterator(); while(iterator.hasNext()) { p1 = (TriangulationPoint)iterator.next(); p2 = (TriangulationPoint)iterator.next(); tcx.newConstraint(p1,p2); } } else { for( int i = 0; i < _index.length; i+=2 ) { // XXX: must change!! tcx.newConstraint( _points.get( _index[i] ), _points.get( _index[i+1] ) ); } } }
TriangulationPoint.mergeInstances(uniquePts, _points); if(_steinerPoints != null) { TriangulationPoint.mergeInstances(uniquePts, _steinerPoints); TriangulationPoint.mergeInstances(uniquePts, p._points);
/** * We use a balancing tree to locate a node smaller or equal to * given key value * * @param x * @return */ public AdvancingFrontNode locateNode( TriangulationPoint point ) { return locateNode( point.getX() ); }
private static void fillRightAboveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) { while( node.next.point.getX() < edge.p.getX() ) { if( tcx.isDebugEnabled() ) { tcx.getDebugContext().setActiveNode( node ); } // Check if next node is below the edge Orientation o1 = orient2d( edge.q, node.next.point, edge.p ); if( o1 == Orientation.CCW ) { fillRightBelowEdgeEvent( tcx, edge, node ); } else { node = node.next; } } }
private static void fillLeftAboveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) { while( node.prev.point.getX() > edge.p.getX() ) { if( tcx.isDebugEnabled() ) { tcx.getDebugContext().setActiveNode( node ); } // Check if next node is below the edge Orientation o1 = orient2d( edge.q, node.prev.point, edge.p ); if( o1 == Orientation.CW ) { fillLeftBelowEdgeEvent( tcx, edge, node ); } else { node = node.prev; } } }