Incremental Remesh
AMCAX::Meshing::Remeshing::TriMesh_IncrementalRemeshing perform isotropic remesh of the input mesh. When the point, face, and parameters (Params) of the input 3D mesh are provided, it outputs the mesh after incremental remesh (aiming to generate as many equilateral triangles as possible).
The parameters in Params that can be set are as follows: :
- Max_error:The maximum error relative to the original mesh, used to calculate the adaptive length. A larger parameter results in a longer adaptive length. The default value is 0.0005.
- targetEdgeLength:The ratio of the target edge length to the average length of all edges in the original mesh. The default value is 0.5. The length range is [0.3 * targetEdgeLength * meanLength, 3 * targetEdgeLength * meanLength].
- isAdaptive:Whether the remesh is adaptive. Set to true for adaptive remesh and false for non-adaptive remesh. The default value is false.
- featurePreserved:Whether to preserve features. Set to true to preserve features, and false to not preserve them. The default value is false.
- tolAngle:The angular threshold for feature detection, in radians. The default value is 0.7854.
- iterNum:The number of iterations. The default value is 5, but 10 iterations are generally sufficient.
The main steps of Incremental Remesh are as follows::
- Input the points and faces of the mesh. The mesh can be read in a specific format (such as .obj or .stl) depending on the actual situation.
- Set the parameters.
- Initialize the reference mesh and variable mesh with points and faces.
- Perform the remeshing.
- Output the result in the desired file format (.obj or .stl).
std::string inputfilename = "./data/32770_sf.obj";
io_options.vertex_has_point = true;
reader.
read(inputfilename, io_options);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Points input_points = std::move(reader.
m_points);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Triangles input_triangles = std::move(reader.
m_triangles);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Points output_points = input_points;
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Triangles output_triangles = input_triangles;
params.Max_error = 0.0002;
std::string outputfilename =
"incrementalRemeshing" + std::to_string(params.
iterNum) +
".obj";
writer.
m_points = std::move(output_points);
writer.
write(outputfilename, io_options, 15);
Options about pre-described properties in mesh IO.
Definition IOOptions.hpp:19
Read triangle soup from an OBJ file.
Definition OBJReader.hpp:38
Points m_points
point position
Definition OBJReader.hpp:125
Triangles m_triangles
triangle faces
Definition OBJReader.hpp:130
AMCAXMeshing_API bool read(const std::string &filename, IOOptions &opt)
Read triangle soup from the file. results will be stored in member variables of reader,...
Write triangle soup to an OBJ file.
Definition OBJWriter.hpp:38
Triangles m_triangles
triangle faces
Definition OBJWriter.hpp:131
AMCAXMeshing_API bool write(const std::string &filename, IOOptions &opt, std::streamsize precision)
Write triangle soup to file with given options and precison.
Points m_points
point position
Definition OBJWriter.hpp:126
Definition TriMesh_IncrementalRemeshing.hpp:24
AMCAXMeshing_API void setReferenceMesh(const iPoints &points, const iTriangles &triangles)
add a triangle mesh (triangle soup) as one input.
AMCAXMeshing_API void setVariableMesh(iPoints &points, iTriangles &triangles)
Set the triangle mesh (triangle soup) as output destination.
AMCAXMeshing_API void remesh(Params params)
Adaptive/Isotropic remeshing controled by the control parameters.
the parameters that control the remeshing
Definition TriMesh_IncrementalRemeshing.hpp:40
bool featurePreserved
Whether keep the feature or not, not yet implemented.
Definition TriMesh_IncrementalRemeshing.hpp:57
double tolAngle
Dihedral angle greater than tolAngle (in radians) will be recognized as a feature edge,...
Definition TriMesh_IncrementalRemeshing.hpp:62
size_t iterNum
The iterations number.
Definition TriMesh_IncrementalRemeshing.hpp:66
bool isAdaptive
If true, adaptive remeshing; else, isotropic remeshing.
Definition TriMesh_IncrementalRemeshing.hpp:53
double targetEdgeLength
Target edge length expressed as a percentage of the mean length of all edges.
Definition TriMesh_IncrementalRemeshing.hpp:49
Mesh Cut and Mesh Parameterization
AMCAX::Meshing::TriMeshCut::GreedyCut< Traits >::cut implements the cut of closed surface meshes to make them homeomorphic to a disk topology, while minimizing the parameterization distortion as much as possible, support parameterization algorithms. It is important to note that the mesh cut algorithm is random, so each cut may not be identical.
Below are the meshes after cutting (the green lines in the image represent the mesh boundaries):
The cut mesh is then used as input for the parameterization algorithm, resulting in a parameterized mesh (the parameterized mesh is a flat, non-self-intersecting surface):
The 3D surface mesh is parameterized to produce a low-distortion, low-self-intersection flat parameterized mesh, support applications such as texture mapping. It is important to ensure that the input mesh has cut boundaries and does not contain non-manifold structures (the mesh must be a 2D manifold mesh). Additionally, STL file may merge points within a certain error range, so it is necessary to verify the input mesh before calling the algorithm.
io_options.vertex_has_point = true;
std::string in_filename = "./data/cow.obj";
std::string out_cut_filename = "bunny_cut.obj";
std::string out_para_filename = "bunny_parameterization.obj";
obj_reader.
read(in_filename, io_options);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Points i_points = std::move(obj_reader.
m_points);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Triangles i_triangles = std::move(obj_reader.
m_triangles);
i_points, i_triangles, true);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Points cut_points;
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Triangles cut_triangles;
mesh_cut.cut(cut_points, cut_triangles);
obj_writer.
write(out_cut_filename, io_options, 10);
AMCAX::Meshing::Mesh::TriSoupTraits_Coord::Points para_points;
cut_points, cut_triangles, para_points,true);
para.parameterization();
obj_writer.
m_points = std::move(para_points);
obj_writer.
write(out_para_filename, io_options, 10);
AMCAXMeshing_API void clear()
Clear data stored in writer.
Definition MeshParameterization.hpp:23
Definition TriMeshCut.hpp:24