typedef OpenMesh::TriMesh_ArrayKernelT<> MyMesh;
MyMesh mesh;
struct TriTraits : public OpenMesh::DefaultTraits
{
/// Use double precision points
typedef OpenMesh::Vec3d Point;
/// Use double precision Normals
typedef OpenMesh::Vec3d Normal;
/// Use RGBA Color
typedef OpenMesh::Vec4f Color;
};
typedef OpenMesh::TriMesh_ArrayKernelT<TriTraits> MyMesh;
MyMesh mesh;
MyMesh mesh;
...
OpenMesh::VertexHandle vh = mesh.add_vertex(MyMesh::Point(x,y,z));
MyMesh mesh;
OpenMesh::VertexHandle vh0, vh1, vh2;
...
OpenMesh::FaceHandle fh = mesh.add_face(vh0, vh1, vh2);
MyMesh mesh;
OpenMesh::VertexHandle vh;
...
MyMesh::Point pos = mesh.point(vh);
MyMesh mesh;
OpenMesh::VertexHandle vh;
MyMesh::Point new_pos;
...
mesh.set_point(vh, new_pos);
MyMesh mesh;
//vertex iterators
MyMesh::VertexIter v_it, v_begin, v_end;
//range of iterators
v_begin = mesh.vertices_begin();
v_end = mesh.vertices_end();
//iterate over all vertices
for(v_it = v_begin; v_it != v_end; ++v_it){
//get vertex handle
OpenMesh::VertexHandle vh = *v_it;
//process the vertex
DoSomethingWithVertex(vh);
}
Iterate over all neighbouring vertices
MyMesh mesh;
OpenMesh::VertexHandle vh;
//circulator around a vertex
MyMesh::VertexVertexIter vv_it = mesh.vv_iter(vh);
// circulate around the current vertex
for(; vv_it.is_valid(); ++vv_it) {
//process the neighbouring vertex
DoSomethingWithVertex(*vv_it);
}
MyMesh mesh;
unsigned int n1 = mesh.n_vertices(),
n2 = mesh.n_faces(),
n3 = mesh.n_edges(),
n4 = mesh.n_halfedges();
MyMesh mesh;
//define a property type, e.g edge property in float
typedef OpenMesh::EPropHandleT<float> edge_length;
//add the property to mesh and name it(optional)
mesh.add_property(edge_length, "edge length");
OpenMesh::EdgeHandle eh;
float L, LL;
//write to the property
mesh.property(edge_length, eh) = L;
//read the property
LL = mesh.property(edge_length, eh);
//remove the property
mesh.remove_property(edge_length);
MyMesh mesh;
OpenMesh::HalfedgeHandle heh;
OpenMesh::VertexHandle vh_from = mesh.from_vertex_handle(heh),
OpenMesh::VertexHandle vh_to = mesh.to_vertex_handle(heh);
OpenMesh::FaceHandle fh = mesh.face_handle(heh);
OpenMesh::HalfedgeHandle heh_next = mesh.next_halfedge_handle(heh);
OpenMesh::HalfedgeHandle heh_prev= mymesh.prev_halfedge_handle(heh);
OpenMesh::HalfedgeHandle heh_opp = mymesh.opposite_halfedge_handle(heh);
MyMesh::Point x, y, a, b, c, d;
...
//arithmetic operations
a = x + y;
b = x - y;
c = x * 0.5;
d = y / 3.0;
...
MyMesh::Point x, y, a, b, c, d;
...
//dot product
Scalar dot = OpenMesh::dot(x, y); //Scalar dot = x | y;
//compute the norm
Scalar norm = x.norm();
//normalize
a = x.normalize();
//cross product
MyMesh::Point cross = OpenMesh::cross(x, y); //Scalar b = x % y;
...