1 #ifndef UNITTESTS_COMMON_DUMMYTRAITS 2 #define UNITTESTS_COMMON_DUMMYTRAITS 3 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> 4 #include <OpenMesh/Core/Utils/color_cast.hh> 11 template <
int DIM>
class Vec {
14 Vec(
float x) : data({ x }) {}
15 Vec(
float x,
float y) : data({ x, y }) {}
16 Vec(
float x,
float y,
float z) : data({ x, y, z }) {}
17 Vec(
float x,
float y,
float z,
float w) : data({ x, y, z, w }) {}
22 float &operator[](
int i) {
return data[i]; }
23 float operator[](
int i)
const {
return data[i]; }
26 std::array<float, DIM> data;
29 template <
int DIM>
bool operator==(
Vec<DIM> const &lhs,
Vec<DIM> const &rhs) {
30 for (
int i = 0; i < DIM; i++)
31 if (lhs[i] != rhs[i])
return false;
38 for (
int i = 0; i < DIM; i++)
39 result[i] = lhs[i] + rhs[i];
46 for (
int i = 0; i < DIM; i++)
47 result[i] = lhs[i] - rhs[i];
53 for (
int i = 0; i < DIM; i++)
54 result[i] = lhs[i] * rhs;
64 for (
int i = 0; i < DIM; i++)
65 result[i] = lhs[i] / rhs;
70 return lhs = lhs + rhs;
73 return lhs = lhs - rhs;
76 return lhs = lhs * rhs;
79 return lhs = lhs / rhs;
82 template <
int DIM>
float norm(
Vec<DIM> const &v) {
84 for (
int i = 0; i < DIM; i++)
86 return std::sqrt(sum);
91 for (
int i = 0; i < DIM; i++)
97 for (
int i = 0; i < DIM; i++)
98 v1[i] = std::min(v1[i], v2[i]);
103 for (
int i = 0; i < DIM; i++)
104 v1[i] = std::max(v1[i], v2[i]);
110 for (
int i = 0; i < DIM; i++)
111 sum += v1[i] * v2[i];
116 return {v1[1] * v2[2] - v1[2] * v2[1],
117 v1[2] * v2[0] - v1[0] * v2[2],
118 v1[0] * v2[1] - v1[1] * v2[0]};
125 using value_type = float;
126 static const size_t size_ = DIM;
127 static size_t size() {
return size_; }
139 #endif // UNITTESTS_COMMON_DUMMYTRAITS Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
A Vector class with the absolute minimum of built-in methods to test the interface expected from Vect...
Definition: unittests_common_customtraits.hh:11
Definition: unittests_common.hh:13
Add 3D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:93
Definition: unittests_common_customtraits.hh:7
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
Helper class providing information about a vector type.
Definition: vector_traits.hh:93
Base class for all traits.
Definition: Traits.hh:126
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:92