Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_labels
This commit is contained in:
commit
16fa68df0c
@ -24,6 +24,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
@ -83,41 +84,15 @@ struct remove_cvref {
|
||||
template< class T >
|
||||
using remove_cvref_t = typename remove_cvref<T>::type;
|
||||
|
||||
struct DOut {
|
||||
#ifndef NDEBUG
|
||||
std::ostream& out = std::cout;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline DOut&& operator<<( DOut&& out, T&& d) {
|
||||
#ifndef NDEBUG
|
||||
out.out << d;
|
||||
#endif
|
||||
return std::move(out);
|
||||
}
|
||||
|
||||
inline DOut dout() { return DOut(); }
|
||||
|
||||
template<class T> FloatingOnly<T, bool> is_approx(T val, T ref) { return std::abs(val - ref) < 1e-8; }
|
||||
template<class T> IntegerOnly <T, bool> is_approx(T val, T ref) { val == ref; }
|
||||
|
||||
template<class T, size_t N = 10> class SymetricMatrix {
|
||||
template<class T> class SymetricMatrix {
|
||||
static const constexpr size_t N = 10;
|
||||
public:
|
||||
|
||||
explicit SymetricMatrix(ArithmeticOnly<T> c = T()) { std::fill(m, m + N, c); }
|
||||
|
||||
SymetricMatrix(T m11, T m12, T m13, T m14,
|
||||
T m22, T m23, T m24,
|
||||
T m33, T m34,
|
||||
T m44)
|
||||
{
|
||||
m[0] = m11; m[1] = m12; m[2] = m13; m[3] = m14;
|
||||
m[4] = m22; m[5] = m23; m[6] = m24;
|
||||
m[7] = m33; m[8] = m34;
|
||||
m[9] = m44;
|
||||
}
|
||||
|
||||
// Make plane
|
||||
SymetricMatrix(T a, T b, T c, T d)
|
||||
{
|
||||
@ -141,21 +116,16 @@ public:
|
||||
return det;
|
||||
}
|
||||
|
||||
const SymetricMatrix operator+(const SymetricMatrix& n) const
|
||||
const SymetricMatrix& operator+=(const SymetricMatrix& n)
|
||||
{
|
||||
return SymetricMatrix(m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3]+n[3],
|
||||
m[4] + n[4], m[5] + n[5], m[6] + n[6],
|
||||
m[7] + n[7], m[8] + n[8],
|
||||
m[9] + n[9]);
|
||||
for (size_t i = 0; i < N; ++i) m[i] += n[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
SymetricMatrix& operator+=(const SymetricMatrix& n)
|
||||
SymetricMatrix operator+(const SymetricMatrix& n)
|
||||
{
|
||||
m[0]+=n[0]; m[1]+=n[1]; m[2]+=n[2]; m[3]+=n[3];
|
||||
m[4]+=n[4]; m[5]+=n[5]; m[6]+=n[6]; m[7]+=n[7];
|
||||
m[8]+=n[8]; m[9]+=n[9];
|
||||
|
||||
return *this;
|
||||
SymetricMatrix self = *this;
|
||||
return self += n;
|
||||
}
|
||||
|
||||
T m[N];
|
||||
@ -350,10 +320,10 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void simplify_mesh_lossless();
|
||||
template<class ProgressFn> void simplify_mesh_lossless(ProgressFn &&fn);
|
||||
void simplify_mesh_lossless() { simplify_mesh_lossless([](int){}); }
|
||||
};
|
||||
|
||||
|
||||
template<class Mesh> void SimplifiableMesh<Mesh>::compact_faces()
|
||||
{
|
||||
auto it = std::remove_if(m_faceinfo.begin(), m_faceinfo.end(),
|
||||
@ -605,7 +575,7 @@ bool SimplifiableMesh<Mesh>::flipped(const Vertex & p,
|
||||
}
|
||||
|
||||
template<class Mesh>
|
||||
void SimplifiableMesh<Mesh>::simplify_mesh_lossless()
|
||||
template<class Fn> void SimplifiableMesh<Mesh>::simplify_mesh_lossless(Fn &&fn)
|
||||
{
|
||||
// init
|
||||
for (FaceInfo &fi : m_faceinfo) fi.deleted = false;
|
||||
@ -629,7 +599,7 @@ void SimplifiableMesh<Mesh>::simplify_mesh_lossless()
|
||||
//
|
||||
double threshold = std::numeric_limits<double>::epsilon(); //1.0E-3 EPS; // Really? (tm)
|
||||
|
||||
dout() << "lossless iteration " << iteration << "\n";
|
||||
fn(iteration);
|
||||
|
||||
for (FaceInfo &fi : m_faceinfo) {
|
||||
if (fi.err[3] > threshold || fi.deleted || fi.dirty) continue;
|
||||
|
@ -502,16 +502,16 @@ void Camera::rotate_local_around_pivot(const Vec3d& rotation_rad, const Vec3d& p
|
||||
m_view_matrix.rotate(Eigen::AngleAxisd(rotation_rad(2), get_dir_forward()));
|
||||
translate_world(center);
|
||||
}
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
|
||||
double Camera::min_zoom() const
|
||||
{
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
return 0.7 * calc_zoom_to_bounding_box_factor(m_scene_box);
|
||||
#else
|
||||
return 0.7 * calc_zoom_to_bounding_box_factor(m_scene_box, (int)m_viewport[2], (int)m_viewport[3]);
|
||||
return 0.7 * calc_zoom_to_bounding_box_factor(m_scene_box, m_viewport[2], m_viewport[3]);
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
}
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
|
||||
std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBoxf3& box) const
|
||||
{
|
||||
|
@ -146,10 +146,9 @@ public:
|
||||
|
||||
// returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis
|
||||
bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }
|
||||
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
double max_zoom() const { return 100.0; }
|
||||
double min_zoom() const;
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
|
||||
private:
|
||||
// returns tight values for nearZ and farZ plane around the given bounding box
|
||||
|
Loading…
Reference in New Issue
Block a user