Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
mesh
ngh
src
bisector.cpp
Go to the documentation of this file.
1
#include <iostream>
2
3
#include "
system/global_defs.h
"
4
#include "
mesh/elements.h
"
5
6
#include "
mesh/ngh/include/bisector.h
"
7
#include "
mesh/ngh/include/mathfce.h
"
8
#include "
mesh/ngh/include/intersection.h
"
9
//#include "mesh/ngh/include/problem.h"
10
11
using namespace
mathfce;
12
13
int
TBisector::numberInstance
= 0;
14
15
int
TBisector::generateId
() {
16
return
TBisector::numberInstance
++;
17
}
18
19
TBisector::TBisector
() {
20
id
= generateId();
21
22
X0 =
new
TPoint
(0, 0, 0);
23
U =
new
TVector
(0, 0, 0);
24
}
25
26
TBisector::TBisector
(
const
TPoint
&XX0,
const
TVector
&UU) {
27
id
= generateId();
28
29
X0 =
new
TPoint
(XX0);
30
U =
new
TVector
(UU);
31
}
32
33
TBisector::TBisector
(
const
TPoint
&P0,
const
TPoint
&P1) {
34
id
= generateId();
35
36
X0 =
new
TPoint
(P0);
37
U =
new
TVector
(P0, P1);
38
}
39
40
TBisector::TBisector
(
const
Element
& ele) {
41
id
= generateId();
42
ASSERT_EQUAL
(ele.
dim
(), 1);
43
44
X0 =
new
TPoint
(ele.
node
[0]->
point
()(0), ele.
node
[0]->
point
()(1), ele.
node
[0]->
point
()(2));
45
U =
new
TVector
(*X0,
TPoint
(ele.
node
[1]->
point
()(0), ele.
node
[1]->
point
()(1), ele.
node
[1]->
point
()(2)) );
46
}
47
48
TBisector::TBisector
(
const
TBisector
&x)
49
{
50
id
= generateId();
51
52
X0 =
new
TPoint
(*(x.
X0
));
53
U =
new
TVector
(*(x.
U
));
54
}
55
56
TBisector::~TBisector
() {
57
delete
X0;
58
delete
U;
59
}
60
61
TBisector
&
TBisector::operator =
(
const
TBisector
&b) {
62
// U = new TVector();
63
// X0 = new TPoint();
64
*(*this).
U
= *b.
U
;
65
*(*this).X0 = *b.
X0
;
66
67
return
*
this
;
68
}
69
70
std::ostream &
operator <<
(std::ostream &stream,
const
TBisector
&b) {
71
stream <<
"U = ("
<< b.
U
->
X1
() <<
", "
<< b.
U
->
X2
() <<
", "
<< b.
U
->
X3
() <<
")\n"
;
72
stream <<
"X0 = ["
<< b.
X0
->
X
() <<
", "
<< b.
X0
->
Y
() <<
", "
<< b.
X0
->
Z
() <<
"]\n"
;
73
74
return
stream;
75
}
76
77
void
TBisector::SetPoint
(
const
TPoint
&P) {
78
*X0 = P;
79
}
80
81
void
TBisector::SetVector
(
const
TVector
&UU) {
82
*U = UU;
83
}
84
85
void
TBisector::SetPoints
(
const
TPoint
&P0,
const
TPoint
&P1) {
86
*X0 = P0;
87
*U = (
TPoint
) P1 - P0;
88
}
89
90
const
TVector
&
TBisector::GetVector
()
const
{
91
92
return
*(this->U);
93
}
94
95
const
TPoint
&
TBisector::GetPoint
()
const
96
{
97
return
*(this->X0);
98
}
99
100
TPoint
TBisector::GetPoint
(
double
t)
const
{
101
TPoint
tmp;
102
103
tmp.
SetCoord
(t * *U);
104
tmp = tmp + *X0;
105
106
return
tmp;
107
}
108
109
void
TBisector::GetParameter
(
const
TPoint
&P,
double
&t,
bool
&onBisector)
const
{
110
t = (P.
X
() - X0->X()) / U->X1();
111
onBisector = (fabs( (P.
Y
() - X0->Y()) / U->X2() - t ) <
epsilon
) & (fabs( (P.
Z
() - X0->Z()) / U->X3() - t ) <
epsilon
);
112
}
113
114
bool
TBisector::Belong
(
const
TPoint
&P)
const
{
115
if
(
IsZero
(
Distance
(*
this
, P))) {
116
return
true
;
117
}
else
{
118
return
false
;
119
}
120
}
Generated on Thu May 29 2014 23:14:49 for Flow123d by
1.8.4