VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbCuboid3D.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 GBCUBOID3D_H
35#define GBCUBOID3D_H
36
37#include <cmath>
38#include <vector>
39
40#include <GbPoint3D.h>
43
44class GbLine3D;
46
47#include <PointerDefinitions.h>
48class GbCuboid3D;
50
52class GbCuboid3D : public GbObject3D, public UbObserver
53{
54public:
55 GbCuboid3D();
56 GbCuboid3D(const double &minX1, const double &minX2, const double &minX3, const double &maxX1, const double &maxX2,
57 const double &maxX3);
60 ~GbCuboid3D() override;
61
62 GbCuboid3D *clone() override { return new GbCuboid3D(this); }
63 void finalize() override;
64
65 GbPoint3D *getPoint1() { return this->p1; }
66 GbPoint3D *getPoint2() { return this->p2; }
67
71
72 double getX1Centroid() override;
73 double getX1Minimum() override;
74 double getX1Maximum() override;
75 double getX2Centroid() override;
76 double getX2Minimum() override;
77 double getX2Maximum() override;
78 double getX3Centroid() override;
79 double getX3Minimum() override;
80 double getX3Maximum() override;
81 void setCenterCoordinates(const UbTupleDouble3 & /*position*/) override
82 {
83 throw UbException(UB_EXARGS, "not implemented for " + (std::string) typeid(*this).name());
84 }
85 void setCenterCoordinates(const double &x1, const double &x2, const double &x3) override;
86
87 void translate(const double &x1, const double &x2, const double &x3) override;
88 void rotate(const double &rx1, const double &rx2, const double &rx3) override { (void)rx1; (void)rx2; (void)rx3; }
89 void scale(const double &sx1, const double &sx2, const double &sx3) override;
90
91 double getLengthX1();
92 double getLengthX2();
93 double getLengthX3();
94
95 bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p, bool &pointIsOnBoundary) override;
96 bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p) override;
97 bool isCellInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
98 const double &x2b, const double &x3b) override;
99 bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
100 const double &x2b, const double &x3b) override;
101 bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
102 const double &x2b, const double &x3b) override;
103 double getCellVolumeInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
104 const double &x2b, const double &x3b) override;
105
107 // GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double&
108 // x1b,const double& x2b,const double& x3b);
110
111 std::vector<GbTriangle3D *> getSurfaceTriangleSet() override;
112 void addSurfaceTriangleSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt3> &triangles) override;
113
114 bool hasRaytracing() override { return true; }
115 /*|r| must be 1! einheitsvector!!*/
116 double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1,
117 const double &rx2, const double &rx3) override;
118
120 {
121 return this->getDistance(p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate());
122 }
123 double getDistance(const double &x1p, const double &x2p, const double &x3p)
124 {
125 throw UbException(UB_EXARGS, "not implemented");
126
127 // falls punkt innerhalt ist: minimalen abstand ausrechnen
128 if (this->isPointInGbObject3D(x1p, x2p, x3p)) {
129 double x1Dist = ub_math::min(std::abs(x1p - this->getX1Minimum()), std::abs(x1p - this->getX1Maximum()));
130 double x2Dist = ub_math::min(std::abs(x2p - this->getX2Minimum()), std::abs(x2p - this->getX2Maximum()));
131 double x3Dist = ub_math::min(std::abs(x3p - this->getX3Minimum()), std::abs(x3p - this->getX3Maximum()));
132
133 return ub_math::min(x1Dist, x2Dist, x3Dist);
134 } else {
135 }
136 }
137
138 std::string toString() override;
139
140 // virtuelle Methoden von UbObserver
143
144 using GbObject3D::isPointInGbObject3D; // Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht
145 // ausprogrammieren, welche sonst hier "ueberdeckt" waere
146
147protected:
150};
151
152#endif
153
This Class provides basic 3D box objects.
Definition GbCuboid3D.h:53
GbCuboid3D * clone() override
Definition GbCuboid3D.h:62
double getDistance(const double &x1p, const double &x2p, const double &x3p)
Definition GbCuboid3D.h:123
bool hasRaytracing() override
Definition GbCuboid3D.h:114
double getDistance(GbPoint3D *p)
Definition GbCuboid3D.h:119
void rotate(const double &rx1, const double &rx2, const double &rx3) override
Definition GbCuboid3D.h:88
GbPoint3D * p2
Definition GbCuboid3D.h:149
GbPoint3D * p1
Definition GbCuboid3D.h:148
GbPoint3D * getPoint1()
Definition GbCuboid3D.h:65
void setCenterCoordinates(const UbTupleDouble3 &) override
Definition GbCuboid3D.h:81
GbPoint3D * getPoint2()
Definition GbCuboid3D.h:66
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
double getX1Coordinate() const
Definition GbPoint3D.h:82
Observable object.
Observer.
Definition UbObserver.h:51
A class implements a tuple.
Definition UbTuple.h:477
std::shared_ptr< T > SPtr
double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1, const double &rx2, const double &rx3) override
void objectChanged(UbObservable *changedObject) override
double getX1Minimum() override
double getX3Centroid() override
double getX2Minimum() override
void scale(const double &sx1, const double &sx2, const double &sx3) override
virtual bool isPointInGbObject3D(GbPoint3D *p)
void objectWillBeDeleted(UbObservable *objectForDeletion) override
void setPoint2(GbPoint3D *point2)
double getX2Centroid() override
bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
double getCellVolumeInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
~GbCuboid3D() override
double getX2Maximum() override
bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p, bool &pointIsOnBoundary) override
double getX3Minimum() override
void addSurfaceTriangleSet(std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleInt3 > &triangles) override
bool isCellInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
GbPoint3D * calculateInterSectionPoint3D(GbPoint3D &point1, GbPoint3D &point2)
double getLengthX2()
double getX1Centroid() override
double getLengthX3()
void setPoint1(GbPoint3D *point1)
void translate(const double &x1, const double &x2, const double &x3) override
bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
double getLengthX1()
GbLine3D * createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2) override
void finalize() override
SPtr< GbCuboid3D > GbCuboid3DPtr
Definition GbCuboid3D.h:49
std::string toString() override
double getX3Maximum() override
double getX1Maximum() override
void setPoints(GbPoint3D *point1, GbPoint3D *point2)
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
#define UB_EXARGS
Definition UbException.h:73
const T & min(const T &a1, const T &a2)
Definition UbMath.h:389