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>
11template <
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 }) {}
21 float &operator[](
int i) {
return data[i]; }
22 float operator[](
int i)
const {
return data[i]; }
25 std::array<float, DIM> data;
28template <
int DIM>
bool operator==(
Vec<DIM> const &lhs,
Vec<DIM> const &rhs) {
29 for (
int i = 0; i < DIM; i++)
30 if (lhs[i] != rhs[i])
return false;
35Vec<DIM> operator+(Vec<DIM>
const &lhs, Vec<DIM>
const &rhs) {
37 for (
int i = 0; i < DIM; i++)
38 result[i] = lhs[i] + rhs[i];
45 for (
int i = 0; i < DIM; i++)
46 result[i] = lhs[i] - rhs[i];
52 for (
int i = 0; i < DIM; i++)
53 result[i] = lhs[i] * rhs;
63 for (
int i = 0; i < DIM; i++)
64 result[i] = lhs[i] / rhs;
69 return lhs = lhs + rhs;
72 return lhs = lhs - rhs;
75 return lhs = lhs * rhs;
78 return lhs = lhs / rhs;
81template <
int DIM>
float norm(
Vec<DIM> const &v) {
83 for (
int i = 0; i < DIM; i++)
85 return std::sqrt(sum);
90 for (
int i = 0; i < DIM; i++)
96 for (
int i = 0; i < DIM; i++)
97 v1[i] = std::min(v1[i], v2[i]);
102 for (
int i = 0; i < DIM; i++)
103 v1[i] = std::max(v1[i], v2[i]);
109 for (
int i = 0; i < DIM; i++)
110 sum += v1[i] * v2[i];
115 return {v1[1] * v2[2] - v1[2] * v2[1],
116 v1[2] * v2[0] - v1[0] * v2[2],
117 v1[0] * v2[1] - v1[1] * v2[0]};
124 using value_type = float;
125 static const size_t size_ = DIM;
126 static size_t size() {
return size_; }
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:59
Base class for all traits.
Definition Traits.hh:122
Helper class providing information about a vector type.
Definition vector_traits.hh:89
static size_t size()
size/dimension of the vector
Definition vector_traits.hh:100
Definition unittests_common.hh:17
A Vector class with the absolute minimum of built-in methods to test the interface expected from Vect...
Definition unittests_common_customtraits.hh:11