www.cemf.ir
infinitePlane.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __infinitePlane_hpp__
22 #define __infinitePlane_hpp__
23 
24 #include "types.hpp"
25 //#include "dictionary.hpp"
26 #include "iIstream.hpp"
27 #include "iOstream.hpp"
28 
29 namespace pFlow
30 {
31 
33 {
34 protected:
35 
37  realx3 normal_{1,0,0};
38 
40  real d_ = 0;
41 
42 public:
43 
44  // - type info
45  TypeInfoNV("infinitePlane");
46 
48 
52 
55  infinitePlane(const realx3& normal, const real& d)
56  :
57  normal_(normal),
58  d_(d)
59  {}
60 
62  infinitePlane(const realx3& normal, const realx3& p)
63  :
64  normal_(normal),
65  d_(-dot(normal,p))
66  {}
67 
69  infinitePlane(const realx3& p1, const realx3& p2, const realx3& p3);
70 
72  infinitePlane(const infinitePlane&) = default;
73 
75  infinitePlane(infinitePlane&&) = default;
76 
78  infinitePlane& operator=(const infinitePlane&) = default;
79 
82 
83  ~infinitePlane()=default;
84 
85  /*FUNCTION_H
86  infinitePlane(const dictionary& dict);
87 
88  FUNCTION_H
89  infinitePlane(iIstream& is);*/
90 
91 
93 
95  real pointFromPlane(const realx3& p)const
96  {
97  return dot(normal_, p) + d_;
98  }
99 
101  bool pointInPositiveSide(const realx3& p)const
102  {
103  return pointFromPlane(p)>=0;
104  }
105 
107  bool pointInNegativeSide(const realx3& p)const
108  {
109  return pointFromPlane(p)<0;
110  }
111 
113  bool inPositiveDistance(const realx3& p, real dist)const
114  {
115  real d = pointFromPlane(p);
116  return d >= 0.0 && d <= dist;
117  }
118 
120  bool inNegativeDistance(const realx3& p, real dist)const
121  {
122  real d = pointFromPlane(p);
123  return d < 0.0 && d >= -dist;
124  }
125 
127  bool pointOnPlane(const realx3& p)const
128  {
129  return equal(pointFromPlane(p),0.0);
130  }
131 
133  realx3 projectPoint(const realx3& p)const
134  {
135  real t = -(dot(normal_, p) + d_);
136  return t*normal_ + p;
137  }
138 
140  bool parallel(const infinitePlane& pln)const
141  {
142  return equal(normal_, pln.normal_) ||
143  equal(normal_,-pln.normal_);
144  }
145 
147  bool parallelTouch(const infinitePlane& pln)const
148  {
149  if(equal(normal_, pln.normal_) && equal(d_, pln.d_))return true;
150  if(equal(normal_,-pln.normal_) && equal(d_,-pln.d_))return true;
151  return false;
152  }
153 
155  const auto& normal()const
156  {
157  return normal_;
158  }
159 
161  const auto& d()const
162  {
163  return d_;
164  }
165 
167 
168  FUNCTION_H
169  bool write(iOstream& os)const;
170 
171  bool read(iIstream & is);
172 
173  /*FUNCTION_H
174  bool read(iIstream & is);
175 
176  FUNCTION_H
177  bool write(iOstream& os)const;
178 
179  FUNCTION_H
180  bool read(const dictionary& dict);
181 
182  FUNCTION_H
183  bool write(dictionary& dict)const;*/
184 
185  static bool validPlane3(
186  const realx3& p1,
187  const realx3& p2,
188  const realx3& p3);
189 };
190 
191 /*FUNCTION_H
192 iIstream& operator >>(iIstream& is, box& b);
193 
194 FUNCTION_H
195 iOstream& operator << (iOstream& os, const box& b);
196 
197 INLINE_FUNCTION_HD
198 box extendBox(const box& b, const realx3& dl)
199 {
200  return box(b.minPoint()-dl , b.maxPoint()+dl);
201 }*/
202 
203 }
204 
205 
206 #endif // __infinitePlane_hpp__
pFlow::infinitePlane::~infinitePlane
~infinitePlane()=default
pFlow::infinitePlane::normal_
realx3 normal_
normal vector
Definition: infinitePlane.hpp:37
pFlow::infinitePlane::pointFromPlane
INLINE_FUNCTION_HD real pointFromPlane(const realx3 &p) const
Definition: infinitePlane.hpp:95
pFlow::infinitePlane::infinitePlane
INLINE_FUNCTION_HD infinitePlane(const realx3 &normal, const realx3 &p)
Definition: infinitePlane.hpp:62
pFlow::infinitePlane::normal
const INLINE_FUNCTION_HD auto & normal() const
Definition: infinitePlane.hpp:155
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::infinitePlane::pointInNegativeSide
INLINE_FUNCTION_HD bool pointInNegativeSide(const realx3 &p) const
Definition: infinitePlane.hpp:107
pFlow::infinitePlane::pointOnPlane
INLINE_FUNCTION_HD bool pointOnPlane(const realx3 &p) const
Definition: infinitePlane.hpp:127
iIstream.hpp
types.hpp
pFlow::infinitePlane
Definition: infinitePlane.hpp:32
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::infinitePlane::read
bool read(iIstream &is)
Definition: infinitePlane.cpp:49
pFlow::infinitePlane::write
FUNCTION_H bool write(iOstream &os) const
Definition: infinitePlane.cpp:42
pFlow::infinitePlane::operator=
FUNCTION_HD infinitePlane & operator=(const infinitePlane &)=default
pFlow::infinitePlane::parallelTouch
INLINE_FUNCTION_HD bool parallelTouch(const infinitePlane &pln) const
Definition: infinitePlane.hpp:147
pFlow::infinitePlane::infinitePlane
INLINE_FUNCTION_HD infinitePlane()
Default.
Definition: infinitePlane.hpp:51
pFlow
Definition: demGeometry.hpp:27
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::infinitePlane::projectPoint
INLINE_FUNCTION_HD realx3 projectPoint(const realx3 &p) const
Definition: infinitePlane.hpp:133
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:61
pFlow::infinitePlane::parallel
INLINE_FUNCTION_HD bool parallel(const infinitePlane &pln) const
Definition: infinitePlane.hpp:140
pFlow::infinitePlane::d
const INLINE_FUNCTION_HD auto & d() const
Definition: infinitePlane.hpp:161
pFlow::infinitePlane::validPlane3
static bool validPlane3(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: infinitePlane.cpp:57
pFlow::infinitePlane::inPositiveDistance
INLINE_FUNCTION_HD bool inPositiveDistance(const realx3 &p, real dist) const
Definition: infinitePlane.hpp:113
pFlow::infinitePlane::infinitePlane
INLINE_FUNCTION_HD infinitePlane(const realx3 &normal, const real &d)
From components.
Definition: infinitePlane.hpp:55
pFlow::infinitePlane::inNegativeDistance
INLINE_FUNCTION_HD bool inNegativeDistance(const realx3 &p, real dist) const
Definition: infinitePlane.hpp:120
pFlow::infinitePlane::d_
real d_
distance value
Definition: infinitePlane.hpp:40
pFlow::infinitePlane::pointInPositiveSide
INLINE_FUNCTION_HD bool pointInPositiveSide(const realx3 &p) const
Definition: infinitePlane.hpp:101
iOstream.hpp
pFlow::infinitePlane::TypeInfoNV
TypeInfoNV("infinitePlane")
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59