From e4f69016803ece0a132b7ddf7bae27401af8180e Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Tue, 1 Sep 2020 14:48:00 +0200 Subject: [PATCH] Adapt basics file to open source. --- src/basics/Core/LbmOrGks.h | 42 +- src/basics/basics/container/CbArray2D.h | 87 +- src/basics/basics/container/CbArray3D.h | 85 +- src/basics/basics/container/CbArray4D.h | 87 +- src/basics/basics/container/CbVector.h | 148 ++-- src/basics/basics/objects/ObObject.h | 61 +- src/basics/basics/utilities/UbComparators.h | 41 +- src/basics/basics/utilities/UbEqual.h | 63 +- src/basics/basics/utilities/UbException.h | 66 +- src/basics/basics/utilities/UbInfinity.h | 54 +- src/basics/basics/utilities/UbKeys.h | 56 +- src/basics/basics/utilities/UbLimits.h | 36 +- src/basics/basics/utilities/UbLogger.cpp | 32 + src/basics/basics/utilities/UbLogger.h | 136 ++-- src/basics/basics/utilities/UbMath.cpp | 32 + src/basics/basics/utilities/UbMath.h | 96 ++- src/basics/basics/utilities/UbObservable.h | 103 +-- src/basics/basics/utilities/UbObserver.h | 71 +- src/basics/basics/utilities/UbScheduler.h | 120 +-- src/basics/basics/utilities/UbSystem.h | 63 +- src/basics/basics/utilities/UbTiming.h | 139 ++-- src/basics/basics/utilities/UbTuple.h | 190 +++-- src/basics/basics/utilities/Vector3D.cpp | 32 + src/basics/basics/utilities/Vector3D.h | 61 +- src/basics/basics/writer/WbWriter.h | 134 +--- .../basics/writer/WbWriterVtkXmlASCII.cpp | 34 +- .../basics/writer/WbWriterVtkXmlASCII.h | 42 +- .../basics/writer/WbWriterVtkXmlBinary.cpp | 75 +- .../basics/writer/WbWriterVtkXmlBinary.h | 48 +- .../geometry3d/CoordinateTransformation3D.cpp | 234 +++--- .../geometry3d/CoordinateTransformation3D.h | 134 ++-- src/basics/geometry3d/GbCuboid3D.cpp | 758 +++++++++--------- src/basics/geometry3d/GbCuboid3D.h | 214 ++--- 33 files changed, 1924 insertions(+), 1650 deletions(-) diff --git a/src/basics/Core/LbmOrGks.h b/src/basics/Core/LbmOrGks.h index f531c4469..96ef76a5a 100644 --- a/src/basics/Core/LbmOrGks.h +++ b/src/basics/Core/LbmOrGks.h @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -35,8 +35,8 @@ enum LbmOrGks { - LBM, - GKS + LBM, + GKS }; #endif diff --git a/src/basics/basics/container/CbArray2D.h b/src/basics/basics/container/CbArray2D.h index 54df75401..c4c115c29 100644 --- a/src/basics/basics/container/CbArray2D.h +++ b/src/basics/basics/container/CbArray2D.h @@ -1,34 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 CbArray2D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY2D_H #define CBARRAY2D_H -////////////////////////////////////////////////////////////////////////// -// 4D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.2 -// Nov. 2003 muffmolch@gmx.de -// Ver 1.3 -// Aug. 2006 - Kosmetik -// Ver 1.4 -// Sep. 2006 - indexer eingefuehrt -// Ver 1.5 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.6 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// - #include <iomanip> #include <basics/utilities/UbException.h> @@ -36,10 +40,6 @@ #include <algorithm> #include <typeinfo> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -90,7 +90,16 @@ public: ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // CbArray2D - +////////////////////////////////////////////////////////////////////////// +//! \brief 2D Array +//! \details the data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX2X1> class CbArray2D { @@ -128,7 +137,7 @@ public: this->resize(uniformDimensionSize,uniformDimensionSize); } /*=======================================================================*/ - //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird) + //ssbernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschlieueend leer, da swap verwendet wird) CbArray2D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2) { assert( (nx1*nx2)==vec.size() ); @@ -190,7 +199,7 @@ public: this->data.resize(rhs.data.size()); //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - //ACHTUNG: für diese Konvertierung muss bei Klassen der demenstrechende operator + //ACHTUNG: fuer diese Konvertierung muss bei Klassen der demenstrechende operator // implementiert sein, e.g.: class value_type2 {public: inline operator value_type2() const { return value_type2(); } for(int x1=0; x1<this->nx1; x1++) for(int x2=0; x2<this->nx2; x2++) @@ -372,16 +381,6 @@ public: return indexer.getIndex(x1,x2,nx1,nx2); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & data; - } -#endif //CAB_RCF - protected: /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbArray3D.h b/src/basics/basics/container/CbArray3D.h index 2ec0306c4..f8ad3e8c9 100644 --- a/src/basics/basics/container/CbArray3D.h +++ b/src/basics/basics/container/CbArray3D.h @@ -1,34 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 CbArray3D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY3D_H #define CBARRAY3D_H -////////////////////////////////////////////////////////////////////////// -// 3D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.2 -// Nov. 2003 muffmolch@gmx.de -// Ver 1.3 -// Aug. 2006 - Kosmetik -// Ver 1.4 -// Sep. 2006 - indexer eingefuehrt -// Ver 1.5 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.2 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// - #include <iomanip> #include <basics/utilities/UbException.h> @@ -37,10 +41,6 @@ #include <typeinfo> #include "PointerDefinitions.h" -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -122,6 +122,16 @@ public: ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // CbArray3D +////////////////////////////////////////////////////////////////////////// +//! \brief 3D Array +//! \details The data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX3X2X1> class CbArray3D { @@ -161,7 +171,7 @@ public: this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); } /*=======================================================================*/ - //�bernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschlie�end leer, da swap verwendet wird) + //ssbernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschliessend leer, da swap verwendet wird) CbArray3D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3) { assert( (nx1*nx2*nx3)==vec.size() ); @@ -422,17 +432,6 @@ public: return indexer.getIndex(x1,x2,x3,nx1,nx2,nx3); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & data; - } -#endif //CAB_RCF - /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbArray4D.h b/src/basics/basics/container/CbArray4D.h index aa91844d0..21579b0da 100644 --- a/src/basics/basics/container/CbArray4D.h +++ b/src/basics/basics/container/CbArray4D.h @@ -1,29 +1,39 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 CbArray4D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY4D_H #define CBARRAY4D_H -////////////////////////////////////////////////////////////////////////// -// 4D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.0 -// Sept. 2006 muffmolch@gmx.de -// Ver 1.1 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.2 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// + #include <iomanip> #include <basics/utilities/UbException.h> @@ -32,13 +42,6 @@ #include <typeinfo> #include "PointerDefinitions.h" -#include "basics_export.h" - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -50,7 +53,7 @@ // for(alle X2) // for(alle X3) // for(alle X4) -class BASICS_EXPORT IndexerX1X2X3X4 +class IndexerX1X2X3X4 { public: typedef int size_type; @@ -93,8 +96,16 @@ public: } }; ////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// // CbArray4D +//! \brief 4D Array +//! \details The data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX4X3X2X1> class CbArray4D { @@ -134,7 +145,7 @@ public: this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); } /*=======================================================================*/ - //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschlie�end leer, da swap verwendet wird) + //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschliessend leer, da swap verwendet wird) CbArray4D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4) { assert( (nx1*nx2*nx3*nx4)==vec.size() ); @@ -403,18 +414,6 @@ public: return indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & nx4; - ar & data; - } -#endif //CAB_RCF - protected: /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbVector.h b/src/basics/basics/container/CbVector.h index bd7174da9..d0fc6144d 100644 --- a/src/basics/basics/container/CbVector.h +++ b/src/basics/basics/container/CbVector.h @@ -1,17 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 CbVector.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBVECTOR_H #define CBVECTOR_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> - #include <RCF/ByteBuffer.hpp> -#endif - #include <vector> #include <algorithm> //for std::swap #include <typeinfo> //for typeid @@ -20,36 +41,23 @@ #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbEqual.h> -/*=========================================================================*/ -/* CbVector */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -@version 1.1 - 09.02.08 -@version 1.2 - 23.04.08 - swap added -@version 1.3 - 08.05.08 - boosting up serialization performance! -*/ - -/* -usage: ... -Da es Voraussetzun bei doeser Klasse war, dass lediglich der Typ als -template-parameter miteingeht, muss der allcocator eine abstrakte klasse sein -ansonsten h�tte sich hier der allokator als zweites argument -wie beim STL vector angeboten, womit man auch keinen pointer speichern muesste. -Im letzteren Fall w�rde aber jeweils ein bestimmeter Klassentyp in Abhaengigkeit -des allokators zur compilezeit erzeugt. Problem wir wollen ein und denselben -typ benutzen und nur der allokator innerhalb der klasse soll sich unterscheiden -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -*/ - template< typename T > class CbVectorAllocator; template< typename T > class CbVectorAllocatorStd; +//========================================================================= +//! \brief A class implements a container like a vector +//! \details +//! For this class it was required to ave only the type as template argument. +//! Hence, the allocator must be an abstract class. With out this requirement, +//! an allocator as second template argument would have been possible, as in the +//! STL vector. This would lead to the compiler generating two different classes +//! for the same data type with different allocators during compile time. Here it +//! is required that the same class can have different allocators. +//! +//! Rangecheck active, if: +//! -debug : not defined "NO_CB_RANGECHECK" +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +//========================================================================= ////////////////////////////////////////////////////////////////////////// template< typename T > class CbVector @@ -194,43 +202,6 @@ public: /*==========================================================*/ CbVectorAllocator<value_type>* getAllocator() const { return allocator; } /*==========================================================*/ - #ifdef CAB_RCF - template<typename Archive> - void serialize(Archive & ar, const unsigned int version) - { - if( ArchiveTools::isWriting(ar) ) - { - ar & allocator; - ar & dataSize; //!!!erst hier - - //old: - //for(size_type i=0; i<dataSize; i++) - // ar & ptrData[i]; - - //new and boosting to the sky: - RCF::ByteBuffer byteBuffer( (char*) &ptrData[0], dataSize*sizeof(value_type) ); - ar & byteBuffer; - } - else - { - CbVectorAllocator<value_type>* tmpCbVectorAllocator(NULL); - size_type tmpInteger; - ar & tmpCbVectorAllocator; - ar & tmpInteger; - this->setAllocator(tmpCbVectorAllocator); - allocator->resize(*this,tmpInteger); - - //old: - //for(size_type i=0; i<dataSize; i++) - // ar & ptrData[i]; - - //new and boosting to the sky: - RCF::ByteBuffer byteBuffer; - ar & byteBuffer; - memcpy( (char*)ptrData, byteBuffer.getPtr(), byteBuffer.getLength() ); - } - } - #endif //CAB_RCF private: value_type* ptrData; @@ -258,13 +229,6 @@ public: virtual bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0; virtual bool dealloc(CbVector< value_type >& vec) = 0; -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - } -#endif //CAB_RCF - protected: //folgende Methoden ersparen eine friend Deklaierung aller moeglichen Allocatoren //denn durch diese beiden Methoden haben sie exklusive Zugriffsrechte! @@ -282,12 +246,6 @@ protected: } }; -#ifdef RCF_USE_SF_SERIALIZATION -SF_NO_CTOR(CbVectorAllocator<double>); -SF_NO_CTOR(CbVectorAllocator<float>); -#endif //RCF_USE_SF_SERIALIZATION - - ////////////////////////////////////////////////////////////////////////// // CbVectorAllocatorStd ////////////////////////////////////////////////////////////////////////// @@ -342,24 +300,8 @@ public: return true; } /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - serializeParent< CbVectorAllocator<value_type> >(ar, *this); - } - #endif //CAB_RCF private: }; - -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType< CbVectorAllocatorStd<double> >(" CbVectorAllocatorStd<double> ") , SF_CbVectorAllocatorStd_double ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<double>, CbVectorAllocatorStd<double> >() ), SF_CbVectorAllocatorStd_double_BD1 ); - - UB_AUTO_RUN_NAMED( SF::registerType< CbVectorAllocatorStd<float> >(" CbVectorAllocatorStd<float> " ) , SF_CbVectorAllocatorStd_float ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<float> , CbVectorAllocatorStd<float> >() ), SF_CbVectorAllocatorStd_float_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif //CBVECTOR_H diff --git a/src/basics/basics/objects/ObObject.h b/src/basics/basics/objects/ObObject.h index addf7e134..c54000521 100644 --- a/src/basics/basics/objects/ObObject.h +++ b/src/basics/basics/objects/ObObject.h @@ -1,24 +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 ObObject.h +//! \ingroup objects +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef OBOBJECT_H #define OBOBJECT_H #include <string> -#include <basics/objects/ObObjectCreator.h> #include <basics/utilities/UbObservable.h> -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - - -class ObObjectCreator; - class ObObject : public UbObservable { public: @@ -28,33 +46,16 @@ public: virtual ~ObObject() { } virtual ObObject* clone()=0; - virtual std::string getTypeID()=0; virtual std::string getName() { return name; } void setName(std::string name) { this->name=name; } virtual std::string toString()=0; - virtual ObObjectCreator* getCreator()=0; - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - //SF::SF_SERIALIZE_PARENT<UbObservable>(ar, *this); - SF_SERIALIZE_PARENT<UbObservable>(ar, *this); - ar & name; - } -#endif //CAB_RCF private: std::string name; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) -SF_NO_CTOR(ObObject); -UB_AUTO_RUN_NAMED( ( SF::registerType<ObObject>("ObObject") ), SF_ObObject ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<UbObservable, ObObject >() ), SF_ObObject_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION #endif diff --git a/src/basics/basics/utilities/UbComparators.h b/src/basics/basics/utilities/UbComparators.h index ee809cf1c..abde77000 100644 --- a/src/basics/basics/utilities/UbComparators.h +++ b/src/basics/basics/utilities/UbComparators.h @@ -1,17 +1,40 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 UbComparators.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBCOMPARATORS_H #define UBCOMPARATORS_H #include <functional> -/*=========================================================================*/ -/* UbComparators */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 16.08.2007 -*/ - namespace UbComparators { //type_traits diff --git a/src/basics/basics/utilities/UbEqual.h b/src/basics/basics/utilities/UbEqual.h index 8c01318af..e748bec34 100644 --- a/src/basics/basics/utilities/UbEqual.h +++ b/src/basics/basics/utilities/UbEqual.h @@ -1,30 +1,55 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 UbEqual.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBEQUAL_H #define UBEQUAL_H #include<cmath> ////////////////////////////////////////////////////////////////////////// -//isUbEqual<T1,T2>(a,b) -//vergleicht die gleichtheit der beiden werte a und b -// -//std-maessig wird hierfür der operator== verwendet -// -//Ausnahme: floating-points -//hier wird jeweils der "genauere typ zum ungenaueren gecastet und dann verglichen" -//e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true -// -//bei klassen muss hier operator== fuer const objecte implementiert sein!!! -//e.g.: bool operator==(const Test&) const { if(blabla) return true; else return false; } // +//! \brief isUbEqual<T1,T2>(a,b) +//! Compares the equality of values a and b. +//! +//! By default operator== is used for this. +//! +//! Execption: floating-point variables +//! In these cases the type with higher precision is casted to the type of lower precision +//! and then the two values are compared. +//! e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true +//! +//! For classes operator== must be implemented for const objects! +//! e.g.: bool operator==(const Test&) const { if(blabla) return true; else return false; } // -//author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//version 1.0 - 25.03.2008 ////////////////////////////////////////////////////////////////////////// //std-trait, fuer alle nicht spezifischen typen: @@ -43,7 +68,7 @@ struct UbEqualTrait< T, T > typedef T Low; }; -//spezialisierung für diverse Typen-Tuples +//spezialisierung fuer diverse Typen-Tuples template<> struct UbEqualTrait< short, int > { typedef int High; typedef short Low; }; template<> struct UbEqualTrait< short, long > { typedef long High; typedef short Low; }; template<> struct UbEqualTrait< short, float > { typedef float High; typedef short Low; }; diff --git a/src/basics/basics/utilities/UbException.h b/src/basics/basics/utilities/UbException.h index 45b013d11..f999f8e13 100644 --- a/src/basics/basics/utilities/UbException.h +++ b/src/basics/basics/utilities/UbException.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 UbException.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBEXCEPTION_H #define UBEXCEPTION_H @@ -15,25 +41,15 @@ #include "./UbTuple.h" -/*=========================================================================*/ -/* UbException */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -@version 1.5 - 14.03.08 -@version 1.6 - 31.03.08 derivation from std::run_time_error -@version 1.6a - helper marco UB_EXARGS -*/ - -/* -usage: UB_THROW( UbException("error message") ); - UB_THROW( UbException(__FILE__, __LINE__,"error message") ); - UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") ); - UB_THROW( UbException(UB_EXARGS,"error") ); //same as above -*/ +//========================================================================= +// +//! \brief UbException +//! usage: UB_THROW( UbException("error message") ); +//! UB_THROW( UbException(__FILE__, __LINE__,"error message") ); +//! UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") ); +//! UB_THROW( UbException(UB_EXARGS,"error") ); //same as above +// +//========================================================================= //Macro UB_FUNCTION: figures out the method/function name (platform dependant) #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) @@ -100,7 +116,7 @@ public: virtual const char* what() const throw() { exceptionString = this->toString(); - return exceptionString.c_str(); //ansonsten ist das Verhalten anschließend undefiniert! + return exceptionString.c_str(); //ansonsten ist das Verhalten anschliessend undefiniert! } /*==========================================================*/ virtual void addInfo(const std::string& err_str) diff --git a/src/basics/basics/utilities/UbInfinity.h b/src/basics/basics/utilities/UbInfinity.h index 5c889c894..229a14b23 100644 --- a/src/basics/basics/utilities/UbInfinity.h +++ b/src/basics/basics/utilities/UbInfinity.h @@ -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 UbInfinity.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UB_INFINITY_H #define UB_INFINITY_H #include <limits> @@ -5,16 +37,14 @@ #include <basics/utilities/UbLimits.h> #include <basics/utilities/UbSystem.h> - ////////////////////////////////////////////////////////////////////////// -// -// UbNegInfinity -// Anm: keine template klasse, da man am Ende eine Instanz "inf" verwendet -// die in "verschiedene"(!!!) Typen konvertiert werden kann und nicht -// nur in den template Typ! -// Note: The UbNegInfinity class cannot be instantiated on its own, but works -// as a base class for the Infinity class. +//! +//! \brief UbNegInfinity +//! \details Note: The UbNegInfinity class cannot be instantiated on its own, but works +//! as a base class for the Infinity class. +//! ////////////////////////////////////////////////////////////////////////// + class UbNegInfinity { public: @@ -29,9 +59,9 @@ class UbNegInfinity inline operator double() const { return UbLimits<double>::ninf(); } inline operator long double() const { return UbLimits<long double>::ninf(); } - // This function compares built-in data types with their largest possible value. The function - // only works for built-in data types. The attempt to compare user-defined class types will - // result in a compile time error. + //! This function compares built-in data types with their largest possible value. The function + //! only works for built-in data types. The attempt to compare user-defined class types will + //! result in a compile time error. template< typename T > inline bool equal( const T& rhs ) const { @@ -81,7 +111,7 @@ inline bool operator!=( const T& lhs, const UbNegInfinity& rhs ) // UbInfinity // ////////////////////////////////////////////////////////////////////////// -class UbInfinity : public UbNegInfinity //um später -UbInfinity leichter zu implementieren!!! +class UbInfinity : public UbNegInfinity //um spaeter -UbInfinity leichter zu implementieren!!! { public: inline UbInfinity() diff --git a/src/basics/basics/utilities/UbKeys.h b/src/basics/basics/utilities/UbKeys.h index 609c08dbe..29713e756 100644 --- a/src/basics/basics/utilities/UbKeys.h +++ b/src/basics/basics/utilities/UbKeys.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 UbKeys.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBKEYS_H #define UBKEYS_H @@ -14,19 +40,12 @@ #include <3rdParty/rcf/RcfSerializationIncludes.h> #endif //CAB_RCF -/*=========================================================================*/ -/* UbKeys */ -/* */ -/** -namespace for global Keys (e.g. for STL-maps) -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.08.07 -*/ - -/* -usage: ... -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \brief +//! namespace for global Keys (e.g. for STL-maps) +//! +////////////////////////////////////////////////////////////////////////// namespace UbKeys { @@ -189,7 +208,6 @@ namespace UbKeys T1 t1; T2 t2; T3 t3; - }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/basics/basics/utilities/UbLimits.h b/src/basics/basics/utilities/UbLimits.h index 30b03f2d9..282ea2c74 100644 --- a/src/basics/basics/utilities/UbLimits.h +++ b/src/basics/basics/utilities/UbLimits.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 UbLimits.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UB_LIMITS_H #define UB_LIMITS_H diff --git a/src/basics/basics/utilities/UbLogger.cpp b/src/basics/basics/utilities/UbLogger.cpp index 3c433a130..29834020f 100644 --- a/src/basics/basics/utilities/UbLogger.cpp +++ b/src/basics/basics/utilities/UbLogger.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 UbLogger.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) diff --git a/src/basics/basics/utilities/UbLogger.h b/src/basics/basics/utilities/UbLogger.h index b239621eb..a7bb006c2 100644 --- a/src/basics/basics/utilities/UbLogger.h +++ b/src/basics/basics/utilities/UbLogger.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 UbLogger.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBLOGGER_H #define UBLOGGER_H @@ -12,6 +38,7 @@ #include <iostream> #include <fstream> #include <iomanip> + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) #include <windows.h> #else @@ -22,33 +49,63 @@ #include <boost/thread.hpp> #endif // CAB_BOOST -////////////////////////////////////////////////////////////////////////// -// UbLogger -// C++ Logger -// Funktionsweise: -// pro Logeintrag wird ein UbLogger-Objekt erstellt, der logstring uebergeben und beim "zerstroeren" -// wird der logstring mittels der entsprechenden policy (=template paramter) z.B. in eine Datei -// oder auf dem Bildschirm ausgegeben. Es werden verschiedene LogLevel unterstuetzt -// -// Hilfsmakro: UBLOG -// Bsp1: UBLOG(logINFO) << "Klasse::foo entered"; //endl wir nicht ben�tigt -// --> Eintrag: -// -// Bsp2: siehe Dateiende! -// -//Idee basierend auf: -//Artikel von Dr. Dobbs Portal -//September 05, 2007 -//Logging In C++ -// -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 12.10.2008 + enum LogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; ////////////////////////////////////////////////////////////////////////// // template <typename OutputPolicy> class Log - declaration ////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +//! +//! \brief +//! C++ Logger +//! \details Functionality: +//! Per logentry an object of type UbLogger is generated, the log string is passed to this object and +//! upon destruction of the object the string is written to a file or the screen depending on +//! the policy (=template paramter). Multiple log level are supported. +//! +//! helpermakro: UBLOG +//! +//! Example 1: +//! \code +//! UBLOG(logINFO) << "Klasse::foo entered"; //endl is not required +//! \endcode +//! +//! Example 2: +//! \code +//! try +//! { +//! UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG3"); +//! //UbLog::output_policy::setStream(&std::cerr); //<- clog is stdandard +//! UbLog::output_policy::setStream("c:/temp/out.txt"); //you can not open these -> error message -> log is output in cerr +//! +//! int count = 3; +//! UBLOG(logINFO, "A loop with " << count << " iterations"); +//! for (int i = 0; i != count; ++i) +//! { +//! UBLOG(logERROR , "error - the counter i = " << i ); +//! UBLOG(logDEBUG1, "debug1 - the counter i = " << i ); +//! UBLOG(logDEBUG2, "debug2 - the counter i = " << i ); +//! UBLOG(logDEBUG3, "debug3 - the counter i = " << i ); +//! //for MultiLine entries: -> formatting in logfile +//! UBLOGML(logDEBUG3, "debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); +//! UBLOGML(logDEBUG3, "debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); +//! UBLOG2ML(logDEBUG3,std:cout,"debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); +//! } +//! return 0; +//! } +//! catch(const std::exception& e) +//! { +//! UBLOG(logERROR) << e.what(); +//! } +//! \endcode +//! Idee based on: +//! Paper by Dr. Dobbs Portal, +//! September 05, 2007, +//! Logging In C++ +//! +////////////////////////////////////////////////////////////////////////// template <typename OutputPolicy> class UbLogger { @@ -59,7 +116,7 @@ public: virtual ~UbLogger(); std::ostringstream& get(const LogLevel& level = logINFO); public: - //static, weil man so sp�ter die ObjErstellunge ersparen kann, + //static, weil man so spaeter die ObjErstellunge ersparen kann, //falls level kleiner als Level static LogLevel& reportingLevel(); @@ -173,22 +230,18 @@ inline std::string UbLogger<OutputPolicy>::logTimeString() ////////////////////////////////////////////////////////////////////////// -// Output2Stream (=implementation of OutputPolicy) +//! Implementation of OutputPolicy) ////////////////////////////////////////////////////////////////////////// -//Anm: die erste Version mit auto_ptr fuer den stream fuehrte zu -// exceptions bei Verwedung vom Logger in dtors stat. globaler -// Objekte. Aber auch die Pointer-Lsg. ist noch nicht die -// optimale L�sung class Output2Stream // implementation of OutputPolicy { public: static std::ostream*& getStream(); static void output(const std::string& msg); - //creates output-file-stream (of file opening fails -> stream is set to std::cerr) + //!creates output-file-stream (of file opening fails -> stream is set to std::cerr) static void setStream(const std::string& filename); - //direct set outputstream, gcControl = true -> object will be deleted by Output2Stream + //!direct set outputstream, gcControl = true -> object will be deleted by Output2Stream static void setStream(std::ostream* pStream, const bool& gcControl = false); protected: @@ -253,29 +306,18 @@ class UbLog : public UbLogger< Output2Stream > }; -//Makro um compilerseitig maxLevel zu beschr�nken +//Macro to limit compiler-side maxLevel #ifndef UBLOG_MAX_LEVEL #define UBLOG_MAX_LEVEL logDEBUG5 #endif ////////////////////////////////////////////////////////////////////////// -//Hauptmakro fuers Loggen // example UBLOG(logINFO) << "das ist ein log eintrag"; ////////////////////////////////////////////////////////////////////////// #define UBLOG(level, logtext) \ if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ else UbLog().get(level) << logtext; -//wieso dieses Macro (was der der scheaeaeaesss???) -// z.B. UBLOG(logDEBUG2) << "Ich bin sooo toll " << username; -//also, was macht der praeprozessor draus?: -// if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; -// else // Log().Get(logINFO) << "Ich bin sooo toll " << username; -//Ergo: das prinzip des logging beruht auf: Log-Objekt erstellen und rauschreiben beim zerstoeren -// -> ist der zu loggende Level < als der im UBLOG angegebene erspart man sich hier die -// Objekt erstellung -> optimale Performance -> laut Petru Marginean (dem Verfasser des -// Ursprungslogger ist der Performance Unterschied kaum messbar, wenn NICHT geloggt wird! - ////////////////////////////////////////////////////////////////////////// //makro 2 fuer korrekten MultiLineOutput (teuer!!) // example1: UBLOGML(logINFO, "line1"<<endl<<"line2"<<endl<<"line3" ) @@ -296,7 +338,7 @@ class UbLog : public UbLogger< Output2Stream > } \ } ////////////////////////////////////////////////////////////////////////// -//makro3, falls auch bildschirmausgabe erw�nscht +//makro3, falls auch bildschirmausgabe erwuenscht // -> es wird sowohl ins logfile als auch auf den "stream" geschrieben // wenn reporting level und level passen :D //example1: UBLOG2ML(logINFO, std::cout, "line1"<<endl<<"line2"<<endl<<"line3" ) diff --git a/src/basics/basics/utilities/UbMath.cpp b/src/basics/basics/utilities/UbMath.cpp index aabcbb9ac..ffed193fb 100644 --- a/src/basics/basics/utilities/UbMath.cpp +++ b/src/basics/basics/utilities/UbMath.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 UbMath.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbMath.h> #include <basics/utilities/UbInfinity.h> #include <cstring> //for memcmp diff --git a/src/basics/basics/utilities/UbMath.h b/src/basics/basics/utilities/UbMath.h index 98034171b..bf0466eee 100644 --- a/src/basics/basics/utilities/UbMath.h +++ b/src/basics/basics/utilities/UbMath.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 UbMath.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBMATH_H #define UBMATH_H @@ -14,20 +40,6 @@ #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbEqual.h> -/*=========================================================================*/ -/* UbMath */ -/* */ -/** -namespace for global math-functions -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.4 - 04.10.07 -*/ - -/* -usage: ... -*/ - namespace UbMath { extern const double PI; @@ -346,7 +358,7 @@ namespace UbMath return UbMath::calcGgt( UbMath::calcGgt(val1, val2), val3 ); } /*=======================================================*/ - //returns the max of two values + //returns the max of c2 values //to avoid errors at mixed argument-types use: double myMax = max<double>(2,2.3); template< typename T > inline const T& max(const T& a1, const T& a2) @@ -399,7 +411,8 @@ namespace UbMath static const double c2o27 = 2. / 27.; static const double c1o54 = 1. / 54.; static const double c1o216 = 1. / 216.; - static const double c9o2 = 9. / 2.; + static const double c9o2 = 9. / 2.; //4.5 + static const double c9o4 = 9. / 4.; //2.25 static const double c3o9 = 3. / 9.; static const double c3o54 = 3. / 54.; static const double c3o216 = 3. / 216.; @@ -420,6 +433,7 @@ namespace UbMath static const double c1o6 = 1. / 6.; //0.16666666 static const double c1o5 = 1. / 5.; //0.2 static const double c1o4 = 1. / 4.; //0.25 + static const double c1o100 = 1. / 100.; static const double c5o16 = 5. / 16.; //0.3125 static const double c1o3 = 1. / 3.; //0.33333333 static const double c3o8 = 3. / 8.; //0.375 @@ -438,25 +452,27 @@ namespace UbMath static const double sqrt2 = sqrt(2.0); //1.4142135 static const double sqrt3 = sqrt(3.0); //1.7320508 static const double zeroReal = 0.0; - static const double one = 1.0; - static const double two = 2.0; - static const double three = 3.0; - static const double four = 4.0; - static const double five = 5.0; - static const double six = 6.0; - static const double seven = 7.0; - static const double eight = 8.0; - static const double nine = 9.0; - static const double fourteen = 14.0; - static const double fiveteen = 15.0; - static const double sixteen = 16.0; - static const double twentyone = 21.0; - static const double twentyfour = 24.0; - static const double twentyeight = 28.0; - static const double twentynine = 29.0; - static const double fourtyeight = 48.0; - static const double fifty = 50.0; - static const double fiftysix = 56.0; + static const double c1 = 1.0; + static const double c2 = 2.0; + static const double c3 = 3.0; + static const double c4 = 4.0; + static const double c5 = 5.0; + static const double c6 = 6.0; + static const double c7 = 7.0; + static const double c8 = 8.0; + static const double c9 = 9.0; + static const double c14 = 14.0; + static const double c15 = 15.0; + static const double c16 = 16.0; + static const double c18 = 18.0; + static const double c21 = 21.0; + static const double c24 = 24.0; + static const double c28 = 28.0; + static const double c29 = 29.0; + static const double c36 = 36.0; + static const double c48 = 48.0; + static const double c50 = 50.0; + static const double c56 = 56.0; static const double c152 = 152.0; static const double c130 = 130.0; } diff --git a/src/basics/basics/utilities/UbObservable.h b/src/basics/basics/utilities/UbObservable.h index 050860767..56967b904 100644 --- a/src/basics/basics/utilities/UbObservable.h +++ b/src/basics/basics/utilities/UbObservable.h @@ -1,51 +1,70 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 UbObservable.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBOBSERVABLE_H #define UBOBSERVABLE_H #include <list> #include <iostream> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <basics/utilities/UbObserver.h> class UbObserver; -/*=========================================================================*/ -/* Beobachtbares Objekt */ -/* */ -/** - This class provides Observables. The Observeres which observe this - Observable are stored in an observerlist. - IMPORTANT: objectWillBeDeleted is called at UbObserver::~UbObserver - this destructor is called AFTER the destructor of the - child classes. if you down_cast the pointer sent with the - objectWillBeDeleted(UbObserver* objpointer) then have to go this: - - if(dynamic_cast<UbObserver*>(observedObj)==objpointer) - (e.g.) observedObj=NULL; - example: see end of file - - a copy of an UbservableObject will NOT copy the observerList - <UL> - <LI><B>Extending:</B> This UbObservable is the observable object itself. Extending should be used - where object types can be extended from UbObservable. - <LI><B>Associating:</B> Initialization is done via the constructor <tt>UbObservable(ObservableObject)</tt>. - Associating may be used, where object types to be observed could not be extended from UbObservable. - </UL> - <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.2 - 13.07.05 - @see UbObserver -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \brief Observable object +//! \details This class provides Observables. The Observeres which observe this +//! Observable are stored in an observerlist. +//! IMPORTANT: objectWillBeDeleted is called at UbObserver::~UbObserver +//! this destructor is called AFTER the destructor of the +//! child classes. if you down_cast the pointer sent with the +//! objectWillBeDeleted(UbObserver* objpointer) then have to go this: +//! +//! if(dynamic_cast<UbObserver*>(observedObj)==objpointer) +//! (e.g.) observedObj=NULL; +//! example: see end of file +//! +//! a copy of an UbservableObject will NOT copy the observerList +//! <UL> +//! <LI><B>Extending:</B> This UbObservable is the observable object itself. Extending should be used +//! where object types can be extended from UbObservable. +//! <LI><B>Associating:</B> Initialization is done via the constructor <tt>UbObservable(ObservableObject)</tt>. +//! Associating may be used, where object types to be observed could not be extended from UbObservable. +//! </UL> +//! +//! see UbObserver +//! +////////////////////////////////////////////////////////////////////////// class UbObservable { @@ -95,7 +114,7 @@ public: /** Adds an UbObserver to the observerlist. - @param observer the observer to add to this observable (note that an observer may observe one observable more than once) + @param observer the observer to add to this observable (note that an observer may observe c1 observable more than once) */ virtual void addObserver(UbObserver* observer) { @@ -164,14 +183,6 @@ public: virtual std::string toString() { return "UbObservable - toString()"; } -#ifdef CAB_RCF - template<typename Archive> - void serialize(Archive & ar, const unsigned int version) - { - //do nothing! - } -#endif //CAB_RCF - private: /** Notifies all of its observers that something happened. Does nothing, if the observed object is null. diff --git a/src/basics/basics/utilities/UbObserver.h b/src/basics/basics/utilities/UbObserver.h index 601e2993a..0f2db5270 100644 --- a/src/basics/basics/utilities/UbObserver.h +++ b/src/basics/basics/utilities/UbObserver.h @@ -1,27 +1,50 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 UbObserver.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBOBSERVER_H #define UBOBSERVER_H class UbObservable; -/*=========================================================================*/ -/* Observer */ -/* */ -/** -This interface must be implemented by classes which want to -observe other objects. -IMPORTANT: if you delete an observer, ensure to remove Observer from - all his oberved observable objects before!!! -example: see end of UbObservable.h-file -<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.1 - 20.11.04 -*/ + +////////////////////////////////////////////////////////////////////////// +//! +//! \brief Observer +//! \details This interface must be implemented by classes which want to +//! observe other objects. +//! IMPORTANT: if you delete an observer, ensure to remove Observer from +//! all his observed observable objects before!!! +//! example: see end of UbObservable.h-file +//! +////////////////////////////////////////////////////////////////////////// class UbObserver { @@ -34,18 +57,18 @@ public: virtual ~UbObserver(){} /*======================================================================*/ - /* Methoden */ + /* Methods */ /* */ - /** + /*! This function is called when the observable indicated that an object has changed. - @param changedObject Object which has changed + \param changedObject Object which has changed */ virtual void objectChanged(UbObservable* changedObject)=0; - /** + /*! This function is called when the observable indicated that an object should be deleted. - @param objectForDeletion Object which should be deleted + \param objectForDeletion Object which should be deleted */ virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0; }; diff --git a/src/basics/basics/utilities/UbScheduler.h b/src/basics/basics/utilities/UbScheduler.h index f132f9528..c927e45b4 100644 --- a/src/basics/basics/utilities/UbScheduler.h +++ b/src/basics/basics/utilities/UbScheduler.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 UbScheduler.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller, Jan Hegewald +//======================================================================================= #ifndef UBSCHEDULER_H #define UBSCHEDULER_H @@ -19,33 +45,13 @@ #include <basics/utilities/UbMath.h> #include <basics/utilities/UbInfinity.h> #include <basics/utilities/UbComparators.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbFileInput.h> - -/*=========================================================================*/ -/* UbScheduler */ -/* */ -/** -namespace for global system-functions -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@author <A HREF="mailto:hegewald@cab.bau.tu-bs.de">J. Hegewald</A> -@version 1.0 - 06.09.06 -@version 1.1 - 09.09.06 -@version 1.2 - 03.07.08 - nun auch isDue(t) mehrmals fuer dasselbe t moeglich - isDue(t) auch fuer t < lastUsedT - bug entfernt, der bei Schedule (5,0,500) auch 505 als Due zur�ckgibt! -*/ - -/* -usage: ... -*/ - -// this class is not thread save -// -class UbScheduler; -typedef std::shared_ptr<UbScheduler> UbSchedulerPtr; +////////////////////////////////////////////////////////////////////////// +//! +//! \brief A class implements scheduling. +//! \details This class is not thread save. +//! +////////////////////////////////////////////////////////////////////////// class UbScheduler { @@ -72,20 +78,6 @@ public: return os; } - //------------- implements CAB serialization ----- start - virtual void write(UbFileOutput* out) - { - out->writeDouble( begin ); - out->writeDouble( end ); - out->writeDouble( step ); - } - virtual void read(UbFileInput* in) - { - begin = in->readDouble(); - end = in->readDouble(); - step = in->readDouble(); - } - private: double step, begin, end; }; @@ -200,9 +192,9 @@ public: nextDueTime = tmpNextDueTime; } - //wenn t = der aktuuellen oder gar schon der n�chstm�glichen ist (hierbei wurde + //wenn t = der aktuuellen oder gar schon der naechstmoeglichen ist (hierbei wurde //zuvor actDueTime und nextDueTime ggf. angepasst) - //Bsp.: nextDuTime war 5, aber f�r t=400 gilt andere schedule -> Bsp actDue=350 und nextDue 405 + //Bsp.: nextDuTime war 5, aber fuer t=400 gilt andere schedule -> Bsp actDue=350 und nextDue 405 if( UbMath::equal(t,actDueTime) || UbMath::equal(t,nextDueTime) ) { @@ -212,7 +204,7 @@ public: } else if( UbMath::lessEqual(t, lastDueTime) ) { - if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man f�r dasselbe t isDue(t) aufruft + if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man fuer dasselbe t isDue(t) aufruft else { //Fall: Zeit liegt faktisch in der Vergangenheit -> neu initialsisieren @@ -289,27 +281,6 @@ public: return os; } - //------------- implements CAB serialization ----- start - virtual void write(UbFileOutput* out) - { - out->writeSize_t( schedules.size() ); - - for(std::size_t i=0; i<schedules.size(); i++) - schedules[i].write(out); - } - virtual void read(UbFileInput* in) - { - this->initVals(); - - std::size_t nofSchedules = in->readSize_t(); - for(std::size_t i=0; i<nofSchedules; i++) - { - UbSchedule schedule; - schedule.read(in); - this->addSchedule(schedule); - } - } - protected: /*==========================================================*/ void initVals() @@ -348,17 +319,6 @@ protected: }; typedef UbScheduler::UbSchedule UbSchedule; -// inline std::ostream& operator<<( std::ostream& os, const UbScheduler& scheduler ) -// { -// os<<"UbScheduler\n"; -// os<<"Schedule | start | end | intervall "<<std::endl; -// for(std::size_t i=0; i<scheduler.schedules.size(); i++) -// os<<std::setw(9)<<i<<"|" -// <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|" -// <<std::setw(19)<<scheduler.schedules[i].getEnd() <<"|" -// <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl; -// return os; -// } #endif //UBSCHEDULER_H diff --git a/src/basics/basics/utilities/UbSystem.h b/src/basics/basics/utilities/UbSystem.h index ec2445480..dcfa4fc6d 100644 --- a/src/basics/basics/utilities/UbSystem.h +++ b/src/basics/basics/utilities/UbSystem.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 UbSystem.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBSYSTEM_H #define UBSYSTEM_H @@ -26,13 +52,12 @@ #include <sys/syscall.h> #include <sys/stat.h> #include <unistd.h> -#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) +#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__)) && !defined(__AIX__) #define UBSYSTEM_LINUX #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> #include <sys/stat.h> #include <unistd.h> + #include <string.h> #elif defined(__AIX__) #define UBSYSTEM_AIX #include "dirent.h" @@ -43,7 +68,6 @@ #error "UbSystem::UnknownMachine" #endif - #if defined(__unix__) && defined(__CYGWIN__) #define UBSYSTEM_CYGWIN #include <windows.h> @@ -64,7 +88,6 @@ #include <typeinfo> #include <cctype> //for toupper #include <ctime> -#include <cstring> #include <basics/utilities/UbException.h> #include <basics/utilities/UbLogger.h> @@ -98,10 +121,12 @@ namespace UbSystem /*==========================================================*/ inline void sleepMs(const unsigned int& msec) { - #if defined UBSYSTEM_WINDOWS + #if defined(UBSYSTEM_WINDOWS) ::Sleep( (msec==0) ? 1 : msec ); // +1 here causes a context switch if SleepMSec(0) is called - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) + #elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)) && !defined(UBSYSTEM_CYGWIN) ::usleep(1000*msec); + #elif defined(UBSYSTEM_CYGWIN) + ::Sleep( (msec==0) ? 1 : msec ); #else #error "UbSystem::sleepMSec - UnknownMachine" #endif @@ -109,9 +134,9 @@ namespace UbSystem /*==========================================================*/ inline void sleepS(const unsigned int& sec) { - #if defined UBSYSTEM_WINDOWS + #if defined(UBSYSTEM_WINDOWS) || defined(UBSYSTEM_CYGWIN) ::Sleep( (sec==0) ? 1 : sec*1000 ); // +1 here causes a context switch if sleepS(0) is called - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) + #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) && !defined(UBSYSTEM_CYGWIN) ::sleep(sec); #else #error "UbSystem::sleepS - UnknownMachine" @@ -236,7 +261,7 @@ namespace UbSystem if( stat(path.c_str(),&stFileInfo) != 0) { return false; - } + } #endif return true; @@ -372,8 +397,10 @@ namespace UbSystem { #if defined UBSYSTEM_WINDOWS return (unsigned long)GetCurrentThreadId(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) + #elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE)) && !defined(UBSYSTEM_CYGWIN) return (unsigned long)syscall(SYS_gettid); + #elif defined(UBSYSTEM_CYGWIN) + return (unsigned long)GetCurrentThreadId(); #elif defined(UBSYSTEM_AIX) return (unsigned long) getpid(); //WORKAROUND for IBM (for get thread id is another function necessary) #else @@ -432,7 +459,7 @@ namespace UbSystem char Name[150]; int i = 0; -#ifdef UBSYSTEM_WINDOWS +#if defined(UBSYSTEM_WINDOWS) || defined(UBSYSTEM_CYGWIN) TCHAR infoBuf[150]; DWORD bufCharCount = 150; memset(Name, 0, 150); @@ -447,7 +474,7 @@ namespace UbSystem { strcpy(Name, "Unknown_Host_Name"); } -#else +#elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)) && !defined(UBSYSTEM_CYGWIN) memset(Name, 0, 150); gethostname(Name, 150); #endif diff --git a/src/basics/basics/utilities/UbTiming.h b/src/basics/basics/utilities/UbTiming.h index 2ba786b97..926089266 100644 --- a/src/basics/basics/utilities/UbTiming.h +++ b/src/basics/basics/utilities/UbTiming.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 UbTiming.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBTIMING_H #define UBTIMING_H @@ -14,27 +40,11 @@ #include <vector> #include <ctime> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #ifdef VF_MPI #include <mpi.h> #include <basics/parallel/PbMpi.h> #endif //VF_MPI -/*=========================================================================*/ -// UbTiming - Time Measuring -// -// -// -//This Class provides the base for ... -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> -//@version 1.1 - 14.02.06 -// - class UbTiming { public: @@ -162,16 +172,6 @@ protected: double deltaT; }; -/*=========================================================================*/ -// UbTimer - Time Measuring -// -// -// -//This Class provides the base for ... -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 16.08.2007 -// #include <basics/utilities/UbSystem.h> //for definitons of system/OS type #ifdef UBSYSTEM_APPLE //Apple hack @@ -197,22 +197,27 @@ protected: #include <pthread.h> #endif -//example: -//t=0 start -//t=1 -//t=2 stop -> return 2; getLapTime=2; getTotalTime 2; getLapTimes: 2 -//t=3 -//t=4 -//t=5 stop -> return 3; getLapTime=3; getTotalTime 5; getLapTimes: 2,3 -//t=6 stop -> return 1; getLapTime=1; getTotalTime 6; getLapTimes: 2,3,1 -//t=7 -//t=8 start ->no consideration of time 7 and 8 -//t=9 -//t=10 stop -> return 2; getLapTime=2; getTotalTime 8; getLapTimes: 2,3,1,2 -//t=11 resetAndStart timer wird zurueckgestellt und neu gestaret -//t=12 -//t=13 -//t=14 stop -> return 3; getLapTime=3; getTotalTime 3; getLapTimes: 3 +/*=========================================================================*/ +//! \brief Time Measuring +//! \details +//! example: +//! \code +//! t=0 start +//! t=1 +//! t=2 stop -> return 2; getLapTime=2; getTotalTime 2; getLapTimes: 2 +//! t=3 +//! t=4 +//! t=5 stop -> return 3; getLapTime=3; getTotalTime 5; getLapTimes: 2,3 +//! t=6 stop -> return 1; getLapTime=1; getTotalTime 6; getLapTimes: 2,3,1 +//! t=7 +//! t=8 start ->no consideration of time 7 and 8 +//! t=9 +//! t=10 stop -> return 2; getLapTime=2; getTotalTime 8; getLapTimes: 2,3,1,2 +//! t=11 resetAndStart -> Timer is reset and restarted +//! t=12 +//! t=13 +//! t=14 stop -> return 3; getLapTime=3; getTotalTime 3; getLapTimes: 3 +//! \endcode class UbTimer { @@ -348,20 +353,6 @@ public: } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & name; - ar & isMeasuring; - ar & startTime; - ar & totalTime; - ar & lapTime; - ar & lapTimes; - ar & storeLapTimes; - } -#endif //CAB_RCF - protected: std::string name; bool isMeasuring; @@ -376,21 +367,17 @@ protected: /*=========================================================================*/ -// UbProgressTimer - Time Measuring -// -// -// -//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstoerung -//und gib die verstrichene Zeit auf "os" in [s] aus -//example: -// { -// UbProgressTimer timer; -// UbSystem::sleepS(10); -// } //--> 10s -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 10.03.2008 -// +//! \brief Time Measuring +//! +//! \details UbProressTimer measures the time from its instantiation to destruction and spend the elapsed time on "os" in [s] +//! example: +//! \code +//! { +//! UbProgressTimer timer; +//! UbSystem::sleepS(10); +//! } //--> 10s +//! \endcode + class UbProgressTimer : public UbTimer { private: diff --git a/src/basics/basics/utilities/UbTuple.h b/src/basics/basics/utilities/UbTuple.h index 710aed4df..4643a08e9 100644 --- a/src/basics/basics/utilities/UbTuple.h +++ b/src/basics/basics/utilities/UbTuple.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 UbTupel.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBTUPLE_H #define UBTUPLE_H @@ -11,56 +37,43 @@ #include <string> #include <ostream> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -/*=========================================================================*/ -/* UbTuple */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.10.06 -*/ - -/* -usage: ... -////Advanced UbTuple -//Bsp: -//// create and use tuple with only one field -//UbTuple<int,int,int,int,int> t1; -//val<1>(t1) += 42; -//std::cout << t1.v1() << std::endl; - -//// create and use duo -//UbTuple<bool,int> t2; -//std::cout << val<1>(t2) << ", "; -//std::cout << t2.v1() << std::endl; - -//// create and use triple -//UbTuple<bool,int,double> t3; -//val<1>(t3) = true; // new values via: val< pos >(triple) = ... -//val<2>(t3) = 42; -//val<3>(t3) = 0.2; -//t3 = makeUbTuple(false, 23, 13.13); - -//std::cout << val<1>(t3) << ", "; -//std::cout << val<2>(t3) << ", "; -//std::cout << val<3>(t3) << std::endl; - -//// create and use quadruple -//UbType<bool,int,float,double> t4(true,42,13,1.95583); -//std::cout << val<4>(t4) << std::endl; //<- option 2 (std) -//std::cout << t4.v2().v2().v2() << std::endl; //<- option 2 -*/ - -//typeop.h -// primary template -/********************************** -* typeop1.hpp: -**********************************/ +////////////////////////////////////////////////////////////////////////// +//! \brief A class implements a tuple +//! \details +//! usage: ...<BR> +//! Advanced UbTuple +//! Example: +//! create and use tuple with only c1 field +//! \code +//! UbTuple<int,int,int,int,int> t1; +//! val<1>(t1) += 42; +//! std::cout << t1.v1() << std::endl; +//! \endcode +//! create and use duo: +//! \code +//! UbTuple<bool,int> t2; +//! std::cout << val<1>(t2) << ", "; +//! std::cout << t2.v1() << std::endl; +//! \endcode +//! create and use triple: +//! \code +//! UbTuple<bool,int,double> t3; +//! val<1>(t3) = true; // new values via: val< pos >(triple) = ... +//! val<2>(t3) = 42; +//! val<3>(t3) = 0.2; +//! t3 = makeUbTuple(false, 23, 13.13); +//! +//! std::cout << val<1>(t3) << ", "; +//! std::cout << val<2>(t3) << ", "; +//! std::cout << val<3>(t3) << std::endl; +//! \endcode +//! create and use quadruple: +//! \code +//! UbType<bool,int,float,double> t4(true,42,13,1.95583); +//! std::cout << val<4>(t4) << std::endl; //<- option 2 (std) +//! std::cout << t4.v2().v2().v2() << std::endl; //<- option 2 +//! \endcode + template <typename T> class UbTypeOp // primary template { @@ -165,15 +178,6 @@ public: T2& v2() { return value2; } T2 const& v2() const { return value2; } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive& ar, const unsigned int version) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - private: T1 value1; // value of first field T2 value2; // value of second field @@ -249,15 +253,6 @@ public: T2& v2() { return value2; } T2 const& v2() const { return value2; } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - private: T1 value1; // value of first field T2 value2; // value of second field @@ -388,7 +383,7 @@ inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT v } //duo6.hpp -// partial specialization for UbDuo<> with only one field +// partial specialization for UbDuo<> with only c1 field template <typename A> struct UbDuo<A,void> { @@ -412,13 +407,6 @@ public: void v2() { } void v2() const { } - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & value1; - } - #endif }; //tupel1.hpp @@ -427,7 +415,44 @@ class UbNullT { }; -// UbTuple<> in general derives from UbTuple<> with one more UbNullT +////////////////////////////////////////////////////////////////////////// +//! \brief A class implements a tuple +//! \details +//! usage: ...<BR> +//! Advanced UbTuple +//! Example: +//! create and use tuple with only c1 field +//! \code +//! UbTuple<int,int,int,int,int> t1; +//! val<1>(t1) += 42; +//! std::cout << t1.v1() << std::endl; +//! \endcode +//! create and use duo: +//! \code +//! UbTuple<bool,int> t2; +//! std::cout << val<1>(t2) << ", "; +//! std::cout << t2.v1() << std::endl; +//! \endcode +//! create and use triple: +//! \code +//! UbTuple<bool,int,double> t3; +//! val<1>(t3) = true; // new values via: val< pos >(triple) = ... +//! val<2>(t3) = 42; +//! val<3>(t3) = 0.2; +//! t3 = makeUbTuple(false, 23, 13.13); +//! +//! std::cout << val<1>(t3) << ", "; +//! std::cout << val<2>(t3) << ", "; +//! std::cout << val<3>(t3) << std::endl; +//! \endcode +//! create and use quadruple: +//! \code +//! UbType<bool,int,float,double> t4(true,42,13,1.95583); +//! std::cout << val<4>(t4) << std::endl; //<- option 2 (std) +//! std::cout << t4.v2().v2().v2() << std::endl; //<- option 2 +//! \endcode + +// UbTuple<> in general derives from UbTuple<> with c1 more UbNullT template <typename P1, typename P2 = UbNullT, typename P3 = UbNullT, @@ -591,7 +616,6 @@ typedef UbTuple<int,int,int,int> UbTupleInt4; typedef UbTuple<int,int,int,int,int> UbTupleInt5; typedef UbTuple<int,int,int,int,int,int> UbTupleInt6; typedef UbTuple<int,int,int,int,int,int,int,int> UbTupleInt8; -typedef UbTuple<unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned> UbTupleUInt8; typedef UbTuple<double,double> UbTupleDouble2; typedef UbTuple<double,double,double> UbTupleDouble3; typedef UbTuple<double,double,double,double> UbTupleDouble4; diff --git a/src/basics/basics/utilities/Vector3D.cpp b/src/basics/basics/utilities/Vector3D.cpp index 34074babd..bb8fb46a2 100644 --- a/src/basics/basics/utilities/Vector3D.cpp +++ b/src/basics/basics/utilities/Vector3D.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 UbVector3D.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/Vector3D.h> #include <cassert> diff --git a/src/basics/basics/utilities/Vector3D.h b/src/basics/basics/utilities/Vector3D.h index 27d48d2e8..03f47b033 100644 --- a/src/basics/basics/utilities/Vector3D.h +++ b/src/basics/basics/utilities/Vector3D.h @@ -1,30 +1,41 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 UbVector3D.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef VECTOR_3D_H #define VECTOR_3D_H #include <string> -/*=========================================================================*/ -/* Vector3D */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.4 - 04.10.07 -*/ - -/* -usage: ... -*/ -#include "basics_export.h" - - - class BASICS_EXPORT Vector3D + class Vector3D { public: // construction @@ -110,14 +121,6 @@ usage: ... static const Vector3D UNIT_X2; static const Vector3D UNIT_X3; - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & m_afTuple; - } - #endif //CAB_RCF - protected: // support for comparisons int CompareArrays (const Vector3D& rkV) const; diff --git a/src/basics/basics/writer/WbWriter.h b/src/basics/basics/writer/WbWriter.h index 2bea860d8..b8d68db7d 100644 --- a/src/basics/basics/writer/WbWriter.h +++ b/src/basics/basics/writer/WbWriter.h @@ -1,19 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// 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 WbWriter.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITER_H #define WBWRITER_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - -#include "basics_export.h" - - #include <vector> #include <string> #include <fstream> @@ -21,19 +40,14 @@ #include <iostream> #include <map> -#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbException.h> +#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbPointerWrapper.h> -#include <basics/utilities/UbAutoRun.hpp> -#include <basics/objects/ObFactory.h> -class BASICS_EXPORT WbWriter +class WbWriter { public: - OBCREATOR_EXT(WbWriter) - ////////////////////////////////////////////////////////////////////////// virtual ~WbWriter() { @@ -78,8 +92,7 @@ public: virtual std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >&celldata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } + std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >&celldata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } ////////////////////////////////////////////////////////////////////////// //octs @@ -92,87 +105,10 @@ public: // 0 ---- 1 virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } + virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } private: }; - -#ifdef CAB_RCF -//serialize von singletons muss hier etwas anders erfolgen ;-) -template<class Archive> -inline bool serializeWbWriter(Archive &ar, WbWriter*& writer) -{ - std::string writerID; - - if( ArchiveTools::isReading(ar) ) - { - ar & writerID; - if(writerID!="no_WbWriter") writer = ObFactory<WbWriter>::getInstance()->createObject(writerID); - else writer = NULL; - } - else /* if (ar.isWrite())) if(Archive::is_saving())*/ - { - if(writer) writerID = writer->getClassObjectTypeID(); - else writerID = "no_WbWriter"; - ar & writerID; - } - return true; -} -////////////////// -template<class Archive, class STL_container> -inline bool serializeWbWriter(Archive &ar, STL_container& writers) -{ - int nofCounter; - std::string writerID; - WbWriter* dummy; - - if( ArchiveTools::isReading(ar) ) - { - ar & nofCounter; - for(int i=0; i<nofCounter; i++) - { - serializeWbWriter(ar, dummy); - writers.push_back(dummy); - } - } - else - { - nofCounter = (int)writers.size(); - ar & nofCounter; - typename STL_container::iterator pos; - for(pos=writers.begin(); pos!=writers.end(); ++pos) - serializeWbWriter(ar, *pos); - } - - return true; -} -////////////////////////////////////////////////////////////////////////// -// Spezialisierung des UbPointerWrappers fuer WbWriter... -// da man bei singletons keine serializemethode einbauen kann... -template< > -class UbPointerWrapper< WbWriter > -{ -public: - UbPointerWrapper() : pointer(NULL) {} - - UbPointerWrapper(WbWriter* pointer) : pointer(pointer) {} - - WbWriter* get() { return pointer; } - - template<class Archive> - void serialize(Archive& ar, const unsigned int version) - { - serializeWbWriter(ar, pointer); - } - -private: - WbWriter* pointer; -}; - - -#endif //CAB_RCF - - #endif //WBWRITER_H diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp b/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp index edf5efea9..880fae2bf 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp +++ b/src/basics/basics/writer/WbWriterVtkXmlASCII.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 WbWriterVtkXmlASCII.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> #include <cstring> @@ -807,7 +839,7 @@ std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,ve return vtkfilename; } /*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleUInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) +std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) { string vtkfilename=filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.h b/src/basics/basics/writer/WbWriterVtkXmlASCII.h index 1d451d8e0..c2d908e14 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlASCII.h +++ b/src/basics/basics/writer/WbWriterVtkXmlASCII.h @@ -1,17 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 WbWriterVtkXmlASCII.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKXMLASCII_H #define WBWRITERVTKXMLASCII_H #include <string> -#include "basics_export.h" - #include <basics/writer/WbWriter.h> -class BASICS_EXPORT WbWriterVtkXmlASCII : public WbWriter +class WbWriterVtkXmlASCII : public WbWriter { public: - OBCREATOR_EXT( WbWriterVtkXmlASCII ) - static WbWriterVtkXmlASCII* getInstance() { static WbWriterVtkXmlASCII instance; @@ -85,12 +113,10 @@ public: // 0 ---- 1 std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleUInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); + std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); private: }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); - #endif //WBWRITERVTKXMLASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp b/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp index b44943302..94e134e89 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp +++ b/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp @@ -1,49 +1,44 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 WbWriterVtkXmlBinary.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/writer/WbWriterVtkXmlBinary.h> #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbSystem.h> - -#include "buildInfo.h" #include <cstring> using namespace std; /*===============================================================================*/ string WbWriterVtkXmlBinary::pvdEndTag =" </Collection>\n</VTKFile>"; - -std::string WbWriterVtkXmlBinary::getHeaderTag() -{ - std::string header = "<!--- \n"; - - header += "git-commit-hash=\""; - header += buildInfo::gitCommitHash(); - header += "\" \n"; - - header += "git-branch=\""; - header += buildInfo::gitBranch(); - header += "\" \n"; - - header += "compiler-flag=\""; - header += buildInfo::compilerFlags(); - header += "\" \n"; - - header += "buildMachine=\""; - header += buildInfo::buildMachine(); - header += "\" \n"; - - header += "ProjectDir=\""; - header += buildInfo::projectDir(); - header += "\" \n"; - - header += "binaryDir=\""; - header += buildInfo::binaryDir(); - header += "\" \n"; - - - header += "-->\n"; - return header; -} - /*===============================================================================*/ string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) { @@ -1195,8 +1190,7 @@ string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector return vtkfilename; } /*===============================================================================*/ - -string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleUInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) +string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) { string vtkfilename = filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); @@ -1223,7 +1217,6 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector unsigned long long offset = 0; //VTK FILE out<<"<?xml version=\"2.0\"?>\n"; - out<< getHeaderTag(); out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; out<<" <UnstructuredGrid>"<<"\n"; out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; @@ -1312,7 +1305,7 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector //float tmp = (float)nodedata[s][d]; //out.write((char*)&tmp,sizeof(float)); double tmp = nodedata[s][d]; - out.write((char*)&tmp,sizeof(double)); + out.write((char*)&tmp,sizeof(double)); } } out<<"\n</AppendedData>\n"; diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.h b/src/basics/basics/writer/WbWriterVtkXmlBinary.h index 81c0a3aea..6ad1ab7fc 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlBinary.h +++ b/src/basics/basics/writer/WbWriterVtkXmlBinary.h @@ -1,19 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 WbWriterVtkXmlBinary.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKXMLBINARY_H #define WBWRITERVTKXMLBINARY_H #include <string> -#include "basics_export.h" - #include <basics/writer/WbWriter.h> -class BASICS_EXPORT WbWriterVtkXmlBinary : public WbWriter +class WbWriterVtkXmlBinary : public WbWriter { public: -#ifndef SWIG - OBCREATOR_EXT( WbWriterVtkXmlBinary ) -#endif - static WbWriterVtkXmlBinary* getInstance() { static WbWriterVtkXmlBinary instance; @@ -34,8 +60,6 @@ private: public: std::string getFileExtension() { return ".bin.vtu"; } - std::string getHeaderTag(); - //write a metafile std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); @@ -88,14 +112,10 @@ public: // 0 ---- 1 std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); + std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); private: }; -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary); -#endif - #endif //WBWRITERVTKXMLBINARY_H diff --git a/src/basics/geometry3d/CoordinateTransformation3D.cpp b/src/basics/geometry3d/CoordinateTransformation3D.cpp index c3d0ff6d1..c54d0e1c6 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.cpp +++ b/src/basics/geometry3d/CoordinateTransformation3D.cpp @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -37,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() @@ -60,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; @@ -68,7 +68,7 @@ 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; // } @@ -84,78 +84,78 @@ 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 +@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; + 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; - //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; + 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); - this->fromX2factorX1 = -cosB*sinA*Sx2; - this->fromX2factorX2 = -(sinG*sinB*sinA-cosG*cosA)*Sx2; - this->fromX2factorX3 = (cosG*sinB*sinA+sinG*cosA)*Sx2; - this->fromX2delta = Tx2; + //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->fromX3factorX1 = sinB*Sx3; - this->fromX3factorX2 = -sinG*cosB*Sx3; - this->fromX3factorX3 = cosG*cosB*Sx3; - this->fromX3delta = Tx3; + 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->active = true; + 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->transformation = true; + this->active = true; + + this->transformation = true; } /*======================================================*/ /*! @@ -164,8 +164,8 @@ Set transformation active state (if this IS a transformation) **/ 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; } /*======================================================*/ /*! @@ -176,20 +176,20 @@ 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; } /*======================================================*/ /*! @@ -198,20 +198,20 @@ Transform FROM global coordinates TO transformed coordinates (ignoring rotation) **/ 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; } /*======================================================*/ /*! @@ -222,20 +222,20 @@ 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; } /*======================================================*/ /*! @@ -244,20 +244,20 @@ Transform FROM transformed coordinates TO global coordinates (ignoring rotation) **/ 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; } /*======================================================*/ /*! @@ -266,7 +266,7 @@ Returns 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; @@ -283,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 17e6505ae..9e7448fb9 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.h +++ b/src/basics/geometry3d/CoordinateTransformation3D.h @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -42,11 +42,11 @@ #include <PointerDefinitions.h> /////////////////////////////////////////////////////////////////////////////////////// -//! +//! //! \brief A class provides 3d coordinate transformation //! \details //! description: x1/x2/x3 = old, x1*/x2*/x3* = new -//! x2 +//! x2 //! ^ x* //! | / //! | 2* @@ -59,66 +59,66 @@ //! 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 + 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); } + //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; } + 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; + 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; }; diff --git a/src/basics/geometry3d/GbCuboid3D.cpp b/src/basics/geometry3d/GbCuboid3D.cpp index dc118ffc3..f95e11428 100644 --- a/src/basics/geometry3d/GbCuboid3D.cpp +++ b/src/basics/geometry3d/GbCuboid3D.cpp @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -42,210 +42,210 @@ using namespace std; // 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) @@ -257,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) @@ -286,282 +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 + 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 */ -} + + /* 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 3e26888e7..992e423bc 100644 --- a/src/basics/geometry3d/GbCuboid3D.h +++ b/src/basics/geometry3d/GbCuboid3D.h @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -50,96 +50,96 @@ 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(); - - //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 +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; }; #endif -- GitLab