Archive for the 'meshlab' Category

mesh structure in meshlab

the mesh is stored in a object m of type MyMesh

Accessing the coords of all the vertexes

MyMesh::VertexIterator vi;
for(vi = m.vert.begin(); vi!=m.vert.end(); ++vi ) 
     {
       DoSomething((*vi).P()); 
     }

Accessing all the faces and computing their barycenter

MyMesh::FaceIterator vi;
 for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
     {
      MyMesh::CoordType b = ((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P() ) / 3.0; 
     }

or using a common shorthand for accessing to the coord of a face vertex:

MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
     {
      MyMesh::CoordType b = ((*fi).P(0) + (*fi).P(1) + (*fi).P(2) ) / 3.0; 
     }

Or even in a shorter way:

MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
     {
      MyMesh::CoordType b = vcg::Barycenter(*fi); 
     }

Creating the simplest single triangle mesh.

 m.Clear();
 Allocator<MyMesh>::AddVertices(m,3);
 Allocator<MyMesh>::AddFaces(m,1);

 MyMesh::VertexPointer ivp[3];
 VertexIterator vi=in.vert.begin();
 ivp[0]=&*vi;(*vi).P()=CoordType ( 1.0, 1.0, 1.0); ++vi;
 ivp[1]=&*vi;(*vi).P()=CoordType (-1.0, 1.0,-1.0); ++vi;
 ivp[2]=&*vi;(*vi).P()=CoordType (-1.0,-1.0, 1.0); ++vi;

 FaceIterator fi=in.face.begin();
 (*fi).V(0)=ivp[0];  (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2];

look to complex/trimesh/create/platonic.hplatonic.h for more examples.

Destroying Elements

Lazy deletion strategy.

Note that the two basic deletion strategies are very low level functions. They simply mark as deleted the corresponding entries without affecting the rest of the structures. So for example if you delete a vertex with these structures without checking that all the faces incident on it have been removed you create a non consistent situation…

Similarly, but less dangerously, when you delete a face its vertices are left around so at the end you can have unreferenced floating vertices.

Allocator<MyMesh>::DeleteVertex(m,v);
Allocator<MyMesh>::DeleteFace(m,v);

If your algorithm performs deletion the size of a container could be different from the number of valid element of your meshes (e.g.:

m.vert.size() != m.vn 
m.face.size() != m.fn

Therefore when you scan the containers of vertices and faces you could encounter deleted elements so you should take care with a simple !IsD() check:

MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
   if(!(*fi).IsD()) //    <---- Check added
     {
      MyMesh::CoordType b = vcg::Barycenter(*fi); 
     }

In some situations, particularly when you have to loop many many times over the element of the mesh without deleting/creating anything, it can be practical and convenient to get rid of deleted elements by explicitly calling the two garbage collecting functions:

Allocator<MyMesh>::CompactVertexVector(m);
Allocator<MyMesh>::CompactFaceVector(m);

After calling these function it is safe to not check the IsD() state of every element and always holds that:

m.vert.size() == m.vn 
m.face.size() == m.fn

Note that if there are no deleted elements in your mesh, the compactor functions returns immediately.

Adjacency relations

VCG meshes DO NOT store edges, only vertex and triangles. Even the basic adjacdncy relations has to be explicitly computed. We always try to do not store per-edge information and keep them only more or less implicitly. This is simply there are many algorithms that do not require it and the cost of updating/storing should be avoided when possible. In many cases algorithms that seems based on some kind

Counting border edges (without topology)

Typical example are border flags. Each face keep a bit for each of its sides saying if that face has a boundary on that side or not. This information can be accessed by mean of the IsB(i) function. To compute the border flags there are various algorithm according to the available topological informations.

Allocator<MyMesh>::CompactFaceVector(m);
UpdateFlags<MyMesh>::FaceBorderFromNone(m);
int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
     {
      for(int i=0;i<3;++i) 
            if((*fi).IsB(i)) BorderEdgeCounter++; 
     }

Counting border edge (using FF adjacency)

When your mesh as Face-Face adjacency the FFp(i) member store the pointer of the face that is adjacent to the current face along the i-th edg

int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
     {
      for(int i=0;i<3;++i) 
            if((*fi).FFp(i) == &*fi) BorderEdgeCounter++; 
     }

or alternatively using the same flag based approach as above

UpdateFlags<MyMesh>::FaceBorderFromFFAdjacency(m);
int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
     {
      for(int i=0;i<3;++i) 
            if((*fi).IsB(i)) BorderEdgeCounter++; 
     }

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

Ref.

http://meshlab.sourceforge.net/wiki/index.php/Accessing_the_mesh

meshlab VCG lib tutorial

VCG Lib is mostly made of header files (and its core part it’s only header files). Just download the tarball from here and uncompress it in a folder, e.g. named vcg, inside you compiler « include » directory. Afterwards, you will include the file you need.

Inside vcg folder you will find 4 sub-folders:

  • vcg: this is the core of the library, where all the algorithms and data structures are defined. This part is pure, quite heavily templated, C++ code with STL support for common data structures and algorithms. You will not find a single include from here to anything else than standard libraries. Note that core part is made of header files (.h files) only.
  • wrap: here you will find the wrapping of VCG concepts towards specific needs/contexts/libraries. For example you will find all the code to import/export meshes from the hard disk in many formats, or the routines for rendering triangle meshes with OpenGL, supports for common GUI tools like a trackball, and so on..
  • apps: this folder contains the command line applications developed with the VCG Lib. Many (much more) examples can be found in MeshLab. The apps/simple directory contains a sub-collection of very basic apps. A good starting point for beginners!
  • docs: documentation lives here (including this tutorial)

ref.

http://vcg.sourceforge.net/index.php/Tutorial

3D mesh meshlab Discussion Forums: Users

http://sourceforge.net/forum/forum.php?forum_id=499532

mesh lab alignment registration

First of all you should have well understood the layers mechanism in MeshLab and the fact that each mesh can have an transformation matrix. The alignment process simply modify the transformation of each layer.

The main idea is that you iteratively glue your misaligned meshes over the already aligned ones. A mesh that is aligned toghether with a set already aligned mesh is said being Glued (a * is shown near to its name). Initially all the meshes are ‘unglued’. You task is to roughly align all your meshes.

Once the mesh are glued in a rather good initial position you can start the Alignment Process: the system chooses what meshes have some overlapping part and for each pair of meshes the system starts a ICP alignment algorithm that precisely align the chosen pair. At the end of the process all the glued meshes will hopefully be aligned toghether.

Key Concepts:

  • ICP: Iterated closed point: The basic algorithm that automatically precisely align a moving mesh M onto a fixed one F. The main idea is that we choose a set of (well distributed) points over M and we search on F the corresponding nearest points. These pairs are used to find the best rigid transformation that bring the points of M onto their corresponding on F. ICP has a lot of tunable parameters.
  • Global Alignment: also known as multiview registration. A final step that evenly distributes the alignment error among all the alignments in order to avoid the biased accumulation of error.
  • Absolute Scale. The parameters of the alignment tool are in absolute units, and the defaults are ok for a standard scanner outputting meshes in millimeter units. So for example the target error (e.g. the error that the ICP try to achieve, is 0.05 mm something that can be achieved with a good scanner. Obviously if your range maps are in a different unit (microns, kilometers, … ) you have to adjust the default alignment parameters, otherwise the alignment process will fail.

Ref.

http://meshlab.sourceforge.net/wiki/index.php/Alignment

MeshLab documentation

MeshLab is a advanced mesh processing system, for the automatic and user assisted

editing,

cleaning,

filtering

converting

and rendering

of large unstructured 3D triangular meshes.

MeshLab is actively developed by the a small group of people at the Visual Computing Lab at the ISTI – CNR institute, a large group of university students and some great developers from the rest of the world.

For the basic mesh processing tasks and for the internal data structures the system relies on the GPL VCG library

Ref:

http://meshlab.sourceforge.net/wiki/index.php/MeshLab_Documentation


I MOVED THIS BLOG FROM WORDPRESS TO BLOGGER. Ce blog est à
ex-ample.blogspot.com

Blog Stats

  • 220 821 hits

localization

Flickr Photos

avril 2019
L M M J V S D
« Oct    
1234567
891011121314
15161718192021
22232425262728
2930