Lagrange
get_opposite_edge.h
1/*
2 * Copyright 2018 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 */
12#pragma once
13
14#include <cassert>
15
16#include <lagrange/Edge.h>
17#include <lagrange/common.h>
18
19namespace lagrange {
20
21template <typename DerivedF>
22[[deprecated]]
23EdgeType<typename DerivedF::Scalar> get_opposite_edge(
24 const Eigen::PlainObjectBase<DerivedF>& facets,
25 typename DerivedF::Scalar fid,
26 typename DerivedF::Scalar vid)
27{
28 using Edge = EdgeType<typename DerivedF::Scalar>;
29 assert(facets.cols() == 3);
30 const auto& f = facets.row(fid);
31 if (f[0] == vid) {
32 return Edge(f[1], f[2]);
33 } else if (f[1] == vid) {
34 return Edge(f[2], f[0]);
35 } else if (f[2] == vid) {
36 return Edge(f[0], f[1]);
37 } else {
38 throw std::runtime_error(
39 "Facet " + std::to_string(fid) + " does not contain vertex " + std::to_string(vid));
40 }
41}
42} // namespace lagrange
@ Edge
Per-edge mesh attributes.
Definition: AttributeFwd.h:34
Main namespace for Lagrange.
Definition: AABBIGL.h:30