1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/**********************************************************************
* $Id: Node.cpp 1820 2006-09-06 16:54:23Z mloskot $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* 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.
*
**********************************************************************/
#include <geos/planargraph/Node.h>
#include <geos/planargraph/DirectedEdge.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
namespace geos {
namespace planargraph {
/* static public */
/* UNUSED */
vector<Edge*>*
Node::getEdgesBetween(Node *node0, Node *node1)
{
std::vector<Edge*> edges0;
DirectedEdge::toEdges(node0->getOutEdges()->getEdges(), edges0);
std::vector<Edge*> edges1;
DirectedEdge::toEdges(node1->getOutEdges()->getEdges(), edges1);
// Sort edge lists (needed for set_intersection below
std::sort( edges0.begin(), edges0.end() );
std::sort( edges1.begin(), edges1.end() );
std::vector<Edge*>* commonEdges = new std::vector<Edge*>();
// Intersect the two sets
std::set_intersection(
edges0.begin(), edges0.end(),
edges1.begin(), edges1.end(),
commonEdges->end()
);
return commonEdges;
}
std::ostream& operator<<(std::ostream& os, const Node& n) {
os << "Node " << n.pt << " with degree " << n.getDegree();
if ( n.isMarked() ) os << " Marked ";
if ( n.isVisited() ) os << " Visited ";
return os;
}
} // namespace planargraph
} // namespace geos
/**********************************************************************
* $Log$
* Revision 1.2 2006/06/12 15:47:08 strk
* implemented missing getEdgesBetween() method (untested).
*
* Revision 1.1 2006/03/21 21:42:54 strk
* planargraph.h header split, planargraph:: classes renamed to match JTS symbols
*
**********************************************************************/
|