/********************************************************************** * $Id$ * * GEOS - Geometry Engine Open Source * http://geos.refractions.net * * Copyright (C) 2001-2002 Vivid Solutions Inc. * Copyright (C) 2005 Refractions Research Inc. * * This is free software; you can redistribute and/or modify it under * the terms of the GNU Lesser General Licence as published * by the Free Software Foundation. * See the COPYING file for more information. * **********************************************************************/ #include #include #include #include using namespace std; using namespace geos::geom; namespace geos { namespace planargraph { /* * Adds a new member to this DirectedEdgeStar. */ void DirectedEdgeStar::add(DirectedEdge *de) { outEdges.push_back(de); sorted=false; } /* * Drops a member of this DirectedEdgeStar. */ void DirectedEdgeStar::remove(DirectedEdge *de) { for(unsigned int i=0; i::iterator DirectedEdgeStar::begin() { sortEdges(); return outEdges.begin(); } vector::iterator DirectedEdgeStar::end() { sortEdges(); return outEdges.end(); } vector::const_iterator DirectedEdgeStar::begin() const { sortEdges(); return outEdges.begin(); } vector::const_iterator DirectedEdgeStar::end() const { sortEdges(); return outEdges.end(); } /* * Returns the coordinate for the node at wich this star is based */ Coordinate& DirectedEdgeStar::getCoordinate() const { if (outEdges.empty()) return Coordinate::getNull(); DirectedEdge *e=outEdges[0]; return e->getCoordinate(); } /* * Returns the DirectedEdges, in ascending order by angle with * the positive x-axis. */ vector& DirectedEdgeStar::getEdges() { sortEdges(); return outEdges; } bool pdeLessThan(DirectedEdge *first, DirectedEdge * second) { if (first->compareTo(second)<0) return true; else return false; } /*private*/ void DirectedEdgeStar::sortEdges() const { if (!sorted) { sort(outEdges.begin(), outEdges.end(), pdeLessThan); sorted=true; } } /* * Returns the zero-based index of the given Edge, after sorting in * ascending order by angle with the positive x-axis. */ int DirectedEdgeStar::getIndex(const Edge *edge) { sortEdges(); for (unsigned int i = 0; igetEdge() == edge) return i; } return -1; } /* * Returns the zero-based index of the given DirectedEdge, after sorting * in ascending order by angle with the positive x-axis. */ int DirectedEdgeStar::getIndex(const DirectedEdge *dirEdge) { sortEdges(); for (unsigned int i = 0; i