/* * 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*/ void PolygonBuilder::add(const vector<DirectedEdge*> *dirEdges, const vector<Node*> *nodes) //throw(TopologyException *) { // PlanarGraph::linkResultDirectedEdgesS(nodes); typedef vector<Node*>::const_iterator NodeIt; for ( NodeIt nodeit = nodes->begin(), nodeEnd = nodes->end(); nodeit != nodeEnd; ++nodeit) { Node *node=*nodeit; DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(node->getEdges()); assert(des); // This might throw a TopologyException des->linkResultDirectedEdges(); } vector<MaximalEdgeRing*>* maxEdgeRings=buildMaximalEdgeRings(dirEdges); vector<EdgeRing*> freeHoleList; vector<MaximalEdgeRing*> *edgeRings; edgeRings= buildMinimalEdgeRings(maxEdgeRings,&shellList,&freeHoleList); sortShellsAndHoles(edgeRings,&shellList,&freeHoleList); placeFreeHoles(shellList, freeHoleList); delete maxEdgeRings; delete edgeRings; //Assert: every hole on freeHoleList has a shell assigned to it }
/*public*/ void MaximalEdgeRing::linkDirectedEdgesForMinimalEdgeRings() { DirectedEdge* de=startDe; do { Node* node=de->getNode(); EdgeEndStar* ees = node->getEdges(); assert(dynamic_cast<DirectedEdgeStar*>(ees)); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees); des->linkMinimalDirectedEdges(this); de=de->getNext(); } while (de!=startDe); }
/*private*/ void EdgeRing::computeMaxNodeDegree() { maxNodeDegree=0; DirectedEdge *de=startDe; do { Node *node=de->getNode(); EdgeEndStar* ees = node->getEdges(); assert(dynamic_cast<DirectedEdgeStar*>(ees)); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees); int degree=des->getOutgoingDegree(this); if (degree>maxNodeDegree) maxNodeDegree=degree; de=getNext(de); } while (de!=startDe); maxNodeDegree *= 2; testInvariant(); }
/*public static*/ void PlanarGraph::linkResultDirectedEdges() { #if GEOS_DEBUG cerr<<"PlanarGraph::linkResultDirectedEdges called"<<endl; #endif NodeMap::iterator nodeit=nodes->nodeMap.begin(); for (;nodeit!=nodes->nodeMap.end();nodeit++) { Node *node=nodeit->second; assert(node); EdgeEndStar* ees=node->getEdges(); assert(ees); assert(dynamic_cast<DirectedEdgeStar*>(ees)); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees); // this might throw an exception des->linkResultDirectedEdges(); } }
/*public static*/ void PlanarGraph::linkResultDirectedEdges( std::vector<Node*>::iterator start, std::vector<Node*>::iterator end) //throw(TopologyException *) { for ( vector<Node*>::iterator nodeit=start; nodeit!=end; ++nodeit ) { Node *node=*nodeit; assert(node); EdgeEndStar* ees=node->getEdges(); assert(ees); assert(dynamic_cast<DirectedEdgeStar*>(ees)); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees); // this might throw an exception des->linkResultDirectedEdges(); } }
/* * Link the DirectedEdges at the nodes of the graph. * This allows clients to link only a subset of nodes in the graph, for * efficiency (because they know that only a subset is of interest). */ void PlanarGraph::linkAllDirectedEdges() { #if GEOS_DEBUG cerr << "PlanarGraph::linkAllDirectedEdges called" << endl; #endif NodeMap::iterator nodeit = nodes->nodeMap.begin(); for(; nodeit != nodes->nodeMap.end(); nodeit++) { Node* node = nodeit->second; assert(node); EdgeEndStar* ees = node->getEdges(); assert(ees); // Unespected non-DirectedEdgeStar in node assert(dynamic_cast<DirectedEdgeStar*>(ees)); DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees); des->linkAllDirectedEdges(); } }