📄 planargraph.h
字号:
* or null if it has none. */ planarEdge* getEdge() const; /* * \brief Associates this DirectedEdge with an Edge * (possibly null, indicating no associated Edge). */ void setEdge(planarEdge* newParentEdge); /* * \brief Returns 0, 1, 2, or 3, indicating the quadrant in which * this DirectedEdge's orientation lies. */ int getQuadrant() const; /* * \brief Returns a point to which an imaginary line is drawn * from the from-node to specify this DirectedEdge's orientation. */ const Coordinate& getDirectionPt() const; /* * \brief Returns whether the direction of the parent Edge (if any) * is the same as that of this Directed Edge. */ bool getEdgeDirection() const; /* * \brief Returns the node from which this DirectedEdge leaves. */ planarNode* getFromNode() const; /* * \brief Returns the node to which this DirectedEdge goes. */ planarNode* getToNode() const; /* * \brief * Returns the coordinate of the from-node. */ Coordinate& getCoordinate() const; /* * \brief * Returns the angle that the start of this DirectedEdge makes * with the positive x-axis, in radians. */ double getAngle() const; /* * \brief * Returns the symmetric DirectedEdge -- the other DirectedEdge * associated with this DirectedEdge's parent Edge. */ planarDirectedEdge* getSym() const; /* * \brief * Sets this DirectedEdge's symmetric DirectedEdge, which runs * in the opposite direction. */ void setSym(planarDirectedEdge *newSym); /* * \brief * Returns 1 if this DirectedEdge has a greater angle with the * positive x-axis than b", 0 if the DirectedEdges are collinear, * and -1 otherwise. * * Using the obvious algorithm of simply computing the angle is * not robust, since the angle calculation is susceptible to roundoff. * A robust algorithm is: * * - first compare the quadrants. * If the quadrants are different, it it * trivial to determine which vector is "greater". * - if the vectors lie in the same quadrant, the robust * RobustCGAlgorithms::computeOrientation(Coordinate, Coordinate, Coordinate) * function can be used to decide the relative orientation of * the vectors. * */ int compareTo(const planarDirectedEdge* obj) const; /* * \brief * Returns 1 if this DirectedEdge has a greater angle with the * positive x-axis than b", 0 if the DirectedEdges are collinear, * and -1 otherwise. * * Using the obvious algorithm of simply computing the angle is * not robust, since the angle calculation is susceptible to roundoff. * A robust algorithm is: * * - first compare the quadrants. * If the quadrants are different, it it trivial to determine * which vector is "greater". * - if the vectors lie in the same quadrant, the robust * RobustCGAlgorithms::computeOrientation(Coordinate, Coordinate, Coordinate) * function can be used to decide the relative orientation of * the vectors. * */ int compareDirection(const planarDirectedEdge *e) const; /* * \brief * Prints a detailed string representation of this DirectedEdge * to the given PrintStream. */ string print() const;};struct planarCoordLT { bool operator()(Coordinate s1, Coordinate s2) const { return s1.compareTo(s2)<0; }};/* * \class planarNodeMap planargraph.h geos/planargraph.h * \brief * A map of Node, indexed by the coordinate of the node. * */class planarNodeMap {private: map<Coordinate,planarNode*, planarCoordLT> *nodeMap;public: /* * \brief Constructs a NodeMap without any Nodes. */ planarNodeMap(); map<Coordinate,planarNode*,planarCoordLT>* getNodeMap(); virtual ~planarNodeMap(); /* * \brief * Adds a node to the map, replacing any that is already * at that location. * @return the added node */ planarNode* add(planarNode *n); /* * \brief * Removes the Node at the given location, and returns it * (or null if no Node was there). */ planarNode* remove(Coordinate& pt); /* * \brief * Returns the Node at the given location, * or null if no Node was there. */ planarNode* find(const Coordinate& coord); /* * \brief * Returns an Iterator over the Nodes in this NodeMap, * sorted in ascending order * by angle with the positive x-axis. */ map<Coordinate,planarNode*,planarCoordLT>::iterator iterator(); /* * \brief * Returns the Nodes in this NodeMap, sorted in ascending order * by angle with the positive x-axis. */ vector<planarNode*>* getNodes();};/* * \class planarPlanarGraph planargraph.h geos/planargraph.h * \brief * Represents a directed graph which is embeddable in a planar surface. * * This class and the other classes in this package serve as a framework for * building planar graphs for specific algorithms. This class must be * subclassed to expose appropriate methods to construct the graph. This allows * controlling the types of graph components (DirectedEdge, Edge and Node) * which can be added to the graph. An application which uses the graph * framework will almost always provide subclasses for one or more graph * components, which hold application-specific data and graph algorithms. */class planarPlanarGraph {protected: vector<planarEdge*> *edges; vector<planarDirectedEdge*> *dirEdges; planarNodeMap *nodeMap; /* * \brief * Adds a node to the map, replacing any that is already at that * location. * * Only subclasses can add Nodes, to ensure Nodes are * of the right type. * @return the added node */ void add(planarNode *node); /* * \brief * 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 add(planarEdge *edge); /* * \brief * Adds the Edge to this PlanarGraph. * * Only subclasses can add DirectedEdges, * to ensure the edges added are of the right class. */ void add(planarDirectedEdge *dirEdge);public: /* * \brief * Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes. */ planarPlanarGraph(); virtual ~planarPlanarGraph(); /* * \brief * Returns the Node at the given location, * or null if no Node was there. */ planarNode* findNode(const Coordinate& pt); /* * \brief * Returns an Iterator over the Nodes in this PlanarGraph. */ map<Coordinate,planarNode*,planarCoordLT>::iterator nodeIterator(); /* * \brief * Returns the Nodes in this PlanarGraph. */ vector<planarNode*>* getNodes(); /* * \brief * Returns an Iterator over the DirectedEdges in this PlanarGraph, * in the order in which they were added. * * @see add(Edge) * @see add(DirectedEdge) */ vector<planarDirectedEdge*>::iterator dirEdgeIterator(); /* * \brief * Returns an Iterator over the Edges in this PlanarGraph, * in the order in which they were added. * * @see #add(Edge) */ vector<planarEdge*>::iterator edgeIterator(); /* * \brief * Returns the Edges that have been added to this PlanarGraph * @see #add(Edge) */ vector<planarEdge*>* getEdges(); /* * \brief * 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 remove(planarEdge *edge); /* * \brief * Removes DirectedEdge from its from-Node and from this PlanarGraph. * * Note: * This method does not remove the Nodes associated with the * DirectedEdge, even if the removal of the DirectedEdge reduces * the degree of a Node to zero. */ void remove(planarDirectedEdge *de); /* * \brief * Removes a node from the graph, along with any associated * DirectedEdges and Edges. */ void remove(planarNode *node); /* * \brief * Returns all Nodes with the given number of Edges around it. */ vector<planarNode*>* findNodesOfDegree(int degree);};//} // namespace planargraph} // namespace geos#endif/********************************************************************** * $Log: planargraph.h,v $ * Revision 1.6 2004/12/14 10:35:44 strk * Comments cleanup. PolygonizeGraph keeps track of generated CoordinateSequence * for delayed destruction. * * Revision 1.5 2004/10/19 19:51:14 strk * Fixed many leaks and bugs in Polygonizer. * Output still bogus. * * Revision 1.4 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.3 2004/07/19 13:19:31 strk * Documentation fixes * * Revision 1.2 2004/07/13 08:33:52 strk * Added missing virtual destructor to virtual classes. * Fixed implicit unsigned int -> int casts * * Revision 1.1 2004/07/02 13:20:42 strk * Header files moved under geos/ dir. * * Revision 1.3 2004/04/16 08:52:52 strk * Unload::Release final delete (static heap allocations should be gone now) * * Revision 1.2 2004/04/07 06:55:50 ybychkov * "operation/linemerge" ported from JTS 1.4 * * Revision 1.1 2004/04/04 06:29:11 ybychkov * "planargraph" and "geom/utill" upgraded to JTS 1.4 * * **********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -