#pragma once
#include <Eigen/Core>
#include <Eigen/Sparse>
#include "arap-mold.h"
#include "mesh.h"
using Eigen::MatrixXd;
using Eigen::MatrixXi;
using Eigen::Vector3d;
// Various computed things about the mesh
// If a point is above the plane.
extern std::vector<bool> is_point_above;
// `Moldable` values for all faces
extern std::vector<arap::Moldable::Enum> moldable;
// `Orientation` values for all faces
extern std::vector<arap::Orientation::Enum> orientation;
// dot products with the removal direction for each face
extern std::vector<double> dots;
// Don't use the ARAP enforcing moldability. (only makes sense to use wiht `stitching`).
extern bool regular_arap;
// Scale factor for all stitching forces
extern float force_scale;
// Multiply forces with the face area
extern bool area_force;
// Force distance cutoff
extern float force_dist_cutoff;
// The number of ARAP iterations performed
extern int iteration_count;
// Whether to stitch together unmoldable geometry
extern bool stitching;
// Endpoints for all forces calculated. If not `nullptr` then this is written to in
// `compute_things`.
extern MatrixXd *forces_endpoints_ptr;
extern arap::Data arap_data;
extern arap::Args arap_args;
extern Eigen::Vector3d plane_p;
extern Eigen::Vector3d plane_n;
struct Ray {
Vector3d src;
Vector3d dir;
};
namespace StepReturn {
enum Enum {
NotDone,
Converged,
WouldNaN,
};
}
int ray_intersect(Ray, int, Mesh &);
int intersect3D_RayTriangle(Ray, Vector3d, int, MatrixXd &, MatrixXi &, Vector3d *);
StepReturn::Enum step_arap(Mesh &, double = 1.0);
void compute_things(Mesh &mesh, double = 1.0, bool only_plane = false);