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

简介

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

代码

#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 << "\n";
            }
        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;
}

转载于:https://www.cnblogs.com/eat-too-much/p/11157148.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值