forked from libigl/libigl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_shared.h
More file actions
113 lines (90 loc) · 3.01 KB
/
Copy pathpython_shared.h
File metadata and controls
113 lines (90 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/complex.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include <pybind11/functional.h>
#include <Eigen/Dense>
#include "py_doc.h"
#include "modules/py_typedefs.h"
template<typename Scalar>
void assert_is_VectorX(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if (v.cols() != 1)
throw std::runtime_error(name + " must be a column vector.");
}
template<typename Scalar>
void assert_is_RowVectorX(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if (v.rows() != 1)
throw std::runtime_error(name + " must be a row vector.");
}
template<typename Scalar>
void assert_is_Vector2(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 1) || (v.rows() != 2))
throw std::runtime_error(name + " must be a column vector with 2 entries.");
}
template<typename Scalar>
void assert_is_RowVector2(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 2) || (v.rows() != 1))
throw std::runtime_error(name + " must be a row vector with 2 entries.");
}
template<typename Scalar>
void assert_is_Vector3(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 1) || (v.rows() != 3))
throw std::runtime_error(name + " must be a column vector with 3 entries.");
}
template<typename Scalar>
void assert_is_RowVector3(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 3) || (v.rows() != 1))
throw std::runtime_error(name + " must be a row vector with 3 entries.");
}
template<typename Scalar>
void assert_is_Vector4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 1) || (v.rows() != 4))
throw std::runtime_error(name + " must be a column vector with 4 entries.");
}
template<typename Scalar>
void assert_is_RowVector4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 4) || (v.rows() != 1))
throw std::runtime_error(name + " must be a row vector with 4 entries.");
}
template<typename Scalar>
void assert_is_Matrix4(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
{
if (v.size() == 0)
return;
if ((v.cols() != 4) || (v.rows() != 4))
throw std::runtime_error(name + " must be a 4x4 matrix.");
}
namespace py = pybind11;