Lagrange
chain_corners_around_edges.h
1/*
2 * Copyright 2020 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
13#pragma once
14
15#include <lagrange/utils/range.h>
16
17#include <Eigen/Core>
19
20namespace lagrange {
21
38template <typename DerivedF, typename DerivedC, typename DerivedE, typename DerivedN>
40 const Eigen::MatrixBase<DerivedF>& facets,
41 const Eigen::MatrixBase<DerivedC>& corner_to_edge,
42 Eigen::PlainObjectBase<DerivedE>& edge_to_corner,
43 Eigen::PlainObjectBase<DerivedN>& next_corner_around_edge)
44{
45 using Index = typename DerivedF::Scalar;
46
47 Index num_edges = (corner_to_edge.size() ? corner_to_edge.maxCoeff() + 1 : 0);
48 Index num_corners = (Index)(facets.rows() * facets.cols());
49
50 // Chain corners around vertices and edges
51 edge_to_corner.resize(num_edges);
52 edge_to_corner.setConstant(invalid<Index>());
53 next_corner_around_edge.resize(num_corners);
54 next_corner_around_edge.setConstant(invalid<Index>());
55 for (auto f : range(facets.rows())) {
56 for (auto lv : range(facets.cols())) {
57 Index c = (Index)(f * facets.cols() + lv);
58 Index e = corner_to_edge(c);
59 next_corner_around_edge[c] = edge_to_corner[e];
60 edge_to_corner[e] = c;
61 }
62 }
63}
64
65} // namespace lagrange
internal::Range< Index > range(Index end)
Returns an iterable object representing the range [0, end).
Definition: range.h:176
Main namespace for Lagrange.
Definition: AABBIGL.h:30
void chain_corners_around_edges(const Eigen::MatrixBase< DerivedF > &facets, const Eigen::MatrixBase< DerivedC > &corner_to_edge, Eigen::PlainObjectBase< DerivedE > &edge_to_corner, Eigen::PlainObjectBase< DerivedN > &next_corner_around_edge)
Chains facet corners around edges of a mesh.
Definition: chain_corners_around_edges.h:39