OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::TextureBake::anonymous_namespace{TextureBakeDecimate.cpp} Namespace Reference

Classes

struct  Quadric
struct  HeapEntry

Functions

double eval_sum (const std::vector< Quadric > &qs, int v1, int v2, const Vec3d &p)
bool solve_q (const std::vector< Quadric > &qs, int v1, int v2, Vec3d &out)
Vec3d face_normal_unit (const std::vector< Vec3d > &pos, int a, int b, int c)

Function Documentation

◆ eval_sum()

double Slic3r::TextureBake::anonymous_namespace{TextureBakeDecimate.cpp}::eval_sum ( const std::vector< Quadric > & qs,
int v1,
int v2,
const Vec3d & p )
51{
52 return qs[size_t(v1)].eval(p.x(), p.y(), p.z()) + qs[size_t(v2)].eval(p.x(), p.y(), p.z());
53}

References eval_sum().

Referenced by eval_sum().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ face_normal_unit()

Vec3d Slic3r::TextureBake::anonymous_namespace{TextureBakeDecimate.cpp}::face_normal_unit ( const std::vector< Vec3d > & pos,
int a,
int b,
int c )
81{
82 const Vec3d n = (pos[size_t(b)] - pos[size_t(a)]).cross(pos[size_t(c)] - pos[size_t(a)]);
83 const double len = n.norm();
84 return (len > 0.0) ? Vec3d(n / len) : Vec3d::Zero();
85}
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
T cross(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:168

References Slic3r::cross(), and face_normal_unit().

Referenced by face_normal_unit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve_q()

bool Slic3r::TextureBake::anonymous_namespace{TextureBakeDecimate.cpp}::solve_q ( const std::vector< Quadric > & qs,
int v1,
int v2,
Vec3d & out )
57{
58 const auto &A = qs[size_t(v1)].q;
59 const auto &B = qs[size_t(v2)].q;
60 const double a00 = A[0] + B[0], a01 = A[1] + B[1], a02 = A[2] + B[2];
61 const double a11 = A[4] + B[4], a12 = A[5] + B[5], a22 = A[7] + B[7];
62 const double b0 = -(A[3] + B[3]), b1 = -(A[6] + B[6]), b2 = -(A[8] + B[8]);
63
64 const double det = a00 * (a11 * a22 - a12 * a12) - a01 * (a01 * a22 - a12 * a02) +
65 a02 * (a01 * a12 - a11 * a02);
66 const double max_el = std::max({ std::abs(a00), std::abs(a01), std::abs(a02), std::abs(a11),
67 std::abs(a12), std::abs(a22) });
68 // Scaled with the matrix, so it means the same at any model scale.
69 const double threshold = max_el * max_el * max_el * 1e-10;
70 if (std::abs(det) < std::max(threshold, 1e-30))
71 return false;
72
73 const double inv = 1.0 / det;
74 out.x() = inv * (b0 * (a11 * a22 - a12 * a12) - a01 * (b1 * a22 - a12 * b2) + a02 * (b1 * a12 - a11 * b2));
75 out.y() = inv * (a00 * (b1 * a22 - a12 * b2) - b0 * (a01 * a22 - a12 * a02) + a02 * (a01 * b2 - b1 * a02));
76 out.z() = inv * (a00 * (a11 * b2 - b1 * a12) - a01 * (a01 * b2 - b1 * a02) + b0 * (a01 * a12 - a11 * a02));
77 return true;
78}

References solve_q().

Referenced by solve_q().

Here is the call graph for this function:
Here is the caller graph for this function: