Atoms Crowd
7.0.0
Edge.h
1
#pragma once
2
// ===========================================================================
3
// Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4
//
5
// Use of this software is subject to the terms of the Toolchefs license
6
// agreement provided at the time of installation or download, or which
7
// otherwise accompanies this software in either electronic or hard copy form.
8
// ===========================================================================
9
10
11
#include <AtomsUtils/Globals.h>
12
#include <AtomsUtils/AtomsMath.h>
13
#include <vector>
14
15
16
namespace
AtomsUtils
17
{
18
20
template
<
class
T>
class
Edge
21
{
22
public
:
24
Edge
();
25
27
32
Edge
(
const
T & v0,
const
T & v1,
unsigned
int
id
= 0);
33
34
Edge
(
const
T& v0,
const
T& v1,
const
unsigned
int
p0Id
,
const
unsigned
int
p1Id
);
35
37
~Edge
();
38
40
bool
operator==
(
const
Edge<T>
& other)
const
;
41
42
public
:
44
T
p0
;
45
47
T
p1
;
48
50
unsigned
int
id
;
51
53
unsigned
int
p0Id
;
54
56
unsigned
int
p1Id
;
57
58
};
59
60
//--------------------
61
// Convenient typedefs
62
//--------------------
63
typedef
Edge<AtomsMath::Vector2f>
Edge2
;
64
typedef
Edge<AtomsMath::Vector3f>
Edge3
;
65
66
//---------------
67
// Implementation
68
//---------------
69
70
template
<
class
T>
Edge<T>::Edge
() :
71
p0(T(0.0, 0.0, 0.0)),
72
p1(T(0.0, 0.0, 0.0)),
73
id(0),
74
p0Id(0),
75
p1Id(0)
76
{}
77
78
template
<
class
T>
Edge<T>::Edge
(
const
T & p0,
const
T & p1,
unsigned
int
id
) :
79
p0(p0),
80
p1(p1),
81
id(id),
82
p0Id(0),
83
p1Id(0)
84
{}
85
86
template
<
class
T>
Edge<T>::Edge
(
const
T& p0,
const
T& p1,
const
unsigned
int
p0Id,
const
unsigned
int
p1Id) :
87
Edge
(p0, p1)
88
{
89
this->p0Id =
p0Id
;
90
this->p1Id =
p1Id
;
91
}
92
93
template
<
class
T>
Edge<T>::~Edge
() {}
94
95
template
<
class
T>
bool
Edge<T>::operator==
(
const
Edge<T>
& other)
const
96
{
97
return
((other.
p0
== p0 && other.
p1
== p1) || (other.
p0
== p1 && other.
p1
== p0));
98
}
99
100
101
template
<
class
T> std::ostream & operator<<(std::ostream & os,
const
Edge<T>
& e)
102
{
103
os <<
"p0: ["
<< e.
p0
<<
" ] p1: ["
<< e.
p1
<<
"]"
;
104
return
os;
105
}
106
107
}
AtomsUtils::Edge
Edge class.
Definition:
Edge.h:21
AtomsUtils::Edge::id
unsigned int id
Edge id.
Definition:
Edge.h:50
AtomsUtils::Edge::Edge
Edge()
Constructor.
Definition:
Edge.h:70
AtomsUtils::Edge::operator==
bool operator==(const Edge< T > &other) const
Equality operator.
Definition:
Edge.h:95
AtomsUtils::Edge::p0
T p0
Vertex 0.
Definition:
Edge.h:44
AtomsUtils::Edge::p1
T p1
Vertex 1.
Definition:
Edge.h:47
AtomsUtils::Edge::~Edge
~Edge()
Destructor.
Definition:
Edge.h:93
AtomsUtils::Edge::p1Id
unsigned int p1Id
Vertex 1 id.
Definition:
Edge.h:56
AtomsUtils::Edge::p0Id
unsigned int p0Id
Vertex 0 id.
Definition:
Edge.h:53
AtomsUtils
AtomsCore namespace.
Definition:
Base64.h:13
Atoms
Public
AtomsUtils
Edge.h