mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 06:15:56 +08:00

* 1. Remove all global include_directories. * 2. Move 3d party dependencies from src to budled deps if possible. * Unify and enforce one way of including headers: e.g. #include "libslic3r/GCode.hpp" vs #include "GCode.hpp" (always use the "libslic3r/GCode.hpp" option). * Make all dependencies (also header only) a cmake target.
40 lines
1.7 KiB
C++
40 lines
1.7 KiB
C++
// This file is part of libigl, a simple c++ geometry processing library.
|
|
//
|
|
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
#include "quad_planarity.h"
|
|
#include <Eigen/Geometry>
|
|
|
|
template <typename DerivedV, typename DerivedF, typename DerivedP>
|
|
IGL_INLINE void igl::quad_planarity(
|
|
const Eigen::PlainObjectBase<DerivedV>& V,
|
|
const Eigen::PlainObjectBase<DerivedF>& F,
|
|
Eigen::PlainObjectBase<DerivedP> & P)
|
|
{
|
|
int nf = F.rows();
|
|
P.setZero(nf,1);
|
|
for (int i =0; i<nf; ++i)
|
|
{
|
|
const Eigen::Matrix<typename DerivedV::Scalar,1,3> &v1 = V.row(F(i,0));
|
|
const Eigen::Matrix<typename DerivedV::Scalar,1,3> &v2 = V.row(F(i,1));
|
|
const Eigen::Matrix<typename DerivedV::Scalar,1,3> &v3 = V.row(F(i,2));
|
|
const Eigen::Matrix<typename DerivedV::Scalar,1,3> &v4 = V.row(F(i,3));
|
|
Eigen::Matrix<typename DerivedV::Scalar,1,3> diagCross=(v3-v1).cross(v4-v2);
|
|
typename DerivedV::Scalar denom =
|
|
diagCross.norm()*(((v3-v1).norm()+(v4-v2).norm())/2);
|
|
if (fabs(denom)<1e-8)
|
|
//degenerate quad is still planar
|
|
P[i] = 0;
|
|
else
|
|
P[i] = (diagCross.dot(v2-v1)/denom);
|
|
}
|
|
}
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
// Explicit template instantiation
|
|
template void igl::quad_planarity<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
|
#endif
|