Lagrange
chain_corners_around_vertices.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#include <lagrange/utils/safe_cast.h>
17
18#include <Eigen/Core>
20
21namespace lagrange {
22
40template <typename DerivedF, typename DerivedE, typename DerivedN>
42 typename DerivedF::Scalar num_vertices,
43 const Eigen::MatrixBase<DerivedF> &facets,
44 Eigen::PlainObjectBase<DerivedE> &vertex_to_corner,
45 Eigen::PlainObjectBase<DerivedN> &next_corner_around_vertex)
46{
47 using Index = typename DerivedF::Scalar;
48
49 Index num_corners = safe_cast<Index>(facets.rows() * facets.cols());
50
51 // Chain corners around vertices and edges
52 vertex_to_corner.resize(num_vertices);
53 vertex_to_corner.setConstant(invalid<Index>());
54 next_corner_around_vertex.resize(num_corners);
55 next_corner_around_vertex.setConstant(invalid<Index>());
56 for (auto f : range(facets.rows())) {
57 for (auto lv : range(facets.cols())) {
58 Index c = (Index)(f * facets.cols() + lv);
59 Index v = facets(f, lv);
60 next_corner_around_vertex[c] = vertex_to_corner[v];
61 vertex_to_corner[v] = c;
62 }
63 }
64}
65
66} // 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_vertices(typename DerivedF::Scalar num_vertices, const Eigen::MatrixBase< DerivedF > &facets, Eigen::PlainObjectBase< DerivedE > &vertex_to_corner, Eigen::PlainObjectBase< DerivedN > &next_corner_around_vertex)
Chains facet corners around vertices of a mesh.
Definition: chain_corners_around_vertices.h:41