Martin Šach 21116995d7 Refactor CMake and improve #includes.
* 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.
2024-07-08 15:36:46 +02:00

64 lines
2.3 KiB
C++

// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2013 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 "columnize.h"
#include <cassert>
template <typename DerivedA, typename DerivedB>
IGL_INLINE void igl::columnize(
const Eigen::PlainObjectBase<DerivedA> & A,
const int k,
const int dim,
Eigen::PlainObjectBase<DerivedB> & B)
{
// Eigen matrices must be 2d so dim must be only 1 or 2
assert(dim == 1 || dim == 2);
// block height, width, and number of blocks
int m,n;
if(dim == 1)
{
m = A.rows()/k;
assert(m*(int)k == (int)A.rows());
n = A.cols();
}else// dim == 2
{
m = A.rows();
n = A.cols()/k;
assert(n*(int)k == (int)A.cols());
}
// resize output
B.resize(A.rows()*A.cols(),1);
for(int b = 0;b<(int)k;b++)
{
for(int i = 0;i<m;i++)
{
for(int j = 0;j<n;j++)
{
if(dim == 1)
{
B(j*m*k+i*k+b) = A(i+b*m,j);
}else
{
B(j*m*k+i*k+b) = A(i,b*n+j);
}
}
}
}
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
template void igl::columnize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
template void igl::columnize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
template void igl::columnize<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, int, int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
template void igl::columnize<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, int, int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&);
#endif