sample codes of vcglib and MeshLab function.
The Visualization and Computer Graphics Library (VCG for short) is a open source portable C++ templated library for manipulation, processing and displaying with OpenGL of triangle and tetrahedral meshes.
Clone vcglib from github. You should select devel
branch (master
branch is too old).
$ git clone -b devel https://github.com/cnr-isti-vclab/vcglib.git
Cloning into 'vcglib'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 42007 (delta 0), reused 1 (delta 0), pack-reused 42002
Receiving objects: 100% (42007/42007), 17.24 MiB | 1.23 MiB/s, done.
Resolving deltas: 100% (28087/28087), done.
Checking out files: 100% (1063/1063), done.
$ cd vcglib
$ git branch
* devel
First, you have to set below environment values
VCGLIB_DIR
: path/to/vcglib (e.g. C:/Users/Public/Documents/GitHub/vcglib
)MESHLAB_DIR
: path/to/MeshLab/source (e.g. C:/Users/Public/Documents/GitHub/meshlab/src
)EIGEN3_INCLUDE_DIR
: path/to/Eigen3 (e.g. C:/eigen-3.3.7
)see this sample for details.
use MeshLab data structure.
Missing Component Exception -FFAdjacency-
のようなケース
// adjacency関連を有効にする(頂点と面でそれぞれ有効化しないといけないものもある)
mesh.vert.EnableVFAdjacency();
mesh.face.EnableFFAdjacency();
mesh.vert.EnableCurvature();
mesh.vert.EnableCurvatureDir();
Assertion failed: f.cFFp(j) != 0, file C:/Users/Public/Documents/GitHub/vcglib/vcg/simplex/face/topology.h, line 39
のようなケース
// 初期化時と関係性が変わった場合は更新が必要
tri::UpdateTopology<CMeshO>::FaceFace(mesh);
tri::UpdateTopology<CMeshO>::VertexFace(mesh);
tri::UpdateNormal<CMeshO>::PerFace(mesh);
tri::UpdateNormal<CMeshO>::NormalizePerFace(mesh);
MeshLab implements many functions in a plugin format. A list of plugins can be found here.
Let's take a look at the structure of the mlsplugin.cpp file as an example. The name of the implemented function is defined here. The function for plugins is the applyFilter function.
The process branches according to the ID contained in the filter
variable.
The applyFiter
function is the starting point of each plug-in process, so if you follow the process from here, you can check all the implementation details.
When searching for the function you want to know how to be implemented on MeshLab, it is recommended way that search function name by using grep command in source directory.
トラックボール表示するだけのサンプル
視点操作はトラックボール使うと楽にできるが、固定シェーダ前提になる
トラックボールとメッシュデータ表示するサンプル
光源用の処理も追加
// mesh1においてmesh2との干渉面が選択される(mesh2はそのまま)
mesh2.face.EnableMark();
int a = vcg::tri::Clean<CMeshO>::SelectIntersectingFaces(mesh1, mesh2);