preCICE v3.1.2
Loading...
Searching...
No Matches
Edge.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <array>
5#include <iostream>
6
8#include "mesh/Vertex.hpp"
10#include "utils/assertion.hpp"
11
12namespace precice {
13namespace mesh {
14
16class Edge {
17public:
19 static constexpr int vertexCount{2};
20
27 Edge(
28 Vertex &vertexOne,
29 Vertex &vertexTwo);
30
32 int getDimensions() const;
33
35 Vertex &vertex(int i);
36
38 const Vertex &vertex(int i) const;
39
41 double getLength() const;
42
44 const Eigen::VectorXd getCenter() const;
45
47 double getEnclosingRadius() const;
48
50 bool connectedTo(const Edge &other) const;
51
58 bool operator==(const Edge &other) const;
59
61 bool operator!=(const Edge &other) const;
62
64 bool operator<(const Edge &other) const
65 {
66 return std::make_tuple(_vertices[0]->getID(), _vertices[1]->getID()) <
67 std::make_tuple(other._vertices[0]->getID(), other._vertices[1]->getID());
68 }
69
70private:
73};
74
75// ------------------------------------------------------ HEADER IMPLEMENTATION
76
78 int i)
79{
80 PRECICE_ASSERT((i == 0) || (i == 1), i);
81 return *_vertices[i];
82}
83
84inline const Vertex &Edge::vertex(
85 int i) const
86{
87 PRECICE_ASSERT((i == 0) || (i == 1), i);
88 return *_vertices[i];
89}
90
91inline int Edge::getDimensions() const
92{
93 return _vertices[0]->getDimensions();
94}
95
96std::ostream &operator<<(std::ostream &stream, const Edge &edge);
97
98} // namespace mesh
99} // namespace precice
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
Linear edge of a mesh, defined by two Vertex objects.
Definition Edge.hpp:16
double getEnclosingRadius() const
Returns the radius of the enclosing circle of the edge.
Definition Edge.cpp:34
bool operator!=(const Edge &other) const
Not equal, implemented in terms of equal.
Definition Edge.cpp:49
double getLength() const
Returns the length of the edge.
Definition Edge.cpp:23
int getDimensions() const
Returns number of spatial dimensions (2 or 3) the edge is embedded to.
Definition Edge.hpp:91
static constexpr int vertexCount
Amount of vertices.
Definition Edge.hpp:19
Edge(Vertex &vertexOne, Vertex &vertexTwo)
Constructor.
Definition Edge.cpp:11
const Eigen::VectorXd getCenter() const
Returns the center of the edge.
Definition Edge.cpp:29
bool operator==(const Edge &other) const
Compares two Edges for equality.
Definition Edge.cpp:44
Vertex & vertex(int i)
Returns the edge's vertex with index 0 or 1.
Definition Edge.hpp:77
std::array< Vertex *, 2 > _vertices
Pointers to Vertex objects defining the edge, ordered by Vertex::getID().
Definition Edge.hpp:72
bool operator<(const Edge &other) const
Weak ordering based on vertex ids.
Definition Edge.hpp:64
bool connectedTo(const Edge &other) const
Checks whether both edges share a vertex.
Definition Edge.cpp:39
Vertex of a mesh.
Definition Vertex.hpp:16
T make_tuple(T... args)
std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)
Main namespace of the precice library.