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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/**********************************************************************
* $Id: planarEdge.cpp,v 1.3 2004/10/13 10:03:02 strk Exp $
*
* 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.
*
**********************************************************************
* $Log: planarEdge.cpp,v $
* Revision 1.3 2004/10/13 10:03:02 strk
* Added missing linemerge and polygonize operation.
* Bug fixes and leaks removal from the newly added modules and
* planargraph (used by them).
* Some comments and indentation changes.
*
* Revision 1.2 2004/07/02 13:28:29 strk
* Fixed all #include lines to reflect headers layout change.
* Added client application build tips in README.
*
* Revision 1.1 2004/04/04 06:29:11 ybychkov
* "planargraph" and "geom/utill" upgraded to JTS 1.4
*
*
**********************************************************************/
#include <geos/planargraph.h>
namespace geos {
//namespace planargraph {
/**
* Constructs an Edge whose DirectedEdges are not yet set. Be sure to call
* {@link #setDirectedEdges(DirectedEdge, DirectedEdge)}
*/
planarEdge::planarEdge(): dirEdge()
{
}
/**
* Constructs an Edge initialized with the given DirectedEdges, and for each
* DirectedEdge: sets the Edge, sets the symmetric DirectedEdge, and adds
* this Edge to its from-Node.
*/
planarEdge::planarEdge(planarDirectedEdge *de0, planarDirectedEdge *de1){
setDirectedEdges(de0, de1);
}
/*
* Initializes this Edge's two DirectedEdges, and for each DirectedEdge:
* sets the Edge,
* sets the symmetric DirectedEdge, and
* adds this Edge to its from-Node.
*/
void
planarEdge::setDirectedEdges(planarDirectedEdge *de0, planarDirectedEdge *de1){
dirEdge.push_back(de0);
dirEdge.push_back(de1);
de0->setEdge(this);
de1->setEdge(this);
de0->setSym(de1);
de1->setSym(de0);
de0->getFromNode()->addOutEdge(de0);
de1->getFromNode()->addOutEdge(de1);
}
/**
* Returns one of the DirectedEdges associated with this Edge.
* @param i 0 or 1
*/
planarDirectedEdge *
planarEdge::getDirEdge(int i)
{
return dirEdge[i];
}
/*
* Returns the DirectedEdge that starts from the given node, or null if the
* node is not one of the two nodes associated with this Edge.
*/
planarDirectedEdge *
planarEdge::getDirEdge(planarNode *fromNode)
{
if (dirEdge[0]->getFromNode()==fromNode) return dirEdge[0];
if (dirEdge[1]->getFromNode()==fromNode) return dirEdge[1];
// node not found
// possibly should throw an exception here?
return NULL;
}
/**
* If <code>node</code> is one of the two nodes associated with this Edge,
* returns the other node; otherwise returns null.
*/
planarNode*
planarEdge::getOppositeNode(planarNode *node)
{
if (dirEdge[0]->getFromNode()==node) return dirEdge[0]->getToNode();
if (dirEdge[1]->getFromNode()==node) return dirEdge[1]->getToNode();
// node not found
// possibly should throw an exception here?
return NULL;
}
//} // namespace planargraph
} // namespace geos
|