hpp-constraints
9.0.2
Definition of basic geometric constraints for motion planning
Toggle main menu visibility
Loading...
Searching...
No Matches
comparison-types.hh
Go to the documentation of this file.
1
// Copyright (c) 2020 CNRS, Airbus SAS
2
// Author: Florent Lamiraux
3
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr), Florent Lamiraux
4
//
5
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are
8
// met:
9
//
10
// 1. Redistributions of source code must retain the above copyright
11
// notice, this list of conditions and the following disclaimer.
12
//
13
// 2. Redistributions in binary form must reproduce the above copyright
14
// notice, this list of conditions and the following disclaimer in the
15
// documentation and/or other materials provided with the distribution.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28
// DAMAGE.
29
30
#ifndef HPP_CONSTRAINTS_COMOARISON_TYPES_HH
31
#define HPP_CONSTRAINTS_COMOARISON_TYPES_HH
32
33
#include <
hpp/constraints/fwd.hh
>
34
#include <iostream>
35
#include <vector>
36
37
namespace
hpp
{
38
namespace
constraints
{
39
namespace
internal
{
41
struct
ReplicateCompType {
42
ComparisonType
type;
43
std::size_t n;
44
45
void
push_to(
ComparisonTypes_t
& v)
const
{
46
for
(std::size_t i = 0; i < n; ++i) v.push_back(type);
47
}
48
// Cast to ComparisonTypes_t
49
operator
ComparisonTypes_t
()
const
{
return
ComparisonTypes_t
(n, type); }
50
};
// struct ReplicateCompType
52
}
// namespace internal
53
inline
internal::ReplicateCompType
operator*
(
const
int
& n,
54
const
ComparisonType
& c) {
55
internal::ReplicateCompType cts;
56
cts.type = c;
57
cts.n = (std::size_t)n;
58
return
cts;
59
}
60
61
inline
ComparisonTypes_t
operator<<
(
const
ComparisonType
& a,
62
const
ComparisonType
& b) {
63
ComparisonTypes_t
v(2);
64
v[0] = a;
65
v[1] = b;
66
return
v;
67
}
68
69
inline
ComparisonTypes_t
operator<<
(
const
internal::ReplicateCompType& a,
70
const
ComparisonType
& b) {
71
ComparisonTypes_t
v;
72
v.reserve(a.n + 1);
73
a.push_to(v);
74
v.push_back(b);
75
return
v;
76
}
77
78
inline
ComparisonTypes_t
operator<<
(
const
ComparisonType
& a,
79
const
internal::ReplicateCompType& b) {
80
ComparisonTypes_t
v;
81
v.reserve(b.n + 1);
82
v.push_back(a);
83
b.push_to(v);
84
return
v;
85
}
86
87
inline
ComparisonTypes_t
&
operator<<
(
ComparisonTypes_t
& v,
88
const
ComparisonType
& c) {
89
v.push_back(c);
90
return
v;
91
}
92
93
inline
ComparisonTypes_t
&
operator<<
(
ComparisonTypes_t
& v,
94
const
internal::ReplicateCompType& c) {
95
for
(std::size_t i = 0; i < c.n; ++i) v.push_back(c.type);
96
return
v;
97
}
98
99
inline
ComparisonTypes_t
operator<<
(
const
ComparisonTypes_t
& v,
100
const
ComparisonType
& c) {
101
ComparisonTypes_t
vv;
102
vv.reserve(v.size() + 1);
103
vv.insert(vv.end(), v.begin(), v.end());
104
vv.push_back(c);
105
return
vv;
106
}
107
108
inline
ComparisonTypes_t
operator<<
(
const
ComparisonTypes_t
& v,
109
const
internal::ReplicateCompType& c) {
110
ComparisonTypes_t
vv;
111
vv.reserve(v.size() + c.n);
112
vv.insert(vv.end(), v.begin(), v.end());
113
for
(std::size_t i = 0; i < c.n; ++i) vv.push_back(c.type);
114
return
vv;
115
}
116
117
inline
bool
operator==
(
const
ComparisonTypes_t
& v,
118
const
internal::ReplicateCompType& r) {
119
if
(v.size() != r.n)
return
false
;
120
for
(std::size_t i = 0; i < v.size(); ++i) {
121
if
(v[i] != r.type)
return
false
;
122
}
123
return
true
;
124
}
125
126
inline
std::ostream&
operator<<
(std::ostream& os,
127
const
ComparisonTypes_t
& comp) {
128
os <<
"("
;
129
for
(ComparisonTypes_t::const_iterator it = comp.begin(); it != comp.end();
130
++it) {
131
if
(*it ==
Equality
) {
132
os <<
"Equality"
;
133
}
else
if
(*it ==
EqualToZero
) {
134
os <<
"EqualToZero"
;
135
}
else
if
(*it ==
Superior
) {
136
os <<
"Superior"
;
137
}
else
if
(*it ==
Inferior
) {
138
os <<
"Inferior"
;
139
}
else
{
140
assert(
"false && ComparisonType out of range."
);
141
}
142
if
(it + 1 != comp.end()) os <<
", "
;
143
}
144
os <<
")"
;
145
return
os;
146
}
147
}
// namespace constraints
148
}
// namespace hpp
149
150
inline
hpp::constraints::ComparisonTypes_t
operator<<
(
151
hpp::constraints::internal::ReplicateCompType c1,
152
hpp::constraints::internal::ReplicateCompType c2) {
153
hpp::constraints::ComparisonTypes_t
vv(c1);
154
for
(std::size_t i = 0; i < c2.n; ++i) vv.push_back(c2.type);
155
return
vv;
156
}
157
158
#endif
// HPP_CONSTRAINTS_COMOARISON_TYPES_HH
operator<<
hpp::constraints::ComparisonTypes_t operator<<(hpp::constraints::internal::ReplicateCompType c1, hpp::constraints::internal::ReplicateCompType c2)
Definition
comparison-types.hh:150
fwd.hh
hpp::constraints::internal
Definition
comparison-types.hh:39
hpp::constraints
Definition
active-set-differentiable-function.hh:37
hpp::constraints::ComparisonTypes_t
std::vector< ComparisonType > ComparisonTypes_t
Definition
fwd.hh:182
hpp::constraints::operator<<
ComparisonTypes_t operator<<(const ComparisonType &a, const ComparisonType &b)
Definition
comparison-types.hh:61
hpp::constraints::operator==
bool operator==(const ComparisonTypes_t &v, const internal::ReplicateCompType &r)
Definition
comparison-types.hh:117
hpp::constraints::operator*
internal::ReplicateCompType operator*(const int &n, const ComparisonType &c)
Definition
comparison-types.hh:53
hpp::constraints::ComparisonType
ComparisonType
Definition
fwd.hh:181
hpp::constraints::Inferior
@ Inferior
Definition
fwd.hh:181
hpp::constraints::Superior
@ Superior
Definition
fwd.hh:181
hpp::constraints::EqualToZero
@ EqualToZero
Definition
fwd.hh:181
hpp::constraints::Equality
@ Equality
Definition
fwd.hh:181
hpp
include
hpp
constraints
comparison-types.hh
Generated by
1.17.0