当前位置: 首页>>代码示例>>C++>>正文


C++ Skeleton::openSegment方法代码示例

本文整理汇总了C++中Skeleton::openSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::openSegment方法的具体用法?C++ Skeleton::openSegment怎么用?C++ Skeleton::openSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Skeleton的用法示例。


在下文中一共展示了Skeleton::openSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: e

// The old version of this was recursing directly and deeply, leading to stack
// overflows in stack restricted environments (e.g. multithreading).  The
// current version is a fairly direct iteratization of the old, directly
// recursive version.
void
Skeletonize::traverse(const GraphVolume::Node& root, Skeleton& skeleton) {
	// DFS of nodes from root.  Data-wise, Nodes are just integer values.
	std::stack<GraphVolume::Node> traversal;
	traversal.push(root);
	while (!traversal.empty()) {
		const GraphVolume::Node n = traversal.top();
		const int nNeighbors = numNeighbors(n);

		// Special nodes that open new segments.
		const bool isOpeningNode = n == _root || nNeighbors != 2;

		// The second time we see a node, we are in back-traversal, popping from
		// traversal stack and potentially closing segments.
		if (_nodeLabels[n] == Visited) {
			if (isOpeningNode) skeleton.closeSegment();
			traversal.pop();
			continue;
		}

		// Otherwise, we're seeing the node for the first time, so opening /
		// extending segment.
		_nodeLabels[n] = Visited;
		const Position pos = _graphVolume.positions()[n];
		const float boundDist = sqrt(boundaryDistance(pos));
		if (isOpeningNode) {
			skeleton.openSegment(pos, 2*boundDist);
		} else {
			skeleton.extendSegment(pos, 2*boundDist);
		}

		// Iterate through neighbors and put unseen ones onto traversal stack.  The
		// loop checks against nNeighbors to allow early termination.
		GraphVolume::IncEdgeIt e(_graphVolume.graph(), n);
		for (int i = 0; i < nNeighbors; ++e /* increment e, not i */) {
			assert(e != lemon::INVALID);  // Should never occur.

			// Only increment i if we are using this edge.
			if (_distanceMap[e] != 0.0) continue;
			++i;

			const GraphVolume::Node neighbor = (_graphVolume.graph().u(e) == n ? _graphVolume.graph().v(e) : _graphVolume.graph().u(e));
			if (_nodeLabels[neighbor] != Visited) traversal.push(neighbor);
		}
	}
}
开发者ID:funkey,项目名称:imageprocessing,代码行数:50,代码来源:Skeletonize.cpp


注:本文中的Skeleton::openSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。