14#include <lagrange/corner_to_edge_mapping.h>
16#include <lagrange/Logger.h>
17#include <lagrange/utils/assert.h>
18#include <lagrange/utils/safe_cast.h>
21#include <lagrange/utils/warnoff.h>
22#include <tbb/parallel_sort.h>
23#include <lagrange/utils/warnon.h>
35template <
typename DerivedF,
typename DerivedC>
37 const Eigen::MatrixBase<DerivedF>& F,
38 Eigen::PlainObjectBase<DerivedC>& C2E)
40 using Index =
typename DerivedF::Scalar;
48 UnorientedEdge(Index x, Index y, Index c)
54 auto key()
const {
return std::make_pair(v1, v2); }
56 bool operator<(
const UnorientedEdge& e)
const {
return key() < e.key(); }
58 bool operator!=(
const UnorientedEdge& e)
const {
return key() != e.key(); }
61 Index vert_per_facet = safe_cast<Index>(F.cols());
64 std::vector<UnorientedEdge> edges;
65 edges.reserve(F.rows() * F.cols());
66 for (Index f = 0; f < (Index) F.rows(); ++f) {
67 for (Index lv = 0; lv < (Index) F.cols(); ++lv) {
69 auto v2 = F(f, (lv + 1) % vert_per_facet);
70 edges.emplace_back(v1, v2, f * vert_per_facet + lv);
73 tbb::parallel_sort(edges.begin(), edges.end());
76 C2E.resize(F.rows() * F.cols());
78 for (
auto it_begin = edges.begin(); it_begin != edges.end();) {
80 auto it_end = std::find_if(it_begin, edges.end(), [&](
auto e) { return (e != *it_begin); });
81 for (
auto it = it_begin; it != it_end; ++it) {
82 C2E(it->corner) = num_edges;
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Eigen::Index corner_to_edge_mapping(const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedC > &C2E)
Computes a mapping from mesh corners (k*f+i) to unique edge ids.
Definition: corner_to_edge_mapping.impl.h:36