Loading...
Searching...
No Matches
vertex.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_VERTEX_HPP__
26#define __BITPIT_VERTEX_HPP__
27
28#include <array>
29#include <memory>
30
31#include "bitpit_common.hpp"
32#include "bitpit_containers.hpp"
33
34namespace bitpit {
35
36class Vertex;
37class PatchKernel;
38
39OBinaryStream& operator<< (OBinaryStream &out, const Vertex &vertex);
40IBinaryStream& operator>> (IBinaryStream &in, Vertex &vertex);
41
42class Vertex {
43
44friend class PatchKernel;
45
46friend OBinaryStream& (operator<<) (OBinaryStream&, const Vertex &);
47friend IBinaryStream& (operator>>) (IBinaryStream&, Vertex &);
48
49public:
50 enum Coordinate {
51 COORD_X =0,
52 COORD_Y,
53 COORD_Z,
54 };
55
59 struct Less {
60
61 Less(double tolerance)
62 : m_tolerance(tolerance)
63 {
64 }
65
66 bool operator()(const Vertex &vertex_1, const Vertex &vertex_2) const
67 {
68 return operator()(vertex_1.getCoords(), vertex_2.getCoords());
69 }
70
71 bool operator()(const Vertex *vertex_1, const Vertex *vertex_2) const
72 {
73 return operator()(vertex_1->getCoords(), vertex_2->getCoords());
74 }
75
76 bool operator()(const std::array<double, 3> &coords_1, const std::array<double, 3> &coords_2) const
77 {
78 for (int d = 0; d < 3; ++d) {
79 if (utils::DoubleFloatingEqual()(coords_1[d], coords_2[d], m_tolerance)) {
80 continue;
81 }
82
83 return coords_1[d] < coords_2[d];
84 }
85
86 return false;
87 }
88
89 private:
90 double m_tolerance;
91
92 };
93
94 Vertex();
95 Vertex(long id, bool interior = true);
96 Vertex(long id, const std::array<double, 3> &coords, bool interior = true);
97
98 void swap(Vertex &other) noexcept;
99
100 void initialize(long id, const std::array<double, 3> &coords, bool interior);
101
102 bool isInterior() const;
103
104 bool operator==(const Vertex &other) const;
105
106 double & operator[](int coord_id);
107 const double & operator[](int coord_id) const;
108
109 void setId(long id);
110 long getId() const;
111
112 void setCoords(const std::array<double, 3> &coords);
113 std::array<double, 3> & getCoords();
114 const std::array<double, 3> & getCoords() const;
115
116 void translate(const std::array<double, 3> &translation);
117 void translate(double sx, double sy, double sz);
118 void rotate(const std::array<double, 3> &n0, const std::array<double, 3> &n1, double angle);
119 void rotate(double n0x, double n0y, double n0z, double n1x, double n1y, double n1z, double angle);
120 void scale(const std::array<double, 3> &scaling, const std::array<double, 3> &center);
121 void scale(double sx, double sy, double sz, double cx, double cy, double cz);
122
123 BITPIT_PUBLIC_API static const long NULL_ID;
124
125 unsigned int getBinarySize() const;
126
127 void display(std::ostream &out, unsigned short int indent) const;
128
129protected:
130 void setInterior(bool interior);
131
132private:
133 std::array<double, 3> m_coords;
134 long m_id;
135 bool m_interior;
136
137 void _initialize(long id, const std::array<double, 3> &coords, bool interior);
138
139};
140
141extern template class PiercedVector<Vertex>;
142
143}
144
145#endif
Output binary stream.
Output binary stream.
The PatchKernel class provides an interface for defining patches.
Metafunction for generating a pierced vector.
The Vertex class defines the vertexs.
Definition vertex.hpp:42
bool operator==(const Vertex &other) const
Definition vertex.cpp:178
void setCoords(const std::array< double, 3 > &coords)
Definition vertex.cpp:236
void translate(const std::array< double, 3 > &translation)
Definition vertex.cpp:266
void display(std::ostream &out, unsigned short int indent) const
Definition vertex.cpp:351
unsigned int getBinarySize() const
Definition vertex.cpp:370
long getId() const
Definition vertex.cpp:226
void initialize(long id, const std::array< double, 3 > &coords, bool interior)
Definition vertex.cpp:131
void swap(Vertex &other) noexcept
Definition vertex.cpp:117
void scale(const std::array< double, 3 > &scaling, const std::array< double, 3 > &center)
Definition vertex.cpp:321
void setInterior(bool interior)
Definition vertex.cpp:155
void rotate(const std::array< double, 3 > &n0, const std::array< double, 3 > &n1, double angle)
Definition vertex.cpp:293
void setId(long id)
Definition vertex.cpp:216
std::array< double, 3 > & getCoords()
Definition vertex.cpp:246
bool isInterior() const
Definition vertex.cpp:166
double & operator[](int coord_id)
Definition vertex.cpp:195
std::ostream & operator<<(std::ostream &, const std::vector< T > &)
--- layout: doxygen_footer ---