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

Basic flattening demo

Demonstrates flattening of a triangular pyramid mesh using ABF++ and LSCM.

Note
The HalfEdgeMesh class currently assumes that the surface has a boundary, is manifold, and that the winding order of all faces is the same. Care should be taken that this assumption is not violated when constructing your mesh.
#include <iostream>
#include "OpenABF/OpenABF.hpp"
int main()
{
// Define the flattening types
using Vec3f = OpenABF::Vec3f;
// Pre-define vertices list
const std::vector vertices = {Vec3f{0.f, 0.f, 0.f}, Vec3f{2.f, 0.f, 0.f},
Vec3f{1.f, std::sqrt(3.f), 0.f},
Vec3f{1.f, std::sqrt(3.f) / 3.f, std::sqrt(6.f) * 2.f / 3.f}};
// Create the 4 pyramid vertices
auto mesh = ABF::Mesh::New();
mesh->insert_vertices(vertices);
// Create the 3 pyramid triangles (the 4th is open)
mesh->insert_faces({{1, 3, 0}, {3, 2, 0}, {3, 1, 2}});
// 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
// Print flattened positions
for (const auto& v : mesh->vertices()) {
std::cout << v->idx << ": " << vertices[v->idx] << " -> " << v->pos << std::endl;
}
// Write the flattened mesh
WriteMesh("openabf_example_basic_flattening.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
Vec< float, 3 > Vec3f
3D, 32-bit float vector
Definition OpenABF.hpp:419
constexpr T INF
Inf, templated for floating-point type.
Definition OpenABF.hpp:69