cell_adjacency.cpp 1023 B

123456789101112131415161718192021222324252627
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Qingnan Zhou <qnzhou@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. //
  9. #include "cell_adjacency.h"
  10. template <typename DerivedC>
  11. IGL_INLINE void igl::copyleft::cgal::cell_adjacency(
  12. const Eigen::PlainObjectBase<DerivedC>& per_patch_cells,
  13. const size_t num_cells,
  14. std::vector<std::set<std::tuple<typename DerivedC::Scalar, bool, size_t> > >&
  15. adjacency_list) {
  16. const size_t num_patches = per_patch_cells.rows();
  17. adjacency_list.resize(num_cells);
  18. for (size_t i=0; i<num_patches; i++) {
  19. const int positive_cell = per_patch_cells(i,0);
  20. const int negative_cell = per_patch_cells(i,1);
  21. adjacency_list[positive_cell].emplace(negative_cell, false, i);
  22. adjacency_list[negative_cell].emplace(positive_cell, true, i);
  23. }
  24. }