VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbPolygon3D.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
34#ifndef GBPOLYGON3D_H
35#define GBPOLYGON3D_H
36
37#include <iostream>
38#include <sstream>
39
40#include <GbLine3D.h>
41#include <GbObject3D.h>
42#include <GbSystem3D.h>
43#include <GbTriangle3D.h>
44
45#include <PointerDefinitions.h>
46
47/*=========================================================================*/
49/* */
51
52class GbPolygon3D : public GbObject3D
53{
54public:
55 using GbObject3D::isPointInGbObject3D; // Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht
56 // ausprogrammieren, welche sonst hier "ueberdeckt" waere
57private:
58 /*======================================================================*/
59 double x1s;
60 double x2s;
61 double x3s;
62 double x1min;
63 double x1max;
64 double x2min;
65 double x2max;
66 double x3min;
67 double x3max;
68
69 std::vector<GbPoint3D> points;
70 bool consistent;
71
73 // private PointObserver po = null;
74
75 void init();
76
77 /*======================================================================*/
78
79 /*======================================================================*/
80 /* Construcrors */
81 /* */
82 /*
83 * Creates an empty 2D polygon.
84 */
85public:
86 static int counter;
88 /*
89 * Creates an empty 2D polygon with the specified capacity.
90 * @param capacity the initial capacity
91 */
93 /*
94 * Creates a 2D polygon with the specified points.
95 * @param points the initial points of the polygon
96 */
97 GbPolygon3D(std::vector<GbPoint3D> &points);
98 /*
99 * Creates a 2D polygon as clone of the specified 2D polygon.
100 * @param polygon the 2D polygon to be cloned
101 */
103
104 ~GbPolygon3D() override;
105
106 /*======================================================================*/
107
108 /*======================================================================*/
109 /* Methoden */
110 /* */
111 /*
112 * Creates a 2D polygon as clone of this 2D polygon.
113 */
114 GbPolygon3D *clone() override { return (new GbPolygon3D(this)); }
115 void finalize() override { throw UbException(UB_EXARGS, "toDo"); }
116
117 /*
118 * Returns the number of points.
119 * @return the number of points
120 */
121 int size();
122 /*
123 * Returns the number of times this 2D polygon contains the specified point.
124 * @param point the point
125 * @return the number of times this 2D polygon contains the specified point
126 */
128 /*
129 * Returns the number of times this 2D polygon contains a point equal to the specified point.
130 * @param point the point
131 * @return the number of times this 2D polygon contains a point equal to the specified point
132 */
134 /*
135 * Returns true, if this 2D polygon contains the specified line.
136 * @param point1 the first point
137 * @param point2 the second point
138 * @return true, if this 2D polygon contains the specified line
139 */
141 /*
142 * Returns true, if this 2D polygon contains the specified line.
143 * @param line the line
144 * @return true, if this 2D polygon contains the specified line
145 */
146 bool containsLine(GbLine3D *line);
147 /*
148 * Returns the first point.
149 * @return the first point
150 */
152 /*
153 * Returns the last point.
154 * @return the last point
155 */
157 /*
158 * Returns the specified point.
159 * @param index the index
160 * @return the specified point
161 * @exception ArrayIndexOutOfBoundsException if the specified index is not valid
162 */
163 GbPoint3D *getPoint(const int &index);
164 /*
165 * Returns the points.
166 * @return the points
167 */
168 std::vector<GbPoint3D> getPoints();
169 /*
170 * Returns the points within the specified rectangle.
171 * @param p1 the 1st point of the rectangle
172 * @param p2 the 2nd point of the rectangle
173 * @return the points within the specified rectangle
174 */
175 std::vector<GbPoint3D> getPoints(GbPoint3D *p1, GbPoint3D *p2);
176 /*
177 * Returns the points within the specified rectangle.
178 * @param p1x1 the 1st x1 coordinate of the rectangle
179 * @param p1x2 the 1st x2 coordinate of the rectangle
180 * @param p2x1 the 2nd x1 coordinate of the rectangle
181 * @param p2x2 the 2nd x2 coordinate of the rectangle
182 * @return the points within the specified rectangle
183 */
184 std::vector<GbPoint3D> getPoints(const double &p1x1, const double &p1x2, const double &p1x3, const double &p2x1,
185 const double &p2x2, const double &p2x3);
186 /*
187 * Returns the area of this polygon.
188 * The area is positive for positive ordered points, otherwise negative.
189 * @return the area of this polygon
190 */
191 // double getArea()
192 //{
193 // if(!this.consistent) this.calculateValues();
194 // return(this.area);
195 //}
196 double getX1Centroid() override;
197 double getX1Minimum() override;
198 double getX1Maximum() override;
199 double getX2Centroid() override;
200 double getX2Minimum() override;
201 double getX2Maximum() override;
202 double getX3Centroid() override;
203 double getX3Minimum() override;
204 double getX3Maximum() override;
205
206 /*
207 * Adds a point to the end of this polygon. Notifies the observers of this 2D polygon.
208 * @param point the point
209 */
210 void addPoint(GbPoint3D *point);
211 /*
212 * Adds a number of points to the end of this polygon. Notifies the observers of this 2D polygon.
213 * @param points the points
214 */
215 void addPoints(std::vector<GbPoint3D> &points);
216 /*
217 * Removes all points from this polygon. Notifies the observers of this 2D polygon.
218 */
219 void clear();
220
221 /*
222 * Returns true if this 2D polygon equals the specified object.
223 * Two polygon are equal, if their points are equal.
224 * <BR>Note that the order of points is recognized!
225 * @return true if this 2D polygon equals the specified object
226 * @see GbPoint2D#equals(java.lang.Object)
227 * @see GbPoint3D#equals(java.lang.Object)
228 */
229 // bool equals(Object object)
230 // {
231 // try
232 // {
233 // GbPolygon2D polygon = (GbPolygon2D) object;
234 // int n = this.size();
235
236 // if(n != polygon.size()) return(false);
237 // for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false);
238 // return(true);
239 // }
240 // catch(Exception e){ return(false); }
241 // }
242 std::vector<GbTriangle3D *> getSurfaceTriangleSet() override
243 {
244 std::cout << "GbPolygon3D::getSurfaceTriangleSet() - not implemented\n";
245 std::vector<GbTriangle3D *> tmp;
246 return tmp;
247 }
248 bool isPointInGbObject3D(const double & /*x1*/, const double & /*x2*/, const double & /*x3*/) override
249 {
250 throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
251 }
252 bool isPointInGbObject3D(const double & /*x1*/, const double & /*x2*/, const double & /*x3*/,
253 bool & /*pointIsOnBoundary*/) override
254 {
255 throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
256 }
257 bool isCellInsideGbObject3D(const double & /*x1a*/, const double & /*x2a*/, const double & /*x3a*/,
258 const double & /*x1b*/, const double & /*x2b*/, const double & /*x3b*/) override
259 {
260 return false;
261 }
262
263 GbLine3D *createClippedLine3D(GbPoint3D & /*point1*/, GbPoint3D & /*point2*/) override
264 {
265 throw UbException(__FILE__, __LINE__, "GbPolygon3D::createClippedLine3D - not implemented");
266 }
267
268 /*
269 * Returns a string representation of this 2D polygon.
270 * @return a string representation of this 2D polygon
271 */
272 std::string toString() override;
273
274 /*======================================================================*/
275 /* Private Methoden */
276 /* */
277 void calculateValues();
278 /*======================================================================*/
279};
280/*=========================================================================*/
281#endif
282
This Class provides basic 3D line objects.
Definition GbLine3D.h:59
This Interface provides basic 3D geometry objects methods.
Definition GbObject3D.h:64
This Class provides basic 3D point objects.
Definition GbPoint3D.h:49
This Class provides basic 3D polygon objects.
Definition GbPolygon3D.h:53
bool isPointInGbObject3D(const double &, const double &, const double &) override
bool isCellInsideGbObject3D(const double &, const double &, const double &, const double &, const double &, const double &) override
GbLine3D * createClippedLine3D(GbPoint3D &, GbPoint3D &) override
GbPolygon3D(std::vector< GbPoint3D > &points)
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
void finalize() override
GbPolygon3D * clone() override
bool isPointInGbObject3D(const double &, const double &, const double &, bool &) override
std::shared_ptr< T > SPtr
int contains(GbPoint3D *point)
GbPoint3D * getFirstPoint()
double getX2Minimum() override
void addPoint(GbPoint3D *point)
void addPoints(std::vector< GbPoint3D > &points)
std::vector< GbPoint3D > getPoints()
double getX1Maximum() override
GbPoint3D * getPoint(const int &index)
double getX3Maximum() override
static int counter
Definition GbPolygon3D.h:86
double getX2Centroid() override
GbPoint3D * getLastPoint()
void calculateValues()
virtual bool isPointInGbObject3D(GbPoint3D *p)
double getX3Centroid() override
int containsEqual(GbPoint3D *point)
double getX3Minimum() override
double getX2Maximum() override
double getX1Centroid() override
bool containsLine(GbPoint3D *point1, GbPoint3D *point2)
std::string toString() override
~GbPolygon3D() override
double getX1Minimum() override
#define UB_EXARGS
Definition UbException.h:73