OpenABF 2.1.0
Loading...
Searching...
No Matches
SplitPath.cpp

Path splitting demo

Demonstrates flattening of a closed, triangular pyramid by introducing a border/seam along two edges.

See also
OpenABF::HalfEdgeMesh::split_path
#include <iomanip>
#include <iostream>
#include "OpenABF/OpenABF.hpp"
int main()
{
// Define the flattening types
// Create the 4 pyramid vertices
auto mesh = ABF::Mesh::New();
mesh->insert_vertex(0, 0, 0);
mesh->insert_vertex(2, 0, 0);
mesh->insert_vertex(1, std::sqrt(3), 0);
mesh->insert_vertex(1, std::sqrt(3) / 3, std::sqrt(6) * 2 / 3);
// Create the 4 pyramid triangles
mesh->insert_faces({{1, 3, 0}, {3, 2, 0}, {3, 1, 2}, {1, 0, 2}});
// Check manifoldness and boundary condition
std::cout << std::boolalpha;
std::cout << "Is manifold: " << IsManifold(mesh) << std::endl;
std::cout << "Has boundary: " << HasBoundary(mesh) << std::endl;
std::cout << "Edges: " << std::endl;
for (const auto& e : mesh->edges()) {
std::cout << " " << e->vertex->idx << " -> " << e->pair->vertex->idx << std::endl;
}
// Insert a border seam between vertices 0 -> 1 -> 2
std::cout << "Splitting path 0 -> 1 -> 2" << std::endl;
mesh->split_path({0, 1, 2});
// Reprint manifoldness and boundary condition
std::cout << "Is manifold: " << IsManifold(mesh) << std::endl;
std::cout << "Has boundary: " << HasBoundary(mesh) << std::endl;
std::cout << "Edges: " << std::endl;
for (const auto& e : mesh->edges()) {
std::cout << " " << e->vertex->idx << " -> " << e->pair->vertex->idx << std::endl;
}
// Run ABF++
std::size_t iters{0};
float grad{OpenABF::INF<float>};
ABF::Compute(mesh, iters, grad);
std::cout << "ABF++ Final gradient: " << grad << std::endl;
std::cout << "ABF++ Iterations: " << iters << std::endl;
// Run LSCM
// Write the flattened mesh
WriteMesh("openabf_example_split_path.obj", mesh);
}
Compute parameterized interior angles using ABF++.
Definition OpenABF.hpp:2640
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:2678
Compute parameterized mesh using Angle-based LSCM.
Definition OpenABF.hpp:2987
static void Compute(typename Mesh::Pointer &mesh)
Compute the parameterized mesh using automatic pin selection.
Definition OpenABF.hpp:3018
constexpr T INF
Inf, templated for floating-point type.
Definition OpenABF.hpp:69