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


C++ Face_handle::centricity方法代码示例

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


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

示例1: computeCentricity

void Mesh::computeCentricity(QWidget* guiParent)
{
	//	float maxCentricity = -FLT_MAX;
	//	float minCentricity = FLT_MAX;

	QProgressDialog *prog = NULL;
	if (guiParent)
		prog = new QProgressDialog("Building centricity", "Stop", 0, numVtx(), guiParent);
		
	int counter = 0;
	int total = size_of_vertices();
	for (Mesh::Vertex_iterator it = vertices_begin(); it != vertices_end(); ++it)
	{
		if (guiParent)
		{
			prog->setValue(counter);
			QCoreApplication::processEvents();
			if (prog->wasCanceled())
				return;
		}


		counter++;

		double distanceSum = 0.0;
		int count = 0;

		dijkstra(&*it);

		for (Mesh::Vertex_iterator n = vertices_begin(); n != vertices_end(); ++n)
		{
			if (n->distance() != FLT_MAX) 
			{
				count++;
				distanceSum += n->distance();
			}
		}
		it->centricity(distanceSum/(double)count);

		//	if (it->centricity() > maxCentricity) maxCentricity = it->centricity();
		//	if (it->centricity() < minCentricity) minCentricity = it->centricity();
		//	printf("%d = %f\n", counter, it->centricity());
	}

	delete prog;


	//if (m_normalize ) 
	//{
	//report("normalizing values");
	/*for (Mesh::Vertex_iterator it = m_mesh->vertices_begin();
	it != m_mesh->vertices_end(); 
	it++)
	{
	if (it->centricity() != FLT_MAX)
	it->centricity() = (it->centricity() - minCentricity) / (maxCentricity - minCentricity);
	}*/
	//normalizeByComponents();
	//}

	// facet centricity is the average of the vertices.

	float featureMin = FLT_MAX;
	float featureMax = -FLT_MAX;

	for (Mesh::Face_iterator fit = faces_begin(); fit != faces_end(); ++fit)
	{
		Face_handle fh = &*fit;
		float val = 0.0;
		for(int fii = 0; fii < fh->size(); ++fii)
		{
			Vertex_handle cv = fh->vertex(fii);
			val += cv->centricity();
		}
		val /= fh->size();

		fh->centricity() = val;

		if (val < featureMin) 
			featureMin = val;
		if (val > featureMax)
			featureMax = val;
	}

	float divwith = 1.0 / (featureMax - featureMin);
	for (Mesh::Face_iterator fit = faces_begin(); fit != faces_end(); ++fit)
	{
		Face_handle fh = &*fit;
		fh->centricity() = (fh->centricity() - featureMin) * divwith;
	}

	m_hasCentricity = true;
}
开发者ID:shooshx,项目名称:kawaiigl,代码行数:93,代码来源:Mesh.cpp


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