Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
mesh
ngh
src
point.cpp
Go to the documentation of this file.
1
#include <iostream>
2
3
#include "
system/exc_common.hh
"
4
#include "
mesh/ngh/include/point.h
"
5
#include "
mesh/ngh/include/mathfce.h
"
6
7
using namespace
mathfce;
8
9
int
TPoint::numberInstance
= 0;
10
11
int
TPoint::generateId
() {
12
return
TPoint::numberInstance
++;
13
}
14
15
TPoint::TPoint
() {
16
x = 0;
17
y = 0;
18
z = 0;
19
20
id
= generateId();
21
}
22
23
TPoint::TPoint
(
double
x,
double
y,
double
z) {
24
this->x = x;
25
this->y = y;
26
this->z = z;
27
28
id
= generateId();
29
}
30
31
TPoint::TPoint
(
const
TPoint
&
point
) {
32
x = point.
X
();
33
y = point.
Y
();
34
z = point.
Z
();
35
36
id
= generateId();
37
}
38
39
TPoint::~TPoint
() {
40
}
41
42
TPoint
&
TPoint::operator =
(
const
TPoint
& P) {
43
x = P.
x
;
44
y = P.
y
;
45
z = P.
z
;
46
47
return
*
this
;
48
}
49
/*
50
bool TPoint::operator ==(TPoint* P) const {
51
if (IsEqual(x, P->x) && IsEqual(y, P->y) && IsEqual(z, P->z)) {
52
return true;
53
}
54
return false;
55
}
56
*/
57
bool
TPoint::operator ==
(
const
TPoint
& P)
const
{
58
if
(
IsEqual
(x, P.
x
) &&
IsEqual
(y, P.
y
) &&
IsEqual
(z, P.
z
)) {
59
return
true
;
60
}
61
return
false
;
62
}
63
64
TPoint
&
TPoint::operator =
(
const
TVector
& U) {
65
x = U.
X1
();
66
y = U.
X2
();
67
z = U.
X3
();
68
69
return
*
this
;
70
}
71
72
TVector
TPoint::operator -
(
const
TPoint
& P)
const
{
73
return
TVector
( x - P.
x
, y - P.
y
, z - P.
z
);
74
}
75
76
/*
77
TPoint* TPoint::operator +(TPoint* P) const {
78
TPoint* res = new TPoint();
79
80
res->x = x + P->x;
81
res->y = y + P->y;
82
res->z = z + P->z;
83
84
return res;
85
}
86
*/
87
88
TPoint
TPoint::operator +
(
const
TPoint
& P)
const
{
89
TPoint
res;
90
91
res.
x
= x + P.
x
;
92
res.
y
= y + P.
y
;
93
res.
z
= z + P.
z
;
94
95
return
res;
96
}
97
98
void
TPoint::SetCoord
(
double
x,
double
y,
double
z) {
99
this->x = x;
100
this->y = y;
101
this->z = z;
102
}
103
104
void
TPoint::SetCoord
(
const
TVector
& U) {
105
x = U.
X1
();
106
y = U.
X2
();
107
z = U.
X3
();
108
}
109
110
double
TPoint::X
()
const
{
111
return
x;
112
}
113
114
double
TPoint::Y
()
const
{
115
return
y;
116
}
117
118
double
TPoint::Z
()
const
{
119
return
z;
120
}
121
122
double
TPoint::Get
(
int
i)
const
{
123
if
(!(i >= 1 && i <= 3)) {
124
THROW
( ExcAssertMsg() << EI_Message(
"Invalid specification of the element of the vector."
) );
125
}
126
127
switch
(i) {
128
case
1:
return
x;
129
case
2:
return
y;
130
case
3:
return
z;
131
}
132
133
return
0.0;
134
}
135
136
std::ostream &
operator <<
(std::ostream& stream,
const
TPoint
& P) {
137
stream <<
"["
<< P.
x
<<
" "
<< P.
y
<<
" "
<< P.
z
<<
"]"
;
138
return
stream;
139
}
Generated on Thu May 29 2014 23:14:49 for Flow123d by
1.8.4