• 查找一个顶点的一层领域面


    简介

    查找一个顶点的一层领域面

    代码

    #include <iostream>
    #include <vector>
    // -------------------- OpenMesh
    using namespace std;
    #include <OpenMesh/Core/IO/MeshIO.hh>
    #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
    #include <OpenMesh/Core/Mesh/Handles.hh>
    typedef OpenMesh::TriMesh_ArrayKernelT<>MyMesh;
    
    int main()
    {
    	MyMesh mesh;
    	// read mesh from stdin
    	int a, x0, y0;
    	if (!OpenMesh::IO::read_mesh(mesh, "C:/Users/lee/Desktop/output8.off"))
    	{
    		cerr << "Error: cannot write mesh to " << endl;
    		return 1;
    	}
    	cout << "请输入您要查找邻域的顶点坐标:" << endl;
    	cout << "x="; cin >> x0;
    	cout << "y="; cin >> y0;
    	for (MyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it)
    	{
    		
    		// circulate around the current vertex  
    		auto point = mesh.point(*v_it);
    		if (point.data()[0] == x0 && point.data()[1] == y0)// 找到匹配的点
    			for (MyMesh::VertexFaceIter vf_it = mesh.vf_iter(*v_it); vf_it.is_valid(); ++vf_it)//这个顶点所带有的面迭代器
    			{
    				for (MyMesh::FaceHalfedgeIter fh_it = mesh.fh_begin(*vf_it); fh_it != mesh.fh_end(*vf_it); ++fh_it)//面的半边迭代器
    																												   //一个面有3个半边
    				{
    					OpenMesh::ArrayKernel::VertexHandle to_v = mesh.to_vertex_handle(*fh_it);// 这个半边所带有的点的handle
    					OpenMesh::Vec3f point = mesh.point(to_v);
    					cout << "邻域面顶点坐标x:" << point.data()[0] << "  y:" << point.data()[1] << "  z:" << point.data()[2] << endl;
    				}
    				cout << "
    ";
    			}
    		else continue;
    	}
    	
    	cin >> a;
    	// write mesh to stdout
    	if (!OpenMesh::IO::write_mesh(mesh, "output9.off"))
    	{
    		cerr << "Error: cannot write mesh to " << endl;
    		return 1;
    	}
    	return 0;
    }
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    结对第一次—原型设计(文献摘要热词统计)
    第一次作业-准备篇
    软件工程实践总结
    团队作业第二次—项目选题报告
    软工实践|结对第二次—文献摘要热词统计
    软工实践|结对第一次—原型设计(文献摘要热词统计)
    第一次作业-准备篇
    个人作业——软件工程实践总结作业
    团队作业第二次——项目选题报告
    结对第二次—文献摘要热词统计
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/11157148.html
Copyright © 2020-2023  润新知