Welcome to mirror list, hosted at ThFree Co, Russian Federation.

connect_boundary_to_infinity.cpp « igl « src - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 627b0b9b63481e391efe7daf498a4acc86aa6890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file is part of libigl, a simple c++ geometry processing library.
// 
// Copyright (C) 2016 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 "connect_boundary_to_infinity.h"
#include "boundary_facets.h"

template <typename DerivedF, typename DerivedFO>
IGL_INLINE void igl::connect_boundary_to_infinity(
  const Eigen::PlainObjectBase<DerivedF> & F,
  Eigen::PlainObjectBase<DerivedFO> & FO)
{
  return connect_boundary_to_infinity(F,F.maxCoeff(),FO);
}
template <typename DerivedF, typename DerivedFO>
IGL_INLINE void igl::connect_boundary_to_infinity(
  const Eigen::PlainObjectBase<DerivedF> & F,
  const typename DerivedF::Scalar inf_index,
  Eigen::PlainObjectBase<DerivedFO> & FO)
{
  // Determine boundary edges
  Eigen::Matrix<typename DerivedFO::Scalar,Eigen::Dynamic,Eigen::Dynamic> O;
  boundary_facets(F,O);
  FO.resize(F.rows()+O.rows(),F.cols());
  typedef Eigen::Matrix<typename DerivedFO::Scalar,Eigen::Dynamic,1> VectorXI;
  FO.topLeftCorner(F.rows(),F.cols()) = F;
  FO.bottomLeftCorner(O.rows(),O.cols()) = O.rowwise().reverse();
  FO.bottomRightCorner(O.rows(),1).setConstant(inf_index);
}

template <
  typename DerivedV, 
  typename DerivedF, 
  typename DerivedVO, 
  typename DerivedFO>
IGL_INLINE void igl::connect_boundary_to_infinity(
  const Eigen::PlainObjectBase<DerivedV> & V,
  const Eigen::PlainObjectBase<DerivedF> & F,
  Eigen::PlainObjectBase<DerivedVO> & VO,
  Eigen::PlainObjectBase<DerivedFO> & FO)
{
  typename DerivedV::Index inf_index = V.rows();
  connect_boundary_to_infinity(F,inf_index,FO);
  VO.resize(V.rows()+1,V.cols());
  VO.topLeftCorner(V.rows(),V.cols()) = V;
  auto inf = std::numeric_limits<typename DerivedVO::Scalar>::infinity();
  VO.row(V.rows()).setConstant(inf);
}

#ifdef IGL_STATIC_LIBRARY
template void igl::connect_boundary_to_infinity<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::Matrix<int, -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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
#endif