/* * Removes a node from the graph, along with any associated * DirectedEdges and Edges. */ void PlanarGraph::remove(Node *node) { // unhook all directed edges vector<DirectedEdge*> &outEdges=node->getOutEdges()->getEdges(); for(unsigned int i=0; i<outEdges.size(); ++i) { DirectedEdge *de =outEdges[i]; DirectedEdge *sym = de->getSym(); // 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; j<dirEdges.size(); ++j) { if (dirEdges[j]==de) { dirEdges.erase(dirEdges.begin()+j); --j; } } Edge *edge=de->getEdge(); if (edge!=NULL) { for(unsigned int k=0; k<edges.size(); ++k) { if(edges[k]==edge) { edges.erase(edges.begin()+k); --k; } } } } // remove the node from the graph nodeMap.remove(node->getCoordinate()); //nodes.remove(node); }
/* * Find and mark L edges which are "covered" by the result area (if any). * L edges at nodes which also have A edges can be checked by checking * their depth at that node. * L edges at nodes which do not have A edges can be checked by doing a * point-in-polygon test with the previously computed result areas. */ void LineBuilder::findCoveredLineEdges() { // first set covered for all L edges at nodes which have A edges too map<Coordinate*, Node*, CoordinateLessThen>& nodeMap = op->getGraph().getNodeMap()->nodeMap; map<Coordinate*, Node*, CoordinateLessThen>::iterator it = nodeMap.begin(); map<Coordinate*, Node*, CoordinateLessThen>::iterator endIt = nodeMap.end(); for(; it != endIt; ++it) { Node* node = it->second; //node.print(System.out); assert(dynamic_cast<DirectedEdgeStar*>(node->getEdges())); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(node->getEdges()); des->findCoveredLineEdges(); //((DirectedEdgeStar*)node->getEdges())->findCoveredLineEdges(); } /* * For all L edges which weren't handled by the above, * use a point-in-poly test to determine whether they are covered */ vector<EdgeEnd*>* ee = op->getGraph().getEdgeEnds(); for(size_t i = 0, s = ee->size(); i < s; ++i) { assert(dynamic_cast<DirectedEdge*>((*ee)[i])); DirectedEdge* de = static_cast<DirectedEdge*>((*ee)[i]); Edge* e = de->getEdge(); if(de->isLineEdge() && !e->isCoveredSet()) { bool isCovered = op->isCoveredByA(de->getCoordinate()); e->setCovered(isCovered); } } }
/*public*/ bool Node::isIncidentEdgeInResult() const { testInvariant(); if (!edges) return false; EdgeEndStar::iterator it=edges->begin(); EdgeEndStar::iterator endIt=edges->end(); for ( ; it!=endIt; ++it) { assert(*it); assert(dynamic_cast<DirectedEdge *>(*it)); DirectedEdge *de = static_cast<DirectedEdge *>(*it); if ( de->getEdge()->isInResult() ) return true; } return false; }