// 计算每个顶点的度数
calc_valences() {
	// EXERCISE 1.2 /////////////////////////////////////////////////////////////
	// 计算 'mesh_' 中每个顶点的度数,并将它们存储在每个顶点中
	// 例如,通过动态自定义使用自定义属性
	// (提示:使用 Mesh::VertexIter 迭代器)

	// 在这里实现一些内容
	Mesh::VertexIter v_end = mesh_.vertices_end();
	//Mesh::Scalar TempValence=0;
	OpenMesh::VPropHandleT<int> Valence;
	mesh_.add_property(Valence, 'Valence');
	for (Mesh::VertexIter v_it = mesh_.vertices_begin(); v_it != v_end; ++v_it) {
		mesh_.property(Valence, v_it);
		for (Mesh::VertexVertexIter vv_it = mesh_.vv_iter(v_it); vv_it; ++vv_it) {
			mesh_.property(Valence, v_it) += 1;
		}
		//cout<<mesh_.property(Valence,v_it)<<endl;
	/////////////////////////////////////////////////////////////////////////////
	}
}

该函数计算了网格中每个顶点的度数,并将其存储在每个顶点中。它使用了一个自定义属性,通过动态自定义来进行存储。在函数中,首先定义了一个顶点迭代器 v_it,用于迭代每个顶点。然后,对于每个顶点,使用另一个顶点迭代器 vv_it 来迭代该顶点的每个相邻顶点,并将其度数增加 1。最后,将每个顶点的度数存储在自定义属性 Valence 中,以便将其保留在网格中。

计算网格顶点度数 (calc_valences())

原文地址: https://www.cveoy.top/t/topic/lPgA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录