/********************************************************************** * $Id$ * * GEOS - Geometry Engine Open Source * http://geos.refractions.net * * Copyright (C) 2005-2006 Refractions Research Inc. * Copyright (C) 2001-2002 Vivid Solutions 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. * ********************************************************************** * * Last port: planargraph/PlanarGraph.java rev. 107/138 (JTS-1.10) * **********************************************************************/ #include #include #include #include #include #include #include using namespace std; namespace geos { namespace planargraph { /* * Adds the Edge and its DirectedEdges with this PlanarGraph. * Assumes that the Edge has already been created with its associated * DirectEdges. * Only subclasses can add Edges, to ensure the edges added are of * the right class. */ void PlanarGraph::add(Edge *edge) { edges.push_back(edge); add(edge->getDirEdge(0)); add(edge->getDirEdge(1)); } /* * Removes an Edge and its associated DirectedEdges from their from-Nodes and * from this PlanarGraph. Note: This method does not remove the Nodes associated * with the Edge, even if the removal of the Edge reduces the degree of a * Node to zero. */ void PlanarGraph::remove(Edge *edge) { remove(edge->getDirEdge(0)); remove(edge->getDirEdge(1)); for(unsigned int i=0; igetSym(); if (sym!=NULL) sym->setSym(NULL); de->getFromNode()->getOutEdges()->remove(de); for(unsigned int i=0; i &outEdges=node->getOutEdges()->getEdges(); for(unsigned int i=0; igetSym(); // remove the diredge that points to this node if (sym!=NULL) remove(sym); // remove this diredge from the graph collection for(unsigned int j=0; jgetEdge(); if (edge!=NULL) { for(unsigned int k=0; kgetCoordinate()); //nodes.remove(node); } /*public*/ vector* PlanarGraph::findNodesOfDegree(size_t degree) { vector *nodesFound=new vector(); findNodesOfDegree(degree, *nodesFound); return nodesFound; } /*public*/ void PlanarGraph::findNodesOfDegree(size_t degree, vector& nodesFound) { NodeMap::container &nm=nodeMap.getNodeMap(); for (NodeMap::container::iterator it=nm.begin(), itEnd=nm.end(); it!=itEnd; ++it) { Node *node=it->second; if (node->getDegree()==degree) nodesFound.push_back(node); } } } // namespace planargraph } // namespace geos /********************************************************************** * $Log$ * Revision 1.4 2006/06/12 10:49:43 strk * unsigned int => size_t * * Revision 1.3 2006/03/21 21:42:54 strk * planargraph.h header split, planargraph:: classes renamed to match JTS symbols * **********************************************************************/