Debian Codegraph @

src/math/aslDistanceFunction.h

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #ifndef ASLDISTANCEFUNCTION_H
25 #define ASLDISTANCEFUNCTION_H
26
27 #include <acl/aclMath/aclVectorOfElementsDef.h>
28 #include <aslUtilities.h>
29
30 namespace acl
31 {
32 class KernelConfiguration;
33 }
34
35 namespace asl {
36
37 template <typename T> class AVec;
38 class Block;
39
40 class AbstractDataWithGhostNodes;
41 typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes;
42
43 /// Abstract class allows to add in kernel distance function from a boundary of a geometrical object
44 ///\ingroup LevelSet
45 /**
46 The class ...
47 */
48 class DistanceFunction
49 {
50 protected:
51 DistanceFunction();
52 public:
53 virtual ~DistanceFunction();
54 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos)=0;
55 };
56
57 ///\ingroup LevelSet
58 typedef std::shared_ptr<DistanceFunction> SPDistanceFunction;
59
60 ///\ingroup LevelSet
61 class DistFBinaryOperation: public DistanceFunction
62 {
63 protected:
64 SPDistanceFunction e1;
65 SPDistanceFunction e2;
66 public:
67 DistFBinaryOperation(SPDistanceFunction a, SPDistanceFunction b);
68 };
69
70 ///\ingroup LevelSet
71 class DistFUnaryOperation: public DistanceFunction
72 {
73 protected:
74 SPDistanceFunction e1;
75 public:
76 DistFUnaryOperation(SPDistanceFunction a);
77 };
78
79 ///\ingroup LevelSet
80 class DistFOperationAnd: public DistFBinaryOperation
81 {
82 public:
83 DistFOperationAnd(SPDistanceFunction a, SPDistanceFunction b);
84 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
85 };
86
87 ///\ingroup LevelSet
88 class DistFOperationOr: public DistFBinaryOperation
89 {
90 public:
91 DistFOperationOr(SPDistanceFunction a, SPDistanceFunction b);
92 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
93 };
94
95 ///\ingroup LevelSet
96 class DistFOperationInversion: public DistFUnaryOperation
97 {
98 public:
99 DistFOperationInversion(SPDistanceFunction a);
100 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
101 };
102
103
104 ///\ingroup LevelSet
105 class DistFSphere: public DistanceFunction
106 {
107 private:
108 acl::VectorOfElements radius;
109 acl::VectorOfElements center;
110 public:
111 DistFSphere(double r, const AVec<double> & c);
112 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
113 };
114
115 ///\ingroup LevelSet
116 /**
117 */
118 class DistFCylinder: public DistanceFunction
119 {
120 private:
121 acl::VectorOfElements radius;
122 acl::VectorOfElements orientation;
123 acl::VectorOfElements center;
124 public:
125 /**
126 \param r radius
127 \param l orientation vector no normalization needed
128 \param c center
129 */
130 DistFCylinder(double r, const AVec<double> & l, const AVec<double> & c);
131 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
132 };
133
134 ///\ingroup LevelSet
135 /**
136 */
137 class DistFCone: public DistanceFunction
138 {
139 private:
140 acl::VectorOfElements tanTheta;
141 acl::VectorOfElements orientation;
142 acl::VectorOfElements apex;
143 public:
144 /**
145 \param th theta, opening angle, 0.5*aperture
146 \param l orientation vector no normalization needed
147 \param a apex position
148 */
149 DistFCone(double th, const AVec<double> & l, const AVec<double> & a);
150 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
151 };
152
153 ///\ingroup LevelSet
154 /**
155 */
156 class DistFPlane: public DistanceFunction
157 {
158 private:
159 acl::VectorOfElements normal;
160 acl::VectorOfElements b;
161 public:
162 DistFPlane(AVec<double> n, AVec<double> p0);
163 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
164 };
165
166
167 /// normalize so that the values are in range [1:-1]
168 ///\ingroup LevelSet
169 class DistFNormalization: public DistFUnaryOperation
170 {
171 protected:
172 acl::VectorOfElements factor;
173 public:
174 static const double scaleFactor;
175 DistFNormalization(SPDistanceFunction a, double dx);
176 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
177 };
178
179 /// transforms discrete data object into continious one, DistanceFunction
180 ///\ingroup LevelSet
181 class DataInterpolation: public DistanceFunction
182 {
183 protected:
184 SPAbstractDataWithGhostNodes data;
185
186 public:
187 DataInterpolation(SPAbstractDataWithGhostNodes d);
188 virtual acl::VectorOfElements getDistance(const acl::VectorOfElements & pos);
189 };
190
191 } // asl
192
193 #endif // ASLDISTANCEFUNCTION