openmesh的入门学习

openmesh元素的操作

Vec3d运算符的操作

OpenMesh::Vec3d ps(xs0, ys0, zs0);
OpenMesh::Vec3d pt(xt0, yt0, zt0);
OpenMesh::Vec3d src_normal;
double AC_dist = (pt - ps) | src_normal / src_normal.sqrnorm();
ps%pt;

|:compute scalar product,数乘,点积,x1x2 + y1y2 + z1z2
%:叉积,(y1
z2-y2z1, x2z1-x1z2, x1y2-x2*y1)
/:component-wise division by with scalar,分量上用标量除
减法-是里面的向量可以直接相减

//提取网格的对应索引的点
mesh src_mesh_;
src_mesh_->vertex_handle(点的索引)//只是得到这个点的顶点句柄
//然后使用函数point()根据点的句柄得到src中点的坐标
src_mesh_->point(src_mesh_->vertex_handle(点的索引)//或者使用函数normal()根据点的句柄得到src中点的法式,返回值是vec3d
 OpenMesh::Vec3d src_normal = src_mesh_->normal(src_mesh_->vertex_handle(点的索引);

向量长度的操作

转自:https://www.cnblogs.com/VVingerfly/p/4402186.html
对于点p(x1,y1), q(x2,y2)
n o r m = ( ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ) ½ : norm =( (x2-x1)^2 + (y2-y1)^2 )^½: norm=((x2x1)2+(y2y1)2)½:

Scalar length() const        //compute euclidean norm
Scalar norm() const         //compute euclidean norm 

n o r m 2 norm^2 norm2

Scalar sqrnorm() const    //compute squared euclidean norm 

曼哈顿距离(L1距离) l1_norm = |x2-x1| + |y2-y1|

Scalar l1_norm() const    //compute L1 (Manhattan) norm 

切比雪夫距离(L∞距离) l8_norm = max{|x2-x1| , |y2-y1|}

Scalar l8_norm() const   //compute l8_norm 

其中openmesh中一些点的读取操作

//提取tar_mesh_中第i个点的第一个坐标值,存到tar_points_(为[x0,x1,...,xn])的第0行,i列中
MatrixXX tar_points_; 
tar_points_.resize(3, n_tar_vertex_);
tar_points_(0, i) = tar_mesh_->point(tar_mesh_->vertex_handle(i))[0];
//correspondence_pairs_[i0].first的第一个值作为提取的索引
point(src_mesh_->vertex_handle(correspondence_pairs_[i0].first))


Mesh* src_mesh_;
Eigen::Matrix3Xd rig_src_v = Eigen::Matrix3Xd::Zero(3, n_src_vertex_);
rig_src_v.col(i0) = Eigen::Map<Eigen::Vector3d>(src_mesh_
	->point(src_mesh_->vertex_handle(correspondence_pairs_[i0].first)).data(), 3, 1);

openmesh的半边数据结构

参考资料:
openmesh官方说明文档的半边结构说明(https://mcoder.cc/2019/07/06/half_edge_data_structure/)
openmesh的半边数据结构,及相关几何元素的遍历

关于点的循环,即与点有关的点、半边、边、邻面的遍历

//迭代点的邻点
VertexVertexIter: iterate over all neighboring vertices.
VertexIHalfedgeIter: iterate over all incoming halfedges.
VertexOHalfedgeIter: iterate over all outgoing halfedges.
//迭代点的所有边
VertexEdgeIter: iterate over all incident edges.
VertexFaceIter: iterate over all adjacent faces.

关于面的循环:即与面有关的点、半边、边、邻面的遍历

FaceVertexIter: iterate over the face’s vertices.
FaceHalfedgeIter: iterate over the face’s halfedges.
FaceEdgeIter: iterate over the face’s edges.
FaceFaceIter: iterate over all edge-neighboring faces.
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页