From bbe27bfd3a3144da84e9b9b0ff7727119c3d74c2 Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Tue, 1 Sep 2020 14:44:50 +0200 Subject: [PATCH] Adapt basics/geometry3d to the open source solution. --- src/basics/Core/LbmOrGks.h | 40 +- .../geometry3d/CoordinateTransformation3D.cpp | 262 +++--- .../geometry3d/CoordinateTransformation3D.h | 235 ++--- src/basics/geometry3d/GbCuboid3D.cpp | 858 ++++++++---------- src/basics/geometry3d/GbCuboid3D.h | 241 ++--- src/basics/geometry3d/GbLine3D.cpp | 66 +- src/basics/geometry3d/GbLine3D.h | 83 +- src/basics/geometry3d/GbObject3D.cpp | 41 +- src/basics/geometry3d/GbObject3D.h | 99 +- src/basics/geometry3d/GbPoint3D.cpp | 64 +- src/basics/geometry3d/GbPoint3D.h | 77 +- src/basics/geometry3d/GbPolygon3D.cpp | 398 +------- src/basics/geometry3d/GbPolygon3D.h | 326 +------ src/basics/geometry3d/GbSystem3D.cpp | 45 +- src/basics/geometry3d/GbSystem3D.h | 40 +- src/basics/geometry3d/GbTriangle3D.cpp | 173 +--- src/basics/geometry3d/GbTriangle3D.h | 113 +-- src/basics/geometry3d/GbVector3D.cpp | 38 +- src/basics/geometry3d/GbVector3D.h | 52 +- 19 files changed, 1306 insertions(+), 1945 deletions(-) diff --git a/src/basics/Core/LbmOrGks.h b/src/basics/Core/LbmOrGks.h index bd9a55ae1..f531c4469 100644 --- a/src/basics/Core/LbmOrGks.h +++ b/src/basics/Core/LbmOrGks.h @@ -1,14 +1,42 @@ -/* -* Author: St. Lenz -* mail: lenz@irmb.tu-bs.de -*/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LbmOrGks.h +//! \ingroup Core +//! \author Stephan Lenz +//======================================================================================= #ifndef LBMORGKS_H #define LBMORGKS_H enum LbmOrGks { - LBM, - GKS + LBM, + GKS }; #endif diff --git a/src/basics/geometry3d/CoordinateTransformation3D.cpp b/src/basics/geometry3d/CoordinateTransformation3D.cpp index f4387d07e..c3d0ff6d1 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.cpp +++ b/src/basics/geometry3d/CoordinateTransformation3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoordinateTransformation3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <geometry3d/CoordinateTransformation3D.h> #include <basics/utilities/UbMath.h> @@ -5,22 +37,22 @@ using namespace std; CoordinateTransformation3D::CoordinateTransformation3D() { - this->setTransformationValues(0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0); + this->setTransformationValues(0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0); } /*======================================================*/ -CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) +CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) { - this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, alpha, beta, gamma); + this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, alpha, beta, gamma); } /*======================================================*/ -CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3) +CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3) { - this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, 0.0, 0.0, 0.0); + this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, 0.0, 0.0, 0.0); } /*======================================================*/ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3D* transformation) { - this->setTransformationValues(transformation->Tx1 , transformation->Tx2 , transformation->Tx3 , transformation->Sx1 , transformation->Sx2 , transformation->Sx3, transformation->alpha, transformation->beta, transformation->gamma); + this->setTransformationValues(transformation->Tx1 , transformation->Tx2 , transformation->Tx3 , transformation->Sx1 , transformation->Sx2 , transformation->Sx3, transformation->alpha, transformation->beta, transformation->gamma); } /*======================================================*/ // void CoordinateTransformation3D::init() @@ -28,7 +60,7 @@ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3 // this->Tx1 = 0.0; this->Tx2 = 0.0; this->Tx3 = 0.0; // this->Sx1 = 1.0; this->Sx2 = 1.0; this->Sx3 = 1.0; // this->alpha = 0.0; this->beta = 0.0; this->gamma = 0.0; -// +// // this->toX1factorX1 = 1.0; this->toX1factorX2 = 0.0; this->toX1factorX3 = 0.0; // this->toX2factorX1 = 0.0; this->toX2factorX2 = 1.0; this->toX2factorX3 = 0.0; // this->toX3factorX1 = 0.0; this->toX3factorX2 = 0.0; this->toX3factorX3 = 1.0; @@ -36,13 +68,15 @@ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3 // this->fromX1factorX1 = 1.0; this->fromX1factorX2 = 0.0; this->fromX1factorX3 = 0.0; // this->fromX2factorX1 = 0.0; this->fromX2factorX2 = 1.0; this->fromX2factorX3 = 0.0; // this->fromX3factorX1 = 0.0; this->fromX3factorX2 = 0.0; this->fromX3factorX3 = 1.0; -// +// // this->active = false; // this->transformation = false; // } /*======================================================*/ -/**==== Set transformation values +/**==== Set transformation values ====**/ +/*! +\brief Set transformation values @param a transformed coordinate system x0 (in global coordinates) @param b transformed coordinate system y0 (in global coordinates) @param c transformed coordinate system z0 (in global coordinates) @@ -50,91 +84,91 @@ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3 @param dx2 y coordinate scaling (dy_transformed/dy_global) @param dx3 z coordinate scaling (dz_transformed/dz_global) @param alpha rotation around z angle (positive FROM global TO transformed coordinate system) -@param beta rotation around y angle -@param gamma rotation around x angle -@exception IllegalArgumentException if one of the scale values is between -1.0E-8 and 1.0E-8 -**/ +@param beta rotation around y angle +@param gamma rotation around x angle +@exception IllegalArgumentException if c1 of the scale values is between -1.0E-8 and 1.0E-8 +*/ void CoordinateTransformation3D::setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) { - if(UbMath::zero(dx1) || UbMath::zero(dx2) || UbMath::zero(dx3)) - throw UbException(UB_EXARGS,"error: at least one delta==0.0"); - - this->Tx1 = originX1; this->Tx2 = originX2; this->Tx3 = originX3; - this->Sx1 = dx1; this->Sx2 = dx2; this->Sx3 = dx3; - this->alpha = alpha; this->beta = beta; this->gamma = gamma; - - double ra = UbMath::PI*alpha/180.0; - double cosA = cos(ra); - double sinA = sin(ra); - double rb = UbMath::PI*beta/180.0; - double cosB = cos(rb); - double sinB = sin(rb); - double rg = UbMath::PI*gamma/180.0; - double cosG = cos(rg); - double sinG = sin(rg); - - //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) - double divisor = (Sx1*Sx2*Sx3); - - this->toX1factorX1 = +cosB*cosA*Sx2*Sx3/divisor; - this->toX1factorX2 = -cosB*sinA*Sx1*Sx3/divisor; - this->toX1factorX3 = +sinB*Sx1*Sx2/divisor; - this->toX1delta = (-Tx3*Sx1*Sx2*sinB - +Tx2*Sx1*Sx3*sinA*cosB - -Tx1*Sx2*Sx3*cosB*cosA)/divisor; - - this->toX2factorX1 = Sx2*Sx3*(sinG*sinB*cosA+cosG*sinA)/divisor; - this->toX2factorX2 = Sx1*Sx3*(-sinG*sinB*sinA+cosG*cosA)/divisor; - this->toX2factorX3 = -Sx1*Sx2*cosB*sinG/divisor; - this->toX2delta = (-Tx2*Sx1*Sx3*cosG*cosA - +Tx3*Sx1*Sx2*sinG*cosB - +Tx2*Sx1*Sx3*sinG*sinA*sinB - -Tx1*Sx2*Sx3*cosG*sinA - -Tx1*Sx2*Sx3*sinB*sinG*cosA )/divisor; - - - this->toX3factorX1 = Sx2*Sx3*(-cosG*sinB*cosA+sinG*sinA)/divisor; - this->toX3factorX2 = Sx1*Sx3*(sinB*cosG*sinA+sinG*cosA)/divisor; - this->toX3factorX3 = Sx1*Sx2*cosB*cosG/divisor; - this->toX3delta = (-Tx2*Sx1*Sx3*sinG*cosA - -Tx3*Sx1*Sx2*cosG*cosB - -Tx2*Sx1*Sx3*cosG*sinA*sinB - -Tx1*Sx2*Sx3*sinG*sinA - +Tx1*Sx2*Sx3*sinB*cosG*cosA )/divisor; - - //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) - this->fromX1factorX1 = cosB*cosA*Sx1; - this->fromX1factorX2 = (sinG*sinB*cosA+cosG*sinA)*Sx1; - this->fromX1factorX3 = (-cosG*sinB*cosA+sinG*sinA)*Sx1; - this->fromX1delta = Tx1; - - this->fromX2factorX1 = -cosB*sinA*Sx2; - this->fromX2factorX2 = -(sinG*sinB*sinA-cosG*cosA)*Sx2; - this->fromX2factorX3 = (cosG*sinB*sinA+sinG*cosA)*Sx2; - this->fromX2delta = Tx2; - - this->fromX3factorX1 = sinB*Sx3; - this->fromX3factorX2 = -sinG*cosB*Sx3; - this->fromX3factorX3 = cosG*cosB*Sx3; - this->fromX3delta = Tx3; - - this->active = true; - - this->transformation = true; -} -/*======================================================*/ -/** + if(UbMath::zero(dx1) || UbMath::zero(dx2) || UbMath::zero(dx3)) + throw UbException(UB_EXARGS,"error: at least one delta==0.0"); + + this->Tx1 = originX1; this->Tx2 = originX2; this->Tx3 = originX3; + this->Sx1 = dx1; this->Sx2 = dx2; this->Sx3 = dx3; + this->alpha = alpha; this->beta = beta; this->gamma = gamma; + + double ra = UbMath::PI*alpha/180.0; + double cosA = cos(ra); + double sinA = sin(ra); + double rb = UbMath::PI*beta/180.0; + double cosB = cos(rb); + double sinB = sin(rb); + double rg = UbMath::PI*gamma/180.0; + double cosG = cos(rg); + double sinG = sin(rg); + + //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) + double divisor = (Sx1*Sx2*Sx3); + + this->toX1factorX1 = +cosB*cosA*Sx2*Sx3/divisor; + this->toX1factorX2 = -cosB*sinA*Sx1*Sx3/divisor; + this->toX1factorX3 = +sinB*Sx1*Sx2/divisor; + this->toX1delta = (-Tx3*Sx1*Sx2*sinB + +Tx2*Sx1*Sx3*sinA*cosB + -Tx1*Sx2*Sx3*cosB*cosA)/divisor; + + this->toX2factorX1 = Sx2*Sx3*(sinG*sinB*cosA+cosG*sinA)/divisor; + this->toX2factorX2 = Sx1*Sx3*(-sinG*sinB*sinA+cosG*cosA)/divisor; + this->toX2factorX3 = -Sx1*Sx2*cosB*sinG/divisor; + this->toX2delta = (-Tx2*Sx1*Sx3*cosG*cosA + +Tx3*Sx1*Sx2*sinG*cosB + +Tx2*Sx1*Sx3*sinG*sinA*sinB + -Tx1*Sx2*Sx3*cosG*sinA + -Tx1*Sx2*Sx3*sinB*sinG*cosA )/divisor; + + + this->toX3factorX1 = Sx2*Sx3*(-cosG*sinB*cosA+sinG*sinA)/divisor; + this->toX3factorX2 = Sx1*Sx3*(sinB*cosG*sinA+sinG*cosA)/divisor; + this->toX3factorX3 = Sx1*Sx2*cosB*cosG/divisor; + this->toX3delta = (-Tx2*Sx1*Sx3*sinG*cosA + -Tx3*Sx1*Sx2*cosG*cosB + -Tx2*Sx1*Sx3*cosG*sinA*sinB + -Tx1*Sx2*Sx3*sinG*sinA + +Tx1*Sx2*Sx3*sinB*cosG*cosA )/divisor; + + //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) + this->fromX1factorX1 = cosB*cosA*Sx1; + this->fromX1factorX2 = (sinG*sinB*cosA+cosG*sinA)*Sx1; + this->fromX1factorX3 = (-cosG*sinB*cosA+sinG*sinA)*Sx1; + this->fromX1delta = Tx1; + + this->fromX2factorX1 = -cosB*sinA*Sx2; + this->fromX2factorX2 = -(sinG*sinB*sinA-cosG*cosA)*Sx2; + this->fromX2factorX3 = (cosG*sinB*sinA+sinG*cosA)*Sx2; + this->fromX2delta = Tx2; + + this->fromX3factorX1 = sinB*Sx3; + this->fromX3factorX2 = -sinG*cosB*Sx3; + this->fromX3factorX3 = cosG*cosB*Sx3; + this->fromX3delta = Tx3; + + this->active = true; + + this->transformation = true; +} +/*======================================================*/ +/*! Set transformation active state (if this IS a transformation) @param active true to be active, false otherwise **/ void CoordinateTransformation3D::setActive(const bool& active) { - if(this->active == active) return; - if(this->transformation) this->active = active; + if(this->active == active) return; + if(this->transformation) this->active = active; } /*======================================================*/ -/** +/*! Transform FROM global coordinates TO transformed coordinates. @param x1 the global x coordinate @param x2 the global y coordinate @@ -142,45 +176,45 @@ Transform FROM global coordinates TO transformed coordinates. **/ double CoordinateTransformation3D::transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->toX1factorX1*x1 + this->toX1factorX2*x2 + this->toX1factorX3*x3 + this->toX1delta; - else return x1; + if(this->active) return this->toX1factorX1*x1 + this->toX1factorX2*x2 + this->toX1factorX3*x3 + this->toX1delta; + else return x1; } /*======================================================*/ double CoordinateTransformation3D::transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->toX2factorX1*x1 + this->toX2factorX2*x2 + this->toX2factorX3*x3 + this->toX2delta; - else return x2; + if(this->active) return this->toX2factorX1*x1 + this->toX2factorX2*x2 + this->toX2factorX3*x3 + this->toX2delta; + else return x2; } /*======================================================*/ double CoordinateTransformation3D::transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->toX3factorX1*x1 + this->toX3factorX2*x2 + this->toX3factorX3*x3 + this->toX3delta; - else return x3; + if(this->active) return this->toX3factorX1*x1 + this->toX3factorX2*x2 + this->toX3factorX3*x3 + this->toX3delta; + else return x3; } /*======================================================*/ -/** +/*! Transform FROM global coordinates TO transformed coordinates (ignoring rotation). @param x1 the global x coordinate **/ double CoordinateTransformation3D::transformForwardToX1CoordinateIgnoringRotation(const double& x1) const { - if(this->active) return (x1-this->Tx1)/this->Sx1; - else return x1; + if(this->active) return (x1-this->Tx1)/this->Sx1; + else return x1; } /*======================================================*/ double CoordinateTransformation3D::transformForwardToX2CoordinateIgnoringRotation(const double& x2) const { - if(this->active) return (x2-this->Tx2)/this->Sx2; - else return x2; + if(this->active) return (x2-this->Tx2)/this->Sx2; + else return x2; } /*======================================================*/ double CoordinateTransformation3D::transformForwardToX3CoordinateIgnoringRotation(const double& x3) const { - if(this->active) return (x3-this->Tx3)/this->Sx3; - else return x3; + if(this->active) return (x3-this->Tx3)/this->Sx3; + else return x3; } /*======================================================*/ -/** +/*! Transform FROM transformed coordinates TO global coordinates. @param x1 the transformed x coordinate @param x2 the transformed y coordinate @@ -188,51 +222,51 @@ Transform FROM transformed coordinates TO global coordinates. **/ double CoordinateTransformation3D::transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->fromX1factorX1*x1 + this->fromX1factorX2*x2 + this->fromX1factorX3*x3 + this->fromX1delta; - else return x1; + if(this->active) return this->fromX1factorX1*x1 + this->fromX1factorX2*x2 + this->fromX1factorX3*x3 + this->fromX1delta; + else return x1; } /*======================================================*/ double CoordinateTransformation3D::transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->fromX2factorX1*x1 + this->fromX2factorX2*x2 + this->fromX2factorX3*x3 + this->fromX2delta; - else return x2; + if(this->active) return this->fromX2factorX1*x1 + this->fromX2factorX2*x2 + this->fromX2factorX3*x3 + this->fromX2delta; + else return x2; } /*======================================================*/ double CoordinateTransformation3D::transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const { - if(this->active) return this->fromX3factorX1*x1 + this->fromX3factorX2*x2 + this->fromX3factorX3*x3 + this->fromX3delta; - else return x3; + if(this->active) return this->fromX3factorX1*x1 + this->fromX3factorX2*x2 + this->fromX3factorX3*x3 + this->fromX3delta; + else return x3; } /*======================================================*/ -/** +/*! Transform FROM transformed coordinates TO global coordinates (ignoring rotation). @param x1 the transformed x coordinate **/ double CoordinateTransformation3D::transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const { - if(this->active) return x1*this->Sx1+this->Tx1; - else return x1; + if(this->active) return x1*this->Sx1+this->Tx1; + else return x1; } /*======================================================*/ double CoordinateTransformation3D::transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const { - if(this->active) return x2*this->Sx2+this->Tx2; - else return x2; + if(this->active) return x2*this->Sx2+this->Tx2; + else return x2; } /*======================================================*/ double CoordinateTransformation3D::transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const { - if(this->active) return x3*this->Sx3+this->Tx3; - else return x3; + if(this->active) return x3*this->Sx3+this->Tx3; + else return x3; } /*======================================================*/ -/** +/*! Returns a string representation of this transformation. @return a string representation of this transformation **/ string CoordinateTransformation3D::toString() const { - stringstream ss; + stringstream ss; ss<<" CoordinateTransformation3D\n"; // ss<<"[isTransformation="<<this->transformation; // ss<<", isActive="<<this->active<<endl; @@ -249,6 +283,6 @@ string CoordinateTransformation3D::toString() const // ss<<", from31="<<this->from31<<", from32="<<this->from32<<", from33="<<this->from33; // ss<<", fromA="<<this->fromA; ss<<", fromB="<<this->fromB; ss<<", fromC="<<this->fromC; // ss<<"]}"; - return ss.str(); + return ss.str(); } diff --git a/src/basics/geometry3d/CoordinateTransformation3D.h b/src/basics/geometry3d/CoordinateTransformation3D.h index 3179de328..17e6505ae 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.h +++ b/src/basics/geometry3d/CoordinateTransformation3D.h @@ -1,160 +1,125 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoordinateTransformation3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef COORDINATETRANSFORMATION3D_H #define COORDINATETRANSFORMATION3D_H -#ifdef RCF_USE_BOOST_SERIALIZATION - #include <boost/archive/text_oarchive.hpp> - #include <boost/archive/text_iarchive.hpp> -#endif //RCF_USE_BOOST_SERIALIZATION - #include <cmath> #include <string> #include <sstream> #include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> #include <PointerDefinitions.h> -//description: x1/x2/x3 = alt, x1*/x2*/x3* = neu -// x2 -// ^ x* -// | / -// | 2* -// 4 / -// | / -// 3 1* => neues coordsys ist um originX1=originX2=originX3=2 verschoben -// | / neues dx1=dx2=dx2=2 -> skalierung um 2 in x1-,x2- und x3-richtung -// 2 / ERST verdrehung um alpha um "x1" achse -// | \ DANN verdrehung um beta um "x2" achse -// 1 \ DANN verdrehung um gamma um "x3" achse -// | x1* -// |--1--2--3--4--5------------- > x1 -// -// Bemerkung: kann sein, dass die Verdrehung um x1 und x3 vertauschst sind -// - muss mal einer pr�fen ... - - +/////////////////////////////////////////////////////////////////////////////////////// +//! +//! \brief A class provides 3d coordinate transformation +//! \details +//! description: x1/x2/x3 = old, x1*/x2*/x3* = new +//! x2 +//! ^ x* +//! | / +//! | 2* +//! 4 / +//! | / +//! 3 1* => new coordsys is translated by originX1=originX2=originX3=2 +//! | / new dx1=dx2=dx2=2 -> scaling by 2 in x1-,x2- und x3-direction +//! 2 / FIRST rotation by alpha around "x1" axis +//! | \ THEN rotation by beta around "x2" axis +//! 1 \ THEN rotation by gamma around "x3" axis +//! | x1* +//! |--1--2--3--4--5------------- > x1 +//! +//! Remark: It might be that the rotations around x1 and x3 axis are swapped. +//! +////////////////////////////////////////////////////////////////////////////////////// class CoordinateTransformation3D { public: - CoordinateTransformation3D(); - CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); - CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3); - CoordinateTransformation3D(CoordinateTransformation3D* transformation); - - void setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); - double getX1CoordinateOffset() const { return this->Tx1; } //Translation - double getX2CoordinateOffset() const { return this->Tx2; } - double getX3CoordinateOffset() const { return this->Tx3; } - double getX1CoordinateScaling() const { return this->Sx1; } //Scaling - double getX2CoordinateScaling() const { return this->Sx2; } - double getX3CoordinateScaling() const { return this->Sx3; } - double getRotationX1Angle() const { return this->alpha; } - double getRotationX2Angle() const { return this->beta; } - double getRotationX3Angle() const { return this->gamma; } //Rotation - - //Achtung die Winkel passen nicht �berein -siehe setTransformationValues - void setRotationX1Angle(double alpha) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, alpha, this->beta, this->gamma); } - void setRotationX2Angle(double beta ) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, beta, this->gamma); } - void setRotationX3Angle(double gamma) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, this->beta, gamma); } - - void setActive(const bool& active); - bool isActive() const { return this->active; } - bool isTransformation() const { return this->transformation; } - - double transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX1CoordinateIgnoringRotation(const double& x1) const; - double transformForwardToX2CoordinateIgnoringRotation(const double& x2) const; - double transformForwardToX3CoordinateIgnoringRotation(const double& x3) const; - double transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const; - double transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const; - double transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const; - std::string toString() const; - - //------------- implements CAB serialization ----- start - void write(UbFileOutput* out) const - { - out->writeString("Coordtransfomartion3D"); - out->writeDouble(this->Tx1); - out->writeDouble(this->Tx2); - out->writeDouble(this->Tx3); - out->writeDouble(this->Sx1); - out->writeDouble(this->Sx2); - out->writeDouble(this->Sx3); - out->writeDouble(this->alpha); - out->writeDouble(this->beta ); - out->writeDouble(this->gamma); - } - void read(UbFileInput* in) - { - in->readString(); - this->Tx1 = in->readDouble(); - this->Tx2 = in->readDouble(); - this->Tx3 = in->readDouble(); - this->Sx1 = in->readDouble(); - this->Sx2 = in->readDouble(); - this->Sx3 = in->readDouble(); - this->alpha = in->readDouble(); - this->beta = in->readDouble(); - this->gamma = in->readDouble(); - - this->setTransformationValues(Tx1,Tx2,Tx3,Sx1,Sx2,Sx3,alpha,beta,gamma); - } - //------------- implements CAB serialization ----- end - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & Tx1; ar & Tx2; ar & Tx3; - ar & Sx1; ar & Sx2; ar & Sx3; - ar & alpha; ar & beta; ar & gamma; - - ar & toX1factorX1; ar & toX1factorX2; ar & toX1factorX3; ar & toX1delta; - ar & toX2factorX1; ar & toX2factorX2; ar & toX2factorX3; ar & toX2delta; - ar & toX3factorX1; ar & toX3factorX2; ar & toX3factorX3; ar & toX3delta; - - ar & fromX1factorX1; ar & fromX1factorX2; ar & fromX1factorX3; ar & fromX1delta; - ar & fromX2factorX1; ar & fromX2factorX2; ar & fromX2factorX3; ar & fromX2delta; - ar & fromX3factorX1; ar & fromX3factorX2; ar & fromX3factorX3; ar & fromX3delta; - - ar & active; - ar & transformation; - } -#endif //CAB_RCF + CoordinateTransformation3D(); + CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); + CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3); + CoordinateTransformation3D(CoordinateTransformation3D* transformation); + + void setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); + double getX1CoordinateOffset() const { return this->Tx1; } //Translation + double getX2CoordinateOffset() const { return this->Tx2; } + double getX3CoordinateOffset() const { return this->Tx3; } + double getX1CoordinateScaling() const { return this->Sx1; } //Scaling + double getX2CoordinateScaling() const { return this->Sx2; } + double getX3CoordinateScaling() const { return this->Sx3; } + double getRotationX1Angle() const { return this->alpha; } + double getRotationX2Angle() const { return this->beta; } + double getRotationX3Angle() const { return this->gamma; } //Rotation + + //Achtung die Winkel passen nicht ueberein -siehe setTransformationValues + void setRotationX1Angle(double alpha) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, alpha, this->beta, this->gamma); } + void setRotationX2Angle(double beta ) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, beta, this->gamma); } + void setRotationX3Angle(double gamma) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, this->beta, gamma); } + + void setActive(const bool& active); + bool isActive() const { return this->active; } + bool isTransformation() const { return this->transformation; } + + double transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformForwardToX1CoordinateIgnoringRotation(const double& x1) const; + double transformForwardToX2CoordinateIgnoringRotation(const double& x2) const; + double transformForwardToX3CoordinateIgnoringRotation(const double& x3) const; + double transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; + double transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const; + double transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const; + double transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const; + std::string toString() const; private: - double Tx1, Tx2, Tx3, Sx1, Sx2, Sx3, alpha, beta, gamma; + double Tx1, Tx2, Tx3, Sx1, Sx2, Sx3, alpha, beta, gamma; - double toX1factorX1, toX1factorX2, toX1factorX3, toX1delta; - double toX2factorX1, toX2factorX2, toX2factorX3, toX2delta; - double toX3factorX1, toX3factorX2, toX3factorX3, toX3delta; + double toX1factorX1, toX1factorX2, toX1factorX3, toX1delta; + double toX2factorX1, toX2factorX2, toX2factorX3, toX2delta; + double toX3factorX1, toX3factorX2, toX3factorX3, toX3delta; - double fromX1factorX1, fromX1factorX2, fromX1factorX3, fromX1delta; - double fromX2factorX1, fromX2factorX2, fromX2factorX3, fromX2delta; - double fromX3factorX1, fromX3factorX2, fromX3factorX3, fromX3delta; + double fromX1factorX1, fromX1factorX2, fromX1factorX3, fromX1delta; + double fromX2factorX1, fromX2factorX2, fromX2factorX3, fromX2delta; + double fromX3factorX1, fromX3factorX2, fromX3factorX3, fromX3delta; - bool active; - bool transformation; + bool active; + bool transformation; - friend class MPIIOCoProcessor; - friend class MPIIORestartCoProcessor; - friend class MPIIOMigrationCoProcessor; - friend class MPIIOMigrationBECoProcessor; - friend class CheckpointConverter; }; #endif //COORDINATETRANSFORMATION3D_H diff --git a/src/basics/geometry3d/GbCuboid3D.cpp b/src/basics/geometry3d/GbCuboid3D.cpp index 4a2fd96e5..dc118ffc3 100644 --- a/src/basics/geometry3d/GbCuboid3D.cpp +++ b/src/basics/geometry3d/GbCuboid3D.cpp @@ -1,226 +1,251 @@ -#include <geometry3d/GbCuboid3D.h> -#include <geometry3d/creator/GbCuboid3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCuboid3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbCuboid3D.h> +#include <GbSystem3D.h> +#include <GbTriangle3D.h> #include <basics/utilities/UbMath.h> -#include <geometry3d/GbSystem3D.h> -#include <geometry3d/GbTriangle3D.h> - using namespace std; -/*=======================================================*/ -ObObjectCreator* GbCuboid3D::getCreator() -{ - return GbCuboid3DCreator::getInstance(); -} /*=======================================================*/ // Konstruktor GbCuboid3D::GbCuboid3D() : GbObject3D() { - this->setName("cuboid"); - this->p1 = new GbPoint3D(0.0, 0.0, 0.0); - this->p2 = new GbPoint3D(0.0, 0.0, 0.0); - this->p1->addObserver(this); - this->p2->addObserver(this); + this->setName("cuboid"); + this->p1 = new GbPoint3D(0.0, 0.0, 0.0); + this->p2 = new GbPoint3D(0.0, 0.0, 0.0); + this->p1->addObserver(this); + this->p2->addObserver(this); } /*=======================================================*/ GbCuboid3D::GbCuboid3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b):GbObject3D() { - this->setName("cuboid"); - this->p1 = new GbPoint3D(x1a, x2a, x3a); - this->p1->addObserver(this); - this->p2 = new GbPoint3D(x1b, x2b, x3b); - this->p2->addObserver(this); + this->setName("cuboid"); + this->p1 = new GbPoint3D(x1a, x2a, x3a); + this->p1->addObserver(this); + this->p2 = new GbPoint3D(x1b, x2b, x3b); + this->p2->addObserver(this); } /*=======================================================*/ GbCuboid3D::GbCuboid3D(GbPoint3D* p1, GbPoint3D* p2) : GbObject3D() { - this->setName("cuboid"); - if(!p1 || !p2) throw UbException(UB_EXARGS,"one point ==NULL"); - this->p1 = p1; - this->p1->addObserver(this); - this->p2 = p2; - this->p2->addObserver(this); + this->setName("cuboid"); + if(!p1 || !p2) throw UbException(UB_EXARGS,"one point ==NULL"); + this->p1 = p1; + this->p1->addObserver(this); + this->p2 = p2; + this->p2->addObserver(this); } /*=======================================================*/ GbCuboid3D::GbCuboid3D(GbCuboid3D* cuboid) : GbObject3D() { - this->setName("cuboid"); - if(!cuboid->getPoint1() || !cuboid->getPoint2()) throw UbException(UB_EXARGS,"cuboid ==NULL"); - this->p1 = cuboid->getPoint1()->clone(); - this->p1->addObserver(this); - this->p2 = cuboid->getPoint2()->clone(); - this->p2->addObserver(this); + this->setName("cuboid"); + if(!cuboid->getPoint1() || !cuboid->getPoint2()) throw UbException(UB_EXARGS,"cuboid ==NULL"); + this->p1 = cuboid->getPoint1()->clone(); + this->p1->addObserver(this); + this->p2 = cuboid->getPoint2()->clone(); + this->p2->addObserver(this); } /*=======================================================*/ // Destruktor GbCuboid3D::~GbCuboid3D() { - //cout<<"~GbCuboid3D()"<<endl; - if(this->p1) this->p1->removeObserver(this); - if(this->p2) this->p2->removeObserver(this); -} -/*=======================================================*/ -void GbCuboid3D::finalize() -{ - if(this->p1) - { - this->p1->removeObserver(this); - this->p1->finalize(); - delete this->p1; - this->p1=NULL; - } - if(this->p2) - { - this->p2->removeObserver(this); - this->p2->finalize(); - delete this->p2; - this->p2=NULL; - } + //cout<<"~GbCuboid3D()"<<endl; + if(this->p1) this->p1->removeObserver(this); + if(this->p2) this->p2->removeObserver(this); +} +/*=======================================================*/ +void GbCuboid3D::finalize() +{ + if(this->p1) + { + this->p1->removeObserver(this); + this->p1->finalize(); + delete this->p1; + this->p1=NULL; + } + if(this->p2) + { + this->p2->removeObserver(this); + this->p2->finalize(); + delete this->p2; + this->p2=NULL; + } } /*=======================================================*/ void GbCuboid3D::setPoint1(GbPoint3D* point1) -{ - if(this->p1) this->p1->removeObserver(this); - this->p1 = point1; - this->p1->addObserver(this); +{ + if(this->p1) this->p1->removeObserver(this); + this->p1 = point1; + this->p1->addObserver(this); - this->notifyObserversObjectChanged(); + this->notifyObserversObjectChanged(); } /*=======================================================*/ void GbCuboid3D::setPoint2(GbPoint3D* point2) -{ - if(this->p2) this->p2->removeObserver(this); - this->p2 = point2; - this->p2->addObserver(this); +{ + if(this->p2) this->p2->removeObserver(this); + this->p2 = point2; + this->p2->addObserver(this); - this->notifyObserversObjectChanged(); + this->notifyObserversObjectChanged(); } /*=======================================================*/ void GbCuboid3D::setPoints(GbPoint3D* point1, GbPoint3D* point2) -{ - if(this->p1) this->p1->removeObserver(this); - if(this->p2) this->p2->removeObserver(this); +{ + if(this->p1) this->p1->removeObserver(this); + if(this->p2) this->p2->removeObserver(this); - this->p1 = point1; - this->p2 = point2; + this->p1 = point1; + this->p2 = point2; - this->p1->addObserver(this); - this->p2->addObserver(this); + this->p1->addObserver(this); + this->p2->addObserver(this); - this->notifyObserversObjectChanged(); + this->notifyObserversObjectChanged(); } /*=======================================================*/ -void GbCuboid3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) +void GbCuboid3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) { - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); + this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); } /*=======================================================*/ double GbCuboid3D::getX1Centroid() { - return (0.5*(p1->x1 + p2->x1)); + return (0.5*(p1->x1 + p2->x1)); } /*=======================================================*/ -double GbCuboid3D::getX1Minimum() +double GbCuboid3D::getX1Minimum() { - return (this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); + return (this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); } /*=======================================================*/ -double GbCuboid3D::getX1Maximum() +double GbCuboid3D::getX1Maximum() { - return (this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); + return (this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); } /*=======================================================*/ double GbCuboid3D::getX2Centroid() { - return (0.5*(p1->x2 + p2->x2)); + return (0.5*(p1->x2 + p2->x2)); } /*=======================================================*/ -double GbCuboid3D::getX2Minimum() +double GbCuboid3D::getX2Minimum() { - return (this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); -} + return (this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); +} /*=======================================================*/ -double GbCuboid3D::getX2Maximum() +double GbCuboid3D::getX2Maximum() { - return ( this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); + return ( this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); } /*=======================================================*/ double GbCuboid3D::getX3Centroid() { - return (0.5*(p1->x3 + p2->x3)); + return (0.5*(p1->x3 + p2->x3)); } /*=======================================================*/ -double GbCuboid3D::getX3Minimum() -{ - return (this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3); -} +double GbCuboid3D::getX3Minimum() +{ + return (this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3); +} /*=======================================================*/ -double GbCuboid3D::getX3Maximum() +double GbCuboid3D::getX3Maximum() { - return (this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); + return (this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); } /*=======================================================*/ -double GbCuboid3D::getLengthX1() -{ - return (this->getX1Maximum() - this->getX1Minimum() ); +double GbCuboid3D::getLengthX1() +{ + return (this->getX1Maximum() - this->getX1Minimum() ); } /*=======================================================*/ -double GbCuboid3D::getLengthX2() -{ - return (this->getX2Maximum() - this->getX2Minimum()); +double GbCuboid3D::getLengthX2() +{ + return (this->getX2Maximum() - this->getX2Minimum()); } /*=======================================================*/ -double GbCuboid3D::getLengthX3() -{ - return (this->getX3Maximum() - this->getX3Minimum()); +double GbCuboid3D::getLengthX3() +{ + return (this->getX3Maximum() - this->getX3Minimum()); } /*=======================================================*/ bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) { - //true, wenn 'in Object' oder 'auf Boundary'! - if (UbMath::less(x1p,this->getX1Minimum())) return false; - else if(UbMath::less(x2p,this->getX2Minimum())) return false; - else if(UbMath::less(x3p,this->getX3Minimum())) return false; - else if(UbMath::greater(x1p,this->getX1Maximum())) return false; - else if(UbMath::greater(x2p,this->getX2Maximum())) return false; - else if(UbMath::greater(x3p,this->getX3Maximum())) return false; + //true, wenn 'in Object' oder 'auf Boundary'! + if (UbMath::less(x1p,this->getX1Minimum())) return false; + else if(UbMath::less(x2p,this->getX2Minimum())) return false; + else if(UbMath::less(x3p,this->getX3Minimum())) return false; + else if(UbMath::greater(x1p,this->getX1Maximum())) return false; + else if(UbMath::greater(x2p,this->getX2Maximum())) return false; + else if(UbMath::greater(x3p,this->getX3Maximum())) return false; - return true; + return true; } /*=======================================================*/ bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) { - pointIsOnBoundary = false; - - //true, wenn 'in Object' oder 'auf Boundary'! - if (UbMath::less(x1p,this->getX1Minimum())) return false; - else if(UbMath::less(x2p,this->getX2Minimum())) return false; - else if(UbMath::less(x3p,this->getX3Minimum())) return false; - else if(UbMath::greater(x1p,this->getX1Maximum())) return false; - else if(UbMath::greater(x2p,this->getX2Maximum())) return false; - else if(UbMath::greater(x3p,this->getX3Maximum())) return false; - - if (UbMath::equal(x1p,this->getX1Minimum())) pointIsOnBoundary = true; - else if(UbMath::equal(x2p,this->getX2Minimum())) pointIsOnBoundary = true; - else if(UbMath::equal(x3p,this->getX3Minimum())) pointIsOnBoundary = true; - else if(UbMath::equal(x1p,this->getX1Maximum())) pointIsOnBoundary = true; - else if(UbMath::equal(x2p,this->getX2Maximum())) pointIsOnBoundary = true; - else if(UbMath::equal(x3p,this->getX3Maximum())) pointIsOnBoundary = true; - - return true; + pointIsOnBoundary = false; + + //true, wenn 'in Object' oder 'auf Boundary'! + if (UbMath::less(x1p,this->getX1Minimum())) return false; + else if(UbMath::less(x2p,this->getX2Minimum())) return false; + else if(UbMath::less(x3p,this->getX3Minimum())) return false; + else if(UbMath::greater(x1p,this->getX1Maximum())) return false; + else if(UbMath::greater(x2p,this->getX2Maximum())) return false; + else if(UbMath::greater(x3p,this->getX3Maximum())) return false; + + if (UbMath::equal(x1p,this->getX1Minimum())) pointIsOnBoundary = true; + else if(UbMath::equal(x2p,this->getX2Minimum())) pointIsOnBoundary = true; + else if(UbMath::equal(x3p,this->getX3Minimum())) pointIsOnBoundary = true; + else if(UbMath::equal(x1p,this->getX1Maximum())) pointIsOnBoundary = true; + else if(UbMath::equal(x2p,this->getX2Maximum())) pointIsOnBoundary = true; + else if(UbMath::equal(x3p,this->getX3Maximum())) pointIsOnBoundary = true; + + return true; } /*=======================================================*/ bool GbCuboid3D::isCellInsideGbObject3D(const double& x1p1,const double& x2p1,const double& x3p1,const double& x1p2,const double& x2p2,const double& x3p2) { - if ( UbMath::less (x1p1, this->getX1Minimum() ) ) return false; - else if( UbMath::less (x2p1, this->getX2Minimum() ) ) return false; - else if( UbMath::less (x3p1, this->getX3Minimum() ) ) return false; - else if( UbMath::greater(x1p2, this->getX1Maximum() ) ) return false; - else if( UbMath::greater(x2p2, this->getX2Maximum() ) ) return false; - else if( UbMath::greater(x3p2, this->getX3Maximum() ) ) return false; + if ( UbMath::less (x1p1, this->getX1Minimum() ) ) return false; + else if( UbMath::less (x2p1, this->getX2Minimum() ) ) return false; + else if( UbMath::less (x3p1, this->getX3Minimum() ) ) return false; + else if( UbMath::greater(x1p2, this->getX1Maximum() ) ) return false; + else if( UbMath::greater(x2p2, this->getX2Maximum() ) ) return false; + else if( UbMath::greater(x3p2, this->getX3Maximum() ) ) return false; - return true; + return true; } /*=======================================================*/ bool GbCuboid3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) @@ -232,24 +257,24 @@ bool GbCuboid3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,con // - cell completely inside cuboid3D ( = cuboid3D boxes cell) // - cell und cuboid3D haben kein gemeinsames Volumen { - //erstmal die dumm Loesung - if( !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) - && this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) - { - return true; - } + //erstmal die dumm Loesung + if( !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) + && this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) + { + return true; + } - return false; + return false; - //GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b); - //if(cube) - //{ - // cube->finalize(); - // delete cube; - // return true; - //} + //GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b); + //if(cube) + //{ + // cube->finalize(); + // delete cube; + // return true; + //} - //return false; + //return false; } /*=======================================================*/ bool GbCuboid3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) @@ -261,373 +286,282 @@ bool GbCuboid3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& // - cell und cuboid3D haben kein gemeinsames Volumen { //simpler check, da unser GbCuboid3D ein AABB is: - // anfA midA endA anfB midB endB - // | x<-- dxA -->| |<-dxB->x | - // |<----------------- T --------------->| - //ist |T| <= dxA + dxB -> overlap! + // anfA midA endA anfB midB endB + // | x<-- dxA -->| |<-dxB->x | + // |<----------------- T --------------->| + //ist |T| <= dxA + dxB -> overlap! - if( UbMath::lessEqual( std::fabs( this->getX1Centroid() - 0.5*(x1b+x1a) /*Tx1*/ ) - , 0.5*( this->getLengthX1() + std::fabs(x1b-x1a) /*dx1A+dx1B*/) ) + if( UbMath::lessEqual( std::fabs( this->getX1Centroid() - 0.5*(x1b+x1a) /*Tx1*/ ) + , 0.5*( this->getLengthX1() + std::fabs(x1b-x1a) /*dx1A+dx1B*/) ) - && UbMath::lessEqual( std::fabs( this->getX2Centroid() - 0.5*(x2b+x2a) /*Tx2*/ ) - , 0.5*( this->getLengthX2() + std::fabs(x2b-x2a) /*dx2A+dx2B*/) ) + && UbMath::lessEqual( std::fabs( this->getX2Centroid() - 0.5*(x2b+x2a) /*Tx2*/ ) + , 0.5*( this->getLengthX2() + std::fabs(x2b-x2a) /*dx2A+dx2B*/) ) - && UbMath::lessEqual( std::fabs( this->getX3Centroid() - 0.5*(x3b+x3a) /*Tx3*/ ) - , 0.5*( this->getLengthX3() + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) ) + && UbMath::lessEqual( std::fabs( this->getX3Centroid() - 0.5*(x3b+x3a) /*Tx3*/ ) + , 0.5*( this->getLengthX3() + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) ) { - return true; + return true; } return false; // if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) - // || this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return true; - // - //return false; + // || this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return true; + // + //return false; } /*=======================================================*/ vector<GbTriangle3D*> GbCuboid3D::getSurfaceTriangleSet() { - vector<GbTriangle3D*> triangles; - GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum()); - GbPoint3D p2(getX1Maximum(),getX2Minimum(),getX3Minimum()); - GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Minimum()); - GbPoint3D p4(getX1Minimum(),getX2Maximum(),getX3Minimum()); - GbPoint3D p5(getX1Minimum(),getX2Minimum(),getX3Maximum()); - GbPoint3D p6(getX1Maximum(),getX2Minimum(),getX3Maximum()); - GbPoint3D p7(getX1Maximum(),getX2Maximum(),getX3Maximum()); - GbPoint3D p8(getX1Minimum(),getX2Maximum(),getX3Maximum()); - - GbPoint3D pUnten(getX1Centroid(),getX2Centroid(),getX3Minimum()); - GbPoint3D pOben(getX1Centroid(),getX2Centroid(),getX3Maximum()); - GbPoint3D pLinks(getX1Minimum(), getX2Centroid(),getX3Centroid()); - GbPoint3D pRechts(getX1Maximum(), getX2Centroid(),getX3Centroid()); - GbPoint3D pVorne(getX1Centroid(),getX2Minimum(),getX3Centroid()); - GbPoint3D pHinten(getX1Centroid(),getX2Maximum(),getX3Centroid()); - - //"unten" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pUnten),new GbPoint3D(p3))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p1),new GbPoint3D(pUnten))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pUnten),new GbPoint3D(p4))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p4),new GbPoint3D(pUnten))); - //"oben" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(p6),new GbPoint3D(pOben))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p6),new GbPoint3D(p7),new GbPoint3D(pOben))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(pOben),new GbPoint3D(p8))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pOben),new GbPoint3D(p7),new GbPoint3D(p8))); - //"links" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(p1),new GbPoint3D(pLinks))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(pLinks),new GbPoint3D(p8))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p8),new GbPoint3D(pLinks),new GbPoint3D(p5))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pLinks),new GbPoint3D(p1),new GbPoint3D(p5))); - //"rechts" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p3),new GbPoint3D(pRechts))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p3),new GbPoint3D(p7))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pRechts),new GbPoint3D(p6))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p7),new GbPoint3D(p6))); - //"hinten" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(p4),new GbPoint3D(pHinten))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pHinten),new GbPoint3D(p7))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p7),new GbPoint3D(pHinten),new GbPoint3D(p8))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pHinten),new GbPoint3D(p4),new GbPoint3D(p8))); - //"vorne" - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(pVorne))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p2),new GbPoint3D(p6))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(pVorne),new GbPoint3D(p5))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p6),new GbPoint3D(p5))); - return triangles; + vector<GbTriangle3D*> triangles; + GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum()); + GbPoint3D p2(getX1Maximum(),getX2Minimum(),getX3Minimum()); + GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Minimum()); + GbPoint3D p4(getX1Minimum(),getX2Maximum(),getX3Minimum()); + GbPoint3D p5(getX1Minimum(),getX2Minimum(),getX3Maximum()); + GbPoint3D p6(getX1Maximum(),getX2Minimum(),getX3Maximum()); + GbPoint3D p7(getX1Maximum(),getX2Maximum(),getX3Maximum()); + GbPoint3D p8(getX1Minimum(),getX2Maximum(),getX3Maximum()); + + GbPoint3D pUnten(getX1Centroid(),getX2Centroid(),getX3Minimum()); + GbPoint3D pOben(getX1Centroid(),getX2Centroid(),getX3Maximum()); + GbPoint3D pLinks(getX1Minimum(), getX2Centroid(),getX3Centroid()); + GbPoint3D pRechts(getX1Maximum(), getX2Centroid(),getX3Centroid()); + GbPoint3D pVorne(getX1Centroid(),getX2Minimum(),getX3Centroid()); + GbPoint3D pHinten(getX1Centroid(),getX2Maximum(),getX3Centroid()); + + //"unten" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pUnten),new GbPoint3D(p3))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p1),new GbPoint3D(pUnten))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pUnten),new GbPoint3D(p4))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p4),new GbPoint3D(pUnten))); + //"oben" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(p6),new GbPoint3D(pOben))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p6),new GbPoint3D(p7),new GbPoint3D(pOben))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(pOben),new GbPoint3D(p8))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pOben),new GbPoint3D(p7),new GbPoint3D(p8))); + //"links" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(p1),new GbPoint3D(pLinks))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(pLinks),new GbPoint3D(p8))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p8),new GbPoint3D(pLinks),new GbPoint3D(p5))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pLinks),new GbPoint3D(p1),new GbPoint3D(p5))); + //"rechts" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p3),new GbPoint3D(pRechts))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p3),new GbPoint3D(p7))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pRechts),new GbPoint3D(p6))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p7),new GbPoint3D(p6))); + //"hinten" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(p4),new GbPoint3D(pHinten))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pHinten),new GbPoint3D(p7))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p7),new GbPoint3D(pHinten),new GbPoint3D(p8))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pHinten),new GbPoint3D(p4),new GbPoint3D(p8))); + //"vorne" + triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(pVorne))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p2),new GbPoint3D(p6))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(pVorne),new GbPoint3D(p5))); + triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p6),new GbPoint3D(p5))); + return triangles; } /*=======================================================*/ void GbCuboid3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) { - /*0*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Minimum())); - /*1*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Minimum())); - /*2*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Minimum())); - /*3*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Minimum())); - - /*4*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Maximum())); - /*5*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Maximum())); - /*6*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Maximum())); - /*7*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Maximum())); - - //"unten" - triangles.push_back( makeUbTuple( 0, 1, 2) ); - triangles.push_back( makeUbTuple( 0, 2, 3) ); - //"oben" - triangles.push_back( makeUbTuple( 4, 5, 6) ); - triangles.push_back( makeUbTuple( 4, 6, 7) ); - //"links" - triangles.push_back( makeUbTuple( 0, 3, 7) ); - triangles.push_back( makeUbTuple( 0, 7, 4) ); - //"rechts" - triangles.push_back( makeUbTuple( 1, 2, 6) ); - triangles.push_back( makeUbTuple( 1, 6, 5) ); - //"hinten" - triangles.push_back( makeUbTuple( 3, 2, 7) ); - triangles.push_back( makeUbTuple( 2, 7, 6) ); - //"vorne" - triangles.push_back( makeUbTuple( 0, 1, 5) ); - triangles.push_back( makeUbTuple( 0, 5, 4) ); -} -/*=======================================================*/ -string GbCuboid3D::toString() -{ - stringstream ss; - ss<<"GbCuboid3D["; - ss<<"p1="<<this->p1->toString(); - ss<<", p2="<<this->p2->toString(); - ss<<"]"; - return ss.str(); + /*0*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Minimum())); + /*1*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Minimum())); + /*2*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Minimum())); + /*3*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Minimum())); + + /*4*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Maximum())); + /*5*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Maximum())); + /*6*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Maximum())); + /*7*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Maximum())); + + //"unten" + triangles.push_back( makeUbTuple( 0, 1, 2) ); + triangles.push_back( makeUbTuple( 0, 2, 3) ); + //"oben" + triangles.push_back( makeUbTuple( 4, 5, 6) ); + triangles.push_back( makeUbTuple( 4, 6, 7) ); + //"links" + triangles.push_back( makeUbTuple( 0, 3, 7) ); + triangles.push_back( makeUbTuple( 0, 7, 4) ); + //"rechts" + triangles.push_back( makeUbTuple( 1, 2, 6) ); + triangles.push_back( makeUbTuple( 1, 6, 5) ); + //"hinten" + triangles.push_back( makeUbTuple( 3, 2, 7) ); + triangles.push_back( makeUbTuple( 2, 7, 6) ); + //"vorne" + triangles.push_back( makeUbTuple( 0, 1, 5) ); + triangles.push_back( makeUbTuple( 0, 5, 4) ); +} +/*=======================================================*/ +string GbCuboid3D::toString() +{ + stringstream ss; + ss<<"GbCuboid3D["; + ss<<"p1="<<this->p1->toString(); + ss<<", p2="<<this->p2->toString(); + ss<<"]"; + return ss.str(); } /*=======================================================*/ GbPoint3D* GbCuboid3D::calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D& point2) { - throw UbException(UB_EXARGS,"not correct implemented"); + throw UbException(UB_EXARGS,"not correct implemented"); } /*=======================================================*/ GbLine3D* GbCuboid3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) { - return GbSystem3D::createClipLine3D(point1, point2, - p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(), - p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() ); + return GbSystem3D::createClipLine3D(point1, point2, + p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(), + p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() ); } /*==========================================================*/ void GbCuboid3D::objectChanged(UbObservable* changedObject) { - GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject); - if(!point || (this->p1!=point && this->p2!=point)) return; + GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject); + if(!point || (this->p1!=point && this->p2!=point)) return; - this->notifyObserversObjectChanged(); + this->notifyObserversObjectChanged(); } /*==========================================================*/ void GbCuboid3D::objectWillBeDeleted(UbObservable* objectForDeletion) { - if(this->p1) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1); - if(objectForDeletion == observedObj) { this->p1 = NULL; } - } - if(this->p2) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2); - if(objectForDeletion == observedObj) { this->p2 = NULL; } - } - //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo -} -/*=======================================================*/ -void GbCuboid3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*=======================================================*/ -void GbCuboid3D::read(UbFileInput* in) -{ - in->readString(); - this->p1 = new GbPoint3D; - p1->read(in); - in->readString(); - this->p2 = new GbPoint3D; - p2->read(in); + if(this->p1) + { + UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1); + if(objectForDeletion == observedObj) { this->p1 = NULL; } + } + if(this->p2) + { + UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2); + if(objectForDeletion == observedObj) { this->p2 = NULL; } + } + //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo } /*=======================================================*/ void GbCuboid3D::translate(const double& tx1, const double& tx2, const double& tx3) -{ - this->p1->translate(tx1, tx2, tx3); - this->p2->translate(tx1, tx2, tx3); - this->notifyObserversObjectChanged(); +{ + this->p1->translate(tx1, tx2, tx3); + this->p2->translate(tx1, tx2, tx3); + this->notifyObserversObjectChanged(); } /*=======================================================*/ void GbCuboid3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - double lenX1 = this->getLengthX1(); - double lenX2 = this->getLengthX2(); - double lenX3 = this->getLengthX3(); +{ + double lenX1 = this->getLengthX1(); + double lenX2 = this->getLengthX2(); + double lenX3 = this->getLengthX3(); - double deltaX1 = lenX1*sx1 - lenX1; - double deltaX2 = lenX2*sx2 - lenX2; - double deltaX3 = lenX3*sx3 - lenX3; + double deltaX1 = lenX1*sx1 - lenX1; + double deltaX2 = lenX2*sx2 - lenX2; + double deltaX3 = lenX3*sx3 - lenX3; - double p1X1 = this->p1->getX1Coordinate(); - double p1X2 = this->p1->getX2Coordinate(); - double p1X3 = this->p1->getX3Coordinate(); + double p1X1 = this->p1->getX1Coordinate(); + double p1X2 = this->p1->getX2Coordinate(); + double p1X3 = this->p1->getX3Coordinate(); - double p2X1 = this->p2->getX1Coordinate(); - double p2X2 = this->p2->getX2Coordinate(); - double p2X3 = this->p2->getX3Coordinate(); + double p2X1 = this->p2->getX1Coordinate(); + double p2X2 = this->p2->getX2Coordinate(); + double p2X3 = this->p2->getX3Coordinate(); - this->p1->setCoordinates(p1X1 - 0.5*deltaX1 - ,p1X2 - 0.5*deltaX2 - ,p1X3 - 0.5*deltaX3); + this->p1->setCoordinates(p1X1 - 0.5*deltaX1 + ,p1X2 - 0.5*deltaX2 + ,p1X3 - 0.5*deltaX3); - this->p2->setCoordinates(p2X1 + 0.5*deltaX1 - ,p2X2 + 0.5*deltaX2 - ,p2X3 + 0.5*deltaX3); + this->p2->setCoordinates(p2X1 + 0.5*deltaX1 + ,p2X2 + 0.5*deltaX2 + ,p2X3 + 0.5*deltaX3); } /*==========================================================*/ double GbCuboid3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) { - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*(x1b-x1a)*(x2b-x2a)*(x3b-x3a); - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; + if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*(x1b-x1a)*(x2b-x2a)*(x3b-x3a); + if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b); + GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b); - if(cube) - { - double eps; - eps = (cube->getLengthX1())*(cube->getLengthX2())*(cube->getLengthX3()); - cube->finalize(); - delete cube; - return eps; - } - return 0.0; + if(cube) + { + double eps; + eps = (cube->getLengthX1())*(cube->getLengthX2())*(cube->getLengthX3()); + cube->finalize(); + delete cube; + return eps; + } + return 0.0; } /*==========================================================*/ double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { - double minB[3] = { this->getX1Minimum(), this->getX2Minimum(), this->getX3Minimum() }; - double maxB[3] = { this->getX1Maximum(), this->getX2Maximum(), this->getX3Maximum() }; - double origin[3] = { x1, x2, x3 }; //point - double dir[3] = { rx1, rx2, rx3 }; //ray - - bool inside = true; - char quadrant[3]; - int whichPlane; - double maxT[3]; - double candidatePlane[3]; - - /* Find candidate planes; this loop can be avoided if - rays cast all from the eye(assume perpsective view) */ - for(int i=0; i<3; i++) - { - if(origin[i] < minB[i]) - { - quadrant[i] = 1/*LEFT*/; - candidatePlane[i] = minB[i]; - inside = false; - } - else if(origin[i] > maxB[i]) - { - quadrant[i] = 0/*RIGHT*/; - candidatePlane[i] = maxB[i]; - inside = false; - } - else - { - quadrant[i] = 2/*MIDDLE*/; - } - } - /* Ray origin inside bounding box */ - if(inside) - { - //throw UbException(UB_EXARGS,"not done"); - return 0.0; - } - - /* Calculate T distances to candidate planes */ - for(int i=0; i<3; i++) - { - if( quadrant[i]!=2/*MIDDLE*/ && fabs(dir[i])>1.E-10 ) - { - maxT[i] = (candidatePlane[i]-origin[i])/dir[i]; - } - else maxT[i] = -1.0; - } - - /* Get largest of the maxT's for final choice of intersection */ - whichPlane = 0; - for(int i=1; i<3; i++) - if (maxT[whichPlane] < maxT[i]) + double minB[3] = { this->getX1Minimum(), this->getX2Minimum(), this->getX3Minimum() }; + double maxB[3] = { this->getX1Maximum(), this->getX2Maximum(), this->getX3Maximum() }; + double origin[3] = { x1, x2, x3 }; //point + double dir[3] = { rx1, rx2, rx3 }; //ray + + bool inside = true; + char quadrant[3]; + int whichPlane; + double maxT[3]; + double candidatePlane[3]; + + /* Find candidate planes; this loop can be avoided if + rays cast all from the eye(assume perpsective view) */ + for(int i=0; i<3; i++) + { + if(origin[i] < minB[i]) + { + quadrant[i] = 1/*LEFT*/; + candidatePlane[i] = minB[i]; + inside = false; + } + else if(origin[i] > maxB[i]) + { + quadrant[i] = 0/*RIGHT*/; + candidatePlane[i] = maxB[i]; + inside = false; + } + else + { + quadrant[i] = 2/*MIDDLE*/; + } + } + /* Ray origin inside bounding box */ + if(inside) + { + //throw UbException(UB_EXARGS,"not done"); + return 0.0; + } + + /* Calculate T distances to candidate planes */ + for(int i=0; i<3; i++) + { + if( quadrant[i]!=2/*MIDDLE*/ && fabs(dir[i])>1.E-10 ) + { + maxT[i] = (candidatePlane[i]-origin[i])/dir[i]; + } + else maxT[i] = -1.0; + } + + /* Get largest of the maxT's for final choice of intersection */ + whichPlane = 0; + for(int i=1; i<3; i++) + if (maxT[whichPlane] < maxT[i]) whichPlane = i; - - /* Check final candidate actually inside box */ - if(maxT[whichPlane]< -1.E-10) return -1.0; - double dummy; - for(int i= 0; i<3; i++) - { - if( whichPlane!= i) - { - dummy = origin[i] + maxT[whichPlane]*dir[i]; - if(dummy < minB[i] || dummy > maxB[i]) - return -1.0; - } - } - - return maxT[whichPlane] ; /* ray hits box */ -} -/*==========================================================*/ -// double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -// { -// double absX,absMaxX,absY,absMaxY,absZ,absMaxZ; -// -// if(rx1<0.0) absX = this->getX1Maximum() - x1; -// else absX = this->getX1Minimum() - x1; -// if(1-(rx1<0.0)) absMaxX = this->getX1Maximum() - x1; -// else absMaxX = this->getX1Minimum() - x1; -// -// if(rx2<0.0) absY = this->getX2Maximum() - x2; -// else absY = this->getX2Minimum() - x2; -// if(1-(rx2<0.0)) absMaxY = this->getX2Maximum() - x2; -// else absMaxY = this->getX2Minimum() - x2; -// -// if(rx3<0.0) absZ = this->getX3Maximum() - x3; -// else absZ = this->getX3Minimum() - x3; -// if(1-(rx3<0.0)) absMaxZ = this->getX3Maximum() - x3; -// else absMaxZ = this->getX3Minimum() - x3; -// -// -// //tmin ist die verschneidung des Gerade (Ray) durch die naehere Gerade (MinX oder MaxX) -// //tmax ist die verschneidung des Gerade (Ray) durch die weiteste Gerade (MinX oder MaxX) -// //analog fuer tymin und tymax -// double tmin, tymin, tzmin, tmax, tymax, tzmax; -// -// if(!UbMath::zero(rx1)) tmin = tmax = 1.0/rx1; -// else if(rx1<0.0) tmin = tmax = -UbMath::getPositiveInfinity<double>(); -// else tmin = tmax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx2)) tymin = tymax = 1.0/rx2; -// else if(rx2<0.0) tymin = tymax = -UbMath::getPositiveInfinity<double>(); -// else tymin = tymax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx3)) tzmin = tzmax = 1.0/rx3; -// else if(rx1<0.0) tzmin = tzmax = -UbMath::getPositiveInfinity<double>(); -// else tzmin = tzmax = UbMath::getPositiveInfinity<double>(); -// -// //tmin *= absX; -// //tmax *= absMaxX; -// //tymin *= absY; -// //tymax *= absMaxY; -// //tzmin *= absZ; -// //tzmax *= absMaxZ; -// -// //0 * 1/0 vermeiden, da es ein Undefined wert produziert -// if( !UbMath::zero(absX) || !UbMath::zero(rx1) ) tmin *= absX; -// else tmin = tymin; -// -// if( !UbMath::zero(absY) || !UbMath::zero(rx2)) tymin *= absY; -// else tymin = tmin; -// -// if( !UbMath::zero(absZ) || !UbMath::zero(rx3)) tzmin *= absZ; -// else tzmin = tymin; -// -// if( !UbMath::zero(absMaxX) || !UbMath::zero(rx1)) tmax *= absMaxX; -// else tmax = tymax; -// -// if( !UbMath::zero(absMaxY) || !UbMath::zero(rx2)) tymax *= absMaxY; -// else tymax = tmax; -// -// if( !UbMath::zero(absMaxZ) || !UbMath::zero(rx3)) tzmax *= absMaxZ; -// else tzmax = tymax; -// -// //in dieser Fall gibt es keine Verschneidung -// if( (tmin > tymax) || (tymin > tmax) ) return -1; -// -// tmin = UbMath::max(tmin,tymin,tzmin); -// tmax = UbMath::min(tmax,tymax,tzmax); -// -// if( (tmin > tzmax) || (tzmin > tmax) ) return -1; -// if(tmin >= 0.0) return tmin ; -// -// return tmax; -//} + + /* Check final candidate actually inside box */ + if(maxT[whichPlane]< -1.E-10) return -1.0; + double dummy; + for(int i= 0; i<3; i++) + { + if( whichPlane!= i) + { + dummy = origin[i] + maxT[whichPlane]*dir[i]; + if(dummy < minB[i] || dummy > maxB[i]) + return -1.0; + } + } + + return maxT[whichPlane] ; /* ray hits box */ +} + diff --git a/src/basics/geometry3d/GbCuboid3D.h b/src/basics/geometry3d/GbCuboid3D.h index d6082dd69..3e26888e7 100644 --- a/src/basics/geometry3d/GbCuboid3D.h +++ b/src/basics/geometry3d/GbCuboid3D.h @@ -1,20 +1,42 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCuboid3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBCUBOID3D_H #define GBCUBOID3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <vector> #include <cmath> -#include <geometry3d/GbPoint3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbObserver.h> #include <basics/utilities/UbMath.h> @@ -25,120 +47,99 @@ class GbObject3DCreator; class GbCuboid3D; typedef SPtr<GbCuboid3D> GbCuboid3DPtr; - +//! \brief This Class provides basic 3D box objects. class GbCuboid3D : public GbObject3D, public UbObserver { -public: - GbCuboid3D(); - GbCuboid3D(const double& minX1,const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); - GbCuboid3D(GbPoint3D *p1, GbPoint3D *p2); - GbCuboid3D(GbCuboid3D *cuboid); - ~GbCuboid3D(); - - GbCuboid3D* clone() { return new GbCuboid3D(this); } - void finalize(); - - GbPoint3D* getPoint1() { return this->p1; } - GbPoint3D* getPoint2() { return this->p2; } - - void setPoint1(GbPoint3D* point1); - void setPoint2(GbPoint3D* point2); - void setPoints(GbPoint3D* point1, GbPoint3D* point2); - - double getX1Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Centroid(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Centroid(); - double getX3Minimum(); - double getX3Maximum(); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - - void translate(const double& x1, const double& x2, const double& x3); - void rotate(const double& rx1, const double& rx2, const double& rx3) {} - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getLengthX1(); - double getLengthX2(); - double getLengthX3(); - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - GbPoint3D* calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2); - //GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - - double getDistance(GbPoint3D* p) - { - return this->getDistance( p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate() ); - } - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - throw UbException( UB_EXARGS, "not implemented" ); - - // falls punkt innerhalt ist: minimalen abstand ausrechnen - if( this->isPointInGbObject3D(x1p,x2p,x3p) ) - { - double x1Dist = UbMath::min( std::abs(x1p-this->getX1Minimum()),std::abs(x1p-this->getX1Maximum()) ); - double x2Dist = UbMath::min( std::abs(x2p-this->getX2Minimum()),std::abs(x2p-this->getX2Maximum()) ); - double x3Dist = UbMath::min( std::abs(x3p-this->getX3Minimum()),std::abs(x3p-this->getX3Maximum()) ); - - return UbMath::min( x1Dist, x2Dist, x3Dist ); - } - else - { - - } - } - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - } -#endif //CAB_RCF +public: + GbCuboid3D(); + GbCuboid3D(const double& minX1,const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); + GbCuboid3D(GbPoint3D *p1, GbPoint3D *p2); + GbCuboid3D(GbCuboid3D *cuboid); + ~GbCuboid3D(); + + GbCuboid3D* clone() { return new GbCuboid3D(this); } + void finalize(); + + GbPoint3D* getPoint1() { return this->p1; } + GbPoint3D* getPoint2() { return this->p2; } + + void setPoint1(GbPoint3D* point1); + void setPoint2(GbPoint3D* point2); + void setPoints(GbPoint3D* point1, GbPoint3D* point2); + + double getX1Centroid(); + double getX1Minimum(); + double getX1Maximum(); + double getX2Centroid(); + double getX2Minimum(); + double getX2Maximum(); + double getX3Centroid(); + double getX3Minimum(); + double getX3Maximum(); + void setCenterCoordinates(const double& x1, const double& x2, const double& x3); + + void translate(const double& x1, const double& x2, const double& x3); + void rotate(const double& rx1, const double& rx2, const double& rx3) {} + void scale(const double& sx1, const double& sx2, const double& sx3); + + double getLengthX1(); + double getLengthX2(); + double getLengthX3(); + + bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); + bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); + bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + + GbPoint3D* calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2); + //GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); + + std::vector<GbTriangle3D*> getSurfaceTriangleSet(); + void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); + + bool hasRaytracing() { return true; } + /*|r| must be 1! einheitsvector!!*/ + double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); + + + double getDistance(GbPoint3D* p) + { + return this->getDistance( p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate() ); + } + double getDistance(const double& x1p, const double& x2p, const double& x3p) + { + throw UbException( UB_EXARGS, "not implemented" ); + + // falls punkt innerhalt ist: minimalen abstand ausrechnen + if( this->isPointInGbObject3D(x1p,x2p,x3p) ) + { + double x1Dist = UbMath::min( std::abs(x1p-this->getX1Minimum()),std::abs(x1p-this->getX1Maximum()) ); + double x2Dist = UbMath::min( std::abs(x2p-this->getX2Minimum()),std::abs(x2p-this->getX2Maximum()) ); + double x3Dist = UbMath::min( std::abs(x3p-this->getX3Minimum()),std::abs(x3p-this->getX3Maximum()) ); + + return UbMath::min( x1Dist, x2Dist, x3Dist ); + } + else + { + + } + } + + std::string toString(); + + //virtuelle Methoden von UbObserver + void objectChanged(UbObservable* changedObject); + void objectWillBeDeleted(UbObservable* objectForDeletion); + + + using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere protected: - GbPoint3D* p1; - GbPoint3D* p2; + GbPoint3D* p1; + GbPoint3D* p2; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCuboid3D>("GbCuboid3D") , SF_GbCuboid3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCuboid3D >()), SF_GbCuboid3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCuboid3D>() ), SF_GbCuboid3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - #endif diff --git a/src/basics/geometry3d/GbLine3D.cpp b/src/basics/geometry3d/GbLine3D.cpp index f71d0a36b..9d4c5a6c4 100644 --- a/src/basics/geometry3d/GbLine3D.cpp +++ b/src/basics/geometry3d/GbLine3D.cpp @@ -1,16 +1,42 @@ -#include <geometry3d/GbLine3D.h> -#include <geometry3d/creator/GbLine3DCreator.h> - -#include <geometry3d/GbSystem3D.h> -#include <geometry3d/GbCuboid3D.h> -#include <geometry3d/GbTriangle3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbLine3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbLine3D.h> +#include <GbSystem3D.h> +#include <GbCuboid3D.h> +#include <GbTriangle3D.h> using namespace std; -ObObjectCreator* GbLine3D::getCreator() -{ - return GbLine3DCreator::getInstance(); -} /*=======================================================*/ GbLine3D::GbLine3D() { @@ -183,26 +209,6 @@ void GbLine3D::objectWillBeDeleted(UbObservable* objectForDeletion) //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo } /*==========================================================*/ -void GbLine3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*==========================================================*/ -void GbLine3D::read(UbFileInput* in) -{ - p1 = new GbPoint3D; - p2 = new GbPoint3D; - in->readString(); - p1->read(in); - p1->addObserver(this); - in->readString(); - p2->read(in); - p2->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ void GbLine3D::scale(const double& sx1, const double& sx2, const double& sx3) { double p1X1 = this->p1->getX1Coordinate(); diff --git a/src/basics/geometry3d/GbLine3D.h b/src/basics/geometry3d/GbLine3D.h index fcc2e9128..2990282f9 100644 --- a/src/basics/geometry3d/GbLine3D.h +++ b/src/basics/geometry3d/GbLine3D.h @@ -1,38 +1,58 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbLine3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBLINE3D_H #define GBLINE3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <sstream> #include <cmath> #include <basics/utilities/UbObserver.h> -#include <geometry3d/GbObject3D.h> -#include <geometry3d/GbPoint3D.h> +#include <GbObject3D.h> +#include <GbPoint3D.h> class GbCuboid3D; -class GbObject3DCreator; #include <PointerDefinitions.h> - -/*=========================================================================*/ -/* GbLine3D */ -/* */ -/** - * This Class provides basic 3D line objects. - * The describing points are observed by 3D line objects. - * <BR><BR><HR> -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbLine3D +//! +//! \brief This Class provides basic 3D line objects. +//! \details The describing points are observed by 3D line objects. +//! +////////////////////////////////////////////////////////////////////////// class GbLine3D : public GbObject3D , public UbObserver { @@ -101,21 +121,6 @@ public: void objectWillBeDeleted(UbObservable* objectForDeletion); std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - ar & length; - if( ArchiveTools::isReading(ar) ) this->calculateValues(); - } -#endif //CAB_RCF using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere protected: @@ -127,10 +132,4 @@ private: void calculateValues(); }; -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbLine3D>("GbLine3D"), SF_GbLine3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbLine3D >()), SF_GbLine3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbLine3D>() ), SF_GbLine3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbObject3D.cpp b/src/basics/geometry3d/GbObject3D.cpp index 23caf63ad..1e96e72f3 100644 --- a/src/basics/geometry3d/GbObject3D.cpp +++ b/src/basics/geometry3d/GbObject3D.cpp @@ -1,14 +1,41 @@ -#include <geometry3d/GbObject3D.h> -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbPoint3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObject3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbObject3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbMath.h> using namespace std; -string GbObject3D::getTypeID() -{ - return this->getCreator()->getTypeID(); -} /*======================================================================*/ bool GbObject3D::isPointInGbObject3D(GbPoint3D* p) { diff --git a/src/basics/geometry3d/GbObject3D.h b/src/basics/geometry3d/GbObject3D.h index 9536a8253..09a3ef38b 100644 --- a/src/basics/geometry3d/GbObject3D.h +++ b/src/basics/geometry3d/GbObject3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObject3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBOBJECT3D_H #define GBOBJECT3D_H @@ -11,14 +37,8 @@ #include <vector> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> #include <basics/utilities/UbObservable.h> #include <basics/utilities/UbTuple.h> #include <basics/objects/ObObject.h> @@ -28,47 +48,23 @@ class GbLine3D; class GbTriangle3D; class GbObject3DCreator; -#ifdef CAB_CTL -#include <ctl.h> -#endif - -#include "basics_export.h" #include <PointerDefinitions.h> +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbObject3D +//! +//! \brief This Interface provides basic 3D geometry objects methods. +//! +////////////////////////////////////////////////////////////////////////// -/*=========================================================================*/ -/* GbObject3D */ -/* */ -/** - * This Interface provides basic 3D geometry objects methods. - * <BR><BR><HR> - * @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> - * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> - * @version 1.0 - 02.02.05 -*/ -class BASICS_EXPORT GbObject3D : public ObObject +class GbObject3D : public ObObject { public: -#ifdef CAB_CTL - virtual ctl::oStream &write(ctl::oStream &os) const - { - return os; - } - virtual ctl::iStream &read(ctl::iStream &is) - { - return is; - } -#endif - virtual ~GbObject3D(){} - //ueberschriebene methode von ObObject - virtual std::string getTypeID(); - //abstract Methods virtual void finalize() =0 ; //detroys also all dynamic objects (e.g. GbPoints in GbLine) - virtual ObObjectCreator* getCreator()=0; - /** * Returns the centroid x1 coordinate of this 3D object. * @return the centroid x1 coordinate of this 3D object @@ -129,9 +125,6 @@ public: virtual void translate(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual void scale(const double& sx1, const double& sx2, const double& sx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void write(UbFileOutput* out)=0; - virtual void read(UbFileInput* in)=0; - virtual bool isPointInGbObject3D(GbPoint3D* p); virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)=0; virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)=0; @@ -153,21 +146,7 @@ public: //|r| must be 1! einheitsvector!! //return negativ value oder zero if no intersection virtual double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { throw UbException("GbObject3D::getIntersectionRaytraceFactor - not implemented"); } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<ObObject>(ar, *this); - } -#endif //CAB_RCF }; /*=========================================================================*/ -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - SF_NO_CTOR(GbObject3D); - UB_AUTO_RUN_NAMED(SF::registerType<GbObject3D>("GbObject3D") , SF_GbObject3D); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<ObObject, GbObject3D >() ), SF_GbObject3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - - #endif diff --git a/src/basics/geometry3d/GbPoint3D.cpp b/src/basics/geometry3d/GbPoint3D.cpp index 8796c8644..6bbc18011 100644 --- a/src/basics/geometry3d/GbPoint3D.cpp +++ b/src/basics/geometry3d/GbPoint3D.cpp @@ -1,14 +1,38 @@ -#include <geometry3d/GbPoint3D.h> -//#include <geometry3d/GbTriangle3D.h> -#include <geometry3d/creator/GbPoint3DCreator.h> - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPoint3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbPoint3D.h> using namespace std; -/*=======================================================*/ -ObObjectCreator* GbPoint3D::getCreator() -{ - return GbPoint3DCreator::getInstance(); -} /*=======================================================*/ GbPoint3D::GbPoint3D() { @@ -77,7 +101,7 @@ vector<GbTriangle3D*> GbPoint3D::getSurfaceTriangleSet() //old: //to avoid unnecessary exceptions a point will generate a triangle with - //three point with same coordinates + //c3 point with same coordinates //vector<GbTriangle3D*> triangles; //GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate()); //triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1))); @@ -95,31 +119,11 @@ string GbPoint3D::toString() return((ss.str()).c_str()); } /*=======================================================*/ -void GbPoint3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(x1); - out->writeDouble(x2); - out->writeDouble(x3); -} -/*=======================================================*/ -void GbPoint3D::read(UbFileInput* in) -{ - x1=in->readDouble(); - x2=in->readDouble(); - x3=in->readDouble(); -} -/*=======================================================*/ void GbPoint3D::translate(const double& dx1, const double& dx2, const double& dx3) { this->x1 += dx1; this->x2 += dx2; this->x3 += dx3; - // wenn Notify hier dann nicht im Cuboid oder spher translate ?! - //sollte eigentlich! - //--> hier muss notify aufgerufen werden udn rekuriv dann z.B. Cuboid, etc - - //aber da ist halt einfach daemlich, ich asse es auf gellers way... (erstmal) this->notifyObserversObjectChanged(); } /*=======================================================*/ diff --git a/src/basics/geometry3d/GbPoint3D.h b/src/basics/geometry3d/GbPoint3D.h index 99adbc3f7..74b8cafaa 100644 --- a/src/basics/geometry3d/GbPoint3D.h +++ b/src/basics/geometry3d/GbPoint3D.h @@ -1,31 +1,49 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPoint3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBPOINT3D_H #define GBPOINT3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <string> #include <sstream> #include <cmath> -#include <geometry3d/GbObject3D.h> +#include <GbObject3D.h> #include <PointerDefinitions.h> class GbTriangle3D; -class GbObject3DCreator; - -#ifdef CAB_CTL - #include <ctl.h> -#endif +//! \brief This Class provides basic 3D point objects. class GbPoint3D : public GbObject3D { public: @@ -77,33 +95,9 @@ public: std::vector<GbTriangle3D*> getSurfaceTriangleSet(); GbLine3D* createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2); virtual std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren //, welche sonst hier "ueberdeckt" waere,da es dieselbe methode mit anderen args gibt! -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & x1; - ar & x2; - ar & x3; - } -#endif //CAB_RCF - -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - return os<<x1<<x2<<x3; - } - ctl::iStream &read(ctl::iStream &is) - { - return is>>x1>>x2>>x3; - } -#endif //member double x1; @@ -112,9 +106,4 @@ public: }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbPoint3D>("GbPoint3D") , SF_GbPoint3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbPoint3D >()), SF_GbPoint3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbPolygon3D.cpp b/src/basics/geometry3d/GbPolygon3D.cpp index 213756e09..713ce56f0 100644 --- a/src/basics/geometry3d/GbPolygon3D.cpp +++ b/src/basics/geometry3d/GbPolygon3D.cpp @@ -1,13 +1,39 @@ -#include <geometry3d/GbPolygon3D.h> -#include <geometry3d/creator/GbPolygon3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPolygon3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbPolygon3D.h> using namespace std; -ObObjectCreator* GbPolygon3D::getCreator() -{ - return GbPolygon3DCreator::getInstance(); -} - int GbPolygon3D::counter = 0; GbPolygon3D::GbPolygon3D() @@ -29,7 +55,7 @@ void GbPolygon3D::init() ps = NULL; } -/** +/*! * Creates an empty 3D polygon with the specified capacity. * @param capacity the initial capacity */ @@ -283,44 +309,6 @@ void GbPolygon3D::addPoints(vector<GbPoint3D>& points) //super.notifyObservers(); } /** -* Inserts a point at the specified position within this polygon. Notifies the observers of this 3D polygon. -* @param point the point -* @param index the index -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -//public void insertPoint(GbPoint3D point, int index) throws ArrayIndexOutOfBoundsException -//{ -// if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.insertPoint(): points of 3D polygons have to be 3D points!"); -// if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon3D.insert(): invalid index specified: "+index); - -// this.ps.insert(point, index); -// point.addObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon identical to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deletePoint(GbPoint3D point) -//{ -// this.ps.delete(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon equal to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deleteEqualPoint(GbPoint3D point) -//{ -// this.ps.deleteEqual(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** * Removes all points from this polygon. Notifies the observers of this 3D polygon. */ void GbPolygon3D::clear() @@ -333,27 +321,6 @@ void GbPolygon3D::clear() this->consistent = false; //super.notifyObservers(); } - -/** -* Returns true if this 3D polygon equals the specified object. -* Two polygon are equal, if their points are equal. -* <BR>Note that the order of points is recognized! -* @return true if this 3D polygon equals the specified object -* @see GbPoint3D#equals(java.lang.Object) -*/ -// bool equals(Object object) -// { -// try -// { -// GbPolygon2D polygon = (GbPolygon3D) object; -//int n = this.size(); - -//if(n != polygon.size()) return(false); -//for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false); -//return(true); -// } -// catch(Exception e){ return(false); } -// } /** * Returns a string representation of this 3D polygon. * @return a string representation of this 3D polygon @@ -363,16 +330,6 @@ string GbPolygon3D::toString() stringstream ss; ss<<"GbPolygon3D["; ss<<this->size()<<" points"; - - // ss<<", x1s="<<this->x1s; - // ss<<", x2s="<<this->x2s; - //ss<<", x3s="<<this->x3s; - // ss<<", x1min="<<this->x1min; - // ss<<", x1max="<<this->x1max; - // ss<<", x2min="<<this->x2min; - // ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - // ss<<", x3max="<<this->x3max; ss<<"]"<<endl; for(int u=0; u<this->size(); u++) ss<<this->ps->getPoint(u)->toString()<<endl; @@ -381,204 +338,6 @@ string GbPolygon3D::toString() } /*======================================================================*/ - -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 3D polygon and the specified 3D line. -* @param line the 3D line to intersect -* @return the intersection points of this 3D polygon and the specified 3D line -*/ -// public GbPoint3D[] calculateIntersectionPoints3D(GbLine3D line) -// { -// GbSystem.PointSet pointSet = new GbSystem.PointSet(0); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D pCrossed = null; -// int n = points.length; -// if(n < 2) return(pointSet.getPoints()); - -// for(int i=1; i<n; i++) -// { -//pCrossed = GbSystem.calculateIntersectionPoint3D(points[i-1], points[i], line.p1, line.p2); -//if(pCrossed != null) pointSet.add(pCrossed); -// } -// pCrossed = GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], line.p1, line.p2); -// if(pCrossed != null) pointSet.add(pCrossed); - -// return(pointSet.getPoints()); -// } - -/* -* Returns true if the specified 3D point lies within (or on the border of) this 3D polygon. -* @param point the 3D point to check -* @return true if the specified 3D point lies within (or on the border of) this 3D polygon -*/ -// public boolean enclosesPoint3D(GbPoint3D point) -// { -// if(GbSystem.less(point.x1, this.x1min)) return(false); -// if(GbSystem.less(point.x2, this.x2min)) return(false); -// if(GbSystem.greater(point.x1, this.x1max)) return(false); -// if(GbSystem.greater(point.x2, this.x2max)) return(false); -// if(this.containsEqual(point) > 0) return(true); - -// QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D ptest; -// int n = points.length; -// if(n < 2) return(false); - -// if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint3D(point.x1, this.x2min-1.0); -// else ptest = new GbPoint3D(point.x1, this.x2max+1.0); - -// for(int i=1; i<n; i++) -// { -//try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } -//catch(Exception e){} -// } -// try { ltest.append(GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], point, ptest)); } -// catch(Exception e){} -// return((ltest.size()%2)==1); -// } - -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param rectangle the 3D rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1 the 1st point of the rectangle -* @param p2 the 2nd point of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbPoint3D *p1, GbPoint3D *p2) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1x1 the 1st x1 coordinate of the rectangle -* @param p1x2 the 1st x2 coordinate of the rectangle -* @param p2x1 the 2nd x1 coordinate of the rectangle -* @param p2x2 the 2nd x2 coordinate of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) -// { -//return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); -// } - -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/*======================================================================*/ - void GbPolygon3D::calculateValues() { this->x1s = 0.0; @@ -591,96 +350,7 @@ void GbPolygon3D::calculateValues() this->x3min = 0.0; this->x3max = 0.0; throw UbException(UB_EXARGS,"should be implemented"); - - //this->consistent = true; - - //this->points = this->ps->getPoints(); - - //int n = (int)this->points.size(); - //if(n < 1) return; - - //GbPoint3D p1 = (this->points)[0]; - //GbPoint3D p2 = NULL; - //double h1 = 0.0; - //double h2 = 0.0; - //double f=0.0; - - //this->x1s = p1.x1; - //this->x1min = p1.x1; - //this->x1max = p1.x1; - //this->x2s = p1.x2; - //this->x2min = p1.x2; - //this->x2max = p1.x2; - //this->x3s = p1.x2; - //this->x3min = p1.x2; - //this->x3max = p1.x2; - - //std::cout<<"Should be implemented "<<endl; - - //for(int i=1; i<n; i++) - //{ - // p2 = (this->points)[i]; - // f = p1.x1*p2.x2 - p1.x2*p2.x1; - // this->area += f; - // h1 += f*(p1.x2 + p2.x2); - // h2 += f*(p1.x1 + p2.x1); - // p1 = p2; - - // if(p1.x1 < this->x1min) this->x1min = p1.x1; - // if(p1.x1 > this->x1max) this->x1max = p1.x1; - // if(p1.x2 < this->x2min) this->x2min = p1.x2; - // if(p1.x2 > this->x2max) this->x2max = p1.x2; - //} - //p2 = (this->points)[0]; - //f = p1.x1*p2.x2 - p1.x2*p2.x1; - //this->area += f; - //h1 += f*(p1.x2 + p2.x2); - //h2 += f*(p1.x1 + p2.x1); - - //this->area *= 0.5; - //h1 /= 6.0; - //h2 /= 6.0; - - //if(n > 2) - //{ - // this->x1s = h2/this->area; - // this->x2s = h1/this->area; - //} - - //if(n < 3 || !GbSystem::inClosedInterval(this->x1s, this->x1min, this->x1max)) this->x1s = 0.5*(this->x1min+this->x1max); - //if(n < 3 || !GbSystem::inClosedInterval(this->x2s, this->x2min, this->x2max)) this->x2s = 0.5*(this->x2min+this->x2max); } /*======================================================================*/ -/*======================================================================*/ -// private class PointObserver implements TiObserver -// { -// GbPolygon3D polygon = null; - -// PointObserver(GbPolygon3D polygon) -// { -//this.polygon = polygon; -// } - -// public void objectChanged(Object object) -// { -//if((object instanceof GbPoint3D) && this.polygon.contains((GbPoint3D)object)>0) -//{ -// this.polygon.consistent = false; -// this.polygon.notifyObservers(); -//} -// } -// } -/*=======================================================*/ -void GbPolygon3D::write(UbFileOutput* out) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ -void GbPolygon3D::read(UbFileInput* in) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ - diff --git a/src/basics/geometry3d/GbPolygon3D.h b/src/basics/geometry3d/GbPolygon3D.h index 372bab268..e9a499c0f 100644 --- a/src/basics/geometry3d/GbPolygon3D.h +++ b/src/basics/geometry3d/GbPolygon3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPolygon3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBPOLYGON3D_H #define GBPOLYGON3D_H @@ -11,21 +37,19 @@ #include <iostream> -#include <geometry3d/GbObject3D.h> -#include <geometry3d/GbLine3D.h> -#include <geometry3d/GbTriangle3D.h> -#include <geometry3d/GbSystem3D.h> +#include <GbObject3D.h> +#include <GbLine3D.h> +#include <GbTriangle3D.h> +#include <GbSystem3D.h> #include <PointerDefinitions.h> -class GbObject3DCreator; /*=========================================================================*/ -/* GbPolygon2D */ +//! \class GbPolygon2D /* */ -/* -* This Class provides basic 3D polygon objects. -*/ +//! \brief This Class provides basic 3D polygon objects. + class GbPolygon3D : public GbObject3D { public: @@ -54,7 +78,7 @@ private: /*======================================================================*/ - /* Konstruktoren */ + /* Construcrors */ /* */ /* * Creates an empty 2D polygon. @@ -149,15 +173,6 @@ public: std::vector<GbPoint3D> getPoints(); /* * Returns the points within the specified rectangle. - * @param rectangle the 2D rectangle - * @return the points within the specified rectangle - */ - //public GbPoint2D[] getPoints(GbRectangle2D rectangle) - //{ - // return(this.getPoints(rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2)); - //} - /* - * Returns the points within the specified rectangle. * @param p1 the 1st point of the rectangle * @param p2 the 2nd point of the rectangle * @return the points within the specified rectangle @@ -203,44 +218,6 @@ public: */ void addPoints(std::vector<GbPoint3D>& points); /* - * Inserts a point at the specified position within this polygon. Notifies the observers of this 2D polygon. - * @param point the point - * @param index the index - * @exception ArrayIndexOutOfBoundsException if the specified index is not valid - */ - //public void insertPoint(GbPoint2D point, int index) throws ArrayIndexOutOfBoundsException - //{ - // if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon2D.insertPoint(): points of 3D polygons have to be 3D points!"); - // if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon2D.insert(): invalid index specified: "+index); - - // this.ps.insert(point, index); - // point.addObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon identical to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deletePoint(GbPoint2D point) - //{ - // this.ps.delete(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon equal to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deleteEqualPoint(GbPoint2D point) - //{ - // this.ps.deleteEqual(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* * Removes all points from this polygon. Notifies the observers of this 2D polygon. */ void clear(); @@ -291,237 +268,12 @@ public: * @return a string representation of this 2D polygon */ std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - /*======================================================================*/ - - - /*======================================================================*/ - /* Calculation */ - /* */ - /* - * Returns the intersection points of this 2D polygon and the specified 2D line. - * @param line the 2D line to intersect - * @return the intersection points of this 2D polygon and the specified 2D line - */ - // public GbPoint2D[] calculateIntersectionPoints2D(GbLine2D line) - // { - // GbSystem.PointSet pointSet = new GbSystem.PointSet(0); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D pCrossed = null; - // int n = points.length; - // if(n < 2) return(pointSet.getPoints()); - - // for(int i=1; i<n; i++) - // { - //pCrossed = GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], line.p1, line.p2); - //if(pCrossed != null) pointSet.add(pCrossed); - // } - // pCrossed = GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], line.p1, line.p2); - // if(pCrossed != null) pointSet.add(pCrossed); - - // return(pointSet.getPoints()); - // } - - /* - * Returns true if the specified 2D point lies within (or on the border of) this 2D polygon. - * @param point the 2D point to check - * @return true if the specified 2D point lies within (or on the border of) this 2D polygon - */ - // public boolean enclosesPoint2D(GbPoint2D point) - // { - // if(GbSystem.less(point.x1, this.x1min)) return(false); - // if(GbSystem.less(point.x2, this.x2min)) return(false); - // if(GbSystem.greater(point.x1, this.x1max)) return(false); - // if(GbSystem.greater(point.x2, this.x2max)) return(false); - // if(this.containsEqual(point) > 0) return(true); - - // QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D ptest; - // int n = points.length; - // if(n < 2) return(false); - - // if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint2D(point.x1, this.x2min-1.0); - // else ptest = new GbPoint2D(point.x1, this.x2max+1.0); - - // for(int i=1; i<n; i++) - // { - //try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } - //catch(Exception e){} - // } - // try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], point, ptest)); } - // catch(Exception e){} - // return((ltest.size()%2)==1); - // } - - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param rectangle the 2D rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1 the 1st point of the rectangle - * @param p2 the 2nd point of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon2D(GbPoint3D *p1, GbPoint3D *p2) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) - // { - //return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); - // }; - - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /*======================================================================*/ - /*======================================================================*/ /* Private Methoden */ /* */ void calculateValues(); /*======================================================================*/ - - - /*======================================================================*/ - // private class PointObserver implements TiObserver - // { - // GbPolygon2D polygon = null; - - // PointObserver(GbPolygon2D polygon) - // { - //this.polygon = polygon; - // } - - // public void objectChanged(Object object) - // { - //if((object instanceof GbPoint2D) && this.polygon.contains((GbPoint2D)object)>0) - //{ - // this.polygon.consistent = false; - // this.polygon.notifyObservers(); - //} - // } - // } - /*======================================================================*/ }; /*=========================================================================*/ #endif diff --git a/src/basics/geometry3d/GbSystem3D.cpp b/src/basics/geometry3d/GbSystem3D.cpp index 42351f26a..142b584f3 100644 --- a/src/basics/geometry3d/GbSystem3D.cpp +++ b/src/basics/geometry3d/GbSystem3D.cpp @@ -1,7 +1,38 @@ -#include <geometry3d/GbSystem3D.h> - -#include <geometry3d/GbPolygon3D.h> -#include <geometry3d/GbCuboid3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSystem3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbSystem3D.h> +#include <GbPolygon3D.h> +#include <GbCuboid3D.h> using namespace std; @@ -1012,7 +1043,7 @@ void GbSystem3D::PointSet3::insert(const GbPoint3D& point, int index) /*=======================================================*/ void GbSystem3D::PointSet3::clear() { - //clears points (size==0 but capacity is the old one) + //clears points (size==0 but capacity is the old c1) this->points.clear(); this->consistent = false; } @@ -1084,7 +1115,7 @@ int GbSystem3D::PointSet3::containsEqual(const GbPoint3D& point) /*=======================================================*/ bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2) { - //returns true if pointset has two in "this->points"vector neighboured points + //returns true if pointset has c2 in "this->points"vector neighboured points //wich have the same adress as point1 or point2 vector<GbPoint3D>::iterator pos1=this->points.begin(); vector<GbPoint3D>::iterator pos2; @@ -1102,7 +1133,7 @@ bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2) /*=======================================================*/ bool GbSystem3D::PointSet3::containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2) { - //returns true if pointset has two in "this->points"vector neighboured points + //returns true if pointset has c2 in "this->points"vector neighboured points //wich have the same coordinates as point1 or point2 vector<GbPoint3D>::iterator pos1=this->points.begin(); vector<GbPoint3D>::iterator pos2; diff --git a/src/basics/geometry3d/GbSystem3D.h b/src/basics/geometry3d/GbSystem3D.h index d96d224da..bfe97c3d0 100644 --- a/src/basics/geometry3d/GbSystem3D.h +++ b/src/basics/geometry3d/GbSystem3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSystem3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBSYSTEM3D_H #define GBSYSTEM3D_H @@ -11,9 +37,9 @@ #include <cmath> #include <vector> +#include <GbPoint3D.h> +#include <GbObject3D.h> #include <basics/utilities/UbMath.h> -#include <geometry3d/GbPoint3D.h> -#include <geometry3d/GbObject3D.h> #include <basics/writer/WbWriter.h> class GbPolygon3D; diff --git a/src/basics/geometry3d/GbTriangle3D.cpp b/src/basics/geometry3d/GbTriangle3D.cpp index 86d5a698e..51edfa5ea 100644 --- a/src/basics/geometry3d/GbTriangle3D.cpp +++ b/src/basics/geometry3d/GbTriangle3D.cpp @@ -1,29 +1,43 @@ -#include <geometry3d/GbTriangle3D.h> -#include <geometry3d/creator/GbTriangle3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangle3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbTriangle3D.h> +#include <GbSystem3D.h> +#include <GbLine3D.h> +#include <GbCuboid3D.h> #include <basics/utilities/UbMath.h> -#include <geometry3d/GbSystem3D.h> -#include <geometry3d/GbLine3D.h> -#include <geometry3d/GbCuboid3D.h> -//#include <geometry3d/GbPolygon3D.h> - -using namespace std; - -ObObjectCreator* GbTriangle3D::getCreator() -{ - return GbTriangle3DCreator::getInstance(); -} - -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -* The describing points are observed by 2D triangle objects. -* <BR><BR><HR> -* @version 1.0 - 24.01.05 -*/ +using namespace std; GbTriangle3D::GbTriangle3D() { @@ -245,42 +259,6 @@ void GbTriangle3D::setPoint(GbPoint3D* point, int index) this->calculateNormal(); } -/* -* Returns true if this 2D triangle equals the specified object. -* Two triangle are equal, if their points are equal. -* <BR>Note that the order of points is not recognized! -* @return true if this 2D triangle equals the specified object -* @see GbPoint2D#equals(java.lang.Object) -* @see GbPoint3D#equals(java.lang.Object) -*/ -//bool equals(GbObject3D *object) -//{ -// try -// { -// GbTriangle3D *triangle = (GbTriangle3D*) object; - -//if(this.points[0].equals(triangle.points[0])) -//{ -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[1])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[1])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[2])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[1])) return(true); -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//return(false); -// } -// catch(Exception e){ return(false); } -// } /* * Returns the surface triangle set with new nodes !!! * @returns the surface triangle set with new nodes !!! @@ -366,32 +344,6 @@ double GbTriangle3D::getIntersectionRaytraceFactor(const double& x1, const doubl return f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3); } -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 2D triangle and the specified 2D line. -* @param line the 2D line to intersect -* @return the intersection points of this 2D triangle and the specified 2D line -*/ -/* -vector<GbPoint3D> GbTriangle3D::calculateIntersectionPoints3D(GbLine3D *line) -{ -//throw UbException(UB_EXARGS,"not yet implemented"); - -GbSystem::PointSet3 pointSet(0); -GbPoint3D *pCrossed = NULL; - -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[0], *this->points[1], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[1], *this->points[2], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[2], *this->points[0], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -//vector<GbPoint3D> points = pointSet->getPoints(); -return(pointSet.getPoints()); -} -*/ /*===========================================================*/ GbLine3D* GbTriangle3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) @@ -900,31 +852,6 @@ void GbTriangle3D::calculateValues() /*======================================================================*/ -/*======================================================================*/ -//class PointObserver : public UbObserver -//{ -// GbTriangle3D *triangle; - -// PointObserver(GbTriangle3D *triangle) -// { -// this->triangle = triangle; -// } - -//public: -// void objectChanged(GbObject3D *object) -// { -// if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) -// { -// this->triangle->consistent = false; -// this->triangle->notifyObservers(); -// } -// } -//}; -//bool GbTriangle3D::isPointOnEdge(GbVector3D& q) -//{ -////cout<<"muss einer machen ...\n"; -// return false; -//} /*======================================================================*/ GbVector3D GbTriangle3D::getNormal() { @@ -946,32 +873,6 @@ void GbTriangle3D::init() points.resize(3,NULL); } /*=======================================================*/ -void GbTriangle3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - if(points[0]) points[0]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[1]) points[1]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[2]) points[2]->write(out); - else {GbPoint3D tmp; tmp.write(out);} -} -/*=======================================================*/ -void GbTriangle3D::read(UbFileInput* in) -{ - this->deletePoints(); - points[0] = new GbPoint3D; - points[1] = new GbPoint3D; - points[2] = new GbPoint3D; - in->readString(); - points[0]->read(in); - in->readString(); - points[1]->read(in); - in->readString(); - points[2]->read(in); - consistent = false; -} -/*=======================================================*/ void GbTriangle3D::calculateNormal() { GbPoint3D*& a = points[0]; diff --git a/src/basics/geometry3d/GbTriangle3D.h b/src/basics/geometry3d/GbTriangle3D.h index 983bd5d0a..7b931c1cc 100644 --- a/src/basics/geometry3d/GbTriangle3D.h +++ b/src/basics/geometry3d/GbTriangle3D.h @@ -1,21 +1,43 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangle3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBTRIANGLE3D_H #define GBTRIANGLE3D_H #include <sstream> -#include <geometry3d/GbObject3D.h> -#include <geometry3d/GbVector3D.h> -#include <geometry3d/GbPoint3D.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF +#include <GbObject3D.h> +#include <GbVector3D.h> +#include <GbPoint3D.h> #include <PointerDefinitions.h> @@ -23,13 +45,14 @@ class GbCuboid3D; class GbPolygon3D; class GbObject3DCreator; -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -*/ -//class GbLine2D; +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbTriangle3D +//! +//! \brief This Class provides basic 3D triangle objects. +//! \details The describing points are observed by 2D triangle objects. +//! +////////////////////////////////////////////////////////////////////////// class GbTriangle3D : public GbObject3D , public UbObserver { @@ -101,9 +124,6 @@ public: double getDistanceFromPoint(GbVector3D punct); std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); /*======================================================================*/ /* Calculation */ @@ -140,27 +160,6 @@ public: /* */ virtual void calculateValues(); - /*======================================================================*/ - //class PointObserver : public UbObserver - //{ - // GbTriangle3D *triangle; - - // PointObserver(GbTriangle3D *triangle) - // { - // this->triangle = triangle; - // } - - //public: - // void objectChanged(GbObject3D *object) - // { - // if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) - // { - // this->triangle->consistent = false; - // this->triangle->notifyObservers(); - // } - // } - //}; - /*======================================================================*/ //virtuelle Methoden von UbObserver //!! quick and dirty von sirann !! @@ -193,28 +192,6 @@ public: } using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & points; - ar & normal; - ar & x1s; - ar & x2s; - ar & x3s; - ar & x1min; - ar & x1max; - ar & x2min; - ar & x2max; - ar & x3min; - ar & x3max; - ar & area; - ar & consistent; - if( ArchiveTools::isReading(ar) ) this->calculateNormal(); - } -#endif //CAB_RCF - protected: bool consistent; double x1s; @@ -236,10 +213,4 @@ private: }; /*=========================================================================*/ -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriangle3D >("GbTriangle3D ") , SF_GbTriangle3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangle3D >() ), SF_GbTriangle3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbTriangle3D>() ), SF_GbTriangle3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbVector3D.cpp b/src/basics/geometry3d/GbVector3D.cpp index df3e06188..94e6e7f67 100644 --- a/src/basics/geometry3d/GbVector3D.cpp +++ b/src/basics/geometry3d/GbVector3D.cpp @@ -1,9 +1,41 @@ -#include <geometry3d/GbVector3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVector3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbVector3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbMath.h> #include <basics/utilities/UbInfinity.h> -#include <geometry3d/GbPoint3D.h> - + using namespace std; diff --git a/src/basics/geometry3d/GbVector3D.h b/src/basics/geometry3d/GbVector3D.h index 538ead812..9bf699fa2 100644 --- a/src/basics/geometry3d/GbVector3D.h +++ b/src/basics/geometry3d/GbVector3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVector3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBVECTOR3D_H #define GBVECTOR3D_H @@ -11,14 +37,11 @@ #include <cassert> #include <string> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <PointerDefinitions.h> class GbPoint3D; +//! \brief This Class provides basic 3D vector objects. class GbVector3D { public: @@ -109,13 +132,6 @@ public: static const GbVector3D UNIT_X2; static const GbVector3D UNIT_X3; -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & m_afTuple; - } -#endif //CAB_RCF private: // support for comparisons int CompareArrays (const GbVector3D& rkV) const; @@ -125,8 +141,4 @@ private: GbVector3D operator* (const double& fScalar, const GbVector3D& rkV); -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbVector3D >("GbVector3D "), SF_GbVector3D ); -#endif //RCF_USE_SF_SERIALIZATION - #endif //GBVECTOR3D_H -- GitLab