libigl v2.5.0
Loading...
Searching...
No Matches
PlainMatrix.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2024 Alec Jacobson <alecjacobson@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#ifndef IGL_PLAINMATRIX_H
10#define IGL_PLAINMATRIX_H
11#include <Eigen/Core>
12
13#include <type_traits>
14#include <Eigen/Dense>
15
16// Define void_t for compatibility if it's not in the standard library (C++11 and later)
17#if __cplusplus < 201703L
18namespace std {
19 template <typename... Ts>
20 using void_t = void;
21}
22#endif
23
24
25#ifndef IGL_DEFAULT_MAJORING
26#define IGL_DEFAULT_MAJORING Eigen::ColMajor
27#endif
28
29namespace igl
30{
31 template <typename Derived, int Rows, int Cols, int Options>
33 using Type = Eigen::Matrix<typename Derived::Scalar,Rows,Cols,((Rows == 1 && Cols != 1) ? Eigen::RowMajor : ((Cols == 1 && Rows != 1) ? Eigen::ColMajor : Options))>;
34 };
35 template <typename Derived, typename = void>
36 struct get_options {
37 static constexpr int value = IGL_DEFAULT_MAJORING;
38 };
39
40 template <typename Derived>
41 struct get_options<Derived, std::void_t<decltype(Derived::Options)>> {
42 static constexpr int value = Derived::Options;
43 };
44
84 // Helper to check if `Options` exists in Derived
85
86 // Modify PlainMatrix to use get_options
87 template <typename Derived,
88 int Rows = Derived::RowsAtCompileTime,
89 int Cols = Derived::ColsAtCompileTime,
90 int Options = get_options<Derived>::value>
92
93}
94
95#endif
#define IGL_DEFAULT_MAJORING
Definition PlainMatrix.h:26
Definition AABB.h:18
typename PlainMatrixHelper< Derived, Rows, Cols, Options >::Type PlainMatrix
Some libigl implementations would (still do?) use a pattern like:
Definition PlainMatrix.h:91
Definition PlainMatrix.h:18
void void_t
Definition PlainMatrix.h:20
Definition PlainMatrix.h:32
Eigen::Matrix< typename Derived::Scalar, Rows, Cols,((Rows==1 &&Cols !=1) ? Eigen::RowMajor :((Cols==1 &&Rows !=1) ? Eigen::ColMajor :Options))> Type
Definition PlainMatrix.h:33
static constexpr int value
Definition PlainMatrix.h:42
Definition PlainMatrix.h:36
static constexpr int value
Definition PlainMatrix.h:37