Builds a mesh with multiple connected components (here, a 3x3 grid torn along two seams), extracts each component as an independent mesh, runs ABF++ + LSCM on each, and writes each flattened chart to its own .obj file.
The original mesh is never modified — the extracted sub-meshes own their own vertices and per-edge state, and each is parameterized in isolation.
#include <iostream>
#include <string>
#include "OpenABF/OpenABF.hpp"
int main()
{
auto mesh = ABF::Mesh::New();
mesh->insert_vertices({
{0.f, 0.f, 0.f},
{1.f, 0.f, 0.f},
{2.f, 0.f, 0.f},
{0.f, 1.f, 0.f},
{1.f, 1.f, 0.f},
{2.f, 1.f, 0.f},
{0.f, 2.f, 0.f},
{1.f, 2.f, 0.f},
{2.f, 2.f, 0.f},
});
mesh->insert_faces({
{0, 3, 1},
{1, 3, 4},
{1, 4, 2},
{2, 4, 5},
{3, 6, 4},
{4, 6, 7},
{4, 7, 5},
{5, 7, 8},
});
std::cout << "Before split: " << mesh->num_connected_components() << " component(s)\n";
mesh->split_path({1, 4, 7});
std::cout << "After split: " << mesh->num_connected_components() << " component(s)\n";
auto charts = mesh->extract_connected_components();
std::cout << "Extracted " << charts.size() << " chart(s)\n";
for (std::size_t i = 0; i < charts.size(); ++i) {
auto& cc = charts[i];
std::size_t iters{0};
const auto out = "openabf_example_multi_chart_" + std::to_string(i) + ".obj";
std::cout << "Chart " << i << ": " << cc.mesh->num_vertices() << " vertices, "
<< cc.mesh->num_faces() << " faces, " << iters << " ABF++ iters -> " << out
<< "\n";
}
std::cout << "Source mesh 3D positions intact: " << mesh->num_vertices() << " vertices, "
<< mesh->num_faces() << " faces\n";
}
Compute parameterized interior angles using ABF++.
Definition OpenABF.hpp:2816
static void Compute(typename Mesh::Pointer &mesh, std::size_t &iters, T &gradient, const std::size_t maxIters=10, T gradThreshold=T(0.001))
Compute parameterized interior angles.
Definition OpenABF.hpp:2868
Compute parameterized mesh using Angle-based LSCM.
Definition OpenABF.hpp:3484
static void Compute(typename Mesh::Pointer &mesh)
Compute the parameterized mesh using automatic pin selection.
Definition OpenABF.hpp:3547
void WriteMesh(const std::filesystem::path &path, const MeshPtr &mesh)
Write a HalfEdgeMesh to a file.
Definition OpenABF.hpp:5509
constexpr T INF
Inf, templated for floating-point type.
Definition OpenABF.hpp:69