VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbTriangle3D.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 GBTRIANGLE3D_H
35#define GBTRIANGLE3D_H
36
37#include <sstream>
38
39#include <GbObject3D.h>
40#include <GbPoint3D.h>
41#include <GbVector3D.h>
42
43#include <PointerDefinitions.h>
44
45class GbCuboid3D;
46class GbPolygon3D;
48
57
58class GbTriangle3D : public GbObject3D, public UbObserver
59{
60public:
61 /*======================================================================*/
62 /* Konstruktoren */
63 /* */
67 ~GbTriangle3D() override;
68 /*======================================================================*/
69 /* Methoden */
70 /* */
71 GbTriangle3D *clone() override;
72 void finalize() override { this->deletePoints(); }
73
74 GbPoint3D *getPoint1() { return this->points[0]; }
75 GbPoint3D *getPoint2() { return this->points[1]; }
76 GbPoint3D *getPoint3() { return this->points[2]; }
77
79 void calculateNormal();
80
81 void deletePoints();
82
85 GbPoint3D *getPoint(const int &index);
86 std::vector<GbPoint3D> getPoints();
87 double getArea();
88 double getX1Centroid() override;
89 double getX1Minimum() override;
90 double getX1Maximum() override;
91 double getX2Centroid() override;
92 double getX2Minimum() override;
93 double getX2Maximum() override;
94 double getX3Centroid() override;
95 double getX3Minimum() override;
96 double getX3Maximum() override;
97
98 void setInconsistent() { this->consistent = false; }
99
100 void setPoint(GbPoint3D *point, int index);
101
102 // bool equals(GbObject3D *object)
103 std::vector<GbTriangle3D *> getSurfaceTriangleSet() override;
104 bool isPointInGbObject3D(const double & /*x1*/, const double & /*x2*/, const double & /*x3*/) override
105 {
106 // der einfachheit halber ...
107 return false;
108 // throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
109 }
110 bool isPointInGbObject3D(const double & /*x1*/, const double & /*x2*/, const double & /*x3*/,
111 bool &pointIsOnBoundary) override
112 {
113 // der einfachheit halber ...
114 pointIsOnBoundary = false;
115 return false;
116 // throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
117 }
118 bool isCellInsideGbObject3D(const double & /*x11*/, const double & /*x21*/, const double & /*x31*/,
119 const double & /*x12*/, const double & /*x22*/, const double & /*x23*/) override
120 {
121 return false;
122 }
123
124 // get distance from a point to the triangle
125 // todo CHANGE...
127
128 std::string toString() override;
129
130 /*======================================================================*/
131 /* Calculation */
132 /* */
133 // std::vector<GbPoint3D> calculateIntersectionPoints3D(GbLine3D *line);
134 bool hasRaytracing() override { return true; }
135 /*|r| must be 1! einheitsvector!!*/
136 double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1,
137 const double &rx2, const double &rx3) override;
138 // bool isPointOnEdge(GbVector3D& q);
139
143 double calculateDistanceToPoint3D(const double &x1, const double &x2, const double &x3);
144 double calculateNormalizedDistanceToPoint3D(const double &x1, const double &y1, const double &z1, const double &x2,
145 const double &y2, const double &z2);
146
147 bool enclosesPoint2D(double x1, double x2);
150 // public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2);
151 GbPolygon3D *createClippedPolygon3D(const double &p1x1, const double &p1x2, const double &p1x3, const double &p2x1,
152 const double &p2x2, const double &p2x3);
153 // bool enclosesRectangle2D(GbRectangle2D *rectangle);
154 // public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2);
155 // public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
156 // public boolean crossesRectangle2D(GbRectangle2D rectangle);
157 // public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
158 // public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
159 // public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle);
160 // public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
161 // public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
162 /*======================================================================*/
163 /*======================================================================*/
164 /* Private Methoden */
165 /* */
166 virtual void calculateValues();
167
168 // virtuelle Methoden von UbObserver
171 {
172 GbPoint3D *point = dynamic_cast<GbPoint3D *>(changedObject);
173 if (!point || (this->points[0] != point && this->points[1] != point && this->points[2] != point))
174 return;
175
176 this->consistent = false;
177 }
179 {
180 if (this->points[0]) {
181 UbObservable *observedObj = dynamic_cast<UbObservable *>(this->points[0]);
182 if (objectForDeletion == observedObj) {
183 this->points[0] = NULL;
184 }
185 }
186 if (this->points[1]) {
187 UbObservable *observedObj = dynamic_cast<UbObservable *>(this->points[1]);
188 if (objectForDeletion == observedObj) {
189 this->points[1] = NULL;
190 }
191 }
192 if (this->points[2]) {
193 UbObservable *observedObj = dynamic_cast<UbObservable *>(this->points[2]);
194 if (objectForDeletion == observedObj) {
195 this->points[2] = NULL;
196 }
197 }
198 // ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
199 }
200 using GbObject3D::isPointInGbObject3D; // Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht
201 // ausprogrammieren, welche sonst hier "ueberdeckt" waere
202
203protected:
205 double x1s;
206 double x2s;
207 double x3s;
208 double x1min;
209 double x1max;
210 double x2min;
211 double x2max;
212 double x3min;
213 double x3max;
214 double area;
215
217 std::vector<GbPoint3D *> points;
218
219private:
220 void init();
221};
222/*=========================================================================*/
223
224#endif
225
This Class provides basic 3D box objects.
Definition GbCuboid3D.h:53
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
This Class provides basic 3D triangle objects.
std::vector< GbPoint3D * > points
GbPoint3D * getPoint2()
void objectWillBeDeleted(UbObservable *objectForDeletion) override
void setInconsistent()
void objectChanged(UbObservable *changedObject) override
! quick and dirty von sirann !!
GbPoint3D * getPoint1()
bool isPointInGbObject3D(const double &, const double &, const double &, bool &pointIsOnBoundary) override
void finalize() override
bool isPointInGbObject3D(const double &, const double &, const double &) override
GbPoint3D * getPoint3()
GbVector3D normal
bool hasRaytracing() override
bool isCellInsideGbObject3D(const double &, const double &, const double &, const double &, const double &, const double &) override
This Class provides basic 3D vector objects.
Definition GbVector3D.h:47
Observable object.
Observer.
Definition UbObserver.h:51
std::shared_ptr< T > SPtr
double getX1Maximum() override
int contains(GbPoint3D *point)
double calculateDistanceToPoint3D(GbPoint3D *point)
~GbTriangle3D() override
GbVector3D getNormal()
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
double getX3Minimum() override
virtual bool isPointInGbObject3D(GbPoint3D *p)
GbPoint3D * getPoint(const int &index)
double getDistanceFromPoint(GbVector3D punct)
void setPoint(GbPoint3D *point, int index)
double getX1Centroid() override
void calculateNormal()
GbLine3D * createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2) override
double getX2Maximum() override
double getX2Centroid() override
GbTriangle3D * clone() override
double getX1Minimum() override
std::string toString() override
GbPolygon3D * createClippedPolygon3D(GbCuboid3D *cube)
double calculateNormalizedDistanceToPoint3D(const double &x1, const double &y1, const double &z1, const double &x2, const double &y2, const double &z2)
bool enclosesPoint2D(double x1, double x2)
double getX3Maximum() override
int containsEqual(GbPoint3D *point)
virtual void calculateValues()
GbPoint3D * calculateIntersectionPoints3D(GbLine3D *line)
double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1, const double &rx2, const double &rx3) override
std::vector< GbPoint3D > getPoints()
double getX3Centroid() override
double getX2Minimum() override