You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a mesh that is represented in float accuracy and this makes the mesh unclose.
So I want to use the function static int MergeCloseVertex(MeshType &m, const ScalarType radius) to merge the vertices.
The function in Meshlab works fine.
Then I tried using the function MergeCloseVertex in VCGLIB. It can merge the vertices the same as Meshlab, but the triangle meshes ( the number of three vertices) are different from Meshlab, which makes the mesh defects.
What should I do to update the triangles correctly ?
Source Code
#include <iostream>
#include <vector>
#include <vcg/complex/complex.h>
#include <vcg/complex/algorithms/clean.h>
#include <wrap/io_trimesh/import_off.h>
#include <wrap/io_trimesh/export_off.h>
using namespace vcg;
using namespace std;
class MyEdge;
class MyFace;
class MyVertex;
struct MyUsedTypes : public UsedTypes<
Use<MyVertex> ::AsVertexType,
Use<MyEdge> ::AsEdgeType,
Use<MyFace> ::AsFaceType> {};
class MyVertex : public Vertex<MyUsedTypes,
vertex::Coord3f,
vertex::Normal3f,
vertex::Qualityf,
vertex::Color4b,
vertex::BitFlags > {};
class MyFace : public Face< MyUsedTypes,
face::VertexRef,
face::BitFlags > {};
class MyEdge : public Edge<MyUsedTypes> {};
class MyMesh : public tri::TriMesh< vector<MyVertex>,
vector<MyFace>,
vector<MyEdge> > {};
int main()
{
MyMesh mesh;
const char* filename = "../../data/ember/resultIntersect_cgal_snapped_mesh.off";
int err = tri::io::ImporterOFF<MyMesh>::Open(mesh, filename);
if (err != 0)
{
cerr << "Error: Unable to open file " << filename << endl;
return 1;
}
cout << "Successfully imported OFF file: " << endl;
cout << "Number of vertices: " << mesh.VN() << endl;
cout << "Number of faces: " << mesh.FN() << endl;
// Merge the vertices
float mergeRadius = 0.001f * mesh.bbox.Diag();
cout << "mergeRadius " << mergeRadius << endl;
tri::UpdateBounding<MyMesh>::Box(mesh);
tri::UpdateNormal<MyMesh>::PerVertexNormalized(mesh);
int TotalMergedVertices = tri::Clean<MyMesh>::MergeCloseVertex(mesh, mergeRadius);
cout << "Successfully merged " << TotalMergedVertices << " vertices" << endl;
// Save the merged mesh to a new OFF file
const char* outputFilename = "../../data/ember/resultIntersect_cgal_snapped_mesh_VCGLIB_Merge.off";
err = tri::io::ExporterOFF<MyMesh>::Save(mesh, outputFilename);
cout << "Vertices merged successfully. Saved to " << outputFilename << endl;
return 0;
}
The text was updated successfully, but these errors were encountered:
Are you using MeshLab 2022.02 or 2022.02d? PyMeshLab uses double precision, therefore that could be the issue.
The code executed by meshlab and pymeshlab is this, and as you can see, nothing magic is done.
Issue Describe
I have a mesh that is represented in float accuracy and this makes the mesh unclose.
So I want to use the function
static int MergeCloseVertex(MeshType &m, const ScalarType radius)
to merge the vertices.The function in Meshlab works fine.
Then I tried using the function MergeCloseVertex in VCGLIB. It can merge the vertices the same as Meshlab, but the triangle meshes ( the number of three vertices) are different from Meshlab, which makes the mesh defects.
What should I do to update the triangles correctly ?
Source Code
The text was updated successfully, but these errors were encountered: