Blender V5.3
BLI_ordered_edge.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12
13namespace blender {
14
20 int v_low;
21 int v_high;
22
23 OrderedEdge(const int v1, const int v2)
24 {
25 if (v1 < v2) {
26 v_low = v1;
27 v_high = v2;
28 }
29 else {
30 v_low = v2;
31 v_high = v1;
32 }
33 }
34 OrderedEdge(const int2 edge) : OrderedEdge(edge[0], edge[1]) {}
35 OrderedEdge(const uint v1, const uint v2) : OrderedEdge(int(v1), int(v2)) {}
36
37 operator int2() const
38 {
39 return int2(v_low, v_high);
40 }
41
42 uint64_t hash() const
43 {
44 return (this->v_low << 8) ^ this->v_high;
45 }
46
47 friend bool operator==(const OrderedEdge &e1, const OrderedEdge &e2)
48 {
49 return e1.v_low == e2.v_low && e1.v_high == e2.v_high;
50 }
51
52 friend bool operator!=(const OrderedEdge &e1, const OrderedEdge &e2)
53 {
54 return !(e1 == e2);
55 }
56
57 friend bool operator<(const OrderedEdge &e1, const OrderedEdge &e2)
58 {
59 if (e1.v_low != e2.v_low) {
60 return e1.v_low < e2.v_low;
61 }
62 return e1.v_high < e2.v_high;
63 }
64
65 friend std::ostream &operator<<(std::ostream &stream, const OrderedEdge &e);
66};
67
68} // namespace blender
std::ostream & operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append)
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
unsigned int uint
Definition BKE_text.h:55
VecBase< int32_t, 2 > int2
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
friend bool operator!=(const OrderedEdge &e1, const OrderedEdge &e2)
uint64_t hash() const
OrderedEdge(const int v1, const int v2)
OrderedEdge(const int2 edge)
friend bool operator==(const OrderedEdge &e1, const OrderedEdge &e2)
OrderedEdge(const uint v1, const uint v2)
friend bool operator<(const OrderedEdge &e1, const OrderedEdge &e2)