⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polygonizegraph.cpp

📁 在Linux下做的QuadTree的程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			// save the line as a cut edge			PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge();			cutLines->push_back(e->getLine());		}	}	return cutLines;}voidPolygonizeGraph::label(std::vector<DirectedEdge*> &dirEdges, long label){	for(unsigned int i=0; i<dirEdges.size(); ++i)	{		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)dirEdges[i];		de->setLabel(label);	}}voidPolygonizeGraph::computeNextCWEdges(Node *node){	DirectedEdgeStar *deStar=node->getOutEdges();	PolygonizeDirectedEdge *startDE=NULL;	PolygonizeDirectedEdge *prevDE=NULL;	// the edges are stored in CCW order around the star	std::vector<DirectedEdge*> &pde=deStar->getEdges();	for(unsigned int i=0; i<pde.size(); ++i) {		PolygonizeDirectedEdge *outDE=(PolygonizeDirectedEdge*)pde[i];		if (outDE->isMarked()) continue;		if (startDE==NULL)			startDE=outDE;		if (prevDE!=NULL) {			PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) prevDE->getSym();			sym->setNext(outDE);		}		prevDE=outDE;	}	if (prevDE!=NULL) {		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) prevDE->getSym();		sym->setNext(startDE);	}}/** * Computes the next edge pointers going CCW around the given node, for the * given edgering label. * This algorithm has the effect of converting maximal edgerings into * minimal edgerings */voidPolygonizeGraph::computeNextCCWEdges(Node *node, long label){	DirectedEdgeStar *deStar=node->getOutEdges();	PolygonizeDirectedEdge *firstOutDE=NULL;	PolygonizeDirectedEdge *prevInDE=NULL;	// the edges are stored in CCW order around the star	std::vector<DirectedEdge*> &edges=deStar->getEdges();	/*	 * Must use a SIGNED int here to allow for beak condition	 * to be true.	 */	for(int i=edges.size()-1; i>=0; --i)	{		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i];		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();		PolygonizeDirectedEdge *outDE=NULL;		if (de->getLabel()==label) outDE=de;		PolygonizeDirectedEdge *inDE=NULL;		if (sym->getLabel()==label) inDE= sym;		if (outDE==NULL && inDE==NULL) continue; // this edge is not in edgering		if (inDE != NULL) {			prevInDE=inDE;		}		if (outDE != NULL) {			if (prevInDE != NULL) {				prevInDE->setNext(outDE);				prevInDE=NULL;			}			if (firstOutDE==NULL)				firstOutDE=outDE;		}	}	if (prevInDE != NULL) {		assert(firstOutDE != NULL);		prevInDE->setNext(firstOutDE);	}}/* * Traverse a ring of DirectedEdges, accumulating them into a list. * This assumes that all dangling directed edges have been removed * from the graph, so that there is always a next dirEdge. * * @param startDE the DirectedEdge to start traversing at * @return a List of DirectedEdges that form a ring */std::vector<DirectedEdge*>*PolygonizeGraph::findDirEdgesInRing(PolygonizeDirectedEdge *startDE){	PolygonizeDirectedEdge *de=startDE;	std::vector<DirectedEdge*> *edges=new std::vector<DirectedEdge*>();	do {		edges->push_back(de);		de=de->getNext();		assert(de != NULL); // found NULL DE in ring		assert(de==startDE || !de->isInRing()); // found DE already in ring	} while (de != startDE);	return edges;}EdgeRing *PolygonizeGraph::findEdgeRing(PolygonizeDirectedEdge *startDE){	PolygonizeDirectedEdge *de=startDE;	EdgeRing *er=new EdgeRing(factory);	// Now, when will we delete those EdgeRings ?	newEdgeRings.push_back(er);	do {		er->add(de);		de->setRing(er);		de=de->getNext();		assert(de != NULL); // found NULL DE in ring		assert(de==startDE || ! de->isInRing()); // found DE already in ring	} while (de != startDE);	return er;}/** * Marks all edges from the graph which are "dangles". * Dangles are which are incident on a node with degree 1. * This process is recursive, since removing a dangling edge * may result in another edge becoming a dangle. * In order to handle large recursion depths efficiently, * an explicit recursion stack is used * * @return a List containing the LineStrings that formed dangles */std::vector<const LineString*>*PolygonizeGraph::deleteDangles(){	std::vector<Node*> *nodesToRemove=findNodesOfDegree(1);	std::vector<const LineString*> *dangleLines=new std::vector<const LineString*>();	std::vector<Node*> nodeStack;	for(int i=0;i<(int)nodesToRemove->size();i++) {		nodeStack.push_back((*nodesToRemove)[i]);	}	delete nodesToRemove;	while (!nodeStack.empty()) {		Node *node=nodeStack[nodeStack.size()-1];		nodeStack.pop_back();		deleteAllEdges(node);		std::vector<DirectedEdge*> &nodeOutEdges=node->getOutEdges()->getEdges();		for(unsigned int j=0; j<nodeOutEdges.size(); ++j)		{			PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)nodeOutEdges[j];			// delete this edge and its sym			de->setMarked(true);			PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();			if (sym != NULL)				sym->setMarked(true);			// save the line as a dangle			PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge();			dangleLines->push_back(e->getLine());			Node *toNode=de->getToNode();			// add the toNode to the list to be processed, if it is now a dangle			if (getDegreeNonDeleted(toNode)==1)				nodeStack.push_back(toNode);		}	}	return dangleLines;}} // namespace geos.operation.polygonize} // namespace geos.operation} // namespace geos/********************************************************************** * $Log$ * Revision 1.18  2006/03/22 11:19:06  strk * opPolygonize.h headers split. * * Revision 1.17  2006/03/21 21:42:54  strk * planargraph.h header split, planargraph:: classes renamed to match JTS symbols * * Revision 1.16  2006/03/06 19:40:47  strk * geos::util namespace. New GeometryCollection::iterator interface, many cleanups. * * Revision 1.15  2006/03/03 10:46:22  strk * Removed 'using namespace' from headers, added missing headers in .cpp files, removed useless includes in headers (bug#46) * * Revision 1.14  2006/02/19 19:46:49  strk * Packages <-> namespaces mapping for most GEOS internal code (uncomplete, but working). Dir-level libs for index/ subdirs. * * Revision 1.13  2006/01/31 19:07:34  strk * - Renamed DefaultCoordinateSequence to CoordinateArraySequence. * - Moved GetNumGeometries() and GetGeometryN() interfaces *   from GeometryCollection to Geometry class. * - Added getAt(int pos, Coordinate &to) funtion to CoordinateSequence class. * - Reworked automake scripts to produce a static lib for each subdir and *   then link all subsystem's libs togheter * - Moved C-API in it's own top-level dir capi/ * - Moved source/bigtest and source/test to tests/bigtest and test/xmltester * - Fixed PointLocator handling of LinearRings * - Changed CoordinateArrayFilter to reduce memory copies * - Changed UniqueCoordinateArrayFilter to reduce memory copies * - Added CGAlgorithms::isPointInRing() version working with *   Coordinate::ConstVect type (faster!) * - Ported JTS-1.7 version of ConvexHull with big attention to *   memory usage optimizations. * - Improved XMLTester output and user interface * - geos::geom::util namespace used for geom/util stuff * - Improved memory use in geos::geom::util::PolygonExtractor * - New ShortCircuitedGeometryVisitor class * - New operation/predicate package * * Revision 1.12  2005/12/09 11:36:38  strk * Small leak plugged in CAPI::GEOSHasZ() and in * invalid input to PolygonizeGraph (again) * * Revision 1.11  2005/12/09 10:03:46  strk * Fixed a bug making PolygonizeGraph choking on invalid LineStrings. * Minor optimizations in Polygonizer loops. * * Revision 1.10  2005/11/21 16:03:20  strk * * Coordinate interface change: *         Removed setCoordinate call, use assignment operator *         instead. Provided a compile-time switch to *         make copy ctor and assignment operators non-inline *         to allow for more accurate profiling. * * Coordinate copies removal: *         NodeFactory::createNode() takes now a Coordinate reference *         rather then real value. This brings coordinate copies *         in the testLeaksBig.xml test from 654818 to 645991 *         (tested in 2.1 branch). In the head branch Coordinate *         copies are 222198. *         Removed useless coordinate copies in ConvexHull *         operations * * STL containers heap allocations reduction: *         Converted many containers element from *         pointers to real objects. *         Made some use of .reserve() or size *         initialization when final container size is known *         in advance. * * Stateless classes allocations reduction: *         Provided ::instance() function for *         NodeFactories, to avoid allocating *         more then one (they are all *         stateless). * * HCoordinate improvements: *         Changed HCoordinate constructor by HCoordinates *         take reference rather then real objects. *         Changed HCoordinate::intersection to avoid *         a new allocation but rather return into a provided *         storage. LineIntersector changed to reflect *         the above change. * * Revision 1.9  2005/11/15 12:14:05  strk * Reduced heap allocations, made use of references when appropriate, * small optimizations here and there. * * Revision 1.8  2004/12/14 10:35:44  strk * Comments cleanup. PolygonizeGraph keeps track of generated CoordinateSequence * for delayed destruction. * * Revision 1.7  2004/12/08 13:54:44  strk * gcc warnings checked and fixed, general cleanups. * * Revision 1.6  2004/10/26 16:09:21  strk * Some more intentation and envelope equality check fix. * * 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/08 19:34:50  strk * Mirrored JTS interface of CoordinateSequence, factory and * default implementations. * Added CoordinateArraySequenceFactory::instance() function. * * 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/08 04:53:56  ybychkov * "operation/polygonize" ported from JTS 1.4 * * **********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -