diff --git a/ThirdParty/Library/basics/container/CMakePackage.txt b/ThirdParty/Library/basics/container/CMakePackage.txt deleted file mode 100644 index f7766736561db92faa97bdef5d1c1a6a40533148..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CMakePackage.txt +++ /dev/null @@ -1,4 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) - - diff --git a/ThirdParty/Library/basics/container/CbArray2D.h b/ThirdParty/Library/basics/container/CbArray2D.h deleted file mode 100644 index 2dc54329b868a760d1803d4c03ba7099c52b4b44..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CbArray2D.h +++ /dev/null @@ -1,414 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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> -#include <basics/utilities/UbEqual.h> -#include <algorithm> -#include <typeinfo> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// IndexClasses - -//IndexerX2X1: -// 4 5 6 -// Array 1 2 3 --> vector 1 2 3 4 5 6 -//optimaler schleifendurchlauf -//for(alle X2) -// for(alle X1) -class IndexerX2X1 -{ -public: - typedef int size_type; -public: - inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const - { - return nx1* x2 + x1; - } - inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const - { - return nx1* x2; - } -}; - -//IndexerX1X2: -// 4 5 6 -// Array 1 2 3 --> vector 1 4 2 5 3 6 -//optimaler schleifendurchlauf -//for(alle X1) -// for(alle X2) -class IndexerX1X2 -{ -public: - typedef int size_type; -public: - inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1,const size_type& nx2) const - { - return nx2* x1+ x2; - } - inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const - { - return nx2* x1; - } -}; - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// CbArray2D - -template<typename T, typename IndexClass = IndexerX2X1> -class CbArray2D -{ -public: - typedef T value_type; - typedef IndexClass indexer_type; - typedef typename IndexClass::size_type size_type; - typedef typename std::vector< value_type >::reference reference; - typedef typename std::vector< value_type >::const_reference const_reference; - typedef typename std::vector< value_type >::pointer pointer; - typedef typename std::vector< value_type >::const_pointer const_pointer; - -private: - template< typename value_type2, typename IndexClass2 > friend class CbArray2D; - -public: - /*=======================================================================*/ - CbArray2D() - { - this->resize(0,0); - } - /*=======================================================================*/ - CbArray2D(const size_type& nx2, const size_type& nx1) - { - this->resize(nx2,nx1); - } - /*=======================================================================*/ - CbArray2D(const size_type& nx2, const size_type& nx1, const value_type& val) - { - this->resize(nx2,nx1,val); - } - /*=======================================================================*/ - CbArray2D(const size_type& uniformDimensionSize /*nx1==nx2*/) - { - this->resize(uniformDimensionSize,uniformDimensionSize); - } - /*=======================================================================*/ - //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird) - CbArray2D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2) - { - assert( (nx1*nx2)==vec.size() ); - this->data.swap(vec); - this->resize(nx1,nx2); - } - /*=======================================================================*/ - CbArray2D(const CbArray2D& src) - : nx1(src.nx1) - , nx2(src.nx2) - , data(src.data) - { - } - /*=======================================================================*/ - template< typename value_type2 > - CbArray2D(const CbArray2D< value_type2 >& src) - : nx1(src.nx1) - , nx2(src.nx2) - { - //Sourcedaten kopieren - this->data.resize( src.data.size() ); - for(std::size_t i=0; i<data.size(); ++i) - this->data[i] = src.data[i]; - } - /*=======================================================================*/ - virtual ~CbArray2D() - { - //vector wird automatisch zerstoert - } - /*=======================================================================*/ - CbArray2D& operator= (const CbArray2D& rhs) - { - if(this == &rhs) return *this; - - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - - //Laenge anpassen - this->data.resize(rhs.data.size()); - //gespeicherte Datenelemente loeschen - this->data.clear(); - - //Sourcedaten kopieren - this->data = rhs.data; - - return *this; - } - /*=======================================================================*/ - //durch value_type2 kann man z.B. ein float array einem double array zuweisen! - template< typename value_type2, typename IndexClass2 > - CbArray2D& operator= (const CbArray2D< value_type2, IndexClass2 >& rhs) - { - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - - //gespeicherte Datenelemente loeschen - this->data.clear(); - //Laenge anpassen - 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 - // 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++) - this->operator()(x1,x2) = static_cast< value_type >( rhs.operator()(x1,x2) ); - - return *this; - } - /*=======================================================================*/ - bool operator== (const CbArray2D& rhs) const - { - if( this == &rhs ) return true; - - if( this->nx1!=rhs.nx1 - || this->nx2!=rhs.nx2 - || this->data.size() != rhs.data.size() ) - { - return false; - } - - return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() ); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator== (const CbArray2D< value_type2, IndexClass2 >& rhs) const - { - if( this->data.size() != rhs.data.size() ) return false; - - //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - for(int x1=0; x1<this->nx1; x1++) - for(int x2=0; x2<this->nx2; x2++) - if( !isUbEqual(this->operator()(x1,x2), rhs.operator()(x1,x2)) ) - return false; - - return true; - } - /*=======================================================================*/ - bool operator!= (const CbArray2D& rhs) const - { - return !(*this==rhs); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator!= (const CbArray2D< value_type2, IndexClass2 >& rhs) const - { - return !(*this==rhs); - } - /*=======================================================================*/ - reference operator() (const size_type& x1,const size_type& x2) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - - return this->data[indexer.getIndex(x1,x2,nx1,nx2)]; - } - /*=======================================================================*/ - const_reference operator() (const size_type& x1,const size_type& x2) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - - return this->data[indexer.getIndex(x1,x2,nx1,nx2)]; - } - /*=======================================================================*/ - pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)]; - } - /*=======================================================================*/ - const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)]; - } - /*=======================================================================*/ - void setObject(const size_type& x1,const size_type& x2,const value_type& value) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - this->data[indexer.getIndex(x1,x2,nx1,nx2)] = value; - } - /*=======================================================================*/ - reference getObject(const size_type& x1, const size_type& x2) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - return this->data[indexer.getIndex(x1,x2,nx1,nx2)] ; - } - /*=======================================================================*/ - typename std::vector<value_type>::const_reference getObject(const size_type& x1, const size_type& x2) const - { - return this->operator()(x1,x2); - } - /*=======================================================================*/ - bool isEmpty() const { return data.empty(); } - size_type getNX1() const { return this->nx1; } - size_type getNX2() const { return this->nx2; } - /*=======================================================================*/ - void reset(const T& val) - { - std::fill( this->data.begin(), this->data.end(), val ); - } - /*=======================================================================*/ - std::string toString() const - { - std::stringstream text; - for(size_type x2=0; x2<this->nx2; x2++) - { - for(size_type x1=0; x1<this->nx1; x1++) - { - //hier kommts zum Konflikt ab und an ... - text<<this->getObject(x1,x2)<<", "; - } - text<<"\n"; - } - - return text.str(); - } - /*=======================================================================*/ - std::string getInfo() const - { - std::stringstream text; - text<<"CbArray2D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >"; - text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<")"; - return text.str(); - } - /*=======================================================================*/ - void resize(const size_type& uniformDimensionSize) - { - this->resize(uniformDimensionSize,uniformDimensionSize); - } - /*=======================================================================*/ - void resize(const size_type& nx1,const size_type& nx2) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->data.resize(nx1*nx2); - } - /*=======================================================================*/ - void resize(const size_type& nx1, const size_type& nx2, const value_type& initVal ) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->data.resize(nx1*nx2,initVal); - } - /*=======================================================================*/ - void clear() - { - this->nx1 = 0; - this->nx2 = 0; - this->data.clear(); - } - /*=======================================================================*/ - std::vector< value_type >& getDataVector() { return this->data; } - /*=======================================================================*/ - const std::vector< value_type >& getDataVector() const { return this->data; } - /*=======================================================================*/ - inline size_type getDataVectorIndex(const size_type& x1, const size_type& x2) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) ); - #endif - - 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 - //else -> false - inline bool indicesInRange(const size_type& x1, const size_type& x2) const - { - if( x1 < 0 || x1 >= this->nx1 - || x2 < 0 || x2 >= this->nx2 ) - { - return false; - } - return true; - } - /*=======================================================================*/ - std::string getExceptionErrorString(const size_type& x1, const size_type& x2) const - { - std::stringstream out("index out of range - "); - out<<"("<<x1<<","<<x2<<") not in ("<<nx1<<","<<nx2<<")"; - return out.str(); - } - /*=======================================================================*/ - -protected: - size_type nx1; - size_type nx2; - indexer_type indexer; - std::vector< value_type > data; -}; - -#endif //CBARRAY2D_H diff --git a/ThirdParty/Library/basics/container/CbArray3D.h b/ThirdParty/Library/basics/container/CbArray3D.h deleted file mode 100644 index e3a172a379ccaa01a26ba06e16b9e6d18a235b67..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CbArray3D.h +++ /dev/null @@ -1,479 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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> -#include <basics/utilities/UbEqual.h> -#include <algorithm> -#include <typeinfo> -#include <boost/serialization/serialization.hpp> -#include <boost/smart_ptr/shared_ptr.hpp> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// IndexClasses - -//IndexerX3X2X1: -// 4 5 6 10 11 12 -// Array ebene A 1 2 3 ebene B 7 8 9 --> vector 1 2 3 4 5 6 7 8 9 10 11 12 -//x1-reihen "liegen am stueck" im speicher -//optimaler schleifendurchlauf -//for(alle X3) -// for(alle X2) -// for(alle X1) -class IndexerX3X2X1// FunctorX1SortedForX1X2Plane -{ -public: - typedef size_t size_type; -public: - inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx1 * ( nx2 * x3 + x2) + x1 ; - } - inline std::size_t getStartIndexOfSortedArray( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx1 * ( nx2 * x3 + x2); - } -}; - -//IndexerX1X2X3: -// 4 5 6 10 11 12 -// Array ebene A 1 2 3 ebene B 7 8 9 --> -//optimaler schleifendurchlauf -//for(alle X1) -// for(alle X2) -// for(alle X3) -class IndexerX1X2X3 //FunctorX3SortedForX3X2Plane -{ -public: - typedef size_t size_type; -public: - inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx3 * ( nx2 * x1 + x2) + x3 ; - } - inline std::size_t getStartIndexOfSortedArray( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx3 * ( nx2 * x1 + x2); - } -}; - -//IndexerX2X1X3: -// 4 5 6 10 11 12 -// Array ebene A 1 2 3 ebene B 7 8 9 --> vector 1 7 2 8 3 9 4 10 5 11 6 12 -//optimaler schleifendurchlauf -//for(alle X2) -// for(alle X1) -// for(alle X3) -class IndexerX2X1X3 -{ -public: - typedef size_t size_type; -public: - inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx3* ( nx1 * x2 + x1) + x3 ; - } - inline std::size_t getStartIndexOfSortedArray( const size_type& x1 , const size_type& x2 , const size_type& x3 - , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const - { - return nx3* ( nx1 * x2 + x1); - } -}; - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// CbArray3D -template<typename T, typename IndexClass = IndexerX3X2X1> -class CbArray3D -{ -public: - typedef boost::shared_ptr< CbArray3D <T,IndexClass> > CbArray3DPtr; - - typedef T value_type; - typedef IndexClass indexer_type; - typedef typename IndexClass::size_type size_type; - typedef typename std::vector< value_type >::reference reference; - typedef typename std::vector< value_type >::const_reference const_reference; - typedef typename std::vector< value_type >::pointer pointer; - typedef typename std::vector< value_type >::const_pointer const_pointer; - -private: - template< typename value_type2, typename IndexClass2 > friend class CbArray3D; - -public: - /*=======================================================================*/ - CbArray3D() - { - this->resize(0,0,0); - } - /*=======================================================================*/ - CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const value_type& val) - { - this->resize(nx1,nx2,nx3,val); - } - /*=======================================================================*/ - CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3) - { - this->resize(nx1,nx2,nx3); - } - /*=======================================================================*/ - CbArray3D(const size_type& uniformDimensionSize /*nx1==nx2==nx3*/) - { - this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); - } - /*=======================================================================*/ - //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend 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() ); - this->data.swap(vec); - this->resize(nx1,nx2,nx3); - } - /*=======================================================================*/ - CbArray3D(const CbArray3D& src) - : nx1(src.nx1) - , nx2(src.nx2) - , nx3(src.nx3) - , data(src.data) - { - } - /*=======================================================================*/ - template< typename value_type2 > - CbArray3D(const CbArray3D< value_type2 >& src) - : nx1(src.nx1) - , nx2(src.nx2) - , nx3(src.nx3) - { - //Sourcedaten kopieren - this->data.resize( src.data.size() ); - for(std::size_t i=0; i<data.size(); ++i) - this->data[i] = src.data[i]; - } - /*=======================================================================*/ - virtual ~CbArray3D() - { - //vector wird automatisch zerstoert - } - /*=======================================================================*/ - CbArray3D& operator= (const CbArray3D& rhs) - { - if(this == &rhs) return *this; - - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - this->nx3 = rhs.nx3; - - //gespeicherte Datenelemente loeschen - //Laenge anpassen - this->data.resize(rhs.data.size()); - //gespeicherte Datenelemente loeschen - this->data.clear(); - - //Sourcedaten kopieren - this->data = rhs.data; - - return *this; - } - /*=======================================================================*/ - //durch value_type2 kann man z.B. ein float array einer double array zuweisen! - template< typename value_type2, typename IndexClass2 > - CbArray3D& operator= (const CbArray3D< value_type2, IndexClass2 >& rhs) - { - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - this->nx3 = rhs.nx3; - - //gespeicherte Datenelemente loeschen - this->data.clear(); - //Laenge anpassen - this->data.resize(rhs.data.size()); - - //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - for(int x3=0; x3<this->nx3; x3++) - for(int x2=0; x2<this->nx2; x2++) - for(int x1=0; x1<this->nx1; x1++) - this->operator()(x1,x2,x3) = static_cast< value_type >( rhs.operator()(x1,x2,x3) ); - - return *this; - } - /*=======================================================================*/ - bool operator== (const CbArray3D& rhs) const - { - if(this == &rhs) return true; - - if( this->nx1!=rhs.nx1 - || this->nx2!=rhs.nx2 - || this->nx3!=rhs.nx3 - || this->data.size() != rhs.data.size() ) - { - return false; - } - - return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() ); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator== (const CbArray3D< value_type2, IndexClass2 >& rhs) const - { - if( this->data.size() != rhs.data.size() ) return false; - - //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - for(int x3=0; x3<this->nx3; x3++) - for(int x2=0; x2<this->nx2; x2++) - for(int x1=0; x1<this->nx1; x1++) - if( !isUbEqual(this->operator()(x1,x2,x3), rhs.operator()(x1,x2,x3)) ) - return false; - - return true; - } - /*=======================================================================*/ - bool operator!= (const CbArray3D& src) const - { - return !(*this==src); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator!= (const CbArray3D< value_type2, IndexClass2 >& rhs) const - { - return !(*this==rhs); - } - /*=======================================================================*/ - reference operator() (const size_type& x1, const size_type& x2, const size_type& x3) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ]; - } - /*=======================================================================*/ - const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ]; - } - /*=======================================================================*/ - pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)]; - } - /*=======================================================================*/ - const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)]; - } - /*=======================================================================*/ - void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const value_type& value) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] = value; - } - /*=======================================================================*/ - reference getObject(const size_type& x1, const size_type& x2, const size_type& x3) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] ; - } - /*=======================================================================*/ - const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3) const - { - return (*this)(x1,x2,x3); - } - /*=======================================================================*/ - bool isEmpty() const { return data.empty(); } - size_type getNX1() const { return this->nx1; } - size_type getNX2() const { return this->nx2; } - size_type getNX3() const { return this->nx3; } - /*=======================================================================*/ - void reset(const value_type& val) - { - std::fill( this->data.begin(), this->data.end(), val ); - } - /*=======================================================================*/ - std::string toString() const - { - std::stringstream text; - for(size_type x1=0; x1<this->nx1; x1++) - { - for(size_type x2=0; x2<this->nx2; x2++) - { - for(size_type x3=0; x3<this->nx3; x3++) - { - text<<(*this)(x1,x2,x3)<<", "; - } - text<<std::endl; - } - text<<std::endl<<std::endl; - } - - return text.str(); - } - /*=======================================================================*/ - std::string getInfo() const - { - std::stringstream text; - text<<"CbArray3D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >"; - text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<")"; - return text.str(); - } - /*=======================================================================*/ - void resize(const int& uniformDimensionSize) - { - this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); - } - /*=======================================================================*/ - void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->data.resize(nx1*nx2*nx3); - } - /*=======================================================================*/ - void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3,const value_type& val) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->data.resize(nx1*nx2*nx3,val); - } - /*=======================================================================*/ - void clear() - { - this->nx1 = 0; - this->nx2 = 0; - this->nx3 = 0; - this->data.clear(); - } - /*=======================================================================*/ - std::vector< value_type >& getDataVector() { return this->data; } - /*=======================================================================*/ - const std::vector< value_type >& getDataVector() const { return this->data; } - /*=======================================================================*/ - inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) ); - #endif - - 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 - //else -> false - inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3) const - { - if( x1 < 0 || x1 >= this->nx1 - || x2 < 0 || x2 >= this->nx2 - || x3 < 0 || x3 >= this->nx3 ) - { - return false; - } - return true; - } -protected: - /*=======================================================================*/ - std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3) const - { - std::stringstream out("index out of range - "); - out<<"("<<x1<<","<<x2<<","<<x3<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<")"; - return out.str(); - } - /*=======================================================================*/ - -protected: - size_type nx1; - size_type nx2; - size_type nx3; - indexer_type indexer; - std::vector< value_type > data; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & data; - } -}; - -#endif //CBARRAY3D_H diff --git a/ThirdParty/Library/basics/container/CbArray4D.h b/ThirdParty/Library/basics/container/CbArray4D.h deleted file mode 100644 index ed2e6aa778efa366d182c5180c20e4e11186cbab..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CbArray4D.h +++ /dev/null @@ -1,463 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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> -#include <basics/utilities/UbEqual.h> -#include <algorithm> -#include <typeinfo> -#include <boost/serialization/serialization.hpp> - -#include <boost/smart_ptr/shared_ptr.hpp> - - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// IndexClasses - -//IndexerX1X2X3X4: -//x4-reihen "liegen am stueck" im speicher -//optimaler schleifendurchlauf -//for(alle X1) -// for(alle X2) -// for(alle X3) -// for(alle X4) -class IndexerX1X2X3X4 -{ -public: - typedef int size_type; -public: - inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4 - , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 ) const - { - return nx4*(nx3*(nx2*x1+ x2)+x3)+x4 ; - } - inline std::size_t getStartIndexOfSortedArray( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4 - , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 ) const - { - return nx4*(nx3*(nx2*x1+ x2)+x3); - } -}; -////////////////////////////////////////////////////////////////////////// -// IndexClasses - -//IndexerX4X3X2X1: -//x1-reihen "liegen am stueck" im speicher -//optimaler schleifendurchlauf -//for(alle X4) -// for(alle X3) -// for(alle X2) -// for(alle X1) -class IndexerX4X3X2X1 -{ -public: - typedef size_t size_type; -public: - inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4 - , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 ) const - { - return nx1*(nx2*(nx3*x4+ x3)+x2)+x1; - } - inline std::size_t getStartIndexOfSortedArray( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4 - , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 ) const - { - return nx1*(nx2*(nx3*x4+ x3)+x2); - } -}; -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// CbArray4D -template<typename T, typename IndexClass = IndexerX4X3X2X1> -class CbArray4D -{ -public: - typedef boost::shared_ptr< CbArray4D <T,IndexClass> > CbArray4DPtr; - - typedef T value_type; - typedef IndexClass indexer_type; - typedef typename IndexClass::size_type size_type; - typedef typename std::vector< value_type >::reference reference; - typedef typename std::vector< value_type >::const_reference const_reference; - typedef typename std::vector< value_type >::pointer pointer; - typedef typename std::vector< value_type >::const_pointer const_pointer; - -private: - template< typename value_type2, typename IndexClass2 > friend class CbArray4D; - -public: - /*=======================================================================*/ - CbArray4D() - { - this->resize(0,0,0,0); - } - /*=======================================================================*/ - CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4) - { - this->resize(nx1,nx2,nx3,nx4); - } - /*=======================================================================*/ - CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val) - { - this->resize(nx1,nx2,nx3,nx4,val); - } - /*=======================================================================*/ - CbArray4D(const size_type& uniformDimensionSize /*nx1=nx2=nx3=nx4*/) - { - this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); - } - /*=======================================================================*/ - //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend 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() ); - this->data.swap(vec); - this->resize(nx1,nx2,nx3,nx4); - } - /*=======================================================================*/ - CbArray4D(const CbArray4D& src) - : nx1(src.nx1) - , nx2(src.nx2) - , nx3(src.nx3) - , nx4(src.nx4) - , data(src.data) - { - } - /*=======================================================================*/ - template< typename value_type2 > - CbArray4D(const CbArray4D< value_type2 >& src) - : nx1(src.nx1) - , nx2(src.nx2) - , nx3(src.nx3) - , nx4(src.nx4) - { - //Sourcedaten kopieren - this->data.resize( src.data.size() ); - for(std::size_t i=0; i<data.size(); ++i) - this->data[i] = src.data[i]; - } - /*=======================================================================*/ - virtual ~CbArray4D() - { - //vector wird automatisch zerstoert - } - /*=======================================================================*/ - CbArray4D& operator= (const CbArray4D& rhs) - { - if(this == &rhs) return *this; - - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - this->nx3 = rhs.nx3; - this->nx4 = rhs.nx4; - - //gespeicherte Datenelemente loeschen - //Laenge anpassen - this->data.resize(rhs.data.size()); - //gespeicherte Datenelemente loeschen - this->data.clear(); - - //Sourcedaten kopieren - this->data = rhs.data; - - return *this; - } - /*=======================================================================*/ - //durch value_type2 kann man z.B. ein float Array einem double Array zuweisen! - template< typename value_type2, typename IndexClass2 > - CbArray4D& operator= (const CbArray4D< value_type2, IndexClass2 >& rhs) - { - this->nx1 = rhs.nx1; - this->nx2 = rhs.nx2; - this->nx3 = rhs.nx3; - this->nx4 = rhs.nx4; - - //gespeicherte Datenelemente loeschen - this->data.clear(); - //Laenge anpassen - this->data.resize(rhs.data.size()); - - //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - for(int x1=0; x1<this->nx1; x1++) - for(int x2=0; x2<this->nx2; x2++) - for(int x3=0; x3<this->nx3; x3++) - for(int x4=0; x4<this->nx4; x4++) - this->operator()(x1,x2,x3,x4) = static_cast< value_type >( rhs.operator()(x1,x2,x3,x4)); - - return *this; - } - /*=======================================================================*/ - bool operator== (const CbArray4D& rhs) const - { - if( this == &rhs ) return true; - - if( this->nx1!=rhs.nx1 - || this->nx2!=rhs.nx2 - || this->nx3!=rhs.nx3 - || this->nx4!=rhs.nx4 - || this->data.size() != rhs.data.size() ) - { - return false; - } - - return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() ); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator== (const CbArray4D< value_type2, IndexClass2 >& rhs) const - { - if( this->data.size() != rhs.data.size() ) return false; - - //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen) - for(int x4=0; x4<this->nx4; x4++) - for(int x3=0; x3<this->nx3; x3++) - for(int x2=0; x2<this->nx2; x2++) - for(int x1=0; x1<this->nx1; x1++) - if( !isUbEqual(this->operator()(x1,x2,x3,x4), rhs.operator()(x1,x2,x3,x4)) ) - return false; - - return true; - } - /*=======================================================================*/ - bool operator!= (const CbArray4D& rhs) const - { - return !(*this==rhs); - } - /*=======================================================================*/ - template< typename value_type2, typename IndexClass2 > - bool operator!= (const CbArray4D< value_type2, IndexClass2 >& rhs) const - { - return !(*this==rhs); - } - /*=======================================================================*/ - reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)]; - } - /*=======================================================================*/ - const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - #ifdef CbArray4D_RANGECHECKING - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)]; - } - /*=======================================================================*/ - pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)]; - } - /*=======================================================================*/ - const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)]; - } - /*=======================================================================*/ - void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4, const value_type& value) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)] = value; - } - /*=======================================================================*/ - reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)]; - } - /*=======================================================================*/ - const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - return (*this)(x1,x2,x3,x4,nx1,nx2,nx3,nx4); - } - /*=======================================================================*/ - bool isEmpty() const { return data.empty(); } - size_type getNX1() const { return this->nx1; } - size_type getNX2() const { return this->nx2; } - size_type getNX3() const { return this->nx3; } - size_type getNX4() const { return this->nx4; } - /*=======================================================================*/ - void reset(const value_type& val) - { - std::fill( this->data.begin(), this->data.end(), val ); - } - /*=======================================================================*/ - std::string toString() const - { - std::stringstream text; - text<<std::setprecision(19); - for(size_type x1=0; x1<this->nx1; x1++) - { - for(size_type x2=0; x2<this->nx2; x2++) - { - for(size_type x3=0; x3<this->nx3; x3++) - { - for(size_type x4=0; x4<this->nx4; x4++) - { - text<<(*this)(x1,x2,x3,x4)<<", "; - } - text<<std::endl; - } - text<<std::endl; - } - text<<std::endl<<std::endl; - } - - return text.str(); - } - /*=======================================================================*/ - std::string getInfo() const - { - std::stringstream text; - text<<"CbArray4D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >"; - text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<", nx4="<<this->nx4<<")"; - return text.str(); - } - /*=======================================================================*/ - void resize(const size_type& uniformDimensionSize) { this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); } - /*=======================================================================*/ - void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->nx4 = nx4; - this->data.resize(nx1*nx2*nx3*nx4); - } - /*=======================================================================*/ - void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->nx4 = nx4; - this->data.resize(nx1*nx2*nx3*nx4,val); - } - /*=======================================================================*/ - std::vector< value_type >& getDataVector() { return this->data; } - /*=======================================================================*/ - const std::vector< value_type >& getDataVector() const { return this->data; } - /*=======================================================================*/ - inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if( !this->indicesInRange(x1,x2,x3,x4) ) - UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) ); - #endif - - 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 - //else -> false - inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - if( x1 < 0 || x1 >= this->nx1 - || x2 < 0 || x2 >= this->nx2 - || x3 < 0 || x3 >= this->nx3 - || x4 < 0 || x4 >= this->nx4 ) - { - return false; - } - return true; - } - /*=======================================================================*/ - std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const - { - std::stringstream out("index out of range - "); - out<<"("<<x1<<","<<x2<<","<<x3<<","<<x4<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<","<<nx4<<")"; - return out.str(); - } - /*=======================================================================*/ - -protected: - size_type nx1; - size_type nx2; - size_type nx3; - size_type nx4; - indexer_type indexer; - std::vector< value_type > data; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & nx4; - ar & data; - } -}; - -#endif //CBARRAY4D_H diff --git a/ThirdParty/Library/basics/container/CbVector.h b/ThirdParty/Library/basics/container/CbVector.h deleted file mode 100644 index 8b16e077308c2773a71530845ed5f98c6243144a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CbVector.h +++ /dev/null @@ -1,365 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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 -#include <memory> //for memcopy - -#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; - -////////////////////////////////////////////////////////////////////////// -template< typename T > -class CbVector -{ -public: - typedef T value_type; - typedef value_type* pointer; - typedef std::size_t size_type; - - friend class CbVectorAllocator<value_type>; //um auf ptrData und dataSize zugreifen zu koennen! - -public: - /*==========================================================*/ - CbVector( CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type> ) - : ptrData(NULL) - , dataSize(0) - , allocator(allocator) - { - this->allocator->alloc(*this,0,value_type()); - } - /*==========================================================*/ - CbVector( const size_type size, CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type>, const value_type& value=value_type() ) - : ptrData(NULL) - , dataSize(0) - , allocator(allocator) - { - this->allocator->alloc(*this,size,value); - } - /*==========================================================*/ - virtual ~CbVector() - { - if(allocator) - { - this->allocator->dealloc(*this); - delete allocator; - allocator=NULL; - } - } - /*=======================================================================*/ - CbVector& operator= (const CbVector& src) - { - if(this == &src) return *this; - - //gespeicherte Datenelemente loeschen - //Laenge anpassen - this->allocator->resize(*this, src.size()); - - //gespeicherte Datenelemente kopieren - if( !src.empty() ) - { - memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); - //for(size_type i=0; i<src.size(); i++) - // (*this)[i] = src[i]; - } - - return *this; - } - /*=======================================================================*/ - CbVector& operator= (const std::vector< value_type >& src) - { - //gespeicherte Datenelemente loeschen - //Laenge anpassen - this->allocator->resize(*this, src.size()); - - //gespeicherte Datenelemente kopieren - if( !src.empty() ) - { - memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); - //for(size_type i=0; i<src.size(); i++) - // (*this)[i] = src[i]; - } - - return *this; - } - /*=======================================================================*/ - bool operator== (const CbVector& rhs) const - { - if( this == &rhs ) return true; - if( this->dataSize != rhs.dataSize ) return false; - - for(size_type i=0; i<rhs.size(); i++) - if( !isUbEqual( this->operator[](i), rhs.operator[](i) ) ) - return false; - - return true; - } - /*==========================================================*/ - void setAllocator( CbVectorAllocator<value_type>* const& allocator ) - { - if(this->allocator) - { - if(this->allocator==allocator) return; - this->allocator->dealloc(*this); - delete this->allocator; - } - this->allocator = allocator; - this->allocator->alloc(*this,0); - } - /*==========================================================*/ - size_type size() const { return dataSize; } - /*==========================================================*/ - bool empty() const { return dataSize==0; } - /*==========================================================*/ - bool resize(const size_type& dataSize) - { - return allocator->resize(*this, dataSize); - } - /*==========================================================*/ - bool resize(const size_type& dataSize, const value_type& value) - { - return allocator->resize(*this, dataSize, value); - } - /*==========================================================*/ - void swap(CbVector& rhs) - { - if( this == &rhs ) return; - - std::swap( this->ptrData , rhs.ptrData ); - std::swap( this->dataSize , rhs.dataSize ); - std::swap( this->allocator, rhs.allocator ); - } - /*==========================================================*/ - value_type& operator[](const size_type& i) - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if(i>=dataSize) - UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") ); - #endif // _DEBUG - - return ptrData[i]; - } - /*==========================================================*/ - const value_type& operator[](const size_type& i) const - { - #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) ) - if(i>=dataSize) - UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") ); - #endif // _DEBUG - - return ptrData[i]; - } - /*==========================================================*/ - 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; - size_type dataSize; - CbVectorAllocator<value_type>* allocator; - CbVector<value_type>(const CbVector<value_type>& src); - //CbVector<value_type>& operator=(const CbVector<value_type>& src); -}; - -////////////////////////////////////////////////////////////////////////// -// CbVectorAllocator-Interface -////////////////////////////////////////////////////////////////////////// -template< typename T > -class CbVectorAllocator -{ -public: - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<value_type>::size_type size_type; - -public: - CbVectorAllocator() {} - virtual ~CbVectorAllocator() {} - - virtual bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0; - 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! - //**********************************************************************************// - inline value_type*& ptrDataOf( CbVector< value_type >& vec ) - { - if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") ); - return vec.ptrData; - } - //**********************************************************************************// - inline size_type& dataSizeOf( CbVector< value_type >& vec ) - { - if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") ); - return vec.dataSize; - } -}; - -#ifdef RCF_USE_SF_SERIALIZATION -SF_NO_CTOR(CbVectorAllocator<double>); -SF_NO_CTOR(CbVectorAllocator<float>); -#endif //RCF_USE_SF_SERIALIZATION - - -////////////////////////////////////////////////////////////////////////// -// CbVectorAllocatorStd -////////////////////////////////////////////////////////////////////////// -template< typename T > -class CbVectorAllocatorStd : public CbVectorAllocator<T> -{ -public: - //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<value_type>::size_type size_type; - -public: - CbVectorAllocatorStd() : CbVectorAllocator<value_type>() - { - - } - /*==========================================================*/ - bool alloc(CbVector< value_type >& src, const size_type& dataSize, const value_type& value=value_type()) - { - return this->resize(src,dataSize,value); - } - /*==========================================================*/ - bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) - { - if( CbVectorAllocatorStd< value_type >::dataSizeOf(vec) == dataSize) return false; - - //new array - value_type* new_data = new value_type[dataSize]; - //copy existing data to array - if( this->ptrDataOf(vec) ) - { - for(size_type i=0; (i<vec.size() && i<dataSize); ++i) new_data[i] = CbVectorAllocatorStd< value_type >::ptrDataOf(vec)[i]; - delete[] this->ptrDataOf(vec); - } - this->ptrDataOf(vec) = new_data; - //new value for new items - for(size_type i=this->dataSizeOf(vec); i<dataSize; ++i) this->ptrDataOf(vec)[i] = value; - //assign new dataSize - this->dataSizeOf(vec) = dataSize; - - return true; - } - /*==========================================================*/ - bool dealloc(CbVector< value_type >& vec) - { - if( this->ptrDataOf(vec) ) - { - delete[] this->ptrDataOf(vec); - this->ptrDataOf(vec) = NULL; - } - this->dataSizeOf(vec) = 0; - 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/ThirdParty/Library/basics/container/CbVectorPool.h b/ThirdParty/Library/basics/container/CbVectorPool.h deleted file mode 100644 index 000fe51593997759bee3446501750eb2eb87db8c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/CbVectorPool.h +++ /dev/null @@ -1,465 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef CBVECTORPOOL_H -#define CBVECTORPOOL_H - -#include <iostream> -#include <sstream> -#include <vector> -#include <map> -#include <limits> -#include <typeinfo> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbLogger.h> -#include <basics/container/CbVector.h> - -//#include "MPICommunicator.h" -// -//#include <execinfo.h> -//#include <stdio.h> -//#include <stdlib.h> -//#include <unistd.h> - -/*=========================================================================*/ -/* CbVectorPool */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -@version 1.1 - 09.02.08 -*/ - -/* -Durch Verwendung eines CbVectors in Verbindung mit einem CbVectorAllocatorPool -wird der Datenvector nicht direkt im CbVector gehalten, sondern ist ein Teil -des Datenvectors des Übergabe-CbVectorPools. -Die Methoden der von CbVectors funktionieren fehlerfrei -Es mss einem jedoch bewußt sein, dass die "resize"-Methoden länger benötigen, da -u.U. viele Elemente im Speicher verschoeben werden muessen. -Der Poolvector enthaelt KEINE gaps, so dass er z.B. gut zur Übertragung via MPI -geeignet ist... - -Verhaltensweise bei Zerstören des Pools: -wird der Pool zerstört bevor man die CbVectoren zerstört, so wird beim nächsten -Datenzugriffsversuch eine entsprechende Exception geworfen, denn alle DatenElemente -des CbVEctors werden restet und der Pool dort zu NULL gesetzt. - -Verhaltensweise bei Zerstören eines CbVectors: -hier ganz normal der Datenspeicher wieder freigegen und der Poolvektor verkürzt -*/ - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - - -template<typename T> class CbVectorAllocatorPool; - -/*==================================================================*/ -template<typename T> -class CbVectorPool -{ -public: - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef unsigned int CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - -public: - ////////////////////////////////////////////////////////////////////////// - CbVectorPool( const size_type& startPoolSize = 20000) //startPoolSize*sizeof(T)/1024/1024 [MB] - : poolStartAdress(NULL) - , nextCbVectorStartIndexInPool(0) - , nextCbVectorKey(0) - { - pool.reserve(startPoolSize); - } - /*==================================================================*/ - virtual ~CbVectorPool() - { - //hier werden lediglich ihre datenvektoren "resetet" - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& vec = *it->second; - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //allocator daten reseten - allocator.ptrVectorPool = NULL; - allocator.key = 0; - allocator.startIndexInPool = 0; - - //Datenzeiger/-groessen reseten - allocator.ptrDataOf(vec) = NULL; - allocator.dataSizeOf(vec) = 0; - } - } - /*==========================================================*/ - CbVectorKey getNextCbVectorKey() const - { - return this->nextCbVectorKey; - } - /*==================================================================*/ - bool allocVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() ) - { - //pool-allocator holen - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //alloc nur wenn cbVector noch kein Element von Pool! - if( cbVectorMap.find(allocator.key)==cbVectorMap.end() ) - { - return this->allocData(allocator, vec, dataSize, value ); - } - - UB_THROW( UbException(UB_EXARGS,"vector-key="+UbSystem::toString(allocator.key)+" bereits vergeben!") ); - } - /*==================================================================*/ - bool resizeVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //cbVector noch nicht in map? - CbVectorMapIter pos = cbVectorMap.find(allocator.key); - - if( pos!=cbVectorMap.end() ) //cbVector vorhanden - { - //wenn bei alloc keine Laenge zugewiesen wurde, so erfolgt das nun - if( allocator.startIndexInPool==0 && allocator.ptrDataOf(vec)==NULL ) - return this->allocData(allocator, vec, dataSize, value ) ; - else - return this->resizeData(allocator, vec, dataSize, value ); - } - - UB_THROW( UbException(UB_EXARGS,"vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?") ); - } - /*==================================================================*/ - bool deallocVectorData(CbVector<value_type>& vec) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //nur wenn vector auch teil des - if( cbVectorMap.erase(allocator.key) > 0 ) - { - if( this->resizeData(allocator,vec,0,0) ) - { - allocator.ptrVectorPool = NULL; - allocator.key = 0; - allocator.startIndexInPool = 0; - - //das Datenzeiger/-groessen reseten wird bereits in resize durchgefuehrt - return true; - } - else UB_THROW( UbException(UB_EXARGS,"unknown error") ); - } - - - //CommunicatorPtr comm = MPICommunicator::getInstance(); - //int myid = comm->getProcessID(); - -// // Get the name of the processor -// char machinename[MPI_MAX_PROCESSOR_NAME]; -// int name_len; -// MPI_Get_processor_name(machinename, &name_len); -// UBLOG(logINFO, "PID = " << myid << " host name: " << machinename); -// -// int j, nptrs; -//#define SIZE 100 -// void *buffer[100]; -// char **strings; -// -// nptrs = backtrace(buffer, SIZE); -// printf("backtrace() returned %d addresses\n", nptrs); -// -// /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) -// would produce similar output to the following: */ -// -// strings = backtrace_symbols(buffer, nptrs); -// if (strings == NULL) -// { -// perror("backtrace_symbols"); -// exit(EXIT_FAILURE); -// } -// -// for (j = 0; j < nptrs; j++) -// printf("%s\n", strings[j]); -// -// free(strings); - - UB_THROW(UbException(UB_EXARGS, "vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?")); - } - /*==================================================================*/ - friend std::ostream& operator<<(std::ostream& os, const CbVectorPool& cbPool) - { - os<<"map"<<std::endl; - for(CbVectorMapIter pos=cbPool.cbVectorMap.begin(); pos!=cbPool.cbVectorMap.end(); ++pos) - { - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*pos->second->getAllocator()); - os<<"vector-size="<<pos->second->size()<<"vector-Adress="<<tmpAllocator->ptrDataOf(*pos->second)<<", allocator(key="<<tmpAllocator.key<<", startIndex="<<tmpAllocator.startIndexInPool<<")"<<std::endl; - for(size_type i=0; i<pos->second->size(); i++) os<<(*pos->second)[i]<<","; - os<<std::endl; - } - os<<"pool"<<std::endl; - for(size_type i=0; i<cbPool.pool.size(); i++) - os<<cbPool.pool[i]<<","; os<<std::endl; - - return os; - } - /*==================================================================*/ - typename CbVectorMap::size_type getNofStoredVectors() const - { - return this->cbVectorMap.size(); - } - /*==================================================================*/ - typename Pool::size_type getPoolSize() const - { - return this->pool.size(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - bool consistencyCheck() - { - std::vector<int> pool2(pool.size(),0); - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - for(size_type i=tmpAllocator.startIndexInPool; i<tmpAllocator.startIndexInPool+tmpVec.size(); ++i) - { - pool2.at(i)++; - } - } - for( size_type i=0; i<pool2.size(); ++i ) - { - if(pool2.at(i) > 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 1"); return false; } - if(pool2.at(i) < 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 2"); return false; } - } - return true; - } -protected: - /*==================================================================*/ - inline bool allocData(CbVectorAllocatorPool< value_type >& allocator, CbVector< value_type >& vec, const size_type& dataSize, const value_type& value ) - { - //safety checks - if( allocator.startIndexInPool!=0 - || allocator.ptrDataOf(vec)!=NULL - || allocator.dataSizeOf(vec)!=0 ) - { - UB_THROW( UbException(UB_EXARGS,"zu allokierender vector ist nicht ganz sauber!!") ); - } - - //poolVector vergroessern - if( dataSize>0 ) - { - pool.resize( pool.size() + dataSize, value ); - - //Zeiger der vorhandenen CbVectoren neu setzen, wenn Pool im Speicher verschoben wurde - if( poolStartAdress != &pool.front() ) - { - poolStartAdress = &pool.front(); - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*tmpVec.getAllocator()); - - if( !tmpAllocator.ptrDataOf(tmpVec) ) continue; //Fall: CbVector hat noch keinen Datenbereich (data zeigt auf NULL) - tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool]; - } - //std::cout<<"CbVectorPoolMpi::allocVectorData vector wurde im speicher verschoben - adressen angepasst!!!"<<std::endl; - } - - //aktuellem element adresse zuweisen (wurde evtl schon inder schleife zuvor gemacht) - allocator.ptrDataOf(vec) = &pool.at(nextCbVectorStartIndexInPool); - allocator.startIndexInPool = nextCbVectorStartIndexInPool; - - //neuen StartIndex fuer naechstes Element berechnen - nextCbVectorStartIndexInPool += dataSize; - if(nextCbVectorStartIndexInPool!=pool.size()) - UB_THROW( UbException(UB_EXARGS,"index Problem... Annahme falsch?") ); - } - - //vector zu map hinzufügen (speicher wird dann anschliessend zugwiesen) - cbVectorMap.insert( std::make_pair( allocator.key, &vec ) ); // ist angeblich performanter als cbVectorMap[ allocator.key ] = cbVector; //aus Effective STL von Scott Meyer - allocator.dataSizeOf(vec) = dataSize; - - //dummDoof nextKey-Generung... - if( allocator.key >= this->nextCbVectorKey ) this->nextCbVectorKey = allocator.key + 1; - - return true; - } - /*==========================================================*/ - bool resizeData(CbVectorAllocatorPool< value_type >& allocator, CbVector<value_type>& vec, const size_type& dataSize, const value_type& value ) - { - //datenvector verlaengern/-kuerzen - typename Pool::iterator startPos = pool.begin()+allocator.startIndexInPool; //startPosition der cbVector-Daten im Pool - if( vec.size() > dataSize ) pool.erase( startPos+dataSize, startPos+vec.size()); - else pool.insert( startPos+vec.size(), dataSize-vec.size(), value ); - - ////////////////////////////////////////////////////////////////////////// - //adressen und laengen der einzelnen vectoren anpassen - if( !pool.empty() ) - { - bool poolMoved = ( poolStartAdress != &pool.front() ); - poolStartAdress = &pool.front(); - - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - - if( tmpVec.size()>0 ) - { - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - //liegt CbVector VOR verändertem CbVector? - if( tmpAllocator.startIndexInPool <= allocator.startIndexInPool ) //ja: anpassung NUR wenn pool verschoben wurde! - { - if(poolMoved && tmpVec.size()>0 ) tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool]; - } - else //nein: -> Adresse + Index MUSS immer angepasst werden - { - tmpAllocator.startIndexInPool += dataSize-vec.size(); - tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool ]; - } - } - } - } - else //Sonderfall: alle Elemente haben Laenge 0 -> kein pool -> alle Feld-Adressen auf NULL setzen! - { - poolStartAdress = NULL; - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - tmpAllocator.startIndexInPool = 0; - } - - } - - //restliche Daten von cbVector + allocator aktualisieren - allocator.dataSizeOf(vec) = dataSize; - if(dataSize==0) - { - allocator.ptrDataOf(vec) = NULL; - allocator.startIndexInPool = 0; - } - - nextCbVectorStartIndexInPool = pool.size(); - - return true; - } - -protected: - /*==================================================================*/ - void getCbVectorData(const CbVector< value_type >& vec, CbVectorKey& vectorKey, size_type& startIndexInPool, size_type& dataSize ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - - startIndexInPool = allocator.startIndexInPool; - vectorKey = allocator.key; - dataSize = vec.size(); - } - /*==================================================================*/ - void setCbVectorData(CbVector< value_type >& vec, const CbVectorKey& vectorKey, const size_type& startIndexInPool, const size_type& dataSize ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - - allocator.startIndexInPool = startIndexInPool; - allocator.key = vectorKey; - allocator.dataSizeOf(vec) = dataSize; - allocator.ptrDataOf(vec) = &this->pool[ startIndexInPool ]; - } - /*==================================================================*/ - - CbVectorMap cbVectorMap; //informationsmap fuer MPIData und zugewiesener vector - - Pool pool; //globaler Datenvector - typename Pool::pointer poolStartAdress; //StartAdresse des aktuellen Datenvektors - typename Pool::size_type nextCbVectorStartIndexInPool; //StartIndex fuer den naechsten CbVector - - //key - erstmal dummdoof - CbVectorKey nextCbVectorKey; -}; - - -////////////////////////////////////////////////////////////////////////// -// CbVectorAllocatorPool -////////////////////////////////////////////////////////////////////////// -template< typename T > -class CbVectorAllocatorPool : public CbVectorAllocator<T> -{ -public: - //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<value_type>::size_type size_type; - - friend class CbVectorPool< value_type >; - -public: - /*==========================================================*/ - CbVectorAllocatorPool(const typename CbVectorPool< value_type >::CbVectorKey& key, CbVectorPool<value_type>* const& ptrVectorPool) - : CbVectorAllocator<value_type>() - , key(key) - , startIndexInPool(0) - , ptrVectorPool(ptrVectorPool) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") ); - } - /*==========================================================*/ - //hier wird der key automatisch erzeugt! - CbVectorAllocatorPool(CbVectorPool<value_type>* const& ptrVectorPool) - : CbVectorAllocator<value_type>() - , startIndexInPool(0) - , ptrVectorPool(ptrVectorPool) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") ); - key = ptrVectorPool->getNextCbVectorKey(); - } - /*==========================================================*/ - bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return ptrVectorPool->allocVectorData(vec, dataSize, value); - } - /*==========================================================*/ - bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return ptrVectorPool->resizeVectorData(vec, dataSize, value); - } - /*==========================================================*/ - bool dealloc(CbVector< value_type >& vec) - { - if(ptrVectorPool) return this->ptrVectorPool->deallocVectorData(vec); - //wenn kein ptrVectorPool -> wurde bereits deallokiert - return true; - } - /*==========================================================*/ - const CbVectorPool< value_type >& getCbVectorPool() - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return *ptrVectorPool; - } - /*==========================================================*/ - -private: - typename CbVectorPool< value_type >::CbVectorKey key; - typename CbVectorPool< value_type >::Pool::size_type startIndexInPool; - - CbVectorPool< value_type >* ptrVectorPool; - - CbVectorAllocatorPool( const CbVectorAllocatorPool& ); //no copy allowed - const CbVectorAllocatorPool& operator=( const CbVectorAllocatorPool& );//no copy allowed -}; - - -#endif //CBVECTORPOOL_H diff --git a/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt b/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt deleted file mode 100644 index 6cf6d2526048573fa4bbf1426f28279b0dc46bb4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(CbVectorPoolTests) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.h - ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT() diff --git a/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h b/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h deleted file mode 100644 index b9e376731e5581c75efbfa093122afc42f2405ad..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h +++ /dev/null @@ -1,190 +0,0 @@ -#include <iostream> -#include <stdlib.h> -#include <stdio.h> -#include <string> -#include <fstream> - -#include <basics/utilities/UbTuple.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbTiming.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -using std::cout; -using std::cerr; -using std::endl; -using std::vector; - -typedef long double value_type; -typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr; -typedef MbSmartPtr<vector< value_type > > StlVectorPtr; - -/*==========================================================*/ -template<typename T> -inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("setValues - sizeCheck failed") ); - } - static value_type stlVal = 1; - static value_type cbVal = 1; - static value_type cbPoolVal = 1; - - for(size_t i=0; i<cbvec.size(); i++) stlvec[i] = stlVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbvec[i] = cbVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++; -} -/*==========================================================*/ -template<typename T> -inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("setValues glob - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val) -{ - stlvec.resize(size,val); - cbvec.resize(size,val); - cbpoolvec.resize(size,val); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("resize glob - sizeCheck failed") ); - } - - if(timed) - { - UbTimer timer; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val); if(timed) cout<<"stl-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val); if(timed) cout<<"cbStd-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl; - } - else - { - for(size_t i=0; i<cbvecs.size(); i++) - resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val); - } -} -/*==========================================================*/ -inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool)))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; - - for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back()); -} -/*==========================================================*/ -inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; -} -/*==========================================================*/ -template<typename T> -inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - bool check=true; - for(size_t i=0; i<cbvec.size(); i++) - if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i] ) - check=false; - - if(!check) - { - cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" "; cout<<endl; - cerr<< "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" "; cout<<endl; - cerr<< "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl; - throw UB_THROW( UbException("equalCheck - equalCheck failed") ); - } -} -/*==========================================================*/ -template<typename T> -void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - { - //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1; - equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); - //cout<<" passed"<<endl; - } -} -/*==========================================================*/ -void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - UbTimer timer; - timer.start(); - for(size_t i=0; i<stlvecs.size(); i++) - { - vector<value_type>& vec = *stlvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"stl-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbvecs.size(); i++) - { - CbVector<value_type>& vec = *cbvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbStd-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbpoolvecs.size(); i++) - { - CbVector<value_type>& vec = *cbpoolvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbPool-accessCheck in "<<timer.stop()<<"s"<<endl; -} diff --git a/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp b/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp deleted file mode 100644 index b3fe50b252cacff1c0484a54a77ee4427316d748..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp +++ /dev/null @@ -1,277 +0,0 @@ -#include "./functions.h" - -using namespace std; - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char** argv) -{ - try - { - { - CbVectorPool<float>* floatPool = new CbVectorPool<float>(0); - CbVector<float> v1,v2,v3; - CbVector<float> v0(new CbVectorAllocatorPool<float>(104,floatPool) ); - v0.resize(20); - v0[3] = 60000; - v0.resize(40); - v0[3] = 90000; - v1.setAllocator( new CbVectorAllocatorPool<float>(100,floatPool) ); - v2.setAllocator( new CbVectorAllocatorPool<float>(101,floatPool) ); - v3.setAllocator( new CbVectorAllocatorPool<float>(102,floatPool) ); - v1.resize(20, 0.0); - v1.resize(30, 0.0); - v2.resize(0); - v2.resize(40, 0.0); - v3.resize(30, 0.0); - v3.resize(50, 0.0); - - for(CbVector<float>::size_type i=v1.size()-1; i>=15; i--) - v1[i] = (CbVector<float>::value_type)i; - for(CbVector<float>::size_type i=v2.size()-1; i>=35; i--) - v2[i] = (CbVector<float>::value_type)i; - for(CbVector<float>::size_type i=v3.size()-1; i>=10; i--) - v3[i] = (CbVector<float>::value_type)i; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v1.size(); i++) v1[i]; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v2.size(); i++) v2[i]; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v3.size(); i++) v3[i]; - } - - CbVectorPool<value_type>* vectorPool = new CbVectorPool<value_type>(0); - - vector< StlVectorPtr > stlVecs; - vector< CbVectorPtr > cbVecs; - vector< CbVectorPtr > cbPoolVecs; - - cout<<"check"<<__LINE__<<endl; - createVecs(10,12,0,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,2); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,3,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(8,5,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - //dealloc check - stlVecs.resize(5); - cbVecs.resize(5); - cbPoolVecs.resize(5); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - - //operator= check - CbVector<value_type> testPool1(10, new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool2(1 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool3(8 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool4(8 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testStd1(10); - - for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ ) - testStd1[i] = (value_type)i*10; - - testPool1 = testStd1; - testPool4 = testStd1; - testPool3 = testPool4; - testPool2 = testPool3; - - for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ ) - cout<<testStd1[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool1.size(); i++ ) - cout<<testPool1[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool2.size(); i++ ) - cout<<testPool2[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool3.size(); i++ ) - cout<<testPool3[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool4.size(); i++ ) - cout<<testPool4[i]<<" "; cout<<endl; - ///end - - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// access test - start"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"check"<<__LINE__<<endl; - createVecs(1000,1000,stlVecs,cbVecs,cbPoolVecs,vectorPool,true); - - CbVectorPool<value_type>* pool2 = new CbVectorPool<value_type>(1); - vector< StlVectorPtr > stlVecs2; - vector< CbVectorPtr > cbVecs2; - vector< CbVectorPtr > cbPoolVecs2; - createVecs(1000,1000,stlVecs2,cbVecs2,cbPoolVecs2,pool2,true); - - cout<<"access check\n"; - //accessCheck(1000,stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,120,3,true); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// access test - end"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// EXCEPTION TEST - start"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - delete vectorPool; - vectorPool = NULL; - try - { - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - } - catch(UbException& e) - { - cout<<"if exception tells something about \"vectorPool==NULL\" -> test successfully passed:"<<endl; - cout<<e<<endl; - } - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// EXCEPTION TEST - end"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - - cout<<"\n\n\nALL TESTS PASSED\n"; - } - catch(UbException& e) - { - std::cerr<<e<<std::endl; - } - catch(const std::exception &e) - { - std::cerr << "Caught exception:\n"; - std::cerr << "Type: " << typeid(e).name() << "\n"; - std::cerr << "What: " << e.what() << "\n"; - } - catch(...) - { - std::cerr<<" ** Verdammte Scheisse - mal wieder Mist gebaut! **"<<endl; - } - return 0; -} - -// #include <functional> -// #include <iostream> -// #include <vector> -// #include <algorithm> -// #include <typeinfo> -// -// struct bar -// { -// bar() -// : data(0) -// {} -// -// void foo(const std::size_t value) { std::cout << "data = " << value << " (old: " << data << ");" << std::endl; data = value; } -// -// private: -// std::size_t data; -// }; -// -// int main() -// { -// std::vector<bar> data(10); -// -// /* operator[] => Indexoperator */ -// for (std::size_t i(0); i < data.size(); ++i) -// data[i].foo(2); -// -// /* begin(), end() => Iterator */ -// const std::vector<bar>::iterator it_end(data.end()); -// for (std::vector<bar>::iterator it(data.begin()); it != it_end; ++it) -// it->foo(3); -// -// /* for_each => Algorithm | Iterator */ -// std::for_each(data.begin(), data.end(), std::bind2nd(std::mem_fun_ref(&bar::foo), 2)); -// } diff --git a/ThirdParty/Library/basics/memory/CMakePackage.txt b/ThirdParty/Library/basics/memory/CMakePackage.txt deleted file mode 100644 index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/ThirdParty/Library/basics/memory/MbChessMemPool2D.h b/ThirdParty/Library/basics/memory/MbChessMemPool2D.h deleted file mode 100644 index c665f7798f096fd9bc95d70e6d45e7b4f2716b30..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbChessMemPool2D.h +++ /dev/null @@ -1,519 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBCHESSMEMPOOL2D_H -#define MBCHESSMEMPOOL2D_H - -#include <map> -#include <vector> -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <fstream> -#include <cmath> -#include <typeinfo> - -#include <basics/utilities/UbException.h> - - -template <class TData, std::size_t cachSize> -class MbChessMemPool2D; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMap2DKey -//key zum Auffinden der ChessMem2DBlocks -class MbChessMap2DKey -{ -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMap2DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0) - { - - } - /*==========================================================*/ - MbChessMap2DKey(std::size_t vectorPos, std::size_t firstCriteria, std::size_t secondCriteria) - : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria) - { - } - /*==========================================================*/ - MbChessMap2DKey& operator=(const MbChessMap2DKey& srcKey) - { - if(this == &srcKey ) return *this; - - mVectorPos = srcKey.mVectorPos; - mFirstCriteria = srcKey.mFirstCriteria; - mSecondCriteria = srcKey.mSecondCriteria; - - return *this; - } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - if(lhsKey.mFirstCriteria < rhsKey.mFirstCriteria ) return true; - if(lhsKey.mFirstCriteria > rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - if(lhsKey.mVectorPos != rhsKey.mVectorPos ) return false; - if(lhsKey.mFirstCriteria != rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - return !(lhsKey==rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const MbChessMap2DKey& key) - { - os<<"VectorPos,first-,second-,third Criteria) ("; - os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<")"; - return os; - } - - ////////////////////////////////////////////////////////////////////////// - //public Methoden - std::size_t getVectorPos() {return mVectorPos;} -private: - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mVectorPos; - std::size_t mFirstCriteria; - std::size_t mSecondCriteria; -}; - - - -template<class T,std::size_t cachSize> -class MbChessMem2DBlock -{ - friend class MbChessMemPool2D<T,cachSize>; -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMem2DBlock() - { - mUsedElements = 0; - std::size_t arrayLength = mBlockWidth*mBlockWidth; - //mDataElements = new T[arrayLength]; - mDataElements = operator new(arrayLength*sizeof(T)); - mFlagVector = new bool[arrayLength]; - for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false; - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMem2DBlock() - { - //if(mDataElements) delete[] mDataElements; - if(mDataElements) operator delete(mDataElements); - if(mFlagVector) delete[] mFlagVector; - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private Methoden - void* getReference(std::size_t chessX1, std::size_t chessX2) - { - std::size_t arrayIndex = chessX2*mBlockWidth + chessX1; - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") ); - - mUsedElements++; - mFlagVector[arrayIndex]=true; - - return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]); - } - /*==========================================================*/ - std::size_t freeReference(void* p) - { - //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0] - std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements)); - - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") ); - - mFlagVector[arrayIndex]=false; - - return --mUsedElements; - } - /*==========================================================*/ - std::size_t getNofUsedElements() { return mUsedElements; } - /*==========================================================*/ - void addPointerToTElementsToVector(std::vector<T*>& tdataVector) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]); - if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex); - } - } - /*==========================================================*/ - template<typename Pred> - void addPointerToTElementsToVector(std::vector<T*>& tdataVector, Pred& pred) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth; - T* tmp; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - if(mFlagVector[arrayIndex]) - { - //tmp = &mDataElements[arrayIndex]; - tmp = (static_cast<T*>(mDataElements))+arrayIndex; - if( pred(*tmp) ) tdataVector.push_back(tmp); - } - } - } -private: - ////////////////////////////////////////////////////////////////////////// - //static Member - static const std::size_t mBlockWidth; - - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mUsedElements; - //T* mDataElements; - void* mDataElements; - bool* mFlagVector; - -}; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMemPool2D -//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur -//die ChessMemBloecke haben hier eine Groesse von ~cachSize -template <class TData, std::size_t cachSize> -class MbChessMemPool2D -{ -private: - ////////////////////////////////////////////////////////////////////////// - //protected static const Member - const static std::size_t mCacheSize; - - ////////////////////////////////////////////////////////////////////////// - //protected Member - static std::vector< std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* > > mMapVector; - static std::map< void*, MbChessMap2DKey > mPointerKeyMap; - - ////////////////////////////////////////////////////////////////////////// - //protected Konstrukoren - MbChessMemPool2D() //protected, um max einmal vererbt werden zu koennen!!! - { //zudem kann man so keine elmente von TreeBasedMemPool erstellen - - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMemPool2D() - { - } - -public: - - ////////////////////////////////////////////////////////////////////////// - //static public Methoden - static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2) - { - if(!MbChessMem2DBlock< TData,cachSize >::mBlockWidth) - { - std::stringstream ss; - ss<<"TreeBasedMemPool() - InitialisationError\n"; - ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n"; - ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n"; - ss<<"\t cache-size has to be larger than data-size"; - UB_THROW( UbException(ss.str()) ); - } - - if( mMapVector.size()<=level ) mMapVector.resize(level+1); - - std::size_t chessX1 = ix1/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX2 = ix2/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - - MbChessMap2DKey mapKey(level,chessX1,chessX2); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey); - - MbChessMem2DBlock<TData,cachSize>* memBlock = NULL; - - if(pos==mMapVector[level].end()) - { - memBlock = new MbChessMem2DBlock<TData,cachSize>; - (mMapVector[level])[mapKey] = memBlock; - } - else memBlock = pos->second; - - std::size_t internalChessX1 = ix1%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX2 = ix2%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - - void* p = memBlock->getReference(internalChessX1,internalChessX2); - - mPointerKeyMap[p]=mapKey; - - return p; - } - /*==========================================================*/ - static void freeReference(void *p) - { - typename std::map<void*,MbChessMap2DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p); - - if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") ); - - MbChessMap2DKey mapKey = posPointerKeyMap->second; - mPointerKeyMap.erase(posPointerKeyMap); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator posMemBlockMap; - posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey); - - if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end()) - UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem2DBlockMap") ); - - std::size_t leftElements = posMemBlockMap->second->freeReference(p); - if(!leftElements) - { - MbChessMem2DBlock<TData,cachSize>* tmp = posMemBlockMap->second; - mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap); - delete tmp; - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks() - { - std::size_t nofElements = 0; - for(std::size_t i=0; i<mMapVector.size(); i++) - { - nofElements+=mMapVector[i].size(); - } - return nofElements; - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks(std::size_t level) - { - if(level<mMapVector.size() )return mMapVector[level].size(); - return 0; - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements() - { - return mPointerKeyMap.size(); - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements(std::size_t level) - { - if(level<mMapVector.size() ) - { - std::size_t nofElements = 0; - typename std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* >::iterator pos; - - for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos) - { - nofElements += pos->second->getNofUsedElements(); - } - return nofElements; - } - return 0; - - } - /*==========================================================*/ - static std::string toString() - { - long double capaticityPerBlock = (std::size_t)pow((double)MbChessMem2DBlock<TData,cachSize>::mBlockWidth,2.0); - std::size_t storedElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(); - std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - - std::stringstream ss; - ss<<std::endl; - ss<<"****************** MbChessMemPool2D-Info (BEGIN) ******************"<<std::endl; - ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl; - ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl; - ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl; - ss<<"#elements per MbChessMem2DBlock [bytes]: "<<capaticityPerBlock<<std::endl; - ss<<"mem per MbChessMem2DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl; - ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl; - ss<<"\n"; - ss<<"#stored Elements = "<<storedElements<<std::endl; - ss<<"#ChessMem2DBlocks = "<<initialisedMemBlocks<<std::endl; - ss<<std::endl; - ss<<"level | #ChessMem2DBlocks | #stored Elements | used capaticity [%] \n"; - ss<<"----------------------------------------------------------------\n"; - for(std::size_t level=0;level<mMapVector.size();level++) - { - std::size_t nofStoredElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(level); - std::size_t nofChessMem2DBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(level); - - ss<<std::left<<" "<<std::setw(5)<<level<<"| " - <<std::setw(16)<<nofChessMem2DBlocks<<"| " - <<std::setw(17)<<nofStoredElements<<"| "; - if(nofStoredElements) - ss<<setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem2DBlocks)*100<<std::endl; - else ss<<"-"<<std::endl; - } - ss<<std::endl; - ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl; - ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl; - double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData)); - if(fabs(denominator)>1.E-13) ss<<"used.............. [%] : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl; - else ss<<"used.............. [%] : 0.0"<<std::endl; - ss<<"****************** MbChessMemPool2D-Info (END) *******************"<<std::endl; - return ss.str(); - } - /*==========================================================*/ - static void writeStatisticFiles(const std::string& filename) - { - //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level) - //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock - //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten - std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str()); - if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") ); - - std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - std::size_t maxNofDataElementsPerBlock = MbChessMem2DBlock<TData,cachSize>::mBlockWidth - * MbChessMem2DBlock<TData,cachSize>::mBlockWidth - * MbChessMem2DBlock<TData,cachSize>::mBlockWidth; - std::vector<std::size_t> spreading; - spreading.resize(maxNofDataElementsPerBlock+1,0); - std::vector< std::vector<std::size_t> > spreadingPerLevel; - spreadingPerLevel.resize(mMapVector.size()); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t level=0; level<mMapVector.size(); level++ ) - { - spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0); - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - std::size_t number = pos->second->getNofUsedElements(); - spreading[number]++; - spreadingPerLevel[level][number]++; - } - } - spreadingFile<<"#BlockUsage nofBlocks(all Level) "; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<"nofBlockLevel"<<level<<" "; - spreadingFile<<std::endl; - - for(std::size_t i=0; i<spreading.size(); i++) - { - spreadingFile<<i<<" "<<spreading[i]; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<" "<<spreadingPerLevel[level][i]; - spreadingFile<<std::endl; - } - spreadingFile.flush(); - spreadingFile.close(); - } - ////////////////////////////////////////////////////////////////////////// - //ueberladene operatoren - void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2) - { - if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") ); - void *p = getReference(level,ix1,ix2); - return p; - } - /*==========================================================*/ - void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - { - //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!! - //UB_THROW( UbException(UB_EXARGS,"Scheisse noch nicht gerafft, wie das geht!") ); - std::cerr<<"MbChessMemPool2D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - Scheisse noch nicht gerafft, wie das geht!\n"; - } - - /*==========================================================*/ - void operator delete(void* p) - { - freeReference(p); - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private statische Methoden -}; - -//statische Variablen initialisieren -template <class TData, std::size_t cachSize> -std::vector< std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* > > MbChessMemPool2D<TData,cachSize>::mMapVector; - -template <class TData, std::size_t cachSize> -std::map<void*,MbChessMap2DKey > MbChessMemPool2D< TData, cachSize>::mPointerKeyMap; - -template <class TData, std::size_t cachSize> -const std::size_t MbChessMemPool2D<TData,cachSize>::mCacheSize=cachSize; - -template <class TData,std::size_t cachSize> -const std::size_t MbChessMem2DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -#endif diff --git a/ThirdParty/Library/basics/memory/MbChessMemPool3D.h b/ThirdParty/Library/basics/memory/MbChessMemPool3D.h deleted file mode 100644 index 99fef93f6c79612e298e08dc3f504df7b0cd695d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbChessMemPool3D.h +++ /dev/null @@ -1,537 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBCHESSMEMPOOL3D_H -#define MBCHESSMEMPOOL3D_H - -#include <map> -#include <vector> -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <fstream> -#include <cmath> - -#include <basics/utilities/UbException.h> - -template <class TData, std::size_t cachSize> -class MbChessMemPool3D; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMap3DKey -//key zum Auffinden der ChessMem3DBlocks -class MbChessMap3DKey -{ -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMap3DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0),mThirdCriteria(0) - { - } - /*==========================================================*/ - MbChessMap3DKey(std::size_t vectorPos,std::size_t firstCriteria,std::size_t secondCriteria,std::size_t thirdCriteria) - : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria), mThirdCriteria(thirdCriteria) - { - } - /*==========================================================*/ - MbChessMap3DKey& operator=(const MbChessMap3DKey& srcKey) - { - if(this == &srcKey ) return *this; - - mVectorPos = srcKey.mVectorPos; - mFirstCriteria = srcKey.mFirstCriteria; - mSecondCriteria = srcKey.mSecondCriteria; - mThirdCriteria = srcKey.mThirdCriteria; - - return *this; - } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - if(lhsKey.mFirstCriteria < rhsKey.mFirstCriteria ) return true; - if(lhsKey.mFirstCriteria > rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true; - if(lhsKey.mSecondCriteria > rhsKey.mSecondCriteria) return false; - if(lhsKey.mThirdCriteria < rhsKey.mThirdCriteria ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - if(lhsKey.mVectorPos != rhsKey.mVectorPos ) return false; - if(lhsKey.mFirstCriteria != rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false; - if(lhsKey.mThirdCriteria != rhsKey.mThirdCriteria ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - return !(lhsKey==rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const MbChessMap3DKey& key) - { - os<<"VectorPos,first-,second-,third Criteria) ("; - os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<","<<key.mThirdCriteria<<")"; - return os; - } - - ////////////////////////////////////////////////////////////////////////// - //public Methoden - std::size_t getVectorPos() {return mVectorPos;} -private: - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mVectorPos; - std::size_t mFirstCriteria; - std::size_t mSecondCriteria; - std::size_t mThirdCriteria; -}; - - - -template<class T,std::size_t cachSize> -class MbChessMem3DBlock -{ - friend class MbChessMemPool3D<T,cachSize>; -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMem3DBlock() - { - mUsedElements = 0; - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - //mDataElements = new T[arrayLength]; - mDataElements = operator new(arrayLength*sizeof(T)); - if(!mDataElements) UB_THROW( UbException(UB_EXARGS,"out of memeory!") ); - mFlagVector = new bool[arrayLength]; - if(!mFlagVector) UB_THROW( UbException(UB_EXARGS,"out of memeory!") ); - for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false; - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMem3DBlock() - { - //if(mDataElements) delete[] mDataElements; - if(mDataElements) operator delete(mDataElements); - if(mFlagVector) delete[] mFlagVector; - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private Methoden - void* getReference(std::size_t chessX1, std::size_t chessX2, std::size_t chessX3) - { - //std::size_t arrayIndex = (chessX1*mBlockWidth+chessX2)*mBlockWidth + chessX3; - std::size_t arrayIndex = (chessX3*mBlockWidth+chessX2)*mBlockWidth + chessX1; - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") ); - - mUsedElements++; - mFlagVector[arrayIndex]=true; - - return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]); - } - /*==========================================================*/ - std::size_t freeReference(void* p) - { - //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0] - std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements)); - - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") ); - - mFlagVector[arrayIndex]=false; - - return --mUsedElements; - } - /*==========================================================*/ - std::size_t getNofUsedElements() { return mUsedElements; } - /*==========================================================*/ - void addPointerToTElementsToVector(std::vector<T*>& tdataVector) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - for(std::size_t arrayIndex=0; arrayIndex<arrayLength; arrayIndex++) - { - //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]); - if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex); - } - } - /*==========================================================*/ - template<typename Pred> - void addPointerToTElementsToVector(std::vector<T*>& tdataVector,Pred& pred ) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - T* tmp; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - if(mFlagVector[arrayIndex]) - { - //tmp = &mDataElements[arrayIndex]; - tmp = static_cast<T*>(mDataElements)+arrayIndex; - if( pred(*tmp) ) tdataVector.push_back(tmp); - } - } - } -private: - ////////////////////////////////////////////////////////////////////////// - //static Member - static const std::size_t mBlockWidth; - - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mUsedElements; - //T* mDataElements; - void* mDataElements; - bool* mFlagVector; - -}; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMemPool3D -//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur -//die ChessMemBloecke haben hier eine Groesse von ~cachSize -template <class TData, std::size_t cachSize> -class MbChessMemPool3D -{ -private: - ////////////////////////////////////////////////////////////////////////// - //protected static const Member - const static std::size_t mCacheSize; - - ////////////////////////////////////////////////////////////////////////// - //protected Member - static std::vector< std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* > > mMapVector; - static std::map< void*, MbChessMap3DKey > mPointerKeyMap; - - ////////////////////////////////////////////////////////////////////////// - //protected Konstrukoren - MbChessMemPool3D() //private, da NUR static erlaubt!!! - { - - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMemPool3D() - { - } - -public: - ////////////////////////////////////////////////////////////////////////// - //static public Methoden - static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - { - if(!MbChessMem3DBlock< TData,cachSize >::mBlockWidth) - { - std::stringstream ss; - ss<<"TreeBasedMemPool() - InitialisationError\n"; - ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n"; - ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n"; - ss<<"\t cache-size has to be larger than data-size"; - UB_THROW( UbException(UB_EXARGS,ss.str()) ); - } - - if( mMapVector.size()<=level ) mMapVector.resize(level+1); - - std::size_t chessX1 = ix1/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX2 = ix2/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX3 = ix3/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - - MbChessMap3DKey mapKey(level,chessX1,chessX2,chessX3); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey); - - MbChessMem3DBlock<TData,cachSize>* memBlock = NULL; - - if(pos==mMapVector[level].end()) - { - memBlock = new MbChessMem3DBlock<TData,cachSize>; - (mMapVector[level])[mapKey] = memBlock; - } - else memBlock = pos->second; - - std::size_t internalChessX1 = ix1%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX2 = ix2%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX3 = ix3%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - - void* p = memBlock->getReference(internalChessX1,internalChessX2,internalChessX3); - - mPointerKeyMap[p]=mapKey; - - return p; - } - static void freeReference(void *p) - { - typename std::map<void*,MbChessMap3DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p); - - if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") ); - - MbChessMap3DKey mapKey = posPointerKeyMap->second; - mPointerKeyMap.erase(posPointerKeyMap); - - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator posMemBlockMap; - posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey); - - - if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end()) - UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem3DBlockMap") ); - - std::size_t leftElements = posMemBlockMap->second->freeReference(p); - if(!leftElements) - { - MbChessMem3DBlock<TData,cachSize>* tmp = posMemBlockMap->second; - mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap); - try{ delete tmp; } - catch(...){UB_THROW( UbException(UB_EXARGS,"could not delete MbChessMem3DBlock") );} - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - } - /*==========================================================*/ - template<class Pred> - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks() - { - std::size_t nofElements = 0; - for(std::size_t i=0;i<mMapVector.size();i++) - { - nofElements+=mMapVector[i].size(); - } - return nofElements; - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks(std::size_t level) - { - if(level<mMapVector.size() ) return mMapVector[level].size(); - return 0; - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements() - { - return mPointerKeyMap.size(); - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements(std::size_t level) - { - if(level<mMapVector.size() ) - { - std::size_t nofElements = 0; - typename std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* >::iterator pos; - - for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos) - { - nofElements+= pos->second->getNofUsedElements(); - } - return nofElements; - } - return 0; - } - /*==========================================================*/ - static std::string toString() - { - long double capaticityPerBlock = pow((double)MbChessMem3DBlock<TData,cachSize>::mBlockWidth,3.0); - std::size_t storedElements = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(); - std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - - std::stringstream ss; - ss<<std::endl; - ss<<"****************** MbChessMemPool3D-Info (BEGIN) ******************"<<std::endl; - ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl; - ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl; - ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl; - ss<<"#elements per MbChessMem3DBlock [bytes]: "<<capaticityPerBlock<<std::endl; - ss<<"mem per MbChessMem3DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl; - ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl; - ss<<"\n"; - ss<<"#stored Elements = "<<storedElements<<std::endl; - ss<<"#ChessMem3DBlocks = "<<initialisedMemBlocks<<std::endl; - ss<<std::endl; - ss<<"level | #ChessMem3DBlocks | #stored Elements | used capaticity [%] \n"; - ss<<"----------------------------------------------------------------\n"; - for(std::size_t level=0;level<mMapVector.size();level++) - { - std::size_t nofStoredElements = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(level); - std::size_t nofChessMem3DBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(level); - - ss<<std::left<<" "<<std::setw(5)<<level<<"| " - <<std::setw(16)<<nofChessMem3DBlocks<<"| " - <<std::setw(17)<<nofStoredElements<<"| "; - if(nofStoredElements) - ss<<std::setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem3DBlocks)*100<<std::endl; - else ss<<"-"<<std::endl; - } - ss<<std::endl; - ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl; - ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl; - double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData)); - if(fabs(denominator)>1.E-13) ss<<"used.............. [%] : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl; - else ss<<"used.............. [%] : 0.0"<<std::endl; - ss<<"****************** MbChessMemPool3D-Info (END) *******************"<<std::endl; - return ss.str(); - } - /*==========================================================*/ - static void writeStatisticFiles(const std::string& filename) - { - //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level) - //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock - //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten - std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str()); - if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") ); - - //std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - std::size_t maxNofDataElementsPerBlock = MbChessMem3DBlock<TData,cachSize>::mBlockWidth - *MbChessMem3DBlock<TData,cachSize>::mBlockWidth - *MbChessMem3DBlock<TData,cachSize>::mBlockWidth; - std::vector<std::size_t> spreading; - spreading.resize(maxNofDataElementsPerBlock+1,0); - std::vector< std::vector<std::size_t> > spreadingPerLevel; - spreadingPerLevel.resize(mMapVector.size()); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t level=0; level<mMapVector.size(); level++ ) - { - spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0); - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - std::size_t number = pos->second->getNofUsedElements(); - spreading[number]++; - spreadingPerLevel[level][number]++; - } - } - spreadingFile<<"#BlockUsage nofBlocks(all Level) "; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<"nofBlockLevel"<<level<<" "; - spreadingFile<<std::endl; - - for(std::size_t i=0;i<spreading.size();i++) - { - spreadingFile<<i<<" "<<spreading[i]; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<" "<<spreadingPerLevel[level][i]; - spreadingFile<<std::endl; - } - spreadingFile.flush(); - spreadingFile.close(); - } - - //////////////////////////////////////////////////////////////////////////// - ////ueberladene operatoren - //void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - //{ - // if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") ); - // void *p = getReference(level,ix1,ix2,ix3); - // return p; - //} - ///*==========================================================*/ - //void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - //{ - // //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!! - // //UB_THROW( UbException(__FILE__, __LINE__, "MbChessMemPool3D::delete - Scheisse noch nicht gerafft, wie das geht!") ); - // cout<<"MbChessMemPool3D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - Scheisse noch nicht gerafft, wie das geht!\n"; - //} - - ///*==========================================================*/ - //void operator delete(void* p) - //{ - // freeReference(p); - //} - -private: - ////////////////////////////////////////////////////////////////////////// - //private statische Methoden -}; - - -//statische Variablen initialisieren -template <class TData, std::size_t cachSize> -std::vector< std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* > > MbChessMemPool3D<TData,cachSize>::mMapVector; - -template <class TData, std::size_t cachSize> -std::map<void*,MbChessMap3DKey > MbChessMemPool3D< TData, cachSize>::mPointerKeyMap; - -template <class TData, std::size_t cachSize> -const std::size_t MbChessMemPool3D<TData,cachSize>::mCacheSize=cachSize; - -//template <class TData, std::size_t cachSize> -//const std::size_t MbChessMemPool3D<TData,cachSize>::mNofElementsWidthMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -//template <class TData, std::size_t cachSize> -//const std::size_t MbChessMemPool3D<TData,cachSize>::mNofElementsInMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.))),3.0)); - -template <class TData,std::size_t cachSize> -const std::size_t MbChessMem3DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(std::pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -//template <class TData,std::size_t cachSize> -//const std::size_t MbChessMem3DBlock<TData,cachSize>::mMaxElements=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1.0/3.0))),3.0))),3.0)); - -#endif diff --git a/ThirdParty/Library/basics/memory/MbMemPool.h b/ThirdParty/Library/basics/memory/MbMemPool.h deleted file mode 100644 index 3a835596a9c717e4e31bf3f6570b7615759a754b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbMemPool.h +++ /dev/null @@ -1,87 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBMEMPOOL_H -#define MBMEMPOOL_H - -#include <queue> -#include <list> - - -template <typename TData, int asize> -class MbMemPool -{ - -protected: - MbMemPool(){} - // Alle 3 Attribute sind Singleton-Objekte ! - // Allokiere Blocke der Groesse m_asize - static int m_asize; - // Halte alle freien Pointer (jedes einzelne Element) in eine FIFO Liste - static std::queue<void*> m_queue; - // Pointer auf Bloecke zum Loeschen ! - static std::list<TData*> m_list; - -public: - - - ~MbMemPool(){} - - // Daten-Bloecke Loeschen, damit wird der gesamte Speicher freigegeben, - // erst aufrufen, wenn die objekte nicht mehr gebraucht werden! - static void deallocatePool(); - - void* operator new(std::size_t size) - { - void* pNew; - TData* feld; - int i; - - //i=m_queue.size(); - //pNew = m_queue.front(); - if(m_queue.size()==0) - { - //Wenn kein freier Speicher mehr vorhanden, Block anlegen - feld = new TData[m_asize]; - m_list.push_back(feld); - for(i=0 ; i<m_asize ; i++) - { - pNew = (void*) &(feld[i]); - m_queue.push( pNew ); - } - } - pNew = m_queue.front(); - m_queue.pop(); - return pNew; - - } - - void operator delete(void* p) - { - m_queue.push(p); - } -}; - - -template <typename TData, int asize> -std::queue<void*> MbMemPool<TData,asize>::m_queue; - -template <typename TData, int asize> -std::list<TData*> MbMemPool<TData,asize>::m_list; - -template <typename TData, int asize> -int MbMemPool<TData,asize>::m_asize=asize; - -template <typename TData, int asize> -void MbMemPool<TData,asize>::deallocatePool() -{ - for(typename std::list<TData*>::iterator pos=m_list.begin() ; pos!=m_list.end(); ++pos) - { - delete[] pos; - } -} - -#endif //MBMEMPOOL_H diff --git a/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h b/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h deleted file mode 100644 index 25c9311e7e5ec10585c96c3cd70792cb7b330ef3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef MBSHAREDPOINTERDEFINES_H -#define MBSHAREDPOINTERDEFINES_H - - -// Boost includes -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> - -#define VFSharedFromThis boost::enable_shared_from_this -#define VFSharedPtr boost::shared_ptr -#define VFWeakPtr boost::weak_ptr -#define VFDynamicPtrCast boost::dynamic_pointer_cast - -template<typename T> -class VFPtrDeleter -{ -public: - void operator()(T* p) { delete p; } -}; - - - -// std includes -#include <vector> - -//#ifdef WIN32 -//# include <memory> -//#else -//# include<tr1/memory> -//#endif - -//# define DCSharedFromThis std::tr1::enable_shared_from_this -//# define DCSharedPtr std::tr1::shared_ptr -//# define DCWeakPtr std::tr1::weak_ptr -//# define DCDynamicPtrCast std::tr1::dynamic_pointer_cast - -#endif diff --git a/ThirdParty/Library/basics/memory/MbSmartPtr.h b/ThirdParty/Library/basics/memory/MbSmartPtr.h deleted file mode 100644 index 6f2bf7631745b9940817d41014205f0a5b6e1077..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbSmartPtr.h +++ /dev/null @@ -1,147 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBSMARTPTR_H -#define MBSMARTPTR_H - -#include <basics/memory/MbSmartPtrBase.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - -//===================================================== -// Globale Funktion, um das Loeschen des referenzierten -// Objektes flexibler zu gestalten. -// -template<class ObjType> -void deleteRefPtr(ObjType* ptr) -{ - delete ptr; -} - -//====================================================== -// Die Reference-Pointer Klasse: -// -// Beim Referenzieren eines Objektes ueber einen SmartPointer wird ein Zaehler fuer die referezierte Objekt- -// adresse inkrementiert. Wird der Pointer wieder einem anderen Objekt zugewiesen, so wird der Zaehler fuer das -// urspruenglich referenzierte Objekt wieder dekremtiert, ebenfalls beim Destruktor des Reference-Pointers. -// Tatsaechlich geloescht wird das referenzierte Objekt erst, wenn der zugehoerige Zaehler auf 0 ist. Dies geschieht -// ueber die globale Template-Funktion deleteRefPtr(), die bei Bedarf ueberschrieben werden kann. -// Der Reference-Pointer verfuegt also sozusagen ueber eine automatische Garbage Collection - -template<class ObjType> -class MbSmartPtr : public MbSmartPtrBase -{ -public: - // Konstruktoren //bei explicit geht der implizite cast nicht mehr, aber um keinen stress zu verursachen - /*explicit*/ MbSmartPtr<ObjType>(const ObjType* pPtr=NULL) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(pPtr); - } - template<class ParamType> - MbSmartPtr<ObjType>(const MbSmartPtr<ParamType>& ptr) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(ptr.get()); - } - // Destruktor - ~MbSmartPtr<ObjType>() - { - init(NULL); - } - //--------------------------------------------------- - // Kopierkonstruktor - MbSmartPtr<ObjType>(const MbSmartPtr<ObjType>& ptr) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(ptr.get()); - } - //--------------------------------------------------- - // Zuweisungsoperatoren - template<class ParamType> - const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ParamType>& ptr) - { - init(ptr.get()); - return *this; - } - const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ObjType>& ptr) - { - init(ptr.get()); - return *this; - } - - const MbSmartPtr<ObjType>& operator =(const ObjType *pPtr) - { - init(pPtr); - return *this; - } - //--------------------------------------------------- - // Dereferenzierung-Operatoren - ObjType& operator *() const { return *mpPtr; } - ObjType* operator ->() const { return mpPtr; } - bool operator !() const { return !mpPtr; } - operator ObjType *() const { return mpPtr; } - //--------------------------------------------------- - // Methoden - ObjType* get() const - { - return mpPtr; - } - //--------------------------------------------------- - int ref_count() const - { - return MbSmartPtrBase::ref_count(mpPtr); - } - //--------------------------------------------------- - bool release() const - { - return MbSmartPtrBase::removeFromGC(mpPtr); - } - -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - if(ArchiveTools::isWriting(ar)) - { - ar & mpPtr; - } - else - { - ObjType* ptr; - ar & ptr; - - mpPtr=NULL; - init(ptr); - } - } -#endif //CAB_RCF - -private: - void init(const ObjType* pPtr) - { - // Nur was tun, wenn wirklich noetig - if(pPtr==mpPtr) return; - - // Aktuell referenziertes Objekt freigeben, dabei ueberpruefen, ob letztes Release - if(mpPtr && releaseRef(mpPtr)) - { - // referenziertes Objekt loeschen - deleteRefPtr(mpPtr); - } - - // Wenn pPtr ein neues Objekt ist, Zugriffszaehler auf neues Objekt erhoehen - mpPtr=const_cast<ObjType*>(pPtr); - if(mpPtr) addRef(mpPtr); - } - -private: - ObjType* mpPtr; -}; - -#endif //MBSMARTPTR_H diff --git a/ThirdParty/Library/basics/memory/MbSmartPtrBase.cpp b/ThirdParty/Library/basics/memory/MbSmartPtrBase.cpp deleted file mode 100644 index d0e07fa9503fe01f94128543d84927804505b97a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbSmartPtrBase.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include <basics/memory/MbSmartPtrBase.h> - -using namespace std; - -bool MbSmartPtrBase::addRef(void* ptr) -{ - MbSmartPtrBaseMap::getInstance()->getMap()[ptr]++; - return true; -} -//------------------------------------------------- -bool MbSmartPtrBase::releaseRef(void* ptr) -{ - map<void*,int>& ptrMap = MbSmartPtrBaseMap::getInstance()->getMap(); - map<void*,int>::iterator pos=ptrMap.find(ptr); - - if( pos!=ptrMap.end() ) - { - pos->second--; - - if(pos->second==0) - { - ptrMap.erase(pos); - return true; - } - } - return false; -} -//------------------------------------------------- -bool MbSmartPtrBase::removeFromGC(void* ptr) const -{ - if( MbSmartPtrBaseMap::getInstance()->getMap().erase(ptr) ) return true; - return false; -} -//------------------------------------------------- -int MbSmartPtrBase::ref_count(void* ptr) const -{ - map<void*,int>& ptrMap = MbSmartPtrBaseMap::getInstance()->getMap(); - map<void*,int>::iterator pos=ptrMap.find(ptr); - - if( pos!=ptrMap.end() ) return pos->second; - else return 0; -} - - diff --git a/ThirdParty/Library/basics/memory/MbSmartPtrBase.h b/ThirdParty/Library/basics/memory/MbSmartPtrBase.h deleted file mode 100644 index d1bf281ce1f7fe8b41c19cd0d6deac9dd43f9574..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/memory/MbSmartPtrBase.h +++ /dev/null @@ -1,50 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBSMARTPTRBASE_H -#define MBSMARTPTRBASE_H - -#include <iostream> -#include <map> - -//============================================================ -// Klasse MbSmartPtrBase -// -// Basisklasse, speziell fuer MbSmartPtr, die das eigentliche -// Reference-Counting uebernimmt. -// -class MbSmartPtrBase -{ - //Ursprung: - // mpCntrMap ist ein Pointer, weil sichergestellt sein muss, dass die - // Map existiert, wenn das erste mal darauf zugegriffen wird. - // Ein Zugriff zwischen zwei statischen Objekten kann zum Fehler fuehren, da - // die Reihenfolge der Konstruktorenaufrufe dann vom Linker bestimmt wird. - - //Anpassung a la UbWriter mit SingletonMap - class MbSmartPtrBaseMap - { - private: - MbSmartPtrBaseMap() { } - MbSmartPtrBaseMap( const MbSmartPtrBaseMap& ); //no copy allowed - const MbSmartPtrBaseMap& operator=( const MbSmartPtrBaseMap& ); //no copy allowed - - std::map<void*,int> mpCntrMap; - public: - static MbSmartPtrBaseMap* getInstance() { static MbSmartPtrBaseMap instance; return &instance; } - std::map<void*,int>& getMap() { return mpCntrMap; } - }; - -protected: - MbSmartPtrBase() {} - virtual ~MbSmartPtrBase() {} - bool addRef(void* p); - bool releaseRef(void* p); - bool removeFromGC(void* ptr) const; - int ref_count(void* ptr) const; -}; - -#endif //MBSMARTPTRBASE_H diff --git a/ThirdParty/Library/basics/objects/CMakePackage.txt b/ThirdParty/Library/basics/objects/CMakePackage.txt deleted file mode 100644 index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/ThirdParty/Library/basics/objects/ObCreator.h b/ThirdParty/Library/basics/objects/ObCreator.h deleted file mode 100644 index 253fc616e2f1d9c2b279423ce93462095e698774..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObCreator.h +++ /dev/null @@ -1,112 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBCREATOR_H -#define OBCREATOR_H - -#include <string> - -/*=========================================================================*/ -/* ObCreator / ObCreatorImpl */ -/* */ -/** -generic factory -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 14.06.07 -@version 1.1 - 12.04.08 -*/ - -/* -usage: see bottom of file "./ObFactory.h" -*/ - -////////////////////////////////////////////////////////////////////////// -// ObCreator -// Um in der Factory verschiedene Typen von Creaors in einer -// std::map<std::string,ObCreator<BaseT>*> halten zu koennen -// muss eine gemeinsame Basisklasse existieren -////////////////////////////////////////////////////////////////////////// -template< class BaseT > -class ObCreator -{ -public: - virtual std::string getObjectTypeID()=0; - virtual BaseT* createObject() = 0; - - virtual ~ObCreator() { } - -protected: - ObCreator() {} -private: - ObCreator( const ObCreator< BaseT >& ); //no copy allowed - const ObCreator& operator=( const ObCreator& ); //no copy allowed -}; - -////////////////////////////////////////////////////////////////////////// -// ObCreatorImpl -// Implementierung des speziellen Creators -////////////////////////////////////////////////////////////////////////// -template< class T, class BaseT=T > -class ObCreatorImpl : public ObCreator< BaseT > -{ -public: - static ObCreator<BaseT >* getInstance() - { - static ObCreatorImpl< T, BaseT > instance; - return &instance; - } - -public: - ~ObCreatorImpl() {} - - //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist - std::string getObjectTypeID() { return T::getStaticClassObjectTypeID(); } - - virtual T* createObject() { return new T(); } - -protected: - ObCreatorImpl() {} -private: - ObCreatorImpl( const ObCreatorImpl< T, BaseT >& ); //no copy allowed - const ObCreatorImpl& operator=( const ObCreatorImpl& ); //no copy allowed -}; - -////////////////////////////////////////////////////////////////////////// -// ObCreatorImpl -// Implementierung des speziellen Creators fuer Singletons -////////////////////////////////////////////////////////////////////////// -template< class T, class BaseT=T > -class ObSingletonCreatorImpl : public ObCreator< BaseT > -{ -public: - static ObCreator<BaseT >* getInstance() - { - static ObSingletonCreatorImpl< T, BaseT > instance; - return &instance; - } -public: - ~ObSingletonCreatorImpl() {} - - //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist - std::string getObjectTypeID() { return T::getStaticClassObjectTypeID(); } - - virtual T* createObject() { return T::getInstance(); } - -protected: - ObSingletonCreatorImpl() {} -private: - ObSingletonCreatorImpl( const ObSingletonCreatorImpl< T, BaseT >& ); //no copy allowed - const ObSingletonCreatorImpl& operator=( const ObSingletonCreatorImpl& ); //no copy allowed -}; - -//workaround for the not perfect C++ world. typeinfo::name is not usable for this purpose! -//see Andrei Alexandrescu, "Modern C++ Design: Generic Programming and Design Patterns Applied", Chapter 8.5 -#define OBCREATOR_EXT( ClassObject ) \ - static std::string getStaticClassObjectTypeID() { return #ClassObject; } \ - virtual std::string getClassObjectTypeID() { return getStaticClassObjectTypeID(); } - -#endif //OBCREATOR_H diff --git a/ThirdParty/Library/basics/objects/ObFactory.h b/ThirdParty/Library/basics/objects/ObFactory.h deleted file mode 100644 index 6b51787819b0548efc89960be450d129753aa0b3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObFactory.h +++ /dev/null @@ -1,174 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBFACTORY_H -#define OBFACTORY_H - - -#include <string> -#include <map> -#include <sstream> -#include <iomanip> -#include <typeinfo> - -#include <basics/objects/ObCreator.h> - -/*=========================================================================*/ -/* ObFactory */ -/* */ -/** -generic factory -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 14.06.07 -@version 1.1 - 12.04.08 -*/ - -/* -usage: T = zu erzeugende Klasse - Creator = Erzeugerklasse -////////////////////////////////////////////////////////////////////////// -//example -////////////////////////////////////////////////////////////////////////// -// class Base{ -// public: -// OBCREATOR_EXT(Base) -// }; -// //automatisches registrieren: -// UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Base>::getInstance()), CAB_Base); -// class Derived : public Base -// { -// public: -// OBCREATOR_EXT(Derived) -//}; -// //automatisches registrieren: -// UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Derived>::getInstance()), CAB_Derived); -//////////////////////////////////////////////////////////////////////////// -// int main() -// { -// //Alternativ zu UB_AUTO_RUN_NAMED: haendisches registrieren -// ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base>::getInstance()); -// ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Derived,Base>::getInstance()); -// -// //create objects - method1 -// Base* test1 = ObFactory<Base>::getInstance()->createObject<Base>(); -// Base* test2 = ObFactory<Base>::getInstance()->createObject<Derived>(); -// -// //create objects - method2 -// Base* test1 = ObFactory<Base>::getInstance()->createObject(Base::getStaticClassObjectTypeID() ); -// Base* test2 = ObFactory<Base>::getInstance()->createObject(Derived::getStaticClassObjectTypeID() ); -// //... -// } -*/ - - -template<class T, typename Creator = ObCreator< T > > -class ObFactory -{ - typedef std::map< std::string, Creator* > CreatorMap; - typedef typename CreatorMap::iterator CreatorMapIt; - typedef std::pair< std::string, Creator* > CreatorMapElement; - -protected: - ObFactory() {} //so ist vererbung gewahrleistet - -private: - ObFactory( const ObFactory< T, Creator >& ); //no copy allowed - const ObFactory& operator=( const ObFactory& ); //no copy allowed - - -public: - virtual ~ObFactory() {} - - static ObFactory< T, Creator >* getInstance() - { - static ObFactory< T, Creator > instance; - return &instance; - } - - bool addObCreator(Creator* creator); - bool removeObCreator(Creator* creator); - - T* createObject(const std::string& objectTypeID); - - template< typename T2 > - T* createObject() { return this->createObject( T2::getStaticClassObjectTypeID() ); } - - Creator* getCreator(const std::string& objectTypeID); - - virtual std::string toString(); - -private: - CreatorMap creatorMap; -}; - -////////////////////////////////////////////////////////////////////////// -//Implementation -template<class T, typename Creator > -bool ObFactory< T, Creator >::addObCreator(Creator* creator) -{ - if(creatorMap.insert( CreatorMapElement(creator->getObjectTypeID(), creator) ).second ) - { - //insert succeeded - return true; - } - //insert fails - return false; -} -/*======================================================================*/ -template<class T, typename Creator > -bool ObFactory< T, Creator >::removeObCreator(Creator* creator) -{ - if(creator && creatorMap->erase( creator->getClassObjectTypeID() ) ) - return true; - - return false; -} -/*======================================================================*/ -template<class T, typename Creator > -Creator* ObFactory< T, Creator >::getCreator(const std::string& obtypeID) -{ - CreatorMapIt it = creatorMap.find(obtypeID); - if(it == creatorMap.end()) return NULL; - - Creator* creator = it->second; - if(!creator) return NULL; - - return creator; -} -/*======================================================================*/ - template<class T, typename Creator > - T* ObFactory< T, Creator >::createObject(const std::string& objectTypeID) - { - Creator* creator = this->getCreator(objectTypeID); - - if(!creator) - { - UB_THROW( UbException(UB_EXARGS,"no creator avaivlable for ID="+objectTypeID ) ); - } - - return creator->createObject(); - } -/*======================================================================*/ -template<class T, typename Creator > -std::string ObFactory< T, Creator >::toString() -{ - std::size_t maxL = 6; - for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it) - if( it->first.size() > maxL ) - maxL = it->first.size(); - - std::stringstream os; - os<<(std::string)typeid(*this).name()<<" - info:"<<std::endl; - os<<" "<<std::left<<std::setw(maxL)<<"object"<<" <-> "<<"creator "<<std::endl; - for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it) - os<< " - " << std::setw(maxL) << it->first << " <-> " << (std::string)typeid(*it->second).name() << std::endl; - - return os.str(); -} -/*======================================================================*/ - -#endif //OBFACTORY_H diff --git a/ThirdParty/Library/basics/objects/ObObject.cpp b/ThirdParty/Library/basics/objects/ObObject.cpp deleted file mode 100644 index 452791ad8f43507c069ea9e90e59193fd39334f6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObject.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//#include <basics/objects/ObObject.h> - -// ObObject::ObObject() -// { -// } -// /*=======================================*/ -// std::string ObObject::getName() -// { -// return name; -// } diff --git a/ThirdParty/Library/basics/objects/ObObject.h b/ThirdParty/Library/basics/objects/ObObject.h deleted file mode 100644 index aeb3ed9c48bb7bbe0b58fc534c6c2313d17ce35b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObject.h +++ /dev/null @@ -1,60 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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: - ObObject() : name("") { } - ObObject(const std::string& name) : name(name) { } - - 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/ThirdParty/Library/basics/objects/ObObjectCreator.h b/ThirdParty/Library/basics/objects/ObObjectCreator.h deleted file mode 100644 index 540f422d5ddc6ef9320743bfbee4432a85225796..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObjectCreator.h +++ /dev/null @@ -1,58 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTCREATOR_H -#define OBOBJECTCREATOR_H - -#include <string> - -class ObObject; -class ObObjectManager; - -class Presentator; -class QViewer; - -#ifdef CAB_QT -class QObObjectSpecificInstrument; -class QWidget; -class QActionGroup; -#endif - -class ObObjectCreator -{ -public: - virtual ~ObObjectCreator() {} - - virtual ObObject* createObObject()=0; - - virtual std::string getTypeID() { return "ObObject"; } - virtual std::string toString() { return "ObObjectCreator"; } - -#ifdef CAB_QT - //virtual Presentator* createObjectPresentator(ObObject *object)=0; - virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; } - virtual QActionGroup* getSpecificPresentatorGroup(ObObject* object, QViewer *viewer, QWidget* parent) { return NULL; } - virtual QActionGroup* getSpecificActionGroup(ObObjectManager* manager, ObObject* object, QWidget* parent) - { - return NULL; - } - - virtual ObObject* createObObjectWithQt() { return NULL; } - virtual void showSpecificInstrument(ObObject* object, QWidget* parent=0) {} - virtual QObObjectSpecificInstrument* getSpecificInstrument() { return NULL; } - - //virtual QActionGroup *getSpecificContextMenuActionGroup() { return NULL; } -#endif - -protected: - ObObjectCreator() {} - -private: - ObObjectCreator( const ObObjectCreator& ); //no copy allowed - const ObObjectCreator& operator=( const ObObjectCreator& ); //no copy allowed - -}; -#endif diff --git a/ThirdParty/Library/basics/objects/ObObjectFactory.cpp b/ThirdParty/Library/basics/objects/ObObjectFactory.cpp deleted file mode 100644 index 5cc03a78f2b2d550406e14a95cdbcffe22157e9c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObjectFactory.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include <basics/objects/ObObjectFactory.h> - -/**** Eigene ****/ -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbException.h> - -using namespace std; - -//ObObjectFactory::ObObjectFactory() -//{ -//} -// -//ObObjectFactory::~ObObjectFactory() -//{ -//} -/*======================================================================*/ -//ObObjectFactory* ObObjectFactory::getInstance() -//{ -// static ObObjectFactory instance; -// return &instance; -//} -/*======================================================================*/ -void ObObjectFactory::addObObjectCreator(ObObjectCreator *creator) -{ - //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getTypeID()<<endl; - creatorSet.insert(std::pair<string, ObObjectCreator*>(creator->getTypeID(), creator)); -} -/*======================================================================*/ -void ObObjectFactory::removeObObjectCreator(ObObjectCreator *creator) -{ - UB_THROW( UbException(UB_EXARGS,"not implemented") ); -} -/*======================================================================*/ -ObObjectCreator* ObObjectFactory::getCreator(string objectType) -{ - std::map<string, ObObjectCreator*>::iterator creatorIterator = creatorSet.find(objectType); - if(creatorIterator == creatorSet.end()) UB_THROW( UbException(UB_EXARGS,"factory has no creator for "+objectType) ); - ObObjectCreator *creator = creatorIterator->second; - if(!creator) UB_THROW( UbException(UB_EXARGS,"no time series creator for type available") ); - return creator; -} -/*======================================================================*/ -string ObObjectFactory::toString() -{ - stringstream text; - - std::map<string, ObObjectCreator*>::iterator creatorIterator; - std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet(); - - for(creatorIterator = creatorSet->begin(); creatorIterator!=creatorSet->end(); ++creatorIterator) - text<<" - "<<(creatorIterator->second)->toString()<<" for "<<(creatorIterator->first)<<endl; - - return text.str(); -} diff --git a/ThirdParty/Library/basics/objects/ObObjectFactory.h b/ThirdParty/Library/basics/objects/ObObjectFactory.h deleted file mode 100644 index da8ef389c6ef433d96be6663eefaf34c9c99bd1c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObjectFactory.h +++ /dev/null @@ -1,42 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTFACTORY_H -#define OBOBJECTFACTORY_H - -#include <string> -#include <map> - -class ObObjectCreator; - -class ObObjectFactory -{ -public: - ObObjectFactory() {} - virtual ~ObObjectFactory() {} - - //static geht nicht, da abgeleitete Factories existieren ... - //static ObObjectFactory* getInstance(); - //virtual ObObjectFactory* getInstance()=0; - - ObObjectCreator* getCreator(std::string objectType); - - void addObObjectCreator(ObObjectCreator* creator); - void removeObObjectCreator(ObObjectCreator* creator); - - std::map<std::string, ObObjectCreator*>* getCreatorSet() { return &creatorSet; } - - virtual std::string toString(); - -private: - ObObjectFactory( const ObObjectFactory& ); //no copy allowed - const ObObjectFactory& operator=( const ObObjectFactory& ); //no copy allowed - - std::map<std::string, ObObjectCreator*> creatorSet; -}; - - -#endif //OBOBJECTFACTORY_H diff --git a/ThirdParty/Library/basics/objects/ObObjectManager.cpp b/ThirdParty/Library/basics/objects/ObObjectManager.cpp deleted file mode 100644 index 44bba546bf9e157bc21baff5d6e24aa8f3700786..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObjectManager.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include <basics/objects/ObObjectManager.h> -#include <basics/objects/ObObject.h> -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbTableModel.h> -#include <basics/utilities/UbException.h> - -using namespace std; - -ObObjectEntry::ObObjectEntry(ObObjectManager *parent, ObObject *object) -{ - this->parent = parent; - this->object = object; -} -/*======================================================*/ -ObObjectManager::ObObjectManager() -{ - this->selectedObject = NULL; - this->tableModel = NULL; -} - -/*======================================================*/ -ObObjectManager::~ObObjectManager() -{ - //cerr<<"NEIN, notifyObserversObjectWillBeDeleted wird AUSSCHLIESSLICH von BasisKlasse aufgerufen!!!"<<endl; - // cerr<<"das muss so sein, denn ansonsten duerfte diese funktion nur in der speziellen klasse stehen, da\n"; - // cerr<<"virtuelle destruktoren sich rekursiv vom speziellen ins allg. aufrufen --> notify.. wuerde\n"; - // cerr<<"oefters aufgerufen werden...\n"; - - this->objectList.clear(); - if(this->tableModel) delete this->tableModel; -} -/*======================================================*/ -UbTableModel* ObObjectManager::getTableModel() -{ - return tableModel; -} -/*======================================================*/ -//bool ObObjectManager::addObObject(ObObject *object) -//{ -// cout<<"ObObjectManager::addObObject "<<object->toString()<<endl; -// for(int pos=0; pos<(int)this->objectList.size(); pos++) -// if(this->objectList[pos]->object==object) -// return false; -// -// this->objectList.push_back(new ObObjectEntry(this,object)); -// //object->addObserver(this); -// this->selectObObject(object); -// return true; -//} -/*======================================================*/ -bool ObObjectManager::addObObjectEntry(ObObjectEntry* objectEntry) -{ - for(int pos=0; pos<(int)this->objectList.size(); pos++) - if(this->objectList[pos]->object==objectEntry->object) - return false; - - this->objectList.push_back(objectEntry); -// objectEntry->getObject()->addObserver(this); - this->selectObObject(objectEntry->object); - return true; -} -/*======================================================*/ -bool ObObjectManager::removeObObject(ObObject* object) -{ - if (this->selectedObject == object) this->selectedObject=NULL; - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - - if(this->objectList[pos]->object==object) - { - return this->removeObObject(pos); -// this->objectList.erase(objectList.begin()+pos); -// //this->removeObserver(this); -// return true; - } - } - return false; -} -/*======================================================*/ -bool ObObjectManager::removeObObject(int index) -{ - try - { - if ( objectList[index]->object == this->selectedObject ) this->selectedObject=NULL; - //den entry loeschen ... das object im Entry ??? erstmal ausserhalb ... - delete objectList[index]; - objectList.erase(objectList.begin()+index); - this->notifyObserversObjectChanged(); - return true; - } - catch(const std::exception& e) { cerr<<e.what()<<endl; } - catch(...) { cerr<<"Fehler in ObObjectManager::removeObObject"<<endl; } - return false; -} -/*======================================================*/ -void ObObjectManager::removeAllObObjects() -{ - //TODO: implementieren!! - //foreach grid: - //grid->removeObserver(this); - //vector<ObObject*>::iterator it; - //for(it=objectList.begin(); it!=objectList.end(); it++) - //{ - // it->removeObserver(this); - //} -// for(int i=0; i<(int)objectList.size(); i++) -// { -// delete objectList[i]->object->removeObserver(this); -// } - this->objectList.clear(); - this->selectedObject = NULL; - this->notifyObserversObjectChanged(); -} -/*======================================================*/ -int ObObjectManager::getNumberOfObObjects() -{ - return (int)this->objectList.size(); -} -/*======================================================*/ -vector<ObObject*>* ObObjectManager::getAllObObjects() -{ - UB_THROW( UbException(UB_EXARGS,"hier muss noch was getan werden") ); -// return this->objectList; -} -vector<ObObjectEntry*>* ObObjectManager::getAllObObjectEntries() -{ - return &this->objectList; -} -/*======================================================*/ -ObObject* ObObjectManager::getObObject(int index) -{ - if(index < 0) return NULL; - if(index >= (int)this->objectList.size()) return NULL; - - return(this->objectList[index]->object); -} -/*======================================================*/ -ObObjectEntry* ObObjectManager::getObObjectEntry(int index) -{ - if(index < 0) return NULL; - if(index >= (int)this->objectList.size()) return NULL; - - return(this->objectList[index]); -} -/*====================================================*/ -string ObObjectManager::toString() -{ - stringstream ss; ss<<endl; - - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - ObObject* object = this->objectList[pos]->object; - ss<<(pos+1)<<". "<<object->toString()<<endl; - } - return ss.str(); -} -/*======================================================*/ -void ObObjectManager::objectChanged(UbObservable* observable) -{ - //cout<<"ObObjectManager::objectChanged ??"; - this->notifyObserversObjectChanged(); -} -/*======================================================*/ -void ObObjectManager::objectWillBeDeleted(UbObservable* observable) -{ - cout<<"ObObjectManager::objectWillBeDeleted ??"; - //observable->removeObserver(this); -} -/*======================================================*/ -bool ObObjectManager::selectObObject(int index) -{ - if((int)this->objectList.size()==0) - { - this->selectedObject = NULL; return false; - } - if (index > (int)this->objectList.size()-1 || index < 0) return false; - if ( this->selectedObject == this->getObObject(index) ) return true; - - this->selectedObject = this->getObObject(index); - //cout<<this->getObserverList()->size()<<endl; - - this->notifyObserversObjectChanged(); - return true; -} -/*======================================================*/ -bool ObObjectManager::selectObObject(ObObject* object) -{ - if((int)this->objectList.size()==0) { this->selectedObject = NULL; return false; } - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - if(this->objectList[pos]->object==object) - { - return this->selectObObject(pos); - } - } - return false; -} -/*======================================================*/ -ObObject* ObObjectManager::getSelectedObObject() -{ - return this->selectedObject; -} -/*======================================================*/ -int ObObjectManager::getSelectedIndex() -{ - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - if(this->objectList[pos]->object==this->selectedObject) - { - return pos; - } - } - return -1; -} -/*======================================================*/ - diff --git a/ThirdParty/Library/basics/objects/ObObjectManager.h b/ThirdParty/Library/basics/objects/ObObjectManager.h deleted file mode 100644 index 632e124bf72f3a259f638f12116eeac2b661e61f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/objects/ObObjectManager.h +++ /dev/null @@ -1,79 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTMANAGER_H -#define OBOBJECTMANAGER_H - -#include <string> -#include <sstream> -#include <vector> - -#include <basics/utilities/UbObservable.h> -#include <basics/utilities/UbObserver.h> - -class UbException; -class UbTableModel; -class ObObjectManager; -class ObObjectFactory; -class ObObject; - - -class ObObjectEntry -{ - friend class ObObjectManager; -public: - ObObjectManager* getParent() { return parent; } - ObObject* getObject() { return object; } - - ObObjectEntry(ObObjectManager* parent, ObObject* object); - virtual ~ObObjectEntry() { } - -protected: - ObObjectManager* parent; - ObObject* object; -}; - - -class ObObjectManager : public UbObservable, public UbObserver -{ -public: - ObObjectManager(); - ~ObObjectManager(); - - //virtual bool addObObject(ObObject* object); - virtual bool addObObjectEntry(ObObjectEntry* objectEntry); - - virtual ObObjectEntry* createNewObObjectEntry(ObObject* obj) { return new ObObjectEntry(this, obj); } - - bool removeObObject(ObObject* object); - bool removeObObject(int index); - void removeAllObObjects(); - bool selectObObject(int index); - bool selectObObject(ObObject* object); - ObObject* getSelectedObObject(); - int getSelectedIndex(); - - int getNumberOfObObjects(); - std::vector<ObObject*>* getAllObObjects(); - std::vector<ObObjectEntry*>* getAllObObjectEntries(); - ObObject* getObObject(int index); - ObObjectEntry* getObObjectEntry(int index); - - std::string toString(); - - virtual void objectChanged(UbObservable* observable); - virtual void objectWillBeDeleted(UbObservable* observable); - - UbTableModel* getTableModel(); - virtual ObObjectFactory* getObObjectFactory()=0; - -protected: - std::vector<ObObjectEntry*> objectList; - ObObject* selectedObject; - UbTableModel* tableModel; -}; - -#endif //OBOBJECTMANAGER_H diff --git a/ThirdParty/Library/basics/parallel/CMakePackage.txt b/ThirdParty/Library/basics/parallel/CMakePackage.txt deleted file mode 100644 index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/ThirdParty/Library/basics/parallel/PbMpi.h b/ThirdParty/Library/basics/parallel/PbMpi.h deleted file mode 100644 index 21dd38f923eed543af9be4262366db5caf2b37f6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/PbMpi.h +++ /dev/null @@ -1,454 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef PbMpi_H -#define PbMpi_H - -#include <vector> -#include <sstream> - -#ifndef VF_MPI -# error VF_MPI has to be defined -#endif - -//#undef SEEK_SET -//#undef SEEK_CUR -//#undef SEEK_END -#include <mpi.h> - -#include <basics/utilities/UbException.h> - -#ifdef USE_MPI_CXX_SYNTAX - #define PbMpi_COMM_WORLD MPI::COMM_WORLD - #define PbMpi_INT MPI::INT - #define PbMpi_CHAR MPI::CHAR - #define PbMpi_SHORT MPI::SHORT - #define PbMpi_FLOAT MPI::FLOAT - #define PbMpi_DOUBLE MPI::DOUBLE - #define PbMpi_COMM_NULL MPI::COMM_NULL - - -namespace PbMpi -{ - typedef MPI::Intracomm Comm; - typedef MPI::Group Group; - typedef MPI::Request Request; - typedef MPI::Status Status; - - inline void Init( ) - { - MPI::Init(); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - } - inline void Init(int& argc, char** argv ) - { - MPI::Init(argc, argv); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - } - inline void Finalize() { MPI::Finalize(); } - - inline int GetCommSize( const Comm& comm ) { return comm.Get_size(); } - inline int GetCommRank( const Comm& comm ) { return comm.Get_rank(); } - inline void Barrier( const Comm& comm ) { comm.Barrier(); } - - inline double Wtime() { return MPI::Wtime(); } - inline double Wtick() { return MPI::Wtick(); } - - inline void Wait( Request& request, Status* outStatus=NULL) - { - if(outStatus) request.Wait(*outStatus); - else request.Wait(); - } - - inline Group GetCommGroup(Comm& comm) { return comm.Get_group(); } - inline Group GetGroupIncl( Group& group, const int& n, int* ranks ) { return group.Incl(n, ranks); } - inline Comm CommCreateComm( Comm& comm, Group& group ) { return comm.Create(group); } - - inline void Alltoall( Comm& comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype) - { - comm.Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype); - } - inline void Bcast(Comm& comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank ) - { - comm.Bcast(data, n, datatype, srcRank); - } - inline void Send(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - try - { - comm.Send(data, length, dataType, destRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - inline void Recv(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag) - { - try - { - comm.Recv(const_cast<void*>(data), length, dataType, srcRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched \n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - - inline void Irecv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest) - { - outRequest = comm.Irecv(const_cast<void*>(data), length, dataType, srcRank, tag); - } - inline void Ssend(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - try - { - comm.Ssend(data, length, dataType, destRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - -} -#else ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // C-Syntax - ////////////////////////////////////////////////////////////////////////// - namespace PbMpi - { - typedef MPI_Comm Comm; - typedef MPI_Group Group; - typedef MPI_Request Request; - typedef MPI_Status Status; - } - - #define PbMpi_COMM_WORLD ((PbMpi::Comm)MPI_COMM_WORLD) - #define PbMpi_INT MPI_INT - #define PbMpi_CHAR MPI_CHAR - #define PbMpi_SHORT MPI_SHORT - #define PbMpi_FLOAT MPI_FLOAT - #define PbMpi_DOUBLE MPI_DOUBLE - #define PbMpi_COMM_NULL MPI_COMM_NULL - -namespace PbMpi -{ - inline void Init( ) - { - int argc = 1; - char** argv = new char*[1]; - argv[0] = new char[1]; - argv[0][0] = 'n'; - MPI_Init(&argc, &argv); - } - inline void Init(int& argc, char** argv ) { MPI_Init(&argc, &argv); } - inline void Finalize( ) { MPI_Finalize(); } - inline int GetCommSize( Comm comm ) { int tmp; MPI_Comm_size(comm, &tmp); return tmp; } - inline int GetCommRank( Comm comm ) { int tmp; MPI_Comm_rank(comm, &tmp); return tmp; } - inline void Barrier( Comm comm ) { MPI_Barrier( comm ); } - inline double Wtime() { return MPI_Wtime(); } - inline double Wtick() { return MPI_Wtick(); } - inline void Wait( Request& request, Status* outStatus=NULL) { MPI_Wait( &request, outStatus); } - - inline Group GetCommGroup(Comm comm) { Group out; MPI_Comm_group(comm, &out); return out; } - inline Group GetGroupIncl( Group group, const int& n, int* ranks ) { Group out; MPI_Group_incl(group, n, ranks, &out); return out; } - inline Comm CommCreateComm( Comm comm, Group& group ) { Comm out; MPI_Comm_create(comm, group, &out); return out; } - - inline void Alltoall( Comm comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype) - { - MPI_Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype, comm); - } - inline void Bcast(Comm comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank ) - { - MPI_Bcast(data, n, datatype, srcRank, comm); - } - inline void Send(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - MPI_Send(const_cast<void*>(data), length, dataType, destRank, tag, comm); - } - inline void Recv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag) - { - MPI_Recv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, MPI_STATUS_IGNORE); - } - inline void Ssend(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - MPI_Ssend(const_cast<void*>(data), length, dataType, destRank, tag, comm); - } - inline void Irecv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest) - { - MPI_Irecv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, &outRequest); - } - -} -#endif - -namespace PbMpi -{ - /*======================================================================*/ - // send a single value "value" of MPI_Datatype - template <class T> - inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives a single value "value" of MPI_Datatype - template <class T> - inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives and returns a single value of MPI_Datatype - // expample: int value = PbMpi::receiveSingleValue<int>(MPI::INT,0,10,comm); - template <class T> - inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline bool receiveBoolValue(int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline std::string receiveStringValue(int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a vector of MPI_Datatype - template <class T> - inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receive a std::vector of MPI_Datatype - template <class T> - inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receive a vector of MPI_Datatype and adds this vector to existing vector - // ans returns number of received elements - template <class T> - inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a std::vector of strings - inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a vector of strings - inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm); -}; - -/*======================================================================*/ -// send a single value of MPI_Datatype -template <class T> -void PbMpi::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm) -{ - PbMpi::Send(comm, &value, 1, datatype, dest, tag); - //comm.Send(&value, 1, datatype, dest, tag); -} -/*======================================================================*/ -template <class T> -void PbMpi::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - PbMpi::Recv(comm, &value, 1, datatype, source, tag); - //comm.Recv(&value, 1, datatype, source, tag); -} -/*======================================================================*/ -template <class T> -T PbMpi::receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - T value; - PbMpi::Recv(comm, &value, 1, datatype, source, tag); - //comm.Recv(&value, 1, datatype, source, tag); - - return value; -} -/*======================================================================*/ -// send a bool value (bool doesn't work with template, why ever) -void PbMpi::sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm) -{ - short dummy; - if(value) dummy=1; - else dummy=0; - - PbMpi::Send(comm, &dummy, 1, PbMpi_SHORT, dest, tag); - //comm.Send(&dummy, 1, MPI::SHORT, dest, tag); -} -/*======================================================================*/ -bool PbMpi::receiveBoolValue(int source, int tag, PbMpi::Comm comm) -{ - short dummy; - PbMpi::Recv(comm, &dummy, 1, PbMpi_SHORT, source, tag); - //comm.Recv(&dummy, 1, MPI::SHORT, source, tag); - - return (dummy==1); -} -/*======================================================================*/ -// sends bool value (doesn't work with template, why ever... stupid MPI) -void PbMpi::sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm) -{ - std::vector<char> vec; - for(std::size_t i=0; i<value.size(); i++) - vec.push_back(value[i]); - - PbMpi::sendVector(vec,PbMpi_CHAR,dest,tag,comm); -} - -/*======================================================================*/ -// receives bool value (doesn't work with template, why ever... stupid MPI) -std::string PbMpi::receiveStringValue(int source, int tag, PbMpi::Comm comm) -{ - std::vector<char> vec; - PbMpi::receiveVector(vec,PbMpi_CHAR,source,tag,comm); - - std::string str; - for(std::size_t i=0; i<vec.size(); i++) - str+=vec[i]; - - return str; -} -/*======================================================================*/ -// send a vector of MPI_Datatype -template <class T> -void PbMpi::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm) -{ - // send size - int size = (int)v.size(); - - PbMpi::Send(comm, &size, 1, PbMpi_INT, dest, tag); - //comm.Send(&size, 1, MPI::INT, dest, tag); - - if(size>0) - { - PbMpi::Send(comm, &v[0], size, datatype, dest, tag); - //comm.Send(&v[0], size, datatype, dest, tag); - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype -template <class T> -void PbMpi::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - int size; - - PbMpi::Recv(comm, &size, 1, PbMpi_INT, source, tag); - //comm.Recv(&size, 1, MPI::INT, source, tag); - - v.resize(size); - - if( size>0 ) - { - PbMpi::Recv(comm, &v[0], size, datatype, source, tag); - //comm.Recv(&v[0], size, datatype, source, tag); - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype and adds this vector to existing vector -// return value is size of received elements -template <class T> -int PbMpi::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - int incommingSize; - - PbMpi::Recv(comm, &incommingSize, 1, PbMpi_INT, source, tag); - //comm.Recv(&incommingSize, 1, MPI::INT, source, tag); - - int oldSize = (int)v.size(); - v.resize(oldSize+incommingSize); - - if( incommingSize>0 ) - { - PbMpi::Recv(comm, &v[oldSize], incommingSize, datatype, source, tag); - //comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); - } - - return incommingSize; -} -/*======================================================================*/ -// send a vector of strings -void PbMpi::sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm) -{ - // send size - int stringVectorSize = (int)v.size(); - - PbMpi::Send(comm, &stringVectorSize, 1, PbMpi_INT, dest, tag); - //comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - int nofChars = 0; - for(int i=0; i<stringVectorSize; i++) - nofChars += singleStringSizes[i] = (int)v[i].length(); - singleStringSizes[stringVectorSize] = nofChars; - - PbMpi::Send(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, dest, tag); - - std::vector<char> charVector(nofChars); - int pos = 0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - charVector[pos++] = v[i][j]; - - PbMpi::Send(comm, &charVector[0], nofChars, PbMpi_CHAR, dest, tag); - //comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); - } -} -/*======================================================================*/ -// send a vector of strings -void PbMpi::receiveStringVector(std::vector<std::string>& v, int source, int tag, PbMpi::Comm comm) -{ - // send size - int stringVectorSize; - PbMpi::Recv(comm, &stringVectorSize, 1, PbMpi_INT, source, tag); - //comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); - - v.clear(); - v.resize(stringVectorSize); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - - PbMpi::Recv(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, source, tag); - //comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); - - int nofChars = singleStringSizes[stringVectorSize]; - std::vector<char> charVector(nofChars); - - PbMpi::Recv(comm, &charVector[0], nofChars, PbMpi_CHAR, source, tag); - //comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); - - int pos=0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - v[i].push_back(charVector[pos++]); - } -} - -#endif //PbMpi_H diff --git a/ThirdParty/Library/basics/parallel/PbMpiTools.h b/ThirdParty/Library/basics/parallel/PbMpiTools.h deleted file mode 100644 index 0842c54b9dad7ca73f7e68613d802bc36c65d378..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/PbMpiTools.h +++ /dev/null @@ -1,303 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef PBMPITOOLS_H -#define PBMPITOOLS_H - -#include <vector> -#include <sstream> - -//#undef SEEK_SET -//#undef SEEK_CUR -//#undef SEEK_END -#include <mpi.h> -#include <basics/utilities/UbException.h> - -#ifdef USE_MPI_CXX_SYNTAX - -namespace PbMpiTools -{ - /*======================================================================*/ - // send a single value "value" of MPI_Datatype - template <class T> - inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives a single value "value" of MPI_Datatype - template <class T> - inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives and returns a single value of MPI_Datatype - // expample: int value = PbMpiTools::receiveSingleValue<int>(MPI::INT,0,10,comm); - template <class T> - inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline bool receiveBoolValue(int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline std::string receiveStringValue(int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a vector of MPI_Datatype - template <class T> - inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receive a std::vector of MPI_Datatype - template <class T> - inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receive a vector of MPI_Datatype and adds this vector to existing vector - // ans returns number of received elements - template <class T> - inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a std::vector of strings - inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a vector of strings - inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm); -}; - -/*======================================================================*/ -// send a single value of MPI_Datatype -template <class T> -void PbMpiTools::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm) -{ - try{ comm.Send(&value, 1, datatype, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } -} -/*======================================================================*/ -template <class T> -void PbMpiTools::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - try { comm.Recv(&value, 1, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } -} -/*======================================================================*/ -template <class T> -T PbMpiTools::receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - T value; - try { comm.Recv(&value, 1, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - return value; -} -/*======================================================================*/ -// send a bool value (bool doesn't work with template, why ever) -void PbMpiTools::sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm) -{ - short dummy; - if(value) dummy=1; - else dummy=0; - - try{ comm.Send(&dummy, 1, MPI::SHORT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } -} -/*======================================================================*/ -bool PbMpiTools::receiveBoolValue(int source, int tag, MPI::Intracomm comm) -{ - short dummy; - try { comm.Recv(&dummy, 1, MPI::SHORT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - return (dummy==1); -} -/*======================================================================*/ -// sends bool value (doesn't work with template, why ever... stupid MPI) -void PbMpiTools::sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm) -{ - std::vector<char> vec; - for(std::size_t i=0; i<value.size(); i++) - vec.push_back(value[i]); - PbMpiTools::sendVector(vec,MPI::CHAR,dest,tag,comm); -} - -/*======================================================================*/ -// receives bool value (doesn't work with template, why ever... stupid MPI) -std::string PbMpiTools::receiveStringValue(int source, int tag, MPI::Intracomm comm) -{ - std::vector<char> vec; - PbMpiTools::receiveVector(vec,MPI::CHAR,source,tag,comm); - std::string str; - for(std::size_t i=0; i<vec.size(); i++) - str+=vec[i]; - - return str; -} -/*======================================================================*/ -// send a vector of MPI_Datatype -template <class T> -void PbMpiTools::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm) -{ - // send size - int size = (int)v.size(); - - try{ comm.Send(&size, 1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - if(size>0) - { - try{ comm.Send(&v[0], size, datatype, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype -template <class T> -void PbMpiTools::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - int size; - - try { comm.Recv(&size, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - v.resize(size); - - if( size>0 ) - { - try{ comm.Recv(&v[0], size, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); } - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype and adds this vector to existing vector -// return value is size of received elements -template <class T> -int PbMpiTools::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - int incommingSize; - - try { comm.Recv(&incommingSize, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - int oldSize = (int)v.size(); - v.resize(oldSize+incommingSize); - - if( incommingSize>0 ) - { - try{ comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); } - } - - return incommingSize; -} -/*======================================================================*/ -// send a vector of strings -void PbMpiTools::sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm) -{ - // send size - int stringVectorSize = (int)v.size(); - - try{ comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - int nofChars = 0; - for(int i=0; i<stringVectorSize; i++) - nofChars += singleStringSizes[i] = (int)v[i].length(); - singleStringSizes[stringVectorSize] = nofChars; - - try{ comm.Send(&singleStringSizes[0], stringVectorSize+1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - std::vector<char> charVector(nofChars); - int pos = 0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - charVector[pos++] = v[i][j]; - - try{ comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - } -} -/*======================================================================*/ -// send a vector of strings -void PbMpiTools::receiveStringVector(std::vector<std::string>& v, int source, int tag, MPI::Intracomm comm) -{ - // send size - int stringVectorSize; - try { comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - v.clear(); - v.resize(stringVectorSize); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - - try{ comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - int nofChars = singleStringSizes[stringVectorSize]; - std::vector<char> charVector(nofChars); - - try{ comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - int pos=0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - v[i].push_back(charVector[pos++]); - } -} - -#endif - -#endif //PBMPITOOLS_H diff --git a/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt b/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt deleted file mode 100644 index 2c93dee4f1f17b3084223e50c1f1628f2878e4df..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -INCLUDE("../../../../CMakeCABMacros.txt") -INCLUDE("../../../../CMakeSetCompilerFlags.txt") - -CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN") -SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake") - -PROJECT(simpleMPI) - -#erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben) -INCLUDE(${CMAKE_CONFIG_FILE}) - -SET(EXECUTABLE_NAME simpleMPI) - -################################################################ -## PACKAGES ### -################################################################ -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/parallel/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -SET(ALL_SOURCES ${ALL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) - -SOURCE_GROUP(main FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) - -ADD_CXX_FLAGS("/wd4996") #deprecated strcpy... - -################################################################# -### MPI ### -################################################################# -SET_MPI_STUFF(CAB_MACHINE) -SET(EXECUTABLE_NAME ${EXECUTABLE_NAME}_mpi) - -################################################################# -### EXCECUTABLE ### -################################################################# -ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} ) - -################################################################# -### ADDITIONAL LINK LIBRARIES ### -################################################################# -IF(ADDITIONAL_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${ADDITIONAL_LINK_LIBRARIES}) -ENDIF(ADDITIONAL_LINK_LIBRARIES) - -################################################################# -### ADDITIONAL LINK PROPERTIES ### -################################################################# -IF(ADDITIONAL_LINK_PROPS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${ADDITIONAL_LINK_PROPS}) -ENDIF(ADDITIONAL_LINK_PROPS) -IF(ADDITIONAL_LINK_PROPS_DEBUG) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_DEBUG ${ADDITIONAL_LINK_PROPS_DEBUG}) -ENDIF(ADDITIONAL_LINK_PROPS_DEBUG) -IF(ADDITIONAL_LINK_PROPS_RELEASE) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_RELEASE ${ADDITIONAL_LINK_PROPS_RELEASE}) -ENDIF(ADDITIONAL_LINK_PROPS_RELEASE) - - - diff --git a/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h b/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h deleted file mode 100644 index 3977c69e00299b64773cb0ff16dc4ed536c37ca6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h +++ /dev/null @@ -1,193 +0,0 @@ -#include <iostream> -#include <stdlib.h> -#include <stdio.h> -#include <string> -#include <fstream> - -#include <basics/utilities/UbTuple.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbTiming.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -using std::cout; -using std::cerr; -using std::endl; -using std::vector; - -typedef long double value_type; -typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr; -typedef MbSmartPtr<vector< value_type > > StlVectorPtr; - -/*==========================================================*/ -template<typename T> -inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("setValues - sizeCheck failed") ); - } - static value_type stlVal = 1; - static value_type cbVal = 1; - static value_type cbPoolVal = 1; - - for(size_t i=0; i<cbvec.size(); i++) stlvec[i] = stlVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbvec[i] = cbVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++; -} -/*==========================================================*/ -template<typename T> -inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("setValues glob - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val) -{ - stlvec.resize(size,val); - cbvec.resize(size,val); - cbpoolvec.resize(size,val); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("resize glob - sizeCheck failed") ); - } - - if(timed) - { - UbTimer timer; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val); if(timed) cout<<"stl-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val); if(timed) cout<<"cbStd-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl; - } - else - { - for(size_t i=0; i<cbvecs.size(); i++) - resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val); - } -} -/*==========================================================*/ -template<typename T> -inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool)))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; - - for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back()); -} -/*==========================================================*/ -template<typename T> -inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; -} -/*==========================================================*/ -template<typename T> -inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - bool check=true; - for(size_t i=0; i<cbvec.size(); i++) - if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i] ) - check=false; - - if(!check) - { - cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" "; cout<<endl; - cerr<< "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" "; cout<<endl; - cerr<< "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl; - throw UB_THROW( UbException("equalCheck - equalCheck failed") ); - } -} -/*==========================================================*/ -template<typename T> -void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - { - //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1; - equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); - //cout<<" passed"<<endl; - } -} -/*==========================================================*/ -template<typename T> -void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - UbTimer timer; - timer.start(); - for(size_t i=0; i<stlvecs.size(); i++) - { - vector<value_type>& vec = *stlvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"stl-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbvecs.size(); i++) - { - CbVector<value_type>& vec = *cbvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbStd-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbpoolvecs.size(); i++) - { - CbVector<value_type>& vec = *cbpoolvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbPool-accessCheck in "<<timer.stop()<<"s"<<endl; -} diff --git a/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp b/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp deleted file mode 100644 index 5ff9dfcbfd4d458d1bfac99df9bf7fea0a4f2374..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include <iostream> -#include <vector> -#include <algorithm> -#include <mpi.h> - -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -int randomNumber () { return (rand()%100); } - -struct RankSetter{ - RankSetter(int rank) : rank(rank) {} - - int operator()() - { - return rank; - } - - int rank; -} /*rankSetter*/; - - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char** argv) -{ - MPI::Init(argc, argv); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - - try - { - MPI::Intracomm comm = MPI::COMM_WORLD; - - int rank = comm.Get_rank(); - - vector<int> sendData(1000,0); - generate(sendData.begin(), sendData.end(), RankSetter(rank+1) ); - - vector<int> recvData(1000,0); - - if(rank==0) - { - UBLOG(logINFO,"rank="<<rank<<" - recv request"); - MPI::Request request = comm.Irecv(&recvData[0], (int)recvData.size(), MPI::INT, 1, 100); - UBLOG(logINFO,"rank="<<rank<<" - sendData"); - comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 1, 100); - sendData.back() = 999; - - UBLOG(logINFO,"rank="<<rank<<" - Wait"); - request.Wait(); - UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back()); - } - else if(rank == 1) - { - UbSystem::sleepS(5); - UBLOG(logINFO,"rank="<<rank<<" - recv request"); - MPI::Request request = comm.Irecv(&recvData[0],(int)recvData.size(), MPI::INT, 0, 100); - - request.Wait(); - UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back()); - - UbSystem::sleepS(5); - UBLOG(logINFO,"rank="<<rank<<" - sendData"); - comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 0, 100); - sendData.back() = 999; - UBLOG(logINFO,"rank="<<rank<<" - data sent"); - } - else - { - throw UB_THROW( UbException(UB_EXARGS,"only two ranks allwoed") ); - } - - UBLOG(logINFO,"rank="<<rank<<" barrier start"); - MPI::COMM_WORLD.Barrier(); - UBLOG(logINFO,"rank="<<rank<<" barrier done "); - - } - catch(const std::exception& e) - { - UBLOG2( logERROR,std::cerr, "caught exception:" ); - UBLOG2( logERROR,std::cerr, "type: " << typeid(e).name() ); - UBLOG2ML(logERROR,std::cerr, "what: " << e.what() ); - } - catch(MPI::Exception e) - { - UBLOG2ML(logERROR,std::cerr, "caught exception:" << e.Get_error_string()); - - MPI::COMM_WORLD.Abort(99); - } - catch(...) - { - UBLOG2(logERROR,std::cerr,"Verdammte Scheisse - mal wieder Mist gebaut!"); - } - - MPI::Finalize(); - - return 0; -} - diff --git a/ThirdParty/Library/basics/relation/CMakePackage.txt b/ThirdParty/Library/basics/relation/CMakePackage.txt deleted file mode 100644 index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/relation/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/ThirdParty/Library/basics/relation/RbAggregation.h b/ThirdParty/Library/basics/relation/RbAggregation.h deleted file mode 100644 index 409336c9ec9f2d4ec31e5151c61bf7afe08fabd8..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/relation/RbAggregation.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef RBAGGREGATION_H -#define RBAGGREGATION_H - -#include <sstream> -#include <iostream> -#include <map> - -using namespace std; - -template <class T1, class T2> -class RbAggregation -{ -private: - string name; - std::multimap<T1,T2> obj1Map; - std::multimap<T2,T1> obj2Map; - -public: - RbAggregation(string name) - { - this->name = name; - } - /*=========================================================================*/ - void insertPair(T1& to1, T2& to2) - { - obj1Map.insert(pair<T1,T2>(to1,to2)); - obj2Map.insert(pair<T2,T1>(to2,to1)); - } - /*=========================================================================*/ - int countObj2forObj1(T1& to1) - { - return((int)obj1Map.count(to1)); - } - - /*=========================================================================*/ - int countObj1forObj2(T2& to2) - { - return((int)obj2Map.count(to2)); - } - /*=========================================================================*/ - vector<T2> getObj2vectorForObj1(T1& to1) - { - vector<T2> obj2vector; - unsigned number = (unsigned)obj1Map.count(to1); - typedef std::multimap<T1, T2>::iterator obj1MapIterator = obj1Map.find(to1); - for(unsigned u =0; u<number; u++) - { - obj2vector.push_back(obj1MapIterator->second); - obj1MapIterator++; - } - return obj2vector; - } - ///*=========================================================================*/ - vector<T1> getObj1vectorForObj2(T2& to2) - { - vector<T1> obj1vector; - unsigned number = (unsigned)obj2Map.count(to2); - typedef std::multimap<T2, T1>::iterator obj2MapIterator = obj2Map.find(to2); - for(unsigned u =0; u<number; u++) - { - obj1vector.push_back(obj2MapIterator->second); - obj2MapIterator++; - } - return obj1vector; - } -}; -/*=========================================================================*/ -#endif - - diff --git a/ThirdParty/Library/basics/transmitter/CMakePackage.txt b/ThirdParty/Library/basics/transmitter/CMakePackage.txt deleted file mode 100644 index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) \ No newline at end of file diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitter.h b/ThirdParty/Library/basics/transmitter/TbTransmitter.h deleted file mode 100644 index 9560e8a771c5c4892579aa38d119bca67c45a354..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitter.h +++ /dev/null @@ -1,69 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTER_H -#define TBTRANSMITTER_H - -#include <string> - -/*================================================================================*/ -/* TbTransmitter */ -/* */ -/** -This Class provides the base for sending and receiving of data. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -////////////////////////////////////////////////////////////////////////// -// Transmitter -// macht nichts ausser daten senden und empfangen -template<typename T> -class TbTransmitter -{ -public: - typedef T value_type; - -public: - TbTransmitter() {} - virtual ~TbTransmitter() { /*std::cout<<typeid(*this).name()<<" dtor"<<std::endl;*/ } - - virtual bool isLocalTransmitter() const = 0; - virtual bool isRemoteTransmitter() const = 0; - - //preprocess (e.g. synchronizing send-/receive-buffer) - virtual void sendDataSize() = 0; - virtual void receiveDataSize()= 0; - - //calculation - virtual void prepareForSend() {} - virtual void sendData()=0; - virtual void prepareForReceive() {} - virtual value_type& receiveData()=0; - virtual void saveData() {} - - //data-access - inline value_type& getData() { return this->data; } - inline const value_type& getData() const { return this->data; } - - //info-section (usable for remote transmitter) - virtual int getSendToRank() const { return -1; } - virtual int getSendToTag() const { return -1; } - virtual int getRecvFromRank() const { return -1; } - virtual int getRecvFromTag() const { return -1; } - - virtual std::string toString() const = 0; - -protected: - value_type data; -}; - -#endif //TBTRANSMITTER_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h b/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h deleted file mode 100644 index 981f880c143d4ed614dfc8cc2c20e6684de91f8a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h +++ /dev/null @@ -1,130 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TOTRANSMITTERLOCAL_H -#define TOTRANSMITTERLOCAL_H - -#include <basics/utilities/UbException.h> -#include <basics/transmitter/TbTransmitter.h> - -#include <boost/shared_ptr.hpp> - -/*================================================================================*/ -/* TbLocalTransmitter, TbVectorSenderLocal, TbVectorReceiverLocal */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -////////////////////////////////////////////////////////////////////////// -// LocalTransmitter lokalen Datenaustausch -// data = send- und zugleich receive-buffer -template<typename T> -class TbLocalTransmitter : public TbTransmitter<T> -{ -public: - typedef boost::shared_ptr< TbLocalTransmitter<T> > TbLocalTransmitterPtr; - - typedef T value_type; - -public: - TbLocalTransmitter() : TbTransmitter<T>() - { - - } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() { } - //reiceive braucht nichts machen, da send==receive buffer ;-) - void receiveDataSize() { } - - void sendData() { } - value_type& receiveData() { return this->data; } - - std::string toString() const { return "TbLocalTransmitter"+(std::string)typeid(T).name(); } -}; - -////////////////////////////////////////////////////////////////////////// -// TbVectorSender/ReceiverLocal lokalen Datenaustausch ueber ZWEI vektoren -template<typename T> -class TbVectorReceiverLocal : public TbTransmitter<T> -{ -public: - typedef T value_type; - -public: - TbVectorReceiverLocal() : TbTransmitter<value_type>() - { - - } - //virtual ~TbVectorReceiverLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl; } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); } - //reiceive braucht nichts machen, das macht der sender :-) - void receiveDataSize() { } - - void sendData() { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); } - value_type& receiveData() { return this->data; } - - std::string toString() const { return "TbVectorReceiverLocal<"+(std::string)typeid(T).name()+">"; } -}; - -template<typename T> -class TbVectorSenderLocal : public TbTransmitter<T> -{ -public: - typedef T value_type; - -public: - TbVectorSenderLocal(boost::shared_ptr< TbVectorReceiverLocal< value_type > > receiver) - : TbTransmitter< value_type >(), receiver(receiver) - { - - } - //virtual ~TbVectorSenderLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl; } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() - { - assert(receiver!=NULL); - receiver->getData().resize( this->data.size() ); - } - //reiceive braucht nichts machen, da send==receive buffer ;-) - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } - - void sendData() - { - assert( this->data.size() == receiver->getData().size() ); - receiver->getData() = this->data; -// for(int i=(int)this->data.size()-1; i>=0; --i) -// receiver->getData()[i]= this->data[i]; - } - value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } - - std::string toString() const { return "TbVectorSenderLocal<"+(std::string)typeid(T).name()+">"; } - -protected: - boost::shared_ptr< TbVectorReceiverLocal< value_type > > receiver; -}; - -#endif //TOTRANSMITTERLOCAL_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpi.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpi.h deleted file mode 100644 index 16d5f8c7f986b9b6832f999be80f6ee5dc81aa76..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpi.h +++ /dev/null @@ -1,237 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPI_H -#define TBTRANSMITTERMPI_H - -#ifdef VF_MPI - -/*=========================================================================*/ -/* MPI Transmitter */ -/* */ -/** -This Class provides the base for exception handling. -Old TbTransmitter was renamed in TbTransmitterCPPB (C++ binding in MPI is deprecated) -Rewrite from K. Kucher with C binding -<BR><BR> -@author <A HREF="mailto:kucher@irmb.tu-bs.de">K. Kucher</A> -@version 1.0 - 21.11.11 -*/ - -/* -usage: ... -*/ - -#include <iostream> -#include <mpi.h> -#include <basics/transmitter/TbTransmitter.h> - - -////////////////////////////////////////////////////////////////////////// -// TbVectorSenderMpiUnblocked -template< typename Vector > -class TbVectorSenderMpiUnblocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorSenderMpiUnblocked(const int& sendTbRank, const int& sendTag, MPI_Comm comm) - : comm(comm), request(MPI_REQUEST_NULL), sendTbRank(sendTbRank), sendTag(sendTag), dataSize(0) - { - //temporaeren vector erstellen um den datentyp zu ermittlen - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for type="+(std::string)typeid(typename Vector::value_type).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() - { - dataSize = (unsigned int)this->getData().size(); - //MPI_Isend(&dataSize, 1, MPI_UNSIGNED, sendTbRank, sendTag, comm, &request); - MPI_Send(&dataSize, 1, MPI_UNSIGNED, sendTbRank, sendTag, comm); - } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - void prepareForSend() { if(request!=MPI_REQUEST_NULL) MPI_Wait(&request, &status); } - void sendData() { MPI_Isend(&this->getData()[0],(int)this->getData().size(), mpiDataType, sendTbRank, sendTag, comm, &request); } - - void prepareForReceive() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - Vector& receiveData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return sendTbRank; } - int getSendTbTag() const { return sendTag; } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - std::string toString() const { return "TbVectorSenderMpiUnblocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(sendTbRank)+"("+UbSystem::toString(sendTag)+")"; } - -protected: - MPI_Comm comm; - MPI_Request request; - MPI_Datatype mpiDataType; - MPI_Status status; - int sendTbRank, sendTag; - unsigned dataSize; -}; - - -////////////////////////////////////////////////////////////////////////// -// TbVectorSenderMpiBlocked -template< typename Vector > -class TbVectorSenderMpiBlocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorSenderMpiBlocked(const int& sendTbRank, const int& sendTag, MPI_Comm comm) - : comm(comm), request(MPI_REQUEST_NULL), sendTbRank(sendTbRank), sendTag(sendTag), dataSize(0) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector"+(std::string)typeid(Vector).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() - { - dataSize = (unsigned int)this->getData().size(); - MPI_Isend(&dataSize, 1, MPI_UNSIGNED, sendTbRank, sendTag, comm, &request); - } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - void sendData() { MPI_Wait(&request, &status); MPI_Send(&this->getData()[0],(int)this->getData().size(), mpiDataType, sendTbRank, sendTag, comm); } - - void prepareForReceive() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return sendTbRank; } - int getSendTbTag() const { return sendTag; } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - std::string toString() const { return "TbVectorSenderMpiBlocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(sendTbRank)+"("+UbSystem::toString(sendTag)+")"; } - -protected: - MPI_Comm comm; - MPI_Request request; - MPI_Datatype mpiDataType; - MPI_Status status; - int sendTbRank, sendTag; - unsigned dataSize; -}; - -////////////////////////////////////////////////////////////////////////// -// TbVectorReceiverMpiUnblocked -template<typename Vector > -class TbVectorReceiverMpiUnblocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorReceiverMpiUnblocked(const int& receiveFromRank, const int& receiveTag, MPI_Comm comm) - : comm(comm), request(MPI_REQUEST_NULL), receiveFromRank(receiveFromRank), receiveTag(receiveTag) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector"+(std::string)typeid(Vector).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - void receiveDataSize() - { - unsigned dataSize; - MPI_Recv(&dataSize, 1, MPI_UNSIGNED, receiveFromRank, receiveTag, comm, &status); - this->getData().resize(dataSize,0.0); - } - void sendData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - - void prepareForReceive() { MPI_Irecv(&this->getData()[0],(int)this->getData().size(), mpiDataType, receiveFromRank, receiveTag, comm, &request); } - Vector& receiveData() { MPI_Wait(&request, &status); return this->getData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getSendTbTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getRecvFromRank() const { return receiveFromRank; } - int getRecvFromTag() const { return receiveTag; } - - std::string toString() const { return "TbVectorReceiverMpiUnblocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(receiveFromRank)+"("+UbSystem::toString(receiveTag)+")"; } - -protected: - MPI_Comm comm; - MPI_Request request; - MPI_Datatype mpiDataType; - MPI_Status status; - int receiveFromRank, receiveTag; -}; - - -////////////////////////////////////////////////////////////////////////// -template<typename Vector> -class TbVectorReceiverMpiBlocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorReceiverMpiBlocked(const int& receiveFromRank, const int& receiveTag, MPI_Comm comm) - : comm(comm), request(MPI_REQUEST_NULL), receiveFromRank(receiveFromRank), receiveTag(receiveTag) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector+(std::string)typeid(Vector).name()") ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - void receiveDataSize() - { - unsigned dataSize; - MPI_Recv(&dataSize, 1, MPI_UNSIGNED, receiveFromRank, receiveTag, comm, &status); - this->getData().resize(dataSize,0.0); - } - void sendData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - Vector& receiveData() - { - MPI_Recv(&this->getData()[0],(int)this->getData().size(), mpiDataType, receiveFromRank, receiveTag, comm, &status); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getSendTbTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getRecvFromRank() const { return receiveFromRank; } - int getRecvFromTag() const { return receiveTag; } - - std::string toString() const { return "TbVectorReceiverMpiBlocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(receiveFromRank)+"("+UbSystem::toString(receiveTag)+")"; } - -protected: - MPI_Comm comm; - MPI_Request request; - MPI_Datatype mpiDataType; - MPI_Status status; - int receiveFromRank, receiveTag; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPI_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiCPPB.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpiCPPB.h deleted file mode 100644 index 1a08a867cb24be0dbbace7570756a5283daf953b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiCPPB.h +++ /dev/null @@ -1,230 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPICPPB_H -#define TBTRANSMITTERMPICPPB_H - -#ifdef VF_MPI - -/*=========================================================================*/ -/* MPI Transmitter */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -#include <iostream> -#include <mpi.h> -#include <basics/transmitter/TbTransmitter.h> - - -////////////////////////////////////////////////////////////////////////// -// TbVectorSenderMpiUnblocked -template< typename Vector > -class TbVectorSenderMpiUnblocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorSenderMpiUnblocked(const int& sendTbRank, const int& sendTag, MPI::Intracomm comm) - : comm(comm), request(MPI::REQUEST_NULL), sendTbRank(sendTbRank), sendTag(sendTag), dataSize(0) - { - //temporaeren vector erstellen um den datentyp zu ermittlen - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI::DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI::FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI::INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for type="+(std::string)typeid(typename Vector::value_type).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() - { - dataSize = (unsigned int)this->getData().size(); - request = comm.Isend(&dataSize, 1, MPI::UNSIGNED, sendTbRank, sendTag); - } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - void prepareForSend() { if(request!=MPI::REQUEST_NULL) request.Wait(); } - void sendData() { request = comm.Isend(&this->getData()[0],(int)this->getData().size(), mpiDataType, sendTbRank, sendTag); } - - void prepareForReceive() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - Vector& receiveData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return sendTbRank; } - int getSendTbTag() const { return sendTag; } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - std::string toString() const { return "TbVectorSenderMpiUnblocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(sendTbRank)+"("+UbSystem::toString(sendTag)+")"; } - -protected: - MPI::Intracomm comm; - MPI::Request request; - MPI::Datatype mpiDataType; - int sendTbRank, sendTag; - unsigned dataSize; -}; - - -////////////////////////////////////////////////////////////////////////// -// TbVectorSenderMpiBlocked -template< typename Vector > -class TbVectorSenderMpiBlocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorSenderMpiBlocked(const int& sendTbRank, const int& sendTag, MPI::Intracomm comm) - : comm(comm), request(MPI::REQUEST_NULL), sendTbRank(sendTbRank), sendTag(sendTag), dataSize(0) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI::DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI::FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI::INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector"+(std::string)typeid(Vector).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() - { - dataSize = (unsigned int)this->getData().size(); - request = comm.Isend(&dataSize, 1, MPI::UNSIGNED, sendTbRank, sendTag); - } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - void sendData() { request.Wait(); comm.Send(&this->getData()[0],(int)this->getData().size(), mpiDataType, sendTbRank, sendTag); } - - void prepareForReceive() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return sendTbRank; } - int getSendTbTag() const { return sendTag; } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorSender sends only") ); } - - std::string toString() const { return "TbVectorSenderMpiBlocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(sendTbRank)+"("+UbSystem::toString(sendTag)+")"; } - -protected: - MPI::Intracomm comm; - MPI::Request request; - MPI::Datatype mpiDataType; - int sendTbRank, sendTag; - unsigned dataSize; -}; - -////////////////////////////////////////////////////////////////////////// -// TbVectorReceiverMpiUnblocked -template<typename Vector > -class TbVectorReceiverMpiUnblocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorReceiverMpiUnblocked(const int& receiveFromRank, const int& receiveTag, MPI::Intracomm comm) - : comm(comm), request(MPI::REQUEST_NULL), receiveFromRank(receiveFromRank), receiveTag(receiveTag) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI::DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI::FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI::INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector"+(std::string)typeid(Vector).name()) ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - void receiveDataSize() - { - unsigned dataSize; - comm.Recv(&dataSize, 1, MPI::UNSIGNED, receiveFromRank, receiveTag); - this->getData().resize(dataSize,0.0); - } - void sendData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - - void prepareForReceive() { request = comm.Irecv(&this->getData()[0],(int)this->getData().size(), mpiDataType, receiveFromRank, receiveTag); } - Vector& receiveData() { request.Wait(); return this->getData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getSendTbTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getRecvFromRank() const { return receiveFromRank; } - int getRecvFromTag() const { return receiveTag; } - - std::string toString() const { return "TbVectorReceiverMpiUnblocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(receiveFromRank)+"("+UbSystem::toString(receiveTag)+")"; } - -protected: - MPI::Intracomm comm; - MPI::Request request; - MPI::Datatype mpiDataType; - int receiveFromRank, receiveTag; -}; - - -////////////////////////////////////////////////////////////////////////// -template<typename Vector> -class TbVectorReceiverMpiBlocked : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - -public: - TbVectorReceiverMpiBlocked(const int& receiveFromRank, const int& receiveTag, MPI::Intracomm comm) - : comm(comm), request(MPI::REQUEST_NULL), receiveFromRank(receiveFromRank), receiveTag(receiveTag) - { - if ( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI::DOUBLE; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI::FLOAT; - else if( (std::string)typeid(typename Vector::value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI::INT; - else UB_THROW( UbException(UB_EXARGS,"no MpiDataType for Vector+(std::string)typeid(Vector).name()") ); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - void receiveDataSize() - { - unsigned dataSize; - comm.Recv(&dataSize, 1, MPI::UNSIGNED, receiveFromRank, receiveTag); - this->getData().resize(dataSize,0.0); - } - void sendData() { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - Vector& receiveData() - { - comm.Recv(&this->getData()[0],(int)this->getData().size(), mpiDataType, receiveFromRank, receiveTag); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getSendTbTag() const { UB_THROW( UbException(UB_EXARGS,"MPIVectorReceiver receives only") ); } - int getRecvFromRank() const { return receiveFromRank; } - int getRecvFromTag() const { return receiveTag; } - - std::string toString() const { return "TbVectorReceiverMpiBlocked<"+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name()+"> > to rank (tag)"+UbSystem::toString(receiveFromRank)+"("+UbSystem::toString(receiveTag)+")"; } - -protected: - MPI::Intracomm comm; - MPI::Request request; - MPI::Datatype mpiDataType; - int receiveFromRank, receiveTag; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPI_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h deleted file mode 100644 index dd406ac49c4c49bd5245ea5a483bffb40fbbf75b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h +++ /dev/null @@ -1,510 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPIPOOL_H -#define TBTRANSMITTERMPIPOOL_H - -#ifdef VF_MPI - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> - -#include <mpi.h> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -#include <boost/shared_ptr.hpp> - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//TbCbVectorMpiPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im TbMpiVectorPool verwaltet -//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class TbCbVectorSenderMpiPool; -template<typename T> class TbCbVectorReceiverMpiPool; - -/*==================================================================*/ -template<typename T> -class TbCbVectorMpiPool : public CbVectorPool<T> -{ -public: - typedef boost::shared_ptr< TbCbVectorMpiPool< T > > MpiPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map<unsigned int, MpiPoolPtr > MpiPoolPtrMap; - typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef unsigned int CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class TbCbVectorSenderMpiPool< T >; - friend class TbCbVectorReceiverMpiPool< T >; - -protected: - ////////////////////////////////////////////////////////////////////////// - static MpiPoolPtrMap poolMap; -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createTbCbVectorMpiPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // mpiRemoteRank: mpi-rank des Empfaengers/Senders - // mpiTag : mpi-tag mit dem empfangen/gesendet wird - static MpiPoolPtr createTbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!"); - } - - //pool erstellen - MpiPoolPtr mpiPool(new TbCbVectorMpiPool<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); - - //pool "speichern" - TbCbVectorMpiPool< value_type >::poolMap[poolKey] = mpiPool; - - return mpiPool; - } - static void deleteTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it = TbCbVectorMpiPool< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden"); - } - TbCbVectorMpiPool< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static MpiPoolPtr getTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it; - if( (it=TbCbVectorMpiPool< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool< T >::poolMap.end() ) - { - return it->second; - } - return MpiPoolPtr(); - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"TbCbVectorMpiPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static void eraseMap() - { - poolMap.clear(); - } -protected: - ////////////////////////////////////////////////////////////////////////// - TbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI_REQUEST_NULL) - , sendRequest(MPI_REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - } - -public: - /*==================================================================*/ - //returns key of Pool in MpiPoolMap - CbVectorKey getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->mpiRemoteRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->mpiTag; } - -protected: - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den - //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los- - //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den - //vorgang abgeschlossen hat!!! -> tmpOrderVec ist class-member!!! - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements); - unsigned index = 0; - tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - if(this->nextCbVectorStartIndexInPool != this->pool.size()) throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!"); - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - CbVectorKey vectorKey=0; - size_type dataSize=0, startIndexInPool=0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!"); - - tmpSendOrderVec[index++] = (unsigned)vectorKey; //vectorKey == allocator.getAllocatorKey() - tmpSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - tmpSendOrderVec[index++] = (unsigned)dataSize; //dataSize - } - MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest); - - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - //receiveRequest.Wait(); - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - std::vector< unsigned > tmpRecvOrderVec; - tmpRecvOrderVec.resize(nofElements); - - //MPI_Status status; - MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); - - if(nofElements!=(unsigned)tmpRecvOrderVec.size()) - throw UbException(UB_EXARGS,"error... vec size stimmt nicht"); - - unsigned index = 0; - this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors - this->pool.resize(this->nextCbVectorStartIndexInPool); - CbVectorMapIter it = this->cbVectorMap.begin(); - for(/*index*/; index<nofElements; index+=3, ++it) - { - CbVectorKey vectorKey = (CbVectorKey)tmpRecvOrderVec.at(index ); - size_type startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1); - size_type dataSize = (size_type)tmpRecvOrderVec.at(index+2); - - //if(it==this->cbVectorMap.end() || it->first != vectorKey ) - //throw UbException(UB_EXARGS, "entweder hat map nicht die gleiche reihenfolge oder vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden"); - if (it==this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"map ist leer"); - else if (it->first != vectorKey) - throw UbException(UB_EXARGS, "vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden it->first =" + UbSystem::toString(it->first)); - - this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - } - if(it!=this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt..."); - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void prepareForSendData() - { - //da sendDataOrder einen request verwendet muss man hier immer abfragen - if(counterPrepareForSend==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - - - //A - non blocking - ////der ERSTE is entscheidend - ////Grund: wenn man - //// for(all trans) { trans->prepare(); trans->fillBuffer(); } - //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!! - //counterPrepareForSend++; - //if(counterPrepareForSend==1) - //{ - // if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait(); - //} - // - //if(counterPrepareForSend==nofStoredVectors) - // counterPrepareForSend=0; - } - /*==================================================================*/ - void sendData() - { - //A - non blocking - //der LETZTE is entscheidend - //counterSend++; - //if(counterSend==nofStoredVectors) - //{ - // //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - // sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - // counterSend=0; - //} - //B - blocking - //der LETZTE is entscheidend - counterSend++; - if(counterSend==nofStoredVectors) - { - //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - //synchronous send - //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - - //standard send - MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -//////////////////////////////////////////////////////////////////////////////////////////// -//DEBUG/////////////////////////////////////// - //int irank; - //MPI_Comm_rank(MPI_COMM_WORLD, &irank); - //std::cout << "MPI_Send: " << irank << " " << mpiRemoteRank << " " <<mpiTag<<std::endl; -/////////////////////////////////////////////////// - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - //A - non blocking - //sobald der Letzte kann man den den request holen. - //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!! - counterPrepareForReceive++; - if(counterPrepareForReceive==this->nofStoredVectors) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - counterPrepareForReceive=0; - } - } - /*==================================================================*/ - void receiveData() - { - //A - non blocking - //sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - //denn erst anschliessend stehen die empfangenen daten zur verfuegung - if(counterReceive==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - counterReceive++; - if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - { - counterReceive=0; - } - - ////B - blocking - ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - ////denn erst anschliessend stehen die empfangenen daten zur verfuegung - //if(counterReceive==0) - //{ - // comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - //} - //counterReceive++; - //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - // counterReceive=0; - } - -protected: - CbVectorKey poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterPrepareForSend; - size_type counterSend; - - std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt - - MPI_Comm comm; - MPI_Request receiveRequest; - MPI_Request sendRequest; - //MPI_Status sendStatus; - //MPI_Status receiveStatus; - MPI_Datatype mpiDataType; - - int mpiRemoteRank, mpiTag; - -#ifdef _DEBUG - T* orgPoolVectorStartPointer; -#endif -}; - -template<typename T> -typename TbCbVectorMpiPool<T>::MpiPoolPtrMap TbCbVectorMpiPool<T>::poolMap; - -////////////////////////////////////////////////////////////////////////// -// TbSenderMpiPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class TbCbVectorSenderMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorSenderMpiPool(unsigned int cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) ); - } - ~TbCbVectorSenderMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->mpiVectorPool->sendDataOrder(); } - void receiveDataSize() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - void prepareForSend() { this->mpiVectorPool->prepareForSendData(); } - void sendData() { this->mpiVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getSendTbTag() const { return this->mpiVectorPool->getRemoteTag(); } - int getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - int getRecvFromTag() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - - std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - - -/*==================================================================*/ -template<typename T> -class TbCbVectorReceiverMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorReceiverMpiPool(unsigned int cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) ); - } - ~TbCbVectorReceiverMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void receiveDataSize() { this->mpiVectorPool->receiveDataOrder(); } - void sendData() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() - { - this->mpiVectorPool->receiveData(); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getSendTbTag() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getRecvFromRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->mpiVectorPool->getRemoteTag(); } - - std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPIPOOL_H - diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool2.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool2.h deleted file mode 100644 index e09d9f4c295be8f1e95ed84eea90389f7fe22f98..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool2.h +++ /dev/null @@ -1,453 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPIPOOL2_H -#define TBTRANSMITTERMPIPOOL2_H - -#ifdef VF_MPI - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> - -#include <mpi.h> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//TbCbVectorMpiPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im TbMpiVectorPool verwaltet -//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class TbCbVectorSenderMpiPool2; -template<typename T> class TbCbVectorReceiverMpiPool2; - -/*==================================================================*/ -template<typename T> -class TbCbVectorMpiPool2 : public CbVectorPool<T> -{ -public: - typedef boost::shared_ptr< TbCbVectorMpiPool2< T > > MpiPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map< int, MpiPoolPtr > MpiPoolPtrMap; - typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef unsigned CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class TbCbVectorSenderMpiPool2< T >; - friend class TbCbVectorReceiverMpiPool2< T >; - -protected: - ////////////////////////////////////////////////////////////////////////// - static MpiPoolPtrMap poolMap; -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createTbCbVectorMpiPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // mpiRemoteRank: mpi-rank des Empfaengers/Senders - // mpiTag : mpi-tag mit dem empfangen/gesendet wird -static MpiPoolPtr createTbCbVectorMpiPool(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI_Comm comm, const size_type& startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!"); - } - //pool erstellen - MpiPoolPtr mpiPool(new TbCbVectorMpiPool2<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); - - //pool "speichern" - TbCbVectorMpiPool2< value_type >::poolMap[poolKey] = mpiPool; - - return mpiPool; - } - static void deleteTbCbVectorMpiPool(const int& poolKey) - { - MpiPoolPtrMapIter it = TbCbVectorMpiPool2< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden"); - } - TbCbVectorMpiPool2< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static MpiPoolPtr getTbCbVectorMpiPool(const int& poolKey) - { - MpiPoolPtrMapIter it; - if( (it=TbCbVectorMpiPool2< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool2< T >::poolMap.end() ) - { - return it->second; - } - return MpiPoolPtr(); - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"TbCbVectorMpiPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - - return true; - } - -protected: - ////////////////////////////////////////////////////////////////////////// -TbCbVectorMpiPool2(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI_Comm comm, const size_type& startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI_REQUEST_NULL) - , sendRequest(MPI_REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - } - -public: - /*==================================================================*/ - //returns key of Pool in MpiPoolMap - int getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->mpiRemoteRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->mpiTag; } - -protected: - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den - //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los- - //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den - //vorgang abgeschlossen hat!!! -> tmpOrderVec ist class-member!!! - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements); - unsigned index = 0; - tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - if(this->nextCbVectorStartIndexInPool != this->pool.size()) throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!"); - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - CbVectorKey vectorKey=0; - size_type dataSize=0, startIndexInPool=0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!"); - - tmpSendOrderVec[index++] = (unsigned)vectorKey; //vectorKey == allocator.getAllocatorKey() - tmpSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - tmpSendOrderVec[index++] = (unsigned)dataSize; //dataSize - } - - MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest); - - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - std::vector< unsigned > tmpRecvOrderVec; - tmpRecvOrderVec.resize(nofElements); - - MPI_Irecv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &receiveRequest); - //MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - - //if(nofElements!=(unsigned)tmpRecvOrderVec.size()) - // throw UbException(UB_EXARGS,"error... vec size stimmt nicht"); - - //unsigned index = 0; - //this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors - //this->pool.resize(this->nextCbVectorStartIndexInPool); - //CbVectorMapIter it = this->cbVectorMap.begin(); - //for(/*index*/; index<nofElements; index+=3, ++it) - //{ - // CbVectorKey vectorKey = (CbVectorKey)tmpRecvOrderVec.at(index ); - // size_type startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1); - // size_type dataSize = (size_type)tmpRecvOrderVec.at(index+2); - - // if(it==this->cbVectorMap.end() || it->first != vectorKey ) - // throw UbException(UB_EXARGS,"entweder hat map nicht die gleiche reihenfolge oder vectorKey nicht vorhanden"); - - // this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - //} - //if(it!=this->cbVectorMap.end()) - // throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt..."); - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - ////////////////////////////////////////////////////////////////////////// - void saveDataOrder() - { - if(counterPrepareForSend==0) - { - if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - } - /*==================================================================*/ - void prepareForSendData() - { - //da sendDataOrder einen request verwendet muss man hier immer abfragen - if(counterPrepareForSend==0) - { - if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - - } - /*==================================================================*/ - void sendData() - { - //A - non blocking - //der LETZTE is entscheidend - counterSend++; - if(counterSend==nofStoredVectors) - { -#ifdef DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - MPI_Isend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &sendRequest); -//////////////////////////////////////////////////////////////////////////////////////////// - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - - } - /*==================================================================*/ - void receiveData() - { - //A - non blocking - //sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - //denn erst anschliessend stehen die empfangenen daten zur verfuegung - //if(counterReceive==0) - //{ - // MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - //} - //counterReceive++; - //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - //{ - // counterReceive=0; - //} - - counterPrepareForReceive++; - if(counterPrepareForReceive==this->nofStoredVectors) - { -#ifdef DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest); - MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - counterPrepareForReceive=0; - } - } - -protected: - int poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterPrepareForSend; - size_type counterSend; - - std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt - - MPI_Comm comm; - MPI_Request receiveRequest; - MPI_Request sendRequest; - MPI_Datatype mpiDataType; - int mpiRemoteRank, mpiTag; - -#ifdef DEBUG - T* orgPoolVectorStartPointer; -#endif -}; - -template<typename T> -typename TbCbVectorMpiPool2<T>::MpiPoolPtrMap TbCbVectorMpiPool2<T>::poolMap; - - -////////////////////////////////////////////////////////////////////////// -// TbSenderMpiPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class TbCbVectorSenderMpiPool2 : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorSenderMpiPool2(const unsigned int& cbVectorKey, TbCbVectorMpiPool2< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) ); - } - ~TbCbVectorSenderMpiPool2() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool2< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->mpiVectorPool->sendDataOrder(); } - void receiveDataSize() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - void prepareForSend() { this->mpiVectorPool->prepareForSendData(); } - void sendData() { this->mpiVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getSendTbTag() const { return this->mpiVectorPool->getRemoteTag(); } - int getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - int getRecvFromTag() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - - std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; } - -protected: - TbCbVectorMpiPool2<T>* mpiVectorPool; -}; - - -/*==================================================================*/ -template<typename T> -class TbCbVectorReceiverMpiPool2 : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorReceiverMpiPool2(const unsigned int& cbVectorKey, TbCbVectorMpiPool2< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) ); - } - ~TbCbVectorReceiverMpiPool2() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool2< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void receiveDataSize() { this->mpiVectorPool->receiveDataOrder(); } - void sendData() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() - { - this->mpiVectorPool->receiveData(); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getSendTbTag() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getRecvFromRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->mpiVectorPool->getRemoteTag(); } - - std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - TbCbVectorMpiPool2<T>* mpiVectorPool; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPIPOOL_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool3.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool3.h deleted file mode 100644 index 1666ecf080a9a4a1dceb22108eed952dddd1e0b0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool3.h +++ /dev/null @@ -1,530 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPIPOOL_H -#define TBTRANSMITTERMPIPOOL_H - -#ifdef VF_MPI - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> - -#include <mpi.h> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -#include <boost/shared_ptr.hpp> - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//TbCbVectorMpiPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im TbMpiVectorPool verwaltet -//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class TbCbVectorSenderMpiPool; -template<typename T> class TbCbVectorReceiverMpiPool; - -/*==================================================================*/ -template<typename T> -class TbCbVectorMpiPool : public CbVectorPool<T> -{ -public: - typedef boost::shared_ptr< TbCbVectorMpiPool< T > > MpiPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map< std::string, MpiPoolPtr > MpiPoolPtrMap; - typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef std::string CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class TbCbVectorSenderMpiPool< T >; - friend class TbCbVectorReceiverMpiPool< T >; - -protected: - ////////////////////////////////////////////////////////////////////////// - static MpiPoolPtrMap poolMap; -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createTbCbVectorMpiPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // mpiRemoteRank: mpi-rank des Empfaengers/Senders - // mpiTag : mpi-tag mit dem empfangen/gesendet wird - static MpiPoolPtr createTbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!"); - } - - //pool erstellen - MpiPoolPtr mpiPool(new TbCbVectorMpiPool<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); - - //pool "speichern" - TbCbVectorMpiPool< value_type >::poolMap[poolKey] = mpiPool; - - return mpiPool; - } - static void deleteTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it = TbCbVectorMpiPool< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden"); - } - TbCbVectorMpiPool< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static MpiPoolPtr getTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it; - if( (it=TbCbVectorMpiPool< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool< T >::poolMap.end() ) - { - return it->second; - } - return MpiPoolPtr(); - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"TbCbVectorMpiPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static void eraseMap() - { - poolMap.clear(); - } -protected: - ////////////////////////////////////////////////////////////////////////// - TbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI_REQUEST_NULL) - , sendRequest(MPI_REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - } - -public: - /*==================================================================*/ - //returns key of Pool in MpiPoolMap - CbVectorKey getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->mpiRemoteRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->mpiTag; } - -protected: - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den - //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los- - //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den - //vorgang abgeschlossen hat!!! -> tmpOrderVec ist class-member!!! - //unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - //tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements); - //unsigned index = 0; - //tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - tmpSendOrderVec = ""; - tmpSendOrderVec+= UbSystem::toString(this->pool.size()+"#"; - if(this->nextCbVectorStartIndexInPool != this->pool.size()) throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!"); - - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - //CbVectorKey vectorKey=0; - //size_type dataSize=0, startIndexInPool=0; - //this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - //if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!"); - - //tmpSendOrderVec[index++] = (unsigned)vectorKey; //vectorKey == allocator.getAllocatorKey() - //tmpSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - //tmpSendOrderVec[index++] = (unsigned)dataSize; //dataSize - - CbVectorKey vectorKey = ""; - size_type dataSize = 0, startIndexInPool = 0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize); - if (it->first != vectorKey) throw UbException(UB_EXARGS, "key mismatch!"); - str += vectorKey+"#"+UbSystem::toString(startIndexInPool)+"#"+UbSystem::toString(dataSize); - - } - - int vsize = tmpSendOrderVec.length(); - MPI_Isend(&vsize, 1, MPI_INT, mpiRemoteRank, mpiTag, comm, &sendRequest[0]); - - MPI_Isend(&tmpSendOrderVec.c_str(), vsize, MPI_CHAR, mpiRemoteRank, mpiTag, comm, &sendRequest[1]); - - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - //receiveRequest.Wait(); - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - std::vector< unsigned > tmpRecvOrderVec; - tmpRecvOrderVec.resize(nofElements); - - //MPI_Status status; - //MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); - - MPI_Irecv(&rbuf.blocksSize, 1, MPI_INT, nProcessID, 0, mpi_comm, &request[rcount]); - - if(nofElements!=(unsigned)tmpRecvOrderVec.size()) - throw UbException(UB_EXARGS,"error... vec size stimmt nicht"); - - unsigned index = 0; - this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors - this->pool.resize(this->nextCbVectorStartIndexInPool); - CbVectorMapIter it = this->cbVectorMap.begin(); - for(/*index*/; index<nofElements; index+=3, ++it) - { - CbVectorKey vectorKey = (CbVectorKey)tmpRecvOrderVec.at(index ); - size_type startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1); - size_type dataSize = (size_type)tmpRecvOrderVec.at(index+2); - - //if(it==this->cbVectorMap.end() || it->first != vectorKey ) - //throw UbException(UB_EXARGS, "entweder hat map nicht die gleiche reihenfolge oder vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden"); - if (it==this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"map ist leer"); - else if (it->first != vectorKey) - throw UbException(UB_EXARGS, "vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden it->first =" + UbSystem::toString(it->first)); - - this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - } - if(it!=this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt..."); - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void prepareForSendData() - { - //da sendDataOrder einen request verwendet muss man hier immer abfragen - if(counterPrepareForSend==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - - - //A - non blocking - ////der ERSTE is entscheidend - ////Grund: wenn man - //// for(all trans) { trans->prepare(); trans->fillBuffer(); } - //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!! - //counterPrepareForSend++; - //if(counterPrepareForSend==1) - //{ - // if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait(); - //} - // - //if(counterPrepareForSend==nofStoredVectors) - // counterPrepareForSend=0; - } - /*==================================================================*/ - void sendData() - { - //A - non blocking - //der LETZTE is entscheidend - //counterSend++; - //if(counterSend==nofStoredVectors) - //{ - // //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - // sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - // counterSend=0; - //} - //B - blocking - //der LETZTE is entscheidend - counterSend++; - if(counterSend==nofStoredVectors) - { - //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - //synchronous send - //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - - //standard send - MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -//////////////////////////////////////////////////////////////////////////////////////////// -//DEBUG/////////////////////////////////////// - //int irank; - //MPI_Comm_rank(MPI_COMM_WORLD, &irank); - //std::cout << "MPI_Send: " << irank << " " << mpiRemoteRank << " " <<mpiTag<<std::endl; -/////////////////////////////////////////////////// - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - //A - non blocking - //sobald der Letzte kann man den den request holen. - //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!! - counterPrepareForReceive++; - if(counterPrepareForReceive==this->nofStoredVectors) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - counterPrepareForReceive=0; - } - } - /*==================================================================*/ - void receiveData() - { - //A - non blocking - //sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - //denn erst anschliessend stehen die empfangenen daten zur verfuegung - if(counterReceive==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - counterReceive++; - if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - { - counterReceive=0; - } - - ////B - blocking - ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - ////denn erst anschliessend stehen die empfangenen daten zur verfuegung - //if(counterReceive==0) - //{ - // comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - //} - //counterReceive++; - //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - // counterReceive=0; - } - -protected: - CbVectorKey poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterPrepareForSend; - size_type counterSend; - - //std::vector< char > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt - std::string tmpSendOrderVec; - - MPI_Comm comm; - MPI_Request receiveRequest; - MPI_Request sendRequest; - //MPI_Status sendStatus; - //MPI_Status receiveStatus; - MPI_Datatype mpiDataType; - - int mpiRemoteRank, mpiTag; - - std::vector<MPI_Request> request; - int rcount; - -#ifdef _DEBUG - T* orgPoolVectorStartPointer; -#endif -}; - -template<typename T> -typename TbCbVectorMpiPool<T>::MpiPoolPtrMap TbCbVectorMpiPool<T>::poolMap; - -////////////////////////////////////////////////////////////////////////// -// TbSenderMpiPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class TbCbVectorSenderMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorSenderMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) ); - } - ~TbCbVectorSenderMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->mpiVectorPool->sendDataOrder(); } - void receiveDataSize() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - void prepareForSend() { this->mpiVectorPool->prepareForSendData(); } - void sendData() { this->mpiVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getSendTbTag() const { return this->mpiVectorPool->getRemoteTag(); } - int getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - int getRecvFromTag() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - - std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - - -/*==================================================================*/ -template<typename T> -class TbCbVectorReceiverMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorReceiverMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) ); - } - ~TbCbVectorReceiverMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void receiveDataSize() { this->mpiVectorPool->receiveDataOrder(); } - void sendData() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() - { - this->mpiVectorPool->receiveData(); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getSendTbTag() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getRecvFromRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->mpiVectorPool->getRemoteTag(); } - - std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPIPOOL_H - diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPoolEx.h b/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPoolEx.h deleted file mode 100644 index dcb52d842363effe7dacca9ddbfb0c81efd50b9a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPoolEx.h +++ /dev/null @@ -1,602 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPIPOOLEX_H -#define TBTRANSMITTERMPIPOOLEX_H - -#ifdef VF_MPI - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> - -#include <mpi.h> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -#include <boost/shared_ptr.hpp> - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//TbCbVectorMpiPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im TbMpiVectorPool verwaltet -//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class TbCbVectorSenderMpiPoolEx; -template<typename T> class TbCbVectorReceiverMpiPoolEx; - -/*==================================================================*/ -template<typename T> -class TbCbVectorMpiPoolEx : public CbVectorPool<T> -{ -public: - typedef boost::shared_ptr< TbCbVectorMpiPoolEx< T > > MpiPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map< int, MpiPoolPtr > MpiPoolPtrMap; - typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef unsigned CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class TbCbVectorSenderMpiPoolEx< T >; - friend class TbCbVectorReceiverMpiPoolEx< T >; - -protected: - ////////////////////////////////////////////////////////////////////////// - static MpiPoolPtrMap poolMap; -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createTbCbVectorMpiPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // mpiRemoteRank: mpi-rank des Empfaengers/Senders - // mpiTag : mpi-tag mit dem empfangen/gesendet wird -#ifdef USE_MPI_CXX_SYNTAX - static MpiPoolPtr createTbCbVectorMpiPool(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI::Intracomm comm, const size_type& startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] -#else - static MpiPoolPtr createTbCbVectorMpiPool(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI_Comm comm, const size_type& startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] -#endif - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!"); - } - - //pool erstellen - MpiPoolPtr mpiPool(new TbCbVectorMpiPoolEx<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); - - //pool "speichern" - TbCbVectorMpiPoolEx< value_type >::poolMap[poolKey] = mpiPool; - - return mpiPool; - } - static void deleteTbCbVectorMpiPool(const int& poolKey) - { - MpiPoolPtrMapIter it = TbCbVectorMpiPoolEx< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden"); - } - TbCbVectorMpiPoolEx< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static MpiPoolPtr getTbCbVectorMpiPool(const int& poolKey) - { - MpiPoolPtrMapIter it; - if( (it=TbCbVectorMpiPoolEx< T >::poolMap.find(poolKey))!=TbCbVectorMpiPoolEx< T >::poolMap.end() ) - { - return it->second; - } - return MpiPoolPtr(); - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"TbCbVectorMpiPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static void eraseMap() - { - poolMap.clear(); - } -protected: - ////////////////////////////////////////////////////////////////////////// -#ifdef USE_MPI_CXX_SYNTAX - TbCbVectorMpiPoolEx(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI::Intracomm comm, const size_type& startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI::REQUEST_NULL) - , sendRequest(MPI::REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI::DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI::FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI::INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - } -#else - TbCbVectorMpiPoolEx(const int& poolKey, const int& mpiRemoteRank, const int& mpiTag, MPI_Comm comm, const size_type& startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI_REQUEST_NULL) - , sendRequest(MPI_REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - } -#endif - - -public: - /*==================================================================*/ - //returns key of Pool in MpiPoolMap - int getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->mpiRemoteRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->mpiTag; } - -protected: - /*==================================================================*/ - /*==================================================================*/ - /*==================================================================*/ - /*==================================================================*/ - /*==================================================================*/ - //void prepareTbReceiveDataOrder() - //{ - //counterPrepareReceiveDataOrder++; - //if(counterPrepareReceiveDataOrder==nofStoredVectors) - //{ - // unsigned nofElements = relationMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - // tmpOrderVec.resize(nofElements); - // std::cout<<RcfSystem::getRank()<<" prepForRecv from rank="<<mpiRemoteRank<<" with tag="<<mpiTag<<"e="<<nofElements<<std::endl; - // receiveRequest = comm.Irecv(&tmpOrderVec[0], nofElements, MPI::UNSIGNED, mpiRemoteRank, mpiTag); - // counterPrepareReceiveDataOrder = 0; - //} - //} - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den - //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los- - //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den - //vorgang abgeschlossen hat!!! -> tmpOrderVec ist class-member!!! - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements); - unsigned index = 0; - tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - if(this->nextCbVectorStartIndexInPool != this->pool.size()) throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!"); - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - CbVectorKey vectorKey=0; - size_type dataSize=0, startIndexInPool=0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!"); - - tmpSendOrderVec[index++] = (unsigned)vectorKey; //vectorKey == allocator.getAllocatorKey() - tmpSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - tmpSendOrderVec[index++] = (unsigned)dataSize; //dataSize - } - //std::cout<<RcfSystem::getRank()<<" send to rank="<<mpiRemoteRank<<" with tag="<<mpiTag<<" e="<<nofElements<<std::endl; - //comm.Send(&tmpOrderVec[0],nofElements, MPI::UNSIGNED, mpiRemoteRank, mpiTag); - - //////////////////////////// - //int rank; - //MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //std::cout<<"rank = " << rank <<" sendDataOrder() nofElements = "<<nofElements<<std::endl; - //////////////////////////// - -#ifdef USE_MPI_CXX_SYNTAX - sendRequest = comm.Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI::UNSIGNED, mpiRemoteRank, mpiTag); -#else - MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest); -#endif - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - -#ifdef DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - //receiveRequest.Wait(); - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - //////////////TODO////////////DEBUG - //int rank; - //MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //std::cout<<"rank = " << rank <<" receiveDataOrder() nofElements = "<<nofElements << " from " << mpiRemoteRank <<std::endl; - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - ////////////////////////// - - std::vector< unsigned > tmpRecvOrderVec; - tmpRecvOrderVec.resize(nofElements); - -#ifdef USE_MPI_CXX_SYNTAX - comm.Recv(&tmpRecvOrderVec[0], nofElements, MPI::UNSIGNED, mpiRemoteRank, mpiTag); -#else - //MPI_Status status; - MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); -#endif - - if(nofElements!=(unsigned)tmpRecvOrderVec.size()) - throw UbException(UB_EXARGS,"error... vec size stimmt nicht"); - - unsigned index = 0; - this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors - this->pool.resize(this->nextCbVectorStartIndexInPool); - CbVectorMapIter it = this->cbVectorMap.begin(); - for(/*index*/; index<nofElements; index+=3, ++it) - { - CbVectorKey vectorKey = (CbVectorKey)tmpRecvOrderVec.at(index ); - size_type startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1); - size_type dataSize = (size_type)tmpRecvOrderVec.at(index+2); - - if(it==this->cbVectorMap.end() || it->first != vectorKey ) - throw UbException(UB_EXARGS,"entweder hat map nicht die gleiche reihenfolge oder vectorKey nicht vorhanden"); - - this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - } - if(it!=this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt..."); - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void prepareForSendData() - { - //da sendDataOrder einen request verwendet muss man hier immer abfragen - if(counterPrepareForSend==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef USE_MPI_CXX_SYNTAX - if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait(); -#else - //if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE); -#endif - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - - - //A - non blocking - ////der ERSTE is entscheidend - ////Grund: wenn man - //// for(all trans) { trans->prepare(); trans->fillBuffer(); } - //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!! - //counterPrepareForSend++; - //if(counterPrepareForSend==1) - //{ - // if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait(); - //} - // - //if(counterPrepareForSend==nofStoredVectors) - // counterPrepareForSend=0; - } - /*==================================================================*/ - void sendData() - { - //A - non blocking - //der LETZTE is entscheidend - //counterSend++; - //if(counterSend==nofStoredVectors) - //{ - // //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - // sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - // counterSend=0; - //} - //B - blocking - //der LETZTE is entscheidend - counterSend++; - if(counterSend==nofStoredVectors) - { - //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - //synchronous send - //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#ifdef DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - - //standard send -#ifdef USE_MPI_CXX_SYNTAX - comm.Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#else - //MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm); - MPI_Isend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &sendRequest); -#endif - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -//////////////////////////////////////////////////////////////////////////////////////////// -//DEBUG/////////////////////////////////////// - //int irank; - //MPI_Comm_rank(MPI_COMM_WORLD, &irank); - //std::cout << "MPI_Send: " << irank << " " << mpiRemoteRank << " " <<mpiTag<<std::endl; -/////////////////////////////////////////////////// - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - //A - non blocking - //sobald der Letzte kann man den den request holen. - //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!! - counterPrepareForReceive++; - if(counterPrepareForReceive==this->nofStoredVectors) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - //std::cout<<"Irecv von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; -#ifdef USE_MPI_CXX_SYNTAX - receiveRequest = comm.Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#else - //MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest); -#endif - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - counterPrepareForReceive=0; - } - } - /*==================================================================*/ - void receiveData() - { - //A - non blocking - //sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - //denn erst anschliessend stehen die empfangenen daten zur verfuegung - if(counterReceive==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef USE_MPI_CXX_SYNTAX - receiveRequest.Wait(); -#else - //MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - MPI_Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); -#endif - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - counterReceive++; - if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - { - counterReceive=0; - } - - ////B - blocking - ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - ////denn erst anschliessend stehen die empfangenen daten zur verfuegung - //if(counterReceive==0) - //{ - // comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - //} - //counterReceive++; - //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - // counterReceive=0; - } - -protected: - int poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterPrepareForSend; - size_type counterSend; - - std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt - -#ifdef USE_MPI_CXX_SYNTAX - MPI::Intracomm comm; - MPI::Request receiveRequest; - MPI::Request sendRequest; - MPI::Datatype mpiDataType; -#else - MPI_Comm comm; - MPI_Request receiveRequest; - MPI_Request sendRequest; - //MPI_Status sendStatus; - //MPI_Status receiveStatus; - MPI_Datatype mpiDataType; -#endif - - int mpiRemoteRank, mpiTag; - -#ifdef DEBUG - T* orgPoolVectorStartPointer; -#endif -}; - -template<typename T> -typename TbCbVectorMpiPoolEx<T>::MpiPoolPtrMap TbCbVectorMpiPoolEx<T>::poolMap; - -// static MpiPoolPtrMap poolMap; - - -////////////////////////////////////////////////////////////////////////// -// TbSenderMpiPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class TbCbVectorSenderMpiPoolEx : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorSenderMpiPoolEx(const unsigned int& cbVectorKey, TbCbVectorMpiPoolEx< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) ); - } - ~TbCbVectorSenderMpiPoolEx() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPoolEx< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->mpiVectorPool->sendDataOrder(); } - void receiveDataSize() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - void prepareForSend() { this->mpiVectorPool->prepareForSendData(); } - void sendData() { this->mpiVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getSendTbTag() const { return this->mpiVectorPool->getRemoteTag(); } - int getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - int getRecvFromTag() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - - std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; } - -protected: - TbCbVectorMpiPoolEx<T>* mpiVectorPool; -}; - - -/*==================================================================*/ -template<typename T> -class TbCbVectorReceiverMpiPoolEx : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorReceiverMpiPoolEx(const unsigned int& cbVectorKey, TbCbVectorMpiPoolEx< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) ); - } - ~TbCbVectorReceiverMpiPoolEx() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPoolEx< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void receiveDataSize() { this->mpiVectorPool->receiveDataOrder(); } - void sendData() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() - { - this->mpiVectorPool->receiveData(); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getSendTbTag() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getRecvFromRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->mpiVectorPool->getRemoteTag(); } - - std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - TbCbVectorMpiPoolEx<T>* mpiVectorPool; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPIPOOL_H - diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterRcf.h b/ThirdParty/Library/basics/transmitter/TbTransmitterRcf.h deleted file mode 100644 index 4ec1c25dddabe3aea4c87331df6536f3e2a58fdd..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterRcf.h +++ /dev/null @@ -1,326 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERRCF_H -#define TBTRANSMITTERRCF_H - -/*=========================================================================*/ -/* RCF Transmitter */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -#include <iostream> -#include <vector> -#include <map> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/utilities/UbLogger.h> - -#ifdef CAB_RCF -////////////////////////////////////////////////////////////////////////// -// RCF STUFF -////////////////////////////////////////////////////////////////////////// - -#include <RCF/Idl.hpp> -#include <RCF/TcpEndpoint.hpp> -#include <boost/shared_ptr.hpp> - -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#include <3rdParty/rcf/RcfSystem.h> -#include <3rdParty/rcf/IRcfIpService.h> -#include <3rdParty/rcf/RcfConnection.h> - -//zum ausstausch mittels RCF transmitter: -RCF_BEGIN(IRcfTransmitterReceiverService, "IRcfTransmitterReceiverService") - RCF_METHOD_V2(void, receiveVectorForTransmitter,int /*tag*/, const std::vector<double>& /*data*/); - RCF_METHOD_V2(void, receiveVectorForTransmitter,int /*tag*/, const CbVector<double>& /*data*/); - RCF_METHOD_V2(void, receiveVectorForTransmitter,int /*tag*/, const std::vector<float>& /*data*/); - RCF_METHOD_V2(void, receiveVectorForTransmitter,int /*tag*/, const CbVector<float>& /*data*/); -RCF_END(IRcfTransmitterReceiverService); - -////////////////////////////////////////////////////////////////////////// -// TbVectorSenderRcf< Vector > -////////////////////////////////////////////////////////////////////////// -template< typename Vector > -class TbVectorSenderRcf : public TbTransmitter< Vector > -{ -public: - typedef Vector value_type; - - //static members -private: - static std::vector< RcfClient<IRcfTransmitterReceiverService> > recvServices; - - static void setRcfClients(const std::string& recvServiceID); - -public: - TbVectorSenderRcf(const std::string& recvServiceName,const RcfConnection& receiveProcess, const int& tag) - : TbTransmitter< Vector >() - { - if( recvServices.empty() ) setRcfClients(recvServiceName); - this->receiveRank = receiveProcess.getRank(); - this->tag = tag; - this->receiveProcess = receiveProcess; - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->sendData(); } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"TbRcfVectorSender sends only") ); } - - void sendData() - { - //remote prozess=client erhaelt daten - recvServices[receiveRank].receiveVectorForTransmitter(tag, TbTransmitter< Vector >::getData()); - } - void prepareForReceive() { UB_THROW( UbException(UB_EXARGS,"TbRcfVectorSender sends only") ); } - Vector& receiveData() { UB_THROW( UbException(UB_EXARGS,"TbRcfVectorSender sends only") ); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->receiveRank; /*=der rank an den gesendet wird*/} - int getSendTbTag() const { return this->tag; } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"TbVectorSenderRcf sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"TbVectorSenderRcf sends only") ); } - - std::string toString() const { return "TbVectorSenderRcf< "+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name() +"> > to rank (tag)"+UbSystem::toString(receiveRank)+"("+UbSystem::toString(tag)+") connection "+receiveProcess.toString(); } - -private: - RcfConnection receiveProcess; - int tag; - int receiveRank; -}; - -////////////////////////////////////////////////////////////////////////// -template< typename Vector > -std::vector< RcfClient<IRcfTransmitterReceiverService> > TbVectorSenderRcf< Vector >::recvServices; - -template< typename Vector > -void TbVectorSenderRcf< Vector >::setRcfClients(const std::string& recvServiceID) -{ - UBLOG(logINFO,"invoked setRcfClients"); - RcfConnection ipConnection = RcfSystem::getIpServiceConnection(); - if(!ipConnection) UB_THROW( UbException(UB_EXARGS,"ups, no IpServiceConnection") ); - RcfClient<IRcfIpService> ipService(RCF::TcpEndpoint(ipConnection.getIp(), ipConnection.getPort())); - - //Mit RecvServices verbinden - std::vector<RcfConnection> connections = ipService.getServiceConnections(recvServiceID); - if(connections.empty()) - UB_THROW( UbException(UB_EXARGS,"no existing RecvService with ID = "+recvServiceID) ); - std::sort(connections.begin(),connections.end(),RcfConnection::compareRank()); - - for(std::size_t i=0; i<connections.size(); i++) - { - if( (int)i != connections[i].getRank() ) - UB_THROW( UbException(UB_EXARGS,"recvServices must have continougs ranks sarting from 0") ); - recvServices.push_back(RcfClient<IRcfTransmitterReceiverService>(RCF::TcpEndpoint(connections[i].getIp(), connections[i].getPort())) ); - } -} - - -////////////////////////////////////////////////////////////////////////// -// TbVectorReceiverRcf -////////////////////////////////////////////////////////////////////////// -template< typename Vector > -class TbVectorReceiverRcf : public TbTransmitter< Vector > -{ - typedef std::map<int, TbVectorReceiverRcf< Vector >* > ReceiverMap; - typedef typename ReceiverMap::iterator ReceiverMapIt; - -public: - typedef Vector value_type; - - //static members -private: - static ReceiverMap receiverMap; - static boost::mutex staticReceiverMapMutex; - -public: - static void receiveVectorForTransmitter(int tag, const Vector& data) - { - TbVectorReceiverRcf< Vector >* receiver = NULL; - - //receiver ermitteln (map nicht thread-safe->lock! aber nur kurz, ansonsten ab einer gewissen anzahl an clients/blöcken->deadlock) - //vermutlich brauch man den nicht mal... (denn das registrieren sollte zu diesem zeitpunkt abgeschlossen sein) - //allerdings sollte man nicht gleichzeitig Suchoperationen in ner nich thread sicheren map durchführen!!! - { - boost::mutex::scoped_lock lock(staticReceiverMapMutex); //wenn man das ausserhalb macht, gibt es ab einer bestimmten anzahl an clients/bloecke einen deadlock - - ReceiverMapIt result = TbVectorReceiverRcf< Vector >::receiverMap.find(tag); - if( result == TbVectorReceiverRcf< Vector >::receiverMap.end() ) - UB_THROW( UbException(UB_EXARGS,"receiver is not registered") ); - - receiver = result->second; - if(!receiver) - UB_THROW( UbException(UB_EXARGS,"receiver is NULL") ); - } - - boost::mutex::scoped_lock lock(receiver->bufferMutex); - - // wait until buffer is empty - while(receiver->isBufferFull) - receiver->bufferEmptiedCondition.wait(lock); - - ////////////////////////////////////////////////////////////////////////// - // put data in buffer - //old: receiver->buffer = data; - - //new: - if( receiver->buffer.size() != data.size() ) - { - receiver->buffer.resize( data.size() ); - } - memcpy( (char*)&receiver->buffer[0], (char*)&data[0], data.size()*sizeof(typename Vector::value_type) ); - - ////////////////////////////////////////////////////////////////////////// - //evtl wartende clients benachrichtigen - //notify "buffer filled" waiters - receiver->isBufferFull = true; - receiver->bufferFilledCondition.notify_all(); // notify_one muesste eigentlich reichen - } - -public: - TbVectorReceiverRcf(const int& tag, const int& recvFromRank/*just for info section*/) - : TbTransmitter< Vector >(), tag(tag), recvFromRank(recvFromRank) - { - { - //receiver registrieren - boost::mutex::scoped_lock lock( TbVectorReceiverRcf< Vector >::staticReceiverMapMutex ); - - std::pair< ReceiverMapIt, bool> result = receiverMap.insert(std::make_pair(tag, this)); - if( !result.second ) - { - ReceiverMapIt existingReceiver = TbVectorReceiverRcf< Vector >::receiverMap.find(tag); - TbVectorReceiverRcf< Vector >::receiverMap.erase(existingReceiver); - TbVectorReceiverRcf< Vector >::receiverMap.insert(std::pair<int, TbVectorReceiverRcf< Vector >* >(tag, this)); - } - } - isBufferFull = false; - } - - ~TbVectorReceiverRcf() - { - ReceiverMapIt existingReceiver = receiverMap.find(tag); - TbVectorReceiverRcf< Vector >::receiverMap.erase(existingReceiver); - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"TbRcfVectorReceiver receives only") ); } - void receiveDataSize() { this->receiveData(); } - - void sendData() { UB_THROW( UbException(UB_EXARGS,"TbRcfVectorReceiver receives only") ); } - - Vector& receiveData() - { - boost::mutex::scoped_lock lock(bufferMutex); - - // wait until buffer is full - while(!isBufferFull) - bufferFilledCondition.wait(lock); - - // get data from buffer - //std::size_t dataSize = this->buffer.size(); - //if( this->getData().size()!=dataSize ) this->getData().resize(dataSize); - //for(std::size_t i=0; i<dataSize; ++i) - // this->getData()[i]=buffer[i]; - - //folgende assert schlaegt bei receiveDataSize(), das receiveData() aufgerufen wird fehl... - //daher ausdokumentiert - //assert( this->getData().size() == this->buffer.size() ); - - this->getData().swap(this->buffer); - - isBufferFull = false; - - // notify "buffer emptied" waiters - bufferEmptiedCondition.notify_all(); // notify_one sollte auch hier reichen - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { UB_THROW( UbException(UB_EXARGS,"getSendTbRank sends only") ); } - int getSendTbTag() const { UB_THROW( UbException(UB_EXARGS,"getSendTbTag sends only") ); } - int getRecvFromRank() const { return this->recvFromRank; /*=der rank an den gesendet wird*/ } - int getRecvFromTag() const { return this->tag; } - - std::string toString() const { return "TbVectorReceiverRcf< "+(std::string)typeid(Vector).name()+"<"+(std::string)typeid(typename Vector::value_type).name() +"> > to rank (tag)"+UbSystem::toString(recvFromRank)+"("+UbSystem::toString(tag)+")"; } - -private: - int tag; - int recvFromRank; //just for info-section - - boost::mutex bufferMutex; - boost::condition bufferFilledCondition; - boost::condition bufferEmptiedCondition; - bool isBufferFull; - - Vector buffer; -}; - -////////////////////////////////////////////////////////////////////////// -// template< typename Vector > -// std::map<int, TbVectorReceiverRcf< Vector >* > TbVectorReceiverRcf< Vector >::receiverMap; -template< typename Vector > -typename TbVectorReceiverRcf< Vector >::ReceiverMap TbVectorReceiverRcf< Vector >::receiverMap; - -template< typename Vector > -boost::mutex TbVectorReceiverRcf< Vector >::staticReceiverMapMutex; - - -// -// -// -// -// //derzeit funzt es nur mit vector<double> dafuer gibt es weiter unten eine spezialisierung -// //Grund: man muss fuer jeden datentyp eine RCF methode beim service registrieren -// // und derzeit ist eben nur eine fuer vector<double> vorhanden -// template< typename Vector > -// class TbVectorSenderRcf : public TbTransmitter< Vector > -// { -// public: -// TbVectorSenderRcf(const std::string& calcServiceName, const RcfConnection& receiveProcess, const int& tag) -// : TbTransmitter< Vector >() -// { -// UB_THROW( UbException("TbVectorSenderRcf::TbVectorSenderRcf() - TbRcfVectorSender not implmeneted for that type ") ); -// } -// void sendDataSize() { UB_THROW( UbException("TbVectorSenderRcf::sendDataSize() - not defined for that type") ); } -// void receiveDataSize() { UB_THROW( UbException("TbVectorSenderRcf::receiveDataSize() - not defined for that type") ); } -// void sendData() { UB_THROW( UbException("TbVectorSenderRcf::sendData() - not defined for that type") ); } -// void prepareForReceive() { UB_THROW( UbException("TbVectorSenderRcf::prepareForReceive() - TbRcfVectorSender sends only") ); } -// Vector& receiveData() { UB_THROW( UbException("TbVectorSenderRcf::receiveData() - TbRcfVectorSender sends only") ); } -// std::string toString() { return "undefined TbVectorSenderRcf"; } -// }; -// -// template< typename Vector > -// class TbVectorReceiverRcf : public TbTransmitter< Vector > -// { -// public: -// TbVectorReceiverRcf(const int& tag, const int& receiveRank) : TbTransmitter< Vector >() -// { -// UB_THROW( UbException("TbVectorReceiverRcf::TbVectorReceiverRcf() - not defined for that type") ); -// } -// void sendDataSize() { UB_THROW( UbException("TbVectorReceiverRcf::sendDataSize() - not defined for that type") ); } -// void receiveDataSize() { UB_THROW( UbException("TbVectorReceiverRcf::receiveDataSize() - not defined for that type") ); } -// void sendData() { UB_THROW( UbException("TbVectorReceiverRcf::sendData() - TbRcfVectorReceiver receives only") ); } -// Vector& receiveData() { UB_THROW( UbException("TbVectorReceiverRcf::receiveData() - not defined for that type") ); } -// std::string toString() { return "undefined TbVectorReceiverRcf"; } -// }; -// -#endif // CAB_RCF - -#endif //TBTRANSMITTERRCF_H diff --git a/ThirdParty/Library/basics/transmitter/TbTransmitterRcfPool.h b/ThirdParty/Library/basics/transmitter/TbTransmitterRcfPool.h deleted file mode 100644 index 361cd7a4475806aeb98bce5a82899147fffe1c65..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/transmitter/TbTransmitterRcfPool.h +++ /dev/null @@ -1,593 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBCBVECTORRCFPOOL_H -#define TBCBVECTORRCFPOOL_H - -#ifdef CAB_RCF - -/*=========================================================================*/ -/* ToCbVectorRcfPool */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 09.10.08 -*/ - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> -#include <cassert> - -#include <RCF/Idl.hpp> -#include <RCF/TcpEndpoint.hpp> -#include <RCF/ByteBuffer.hpp> - -#include <boost/shared_ptr.hpp> - -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#include <3rdParty/rcf/RcfSystem.h> -#include <3rdParty/rcf/IRcfIpService.h> -#include <3rdParty/rcf/RcfConnection.h> - -#include <basics/transmitter/ToTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbLogger.h> - - -// zum ausstausch mittels RCF transmitter: -RCF_BEGIN(IRcfTransmitterReceiverPoolService, "IRcfTransmitterReceiverPoolService") -RCF_METHOD_V3(void, receiveRcfPoolData , const float& /*dummy*/, const int& /*poolKey*/, const RCF::ByteBuffer& /*databuffer*/ ) -RCF_METHOD_V3(void, receiveRcfPoolDataOrder, const float& /*dummy*/, const int& /*poolKey*/, const std::vector< unsigned >& /*dataOrder*/ ) -RCF_METHOD_V3(void, receiveRcfPoolData , const double& /*dummy*/, const int& /*poolKey*/, const RCF::ByteBuffer& /*databuffer*/ ) -RCF_METHOD_V3(void, receiveRcfPoolDataOrder, const double& /*dummy*/, const int& /*poolKey*/, const std::vector< unsigned >& /*dataOrder*/ ) -RCF_END(IRcfTransmitterReceiverPoolService); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//ToRcfPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder RcfPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im ToRcfVectorPool verwaltet -//RcfPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class ToCbVectorSenderRcfPool; -template<typename T> class ToCbVectorReceiverRcfPool; - -/*==================================================================*/ -template<typename T> -class ToCbVectorRcfPool : public CbVectorPool<T> -{ -public: - typedef boost::shared_ptr< ToCbVectorRcfPool< T > > RcfPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map< int, RcfPoolPtr > RcfPoolPtrMap; - typedef typename RcfPoolPtrMap::iterator RcfPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef unsigned CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class ToCbVectorSenderRcfPool< T >; - friend class ToCbVectorReceiverRcfPool< T >; - -private: - ////////////////////////////////////////////////////////////////////////// - static RcfPoolPtrMap poolMap; - -// //wenn pool als recevier fungiert -// static ReceiverPoolMap receiverPoolMap; - static boost::mutex staticPoolMapMutex; - - //wenn pool als sender fungiert - static std::vector< RcfConnection > recvConnections; - static std::vector< RcfClient<IRcfTransmitterReceiverPoolService> > recvServices; - static void setRcfSendToClients(const std::string& receiveServiceID, const int& rcfSendToRank); - -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createToCbVectorRcfPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // : (dieser schluessel ist eindeutig und muss bei send und recevicePool uebereinstimmen (ersetzt Tag) - // rcfRemoteRank: rcf-rank des Empfaengers/Senders - // rcfTag : rcf-tag mit dem empfangen/gesendet wird - static RcfPoolPtr createToCbVectorRcfSendPool(const std::string& rcfSendToServiceName, const int& poolKey, const int& rcfSendToRank, const size_type& startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - { - if( poolMap.find(poolKey)!=ToCbVectorRcfPool< value_type >::poolMap.end() ) - { - UB_THROW( UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!") ); - } - //pool erstellen - RcfPoolPtr rcfPool(new ToCbVectorRcfPool<T>(rcfSendToServiceName, poolKey, rcfSendToRank, startPoolSize) ); - - //pool "speichern" - ToCbVectorRcfPool< value_type >::poolMap[poolKey] = rcfPool; - - ToCbVectorRcfPool::setRcfSendToClients(rcfSendToServiceName, rcfSendToRank); - - return rcfPool; - } - /*==================================================================*/ - static RcfPoolPtr createToCbVectorRcfRecvPool(const int& poolKey, const int& rcfRecvRank, const size_type& startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - UB_THROW( UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!") ); - } - //pool erstellen - RcfPoolPtr rcfPool(new ToCbVectorRcfPool<T>( "", poolKey, rcfRecvRank, startPoolSize ) ); - - //pool "speichern" - ToCbVectorRcfPool< value_type >::poolMap[poolKey] = rcfPool; - - return rcfPool; - } - /*==================================================================*/ - static void deleteToCbVectorRcfPool(const int& poolKey) - { - RcfPoolPtrMapIter it = ToCbVectorRcfPool< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - UB_THROW( UbException(UB_EXARGS,"kein Pool mit dem key vorhanden") ); - } - ToCbVectorRcfPool< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static RcfPoolPtr getToCbVectorRcfPool(const int& poolKey) - { - RcfPoolPtrMapIter it; - if( (it=ToCbVectorRcfPool< T >::poolMap.find(poolKey))!=ToCbVectorRcfPool< T >::poolMap.end() ) - { - return it->second; - } - return NULL; - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"ToCbVectorRcfPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(RcfPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(RcfPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - return true; - } - /*==================================================================*/ - static void receiveDataOrder(int poolKey, const std::vector< unsigned >& dataOrder) - { - RcfPoolPtr receiverPool; - - //receiver ermitteln (map nicht thread-safe->lock! aber nur kurz, ansonsten ab einer gewissen anzahl an clients/blöcken->deadlock) - //vermutlich brauch man den nicht mal... (denn das registrieren sollte zu diesem zeitpunkt abgeschlossen sein) - //allerdings sollte man nicht gleichzeitig Suchoperationen in ner nicht thread sicheren map durchführen!!! - { - boost::mutex::scoped_lock lock(staticPoolMapMutex); //wenn man das ausserhalb macht, gibt es ab einer bestimmten anzahl an clients/bloecke einen deadlock - receiverPool = getToCbVectorRcfPool(poolKey); - if(!receiverPool) UB_THROW( UbException(UB_EXARGS,"kein pool mit poolKey="+UbSystem::toString(poolKey)) ); - } - - boost::mutex::scoped_lock lock(receiverPool->receiveDataOrderMutex); - - // wait until buffer is empty - while(receiverPool->receivedDataOrderBufferIsFull) - receiverPool->dataOrderVectorEmptiedCondition.wait(lock); - - receiverPool->recvOrderVec = dataOrder; - - ////////////////////////////////////////////////////////////////////////// - //evtl wartende clients benachrichtigen - //notify "buffer filled" waiters - - receiverPool->receivedDataOrderBufferIsFull = true; - receiverPool->dataOrderVectorFilledCondition.notify_all(); - } - /*==================================================================*/ - static void receivePoolData(const int& poolKey, const RCF::ByteBuffer& byteBuffer) //const typename CbVectorPool< T >::Pool& data) - { - RcfPoolPtr receiverPool; - - //receiver ermitteln (map nicht thread-safe->lock! aber nur kurz, ansonsten ab einer gewissen anzahl an clients/blöcken->deadlock) - //vermutlich brauch man den nicht mal... (denn das registrieren sollte zu diesem zeitpunkt abgeschlossen sein) - //allerdings sollte man nicht gleichzeitig Suchoperationen in ner nich thread sicheren map durchführen!!! - { - boost::mutex::scoped_lock lock(staticPoolMapMutex); //wenn man das ausserhalb macht, gibt es ab einer bestimmten anzahl an clients/bloecke einen deadlock - receiverPool = getToCbVectorRcfPool(poolKey); - if(!receiverPool) UB_THROW( UbException(UB_EXARGS,"kein pool mit poolKey="+UbSystem::toString(poolKey)) ); - - //std::cout<<"poolMap.size()="<<poolMap.size()<<std::endl; - } - - boost::mutex::scoped_lock lock(receiverPool->receiveMutex); - //UBLOG(logDEBUG5,"receivePoolVector - entered, pool"); - // wait until buffer is full - while(!receiverPool->performPoolUpdate) - receiverPool->performPoolUpdateCond.wait(lock); - //UBLOG(logDEBUG5,"receivePoolVector - es kann losgehen buggercopy"); - - //ACHTUNG! nie einen pool.swap(data) machen -> startadressen der "kleinen" vektoren passen sonst nimmer! - if( receiverPool->pool.size()*sizeof( T ) != byteBuffer.getLength() ) - { - UB_THROW( UbException(UB_EXARGS,"pool.size()!=byteBuffer.size()") ); - } - memcpy( (char*)&receiverPool->pool[0], byteBuffer.getPtr(), byteBuffer.getLength() ); -// memcpy( (char*)&receiverPool->pool[0], (char*)&data[0], data.size()*sizeof( T ) ); - //UBLOG(logDEBUG5,"receivePoolVector - nach memcopy"); - - receiverPool->poolWasUpdated = true; - receiverPool->performPoolUpdate = false; - receiverPool->waitForPoolUpdateCond.notify_one(); // notify_one sollte auch hier reichen - } - -protected: - ////////////////////////////////////////////////////////////////////////// - ToCbVectorRcfPool(const std::string& rcfReceiveServiceName, const int& poolKey, const int& rcfRank, const size_type& startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterSend(0) - , rcfReceiveServiceName(rcfReceiveServiceName) - , rcfRank(rcfRank) - , receivedDataOrderBufferIsFull(false) - , performPoolUpdate(false) - , poolWasUpdated(false) - { - } - -public: - //returns key of Pool in RcfPoolMap - int getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->rcfRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->rcfRank; } - -protected: - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - std::vector< unsigned >localSendOrderVec(nofElements); - unsigned index = 0; - localSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - if(this->nextCbVectorStartIndexInPool != this->pool.size()) UB_THROW( UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!") ); - - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - CbVectorKey vectorKey=0; - size_type dataSize=0, startIndexInPool=0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - if(it->first != vectorKey) UB_THROW( UbException(UB_EXARGS,"key mismatch!") ); - - localSendOrderVec[index++] = (unsigned)vectorKey; //vectorKey == allocator.getAllocatorKey() - localSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - localSendOrderVec[index++] = (unsigned)dataSize; //dataSize - } - - //remote prozess=client erhaelt daten - recvServices[this->rcfRank].receiveRcfPoolDataOrder(T(), this->poolKey, localSendOrderVec); - - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - boost::mutex::scoped_lock lock(receiveDataOrderMutex); - - // wait until buffer is full - while(!receivedDataOrderBufferIsFull) - dataOrderVectorFilledCondition.wait(lock); //wird in receivePoolVectorForTransmitter freigegeben :) - - ////////////////////////////////////////////////////////////////////////// - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - if(nofElements!=(unsigned)recvOrderVec.size()) - UB_THROW( UbException(UB_EXARGS,"error... vec size stimmt nicht") ); - - unsigned index = 0; - this->nextCbVectorStartIndexInPool = recvOrderVec[index++]; //= laenge des vectors - this->pool.resize(this->nextCbVectorStartIndexInPool); - CbVectorMapIter it = this->cbVectorMap.begin(); - for(/*index*/; index<nofElements; index+=3, ++it) - { - CbVectorKey vectorKey = (CbVectorKey)recvOrderVec.at(index ); - size_type startIndexInPool = (size_type)recvOrderVec.at(index+1); - size_type dataSize = (size_type)recvOrderVec.at(index+2); - - if(it==this->cbVectorMap.end() || it->first != vectorKey ) - UB_THROW( UbException(UB_EXARGS,"entweder hat map nicht die gleiche reihenfolge oder vectorKey nicht vorhanden") ); - - this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - } - if(it!=this->cbVectorMap.end()) - UB_THROW( UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt...") ); - - recvOrderVec.resize(0); - - // notify "buffer emptied" waiters - this->receivedDataOrderBufferIsFull = false; //->somit kann wieder neue reihenfolge empfangen werden - dataOrderVectorEmptiedCondition.notify_all(); // notify_one sollte auch hier reichen - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - } - } - /*==================================================================*/ - void prepareForSendData() {} - /*==================================================================*/ - void sendData() - { - counterSend++; - if( counterSend == nofStoredVectors ) - { - //remote prozess=client erhaelt daten - //T() -> auf der empfangsseite wird automatisch die methode für den entsprechenden ToCbVectorRcfPool< T > - //aufgerufen - RCF::ByteBuffer byteBuffer( (char*)&this->pool[0], this->pool.size()*sizeof( T ), true ); - recvServices[this->rcfRank].receiveRcfPoolData( T(), this->poolKey, byteBuffer ); - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - counterPrepareForReceive++; - if( counterPrepareForReceive == this->nofStoredVectors ) - { - boost::mutex::scoped_lock lock(receiveMutex); - //UBLOG(logDEBUG5,"prepareForReceiveData - entered -> notfifiziere performPoolUpdateCond"); - - counterPrepareForReceive = 0; - this->performPoolUpdate = true; - performPoolUpdateCond.notify_one(); - } - } - /*==================================================================*/ - void receiveData() - { - if( counterReceive == 0 ) - { - boost::mutex::scoped_lock lock(receiveMutex); - //UBLOG(logDEBUG5,"receiveData - wait for pool update"); - - while(!this->poolWasUpdated) - waitForPoolUpdateCond.wait(lock); - this->poolWasUpdated = false; - //UBLOG(logDEBUG5,"receiveData - pool update seems to be finished"); - } - - counterReceive++; - if( counterReceive == this->nofStoredVectors ) //alle receiver waren hier - { - counterReceive=0; - } - } - -protected: - int poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterSend; - - std::string rcfReceiveServiceName; //nur als SENDER wichtig!! - int rcfRank; - - bool receivedDataOrderBufferIsFull; - boost::mutex receiveDataOrderMutex; - boost::condition dataOrderVectorFilledCondition; - boost::condition dataOrderVectorEmptiedCondition; - std::vector< unsigned > recvOrderVec; - - bool performPoolUpdate; - boost::mutex receiveMutex; - bool poolWasUpdated; - boost::condition waitForPoolUpdateCond; - boost::condition performPoolUpdateCond; -}; - -////////////////////////////////////////////////////////////////////////// -template< typename T > -std::vector< RcfClient<IRcfTransmitterReceiverPoolService> > ToCbVectorRcfPool< T >::recvServices; - -template< typename T > -std::vector< RcfConnection > ToCbVectorRcfPool< T >::recvConnections; - -template< typename T > -void ToCbVectorRcfPool< T >::setRcfSendToClients(const std::string& recvServiceID, const int& rcfSendToRank) -{ - UBLOG(logINFO,"ToCbVectorRcfPool< T >::setRcfSendToClients - invoked setRcfClients"); - RcfConnection ipConnection = RcfSystem::getIpServiceConnection(); - if(!ipConnection) UB_THROW( UbException(UB_EXARGS,"ups, no IpServiceConnection") ); - RcfClient<IRcfIpService> ipService(RCF::TcpEndpoint(ipConnection.getIp(), ipConnection.getPort())); - - ////////////////////////////////////////////////////////////////////////// - //CalcService Verbindungsdaten holen und nach rank sortiere - std::vector<RcfConnection> connections = ipService.getServiceConnections(recvServiceID); - if(connections.empty()) UB_THROW( UbException(UB_EXARGS,"no existing RecvService with ID = "+recvServiceID) ); - std::sort(connections.begin(),connections.end(),RcfConnection::compareRank()); - - ////////////////////////////////////////////////////////////////////////// - //CalcServiceClient für rcfSendToRank übernehmen - assert( recvConnections.size() == recvServices.size() ); - - if( rcfSendToRank >= (int)recvConnections.size() ) - { - recvConnections.resize(rcfSendToRank+1); - recvServices.resize( rcfSendToRank+1 ); - } - - //Anm.: nur, wenn nicht schon vorhanden (hierfür merkt man sich zusätzlich die connection! - if( recvConnections[rcfSendToRank] != connections[rcfSendToRank] ) - { - if( connections[rcfSendToRank].getRank() != rcfSendToRank ) - UB_THROW( UbException(UB_EXARGS,"error - ranks ranks anscheinend nicht kontinierlich von [0..n]") ); - - recvConnections[rcfSendToRank] = connections[rcfSendToRank]; - recvServices[rcfSendToRank] = RcfClient<IRcfTransmitterReceiverPoolService>(RCF::TcpEndpoint(connections[rcfSendToRank].getIp(), connections[rcfSendToRank].getPort())); - UBLOG(logINFO,"ToCbVectorRcfPool< T >::setRcfSendToClients - rank="<<rcfSendToRank<<" : set RcfClient with connection = " << connections[rcfSendToRank] ); - } - else - { - UBLOG(logINFO,"ToCbVectorRcfPool< T >::setRcfSendToClients - rank="<<rcfSendToRank<<" : RcfClient already exists with connection = " << connections[rcfSendToRank] ); - } - //for(std::size_t i=0; i<connections.size(); i++) - //{ - // if( (int)i != connections[i].getRank() ) - // UB_THROW( UbException(UB_EXARGS,"recvServices must have continous ranks sarting from 0") ); - // recvServices[i] = RcfClient<IRcfTransmitterReceiverPoolService>(RCF::TcpEndpoint(connections[i].getIp(), connections[i].getPort())); - // UBLOG(logINFO,"ToCbVectorRcfPool< T >::setRcfSendToClients - pos="<<i<<" : set RcfClient with connection = " << connections[i] ); - //} -} - -template<typename T> -typename ToCbVectorRcfPool<T>::RcfPoolPtrMap ToCbVectorRcfPool<T>::poolMap; - -template< typename T > -boost::mutex ToCbVectorRcfPool< T >::staticPoolMapMutex; - - -////////////////////////////////////////////////////////////////////////// -// ToSenderRcfPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class ToCbVectorSenderRcfPool : public ToTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - ToCbVectorSenderRcfPool(const unsigned int& cbVectorKey, ToCbVectorRcfPool< T >* rcfVectorPool) - : rcfVectorPool(rcfVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->rcfVectorPool) ); - } - ~ToCbVectorSenderRcfPool() - { - if( this->rcfVectorPool->getNofStoredVectors()==1 ) //last entry! - { - ToCbVectorRcfPool< T >::deleteToCbVectorRcfPool(this->rcfVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->rcfVectorPool->sendDataOrder(); } - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"ToRcfPoolSender sends only") ); } - CbVector< T >& receiveData() { UB_THROW( UbException(UB_EXARGS,"ToRcfPoolSender sends only") ); } - void prepareForSend() { this->rcfVectorPool->prepareForSendData(); } - void sendData() { this->rcfVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendToRank() const { return this->rcfVectorPool->getRemoteRank(); } - int getSendToTag() const { return this->rcfVectorPool->getRemoteTag(); } - int getRecvFromRank() const { UB_THROW( UbException(UB_EXARGS,"ToCbVectorSenderRcfPool sends only") ); } - int getRecvFromTag() const { UB_THROW( UbException(UB_EXARGS,"ToCbVectorSenderRcfPool sends only") ); } - - std::string toString() const { return "ToCbVectorSenderRcfPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendToRank())+"("+UbSystem::toString(getSendToTag())+")"; } - -protected: - ToCbVectorRcfPool<T>* rcfVectorPool; -}; - -/*==================================================================*/ -template<typename T> -class ToCbVectorReceiverRcfPool : public ToTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - ToCbVectorReceiverRcfPool(const unsigned int& cbVectorKey, ToCbVectorRcfPool< T >* rcfVectorPool) - : rcfVectorPool(rcfVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->rcfVectorPool) ); - } - ~ToCbVectorReceiverRcfPool() - { - if( this->rcfVectorPool->getNofStoredVectors()==1 ) //last entry! - { - UBLOG(logINFO,"ToCbVectorReceiverRcfPool - loesche map - poolKey "<<this->rcfVectorPool->getPoolKey()); - ToCbVectorRcfPool< T >::deleteToCbVectorRcfPool(this->rcfVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"ToCbVectorReceiverRcfPool receives only") ); } - void receiveDataSize() { this->rcfVectorPool->receiveDataOrder(); } - void sendData() { UB_THROW( UbException(UB_EXARGS,"ToCbVectorReceiverRcfPool receives only") ); } - void prepareForReceive() { this->rcfVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() { this->rcfVectorPool->receiveData(); return this->getData(); } - - //info-section (usable for remote transmitter) - int getSendToRank() const { UB_THROW( UbException(UB_EXARGS,"ToCbVectorReceiverRcfPool receives only") ); } - int getSendToTag() const { UB_THROW( UbException(UB_EXARGS,"ToCbVectorReceiverRcfPool receives only") ); } - int getRecvFromRank() const { return this->rcfVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->rcfVectorPool->getRemoteTag(); } - - std::string toString() const { return "ToCbVectorReceiverRcfPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - ToCbVectorRcfPool<T>* rcfVectorPool; -}; - -#endif //CAB_RCF - -#endif //TOCBVECTORRCFPOOL_H diff --git a/ThirdParty/Library/basics/utilities/CMakePackage.txt b/ThirdParty/Library/basics/utilities/CMakePackage.txt deleted file mode 100644 index 2bae505538e07aa6c724c29a4b8d472975ef29e0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/CMakePackage.txt +++ /dev/null @@ -1,21 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption) - -IF(${outOption}) - IF(WIN32) - ADD_DEFINITIONS( -DNOMINMAX ) - ENDIF(WIN32) - - IF(BOOST_VERSION) - OPTION(USE_THREADSAFE_LOGGER "ON=thread safe, OFF=not thread safe" ON) - IF(NOT ${outOption}) - ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING) - ELSE() - SET(NECESSARY_BOOST_LIBS ${NECESSARY_BOOST_LIBS} thread) - ENDIF() - ELSE() - #um die thread safe zu machen benoetigt man boost - ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING) - ENDIF() - -ENDIF() \ No newline at end of file diff --git a/ThirdParty/Library/basics/utilities/UbAutoRun.hpp b/ThirdParty/Library/basics/utilities/UbAutoRun.hpp deleted file mode 100644 index c9ac45115bb4ff37c45d69e101e9a58d936e5d7e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbAutoRun.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef UB_AUTORUN_HPP -#define UB_AUTORUN_HPP - -#define UB_AUTO_RUN(func) UB_AUTO_RUN_(func, __LINE__) -#define UB_AUTO_RUN_(func, nID) UB_AUTO_RUN__(func, nID) -#define UB_AUTO_RUN__(func, nID) UB_AUTO_RUN___(func, nID) -#define UB_AUTO_RUN___(func, ID) \ - namespace { \ - struct UbAutoRun##ID { \ - UbAutoRun##ID() { \ - func; \ - } \ - } UbAutoRunInst##ID; \ - } - - // More concise to implement UB_AUTO_RUN using the following, but BCB emits an ICE on it. - //static bool UB_AutoRun##ID = ( func , false); - - -#define UB_AUTO_RUN_1(func) UB_AUTO_RUN_NAMED(func, 1) -#define UB_AUTO_RUN_2(func) UB_AUTO_RUN_NAMED(func, 2) -#define UB_AUTO_RUN_3(func) UB_AUTO_RUN_NAMED(func, 3) -#define UB_AUTO_RUN_4(func) UB_AUTO_RUN_NAMED(func, 4) -#define UB_AUTO_RUN_5(func) UB_AUTO_RUN_NAMED(func, 5) - -#define UB_AUTO_RUN_NAMED(func, name) UB_AUTO_RUN_NAMED_(func, name, __LINE__) -#define UB_AUTO_RUN_NAMED_(func, name, nID) UB_AUTO_RUN_NAMED__(func, name, nID) -#define UB_AUTO_RUN_NAMED__(func, name, nID) UB_AUTO_RUN___(func, _##name##_##nID) - -#define UB_AUTO_RUN_ONCE(func) UB_AUTO_RUN_ONCE_(func, __LINE__) -#define UB_AUTO_RUN_ONCE_(func, nID) UB_AUTO_RUN_ONCE__(func, nID) -#define UB_AUTO_RUN_ONCE__(func, nID) UB_AUTO_RUN_ONCE___(func, nID) -#define UB_AUTO_RUN_ONCE___(func, ID) \ - struct UbAutoRunOnce##ID { \ - UbAutoRunOnce##ID() { \ - if (!init()) { \ - init() = true; \ - func; \ - } \ - } \ - static bool &init() { \ - static bool bInit = false; \ - return bInit; \ - } \ - }; \ - static UbAutoRunOnce##ID AutoRunOnceInst##ID; - -#define UB_AUTO_RUN_ONCE_1(func) UB_AUTO_RUN_ONCE_NAMED(func, 1) -#define UB_AUTO_RUN_ONCE_2(func) UB_AUTO_RUN_ONCE_NAMED(func, 2) -#define UB_AUTO_RUN_ONCE_3(func) UB_AUTO_RUN_ONCE_NAMED(func, 3) -#define UB_AUTO_RUN_ONCE_4(func) UB_AUTO_RUN_ONCE_NAMED(func, 4) -#define UB_AUTO_RUN_ONCE_5(func) UB_AUTO_RUN_ONCE_NAMED(func, 5) - -#define UB_AUTO_RUN_ONCE_NAMED(func, name) UB_AUTO_RUN_ONCE_NAMED_(func, name, __LINE__) -#define UB_AUTO_RUN_ONCE_NAMED_(func, name, nID) UB_AUTO_RUN_ONCE_NAMED__(func, name, nID) -#define UB_AUTO_RUN_ONCE_NAMED__(func, name, nID) UB_AUTO_RUN_ONCE___(func, _##name##_##nID) - -#endif // ! UB_AUTORUN_HPP diff --git a/ThirdParty/Library/basics/utilities/UbComparators.h b/ThirdParty/Library/basics/utilities/UbComparators.h deleted file mode 100644 index 2d1448c93b6c0ee2b6361aad87a379140ffa0f49..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbComparators.h +++ /dev/null @@ -1,208 +0,0 @@ -#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 - template <typename T> struct MemberInfo; //not defined for correct compiler errors! - - // specialization for MemberFunctionsPtr - // C - class with return T method - template <typename T, typename C> - struct MemberInfo<T C::*> - { - typedef T type; - typedef C class_type; - - static T& apply( C& c, T C::* ptr ) { return c.*ptr; } - static const T& apply( const C& c, T C::* ptr ) { return c.*ptr; } - }; - //specialization for MemberFunctionsPtr - //C - class with return T method - template <typename T, typename C> - struct MemberInfo<T (C::*)()> - { - typedef T type; - typedef C class_type; - - static T apply( C& c, T (C::*ptr)() ) { return (c.*ptr)(); } - }; - //specialization for const MemberFunctionsPtr - //C - class with return T method - template <typename T, typename C> - struct MemberInfo<T (C::*)() const> - { - typedef T type; - typedef C class_type; - - static T apply( const C& c, T (C::*ptr)() const ) { return (c.*ptr)(); } - }; - - //MemberComparative-Class - template <typename Ptr, typename Comp = std::less<typename MemberInfo<Ptr>::type> > - class MemComp - : private Comp // -> usage of Empty Base Class Optimization (EBCO) - { - typedef typename MemberInfo<Ptr>::class_type C; - - public: - MemComp( Ptr ptr, Comp c = Comp() ) - : Comp(c), mp_(ptr) - {} - - bool operator()(C& lhs, C& rhs) - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(C& lhs, C& rhs) const - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(const C& lhs, const C& rhs) - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(const C& lhs, const C& rhs) const - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - - private: - Ptr mp_; - }; - - // Factoryfunktionen - template <typename Ptr> - MemComp<Ptr> membercomp(Ptr p) - { - return MemComp<Ptr>(p); - } - - template<typename Comp, typename Ptr> - MemComp<Ptr, Comp> membercomp(Ptr p, Comp c = Comp()) - { - return MemComp<Ptr, Comp>(p, c); - } - - template<template<typename> class Comp, typename Ptr> - MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> > - membercomp(Ptr p, Comp<typename MemberInfo<Ptr>::type> c = Comp<typename MemberInfo<Ptr>::type>()) - { - return MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> >(p, c); - } - - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - //andere Variante (alerdings ist hier keine Deduction moeglich!!!) - ////////////////////////////////////////////////////////////////////////// - //Vergleichs-Templates: - //Funktor zum "non-const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1 ); - template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() /*MethodenPointer*/> // Allgemeiner Fall - struct compareMethods - { - bool operator()(K& r, K& l) const // da fct nicht const ist, kann auch K nicht const sein. das const hinter der deklaration besagt dass compareMethods const sein kann - { return (r.*fct)() < (l.*fct)(); } - }; - ////////////////////////////////////////////////////////////////////////// - //Funktor zum "const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1 ); - template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() const /*MethodenPointer*/> // <- hier const - struct compareConstMethods - { - bool operator()(const K& r, const K& l) const //hier koennen die K's auch const sein, muessen sie aber nicht (const hinzufuegen geht ja problemlos) - { return (r.*fct)() < (l.*fct)(); } - }; - ////////////////////////////////////////////////////////////////////////// - //Funktor zum Membervergleich: lise.sort( compareMember<Klasse, int, &Klasse::member>() ); - template<typename K/*Klasse*/, typename M /*MemberTyp*/, M (K::*Member) /*MemberPointer*/> // <- hier const - struct compareMember - { - bool operator()(const K& r,const K& l) const - { return r.*Member < l.*Member; } - }; - //Bsp: - //class Klasse{ - //public: - // Klasse(double val1, double val2 ) : val1(val1),val2(val2) {} - // double getVal1() { return val1; } - // double getVal2() const { return val2; } // <- hier const - // double val1, val2; - //}; - //int main(int argc, char** argv){ - // std::list<Klasse> l; - // l.push_back( Klasse(10,10) ); - // l.push_back( Klasse(1,5) ); - // l.sort( compareMember<Klasse, double, &Klasse::val1 >() ); - // l.sort( compareMethods<Klasse, double, &Klasse::getVal1 >() ); - // l.sort( compareConstMethods<Klasse, double, &Klasse::getVal1 >() ); - //} - -}; - -#endif //UBCOMPARATOR_H - -//example -// #include <basics/utilities/UbComparators.h" -// #include <list> -// using namespace std; -// using namespace UbComparators; -// -// struct S { -// S(int i) :x(i) {} -// int x; -// float f() {return x;}; -// double g() const {return x;} -// }; -// -// struct intComp { -// bool operator()(int l, int r) const -// { return l > r; } -// }; -// -// struct dblComp { -// bool operator()(double l, double r) const -// { return l > r; } -// }; -// -// template <typename T> -// struct genComp { -// bool operator()(const T& l, const T& r) const -// { return l > r; } -// }; -// -// -// int main() -// { -// S a(1); -// S b(2); -// list<S> sList; -// sList.push_back(a); -// sList.push_back(b); -// sList.sort(UbComparators::membercomp(&S::x,intComp())); //calls overload (1) -// sList.sort(UbComparators::membercomp<intComp>(&S::x)); //same -// sList.sort(UbComparators::membercomp(&S::x)); //calls overload (5) -// sList.sort(UbComparators::membercomp<genComp>(&S::x)); //calls overload(3) -// sList.sort(UbComparators::membercomp(&S::x, genComp<int>())); //calls overload(1) -// //same for nonconst function -// sList.sort(UbComparators::membercomp(&S::f, dblComp())); //overload(2) -// sList.sort(UbComparators::membercomp<dblComp>(&S::f)); //same -// sList.sort(UbComparators::membercomp(&S::f)); //overload(6) -// sList.sort(UbComparators::membercomp<genComp>(&S::f)); //overload(4) -// //same for const function -// sList.sort(UbComparators::membercomp(&S::g, dblComp())); //overload(2) -// sList.sort(UbComparators::membercomp<dblComp>(&S::g)); //same -// sList.sort(UbComparators::membercomp(&S::g)); //overload(6) -// sList.sort(UbComparators::membercomp<genComp>(&S::g)); //overload(4) -// } diff --git a/ThirdParty/Library/basics/utilities/UbConverter.cpp b/ThirdParty/Library/basics/utilities/UbConverter.cpp deleted file mode 100644 index ad5a99923c0985192555d6ed95efd7502a0efe18..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbConverter.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include <basics/utilities/UbConverter.h> - -const std::string UbConverter::base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - -std::string UbConverter::base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) -{ - std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; - - while (in_len--) - { - char_array_3[i++] = *(bytes_to_encode++); - if( i==3) - { - char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for( i=0; i<4 ; i++) - ret += base64_chars[char_array_4[i]]; - i=0; - } - } - - if( i ) - { - for( j=i; j<3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for ( j=0; j<i+1; j++) - ret += base64_chars[char_array_4[j]]; - - while( i++<3 ) - ret += '='; - } - - return ret; -} -/*=======================================================*/ -std::string UbConverter::base64_decode(std::string const& encoded_string) -{ - int in_len = (int)encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; - std::string ret; - - while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) - { - char_array_4[i++] = encoded_string[in_]; in_++; - if(i ==4) - { - for (i = 0; i <4; i++) - char_array_4[i] = (unsigned char)base64_chars.find(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret += char_array_3[i]; - i = 0; - } - } - - if( i ) - { - for(j = i; j <4; j++) - char_array_4[j] = 0; - - for(j = 0; j <4; j++) - char_array_4[j] = (unsigned char)base64_chars.find(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for(j = 0; (j < i - 1); j++) - ret += char_array_3[j]; - } - - return ret; -} diff --git a/ThirdParty/Library/basics/utilities/UbConverter.h b/ThirdParty/Library/basics/utilities/UbConverter.h deleted file mode 100644 index 51e713cd47e832848d47a9db022078666222b3e6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbConverter.h +++ /dev/null @@ -1,49 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBCONVERTER_H -#define UBCONVERTER_H - -#include <cstdlib> -#include <ctime> -#include <cassert> -#include <string> - -/*=========================================================================*/ -/* UBConverter */ -/* */ -// -// encodes vals to e.g. base64 -// dencodes vals from e.g. base64 -// author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -// version 1.0 - 22.10.2007 - - -class UbConverter -{ -public: - static std::string base64_encode(unsigned char const* , unsigned int len); - static std::string base64_decode(std::string const& s); - - static inline bool is_base64(const unsigned char& c) - { - return (isalnum(c) || (c == '+') || (c == '/')); - } - -protected: - UbConverter() {} - ~UbConverter() {} - -private: - UbConverter(const UbConverter&); // not implemented. - void operator=(const UbConverter&); //not implemented. - - static const std::string base64_chars; -}; - - - -#endif //UBCONVERTER_H diff --git a/ThirdParty/Library/basics/utilities/UbEqual.h b/ThirdParty/Library/basics/utilities/UbEqual.h deleted file mode 100644 index e838aca00223d0e0064784dc555ee51d13efe144..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbEqual.h +++ /dev/null @@ -1,120 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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; } -// -// -//author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//version 1.0 - 25.03.2008 -////////////////////////////////////////////////////////////////////////// - -//std-trait, fuer alle nicht spezifischen typen: -template < typename T1, typename T2 > -struct UbEqualTrait -{ - typedef T1 High; - typedef T1 Low; -}; - -//std-trait, fuer gleiche T -template < typename T > -struct UbEqualTrait< T, T > -{ - typedef T High; - typedef T Low; -}; - -//spezialisierung für 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; }; -template<> struct UbEqualTrait< short, double > { typedef double High; typedef short Low; }; -template<> struct UbEqualTrait< short, long double > { typedef long double High; typedef short Low; }; - -template<> struct UbEqualTrait< int, short > { typedef int High; typedef short Low; }; -template<> struct UbEqualTrait< int, long > { typedef long High; typedef int Low; }; -template<> struct UbEqualTrait< int, float > { typedef float High; typedef int Low; }; -template<> struct UbEqualTrait< int, double > { typedef double High; typedef int Low; }; -template<> struct UbEqualTrait< int, long double > { typedef long double High; typedef int Low; }; - -template<> struct UbEqualTrait< long, short > { typedef long High; typedef short Low; }; -template<> struct UbEqualTrait< long, int > { typedef long High; typedef int Low; }; -template<> struct UbEqualTrait< long, float > { typedef float High; typedef long Low; }; -template<> struct UbEqualTrait< long, double > { typedef double High; typedef long Low; }; -template<> struct UbEqualTrait< long, long double > { typedef long double High; typedef long Low; }; - -template<> struct UbEqualTrait< float, short > { typedef float High; typedef short Low; }; -template<> struct UbEqualTrait< float, int > { typedef float High; typedef int Low; }; -template<> struct UbEqualTrait< float, long > { typedef float High; typedef long Low; }; -template<> struct UbEqualTrait< float, double > { typedef double High; typedef float Low; }; -template<> struct UbEqualTrait< float, long double > { typedef long double High; typedef float Low; }; - -template<> struct UbEqualTrait< double, short > { typedef double High; typedef short Low; }; -template<> struct UbEqualTrait< double, int > { typedef double High; typedef int Low; }; -template<> struct UbEqualTrait< double, long > { typedef double High; typedef long Low; }; -template<> struct UbEqualTrait< double, float > { typedef double High; typedef float Low; }; -template<> struct UbEqualTrait< double, long double > { typedef long double High; typedef double Low; }; - -template<> struct UbEqualTrait< long double, short > { typedef long double High; typedef short Low; }; -template<> struct UbEqualTrait< long double, int > { typedef long double High; typedef int Low; }; -template<> struct UbEqualTrait< long double, long > { typedef long double High; typedef long Low; }; -template<> struct UbEqualTrait< long double, float > { typedef long double High; typedef float Low; }; -template<> struct UbEqualTrait< long double, double > { typedef long double High; typedef double Low; }; - -////////////////////////////////////////////////////////////////////////// -//fuer Allgmeine-Typen ( operator== ): -template< typename T1, typename T2 > -inline bool specific_equal(const T1& a, const T2& b) { return a==b; } - -////////////////////////////////////////////////////////////////////////// -//fuer floating point build-in-type -//float.float -template< /*float,float*/> -inline bool specific_equal< float, float >(const float& a, const float& b) { return std::fabs( a - b ) < 1E-8; } - -template</*double,double*/> -inline bool specific_equal< double, double >(const double& a, const double& b) { return std::fabs( a - b ) < 1E-13; } - -template</*long double,long double*/> -inline bool specific_equal< long double, long double >(const long double& a, const long double& b) { return std::fabs( a - b ) < 1E-16; } - -////////////////////////////////////////////////////////////////////////// -//globale isUbEqual - Funktion -template< typename T1, typename T2 > -inline bool isUbEqual(const T1& a, const T2& b) -{ - typedef typename UbEqualTrait<T1,T2>::Low Low; - return specific_equal< Low, Low >(static_cast< Low >( a ),static_cast< Low >( b )); -}; - -////////////////////////////////////////////////////////////////////////// -//UbEqual-Functor -template< typename T1, typename T2 > -struct UbEqual -{ - bool operator()(const T1& a, const T2& b) - { - return isUbEqual(a,b); - } -}; - -#endif //UBEQUAL_H diff --git a/ThirdParty/Library/basics/utilities/UbException.h b/ThirdParty/Library/basics/utilities/UbException.h deleted file mode 100644 index 48d1e1a60065d6f6e057aafa59abded38b800664..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbException.h +++ /dev/null @@ -1,163 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBEXCEPTION_H -#define UBEXCEPTION_H - -#include <vector> -#include <iostream> -#include <string> -#include <sstream> -#include <stdexcept> - -#include <boost/exception/all.hpp> - -#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 -*/ - -//Macro UB_FUNCTION: figures out the method/function name (platform dependant) -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) - # define UB_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__DMC__) && (__DMC__ >= 0x810) - # define UB_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__FUNCSIG__) - # define UB_FUNCTION __FUNCSIG__ -#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) - # define UB_FUNCTION __FUNCTION__ -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) - # define UB_FUNCTION __FUNC__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) - # define UB_FUNCTION __func__ -#else - # define UB_FUNCTION "(unknown)" -#endif - -//Helper Marco -#define UB_EXARGS __FILE__,__LINE__,UB_FUNCTION - -#ifdef CAB_BOOST - #define UB_THROW(e) throw boost::enable_current_exception(e) -#else - #define UB_THROW(e) throw e -#endif - -class UbException : public std::runtime_error, public boost::exception -{ -public: - typedef UbTuple< std::string, int, std::string, std::string > ExceptionData; -public: - ////////////////////////////////////////////////////////////////////////// - //constructors - UbException() - : std::runtime_error("") - { - } - /*==========================================================*/ - UbException(const std::string& str) - : std::runtime_error("") - { - this->addInfo(str); - } - /*==========================================================*/ - UbException(const std::string& file, const int& line, const std::string& err_str) - : std::runtime_error("") - { - this->addInfo(file,line,"unknown",err_str); - } - /*==========================================================*/ - //UbException(const char* file, const int& line, const char* function, const std::string& err_str) - UbException(const std::string& file, const int& line, const std::string& function, const std::string& err_str) - : std::runtime_error("") - { - this->addInfo(file,line,function,err_str); - } - ////////////////////////////////////////////////////////////////////////// - //destructor - virtual ~UbException() throw() { } - ////////////////////////////////////////////////////////////////////////// - //virtual public methods - //returns exception-string - virtual const char* what() const throw() - { - exceptionString = this->toString(); - return exceptionString.c_str(); //ansonsten ist das Verhalten anschließend undefiniert! - } - /*==========================================================*/ - virtual void addInfo(const std::string& err_str) - { - exceptionData.push_back( makeUbTuple( (std::string)"-", 0, (std::string)"unknown", err_str) ); - } - /*==========================================================*/ - //add exception - virtual void addInfo(const std::string& file, const int& line, const std::string& function, const std::string& err_str) - { - exceptionData.push_back( makeUbTuple( file, line, function, err_str ) ); - } - /*==========================================================*/ - //returns exception-string with all calles exceptions - virtual const std::vector<std::string> getInfo() const - { - std::vector<std::string> tmp; - for(std::size_t i=0; i<exceptionData.size(); i++) - { - std::stringstream str; - str << val<1>( exceptionData[i] ) << ", " - << val<2>( exceptionData[i] ) << ", " - << val<3>( exceptionData[i] ) << ", " - << val<4>( exceptionData[i] ); - tmp.push_back( str.str()); - } - return tmp; - } - /*==========================================================*/ - //returns exception-string with all calles exceptions and detailes informations - virtual std::string toString() const - { - std::stringstream str("UbExeption"); - - for(std::size_t i=0; i<exceptionData.size(); i++) - str<<(std::string)"caller[" << i << "]\n" - <<" - file: "<< val<1>( exceptionData[i] )<<"\n" - <<" - line: "<< val<2>( exceptionData[i] )<<"\n" - <<" - function: "<< val<3>( exceptionData[i] )<<"\n" - <<" - what: "<< val<4>( exceptionData[i] )<< std::endl; - - return str.str(); - } - -protected: - ////////////////////////////////////////////////////////////////////////// - //protected member - std::vector< ExceptionData > exceptionData; - mutable std::string exceptionString; -}; - -//overlading operator << -inline std::ostream& operator<<(std::ostream& os, const UbException& e) -{ - return os<<e.toString(); -} - -#endif //UBEXCEPTION_H diff --git a/ThirdParty/Library/basics/utilities/UbFileInput.h b/ThirdParty/Library/basics/utilities/UbFileInput.h deleted file mode 100644 index 3b08a7fdb532c3b5b45cc14d3315dd1eee52b379..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileInput.h +++ /dev/null @@ -1,97 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUT_H -#define UBFILEINPUT_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <cstdlib> //atoi -#include <cstring> //strstr - -#include <basics/utilities/UbException.h> - -/*=========================================================================*/ -/* UbFileInput */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInput -{ -public: - enum FILETYPE {ASCII, BINARY}; - -public: - UbFileInput() : filename(""), commentindicator('C') { } - virtual ~UbFileInput() { infile.close(); } - - virtual bool operator!() { return !(infile); } - virtual bool isOpen() { return !(!(infile)); } - - virtual bool open(std::string filename)=0; - virtual void close() { infile.close(); } - virtual int eof() { return infile.eof(); } - - virtual void skipLine()=0; // Springt zur naechsten Zeile - virtual void readLine()=0; - virtual std::string readStringLine()=0; - virtual int readInteger()=0; // Liest einen Int-Wert ein - virtual std::size_t readSize_t()=0; - virtual double readDouble()=0; // Liest einen double-Wert ein - virtual float readFloat()=0; // Liest einen float-Wert ein - virtual bool readBool()=0; // Liest einen bool-Wert ein - virtual char readChar()=0; // Liest einen char-Wert ein - virtual std::string readString()=0; // Liest ein Wort ein - virtual std::string readLineTill(char stop)=0; // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - virtual std::string parseString()=0; // Liest - - virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - virtual bool containsString( const std::string& var)=0; - virtual void setPosAfterLineWithString( const std::string& var)=0; - virtual int readIntegerAfterString( const std::string& var)=0; - virtual double readDoubleAfterString( const std::string& var)=0; - virtual bool readBoolAfterString( const std::string& var)=0; - virtual std::string readStringAfterString( const std::string& var)=0; - - virtual std::string getFileName() {return this->filename;} - - //returns file extension: - //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> "" - virtual std::string getFileExtension() - { - std::size_t pos1 = filename.rfind("/"); - if(pos1==std::string::npos) pos1 = 0; - std::size_t pos2 = filename.rfind("."); - if(pos2!=std::string::npos && pos2>pos1) - return filename.substr(pos2+1); - - return ""; - } - - //returns "ASCII", "BINARY" - virtual FILETYPE getFileType()=0; - -protected: - std::ifstream infile; - std::string filename; - char commentindicator; -}; - -#endif //UBFILEINPUT_H - - diff --git a/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp b/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp deleted file mode 100644 index d17d69cf9c3555f3ab742ec5922e3872ba93b796..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include <basics/utilities/UbFileInputASCII.h> -#include <cstring> - -using namespace std; - -UbFileInputASCII::UbFileInputASCII(string filename) -{ - this->filename = filename; - this->commentindicator = 'C'; - - infile.open(filename.c_str()); - - //if(!infile) UB_THROW( UbException((string)("UbFileInputASCII::UbFileInputASCII(string filename, int how) couldn't open file:\n "+filename)) ); -} -/*==========================================================*/ -bool UbFileInputASCII::open(string filename) -{ - infile.close(); - infile.clear(); //setzt flags zurueck - - this->filename = filename; - infile.open(this->filename.c_str()); - - return infile.is_open(); -} -/*==========================================================*/ -int UbFileInputASCII::readInteger() -{ - int dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::getFileName() -{ - return this->filename; -} - -/*==========================================================*/ -void UbFileInputASCII::skipLine() -{ - string dummy; - getline(infile, dummy); -} -/*==========================================================*/ -void UbFileInputASCII::readLine() -{ - string dummy; - getline(infile, dummy); -} -/*==========================================================*/ -string UbFileInputASCII::readStringLine() -{ - string dummy; - getline(infile, dummy); - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::readLineTill(char stop) -{ - string dummy; - getline(infile, dummy, stop); - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::parseString() -{ - string dummy; - getline(infile, dummy, ' '); - return dummy; -} -/*==========================================================*/ -double UbFileInputASCII::readDouble() -{ - double dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -float UbFileInputASCII::readFloat() -{ - float dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::readString() -{ - string dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -char UbFileInputASCII::readChar() -{ - int dummy; - infile>>dummy; - return (char)dummy; -} -/*==========================================================*/ -std::size_t UbFileInputASCII::readSize_t() -{ - std::size_t dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -void UbFileInputASCII::setPosAfterLineWithString(const string& var) -{ - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - infile.getline(line,512); - if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> string "+var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt -} -/*==========================================================*/ -bool UbFileInputASCII::containsString(const string& var) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - infile.getline(line,512); - if(infile.eof()) return false; - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - return true; -} -/*==========================================================*/ -int UbFileInputASCII::readIntegerAfterString(const string& var) -// last change [10.3.2004] at [9:46] -//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. timesteps 9 -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - infile.getline(line,512); - if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return(atoi(line)); // Umwandlung in int -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -double UbFileInputASCII::readDoubleAfterString(const string& var) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - infile.getline(line,512); - if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) ); - }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return (atof(line)); // Umwandlung in double -} -/*==========================================================*/ -// [9.9.2002] -// liefert string-Wert der hinter dem uebergebenen char feld in der datei infile steht -// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig) -string UbFileInputASCII::readStringAfterString(const string& var)//,char *value) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - //string line_copy[512]; - - do{ - infile.getline(line,512); - if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - char *p; - p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab - p=strtok(line,"\t");//schneidet alles "ab und inklusive tab " nach namen ab - - return static_cast<string>(p); // Umwandlung in string -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbFileInputASCII::readBoolAfterString(const string& var) -{ - if(this->readStringAfterString(var) == "true" ) return true; - else if(this->readStringAfterString(var) == "false") return false; - else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression after "+var+" is not equal to 'true' or 'false' in "+this->filename) ); -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbFileInputASCII::readBool() -{ - string tmp = this->readString(); - if( tmp == "true" ) return true; - else if(tmp == "false") return false; - else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression=\""+tmp+"\" is not equal to 'true' or 'false' in "+this->filename) ); -} diff --git a/ThirdParty/Library/basics/utilities/UbFileInputASCII.h b/ThirdParty/Library/basics/utilities/UbFileInputASCII.h deleted file mode 100644 index 77c07137bbaf9c9b542ac1b1e939729af15dd85f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileInputASCII.h +++ /dev/null @@ -1,73 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTASCII_H -#define UBFILEINPUTASCII_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -/*=========================================================================*/ -/* UbFileInputASCII */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInputASCII : public UbFileInput -{ -public: - UbFileInputASCII() : UbFileInput() { } - UbFileInputASCII(std::string filename); - - bool open(std::string filename); - - std::string getFileName(); - void skipLine(); // Springt zur naechsten Zeile - - void readLine(); - std::string readStringLine(); - int readInteger(); // Liest einen Int-Wert ein - std::size_t readSize_t(); - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); - - bool containsString(const std::string& var); - void setPosAfterLineWithString(const std::string& var); - int readIntegerAfterString(const std::string& var); - double readDoubleAfterString(const std::string& var); - bool readBoolAfterString(const std::string& var); - std::string readStringAfterString(const std::string& var); - - FILETYPE getFileType() { return ASCII; } - - template< typename T > - friend inline UbFileInputASCII& operator>>(UbFileInputASCII& file, T& data) - { - file.infile>>data; - return file; - } -}; - -#endif //UBFILEINPUTASCII_H - - diff --git a/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp b/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp deleted file mode 100644 index 0bcf60ce0ca665403e95d6f0f5366e03c18382fb..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include <basics/utilities/UbFileInputBinary.h> -#include <cstring> - -using namespace std; - -/*==========================================================*/ -UbFileInputBinary::UbFileInputBinary(string filename) -{ - this->filename = filename; - infile.open(filename.c_str(), ios::in | ios::binary); -} -/*==========================================================*/ -bool UbFileInputBinary::open(string filename) -{ - infile.close(); - infile.clear(); //setzt flags zurueck - - this->filename = filename; - infile.open(this->filename.c_str(), ios::in | ios::binary); - - return infile.is_open(); -} -/*==========================================================*/ -int UbFileInputBinary::readInteger() -{ - int dummy; - infile.read((char*)&dummy,sizeof(int)); - return dummy; -} -/*==========================================================*/ -std::size_t UbFileInputBinary::readSize_t() -{ - std::size_t dummy; - infile.read((char*)&dummy,sizeof(std::size_t)); - return dummy; -} -/*==========================================================*/ -double UbFileInputBinary::readDouble() -{ - double dummy; - infile.read((char*)&dummy,sizeof(double)); - return dummy; -} -/*==========================================================*/ -float UbFileInputBinary::readFloat() -{ - float dummy; - infile.read((char*)&dummy,sizeof(float)); - return dummy; -} -/*==========================================================*/ -char UbFileInputBinary::readChar() -{ - char dummy; - infile.read((char*)&dummy,sizeof(char)); - return dummy; -} -/*==========================================================*/ -string UbFileInputBinary::readString() -{ - char c; - infile.read(&c,sizeof(char)); - while(c==' ' || c=='\t') infile.read(&c,sizeof(char)); - - string dummy; - dummy+=c; - - infile.read(&c,sizeof(char)); - while(c!='\0' && c!=' ' && c!='\t' && c!='\n') - { - dummy+=c; - infile.read(&c,sizeof(char)); - } - return dummy; -} -/*==========================================================*/ -bool UbFileInputBinary::readBool() -{ - bool dummy; - infile.read((char*)&dummy,sizeof(bool)); - return dummy; -} -/*==========================================================*/ -void UbFileInputBinary::skipLine() -{ - char c; - do{ - infile.read(&c,sizeof(char)); - }while(c!='\n'); -} -/*==========================================================*/ -void UbFileInputBinary::readLine() -{ - char c; - infile.read(&c,sizeof(char)); - while(c!='\n') infile.read(&c,sizeof(char)); -} -/*==========================================================*/ -string UbFileInputBinary::readStringLine() -{ - char c; - string dummy; - infile.read(&c,sizeof(char)); - while(c!='\n') - { - dummy+=c; - infile.read(&c,sizeof(char)); - } - return dummy; -} -/*==========================================================*/ -string UbFileInputBinary::readLineTill(char stop) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -string UbFileInputBinary::parseString() -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -bool UbFileInputBinary::containsString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -void UbFileInputBinary::setPosAfterLineWithString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -int UbFileInputBinary::readIntegerAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -double UbFileInputBinary::readDoubleAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -string UbFileInputBinary::readStringAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -bool UbFileInputBinary::readBoolAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} diff --git a/ThirdParty/Library/basics/utilities/UbFileInputBinary.h b/ThirdParty/Library/basics/utilities/UbFileInputBinary.h deleted file mode 100644 index 1e994ba792ccf82941cd6cf2aba87e5edeb9f51e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileInputBinary.h +++ /dev/null @@ -1,71 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTBINARY_H -#define UBFILEINPUTBINARY_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -/*=========================================================================*/ -/* UbFileInputBinary */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInputBinary : public UbFileInput -{ -public: - UbFileInputBinary() : UbFileInput() { } - UbFileInputBinary(std::string filename); - - bool open(std::string filename); - - void skipLine(); // Springt zur naechsten Zeile - void readLine(); - std::string readStringLine(); - std::size_t readSize_t(); - int readInteger(); // Liest einen Int-Wert ein - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); // Liest - - bool containsString(const std::string& var); - void setPosAfterLineWithString(const std::string& var); - int readIntegerAfterString(const std::string& var); - double readDoubleAfterString(const std::string& var); - bool readBoolAfterString(const std::string& var); - std::string readStringAfterString(const std::string& var); - - FILETYPE getFileType() { return BINARY; } - - template< typename T > - friend inline UbFileInputBinary& operator>>(UbFileInputBinary& file, T& data) - { - file.infile.read((char*)&data,sizeof(T)); - return file; - } -}; - -#endif - - diff --git a/ThirdParty/Library/basics/utilities/UbFileOutput.h b/ThirdParty/Library/basics/utilities/UbFileOutput.h deleted file mode 100644 index c55dd82fcf5074e66f709fb662dd680732dacbc3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileOutput.h +++ /dev/null @@ -1,93 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUT_H -#define UBFILEOUTPUT_H - -#include <iomanip> -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> - -/*=========================================================================*/ -/* UbFileOutput */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutput -{ -public: - enum CREATEOPTION {OUTFILE=0, INANDOUTFILE=1, APPENDFILE=2}; - enum FILETYPE {ASCII, BINARY}; - -public: - UbFileOutput() : filename(""), commentindicator('C') { } - UbFileOutput(const std::string& filename) : filename(filename), commentindicator('C') { } - virtual ~UbFileOutput() { outfile.flush();outfile.close(); } - - virtual bool open(const std::string& filename, CREATEOPTION opt=OUTFILE) = 0; - - virtual bool operator!() { return !(outfile); } - virtual bool isOpen() { return !(!(outfile)); } - - virtual void flush() { outfile.flush(); } - virtual void close() { outfile.close(); } - - virtual void writeInteger(const int& value, const int& width=0)=0; - virtual void writeDouble(const double& value, const int& width=0)=0; - virtual void writeFloat(const float& value, const int& width=0)=0; - virtual void writeBool(const bool& value, const int& width=0)=0; - virtual void writeSize_t(const std::size_t& value, const int& width=0)=0; - virtual void writeChar(const char& value, const int& width=0)=0; - virtual void writeString(const std::string& value, const int& width=0)=0; - virtual void writeStringOnly(const std::string& value)=0; - virtual void writeLine(const std::string& value, const int& width=0)=0; - virtual void writeLine()=0; - - virtual void writeCommentLine(const std::string& line)=0; - virtual void writeCommentLine(char indicator, const std::string& line)=0; - virtual void writeCopyOfFile(const std::string& filename)=0; - - virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - virtual void setPrecision(const int& precision)=0; - virtual int getPrecision()=0; - - //returns "ASCII", "BINARY" - virtual FILETYPE getFileType()=0; - - //returns file extension: - //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> "" - virtual std::string getFileExtension() - { - std::size_t pos1 = filename.rfind("/"); - if(pos1==std::string::npos) pos1 = 0; - std::size_t pos2 = filename.rfind("."); - if(pos2!=std::string::npos && pos2>pos1) - return filename.substr(pos2+1); - - return ""; - } - - virtual std::string getFileName() {return this->filename;} -protected: - std::ofstream outfile; - std::string filename; - char commentindicator; -}; - -#endif //UBFILEOUTPUT_H diff --git a/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp b/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp deleted file mode 100644 index d68a766be8622f1138f6a0e22863b0962141f0bc..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp +++ /dev/null @@ -1,177 +0,0 @@ -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbInfinity.h> -#include <basics/utilities/UbMath.h> -#include <cstring> - -using namespace std; - -UbFileOutputASCII::UbFileOutputASCII(const string& filename, const bool& createPath, const int& precision) - : UbFileOutput(filename) -{ - this->commentindicator = 'C'; - this->setPrecision(20); - - outfile.open(filename.c_str(),ios::out); - - if(!outfile && createPath) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - UbSystem::makeDirectory(path); - outfile.open(filename.c_str(),ios::out); - } - } - - if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); -} -/*==========================================================*/ -UbFileOutputASCII::UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath, const int& precision) - : UbFileOutput(filename) -{ - this->commentindicator = 'C'; - this->setPrecision(precision); - - if(!this->open(filename,opt) && createPath) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) UbSystem::makeDirectory(path); - - this->open(filename,opt); - } - - if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); -} -/*==========================================================*/ -bool UbFileOutputASCII::open(const std::string& filename, CREATEOPTION opt) -{ - outfile.close(); - outfile.clear(); //setzt flags zurueck - this->filename = filename; - - if (opt==UbFileOutput::OUTFILE ) outfile.open(this->filename.c_str(),ios::out); - else if(opt==UbFileOutput::INANDOUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::in); - else if(opt==UbFileOutput::APPENDFILE ) outfile.open(this->filename.c_str(),ios::app); - else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") ); - - return outfile.is_open(); -} -/*==========================================================*/ -void UbFileOutputASCII::writeBool(const bool& value, const int& width) -{ - outfile.width(width); - if(value) outfile<<"true "; - else outfile<<"false "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeDouble(const double& value, const int& width) -{ - outfile.width(width); - //Problem: Ub::inf wird gerundet - // -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus - // -> max Laenge darstellen und gut ist - if(UbMath::equal(value, (double)Ub::inf) ) - { - ios_base::fmtflags flags = outfile.flags(); - outfile<<setprecision(std::numeric_limits<double>::digits10+2); - outfile<<value<<" "; - outfile.flags(flags); - return; - } - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeFloat(const float& value, const int& width) -{ - outfile.width(width); - //Problem: Ub::inf wird gerundet - // -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus - // -> max Laenge darstellen und gut ist - if(UbMath::equal(value, (float)Ub::inf) ) - { - ios_base::fmtflags flags = outfile.flags(); - outfile<<setprecision(std::numeric_limits<float>::digits10+2); - outfile<<value<<" "; - outfile.flags(flags); - return; - } - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::setPrecision(const int& precision) -{ - outfile<<setprecision(precision); -} -/*==========================================================*/ -void UbFileOutputASCII::writeInteger(const int& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeSize_t(const std::size_t& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeChar(const char& value, const int& width) -{ - outfile.width(width); - outfile<<(int)value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeString(const string& value, const int& width) -{ - outfile.width(width); - outfile<<value.c_str()<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeStringOnly(const string& value) -{ - outfile<<value.c_str(); -} - -/*==========================================================*/ -void UbFileOutputASCII::writeLine(const string& value, const int& width) -{ - outfile.width(width); - outfile<<value.c_str()<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeLine() -{ - outfile<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeCommentLine(const string& line) -{ - this->writeCommentLine(this->commentindicator, line); -} -/*==========================================================*/ -void UbFileOutputASCII::writeCommentLine(char indicator, const string& line) -{ - this->outfile<<indicator<<line<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeCopyOfFile(const string& filename) -{ - ifstream infile(filename.c_str()); - if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); - - try - { - char c; - while(infile.get(c)) - { - outfile.put(c); //=out<<c; - } - outfile.flush(); - infile.close(); - } - catch(std::exception& e) { UB_THROW( UbException(UB_EXARGS,"catched std::exception, error: "+(std::string)e.what()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown error") ); } -} diff --git a/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h b/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h deleted file mode 100644 index c0accdfbefc4f78aefc4812ff6f10fbce7e13ac7..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h +++ /dev/null @@ -1,72 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUTASCII_H -#define UBFILEOUTPUTASCII_H - -#include <iomanip> -#include <fstream> -#include <iostream> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileOutput.h> - -/*=========================================================================*/ -/* UbFileOutputASCII */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutputASCII : public UbFileOutput -{ -public: - UbFileOutputASCII() : UbFileOutput() {} - UbFileOutputASCII(const std::string& filename, const bool& createPath=true, const int& precision=15); - UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath=true, const int& precision=15); - - bool open(const std::string& filename, CREATEOPTION opt=OUTFILE); - - void writeBool(const bool& value, const int& width=0); - void writeDouble(const double& value, const int& width=0); - void writeFloat(const float& value, const int& width=0); - void writeInteger(const int& value, const int& width=0); - void writeSize_t(const std::size_t& value, const int& width=0); - void writeChar(const char& value, const int& width=0); - void writeString(const std::string& value, const int& width=0); - void writeStringOnly(const std::string& value); - void writeLine(const std::string& value, const int& width=0); - void writeLine(); - - void setPrecision(const int& precision); - int getPrecision() { return (int)outfile.precision(); } - - void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - void writeCommentLine(const std::string& line); - void writeCommentLine(char indicator, const std::string& line); - void writeCopyOfFile(const std::string& filename); - - FILETYPE getFileType() { return ASCII; } - - template< typename T > - friend inline UbFileOutputASCII& operator<<(UbFileOutputASCII& file, const T& data) - { - file.outfile<<data; - return file; - } -}; - -#endif - - diff --git a/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp b/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp deleted file mode 100644 index 144adbc76b1b020f049f237bbd23c496110ebd9a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include <basics/utilities/UbFileOutputBinary.h> -#include <basics/utilities/UbSystem.h> -#include <cstring> - -using namespace std; - -/*==========================================================*/ -UbFileOutputBinary::UbFileOutputBinary(const string& filename, const bool& createPath) -{ - this->filename = filename; - this->commentindicator = 'C'; - - outfile.open(filename.c_str(),ios::out | ios::binary); - - if(!outfile && createPath) - { - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - UbSystem::makeDirectory(path); - outfile.open(filename.c_str(),ios::out | ios::binary); - } - } - - if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); - -} -/*==========================================================*/ -UbFileOutputBinary::UbFileOutputBinary(const string& filename,UbFileOutput::CREATEOPTION opt, const bool& createPath) -{ - this->filename = filename; - this->commentindicator = 'C'; - - this->open(filename,opt); - - if(!this->open(filename,opt) && createPath) - { - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - UbSystem::makeDirectory(path,20); - - this->open(filename,opt); - } - } - - if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); -} -/*==========================================================*/ -bool UbFileOutputBinary::open(const string& filename, UbFileOutput::CREATEOPTION opt) -{ - outfile.close(); - outfile.clear(); //setzt flags zurueck - - this->filename = filename; - - if (opt==UbFileOutput::OUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::binary); - else if(opt==UbFileOutput::APPENDFILE ) outfile.open(this->filename.c_str(),ios::app | ios::binary); - else if(opt==UbFileOutput::INANDOUTFILE) UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION - INANDOUTFILE not possible for BINARY files") ); - else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") ); - - return outfile.is_open(); -} -/*==========================================================*/ -void UbFileOutputBinary::writeBool(const bool& value, const int& width) -{ - outfile.write((char*)&value,sizeof(bool)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeDouble(const double& value, const int& width) -{ - outfile.write((char*)&value,sizeof(double)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeFloat(const float& value, const int& width) -{ - outfile.write((char*)&value,sizeof(float)); -} -/*==========================================================*/ -void UbFileOutputBinary::setPrecision(const int& precision) -{ - UB_THROW( UbException(UB_EXARGS,"no way") ); -} -/*==========================================================*/ -int UbFileOutputBinary::getPrecision() -{ - UB_THROW( UbException(UB_EXARGS,"no way") ); -} -/*==========================================================*/ -void UbFileOutputBinary::writeInteger(const int& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeSize_t(const std::size_t& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeChar(const char& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeString(const string& value, const int& width) -{ - char c='\0'; - unsigned int length = (unsigned)value.length(); - - unsigned pos; - //whitespaces und tabs am stringanfang uebergehen - for(pos=0; pos<length; pos++) - if( value[pos]!=' ' && value[pos]!='\t' ) break; - - while(pos<length) - { - while(pos<length && value[pos]!=' ' && value[pos]!='\t' && value[pos]!='\0') - { - outfile.write((char*)&(value[pos++]),sizeof(char)); - } - - outfile.write(&c,sizeof(char)); - pos++; - - while(pos<length && (value[pos]==' ' || value[pos]=='\t' || value[pos]=='\0') ) - { - pos++; - } - } -} -/*==========================================================*/ -void UbFileOutputBinary::writeStringOnly(const string& value) -{ - UbException(UB_EXARGS,"no way... causes to many errors"); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLine(const std::string& value, const int& width) -{ - this->writeString(value); - char c='\n'; - outfile.write(&c,sizeof(char)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLine() -{ - char c='\n'; - outfile.write(&c,sizeof(char)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeCommentLine(const string& line) -{ - try { this->writeCommentLine(this->commentindicator, line); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown error") ); } -} -/*==========================================================*/ -void UbFileOutputBinary::writeCommentLine(char indicator, const string& line) -{ - string dummy = indicator + line; - this->writeLine(dummy); -} -/*==========================================================*/ -void UbFileOutputBinary::writeCopyOfFile(const string& filename) -{ - ifstream infile(filename.c_str(),ios::in | ios::binary); - if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) ); - - try - { - char c; - while(infile.get(c)) - { - outfile.put(c); //=out<<c; - } - outfile.flush(); - infile.close(); - } - catch(...) {UB_THROW( UbException(UB_EXARGS,"unknown error") );} -} diff --git a/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h b/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h deleted file mode 100644 index fac53e7ac439f4fe55410043f5830ff72fc4c852..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h +++ /dev/null @@ -1,70 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUTBINARY_H -#define UBFILEOUTPUTBINARY_H - -#include <iomanip> -#include <fstream> -#include <iostream> - - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileOutput.h> - -/*=========================================================================*/ -/* UbFileOutputBinary */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutputBinary : public UbFileOutput -{ -public: - UbFileOutputBinary() : UbFileOutput() {} - UbFileOutputBinary(const std::string& filename, const bool& createPath=true); - UbFileOutputBinary(const std::string& filename, UbFileOutput::CREATEOPTION opt, const bool& createPath); - - bool open(const std::string& filename, UbFileOutput::CREATEOPTION opt=OUTFILE); - - void writeInteger(const int& value, const int& width=0); - void writeDouble(const double& value, const int& width=0); - void writeFloat(const float& value, const int& width=0); - void writeBool(const bool& value, const int& width=0); - void writeChar(const char& value, const int& width=0); - void writeSize_t(const std::size_t& value, const int& width=0); - void writeString(const std::string& value, const int& width=0); - void writeStringOnly(const std::string& value); - void writeLine(const std::string& value, const int& width=0); - void writeLine(); - void writeCommentLine(const std::string& line); - void writeCommentLine(char indicator, const std::string& line); - void writeCopyOfFile(const std::string& filename); - - void setPrecision(const int& precision); - int getPrecision(); - - FILETYPE getFileType() { return BINARY; } - - template< typename T > - friend inline UbFileOutputBinary& operator<<(UbFileOutputBinary& file, const T& data) - { - file.outfile.write((char*)&data,sizeof(T)); - return file; - } -}; - -#endif - - diff --git a/ThirdParty/Library/basics/utilities/UbInfinity.h b/ThirdParty/Library/basics/utilities/UbInfinity.h deleted file mode 100644 index 18546b8ad9d29c6c6119446243953ae235342724..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbInfinity.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef UB_INFINITY_H -#define UB_INFINITY_H -#include <limits> - -#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. -////////////////////////////////////////////////////////////////////////// -class UbNegInfinity -{ - public: - //name Conversion operators - inline operator signed char() const { return UbLimits<signed char>::ninf(); } - inline operator char() const { return UbLimits<char>::ninf(); } - inline operator wchar_t() const { return UbLimits<wchar_t>::ninf(); } - inline operator short() const { return UbLimits<short>::ninf(); } - inline operator int() const { return UbLimits<int>::ninf(); } - inline operator long() const { return UbLimits<long>::ninf(); } - inline operator float() const { return UbLimits<float>::ninf(); } - 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. - template< typename T > - inline bool equal( const T& rhs ) const - { - UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized ); - return UbLimits<T>::ninf() == rhs; - } - protected: - inline UbNegInfinity() {} - - private: - UbNegInfinity( const UbNegInfinity& ninf ); //copy constructor (private & undefined) - UbNegInfinity& operator=( const UbNegInfinity& ninf ); //copy assignment operator (private & undefined) - void* operator&() const; //address operator (private & undefined) -}; - -//================================================================================================= -// -// GLOBAL OPERATORS -// -//================================================================================================= -template< typename T > -inline bool operator==( const UbNegInfinity& lhs, const T& rhs ) -{ - return lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator==( const T& lhs, const UbNegInfinity& rhs ) -{ - return rhs.equal( lhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const UbNegInfinity& lhs, const T& rhs ) -{ - return !lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const T& lhs, const UbNegInfinity& rhs ) -{ - return !rhs.equal( lhs ); -} - -////////////////////////////////////////////////////////////////////////// -// -// UbInfinity -// -////////////////////////////////////////////////////////////////////////// -class UbInfinity : public UbNegInfinity //um später -UbInfinity leichter zu implementieren!!! -{ - public: - inline UbInfinity() - : UbNegInfinity() - {} - - inline operator unsigned char() const { return UbLimits<unsigned char>::inf(); } - inline operator signed char() const { return UbLimits<signed char>::inf(); } - inline operator char() const { return UbLimits<char>::inf(); } - inline operator wchar_t() const { return UbLimits<wchar_t>::inf(); } - inline operator unsigned short() const { return UbLimits<unsigned short>::inf(); } - inline operator short() const { return UbLimits<short>::inf(); } - inline operator unsigned int() const { return UbLimits<unsigned int>::inf(); } - inline operator int() const { return UbLimits<int>::inf(); } - inline operator unsigned long() const { return UbLimits<unsigned long>::inf(); } - inline operator long() const { return UbLimits<long>::inf(); } - inline operator float() const { return UbLimits<float>::inf(); } - inline operator double() const { return UbLimits<double>::inf(); } - inline operator long double() const { return UbLimits<long double>::inf(); } - - inline const UbNegInfinity& operator-() const { return static_cast<const UbNegInfinity&>( *this ); } - - /*==========================================================*/ - template< typename T > - inline bool equal( const T& rhs ) const - { - UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized ); - return UbLimits<T>::inf() == rhs; - } - - private: - UbInfinity( const UbInfinity& inf ); //Copy constructor (private & undefined) - UbInfinity& operator=( const UbInfinity& inf ); //Copy assignment operator (private & undefined) - void* operator&() const; //Address operator (private & undefined) -}; - -////////////////////////////////////////////////////////////////////////// -// GLOBAL OPERATORS -////////////////////////////////////////////////////////////////////////// -template< typename T > -inline bool operator==( const UbInfinity& lhs, const T& rhs ); - -template< typename T > -inline bool operator==( const T& lhs, const UbInfinity& rhs ); - -template< typename T > -inline bool operator!=( const UbInfinity& lhs, const T& rhs ); - -template< typename T > -inline bool operator!=( const T& lhs, const UbInfinity& rhs ); -//@} -//************************************************************************************************* - - -//************************************************************************************************* -/*!\brief Equality comparison between an Infinity object and a built-in data type. -// \ingroup util -// -// This operator works only 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 operator==( const UbInfinity& lhs, const T& rhs ) -{ - return lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator==( const T& lhs, const UbInfinity& rhs ) -{ - return rhs.equal( lhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const UbInfinity& lhs, const T& rhs ) -{ - return !lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const T& lhs, const UbInfinity& rhs ) -{ - return !rhs.equal( lhs ); -} -//************************************************************************************************* - -////////////////////////////////////////////////////////////////////////// -// GLOBAL INFINITY VALUE -////////////////////////////////////////////////////////////////////////// -namespace Ub -{ - //e.g. double x = UbSystem::inf; float x = -Ub::inf; - const UbInfinity inf; -} - -#endif //UB_INFINITY_H diff --git a/ThirdParty/Library/basics/utilities/UbKeys.h b/ThirdParty/Library/basics/utilities/UbKeys.h deleted file mode 100644 index feaf5cab8c58e6fe2f26bd3ce6d63b2aee609ed5..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbKeys.h +++ /dev/null @@ -1,311 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBKEYS_H -#define UBKEYS_H - -#include <iostream> - -#include <boost/serialization/serialization.hpp> - -#ifdef CAB_RCF - #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: ... -*/ - -namespace UbKeys -{ - //nested class - template< typename T1, typename T2 = T1 > - class Key2 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key2(const T1& t1, const T2& t2) - : t1(t1), t2(t2) - { - } - /*==========================================================*/ - Key2& operator=(const Key2& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - - return *this; - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key2& lhsKey,const Key2& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key2& lhsKey, const Key2& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const Key2& lhsKey, const Key2& rhsKey) - { - return !(lhsKey == rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key2& key) - { - os<<"Key2<"<<typeid(T1).name()<<","<<typeid(T2).name()<<">,("<<key.t1<<","<<key.t2<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - } - }; - - ////////////////////////////////////////////////////////////////////////// - // - ////////////////////////////////////////////////////////////////////////// - template< typename T1, typename T2 = T1, typename T3 = T1 > - class Key3 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key3() : t1(0), t2(0), t3(0) - { - - } - Key3(const T1& t1, const T2& t2, const T3& t3) - : t1(t1), t2(t2), t3(t3) - { - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - T3 getT3() const { return t3; } - /*==========================================================*/ - Key3& operator=(const Key3& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - t3 = srcKey.t3; - - return *this; - } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key3& lhsKey,const Key3& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - if( lhsKey.t2 > rhsKey.t2 ) return false; - if( lhsKey.t3 < rhsKey.t3 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key3& lhsKey,const Key3& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - if(lhsKey.t3 != rhsKey.t3 ) return false; - - return true; - } - /*==========================================================*/ - //ueberladene Operatoren - friend inline bool operator!=(const Key3& lhsKey, const Key3& rhsKey) - { - return !(lhsKey == rhsKey); - } - - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key3& key) - { - os<<"Key3<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name(); - os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - ar & t3; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - T3 t3; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - ar & t3; - } - }; - - ////////////////////////////////////////////////////////////////////////// - // - ////////////////////////////////////////////////////////////////////////// - template< typename T1, typename T2 = T1, typename T3 = T1, typename T4 = T1 > - class Key4 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key4(const T1& t1, const T2& t2, const T3& t3, const T4& t4) - : t1(t1), t2(t2), t3(t3), t4(t4) - { - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - T3 getT3() const { return t3; } - T4 getT4() const { return t4; } - /*==========================================================*/ - Key4& operator=(const Key4& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - t3 = srcKey.t3; - t4 = srcKey.t4; - - return *this; - } - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key4& lhsKey,const Key4& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - if( lhsKey.t2 > rhsKey.t2 ) return false; - if( lhsKey.t3 < rhsKey.t3 ) return true; - if( lhsKey.t3 > rhsKey.t3 ) return false; - if( lhsKey.t4 < rhsKey.t4 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key4& lhsKey,const Key4& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - if(lhsKey.t3 != rhsKey.t3 ) return false; - if(lhsKey.t4 != rhsKey.t4 ) return false; - - return true; - } - - //ueberladene Operatoren - friend inline bool operator!=(const Key4& lhsKey, const Key4& rhsKey) - { - return !(lhsKey == rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key4& key) - { - os<<"Key4<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name()<<","<<typeid(T4).name(); - os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<","<<key.t4<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - ar & t3; - ar & t4; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - T3 t3; - T4 t4; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & t1; - ar & t2; - ar & t3; - ar & t4; - } - }; -} - -#endif //UBKEYS_H diff --git a/ThirdParty/Library/basics/utilities/UbLimits.h b/ThirdParty/Library/basics/utilities/UbLimits.h deleted file mode 100644 index 9313f0620a138785dd9b7e6c334917806da93c30..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbLimits.h +++ /dev/null @@ -1,139 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UB_LIMITS_H -#define UB_LIMITS_H - - -//************************************************************************************************* -// Includes -//************************************************************************************************* - -#include <limits> - -////////////////////////////////////////////////////////////////////////// -// CLASS DEFINITION -////////////////////////////////////////////////////////////////////////// -template< typename T > -struct UbLimits {}; - -////////////////////////////////////////////////////////////////////////// -// SPECIALIZATIONS -////////////////////////////////////////////////////////////////////////// -template<> -struct UbLimits<unsigned char> -{ - //return the largest possible positive unsigned char value - static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<char> -{ - //return the largest possible positive char value. */ - static inline char inf () { return std::numeric_limits<char>::max(); } - //return the largest possible negative char value - static inline char ninf() { return std::numeric_limits<char>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<signed char> -{ - //return the largest possible positive signed char value - static inline signed char inf () { return std::numeric_limits<signed char>::max(); } - - //return The largest possible negative signed char value - static inline signed char ninf() { return std::numeric_limits<signed char>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<wchar_t> -{ - //return The largest possible positive wchar_t value - static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); } - //return The largest possible negative wchar_t value - static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned short> -{ - //return The largest possible positive unsigned short value - static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<short> -{ - //return The largest possible positive short value - static inline short inf () { return std::numeric_limits<short>::max(); } - //return The largest possible negative short value - static inline short ninf() { return std::numeric_limits<short>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned int> -{ - //return The largest possible positive unsigned int value - static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<int> -{ - //return The largest possible positive int value - static inline int inf () { return std::numeric_limits<int>::max(); } - - //return The largest possible negative int value - static inline int ninf() { return std::numeric_limits<int>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned long> -{ - //return The largest possible positive unsigned long value - static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<long> -{ - //return The largest possible positive long value - static inline long inf () { return std::numeric_limits<long>::max(); } - - //return The largest possible negative long value - static inline long ninf() { return std::numeric_limits<long>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<float> -{ - //return The largest possible positive float value - static inline float inf () { return std::numeric_limits<float>::max(); } - - //return The largest possible negative float value - static inline float ninf() { return -std::numeric_limits<float>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<double> -{ - //return The largest possible positive double value - static inline double inf () { return std::numeric_limits<double>::max(); } - //return The largest possible negative double value - static inline double ninf() { return -std::numeric_limits<double>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<long double> -{ - //return The largest possible positive long double value - static inline long double inf () { return std::numeric_limits<long double>::max(); } - //return The largest possible negative long double value - static inline long double ninf() { return -std::numeric_limits<long double>::max(); } -}; - -#endif //UB_LIMITS_H diff --git a/ThirdParty/Library/basics/utilities/UbLogger.cpp b/ThirdParty/Library/basics/utilities/UbLogger.cpp deleted file mode 100644 index f487a02ed08408d632ccab624b657f0283686ad5..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbLogger.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include <basics/utilities/UbLogger.h> - -#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) - -boost::mutex Output2Stream::mtx; - -#endif // CAB_BOOST - diff --git a/ThirdParty/Library/basics/utilities/UbLogger.h b/ThirdParty/Library/basics/utilities/UbLogger.h deleted file mode 100644 index 7d4e432ce7c4ec2284aba328cc7344d1db6aec4b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbLogger.h +++ /dev/null @@ -1,362 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBLOGGER_H -#define UBLOGGER_H - -#include <sstream> -#include <string> -#include <iostream> -#include <fstream> -#include <iomanip> -#include <memory> - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) - #include <windows.h> -#else - #include <sys/time.h> -#endif - -#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) - #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 -////////////////////////////////////////////////////////////////////////// -template <typename OutputPolicy> -class UbLogger -{ -public: - typedef OutputPolicy output_policy; -public: - UbLogger(); - virtual ~UbLogger(); - std::ostringstream& get(const LogLevel& level = logINFO); -public: - //static, weil man so später die ObjErstellunge ersparen kann, - //falls level kleiner als Level - static LogLevel& reportingLevel(); - - static std::string logLevelToString(const LogLevel& level); - static LogLevel logLevelFromString(const std::string& level); - - static std::string logTimeString(); - -protected: - std::ostringstream os; - -private: - UbLogger(const UbLogger&); - UbLogger& operator =(const UbLogger&); -}; - -////////////////////////////////////////////////////////////////////////// -// template <typename OutputPolicy> class Log - implementation -////////////////////////////////////////////////////////////////////////// -template <typename OutputPolicy> -UbLogger<OutputPolicy>::UbLogger() -{ -} -/*==========================================================*/ -template <typename OutputPolicy> -std::ostringstream& UbLogger<OutputPolicy>::get(const LogLevel& level) -{ - os << logTimeString() << " " << std::setw(6) -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - <<boost::this_thread::get_id() << " " -#endif - << std::setw(8) << std::left << UbLogger<OutputPolicy>::logLevelToString(level) << ": " - << std::string(level > logDEBUG ? 3*(level - logDEBUG) : 0, ' '); //<baumartiger output :D - - return os; -} -/*==========================================================*/ -template <typename OutputPolicy> -UbLogger<OutputPolicy>::~UbLogger() -{ - os << std::endl; - OutputPolicy::output(os.str()); -} -/*==========================================================*/ -template <typename OutputPolicy> -LogLevel& UbLogger<OutputPolicy>::reportingLevel() -{ - static LogLevel reportLevel = logINFO; - return reportLevel; -} -/*==========================================================*/ -template <typename OutputPolicy> -std::string UbLogger<OutputPolicy>::logLevelToString(const LogLevel& level) -{ - static std::string const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"}; - return buffer[level]; -} -/*==========================================================*/ -template <typename OutputPolicy> -LogLevel UbLogger<OutputPolicy>::logLevelFromString(const std::string& level) -{ - if (level == "DEBUG5" ) return logDEBUG5; - if (level == "DEBUG4" ) return logDEBUG4; - if (level == "DEBUG3" ) return logDEBUG3; - if (level == "DEBUG2" ) return logDEBUG2; - if (level == "DEBUG1" ) return logDEBUG1; - if (level == "DEBUG" ) return logDEBUG; - if (level == "INFO" ) return logINFO; - if (level == "WARNING") return logWARNING; - if (level == "ERROR" ) return logERROR; - - UbLogger<OutputPolicy>().get(logWARNING) << "UbLogger<OutputPolicy>::logLevelFromString(level) - unknown logging level '" << level << "'. Using INFO level as default."; - return logINFO; -} - -////////////////////////////////////////////////////////////////////////// -// logTimeString -////////////////////////////////////////////////////////////////////////// -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) -template <typename OutputPolicy> -inline std::string UbLogger<OutputPolicy>::logTimeString() -{ - const int MAX_LEN = 200; - char buffer[MAX_LEN]; - if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, "HH':'mm':'ss", buffer, MAX_LEN) == 0 ) - { - return "Error in std::string UbLogger<OutputPolicy>::logTimeString()"; - } - - char result[100] = {0}; - static DWORD first = GetTickCount(); - std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); - return result; -} -#else -template <typename OutputPolicy> -inline std::string UbLogger<OutputPolicy>::logTimeString() -{ - char buffer[11]; - time_t t; - time(&t); - tm r = {0}; - strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r)); - struct timeval tv; - gettimeofday(&tv, 0); - char result[100] = {0}; - std::sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); - return result; -} -#endif - - -////////////////////////////////////////////////////////////////////////// -// Output2Stream (=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) - static void setStream(const std::string& filename); - - //direct set outputstream, gcControl = true -> object will be deleted by Output2Stream - static void setStream(std::ostream* pStream, const bool& gcControl = false); - -protected: -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - static boost::mutex mtx; -#endif -}; -/*==========================================================*/ -inline std::ostream*& Output2Stream::getStream() -{ - static std::ostream* pStream = &std::clog; - return pStream; -} -/*==========================================================*/ -inline void Output2Stream::setStream(std::ostream* pFile, const bool& gcControl) -{ -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - boost::mutex::scoped_lock lock(mtx); -#endif - static bool s_gcControl = false; - - if( s_gcControl && Output2Stream::getStream() ) - { - delete Output2Stream::getStream(); - } - - s_gcControl = gcControl; - - Output2Stream::getStream() = pFile; -} -/*==========================================================*/ -inline void Output2Stream::setStream(const std::string& filename) -{ - std::ofstream* file = new std::ofstream( filename.c_str() ); - if( !(*file) ) - { - delete file; - Output2Stream::setStream(&std::cerr, false); - UbLogger<Output2Stream>().get(logERROR) << " Output2Stream::setStream(const std::string& filename) could not open file " - << filename << " -> std::cerr is used instead " << std::endl; - return; - } - std::cout<<"UbLog writes to "<<filename<<std::endl; - Output2Stream::setStream(file,true); -} -/*==========================================================*/ -inline void Output2Stream::output(const std::string& msg) -{ -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - boost::mutex::scoped_lock lock(mtx); -#endif - std::ostream* pStream = getStream(); - if (!pStream) return; - (*pStream) << msg << std::flush; -} - -////////////////////////////////////////////////////////////////////////// -// UbLog -////////////////////////////////////////////////////////////////////////// -class UbLog : public UbLogger< Output2Stream > -{ -public: - typedef Output2Stream output_policy; -}; - -//Makro um compilerseitig maxLevel zu beschränken -#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" ) -// example2: UBLOGML(logINFO, "line1\nline2\nendl\nline3" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOGML(level, multiline) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else \ - { \ - std::ostringstream output; \ - output << multiline; \ - std::istringstream input( output.str() ); \ - while(!input.eof()) \ - { \ - std::string dummy; \ - getline(input,dummy,'\n'); \ - UbLog().get(level) << dummy; \ - } \ - } -////////////////////////////////////////////////////////////////////////// -//makro3, falls auch bildschirmausgabe erwünscht -// -> 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" ) -//example2: UBLOG2ML(logINFO, std::cout, "line1\nline2\nendl\nline3" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOG2(level, stream, text ) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else { stream << text <<std::endl; UbLog().get(level) << text; } - -////////////////////////////////////////////////////////////////////////// -//makro4, wie 3 nur mit multiline -//example: UBLOG2(logINFO, std::cout, "test" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOG2ML(level, stream, multiline ) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else \ - { \ - stream << multiline << std::endl; \ - std::ostringstream output; \ - output << multiline; \ - std::istringstream input( output.str() ); \ - while(!input.eof()) \ - { \ - std::string dummy; \ - getline(input,dummy,'\n'); \ - UbLog().get(level) << dummy; \ - } \ - } - -////////////////////////////////////////////////////////////////////////// -// example 2 -////////////////////////////////////////////////////////////////////////// -// try -// { -// UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG3"); -// //UbLog::output_policy::setStream(&std::cerr); //<- clog ist stdandard -// UbLog::output_policy::setStream("c:/temp/out.txt"); //kann man diese nicht oeffnen -> fehlermeldung -> Log wird in cerr ausgegben -// -// 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 ); -// //fuer MultiLine Eintraege: --> koerrekte formatierung im 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(); -// } - - -#endif //UBLOGGER_H diff --git a/ThirdParty/Library/basics/utilities/UbMath.cpp b/ThirdParty/Library/basics/utilities/UbMath.cpp deleted file mode 100644 index ad38b9cf945d569e8f2d7bd6118c35b27fadd4fe..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbMath.cpp +++ /dev/null @@ -1,614 +0,0 @@ -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <cstring> //for memcmp - -// namespace UbMath -// { -//double UbMath::EPSILON = 1.0E-10; -const double UbMath::PI = 4.0* std::atan(1.0); //3.1415926535897932384626433832795 -//} -namespace UbMath{ - -////////////////////////////////////////////////////////////////////////// -const Vector3D Vector3D::ZERO(0.0,0.0,0.0); -const Vector3D Vector3D::UNIT_X1(1.0,0.0,0.0); -const Vector3D Vector3D::UNIT_X2(0.0,1.0,0.0); -const Vector3D Vector3D::UNIT_X3(0.0,0.0,1.0); - -/*=======================================================*/ -Vector3D::Vector3D() -{ - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; -} -/*=======================================================*/ -Vector3D::Vector3D(const double& fX, const double& fY, const double& fZ) -{ - m_afTuple[0] = fX; - m_afTuple[1] = fY; - m_afTuple[2] = fZ; -} -/*=======================================================*/ -Vector3D::Vector3D (const Vector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; -} -/*=======================================================*/ -std::string Vector3D::toString() const -{ - std::stringstream os; - os<< "Vector3D["<<m_afTuple[0]<<","<<m_afTuple[1]<<","<<m_afTuple[2]<<"]"; - return os.str(); -} -/*=======================================================*/ -Vector3D::operator const double*() const -{ - return m_afTuple; -} -/*=======================================================*/ -Vector3D::operator double*() -{ - return m_afTuple; -} -/*=======================================================*/ -double Vector3D::operator[](const int& i) const -{ - assert( i >= 0 && i <= 2 ); - return m_afTuple[i]; -} -/*=======================================================*/ -double& Vector3D::operator[](const int& i) -{ - assert( i >= 0 && i <= 2 ); - return m_afTuple[i]; -} -/*=======================================================*/ -double Vector3D::X1() const -{ - return m_afTuple[0]; -} -/*=======================================================*/ -double& Vector3D::X1() -{ - return m_afTuple[0]; -} -/*=======================================================*/ -double Vector3D::X2() const -{ - return m_afTuple[1]; -} -/*=======================================================*/ -double& Vector3D::X2() -{ - return m_afTuple[1]; -} -/*=======================================================*/ -double Vector3D::X3() const -{ - return m_afTuple[2]; -} -/*=======================================================*/ -double& Vector3D::X3() -{ - return m_afTuple[2]; -} -/*=======================================================*/ -Vector3D& Vector3D::operator=(const Vector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -int Vector3D::CompareArrays(const Vector3D& rkV) const -{ - return memcmp(m_afTuple,rkV.m_afTuple,3*sizeof(double)); -} -/*=======================================================*/ -bool Vector3D::operator==(const Vector3D& rkV) const -{ - return CompareArrays(rkV) == 0; -} -/*=======================================================*/ -bool Vector3D::operator!=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) != 0; -} -/*=======================================================*/ -bool Vector3D::operator<(const Vector3D& rkV) const -{ - return CompareArrays(rkV) < 0; -} -/*=======================================================*/ -bool Vector3D::operator<=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) <= 0; -} -/*=======================================================*/ -bool Vector3D::operator> (const Vector3D& rkV) const -{ - return CompareArrays(rkV) > 0; -} -/*=======================================================*/ -bool Vector3D::operator>=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) >= 0; -} -/*=======================================================*/ -Vector3D Vector3D::operator+(const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[0]+rkV.m_afTuple[0], - m_afTuple[1]+rkV.m_afTuple[1], - m_afTuple[2]+rkV.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::Add(Vector3D& vector) -{ - return Vector3D( m_afTuple[0]+vector.m_afTuple[0], - m_afTuple[1]+vector.m_afTuple[1], - m_afTuple[2]+vector.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator- (const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[0]-rkV.m_afTuple[0], - m_afTuple[1]-rkV.m_afTuple[1], - m_afTuple[2]-rkV.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::Subtract(Vector3D& vector) -{ - return Vector3D( m_afTuple[0]-vector.m_afTuple[0], - m_afTuple[1]-vector.m_afTuple[1], - m_afTuple[2]-vector.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator*(const double& fScalar) const -{ - return Vector3D( fScalar*m_afTuple[0], - fScalar*m_afTuple[1], - fScalar*m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator/(const double& fScalar) const -{ - Vector3D kQuot; - - if ( fScalar != 0.0 ) - { - double fInvScalar = 1.0/fScalar; - kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0]; - kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1]; - kQuot.m_afTuple[2] = fInvScalar*m_afTuple[2]; - } - else - { - kQuot.m_afTuple[0] = Ub::inf; - kQuot.m_afTuple[1] = Ub::inf; - kQuot.m_afTuple[2] = Ub::inf; - } - - return kQuot; -} -/*=======================================================*/ -Vector3D Vector3D::operator-() const -{ - return Vector3D( -m_afTuple[0], - -m_afTuple[1], - -m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D& Vector3D::operator+=(const Vector3D& rkV) -{ - m_afTuple[0] += rkV.m_afTuple[0]; - m_afTuple[1] += rkV.m_afTuple[1]; - m_afTuple[2] += rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator-=(const Vector3D& rkV) -{ - m_afTuple[0] -= rkV.m_afTuple[0]; - m_afTuple[1] -= rkV.m_afTuple[1]; - m_afTuple[2] -= rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator*=(const double& fScalar) -{ - m_afTuple[0] *= fScalar; - m_afTuple[1] *= fScalar; - m_afTuple[2] *= fScalar; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator/=(const double& fScalar) -{ - if ( !zero(fScalar) ) - { - double fInvScalar = 1.0/fScalar; - m_afTuple[0] *= fInvScalar; - m_afTuple[1] *= fInvScalar; - m_afTuple[2] *= fInvScalar; - } - else - { - m_afTuple[0] = Ub::inf; - m_afTuple[1] = Ub::inf; - m_afTuple[2] = Ub::inf; - } - - return *this; -} -/*=======================================================*/ -Vector3D Vector3D::Scale(const double& x) -{ - Vector3D PointA(0.0,0.0,0.0); - PointA.m_afTuple[0] = x * m_afTuple[0]; - PointA.m_afTuple[1] = x * m_afTuple[1]; - PointA.m_afTuple[2] = x * m_afTuple[2]; - return PointA; -} -/*=======================================================*/ -double Vector3D::Length() const -{ - return std::sqrt( m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2] ); -} -/*=======================================================*/ -double Vector3D::SquaredLength() const -{ - return m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2]; -} -/*=======================================================*/ -double Vector3D::Dot(const Vector3D& rkV) const -{ - return m_afTuple[0]*rkV.m_afTuple[0] + - m_afTuple[1]*rkV.m_afTuple[1] + - m_afTuple[2]*rkV.m_afTuple[2]; -} -/*=======================================================*/ -double Vector3D::Normalize() -{ - double fLength = Length(); - - if( !zero(fLength) ) - { - double fInvLength = 1.0/fLength; - m_afTuple[0] *= fInvLength; - m_afTuple[1] *= fInvLength; - m_afTuple[2] *= fInvLength; - } - else - { - fLength = 0.0; - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; - } - - return fLength; -} -/*=======================================================*/ -Vector3D Vector3D::Cross(const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0] ); -} -/*=======================================================*/ -Vector3D Vector3D::UnitCross(const Vector3D& rkV) const -{ - Vector3D kCross( m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0] ); - kCross.Normalize(); - return kCross; -} -/*=======================================================*/ -void Vector3D::GetBarycentrics(const Vector3D& rkV0,const Vector3D& rkV1, const Vector3D& rkV2,const Vector3D& rkV3, double afBary[4]) const -{ - // compute the vectors relative to V3 of the tetrahedron - Vector3D akDiff[4] = { rkV0 - rkV3, - rkV1 - rkV3, - rkV2 - rkV3, - *this - rkV3 }; - - // If the vertices have large magnitude, the linear system of - // equations for computing barycentric coordinates can be - // ill-conditioned. To avoid this, uniformly scale the tetrahedron - // edges to be of order 1. The scaling of all differences does not - // change the barycentric coordinates. - double fMax = 0.0,fValue=0.0; - for(int i=0; i<3; i++) - for (int j=0; j<3; j++) - { - fValue = std::fabs(akDiff[i][j]); - if ( fValue > fMax ) fMax = fValue; - } - - // scale down only large data - if( greater(fMax,1.0) ) - { - double fInvMax = ((double)1.0)/fMax; - for( int i=0; i<4; i++) - akDiff[i] *= fInvMax; - } - - double fDet = akDiff[0].Dot(akDiff[1].Cross(akDiff[2])); - Vector3D kE1cE2 = akDiff[1].Cross(akDiff[2]); - Vector3D kE2cE0 = akDiff[2].Cross(akDiff[0]); - Vector3D kE0cE1 = akDiff[0].Cross(akDiff[1]); - - if( !zero( fDet ) ) - { - double fInvDet = 1.0/fDet; - afBary[0] = akDiff[3].Dot(kE1cE2)*fInvDet; - afBary[1] = akDiff[3].Dot(kE2cE0)*fInvDet; - afBary[2] = akDiff[3].Dot(kE0cE1)*fInvDet; - afBary[3] = 1.0 - afBary[0] - afBary[1] - afBary[2]; - } - else - { - // The tetrahedron is potentially flat. Determine the face of - // maximum area and compute barycentric coordinates with respect - // to that face. - Vector3D kE02 = rkV0 - rkV2; - Vector3D kE12 = rkV1 - rkV2; - Vector3D kE02cE12 = kE02.Cross(kE12); - double fMaxSqrArea = kE02cE12.SquaredLength(); - int iMaxIndex = 3; - double fSqrArea = kE0cE1.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 0; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE1cE2.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 1; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE2cE0.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 2; - fMaxSqrArea = fSqrArea; - } - - if ( greater(fMaxSqrArea,0.0) ) - { - double fInvSqrArea = 1.0/fMaxSqrArea; - Vector3D kTmp; - if( iMaxIndex==0 ) - { - kTmp = akDiff[3].Cross(akDiff[1]); - afBary[0] = kE0cE1.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[0].Cross(akDiff[3]); - afBary[1] = kE0cE1.Dot(kTmp)*fInvSqrArea; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[0] - afBary[1]; - } - else if( iMaxIndex == 1 ) - { - afBary[0] = 0.0; - kTmp = akDiff[3].Cross(akDiff[2]); - afBary[1] = kE1cE2.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[1].Cross(akDiff[3]); - afBary[2] = kE1cE2.Dot(kTmp)*fInvSqrArea; - afBary[3] = 1.0 - afBary[1] - afBary[2]; - } - else if( iMaxIndex == 2 ) - { - kTmp = akDiff[2].Cross(akDiff[3]); - afBary[0] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[1] = 0.0; - kTmp = akDiff[3].Cross(akDiff[0]); - afBary[2] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[3] = 1.0 - afBary[0] - afBary[2]; - } - else - { - akDiff[3] = *this - rkV2; - kTmp = akDiff[3].Cross(kE12); - afBary[0] = kE02cE12.Dot(kTmp)*fInvSqrArea; - kTmp = kE02.Cross(akDiff[3]); - afBary[1] = kE02cE12.Dot(kTmp)*fInvSqrArea; - afBary[2] = 1.0 - afBary[0] - afBary[1]; - afBary[3] = 0.0; - } - } - else - { - // The tetrahedron is potentially a sliver. Determine the edge of - // maximum length and compute barycentric coordinates with respect - // to that edge. - double fMaxSqrLength = akDiff[0].SquaredLength(); - iMaxIndex = 0; // <V0,V3> - double fSqrLength = akDiff[1].SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 1; // <V1,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = akDiff[2].SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 2; // <V2,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE02.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 3; // <V0,V2> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE12.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 4; // <V1,V2> - fMaxSqrLength = fSqrLength; - } - - Vector3D kE01 = rkV0 - rkV1; - fSqrLength = kE01.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 5; // <V0,V1> - fMaxSqrLength = fSqrLength; - } - - if( greater(fMaxSqrLength, 0.0) ) - { - double fInvSqrLength = 1.0/fMaxSqrLength; - if( iMaxIndex == 0 ) - { - // P-V3 = t*(V0-V3) - afBary[0] = akDiff[3].Dot(akDiff[0])*fInvSqrLength; - afBary[1] = 0.0; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[0]; - } - else if( iMaxIndex == 1 ) - { - // P-V3 = t*(V1-V3) - afBary[0] = 0.0; - afBary[1] = akDiff[3].Dot(akDiff[1])*fInvSqrLength; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[1]; - } - else if( iMaxIndex == 2 ) - { - // P-V3 = t*(V2-V3) - afBary[0] = 0.0; - afBary[1] = 0.0; - afBary[2] = akDiff[3].Dot(akDiff[2])*fInvSqrLength; - afBary[3] = 1.0 - afBary[2]; - } - else if( iMaxIndex == 3 ) - { - // P-V2 = t*(V0-V2) - akDiff[3] = *this - rkV2; - afBary[0] = akDiff[3].Dot(kE02)*fInvSqrLength; - afBary[1] = 0.0; - afBary[2] = 1.0 - afBary[0]; - afBary[3] = 0.0; - } - else if( iMaxIndex == 4 ) - { - // P-V2 = t*(V1-V2) - akDiff[3] = *this - rkV2; - afBary[0] = 0.0; - afBary[1] = akDiff[3].Dot(kE12)*fInvSqrLength; - afBary[2] = 1.0 - afBary[1]; - afBary[3] = 0.0; - } - else - { - // P-V1 = t*(V0-V1) - akDiff[3] = *this - rkV1; - afBary[0] = akDiff[3].Dot(kE01)*fInvSqrLength; - afBary[1] = 1.0 - afBary[0]; - afBary[2] = 0.0; - afBary[3] = 0.0; - } - } - else - { - // tetrahedron is a nearly a point, just return equal weights - afBary[0] = 0.25; - afBary[1] = afBary[0]; - afBary[2] = afBary[0]; - afBary[3] = afBary[0]; - } - } - } -} -/*=======================================================*/ -void Vector3D::Orthonormalize(Vector3D& rkU, Vector3D& rkV, Vector3D& rkW) -{ - // If the input vectors are v0, v1, and v2, then the Gram-Schmidt - // orthonormalization produces vectors u0, u1, and u2 as follows, - // - // u0 = v0/|v0| - // u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0| - // u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1| - // - // where |A| indicates length of vector A and A*B indicates dot - // product of vectors A and B. - - // compute u0 - rkU.Normalize(); - - // compute u1 - double fDot0 = rkU.Dot(rkV); - rkV -= fDot0*rkU; - rkV.Normalize(); - - // compute u2 - double fDot1 = rkV.Dot(rkW); - fDot0 = rkU.Dot(rkW); - rkW -= fDot0*rkU + fDot1*rkV; - rkW.Normalize(); -} -/*=======================================================*/ -void Vector3D::Orthonormalize(Vector3D* akV) -{ - Orthonormalize(akV[0],akV[1],akV[2]); -} -/*=======================================================*/ -void Vector3D::GenerateOrthonormalBasis(Vector3D& rkU, Vector3D& rkV,Vector3D& rkW, bool bUnitLengthW) -{ - if ( !bUnitLengthW ) - rkW.Normalize(); - - double fInvLength; - - if ( greaterEqual( std::fabs(rkW.m_afTuple[0]),std::fabs(rkW.m_afTuple[1]) ) ) - { - // W.x or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[0]*rkW.m_afTuple[0] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = -rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[1] = (double)0.0; - rkU.m_afTuple[2] = +rkW.m_afTuple[0]*fInvLength; - } - else - { - // W.y or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[1]*rkW.m_afTuple[1] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = (double)0.0; - rkU.m_afTuple[1] = +rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[2] = -rkW.m_afTuple[1]*fInvLength; - } - - rkV = rkW.Cross(rkU); -} -/*=======================================================*/ -//globaler operator* -Vector3D operator*(const double& fScalar, const Vector3D& rkV) -{ - return Vector3D( fScalar*rkV[0], - fScalar*rkV[1], - fScalar*rkV[2] ); -} -/*=======================================================*/ -std::ostream& operator* (std::ostream& os, const Vector3D& rkV) -{ - os<<rkV.toString(); - return os; -} -} //end namespace UbMath - diff --git a/ThirdParty/Library/basics/utilities/UbMath.h b/ThirdParty/Library/basics/utilities/UbMath.h deleted file mode 100644 index 4571514f86d3cc743008dd9b5d4ba1d5f687dd5e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbMath.h +++ /dev/null @@ -1,548 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBMATH_H -#define UBMATH_H - -#include <cmath> -#include <limits> -#include <iostream> -#include <cassert> -#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; - - - ////////////////////////////////////////////////////////////////////////// - //Hilfsfunktion fuer Genauigkeit - template< typename T > - struct Epsilon { }; - - ////////////////////////////////////////////////////////////////////////// - // SPECIALIZATIONS von Epsilon - ////////////////////////////////////////////////////////////////////////// - template<> - struct Epsilon<double> { static inline double val() { return 1.0E-11; } }; - template<> - struct Epsilon<float> { static inline float val() { return 1.0E-7f; } }; - template<> - struct Epsilon<long double> { static inline long double val() { return 1.0E-15; } }; - template<> - struct Epsilon<int> { static inline int val() { return 0; } }; - - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den Logarithmus einer Zahl z bzgl. der Basis b - // ------------------------------------------------------------------------------------------------- - template<typename T> - inline T log(const T& z, const T& base) - { - if( ::log(base)==0 ) return 1.0f; - return ::log(z) / ::log(base); - } - /*=======================================================*/ - //double x = UbMath::getNegativeInfinity<double>(); - template<typename T> - inline T getNegativeInfinity() - { - //assert(std::numeric_limits<T>::has_infinity); - UB_STATIC_ASSERT(std::numeric_limits<T>::has_infinity); - return -std::numeric_limits<T>::infinity(); - } - /*=======================================================*/ - //double x = UbMath::getPositiveInfinity<double>(); - template<typename T> - inline T getPositiveInfinity() - { - //assert(std::numeric_limits<T>::has_infinity); - UB_STATIC_ASSERT(std::numeric_limits<T>::has_infinity); - return std::numeric_limits<T>::infinity(); - } - /*=======================================================*/ - //double x; bool b = UbMath::isInfinity(x); - template<typename T> - inline bool isInfinity(const T& value) - { - if(value==getNegativeInfinity<T>()) return true; - if(value==getPositiveInfinity<T>()) return true; - return false; - } - /*=======================================================*/ - //double x = UbMath::getNaN<double>(x); - template<typename T> - inline T getNaN() - { - UB_STATIC_ASSERT(std::numeric_limits<T>::has_quiet_NaN); - return std::numeric_limits<T>::quiet_NaN(); - } - /*=======================================================*/ - //double x; bool b = UbMath::isNaN(x); - // x!=x liefert bei #QNAN "true"! - template<typename T> - inline bool isNaN(const T& x) - { - UB_STATIC_ASSERT(std::numeric_limits<T>::has_quiet_NaN); - return (x != x); - } - /*=======================================================*/ - template<typename T> - inline T getEqualityEpsilon() - { - return Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool zero(const T& value) - { - return std::fabs( value ) < Epsilon<T>::val(); - //return value >= -UbMath::EPSILON && value <= UbMath::EPSILON; - } - /*=======================================================*/ - //spezialisierung fuer ints - template<> - inline bool zero(const int& value) - { - return value == 0; - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool zero(const T1& value1, const T2& value2) - { - return !(!UbMath::zero(value1) || !UbMath::zero(value2)); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool zero(const T1& value1, const T2& value2, const T3& value3) - { - return !(!UbMath::zero(value1) || !UbMath::zero(value2,value3)); - } - /*=======================================================*/ - template<typename T> - inline bool negative(const T& value) - { - return value < -Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool nonPositive(const T& value) - { - return value <= Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool positive(const T& value) - { - return value > +Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool nonNegative(const T& value) - { - return value >= -Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool equal(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return std::fabs(value-reference) < Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool equal(const T1& val1, const T2& val2, const T3& val3) - { - return ( UbMath::equal(val1,val2) && UbMath::equal(val1,val3) ); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool less(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value < reference - Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool lessEqual(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value <= reference + Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool greater(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value > reference + Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool greaterEqual(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value >= reference - Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T> - inline T round(const T& value, const int& decimalPlaces) - { - return static_cast<T>(floor(value * pow( 10.0, decimalPlaces) + 0.5 ) * pow(10.0, -decimalPlaces)); - } - /*=======================================================*/ - template<typename T> - inline int integerRounding(const T& value) - { - return static_cast<int>( UbMath::zero(value) ? 0 : ( (value<0.0) ? (value-0.5) : (value+0.5) ) ); - } - /*=======================================================*/ - template<typename T> - inline T getRad(const T& degrees) - { - return degrees*static_cast<T>(UbMath::PI/180.0); - } - /*=======================================================*/ - template<typename T> - inline T getDegrees(const T& rad) - { - return rad*static_cast<T>(UbMath::PI/180.0); - } - /*=======================================================*/ - //aus wildmagic - template<typename T> - inline T ACos (const T& fValue) - { - if ( -1.0 < fValue ) - { - if ( fValue < 1.0 ) return static_cast<T>( acos(fValue) ); - else return static_cast<T>( 0.0 ); - } - else return static_cast<T>( PI ); - } - /*=======================================================*/ - template<typename T> - inline T ASin(const T& fValue) - { - double HALF_PI = 0.5*UbMath::PI; - if ( -1.0 < fValue ) - { - if ( fValue < 1.0 ) return static_cast<T>( asin(fValue) ); - else return static_cast<T>( HALF_PI ); - } - else return -static_cast<T>( HALF_PI ); - } - /*=======================================================*/ - template<typename T> - inline T invSqrt(const T& fValue) - { - return static_cast<T>(1.0/sqrt(fValue)); - } - - /*=======================================================*/ - /** - * Returns true, if specified values a and b are less both values c and d. - * @param a the first value to check - * @param b the second value to check - * @param c the first value to check against - * @param d the second value to check against - * @return true, if specified values a and b are less both values c and d - **/ - template<typename T1, typename T2, typename T3, typename T4> - inline bool less2(const T1& value1, const T2& value2, T3 toBeLessAs1, T4 toBeLessAs2) - { - return ( less(value1,toBeLessAs1) - && less(value1,toBeLessAs2) - && less(value2,toBeLessAs1) - && less(value2,toBeLessAs2) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3, typename T4> - inline bool greater2(const T1& value1, const T2& value2, T3 toBeGreaterAs1, T4 toBeGreaterAs2) - { - return ( greater(value1,toBeGreaterAs1) - && greater(value1,toBeGreaterAs2) - && greater(value2,toBeGreaterAs1) - && greater(value2,toBeGreaterAs2) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool inClosedInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - return ( greaterEqual( value, threshold1) && lessEqual( value, threshold2) ); - } - - return ( greaterEqual( value, threshold2) && lessEqual( value, threshold1) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool inOpenInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - return (greater( value, threshold1) && less( value, threshold2)); - } - - return (greater( value, threshold2) && less( value, threshold1)); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline double adaptToClosedInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - if ( less( value, threshold1) ) return threshold1; - else if( greater(value, threshold2) ) return threshold2; - } - else - { - if ( less( value, threshold2) ) return threshold2; - else if( greater(value, threshold1) ) return threshold1; - } - return value; - } - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den groessten gemeinsamen Teiler zweier Zahlen (MK) - // ------------------------------------------------------------------------------------------------- - /*=======================================================*/ - inline int calcGgt(int val1, int val2) - { - if( val1 < val2 ) std::swap(val1,val2); - int ggt=val2; - while(ggt > 1) - { - if( (val1%ggt)==0 && (val2%ggt)==0 ) break; - - ggt -=1; - } - return ggt; - } - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den groessten gemeinsamen Teiler von drei Zahlen (MK) - // ------------------------------------------------------------------------------------------------- - inline int calcGgt(int val1, const int& val2, int val3) - { - return UbMath::calcGgt( UbMath::calcGgt(val1, val2), val3 ); - } - /*=======================================================*/ - //returns the max of two 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) - { - return (a1<a2) ? a2 : a1; - } - /*=======================================================*/ - template< typename T > - inline const T& max(const T& a1, const T& a2, const T& a3) - { - return max(max(a1,a2),a3); - } - /*=======================================================*/ - template< typename T > - inline const T& max(const T& a1, const T& a2, const T& a3, const T& a4) - { - return max(max(max(a1,a2),a3),a4); - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1,const T& a2) - { - return (a1<a2) ? a1 : a2; - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1, const T& a2, const T& a3) - { - return min(min(a1,a2),a3); - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1, const T& a2, const T& a3, const T& a4) - { - return min(min(min(a1,a2),a3),a4); - -// double tmp = a1; -// if(tmp>a2) tmp=a2; -// if(tmp>a3) tmp=a3; -// if(tmp>a4) tmp=a4; -// return tmp; - } - /*=======================================================*/ - - class Vector3D - { - public: - // construction - Vector3D(); - Vector3D(const double& fX1, const double& fX2, const double& fX3); - Vector3D(const Vector3D& rkV); - - std::string toString() const; - - // coordinate access - operator const double*() const; - operator double*(); - double operator[](const int& i) const; - double& operator[](const int& i); - double X1() const; - double& X1(); - double X2() const; - double& X2(); - double X3() const; - double& X3(); - - // assignment - Vector3D& operator=(const Vector3D& rkV); - - // comparison - bool operator==(const Vector3D& rkV) const; - bool operator!=(const Vector3D& rkV) const; - bool operator< (const Vector3D& rkV) const; - bool operator<=(const Vector3D& rkV) const; - bool operator> (const Vector3D& rkV) const; - bool operator>=(const Vector3D& rkV) const; - - // arithmetic operations - Vector3D operator+(const Vector3D& rkV) const; - Vector3D operator-(const Vector3D& rkV) const; - Vector3D operator*(const double& fScalar) const; - Vector3D operator/(const double& fScalar) const; - Vector3D operator-() const; - - // arithmetic updates - Vector3D& operator+= (const Vector3D& rkV); - Vector3D& operator-= (const Vector3D& rkV); - Vector3D& operator*= (const double& fScalar); - Vector3D& operator/= (const double& fScalar); - - Vector3D Add(Vector3D& vector); - Vector3D Subtract(Vector3D& vector); - Vector3D Scale(const double& x); - - // vector operations - double Length () const; - double SquaredLength () const; - double Dot (const Vector3D& rkV) const; - double Normalize (); - - // The cross products are computed using the right-handed rule. Be aware - // that some graphics APIs use a left-handed rule. If you have to compute - // a cross product with these functions and send the result to the API - // that expects left-handed, you will need to change sign on the vector - // (replace each component value c by -c). - Vector3D Cross (const Vector3D& rkV) const; - Vector3D UnitCross (const Vector3D& rkV) const; - - // Compute the barycentric coordinates of the point with respect to the - // tetrahedron <V0,V1,V2,V3>, P = b0*V0 + b1*V1 + b2*V2 + b3*V3, where - // b0 + b1 + b2 + b3 = 1. - void GetBarycentrics (const Vector3D& rkV0, const Vector3D& rkV1, const Vector3D& rkV2, const Vector3D& rkV3, double afBary[4]) const; - - // Gram-Schmidt orthonormalization. Take linearly independent vectors - // U, V, and W and compute an orthonormal set (unit length, mutually - // perpendicular). - static void Orthonormalize (Vector3D& rkU, Vector3D& rkV, Vector3D& rkW); - static void Orthonormalize (Vector3D* akV); - - // Input W must be initialized to a nonzero vector, output is {U,V,W}, - // an orthonormal basis. A hint is provided about whether or not W - // is already unit length. - static void GenerateOrthonormalBasis (Vector3D& rkU, Vector3D& rkV, Vector3D& rkW, bool bUnitLengthW); - - // special vectors - static const Vector3D ZERO; - static const Vector3D UNIT_X1; - 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; - - double m_afTuple[3]; - }; - - //globaler multiplaktor mit skalar - Vector3D operator*(const double& fScalar, const Vector3D& rkV); - std::ostream& operator<<(std::ostream& os, const Vector3D& rkV); - - ////////////////////////////////////////////////////////////////////////// - // - //constants - // - ////////////////////////////////////////////////////////////////////////// - static const double c8o27=8./27.; - 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 c3o9=3./9.; - static const double c3o54=3./54.; - static const double c3o216=3./216.; - - static const double c1o27=1./27.; - - static const double c1o72 = 1./72.; //0.01388888 - static const double c1o36 = 1./36.; //0.02777777 - static const double c1o48 = 1./48.; //0.02083333 - static const double c1o32 = 1./32.; //0.03125 - static const double c1o24 = 1./24.; //0.04166666 - static const double c1o20 = 1./20.; //0.05 - static const double c1o18 = 1./18.; //0.05555555 - static const double c1o16 = 1./16.; //0.0625 - static const double c1o12 = 1./12.; //0.08333333 - static const double c1o9 = 1./9.; //0.11111111 - static const double c1o8 = 1./8.; //0.125 - 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 c5o16 = 5./16.; //0.3125 - static const double c1o3 = 1./3.; //0.33333333 - static const double c3o8 = 3./8.; //0.375 - static const double c4o9 = 4./9.; //0.44444444 - static const double c1o2 = 1./2.; //0.5 - static const double c9o16 = 9./16.; //0.5625 - static const double c2o3 = 2./3.; //0.66666666 - static const double c3o4 = 3./4.; //0.75 - static const double c3o2 = 3./2.; //1.5 - static const double c4o3 = 4./3.; //1.33333333 - static const double c5o3 = 5./3.; //1.66666666 - static const double c9o5 = 9./5.; //1.8 - static const double c2o9 = 2./9.; //0.22222222 - static const double one_over_sqrt2 = 1.0/sqrt(2.0); //0.707106781 - static const double one_over_sqrt3 = 1.0/sqrt(3.0); //0.577350269 - static const double sqrt2 = sqrt(2.0); //1.4142135 - static const double sqrt3 = sqrt(3.0); //1.7320508 -} - -#endif diff --git a/ThirdParty/Library/basics/utilities/UbNupsTimer.h b/ThirdParty/Library/basics/utilities/UbNupsTimer.h deleted file mode 100644 index 8320aa7de8c5e465edaa032a1816f016e6133bc7..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbNupsTimer.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef UBNUPSTIMER_H -#define UBNUPSTIMER_H - -#include <basics/utilities/UbTiming.h> -#include <sstream> -#include <vector> - - -/*=========================================================================*/ -/* UbNupsTimer */ -/* */ -/** -This Class provides the base for ... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 01.11.04 -*/ -class UbNupsTimer : public UbTiming -{ -public: - UbNupsTimer() : UbTiming() - { - mTempNodes = 0.0; - mNofNodes.resize(0); - mDurations.resize(0); - } - /*==========================================================*/ - UbNupsTimer(std::string name) : UbTiming(name) - { - mNofNodes.resize(0); - mDurations.resize(0); - mTempNodes = 0.0; - } - /*==========================================================*/ - void initTiming() - { - UbTiming::initTiming(); - mNofNodes.resize(0); - mDurations.resize(0); - mTempNodes = 0.0; - } - /*==========================================================*/ - void startTiming(double nofNodes) - { - mTempNodes=nofNodes; - UbTiming::startTiming(); - } - /*==========================================================*/ - void endTiming() - { - UbTiming::endTiming(); - //save #node and time informations - mNofNodes.push_back(mTempNodes); - mDurations.push_back(UbTiming::getDuration()); - //reset internal timecounter - UbTiming::initTiming(); - } - /*==========================================================*/ - double getAverageNups() - { - double averageNups = 0.0; - for(int i=0;i<(int)mNofNodes.size();i++) - averageNups+=mNofNodes.at(i)/mDurations.at(i); - - return averageNups/(double)mNofNodes.size(); - } - /*==========================================================*/ - double getSumOfDuration() - { - double duration = 0.0; - for(int i=0;i<(int)mDurations.size();i++) duration+=mDurations.at(i); - return duration; - } - /*==========================================================*/ - std::string getNupsString() - { - std::stringstream ss; - ss<<"saved nups informations"<<std::endl; - for(int i=0;i<(int)mNofNodes.size();i++) - ss<<mNofNodes.at(i)<<"nodes/"<<mDurations.at(i)<<"sec="<<mNofNodes.at(i)/mDurations.at(i)<<"nups\n"; - return ss.str(); - } - -protected: - -private: - std::vector<double> mNofNodes; - std::vector<double> mDurations; - - double mTempNodes; -}; - -#endif diff --git a/ThirdParty/Library/basics/utilities/UbObservable.h b/ThirdParty/Library/basics/utilities/UbObservable.h deleted file mode 100644 index a1ab9cafbe4443680dc728d1f8907a1ba34c1462..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbObservable.h +++ /dev/null @@ -1,259 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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 -*/ - -class UbObservable -{ -protected: - /*======================================================================*/ - /* Konstruktoren */ - /* */ - /** - Creates a UbObservable itself to be the object to be observed. - Usually this constructor is used in extended classes. - */ - UbObservable() - { - } - - UbObservable(const UbObservable& src) - { - //no copy of observers !!! - } - - //falls irgendein schlaumeier den =operator von UbObservable aufrufen sollte, - //dann macht diesr auch keine kopie! (Allg: zuweisungsoperatoren werden nie vererbt - UbObservable& operator=(const UbObservable& src) - { - return *this; - } - - // /** - // Creates a UbObservable for the specified Object to be observed. - // Usually this constructor is used in associating UbObservable. - // @param object Object to be observed - // */ -public: - /*======================================================================*/ - /* Destruktor */ - /* */ - /** - */ - virtual ~UbObservable() - { - this->notifyObserversObjectWillBeDeleted(); - } - - /*======================================================================*/ - /* methods */ - /* */ - - /** - 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) - */ - virtual void addObserver(UbObserver* observer) - { - if(!observer) return; - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos) - { - if(*pos == observer) return; - } - this->mObserverList.push_back(observer); - } - /** - Deletes an UbObserver from the observerlist. - @param observer the observer to remove from this observable (note that all observers identical are deleted) - ( delete means delete Heap... but here we're only removing a pointer) - */ - virtual void removeObserver(UbObserver* observer) - { - if(!observer) return; - this->mObserverList.remove(observer); - - } - /** - Deletes all Observers from the observerlist. - ( delete means delete Heap... but here we're only removing a pointer) - */ - virtual void removeAllObservers() - { - this->mObserverList.clear(); - } - - /** - Checks whether the specified UbObserver observes this observable. - @param observer the observer to remove from this observable (note that all observers identical are deleted) - @return true if the specified observer observes this observable - */ - virtual bool isObservedBy(UbObserver* observer) - { - if(!observer) return false; - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos) - { - if(*pos == observer) return true; - } - return false; - } - /** - Notifies all of its observers that something happened. Does nothing, if the observed object is null. - Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter. - The Method UbObserver.objectChanged(Object) must be defined - by each class implementing the interface TiObserver - */ - virtual void notifyObserversObjectChanged() - { - std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend - //objectChanged() removed wird... - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();) - { - //cout<<"in notifyObserversObjectChanged\n"; - //cout<<this->mObserverList.size()<<endl; - - tmp_pos = pos++; // erst tmp_pos=pos und dann pos++ - (*tmp_pos)->objectChanged(this); - } - } - - std::list<UbObserver*>* getObserverList() { return &mObserverList;} - - 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. - Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter. - The Method UbObserver.objectChanged(Object) must be defined - by each class implementing the interface TiObserver - */ - virtual void notifyObserversObjectWillBeDeleted() - { - std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend - //objectWillBeDeleted() removed wird... - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();) - { - //cout<<"in notifyObserversObjectWillBeDeleted\n"; - //cout<<this->mObserverList.size()<<endl; - - tmp_pos = pos++; - (*tmp_pos)->objectWillBeDeleted(this); - } - } - - std::list<UbObserver*> mObserverList; -}; -/*=========================================================================*/ - - -#ifdef RCF_USE_SF_SERIALIZATION - SF_NO_CTOR(UbObservable); -#endif //RCF_USE_SF_SERIALIZATION - -#endif - -//// E X A M P L E -////=================== -//class Point : public UbObservable -//{ -//public: -// Point(){x=y=0;} -// ~Point(){} -// void setXCorrdinates(int x,int y) -// { -// this->x = x; this->y = y; -// this->notifyObserverObjectChanged(); -// } -//private: -// int x,y; -//}; -//class VisPoint : public UbObserver -//{ -//public: -// VisPoint(Point* point) -// { -// this->point = point; -// this->point->addObserver(this); -// } -// ~VisPoint() -// { -// if(this->point) point->removeObserver(this); -// } -// void update() { /* do some actualisation stuff */ } -// void objectChanged(UbObservable* changedObject) -// { -// Point* point = dynamic_cast<Point*>(changedObject); -// if( !this->point || this->point != point ) return; -// this->repaint(); -// } -// void objectWillBeDeleted(UbObservable* objectForDeletion) -// { -// if(!this->point) return; -// UbObservable* obsobjet = dynamic_cast<UbObservable*>(this->point); -// if(obsobjet == objectForDeletion) this->point = NULL; -// /////////////////////////////////////////////////////////////////// -// //*********************************************************************// -// //INGEGEN erster annahmen nicht verwenden, da es nicht immer funktioniert -// //z.B. bei mehrfachvererbung haut es nicht hin! -// //// Point* point = reinterpret_cast<point*>(objectForDeletion); -// ////if(!this->point || objectForDeletion != this->point) return; -// ////this->point = NULL; -// //*********************************************************************// -// //was hingegen immer moeglich sein sollte: -// //if(dynamic_cast<void*>(objectForDeletion)==dynamic_cast<void*>(this->point)) -// } -//private: -// Point* point; -//}; diff --git a/ThirdParty/Library/basics/utilities/UbObserver.h b/ThirdParty/Library/basics/utilities/UbObserver.h deleted file mode 100644 index 6008481f65fffca2853ab6409d492ac7f9183050..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbObserver.h +++ /dev/null @@ -1,55 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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 -*/ - -class UbObserver -{ -protected: - - UbObserver(){} - -public: - - virtual ~UbObserver(){} - - /*======================================================================*/ - /* Methoden */ - /* */ - /** - This function is called when the observable indicated that an object - 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 - */ - virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0; -}; - -#endif - - diff --git a/ThirdParty/Library/basics/utilities/UbPointerWrapper.h b/ThirdParty/Library/basics/utilities/UbPointerWrapper.h deleted file mode 100644 index 3fcf0b599c3f87971bbd9f4ee316cb26a9a55275..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbPointerWrapper.h +++ /dev/null @@ -1,36 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBPOINTERWRAPPER_H -#define UBPOINTERWRAPPER_H - -//kappselt dynamische Objekte zur remote uebetragung -//bei RCF werden z.B. aufgrund GC alle lokalen Objekte und -//"nackte" Pointer die automatisch als shared_ptr initialisert -//werde nach Methoden-Aufruf zerstoert -//hierfuer kann man dann den UbPointerWrapper verwenden - -template<typename T> -class UbPointerWrapper -{ -public: - UbPointerWrapper() : pointer(NULL) {} - - UbPointerWrapper(T* pointer) : pointer(pointer) {} - - T* get() { return pointer; } - - template<class Archive> - void serialize(Archive& ar, const unsigned int version) - { - ar & pointer; - } - -private: - T* pointer; -}; - -#endif //UBPOINTERWRAPPER_H diff --git a/ThirdParty/Library/basics/utilities/UbRandom.h b/ThirdParty/Library/basics/utilities/UbRandom.h deleted file mode 100644 index b4429579eeb94f7a0381bc0f0a19d24845bd3e36..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbRandom.h +++ /dev/null @@ -1,60 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBRANDOM_H -#define UBRANDOM_H - -#include <cstdlib> -#include <ctime> -#include <cassert> -#include <cmath> - -/*=========================================================================*/ -/* UbRandom */ -/* */ -/** -generates a random number -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 04.10.2007 -*/ -/* -usage: - int main() - { - char* hand[] = {"Schere", "Stein", "Papier"}; - for (unsigned u = 0; u < 20; u++) - { - cout << hand[UbRandom::rand(0, 2, 1)] << endl; - } - - return 0; - } -*/ - -class UbRandom -{ -private: - UbRandom() { std::srand(static_cast<int>(std::time(NULL))); } - -public: - //returns arbitrary int value element of [min ; max] - static inline int rand(const int& min, const int& max) - { - static UbRandom dummy; - assert(max - min < RAND_MAX); - return ( min + std::rand() % (max - min + 1) ); - } - //returns arbitrary float value element of "( (max - min) / gran ) * [min ; max]" - //with other words: val = min+n*(max-min)/gran, n=0..gran-1 - static inline double rand(const double& min, const double& max, const double& gran) - { - static UbRandom dummy; - return (min + std::floor( std::rand() / (1.0 + RAND_MAX) * gran)* (max - min) / gran); - } -}; - -#endif //UBRANDOM_H diff --git a/ThirdParty/Library/basics/utilities/UbScheduler.h b/ThirdParty/Library/basics/utilities/UbScheduler.h deleted file mode 100644 index 493b567c8c7fbbdaeadda18711b1cc1a1ca14bab..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbScheduler.h +++ /dev/null @@ -1,414 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSCHEDULER_H -#define UBSCHEDULER_H - -#include <iostream> -#include <string> -#include <limits> -#include <cassert> -#include <sstream> -#include <iomanip> -#include <algorithm> - -#include <basics/utilities/UbSystem.h> -#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> - -#include <boost/serialization/serialization.hpp> - - -/*=========================================================================*/ -/* 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 -// -#include <boost/smart_ptr.hpp> -class UbScheduler; -typedef boost::shared_ptr<UbScheduler> UbSchedulerPtr; - -class UbScheduler -{ -public: - class UbSchedule - { - friend class UbScheduler; - public: - UbSchedule() : step(Ub::inf), begin(Ub::inf), end(Ub::inf) { } - UbSchedule(const double& step, const double& begin=0.0, const double& end=Ub::inf) - : step(step), begin(begin), end(end) - { - } - double getStep() const { return this->step; } - double getBegin() const { return this->begin; } - double getEnd() const { return this->end; } - - /*==========================================================*/ - std::string toString() { std::stringstream text; text<<*this; return text.str(); } - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const UbSchedule& schedule) - { - os<<"Schedule[start,end,step]=["<<schedule.begin<<", "<<schedule.end<<", "<<schedule.step<<"]"; - 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(); - } - //------------- implements boost serialization ----- end - - private: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & begin; - ar & end; - ar & step; - } - - - private: - double step, begin, end; - }; - -public: - UbScheduler() - { - this->initVals(); - } - /*==========================================================*/ - UbScheduler(const double& step,const double& begin=0, const double& end=Ub::inf ) - { - this->initVals(); - this->addSchedule(step,begin,end); - } - /*==========================================================*/ - UbScheduler(const UbSchedule& schedule) - { - this->initVals(); - this->addSchedule(schedule); - } - /*==========================================================*/ - virtual ~UbScheduler() {} - /*==========================================================*/ - inline void addSchedule(const UbSchedule& schedule) - { - this->addSchedule(schedule.step, schedule.begin, schedule.end); - } - /*==========================================================*/ - bool addSchedule(const double& step, const double& begin, double end) - { - if( UbMath::zero(step) || begin>end ) - { - std::cerr<<"UbScheduler::addSchedule - invalid Schedule:\n\t"<<UbSchedule(step, begin, end)<<std::endl; - return false; - } - - if( UbMath::less( end, (double)Ub::inf ) ) - { - //es kann vorkommen, dass man mit dem intervall nicht genau auf den letzten wert kommt - //(z.B. step=2; start=0; end=9; -> ende wird angepasst) - //also wenn end-begin>Ub::inf ist, dann geht es halt nicht.. ein cast in long double half hier nichts - double multiplier=0.0; - double fractpart = modf( (end-begin)/step, &multiplier); - if( !UbMath::zero(fractpart) ) - { - //tmp-speicherung (fuer cerr) - fractpart = end; - //neues ende - end = begin+multiplier*step; - - std::cerr<<"Warning: UbScheduler::addSchedule - " - <<"end of schedule was adapted to intervall \n\t" - <<"from "<< UbSchedule(step, begin, fractpart) <<" to "<< UbSchedule(step, begin, end) <<std::endl; - } - } - - //nu aber: - schedules.push_back(UbSchedule(step, begin, end)); - - if( end>maxT ) maxT = end; - - double potentialDueTime; - if( calcNextDueTimeForSchedule(schedules.back(), lastUsedT, potentialDueTime) - && potentialDueTime < nextDueTime ) - { - nextDueTime = potentialDueTime; - } - - return true; - } - /*==========================================================*/ - //returns true if scheduler contains schedules - bool hasSchedules() const { return !schedules.empty(); } - /*==========================================================*/ - //time bei dem das letzte mal isDue(time) true war - double getLastDueTime() const { return lastDueTime; } - /*==========================================================*/ - //time bei dem das naechste mal isDue(time) true ergibt - double getNextDueTime() const { return nextDueTime; } - /*==========================================================*/ - //maxDueTime (maxTime der Schedules! - double getMaxDueTime() const { return this->maxT; } - /*==========================================================*/ - bool isDue(const double& t) - { - lastUsedT = t; - if( UbMath::greaterEqual(t,nextDueTime) ) - { - //groesser maxT is nicht - if( UbMath::greater(t,maxT) ) return false; - - //temp var - double actDueTime = nextDueTime; - - //um Suche nach nextDueTime bei "Zukunfts-t" zu optimieren, setzt man die "start"-suchzeit auf "t-1": - nextDueTime = t-1; //t-1 deshlab, damit falls z.B. while Schleife nicht durchlaufen wird - //die folgende if Abfrage nicht faelschlicher Weise true ist! - while( UbMath::greaterEqual(t,nextDueTime) && !UbMath::equal(nextDueTime, maxT) ) - { - double tmpNextDueTime = maxT, potentialDueTime=-1.0; - for(std::size_t i=0; i<schedules.size(); i++) - { - if( calcNextDueTimeForSchedule(schedules[i], nextDueTime, potentialDueTime) - && potentialDueTime < tmpNextDueTime ) - { - assert( nextDueTime < potentialDueTime ); - tmpNextDueTime = potentialDueTime; - } - } - actDueTime = nextDueTime; - nextDueTime = tmpNextDueTime; - } - - //wenn t = der aktuuellen oder gar schon der nächstmöglichen 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 - if( UbMath::equal(t,actDueTime) - || UbMath::equal(t,nextDueTime) ) - { - lastDueTime = t; - return true; - } - } - else if( UbMath::lessEqual(t, lastDueTime) ) - { - if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man für dasselbe t isDue(t) aufruft - else - { - //Fall: Zeit liegt faktisch in der Vergangenheit -> neu initialsisieren - double tmpNextDueTime = maxT, potentialDueTime=-1.0; - for(size_t i=0; i<schedules.size(); i++) - { - if( calcNextDueTimeForSchedule(schedules[i], t-1, potentialDueTime) - && potentialDueTime < tmpNextDueTime ) - { - tmpNextDueTime = potentialDueTime; - } - } - nextDueTime = tmpNextDueTime; - - return UbMath::equal(t, nextDueTime); - } - } - - return false; - } - /*==========================================================*/ - inline double getMinBegin( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin(); - } - /*==========================================================*/ - inline double getMaxBegin( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin(); - } - /*==========================================================*/ - inline double getMinEnd( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd(); - } - /*==========================================================*/ - inline double getMaxEnd( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd(); - } - /*==========================================================*/ - inline double getMinStep( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep(); - } - /*==========================================================*/ - inline double getMaxStep( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep(); - } - /*==========================================================*/ - inline std::string toString() const - { - std::stringstream text; - text<<*this; - return text.str(); - } - /*==========================================================*/ - friend 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; - } - - //------------- 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); - } - } - //------------- implements boost serialization ----- end - -private: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & lastUsedT; - ar & lastDueTime; - ar & nextDueTime; - ar & maxT; - ar & schedules; - } - -protected: - /*==========================================================*/ - void initVals() - { - lastUsedT = -Ub::inf; - lastDueTime = -Ub::inf; - nextDueTime = Ub::inf; - maxT = -Ub::inf; - } - /*==========================================================*/ - // calculates next due time for a schedule - // with nextDueTime > searchStart - bool calcNextDueTimeForSchedule(const UbSchedule& schedule, const double& searchStart, double& nextDueTime ) - { - if ( UbMath::greater(searchStart, schedule.end ) ) return false; - else if( UbMath::less( searchStart, schedule.begin) ) nextDueTime = schedule.begin; - else - { - nextDueTime = schedule.begin + ((int)((searchStart-schedule.begin)/schedule.step)+1)*schedule.step; - if( UbMath::less( nextDueTime, searchStart ) - || UbMath::greater(nextDueTime, schedule.end) ) - { - return false; - } - } - return true; - } - -protected: - double lastUsedT; - double lastDueTime; - double nextDueTime; - double maxT; - - std::vector<UbSchedule> schedules; -}; - -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 - - - -//int main(int argc, char** argv) -//{ -// UbScheduler writeSchedule; -//// writeSchedule.addSchedule(0,2000,100); -//// writeSchedule.addSchedule(3005,4500,300); -//// writeSchedule.addSchedule(0,10,1); -//// writeSchedule.addSchedule(0,100001,100); -// writeSchedule.addSchedule(0,2,1); -// writeSchedule.addSchedule(0,100001,200); -// -// for(int t = 0; t < 1001; t++) -// { -// if(writeSchedule.isDue(t)) -// { -// cout<<"due@ "<<t<<endl; -// } -// } -// return 0; -//} - diff --git a/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp b/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp deleted file mode 100644 index 7772fc5d822487033d53af7caeb49b956ba7a201..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include <basics/utilities/UbStaticPathMap.h> - -UbStaticPathMap::PathMap UbStaticPathMap::pathMap; -const std::string UbStaticPathMap::GLOBAL = "UbStaticPathMap::GLOBAL"; diff --git a/ThirdParty/Library/basics/utilities/UbStaticPathMap.h b/ThirdParty/Library/basics/utilities/UbStaticPathMap.h deleted file mode 100644 index 20e5b7e8fb294ba8da532aac010d8f85a878fd1c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbStaticPathMap.h +++ /dev/null @@ -1,71 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSTATICPATHMAP_H -#define UBSTATICPATHMAP_H - -#include <iostream> -#include <string> -#include <map> - -#include <basics/utilities/UbSystem.h> - -/*=========================================================================*/ -/* UbStaticPathMap */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 12.10.2007 -*/ - -/* -stores pathnames for pathIDs (e.g. on different processes different paths with same pathID) -adding an path autom. changes "\" to "/" and removed last "/" if exists - -*/ - -class UbStaticPathMap -{ - typedef std::map< std::string, std::string > PathMap; -public: - static const std::string GLOBAL; -public: - - static std::string addAndMakePath(const std::string& id, const std::string& path) - { - std::string tmpPath = UbStaticPathMap::addPath(id,path); - if( !tmpPath.empty() ) UbSystem::makeDirectory(tmpPath,20); - return tmpPath; - } - static std::string addPath(const std::string& id, const std::string& path) - { - std::string tmpPath = UbSystem::replaceInString(path,"\\","/"); - if(tmpPath.rfind("/") == tmpPath.size()-1) tmpPath.resize(tmpPath.size()-1); - pathMap[id] = tmpPath; - return tmpPath; - } - static std::string getPath(const std::string& id) - { - PathMap::iterator it = pathMap.find(id); - if(it == pathMap.end()) return ""; - return it->second; - } - static void removePath(const std::string& id) - { - pathMap.erase(id); - } - -protected: - static PathMap pathMap; - -private: - UbStaticPathMap() {} - UbStaticPathMap(const UbStaticPathMap&) {} -}; - -#endif //UBSTATICPATHMAP_H diff --git a/ThirdParty/Library/basics/utilities/UbString.h b/ThirdParty/Library/basics/utilities/UbString.h deleted file mode 100644 index 516ee76ea90d44d33983fa3a1a531f98211e3dd1..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbString.h +++ /dev/null @@ -1,24 +0,0 @@ -//unnoetig: UbSystem::toString() verwenden,... andere Richtung: stringTo... oder am besten boost::lexical_cast - - -//#ifndef UBSTRING_H -//#define UBSTRING_H -//#include <string> -//#include <sstream> -// -//using namespace std; -// -//class UbString -//{ -//public: -// static void IntToString(int i, string& res) -// { -// ostringstream temp; -// temp << i; -// res = temp.str(); -// } -//protected: -//private: -//}; -// -//#endif //end UBSTRING_H diff --git a/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp b/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp deleted file mode 100644 index cf104b9fd8c182621b67975e9693f8cd78d91b84..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include <basics/utilities/UbStringInputASCII.h> -#include <cstring> - -using namespace std; - - -UbStringInputASCII::UbStringInputASCII(string inputString) : UbFileInputASCII("") -{ - instream.str(inputString); - - -// this->filename = filename; -// this->commentindicator = 'C'; -// -// infile.open(filename.c_str()); - -} -/*==========================================================*/ -int UbStringInputASCII::readInteger() -{ - int dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -std::size_t UbStringInputASCII::readSize_t() -{ - std::size_t dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::getFileName() -{ - return this->filename; -} - -/*==========================================================*/ -void UbStringInputASCII::skipLine() -{ - string dummy; - getline(instream, dummy); -} -/*==========================================================*/ -void UbStringInputASCII::readLine() -{ - string dummy; - getline(instream, dummy); -} -/*==========================================================*/ -string UbStringInputASCII::readStringLine() -{ - string dummy; - getline(instream, dummy); - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::readLineTill(char stop) -{ - string dummy; - getline(instream, dummy, stop); - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::parseString() -{ - string dummy; - getline(instream, dummy, ' '); - return dummy; -} -/*==========================================================*/ -double UbStringInputASCII::readDouble() -{ - double dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -float UbStringInputASCII::readFloat() -{ - float dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -char UbStringInputASCII::readChar() -{ - char dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::readString() -{ - string dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -bool UbStringInputASCII::containsString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - instream.getline(line,512); - if(instream.eof()) return false; - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - return true; -} -/*==========================================================*/ -void UbStringInputASCII::setPosAfterLineWithString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - instream.getline(line,512); - if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt -} -/*==========================================================*/ -int UbStringInputASCII::readIntegerAfterString(string var) -// last change [10.3.2004] at [9:46] -//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. timesteps 9 -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - instream.getline(line,512); - if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return(atoi(line)); // Umwandlung in int -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -double UbStringInputASCII::readDoubleAfterString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - instream.getline(line,512); - if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) ); - }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return (atof(line)); // Umwandlung in double -} -/*==========================================================*/ -// [9.9.2002] -// liefert sring-Wert der hinter dem uebergebenen char feld in der datei instream steht -// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig) -string UbStringInputASCII::readStringAfterString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - //string line_copy[512]; - - do{ - instream.getline(line,512); - if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) ); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - char *p; - p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab - p=strtok(line,"\t");//schneidet alles "ab und inklusive tab " nach namen ab - - return (string)p; // Umwandlung in string -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbStringInputASCII::readBoolAfterString(string var) -{ - if(this->readStringAfterString(var.c_str()) == "true" ) return true; - else if(this->readStringAfterString(var.c_str()) == "false") return false; - else UB_THROW( UbException(UB_EXARGS,var+" is not equal to 'true' or 'false' in "+this->filename) ); -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbStringInputASCII::readBool() -{ - string tmp = this->readString(); - if( tmp == "true" ) return true; - else if(tmp == "false") return false; - else UB_THROW( UbException(UB_EXARGS,"expression is not equal to 'true' or 'false' in "+this->filename) ); -} diff --git a/ThirdParty/Library/basics/utilities/UbStringInputASCII.h b/ThirdParty/Library/basics/utilities/UbStringInputASCII.h deleted file mode 100644 index 787048e071daf501e988d2baf9ebd861f04bf6cf..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbStringInputASCII.h +++ /dev/null @@ -1,55 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSTRINGINPUTASCII_H -#define UBSTRINGINPUTASCII_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -#include <basics/utilities/UbFileInputASCII.h> - -class UbStringInputASCII : public UbFileInputASCII -{ -public: - UbStringInputASCII(std::string inputString); - - std::string getFileName(); - void skipLine(); // Springt zur naechsten Zeile - - void readLine(); - std::string readStringLine(); - std::size_t readSize_t(); - int readInteger(); // Liest einen Int-Wert ein - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); - - bool containsString(std::string var); - void setPosAfterLineWithString(std::string var); - int readIntegerAfterString(std::string var); - double readDoubleAfterString(std::string var); - bool readBoolAfterString(std::string var); - std::string readStringAfterString(std::string var); - - FILETYPE getFileType() { return ASCII; } - -private: - std::istringstream instream; -}; - - -#endif - - diff --git a/ThirdParty/Library/basics/utilities/UbSystem.h b/ThirdParty/Library/basics/utilities/UbSystem.h deleted file mode 100644 index 4178ff2c02342837c0638c8fdac4406caab30d7e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbSystem.h +++ /dev/null @@ -1,534 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSYSTEM_H -#define UBSYSTEM_H - -#if defined(_WIN32) || defined(_WIN64) - #define UBSYSTEM_WINDOWS - #include <process.h> - #include <io.h> - #include <direct.h> - //#ifndef _WINSOCK2API_ //ansonsten gibt es mecker bei #include "Windows.h" und ::Sleep() - // #define _WINSOCK2API_ - // #include<WinSock2.h> - //#endif - #include <windows.h> - //#include <Windows.h> - //#include <tchar.h> -#elif defined(__APPLE__) - #define UBSYSTEM_APPLE - #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> - #include <sys/stat.h> -#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) - #define UBSYSTEM_LINUX - #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> - #include <sys/stat.h> - #include <unistd.h> -#elif defined(__AIX__) - #define UBSYSTEM_AIX - #include "dirent.h" - #include <unistd.h> - #include <sys/stat.h> - #include <sys/types.h> -#else - #error "UbSystem::UnknownMachine" -#endif - - - -#if defined(min) || defined(max) //daruch kann man sich spaeter #undef min; #undef max erparen -# error add NOMINMAX to preprocessor defines -#endif - - -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <algorithm> -#include <typeinfo> -#include <cctype> //for toupper -#include <ctime> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbLogger.h> - -#if defined(CAB_BOOST) -#include <boost/thread.hpp> -#endif // CAB_BOOST - -//DEFINE TO STRING -//e.g. #define FOO hallo -// -> QUOTEME(FOO) == "hallo" -#define _QUOTEME(x) #x -#define QUOTEME(x) _QUOTEME(x) - -//allg.: -//const int * C1 -> C1 is variable pointer to a constant integer -//int const * C2 -> C2 is variable pointer to a constant integer (same as above) -//int * const C3 -> C3 is constant pointer to a variable integer -//int const * const C4 -> C4 is constant pointer to a constant integer - -////////////////////////////////////////////////////////////////////////// -//UbSystem -////////////////////////////////////////////////////////////////////////// -namespace UbSystem -{ - template<bool> struct ub_static_assert; //deklaration (ub_xxx da static_assert in C++0x ein keyword werden wird) - template<> struct ub_static_assert<true>{}; //deklaration + definition der spezialisierung fuer "true" - //ub_static_assert<false> fuehrt zu compiler fehler, da dafuer - //keine implementierung vorhanden! //UB_STATIC_ASSERT(false) - - /*==========================================================*/ - inline void sleepMs(const unsigned int& msec) - { - #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) - ::usleep(1000*msec); - #else - #error "UbSystem::sleepMSec - UnknownMachine" - #endif - } - /*==========================================================*/ - inline void sleepS(const unsigned int& sec) - { - #if defined UBSYSTEM_WINDOWS - ::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) - ::sleep(sec); - #else - #error "UbSystem::sleepS - UnknownMachine" - #endif - } - /*==========================================================*/ - //checks if the bits of bitmask are set in value - template<typename T> - inline bool bitCheck(const T& value, const T& bitmask) - { - return ( (value & bitmask) == bitmask); - } - /*==========================================================*/ - //checks if the bits of bitmask are set in value - template<typename T> - inline void setBit(T& value, const T& bitmask) - { - value |= bitmask; - } - /*==========================================================*/ - template<typename T> - inline void unsetBit(T& value, const T& bitmask) - { - value &= ~bitmask; - } - /*==========================================================*/ - //returns bitmask as string e.g. 0001 0100 1101 - template<typename T> - inline std::string getBitString(const T& value) - { - std::stringstream text; - for(int i=sizeof(value)*8-1/*8 bits per byte*/; i>=0; i--) - { - text<<(char) ( ((value>>i) & 1) + '0'); - if(i%4 == 0 && i>0) text<<' '; - } - return text.str(); - } - /*==========================================================*/ - //converts string to type T - // usage: int x = stringTo<int>("123"); - template<typename T> - inline T stringTo(const std::string& s) - { - std::istringstream iss(s); - T x; - iss >> x; - if(!iss) - UB_THROW( UbException(UB_EXARGS," cannot convert \""+s+"\" to type <"+static_cast<std::string>(typeid(x).name())+">") ); - - return x; - } - /*==========================================================*/ - // usage: string s = toString(x); - template<typename T> - inline std::string toString(const T& x, int precision=15) - { - std::ostringstream oss; - oss<<std::setprecision(precision); - oss<<x; - return oss.str(); - } - /*==========================================================*/ - //e.g. str="iHcsnW" -> "IHCSNW" - inline std::string toUpperString(const std::string& str) - { - std::string tmp(str); - std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::toupper)); - - return tmp; - } - /*==========================================================*/ - //e.g. str="iHcsnW" -> "ihcsnw" - inline std::string toLowerString(const std::string& str) - { - std::string tmp(str); - std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::tolower)); - - return tmp; - } - /*==========================================================*/ - // usage: std::string s = replaceInString(str,"\\","/"); - // std::string s = replaceInString(str,"ich","du"); - static std::string replaceInString(std::string original, const std::string& replace, const std::string& replaceWith ) - { - size_t pos=0; - while( (pos=original.find(replace,pos))!=std::string::npos ) - { - original.replace(pos,replace.size(),replaceWith); - pos+=replaceWith.size(); - } - return original; - } - /*==========================================================*/ - //returns content of an enviroment variable - inline std::string getEnv(const std::string& var) - { - char* str = getenv( var.c_str()); - if( str == NULL ) - { - return std::string(""); - } - - return static_cast<std::string>( str ); - } - /*==========================================================*/ - inline bool isDirectory(const std::string& dir, const unsigned& attemptions = 3) - { - if( dir.empty() ) - UB_THROW( UbException(UB_EXARGS,"dir is empty") ); - - std::string path = UbSystem::replaceInString(dir,"\\","/"); - - #if defined UBSYSTEM_WINDOWS - #ifndef _UNICODE - if( _access(path.c_str(), 0 ) == -1 ) return false; - #else - if( _waccess(path.c_str(), 0 ) == -1 ) return false; - #endif - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) - struct stat stFileInfo; - if( stat(path.c_str(),&stFileInfo) != 0) - { - return false; - } - #endif - - return true; - } - /*==========================================================*/ - // usage: makeDirectory("c:/temp"); - // makeDirectory("c:/temp/"); - // return: true -> successful - // false -> failed - #if defined(CAB_BOOST) - static boost::mutex mtx_makeDirectory; - #endif - inline bool makeDirectory(const std::string& dir, const unsigned& attemptions = 3) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory - start, dir="<<dir<<" #attemptions="<<attemptions); - - if( dir.empty() ) UB_THROW( UbException(UB_EXARGS,"dir is empty") ); - std::string path = UbSystem::replaceInString(dir,"\\","/"); - - bool dirCreated = true; - #if defined UBSYSTEM_WINDOWS - if(path[path.size()-1] != '/') path+="/"; - size_t pos = 0; - while( ( pos=path.find("/",pos+1) ) != std::string::npos ) - { - std::string tmpdir = path.substr(0,pos); - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_makeDirectory); - #endif - if( - #ifndef _UNICODE - _access(tmpdir.c_str(), 0 ) == -1 && _mkdir(tmpdir.c_str() ) == -1 - #else - _waccess(tmpdir.c_str(), 0) == -1 && _wmkdir(tmpdir.c_str()) == -1 - #endif - ) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory- dir=\""<<tmpdir<<"\" doesn't exit or makedir failed"); - dirCreated = false; - break; - } - } - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) - std::string command = "mkdir -p \""+path+"\""; - { - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_makeDirectory); - #endif - if(system(command.c_str())!=0) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory- dir=\""<<path<<"\" doesn't exit or makedir failed"); - dirCreated = false; - } - } - #else - #error "UbSystem::makeDirectory - UnknownMachine" - #endif - - if(!dirCreated && attemptions > 1) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory - internal call of UbSystem::makeDirectory"); - UbSystem::sleepMs(500); - dirCreated = UbSystem::makeDirectory(path, attemptions-1); - } - - UBLOG(logDEBUG5,"UbSystem::makeDirectory - end (success="<<dirCreated<<", attemptions = "<<attemptions<<")"); - return dirCreated; - } - /*==========================================================*/ -#if defined(CAB_BOOST) - static boost::mutex mtx_removeDirectory; -#endif - inline int removeDirectory(const std::string& dir) - { - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_removeDirectory); - #endif - std::string command = "rmdir \""+dir+"\""; - return std::system(command.c_str()); - } - /*==========================================================*/ - // usage : getPathFromString("c:/temp/foo.txt"); - //returns: "c:/temp" - // usage : getPathFromString("c:\\temp\\foo.txt"); - //returns: "c:/temp" - // usage : getPathFromString("foo.txt"); - // returns: "" - inline std::string getPathFromString(const std::string& fileStringWithPath) - { - std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/"); - std::size_t last = tmp.rfind("/"); - if(last!=std::string::npos) tmp.resize(last); - else tmp = ""; - return tmp; - } - /*==========================================================*/ - // usage : getFilenameFromString("c:/temp/foo.txt"); - // returns: "foo.txt" - // usage : getFilenameFromString("c:/temp/foo.txt",false); - // returns: "foo" - // usage : getFilenameFromString("c:/temp/"); - // returns: "" - inline std::string getFilenameFromString(const std::string& fileStringWithPath, bool withExtension = true) - { - std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/"); - - //remove path - std::size_t last = tmp.rfind("/"); - if(last!=std::string::npos && (last+1)<tmp.size()) tmp.erase(0,last+1); - - //remove extension - if(!withExtension) - { - last = tmp.rfind("."); - if(last!=std::string::npos) tmp.erase(last); - } - - return tmp; - } - /*==========================================================*/ - inline int getProcessID() - { - #if defined UBSYSTEM_WINDOWS - return _getpid(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) - return getpid(); - #else - #error "int UbSystem::getProcessID() - UnknownMachine" - #endif - } - /*==========================================================*/ - inline unsigned long getCurrentThreadID() - { - #if defined UBSYSTEM_WINDOWS - return (unsigned long)GetCurrentThreadId(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - return (unsigned long)syscall(SYS_gettid); - #elif defined(UBSYSTEM_AIX) - return (unsigned long) getpid(); //WORKAROUND for IBM (for get thread id is another function necessary) - #else - #error "unsigned long UbSystem::getCurrentThreadID() - UnknownMachine" - #endif - } - /*==========================================================*/ - inline bool isBigEndian() - { - short word = 0x4321; - if((*(char*)& word) != 0x21 ) return true; - else return false; - } - /*==========================================================*/ - inline bool isLittleEndian() - { - return !isBigEndian(); - } - /*==========================================================*/ - inline std::string getTimeStamp() - { - time_t t = time(NULL); - tm* localTime = localtime(&t); - - std::stringstream tmp; - tmp.fill('0'); - - tmp << localTime->tm_year+1900 - << "." << std::setw(2) <<localTime->tm_mon+1 - << "." << std::setw(2) << localTime->tm_mday - << "@" << std::setw(2) << localTime->tm_hour - << "." << std::setw(2) << localTime->tm_min - << "." << std::setw(2) << localTime->tm_sec ; - - return tmp.str(); - } - /*==========================================================*/ - //swap Byte Order - //usage: int test = 8; - // swapByteOrder((unsigned char*)& test, sizeof(int)) - //#define ByteSwap5(x) ByteSwap((unsigned char *) &x,sizeof(x)) - inline void swapByteOrder(unsigned char* toSwap, int length) - { - register int i = 0; - register int j = length-1; - while(i<j) - { - std::swap(toSwap[i], toSwap[j]); - i++, j--; - } - } - ////////////////////////////////////////////////////////////////////////// - //get host name - inline std::string getMachineName() - { - char Name[150]; - int i = 0; - -#ifdef UBSYSTEM_WINDOWS - TCHAR infoBuf[150]; - DWORD bufCharCount = 150; - memset(Name, 0, 150); - if (GetComputerName(infoBuf, &bufCharCount)) - { - for (i = 0; i<150; i++) - { - Name[i] = infoBuf[i]; - } - } - else - { - strcpy(Name, "Unknown_Host_Name"); - } -#else - memset(Name, 0, 150); - gethostname(Name, 150); -#endif - return std::string(Name); - } - - ////////////////////////////////////////////////////////////////////////// - // generic IfThenElse - start - ////////////////////////////////////////////////////////////////////////// - // primary template: yield second or third argument depending on first argument - template<bool C, typename Ta, typename Tb> - class IfThenElse; - - // partial specialization: true yields second argument - template<typename Ta, typename Tb> - class IfThenElse<true, Ta, Tb> { - public: - typedef Ta ResultT; - }; - - // partial specialization: false yields third argument - template<typename Ta, typename Tb> - class IfThenElse<false, Ta, Tb> { - public: - typedef Tb ResultT; - }; - ////////////////////////////////////////////////////////////////////////// - // generic IfThenElse - end - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //help struct for overloading methods in template classes for specific types - ////////////////////////////////////////////////////////////////////////// - template< typename T> - struct type2type - { - typedef T type; - }; - - - ////////////////////////////////////////////////////////////////////////// - // pair selector - ////////////////////////////////////////////////////////////////////////// - template <typename Pair> - struct select1st - { - typedef Pair argument_type ; - typedef typename Pair::first_type result_type ; - - const result_type& operator()(const argument_type &p) const - { - return p.first ; - } - }; - - template <typename Pair> - struct select2nd - { - typedef Pair argument_type ; - typedef typename Pair::second_type result_type ; - - const result_type& operator()(const argument_type &p) const - { - return p.second ; - } - }; - -}; - -#define UB_STATIC_ASSERT(expr) static_cast<void>(sizeof( UbSystem::ub_static_assert<expr> )); -//zum ueberpruefen von STATISCHEN ausdruecken waehrend der compile-zeit -//--> Ausdruecke muessen schon ZUR compilerzeit auswertbar sein !!! -//Anwendung z.B. zur Ueberpruefung von Funktionalitaeten, wie z.B. bei UbMath::getNegativeInfinity<double>(); -// -//Grund fuer macro ist einfach, dass es besser anzuwenden ist in der praxis! -//ansonsten würde es so aussehen: -// UbSystem::ub_static_assert< aaa == 1 > test(); -// da ist UB_STATIC_ASSERT(aaa == 1); schoener -// -//um das zu vermeiden machtman hier diesen static_cast<void>(sizeof(...) ) -//Code-Snippet: -// struct Test { const static bool m_const_bool = true; bool m_bool; }; -// int main() { -// UB_STATIC_ASSERT( Test::m_const_bool == true ); -// --> okay, assert bestanden -// UB_STATIC_ASSERT( Test::m_const_bool == false); //: -// --> assert nicht bestanden z.B. error C2027: use of undefined type 'UbSystem::ub_static_assert<__formal> with __formal = false --> funzt nicht. fehler im code -// UB_STATIC_ASSERT( Test::m_bool == true ); -// --> nicht erlaubt, da m_bool nicht statisch und nicht const ist. -//} - -#endif //UBSYSTEM_H diff --git a/ThirdParty/Library/basics/utilities/UbTableModel.cpp b/ThirdParty/Library/basics/utilities/UbTableModel.cpp deleted file mode 100644 index eca533129a77a21e3515939b72f848e8f611c9d4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbTableModel.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <basics/utilities/UbTableModel.h> - -UbTableModel::UbTableModel() -{ -} - -UbTableModel::~UbTableModel() -{ - //this->notifyObserversObjectWillBeDeleted(); -} - -//void UbTableModel::objectChanged(UbObservable* changedObject) -//{ -// this->notifyObserversObjectChanged(); -//} -// -//void UbTableModel::objectWillBeDeleted(UbObservable* objectForDeletion) -//{ -// objectForDeletion->removeObserver(this); -//} diff --git a/ThirdParty/Library/basics/utilities/UbTableModel.h b/ThirdParty/Library/basics/utilities/UbTableModel.h deleted file mode 100644 index 4a12d63b3881238daeb261b35b599ccbb7b64890..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbTableModel.h +++ /dev/null @@ -1,37 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTABLEMODEL_H -#define UBTABLEMODEL_H - -#include <iostream> - -class UbTableModel -{ -public: - const static int COL_TYPE_STRING = 1; - const static int COL_TYPE_BOOL = 2; - const static int COL_TYPE_INTEGER = 3; - const static int COL_TYPE_DOUBLE = 4; - - UbTableModel(); - virtual ~UbTableModel(); - - ////////////////////////////////////////////////////////////////////////// - //void objectChanged(UbObservable*); - //void objectWillBeDeleted(UbObservable*); - - virtual int getColumnNumber() = 0; - virtual int getRowNumber() = 0; - virtual std::string getColumnLabel(int column) = 0; - virtual int getColumnType(int column) = 0; - virtual std::string getStringValue(int row, int col) = 0; - virtual void setStringValue(int row, int col, std::string str) = 0; - virtual int getSelectedRowIndex() = 0; - //virtual bool GetBoolValue(int row, int col) = 0; -}; - -#endif //UBTABLEMODEL_H diff --git a/ThirdParty/Library/basics/utilities/UbTiming.h b/ThirdParty/Library/basics/utilities/UbTiming.h deleted file mode 100644 index 5f768fea3d98129f7359f1576c46032ea42cf763..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbTiming.h +++ /dev/null @@ -1,429 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTIMING_H -#define UBTIMING_H - -#include <string> -#include <limits> -#include <iostream> -#include <sstream> -#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: - UbTiming() - { - this->duration = 0.0; - this->deltaT = 0.0; - this->startTime = 0; - this->name = "noname"; - } - /*==========================================================*/ - UbTiming(const std::string& name) - { - this->duration = 0.0; - this->deltaT = 0.0; - this->startTime = 0; - this->name = name; - } - /*==========================================================*/ - virtual ~UbTiming() {} - /*==========================================================*/ - virtual void initTiming() - { - this->duration = 0.0; - } - /*==========================================================*/ - virtual void startTiming() - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //VF_MPI - } - /*==========================================================*/ - virtual void initAndStartTiming() - { - this->initTiming(); - this->startTiming(); - } - /*==========================================================*/ - virtual void endTiming() - { - this->stopTiming(); - } - /*==========================================================*/ - virtual void stopTiming() - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->deltaT = PbMpi::Wtime()-this->startTime; - #else - this->deltaT = ((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //VF_MPI - - this->duration += this->deltaT; - } - /*==========================================================*/ - virtual double getDuration() const - { - return this->duration; - } - /*==========================================================*/ - virtual void setName(const std::string& name) - { - this->name = name; - } - /*==========================================================*/ - virtual std::string getName() const - { - return this->name; - } - /*==========================================================*/ - void start() - { - this->duration = 0.0; - - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //VF_MPI - } - /*==========================================================*/ - void pause() - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->duration += PbMpi::Wtime()-this->startTime; - #else - this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //VF_MPI - } - /*==========================================================*/ - void unpause() - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //VF_MPI - } - /*==========================================================*/ - void stop() - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->duration += PbMpi::Wtime()-this->startTime; - #else - this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //VF_MPI - } - /*==========================================================*/ - double getTicks() const - { - #if defined(VF_MPI) && !defined(CAB_RUBY) - return PbMpi::Wtick(); - #else - return double(1.0)/double(CLOCKS_PER_SEC); - #endif //VF_MPI - } - -protected: - std::string name; - - double startTime; - double duration; - 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 - #include <mach/mach_time.h> - #include <time.h> - #include <stdio.h> - inline void mach_absolute_difference(const uint64_t& end, const uint64_t& start, struct timespec *tp) - { - uint64_t difference = end - start; - static mach_timebase_info_data_t info = {0,0}; - - if (info.denom == 0) - mach_timebase_info(&info); - - uint64_t elapsednano = difference * (info.numer / info.denom); - - tp->tv_sec = elapsednano * 1e-9; - tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9); - } -#elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX) - #include <ctime> - #include <unistd.h> // for sysconf - #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 - -class UbTimer -{ -public: - UbTimer(const bool& storeLapTimes = false) - : name("unamed"), isMeasuring(false), storeLapTimes(storeLapTimes) - , startTime(0.0), totalTime(0.0), lapTime(0.0) - { - - } - /*==========================================================*/ - UbTimer(const std::string& name, const bool& storeLapTimes = false) - : name(name), isMeasuring(false), storeLapTimes(storeLapTimes) - , startTime(0.0), totalTime(0.0), lapTime(0.0) - { - - } - /*==========================================================*/ - virtual ~UbTimer() {} - /*==========================================================*/ - double getLapTime() const { return this->lapTime; } - std::vector<double> getLapTimes() const { return this->lapTimes; } - void setName(const std::string& name) { this->name = name; } - std::string getName() const { return this->name; } - bool isRunning() const { return isMeasuring; } - bool isStoringLapTimes() const { return storeLapTimes; } - /*==========================================================*/ - void setStoreLapTimes(const bool& storeLapTimes) { this->storeLapTimes = storeLapTimes; } - /*==========================================================*/ - void start() - { - this->isMeasuring = true; - - #if defined(VF_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #elif defined(UBSYSTEM_APPLE) - this->startTime = mach_absolute_time(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - this->startTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec); - #else - this->startTime = (double)clock(); - #endif //VF_MPI - } - /*==========================================================*/ - void resetAndStart() { this->reset(); this->start(); } - /*==========================================================*/ - //stop: - stops the calculation and returns the time elapsed since last start/stop - // - timing continues - double stop() - { - //if start() was never activated before: - if(!isMeasuring) return 0.0; - - #if defined(VF_MPI) && !defined(CAB_RUBY) - double actTime = PbMpi::Wtime(); - this->lapTime = actTime-this->startTime; - #elif defined(UBSYSTEM_APPLE) - double actTime = mach_absolute_time(); - timespec tp; - mach_absolute_difference(actTime, this->startTime, &tp); - this->lapTime = tp.tv_sec + tp.tv_nsec*1e-9; - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - double actTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec); - this->lapTime = (actTime-this->startTime)*1.0e-9; - #else - double actTime = (double)clock(); - this->lapTime = (actTime-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //VF_MPI - - this->startTime = actTime; - this->totalTime += this->lapTime; - if(storeLapTimes) lapTimes.push_back(this->lapTime); - - return lapTime; - } - /*==========================================================*/ - void reset() - { - this->isMeasuring = false; - - this->startTime = 0.0; - this->totalTime = 0.0; - this->lapTime = 0.0; - - lapTimes.resize(0); - } - /*==========================================================*/ - double getCurrentLapTime() const - { - //if start() was never activated before: - if(!isMeasuring) return 0.0; - - #if defined(VF_MPI) && !defined(CAB_RUBY) - return PbMpi::Wtime() - this->startTime; - #elif defined(UBSYSTEM_APPLE) - timespec tp; - mach_absolute_difference(mach_absolute_time(), this->startTime, &tp); - return tp.tv_sec + tp.tv_nsec*1e-9; - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - return ((double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec) - this->startTime)*1.0e-9; - #else - return ( (double)clock() - this->startTime ) / (double)CLOCKS_PER_SEC; - #endif //VF_MPI - - } - /*==========================================================*/ - double getTotalTime() const - { - return this->totalTime; - } - /*==========================================================*/ - std::string toString() - { - std::stringstream text; - text<<*this; - return text.str(); - } - - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const UbTimer& timer) - { - os<<"UbTimer[totalTime="<<timer.totalTime<<"sec, lapTimes("; - for(std::size_t i=0; i<timer.lapTimes.size(); i++) os<<timer.lapTimes[i]<<","; - os<<")]"; - return os; - } - - -#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; - bool storeLapTimes; - - double startTime; - double totalTime; - double lapTime; - - std::vector<double> lapTimes; -}; - - -/*=========================================================================*/ -// UbProgressTimer - Time Measuring -// -// -// -//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstörung -//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 -// -class UbProgressTimer : public UbTimer -{ -private: - UbProgressTimer(const UbProgressTimer& rhs); -public: - explicit UbProgressTimer( std::ostream & os = std::cout ) - : UbTimer(),os(os) - { - this->start(); - } - /*==========================================================*/ - ~UbProgressTimer() - { - // A) Throwing an exception from a destructor is a Bad Thing. - // B) The progress_timer destructor does output which may throw. - // C) A progress_timer is usually not critical to the application. - // Therefore, wrap the I/O in a try block, catch and ignore all exceptions. - try - { - // use istream instead of ios_base to workaround GNU problem (Greg Chicares) - std::istream::fmtflags old_flags = os.setf( std::istream::fixed, - std::istream::floatfield ); - std::streamsize old_prec = os.precision( 2 ); - os << stop() << " s" << std::endl; - os.flags( old_flags ); - os.precision( old_prec ); - } - catch (...) {} // eat any exceptions - } - -private: - std::ostream & os; -}; - - -#endif //UBTIMING_H diff --git a/ThirdParty/Library/basics/utilities/UbTuple.h b/ThirdParty/Library/basics/utilities/UbTuple.h deleted file mode 100644 index bb711c9dc9c3b91922a1252f78b1f00208d5ccc7..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/utilities/UbTuple.h +++ /dev/null @@ -1,1138 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTUPLE_H -#define UBTUPLE_H - -#include <iostream> -#include <string> - -#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: -**********************************/ -template <typename T> -class UbTypeOp // primary template -{ -public: - typedef T ArgT; - typedef T BareT; - typedef T const ConstT; - typedef T & RefT; - typedef T & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop1.hpp ****/ - -// partial specialization for const -/********************************** -* typeop2.hpp: -**********************************/ -template <typename T> -class UbTypeOp <T const> // partial specialization for const types -{ - public: - typedef T const ArgT; - typedef T BareT; - typedef T const ConstT; - typedef T const & RefT; - typedef T & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop2.hpp ****/ - -// partial specialization for references -/********************************** -* typeop3.hpp: -**********************************/ -template <typename T> -class UbTypeOp <T&> // partial specialization for references -{ -public: - typedef T & ArgT; - typedef typename UbTypeOp<T>::BareT BareT; - typedef T const ConstT; - typedef T & RefT; - typedef typename UbTypeOp<T>::BareT & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop3.hpp ****/ - -// full specialization for void -/********************************** -* typeop4.hpp: -**********************************/ -template<> -class UbTypeOp <void> // full specialization for void -{ -public: - typedef void ArgT; - typedef void BareT; - typedef void const ConstT; - typedef void RefT; - typedef void RefBareT; - typedef void RefConstT; -}; -/**** end of typeop4.hpp ****/ - -//duo1.hpp -template <typename T1, typename T2> -class UbDuo -{ -public: - typedef T1 Type1; // type of first field - typedef T2 Type2; // type of second field - enum { N = 2 }; // number of fields - -public: - // constructors - UbDuo() : value1(), value2() { } - UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } - - // for implicit type conversion during construction - template <typename U1, typename U2> - UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } - - // for implicit type conversion during assignments - template <typename U1, typename U2> - UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) - { - value1 = d.v1();//value1; - value2 = d.v2();//value2; - return *this; - } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - 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 -}; - -// comparison operators (allow mixed types): -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - return d1.v1()==d2.v1() && d1.v2()==d2.v2(); -} - -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - return !(d1==d2); -} - -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator < (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - if (d1.v1() < d2.v1() ) return true; - else if(d1.v1() == d2.v1() ) return d1.v2() < d2.v2(); - - return false; -} - -// convenience function for creation and initialization -template <typename T1, typename T2> -inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b) -{ - return UbDuo<T1,T2>(a,b); -} - -//duo2.hpp -template <typename A, typename B, typename C> -class UbDuo<A, UbDuo<B,C> > -{ -public: - typedef A T1; // type of first field - typedef UbDuo<B,C> T2; // type of second field - enum { N = UbDuo<B,C>::N + 1 }; // number of fields - -public: - // constructors - UbDuo() : value1(), value2() { } - UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } - - // for implicit type conversion during construction - template <typename U1, typename U2> - UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } - - // for implicit type conversion during assignments - template <typename U1, typename U2> - UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) - { - value1 = d.v1();//value1; - value2 = d.v2();//value2; - return *this; - } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - 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 -}; - -//duo3.hpp -// primary template for type of Nth field of (duo) T -template <int N, typename T> -class UbDuoT -{ -public: - typedef void ResultT; // in general, the result type is void -}; - -// specialization for 1st field of a plain duo -template <typename A, typename B> -class UbDuoT<1, UbDuo<A,B> > -{ -public: - typedef A ResultT; -}; - -// specialization for 2nd field of a plain duo -template <typename A, typename B> -class UbDuoT<2, UbDuo<A,B> > -{ -public: - typedef B ResultT; -}; - -// specialization for Nth field of a recursive duo -template <int N, typename A, typename B, typename C> -class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT; -}; - -// specialization for 1st field of a recursive duo -template <typename A, typename B, typename C> -class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef A ResultT; -}; - -// specialization for 2nd field of a recursive duo -template <typename A, typename B, typename C> -class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef B ResultT; -}; - -//duo4.hpp -// primary template for value of Nth field of (duo) T -template <int N, typename T> -class DuoValue -{ -public: - static void get(T&) { } // in general, we have no value - static void get(T const&) { } -}; - -// specialization for 1st field of a plain duo -template <typename A, typename B> -class DuoValue<1, UbDuo<A, B> > -{ -public: - static A& get(UbDuo<A, B> &d) { return d.v1(); } - static A const& get(UbDuo<A, B> const &d) { return d.v1(); } -}; - -// specialization for 2nd field of a plain duo -template <typename A, typename B> -class DuoValue<2, UbDuo<A, B> > -{ -public: - static B& get(UbDuo<A, B> &d) { return d.v2(); } - static B const& get(UbDuo<A, B> const &d) { return d.v2(); } -}; - -// specialization for Nth field of recursive duo -template <int N, typename A, typename B, typename C> -struct DuoValue<N, UbDuo<A, UbDuo<B,C> > > -{ - static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT get(UbDuo<A, UbDuo<B,C> > &d) - { - return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); - } - static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT get(UbDuo<A, UbDuo<B,C> > const &d) - { - return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); - } -}; - -// specialization for 1st field of recursive duo -template <typename A, typename B, typename C> -class DuoValue<1, UbDuo<A, UbDuo<B,C> > > -{ -public: - static A& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v1(); } - static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); } -}; - -// specialization for 2nd field of recursive duo -template <typename A, typename B, typename C> -class DuoValue<2, UbDuo<A, UbDuo<B,C> > > -{ -public: - static B& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v2().v1(); } - static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); } -}; - -//duo5.hpp -// return Nth value of variable duo -template <int N, typename A, typename B> -inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT val(UbDuo<A, B>& d) -{ - return DuoValue<N, UbDuo<A, B> >::get(d); -} - -// return Nth value of constant duo -template <int N, typename A, typename B> -inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT val(UbDuo<A, B> const& d) -{ - return DuoValue<N, UbDuo<A, B> >::get(d); -} - -//duo6.hpp -// partial specialization for UbDuo<> with only one field -template <typename A> -struct UbDuo<A,void> -{ -public: - typedef A T1; // type of first field - typedef void T2; // type of second field - enum { N = 1 }; // number of fields - -private: - T1 value1; // value of first field - -public: - // constructors - UbDuo() : value1() { } - UbDuo (T1 const & a) : value1(a) { } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - void v2() { } - void v2() const { } - - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & value1; - } - #endif -}; - -//tupel1.hpp -// type that represents unused type parameters -class UbNullT -{ -}; - -// UbTuple<> in general derives from UbTuple<> with one more UbNullT -template <typename P1, - typename P2 = UbNullT, - typename P3 = UbNullT, - typename P4 = UbNullT, - typename P5 = UbNullT, - typename P6 = UbNullT, - typename P7 = UbNullT, - typename P8 = UbNullT > -class UbTuple : public UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> -{ -public: - typedef UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<P2>::RefConstT a2, - typename UbTypeOp<P3>::RefConstT a3 = UbNullT(), - typename UbTypeOp<P4>::RefConstT a4 = UbNullT(), - typename UbTypeOp<P5>::RefConstT a5 = UbNullT(), - typename UbTypeOp<P6>::RefConstT a6 = UbNullT(), - typename UbTypeOp<P7>::RefConstT a7 = UbNullT(), - typename UbTypeOp<P8>::RefConstT a8 = UbNullT() ) - : BaseT(a1, UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>(a2,a3,a4,a5,a6,a7,a8)) - { - } - - // for implicit type conversion during assignments - template <typename U1,typename U2, typename U3, typename U4, typename U5, typename U6, typename U7, typename U8 > - UbTuple<P1,P2,P3,P4,P5,P6,P7,P8>& operator = ( const UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>& rhs) - { - this->BaseT::operator=( typename UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>::BaseT(rhs) ); - return *this; - } - -}; - -// specialization to end deriving recursion -template <typename P1, typename P2> -class UbTuple<P1,P2,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> { -public: - typedef UbDuo<P1,P2> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<P2>::RefConstT a2, - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) - : BaseT(a1, a2) - { - } - - // for implicit type conversion during assignments - template <typename U1,typename U2 > - UbTuple<P1,P2>& operator = ( const UbTuple<U1,U2>& rhs) - { - this->BaseT::operator=( typename UbTuple<U1,U2>::BaseT(rhs) ); - return *this; - } - -}; - -// specialization for singletons -template <typename P1> -class UbTuple<P1,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void> -{ -public: - typedef UbDuo<P1,void> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) - : BaseT(a1) - { - } - - // for implicit type conversion during assignments - template <typename U1 > - UbTuple<P1>& operator = ( const UbTuple<U1>& rhs) - { - this->v1() = rhs.v1(); - return *this; - } - -}; - -// convenience function for 1 argument -template <typename T1> -inline UbTuple<T1> makeUbTuple(T1 const &a1) -{ - return UbTuple<T1>(a1); -} - -// convenience function for 2 arguments -template <typename T1, typename T2> -inline UbTuple<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2) -{ - return UbTuple<T1,T2>(a1,a2); -} - -// convenience function for 3 arguments -template <typename T1, typename T2, typename T3> -inline UbTuple<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3) -{ - return UbTuple<T1,T2,T3>(a1,a2,a3); -} - -// convenience function for 4 arguments -template <typename T1, typename T2, typename T3, typename T4> -inline UbTuple<T1,T2,T3,T4> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4) -{ - return UbTuple<T1,T2,T3,T4>(a1,a2,a3,a4); -} - -// convenience function for 5 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5> -inline UbTuple<T1,T2,T3,T4,T5> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4,T5 const &a5) -{ - return UbTuple<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5); -} - -// convenience function for 6 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> -inline UbTuple<T1,T2,T3,T4,T5,T6> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6) -{ - return UbTuple<T1,T2,T3,T4,T5,T6>(a1,a2,a3,a4,a5,a6); -} - -// convenience function for 7 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> -inline UbTuple<T1,T2,T3,T4,T5,T6,T7> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6, T7 const &a7) -{ - return UbTuple<T1,T2,T3,T4,T5,T6,T7>(a1,a2,a3,a4,a5,a6,a7); -} - -// convenience function for 8 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> -inline UbTuple<T1,T2,T3,T4,T5,T6,T7,T8> makeUbTuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5, T6 const &a6,T7 const &a7, T8 const &a8 ) -{ - return UbTuple<T1,T2,T3,T4,T5,T6,T7,T8>(a1,a2,a3,a4,a5,a6,a7,a8); -} - -//some typedefs -typedef UbTuple<float,float> UbTupleFloat2; -typedef UbTuple<float,float,float> UbTupleFloat3; -typedef UbTuple<int,int> UbTupleInt2; -typedef UbTuple<int,int,int> UbTupleInt3; -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<double,double> UbTupleDouble2; -typedef UbTuple<double,double,double> UbTupleDouble3; -typedef UbTuple<double,double,double,double> UbTupleDouble4; -typedef UbTuple<double,double,double,double,double,double> UbTupleDouble6; -typedef UbTuple<std::string,double,double> UbTupleStringDouble2; -typedef UbTuple<std::string,double,double,double> UbTupleStringDouble3; -typedef UbTuple<std::string,int,int,int> UbTupleStringInt3; -typedef UbTuple<short,short,short,short> UbTupleShort4; -typedef UbTuple<bool,bool,bool> UbTupleBool3; -typedef UbTuple<int,double,double> UbTupleIntDouble2; -typedef UbTuple<int, bool> UbTupleIntBool; - - -// class UbTupleWrapper -// { -// public: -// UbTuple<int, int> a; -// -// #ifdef CAB_RCF -// template<class Archive> -// void serialize(Archive & ar, const unsigned int version) -// { -// ar & a; -// } -// void tuWas() -// { -// std::cout<<val<1>(a)<<std::endl; -// -// std::cout<<val<2>(a)<<std::endl; -// } -// -// #endif -// -// }; - - -#endif //UBTUPLE_H - - -//#ifndef AAAAAAAAAAAAAAAAAAAAAAAAAAAAA //UBTUPLE_H -//#define AAAAAAAAAAAAAAAAAAAAAAAAAAAAA //UBTUPLE_H -//class UbTuble; -//#include <iostream> -//#include <string> -//#include <algorithm> -// -// -//// a helper traits to make the make_tuple functions shorter (Vesa Karvonen's suggestion) -//struct UbNullType{}; -// -//template < class T0 = UbNullType, class T1 = UbNullType, class T2 = UbNullType, -//class T3 = UbNullType, class T4 = UbNullType, class T5 = UbNullType, -//class T6 = UbNullType, class T7 = UbNullType, class T8 = UbNullType > -//class UbSimpleTuple -//{ -//public: -// UbSimpleTuple() {} -// UbSimpleTuple(T0 t0) {} -// UbSimpleTuple( const T0& t0) -// : t0(t0) {} -// UbSimpleTuple( const T0& t0, const T1& t1) -// : t0(t0), t1(t1){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2) -// : t0(t0), t1(t1), t2(t2) {} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3) -// : t0(t0), t1(t1), t2(t2), t3(t3){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6), t7(t7){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6), t7(t7), t8(t8){} -// -// T0 t0; -// T1 t1; -// T2 t2; -// T3 t3; -// T4 t4; -// T5 t5; -// T6 t6; -// T7 t7; -// T8 t8; -//}; -// -// -//UbSimpleTuple<> -//inline makeUbSimpleTuple() { return UbSimpleTuple<>(); } -// -//template<class T0> -//inline UbSimpleTuple<T0> makeUbSimpleTuple(const T0& t0) { return UbSimpleTuple<T0>(t0); } -// -//template<class T0, class T1> -//inline UbSimpleTuple<T0,T1> makeUbSimpleTuple(const T0& t0, const T1& t1) { return UbSimpleTuple<T0,T1>(t0,t1); } -// -//template<class T0, class T1, class T2> -//inline UbSimpleTuple<T0,T1,T2> makeUbSimpleTuple(const T0& t0, const T1& t1, const T2& t2) { return UbSimpleTuple<T0,T1,T2>(t0,t1,t2); } -// -//template<class T0, class T1, class T2, class T3> -//inline UbSimpleTuple<T0,T1,T2,T3> makeUbSimpleTuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3) { return UbSimpleTuple<T0,T1,T2,T3>(t0,t1,t2,t2); } -// -//////////////////////////////////////////////////////////////////////////// -////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; -// -// //UbTuple<int,double,double> ttt3; -// //val<3>(t3); -// // -// //// create and use duo -// //UbType<bool,int> t2; -// //std::cout << val<1>(t2) << ", "; -// //std::cout << t2.v1() << std::endl; -// -// //// create and use triple -// //UbType<bool,int,double> t3; -// //val<1>(t3) = true; -// //val<2>(t3) = 42; -// //val<3>(t3) = 0.2; -// -// //std::cout << val<1>(t3) << ", "; -// //std::cout << val<2>(t3) << ", "; -// //std::cout << val<3>(t3) << std::endl; -// -// //t3 = make_tuple(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; -// //std::cout << t4.v2().v2().v2() << std::endl; -// -////typeop.hpp -//// primary template -///********************************** -//* typeop1.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp // primary template -//{ -//public: -// typedef T ArgT; -// typedef T BareT; -// typedef T const ConstT; -// typedef T & RefT; -// typedef T & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop1.hpp ****/ -// -//// partial specialization for const -///********************************** -//* typeop2.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp <T const> // partial specialization for const types -//{ -// public: -// typedef T const ArgT; -// typedef T BareT; -// typedef T const ConstT; -// typedef T const & RefT; -// typedef T & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop2.hpp ****/ -// -//// partial specialization for references -///********************************** -//* typeop3.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp <T&> // partial specialization for references -//{ -//public: -// typedef T & ArgT; -// typedef typename UbTypeOp<T>::BareT BareT; -// typedef T const ConstT; -// typedef T & RefT; -// typedef typename UbTypeOp<T>::BareT & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop3.hpp ****/ -// -//// full specialization for void -///********************************** -//* typeop4.hpp: -//**********************************/ -//template<> -//class UbTypeOp <void> // full specialization for void -//{ -//public: -// typedef void ArgT; -// typedef void BareT; -// typedef void const ConstT; -// typedef void RefT; -// typedef void RefBareT; -// typedef void RefConstT; -//}; -///**** end of typeop4.hpp ****/ -// -////duo1.hpp -//template <typename T1, typename T2> -//class UbDuo -//{ -//public: -// typedef T1 Type1; // type of first field -// typedef T2 Type2; // type of second field -// enum { N = 2 }; // number of fields -// -//private: -// T1 value1; // value of first field -// T2 value2; // value of second field -// -//public: -// // constructors -// UbDuo() : value1(), value2() { } -// UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } -// -// // for implicit type conversion during construction -// template <typename U1, typename U2> -// UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } -// -// // for implicit type conversion during assignments -// template <typename U1, typename U2> -// UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) -// { -// value1 = d.value1; -// value2 = d.value2; -// return *this; -// } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// T2& v2() { return value2; } -// T2 const& v2() const { return value2; } -//}; -// -//// comparison operators (allow mixed types): -//template <typename T1, typename T2, -//typename U1, typename U2> -//inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -//{ -// return d1.v1()==d2.v1() && d1.v2()==d2.v2(); -//} -// -//template <typename T1, typename T2, -//typename U1, typename U2> -//inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -//{ -// return !(d1==d2); -//} -// -//// convenience function for creation and initialization -//template <typename T1, typename T2> -//inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b) -//{ -// return UbDuo<T1,T2>(a,b); -//} -// -////duo2.hpp -//template <typename A, typename B, typename C> -//class UbDuo<A, UbDuo<B,C> > -//{ -//public: -// typedef A T1; // type of first field -// typedef UbDuo<B,C> T2; // type of second field -// enum { N = UbDuo<B,C>::N + 1 }; // number of fields -// -//private: -// T1 value1; // value of first field -// T2 value2; // value of second field -// -//public: -// // constructors -// UbDuo() : value1(), value2() {} -// UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } -// -// // for implicit type conversion during construction -// template <typename U1, typename U2> -// UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } -// -// // for implicit type conversion during assignments -// template <typename U1, typename U2> -// UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) -// { -// value1 = d.value1; -// value2 = d.value2; -// return *this; -// } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// T2& v2() { return value2; } -// T2 const& v2() const { return value2; } -//}; -// -////duo3.hpp -//// primary template for type of Nth field of (duo) T -//template <int N, typename T> -//class UbDuoT -//{ -//public: -// typedef void ResultT; // in general, the result type is void -//}; -// -//// specialization for 1st field of a plain duo -//template <typename A, typename B> -//class UbDuoT<1, UbDuo<A,B> > -//{ -//public: -// typedef A ResultT; -//}; -// -//// specialization for 2nd field of a plain duo -//template <typename A, typename B> -//class UbDuoT<2, UbDuo<A,B> > -//{ -//public: -// typedef B ResultT; -//}; -// -//// specialization for Nth field of a recursive duo -//template <int N, typename A, typename B, typename C> -//class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT; -//}; -// -//// specialization for 1st field of a recursive duo -//template <typename A, typename B, typename C> -//class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef A ResultT; -//}; -// -//// specialization for 2nd field of a recursive duo -//template <typename A, typename B, typename C> -//class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef B ResultT; -//}; -// -////duo4.hpp -//// primary template for value of Nth field of (duo) T -//template <int N, typename T> -//class UbDuoValue -//{ -//public: -// static void get(T&) { } // in general, we have no value -// static void get(T const&) { } -//}; -// -//// specialization for 1st field of a plain duo -//template <typename A, typename B> -//class UbDuoValue<1, UbDuo<A, B> > -//{ -//public: -// static A& get(UbDuo<A, B> &d) { return d.v1(); } -// static A const& get(UbDuo<A, B> const &d) { return d.v1();} -//}; -// -//// specialization for 2nd field of a plain duo -//template <typename A, typename B> -//class UbDuoValue<2, UbDuo<A, B> > -//{ -//public: -// static B& get(UbDuo<A, B> &d) -// { -// return d.v2(); -// } -// static B const& get(UbDuo<A, B> const &d) { return d.v2(); } -//}; -// -//// specialization for Nth field of recursive duo -//template <int N, typename A, typename B, typename C> -//struct UbDuoValue<N, UbDuo<A, UbDuo<B,C> > > -//{ -// static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT -// get(UbDuo<A, UbDuo<B,C> > &d) { return UbDuoValue<N-1, UbDuo<B,C> >::get(d.v2()); } -// -// static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT -// get(UbDuo<A, UbDuo<B,C> > const &d) { return UbDuoValue<N-1, UbDuo<B,C> >::get(d.v2()); } -//}; -// -//// specialization for 1st field of recursive duo -//template <typename A, typename B, typename C> -//class UbDuoValue<1, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// static A& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v1(); } -// static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); } -//}; -// -//// specialization for 2nd field of recursive duo -//template <typename A, typename B, typename C> -//class UbDuoValue<2, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// static B& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v2().v1(); } -// static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); } -//}; -// -////duo5.hpp -//// return Nth value of variable duo -//template <int N, typename A, typename B> -//inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT -//val(UbDuo<A, B>& d) -//{ -// return UbDuoValue<N, UbDuo<A, B> >::get(d); -//} -// -//// return Nth value of constant duo -//template <int N, typename A, typename B> -//inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT -//val(UbDuo<A, B> const& d) -//{ -// return UbDuoValue<N, UbDuo<A, B> >::get(d); -//} -// -////duo6.hpp -//// partial specialization for UbDuo<> with only one field -//template <typename A> -//struct UbDuo<A,void> -//{ -//public: -// typedef A T1; // type of first field -// typedef void T2; // type of second field -// enum { N = 1 }; // number of fields -// -//private: -// T1 value1; // value of first field -// -//public: -// // constructors -// UbDuo() : value1() { } -// UbDuo (T1 const & a) : value1(a) { } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// void v2() { } -// void v2() const { } -// //... -//}; -// -////tuple1.hpp -//// a helper traits to make the make_tuple functions shorter (Vesa Karvonen's suggestion) -//struct UbNullT{}; -// -//// UbType<> in general derives from UbType<> with one more UbNullT -//template <typename P1, -// typename P2 = UbNullT, -// typename P3 = UbNullT, -// typename P4 = UbNullT, -// typename P5 = UbNullT> -//class UbType : public UbDuo<P1, typename UbType<P2,P3,P4,P5,UbNullT>::BaseT> -//{ -//public: -// typedef UbDuo<P1, typename UbType<P2,P3,P4,P5,UbNullT>::BaseT> BaseT; -// -// // constructors: -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<P2>::RefConstT a2, -// typename UbTypeOp<P3>::RefConstT a3 = UbNullT(), -// typename UbTypeOp<P4>::RefConstT a4 = UbNullT(), -// typename UbTypeOp<P5>::RefConstT a5 = UbNullT() ) : BaseT(a1, UbType<P2,P3,P4,P5,UbNullT>(a2,a3,a4,a5)) -// { -// } -//}; -// -//// specialization to end deriving recursion -//template <typename P1, typename P2> -//class UbType<P1,P2,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> -//{ -//public: -// typedef UbDuo<P1,P2> BaseT; -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<P2>::RefConstT a2, -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) : BaseT(a1, a2) -// { -// } -//}; -// -//// specialization for singletons -//template <typename P1> -//class UbType<P1,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void> -//{ -//public: -// typedef UbDuo<P1,void> BaseT; -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) : BaseT(a1) -// { -// } -//}; -// -//// convenience function for 1 argument -//template <typename T1> -//inline UbType<T1> makeUbTuple(T1 const &a1) -//{ -// return UbType<T1>(a1); -//} -// -//// convenience function for 2 arguments -//template <typename T1, typename T2> -//inline UbType<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2) -//{ -// return UbType<T1,T2>(a1,a2); -//} -// -//// convenience function for 3 arguments -//template <typename T1, typename T2, typename T3> -//inline UbType<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3) -//{ -// return UbType<T1,T2,T3>(a1,a2,a3); -//} -// -//// convenience function for 4 arguments -//template <typename T1, typename T2, typename T3, typename T4> -//inline UbType<T1,T2,T3,T4> make_tuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4) -//{ -// return UbType<T1,T2,T3,T4>(a1,a2,a3,a4); -//} -// -//// convenience function for 5 arguments -//template <typename T1, typename T2, typename T3, -//typename T4, typename T5> -//inline UbType<T1,T2,T3,T4,T5> make_tuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5) -//{ -// return UbType<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5); -//} -// -//#endif - diff --git a/ThirdParty/Library/basics/writer/CMakePackage.txt b/ThirdParty/Library/basics/writer/CMakePackage.txt deleted file mode 100644 index 1222f87f3fb0a45838379cdf4345e3d11a06e575..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/CMakePackage.txt +++ /dev/null @@ -1,3 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) - diff --git a/ThirdParty/Library/basics/writer/WbWriter.h b/ThirdParty/Library/basics/writer/WbWriter.h deleted file mode 100644 index 77869d11876747e42811a0c0659233804353a5a0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriter.h +++ /dev/null @@ -1,183 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITER_H -#define WBWRITER_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - - -#include <vector> -#include <string> -#include <fstream> -#include <sstream> -#include <iostream> -#include <map> - - -#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> - -#include <boost/serialization/serialization.hpp> - -class WbWriter -{ -public: - OBCREATOR_EXT(WbWriter) - - ////////////////////////////////////////////////////////////////////////// - virtual ~WbWriter() - { - - } - - ////////////////////////////////////////////////////////////////////////// - //rein virtuelle Methoden - virtual std::string getFileExtension() = 0; - - ////////////////////////////////////////////////////////////////////////// - //nodes - virtual std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, 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 writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - virtual std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0 === 1 - //nodenumbering must start with 0! - virtual std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - virtual std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - 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() ); } - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<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: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - - } -}; - - -#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/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp b/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp deleted file mode 100644 index 7a9616fd73b6ee250b1e11ac266d8bea77e478b2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp +++ /dev/null @@ -1,896 +0,0 @@ -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterAvsASCII::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+avsfilename); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)nodedatanames.size(); - int nofCellData = (int)celldatanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char nodelabels[1024]; - char nodeunits[1024]; - strcpy(nodelabels, ""); - strcpy(nodeunits, ""); - - for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); } - strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit."); - strcat(nodeunits, "no_unit"); - - out.write((char*)&nodelabels,sizeof(nodelabels)); - out.write((char*)&nodeunits,sizeof(nodeunits)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //CELL DATA - char celllabels[1024]; - char cellunits[1024]; - strcpy(celllabels, ""); - strcpy(cellunits, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); } - strcat(celllabels, celldatanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit."); - strcat(cellunits, "no_unit"); - - out.write((char*)&celllabels,sizeof(celllabels)); - out.write((char*)&cellunits,sizeof(cellunits)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofLines<<" 0 0 0 "<<endl; - - for(int n=0; n<nofNodes; n++) - out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - - for(int l=0; l<nofLines; l++) - out<<l+1<<" 2 line "<< val<1>(lines[l])+1 <<" "<< val<2>(lines[l])+1 <<" "<<endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTrian = (int)triangles.size(); - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofTrian<<" 0 0 0 "<<endl; - - for(int n=0; n<nofNodes; n++) - out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - - for(int l=0; l<nofTrian; l++) - out<<l+1<<" 2 tri "<< val<1>(triangles[l])+1 <<" "<< val<2>(triangles[l])+1 <<" "<< val<3>(triangles[l])+1 <<" "<<endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 2; //triangle - int nofNodesPerCell = 3; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; - } -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!"); - if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!"); - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; - } diff --git a/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h b/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h deleted file mode 100644 index 5c65e1683d3de61a6322be303be76bdfd7f5a677..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h +++ /dev/null @@ -1,76 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSASCII_H -#define WBWRITERAVSASCII_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsASCII : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterAvsASCII ) - - static WbWriterAvsASCII* getInstance() - { - static WbWriterAvsASCII instance; - return &instance; - } - -private: - WbWriterAvsASCII() : WbWriter() {} - WbWriterAvsASCII( const WbWriterAvsASCII& ); //no copy allowed - const WbWriterAvsASCII& operator=( const WbWriterAvsASCII& ); //no copy allowed - -public: - std::string getFileExtension() { return ".ascii.inp"; } - - ///////////////////virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) = 0; - /////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII); - -#endif //WBWRITERAVSASCII_H diff --git a/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp b/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp deleted file mode 100644 index 34d1d3415cf6ca738b0343b334a9d158d783012a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp +++ /dev/null @@ -1,975 +0,0 @@ -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterAvsBinary::writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){ UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary); } - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 1; //line - int nofNodesPerCell = 2; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); - - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)triangles.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 2; //triangle - int nofNodesPerCell = 3; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 2; //triangle - int nofNodesPerCell = 3; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)nodedatanames.size(); - int nofCellData = (int)celldatanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char nodelabels[1024]; - char nodeunits[1024]; - strcpy(nodelabels, ""); - strcpy(nodeunits, ""); - - for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); } - strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit."); - strcat(nodeunits, "no_unit"); - - out.write((char*)&nodelabels,sizeof(nodelabels)); - out.write((char*)&nodeunits,sizeof(nodeunits)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //CELL DATA - char celllabels[1024]; - char cellunits[1024]; - strcpy(celllabels, ""); - strcpy(cellunits, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); } - strcat(celllabels, celldatanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit."); - strcat(cellunits, "no_unit"); - - out.write((char*)&celllabels,sizeof(celllabels)); - out.write((char*)&cellunits,sizeof(cellunits)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; - } -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!"); - if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!"); - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; - } diff --git a/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h b/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h deleted file mode 100644 index 39a5019e92568ea529aacb257253fc5274a4ae2e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h +++ /dev/null @@ -1,74 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSBINARY_H -#define WBWRITERAVSBINARY_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsBinary : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterAvsBinary ) - - static WbWriterAvsBinary* getInstance() - { - static WbWriterAvsBinary instance; - return &instance; - } -private: - WbWriterAvsBinary() : WbWriter() {} - WbWriterAvsBinary( const WbWriterAvsBinary& ); //no copy allowed - const WbWriterAvsBinary& operator=( const WbWriterAvsBinary& ); //no copy allowed - -public: - std::string getFileExtension() { return ".bin.inp"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary); - -#endif //WBWRITERAVSBINARY_H diff --git a/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp b/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp deleted file mode 100644 index 20b1774de592e73bd0bb95d52cffeeacd1431345..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifdef CAB_ZLIB - #include <basics/writer/WbWriterBOBJ.h> - #include <basics/utilities/UbLogger.h> - #include <cstring> - - #include <zlib.h> - - - using namespace std; - /*===============================================================================*/ - std::string WbWriterBOBJ::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles) - { - string bobjFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - start"); - - gzFile gzf = gzopen( bobjFilename.c_str(), "wb1" ); - - size_t nofNodes = nodes.size(); - size_t nofTriangles = triangles.size(); - - //write to file - size_t numVerts; - //double v[3]; - if(sizeof(numVerts)!=4) { throw UbException(UB_EXARGS,"danger..."); } - numVerts = nofNodes; - gzwrite(gzf, &numVerts, sizeof(numVerts)); - - for(size_t k=0; k<nofNodes; k++) { - float vertp = val<1>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - vertp = val<2>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - vertp = val<3>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - } - - //NORMAL VECTOR - //double n[3]; - gzwrite(gzf, &numVerts, sizeof(numVerts)); - for(size_t k=0; k<nofNodes; k++) { - //poly->GetPointData()->GetNormals()->GetTuple(k, n); - float normp = 0.0;//n[0]; - gzwrite(gzf, &normp, sizeof(normp)); - normp = 0.0;//n[1]; - gzwrite(gzf, &normp, sizeof(normp)); - normp = 0.0;//n[2]; - gzwrite(gzf, &normp, sizeof(normp)); - } - - //vtkIdType npts = 3; - //vtkIdType* pts; - size_t numTris = nofTriangles; - gzwrite(gzf, &numTris, sizeof(numTris)); - for(size_t k=0; k<nofTriangles/*(size_t)poly->GetNumberOfPolys()*/; k++) { - //poly->GetPolys()->GetNextCell(npts, pts); - //int triIndex = *pts; - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //triIndex = *(pts+1); - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //triIndex = *(pts+2); - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //poly->GetPolys()->GetNextCell(npts, pts); - int triIndex = val<1>(triangles[k]);//*pts; - gzwrite(gzf, &triIndex, sizeof(triIndex)); - triIndex = val<2>(triangles[k]);//*(pts+1); - gzwrite(gzf, &triIndex, sizeof(triIndex)); - triIndex = val<3>(triangles[k]);//*(pts+2); - gzwrite(gzf, &triIndex, sizeof(triIndex)); - } - - gzclose( gzf ); - - UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - end"); - - return bobjFilename; - } - /*===============================================================================*/ - -#endif //CAB_ZLIB diff --git a/ThirdParty/Library/basics/writer/WbWriterBOBJ.h b/ThirdParty/Library/basics/writer/WbWriterBOBJ.h deleted file mode 100644 index fec3454c3d4cbafb5d360c37f99a3a847f052dec..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterBOBJ.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifdef CAB_ZLIB - #ifndef WBWRITERBOBJ_H - #define WBWRITERBOBJ_H - - #include <string> - #include <basics/writer/WbWriter.h> - - class WbWriterBOBJ : public WbWriter - { - public: - OBCREATOR_EXT( WbWriterBOBJ ) - - static WbWriterBOBJ* getInstance() - { - static WbWriterBOBJ instance; - return &instance; - } - private: - WbWriterBOBJ() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterBOBJ( const WbWriterBOBJ& ); //no copy allowed - const WbWriterBOBJ& operator=( const WbWriterBOBJ& ); //no copy allowed - - static std::string pvdEndTag; - - public: - std::string getFileExtension() { return "BOBJ.gz"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - }; - - UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterBOBJ ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); - - #endif //WBWRITERBOBJ_H - -#endif //CAB_ZLIB diff --git a/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp b/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp deleted file mode 100644 index 4fa1a6381babc0837a2f3c65c576cfe76b75431c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include <basics/writer/WbWriterSunflow.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterSunflow::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string sunflowFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - start"); - - std::ofstream out(sunflowFilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(sunflowFilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(sunflowFilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+sunflowFilename); - } - - // General part - - // Image details - out<<"image {" <<endl; - out<<" resolution 640 480"<<endl; - out<<" aa 0 1" <<endl; - out<<" filter mitchell" <<endl; - out<<"}" <<endl<<endl; - - // Camera position - out<<"camera {" <<endl; - out<<" type pinhole" <<endl; - out<<" eye -0.25 -0.3 0.13"<<endl; - out<<" target -0.1 0.1 0.13" <<endl; - out<<" up 0 0 1" <<endl; - out<<" fov 60" <<endl; - out<<" aspect 1.333333" <<endl; - out<<"}" <<endl<<endl; - - // Light - out<<"light {" <<endl; - out<<" type ibl" <<endl; - out<<" image sky_small.hdr" <<endl; - out<<" center 0 -1 0" <<endl; - out<<" up 0 0 1" <<endl; - out<<" lock true" <<endl; - out<<" samples 200" <<endl; - out<<"}" <<endl<<endl; - - // Shaders - out<<"shader {" <<endl; - out<<" name default-shader" <<endl; - out<<" type diffuse" <<endl; - out<<" diff 0.25 0.25 0.25" <<endl; - out<<"}" <<endl<<endl; - - out<<"shader {" <<endl; - out<<" name Glass" <<endl; - out<<" type glass" <<endl; - out<<" eta 1.333" <<endl; - out<<" color 0.1 0.3 0.8" <<endl; - out<<"}" <<endl<<endl; - - out<<"shader {" <<endl; - out<<" name Mirror" <<endl; - out<<" type mirror" <<endl; - out<<" refl 0.7 0.7 0.7" <<endl; - out<<"}" <<endl<<endl; - - // Objects - // a) Ground plane - out<<"object {" <<endl; - out<<" shader default-shader" <<endl; - out<<" type plane" <<endl; - out<<" p 0 0 0" <<endl; - out<<" n 0 0 1" <<endl; - out<<"}" <<endl<<endl; - - // b) Mesh - out<<"object {" <<endl; - out<<" shader Glass" <<endl; - out<<" transform {" <<endl; - out<<" rotatey 270.0" <<endl; - out<<" }" <<endl; - out<<" type generic-mesh" <<endl; - out<<" name polySurfac" <<endl<<endl; - - - // POINTS SECTION - int nofNodes = (int)nodes.size(); - out<<" points "<<nofNodes<<endl; - for(int n=0; n<nofNodes; n++) - out<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl; - - // TRIANGLES SECTION - int nofTriangles= (int)triangles.size(); - out<<" triangles "<<nofTriangles<<endl; - for(int c=0; c<nofTriangles; c++) - out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl; - - // FOOTER - out<<" normals none" << endl; - out<<" uvs none" << endl; - out<<"}" << endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - end"); - - return sunflowFilename; -} -/*===============================================================================*/ diff --git a/ThirdParty/Library/basics/writer/WbWriterSunflow.h b/ThirdParty/Library/basics/writer/WbWriterSunflow.h deleted file mode 100644 index 5681eac73dc63a24c703120bb58821312aab2090..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterSunflow.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WbWriterSunflow_H -#define WbWriterSunflow_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterSunflow : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterSunflow ) - - static WbWriterSunflow* getInstance() - { - static WbWriterSunflow instance; - return &instance; - } -private: - WbWriterSunflow() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterSunflow( const WbWriterSunflow& ); //no copy allowed - const WbWriterSunflow& operator=( const WbWriterSunflow& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return "ascii.sunflow"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterSunflow ,WbWriter>::getInstance()), CAB_WbWriterSunflow); - -#endif //WbWriterSunflow_H diff --git a/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp b/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp deleted file mode 100644 index b2f83ef59c09e5d9b00b15b90c3d166042444f6a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <basics/writer/WbWriterTecPlotASCII.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/*===============================================================================*/ -string WbWriterTecPlotASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string tecplotfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - start"); - - ofstream out(tecplotfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(tecplotfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(tecplotfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+tecplotfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"TITLE = VirtualFluids OctGrid from "<<UbSystem::getTimeStamp()<<endl; - - out<<"VARIABLES = \"X\", \"Y\", \"Z\""; - for(size_t d=0; d<datanames.size(); d++) - out<<", \""<<datanames[d]<<"\""; - out<<endl; - - out<<"ZONE NODES="<<nofNodes<<", ELEMENTS="<<nofCells<<", DATAPACKING=POINT, ZONETYPE=FEBRICK"<<endl; - for(size_t n=0; n<nodes.size(); n++) - { - UbTupleFloat3& coords = nodes[n]; - out<<val<1>(coords)<<" " - <<val<2>(coords)<<" " - <<val<3>(coords); - for(size_t d=0; d<datanames.size(); d++) - out<<" "<<nodedata[d][n]; - out<<endl; - } - - for(size_t c=0; c<cells.size(); c++) - { - UbTupleInt8& cell = cells[c]; - out<<val<1>(cell)<<" " - <<val<2>(cell)<<" " - <<val<3>(cell)<<" " - <<val<4>(cell)<<" " - <<val<5>(cell)<<" " - <<val<6>(cell)<<" " - <<val<7>(cell)<<" " - <<val<8>(cell)<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - end"); - - return tecplotfilename; -} -/*===============================================================================*/ -string WbWriterTecPlotASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - vector<string > datanames; - vector<vector<double > > nodedata; - return writeOctsWithNodeData(filename,nodes,cells,datanames,nodedata); -} -/*===============================================================================*/ diff --git a/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h b/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h deleted file mode 100644 index ff50c9c928d3636c0a894a77c5e2d523fb88be86..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef WBWRITERTECPLOTASCII_H -#define WBWRITERTECPLOTASCII_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterTecPlotASCII : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterTecPlotASCII ) - #endif - - static WbWriterTecPlotASCII* getInstance() - { - static WbWriterTecPlotASCII instance; - return &instance; - } -private: - WbWriterTecPlotASCII() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"machine error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"machine error float type mismatch"); - } - - WbWriterTecPlotASCII( const WbWriterTecPlotASCII& ); //no copy allowed - const WbWriterTecPlotASCII& operator=( const WbWriterTecPlotASCII& ); //no copy allowed - - static std::string pvdEndTag; -public: - std::string getFileExtension() { return ".ascii.dat"; } - - //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); -// std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes -// std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); -// std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! -// std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); -// std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); -// - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! -// std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -// std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - -// std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); -// 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); -// 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); -// 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 ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterTecPlotASCII ,WbWriter>::getInstance()), CAB_WbWriterTecPlotASCII); -#endif - -#endif //WBWRITERTECPLOTASCII_H diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp b/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp deleted file mode 100644 index 0356f38fa155525ac929c81a7117acba2ffbd0bc..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp +++ /dev/null @@ -1,601 +0,0 @@ -#include <basics/writer/WbWriterVtkASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterVtkASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write node data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - //write cell data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofLines<<" "<<3*nofLines<<"\n"; - int nr = 0; - for(int l=0; l<nofLines; l++) - { - int el = nr+1; - out<<"2 "<< val<1>(lines[l]) <<" "<< val<2>(lines[l]) <<" "<<endl; - nr=el+1; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofLines<<"\n"; - for(int l=0; l<nofLines; l++) out<<"3"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTriangles = (int)triangles.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofTriangles<<" "<<4*nofTriangles<<"\n"; - int nr = 0; - for(int t=0; t<nofTriangles; t++) - { - int el = nr+1; - out<<"3 "<< val<1>(triangles[t]) <<" "<< val<2>(triangles[t]) <<" "<< val<3>(triangles[t]) <<" "<<endl; - nr=el+1; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofTriangles<<"\n"; - for(int l=0; l<nofTriangles; l++) out<<"5"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<4*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"3 "<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"5"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - { out<<"8 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" \n"; - } - - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11 "<<endl; - out<<endl; - - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - { out<<"8 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" \n"; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"8 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - end"); - return vtkfilename; -} diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h b/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h deleted file mode 100644 index 914ab2cab9a37ace767e9fd389c79401d12c5a8a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h +++ /dev/null @@ -1,78 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKASCII_H -#define WBWRITERVTKASCII_H - -#include <basics/writer/WbWriter.h> - -class WbWriterVtkASCII : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterVtkASCII ) - - static WbWriterVtkASCII* getInstance() - { - static WbWriterVtkASCII instance; - return &instance; - } -private: - WbWriterVtkASCII() : WbWriter() {} - WbWriterVtkASCII( const WbWriterVtkASCII& ); //no copy allowed - const WbWriterVtkASCII& operator=( const WbWriterVtkASCII& ); //no copy allowed - -public: - std::string getFileExtension() { return ".ascii.vtk"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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 ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsBinary(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< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII); - -#endif //WBWRITERVTKASCII_H diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp b/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp deleted file mode 100644 index f766fa402236f3fa47a218a54e3187fb3b3a9fb0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp +++ /dev/null @@ -1,747 +0,0 @@ -#include <basics/writer/WbWriterVtkBinary.h> -#include <basics/writer/WbWriterVtkASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterVtkBinary::writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) -{ - return WbWriterVtkASCII::getInstance()->writeLines(filename,nodes,lines); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells) -{ - return WbWriterVtkASCII::getInstance()->writeTriangles(filename,nodes,cells); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - return WbWriterVtkASCII::getInstance()->writeTrianglesWithNodeData(filename,nodes,cells,datanames,nodedata); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - //HEADER-SECTION - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //NODE DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - //CELL DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //CELL DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - //HEADER-SECTION - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = val<1>(nodes[n]); - float x2 = val<2>(nodes[n]); - float x3 = val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //NODE DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = val<1>(nodes[n]); - float x2 = val<2>(nodes[n]); - float x3 = val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - end"); - return vtkfilename; -} - diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h b/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h deleted file mode 100644 index dca3567d3505e0bea3c549ab601cb478c0bb17ed..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h +++ /dev/null @@ -1,77 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKBINARY_H -#define WBWRITERVTKBINARY_H - -#include <basics/writer/WbWriter.h> - -class WbWriterVtkBinary : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterVtkBinary ) - - static WbWriterVtkBinary* getInstance() - { - static WbWriterVtkBinary instance; - return &instance; - } -private: - WbWriterVtkBinary() : WbWriter() {} - WbWriterVtkBinary( const WbWriterVtkBinary& ); //no copy allowed - const WbWriterVtkBinary& operator=( const WbWriterVtkBinary& ); //no copy allowed - -public: - std::string getFileExtension() { return ".bin.vtk"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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 ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary); - -#endif //WBWRITERVTKBINARY_H diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp b/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp deleted file mode 100644 index a5e5fdf7cf9d5550046fb66dfc0250de23a797d0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp +++ /dev/null @@ -1,1188 +0,0 @@ -#include <basics/writer/WbWriterVtkXmlASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::pvdEndTag =" </Collection>\n</VTKFile>"; -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups) -{ - std::string vtkfilename=filename+".pvd"; - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - std::string endian; - if(UbSystem::isLittleEndian()) endian = "LittleEndian"; - else endian = "BigEndian"; - out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >\n"; - out<<" <Collection>"<<endl; - - int group = 0, part=0; - for(std::size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>\n"; - if(sepGroups) group++; - else part++; - } - out<<pvdEndTag; - out.close(); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups) -{ - std::string vtkfilename=filename; - std::fstream test(vtkfilename.c_str(), ios::in); - if(!test) - { - test.clear(); - vtkfilename += ".pvd"; - test.open(vtkfilename.c_str(), ios::in); - if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups); - } - - std::fstream out(vtkfilename.c_str(), ios::in | ios::out); - out.seekp(-(int)pvdEndTag.size()-1, ios_base::end); - - int group = 0; - for(std::size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>\n"; - if(sepGroups) group++; - } - out<<pvdEndTag; - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames) -{ - string vtkfilename=filename+".pvtu"; - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //VTK FILE - out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"; - out<<" <PUnstructuredGrid GhostLevel=\"0\">\n"; - out<<" <PPoints>\n"; - out<<" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n"; - out<<" </PPoints>\n"; - out<<" <PPointData>\n"; - for(size_t s=0; s<pointDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n"; - out<<" </PPointData>\n"; - if (cellDataNames.size() > 0) - { - out<<" <PCellData>\n"; - for(size_t s=0; s<cellDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n"; - out<<" </PCellData>\n"; - } - - for(size_t s=0; s<pieceSources.size(); s++) - out<<" <Piece Source=\""<<pieceSources[s]<<"\"/>\n"; - out<<" </PUnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <CellData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write PointData section - out<<" <PointData Scalars=\"PScalars\"> \n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - - //write celldata section - out<<" <CellData Scalars=\"CScalars\"> \n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofLines<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<=nofLines; c++) - out<<c*2<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<<"3 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofLines<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<=nofLines; c++) - out<<c*2<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<<"3 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTriangles= (int)triangles.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofTriangles<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofTriangles; c++) - out<< val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<nofTriangles+1; c++) - out<<c*3<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofTriangles; c++) - out<<"5 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*3<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"5 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - - //write data section - out<<" <CellData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -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"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<<val<1>(nodes[n])<<" "<<val<2>(nodes[n])<<" "<<val<3>(nodes[n])<<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write PointData section - out<<" <PointData Scalars=\"PScalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\">"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - { - //out<<base64_encode((unsigned char*)(&nodedata[s][d]),sizeof(float)); - //out.write((char*)&nodedata[s][d],sizeof(float)); - out<<nodedata[s][d]<<" "; - } - out<<"</DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlASCII::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< n << " "; - out<<"\n"; - - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int n=1; n<=nofNodes; n++) - out << n << " "; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int n=0; n<nofNodes; n++) - out<<"1 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlASCII::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofNodes; c++) - out << c <<" "; - out<<"\n"; - - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofNodes+1; c++) - out<<c<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - for(int c=0; c<nofNodes; c++) - out<<"1 "; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} - -////////////////////////////////////////////////////////////////////////// -std::string WbWriterVtkXmlASCII::writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - out.precision (std::numeric_limits<double>::digits10 + 1); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofNodes; c++) - out << c <<" "; - out<<"\n"; - - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofNodes+1; c++) - out<<c<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - for(int c=0; c<nofNodes; c++) - out<<"1 "; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float64\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h b/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h deleted file mode 100644 index 84212bd509f14768427a5792717b907e4e90601c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef WBWRITERVTKXMLASCII_H -#define WBWRITERVTKXMLASCII_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -#include <boost/serialization/base_object.hpp> - -class WbWriterVtkXmlASCII : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterVtkXmlASCII ) - - static WbWriterVtkXmlASCII* getInstance() - { - static WbWriterVtkXmlASCII instance; - return &instance; - } -private: - WbWriterVtkXmlASCII() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterVtkXmlASCII( const WbWriterVtkXmlASCII& ); //no copy allowed - const WbWriterVtkXmlASCII& operator=( const WbWriterVtkXmlASCII& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return ".ascii.vtu"; } - - //write a metafile - std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timesteps, const bool& sepGroups);//std::vector<double>& groups, std::vector<double>& parts); - std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); - std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes - std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); - std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - std::string writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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 ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - -private: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object<WbWriter>(*this); - } -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); - -#endif //WBWRITERVTKXMLASCII_H diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp b/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp deleted file mode 100644 index 8d3d9dbf790dee6b6eca2eeb78135fcf877961f3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp +++ /dev/null @@ -1,1582 +0,0 @@ -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -string WbWriterVtkXmlBinary::pvdEndTag =" </Collection>\n</VTKFile>"; -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) -{ - string vtkfilename=filename+".pvd"; - ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - string endian; - if(UbSystem::isLittleEndian()) endian = "LittleEndian"; - else endian = "BigEndian"; - out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >"<<endl; - out<<" <Collection>"<<endl; - - int group = 0, part=0; - for(size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - else part++; - } - out<<pvdEndTag; - out.close(); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::addFilesToCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) -{ - string vtkfilename=filename; - fstream test(vtkfilename.c_str(), ios::in); - if(!test) - { - test.clear(); - vtkfilename += ".pvd"; - test.open(vtkfilename.c_str(), ios::in); - if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups); - } - - fstream out(vtkfilename.c_str(), ios::in | ios::out); - out.seekp(-(int)pvdEndTag.size()-1, ios_base::end); - - int group = 0; - for(size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - } - out<<pvdEndTag; - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames) -{ - string vtkfilename=filename+".pvtu"; - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //VTK FILE - out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">"<<"\n"; - out<<" <PUnstructuredGrid GhostLevel=\"0\">"<<"\n"; - out<<" <PPoints>\n"; - out<<" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n"; - out<<" </PPoints>\n"; - out<<" <PPointData>\n"; - for(size_t s=0; s<pointDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n"; - out<<" </PPointData>\n"; - if (cellDataNames.size() > 0) - { - out<<" <PCellData>\n"; - for(size_t s=0; s<cellDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n"; - out<<" </PCellData>\n"; - } - - for(size_t s=0; s<pieceSources.size(); s++) - out<<" <Piece Source=\""<<pieceSources[s]<<"\"/>\n"; - out<<" </PUnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per line */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(lines[c]), sizeof(int) ); - out.write( (char*)&val<2>(lines[c]), sizeof(int) ); - - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 2 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 3; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlBinary::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per line */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(lines[c]), sizeof(int) ); - out.write( (char*)&val<2>(lines[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; - -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - - int nofNodes = (int)nodes.size(); - int nofCells = (int)triangles.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 - coord */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 3 /*nodes per triangle */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per triangle */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of triangle */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(triangles[c]), sizeof(int) ); - out.write( (char*)&val<2>(triangles[c]), sizeof(int) ); - out.write( (char*)&val<3>(triangles[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out<<flush; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 3 /*nodes per tri */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per tri */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of tri */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out<<flush; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - - out<<"\n</AppendedData>\n"; - - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarDataPoint = 1 /*scalar */ * nofNodes * sizeof(float); - int bytesScalarDataCell = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - // Point DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<nodedatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarDataPoint); - } - out<<" </PointData>\n"; - - - // Cell DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<celldatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarDataCell); - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //Point DATA SECTION - //scalarData - for(size_t s=0; s<nodedatanames.size(); ++s) - { - out.write((char*)&bytesScalarDataPoint,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - //Cell DATA SECTION - //scalarData - for(size_t s=0; s<celldatanames.size(); ++s) - { - out.write((char*)&bytesScalarDataCell,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -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"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - //int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlBinary::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int ); - int bytesCellOffsets = 1 /*offset per cell */ * nofNodes * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofNodes * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - for(int c=1; c<=nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 1; - for(int c=0; c<nofNodes; c++) - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int ); - int bytesCellOffsets = 1 /*offset per cell*/ * nofNodes * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofNodes * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - for(int c=1; c<=nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 1; - for(int c=0; c<nofNodes; c++) - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; - -} diff --git a/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h b/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h deleted file mode 100644 index b00157fed2b38826b31375e6ffa459eda1b1483b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef WBWRITERVTKXMLBINARY_H -#define WBWRITERVTKXMLBINARY_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -#include <boost/serialization/base_object.hpp> - -class WbWriterVtkXmlBinary : public WbWriter -{ -public: -#ifndef SWIG - OBCREATOR_EXT( WbWriterVtkXmlBinary ) -#endif - - static WbWriterVtkXmlBinary* getInstance() - { - static WbWriterVtkXmlBinary instance; - return &instance; - } -private: - WbWriterVtkXmlBinary() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"machine error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"machine error float type mismatch"); - } - - WbWriterVtkXmlBinary( const WbWriterVtkXmlBinary& ); //no copy allowed - const WbWriterVtkXmlBinary& operator=( const WbWriterVtkXmlBinary& ); //no copy allowed - - static std::string pvdEndTag; -public: - std::string getFileExtension() { return ".bin.vtu"; } - - //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); - std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes - std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); - std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - 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); - 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); - 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 ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -private: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object<WbWriter>(*this); - } -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary); -#endif - -#endif //WBWRITERVTKXMLBINARY_H diff --git a/ThirdParty/Library/basics/writer/WbWriterX3D.cpp b/ThirdParty/Library/basics/writer/WbWriterX3D.cpp deleted file mode 100644 index 68eee613779233c44dbb0cf6c501c564a0bfdab2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterX3D.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include <basics/writer/WbWriterX3D.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterX3D::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string X3DFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - start"); - - std::ofstream out(X3DFilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(X3DFilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(X3DFilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+X3DFilename); - } - - // General part - - //Root Element - out<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" <<endl; - out<<"<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.1//EN\" \"http://www.web3d.org/specifications/x3d-3.1.dtd\">" <<endl; - out<<"<X3D profile='Interchange' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>"<<endl<<endl; - - //Head - out<<"<head>" <<endl; - out<<"<meta content='Simple X3D Writer for blender'/>"<<endl; - out<<"</head>" <<endl<<endl; - - //Scene, Shape beginn - out<<"<Scene>" <<endl; - out<<"<Shape>" <<endl; - - //IndexedFaceSet => Polylinien der Dreiecke - out<<"<IndexedFaceSet coordIndex=\""<<endl; - - // TRIANGLES Ponits SECTION - int nofTriangles= (int)triangles.size(); - //out<<" triangles "<<nofTriangles<<endl; - for(int c=0; c<nofTriangles; c++) - out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" -1"<<endl; - out<<"\">" <<endl; - - //Coordinates - out<<"<Coordinate point=\"" <<endl; - - // Coordinates SECTION - int nofNodes = (int)nodes.size(); - //out<<" points "<<nofNodes<<endl; - for(int n=0; n<nofNodes; n++) - out<<" "<< val<1>(nodes[n]) <<", "<< val<2>(nodes[n]) <<", "<< val<3>(nodes[n])<<", "<<endl; - out<<"\"/>" <<endl; - - //Footer - out<<"</IndexedFaceSet>"<< endl; - out<<"</Shape>" << endl; - out<<"</Scene>" << endl; - out<<"</X3D>" << endl; - - - //// Image details - //out<<"image {" <<endl; - //out<<" resolution 640 480"<<endl; - //out<<" aa 0 1" <<endl; - //out<<" filter mitchell" <<endl; - //out<<"}" <<endl<<endl; - - //// Camera position - //out<<"camera {" <<endl; - //out<<" type pinhole" <<endl; - //out<<" eye -0.25 -0.3 0.13"<<endl; - //out<<" target -0.1 0.1 0.13" <<endl; - //out<<" up 0 0 1" <<endl; - //out<<" fov 60" <<endl; - //out<<" aspect 1.333333" <<endl; - //out<<"}" <<endl<<endl; - - //// Light - //out<<"light {" <<endl; - //out<<" type ibl" <<endl; - //out<<" image sky_small.hdr" <<endl; - //out<<" center 0 -1 0" <<endl; - //out<<" up 0 0 1" <<endl; - //out<<" lock true" <<endl; - //out<<" samples 200" <<endl; - //out<<"}" <<endl<<endl; - - //// Shaders - //out<<"shader {" <<endl; - //out<<" name default-shader" <<endl; - //out<<" type diffuse" <<endl; - //out<<" diff 0.25 0.25 0.25" <<endl; - //out<<"}" <<endl<<endl; - - //out<<"shader {" <<endl; - //out<<" name Glass" <<endl; - //out<<" type glass" <<endl; - //out<<" eta 1.333" <<endl; - //out<<" color 0.1 0.3 0.8" <<endl; - //out<<"}" <<endl<<endl; - // - //out<<"shader {" <<endl; - //out<<" name Mirror" <<endl; - //out<<" type mirror" <<endl; - //out<<" refl 0.7 0.7 0.7" <<endl; - //out<<"}" <<endl<<endl; - - //// Objects - //// a) Ground plane - //out<<"object {" <<endl; - //out<<" shader default-shader" <<endl; - //out<<" type plane" <<endl; - //out<<" p 0 0 0" <<endl; - //out<<" n 0 0 1" <<endl; - //out<<"}" <<endl<<endl; - - //// b) Mesh - //out<<"object {" <<endl; - //out<<" shader Glass" <<endl; - //out<<" transform {" <<endl; - //out<<" rotatey 270.0" <<endl; - //out<<" }" <<endl; - //out<<" type generic-mesh" <<endl; - //out<<" name polySurfac" <<endl<<endl; - - - //// POINTS SECTION - //int nofNodes = (int)nodes.size(); - //out<<" points "<<nofNodes<<endl; - //for(int n=0; n<nofNodes; n++) - // out<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl; - - //// TRIANGLES SECTION - //int nofTriangles= (int)triangles.size(); - //out<<" triangles "<<nofTriangles<<endl; - //for(int c=0; c<nofTriangles; c++) - // out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl; - - //// FOOTER - //out<<" normals none" << endl; - //out<<" uvs none" << endl; - //out<<"}" << endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - end"); - - return X3DFilename; -} -/*===============================================================================*/ diff --git a/ThirdParty/Library/basics/writer/WbWriterX3D.h b/ThirdParty/Library/basics/writer/WbWriterX3D.h deleted file mode 100644 index b9c708c1215bb897d6ff58e5e30367b4b54505ae..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/basics/writer/WbWriterX3D.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WBWRITERX3D_H -#define WBWRITERX3D_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterX3D : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterX3D ) - - static WbWriterX3D* getInstance() - { - static WbWriterX3D instance; - return &instance; - } -private: - WbWriterX3D() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterX3D( const WbWriterX3D& ); //no copy allowed - const WbWriterX3D& operator=( const WbWriterX3D& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return "ascii.X3D"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D); - -#endif //WBWRITERX3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt deleted file mode 100644 index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp b/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp deleted file mode 100644 index 0d20dadd41c1c4ad2f93eea2f8ddc7dc3fb5de67..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include <numerics/geometry3d/CoordinateTransformation3D.h> -#include <basics/utilities/UbMath.h> - -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); -} -/*======================================================*/ -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); -} -/*======================================================*/ -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); -} -/*======================================================*/ -CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3D* transformation) -{ - this->setTransformationValues(transformation->Tx1 , transformation->Tx2 , transformation->Tx3 , transformation->Sx1 , transformation->Sx2 , transformation->Sx3, transformation->alpha, transformation->beta, transformation->gamma); -} -/*======================================================*/ -// void CoordinateTransformation3D::init() -// { -// 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; -// this->toX1delta = 0.0; this->toX2delta = 0.0; this->toX3delta = 0.0; -// this->fromX1factorX1 = 1.0; this->fromX1factorX2 = 0.0; this->fromX1factorX3 = 0.0; -// this->fromX2factorX1 = 0.0; this->fromX2factorX2 = 1.0; this->fromX2factorX3 = 0.0; -// this->fromX3factorX1 = 0.0; this->fromX3factorX2 = 0.0; this->fromX3factorX3 = 1.0; -// -// this->active = false; -// this->transformation = false; -// } -/*======================================================*/ - -/**==== Set transformation values -@param a transformed coordinate system x0 (in global coordinates) -@param b transformed coordinate system y0 (in global coordinates) -@param c transformed coordinate system z0 (in global coordinates) -@param dx1 x coordinate scaling (dx_transformed/dx_global) -@param dx2 y coordinate scaling (dy_transformed/dy_global) -@param dx3 z coordinate scaling (dz_transformed/dz_global) -@param alpha rotation around z angle (positive FROM global TO transformed coordinate system) -@param beta rotation around y angle -@param gamma rotation around x angle -@exception IllegalArgumentException if one of the scale values is between -1.0E-8 and 1.0E-8 -**/ - -void CoordinateTransformation3D::setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) -{ - if(UbMath::zero(dx1) || UbMath::zero(dx2) || UbMath::zero(dx3)) - throw UbException(UB_EXARGS,"error: at least one delta==0.0"); - - this->Tx1 = originX1; this->Tx2 = originX2; this->Tx3 = originX3; - this->Sx1 = dx1; this->Sx2 = dx2; this->Sx3 = dx3; - this->alpha = alpha; this->beta = beta; this->gamma = gamma; - - double ra = UbMath::PI*alpha/180.0; - double cosA = cos(ra); - double sinA = sin(ra); - double rb = UbMath::PI*beta/180.0; - double cosB = cos(rb); - double sinB = sin(rb); - double rg = UbMath::PI*gamma/180.0; - double cosG = cos(rg); - double sinG = sin(rg); - - //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) - double divisor = (Sx1*Sx2*Sx3); - - this->toX1factorX1 = +cosB*cosA*Sx2*Sx3/divisor; - this->toX1factorX2 = -cosB*sinA*Sx1*Sx3/divisor; - this->toX1factorX3 = +sinB*Sx1*Sx2/divisor; - this->toX1delta = (-Tx3*Sx1*Sx2*sinB - +Tx2*Sx1*Sx3*sinA*cosB - -Tx1*Sx2*Sx3*cosB*cosA)/divisor; - - this->toX2factorX1 = Sx2*Sx3*(sinG*sinB*cosA+cosG*sinA)/divisor; - this->toX2factorX2 = Sx1*Sx3*(-sinG*sinB*sinA+cosG*cosA)/divisor; - this->toX2factorX3 = -Sx1*Sx2*cosB*sinG/divisor; - this->toX2delta = (-Tx2*Sx1*Sx3*cosG*cosA - +Tx3*Sx1*Sx2*sinG*cosB - +Tx2*Sx1*Sx3*sinG*sinA*sinB - -Tx1*Sx2*Sx3*cosG*sinA - -Tx1*Sx2*Sx3*sinB*sinG*cosA )/divisor; - - - this->toX3factorX1 = Sx2*Sx3*(-cosG*sinB*cosA+sinG*sinA)/divisor; - this->toX3factorX2 = Sx1*Sx3*(sinB*cosG*sinA+sinG*cosA)/divisor; - this->toX3factorX3 = Sx1*Sx2*cosB*cosG/divisor; - this->toX3delta = (-Tx2*Sx1*Sx3*sinG*cosA - -Tx3*Sx1*Sx2*cosG*cosB - -Tx2*Sx1*Sx3*cosG*sinA*sinB - -Tx1*Sx2*Sx3*sinG*sinA - +Tx1*Sx2*Sx3*sinB*cosG*cosA )/divisor; - - //Matrix-Werte von T_invers (indizes: 12 = spalte 1 zeile 2) - this->fromX1factorX1 = cosB*cosA*Sx1; - this->fromX1factorX2 = (sinG*sinB*cosA+cosG*sinA)*Sx1; - this->fromX1factorX3 = (-cosG*sinB*cosA+sinG*sinA)*Sx1; - this->fromX1delta = Tx1; - - this->fromX2factorX1 = -cosB*sinA*Sx2; - this->fromX2factorX2 = -(sinG*sinB*sinA-cosG*cosA)*Sx2; - this->fromX2factorX3 = (cosG*sinB*sinA+sinG*cosA)*Sx2; - this->fromX2delta = Tx2; - - this->fromX3factorX1 = sinB*Sx3; - this->fromX3factorX2 = -sinG*cosB*Sx3; - this->fromX3factorX3 = cosG*cosB*Sx3; - this->fromX3delta = Tx3; - - this->active = true; - - this->transformation = true; -} -/*======================================================*/ -/** -Set transformation active state (if this IS a transformation) -@param active true to be active, false otherwise -**/ -void CoordinateTransformation3D::setActive(const bool& active) -{ - if(this->active == active) return; - if(this->transformation) this->active = active; -} -/*======================================================*/ -/** -Transform FROM global coordinates TO transformed coordinates. -@param x1 the global x coordinate -@param x2 the global y coordinate -@param x3 the global z coordinate -**/ -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; -} -/*======================================================*/ -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; -} -/*======================================================*/ -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; -} -/*======================================================*/ -/** -Transform FROM global coordinates TO transformed coordinates (ignoring rotation). -@param x1 the global x coordinate -**/ -double CoordinateTransformation3D::transformForwardToX1CoordinateIgnoringRotation(const double& x1) const -{ - if(this->active) return (x1-this->Tx1)/this->Sx1; - else return x1; -} -/*======================================================*/ -double CoordinateTransformation3D::transformForwardToX2CoordinateIgnoringRotation(const double& x2) const -{ - 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; -} -/*======================================================*/ -/** -Transform FROM transformed coordinates TO global coordinates. -@param x1 the transformed x coordinate -@param x2 the transformed y coordinate -@param x3 the transformed z coordinate -**/ -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; -} -/*======================================================*/ -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; -} -/*======================================================*/ -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; -} -/*======================================================*/ -/** -Transform FROM transformed coordinates TO global coordinates (ignoring rotation). -@param x1 the transformed x coordinate -**/ -double CoordinateTransformation3D::transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const -{ - if(this->active) return x1*this->Sx1+this->Tx1; - else return x1; -} -/*======================================================*/ -double CoordinateTransformation3D::transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const -{ - 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; -} -/*======================================================*/ -/** -Returns a string representation of this transformation. -@return a string representation of this transformation -**/ -string CoordinateTransformation3D::toString() const -{ - stringstream ss; - ss<<" CoordinateTransformation3D\n"; -// ss<<"[isTransformation="<<this->transformation; -// ss<<", isActive="<<this->active<<endl; - ss<<" ,a="<<this->Tx1<<", b="<<this->Tx2<<", c="<<this->Tx3<<endl; - ss<<" , dx1="<<this->Sx1<<", dx2="<<this->Sx2<<", dx2="<<this->Sx3<<endl; -// ss<<" , alpha="<<this->alpha<<", beta="<<this->beta<endl; -// ss<<"]"; -// ss<<"[to11="<<this->to11<<", to12="<<this->to12<<", to13="<<this->to13; -// ss<<", to21="<<this->to21<<", to22="<<this->to22<<", to23="<<this->to23; -// ss<<", to31="<<this->to31<<", to32="<<this->to32<<", to33="<<this->to33; -// ss<<", toA="<<this->toA<<", toB="<<this->toB<<", toC="<<this->toC; -// ss<<", from11="<<this->from11<<", from12="<<this->from12<<", from13="<<this->from13; -// ss<<", from21="<<this->from21<<", from22="<<this->from22<<", from23="<<this->from23; -// 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(); -} - diff --git a/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.h b/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.h deleted file mode 100644 index 9b0b83dec47590765f0d99e2cb37565d78b5cafd..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.h +++ /dev/null @@ -1,178 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef COORDINATETRANSFORMATION3D_H -#define COORDINATETRANSFORMATION3D_H - -#ifdef RCF_USE_BOOST_SERIALIZATION - #include <boost/archive/text_oarchive.hpp> - #include <boost/archive/text_iarchive.hpp> -#endif //RCF_USE_BOOST_SERIALIZATION - -#include <cmath> -#include <string> -#include <sstream> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class CoordinateTransformation3D; -typedef VFSharedPtr<CoordinateTransformation3D> CoordinateTransformation3DPtr; - -#include <boost/serialization/serialization.hpp> - -//description: x1/x2/x3 = alt, x1*/x2*/x3* = neu -// x2 -// ^ x* -// | / -// | 2* -// 4 / -// | / -// 3 1* => neues coordsys ist um originX1=originX2=originX3=2 verschoben -// | / neues dx1=dx2=dx2=2 -> skalierung um 2 in x1-,x2- und x3-richtung -// 2 / ERST verdrehung um alpha um "x1" achse -// | \ DANN verdrehung um beta um "x2" achse -// 1 \ DANN verdrehung um gamma um "x3" achse -// | x1* -// |--1--2--3--4--5------------- > x1 -// -// Bemerkung: kann sein, dass die Verdrehung um x1 und x3 vertauschst sind -// - muss mal einer prüfen ... - - - -class CoordinateTransformation3D -{ -public: - CoordinateTransformation3D(); - CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); - CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3); - CoordinateTransformation3D(CoordinateTransformation3D* transformation); - - void setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma); - double getX1CoordinateOffset() const { return this->Tx1; } //Translation - double getX2CoordinateOffset() const { return this->Tx2; } - double getX3CoordinateOffset() const { return this->Tx3; } - double getX1CoordinateScaling() const { return this->Sx1; } //Scaling - double getX2CoordinateScaling() const { return this->Sx2; } - double getX3CoordinateScaling() const { return this->Sx3; } - double getRotationX1Angle() const { return this->alpha; } - double getRotationX2Angle() const { return this->beta; } - double getRotationX3Angle() const { return this->gamma; } //Rotation - - //Achtung die Winkel passen nicht überein -siehe setTransformationValues - void setRotationX1Angle(double alpha) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, alpha, this->beta, this->gamma); } - void setRotationX2Angle(double beta ) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, beta, this->gamma); } - void setRotationX3Angle(double gamma) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, this->beta, gamma); } - - void setActive(const bool& active); - bool isActive() const { return this->active; } - bool isTransformation() const { return this->transformation; } - - double transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformForwardToX1CoordinateIgnoringRotation(const double& x1) const; - double transformForwardToX2CoordinateIgnoringRotation(const double& x2) const; - double transformForwardToX3CoordinateIgnoringRotation(const double& x3) const; - double transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const; - double transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const; - double transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const; - double transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const; - std::string toString() const; - - //------------- implements CAB serialization ----- start - void write(UbFileOutput* out) const - { - out->writeString("Coordtransfomartion3D"); - out->writeDouble(this->Tx1); - out->writeDouble(this->Tx2); - out->writeDouble(this->Tx3); - out->writeDouble(this->Sx1); - out->writeDouble(this->Sx2); - out->writeDouble(this->Sx3); - out->writeDouble(this->alpha); - out->writeDouble(this->beta ); - out->writeDouble(this->gamma); - } - void read(UbFileInput* in) - { - in->readString(); - this->Tx1 = in->readDouble(); - this->Tx2 = in->readDouble(); - this->Tx3 = in->readDouble(); - this->Sx1 = in->readDouble(); - this->Sx2 = in->readDouble(); - this->Sx3 = in->readDouble(); - this->alpha = in->readDouble(); - this->beta = in->readDouble(); - this->gamma = in->readDouble(); - - this->setTransformationValues(Tx1,Tx2,Tx3,Sx1,Sx2,Sx3,alpha,beta,gamma); - } - //------------- implements CAB serialization ----- end - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & Tx1; ar & Tx2; ar & Tx3; - ar & Sx1; ar & Sx2; ar & Sx3; - ar & alpha; ar & beta; ar & gamma; - - ar & toX1factorX1; ar & toX1factorX2; ar & toX1factorX3; ar & toX1delta; - ar & toX2factorX1; ar & toX2factorX2; ar & toX2factorX3; ar & toX2delta; - ar & toX3factorX1; ar & toX3factorX2; ar & toX3factorX3; ar & toX3delta; - - ar & fromX1factorX1; ar & fromX1factorX2; ar & fromX1factorX3; ar & fromX1delta; - ar & fromX2factorX1; ar & fromX2factorX2; ar & fromX2factorX3; ar & fromX2delta; - ar & fromX3factorX1; ar & fromX3factorX2; ar & fromX3factorX3; ar & fromX3delta; - - ar & active; - ar & transformation; - } -#endif //CAB_RCF - -private: - 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 fromX1factorX1, fromX1factorX2, fromX1factorX3, fromX1delta; - double fromX2factorX1, fromX2factorX2, fromX2factorX3, fromX2delta; - double fromX3factorX1, fromX3factorX2, fromX3factorX3, fromX3delta; - - bool active; - bool transformation; - - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & Tx1; ar & Tx2; ar & Tx3; - ar & Sx1; ar & Sx2; ar & Sx3; - ar & alpha; ar & beta; ar & gamma; - - ar & toX1factorX1; ar & toX1factorX2; ar & toX1factorX3; ar & toX1delta; - ar & toX2factorX1; ar & toX2factorX2; ar & toX2factorX3; ar & toX2delta; - ar & toX3factorX1; ar & toX3factorX2; ar & toX3factorX3; ar & toX3delta; - - ar & fromX1factorX1; ar & fromX1factorX2; ar & fromX1factorX3; ar & fromX1delta; - ar & fromX2factorX1; ar & fromX2factorX2; ar & fromX2factorX3; ar & fromX2delta; - ar & fromX3factorX1; ar & fromX3factorX2; ar & fromX3factorX3; ar & fromX3delta; - - ar & active; - ar & transformation; - } -}; - -#endif //COORDINATETRANSFORMATION3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp deleted file mode 100644 index eae8f331512e53ec99aefd73bc55d9dadbc9aed3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp +++ /dev/null @@ -1,633 +0,0 @@ -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/creator/GbCuboid3DCreator.h> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* GbCuboid3D::getCreator() -{ - return GbCuboid3DCreator::getInstance(); -} -/*=======================================================*/ -// Konstruktor -GbCuboid3D::GbCuboid3D() : GbObject3D() -{ - this->setName("cuboid"); - this->p1 = new GbPoint3D(0.0, 0.0, 0.0); - this->p2 = new GbPoint3D(0.0, 0.0, 0.0); - this->p1->addObserver(this); - this->p2->addObserver(this); -} -/*=======================================================*/ -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); -} -/*=======================================================*/ -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); -} -/*=======================================================*/ -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); -} -/*=======================================================*/ -// 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; - } -} -/*=======================================================*/ -void GbCuboid3D::setPoint1(GbPoint3D* point1) -{ - if(this->p1) this->p1->removeObserver(this); - this->p1 = point1; - this->p1->addObserver(this); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCuboid3D::setPoint2(GbPoint3D* point2) -{ - if(this->p2) this->p2->removeObserver(this); - this->p2 = point2; - this->p2->addObserver(this); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCuboid3D::setPoints(GbPoint3D* point1, GbPoint3D* point2) -{ - if(this->p1) this->p1->removeObserver(this); - if(this->p2) this->p2->removeObserver(this); - - this->p1 = point1; - this->p2 = point2; - - this->p1->addObserver(this); - this->p2->addObserver(this); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCuboid3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} -/*=======================================================*/ -double GbCuboid3D::getX1Centroid() -{ - return (0.5*(p1->x1 + p2->x1)); -} -/*=======================================================*/ -double GbCuboid3D::getX1Minimum() -{ - return (this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); -} -/*=======================================================*/ -double GbCuboid3D::getX1Maximum() -{ - return (this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); -} -/*=======================================================*/ -double GbCuboid3D::getX2Centroid() -{ - return (0.5*(p1->x2 + p2->x2)); -} -/*=======================================================*/ -double GbCuboid3D::getX2Minimum() -{ - return (this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); -} -/*=======================================================*/ -double GbCuboid3D::getX2Maximum() -{ - return ( this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); -} -/*=======================================================*/ -double GbCuboid3D::getX3Centroid() -{ - 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::getX3Maximum() -{ - return (this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); -} -/*=======================================================*/ -double GbCuboid3D::getLengthX1() -{ - return (this->getX1Maximum() - this->getX1Minimum() ); -} -/*=======================================================*/ -double GbCuboid3D::getLengthX2() -{ - return (this->getX2Maximum() - this->getX2Minimum()); -} -/*=======================================================*/ -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; - - 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; -} -/*=======================================================*/ -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; - - return true; -} -/*=======================================================*/ -bool GbCuboid3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung -//returns true: -// - cell cuts cuboid3D -// - cell boxes cuboid3D -//returns false: -// - 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; - } - - return false; - - //GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b); - //if(cube) - //{ - // cube->finalize(); - // delete cube; - // return true; - //} - - //return false; -} -/*=======================================================*/ -bool GbCuboid3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside cuboid3D ( = cuboid3D boxes cell) -// - cell cuts cuboid3D -// - cell boxes cuboid3D -//returns false: -// - 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! - - 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->getX3Centroid() - 0.5*(x3b+x3a) /*Tx3*/ ) - , 0.5*( this->getLengthX3() + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) ) - { - 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; -} -/*=======================================================*/ -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; -} -/*=======================================================*/ -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(); -} -/*=======================================================*/ -GbPoint3D* GbCuboid3D::calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D& point2) -{ - 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() ); -} -/*==========================================================*/ -void GbCuboid3D::objectChanged(UbObservable* changedObject) -{ - GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject); - if(!point || (this->p1!=point && this->p2!=point)) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void GbCuboid3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->p1) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1); - if(objectForDeletion == observedObj) { this->p1 = NULL; } - } - if(this->p2) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2); - if(objectForDeletion == observedObj) { this->p2 = NULL; } - } - //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo -} -/*=======================================================*/ -void GbCuboid3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*=======================================================*/ -void GbCuboid3D::read(UbFileInput* in) -{ - in->readString(); - this->p1 = new GbPoint3D; - p1->read(in); - in->readString(); - this->p2 = new GbPoint3D; - p2->read(in); -} -/*=======================================================*/ -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(); -} -/*=======================================================*/ -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 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 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->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; - - 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; -} -/*==========================================================*/ -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]) - whichPlane = i; - - /* Check final candidate actually inside box */ - if(maxT[whichPlane]< -1.E-10) return -1.0; - double dummy; - for(int i= 0; i<3; i++) - { - if( whichPlane!= i) - { - dummy = origin[i] + maxT[whichPlane]*dir[i]; - if(dummy < minB[i] || dummy > maxB[i]) - return -1.0; - } - } - - return maxT[whichPlane] ; /* ray hits box */ -} -// /*==========================================================*/ -// double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -// { -// double absX,absMaxX,absY,absMaxY,absZ,absMaxZ; -// -// if(rx1<0.0) absX = this->getX1Maximum() - x1; -// else absX = this->getX1Minimum() - x1; -// if(1-(rx1<0.0)) absMaxX = this->getX1Maximum() - x1; -// else absMaxX = this->getX1Minimum() - x1; -// -// if(rx2<0.0) absY = this->getX2Maximum() - x2; -// else absY = this->getX2Minimum() - x2; -// if(1-(rx2<0.0)) absMaxY = this->getX2Maximum() - x2; -// else absMaxY = this->getX2Minimum() - x2; -// -// if(rx3<0.0) absZ = this->getX3Maximum() - x3; -// else absZ = this->getX3Minimum() - x3; -// if(1-(rx3<0.0)) absMaxZ = this->getX3Maximum() - x3; -// else absMaxZ = this->getX3Minimum() - x3; -// -// -// //tmin ist die verschneidung des Gerade (Ray) durch die naehere Gerade (MinX oder MaxX) -// //tmax ist die verschneidung des Gerade (Ray) durch die weiteste Gerade (MinX oder MaxX) -// //analog fuer tymin und tymax -// double tmin, tymin, tzmin, tmax, tymax, tzmax; -// -// if(!UbMath::zero(rx1)) tmin = tmax = 1.0/rx1; -// else if(rx1<0.0) tmin = tmax = -UbMath::getPositiveInfinity<double>(); -// else tmin = tmax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx2)) tymin = tymax = 1.0/rx2; -// else if(rx2<0.0) tymin = tymax = -UbMath::getPositiveInfinity<double>(); -// else tymin = tymax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx3)) tzmin = tzmax = 1.0/rx3; -// else if(rx1<0.0) tzmin = tzmax = -UbMath::getPositiveInfinity<double>(); -// else tzmin = tzmax = UbMath::getPositiveInfinity<double>(); -// -// //tmin *= absX; -// //tmax *= absMaxX; -// //tymin *= absY; -// //tymax *= absMaxY; -// //tzmin *= absZ; -// //tzmax *= absMaxZ; -// -// //0 * 1/0 vermeiden, da es ein Undefined wert produziert -// if( !UbMath::zero(absX) || !UbMath::zero(rx1) ) tmin *= absX; -// else tmin = tymin; -// -// if( !UbMath::zero(absY) || !UbMath::zero(rx2)) tymin *= absY; -// else tymin = tmin; -// -// if( !UbMath::zero(absZ) || !UbMath::zero(rx3)) tzmin *= absZ; -// else tzmin = tymin; -// -// if( !UbMath::zero(absMaxX) || !UbMath::zero(rx1)) tmax *= absMaxX; -// else tmax = tymax; -// -// if( !UbMath::zero(absMaxY) || !UbMath::zero(rx2)) tymax *= absMaxY; -// else tymax = tmax; -// -// if( !UbMath::zero(absMaxZ) || !UbMath::zero(rx3)) tzmax *= absMaxZ; -// else tzmax = tymax; -// -// //in dieser Fall gibt es keine Verschneidung -// if( (tmin > tymax) || (tymin > tmax) ) return -1; -// -// tmin = UbMath::max3(tmin,tymin,tzmin); -// tmax = UbMath::min3(tmax,tymax,tzmax); -// -// if( (tmin > tzmax) || (tzmin > tmax) ) return -1; -// if(tmin >= 0.0) return tmin ; -// -// return tmax; -//} diff --git a/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h b/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h deleted file mode 100644 index 4cce923fcc1db37136465b323d3a8cc471a6404c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h +++ /dev/null @@ -1,144 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBCUBOID3D_H -#define GBCUBOID3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbPoint3D.h> -#include <basics/utilities/UbObserver.h> -#include <basics/utilities/UbMath.h> - -class GbLine3D; -class GbObject3DCreator; - -#include <basics/memory/MbSharedPointerDefines.h> -class GbCuboid3D; -typedef VFSharedPtr<GbCuboid3D> GbCuboid3DPtr; - - -class GbCuboid3D : public GbObject3D, public UbObserver -{ -public: - GbCuboid3D(); - GbCuboid3D(const double& minX1,const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); - GbCuboid3D(GbPoint3D *p1, GbPoint3D *p2); - GbCuboid3D(GbCuboid3D *cuboid); - ~GbCuboid3D(); - - GbCuboid3D* clone() { return new GbCuboid3D(this); } - void finalize(); - - GbPoint3D* getPoint1() { return this->p1; } - GbPoint3D* getPoint2() { return this->p2; } - - void setPoint1(GbPoint3D* point1); - void setPoint2(GbPoint3D* point2); - void setPoints(GbPoint3D* point1, GbPoint3D* point2); - - double getX1Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Centroid(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Centroid(); - double getX3Minimum(); - double getX3Maximum(); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - - void translate(const double& x1, const double& x2, const double& x3); - void rotate(const double& rx1, const double& rx2, const double& rx3) {} - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getLengthX1(); - double getLengthX2(); - double getLengthX3(); - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - GbPoint3D* calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2); - //GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - - double getDistance(GbPoint3D* p) - { - return this->getDistance( p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate() ); - } - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - throw UbException( UB_EXARGS, "not implemented" ); - - // falls punkt innerhalt ist: minimalen abstand ausrechnen - if( this->isPointInGbObject3D(x1p,x2p,x3p) ) - { - double x1Dist = UbMath::min( std::abs(x1p-this->getX1Minimum()),std::abs(x1p-this->getX1Maximum()) ); - double x2Dist = UbMath::min( std::abs(x2p-this->getX2Minimum()),std::abs(x2p-this->getX2Maximum()) ); - double x3Dist = UbMath::min( std::abs(x3p-this->getX3Minimum()),std::abs(x3p-this->getX3Maximum()) ); - - return UbMath::min( x1Dist, x2Dist, x3Dist ); - } - else - { - - } - } - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - } -#endif //CAB_RCF - -protected: - GbPoint3D* p1; - GbPoint3D* p2; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCuboid3D>("GbCuboid3D") , SF_GbCuboid3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCuboid3D >()), SF_GbCuboid3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCuboid3D>() ), SF_GbCuboid3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp deleted file mode 100644 index e439a52966dc20ca95cdc965da9d890ccd8a01e8..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp +++ /dev/null @@ -1,1262 +0,0 @@ -#include <numerics/geometry3d/GbCylinder3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <basics/utilities/UbInfinity.h> - -#include <numerics/geometry3d/creator/GbCylinder3DCreator.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* GbCylinder3D::getCreator() -{ - return GbCylinder3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -GbCylinder3D::GbCylinder3D() - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - mRad = 0.0; - cylinderType = GbCylinder3D::NOTPARALLELTOAXIS; - this->mLine->addObserver(this); - this->calculateValues(); -} -/*=======================================================*/ -GbCylinder3D::GbCylinder3D(GbCylinder3D* cylinder) - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = cylinder->getRadius(); - cylinderType = cylinder->cylinderType; - mLine = cylinder->getLine()->clone(); - - this->mLine->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad) - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mLine = new GbLine3D; - //Min/Max, damit gewaehrleistet ist, dass Startpunkt immer der "Achs-Minimale" ist - //Anm.: bin nich tsicher ob weiter unten irgendwelche Algos drauf beruhen... - // geht nat nur solange, zylinder achs-parallel, aber das ist erzeit so!!! - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - //mLine->setPoints( new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b, x2b ,x3b )); - this->mLine->addObserver(this); - mRad = fabs(rad); - - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad) - : minX1(0.0), minX2(0.0), minX3(0.0) - , maxX1(0.0), maxX2(0.0), maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = rad; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(GbLine3D* line, const double& rad) - : minX1(0.0), minX2(0.0), minX3(0.0) - , maxX1(0.0), maxX2(0.0), maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = rad; - - this->mLine = line; - this->mLine->addObserver(this); - - this->calculateValues(); -} -/*==========================================================*/ -// Destruktor -GbCylinder3D::~GbCylinder3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void GbCylinder3D::calculateValues() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->cylinderType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->cylinderType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->cylinderType = X3PARALLEL; - // nach dem serialisieren ruft er den Standardkonstruktor auf wo alles 0 ist und bricht sonst hier ab - else if(x3a==x3b && x1a==x1b && x2a==x2b) this->cylinderType = X1PARALLEL; - else this->cylinderType = NOTPARALLELTOAXIS; - - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - if(this->isParallelToX1Axis()) - { - minX1 = mLine->getX1Minimum(); - maxX1 = mLine->getX1Maximum(); - minX2 = mLine->getX2Centroid()-mRad; - maxX2 = mLine->getX2Centroid()+mRad; - minX3 = mLine->getX3Centroid()-mRad; - maxX3 = mLine->getX3Centroid()+mRad; - } - else if(this->isParallelToX2Axis()) - { - minX1 = mLine->getX1Centroid()-mRad; - maxX1 = mLine->getX1Centroid()+mRad; - minX2 = mLine->getX2Minimum(); - maxX2 = mLine->getX2Maximum(); - minX3 = mLine->getX3Centroid()-mRad; - maxX3 = mLine->getX3Centroid()+mRad; - } - else if(this->isParallelToX3Axis()) - { - minX1 = mLine->getX1Centroid()-mRad; - maxX1 = mLine->getX1Centroid()+mRad; - minX2 = mLine->getX2Centroid()-mRad; - maxX2 = mLine->getX2Centroid()+mRad; - minX3 = mLine->getX3Minimum(); - maxX3 = mLine->getX3Maximum(); - } - - centerX1 = mLine->getX1Centroid(); - centerX2 = mLine->getX2Centroid(); - centerX3 = mLine->getX3Centroid(); -} - -/*=======================================================*/ -void GbCylinder3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double GbCylinder3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* GbCylinder3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* GbCylinder3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void GbCylinder3D::setRadius(const double& radius) -{ - this->mRad = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCylinder3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->calculateValues(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCylinder3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->calculateValues(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void GbCylinder3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->calculateValues(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - //true, wenn 'in Object' oder 'auf Boundary'! - if ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1))) return false; - else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2))) return false; - else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3))) return false; - else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - return UbMath::lessEqual(fabs(mLine->getDistance(x1p,x2p,x3p)),fabs(mRad)); -} -/*==========================================================*/ -bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - //funzt derzeit nur bei achsparallelen cylindern - pointIsOnBoundary = false; - - if ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1))) return false; - else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2))) return false; - else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3))) return false; - else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - //true, wenn 'in Object' oder 'auf Boundary'! - - double dis = mLine->getDistance(x1p,x2p,x3p); - - if(UbMath::equal(dis,mRad)) pointIsOnBoundary = true; - - if (this->isParallelToX1Axis() && (UbMath::equal(x1p,minX1) || UbMath::equal(x1p,maxX1))) pointIsOnBoundary = true; - else if(this->isParallelToX2Axis() && (UbMath::equal(x2p,minX2) || UbMath::equal(x2p,maxX2))) pointIsOnBoundary = true; - else if(this->isParallelToX3Axis() && (UbMath::equal(x3p,minX3) || UbMath::equal(x3p,maxX3))) pointIsOnBoundary = true; - - return UbMath::lessEqual(dis,mRad); -} -/*==========================================================*/ -string GbCylinder3D::toString() -{ - stringstream ss; - ss<<"GbCylinder3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", r="<<this->mRad; - ss<<"]"; - return(ss.str()); -} -/*=======================================================*/ -bool GbCylinder3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - if( this->isPointInGbObject3D(x1a, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2b, x3b) - && this->isPointInGbObject3D(x1a, x2b, x3b)) - { - return true; - } - return false; -} -/*==========================================================*/ -bool GbCylinder3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung -//returns true: -// - cell cuts cylinder3D -// - cell boxes cylinder3D -//returns false: -// - cell completely inside cylinder3D ( = cylinder3D boxes cell) -// - cell und cylinder3D haben kein gemeinsames Volumen -{ - //erstmal wieder die dumm Loesung - if( this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) - && !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) - { - return true; - } - - return false; -} -/*==========================================================*/ -bool GbCylinder3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside cylinder3D ( = cylinder3D boxes cell) -// - cell cuts cylinder3D -// - cell boxes cylinder3D -//returns false: -// - cell und cylinder3D haben kein gemeinsames Volumen -{ - double dmin = 0.0; - - if(this->isParallelToX1Axis()) - { - //check liegt Cell komplett !x1-ausserhalb"? - if( UbMath::less (x1a,minX1) && UbMath::less (x1b,minX1) ) return false; - if( UbMath::greater(x1a,maxX1) && UbMath::greater(x1b,maxX1) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX2 = mLine->getPoint1()->x2; - double& midX3 = mLine->getPoint1()->x3; - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad) ) return true; - - return false; - } - else if(this->isParallelToX2Axis()) - { - //check liegt Cell komplett !x2-ausserhalb"? - if( UbMath::less (x2a,minX2) && UbMath::less (x2b,minX2) ) return false; - if( UbMath::greater(x2a,maxX2 ) && UbMath::greater(x2b,maxX2) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX1 = mLine->getPoint1()->x1; - double& midX3 = mLine->getPoint1()->x3; - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true; - - } - else if(this->isParallelToX3Axis()) - { - //check liegt Cell komplett !x3-ausserhalb"? - if( UbMath::less (x3a,minX3) && UbMath::less (x3b,minX3) ) return false; - if( UbMath::greater(x3a,maxX3) && UbMath::greater(x3b,maxX3) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX1 = mLine->getPoint1()->x1; - double& midX2 = mLine->getPoint1()->x2; - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true; - } - - return false; -} -/*==========================================================*/ -GbLine3D* GbCylinder3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - //liefert immer "innere" linie, also der teil, der vom Zylinder "abgeschnitten" wurde! - //funktioniert derzeit nur mit achsenparallelen Zylindern! - vector<GbPoint3D*> schnittpunkte; - - double xa,ya,za,xb,yb,zb,xm,ym,zStart,zEnd,t1,t2; - - if(this->isParallelToX1Axis()) - { - xa = point1.getX2Coordinate(); - ya = point1.getX3Coordinate(); - za = point1.getX1Coordinate(); - xb = point2.getX2Coordinate(); - yb = point2.getX3Coordinate(); - zb = point2.getX1Coordinate(); - xm = mLine->getPoint1()->getX2Coordinate(); - ym = mLine->getPoint1()->getX3Coordinate(); - zStart = mLine->getPoint1()->getX1Coordinate(); - zEnd = mLine->getPoint2()->getX1Coordinate(); - } - else if(this->isParallelToX2Axis()) - { - xa = point1.getX1Coordinate(); - ya = point1.getX3Coordinate(); - za = point1.getX2Coordinate(); - xb = point2.getX1Coordinate(); - yb = point2.getX3Coordinate(); - zb = point2.getX2Coordinate(); - xm = mLine->getPoint1()->getX1Coordinate(); - ym = mLine->getPoint1()->getX3Coordinate(); - zStart = mLine->getPoint1()->getX2Coordinate(); - zEnd = mLine->getPoint2()->getX2Coordinate(); - } - else if(this->isParallelToX3Axis()) - { - xa = point1.getX1Coordinate(); - ya = point1.getX2Coordinate(); - za = point1.getX3Coordinate(); - xb = point2.getX1Coordinate(); - yb = point2.getX2Coordinate(); - zb = point2.getX3Coordinate(); - xm = mLine->getPoint1()->getX1Coordinate(); - ym = mLine->getPoint1()->getX2Coordinate(); - zStart = mLine->getPoint1()->getX3Coordinate(); - zEnd = mLine->getPoint2()->getX3Coordinate(); - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - //Bestimmung des Schnittpunktes mit unendlich ausgedehntem Zylinder - double r = mRad; - double r2 = r*r; - double xa2 = xa*xa; - double xb2 = xb*xb; - double ya2 = ya*ya; - double yb2 = yb*yb; - double xm2 = xm*xm; - double ym2 = ym*ym; - - double wurzel = 2.0*xa*xm*yb2+2.0*ya*ym*xb2-2.0*xa*xb*r2+2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*xa2*yb*ym - +2.0*xa*xm*ya*ym-2.0*xa*xm*yb*ym-2.0*ya*ym*xb*xm+2.0*xb*xm*yb*ym+2.0*ya*yb*xa*xb - -2.0*ya*yb*xa*xm-2.0*ya*yb*xb*xm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+2.0*xb*xm*ya2 - +2.0*ya*yb*xm2-xa2*yb2-xb2*ya2+xa2*r2-xa2*ym2+xb2*r2-xb2*ym2+ya2*r2-ya2*xm2+yb2*r2-yb2*xm2; - double nenner = -2.0*(ya*yb+xa*xb)+xa2+xb2+ya2+yb2; - double zaehler = 2.0*(-xa*xm+xb*xm-ya*ym+yb*ym)+xa2-xb2+ya2-yb2; - - if(UbMath::greaterEqual(wurzel,0.0) && !UbMath::zero(nenner) )//fabs(nenner)>1.E-13) - { - t1 = (zaehler+2.0*sqrt(wurzel))/nenner; - t2 = (zaehler-2.0*sqrt(wurzel))/nenner; - - if(UbMath::inClosedInterval(t1, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x = xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1); - double y = ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1); - double z = za*(0.5-0.5*t1)+zb*(0.5+0.5*t1); - - if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden - { - if (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y)); - else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y)); - else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x = xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2); - double y = ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2); - double z = za*(0.5-0.5*t2)+zb*(0.5+0.5*t2); - - if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden - { - if (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y)); - else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y)); - else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - //wenn nenner==0 -> Strecke parallel zu Zylinder! Es muss noch auf Schnittpunkt mit "Deckeln" geprueft werden - - //Schnittpunkt mit Seitenflaechen bestimmen - //hierzu wird der schnittpunkt der gegebnen strecke mit den seitenflaechenberechnet - //als erstes "schaut man seitlich auf den Zylinder" --> kreisflaechen wird als strecke darsgestellt - //mit diesen "strecken" berechnet man Schnittpunkte. - //anschliessend wird geprueft, ob der berechnete Schnittpunkt ueberhaupt im kreis liegt - //falls ja --> Schnittpunkt vorhanden - - double x1a,y1a,z1a,x1b,y1b,z1b, //uebergebene Strecke - x2a,y2a,x2b,y2b, //erste "Kreisstrecke" - x3a,y3a,x3b,y3b, //zweite "Kreisstrecke" - y2m,z2m,y3m,z3m; - double nenner1ab; - - if(this->isParallelToX1Axis()) - { - x1a=point1.getX1Coordinate(); - y1a=point1.getX2Coordinate(); - z1a=point1.getX3Coordinate(); - x1b=point2.getX1Coordinate(); - y1b=point2.getX2Coordinate(); - z1b=point2.getX3Coordinate(); - - x2a=mLine->getPoint1()->getX1Coordinate(); - y2m=mLine->getPoint1()->getX2Coordinate(); - z2m=mLine->getPoint1()->getX3Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX1Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX1Coordinate(); // - y3m=mLine->getPoint2()->getX2Coordinate(); - z3m=mLine->getPoint2()->getX3Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX1Coordinate(); - y3b=y3m-mRad; - } - else if(this->isParallelToX2Axis()) - { - x1a=point1.getX2Coordinate(); - y1a=point1.getX3Coordinate(); - z1a=point1.getX1Coordinate(); - x1b=point2.getX2Coordinate(); - y1b=point2.getX3Coordinate(); - z1b=point2.getX1Coordinate(); - - x2a=mLine->getPoint1()->getX2Coordinate(); - y2m=mLine->getPoint1()->getX3Coordinate(); - z2m=mLine->getPoint1()->getX1Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX2Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX2Coordinate(); // - y3m=mLine->getPoint2()->getX3Coordinate(); - z3m=mLine->getPoint2()->getX1Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX2Coordinate(); - y3b=y3m-mRad; - } - else if(this->isParallelToX3Axis()) - { - x1a=point1.getX3Coordinate(); - y1a=point1.getX2Coordinate(); - z1a=point1.getX1Coordinate(); - x1b=point2.getX3Coordinate(); - y1b=point2.getX2Coordinate(); - z1b=point2.getX1Coordinate(); - - x2a=mLine->getPoint1()->getX3Coordinate(); - y2m=mLine->getPoint1()->getX2Coordinate(); - z2m=mLine->getPoint1()->getX1Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX3Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX3Coordinate(); // - y3m=mLine->getPoint2()->getX2Coordinate(); - z3m=mLine->getPoint2()->getX1Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX3Coordinate(); - y3b=y3m-mRad; - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - nenner1ab = -y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b+x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b; - //double nenner2 = x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b-y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b; - if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel - { - //tStrecke ist fuer gegebene Strecke! - double t1ab = (-y1a*x2a+y1a*x2b-2.0*y2a*x2b+x1a*y2a-x1a*y2b-x1b*y2b+2.0*y2b*x2a+x1b*y2a-y1b*x2a+y1b*x2b)/nenner1ab; - //double tStrecke = -(-x1a*y2a+x1a*y2b+2.0*y2a*x2b+y1a*x2a-2.0*x2a*y2b-y1a*x2b+y1b*x2a-y1b*x2b-x1b*y2a+x1b*y2b)/nenner2; - //wenn -1 <= t2 <= +1 -> SP mit strecke - if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x,y,z,abstand_ist; - if (this->isParallelToX1Axis()) - { - x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z)); - } - else if(this->isParallelToX2Axis()) - { - y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x)); - } - else if(this->isParallelToX3Axis()) - { - z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x)); - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - //pruefen, ob Punkt Element von Kreisflaeche - //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z)); - if(UbMath::lessEqual(abstand_ist,mRad)) //Punkt ist Schnittpunkt - { - bool exists = false; - for(int pos=0;pos<(int)schnittpunkte.size();++pos) - { - if( fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13 - && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13 - && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true; - } - - if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - - nenner1ab = -y1a*x3a+y1a*x3b+y1b*x3a-y1b*x3b+x1a*y3a-x1a*y3b-x1b*y3a+x1b*y3b; - - if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel - { - //tStrecke ist fuer gegebene Strecke! - double t1ab = (-y1a*x3a+y1a*x3b-x1b*y3b-2.0*y3a*x3b-x1a*y3b+2.0*y3b*x3a+x1a*y3a+x1b*y3a-y1b*x3a+y1b*x3b)/nenner1ab; - - if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x,y,z,abstand_ist; - if (this->isParallelToX1Axis()) - { - x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z)); - } - else if(this->isParallelToX2Axis()) - { - y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x)); - } - else if(this->isParallelToX3Axis()) - { - z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x)); - } - else throw UbException(UB_EXARGS,"cylinder must be parallel to one axis"); - - //pruefen, ob Punkt Element von Kreisflaeche - //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z)); - - if(UbMath::lessEqual(abstand_ist,mRad)) //Punkt ist Schnittpunkt - { - bool exists = false; - for(int pos=0;pos<(int)schnittpunkte.size();++pos) - { - if( fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13 - && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13 - && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true; - } - - if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - - int nofSchnittpunkte = (int)schnittpunkte.size(); - if (nofSchnittpunkte==0) return NULL; - else if(nofSchnittpunkte >2) throw UbException(UB_EXARGS,"more than three intersection points - not possible"); - else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]); - else if(nofSchnittpunkte==1) - { - if (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1)); - else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2)); - else return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); //strecke beruehrt clippedLine reduziert sich auf einen Punkt!!! - } - - return NULL; -} -/*==========================================================*/ -vector<GbTriangle3D*> GbCylinder3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 20; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+mRad*std::sin(phiX1a); - x3a = x3m+mRad*std::cos(phiX1a); - x2b = x2m+mRad*std::sin(phiX1b); - x3b = x3m+mRad*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1b,x2a,x3a),new GbPoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1a,x2b,x3b),new GbPoint3D(x1b,x2b,x3b))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2b,x1b,x3b),new GbPoint3D(x2a,x1b,x3a),new GbPoint3D(x2a,x1a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1a,x3a),new GbPoint3D(x2b,x1a,x3b),new GbPoint3D(x2b,x1b,x3b))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3b,x2b,x1b),new GbPoint3D(x3a,x2a,x1b),new GbPoint3D(x3a,x2a,x1a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1a),new GbPoint3D(x3b,x2b,x1a),new GbPoint3D(x3b,x2b,x1b))); - } - - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+radius0*std::sin(phiX1a); - x3a = x3m+radius0*std::cos(phiX1a); - x2b = x2m+radius0*std::sin(phiX1b); - x3b = x3m+radius0*std::cos(phiX1b); - x2c = x2m+radius1*std::sin(phiX1b); - x3c = x3m+radius1*std::cos(phiX1b); - x2d = x2m+radius1*std::sin(phiX1a); - x3d = x3m+radius1*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2a,x3a),new GbPoint3D(x1ma,x2b,x3b),new GbPoint3D(x1ma,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2c,x3c),new GbPoint3D(x1ma,x2d,x3d),new GbPoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2c,x3c),new GbPoint3D(x1mb,x2b,x3b),new GbPoint3D(x1mb,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2a,x3a),new GbPoint3D(x1mb,x2d,x3d),new GbPoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1ma,x3a),new GbPoint3D(x2b,x1ma,x3b),new GbPoint3D(x2c,x1ma,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1ma,x3c),new GbPoint3D(x2d,x1ma,x3d),new GbPoint3D(x2a,x1ma,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1mb,x3c),new GbPoint3D(x2b,x1mb,x3b),new GbPoint3D(x2a,x1mb,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1mb,x3a),new GbPoint3D(x2d,x1mb,x3d),new GbPoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1ma),new GbPoint3D(x3b,x2b,x1ma),new GbPoint3D(x3c,x2c,x1ma))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1ma),new GbPoint3D(x3d,x2d,x1ma),new GbPoint3D(x3a,x2a,x1ma))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1mb),new GbPoint3D(x3b,x2b,x1mb),new GbPoint3D(x3a,x2a,x1mb))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1mb),new GbPoint3D(x3d,x2d,x1mb),new GbPoint3D(x3c,x2c,x1mb))); - } - } - } - - return triangles; -} -/*==========================================================*/ -void GbCylinder3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ - float x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = (float)this->getX1Minimum(); - x1mb = (float)this->getX1Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = (float)this->getX2Minimum(); - x1mb = (float)this->getX2Maximum(); - x2m = (float)this->getX1Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = (float)this->getX3Minimum(); - x1mb = (float)this->getX3Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - int segmentsCircle = 20; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - int nodenr = 0; - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = (float)(x1ma+segCyl*dXCylinder); - x1b = x1c = (float)(x1a+dXCylinder); - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = (float)(x2m+mRad*std::sin(phiX1a)); - x3a = (float)(x3m+mRad*std::cos(phiX1a)); - x2b = (float)(x2m+mRad*std::sin(phiX1b)); - x3b = (float)(x3m+mRad*std::cos(phiX1b)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); - } - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+(float)(radius0*std::sin(phiX1a)); - x3a = x3m+(float)(radius0*std::cos(phiX1a)); - x2b = x2m+(float)(radius0*std::sin(phiX1b)); - x3b = x3m+(float)(radius0*std::cos(phiX1b)); - x2c = x2m+(float)(radius1*std::sin(phiX1b)); - x3c = x3m+(float)(radius1*std::cos(phiX1b)); - x2d = x2m+(float)(radius1*std::sin(phiX1a)); - x3d = x3m+(float)(radius1*std::cos(phiX1a)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); - nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); - nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); - } - - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } -} -/*==========================================================*/ -void GbCylinder3D::addSurfaceTriangleSetSegments(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight ) -{ - float x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = (float)this->getX1Minimum(); - x1mb = (float)this->getX1Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = (float)this->getX2Minimum(); - x1mb = (float)this->getX2Maximum(); - x2m = (float)this->getX1Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = (float)this->getX3Minimum(); - x1mb = (float)this->getX3Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - int segmentsCircle = segmentsRound; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsHeight; //hier evtl. segmentsheight - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - int nodenr = 0; - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = (float)(x1ma+segCyl*dXCylinder); - x1b = x1c = (float)(x1a+dXCylinder); - - //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi) - for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = (float)(x2m+mRad*std::sin(phiX1a)); - x3a = (float)(x3m+mRad*std::cos(phiX1a)); - x2b = (float)(x2m+mRad*std::sin(phiX1b)); - x3b = (float)(x3m+mRad*std::cos(phiX1b)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); - } - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi) - for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+(float)(radius0*std::sin(phiX1a)); - x3a = x3m+(float)(radius0*std::cos(phiX1a)); - x2b = x2m+(float)(radius0*std::sin(phiX1b)); - x3b = x3m+(float)(radius0*std::cos(phiX1b)); - x2c = x2m+(float)(radius1*std::sin(phiX1b)); - x3c = x3m+(float)(radius1*std::cos(phiX1b)); - x2d = x2m+(float)(radius1*std::sin(phiX1a)); - x3d = x3m+(float)(radius1*std::cos(phiX1a)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); - nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); - nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); - } - - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } -} - -/*==========================================================*/ -void GbCylinder3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void GbCylinder3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void GbCylinder3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible"); - this->mRad*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible"); - this->mRad*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible"); - this->mRad*=sx1; - } - else throw UbException(UB_EXARGS,"unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void GbCylinder3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(mRad); - out->writeInteger(cylinderType); -} -/*==========================================================*/ -void GbCylinder3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - mRad = in->readDouble(); - cylinderType = in->readInteger(); -} -/*==========================================================*/ -double GbCylinder3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - /* - Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 - dc = a*dx1 + b*dx2 + c*dx3 - dw = a*ox1 + b*ox2 + c*ox3 + d - D = - dw / dc - */ - double px1, px2, px3; - double d = Ub::inf; // Distance to Min or Max Plane of the Zylinder - // final distance should be less that d - - if( this->isParallelToX1Axis() ) - { - if (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1)) return -1.0; - else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1)) return -1.0; - - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( x1< minX1 || x1 > maxX1 ) //nur fuer punkte links und rechts des cylinders - { - px1 = (x1 < minX1 ? minX1 : maxX1); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( !UbMath::zero(rx1) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1.0*(x1 - px1) / rx1; - px2 = x2 + d*rx2; - px3 = x3 + d*rx3; - - if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x1 < minX1 && rx1>0.0 ) d = Ub::inf; //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberflaeche - else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - //if (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1; - //else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - if (UbMath::negative(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - else if(UbMath::positive(rx1)) d = -1.0 * (x1 - minX1) / rx1; - } - } - else if( this->isParallelToX2Axis() ) - { - if (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2)) return -1; - else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2)) return -1; - - if( minX2 > x2 || x2 > maxX2 ) - { - px2 = (x2 < minX2 ? minX2 : maxX2); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( !UbMath::zero(rx2) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1*(x2 - px2) / rx2; - px1 = x1 + d*rx1; - px3 = x3 + d*rx3; - - if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x2 < minX2 && rx2>0.0 ) d = Ub::inf; //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberflaeche - else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2; - else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2; - } - } - else if( this->isParallelToX3Axis() ) - { - if (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; - else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; - - if(minX3 > x3 || x3 > maxX3 ) - { - px3 = (x3 < minX3 ? minX3 : maxX3); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if (!UbMath::zero(rx3)) - { - // Plane a= 0, b= 0, c=1 d= -1*px3 - d = -1.0*(x3 - px3) / rx3; - px2 = x2 + d*rx2; - px1 = x1 + d*rx1; - if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) ) - { - if (x3 < minX3 && rx3>0.0 ) d = Ub::inf; - else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3; - else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3; - } - } - else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder"); - ////////////////////////////////////////////////////////////////////////// - //Q berechnen fuer Infinity Zylinder - double axisX1 = mLine->getPoint2()->x1 - mLine->getPoint1()->x1; /* Axis of the cylinder */ - double axisX2 = mLine->getPoint2()->x2 - mLine->getPoint1()->x2; /* mit p1 als base of cylinder */ - double axisX3 = mLine->getPoint2()->x3 - mLine->getPoint1()->x3; - - //double dirlen = mLine->getLength(); - //double abs, t, s; - - double RCx1 = x1 - mLine->getPoint1()->x1; - double RCx2 = x2 - mLine->getPoint1()->x2; - double RCx3 = x3 - mLine->getPoint1()->x3; - - //n = ray x axis - double nx1 = rx2*axisX3 - rx3*axisX2; - double nx2 = rx3*axisX1 - rx1*axisX3; - double nx3 = rx1*axisX2 - rx2*axisX1; - double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3; - - double abs; - if( UbMath::zero( nLength ) ) - { /* ray parallel to cyl */ - //abs = RC dot axis - double tmpabs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3; - double dx1 = RCx1 - tmpabs*axisX1; - double dx2 = RCx2 - tmpabs*axisX2; - double dx3 = RCx3 - tmpabs*axisX3; - if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) - return -1.0; - } - - //normalize "n" - nLength = std::sqrt(nLength); - double invnLength = 1.0/nLength; - nx1*=invnLength; - nx2*=invnLength; - nx3*=invnLength; - - //shortest distance = fabs( RC dot n ) - abs = std::fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 ); - - if( UbMath::lessEqual(abs, mRad) ) - { /* if ray hits cylinder */ - //Ox1 = RC x axis - double Ox1 = RCx2*axisX3 - RCx3*axisX2; - double Ox2 = RCx3*axisX1 - RCx1*axisX3; - double Ox3 = RCx1*axisX2 - RCx2*axisX1; - //t = - O dot n / nLength; - double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength; - - //O = n x axis; - Ox1 = nx2*axisX3 - nx3*axisX2; - Ox2 = nx3*axisX1 - nx1*axisX3; - Ox3 = nx1*axisX2 - nx2*axisX1; - - //normalize O - invnLength = 1.0/std::sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3); - Ox1*=invnLength; - Ox2*=invnLength; - Ox3*=invnLength; - - double s = std::fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) ); - - //Wert a) t-s: entering distance - // b) t+s: exiting distance - // - // -> we only consider factors in ray-dir -> means positive values! - // (s is always positive) - - if(t>s) - { - return UbMath::min( t-s, d ); - } - else if( (t+s) > 0 ) - { - return UbMath::min( t+s, d ); - } - } - - return -1.0; -} -/*==========================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h b/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h deleted file mode 100644 index e0e5425c9c77a6681f7b1321afa80299e0b9b931..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h +++ /dev/null @@ -1,153 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBCYLINDER3D_H -#define GBCYLINDER3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -#include <basics/memory/MbSharedPointerDefines.h> -class GbCylinder3D; -typedef VFSharedPtr<GbCylinder3D> GbCylinder3DPtr; - - -class GbCylinder3D : public GbObject3D , public UbObserver -{ -public: - GbCylinder3D(); - GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius); - GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius); - GbCylinder3D(GbLine3D* line, const double& rad); - GbCylinder3D(GbCylinder3D* cylinder); - ~GbCylinder3D(); - - GbCylinder3D* clone() { return new GbCylinder3D(this); } - void finalize(); - - double getRadius() { return this->mRad; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->mLine->translate( x1, x2, x3 ); - this->calculateValues(); - //this->notifyObserversObjectChanged(); - } - - double getX1Centroid() { return centerX1; } - double getX1Minimum() { return minX1; } - double getX1Maximum() { return maxX1; } - double getX2Centroid() { return centerX2; } - double getX2Minimum() { return minX2; } - double getX2Maximum() { return maxX2; } - double getX3Centroid() { return centerX3; } - double getX3Minimum() { return minX3; } - double getX3Maximum() { return maxX3; } - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - //SG ausdokumentieren, da der nur unendlcihe Zylinder macht ... - //bool hasRaytracing() { return true; } - bool hasRaytracing() { return false; } - bool raytracingSupportsPointsInside() { 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); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - void addSurfaceTriangleSetSegments(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight ); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & mLine; - ar & mRad; - ar & cylinderType; - - if( ArchiveTools::isReading(ar) ) - this->calculateValues(); - } -#endif //CAB_RCF - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - - -protected: - void calculateValues(); - - GbLine3D* mLine; - double mRad; - - double minX1, minX2, minX3; - double maxX1, maxX2, maxX3; - double centerX1, centerX2, centerX3; - - int cylinderType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCylinder3D >("GbCylinder3D") , SF_GbCylinder3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCylinder3D >() ), SF_GbCylinder3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCylinder3D>() ), SF_GbCylinder3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp deleted file mode 100644 index 0d1072db51f301511642803e076dcd5afd63a925..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include <numerics/geometry3d/GbHalfSpace3D.h> - -using namespace std; - -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbTriangle3D* triangle) -{ - GbPoint3D* PointA = triangle->getPoint1(); - GbPoint3D* PointB = triangle->getPoint2(); - GbPoint3D* PointC = triangle->getPoint3(); - - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - //this->Normal = BACA; - normalX = BACA[0]; - normalY = BACA[1]; - normalZ = BACA[2]; - //this->d = this->Normal.Dot(A); - this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - //this->Normal = BACA; - normalX = BACA[0]; - normalY = BACA[1]; - normalZ = BACA[2]; - //this->d = this->Normal.Dot(A); - this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D B(PointB->x1, PointB->x2, PointB->x3 ); - GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point - - GbVector3D PointBA = B-A; - GbVector3D PointBAK = PointBA.Cross(K); - PointBAK.Normalize(); - - //this->Normal = PointBAK; - normalX = PointBAK[0]; - normalY = PointBAK[1]; - normalZ = PointBAK[2]; - - //this->d = this->Normal.Dot(A); - this->d = normalX*PointA->x1 + normalY*PointA->x2 + normalZ*PointA->x3; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ) -{ - double p2minusP1x = p2x-p1x; - double p2minusP1y = p2y-p1y; - double p2minusP1z = p2z-p1z; - - double P3minusP1x = p3x-p1x; - double P3minusP1y = p3y-p1y; - double P3minusP1z = p3z-p1z; - - //normal = BA x CA - normalX = p2minusP1y*P3minusP1z - p2minusP1z*P3minusP1y; - normalY = p2minusP1z*P3minusP1x - p2minusP1x*P3minusP1z; - normalZ = p2minusP1x*P3minusP1y - p2minusP1y*P3minusP1x; - - //normalize BACA - double oneOverNormalLength = 1.0 / ( std::sqrt( normalX*normalX + normalY*normalY + normalZ*normalZ ) ); - normalX *= oneOverNormalLength; - normalY *= oneOverNormalLength; - normalZ *= oneOverNormalLength; - - //d = normal * p1 - this->d = normalX*p1x + normalY*p1y + normalZ*p1z; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z, - const double& nx, const double& ny, const double& nz) -{ - //normal = BA x CA - normalX =nx; - normalY =ny; - normalZ =nz; - - //d = normal * p1 - this->d = nx*p1x + ny*p1y + nz*p1z; -} -/*==========================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h b/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h deleted file mode 100644 index 8dfea3e74f4d7ce3745a3eadc9410061eae9b0f7..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h +++ /dev/null @@ -1,86 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBHALFSPACE3D_H -#define GBHALFSPACE3D_H - -#include <sstream> -#include <iostream> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbHalfSpace3D; -typedef VFSharedPtr<GbHalfSpace3D> GbHalfSpace3DPtr; - - -/*=========================================================================*/ -/* GbHalfSpace3D */ -/* */ -/** -* This Class helps in performing some operations on a halfspace defined by 2 or 3 points -*/ - -class GbHalfSpace3D -{ -public: - GbHalfSpace3D(GbTriangle3D* triangle); - - GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC); - - GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB); - - GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ); - GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z, - const double& nx, const double& ny, const double& nz); - - /*=======================================================*/ - std::string getTypeID() {return "GbHalfSpace3D"; } - /*=============================================*/ - bool ptInside(const double& x, const double& y, const double& z) - { - return UbMath::greaterEqual( normalX*x + normalY*y + normalZ*z, this->d ); - } - /*=============================================*/ - bool ptInside(GbPoint3D* pointX) - { - //GbVector3D X(PointX->x1, PointX->x2, PointX->x3 ); - //return UbMath::greaterEqual(this->Normal.Dot(X), this->d); - return UbMath::greaterEqual( normalX*pointX->x1 + normalY*pointX->x2 + normalZ*pointX->x3, this->d ); - } - /*=============================================*/ - bool ptInside(GbVector3D& x) - { - //return UbMath::greaterEqual(this->Normal.Dot(X), this->d); - return UbMath::greaterEqual( normalX*x[0] + normalY*x[1] + normalZ*x[2], this->d ); - } - /*=============================================*/ - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - return (normalX*x1p + normalY*x2p + normalZ*x3p) - this->d; - } - - const double& getNormalX() { return this->normalX; } - const double& getNormalY() { return this->normalY; } - const double& getNormalZ() { return this->normalZ; } - const double& getD() { return this->d; } - -private: - //GbVector3D Normal; - double normalX; - double normalY; - double normalZ; - double d; -}; -/*=========================================================================*/ - -#endif //GBHALFSPACE3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp deleted file mode 100644 index 0cfb68ce2b7b38091c63869cbf78107798318b70..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h> - -using namespace std; - -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbTriangle3D* triangle) -{ - GbPoint3D* PointA = triangle->getPoint1(); - GbPoint3D* PointB = triangle->getPoint2(); - GbPoint3D* PointC = triangle->getPoint3(); - - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D B(PointB->x1, PointB->x2, PointB->x3 ); - GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point - - GbVector3D PointBA = B-A; - GbVector3D PointBAK = PointBA.Cross(K); - PointBAK.Normalize(); - this->Normal = PointBAK; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ) -{ - GbVector3D A( p1x, p1y, p1z ); - GbVector3D BA(p2x-p1x, p2y-p1y, p2z-p1z ); - GbVector3D CA(p3x-p1x, p3y-p1y, p3z-p1z ); - GbVector3D BACA = BA.Cross(CA); - - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist) -{ - this->Normal = GbVector3D(nx,ny,nz); - this->Normal.Normalize(); - this->d = dist; -} -/*==========================================================*/ -double GbHalfSpaceKrischan3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - - double x1 = x1b-x1a; - double x2 = x2b-x2a; - double x3 = x3b-x3a; - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*x1*x2*x3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double alpha=0.0; - double internX1,internX2,internX3; - - for(int x1vers=0;x1vers<2;x1vers++){ - for(int x2vers=0;x2vers<2;x2vers++){ - for(int x3vers=0;x3vers<2;x3vers++){ - internX1 = x1a + (x1b-x1a)*x1vers; - internX2 = x2a + (x2b-x2a)*x2vers; - internX3 = x3a + (x3b-x3a)*x3vers; - - // if point is INSIDE the halfspace, distance is smaller than zero - // --> loop determines the minimum alpha...i.e. the alpha with maximum absolute value for all points INSIDE the halfspace - if( UbMath::lessEqual( this->getDistance(internX1,internX2,internX3) , alpha ) ) - alpha = this->getDistance(internX1,internX2,internX3); - //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl; - }//end first for - }//end second for - }//end third for - - // PLIC needs alphas > 0.0 - alpha = (-1)*alpha; - - - - double n[3]; - n[0] = this->Normal[0]; - n[1] = this->Normal[1]; - n[2] = this->Normal[2]; - - //cout << "Koordinaten: "<<x1<<" "<<x2<<" "<<x3<<endl; - //cout << "Deltas: "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl; - //cout << "Halbe Zelle: "<<halfcelldelta<<endl; - - //cout<<"Centroid: "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double normLength; - normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); - n[0] /= normLength; - n[1] /= normLength; - n[2] /= normLength; - - if( UbMath::less(n[0],0.0) ) n[0] = -n[0]; - if( UbMath::less(n[1],0.0) ) n[1] = -n[1]; - if( UbMath::less(n[2],0.0) ) n[2] = -n[2]; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double dummy; - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;} - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double n1,n2,n3; - n1=n[0]; - n2=n[1]; - n3=n[2]; - - double preresult=0.0,result=0.0; - - // 1D Check - if ( UbMath::lessEqual(n1,0.00001)&&UbMath::lessEqual(n2,0.00001) ) - { - result = alpha * x1 * x2; - } - // 2D Check - else if ( UbMath::lessEqual(n1,0.00001) ) - { - preresult = (2*n2*n3); - result = (alpha*alpha)/preresult; - - if( UbMath::greater(alpha,n2*x2) ) - { - result += -(alpha-n2*x2)*(alpha-n2*x2)/preresult; - } - if( UbMath::greater(alpha,n3*x3) ) - { - result += -(alpha-n3*x3)*(alpha-n3*x3)/preresult; - } - if( UbMath::greater(alpha,n2*x2+n3*x3) ) - { - result += (alpha-n2*x2-n3*x3)*(alpha-n2*x2-n3*x3)/preresult; - } - - // tiefenrichtung mit einmultiplizieren... - result *= x1; - } - // 3D Check - else - { - preresult =6*n1*n2*n3; - - result = alpha*alpha*alpha/preresult; - - if ( UbMath::greater (alpha,n1*x1)) - { - result+=-((alpha-n1*x1)*(alpha-n1*x1)*(alpha-n1*x1))/preresult; - } - if (UbMath::greater(alpha,n2*x2)) - { - result+=-((alpha-n2*x2)*(alpha-n2*x2)*(alpha-n2*x2))/preresult; - } - if (UbMath::greater(alpha,n3*x3)) - { - result+=-((alpha-n3*x3)*(alpha-n3*x3)*(alpha-n3*x3))/preresult; - } - if (UbMath::greater(alpha,(n1*x1+n2*x2))) - { - result+=((alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2)))/preresult; - } - if (UbMath::greater(alpha,(n1*x1+n3*x3))) - { - result+=((alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3)))/preresult; - } - if (UbMath::greater(alpha,(n2*x2+n3*x3))) - { - result+=((alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3)))/preresult; - } - - //NEW - if (UbMath::greater(alpha,(n1*x1+n2*x2+n3*x3))) - { - result+= -((alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3)))/preresult; - } - - } - - if( !UbMath::inClosedInterval( result/ (x1*x2*x3), -0.01, 1.01) ) - { - stringstream errMsg; - - errMsg << "Danger...Fuellstand "<<result<<" nicht im Interfall [0.0..1.0]" << endl; - errMsg << "NormVec: " << n1 << " " << n2 << " " << n3 << endl; - errMsg << "Cell: " << x1 << " " << x2 << " " << x3 << endl; - errMsg << "Alpha: " << alpha << endl; - - - throw UbException( UB_EXARGS, errMsg.str() ); - } - - return result; - - - //double eps=0.0; - //if( UbMath::equal(n1,0.0) && UbMath::equal(n2,0.0) ) - //{ - // eps = alpha/n3; - //} - //else if( UbMath::equal(n1,0.0) ) - //{ - // double dim1,dim2; - // dim1 = alpha/n2; - // dim2 = alpha/n3; - - // eps = 0.5*dim1*dim2; - // if( UbMath::greater(dim1,1.0) ) eps -= 0.5*(dim1-1.0)*dim2/dim1*(dim1-1.0); - // if( UbMath::greater(dim2,1.0) ) eps -= 0.5*(dim2-1.0)*dim1/dim2*(dim2-1.0); - //} - //else - //{ - // eps = alpha*alpha*alpha; - // if( UbMath::greater(alpha,n1) ) - // eps -= (alpha-n1)*(alpha-n1)*(alpha-n1); - // if( UbMath::greater(alpha,n2) ) - // eps -= (alpha-n2)*(alpha-n2)*(alpha-n2); - // if( UbMath::greater(alpha,n3) ) - // eps -= (alpha-n3)*(alpha-n3)*(alpha-n3); - - // if( UbMath::greater(alpha,n1+n2) ) - // eps += (alpha-n1-n2)*(alpha-n1-n2)*(alpha-n1-n2); - // if( UbMath::greater(alpha,n1+n3) ) - // eps += (alpha-n1-n3)*(alpha-n1-n3)*(alpha-n1-n3); - // if( UbMath::greater(alpha,n2+n3) ) - // eps += (alpha-n2-n3)*(alpha-n2-n3)*(alpha-n2-n3); - - // //attention: use without delta_i - // eps = eps / (6*n[0]*n[1]*n[2]); - - // eps = eps / (deltaX1*deltaX2*deltaX3); - //} - - - //return(eps) ; - //cout << "alpha ist " << alpha << endl; - //cout << "fillLevel ist " << eps << endl; -} -/*==========================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h b/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h deleted file mode 100644 index 1765eec1ede944576cd22fdc57d054c4a4cee12f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h +++ /dev/null @@ -1,205 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GbHalfSpaceKrischan3D_H -#define GbHalfSpaceKrischan3D_H - -#include <sstream> -#include <iostream> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> -#include <numerics/geometry3d/GbLine3D.h> - -/*=========================================================================*/ -/* GbHalfSpaceKrischan3D */ -/* */ -/** -* This Class helps in performing some operations on a halfspace defined by 2 or 3 points -*/ - -class GbHalfSpaceKrischan3D : public GbObject3D , public UbObserver -{ -public: - GbHalfSpaceKrischan3D(GbTriangle3D* triangle); - - GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC); - - GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist); - - GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB); - - GbHalfSpaceKrischan3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ); - - /*=======================================================*/ - virtual ~GbHalfSpaceKrischan3D() { } - /*=======================================================*/ - std::string getTypeID() {return "GbHalfSpaceKrischan3D"; } - /*=============================================*/ - bool ptInside(const double& x, const double& y, const double& z) - { - return UbMath::lessEqual(Normal[0]*x+Normal[1]*y+Normal[2]*z, this->d); - } - /*=============================================*/ - bool ptInside(GbPoint3D* PointX) - { - GbVector3D X(PointX->x1, PointX->x2, PointX->x3 ); - return UbMath::lessEqual(this->Normal.Dot(X), this->d); - } - /*=============================================*/ - bool ptInside(GbVector3D &X) - { - return UbMath::lessEqual(this->Normal.Dot(X), this->d); - } - - /*=====================================================*/ - //true, wenn 'in Object' oder 'auf Boundary'! - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) - { - return (ptInside(x1p,x2p,x3p)); - } - /*=====================================================*/ - //true, wenn 'in Object' oder 'auf Boundary'! - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) - { - return (ptInside(x1p,x2p,x3p)); - } - - void finalize(){} - ObObjectCreator* getCreator(){ return NULL; } - - double getX1Centroid(){ return 0.0; } - double getX1Minimum() { return -99999.0; } - double getX1Maximum() { return 99999.0; } - double getX2Centroid(){ return 0.0; } - double getX2Minimum() { return -99999.0; } - double getX2Maximum() { return 99999.0; } - double getX3Centroid(){ return 0.0; } - double getX3Minimum() { return -99999.0; } - double getX3Maximum() { return 99999.0; } - - void write(UbFileOutput* out){} - void read(UbFileInput* in){} - - GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2) - { - GbPoint3D *p1 = new GbPoint3D(point1); - GbPoint3D *p2 = new GbPoint3D(point2); - - GbVector3D p1p2( p2->x1-p1->x1, p2->x2-p1->x2, p2->x3-p1->x3); - - double dist1 = getDistance( p1->x1,p1->x2,p1->x3 ); - double dist2 = getDistance( p2->x1,p2->x2,p2->x3 ); - - double totalDist = std::abs(dist1) + std::abs(dist2); - - // Falls erster Punkt nicht drinliegt - if( !ptInside(p1) ) - { - if( !ptInside(p2) ) return NULL; - - // distance ausrechnen (groesser null) - if( UbMath::less( dist1, 0.0 ) ) throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" ); - - p1->x1 = p1->x1 + dist1/totalDist*p1p2[0]; - p1->x2 = p1->x2 + dist1/totalDist*p1p2[1]; - p1->x3 = p1->x3 + dist1/totalDist*p1p2[2]; - } - // Falls zweiter Punkt nicht drinliegt - if( !ptInside(p2) ) - { - if( !ptInside(p1) ) return NULL; - - // distance ausrechnen (groesser null) - if( UbMath::less( dist2, 0.0 ) ) throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" ); - - p2->x1 = p2->x1 - dist2/totalDist*p1p2[0]; - p2->x2 = p2->x2 - dist2/totalDist*p1p2[1]; - p2->x3 = p2->x3 - dist2/totalDist*p1p2[2]; - } - - return new GbLine3D(p1,p2); - } - - - double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - return (Normal[0]*x1p + Normal[1]*x2p + Normal[2]*x3p) - this->d; - } - - void getNormal( double& n1, double& n2, double& n3 ) - { - n1 = this->Normal[0]; - n2 = this->Normal[1]; - n3 = this->Normal[2]; - } - - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) - { - std::cout << " addSurfaceTriangleSet(): TO BE DONE AND CHECKED ... " << std::endl; - } - - std::vector<GbTriangle3D*> getSurfaceTriangleSet() - { - std::vector<GbTriangle3D*> triangles; - GbPoint3D p1( 0.0,0.0,0.0 ); - GbPoint3D p2( 1.0,0.0,0.0 ); - GbPoint3D p3( 0.0,1.0,0.0 ); - - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3))); - - return triangles; - } - - void objectChanged(UbObservable* changedObject) - { - return; - - //GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - //if(!line || this->mLine!=line) return; - //this->notifyObserversObjectChanged(); - } - /*==========================================================*/ - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - return; - //if(this->mLine) - //{ - // UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - // if(objectForDeletion == observedObj) { this->mLine = NULL; } - //} - } - - ObObject* clone(){ return NULL; }; - - std::string toString() - { - std::stringstream temp; - - temp << "GbHalfSpaceKrischan3D: "; - temp << " Distance " << this->d; - temp << " Norm vec " << this->Normal[0]; - temp << " " << this->Normal[1]; - temp << " " << this->Normal[2]; - - - return temp.str(); - }; - -private: - GbVector3D Normal; - double d; -}; -/*=========================================================================*/ - -#endif //GbHalfSpaceKrischan3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp deleted file mode 100644 index 7cd729d8aca94749f3c92c49c5aec9a8e806f858..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/creator/GbLine3DCreator.h> - -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -ObObjectCreator* GbLine3D::getCreator() -{ - return GbLine3DCreator::getInstance(); -} -/*=======================================================*/ -GbLine3D::GbLine3D() -{ - p1 = NULL; - p2 = NULL; - length = 0.0; -} -/*=======================================================*/ -GbLine3D::GbLine3D(GbPoint3D* point1, GbPoint3D* point2) -{ - this->p1 = point1; - this->p2 = point2; - this->p1->addObserver(this); - this->p2->addObserver(this); - this->calculateValues(); -} -/*=======================================================*/ -GbLine3D::GbLine3D(GbLine3D* line) -{ - this->p1 = line->p1->clone(); - this->p2 = line->p2->clone(); - this->p1->addObserver(this); - this->p2->addObserver(this); - this->calculateValues(); -} -/*=======================================================*/ -GbLine3D::~GbLine3D() -{ - if(this->p1) this->p1->removeObserver(this); - if(this->p2) this->p2->removeObserver(this); -} -/*=======================================================*/ -void GbLine3D::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; - } -} -/*=======================================================*/ -vector<GbTriangle3D*> GbLine3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> triangles; - GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum()); - GbPoint3D p2(getX1Centroid(),getX2Centroid(),getX3Centroid()); - GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Maximum()); - - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3))); - - return triangles; -} -/*=======================================================*/ -void GbLine3D::setPoint1(GbPoint3D* point1) -{ - if(this->p1) this->p1->removeObserver(this); - this->p1 = point1; - this->p1->addObserver(this); - - if(this->p1 && this->p2) this->calculateValues(); -} -/*=======================================================*/ -void GbLine3D::setPoint2(GbPoint3D* point2) -{ - if(this->p2) this->p2->removeObserver(this); - this->p2 = point2; - this->p2->addObserver(this); - - if(this->p1 && this->p2) this->calculateValues(); -} -/*=======================================================*/ -void GbLine3D::setPoints(GbPoint3D* point1, GbPoint3D* point2) -{ - if(this->p1) this->p1->removeObserver(this); - if(this->p2) this->p2->removeObserver(this); - - this->p1 = point1; - this->p2 = point2; - - this->p1->addObserver(this); - this->p2->addObserver(this); - - this->calculateValues(); -} -/*=======================================================*/ -string GbLine3D::toString() -{ - stringstream ss; - ss<<"GbLine3D[p1="; - ss<<this->p1->toString()<<",p2="<<this->p2->toString()<<",l="<<this->getLength()<<"]"; - return(ss.str()); -} -/*=======================================================*/ -GbPoint3D* GbLine3D::calculateIntersectionPoint3D(GbLine3D* line) -{ - throw UbException(UB_EXARGS," not implemented"); - //return(GbSystem::calculateIntersectionPoint3D(*this->p1, *this->p2, *line->p1, *line->p2)); -} -/*======================================================================*/ -GbLine3D* GbLine3D::createClippedLine3D(GbCuboid3D* cuboid) -{ - return GbSystem3D::createClipLine3D(*this->p1, *this->p2, cuboid->getPoint1()->x1, cuboid->getPoint1()->x2, cuboid->getPoint1()->x3, cuboid->getPoint2()->x1, cuboid->getPoint2()->x2, cuboid->getPoint2()->x3); -} -/*======================================================================*/ -GbLine3D* GbLine3D::createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE) -{ - return GbSystem3D::createClipLine3D(*this->p1, *this->p2, pA->x1, pA->x2, pA->x3, pE->x1, pE->x2, pE->x3); -} -/*======================================================================*/ -double GbLine3D::getDistance(const GbPoint3D& point) -{ - return this->getDistance(point.x1,point.x2,point.x3); -} -/*======================================================================*/ -double GbLine3D::getDistance(const double& x1,const double& x2,const double& x3) -{ - double dx1 = this->p2->x1 - this->p1->x1; - double dx2 = this->p2->x2 - this->p1->x2; - double dx3 = this->p2->x3 - this->p1->x3; - - //double vec[3]; - double a0 = x1 - p1->x1; - double a1 = x2 - p1->x2; - double a2 = x3 - p1->x3; - - double kreuzProd0 = a1 * dx3 - a2 * dx2; - double kreuzProd1 = a2 * dx1 - a0 * dx3; - double kreuzProd2 = a0 * dx2 - a1 * dx1; - - return (std::sqrt(kreuzProd0*kreuzProd0+kreuzProd1*kreuzProd1+kreuzProd2*kreuzProd2))/length; -} -/*=======================================================*/ -void GbLine3D::calculateValues() -{ - double dx1 = this->p2->x1 - this->p1->x1; - double dx2 = this->p2->x2 - this->p1->x2; - double dx3 = this->p2->x3 - this->p1->x3; - this->length = std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3); -} -/*==========================================================*/ -void GbLine3D::objectChanged(UbObservable* changedObject) -{ - GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject); - if(!point || (this->p1!=point && this->p2!=point)) return; - - this->calculateValues(); -} -/*==========================================================*/ -void GbLine3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->p1) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1); - if(objectForDeletion == observedObj) { this->p1 = NULL; length = 0.0; } - } - if(this->p2) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2); - if(objectForDeletion == observedObj) { this->p2 = NULL; length = 0.0; } - } - //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo -} -/*==========================================================*/ -void GbLine3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*==========================================================*/ -void GbLine3D::read(UbFileInput* in) -{ - p1 = new GbPoint3D; - p2 = new GbPoint3D; - in->readString(); - p1->read(in); - p1->addObserver(this); - in->readString(); - p2->read(in); - p2->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ -void GbLine3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - double p1X1 = this->p1->getX1Coordinate(); - 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 lenX1 = fabs( p1X1 - p2X1 ); - double lenX2 = fabs( p1X2 - p2X2 ); - double lenX3 = fabs( p1X3 - p2X3 ); - - double deltaX1 = lenX1*sx1 - lenX1; - double deltaX2 = lenX2*sx2 - lenX2; - double deltaX3 = lenX3*sx3 - lenX3; - - if(p1X1<p2X1) { p1X1 -= 0.5*deltaX1; p2X1 += 0.5*deltaX1; } - else { p1X1 += 0.5*deltaX1; p2X1 -= 0.5*deltaX1; } - if(p1X2<p2X2) { p1X2 -= 0.5*deltaX2; p2X2 += 0.5*deltaX2; } - else { p1X2 += 0.5*deltaX2; p2X2 -= 0.5*deltaX2; } - if(p1X3<p2X3) { p1X3 -= 0.5*deltaX3; p2X3 += 0.5*deltaX3; } - else { p1X3 += 0.5*deltaX3; p2X3 -= 0.5*deltaX3; } - - this->p1->setCoordinates(p1X1,p1X2,p1X3); - this->p2->setCoordinates(p2X1,p2X2,p2X3); -} -/*=======================================================*/ -void GbLine3D::translate(const double& tx1, const double& tx2, const double& tx3) -{ - this->p1->translate(tx1, tx2, tx3); - this->p2->translate(tx1, tx2, tx3); - //this->notifyObserversObjectChanged(); -} diff --git a/ThirdParty/Library/numerics/geometry3d/GbLine3D.h b/ThirdParty/Library/numerics/geometry3d/GbLine3D.h deleted file mode 100644 index 9267666ce804cc800c92f0c08ec56b11e75f2bb8..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbLine3D.h +++ /dev/null @@ -1,138 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBLINE3D_H -#define GBLINE3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <sstream> -#include <cmath> - -#include <basics/utilities/UbObserver.h> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbPoint3D.h> - -class GbCuboid3D; -class GbObject3DCreator; - -#include <basics/memory/MbSharedPointerDefines.h> -class GbLine3D; -typedef VFSharedPtr<GbLine3D> GbLine3DPtr; - - -/*=========================================================================*/ -/* GbLine3D */ -/* */ -/** - * This Class provides basic 3D line objects. - * The describing points are observed by 3D line objects. - * <BR><BR><HR> -*/ - -class GbLine3D : public GbObject3D , public UbObserver -{ -public: - GbLine3D(); - GbLine3D(GbPoint3D* point1, GbPoint3D* point2); - GbLine3D(GbLine3D* line); - ~GbLine3D(); - - GbLine3D* clone() { return new GbLine3D(this); } - void finalize(); - - void setPoint1(GbPoint3D* point1); - void setPoint2(GbPoint3D* point2); - void setPoints(GbPoint3D* point1, GbPoint3D* point2); - - void deletePoint1() { if(this->p1) {this->p1->removeObserver(this); delete this->p1; this->p1=NULL;} } - void deletePoint2() { if(this->p2) {this->p2->removeObserver(this); delete this->p2; this->p2=NULL;} } - void deletePoints() { this->deletePoint1(); this->deletePoint2(); } - - GbPoint3D* getPoint1() { return this->p1; } - GbPoint3D* getPoint2() { return this->p2; } - - double getLength() { return(this->length); } - - double getX1Centroid() { return((this->p1->x1+this->p2->x1)*0.5);} - double getX2Centroid() { return((this->p1->x2+this->p2->x2)*0.5); }; - double getX3Centroid() { return((this->p1->x3+this->p2->x3)*0.5); } - - double getX1Minimum() { return(this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); } - double getX2Minimum() { return(this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); } - double getX3Minimum() { return(this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3); } - - double getX1Maximum() { return(this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); } - double getX2Maximum() { return(this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); } - double getX3Maximum() { return(this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); } - - void scale(const double& sx1, const double& sx2, const double& sx3); - void translate(const double& tx1, const double& tx2, const double& tx3); - - GbPoint3D* calculateIntersectionPoint3D(GbLine3D* line); - GbLine3D* createClippedLine3D(GbCuboid3D* cuboid); - GbLine3D* createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE); - - double getDistance(const GbPoint3D& point); - double getDistance(const double& x1,const double& x2,const double& x3); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3) - { - throw UbException(UB_EXARGS,"not implemented"); - } - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) - { - throw UbException(UB_EXARGS,"not implemented"); - } - bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x32) { return false; } - - GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) - { - throw UbException(UB_EXARGS,"not implemented"); - } - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - ar & length; - if( ArchiveTools::isReading(ar) ) this->calculateValues(); - } -#endif //CAB_RCF - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -protected: - GbPoint3D* p1; - GbPoint3D* p2; - double length; - -private: - void calculateValues(); -}; - -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbLine3D>("GbLine3D"), SF_GbLine3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbLine3D >()), SF_GbLine3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbLine3D>() ), SF_GbLine3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h b/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h deleted file mode 100644 index e5430ca9af27c461d2ac7eabb1f10c47b0f9917f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h +++ /dev/null @@ -1,402 +0,0 @@ -#ifndef GBMESHTOOLS3D_H -#define GBMESHTOOLS3D_H - -#include <sstream> -#include <iostream> -#include <vector> - -#include <basics/utilities/UbMath.h> - -namespace GbMeshTools3D -{ - inline int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3]) // -NJMP- - { - int q; - float vmin[3],vmax[3],v; - - for(q=0;q<=2;q++) - { - v=vert[q]; // -NJMP- - if(normal[q]>0.0f) - { - vmin[q]=-maxbox[q] - v; // -NJMP- - vmax[q]= maxbox[q] - v; // -NJMP- - } - else - { - vmin[q]= maxbox[q] - v; // -NJMP- - vmax[q]=-maxbox[q] - v; // -NJMP- - } - } - if(( normal[0]*vmin[0] + normal[1]*vmin[1] + normal[2]*vmin[2] )>0.0f ) return 0; // -NJMP- - if(( normal[0]*vmax[0] + normal[1]*vmax[1] + normal[2]*vmax[2] )>=0.0f) return 1; // -NJMP- - return 0; - } - - //Testet auf schnittpunkt Box <-> Dreieck - //boxcenter = Mittelpunkt der Box - //boxhalfsize = Halbe Laenge/Hoehe/Breite der Box - //triverts = Koordinaten der Deickspunkte - inline int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3]) - { - /* use separating axis theorem to test overlap between triangle and box */ - /* need to test for overlap in these directions: */ - /* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */ - /* we do not even need to test these) */ - /* 2) normal of the triangle */ - /* 3) crossproduct(edge from tri, {x,y,z}-directin) */ - /* this gives 3x3=9 more tests */ - - float v0[3],v1[3],v2[3]; - - // float axis[3]; - - float min,max,p0,p1,p2,rad,fex,fey,fez; // -NJMP- "d" local variable removed - float normal[3],e0[3],e1[3],e2[3]; - - /* This is the fastest branch on Sun */ - /* move everything so that the boxcenter is in (0,0,0) */ - //SUB(v0,triverts[0],boxcenter); - //#define SUB(dest,v1,v2) - v0[0]=triverts[0][0]-boxcenter[0]; - v0[1]=triverts[0][1]-boxcenter[1]; - v0[2]=triverts[0][2]-boxcenter[2]; - - //SUB(v1,triverts[1],boxcenter); - //#define SUB(dest,v1,v2) - v1[0]=triverts[1][0]-boxcenter[0]; - v1[1]=triverts[1][1]-boxcenter[1]; - v1[2]=triverts[1][2]-boxcenter[2]; - - //SUB(v2,triverts[2],boxcenter); - //#define SUB(dest,v1,v2) - v2[0]=triverts[2][0]-boxcenter[0]; - v2[1]=triverts[2][1]-boxcenter[1]; - v2[2]=triverts[2][2]-boxcenter[2]; - - /* compute triangle edges */ - //SUB(e0,v1,v0); /* tri edge 0 */ - //#define SUB(dest,v1,v2) - e0[0]=v1[0]-v0[0]; - e0[1]=v1[1]-v0[1]; - e0[2]=v1[2]-v0[2]; - - //SUB(e1,v2,v1); /* tri edge 1 */ - //#define SUB(dest,v1,v2) - e1[0]=v2[0]-v1[0]; - e1[1]=v2[1]-v1[1]; - e1[2]=v2[2]-v1[2]; - - //SUB(e2,v0,v2); /* tri edge 2 */ - //#define SUB(dest,v1,v2) - e2[0]=v0[0]-v2[0]; - e2[1]=v0[1]-v2[1]; - e2[2]=v0[2]-v2[2]; - - /* Bullet 3: */ - /* test the 9 tests first (this was faster) */ - fex = fabsf(e0[0]); - fey = fabsf(e0[1]); - fez = fabsf(e0[2]); - - //AXISTEST_X01(e0[2], e0[1], fez, fey); - //#define AXISTEST_X01(a, b, fa, fb) - p0 = e0[2]*v0[1] - e0[1]*v0[2]; - p2 = e0[2]*v2[1] - e0[1]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y02(e0[2], e0[0], fez, fex); - //#define AXISTEST_Y02(a, b, fa, fb) - p0 = -e0[2]*v0[0] + e0[0]*v0[2]; - p2 = -e0[2]*v2[0] + e0[0]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z12(e0[1], e0[0], fey, fex); - //#define AXISTEST_Z12(a, b, fa, fb) - p1 = e0[1]*v1[0] - e0[0]*v1[1]; - p2 = e0[1]*v2[0] - e0[0]*v2[1]; - if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[1]; - if(min>rad || max<-rad) return 0; - - fex = fabsf(e1[0]); - fey = fabsf(e1[1]); - fez = fabsf(e1[2]); - - //AXISTEST_X01(e1[2], e1[1], fez, fey); - //#define AXISTEST_X01(a, b, fa, fb) - p0 = e1[2]*v0[1] - e1[1]*v0[2]; - p2 = e1[2]*v2[1] - e1[1]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y02(e1[2], e1[0], fez, fex); - //#define AXISTEST_Y02(a, b, fa, fb) - p0 = -e1[2]*v0[0] + e1[0]*v0[2]; - p2 = -e1[2]*v2[0] + e1[0]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z0(e1[1], e1[0], fey, fex); - //#define AXISTEST_Z0(a, b, fa, fb) - p0 = e1[1]*v0[0] - e1[0]*v0[1]; - p1 = e1[1]*v1[0] - e1[0]*v1[1]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - fex = fabsf(e2[0]); - fey = fabsf(e2[1]); - fez = fabsf(e2[2]); - //AXISTEST_X2(e2[2], e2[1], fez, fey); - //#define AXISTEST_X2(a, b, fa, fb) - p0 = e2[2]*v0[1] - e2[1]*v0[2]; - p1 = e2[2]*v1[1] - e2[1]*v1[2]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y1(e2[2], e2[0], fez, fex); - //#define AXISTEST_Y1(a, b, fa, fb) - p0 = -e2[2]*v0[0] + e2[0]*v0[2]; - p1 = -e2[2]*v1[0] + e2[0]*v1[2]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z12(e2[1], e2[0], fey, fex); - //#define AXISTEST_Z12(a, b, fa, fb) - p1 = e2[1]*v1[0] - e2[0]*v1[1]; - p2 = e2[1]*v2[0] - e2[0]*v2[1]; - if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[1]; - if(min>rad || max<-rad) return 0; - - /* Bullet 1: */ - /* first test overlap in the {x,y,z}-directions */ - /* find min, max of the triangle each direction, and test for overlap in */ - /* that direction -- this is equivalent to testing a minimal AABB around */ - /* the triangle against the AABB */ - /* test in X-direction */ - //FINDMINMAX(v0[0],v1[0],v2[0],min,max); - min = (float)UbMath::min(v0[0],v1[0],v2[0]); - max = (float)UbMath::max(v0[0],v1[0],v2[0]); - if(min>boxhalfsize[0] || max<-boxhalfsize[0]) return 0; - - /* test in Y-direction */ - //FINDMINMAX(v0[1],v1[1],v2[1],min,max); - min = (float)UbMath::min(v0[1],v1[1],v2[1]); - max = (float)UbMath::max(v0[1],v1[1],v2[1]); - if(min>boxhalfsize[1] || max<-boxhalfsize[1]) return 0; - - /* test in Z-direction */ - //FINDMINMAX(v0[2],v1[2],v2[2],min,max); - min = (float)UbMath::min(v0[2],v1[2],v2[2]); - max = (float)UbMath::max(v0[2],v1[2],v2[2]); - - if(min>boxhalfsize[2] || max<-boxhalfsize[2]) return 0; - - /* Bullet 2: */ - /* test if the box intersects the plane of the triangle */ - /* compute plane equation of triangle: normal*x+d=0 */ - //CROSS(normal,e0,e1); - //#define CROSS(dest,v1,v2) - normal[0]=e0[1]*e1[2]-e0[2]*e1[1]; - normal[1]=e0[2]*e1[0]-e0[0]*e1[2]; - normal[2]=e0[0]*e1[1]-e0[1]*e1[0]; - - // -NJMP- (line removed here) - if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0; // -NJMP- - return 1; /* box and triangle overlaps */ - } - - - -}; - -#endif - -//original - NICHT LOESCHEN - von kroete lynn - -//#define X 0 -//#define Y 1 -//#define Z 2 -// -//#define CROSS(dest,v1,v2) -// dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; -// dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; -// dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; -// -//#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) -// -//#define SUB(dest,v1,v2) -// dest[0]=v1[0]-v2[0]; -// dest[1]=v1[1]-v2[1]; -// dest[2]=v1[2]-v2[2]; -// -//#define FINDMINMAX(x0,x1,x2,min,max) -// min = max = x0; -// if(x1<min) min=x1; -// if(x1>max) max=x1; -// if(x2<min) min=x2; -// if(x2>max) max=x2; -// -//int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3]) // -NJMP- -//{ -// int q; -// float vmin[3],vmax[3],v; -// -// for(q=X;q<=Z;q++) -// { -// v=vert[q]; // -NJMP- -// if(normal[q]>0.0f) -// { -// vmin[q]=-maxbox[q] - v; // -NJMP- -// vmax[q]= maxbox[q] - v; // -NJMP- -// } -// else -// { -// vmin[q]= maxbox[q] - v; // -NJMP- -// vmax[q]=-maxbox[q] - v; // -NJMP- -// } -// } -// if(DOT(normal,vmin)>0.0f) return 0; // -NJMP- -// if(DOT(normal,vmax)>=0.0f) return 1; // -NJMP- -// return 0; -//} -// -///*======================== X-tests ======================== -// -//#define AXISTEST_X01(a, b, fa, fb) -// p0 = a*v0[Y] - b*v0[Z]; -// p2 = a*v2[Y] - b*v2[Z]; -// if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} -// rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_X2(a, b, fa, fb) -// p0 = a*v0[Y] - b*v0[Z]; -// p1 = a*v1[Y] - b*v1[Z]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -// -// -///*======================== Y-tests ======================== -// -//#define AXISTEST_Y02(a, b, fa, fb) -// p0 = -a*v0[X] + b*v0[Z]; -// p2 = -a*v2[X] + b*v2[Z]; -// if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_Y1(a, b, fa, fb) -// p0 = -a*v0[X] + b*v0[Z]; -// p1 = -a*v1[X] + b*v1[Z]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//======================== Z-tests ======================== -// -//#define AXISTEST_Z12(a, b, fa, fb) -// p1 = a*v1[X] - b*v1[Y]; -// p2 = a*v2[X] - b*v2[Y]; -// if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_Z0(a, b, fa, fb) -// p0 = a*v0[X] - b*v0[Y]; -// p1 = a*v1[X] - b*v1[Y]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; -// if(min>rad || max<-rad) return 0; -// -//int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3]) -//{ -// //use separating axis theorem to test overlap between triangle and box -// //need to test for overlap in these directions: -// //1) the {x,y,z}-directions (actually, since we use the AABB of the triangle -// // we do not even need to test these) -// //2) normal of the triangle -// //3) crossproduct(edge from tri, {x,y,z}-directin) -// // this gives 3x3=9 more tests -// -// float v0[3],v1[3],v2[3]; -// -// // float axis[3]; -// -// float min,max,p0,p1,p2,rad,fex,fey,fez; // -NJMP- "d" local variable removed -// float normal[3],e0[3],e1[3],e2[3]; -// -// /* This is the fastest branch on Sun */ -// /* move everything so that the boxcenter is in (0,0,0) */ -// SUB(v0,triverts[0],boxcenter); -// SUB(v1,triverts[1],boxcenter); -// SUB(v2,triverts[2],boxcenter); -// -// /* compute triangle edges */ -// SUB(e0,v1,v0); /* tri edge 0 */ -// SUB(e1,v2,v1); /* tri edge 1 */ -// SUB(e2,v0,v2); /* tri edge 2 */ -// -// /* Bullet 3: */ -// /* test the 9 tests first (this was faster) */ -// fex = fabsf(e0[X]); -// fey = fabsf(e0[Y]); -// fez = fabsf(e0[Z]); -// -// AXISTEST_X01(e0[Z], e0[Y], fez, fey); -// AXISTEST_Y02(e0[Z], e0[X], fez, fex); -// AXISTEST_Z12(e0[Y], e0[X], fey, fex); -// fex = fabsf(e1[X]); -// fey = fabsf(e1[Y]); -// fez = fabsf(e1[Z]); -// -// AXISTEST_X01(e1[Z], e1[Y], fez, fey); -// AXISTEST_Y02(e1[Z], e1[X], fez, fex); -// AXISTEST_Z0(e1[Y], e1[X], fey, fex); -// -// fex = fabsf(e2[X]); -// fey = fabsf(e2[Y]); -// fez = fabsf(e2[Z]); -// AXISTEST_X2(e2[Z], e2[Y], fez, fey); -// AXISTEST_Y1(e2[Z], e2[X], fez, fex); -// AXISTEST_Z12(e2[Y], e2[X], fey, fex); -// -// /* Bullet 1: */ -// /* first test overlap in the {x,y,z}-directions */ -// /* find min, max of the triangle each direction, and test for overlap in */ -// /* that direction -- this is equivalent to testing a minimal AABB around */ -// /* the triangle against the AABB */ -// /* test in X-direction */ -// FINDMINMAX(v0[X],v1[X],v2[X],min,max); -// if(min>boxhalfsize[X] || max<-boxhalfsize[X]) return 0; -// -// /* test in Y-direction */ -// FINDMINMAX(v0[Y],v1[Y],v2[Y],min,max); -// if(min>boxhalfsize[Y] || max<-boxhalfsize[Y]) return 0; -// -// /* test in Z-direction */ -// FINDMINMAX(v0[Z],v1[Z],v2[Z],min,max); -// if(min>boxhalfsize[Z] || max<-boxhalfsize[Z]) return 0; -// -// /* Bullet 2: */ -// /* test if the box intersects the plane of the triangle */ -// /* compute plane equation of triangle: normal*x+d=0 */ -// CROSS(normal,e0,e1); -// -// // -NJMP- (line removed here) -// if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0; // -NJMP- -// return 1; /* box and triangle overlaps */ -//} - diff --git a/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp deleted file mode 100644 index 85f0332e1443d9c8cc593f78c9bf494f8b807af2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <basics/utilities/UbMath.h> - -using namespace std; - -string GbObject3D::getTypeID() -{ - return this->getCreator()->getTypeID(); -} -/*======================================================================*/ -bool GbObject3D::isPointInGbObject3D(GbPoint3D* p) -{ - return this->isPointInGbObject3D(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate()); -} -/*======================================================================*/ -bool GbObject3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - - if( this->isPointInGbObject3D(x1a, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2b, x3b) - && this->isPointInGbObject3D(x1a, x2b, x3b)) - { - return true; - } - - return false; -} -/*======================================================================*/ -bool GbObject3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - if( this->isPointInGbObject3D(x1a, x2a, x3a) - || this->isPointInGbObject3D(x1b, x2a, x3a) - || this->isPointInGbObject3D(x1b, x2b, x3a) - || this->isPointInGbObject3D(x1a, x2b, x3a) - || this->isPointInGbObject3D(x1a, x2a, x3b) - || this->isPointInGbObject3D(x1b, x2a, x3b) - || this->isPointInGbObject3D(x1b, x2b, x3b) - || this->isPointInGbObject3D(x1a, x2b, x3b) ) - { - if( !this->isPointInGbObject3D(x1a, x2a, x3a) - || !this->isPointInGbObject3D(x1b, x2a, x3a) - || !this->isPointInGbObject3D(x1b, x2b, x3a) - || !this->isPointInGbObject3D(x1a, x2b, x3a) - || !this->isPointInGbObject3D(x1a, x2a, x3b) - || !this->isPointInGbObject3D(x1b, x2a, x3b) - || !this->isPointInGbObject3D(x1b, x2b, x3b) - || !this->isPointInGbObject3D(x1a, x2b, x3b)) return true; - } - return false; -} -/*======================================================================*/ -bool GbObject3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - if( this->isPointInGbObject3D(x1a, x2a, x3a) - || this->isPointInGbObject3D(x1b, x2a, x3a) - || this->isPointInGbObject3D(x1b, x2b, x3a) - || this->isPointInGbObject3D(x1a, x2b, x3a) - || this->isPointInGbObject3D(x1a, x2a, x3b) - || this->isPointInGbObject3D(x1b, x2a, x3b) - || this->isPointInGbObject3D(x1b, x2b, x3b) - || this->isPointInGbObject3D(x1a, x2b, x3b)) - { - return true; - } - - return false; -} -/*=======================================================*/ -bool GbObject3D::isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3) -{ - if( UbMath::greaterEqual(this->getX1Minimum(),minX1) - && UbMath::greaterEqual(this->getX2Minimum(),minX2) - && UbMath::greaterEqual(this->getX3Minimum(),minX3) - && UbMath::lessEqual(this->getX1Maximum(),maxX1) - && UbMath::lessEqual(this->getX2Maximum(),maxX2) - && UbMath::lessEqual(this->getX2Maximum(),maxX3) ) return true; - - return false; -} - - diff --git a/ThirdParty/Library/numerics/geometry3d/GbObject3D.h b/ThirdParty/Library/numerics/geometry3d/GbObject3D.h deleted file mode 100644 index 48cb40af7f284f988f991d7a87ad2dc6802ac8b0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObject3D.h +++ /dev/null @@ -1,173 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECT3D_H -#define GBOBJECT3D_H - -#include <string> -#include <vector> - - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbObservable.h> -#include <basics/utilities/UbTuple.h> -#include <basics/objects/ObObject.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -#ifdef CAB_CTL -#include <ctl.h> -#endif - -#include <basics/memory/MbSharedPointerDefines.h> -class GbObject3D; -typedef VFSharedPtr<GbObject3D> GbObject3DPtr; - - -/*=========================================================================*/ -/* GbObject3D */ -/* */ -/** - * This Interface provides basic 3D geometry objects methods. - * <BR><BR><HR> - * @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> - * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> - * @version 1.0 - 02.02.05 -*/ -class GbObject3D : public ObObject -{ -public: -#ifdef CAB_CTL - virtual ctl::oStream &write(ctl::oStream &os) const - { - return os; - } - virtual ctl::iStream &read(ctl::iStream &is) - { - return is; - } -#endif - - virtual ~GbObject3D(){} - - //ueberschriebene methode von ObObject - virtual std::string getTypeID(); - - //abstract Methods - virtual void finalize() =0 ; //detroys also all dynamic objects (e.g. GbPoints in GbLine) - virtual ObObjectCreator* getCreator()=0; - - /** - * Returns the centroid x1 coordinate of this 3D object. - * @return the centroid x1 coordinate of this 3D object - */ - virtual double getX1Centroid()=0; - /** - * Returns the minimum x1 coordinate of this 3D object. - * @return the minimum x1 coordinate of this 3D object - */ - virtual double getX1Minimum()=0; - /** - * Returns the maximum x1 coordinate of this 3D object. - * @return the maximum x1 coordinate of this 3D object - */ - virtual double getX1Maximum()=0; - /** - * Returns the centroid x2 coordinate of this 3D object. - * @return the centroid x2 coordinate of this 3D object - */ - virtual double getX2Centroid()=0; - /** - * Returns the minimum x2 coordinate of this 3D object. - * @return the minimum x2 coordinate of this 3D object - */ - virtual double getX2Minimum()=0; - /** - * Returns the maximum x2 coordinate of this 3D object. - * @return the maximum x2 coordinate of this 3D object - */ - virtual double getX2Maximum()=0; - - virtual double getX3Centroid()=0; - /** - * Returns the minimum x2 coordinate of this 3D object. - * @return the minimum x2 coordinate of this 3D object - */ - virtual double getX3Minimum()=0; - /** - * Returns the maximum x2 coordinate of this 3D object. - * @return the maximum x2 coordinate of this 3D object - */ - virtual double getX3Maximum()=0; - - /*=======================================================*/ - double getLengthX1() { return (getX1Maximum()-getX1Minimum()); } - double getLengthX2() { return (getX2Maximum()-getX2Minimum()); } - double getLengthX3() { return (getX3Maximum()-getX3Minimum()); } - - virtual void setCenterX1Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void setCenterX2Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void setCenterX3Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void setCenterCoordinates(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - //Rotates the Point in relation to the origen. - //Parameters must be radian measure. - virtual void rotate(const double& rx1, const double& rx2, const double& rx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void translate(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void scale(const double& sx1, const double& sx2, const double& sx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - virtual void write(UbFileOutput* out)=0; - virtual void read(UbFileInput* in)=0; - - virtual bool isPointInGbObject3D(GbPoint3D* p); - virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)=0; - virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)=0; - - virtual bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - virtual bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - virtual bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - virtual double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b){ return -1.0;}; - - virtual bool isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3); - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2)=0; - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet()=0; - - virtual void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) { throw UbException("GbObject3D::addSurfaceTriangleSet - not implemented for "+(std::string)typeid(*this).name()); } - - virtual bool hasRaytracing() { return false; } - virtual bool raytracingSupportsPointsInside() { return false; } - //|r| must be 1! einheitsvector!! - //return negativ value oder zero if no intersection - virtual double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { throw UbException("GbObject3D::getIntersectionRaytraceFactor - not implemented"); } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<ObObject>(ar, *this); - } -#endif //CAB_RCF -}; -/*=========================================================================*/ - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - SF_NO_CTOR(GbObject3D); - UB_AUTO_RUN_NAMED(SF::registerType<GbObject3D>("GbObject3D") , SF_GbObject3D); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<ObObject, GbObject3D >() ), SF_GbObject3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp b/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp deleted file mode 100644 index 38fc910e8b5223295677abaf1e87c217f411da3d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp +++ /dev/null @@ -1,285 +0,0 @@ -#include <numerics/geometry3d/GbObject3DManager.h> -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/creator/GbObject3DFactory.h> - -using namespace std; - -GbObject3DEntry::GbObject3DEntry(GbObject3DManager *parent, GbObject3D *geoObject, bool active, string name):ObObjectEntry(parent, geoObject) -{ - //this->parent = parent; - //this->geoObject = geoObject; - this->active = active; - this->name = name; -} - -/*======================================================*/ -/*== nun halt der Manager ====*/ -/*======================================================*/ - -GbObject3DManager::GbObject3DManager(): ObObjectManager() -{ - this->tableModel = new GbObject3DTableModel(this); -} -/*======================================================*/ -GbObject3DManager::~GbObject3DManager() -{ -// this->gbObject3DList.clear(); -} -/*======================================================*/ -ObObjectFactory* GbObject3DManager::getObObjectFactory() -{ - return GbObject3DFactory::getInstance(); -} - -/*======================================================*/ -ObObjectEntry* GbObject3DManager::createNewObObjectEntry(ObObject *obj) -{ - GbObject3D *geoobject = dynamic_cast<GbObject3D*>(obj); - return new GbObject3DEntry(this, geoobject, true, geoobject->getTypeID()); -} - -/*======================================================*/ -//UbTableModel* GbObject3DManager::getTableModel() -//{ -// return this->tablemodel; -//} - -/*======================================================*/ -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject) -//{ -// return this->addGbObject3D(geoObject, true, "GeoObject"); -//} -// -///*======================================================*/ -bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, string name) -{ - GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); - return ObObjectManager::addObObjectEntry(entry); -} -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, bool active, string name) -//{ -// GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); -// return ObObjectManager::addObObjectEntry(entry); -//} -// -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(GbObject3D *geoObject) -{ - return ObObjectManager::removeObObject(geoObject); -} -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(int index) -{ - return ObObjectManager::removeObObject(index); -} -/*======================================================*/ -//void GbObject3DManager::removeAllGbObject3Ds() -//{ -// this->gbObject3DList.clear(); -//} -/*======================================================*/ -int GbObject3DManager::getNumberOfGbObject3Ds() -{ - return GbObject3DManager::getNumberOfObObjects(); -} -/*======================================================*/ -vector<GbObject3D*>* GbObject3DManager::getAllGbObject3Ds() -{ - throw UbException(UB_EXARGS,"not implemented"); - //vector<GbObject3D*> *geoVektor = new vector<GbObject3D*>; - //for(int u=0; u<(int)this->gbObject3DList.size();u++) - //{ - // GbObject3D* geoObject = dynamic_cast<GbObject3D*>((gbObject3DList)[u]->getObject()); - // geoVektor->push_back(geoObject); - //} - //return geoVektor; -} -/*======================================================*/ -GbObject3D* GbObject3DManager::getGbObject3D(int index) -{ - if(index < 0) return NULL; - if(index >= this->getNumberOfObObjects()) return NULL; - - GbObject3D* geoObject = dynamic_cast<GbObject3D*>(this->getObObject(index)); - return(geoObject); -} -/*======================================================*/ -//GbObject3DEntry* GbObject3DManager::getGbObject3DEntry(int index) -//{ -// if(index < 0) return NULL; -// if(index >= (int)this->gbObject3DList.size()) return NULL; -// -// return((this->gbObject3DList)[index]); -//} -/*====================================================*/ -void GbObject3DManager::write(UbFileOutput *out) -{ - int size = this->getNumberOfObObjects(); - out->writeInteger(size); - out->writeString("// #GbObjects"); - - GbObject3D *geoObject; - for(int pos=0; pos<size; pos++) - { - out->writeLine(); - geoObject = dynamic_cast<GbObject3D*>(this->getObObject(pos)); - cout<<pos<<".:"<<geoObject->toString()<<endl; - geoObject->write(out); - } -} -/*======================================================================*/ -void GbObject3DManager::read(UbFileInput *in) -{ - this->removeAllObObjects(); - - int n = in->readInteger(); - - cout<<"GbObject3DManager::read "<<n<<" GbObject3Ds\n"; - GbObject3D *geoObject; - for(int pos=1; pos<=n; pos++) - { - in->readLine(); - cout<<" - GbObject3D "<<pos<<" ..."; - geoObject = GbObject3DFactory::getInstance()->createGbObject3D(in); - - GbObject3DEntry *entry = new GbObject3DEntry(this, geoObject, true, "GeoObject"); - this->addObObjectEntry(entry); - cout<<"done\n"; - } -} -/*======================================================*/ -string GbObject3DManager::toString() -{ - stringstream ss; ss<<endl; - - int size = this->getNumberOfObObjects(); - for(int pos=0; pos<size; pos++) - { - ObObject* geoObject = this->getObObject(pos); - ss<<(pos+1)<<". "<<geoObject->toString()<<endl; - } - string back = ss.str(); - return back; -} - -/*======================================================*/ -/*======================================================*/ -/*======================================================*/ - -GbObject3DTableModel::GbObject3DTableModel(GbObject3DManager* manager) -{ - this->objectManager = manager; -} - -/*======================================================*/ -GbObject3DTableModel::~GbObject3DTableModel(void) -{ -} - -/*======================================================*/ -//Gibt die Anzahl der Spalten zurueck. -int GbObject3DTableModel::getColumnNumber() -{ - return 3; -} - -/*======================================================*/ -std::string GbObject3DTableModel::getColumnLabel(int column) -{ - switch(column) - { - case COL_NAME: return "Name"; - case COL_TYPE: return "Type"; - case COL_ACTIVE: return "Active"; - default: throw UbException(UB_EXARGS,"falscher Spaltenindex"); - } -} - -/*======================================================*/ -int GbObject3DTableModel::getRowNumber() -{ - return this->objectManager->getNumberOfGbObject3Ds(); -} -/*======================================================*/ -int GbObject3DTableModel::getSelectedRowIndex() -{ - return 0; - // return this->objectManager->getSelectedIndex(); -} - -/*======================================================*/ -int GbObject3DTableModel::getColumnType(int column) -{ - switch(column) { - case COL_NAME : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_TYPE : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_ACTIVE : - return UbTableModel::COL_TYPE_BOOL; - break; - } - return -1; -} - -//Gibt den Eintag der Tabelle an der angegebenen Spalten- und -//Zeilenposition in Form eines String Werts zurueck. -std::string GbObject3DTableModel::getStringValue(int row, int col) -{ - GbObject3DEntry* gbObjEntry = dynamic_cast<GbObject3DEntry*>(this->objectManager->getObObjectEntry(row)); - switch(col) { - case COL_NAME: - return gbObjEntry->name; - break; - case COL_TYPE: - return gbObjEntry->getObject()->getTypeID(); - break; - case COL_ACTIVE: - if ( gbObjEntry->active ) return "True"; - return "False"; - break; - } - return "Fehler"; -} - -/*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(int index) -//{ -// cout<<"GbObject3DManager::selectGbObject3D(int index):"<<index<<endl; -// if (index > (int)this->gbObject3DList.size()-1 || index < 0) return false; -// if ( this->selectedObject == this->getGbObject3D(index) ) return true; -// this->selectedObject = this->getGbObject3D(index); -// this->notifyObserversObjectChanged(); -// return true; -//} -///*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(GbObject3D* geoObject) -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==geoObject) -// { -// return this->selectGbObject3D(pos); -// } -// } -// return false; -//} -///*======================================================*/ -//GbObject3D* GbObject3DManager::getSelectedGbObject3D() -//{ -// return this->selectedObject; -//} -///*======================================================*/ -//int GbObject3DManager::getSelectedIndex() -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==this->selectedObject) -// { -// return pos; -// } -// } -// return -1; -//} diff --git a/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h b/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h deleted file mode 100644 index c842ddaff866fa615da8393d80d8c728290e3ffd..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h +++ /dev/null @@ -1,122 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECT3DMANAGER_H -#define GBOBJECT3DMANAGER_H - -#include <string> -#include <sstream> -#include <vector> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbTableModel.h> -#include <basics/objects/ObObjectManager.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbObject3DManager; -typedef VFSharedPtr<GbObject3DManager> GbObject3DManagerPtr; - - -class GbObject3D; -class GbObject3DManager; -class GbObject3DTableModel; - -class GbObject3DEntry : public ObObjectEntry -{ - friend class GbObject3DManager; - friend class GbObject3DTableModel; -public: - std::string getName() { return this->name;} -private: - //GbObject3DManager *parent; - //GbObject3D *geoObject; - bool active; - std::string name; - - - GbObject3DEntry(GbObject3DManager* parent, GbObject3D* geoObject, bool active, std::string name); - -}; - - -class GbObject3DManager : public ObObjectManager -{ -public: - GbObject3DManager(); - ~GbObject3DManager(); - - ObObjectEntry* createNewObObjectEntry(ObObject *obj); - ObObjectFactory* getObObjectFactory(); - - - //bool addGbObject3D(GbObject3D *geoObject3D); - bool addGbObject3D(GbObject3D *geoObject3D, std::string name); - //bool addGbObject3D(GbObject3D *geoObject3D, bool active, std::string name); - - bool removeGbObject3D(GbObject3D *geoObject3D); - bool removeGbObject3D(int index); - - int getNumberOfGbObject3Ds(); - std::vector<GbObject3D*>* getAllGbObject3Ds(); - GbObject3D* getGbObject3D(int index); - - //keine Definition dafuer da ... - //void writeValidationAVSFile(string filename); - //void writeSurfaceAVSFile(string filename); - - //public final OctConstructionDescriptor[] getAllActiveConstructions() - //public final OctSpecificConstructionInstrument getSpecificConstructionInstrumentInstance(int index) - //public final boolean isConstructionActive(int index) - //public final boolean isConstructionVisible(int index) - //public final void activateConstruction(int index, boolean active) - //public final void visibleConstruction(int index, boolean visible) - // UbTableModel* getTableModel(); - //void objectChanged(UbObservable* observable); - //void objectWillBeDeleted(UbObservable* observable); - - - void read(UbFileInput *in); - void write(UbFileOutput *out); - - std::string toString(); - -private: - //GbObject3DTableModel* tablemodel; - // GbObject3D* selectedObject; - //vector<GbObject3DEntry*> gbObject3DList; -}; - -class GbObject3DTableModel : public UbTableModel -{ -public: - - static const int COL_NAME = 0; - static const int COL_TYPE = 1; - static const int COL_ACTIVE = 2; - - GbObject3DTableModel(GbObject3DManager* manager); - ~GbObject3DTableModel(void); - - ////////////////////////////////////////////////////////////////////////// - //Geerbt von CabTable - int getColumnNumber(void); - int getRowNumber(); - - std::string getColumnLabel(int column); - - int getColumnType(int); - std::string getStringValue(int row, int col); - int getSelectedRowIndex(); - //bool GetBoolValue(int row, int col); - void setStringValue(int row, int col, std::string str) { throw UbException(UB_EXARGS,"not implemented"); } - -protected: - GbObject3DManager* objectManager; -}; - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp deleted file mode 100644 index 3e8c4087d537ae4c0bcf03155b032c459ade327f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include <numerics/geometry3d/GbObjectGroup3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -/*=====================================================*/ -GbObjectGroup3D::GbObjectGroup3D() -{ - this->setName("ObjectGroup"); -} -/*=====================================================*/ -GbObjectGroup3D::~GbObjectGroup3D() -{ -} -/*=====================================================*/ -void GbObjectGroup3D::finalize() -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=======================================================*/ -void GbObjectGroup3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -double GbObjectGroup3D::getDistance(GbPoint3D* p) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ - -void GbObjectGroup3D::setCenterX1Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setCenterX2Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setCenterX3Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setRadius(const double& radius) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -double GbObjectGroup3D::getDistance(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - return false; -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - return false; -} -/*=====================================================*/ -string GbObjectGroup3D::toString() -{ - stringstream ss; - ss<< "GbObjectGroup3D["; - ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]"; - return ss.str(); -} -/*=====================================================*/ -GbLine3D* GbObjectGroup3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - return NULL; -} -/*=========================================================================*/ -vector<GbTriangle3D*> GbObjectGroup3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> allTriangles; - - //loop ueber alle objekte in der group - for( std::list< GbObject3D* >::iterator iter = this->geoobjects.begin(); - iter != this->geoobjects.end(); - iter++ ) - { - vector<GbTriangle3D*> triangles; - triangles = (*iter)->getSurfaceTriangleSet(); - - for( size_t i=0;i<triangles.size(); i++ ) - { - //kopieren... - allTriangles.push_back( triangles[i] ); - } - } - return allTriangles; -} -/*=======================================================*/ -void GbObjectGroup3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ -} -/*=======================================================*/ -void GbObjectGroup3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbObjectGroup3D::read(UbFileInput* in) -{ -} -/*=======================================================*/ -bool GbObjectGroup3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) -{ - return false; -} -/*=======================================================*/ -bool GbObjectGroup3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return false; -} -/*=======================================================*/ -bool GbObjectGroup3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return false; -} -/*==========================================================*/ -double GbObjectGroup3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return 0.0; -} -/*==========================================================*/ -double GbObjectGroup3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - return 0.0; -} -/*=======================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h b/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h deleted file mode 100644 index 52ffdcf7c6ec5e0261d41ff9b38337b193c1e423..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h +++ /dev/null @@ -1,162 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECTGROUP3D_H -#define GBOBJECTGROUP3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF -#ifdef CAB_CTL - #include <ctl.h> -#endif //CAB_CTL - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbObjectGroup3D; -typedef VFSharedPtr<GbObjectGroup3D> GbObjectGroup3DPtr; - - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbObjectGroup3D : public GbObject3D, public UbObserver -{ -public: - enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION }; - - ////////////////////////////////////////////////////////////////////////// - // Konstruktoren - GbObjectGroup3D(); - GbObjectGroup3D(GbObjectGroup3D *group){}; - ~GbObjectGroup3D(); - - GbObjectGroup3D* clone() {return new GbObjectGroup3D(this);} - void finalize(); - - void addGbObject(GbObject3D* object) - { - this->geoobjects.push_back(object); - } - - double getRadius() const { return this->radius; } - - double getX1Centroid() { return midPoint->getX1Coordinate();} - double getX1Minimum() { return midPoint->getX1Coordinate()-radius;} - double getX1Maximum() { return midPoint->getX1Coordinate()+radius;} - double getX2Centroid() { return midPoint->getX2Coordinate();} - double getX2Minimum() { return midPoint->getX2Coordinate()-radius;} - double getX2Maximum() { return midPoint->getX2Coordinate()+radius;} - double getX3Centroid() { return midPoint->getX3Coordinate();} - double getX3Minimum() { return midPoint->getX3Coordinate()-radius;} - double getX3Maximum() { return midPoint->getX3Coordinate()+radius;} - - void setCenterX1Coordinate(const double& value); - void setCenterX2Coordinate(const double& value); - void setCenterX3Coordinate(const double& value); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - void setRadius(const double& radius); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - double getDistance(GbPoint3D* p); - double getDistance(const double& x1p, const double& x2p, const double& x3p); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - - 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); - - 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); - - bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction); - - std::string toString(); - - ObObjectCreator* getCreator(){ return NULL; }; - void write(UbFileOutput* out); - void read(UbFileInput* in); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->midPoint->translate(x1, x2, x3); - this->notifyObserversObjectChanged(); - } - void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ } - void scale(const double& sx1, const double& sx2, const double& sx3) { this->radius *= sx1; } - - TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;} - void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; } - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) - { - this->notifyObserversObjectChanged(); - //std::cout<<"GbSphere:objectChanged() - toDo-);"; - } - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - std::cout<<"throw UbException(-GbObjectGroup3D::finalize() - toDo-);"; - } - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine - - std::list< GbObject3D* > getGbObject3DList() { return this->geoobjects; } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - ar & geoobjects; - } -#endif //CAB_RCF -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - midPoint->write(os); - return os<<radius; - } - ctl::iStream &read(ctl::iStream &is) - { - midPoint->read(is); - return is>>radius; - } -#endif //CAB_CTL - -private: - GbPoint3D* midPoint; - double radius; // Radius des Kreises - TRIANGULATIONMODE triangulationMode; - - std::list< GbObject3D* > geoobjects; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) - SF_SERIALIZE_ENUM(GbObjectGroup3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbObjectGroup3D>("GbObjectGroup3D") , SF_GbObjectGroup3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbObjectGroup3D >()), SF_GbObjectGroup3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GbObjectGroup3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp deleted file mode 100644 index 980fcf386f20cb0e64c56e0301bbc23995b269e4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include <numerics/geometry3d/GbPoint3D.h> -//#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/creator/GbPoint3DCreator.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* GbPoint3D::getCreator() -{ - return GbPoint3DCreator::getInstance(); -} -/*=======================================================*/ -GbPoint3D::GbPoint3D() -{ - this->x1=0.0; - this->x2=0.0; - this->x3=0.0; -} -/*=======================================================*/ -GbPoint3D::GbPoint3D(const double& x1, const double& x2, const double& x3) -{ - this->x1=x1; - this->x2=x2; - this->x3=x3; -} -/*=======================================================*/ -GbPoint3D::GbPoint3D(GbPoint3D* point) -{ - this->x1 = point->x1; - this->x2 = point->x2; - this->x3 = point->x3; -} -/*=======================================================*/ -double GbPoint3D::getDistance(GbPoint3D* p) -{ - double dx1 = this->x1 - p->x1; - double dx2 = this->x2 - p->x2; - double dx3 = this->x3 - p->x3; - return std::sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3); -} -/*=======================================================*/ -bool GbPoint3D::equals(const GbPoint3D* point) const -{ - if(fabs(this->x1-point->x1)>1.E-10) return false; - if(fabs(this->x2-point->x2)>1.E-10) return false; - if(fabs(this->x3-point->x3)>1.E-10) return false; - - return true; -} -/*=======================================================*/ -void GbPoint3D::transform(const double matrix[4][4]) -{ - double tempX1 = x1; - double tempX2 = x2; - double tempX3 = x3; - x1 = matrix[0][0] * tempX1 + matrix[0][1] * tempX2 + matrix[0][2] * tempX3 + matrix[0][3] * 1.; - x2 = matrix[1][0] * tempX1 + matrix[1][1] * tempX2 + matrix[1][2] * tempX3 + matrix[1][3] * 1.; - x3 = matrix[2][0] * tempX1 + matrix[2][1] * tempX2 + matrix[2][2] * tempX3 + matrix[2][3] * 1.; -} -/*=======================================================*/ -bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - return (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 ); -} -/*=======================================================*/ -bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - pointIsOnBoundary = (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 ); - return pointIsOnBoundary; -} -/*=======================================================*/ -vector<GbTriangle3D*> GbPoint3D::getSurfaceTriangleSet() -{ - cout<<"GbPoint3D::getSurfaceTriangleSet() - test ... if no exception occurs, everything is fine\n"; - vector<GbTriangle3D*> triangles; - return triangles; //<-empty vector! is okay! - - //old: - //to avoid unnecessary exceptions a point will generate a triangle with - //three point with same coordinates - //vector<GbTriangle3D*> triangles; - //GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate()); - //triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1))); -} -/*=======================================================*/ -GbLine3D* GbPoint3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ -string GbPoint3D::toString() -{ - stringstream ss; - ss<<"GbPoint3D["<<this->x1<<","<<this->x2<<","<<this->x3<<"]"; - return((ss.str()).c_str()); -} -/*=======================================================*/ -void GbPoint3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(x1); - out->writeDouble(x2); - out->writeDouble(x3); -} -/*=======================================================*/ -void GbPoint3D::read(UbFileInput* in) -{ - x1=in->readDouble(); - x2=in->readDouble(); - x3=in->readDouble(); -} -/*=======================================================*/ -void GbPoint3D::translate(const double& dx1, const double& dx2, const double& dx3) -{ - this->x1 += dx1; - this->x2 += dx2; - this->x3 += dx3; - // wenn Notify hier dann nicht im Cuboid oder spher translate ?! - //sollte eigentlich! - //--> hier muss notify aufgerufen werden udn rekuriv dann z.B. Cuboid, etc - - //aber da ist halt einfach daemlich, ich asse es auf gellers way... (erstmal) - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbPoint3D::rotate(const double& rx1, const double& rx2, const double& rx3) -{ - double newX1 = cos(rx3)*cos(rx2)*x1-x2*sin(rx3)*cos(rx1)+x2*cos(rx3)*sin(rx2)*sin(rx1)+x3*sin(rx3)*sin(rx1)+x3*cos(rx3)*sin(rx2)*cos(rx1); - double newX2 = sin(rx3)*cos(rx2)*x1+x2*cos(rx3)*cos(rx1)+x2*sin(rx3)*sin(rx2)*sin(rx1)-x3*cos(rx3)*sin(rx1)+x3*sin(rx3)*sin(rx2)*cos(rx1); - double newX3 = -sin(rx2)*x1+cos(rx2)*sin(rx1)*x2+cos(rx2)*cos(rx1)*x3; - - this->x1 = newX1; - this->x2 = newX2; - this->x3 = newX3; - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbPoint3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - this->x1 *= sx1; - this->x2 *= sx2; - this->x3 *= sx3; - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ - diff --git a/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h b/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h deleted file mode 100644 index 5cccbc1718b10321867742def359e18109afeb8d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h +++ /dev/null @@ -1,123 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBPOINT3D_H -#define GBPOINT3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <string> -#include <sstream> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbPoint3D; -typedef VFSharedPtr<GbPoint3D> GbPoint3DPtr; - - -class GbTriangle3D; -class GbObject3DCreator; - -#ifdef CAB_CTL - #include <ctl.h> -#endif - -class GbPoint3D : public GbObject3D -{ -public: - GbPoint3D(); - GbPoint3D(const double& x1, const double& x2, const double& x3); - GbPoint3D(GbPoint3D *point); - ~GbPoint3D() {} - - GbPoint3D* clone() {return new GbPoint3D(this);} - void finalize() {} - - void setCoordinates(const double& x1, const double& x2, const double& x3) - { - this->x1=x1; - this->x2=x2; - this->x3=x3; - this->notifyObserversObjectChanged(); - } - void setX1(const double& x1) { this->x1=x1; this->notifyObserversObjectChanged(); } - void setX2(const double& x2) { this->x2=x2; this->notifyObserversObjectChanged(); } - void setX3(const double& x3) { this->x3=x3; this->notifyObserversObjectChanged(); } - - double getX1Coordinate() const { return this->x1; } - double getX2Coordinate() const { return this->x2; } - double getX3Coordinate() const { return this->x3; } - - void transform(const double matrix[4][4]); - - double getX1Centroid() { return this->x1; } - double getX1Minimum() { return this->x1; } - double getX1Maximum() { return this->x1; } - double getX2Centroid() { return this->x2; } - double getX2Minimum() { return this->x2; } - double getX2Maximum() { return this->x2; } - double getX3Centroid() { return this->x3; } - double getX3Minimum() { return this->x3; } - double getX3Maximum() { return this->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 getDistance(GbPoint3D *p); - bool equals(const GbPoint3D* point) const; - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; } - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - GbLine3D* createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2); - virtual std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren - //, welche sonst hier "ueberdeckt" waere,da es dieselbe methode mit anderen args gibt! -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & x1; - ar & x2; - ar & x3; - } -#endif //CAB_RCF - -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - return os<<x1<<x2<<x3; - } - ctl::iStream &read(ctl::iStream &is) - { - return is>>x1>>x2>>x3; - } -#endif - - //member - double x1; - double x2; - double x3; -}; - - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbPoint3D>("GbPoint3D") , SF_GbPoint3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbPoint3D >()), SF_GbPoint3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp deleted file mode 100644 index 879c6a9af274e551d306ccb99eb6a1998a7cd723..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp +++ /dev/null @@ -1,686 +0,0 @@ -#include <numerics/geometry3d/GbPolygon3D.h> -#include <numerics/geometry3d/creator/GbPolygon3DCreator.h> - -using namespace std; - -ObObjectCreator* GbPolygon3D::getCreator() -{ - return GbPolygon3DCreator::getInstance(); -} - -int GbPolygon3D::counter = 0; - -GbPolygon3D::GbPolygon3D() -{ - init(); - counter++; - this->ps = new GbSystem3D::PointSet3(0); -} -void GbPolygon3D::init() -{ - x1s = 0.0; - x2s = 0.0; - x1min = 0.0; - x1max = 0.0; - x2min = 0.0; - x2max = 0.0; - // points = NULL; - consistent = false; - ps = NULL; -} - -/** -* Creates an empty 3D polygon with the specified capacity. -* @param capacity the initial capacity -*/ -GbPolygon3D::GbPolygon3D(int capacity) -{ - init(); - counter++; - this->ps = new GbSystem3D::PointSet3(capacity); - // this.po = new PointObserver(this); -} -/** -* Creates a 3D polygon with the specified points. -* @param points the initial points of the polygon -*/ -GbPolygon3D::GbPolygon3D(vector<GbPoint3D>& points) -{ - init(); - counter++; - this->ps = new GbSystem3D::PointSet3((int)points.size()); - this->addPoints(points); -} -/** -* Creates a 3D polygon as clone of the specified 3D polygon. -* @param polygon the 3D polygon to be cloned -*/ -GbPolygon3D::GbPolygon3D(GbPolygon3D* polygon) -{ - this->init(); - counter++; - this->ps = new GbSystem3D::PointSet3((int)polygon->size()); - vector<GbPoint3D> temp = polygon->getPoints(); - this->addPoints( temp ); -} - -GbPolygon3D::~GbPolygon3D() -{ - counter--; - //if(points) - //for(unsigned u=0; u<points->size(); u++) - //{ - // delete (*points)[u]; - //} - // delete this->points; - delete this->ps; -} - -/*======================================================================*/ -/** -* Returns the number of points. -* @return the number of points -*/ -int GbPolygon3D::size() -{ - return(this->ps->size()); -} -/** -* Returns the number of times this 3D polygon contains the specified point. -* @param point the point -* @return the number of times this 3D polygon contains the specified point -*/ -int GbPolygon3D::contains(GbPoint3D* point) -{ - return(this->ps->contains(point)); -} -/** -* Returns the number of times this 3D polygon contains a point equal to the specified point. -* @param point the point -* @return the number of times this 3D polygon contains a point equal to the specified point -*/ -int GbPolygon3D::containsEqual(GbPoint3D* point) -{ - return(this->ps->containsEqual(point)); -} -/** -* Returns true, if this 3D polygon contains the specified line. -* @param point1 the first point -* @param point2 the second point -* @return true, if this 3D polygon contains the specified line -*/ -bool GbPolygon3D::containsLine(GbPoint3D* point1, GbPoint3D* point2) -{ - return(this->ps->containsLine(point1, point2)); -} -/** -* Returns true, if this 3D polygon contains the specified line. -* @param line the line -* @return true, if this 3D polygon contains the specified line -*/ -bool GbPolygon3D::containsLine(GbLine3D* line) -{ - return(this->ps->containsLine(line->getPoint1(), line->getPoint2())); -} -/** -* Returns the first point. -* @return the first point -*/ -GbPoint3D* GbPolygon3D::getFirstPoint() -{ - return(this->ps->getFirstPoint()); -} -/** -* Returns the last point. -* @return the last point -*/ -GbPoint3D* GbPolygon3D::getLastPoint() -{ - return(this->ps->getLastPoint()); -} -/** -* Returns the specified point. -* @param index the index -* @return the specified point -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -GbPoint3D* GbPolygon3D::getPoint(const int& index) -{ - if(index < 0 || index > this->ps->size()) throw UbException(UB_EXARGS,"ArrayIndexOutOfBoundsException-GbPolygon3D.getPoint()"); - return(this->ps->getPoint(index)); -} -/** -* Returns the points. -* @return the points -*/ -vector<GbPoint3D> GbPolygon3D::getPoints() -{ - if(!this->consistent) this->calculateValues(); - return(this->points); -} -/** -* Returns the points within the specified rectangle. -* @param p1 the 1st point of the rectangle -* @param p2 the 2nd point of the rectangle -* @return the points within the specified rectangle -*/ -vector<GbPoint3D> GbPolygon3D::getPoints(GbPoint3D* p1, GbPoint3D* p2) -{ - return(this->getPoints(p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); -} -/** -* Returns the points within the specified rectangle. -* @param p1x1 the 1st x1 coordinate of the rectangle -* @param p1x2 the 1st x2 coordinate of the rectangle -* @param p1x3 the 1st x3 coordinate of the rectangle -* @param p2x1 the 2nd x1 coordinate of the rectangle -* @param p2x2 the 2nd x2 coordinate of the rectangle -* @param p2x3 the 2nd x3 coordinate of the rectangle -* @return the points within the specified rectangle -*/ -vector<GbPoint3D> GbPolygon3D::getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3) -{ - double x1min, x1max, x2min, x2max, x3min, x3max; - - if(UbMath::less(p1x1, p2x1)) { x1min = p1x1; x1max = p2x1; } - else { x1min = p2x1; x1max = p1x1; } - if(UbMath::less(p1x2, p2x2)) { x2min = p1x2; x2max = p2x2; } - else { x2min = p2x2; x2max = p1x2; } - if(UbMath::less(p1x3, p2x3)) { x3min = p1x3; x3max = p2x3; } - else { x3min = p2x3; x3max = p1x3; } - - GbSystem3D::PointSet3 *pts = new GbSystem3D::PointSet3(1); - - if(!this->consistent) this->calculateValues(); - for(int i=this->size()-1; i>=0; i--) - { - if(UbMath::lessEqual(x1min, (this->points)[i].x1) && UbMath::greaterEqual(x1max, (this->points)[i].x1) && - UbMath::lessEqual(x2min, (this->points)[i].x2) && UbMath::greaterEqual(x2max, (this->points)[i].x2) && - UbMath::lessEqual(x3min, (this->points)[i].x3) && UbMath::greaterEqual(x3max, (this->points)[i].x3)) pts->add((this->points)[i]); - } - return(pts->getPoints()); -} -/** -* Returns the area of this polygon. -* The area is positive for positive ordered points, otherwise negative. -* @return the area of this polygon -*/ -//double getArea() -//{ -// if(!this.consistent) this.calculateValues(); -// return(this.area); -//} -double GbPolygon3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1s); -} -double GbPolygon3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -double GbPolygon3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -double GbPolygon3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2s); -} -double GbPolygon3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -double GbPolygon3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -double GbPolygon3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3s); -} -double GbPolygon3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -double GbPolygon3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -/** -* Adds a point to the end of this polygon. Notifies the observers of this 3D polygon. -* @param point the point -*/ -void GbPolygon3D::addPoint(GbPoint3D* point) -{ - //if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.addPoint(): points of 3D polygons have to be 3D points!"); - - this->ps->add(point); - //point.addObserver(this.po); - this->consistent = false; - //super.notifyObservers(); -} -/** -* Adds a number of points to the end of this polygon. Notifies the observers of this 3D polygon. -* @param points the points -*/ -void GbPolygon3D::addPoints(vector<GbPoint3D>& points) -{ - //if((this instanceof GbPolygon3D) && (points.getClass().getComponentType() != GbPoint3D.class)) throw new IllegalArgumentException("GbPolygon3D.addPoints(): points of 3D polygons have to be 3D points!"); - - this->ps->add(points); - //for(int i=0; i<points.length; i++) points[i].addObserver(this.po); - this->consistent = false; - //super.notifyObservers(); -} -/** -* Inserts a point at the specified position within this polygon. Notifies the observers of this 3D polygon. -* @param point the point -* @param index the index -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -//public void insertPoint(GbPoint3D point, int index) throws ArrayIndexOutOfBoundsException -//{ -// if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.insertPoint(): points of 3D polygons have to be 3D points!"); -// if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon3D.insert(): invalid index specified: "+index); - -// this.ps.insert(point, index); -// point.addObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon identical to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deletePoint(GbPoint3D point) -//{ -// this.ps.delete(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon equal to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deleteEqualPoint(GbPoint3D point) -//{ -// this.ps.deleteEqual(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon. Notifies the observers of this 3D polygon. -*/ -void GbPolygon3D::clear() -{ - // delete this->points; - this->ps->clearAndTrim(); - delete this->ps; - - //for(int i=points.length-1; i>=0; i--) points[i].removeObserver(this.po); - this->consistent = false; - //super.notifyObservers(); -} - -/** -* Returns true if this 3D polygon equals the specified object. -* Two polygon are equal, if their points are equal. -* <BR>Note that the order of points is recognized! -* @return true if this 3D polygon equals the specified object -* @see GbPoint3D#equals(java.lang.Object) -*/ -// bool equals(Object object) -// { -// try -// { -// GbPolygon2D polygon = (GbPolygon3D) object; -//int n = this.size(); - -//if(n != polygon.size()) return(false); -//for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false); -//return(true); -// } -// catch(Exception e){ return(false); } -// } -/** -* Returns a string representation of this 3D polygon. -* @return a string representation of this 3D polygon -*/ -string GbPolygon3D::toString() -{ - stringstream ss; - ss<<"GbPolygon3D["; - ss<<this->size()<<" points"; - - // ss<<", x1s="<<this->x1s; - // ss<<", x2s="<<this->x2s; - //ss<<", x3s="<<this->x3s; - // ss<<", x1min="<<this->x1min; - // ss<<", x1max="<<this->x1max; - // ss<<", x2min="<<this->x2min; - // ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - // ss<<", x3max="<<this->x3max; - ss<<"]"<<endl; - for(int u=0; u<this->size(); u++) - ss<<this->ps->getPoint(u)->toString()<<endl; - - return(ss.str()); -} -/*======================================================================*/ - - -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 3D polygon and the specified 3D line. -* @param line the 3D line to intersect -* @return the intersection points of this 3D polygon and the specified 3D line -*/ -// public GbPoint3D[] calculateIntersectionPoints3D(GbLine3D line) -// { -// GbSystem.PointSet pointSet = new GbSystem.PointSet(0); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D pCrossed = null; -// int n = points.length; -// if(n < 2) return(pointSet.getPoints()); - -// for(int i=1; i<n; i++) -// { -//pCrossed = GbSystem.calculateIntersectionPoint3D(points[i-1], points[i], line.p1, line.p2); -//if(pCrossed != null) pointSet.add(pCrossed); -// } -// pCrossed = GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], line.p1, line.p2); -// if(pCrossed != null) pointSet.add(pCrossed); - -// return(pointSet.getPoints()); -// } - -/* -* Returns true if the specified 3D point lies within (or on the border of) this 3D polygon. -* @param point the 3D point to check -* @return true if the specified 3D point lies within (or on the border of) this 3D polygon -*/ -// public boolean enclosesPoint3D(GbPoint3D point) -// { -// if(GbSystem.less(point.x1, this.x1min)) return(false); -// if(GbSystem.less(point.x2, this.x2min)) return(false); -// if(GbSystem.greater(point.x1, this.x1max)) return(false); -// if(GbSystem.greater(point.x2, this.x2max)) return(false); -// if(this.containsEqual(point) > 0) return(true); - -// QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D ptest; -// int n = points.length; -// if(n < 2) return(false); - -// if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint3D(point.x1, this.x2min-1.0); -// else ptest = new GbPoint3D(point.x1, this.x2max+1.0); - -// for(int i=1; i<n; i++) -// { -//try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } -//catch(Exception e){} -// } -// try { ltest.append(GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], point, ptest)); } -// catch(Exception e){} -// return((ltest.size()%2)==1); -// } - -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param rectangle the 3D rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1 the 1st point of the rectangle -* @param p2 the 2nd point of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbPoint3D *p1, GbPoint3D *p2) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1x1 the 1st x1 coordinate of the rectangle -* @param p1x2 the 1st x2 coordinate of the rectangle -* @param p2x1 the 2nd x1 coordinate of the rectangle -* @param p2x2 the 2nd x2 coordinate of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) -// { -//return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); -// } - -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/*======================================================================*/ - -void GbPolygon3D::calculateValues() -{ - this->x1s = 0.0; - this->x2s = 0.0; - this->x3s = 0.0; - this->x1min = 0.0; - this->x1max = 0.0; - this->x2min = 0.0; - this->x2max = 0.0; - this->x3min = 0.0; - this->x3max = 0.0; - throw UbException(UB_EXARGS,"should be implemented"); - - //this->consistent = true; - - //this->points = this->ps->getPoints(); - - //int n = (int)this->points.size(); - //if(n < 1) return; - - //GbPoint3D p1 = (this->points)[0]; - //GbPoint3D p2 = NULL; - //double h1 = 0.0; - //double h2 = 0.0; - //double f=0.0; - - //this->x1s = p1.x1; - //this->x1min = p1.x1; - //this->x1max = p1.x1; - //this->x2s = p1.x2; - //this->x2min = p1.x2; - //this->x2max = p1.x2; - //this->x3s = p1.x2; - //this->x3min = p1.x2; - //this->x3max = p1.x2; - - //std::cout<<"Should be implemented "<<endl; - - //for(int i=1; i<n; i++) - //{ - // p2 = (this->points)[i]; - // f = p1.x1*p2.x2 - p1.x2*p2.x1; - // this->area += f; - // h1 += f*(p1.x2 + p2.x2); - // h2 += f*(p1.x1 + p2.x1); - // p1 = p2; - - // if(p1.x1 < this->x1min) this->x1min = p1.x1; - // if(p1.x1 > this->x1max) this->x1max = p1.x1; - // if(p1.x2 < this->x2min) this->x2min = p1.x2; - // if(p1.x2 > this->x2max) this->x2max = p1.x2; - //} - //p2 = (this->points)[0]; - //f = p1.x1*p2.x2 - p1.x2*p2.x1; - //this->area += f; - //h1 += f*(p1.x2 + p2.x2); - //h2 += f*(p1.x1 + p2.x1); - - //this->area *= 0.5; - //h1 /= 6.0; - //h2 /= 6.0; - - //if(n > 2) - //{ - // this->x1s = h2/this->area; - // this->x2s = h1/this->area; - //} - - //if(n < 3 || !GbSystem::inClosedInterval(this->x1s, this->x1min, this->x1max)) this->x1s = 0.5*(this->x1min+this->x1max); - //if(n < 3 || !GbSystem::inClosedInterval(this->x2s, this->x2min, this->x2max)) this->x2s = 0.5*(this->x2min+this->x2max); -} -/*======================================================================*/ - - -/*======================================================================*/ -// private class PointObserver implements TiObserver -// { -// GbPolygon3D polygon = null; - -// PointObserver(GbPolygon3D polygon) -// { -//this.polygon = polygon; -// } - -// public void objectChanged(Object object) -// { -//if((object instanceof GbPoint3D) && this.polygon.contains((GbPoint3D)object)>0) -//{ -// this.polygon.consistent = false; -// this.polygon.notifyObservers(); -//} -// } -// } -/*=======================================================*/ -void GbPolygon3D::write(UbFileOutput* out) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ -void GbPolygon3D::read(UbFileInput* in) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ - diff --git a/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h b/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h deleted file mode 100644 index da383fb05530409a9626ae1a39062f9636d9951a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h +++ /dev/null @@ -1,536 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBPOLYGON3D_H -#define GBPOLYGON3D_H - -#include <sstream> -#include <iostream> - - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbSystem3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbPolygon3D; -typedef VFSharedPtr<GbPolygon3D> GbPolygon3DPtr; - - -class GbObject3DCreator; - -/*=========================================================================*/ -/* GbPolygon2D */ -/* */ -/* -* This Class provides basic 3D polygon objects. -*/ -class GbPolygon3D : public GbObject3D -{ -public: - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -private: - /*======================================================================*/ - double x1s ; - double x2s ; - double x3s ; - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - - std::vector<GbPoint3D> points; - bool consistent; - - GbSystem3D::PointSet3 *ps; - //private PointObserver po = null; - - void init(); - - /*======================================================================*/ - - - /*======================================================================*/ - /* Konstruktoren */ - /* */ - /* - * Creates an empty 2D polygon. - */ -public: - static int counter; - GbPolygon3D(); - /* - * Creates an empty 2D polygon with the specified capacity. - * @param capacity the initial capacity - */ - GbPolygon3D(int capacity); - /* - * Creates a 2D polygon with the specified points. - * @param points the initial points of the polygon - */ - GbPolygon3D(std::vector<GbPoint3D> &points); - /* - * Creates a 2D polygon as clone of the specified 2D polygon. - * @param polygon the 2D polygon to be cloned - */ - GbPolygon3D(GbPolygon3D *polygon); - - ~GbPolygon3D(); - - /*======================================================================*/ - - - /*======================================================================*/ - /* Methoden */ - /* */ - /* - * Creates a 2D polygon as clone of this 2D polygon. - */ - GbPolygon3D* clone() { return(new GbPolygon3D(this)); } - void finalize() - { - throw UbException(UB_EXARGS,"toDo"); - } - - /* - * Returns the number of points. - * @return the number of points - */ - int size(); - /* - * Returns the number of times this 2D polygon contains the specified point. - * @param point the point - * @return the number of times this 2D polygon contains the specified point - */ - int contains(GbPoint3D *point); - /* - * Returns the number of times this 2D polygon contains a point equal to the specified point. - * @param point the point - * @return the number of times this 2D polygon contains a point equal to the specified point - */ - int containsEqual(GbPoint3D* point); - /* - * Returns true, if this 2D polygon contains the specified line. - * @param point1 the first point - * @param point2 the second point - * @return true, if this 2D polygon contains the specified line - */ - bool containsLine(GbPoint3D* point1, GbPoint3D* point2); - /* - * Returns true, if this 2D polygon contains the specified line. - * @param line the line - * @return true, if this 2D polygon contains the specified line - */ - bool containsLine(GbLine3D* line); - /* - * Returns the first point. - * @return the first point - */ - GbPoint3D* getFirstPoint(); - /* - * Returns the last point. - * @return the last point - */ - GbPoint3D* getLastPoint(); - /* - * Returns the specified point. - * @param index the index - * @return the specified point - * @exception ArrayIndexOutOfBoundsException if the specified index is not valid - */ - GbPoint3D* getPoint(const int& index); - /* - * Returns the points. - * @return the points - */ - std::vector<GbPoint3D> getPoints(); - /* - * Returns the points within the specified rectangle. - * @param rectangle the 2D rectangle - * @return the points within the specified rectangle - */ - //public GbPoint2D[] getPoints(GbRectangle2D rectangle) - //{ - // return(this.getPoints(rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2)); - //} - /* - * Returns the points within the specified rectangle. - * @param p1 the 1st point of the rectangle - * @param p2 the 2nd point of the rectangle - * @return the points within the specified rectangle - */ - std::vector<GbPoint3D> getPoints(GbPoint3D* p1, GbPoint3D* p2); - /* - * Returns the points within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the points within the specified rectangle - */ - std::vector<GbPoint3D> getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3); - /* - * Returns the area of this polygon. - * The area is positive for positive ordered points, otherwise negative. - * @return the area of this polygon - */ - //double getArea() - //{ - // if(!this.consistent) this.calculateValues(); - // return(this.area); - //} - double getX1Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Centroid(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Centroid(); - double getX3Minimum(); - double getX3Maximum(); - - /* - * Adds a point to the end of this polygon. Notifies the observers of this 2D polygon. - * @param point the point - */ - void addPoint(GbPoint3D* point); - /* - * Adds a number of points to the end of this polygon. Notifies the observers of this 2D polygon. - * @param points the points - */ - void addPoints(std::vector<GbPoint3D>& points); - /* - * Inserts a point at the specified position within this polygon. Notifies the observers of this 2D polygon. - * @param point the point - * @param index the index - * @exception ArrayIndexOutOfBoundsException if the specified index is not valid - */ - //public void insertPoint(GbPoint2D point, int index) throws ArrayIndexOutOfBoundsException - //{ - // if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon2D.insertPoint(): points of 3D polygons have to be 3D points!"); - // if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon2D.insert(): invalid index specified: "+index); - - // this.ps.insert(point, index); - // point.addObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon identical to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deletePoint(GbPoint2D point) - //{ - // this.ps.delete(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon equal to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deleteEqualPoint(GbPoint2D point) - //{ - // this.ps.deleteEqual(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon. Notifies the observers of this 2D polygon. - */ - void clear(); - - /* - * Returns true if this 2D polygon equals the specified object. - * Two polygon are equal, if their points are equal. - * <BR>Note that the order of points is recognized! - * @return true if this 2D polygon equals the specified object - * @see GbPoint2D#equals(java.lang.Object) - * @see GbPoint3D#equals(java.lang.Object) - */ - // bool equals(Object object) - // { - // try - // { - // GbPolygon2D polygon = (GbPolygon2D) object; - //int n = this.size(); - - //if(n != polygon.size()) return(false); - //for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false); - //return(true); - // } - // catch(Exception e){ return(false); } - // } - std::vector<GbTriangle3D*> getSurfaceTriangleSet() - { - std::cout<<"GbPolygon3D::getSurfaceTriangleSet() - not implemented\n"; - std::vector<GbTriangle3D*> tmp; - return tmp; - } - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3) - { - throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented"); - } - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) - { - throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented"); - } - bool isCellInsideGbObject3D(double x11,double x21,double x31,double x12,double x22,double x32) { return false; } - - GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D &point2) - { - throw UbException(__FILE__, __LINE__, "GbPolygon3D::createClippedLine3D - not implemented"); - } -/* - * Returns a string representation of this 2D polygon. - * @return a string representation of this 2D polygon - */ - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - /*======================================================================*/ - - - /*======================================================================*/ - /* Calculation */ - /* */ - /* - * Returns the intersection points of this 2D polygon and the specified 2D line. - * @param line the 2D line to intersect - * @return the intersection points of this 2D polygon and the specified 2D line - */ - // public GbPoint2D[] calculateIntersectionPoints2D(GbLine2D line) - // { - // GbSystem.PointSet pointSet = new GbSystem.PointSet(0); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D pCrossed = null; - // int n = points.length; - // if(n < 2) return(pointSet.getPoints()); - - // for(int i=1; i<n; i++) - // { - //pCrossed = GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], line.p1, line.p2); - //if(pCrossed != null) pointSet.add(pCrossed); - // } - // pCrossed = GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], line.p1, line.p2); - // if(pCrossed != null) pointSet.add(pCrossed); - - // return(pointSet.getPoints()); - // } - - /* - * Returns true if the specified 2D point lies within (or on the border of) this 2D polygon. - * @param point the 2D point to check - * @return true if the specified 2D point lies within (or on the border of) this 2D polygon - */ - // public boolean enclosesPoint2D(GbPoint2D point) - // { - // if(GbSystem.less(point.x1, this.x1min)) return(false); - // if(GbSystem.less(point.x2, this.x2min)) return(false); - // if(GbSystem.greater(point.x1, this.x1max)) return(false); - // if(GbSystem.greater(point.x2, this.x2max)) return(false); - // if(this.containsEqual(point) > 0) return(true); - - // QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D ptest; - // int n = points.length; - // if(n < 2) return(false); - - // if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint2D(point.x1, this.x2min-1.0); - // else ptest = new GbPoint2D(point.x1, this.x2max+1.0); - - // for(int i=1; i<n; i++) - // { - //try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } - //catch(Exception e){} - // } - // try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], point, ptest)); } - // catch(Exception e){} - // return((ltest.size()%2)==1); - // } - - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param rectangle the 2D rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1 the 1st point of the rectangle - * @param p2 the 2nd point of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon2D(GbPoint3D *p1, GbPoint3D *p2) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) - // { - //return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); - // }; - - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /*======================================================================*/ - - - /*======================================================================*/ - /* Private Methoden */ - /* */ - void calculateValues(); - /*======================================================================*/ - - - /*======================================================================*/ - // private class PointObserver implements TiObserver - // { - // GbPolygon2D polygon = null; - - // PointObserver(GbPolygon2D polygon) - // { - //this.polygon = polygon; - // } - - // public void objectChanged(Object object) - // { - //if((object instanceof GbPoint2D) && this.polygon.contains((GbPoint2D)object)>0) - //{ - // this.polygon.consistent = false; - // this.polygon.notifyObservers(); - //} - // } - // } - /*======================================================================*/ -}; -/*=========================================================================*/ -#endif - - - - - - diff --git a/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp deleted file mode 100644 index c6b8df7927fe730d7a1271cfec5b327c641d2173..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp +++ /dev/null @@ -1,362 +0,0 @@ -#include <numerics/geometry3d/GbQuadFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h> - -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> - - -using namespace std; - -GbQuadFaceMesh3D::GbQuadFaceMesh3D() : GbObject3D() -{ - this->name = "new GbMesh"; - this->nodes = new vector<Vertex>; - this->quads = new vector<QuadFace>; - this->consistent = false; -} - -GbQuadFaceMesh3D::GbQuadFaceMesh3D(string name, vector<Vertex> *nodes, vector<QuadFace> *quads) : GbObject3D() -{ - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!quads ) throw UbException(UB_EXARGS,"no quads specified"); - - this->name = name; - this->nodes = nodes; - this->quads = quads; - this->consistent = false; -} -/*=============================================================================================*/ - -GbQuadFaceMesh3D::~GbQuadFaceMesh3D() -{ - if(nodes) - { - // for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u]; - delete nodes; - } - if(quads) - { - delete quads; - } -} -/*======================================================================*/ -ObObjectCreator* GbQuadFaceMesh3D::getCreator() -{ - return GbQuadFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ - -void GbQuadFaceMesh3D::init() -{ - nodes = NULL; - quads = NULL; - x1min = 0.0; - x1max = 0.0; - x2min = 0.0; - x2max = 0.0; - x3min = 0.0; - x3max = 0.0; - consistent = false; -} - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbQuadFaceMesh3D::toString() -{ - stringstream ss; - ss<<"GbQuadFaceMesh3D["; - ss<<(int)this->quads->size()<<"-Quadangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl; - //ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\""; - //ss<<", x1min="<<this->x1min; - //ss<<", x1max="<<this->x1max; - //ss<<", x2min="<<this->x2min; - //ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - //ss<<", x3max="<<this->x3max; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the name of this triangular mesh. - * @return the name of this triangular mesh - */ -string GbQuadFaceMesh3D::getName(){ return(this->name); } - -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbQuadFaceMesh3D::Vertex>* GbQuadFaceMesh3D::getNodes() { return(this->nodes); } -/** - * Returns the quads of this triangular mesh. - * @return the quads of this triangular mesh - */ -vector<GbQuadFaceMesh3D::QuadFace>* GbQuadFaceMesh3D::getQuads() { return(this->quads); } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x1min+this->x1max)); -} -/** - * Returns the center x2 coordinate of this triangular mesh. - * @return the center x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x2min+this->x2max)); -} -/** -* Returns the center x3 coordinate of this triangular mesh. - * @return the center x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x3min+this->x3max)); -} - -/** - * Returns the minimum x1 coordinate of this triangular mesh. - * @return the minimum x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -/** - * Returns the maximum x1 coordinate of this triangular mesh. - * @return the maximum x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -/** - * Returns the minimum x2 coordinate of this triangular mesh. - * @return the minimum x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -/** - * Returns the maximum x2 coordinate of this triangular mesh. - * @return the maximum x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -/** - * Returns the minimum x3 coordinate of this triangular mesh. - * @return the minimum x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -/** - * Returns the maximum x3 coordinate of this triangular mesh. - * @return the maximum x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -void GbQuadFaceMesh3D::calculateValues() -{ - double x1, x2, x3; - - this->x1min = (*this->nodes)[0].x; - this->x1max = (*this->nodes)[0].x; - this->x2min = (*this->nodes)[0].y; - this->x2max = (*this->nodes)[0].y; - this->x3min = (*this->nodes)[0].z; - this->x3max = (*this->nodes)[0].z; - - for(int i=1; i<(int)this->nodes->size(); i++) - { - x1 = (*this->nodes)[i].x; - x2 = (*this->nodes)[i].y; - x3 = (*this->nodes)[i].z; - if(x1 < this->x1min) this->x1min = x1; - if(x1 > this->x1max) this->x1max = x1; - if(x2 < this->x2min) this->x2min = x2; - if(x2 > this->x2max) this->x2max = x2; - if(x3 < this->x3min) this->x3min = x3; - if(x3 > this->x3max) this->x3max = x3; - } - this->consistent = true; -} - - -/*======================================================================*/ -vector<GbTriangle3D*> GbQuadFaceMesh3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> triangles(0); - return triangles; - //throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceTriangelSet - not implemented"); -} -//vector<GbQuad3D*> GbQuadFaceMesh3D::getSurfaceQuadSet() -//{ -// throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceQuadSet - not implemented"); -// //vector<GbQuadangle3D*> tris; -// //GbQuadangle3D* quad; -// //GbPoint3D* p1; -// //GbPoint3D* p2; -// //GbPoint3D* p3; -// //int size = (int)this->quads->size(); -// //for(int u=0; u<size;u++) -// //{ -// // quad = (*this->quads)[u]; -// // p1 = new GbPoint3D(quad->getPoint1()); -// // p2 = new GbPoint3D(quad->getPoint2()); -// // p3 = new GbPoint3D(quad->getPoint3()); -// // tris.push_back(new GbQuadangle3D(p1, p2, p3)); -// //} -// //return tris; -//} -/*======================================================================*/ -/* -* Function to determine if the point is inside the polyhedron defined as a 3D object -* using the Halfspace algorithm -* @param xp the x-coordinate of the point -* @param yp the y-coordinate of the point -* @param zp the z-coordinate of the point -* @return true if point is inside else return false -*/ -bool GbQuadFaceMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp) -{ - throw UbException(UB_EXARGS,"not implemented"); - //vector<GbQuadangle3D*> *Quadangles = this->quads; - //int Quadanglesize = (int)Quadangles->size(); - //GbPoint3D Point(xp,yp,zp); - //for (int i=0; i<Quadanglesize; i++) - //{ - // GbPoint3D* point1 = (*Quadangles)[i]->getPoint1(); - // GbPoint3D* point2 = (*Quadangles)[i]->getPoint2(); - // GbPoint3D* point3 = (*Quadangles)[i]->getPoint3(); - - // GbHalfSpace3D halfspace(point1, point2, point3); - // if (halfspace.ptInside(&Point)) return false; - //} - //return true; -} -/*======================================================================*/ -/*======================================================================*/ -bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - double dX = (xmax-xmin)/100.; - double dY = (ymax-ymin)/100.; - double dZ = (zmax-zmin)/100.; - GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) - { - boundingCube.finalize(); - return false; - } - boundingCube.finalize(); - - // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm - GbVector3D bMin(boundingCube.getPoint1()); - GbVector3D bMax(boundingCube.getPoint2()); - bMin = bMax.Subtract(bMin); - //int radius = (int)bMin.Length(); - - //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3DHalfSpace(x1,x2,x3) ) - //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3Darea(x11,x12,x13,numQuadangles)) - //if(this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->quads->size())) - // return true; - //else - return false; -} -/*======================================================================*/ -bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -GbLine3D* GbQuadFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} - -/*======================================================================*/ -void GbQuadFaceMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbQuadFaceMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbQuadFaceMesh3D"); - - int quadsize = (int)this->quads->size(); - int nodesize = (int)this->nodes->size(); - - out->writeInteger(nodesize); - out->writeInteger(quadsize); - - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - Vertex node; - QuadFace face; - for(int i=0;i<nodesize; i++) - { - node = (*nodes)[i]; - out->writeInteger(nr++); - out->writeDouble(node.x); - out->writeDouble(node.y); - out->writeDouble(node.z); - out->writeLine(); - } - - nr=1; - for(int i=0;i<quadsize; i++) - { - face = (*quads)[i]; - out->writeInteger(nr++); - out->writeInteger(2); - out->writeString("quad"); - out->writeInteger(face.vertex1+1); - out->writeInteger(face.vertex2+1); - out->writeInteger(face.vertex3+1); - out->writeInteger(face.vertex4+1); - out->writeLine(); - } - - //out->writeInteger(0); out->writeInteger(1); out->writeLine(); - //out->writeInteger(1); out->writeInteger(1); out->writeLine(); - //out->writeLine("TEST,no_unit"); - //nr=1; - //for(int i=0;i<quadsize; i++) - //{ - // out->writeInteger(nr++); - // out->writeInteger(10); - // out->writeLine(); - //} - cout<<"done\n"; -} - diff --git a/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h b/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h deleted file mode 100644 index 43528dca68b8e4666612aa8f62ef60fefd1c90a8..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h +++ /dev/null @@ -1,125 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBQUADFACEMESH3D_H -#define GBQUADFACEMESH3D_H - -#include <sstream> -#include <iostream> - - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbException.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbQuadFaceMesh3D; -typedef VFSharedPtr<GbQuadFaceMesh3D> GbQuadFaceMesh3DPtr; - -class UbFileOutput; -class UbFileInput; -/*=========================================================================*/ -/* GbQuadFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class GbQuadFaceMesh3D : public GbObject3D -{ -public: - // nested class start - class Vertex - { - public: - Vertex(){} - Vertex(float x, float y, float z) - { - this->x=x; - this->y=y; - this->z=z; - } - float x, y, z; - }; - - class QuadFace - { - public: - QuadFace() {} - QuadFace(int v1, int v2, int v3, int v4) - { - this->vertex1=v1; - this->vertex2=v2; - this->vertex3=v3; - this->vertex4=v4; - } - - int vertex1, vertex2, vertex3, vertex4; - }; - // nested class end - -public: - GbQuadFaceMesh3D(); - GbQuadFaceMesh3D(std::string name, std::vector<Vertex> *nodes, std::vector<QuadFace> *quads); - virtual ~GbQuadFaceMesh3D(); - GbQuadFaceMesh3D* clone() { throw UbException(UB_EXARGS,"clone() - not implemented"); } - void finalize() { throw UbException(UB_EXARGS,"finalize() - not implemented");} - - std::string toString(); - std::string getName(); - std::vector<Vertex>* getNodes(); - std::vector<QuadFace>* getQuads(); - double getX1Centroid(); - double getX2Centroid(); - double getX3Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Minimum(); - double getX3Maximum(); - void calculateValues(); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp); //based on Halfspace algorithm - //bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numQuads); //based on Spherical polygon area method - //bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numQuads); //based on Ray tracing algorithm - - //char SegPlaneInt(GbQuad3D *quad, GbVector3D &PointQ, GbVector3D &PointR, GbVector3D &Point, int *m); - //char SegQuadCross(GbQuad3D *quad, GbVector3D &PointQ, GbVector3D &PointR); - //till here !!! - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - //virtual std::vector<GbQuad3D*> getSurfaceQuadSet(); - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); - - virtual void write(UbFileOutput* out) { std::cout<<"GbQuadFaceMesh3D::write - sorry not implemented\n"; } - virtual void read(UbFileInput* in) { std::cout<<"GbQuadFaceMesh3D::read - sorry not implemented\n"; } - - void writeAVSMesh(UbFileOutput *out, bool normals=false); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -private: - void init(); - /*======================================================================*/ - std::string name; - std::vector<Vertex> *nodes; - std::vector<QuadFace> *quads; - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; -}; -/*=========================================================================*/ - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp deleted file mode 100644 index 064cc0cff91d812162489a34149a870e8fc23b75..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp +++ /dev/null @@ -1,911 +0,0 @@ -#include <numerics/geometry3d/GbSphere3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -#include <numerics/geometry3d/creator/GbSphere3DCreator.h> - -using namespace std; - -ObObjectCreator* GbSphere3D::getCreator() -{ - return GbSphere3DCreator::getInstance(); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D() - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - radius=0; - midPoint=new GbPoint3D(0,0,0); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius) - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - midPoint = new GbPoint3D(x1,x2,x3); - midPoint->addObserver(this); - - this->radius = radius; - triangulationMode = RAYPROJECTION; - //triangulationMode = CUBOIDPROJECTION; -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(const GbSphere3D& sphere) - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - - this->midPoint = sphere.midPoint->clone(); - this->radius = sphere.radius; - triangulationMode = RAYPROJECTION; - - this->midPoint->addObserver(this); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(GbSphere3D* sphere) - : GbObject3D(), UbObserver() -{ - this->setName(sphere->getName()); - midPoint = sphere->midPoint->clone(); - midPoint->addObserver(this); - - this->radius = sphere->getRadius(); - triangulationMode = RAYPROJECTION; -} -/*=====================================================*/ -GbSphere3D::~GbSphere3D() -{ - if(this->midPoint) this->midPoint->removeObserver(this); -} -/*=====================================================*/ -void GbSphere3D::finalize() -{ - if(this->midPoint) - { - this->midPoint->removeObserver(this); - this->midPoint->finalize(); - delete this->midPoint; - this->midPoint = NULL; - } - - if(this->midPoint) this->midPoint->removeObserver(this); -} -/*=======================================================*/ -void GbSphere3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} -/*=====================================================*/ -double GbSphere3D::getDistance(GbPoint3D* p) -{ - return this->getDistance(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate()); -} -/*=====================================================*/ -void GbSphere3D::setCenterX1Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX1(value); - else throw UbException(UB_EXARGS,"Sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setCenterX2Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX2(value); - else throw UbException(UB_EXARGS,"Sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setCenterX3Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX3(value); - else throw UbException(UB_EXARGS,"sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setRadius(const double& radius) -{ - if (radius != this->radius) - { - this->radius=radius; - this->notifyObserversObjectChanged(); -} -} -/*=====================================================*/ -double GbSphere3D::getDistance(const double& x1p, const double& x2p, const double& x3p) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - return sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3)-this->radius; -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - - return UbMath::lessEqual(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3, this->radius*this->radius); -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - - double distanceSquare = deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3; - double radiusSquare = this->radius*this->radius; - - pointIsOnBoundary = UbMath::equal(distanceSquare,radiusSquare); - - return UbMath::lessEqual(distanceSquare,radiusSquare); -} -/*=====================================================*/ -//bool GbSphere3D::crossCellCrossSection(double x11,double x21,double x12,double x22, double ra) -//{ -// if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12)) -// { -// if(!this->isPointInCrossection(x11, x12) || !this->isPointInCrossection(x21, x22) || !this->isPointInCrossection(x11, x22) || !this->isPointInCrossection(x21, x12)) return true; -// } -// return false; -//} -// -///*=====================================================*/ -//bool GbSphere3D::cellCrossAndInsideCrossSection(double x11,double x21,double x12,double x22, double ra) -//{ -// if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12)) return true; -// return false; -//} -/*=====================================================*/ -string GbSphere3D::toString() -{ - stringstream ss; - ss<< "GbSphere3D["; - ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]"; - return ss.str(); -} -/*=====================================================*/ -GbLine3D* GbSphere3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - double factor = 100.0; //um rundungsfehler beim wurzelterm zu minimieren - double xa = factor*point1.getX1Coordinate(); - double ya = factor*point1.getX2Coordinate(); - double za = factor*point1.getX3Coordinate(); - double xb = factor*point2.getX1Coordinate(); - double yb = factor*point2.getX2Coordinate(); - double zb = factor*point2.getX3Coordinate(); - double xm = factor*this->midPoint->getX1Coordinate(); - double ym = factor*this->midPoint->getX2Coordinate(); - double zm = factor*this->midPoint->getX3Coordinate(); - double r = factor*this->radius; - - double xa2 = xa*xa; - double ya2 = ya*ya; - double za2 = za*za; - double xb2 = xb*xb; - double yb2 = yb*yb; - double zb2 = zb*zb; - double xm2 = xm*xm; - double ym2 = ym*ym; - double zm2 = zm*zm; - double r2 = r*r; - - double wurzel = 2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*ya*ym*xb2+2.0*yb*ym*za2 - +2.0*ya*ym*zb2+2.0*xb*xm*za2+2.0*za*zb*ym2+2.0*xb*xm*ya2+2.0*xa*xm*yb2 - +2.0*yb*ym*xa2+2.0*zb*zm*ya2+2.0*xa*xm*zb2+2.0*za*zm*xb2+2.0*za*zm*yb2 - +2.0*xa*xb*zm2-2.0*xa*xb*r2-2.0*za*zb*r2+2.0*za*zb*xm2-2.0*ya*yb*xa*xm - +2.0*ya*yb*xa*xb+2.0*zb*zm*xa2-2.0*ya*yb*xb*xm+2.0*ya*yb*xm2-2.0*ya*yb*zb*zm - +2.0*ya*yb*zm2+2.0*zb*zm*yb*ym-2.0*zb*zm*ya*ym+2.0*zb*zm*xb*xm-2.0*xa*xm*yb*ym - +2.0*xa*xm*za*zm+2.0*xa*xm*ya*ym-2.0*yb*ym*za*zm+2.0*yb*ym*xb*xm+2.0*za*zm*ya*ym - -2.0*za*zm*xb*xm-2.0*ya*ym*xb*xm+2.0*za*zb*xa*xb-2.0*za*zb*xa*xm-2.0*za*zb*xb*xm - +2.0*za*zb*ya*yb-2.0*za*zb*ya*ym-2.0*za*zb*yb*ym-2.0*ya*yb*za*zm-xa2*zb2 - -xa2*yb2-zb2*ya2-za2*xb2-za2*yb2-xb2*ya2-2.0*zb*zm*xa*xm - -2.0*xa*xb*za*zm-2.0*xa*xb*zb*zm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+za2*r2 - -za2*xm2-za2*ym2+zb2*r2-zb2*xm2-zb2*ym2+xa2*r2-xa2*zm2 - -xa2*ym2+xb2*r2-xb2*zm2-xb2*ym2+ya2*r2-ya2*zm2-ya2*xm2 - +yb2*r2-yb2*zm2-yb2*xm2; - double nenner = -2.0*za*zb-2.0*ya*yb-2.0*xa*xb+za2+zb2+xa2+xb2+ya2+yb2; - double zaehler = 2.0*zb*zm-2.0*xa*xm+2.0*yb*ym-2.0*za*zm+xa2-2.0*ya*ym - +2.0*xb*xm-zb2+za2-xb2+ya2-yb2; - - vector<GbPoint3D*> schnittpunkte; - - if(fabs(nenner)>1.E-13 && UbMath::greaterEqual(wurzel,0.0)) - { - double t1 = (zaehler+2.0*sqrt(wurzel))/nenner; - double t2 = (zaehler-2.0*sqrt(wurzel))/nenner; - - if(UbMath::inClosedInterval(t1,-1.0,1.0)) - { - double x = ( xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1) )/factor; - double y = ( ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1) )/factor; - double z = ( za*(0.5-0.5*t1)+zb*(0.5+0.5*t1) )/factor; - - schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2,-1.0,1.0)) - { - double x = ( xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2) )/factor; - double y = ( ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2) )/factor; - double z = ( za*(0.5-0.5*t2)+zb*(0.5+0.5*t2) )/factor; - - schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - - int nofSchnittpunkte = (int)schnittpunkte.size(); - if(nofSchnittpunkte==1) - { - if (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1)); - else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2)); - else //line beruehrt kugel! -> clippedLine reduziert sich zu einem Punkt! - { - if(std::fabs(this->getDistance(schnittpunkte[0])-this->radius)<1.E-13) - throw UbException(UB_EXARGS,"Beide LinenPunkte ausserhalb des Kreises, der berechnete Punkt ist jedoch KEIN Beruhrungspunkt der Sphere..."); - return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); - } - } - else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]); - - return NULL; -} -/*=========================================================================*/ -vector<GbTriangle3D*> GbSphere3D::getSurfaceTriangleSet() -{ - if(triangulationMode==RAYPROJECTION) - { - double x1m = midPoint->getX1Coordinate(); - double x2m = midPoint->getX2Coordinate(); - double x3m = midPoint->getX3Coordinate(); - - vector<GbTriangle3D*> triangles; - - int segments =30; - double deltaPhi = UbMath::PI/(double)segments; - double phiX1a,phiX1b,phiX3a,phiX3b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - for(phiX3a=0.5*UbMath::PI; phiX3a>-1.5*UbMath::PI; phiX3a-=deltaPhi) - { - for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - phiX3b = phiX3a+deltaPhi; - - x1a = x1m+radius*cos(phiX3a)*std::cos(phiX1a); - x2a = x2m+radius*cos(phiX3a)*std::sin(phiX1a); - x3a = x3m+radius*sin(phiX3a); - x1b = x1m+radius*cos(phiX3a)*std::cos(phiX1b); - x2b = x2m+radius*cos(phiX3a)*std::sin(phiX1b); - x3b = x3m+radius*sin(phiX3a); - x1c = x1m+radius*cos(phiX3b)*std::cos(phiX1b); - x2c = x2m+radius*cos(phiX3b)*std::sin(phiX1b); - x3c = x3m+radius*sin(phiX3b); - x1d = x1m+radius*cos(phiX3b)*std::cos(phiX1a); - x2d = x2m+radius*cos(phiX3b)*std::sin(phiX1a); - x3d = x3m+radius*sin(phiX3b); - - if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI)) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1c,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1d,x2d,x3d))); - } - else - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1d,x2d,x3d),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1a,x2a,x3a))); - } - } - } - return triangles; - } - else if(triangulationMode==CUBOIDPROJECTION) - { - vector<GbTriangle3D*> triangles; - vector<GbPoint3D*> points; - double x1min = this->getX1Minimum(); - double x2min = this->getX2Minimum(); - double x3min = this->getX3Minimum(); - double x1max = this->getX1Maximum(); - double x2max = this->getX2Maximum(); - double x3max = this->getX3Maximum(); - double ax1 = x1min; double bx2 = x2min; double cx1 = x1min; - double ax2 = x2min; double bx3 = x3min; double cx3 = x3min; - - int anzahl = 20; - double dx1 = (x1max-x1min)/(double)(anzahl-1); - double dx2 = (x2max-x2min)/(double)(anzahl-1); - double dx3 = (x3max-x3min)/(double)(anzahl-1); - - for (int u=0; u<anzahl; u++) - { - ax2 = x2min; - bx2 = x2min; - cx3 = x3min; - for (int v=0; v<anzahl; v++) - { - GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max); - GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min); - GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3); - GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3); - GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3); - GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3); - - GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1); - GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2); - GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3); - GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4); - GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5); - GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6); - points.push_back(new GbPoint3D(clippedline1->getPoint1())); - points.push_back(new GbPoint3D(clippedline2->getPoint1())); - points.push_back(new GbPoint3D(clippedline3->getPoint1())); - points.push_back(new GbPoint3D(clippedline4->getPoint1())); - points.push_back(new GbPoint3D(clippedline5->getPoint1())); - points.push_back(new GbPoint3D(clippedline6->getPoint1())); - clippedline1->deletePoints(); delete clippedline1; - clippedline2->deletePoints(); delete clippedline2; - clippedline3->deletePoints(); delete clippedline3; - clippedline4->deletePoints(); delete clippedline4; - clippedline5->deletePoints(); delete clippedline5; - clippedline6->deletePoints(); delete clippedline6; - ax2 +=dx2; - cx3 +=dx3; - bx2 +=dx2; - } - ax1 +=dx1; - cx1 +=dx1; - bx3 +=dx3; - } - - int anz = anzahl*anzahl*6; - GbPoint3D* point1 = NULL; - GbPoint3D* point2 = NULL; - GbPoint3D* point3 = NULL; - int anzahl2 = anzahl*6; - int anzahl3 = anzahl2+6; - for (int u=0; u<anz-anzahl3; u++) - { - point1 = new GbPoint3D(points[u+6]); - point2 = new GbPoint3D(points[u]); - point3 = new GbPoint3D(points[u+anzahl2]); - if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3)); - else triangles.push_back(new GbTriangle3D(point2, point1, point3)); - - point1 = new GbPoint3D(points[u+6]); - point2 = new GbPoint3D(points[u+anzahl2]); - point3 = new GbPoint3D(points[u+anzahl3]); - if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3)); - else triangles.push_back(new GbTriangle3D(point2, point1, point3)); - } - for (int u=0; u<anz; u++) delete points[u]; - - return triangles; - } - else throw UbException(UB_EXARGS,"undefined triangulationmode"); -} -/*=======================================================*/ -void GbSphere3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ - //wenn ich viele Kugeln bei der PE rausschreibe sollten die vektoren nicht geresized werden - //nodes.resize(0); - //triangles.resize(0); - - if(triangulationMode==RAYPROJECTION) - { - float x1m = (float)midPoint->getX1Coordinate(); - float x2m = (float)midPoint->getX2Coordinate(); - float x3m = (float)midPoint->getX3Coordinate(); - - int segments =30; - float deltaPhi = (float)UbMath::PI/(float)segments; - float phiX1a,phiX1b,phiX3a,phiX3b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - int nodeNr = 0; - for(phiX3a=(float)(0.5*UbMath::PI); phiX3a > (float)(-1.5*UbMath::PI); phiX3a-=deltaPhi) - { - for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - phiX3b = phiX3a+deltaPhi; - - x1a = x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1a)); - x2a = x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1a)); - x3a = x3m+(float)(radius*sin(phiX3a)); - x1b = x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1b)); - x2b = x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1b)); - x3b = x3m+(float)(radius*sin(phiX3a)); - x1c = x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1b)); - x2c = x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1b)); - x3c = x3m+(float)(radius*sin(phiX3b)); - x1d = x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1a)); - x2d = x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1a)); - x3d = x3m+(float)(radius*sin(phiX3b)); - - if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI)) - { - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1d,x2d,x3d) ); - } - else - { - nodes.push_back( makeUbTuple(x1d,x2d,x3d) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - } - triangles.push_back( makeUbTuple(nodeNr, nodeNr+1, nodeNr+2) ); - triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - nodeNr+=6; - } - } - } - else if(triangulationMode==CUBOIDPROJECTION) - { - vector<GbPoint3D*> points; - double x1min = this->getX1Minimum(); - double x2min = this->getX2Minimum(); - double x3min = this->getX3Minimum(); - double x1max = this->getX1Maximum(); - double x2max = this->getX2Maximum(); - double x3max = this->getX3Maximum(); - double ax1 = x1min; double bx2 = x2min; double cx1 = x1min; - double ax2 = x2min; double bx3 = x3min; double cx3 = x3min; - - int anzahl = 20; - double dx1 = (x1max-x1min)/(double)(anzahl-1); - double dx2 = (x2max-x2min)/(double)(anzahl-1); - double dx3 = (x3max-x3min)/(double)(anzahl-1); - - for (int u=0; u<anzahl; u++) - { - ax2 = x2min; - bx2 = x2min; - cx3 = x3min; - for (int v=0; v<anzahl; v++) - { - GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max); - GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min); - GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3); - GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3); - GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3); - GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3); - - GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1); - GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2); - GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3); - GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4); - GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5); - GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6); - points.push_back(new GbPoint3D(clippedline1->getPoint1())); - points.push_back(new GbPoint3D(clippedline2->getPoint1())); - points.push_back(new GbPoint3D(clippedline3->getPoint1())); - points.push_back(new GbPoint3D(clippedline4->getPoint1())); - points.push_back(new GbPoint3D(clippedline5->getPoint1())); - points.push_back(new GbPoint3D(clippedline6->getPoint1())); - clippedline1->deletePoints(); delete clippedline1; - clippedline2->deletePoints(); delete clippedline2; - clippedline3->deletePoints(); delete clippedline3; - clippedline4->deletePoints(); delete clippedline4; - clippedline5->deletePoints(); delete clippedline5; - clippedline6->deletePoints(); delete clippedline6; - ax2 +=dx2; - cx3 +=dx3; - bx2 +=dx2; - } - ax1 +=dx1; - cx1 +=dx1; - bx3 +=dx3; - } - - int anz = anzahl*anzahl*6; - int anzahl2 = anzahl*6; - int anzahl3 = anzahl2+6; - int nodeNr = 0; - for (int u=0; u<anz-anzahl3; u++) - { - nodes.push_back( makeUbTuple((float)points[u+6]->x1 , (float)points[u+6]->x2 , (float)points[u+6]->x3) ); - nodes.push_back( makeUbTuple((float)points[u]->x1 , (float)points[u]->x2 , (float)points[u]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) ); - - if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr , nodeNr+1, nodeNr+2) ); - else triangles.push_back( makeUbTuple(nodeNr , nodeNr+1, nodeNr+2) ); - - nodes.push_back( makeUbTuple((float)points[u+6]->x1 , (float)points[u+6]->x2 , (float)points[u+6]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl3]->x1, (float)points[u+anzahl3]->x2, (float)points[u+anzahl3]->x3) ); - if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - else triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - - nodeNr+=6; - } - for(int u=0; u<anz; u++) delete points[u]; - } - else throw UbException(UB_EXARGS,"undefined triangulationmode"); -} -/*=======================================================*/ -void GbSphere3D::transform(const double matrix[4][4]) -{ - midPoint->transform(matrix); - this->setRadius(this->getRadius()*matrix[0][0]); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbSphere3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbSphere3D::read(UbFileInput* in) -{ - if(midPoint) - { - midPoint->removeObserver(this); - midPoint->finalize(); - delete midPoint; - } - midPoint = new GbPoint3D; - in->readString(); - midPoint->read(in); - midPoint->addObserver(this); - radius = in->readDouble(); - triangulationMode = (TRIANGULATIONMODE)in->readInteger(); -} -/*=======================================================*/ -bool GbSphere3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) -{ - GbVector3D vecOrigin(origin.getX1Coordinate(),origin.getX2Coordinate(), origin.getX3Coordinate()) ; - GbVector3D vecDirection(direction.getX1Coordinate(),direction.getX2Coordinate(), direction.getX3Coordinate()); - GbVector3D vecSfereCenter(getX1Centroid(), getX2Centroid(), getX3Centroid()); - GbVector3D diff = vecOrigin - vecSfereCenter; - float a = (float)(vecDirection.Dot(vecDirection)); - float b = (float)(2.0 * vecDirection.Dot(diff)); - float c = (float)(diff.Dot(diff) - this->getRadius()*this->getRadius()); - - // use 'abc'-formula for finding root t_1,2 = (-b +/- sqrt(b^2-4ac))/(2a) - float inRoot = (float)(b*b - 4.0*a*c); - if (inRoot < 0) return false; - float root = sqrt(inRoot); - - float dist = (float)((-b - root)/(2.0*a)); - - double infinity = DBL_MAX; - double eps = 1E-4; - - if (dist > infinity) - return false; - - if (dist < eps) - { - dist = (float)((-b + root)/(2.0*a)); - if (dist < eps || dist > infinity) - return false; - } - return true; -} -/*=======================================================*/ -bool GbSphere3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der SphereUmrandung -//returns true: -// - cell cuts sphere3D -// - cell boxes sphere3D -//returns false: -// - cell completely inside sphere3D ( = sphere3D boxes cell) -// - cell und sphere3D haben kein gemeinsames Volumen -{ - double midX[] = { this->getX1Centroid() - , this->getX2Centroid() - , this->getX3Centroid() }; - - double Bmin[] = { UbMath::min(x1a, x1b) - , UbMath::min(x2a, x2b) - , UbMath::min(x3a, x3b) }; - - double Bmax[] = { UbMath::max(x1a, x1b) - , UbMath::max(x2a, x2b) - , UbMath::max(x3a, x3b) }; - - /* Solid Box - Hollow Sphere */ - double dmin = 0.0; - double dmax = 0.0; - double r2 = radius*radius; - - for( int i=0; i<3; i++ ) - { - double a = pow( midX[i] - Bmin[i], 2.0 ); - double b = pow( midX[i] - Bmax[i], 2.0 ); - dmax += UbMath::max( a, b ); - if ( UbMath::less ( midX[i], Bmin[i] ) ) dmin += a; - else if( UbMath::greater( midX[i], Bmax[i] ) ) dmin += b; - } - if( UbMath::lessEqual(dmin, r2 ) - && UbMath::lessEqual(r2 , dmax ) ) - { - return true; - } - return false; -} -/*=======================================================*/ -bool GbSphere3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside sphere3D ( = sphere3D boxes cell) -// - cell cuts sphere3D -// - cell boxes sphere3D -//returns false: -// - cell und sphere3D haben kein gemeinsames Volumen -{ - //URL: http://tog.acm.org/GraphicsGems/gems/BoxSphere.c (mode=4, beides solids!!!) - // solid - solid - //this routine tests for intersection between an 3-dimensional - //axis-aligned box and an 3-dimensional sphere. - - //true: - // - wenn Schnitt - // - Cell komplett innerhalb GbSphere3D - // - Cell umhuellt GbSphere3D - - - double midX1 = this->getX1Centroid(); - double midX2 = this->getX2Centroid(); - double midX3 = this->getX3Centroid(); - - double dmin = 0.0; - - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - - if( UbMath::lessEqual( dmin, radius*radius ) ) - { - return true; - } - - return false; -} -/*==========================================================*/ -double GbSphere3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - double deltaX1 = (x1b-x1a); - double deltaX2 = (x2b-x2a); - double deltaX3 = (x3b-x3a); - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*deltaX1*deltaX2*deltaX3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double tempResult = 0.0; - - int iMax = 10; - int jMax = 10; - int kMax = 10; - - for( int i=0; i<iMax; i++){ - for( int j=0; j<jMax; j++){ - for( int k=0; k<kMax; k++){ - - tempResult += getCellVolumeInsideGbObject3DHelperFunction( - x1a+((double) i )*deltaX1/((double)iMax), x2a+((double) j )*deltaX2/((double)jMax), x3a+((double) k )*deltaX3/((double)kMax), - x1a+((double)(i+1))*deltaX1/((double)iMax), x2a+((double)(j+1))*deltaX2/((double)jMax), x3a+((double)(k+1))*deltaX3/((double)kMax) ); - } - } - } - - - double resultWithOneCell = getCellVolumeInsideGbObject3DHelperFunction( x1a, x2a, x3a, x1b, x2b, x3b ); - - //cout << tempResult << " vs. " << resultWithOneCell << endl; - - return tempResult; - -} -/*==========================================================*/ -double GbSphere3D::getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - - double deltaX1 = x1b-x1a; - double deltaX2 = x2b-x2a; - double deltaX3 = x3b-x3a; - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*deltaX1*deltaX2*deltaX3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double alpha=0.0; - double internX1,internX2,internX3; - - for(int x1vers=0;x1vers<2;x1vers++){ - for(int x2vers=0;x2vers<2;x2vers++){ - for(int x3vers=0;x3vers<2;x3vers++){ - internX1 = x1a + (x1b-x1a)*x1vers; - internX2 = x2a + (x2b-x2a)*x2vers; - internX3 = x3a + (x3b-x3a)*x3vers; - - if( UbMath::lessEqual(this->getDistance(internX1,internX2,internX3),alpha) ) - alpha = this->getDistance(internX1,internX2,internX3); - //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl; - }//end first for - }//end second for - }//end third for - - alpha = (-1)*alpha; - - - - double n[3]; - n[0] = 0.5*(x1b+x1a) - this->getX1Centroid(); - n[1] = 0.5*(x2b+x2a) - this->getX2Centroid(); - n[2] = 0.5*(x3b+x3a) - this->getX3Centroid(); - - //cout << "Koordinaten: "<<x1<<" "<<x2<<" "<<x3<<endl; - //cout << "Deltas: "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl; - //cout << "Halbe Zelle: "<<halfcelldelta<<endl; - - //cout<<"Centroid: "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double normLength; - normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); - n[0] /= normLength; - n[1] /= normLength; - n[2] /= normLength; - - if( UbMath::less(n[0],0.0) ) n[0] = -n[0]; - if( UbMath::less(n[1],0.0) ) n[1] = -n[1]; - if( UbMath::less(n[2],0.0) ) n[2] = -n[2]; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double dummy; - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;} - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double n1,n2,n3; - n1=n[0]; - n2=n[1]; - n3=n[2]; - - double maxVol = deltaX1*deltaX2*deltaX3; - - double result = 0.0, preresult = 0.0; - - if( UbMath::lessEqual( maxVol, 0.000001 ) ) - return 0.0; - - // 1D Check - if ( UbMath::lessEqual(n1,0.001)&&UbMath::lessEqual(n2,0.001) ) - { - result = alpha*deltaX1*deltaX2; - } - // 2D Check - else if ( UbMath::lessEqual(n1,0.001) ) - { - preresult = (2*n2*n3); - result = (alpha*alpha)/preresult; - - if( UbMath::greater(alpha,n2*deltaX2) ) - { - result += -(alpha-n2*deltaX2)*(alpha-n2*deltaX2)/preresult; - } - if( UbMath::greater(alpha,n3*deltaX3) ) - { - result += -(alpha-n3*deltaX3)*(alpha-n3*deltaX3)/preresult; - } - if( UbMath::greater(alpha,n2*deltaX2+n3*deltaX3) ) - { - result += (alpha-n2*deltaX2-n3*deltaX3)*(alpha-n2*deltaX2-n3*deltaX3)/preresult; - } - - // tiefenrichtung mit einmultiplizieren... - result *= deltaX1; - } - // 3D Check - else - { - preresult =6*n1*n2*n3; - - result = alpha*alpha*alpha; - - if ( UbMath::greaterEqual(alpha,n1*deltaX1)) - { - result+=-((alpha-n1*deltaX1)*(alpha-n1*deltaX1)*(alpha-n1*deltaX1)); - } - if (UbMath::greaterEqual(alpha,n2*deltaX2)) - { - result+=-((alpha-n2*deltaX2)*(alpha-n2*deltaX2)*(alpha-n2*deltaX2)); - } - if (UbMath::greaterEqual(alpha,n3*deltaX3)) - { - result+=-((alpha-n3*deltaX3)*(alpha-n3*deltaX3)*(alpha-n3*deltaX3)); - } - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2))) - { - result+=((alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))); - } - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n3*deltaX3))) - { - result+=((alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))); - } - if (UbMath::greaterEqual(alpha,(n2*deltaX2+n3*deltaX3))) - { - result+=((alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))); - } - - //NEW - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2+n3*deltaX3))) - { - result+= -((alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))); - } - - result = result / preresult; - - } - return(result) ; - - //cout << "alpha ist " << alpha << endl; - //cout << "fillLevel ist " << eps << endl; -} -/*==========================================================*/ -double GbSphere3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - double lx1 = midPoint->x1 - x1; - double lx2 = midPoint->x2 - x2; - double lx3 = midPoint->x3 - x3; - double l_sq = lx1*lx1 + lx2*lx2 + lx3*lx3; //l = abstand Punkt(x1,x2,x3)<->kreismittelpunkt - - double s = lx1*rx1 + lx2*rx2 + lx3*rx3; //s= l*ray_dir) - double r_sq = this->radius * this->radius; // r² =r*r - //if (d<0 (fuer die Richtung falls sie gegen das Kreis dann haben wir ein negativer Zahl) - // && l² > r² (point outside )) - //wenn s<0->Punkt liegt rechts vom mittelpunkt, wenn nun punkt ausserhalb des kreises liegt, kann es keinen SP mehr geben - if( s<-1.E-10 && l_sq>r_sq+1.E-10 ) - return -1.0; - //Pythagor on Triangle Rectangle (point, center of the cercle, intersection of the direction on point and m) - // l² = m² + d² - double m_sq = l_sq - s*s; - // if (m² > r² (dann gibt es kein schnittpunt zwischen direction und circle)) - if( m_sq > r_sq+1.E-10 ) return -1.0; - // Pythagoras on Triangle Rectangle in cercle (direction , m, r) - // r² = m² + h² - - //patch: rundungsfehler bei kleinen delta!!! - //-> wenn wurzel minimal null-> - double wurzelTerm = r_sq - m_sq; - if(wurzelTerm<0.0) - { - if(wurzelTerm<-1E-10) return -1.0; //definitiv kein SP - else return s; //im rundungsfehler-bereich. SP liegt dierkt auf sphere umrandung - } - - //if point outside of the circle - if(l_sq>r_sq) return s-sqrt(wurzelTerm); - - return s+sqrt(wurzelTerm); -} -/*=======================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h b/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h deleted file mode 100644 index f9d4d86ea7fabe544e768f90e7ba2aefc2cabec6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h +++ /dev/null @@ -1,163 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBSPHERE3D_H -#define GBSPHERE3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF -#ifdef CAB_CTL - #include <ctl.h> -#endif //CAB_CTL - -#include <vector> -#include <cmath> - -#include <basics/utilities/UbObserver.h> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbSphere3D; -typedef VFSharedPtr<GbSphere3D> GbSphere3DPtr; - - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbSphere3D : public GbObject3D, public UbObserver -{ -public: - enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION }; - - ////////////////////////////////////////////////////////////////////////// - // Konstruktoren - GbSphere3D(); - GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius); - GbSphere3D(const GbSphere3D& sphere); - GbSphere3D(GbSphere3D* sphere); //<-unschoen! - - ~GbSphere3D(); - - GbSphere3D* clone() { return new GbSphere3D(*this);} - void finalize(); - - double getRadius() const { return this->radius; } - - double getX1Centroid() { return midPoint->getX1Coordinate();} - double getX1Minimum() { return midPoint->getX1Coordinate()-radius;} - double getX1Maximum() { return midPoint->getX1Coordinate()+radius;} - double getX2Centroid() { return midPoint->getX2Coordinate();} - double getX2Minimum() { return midPoint->getX2Coordinate()-radius;} - double getX2Maximum() { return midPoint->getX2Coordinate()+radius;} - double getX3Centroid() { return midPoint->getX3Coordinate();} - double getX3Minimum() { return midPoint->getX3Coordinate()-radius;} - double getX3Maximum() { return midPoint->getX3Coordinate()+radius;} - - void setCenterX1Coordinate(const double& value); - void setCenterX2Coordinate(const double& value); - void setCenterX3Coordinate(const double& value); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - void setRadius(const double& radius); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - double getDistance(GbPoint3D* p); - double getDistance(const double& x1p, const double& x2p, const double& x3p); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - - 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); - double getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - 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); - - bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction); - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->midPoint->translate(x1, x2, x3); - this->notifyObserversObjectChanged(); - } - void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ } - void scale(const double& sx1, const double& sx2, const double& sx3) - { - this->radius *= sx1; - this->notifyObserversObjectChanged(); - } - - void transform(const double matrix[4][4]); - - TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;} - void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; } - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) - { - this->notifyObserversObjectChanged(); - //std::cout<<"GbSphere:objectChanged() - toDo-);"; - } - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - throw UbException(UB_EXARGS,"not implemented"); - } - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - } -#endif //CAB_RCF -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - midPoint->write(os); - return os<<radius; - } - ctl::iStream &read(ctl::iStream &is) - { - midPoint->read(is); - return is>>radius; - } -#endif //CAB_CTL - -private: - GbPoint3D* midPoint; - double radius; // Radius des Kreises - TRIANGULATIONMODE triangulationMode; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if CAB_RCF <= 903 - SF_SERIALIZE_ENUM(GbSphere3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbSphere3D>("GbSphere3D") , SF_GbSphere3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbSphere3D >()), SF_GbSphere3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GBSPHERE3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp deleted file mode 100644 index 529d3222c8b643631e6e33fe2499c5df873313e2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp +++ /dev/null @@ -1,1187 +0,0 @@ -#include <numerics/geometry3d/GbSystem3D.h> - -#include <numerics/geometry3d/GbPolygon3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> - -using namespace std; - -double GbSystem3D::getDistance(const GbPoint3D& p11, const GbPoint3D& p12) -{ - double dx1 = p11.x1 - p12.x1; - double dx2 = p11.x2 - p12.x2; - double dx3 = p11.x3 - p12.x3; - return std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3); -} - -GbPoint3D* GbSystem3D::calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22) -{ - if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1)) return NULL; - if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2)) return NULL; - if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3)) return NULL; - if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return NULL; - if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return NULL; - if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return NULL; - - double a11 = p12.x1 - p11.x1; //..HOW PARAMETERS ARE USED......... - double a12 = p12.x2 - p11.x2; // - double a13 = p12.x3 - p11.x3; // p11 and p12 represent line 1 - double a21 = p21.x1 - p22.x1; // p21 and p22 represent line 2 - double a22 = p21.x2 - p22.x2; // - double a23 = p21.x3 - p22.x3; //.................................. - double b1 = p21.x1 - p11.x1; - double b2 = p21.x2 - p11.x2; - double b3 = p21.x3 - p11.x3; - double d1 = a11*a22 - a12*a21; - double d2 = a11*a23 - a13*a21; - double d3 = a12*a23 - a13*a22; - double t; - - if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return NULL; - if(UbMath::zero(d1)) - { - if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2; - else t = (a23*b2-a22*b3)/d3; - } - else if(UbMath::zero(d2)) - { - if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1; - else t = (a23*b2-a22*b3)/d3; - } - else if(UbMath::zero(d3)) - { - if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1; - else t = (a23*b1-a21*b3)/d2; - } - else return NULL; - - double x1 = p11.x1 + t*a11; - double x2 = p11.x2 + t*a12; - double x3 = p11.x3 + t*a13; - - if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) && - UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) && - UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3) ) return new GbPoint3D(x1, x2, x3); - - return NULL; -} -/*=================================================================*/ -//Line1: p11 -> p12 and Line2: p21 -> p22 -bool GbSystem3D::hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22) -{ - if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1)) return false; - if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2)) return false; - if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3)) return false; - if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return false; - if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return false; - if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return false; - - double a11 = p12.x1 - p11.x1; //..HOW PARAMETERS ARE USED......... - double a12 = p12.x2 - p11.x2; // - double a13 = p12.x3 - p11.x3; // p11 and p12 represent line 1 - double a21 = p21.x1 - p22.x1; // p21 and p22 represent line 2 - double a22 = p21.x2 - p22.x2; // - double a23 = p21.x3 - p22.x3; //.................................. - double b1 = p21.x1 - p11.x1; - double b2 = p21.x2 - p11.x2; - double b3 = p21.x3 - p11.x3; - double d1 = a11*a22 - a12*a21; - double d2 = a11*a23 - a13*a21; - double d3 = a12*a23 - a13*a22; - double t; - - if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return false; - if(UbMath::zero(d1)) - { - if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2; - else t = (a23*b2-a22*b3)/d3; - } - else if(UbMath::zero(d2)) - { - if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1; - else t = (a23*b2-a22*b3)/d3; - } - else if(UbMath::zero(d3)) - { - if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1; - else t = (a23*b1-a21*b3)/d2; - } - else return false; - - double x1 = p11.x1 + t*a11; - double x2 = p11.x2 + t*a12; - double x3 = p11.x3 + t*a13; - - if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) && - UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) && - UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3)) return true; - return false; -} - /*======================================================================*/ -// -// -// /*======================================================================*/ -// /* Private Methoden (Parallelism) */ -// /* */ -bool GbSystem3D::isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22) -{ - double a11 = p12.x1 - p11.x1; //..HOW PARAMETERS ARE USED......... - double a12 = p12.x2 - p11.x2; // - double a13 = p12.x3 - p11.x3; // p11 and p12 represent line 1 - double a21 = p21.x1 - p22.x1; // p21 and p22 represent line 2 - double a22 = p21.x2 - p22.x2; // - double a23 = p21.x3 - p22.x3; //.................................. - - return (UbMath::zero(a11*a22 - a12*a21) && UbMath::zero(a11*a23 - a13*a21) && UbMath::zero(a12*a23 - a13*a22)); -} -/*======================================================================*/ - - -/*======================================================================*/ -/* General Clipping Methods */ -//......................................................................*/ -// -// Method Parameters Result Remarks -// --------- --------------------------------------------- --------- ------------------- -// clip###2D (2D objects to be clipped, 2+2 clipping values) 2D object clipping x1, x2 -// clip###3D (3D objects to be clipped, 2+2 clipping values) 3D object clipping x1, x2 -// clip###3D (3D objects to be clipped, 3+3 clipping values) 3D object clipping x1, x2, x3 -// clip###3D (3D objects to be clipped, 1+1 clipping values) 3D object clipping x3 -// -/*======================================================================*/ -/* Private Methoden (Clipping Lines) */ -/* */ -GbLine3D* GbSystem3D::createClipLine3D(GbPoint3D &pA, GbPoint3D &pB, double x1a, double x2a, double x3a, double x1b, double x2b, double x3b) -{ - GbPoint3D *p1 = new GbPoint3D(pA); - GbPoint3D *p2 = new GbPoint3D(pB); - - if(UbMath::greater(x1a, x1b)) { double x1 = x1a; x1a = x1b; x1b = x1; } - if(UbMath::greater(x2a, x2b)) { double x2 = x2a; x2a = x2b; x2b = x2; } - if(UbMath::greater(x3a, x3b)) { double x3 = x3a; x3a = x3b; x3b = x3; } - - double f; - - /*-------------------------------------------------------------------*/ - /* Schneiden an vorderer Kante */ - /* */ - if(UbMath::less(p1->x3, x3a)) - { - if(UbMath::less(p2->x3, x3a)) { delete p1; delete p2; return NULL; } - - f = (x3a-p1->x3)/(p1->x3-p2->x3); - p1->x1 += (p1->x1-p2->x1)*f; - p1->x2 += (p1->x2-p2->x2)*f; - p1->x3 = x3a; - } - else if(UbMath::less(p2->x3, x3a)) - { - f = (x3a-p2->x3)/(p2->x3-p1->x3); - p2->x1 += (p2->x1-p1->x1)*f; - p2->x2 += (p2->x2-p1->x2)*f; - p2->x3 = x3a; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an unterer Kante */ - /* */ - if(UbMath::less(p1->x2, x2a)) - { - if(UbMath::less(p2->x2, x2a)) { delete p1; delete p2; return NULL; - } - - f = (x2a-p1->x2)/(p1->x2-p2->x2); - p1->x1 += (p1->x1-p2->x1)*f; - p1->x3 += (p1->x3-p2->x3)*f; - p1->x2 = x2a; - } - else if(UbMath::less(p2->x2, x2a)) - { - f = (x2a-p2->x2)/(p2->x2-p1->x2); - p2->x1 += (p2->x1-p1->x1)*f; - p2->x3 += (p2->x3-p1->x3)*f; - p2->x2 = x2a; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an rechter Kante */ - /* */ - if(UbMath::greater(p1->x1, x1b)) - { - if(UbMath::greater(p2->x1, x1b)) { delete p1;delete p2; return NULL;} - - f = (x1b-p1->x1)/(p1->x1-p2->x1); - p1->x2 += (p1->x2-p2->x2)*f; - p1->x3 += (p1->x3-p2->x3)*f; - p1->x1 = x1b; - } - else if(UbMath::greater(p2->x1, x1b)) - { - f = (x1b-p2->x1)/(p2->x1-p1->x1); - p2->x2 += (p2->x2-p1->x2)*f; - p2->x3 += (p2->x3-p1->x3)*f; - p2->x1 = x1b; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an hinterer Kante */ - /* */ - if(UbMath::greater(p1->x3, x3b)) - { - if(UbMath::greater(p2->x3, x3b)) { delete p1;delete p2; return NULL;} - - f = (x3b-p1->x3)/(p1->x3-p2->x3); - p1->x1 += (p1->x1-p2->x1)*f; - p1->x2 += (p1->x2-p2->x2)*f; - p1->x3 = x3b; - } - else if(UbMath::greater(p2->x3, x3b)) - { - f = (x3b-p2->x3)/(p2->x3-p1->x3); - p2->x1 += (p2->x1-p1->x1)*f; - p2->x2 += (p2->x2-p1->x2)*f; - p2->x3 = x3b; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an oberer Kante */ - /* */ - if(UbMath::greater(p1->x2, x2b)) - { - if(UbMath::greater(p2->x2, x2b)) { delete p1;delete p2; return NULL;} - - f = (x2b-p1->x2)/(p1->x2-p2->x2); - p1->x1 += (p1->x1-p2->x1)*f; - p1->x3 += (p1->x3-p2->x3)*f; - p1->x2 = x2b; - } - else if(UbMath::greater(p2->x2, x2b)) - { - f = (x2b-p2->x2)/(p2->x2-p1->x2); - p2->x1 += (p2->x1-p1->x1)*f; - p2->x3 += (p2->x3-p1->x3)*f; - p2->x2 = x2b; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an linker Kante */ - /* */ - if(UbMath::less(p1->x1, x1a)) - { - if(UbMath::less(p2->x1, x1a)) { delete p1;delete p2; return NULL;} - - f = (x1a-p1->x1)/(p1->x1-p2->x1); - p1->x2 += (p1->x2-p2->x2)*f; - p1->x3 += (p1->x3-p2->x3)*f; - p1->x1 = x1a; - } - else if(UbMath::less(p2->x1, x1a)) - { - f = (x1a-p2->x1)/(p2->x1-p1->x1); - p2->x2 += (p2->x2-p1->x2)*f; - p2->x3 += (p2->x3-p1->x3)*f; - p2->x1 = x1a; - } - /*-------------------------------------------------------------------*/ - return new GbLine3D(p1, p2); -} -// /*======================================================================*/ -// /* Private Methoden (Clipping Rectangles) */ -// /* */ -// final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x11, double x12, double x21, double x22) -// { -// GbPoint3D last = null; -// PointSet3 ps = new PointSet3(points); -// boolean flag = false; -// int n = points.length; -// int i; -// double f; -// -// if(n == 0) return(null); -// if(greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; } -// if(greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; } -// -// /*-------------------------------------------------------------------*/ -// /* Schneiden an unterer Kante */ -// /* */ -// if(less(ps.getX2Minimum(), x12)) -// { -// ps.clear(); -// last = points[0]; -// if(less((*points)[0]->x2, x12)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(less((*points)[i]->x2, x12)) -// { -// if(flag) -// { -// f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2); -// ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2); -// ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f)); -// } -// ps.add((*points)[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((less(points[0].x2, x12)) ^ flag)) -// { -// f = (x12-points[0].x2)/(points[0].x2-last->x2); -// ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last->x1)*f, x12, points[0].x3 + (points[0].x3-last->x3)*f)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// /* Schneiden an rechter Kante */ -// /* */ -// if(greater(ps.getX1Maximum(), x21)) -// { -// ps.clear(); -// last = points[0]; -// if(greater(points[0].x1, x21)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(greater((*points)[i]->x1, x21)) -// { -// if(flag) -// { -// f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1); -// ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1); -// ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f)); -// } -// ps.add(points[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((greater(points[0].x1, x21)) ^ flag)) -// { -// f = (x21-points[0].x1)/(points[0].x1-last.x1); -// ps.add(new GbPoint3D(x21, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// /* Schneiden an oberer Kante */ -// /* */ -// if(greater(ps.getX2Maximum(), x22)) -// { -// ps.clear(); -// last = points[0]; -// if(greater(points[0].x2, x22)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(greater((*points)[i]->x2, x22)) -// { -// if(flag) -// { -// f = (x22-(*points)[i]->x2)/(points[i].x2-last.x2); -// ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x22-points[i].x2)/(points[i].x2-last.x2); -// ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f)); -// } -// ps.add(points[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((greater(points[0].x2, x22)) ^ flag)) -// { -// f = (x22-points[0].x2)/(points[0].x2-last.x2); -// ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, x22, points[0].x3 + (points[0].x3-last.x3)*f)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// /* Schneiden an linker Kante */ -// /* */ -// if(less(ps.getX1Minimum(), x11)) -// { -// ps.clear(); -// last = points[0]; -// if(less(points[0].x1, x11)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(less(points[i].x1, x11)) -// { -// if(flag) -// { -// f = (x11-points[i].x1)/(points[i].x1-last.x1); -// ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x11-points[i].x1)/(points[i].x1-last.x1); -// ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f)); -// } -// ps.add(points[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((less(points[0].x1, x11)) ^ flag)) -// { -// f = (x11-points[0].x1)/(points[0].x1-last.x1); -// ps.add(new GbPoint3D(x11, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// GbPolygon3D polygon = new GbPolygon3D(points); -// -// if(n > 2) -// { -// for(i=2; i<n; i++) if(zero(i_TA(points[i-2], points[i-1], points[i]))) polygon.deletePoint(points[i-1]); -// if(zero(i_TA(points[n-2], points[n-1], points[0]))) polygon.deletePoint(points[n-1]); -// if(zero(i_TA(points[n-1], points[0], points[1]))) polygon.deletePoint(points[0]); -// } -// return(polygon); -// } -// final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x13, double x23) -// { -// GbPoint3D last = null; -// PointSet3 ps = new PointSet3(points); -// boolean flag = false; -// int n = points.length; -// int i; -// double f; -// -// if(n == 0) return(null); -// if(greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; } -// -// /*-------------------------------------------------------------------*/ -// /* Schneiden an vorderer Kante */ -// /* */ -// if(less(ps.getX3Minimum(), x13)) -// { -// ps.clear(); -// last = points[0]; -// if(less(points[0].x3, x13)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(less(points[i].x3, x13)) -// { -// if(flag) -// { -// f = (x13-points[i].x3)/(points[i].x3-last.x3); -// ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x13-points[i].x3)/(points[i].x3-last.x3); -// ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13)); -// } -// ps.add(points[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((less(points[0].x3, x13)) ^ flag)) -// { -// f = (x13-points[0].x3)/(points[0].x3-last.x3); -// ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x13)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// /* Schneiden an hinterer Kante */ -// /* */ -// if(greater(ps.getX3Maximum(), x23)) -// { -// ps.clear(); -// last = points[0]; -// if(greater(points[0].x3, x23)) flag = false; -// else -// { -// ps.add(points[0]); -// flag = true; -// } -// for(i=1; i<n; i++) -// { -// if(greater(points[i].x3, x23)) -// { -// if(flag) -// { -// f = (x23-points[i].x3)/(points[i].x3-last.x3); -// ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x23)); -// } -// flag = false; -// } -// else -// { -// if(!flag) -// { -// f = (x23-points[i].x3)/(points[i].x3-last.x3); -// ps.add(new GbPoint3D(points[i].x1 + ((*points)[i]->x1-last.x1)*f, (*points)[i]->x2 + ((*points)[i]->x2-last.x2)*f, x23)); -// } -// ps.add(points[i]); -// flag = true; -// } -// last = points[i]; -// } -// if(!((greater(points[0].x3, x23)) ^ flag)) -// { -// f = (x23-points[0].x3)/(points[0].x3-last.x3); -// ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x23)); -// } -// -// points = ps.getPoints(); -// n = points.length; -// -// if(n == 0) return(null); -// } -// /*-------------------------------------------------------------------*/ -// GbPolygon3D polygon = new GbPolygon3D(points); -// -// return(polygon); -// } -GbPolygon3D* GbSystem3D::clipPolygon3D(vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23) -{ - GbPoint3D last; - PointSet3 ps(points); - bool flag = false; - int n = (int)points.size(); - int i; - double f; - - if(n == 0) return NULL; - if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; } - if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; } - if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; } - - /*-------------------------------------------------------------------*/ - /* Schneiden an vorderer Kante */ - /* */ - if(UbMath::less(ps.getX3Minimum(), x13)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::less((points)[0].x3, x13)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::less((points)[i].x3, x13)) - { - if(flag) - { - f = (x13-(points)[i].x3)/((points)[i].x3-last.x3); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13)); - } - flag = false; - } - else - { - if(!flag) - { - f = (x13-(points)[i].x3)/((points)[i].x3-last.x3); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::less((points)[0].x3, x13)) ^ flag)) - { - f = (x13-(points)[0].x3)/((points)[0].x3-last.x3); - ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x13)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - - /*-------------------------------------------------------------------*/ - /* Schneiden an unterer Kante */ - /* */ - if(UbMath::less(ps.getX2Minimum(), x12)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::less((points)[0].x2, x12)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::less((points)[i].x2, x12)) - { - if(flag) - { - f = (x12-(points)[i].x2)/((points)[i].x2-last.x2); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - flag = false; - } - else - { - if(!flag) - { - f = (x12-(points)[i].x2)/((points)[i].x2-last.x2); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::less((points)[0].x2, x12)) ^ flag)) - { - f = (x12-(points)[0].x2)/((points)[0].x2-last.x2); - ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x12, (points)[0].x3 + ((points)[0].x3-last.x3)*f)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an rechter Kante */ - /* */ - - if(UbMath::greater(ps.getX1Maximum(), x21)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::greater((points)[0].x1, x21)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::greater((points)[i].x1, x21)) - { - if(flag) - { - f = (x21-(points)[i].x1)/((points)[i].x1-last.x1); - ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - flag = false; - } - else - { - if(!flag) - { - f = (x21-(points)[i].x1)/((points)[i].x1-last.x1); - ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::greater((points)[0].x1, x21)) ^ flag)) - { - f = (x21-(points)[0].x1)/((points)[0].x1-last.x1); - ps.add(GbPoint3D(x21, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an hinterer Kante */ - /* */ - if(UbMath::greater(ps.getX3Maximum(), x23)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::greater((points)[0].x3, x23)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::greater((points)[i].x3, x23)) - { - if(flag) - { - f = (x23-(points)[i].x3)/((points)[i].x3-last.x3); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23)); - } - flag = false; - } - else - { - if(!flag) - { - f = (x23-(points)[i].x3)/((points)[i].x3-last.x3); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::greater((points)[0].x3, x23)) ^ flag)) - { - f = (x23-(points)[0].x3)/((points)[0].x3-last.x3); - ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x23)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an oberer Kante */ - /* */ - - if(UbMath::greater(ps.getX2Maximum(), x22)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::greater((points)[0].x2, x22)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::greater((points)[i].x2, x22)) - { - if(flag) - { - f = (x22-(points)[i].x2)/((points)[i].x2-last.x2); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - flag = false; - } - else - { - if(!flag) - { - f = (x22-(points)[i].x2)/((points)[i].x2-last.x2); - ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::greater((points)[0].x2, x22)) ^ flag)) - { - f = (x22-(points)[0].x2)/((points)[0].x2-last.x2); - ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x22, (points)[0].x3 + ((points)[0].x3-last.x3)*f)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - /*-------------------------------------------------------------------*/ - /* Schneiden an linker Kante */ - /* */ - if(UbMath::less(ps.getX1Minimum(), x11)) - { - ps.clear(); - last = (points)[0]; - if(UbMath::less((points)[0].x1, x11)) flag = false; - else - { - ps.add((points)[0]); - flag = true; - } - for(i=1; i<n; i++) - { - if(UbMath::less((points)[i].x1, x11)) - { - if(flag) - { - f = (x11-(points)[i].x1)/((points)[i].x1-last.x1); - ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - - } - flag = false; - } - else - { - if(!flag) - { - f = (x11-(points)[i].x1)/((points)[i].x1-last.x1); - ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f)); - } - ps.add((points)[i]); - flag = true; - } - last = (points)[i]; - } - if(!((UbMath::less((points)[0].x1, x11)) ^ flag)) - { - f = (x11-(points)[0].x1)/((points)[0].x1-last.x1); - ps.add(GbPoint3D(x11, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f)); - } - - points = ps.getPoints(); - n = (int)points.size(); - - if(n == 0) return NULL; - } - /*-------------------------------------------------------------------*/ - return new GbPolygon3D(points); -} -/*=========================================================================*/ -GbCuboid3D* GbSystem3D::clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23) -{ - double r11 = p1.x1; - double r12 = p1.x2; - double r13 = p1.x3; - double r21 = p2.x1; - double r22 = p2.x2; - double r23 = p2.x3; - - if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; } - if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; } - if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; } - if(UbMath::greater(r11, r21)) { double bx = r11; r11 = r21; r21 = bx; } - if(UbMath::greater(r12, r22)) { double by = r12; r12 = r22; r22 = by; } - if(UbMath::greater(r13, r23)) { double bz = r13; r13 = r23; r23 = bz; } - - double m11 = UbMath::greater(x11, r11) ? x11 : r11; - double m12 = UbMath::greater(x12, r12) ? x12 : r12; - double m13 = UbMath::greater(x13, r13) ? x13 : r13; - double m21 = UbMath::greater(x21, r21) ? r21 : x21; - double m22 = UbMath::greater(x22, r22) ? r22 : x22; - double m23 = UbMath::greater(x23, r23) ? r23 : x23; - - if(UbMath::lessEqual(m11, m21) && UbMath::lessEqual(m12, m22) && UbMath::lessEqual(m13, m23)) - return(new GbCuboid3D(new GbPoint3D(m11, m12, m13), new GbPoint3D(m21, m22, m23))); - else - return(NULL); -} - -/*=========================================================================*/ -/*=========================================================================*/ -/*=========================================================================*/ - - -GbSystem3D::PointSet3::PointSet3(int n) -{ - this->init(); - this->points.reserve(n); //reserves n elements! but the size of the vector ist still "0" -} -/*=======================================================*/ -GbSystem3D::PointSet3::PointSet3(const vector<GbPoint3D>& points) -{ - this->init(); - this->add(points); -} -/*=======================================================*/ -void GbSystem3D::PointSet3::add(const GbPoint3D& point) -{ - //is point equal to last point in points then return - if(!this->points.empty() && point.equals(&this->points.back())) return; //WHY??? - - //push point to vector - this->points.push_back(point); - - this->consistent = false; -} -/*=======================================================*/ -void GbSystem3D::PointSet3::addUnequal(const GbPoint3D& point) -{ - if(this->containsEqual(point) > 0) return; - - this->points.push_back(point); - this->consistent = false; -} -/*=======================================================*/ -void GbSystem3D::PointSet3::add(const vector<GbPoint3D>& pointVector) -{ - for(int pos=0; pos<(int)pointVector.size(); pos++ ) - this->points.push_back(pointVector[pos]); - - this->consistent = false; -} -/*=======================================================*/ -void GbSystem3D::PointSet3::insert(const GbPoint3D& point, int index) -{ - if(index<0 || index>=(int)this->points.size()) - throw UbException(UB_EXARGS,"index out of range"); - - //get iterator for index-position - vector<GbPoint3D>::iterator pos=this->points.begin(); - for(int i=1; i<=index; i++) ++pos; - - //insert point - this->points.insert(pos,point); - - this->consistent = false; -} -/*=======================================================*/ -//void delete(GbPoint3D point) -//{ -// for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i); -//} -/*=======================================================*/ -//void delete(int index) -//{ -// int j = this.size - index - 1; -// if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j); -// this.consistent = false; -// this.size--; -//} -/*=======================================================*/ -void GbSystem3D::PointSet3::clear() -{ - //clears points (size==0 but capacity is the old one) - this->points.clear(); - this->consistent = false; -} -/*=======================================================*/ -void GbSystem3D::PointSet3::clearAndTrim() -{ - //clears points (size==0 AND capacity==0) - this->points.resize(0); - this->consistent = false; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return this->x1min; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return this->x1max; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return this->x2min; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return this->x2max; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return this->x3min; -} -/*=======================================================*/ -double GbSystem3D::PointSet3::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return this->x3max; -} -/*=======================================================*/ -int GbSystem3D::PointSet3::contains(GbPoint3D* point) -{ - //returns number of points which has the same adress (this should be 0 or 1!!!) - int n=0; - - for(int pos=(int)this->points.size()-1; pos>=0; pos--) - if(&this->points[pos]==point) n++; - - return n; -} -/*=======================================================*/ -int GbSystem3D::PointSet3::containsEqual(const GbPoint3D& point) -{ - //returns number of points which have the same coordinates with point (could be 0,1 or even more) - int n=0; - - for(int pos=(int)this->points.size()-1; pos>=0; pos--) - if(this->points[pos].equals(&point)) n++; - - return n; -} -/*=======================================================*/ -bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2) -{ - //returns true if pointset has two in "this->points"vector neighboured points - //wich have the same adress as point1 or point2 - vector<GbPoint3D>::iterator pos1=this->points.begin(); - vector<GbPoint3D>::iterator pos2; - - for(pos2=pos1++; pos2!=this->points.end(); ++pos2) - { - if (&(*pos1)==point1 && &(*pos2)==point2) return true; - else if(&(*pos1)==point2 && &(*pos2)==point1) return true; - - pos1=pos2; - } - - return false; -} -/*=======================================================*/ -bool GbSystem3D::PointSet3::containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2) -{ - //returns true if pointset has two in "this->points"vector neighboured points - //wich have the same coordinates as point1 or point2 - vector<GbPoint3D>::iterator pos1=this->points.begin(); - vector<GbPoint3D>::iterator pos2; - - for(pos2=pos1++; pos2!=this->points.end(); ++pos2) - { - if ((*pos1).equals(&point1) && (*pos2).equals(&point2)) return true; - else if((*pos1).equals(&point2) && (*pos2).equals(&point1)) return true; - - pos1=pos2; - } - - return false; -} -/*=======================================================*/ -GbPoint3D* GbSystem3D::PointSet3::getPoint(int index) -{ - if(index<0 || index>=(int)this->points.size()) throw UbException(UB_EXARGS,"index out of range"); - return &(this->points)[index]; -} -/*=======================================================*/ -GbPoint3D* GbSystem3D::PointSet3::getFirstPoint() -{ - return &(this->points.front()); -} -/*=======================================================*/ -GbPoint3D* GbSystem3D::PointSet3::getLastPoint() -{ - return &(this->points.back()); -} -/*=======================================================*/ -int GbSystem3D::PointSet3::size() -{ - return (int)this->points.size(); -} -/*=======================================================*/ -vector<GbPoint3D> GbSystem3D::PointSet3::getPoints() -{ - //is this right? it's another effect as at GbPoint3D* getNode(index)!!! - //or do we want to have the next uncommented getPoints() funktion - return this->points; -} -///*=======================================================*/ -//vector<GbPoint3D*> GbSystem3D::PointSet3::getPoints() -//{ -// vector<GbPoint3D*> tmp; -// for(int pos=0; pos<(int)this->points.size();pos++) tmp.push_back(&this->points[pos]); -// -// return tmp; -//} -/*=======================================================*/ -void GbSystem3D::PointSet3::calculateValues() -{ - if(this->points.empty()) - { - this->x1min = this->x2min = this->x3min = 0.0; - this->x1max = this->x2max = this->x3max = 0.0; - } - else - { - this->x1min = (this->points)[0].x1; - this->x1max = (this->points)[0].x1; - this->x2min = (this->points)[0].x2; - this->x2max = (this->points)[0].x2; - this->x3min = (this->points)[0].x3; - this->x3max = (this->points)[0].x3; - - for(int i=(int)this->points.size()-1; i>0; --i) - { - if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1; - if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1; - if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2; - if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2; - if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3; - if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3; - } - } - this->consistent = true; -} - - - diff --git a/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h b/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h deleted file mode 100644 index a3f579b282f16b5c74b4958688305081c09b7c29..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h +++ /dev/null @@ -1,396 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBSYSTEM3D_H -#define GBSYSTEM3D_H - -#include <iostream> -#include <cmath> -#include <vector> - -#include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/writer/WbWriter.h> - -class GbPolygon3D; -class GbCuboid3D; -class GbLine3D; - -namespace GbSystem3D -{ - extern double getDistance(const GbPoint3D& p11, const GbPoint3D& p12); - extern GbPoint3D* calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22); - extern GbPolygon3D* clipPolygon3D(std::vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23); - extern GbLine3D* createClipLine3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23); - extern bool hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22); - extern bool isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22); - extern GbCuboid3D* clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23); - - /*========================================================================================*/ - inline static std::string writeGeoObject(GbObject3D* gbobject, const std::string& filename, WbWriter* writer) - { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - gbobject->addSurfaceTriangleSet(nodes, triangles); - - std::string outFilename = writer->writeTriangles(filename,nodes,triangles); - return outFilename; - } - //the same as before - /*========================================================================================*/ - inline static std::string writeGeoObject(GbObject3DPtr gbobject, const std::string& filename, WbWriter* writer) - { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - gbobject->addSurfaceTriangleSet(nodes, triangles); - - std::string outFilename = writer->writeTriangles(filename,nodes,triangles); - return outFilename; - } - /*========================================================================================*/ - inline static std::vector< std::string > writeGeoObject(GbObject3D* gbobject, const std::string& filename, std::vector< WbWriter* > writer ) - { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - gbobject->addSurfaceTriangleSet(nodes, triangles); - - std::vector< std::string > outFilenames; - for(std::size_t i=0; i<writer.size(); ++i) - outFilenames.push_back( writer[i]->writeTriangles(filename,nodes,triangles) ); - return outFilenames; - } - /*========================================================================================*/ - inline static std::string writeGeoObjects(std::vector< GbObject3D* > gbobjects, const std::string& filename, WbWriter* writer) - { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - - for(std::size_t i=0; i<gbobjects.size(); ++i) - { - //std::cout<<i<<", "<<gbobjects[i]<<std::endl; - gbobjects[i]->addSurfaceTriangleSet(nodes, triangles); - } - - std::string outFilename = writer->writeTriangles(filename,nodes,triangles); - return outFilename; - } - /*========================================================================================*/ - - ////////////////////////////////////////////////////////////////////////// - class PointSet3 - { - public: - PointSet3(int n); - PointSet3(const std::vector<GbPoint3D>& points); - ~PointSet3(){} - void add(const GbPoint3D& point); - void addUnequal(const GbPoint3D& point); - void add(const std::vector<GbPoint3D>& p); - int contains(GbPoint3D* point); - void insert(const GbPoint3D& point, int index); - void clear(); - void clearAndTrim(); - int containsEqual(const GbPoint3D& point); - bool containsLine(GbPoint3D* point1, GbPoint3D* point2); - bool containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2); - double getX1Minimum(); - double getX1Maximum(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Minimum(); - double getX3Maximum(); - void calculateValues(); - int size(); - GbPoint3D* getPoint(int index); - GbPoint3D* getFirstPoint(); - GbPoint3D* getLastPoint() ; - std::vector<GbPoint3D> getPoints(); - - private: - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; - std::vector<GbPoint3D> points; - - void init() - { - consistent = false; - x1min = x2min = x3min = 0.0; - x1max = x2max = x3max = 0.0; - } - }; - /*=================================================================*/ - class OldPointSet3 - { - private: - int sizet; - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; - std::vector<GbPoint3D> points; - - void init() - { - sizet = 0; - x1min = 0.0; - x1max = 0.0; - x2min = 0.0; - x2max = 0.0; - x3min = 0.0; - x3max = 0.0; - consistent = false; - //points = NULL; - }; - - public: - OldPointSet3(int n) - { - this->init(); - this->points.resize(n); - } - OldPointSet3(std::vector<GbPoint3D> &points) - { - this->init(); - this->points.resize(0);//, NULL); - this->add(points); - }; - ~OldPointSet3() - { - // delete points; - }; - void add(GbPoint3D point) - { - if(this->sizet>0 && point.equals(&(this->points)[this->sizet-1])) return; - if(this->sizet == (int)this->points.size()) - { - std::vector<GbPoint3D> a; - a.resize(1+(this->sizet<<1)); - for(int u=0; u<this->sizet; u++) { (a)[u] = (points)[u]; } - this->points = a; - } - (this->points)[this->sizet] = point; - this->consistent = false; - this->sizet++; - } - void addUnequal(GbPoint3D *point) - { - if(this->containsEqual(point) > 0) return; - if(this->sizet == (int)this->points.size()) - { - std::vector<GbPoint3D> a; - a.resize(1+(this->sizet<<1)); - for(int u=0; u<this->sizet; u++) { (a)[u] = (points)[u]; } - this->points = a; - } - (this->points)[this->sizet] = point; - this->consistent = false; - this->sizet++; - } - void add(std::vector<GbPoint3D> &p) - { - if(this->sizet+p.size() >= this->points.size()) - { - std::vector<GbPoint3D> a; - a.resize(this->sizet+p.size()); - for(int u=0; u<(int)this->points.size(); u++) { (a)[u] = (this->points)[u]; } - this->points = a; - } - int u = this->sizet;// (int)this->points->size(); - for(int b=0; b<(int)p.size(); b++) (this->points)[u++] = (p)[b]; - //u = this->sizet; - //for(int b=0; b<(int)p->size(); b++) - // cout<<(this->points)[u++].toString()<<endl; - this->consistent = false; - this->sizet += (int)p.size(); - }; - // void insert(GbPoint3D *point, int index) - // { - // if(this.size == this.points.length) - // { - // GbPoint3D a[] = new GbPoint3D[1+(this.size<<1)]; - // System.arraycopy(this.points, 0, a, 0, this.size); - // this.points = a; - // } - // System.arraycopy(this.points, index, this.points, index+1, this.size-index); - // this.points[index] = point; - // this.consistent = false; - // this.size++; - // } - // void delete(GbPoint3D point) - // { - // for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i); - // } - // void delete(int index) - // { - // int j = this.size - index - 1; - // if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j); - // this.consistent = false; - // this.size--; - // } - void clear() - { - this->sizet = 0; - this->consistent = false; - } - void clearAndTrim() - { - this->sizet = 0; - this->points.resize(0); - this->consistent = false; - } - - double getX1Minimum() - { - if(!this->consistent) this->calculateValues(); - return(this->x1min); - } - double getX1Maximum() - { - if(!this->consistent) this->calculateValues(); - return(this->x1max); - } - double getX2Minimum() - { - if(!this->consistent) this->calculateValues(); - return(this->x2min); - } - double getX2Maximum() - { - if(!this->consistent) this->calculateValues(); - return(this->x2max); - } - double getX3Minimum() - { - if(!this->consistent) this->calculateValues(); - return(this->x3min); - } - double getX3Maximum() - { - if(!this->consistent) this->calculateValues(); - return(this->x3max); - } - void calculateValues() - { - this->x1min = 0.0; - this->x1max = 0.0; - this->x2min = 0.0; - this->x2max = 0.0; - this->x3min = 0.0; - this->x3max = 0.0; - this->consistent = true; - - if(this->sizet == 0) return; - - this->x1min = (this->points)[0].x1; - this->x1max = (this->points)[0].x1; - this->x2min = (this->points)[0].x2; - this->x2max = (this->points)[0].x2; - this->x3min = (this->points)[0].x3; - this->x3max = (this->points)[0].x3; - - for(int i=this->sizet-1; i>0; i--) - { - if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1; - if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1; - if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2; - if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2; - if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3; - if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3; - } - }; - - int contains(GbPoint3D *point) - { - int n = 0; - for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point) n++; - return(n); - }; - int containsEqual(GbPoint3D *point) - { - int n = 0; - for(int i=this->sizet-1; i>=0; i--) if((this->points)[i].equals(point)) n++; - return(n); - } - bool containsLine(GbPoint3D *point1, GbPoint3D *point2) - { - for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point1) - { - if(i == 0) - { - if(&(this->points)[i+1] == point2) return(true); - if(&(this->points)[this->sizet-1] == point2) return(true); - } - else if(i == this->sizet-1) - { - if(&(this->points)[0] == point2) return(true); - if(&(this->points)[i-1] == point2) return(true); - } - else - { - if(&(this->points)[i+1] == point2) return(true); - if(&(this->points)[i-1] == point2) return(true); - } - } - return(false); - }; - // boolean containsEqualLine(GbPoint2D point1, GbPoint2D point2) - // { - // for(int i=this.size-1; i>=0; i--) if(this.points[i].equals(point1)) - // { - // if(i == 0) - // { - // if(this.points[i+1].equals(point2)) return(true); - // if(this.points[this.size-1].equals(point2)) return(true); - // } - // else if(i == this.size-1) - // { - // if(this.points[0].equals(point2)) return(true); - // if(this.points[i-1].equals(point2)) return(true); - // } - // else - // { - // if(this.points[i+1].equals(point2)) return(true); - // if(this.points[i-1].equals(point2)) return(true); - // } - // } - // return(false); - // } - GbPoint3D *getPoint(int index) - { - return(&(this->points)[index]); - } - GbPoint3D *getFirstPoint() - { - return(&(this->points)[0]); - } - GbPoint3D *getLastPoint() { return(&(this->points)[this->sizet-1]); } - int size() { return(this->sizet); } - std::vector<GbPoint3D> getPoints() - { - points.resize(sizet); - return points; - //int l = this->sizet; - //if(l > 1 && (this->points)[0].equals(&(this->points)[l-1])) l--; - - //vector<GbPoint3D*> *a = new vector<GbPoint3D*>; - //a->resize(l, NULL); - //for(int u=0; u<l; u++) { (*a)[u] = &((points)[u]); } - //return(a); - } - }; - /*=================================================================*/ -} - -#endif //GBSYSTEM3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp deleted file mode 100644 index 70cc36cfd640cd6fe3f93fdfb05e7fd3ec81c58d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp +++ /dev/null @@ -1,1146 +0,0 @@ - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <basics/utilities/UbRandom.h> -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbLogger.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -using namespace std; - -GbTriFaceMesh3D::GbTriFaceMesh3D() - : GbObject3D() - , buildVertTriRelationMap(false) - , kdTree(NULL) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) - -{ - this->setName("CAB_GbTriFaceMesh3D"); - this->nodes = new vector<Vertex>; - this->triangles = new vector<TriFace>; - this->consistent = false; - this->kdtreeSplitAlg = KDTREE_SAHPLIT; -} -/*=======================================================================*/ -GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) - : GbObject3D() - , nodes(nodes) - , triangles(triangles) - , buildVertTriRelationMap(false) - , consistent(false) - , kdTree(NULL) - , kdtreeSplitAlg(splitAlg) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) -{ - if( name.empty() ) throw UbException(UB_EXARGS,"no name specified"); - if( !nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if( !triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - - this->setName(name); - - if(removeRedundantNodes) - { - this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen - } - else - { - this->calculateValues(); - } -} -/*=======================================================================*/ -GbTriFaceMesh3D::~GbTriFaceMesh3D() -{ - if( nodes ) { delete nodes; nodes = NULL; } - if( triangles ) { delete triangles; triangles = NULL; } - if( kdTree ) { delete kdTree; kdTree = NULL; } -} -/*======================================================================*/ -ObObjectCreator* GbTriFaceMesh3D::getCreator() -{ - return GbTriFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::init() -{ - nodes = NULL; - triangles = NULL; - x1min = 0.0; - x1max = 0.0; - x1center = 0.0; - x2min = 0.0; - x2max = 0.0; - x2center = 0.0; - x3min = 0.0; - x3max = 0.0; - x3center = 0.0; - consistent = false; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3D::clone() -{ - vector<GbTriFaceMesh3D::Vertex> *newNodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *newTriangles = new vector<GbTriFaceMesh3D::TriFace>; - - int numberNodes = (int)this->nodes->size(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=(*nodes)[u].x; - y=(*nodes)[u].y; - z=(*nodes)[u].z; - newNodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int numberTris = (int)this->triangles->size(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - id1 = (*this->triangles)[u].v1; - id2 = (*this->triangles)[u].v2; - id3 = (*this->triangles)[u].v3; - newTriangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D("no name", newNodes, newTriangles); - UBLOG(logDEBUG1,"mesh cloned ..."); - - return mesh; -} - -/*======================================================================*/ -//checks for doppelt nodes und fixed Dreicke die zweimal denselben Knoten haben -void GbTriFaceMesh3D::deleteRedundantNodes() -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size()); - - map<Vertex,size_t/*new vecIndex*/> vertexMap; - map<Vertex,size_t/*new vecIndex*/>::iterator pos; - map<Vertex,size_t/*new vecIndex*/>::iterator it; - - vector<TriFace>& tris = *this->triangles; - vector<Vertex>& oldNodes = *this->nodes; - vector<Vertex> newNodes; - - for(size_t t=0; t<tris.size(); t++) - { - if(t%100==0) UBLOG(logDEBUG5,"GbTriFaceMesh3D::deleteRedundantNodes - tri: "<<(t)<<" von "<<tris.size()); - TriFace& tri = tris[t]; - //Knoten bereits in neuem node vector? - for(int v=0; v<=2; v++) - { - Vertex& vert = tri.getNode(v,oldNodes); - //pos=vertexMap.find( vert ); - //if( pos==vertexMap.end() ) - { - for(pos=vertexMap.begin();pos!=vertexMap.end();pos++) - { - Vertex rhs = pos->first; - //if(UbMath::inClosedInterval(vert.z,0.01999, 0.02001)) - if ( fabs(vert.x-rhs.x)<1.E-5 && fabs(vert.y-rhs.y)<1.E-5 && fabs(vert.z-rhs.z)<1.E-5 ) - { - break; - } - } - } - if( pos!=vertexMap.end() ) tri.setNode(v, (int)pos->second); - else - { - newNodes.push_back(vert); - int index = (int)newNodes.size()-1; - vertexMap[vert] = index; - tri.setNode(v,index); - } - } - } - - std::swap(*nodes,newNodes); - - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size()); - // - //Das geht irgendwie nicht ... - // - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for double triangles !!!"); - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles before deleting redundant: "<<this->triangles->size()); - //vector<TriFace> newSingleTris; - //newSingleTris.reserve( this->triangles->size() ); - //for(size_t t=0; t<tris.size(); t++) - //{ - // Vertex& v1 = tris[t].getNode(0,*nodes); - // Vertex& v2 = tris[t].getNode(1,*nodes); - // Vertex& v3 = tris[t].getNode(2,*nodes); - - // if(UbMath::greater(std::fabs(v1.x), 0.0634) && UbMath::inClosedInterval(v1.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V1:"<<v1.x<<" "<<v1.y<<" "<<v1.z); - // } - // if(UbMath::greater(std::fabs(v2.x), 0.0634) && UbMath::inClosedInterval(v2.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V2:"<<v2.x<<" "<<v2.y<<" "<<v2.z); - // } - // if(UbMath::greater(std::fabs(v3.x), 0.0634) && UbMath::inClosedInterval(v3.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V3:"<<v3.x<<" "<<v3.y<<" "<<v3.z); - // } - - // bool inList = false; - // for(size_t u=0; u<newSingleTris.size(); u++) - // { - // Vertex& vn1 = newSingleTris[t].getNode(0,*nodes); - // Vertex& vn2 = newSingleTris[t].getNode(1,*nodes); - // Vertex& vn3 = newSingleTris[t].getNode(2,*nodes); - - // if(v1==vn1 && v2==vn2 && v3==vn3) inList = true; - // else if(v1==vn1 && v2==vn3 && v3==vn2) inList = true; - // else if(v1==vn2 && v2==vn3 && v3==vn1) inList = true; - // else if(v1==vn2 && v2==vn1 && v3==vn3) inList = true; - // else if(v1==vn3 && v2==vn1 && v3==vn2) inList = true; - // else if(v1==vn3 && v2==vn2 && v3==vn1) inList = true; - // } - // if(!inList) newSingleTris.push_back(tris[t]); - // else - // UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - inList !!!!"); - - //} - //swap(tris,newSingleTris); - - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles after deleting redundant:"<<this->triangles->size()); - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!"); - int counter1 = 0; - int counter2 = 0; - vector<TriFace> newTris; - newTris.reserve( this->triangles->size() ); - for(size_t t=0; t<tris.size(); t++) - { - Vertex& v1 = tris[t].getNode(0,*nodes); - Vertex& v2 = tris[t].getNode(1,*nodes); - Vertex& v3 = tris[t].getNode(2,*nodes); - if( v1==v2 || v1==v3 || v2==v3 ) - { - counter1++; - } - else if( tris[t].getArea(*nodes)<1.0E-8 ) - { - counter2++; - } - else newTris.push_back(tris[t]); - } - if(counter1) - { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter1<<" triangle with double nodes!"); - } - if(counter2) - { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter2<<" triangle that are lines!") ; - } - if(!counter1 && !counter2) { UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); } - else swap(tris,newTris); - - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - done" ); - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode) -{ - if(kdTree && mode != this->kdtreeSplitAlg) { delete kdTree; kdTree = NULL; } - this->kdtreeSplitAlg = mode; -} -/*======================================================================*/ - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbTriFaceMesh3D::toString() -{ - stringstream ss; - ss<<"GbTriFaceMesh3D["; - ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbTriFaceMesh3D::Vertex>* GbTriFaceMesh3D::getNodes() { return this->nodes; } -/** - * Returns the triangles of this triangular mesh. - * @return the triangles of this triangular mesh - */ -vector<GbTriFaceMesh3D::TriFace>* GbTriFaceMesh3D::getTriangles() { return this->triangles; } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbTriFaceMesh3D::getVolume() -{ - vector<Vertex>& vertices = *nodes; - vector<TriFace>& tris = *triangles; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3, G3i; - //double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - for(size_t t=0; t<tris.size(); t++) - { - TriFace& triangle = tris[t]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - } - return volume; -} -/*===============================================*/ -UbTupleDouble3 GbTriFaceMesh3D::calculateCenterOfGravity() -{ - vector<Vertex>& vertices = *nodes; - vector<TriFace>& tris = *triangles; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double rSP1 = 0.0, rSP2 = 0.0, rSP3 = 0.0, volume = 0.0; - - for(size_t t=0; t<tris.size(); t++) - { - TriFace& triangle = tris[t]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - return UbTupleDouble3(rSP1, rSP2, rSP3); -} -/*===============================================*/ -UbTupleDouble6 GbTriFaceMesh3D::calculateMomentOfInertia(double rhoP) -{ - vector<Vertex>& vertices = *nodes; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double xx,yy,zz,xy,yz,zx; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - double top11 = 0.0;double top22 = 0.0;double top33 = 0.0; - double top12 = 0.0;double top23 = 0.0;double top13 = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - TriFace& triangle = (*this->triangles)[u]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - double x1s = 0.0;//rSP1;//0.0;// - double x2s = 0.0;//rSP2;//0.0;// - double x3s = 0.0;//rSP3;//0.0;// - - for(int u=0; u<size;u++) - { - TriFace& triangle = (*this->triangles)[u]; - x1 = triangle.getV1x(vertices)-x1s; - y1 = triangle.getV1y(vertices)-x2s; - z1 = triangle.getV1z(vertices)-x3s; - x2 = triangle.getV2x(vertices)-x1s; - y2 = triangle.getV2y(vertices)-x2s; - z2 = triangle.getV2z(vertices)-x3s; - x3 = triangle.getV3x(vertices)-x1s; - y3 = triangle.getV3y(vertices)-x2s; - z3 = triangle.getV3z(vertices)-x3s; - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume); - //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume); - //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume); - xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1; - yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1; - zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1; - top11 = top11+(yy+zz)*rhoP*G3i/60.; - top22 = top22+(xx+zz)*rhoP*G3i/60.; - top33 = top33+(yy+xx)*rhoP*G3i/60.; - xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1; - yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1; - zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1; - top12 = top12-xy*rhoP*G3i/120.; - top23 = top23-yz*rhoP*G3i/120.; - top13 = top13-zx*rhoP*G3i/120.; - } - //Satz von Steiner ... - top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3); - top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1); - top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2); - top12 = top12+rhoP*volume*rSP1*rSP2; - top23 = top23+rhoP*volume*rSP2*rSP3; - top13 = top13+rhoP*volume*rSP3*rSP1; - - cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n"; - cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl; - cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl; - - return UbTupleDouble6(top11,top22,top33,top12,top23,top13); -} -/*==============================================================*/ -void GbTriFaceMesh3D::calculateValues() -{ - relationVertTris.clear(); - - if( nodes->empty() ) - { - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; - } - else - { - Vertex& v = (*nodes)[0]; - x1min = x1max = v.x; - x2min = x2max = v.y; - x3min = x3max = v.z; - - for(size_t i=1; i<this->nodes->size(); i++) - { - Vertex& v1 = (*nodes)[i]; - - x1min = UbMath::min<double>(x1min,v1.x); - x2min = UbMath::min<double>(x2min,v1.y); - x3min = UbMath::min<double>(x3min,v1.z); - - x1max = UbMath::max<double>(x1max,v1.x); - x2max = UbMath::max<double>(x2max,v1.y); - x3max = UbMath::max<double>(x3max,v1.z); - } - x1center = 0.5 * (x1min + x1max ); - x2center = 0.5 * (x2min + x2max ); - x3center = 0.5 * (x3min + x3max ); - - vector<TriFace>& tris = *this->triangles; - vector<Vertex>& verts = *this->nodes; - for(size_t i=0; i<this->triangles->size(); i++) - { - tris[i].calculateNormal(verts); - } - //relation Vertex <-> Triangle ermitteln - if(buildVertTriRelationMap) - { - for(size_t t=0; t<tris.size(); t++) - { - TriFace& tri = tris[t]; - relationVertTris.insert( make_pair( &verts[tri.v1], &tri) ); - relationVertTris.insert( make_pair( &verts[tri.v2], &tri) ); - relationVertTris.insert( make_pair( &verts[tri.v3], &tri) ); - } - } - } - if(kdTree) - { - delete kdTree; - kdTree=NULL; - } - - this->consistent = true; -} -/*=========================================================================*/ -std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Vertex* vertex) -{ - if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false;} - if(!consistent) this->calculateValues(); - - typedef std::multimap<Vertex*,TriFace*>::iterator Iterator; - pair<Iterator,Iterator> objRange = relationVertTris.equal_range(vertex); - - std::vector<TriFace*> tmpTris; - for(Iterator pos=objRange.first; pos!=objRange.second; ++pos) - tmpTris.push_back( pos->second ); - - return tmpTris; -} -/*=======================================================*/ -void GbTriFaceMesh3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} - -/*======================================================================*/ -void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), sx1, sx2, sx3, 0, 0, 0); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::rotate(const double& alpha, const double& beta, const double& gamma) -{ - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma) -{ - CoordinateTransformation3D trafoForw(px1, px2, px3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(px1, px2, px3, 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} - - -/*======================================================================*/ -void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double& x3) -{ - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - v.x += static_cast<float>(x1); - v.y += static_cast<float>(x2); - v.z += static_cast<float>(x3); - } - this->calculateValues(); -} -/*======================================================================*/ -vector<GbTriangle3D*> GbTriFaceMesh3D::getSurfaceTriangleSet() -{ - //SirAnn: eine miese Speicherlochmethode - // hier werden dynmamische Objekte angelegt - // mit sowas rechnet von aussen kein Mensch!!! - vector<GbTriangle3D*> tris( triangles->size() ); - - for(size_t i=0; i<this->triangles->size(); i++) - { - Vertex& v1 = (*nodes)[(*triangles)[i].v1]; - Vertex& v2 = (*nodes)[(*triangles)[i].v2]; - Vertex& v3 = (*nodes)[(*triangles)[i].v3]; - - tris[i] = new GbTriangle3D( new GbPoint3D(v1.x,v1.y,v1.z) - , new GbPoint3D(v2.x,v2.y,v2.z) - , new GbPoint3D(v3.x,v3.y,v3.z) ); - } - return tris; -} -/*=======================================================*/ -void GbTriFaceMesh3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& pts, vector<UbTupleInt3>& tris) -{ - for(int i=0; i<(int)this->triangles->size(); i++) - { - Vertex& v1 = (*nodes)[(*triangles)[i].v1]; - Vertex& v2 = (*nodes)[(*triangles)[i].v2]; - Vertex& v3 = (*nodes)[(*triangles)[i].v3]; - pts.push_back( makeUbTuple(v1.x,v1.y,v1.z)); - pts.push_back( makeUbTuple(v2.x,v2.y,v2.z)); - pts.push_back( makeUbTuple(v3.x,v3.y,v3.z)); - - tris.push_back( makeUbTuple( 3*i, 3*i+1, 3*i+2) ); - } -} -/*======================================================================*/ -//bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) -//{ -// -// -// if( !nodes->empty() ) -// { -// //Baum erstellen, wen noch keiner vorhanden -// if( !kdTree) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); -// UbTimer timer; timer.start(); -// if(kdtreeSplitAlg == KDTREE_SAHPLIT ) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); -// } -// else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); -// } -// else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); -// } -// -// //eigentlicher PIO-Test -// //int iSec; -// //for(int i=0; i<100; i++) -// //{ -// // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); -// // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); -// // -// // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); -// // -// // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen -// // { -// // if(iSec == Kd::Intersection::ON_BOUNDARY ) -// // { -// // return true; -// // } -// // return (iSec&1); //ungerade anzahl an schnitten --> drinnen -// // } -// // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); -// //} -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// int iSec1,iSec2; -// -// Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); -// iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); -// Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); -// iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); -// -// if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) -// { -// return true; -// } -// if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec2&1); -// } -// else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec1&1); -// } -// else -// { -// if((iSec1&1) != (iSec2&1)) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// return iSec1&1; -// } -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// -// } -// return false; -//} -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) -{ - - - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - //int iSec; - //for(int i=0; i<100; i++) - //{ - // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - // - // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - // - // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - // { - // if(iSec == Kd::Intersection::ON_BOUNDARY ) - // { - // return true; - // } - // return (iSec&1); //ungerade anzahl an schnitten --> drinnen - // } - // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - //} - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - int iSec1,iSec2; - double eps = 0.05; - Kd::Ray<double> ray1( x1, x2, x3, 1.0+eps*((double)counter), eps*((double)counter) ,eps*((double)counter) ); - iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - Kd::Ray<double> ray2( x1, x2, x3, -1.0-eps*((double)counter), -eps*((double)counter) ,-eps*((double)counter) ); - - iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - { - return true; - } - if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec2&1); - } - else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec1&1); - } - else - { - if((iSec1&1) != (iSec2&1)) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - return iSec1&1; - } - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - } - return false; -} -/*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - int counter=0; - - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<100; i++) - { - Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - return true; - } - return (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - // int iSec1,iSec2; - // - // Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); - // iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - // Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); - // iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - // if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - // { - // return true; - // } - // if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec2&1); - // } - // else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec1&1); - // } - // else - // { - // if((iSec1&1) != (iSec2&1)) - // { - // UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // return iSec1&1; - // } - // //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - } - return false; -} -/*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<100; i++) - { - Kd::Ray<double> ray( x1, x2, x3 - , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - pointIsOnBoundary = true; - return true; - } - pointIsOnBoundary = false; - return (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - } - - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - - return false; -} -/*======================================================================*/ -GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -void GbTriFaceMesh3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeInteger((int)kdtreeSplitAlg); - out->writeBool(transferViaFilename); - - if(!transferViaFilename) - { - //nodes - vector<Vertex>& vertices = *nodes; - out->writeSize_t( nodes->size() ); - out->writeLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - out->writeFloat(v.x); - out->writeFloat(v.y); - out->writeFloat(v.z); - out->writeLine(); - } - - //triangles - vector<TriFace>& tris = *triangles; - out->writeSize_t( tris.size() ); - out->writeLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - out->writeInteger(t.v1); - out->writeInteger(t.v2); - out->writeInteger(t.v3); - out->writeLine(); - } - } - else - { - out->writeString(filename); - out->writeLine(); - out->writeDouble(transX1); - out->writeDouble(transX2); - out->writeDouble(transX3); - - } -} -/*======================================================================*/ -void GbTriFaceMesh3D::read(UbFileInput* in) -{ - kdtreeSplitAlg = (KDTREE_SPLITAGORITHM)in->readInteger(); - transferViaFilename = in->readBool(); - - if(!transferViaFilename) - { - if(!nodes) nodes = new vector<Vertex>; - //nodes - vector<Vertex>& vertices = *nodes; - vertices.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - v.x = in->readFloat(); - v.y = in->readFloat(); - v.z = in->readFloat(); - in->readLine(); - } - - //triangles - if(!triangles) triangles = new vector<TriFace>; - vector<TriFace>& tris = *triangles; - tris.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - t.v1 = in->readInteger(); - t.v2 = in->readInteger(); - t.v3 = in->readInteger(); - in->readLine(); - } - - this->calculateValues(); - } - else - { - filename = in->readString(); - in->readLine(); - transX1 = in->readDouble(); - transX2 = in->readDouble(); - transX3 = in->readDouble(); - - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } -} -/*======================================================================*/ -UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata ) -{ - UBLOG(logINFO, "GbTriFaceMesh3D::writeMesh "); - - vector<UbTupleFloat3 > triNodes(nodes->size()); - vector<UbTupleInt3 > tris(triangles->size()); - - for(size_t i=0; i<nodes->size(); i++) - triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - - for(size_t i=0; i<triangles->size(); i++) - tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ; - - UbTuple<string, string> filenames("",""); - - if( !datanames || datanames->empty() || !nodedata ) - { - val<1>(filenames) = writer->writeTriangles(filename,triNodes,tris); - } - else - { - val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,*datanames,*nodedata); - } - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - TriFace& triangle = (*triangles)[i]; - lineNodes[i*2 ] = makeUbTuple( triangle.getX1Centroid(*nodes) - ,triangle.getX2Centroid(*nodes) - ,triangle.getX3Centroid(*nodes)); - - lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.0*triangle.nx) - ,(float)(triangle.getX2Centroid(*nodes)+1.0*triangle.ny) - ,(float)(triangle.getX3Centroid(*nodes)+1.0*triangle.nz)); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines); - } - - return filenames; -} -/*======================================================================*/ -void GbTriFaceMesh3D::writeMeshPly( const std::string& filename) -{ - ofstream out(filename.c_str() ); - if( !out ) - throw UbException(UB_EXARGS, "couldn't open " + filename); - - out << "ply" << endl; - out << "format ascii 1.0" << endl; - out << "element vertex " << (int)nodes->size() << endl; - out << "property float x" << endl; - out << "property float y" << endl; - out << "property float z" << endl; - out << "element face " << (int)triangles->size() << endl; - out << "property list uchar int vertex_indices" << endl; - out << "end_header" << endl; - - for(size_t i=0; i<nodes->size(); i++) - out << (*nodes)[i].x << " " << (*nodes)[i].y << " " << (*nodes)[i].z << endl; - - for(size_t i=0; i<triangles->size(); i++) - out << "3 " << (*triangles)[i].v1 << " " << (*triangles)[i].v2 << " " << (*triangles)[i].v3 << endl; -} -/*======================================================================*/ -void GbTriFaceMesh3D::readMeshFromSTLFile(string filename, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - UbFileInputASCII in(filename); - //this->nodes = new vector<GbTriFaceMesh3D::Vertex>; - //this->triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in.readLine(); - while(dummy!="endsolid") - { - in.readLine(); - in.readLine(); - dummy = in.readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in.readLine(); - in.readString(); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in.readLine(); - in.readString(); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in.readLine(); - in.readLine(); - in.readLine(); - dummy = in.readString(); - nr+=3; - } - if(removeRedundantNodes) - { - this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen - } - else - { - this->calculateValues(); - } -} diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h b/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h deleted file mode 100644 index 05c3635e95a5d983119a84c77e02eed2fc35856d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h +++ /dev/null @@ -1,384 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBTRIFACEMESH3D_H -#define GBTRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> -#include <basics/writer/WbWriter.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <numerics/geometry3d/GbPoint3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbTriFaceMesh3D; -typedef VFSharedPtr<GbTriFaceMesh3D> GbTriFaceMesh3DPtr; - - -namespace Kd -{ - template< typename T> class Tree; - template< typename T > class SplitAlgorithm; - template< typename T > class RayIntersectionHandler; -} - - -/*=========================================================================*/ -/* GbTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class GbTriFaceMesh3D : public GbObject3D -{ -public: - // nested class start - class Vertex - { - public: - Vertex() : x(0.0), y(0.0), z(0.0) { } - Vertex(const float& x, const float& y, const float& z) : x(x), y(y),z(z) { } - Vertex(Vertex* vert) - { - this->x = vert->x; - this->y = vert->y; - this->z = vert->z; - } - float operator[] (const int&i) const - { - if (i==0) return x; - else if(i==1) return y; - else if(i==2) return z; - - throw UbException(UB_EXARGS,"i not in [0;2]"); - } - float& operator[] (const int& i) - { - if (i==0) return x; - else if(i==1) return y; - else if(i==2) return z; - - throw UbException(UB_EXARGS,"not in [0;2]"); - } - bool operator== (const Vertex& rhs) - { - return ( fabs(x-rhs.x)<1.E-8 && fabs(y-rhs.y)<1.E-8 && fabs(z-rhs.z)<1.E-8 ); - } - friend inline bool operator<(const Vertex & lhsVert,const Vertex & rhsVert) - { - if( lhsVert.x < rhsVert.x ) return true; - if( lhsVert.x > rhsVert.x ) return false; - if( lhsVert.y < rhsVert.y ) return true; - if( lhsVert.y > rhsVert.y ) return false; - if( lhsVert.z < rhsVert.z ) return true; - - return false; - } - friend std::ostream& operator<<( std::ostream& os, const Vertex& node ) - { - return os<<node.x<<","<<node.y<<","<<node.z; - } - Vertex* clone() - { - return(new Vertex(this)); - } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & x; ar & y; ar & z; - } -#endif //CAB_RCF - - public: - float x, y, z; - }; - ////////////////////////////////////////////////////////////////////////// - class TriFace - { - public: - TriFace() - : v1(-1), v2(-1), v3(-1), nx(0.0), ny(0.0), nz(0.0) - { - - } - TriFace(const int& v1, const int& v2, const int& v3) - : v1(v1), v2(v2), v3(v3), nx(0.0), ny(0.0), nz(0.0) - { - } - - const int& getIndexVertex1() const { return v1; } - const int& getIndexVertex2() const { return v2; } - const int& getIndexVertex3() const { return v3; } - - Vertex& getNode(const int& i, std::vector<Vertex>& nodes) - { - if(i==0) return nodes[v1]; - if(i==1) return nodes[v2]; - if(i==2) return nodes[v3]; - throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - void setNode(const int& i, const int& index) - { - if (i==0) v1=index; - else if(i==1) v2=index; - else if(i==2) v3=index; - else throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - - int operator[] (int index) - { - if(index==0) return v1; - if(index==1) return v2; - if(index==2) return v3; - throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - - float& getV1x(std::vector<Vertex>& nodes) { return nodes[v1].x; } - float& getV1y(std::vector<Vertex>& nodes) { return nodes[v1].y; } - float& getV1z(std::vector<Vertex>& nodes) { return nodes[v1].z; } - - float& getV2x(std::vector<Vertex>& nodes) { return nodes[v2].x; } - float& getV2y(std::vector<Vertex>& nodes) { return nodes[v2].y; } - float& getV2z(std::vector<Vertex>& nodes) { return nodes[v2].z; } - - float& getV3x(std::vector<Vertex>& nodes) { return nodes[v3].x; } - float& getV3y(std::vector<Vertex>& nodes) { return nodes[v3].y; } - float& getV3z(std::vector<Vertex>& nodes) { return nodes[v3].z; } - - float getMinX(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].x,nodes[v2].x,nodes[v3].x); } - float getMinY(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].y,nodes[v2].y,nodes[v3].y); } - float getMinZ(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].z,nodes[v2].z,nodes[v3].z); } - - float getMaxX(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].x,nodes[v2].x,nodes[v3].x); } - float getMaxY(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].y,nodes[v2].y,nodes[v3].y); } - float getMaxZ(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].z,nodes[v2].z,nodes[v3].z); } - - float getX1Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1x(nodes)+getV2x(nodes)+getV3x(nodes)); } - float getX2Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1y(nodes)+getV2y(nodes)+getV3y(nodes)); } - float getX3Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1z(nodes)+getV2z(nodes)+getV3z(nodes)); } - - double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3, std::vector<Vertex>& nodes); - - double getArea(std::vector<Vertex>& nodes) - { - //GbVector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); - //GbVector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); - //GbVector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); - //GbVector3D AB = B-A; - //GbVector3D AC = C-A; - //GbVector3D N = AB.Cross(AC); - //return 0.5*N.Length(); - UbMath::Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); - UbMath::Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); - UbMath::Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); - UbMath::Vector3D AB = B-A; - UbMath::Vector3D AC = C-A; - UbMath::Vector3D N = AB.Cross(AC); - return 0.5*N.Length(); - } - void calculateNormal(std::vector<Vertex>& nodes) - { - const float& v1x = nodes[v1].x; const float& v1y = nodes[v1].y; const float& v1z = nodes[v1].z; - const float& v2x = nodes[v2].x; const float& v2y = nodes[v2].y; const float& v2z = nodes[v2].z; - const float& v3x = nodes[v3].x; const float& v3y = nodes[v3].y; const float& v3z = nodes[v3].z; - - nx = ( v3z - v1z) * ( v2y - v1y ) - ( v2z - v1z) * ( v3y - v1y ); - ny = ( v2z - v1z) * ( v3x - v1x ) - ( v2x - v1x) * ( v3z - v1z ); - nz = ( v2x - v1x) * ( v3y - v1y ) - ( v2y - v1y) * ( v3x - v1x ); - - float length = std::sqrt( nx*nx + ny*ny + nz*nz ); - if(length>1.E-10) - { - length = 1.0f/length; - nx *= length; - ny *= length; - nz *= length; - } - else - { - std::cerr<<"GbTriFaceMesh3D::TriFace - calculateNormal: nx=ny=nz=0 -> kann nich sein " - <<"(dreieck hat evtl knoten doppelt oder ist ne Linie)" - <<"->removeRedunantNodes"<<std::endl; - } - } - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & v1; ar & v2; ar & v3; - } - #endif //CAB_RCF - - public: - int v1, v2, v3; - float nx, ny, nz; - }; - -public: - enum KDTREE_SPLITAGORITHM { KDTREE_SAHPLIT, KDTREE_SPATIALSPLIT }; - -public: - GbTriFaceMesh3D(); - GbTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg = KDTREE_SAHPLIT, bool removeRedundantNodes=true); - ~GbTriFaceMesh3D(); - - GbTriFaceMesh3D* clone();// { throw UbException(UB_EXARGS,"not implemented"); } - void finalize() {} - - //void setRegardPointInPolyhedronTest(bool value) { this->regardPiO=value; } - - std::string toString(); - - //std::string getName(); - std::vector<Vertex>* getNodes(); - std::vector<TriFace>* getTriangles(); - - void setTransferViaFilename(bool transferViaFilename, std::string filename, double transX1, double transX2, double transX3) - { - this->filename = filename; - this->transferViaFilename = transferViaFilename; - this->transX1 = transX1; - this->transX2 = transX2; - this->transX3 = transX3; - } - void readMeshFromSTLFile(std::string filename, bool removeRedundantNodes); - - double getX1Minimum() { if(!this->consistent) this->calculateValues(); return this->x1min; } - double getX1Maximum() { if(!this->consistent) this->calculateValues(); return this->x1max; } - double getX1Centroid() { if(!this->consistent) this->calculateValues(); return this->x1center; } - - double getX2Minimum() { if(!this->consistent) this->calculateValues(); return this->x2min; } - double getX2Maximum() { if(!this->consistent) this->calculateValues(); return this->x2max; } - double getX2Centroid() { if(!this->consistent) this->calculateValues(); return this->x2center; } - - double getX3Minimum() { if(!this->consistent) this->calculateValues(); return this->x3min; } - double getX3Centroid() { if(!this->consistent) this->calculateValues(); return this->x3center; } - double getX3Maximum() { if(!this->consistent) this->calculateValues(); return this->x3max; } - - void calculateValues(); - - double getVolume(); - void deleteRedundantNodes(); - - UbTupleDouble6 calculateMomentOfInertia(double rhoP); - UbTupleDouble3 calculateCenterOfGravity(); - - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - - - void scale(const double& sx1, const double& sx2, const double& sx3); - void rotate(const double& alpha, const double& beta, const double& gamma); - void rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma); - void translate(const double& x1, const double& x2, const double& x3); - void reflectAcrossXYLine(const double& alpha); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - std::vector<GbTriFaceMesh3D::TriFace*> getTrianglesForVertex(Vertex* vertex); - - void setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode); - KDTREE_SPLITAGORITHM getKdTreeSplitAlgorithm() { return this->kdtreeSplitAlg; } - Kd::Tree<double>* getKdTree() { return this->kdTree; } - - virtual ObObjectCreator* getCreator(); - - void write(UbFileOutput* out); - void read(UbFileInput* in); - - virtual UbTuple<std::string, std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL ); - void writeMeshPly( const std::string& filename); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & kdtreeSplitAlg; - ar & transferViaFilename; - if(!transferViaFilename) - { - ar & nodes; - ar & triangles; - } - else - { - ar & filename; - ar & transX1; - ar & transX2; - ar & transX3; - if(ArchiveTools::isReading(ar) ) - { - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } - } - - if(ArchiveTools::isReading(ar)) this->calculateValues(); - } -#endif //CAB_RCF - -protected: - KDTREE_SPLITAGORITHM kdtreeSplitAlg; - void init(); - - std::vector<Vertex>* nodes; - std::vector<TriFace>* triangles; - //for transfer - std::string filename; - bool transferViaFilename; - double transX1; - double transX2; - double transX3; - - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - double x1center; - double x2center; - double x3center; - - bool consistent; - - bool buildVertTriRelationMap; - std::multimap<Vertex*,TriFace*> relationVertTris; - - Kd::Tree< double >* kdTree; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriFaceMesh3D >("GbTriFaceMesh3D ") , SF_GbTriFaceMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriFaceMesh3D >() ), SF_GbTriFaceMesh3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GBTRIFACEMESH3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp deleted file mode 100644 index f3edda2240522d65a212729acaf258da4fcc94e6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp +++ /dev/null @@ -1,1229 +0,0 @@ -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/creator/GbTriangle3DCreator.h> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -//#include <numerics/geometry3d/GbPolygon3D.h> - -using namespace std; - -ObObjectCreator* GbTriangle3D::getCreator() -{ - return GbTriangle3DCreator::getInstance(); -} - -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -* The describing points are observed by 2D triangle objects. -* <BR><BR><HR> -* @version 1.0 - 24.01.05 -*/ - -GbTriangle3D::GbTriangle3D() -{ - this->init(); - this->consistent = false; -} -/*======================================================================*/ -/* -* Creates an empty 2D triangle with the specified points. -* @param point1 the 1st point -* @param point2 the 2nd point -* @param point3 the 3nd point -*/ -GbTriangle3D::GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3) -{ - this->init(); - this->points[0] = point1; - this->points[1] = point2; - this->points[2] = point3; - - this->calculateNormal(); - this->consistent = false; - - this->points[0]->addObserver(this); - this->points[1]->addObserver(this); - this->points[2]->addObserver(this); - - //this.po = new PointObserver(this); - //this.points[0].addObserver(this.po); - //this.points[1].addObserver(this.po); - //this.points[2].addObserver(this.po); -} -/*======================================================================*/ -/* -* Creates a 3D triangle as clone of the specified 2D triangle. -* @param triangle the 3D triangle to be cloned -*/ -GbTriangle3D::GbTriangle3D(GbTriangle3D* triangle) -{ - this->init(); - this->points[0] = triangle->points[0]->clone(); - this->points[1] = triangle->points[1]->clone(); - this->points[2] = triangle->points[2]->clone(); - - this->consistent = false; - this->calculateNormal(); - this->calculateValues(); -} -/*======================================================================*/ -GbTriangle3D::~GbTriangle3D() -{ - if(this->points[0]) this->points[0]->removeObserver(this); - if(this->points[1]) this->points[1]->removeObserver(this); - if(this->points[2]) this->points[2]->removeObserver(this); -} -/*======================================================================*/ -void GbTriangle3D::deletePoints() -{ - if(points[0]) { delete points[0]; points[0]=NULL;} - if(points[1]) { delete points[1]; points[1]=NULL;} - if(points[2]) { delete points[2]; points[2]=NULL;} -} - -/*======================================================================*/ -/* Methoden */ -/* */ -/* -* Creates a 3D triangle as clone of this 3D triangle. -*/ -GbTriangle3D* GbTriangle3D::clone() -{ - return(new GbTriangle3D(this)); -} -/*======================================================================*/ -/* -* Returns the number of times this 2D triangle contains the specified point. -* @param point the point -* @return the number of times this 2D triangle contains the specified point -*/ -int GbTriangle3D::contains(GbPoint3D* point) -{ - int n = 0; - for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++; - return(n); -} -/*======================================================================*/ -/* -* Returns the number of times this 2D triangle contains a point equal to the specified point. -* @param point the point -* @return the number of times this 2D triangle contains a point equal to the specified point -*/ -int GbTriangle3D::containsEqual(GbPoint3D* point) -{ - int n = 0; - for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++; - return(n); -} -/*======================================================================*/ -/* -* Returns the specified point. -* @param index the index (must be 0, 1, or 2) -* @return the specified point -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -GbPoint3D* GbTriangle3D::getPoint(const int& index) -{ - if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: "); - return((this->points[index])); -} -/*======================================================================*/ -vector<GbPoint3D> GbTriangle3D::getPoints() -{ - vector<GbPoint3D> p(3); - p[0] = *(points[0]); - p[1] = *(points[1]); - p[2] = *(points[2]); - return p; - // - //vector<GbPoint3D> p(3);// = new vector<GbPoint3D*>; - //p.resize(3);//, NULL); - //p[0] = this->points[0]; - //p[1] = this->points[1]; - //p[2] = this->points[2]; - //return(p); -} -/*======================================================================*/ -/* -* Returns the area of this triangle. -* The area is positive for positive ordered points, otherwise negative. -* @return the area of this triangle -*/ -double GbTriangle3D::getArea() -{ - if(!this->consistent) this->calculateValues(); - // throw UbException(UB_EXARGS,"not correct calculated ..."); - return(this->area); -} -/* -* Returns the centroid x1 coordinate of this triangle. -* @return the centroid x1 coordinate of this triangle -*/ -double GbTriangle3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1s); -} -/* -* Returns the minimum x1 coordinate of this triangle. -* @return the minimum x1 coordinate of this triangle -*/ -double GbTriangle3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -/* -* Returns the maximum x1 coordinate of this triangle. -* @return the maximum x1 coordinate of this triangle -*/ -double GbTriangle3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -/* -* Returns the centroid x2 coordinate of this triangle. -* @return the centroid x2 coordinate of this triangle -*/ -double GbTriangle3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2s); -} -/* -* Returns the minimum x2 coordinate of this triangle. -* @return the minimum x2 coordinate of this triangle -*/ -double GbTriangle3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -/* -* Returns the maximum x2 coordinate of this triangle. -* @return the maximum x2 coordinate of this triangle -*/ -double GbTriangle3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -double GbTriangle3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3s); -} -double GbTriangle3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -double GbTriangle3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -/* -* Sets the specified point. -* @param point the point -* @param index the index (must be 0, 1, or 2) -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -void GbTriangle3D::setPoint(GbPoint3D* point, int index) -{ - if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: "); - this->points[index] = point; - this->consistent = false; - this->calculateNormal(); -} - -/* -* Returns true if this 2D triangle equals the specified object. -* Two triangle are equal, if their points are equal. -* <BR>Note that the order of points is not recognized! -* @return true if this 2D triangle equals the specified object -* @see GbPoint2D#equals(java.lang.Object) -* @see GbPoint3D#equals(java.lang.Object) -*/ -//bool equals(GbObject3D *object) -//{ -// try -// { -// GbTriangle3D *triangle = (GbTriangle3D*) object; - -//if(this.points[0].equals(triangle.points[0])) -//{ -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[1])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[1])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[2])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[1])) return(true); -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//return(false); -// } -// catch(Exception e){ return(false); } -// } -/* -* Returns the surface triangle set with new nodes !!! -* @returns the surface triangle set with new nodes !!! -*/ -vector<GbTriangle3D*> GbTriangle3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> triangles; - - triangles.push_back(new GbTriangle3D(new GbPoint3D(getPoint1()),new GbPoint3D(getPoint2()),new GbPoint3D(getPoint3()))); - - return triangles; -} - - -/* -* Returns the string representation of the triangle -* @returns the string representation of the triangle -*/ - -string GbTriangle3D::toString() -{ - stringstream ss; - ss<<"GbTriangle3D[area="; - ss<<this->getArea(); - - ss<<", x1s="<<this->x1s; - ss<<", x2s="<<this->x2s; - ss<<", x3s="<<this->x3s; - ss<<", x1min="<<this->x1min; - ss<<", x1max="<<this->x1max; - ss<<", x2min="<<this->x2min; - ss<<", x2max="<<this->x2max; - ss<<", x3min="<<this->x3min; - ss<<", x3max="<<this->x3max; - ss<<", points1="<<this->points[0]->toString(); - ss<<", points2="<<this->points[1]->toString(); - ss<<", points3="<<this->points[2]->toString(); - ss<<"]"; - return((ss.str()).c_str()); -} -/*======================================================================*/ -double GbTriangle3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - //e1 = v1 - v0 - double e1x1 = this->points[1]->x1-this->points[0]->x1; - double e1x2 = this->points[1]->x2-this->points[0]->x2; - double e1x3 = this->points[1]->x3-this->points[0]->x3; - - //e2 = v2 - v0 - double e2x1 = this->points[2]->x1-this->points[0]->x1; - double e2x2 = this->points[2]->x2-this->points[0]->x2; - double e2x3 = this->points[2]->x3-this->points[0]->x3; - - //p = d x e2 - double px1 = rx2*e2x3 - rx3*e2x2; - double px2 = rx3*e2x1 - rx1*e2x3; - double px3 = rx1*e2x2 - rx2*e2x1; - - //a = e1 dot p - double a = e1x1*px1 + e1x2*px2 + e1x3*px3; - if(fabs(a)<1.E-10) return -1.0; - double f = 1.0/a; - - //s = o - v0 - double sx1 = x1 - this->points[0]->x1; - double sx2 = x2 - this->points[0]->x2; - double sx3 = x3 - this->points[0]->x3; - - //u = f * ( s dot p) - double u = f * ( sx1*px1 + sx2*px2 + sx3*px3 ); - if(u<-1.E-10 || u>1.0+1.E-10) return -1.0; - - //q = s x e1 - double qx1 = sx2*e1x3 - sx3*e1x2; - double qx2 = sx3*e1x1 - sx1*e1x3; - double qx3 = sx1*e1x2 - sx2*e1x1; - - //v = f*(e2 dot q) - double v = f * (rx1*qx1 + rx2*qx2 + rx3*qx3); - if(v<-1.E-10 || (u+v)>1.0+1.E-10) return -1.0; - - //t = f * (e2 dot q) - return f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3); -} - -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 2D triangle and the specified 2D line. -* @param line the 2D line to intersect -* @return the intersection points of this 2D triangle and the specified 2D line -*/ -/* -vector<GbPoint3D> GbTriangle3D::calculateIntersectionPoints3D(GbLine3D *line) -{ -//throw UbException(UB_EXARGS,"not yet implemented"); - -GbSystem::PointSet3 pointSet(0); -GbPoint3D *pCrossed = NULL; - -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[0], *this->points[1], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[1], *this->points[2], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[2], *this->points[0], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -//vector<GbPoint3D> points = pointSet->getPoints(); -return(pointSet.getPoints()); -} -*/ -/*===========================================================*/ - -GbLine3D* GbTriangle3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - GbPoint3D *result = this->calculateIntersectionPoints3D(&point1, &point2); - if(!result) return NULL; - - return new GbLine3D(result, new GbPoint3D(point2)); - - //return GbSystem::createClipLine3D(point1, point2, - //p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(), - //p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() ); -} - -//von Navodit ... -/*===========================================================*/ -GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbLine3D* line) -{ - return this->calculateIntersectionPoints3D(line->getPoint1(), line->getPoint2()); -} -/*===========================================================*/ -GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2) -{ - GbVector3D Point1(linePoint1->x1, linePoint1->x2, linePoint1->x3); - GbVector3D Point2(linePoint2->x1, linePoint2->x2, linePoint2->x3); - GbVector3D direction = Point2-Point1; - GbVector3D GbPoint3D1(this->getPoint1()->x1,this->getPoint1()->x2,this->getPoint1()->x3); - GbVector3D GbPoint3D2(this->getPoint2()->x1,this->getPoint2()->x2,this->getPoint2()->x3); - GbVector3D GbPoint3D3(this->getPoint3()->x1,this->getPoint3()->x2,this->getPoint3()->x3); - GbVector3D V2V1 = GbPoint3D2-GbPoint3D1; - GbVector3D V3V1 = GbPoint3D3-GbPoint3D1; - GbVector3D V2V1V3V1 = V2V1.Cross(V3V1); - V2V1V3V1.Normalize(); - GbVector3D Normal = V2V1V3V1; - - double d = -Normal.Dot(GbPoint3D1); - double denom = Normal.Dot(direction); - - if (UbMath::zero(denom)) return NULL; //line does not intersect the plane of the triangle ! - else - { - double mu = -1.*(d + Point1.Dot(Normal))/denom; //mu = -(d+ Normal.Point1)/denom - - // GbVector3D p1 = Point2-Point1; - // GbVector3D p2 = p1*mu; - // GbVector3D p3 = Point1+p2; - GbVector3D point = Point1 + mu*(Point2 -Point1); - - if (mu<0.0 || mu>1.0) return NULL; // Point of intersection of line and plane does not lie on the triangle - else - { - //Test whether Point lies inside the triangle or not - bool test=true; - GbVector3D a = GbPoint3D1-point; - GbVector3D b = GbPoint3D2-point; - GbVector3D c = GbPoint3D3-point; - GbVector3D ab = a.Cross(b); - GbVector3D bc = b.Cross(c); - GbVector3D ca = c.Cross(a); - GbVector3D Q1 = ab*0.5; - GbVector3D Q2 = bc*0.5; - GbVector3D Q3 = ca*0.5; - GbVector3D Q1Q2 = Q1+Q2; - GbVector3D Q = Q1Q2+Q3; - - if (UbMath::less(Q.Dot(Q1), 0.0)) test = false; - if (UbMath::less(Q.Dot(Q2), 0.0)) test = false; - if (UbMath::less(Q.Dot(Q3), 0.0)) test = false; - - if (test == true) return (new GbPoint3D(point.X1(), point.X2(), point.X3())); - else return NULL; - } - } -} - -/** -* Returns the distance between the 3D triangle and the specified 3D Point -* @param point the 3D point from whom the distance is to be calculated -* @return the distance of the specified point from the triangle -*/ -double GbTriangle3D::calculateDistanceToPoint3D(GbPoint3D *point) -{ - return this->calculateDistanceToPoint3D(point->x1, point->x2, point->x3); -} -/*=======================================================================*/ -double GbTriangle3D::calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3) -{ - // - //throw UbException(UB_EXARGS,"Ich glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's"); - cout<<"??? ch glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's"<<endl; - GbVector3D P0(x1, x2, x3); - GbVector3D P1(this->points[0]->x1, this->points[0]->x2, this->points[0]->x3); - GbVector3D P2(this->points[1]->x1, this->points[1]->x2, this->points[1]->x3); - GbVector3D P3(this->points[2]->x1, this->points[2]->x2, this->points[2]->x3); - - //Determine normal to triangle - GbVector3D Normal = (P1-P2).Cross(P1-P3); - double alpha = UbMath::ACos((P1-P0).Dot(Normal)/((P1-P0).Length()*Normal.Length())); - - double P0P0dash = (P0-P1).Length()*cos(alpha); - Normal.Normalize(); - GbVector3D Projection = Normal*(-P0P0dash); - - GbVector3D P0dash = P0+Projection; - - //Check if point P0dash lies within the triangle P1P2P3. - bool test = false; - if ( ((P1-P0).Cross(P2-P0)).Dot(Normal) > 0 ) test = true; - if ( ((P2-P0).Cross(P3-P0)).Dot(Normal) > 0 ) test = true; - if ( ((P3-P0).Cross(P1-P0)).Dot(Normal) > 0 ) test = true; - - if (test == true) return (P0-P0dash).Length(); - else - // Determine the distance of point P0 from all edges and vertices and return the minimum distance - { - double dP0P1 = (P0-P1).Length(); //Distance of Point P0 from Point P1 - double dP0P2 = (P0-P2).Length(); //Distance of Point P0 from Point P2 - double dP0P3 = (P0-P3).Length(); //Distance of Point P0 from Point P3 - - GbVector3D MP1P2 = P2-P1; //Direction vector for line P1P2 - GbVector3D MP2P3 = P3-P2; //Direction vector for line P2P3 - GbVector3D MP3P1 = P1-P3; //Direction vector for line P3P1 - - double tP1P2 = MP1P2.Dot(P0-P1) / MP1P2.Dot(MP1P2); - double tP2P3 = MP2P3.Dot(P0-P2) / MP2P3.Dot(MP2P3); - double tP3P1 = MP3P1.Dot(P0-P3) / MP3P1.Dot(MP3P1); - - double dP1P2 = (P0-(P1+(MP1P2*tP1P2))).Length(); //Distance of Point P0 from line P1P2 - double dP2P3 = (P0-(P2+(MP2P3*tP2P3))).Length(); //Distance of Point P0 from line P2P3 - double dP3P1 = (P0-(P3+(MP3P1*tP3P1))).Length(); //Distance of Point P0 from line P3P1 - - double distanceP0[6]; //Array to store all the distances from Point P0 - distanceP0[0] = dP0P1; - distanceP0[1] = dP0P2; - distanceP0[2] = dP0P3; - distanceP0[3] = dP1P2; - distanceP0[4] = dP2P3; - distanceP0[5] = dP3P1; - - double d = 0.0; - //Find the minimum distance from Point P0 - for (int i=0; i<6; i++) - { - if(distanceP0[i]<d) d = distanceP0[i]; - } - return d; - } -} -/** -* Returns the normalized distance between the 3D triangle and the specified 3D Point -* copied from Benjamin A. -* @param point the 3D point from whom the distance is to be calculated -* @return the distance of the specified point from the triangle -*/ -double GbTriangle3D::calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, - const double& x2, const double& y2, const double& z2) -{ - //face* pf - double xa, xb, xc, ya, yb, yc, za, zb, zc; - //double xp, yp, zp; - double tt=0, xi=0, eta=0; - double zaehler, nenner; - double wurzel3 = sqrt(3.); - - //Weltkoordinaten der Dreiecke - xa = this->points[0]->x1; - xb = this->points[1]->x1; - xc = this->points[2]->x1; - - ya = this->points[0]->x2; - yb = this->points[1]->x2; - yc = this->points[2]->x2; - - za = this->points[0]->x3; - zb = this->points[1]->x3; - zc = this->points[2]->x3; - - //Shape-Funktionen zum Berechnen der Schnittpunkte - zaehler = - static_cast<double>(((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1 - +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa - +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zc+zb)*ya+(yc-1.0*yb)*za - +zc*yb-1.0*zb*yc)*x2+((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2 - +((-1.0*yc+yb)*xa+(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z2+(2.0*zb*yc-2.0*zc*yb)*xa - +(2.0*xb*zc-2.0*xc*zb)*ya+(-2.0*xb*yc+2.0*xc*yb)*za); - nenner = - static_cast<double>((((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1 - +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa - +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zb+zc)*ya+(-1.0*yc+yb)*za-1.0*zc*yb+zb*yc) - *x2+((-1.0*zc+zb)*xa+(-1.0*xb+xc)*za+xb*zc-1.0*xc*zb)*y2+((yc-1.0*yb)*xa+(xb - -1.0*xc)*ya+xc*yb-1.0*xb*yc)*z2)); - if( UbMath::greater(nenner, 0.0) ) tt = zaehler/nenner; - else tt=-999.; - - zaehler = - static_cast<double>(((-2.0*zc+za+zb)*y2+(-1.0*yb-1.0*ya+2.0*yc)*z2+zc*ya - -1.0*zb*yc+zc*yb-1.0*za*yc)*x1+((-1.0*za+2.0*zc-1.0*zb)*x2+(xa-2.0*xc+xb)*z2 - -1.0*xa*zc-1.0*xb*zc+xc*za+xc*zb)*y1+((-2.0*yc+ya+yb)*x2+(-1.0*xa-1.0*xb+2.0*xc) - *y2-1.0*xc*yb+xa*yc+xb*yc-1.0*xc*ya)*z1+(zb*yc-1.0*zc*ya-1.0*zc*yb+za*yc) - *x2+(-1.0*xc*za+xb*zc+xa*zc-1.0*xc*zb)*y2+(xc*yb-1.0*xa*yc-1.0*xb*yc+xc*ya)*z2); - nenner = - static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1 - +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc) - *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2 - +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa - +(xc-1.0*xb)*ya+xb*yc-1.0*xc*yb)*z2)); - if( UbMath::greater(nenner, 0.0) ) xi = zaehler/nenner; - else xi=-999.; - - zaehler = - static_cast<double>(((za-1.0*zb)*y2+(-1.0*ya+yb)*z2-1.0*za*yb+zb*ya)*x1+ - ((-1.0*za+zb)*x2+(xa-1.0*xb)*z2-1.0*xa*zb+xb*za)*y1+((ya-1.0*yb)*x2+(xb-1.0*xa) - *y2+xa*yb-1.0*xb*ya)*z1+(-1.0*zb*ya+za*yb)*x2+(-1.0*xb*za+xa*zb)*y2 - +(-1.0*xa*yb+xb*ya)*z2); - nenner = - static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1 - +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc) - *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2 - +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa+(xc-1.0*xb) - *ya+xb*yc-1.0*xc*yb)*z2)); - if ( UbMath::greater(nenner, 0.0) ) eta = static_cast<double>((zaehler/nenner)*wurzel3*-1.); - else eta=-999.; - - if (tt >= -1.0-UbMath::Epsilon<double>::val() && tt <= 1.0){ - if(xi >= -1.0+eta/wurzel3-UbMath::Epsilon<double>::val() && xi <= - 1.0-eta/wurzel3+UbMath::Epsilon<double>::val()){ - if (eta >= 0-UbMath::Epsilon<double>::val() && eta <= wurzel3+UbMath::Epsilon<double>::val()){ - /*xp = x1*(0.5-tt/2)+x2*(0.5+tt/2); - yp = y1*(0.5-tt/2)+y2*(0.5+tt/2); - zp = z1*(0.5-tt/2)+z2*(0.5+tt/2);*/ - return - static_cast<double>((sqrt(pow((x1*(0.5-tt/2)+x2*(0.5+tt/2))-x1,2) - +pow((y1*(0.5-tt/2)+y2*(0.5+tt/2))-y1,2)+pow((z1*(0.5-tt/2)+z2*(0.5+tt/2))-z1,2)))); - } - } - } - return (-999.); -} -/* -* Returns true if the specified 2D point lies within (or on the border of) this 2D triangle. -* @param point the 2D point to check -* @return true if the specified 2D point lies within (or on the border of) this 2D triangle -*/ - bool GbTriangle3D::enclosesPoint2D(double x1, double x2) - { - int i=0; - //Punkt(x1,x2) liegt auf einem der Eckpunkte - if(x1==this->getPoint(0)->getX1Coordinate() && x2 == this->getPoint(0)->getX2Coordinate()) return true; - if(x1==this->getPoint(1)->getX1Coordinate() && x2 == this->getPoint(1)->getX2Coordinate()) return true; - if(x1==this->getPoint(2)->getX1Coordinate() && x2 == this->getPoint(2)->getX2Coordinate()) return true; - - //Erste Grade aus dem zu pruefenden Punkt(x,y) und einem zweiten Punkt(x+0.333,y+2.333) - GbPoint3D p1; p1.setX1(x1); p1.setX2(x2); p1.setX3(0.0); - GbPoint3D p2; p2.setX1(x1+0.333); p2.setX2(x2+3.333); p2.setX3(0.0); - //Punkte des Dreiecks auf 2D reduziert - GbPoint3D dp1; dp1.setX1(this->getPoint(0)->getX1Coordinate()); dp1.setX2(this->getPoint(0)->getX2Coordinate()); dp1.setX3(0.0); - GbPoint3D dp2; dp2.setX1(this->getPoint(1)->getX1Coordinate()); dp2.setX2(this->getPoint(1)->getX2Coordinate()); dp2.setX3(0.0); - GbPoint3D dp3; dp3.setX1(this->getPoint(2)->getX1Coordinate()); dp3.setX2(this->getPoint(2)->getX2Coordinate()); dp3.setX3(0.0); - //ueberpruefen, ob der Punkt(x,y) innerhalt der Boundingbox des Dreiecks liegt - if( x1<this->getX1Maximum() && x1>getX1Minimum() - && x2<this->getX2Maximum() && x2>getX2Minimum()) - { - GbPoint3D* dummy = NULL; - //ueberpruefen, ob der Punkt innerhalb des Dreiecks liegt - dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp1,dp2); - if(dummy!=NULL) - { - if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate()) - { - delete dummy; - return true; - } - else if(dummy->getX1Coordinate()>p1.getX1Coordinate()) - { - i++; - } - else - { - i--; - } - } - if(dummy) delete dummy; - - dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp2,dp3); - if(dummy!=NULL) - { - if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate()) - { - if(dummy) delete dummy; - return true; - } - else if(dummy->getX1Coordinate()>p1.getX1Coordinate()) - { - i++; - } - else - { - i--; - } - } - if(dummy) delete dummy; - - dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp3,dp1); - if(dummy!=NULL) - { - if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate()) - { - if(dummy) delete dummy; - return true; - } - else if(dummy->getX1Coordinate()>p1.getX1Coordinate()) - { - i++; - } - else - { - i--; - } - } - if(dummy) delete dummy; - } - if(i==-1) return true; - if(i==1 ) return true; - - return false; - } - -///* -//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). -//* @param rectangle the 2D rectangle -//* @return a new 2D polygon clipped by the specified 2D rectangle -//*/ -GbPolygon3D* GbTriangle3D::createClippedPolygon3D(GbCuboid3D* cube) -{ - return(GbSystem3D::clipPolygon3D(this->getPoints(), cube->getPoint1()->getX1Coordinate(), cube->getPoint1()->getX2Coordinate(), cube->getPoint1()->getX3Coordinate(), cube->getPoint2()->getX1Coordinate(), cube->getPoint2()->getX2Coordinate(), cube->getPoint2()->getX3Coordinate())); -} -///* -//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). -//* @param p1 the 1st point of the rectangle -//* @param p2 the 2nd point of the rectangle -//* @return a new 2D polygon clipped by the specified 2D rectangle -//*/ -//public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2) -//{ -// return(GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2)); -//} -/* -* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). -* @param p1x1 the 1st x1 coordinate of the rectangle -* @param p1x2 the 1st x2 coordinate of the rectangle -* @param p2x1 the 2nd x1 coordinate of the rectangle -* @param p2x2 the 2nd x2 coordinate of the rectangle -* @return a new 2D polygon clipped by the specified 2D rectangle -*/ -GbPolygon3D* GbTriangle3D::createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3) -{ - return(GbSystem3D::clipPolygon3D(this->getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2, p2x3)); -} - -/* -* Returns true if the specified 2D rectangle lies completely within this 2D triangle. -* @param rectangle the 2D rectangle to check -* @return true if the specified 2D rectangle lies completely within this 2D triangle -*/ -//bool enclosesRectangle2D(GbRectangle2D *rectangle) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); -//} -/* -* Returns true if the specified 2D rectangle lies completely within this 2D triangle. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check triangle -* @return true if the specified 2D rectangle lies completely within this 2D -*/ -//public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 2D rectangle lies completely within this 2D triangle. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 2D rectangle lies completely within this 2D triangle -*/ -//public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 2D rectangle is crossed by this 2D triangle. -* @param rectangle the 2D rectangle to check -* @return true if the specified 2D rectangle is crossed by this 2D triangle -*/ -//public boolean crossesRectangle2D(GbRectangle2D rectangle) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); -//} -/* -* Returns true if the specified 2D rectangle is crossed by this 2D triangle. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 2D rectangle is crossed by this 2D triangle -*/ -//public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 2D rectangle is crossed by this 2D triangle. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 2D rectangle is crossed by this 2D triangle -*/ -//public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle. -* @param rectangle the 2D rectangle to check -* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle -*/ -//public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle -*/ -//public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle -*/ -//public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/*======================================================================*/ - - -/*======================================================================*/ -/* Private Methoden */ -/* */ -void GbTriangle3D::calculateValues() -{ - this->x1min = this->points[0]->x1; - this->x1max = this->points[0]->x1; - this->x2min = this->points[0]->x2; - this->x2max = this->points[0]->x2; - this->x3min = this->points[0]->x3; - this->x3max = this->points[0]->x3; - - if(this->points[1]->x1 < this->x1min) this->x1min = this->points[1]->x1; - if(this->points[1]->x1 > this->x1max) this->x1max = this->points[1]->x1; - if(this->points[1]->x2 < this->x2min) this->x2min = this->points[1]->x2; - if(this->points[1]->x2 > this->x2max) this->x2max = this->points[1]->x2; - if(this->points[1]->x3 < this->x3min) this->x3min = this->points[1]->x3; - if(this->points[1]->x3 > this->x3max) this->x3max = this->points[1]->x3; - - if(this->points[2]->x1 < this->x1min) this->x1min = this->points[2]->x1; - if(this->points[2]->x1 > this->x1max) this->x1max = this->points[2]->x1; - if(this->points[2]->x2 < this->x2min) this->x2min = this->points[2]->x2; - if(this->points[2]->x2 > this->x2max) this->x2max = this->points[2]->x2; - if(this->points[2]->x3 < this->x3min) this->x3min = this->points[2]->x3; - if(this->points[2]->x3 > this->x3max) this->x3max = this->points[2]->x3; - - this->x1s = (this->points[0]->x1+this->points[1]->x1+this->points[2]->x1)/3.0; - this->x2s = (this->points[0]->x2+this->points[1]->x2+this->points[2]->x2)/3.0; - this->x3s = (this->points[0]->x3+this->points[1]->x3+this->points[2]->x3)/3.0; - - GbVector3D A(points[0]->x1,points[0]->x2,points[0]->x3); - GbVector3D B(points[1]->x1,points[1]->x2,points[1]->x3); - GbVector3D C(points[2]->x1,points[2]->x2,points[2]->x3); - GbVector3D AB = B-A; - GbVector3D AC = C-A; - GbVector3D N = AB.Cross(AC); - this->area = 0.5*N.Length(); - this->consistent = true; -} -/*======================================================================*/ - - -/*======================================================================*/ -//class PointObserver : public UbObserver -//{ -// GbTriangle3D *triangle; - -// PointObserver(GbTriangle3D *triangle) -// { -// this->triangle = triangle; -// } - -//public: -// void objectChanged(GbObject3D *object) -// { -// if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) -// { -// this->triangle->consistent = false; -// this->triangle->notifyObservers(); -// } -// } -//}; -//bool GbTriangle3D::isPointOnEdge(GbVector3D& q) -//{ -////cout<<"muss einer machen ...\n"; -// return false; -//} -/*======================================================================*/ -GbVector3D GbTriangle3D::getNormal() -{ - this->calculateNormal(); - return normal; -} -/*======================================================================*/ -void GbTriangle3D::init() -{ - x1s = 0.0; - x2s = 0.0; - x3s = 0.0; - x1min = 0.0; - x1max = 0.0; - x2min = 0.0; - x2max = 0.0; - area = 0.0; - consistent = false; - points.resize(3,NULL); -} -/*=======================================================*/ -void GbTriangle3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - if(points[0]) points[0]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[1]) points[1]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[2]) points[2]->write(out); - else {GbPoint3D tmp; tmp.write(out);} -} -/*=======================================================*/ -void GbTriangle3D::read(UbFileInput* in) -{ - this->deletePoints(); - points[0] = new GbPoint3D; - points[1] = new GbPoint3D; - points[2] = new GbPoint3D; - in->readString(); - points[0]->read(in); - in->readString(); - points[1]->read(in); - in->readString(); - points[2]->read(in); - consistent = false; -} -/*=======================================================*/ -void GbTriangle3D::calculateNormal() -{ - GbPoint3D*& a = points[0]; - GbPoint3D*& b = points[1]; - GbPoint3D*& c = points[2]; - normal[0] = ( c->getX3Coordinate() - a->getX3Coordinate()) * ( b->getX2Coordinate() - a->getX2Coordinate() ) - - ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() ); - normal[1] = ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() ) - - ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX3Coordinate() - a->getX3Coordinate() ); - normal[2] = ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() ) - - ( b->getX2Coordinate() - a->getX2Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() ); - normal.Normalize(); -} -/*=======================================================*/ -//toDo: -double GbTriangle3D::getDistanceFromPoint(GbVector3D punct) -{ - GbVector3D Point1(this->getPoint1()->getX1Coordinate(), this->getPoint1()->getX2Coordinate(), this->getPoint1()->getX3Coordinate()); - GbVector3D Point2(this->getPoint2()->getX1Coordinate(), this->getPoint2()->getX2Coordinate(), this->getPoint2()->getX3Coordinate()); - GbVector3D Point3(this->getPoint3()->getX1Coordinate(), this->getPoint3()->getX2Coordinate(), this->getPoint3()->getX3Coordinate()); - - GbVector3D kDiff = Point1 - punct; - GbVector3D kEdge0 = Point2 - Point1; - GbVector3D kEdge1 = Point3 - Point1; - double fA00 = kEdge0.SquaredLength(); - double fA01 = kEdge0.Dot(kEdge1); - double fA11 = kEdge1.SquaredLength(); - double fB0 = kDiff.Dot(kEdge0); - double fB1 = kDiff.Dot(kEdge1); - double fC = kDiff.SquaredLength(); - double fDet = fabs(fA00*fA11-fA01*fA01); - double fS = fA01*fB1-fA11*fB0; - double fT = fA01*fB0-fA00*fB1; - double fSqrDistance; - - if (fS + fT <= fDet) - { - if (fS < (double)0.0) - { - if (fT < (double)0.0) // region 4 - { - if (fB0 < (double)0.0) - { - fT = (double)0.0; - if (-fB0 >= fA00) - { - fS = (double)1.0; - fSqrDistance = fA00+((double)2.0)*fB0+fC; - } - else - { - fS = -fB0/fA00; - fSqrDistance = fB0*fS+fC; - } - } - else - { - fS = (double)0.0; - if (fB1 >= (double)0.0) - { - fT = (double)0.0; - fSqrDistance = fC; - } - else if (-fB1 >= fA11) - { - fT = (double)1.0; - fSqrDistance = fA11+((double)2.0)*fB1+fC; - } - else - { - fT = -fB1/fA11; - fSqrDistance = fB1*fT+fC; - } - } - } - else // region 3 - { - fS = (double)0.0; - if (fB1 >= (double)0.0) - { - fT = (double)0.0; - fSqrDistance = fC; - } - else if (-fB1 >= fA11) - { - fT = (double)1.0; - fSqrDistance = fA11+((double)2.0)*fB1+fC; - } - else - { - fT = -fB1/fA11; - fSqrDistance = fB1*fT+fC; - } - } - } - else if (fT < (double)0.0) // region 5 - { - fT = (double)0.0; - if (fB0 >= (double)0.0) - { - fS = (double)0.0; - fSqrDistance = fC; - } - else if (-fB0 >= fA00) - { - fS = (double)1.0; - fSqrDistance = fA00+((double)2.0)*fB0+fC; - } - else - { - fS = -fB0/fA00; - fSqrDistance = fB0*fS+fC; - } - } - else // region 0 - { - // minimum at interior point - double fInvDet = ((double)1.0)/fDet; - fS *= fInvDet; - fT *= fInvDet; - fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) + - fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC; - } - } - else - { - double fTmp0, fTmp1, fNumer, fDenom; - - if (fS < (double)0.0) // region 2 - { - fTmp0 = fA01 + fB0; - fTmp1 = fA11 + fB1; - if (fTmp1 > fTmp0) - { - fNumer = fTmp1 - fTmp0; - fDenom = fA00-2.0f*fA01+fA11; - if (fNumer >= fDenom) - { - fS = (double)1.0; - fT = (double)0.0; - fSqrDistance = fA00+((double)2.0)*fB0+fC; - } - else - { - fS = fNumer/fDenom; - fT = (double)1.0 - fS; - fSqrDistance = fS*(fA00*fS+fA01*fT+2.0f*fB0) + - fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC; - } - } - else - { - fS = (double)0.0; - if (fTmp1 <= (double)0.0) - { - fT = (double)1.0; - fSqrDistance = fA11+((double)2.0)*fB1+fC; - } - else if (fB1 >= (double)0.0) - { - fT = (double)0.0; - fSqrDistance = fC; - } - else - { - fT = -fB1/fA11; - fSqrDistance = fB1*fT+fC; - } - } - } - else if (fT < (double)0.0) // region 6 - { - fTmp0 = fA01 + fB1; - fTmp1 = fA00 + fB0; - if (fTmp1 > fTmp0) - { - fNumer = fTmp1 - fTmp0; - fDenom = fA00-((double)2.0)*fA01+fA11; - if (fNumer >= fDenom) - { - fT = (double)1.0; - fS = (double)0.0; - fSqrDistance = fA11+((double)2.0)*fB1+fC; - } - else - { - fT = fNumer/fDenom; - fS = (double)1.0 - fT; - fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) + - fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC; - } - } - else - { - fT = (double)0.0; - if (fTmp1 <= (double)0.0) - { - fS = (double)1.0; - fSqrDistance = fA00+((double)2.0)*fB0+fC; - } - else if (fB0 >= (double)0.0) - { - fS = (double)0.0; - fSqrDistance = fC; - } - else - { - fS = -fB0/fA00; - fSqrDistance = fB0*fS+fC; - } - } - } - else // region 1 - { - fNumer = fA11 + fB1 - fA01 - fB0; - if (fNumer <= (double)0.0) - { - fS = (double)0.0; - fT = (double)1.0; - fSqrDistance = fA11+((double)2.0)*fB1+fC; - } - else - { - fDenom = fA00-2.0f*fA01+fA11; - if (fNumer >= fDenom) - { - fS = (double)1.0; - fT = (double)0.0; - fSqrDistance = fA00+((double)2.0)*fB0+fC; - } - else - { - fS = fNumer/fDenom; - fT = (double)1.0 - fS; - fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) + - fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC; - } - } - } - } - - // account for numerical round-off error - if (fSqrDistance < (double)0.0) - { - fSqrDistance = (double)0.0; - } -/* - m_kClosestPoint0 = punct; - m_kClosestPoint1 = m_rkTriangle.V[0] + fS*kEdge0 + fT*kEdge1; - m_afTriangleBary[1] = fS; - m_afTriangleBary[2] = fT; - m_afTriangleBary[0] = (double)1.0 - fS - fT; -*/ - return sqrt(fSqrDistance); -} diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h b/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h deleted file mode 100644 index 42072eb2d153ff473e634818add9da8f7194f133..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h +++ /dev/null @@ -1,248 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBTRIANGLE3D_H -#define GBTRIANGLE3D_H - -#include <sstream> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbVector3D.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <basics/memory/MbSharedPointerDefines.h> -class GbTriangle3D; -typedef VFSharedPtr<GbTriangle3D> GbTriangle3DPtr; - - -class GbCuboid3D; -class GbPolygon3D; -class GbObject3DCreator; - -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -*/ -//class GbLine2D; - -class GbTriangle3D : public GbObject3D , public UbObserver -{ -public: - /*======================================================================*/ - /* Konstruktoren */ - /* */ - GbTriangle3D(); - GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3); - GbTriangle3D(GbTriangle3D* triangle); - ~GbTriangle3D(); - /*======================================================================*/ - /* Methoden */ - /* */ - GbTriangle3D* clone(); - void finalize() - { - this->deletePoints(); - } - - GbPoint3D* getPoint1() { return this->points[0]; } - GbPoint3D* getPoint2() { return this->points[1]; } - GbPoint3D* getPoint3() { return this->points[2]; } - - GbVector3D getNormal(); - void calculateNormal(); - - void deletePoints(); - - int contains(GbPoint3D* point); - int containsEqual(GbPoint3D* point); - GbPoint3D* getPoint(const int& index); - std::vector<GbPoint3D> getPoints(); - double getArea(); - double getX1Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Centroid(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Centroid(); - double getX3Minimum(); - double getX3Maximum(); - - void setInconsistent() { this->consistent = false;} - - void setPoint(GbPoint3D *point, int index); - - //bool equals(GbObject3D *object) - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3) - { - //der einfachheit halber ... - return false; - //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented"); - } - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) - { - //der einfachheit halber ... - pointIsOnBoundary = false; - return false; - //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented"); - } - bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; } - - - // get distance from a point to the triangle - //todo CHANGE... - double getDistanceFromPoint(GbVector3D punct); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - /*======================================================================*/ - /* Calculation */ - /* */ -// std::vector<GbPoint3D> calculateIntersectionPoints3D(GbLine3D *line); - 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); -// bool isPointOnEdge(GbVector3D& q); - - GbPoint3D* calculateIntersectionPoints3D(GbLine3D* line); - GbPoint3D* calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2); - double calculateDistanceToPoint3D(GbPoint3D *point); - double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3); - double calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, const double& x2, const double& y2, const double& z2); - - bool enclosesPoint2D(double x1, double x2); - GbPolygon3D* createClippedPolygon3D(GbCuboid3D* cube); - GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2); - //public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2); - GbPolygon3D* createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3); - //bool enclosesRectangle2D(GbRectangle2D *rectangle); - //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2); - //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2); - //public boolean crossesRectangle2D(GbRectangle2D rectangle); - //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2); - //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2); - //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle); - //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2); - //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2); - /*======================================================================*/ - /*======================================================================*/ - /* Private Methoden */ - /* */ - virtual void calculateValues(); - - /*======================================================================*/ - //class PointObserver : public UbObserver - //{ - // GbTriangle3D *triangle; - - // PointObserver(GbTriangle3D *triangle) - // { - // this->triangle = triangle; - // } - - //public: - // void objectChanged(GbObject3D *object) - // { - // if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) - // { - // this->triangle->consistent = false; - // this->triangle->notifyObservers(); - // } - // } - //}; - /*======================================================================*/ - - //virtuelle Methoden von UbObserver - //!! quick and dirty von sirann !! - void objectChanged(UbObservable* changedObject) - { - GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject); - if(!point || ( this->points[0]!=point && this->points[1]!=point && this->points[2]!=point) ) - return; - - this->consistent = false; - } - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - if(this->points[0]) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[0]); - if(objectForDeletion == observedObj) { this->points[0] = NULL; } - } - if(this->points[1]) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[1]); - if(objectForDeletion == observedObj) { this->points[1] = NULL; } - } - if(this->points[2]) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[2]); - if(objectForDeletion == observedObj) { this->points[2] = NULL; } - } - //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo - } - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & points; - ar & normal; - ar & x1s; - ar & x2s; - ar & x3s; - ar & x1min; - ar & x1max; - ar & x2min; - ar & x2max; - ar & x3min; - ar & x3max; - ar & area; - ar & consistent; - if( ArchiveTools::isReading(ar) ) this->calculateNormal(); - } -#endif //CAB_RCF - -protected: - bool consistent; - double x1s; - double x2s; - double x3s; - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - double area; - - GbVector3D normal; - std::vector<GbPoint3D*> points; - -private: - void init(); -}; -/*=========================================================================*/ - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriangle3D >("GbTriangle3D ") , SF_GbTriangle3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangle3D >() ), SF_GbTriangle3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbTriangle3D>() ), SF_GbTriangle3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp deleted file mode 100644 index b98dca0da97656d937c8ad6562b936b6e81c42a5..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp +++ /dev/null @@ -1,1535 +0,0 @@ -#include <numerics/geometry3d/GbTriangularMesh3D.h> -#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> - -#include <map> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> - -using namespace std; - -GbTriangularMesh3D::GbTriangularMesh3D() : GbObject3D() -{ - this->setName("new GbMesh"); - this->nodes = new vector<GbPoint3D*>; - this->triangles = new vector<GbTriangle3D*>; - this->edges = new vector<GbLine3D*>; - - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbObject3D() -{ - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - - this->setName(name); - this->nodes = nodes; - this->triangles = triangles; - this->edges = new vector<GbLine3D*>; - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbTriangle3D*> *tris) : GbObject3D() -{ - cout<<"Das Teil erzeugt seinen KnotenVector aus den Dreiecken ...\n Es sollte deleteRedundantNodes() aufgerufen werden \n"; - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!tris ) throw UbException(UB_EXARGS,"no triangles specified"); - - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - this->triangles = new vector<GbTriangle3D*>; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - for(int u=0;u<(int)tris->size();u++) - { - if(UbMath::zero((*tris)[u]->getArea())) - { - (*tris)[u]->finalize(); - delete (*tris)[u]; - (*tris)[u] = NULL; - continue; - } - this->triangles->push_back((*tris)[u]); - p1 = (*tris)[u]->getPoint1(); - p2 = (*tris)[u]->getPoint2(); - p3 = (*tris)[u]->getPoint3(); - points->push_back(p1); - points->push_back(p2); - points->push_back(p3); - } - - this->setName(name); - this->nodes = points; - //this->triangles = triangles; - this->edges = new vector<GbLine3D*>; - this->edges->resize(0, NULL); - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbObject3D() -{ - if(name.size()==0) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - if(!edges ) throw UbException(UB_EXARGS,"no edges specified"); - - this->setName(name); - this->nodes = nodes; - this->edges = edges; - this->triangles = triangles; - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::~GbTriangularMesh3D() -{ - if( this->nodes ) - { - for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u]; - delete nodes; - } - if(triangles) - { - for(unsigned u=0; u<triangles->size(); u++) delete (*triangles)[u]; - delete triangles; - } -} -/*======================================================================*/ -ObObjectCreator* GbTriangularMesh3D::getCreator() -{ - return GbTriangularMesh3DCreator::getInstance(); -} -/*======================================================================*/ -void GbTriangularMesh3D::deleteRedundantNodes() -{ - std::map<GbPoint3D*,GbTriangle3D*> pointTriMap; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - GbTriangle3D* tri = NULL; - - for(int u=0;u<(int)this->triangles->size();u++) - { - tri = (*this->triangles)[u]; - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri)); - } - - cout<<"Nodes before deleting redundant:"<<this->nodes->size()<<endl; - GbPoint3D* pA = NULL; - GbPoint3D* pB = NULL; - std::map<GbPoint3D*,GbTriangle3D*>::iterator mapIterator; - for(int u=0;u<(int)this->nodes->size();u++) - { - //cout<<u<<" von "<<this->nodes->size()<<endl; - pA = (*this->nodes)[u]; - if(pA==NULL) continue; - for(int w=u+1;w<(int)this->nodes->size();w++) - { - // cout<<w<<" Wvon "<<this->nodes->size()<<endl; - pB = (*this->nodes)[w]; - if(pB==NULL) continue; - if(pA->equals(pB)) - { - //doppelter Knoten ... - mapIterator = pointTriMap.find(pB); - tri = dynamic_cast<GbTriangle3D*>(mapIterator->second); - if(!tri) throw UbException(UB_EXARGS,"triangle not found"); - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - if(pB==p1) tri->setPoint(pA, 0); - else if(pB==p2) tri->setPoint(pA, 1); - else if(pB==p3) tri->setPoint(pA, 2); - else throw UbException(UB_EXARGS,"node should be there"); - delete pB; - (*this->nodes)[w] = NULL; - } - } - } - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - for(int u=0;u<(int)this->nodes->size();u++) - { - pA = (*this->nodes)[u]; - if(pA!=NULL) points->push_back(pA); - } - delete this->nodes; - this->nodes = points; - cout<<"Nodes after deleting redundant:"<<this->nodes->size()<<endl; - - -//nochmal kontrolle ... - pointTriMap.clear(); - for(int u=0;u<(int)this->triangles->size();u++) - { - tri = (*this->triangles)[u]; - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri)); - } - for(int u=0;u<(int)this->nodes->size();u++) - { - pA = (*this->nodes)[u]; - if(pA==NULL) throw UbException(UB_EXARGS,"sollte kein NULL pointer sein ..."); - mapIterator = pointTriMap.find(pA); - tri = dynamic_cast<GbTriangle3D*>(mapIterator->second); - if(!tri) throw UbException(UB_EXARGS,"triangle not found"); - } -} -/*======================================================================*/ -void GbTriangularMesh3D::translate(const double& x1, const double& x2, const double& x3) -{ - GbPoint3D* pt; - for(int u=0;u<(int)this->nodes->size();u++) - { - pt = (*nodes)[u]; - pt->setX1(pt->getX1Coordinate()+x1); - pt->setX2(pt->getX2Coordinate()+x2); - pt->setX3(pt->getX3Coordinate()+x3); - } - this->consistent = false; -} -/*======================================================================*/ -void GbTriangularMesh3D::rotate(const double& alpha, const double& beta, const double& gamma) -{ - if(!this->consistent) this->calculateValues(); - double a1 = this->getX1Centroid(); - double a2 = this->getX2Centroid(); - double a3 = this->getX3Centroid(); - CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(a1, a2, a3, 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<GbPoint3D*> points; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - for(int u=0;u<(int)this->triangles->size();u++) - { - p1 = (*triangles)[u]->getPoint1(); - p2 = (*triangles)[u]->getPoint2(); - p3 = (*triangles)[u]->getPoint3(); - double p1x1 = trafoFor.transformForwardToX1Coordinate(p1->x1, p1->x2, p1->x3); - double p1x2 = trafoFor.transformForwardToX2Coordinate(p1->x1, p1->x2, p1->x3); - double p1x3 = trafoFor.transformForwardToX3Coordinate(p1->x1, p1->x2, p1->x3); - double p2x1 = trafoFor.transformForwardToX1Coordinate(p2->x1, p2->x2, p2->x3); - double p2x2 = trafoFor.transformForwardToX2Coordinate(p2->x1, p2->x2, p2->x3); - double p2x3 = trafoFor.transformForwardToX3Coordinate(p2->x1, p2->x2, p2->x3); - double p3x1 = trafoFor.transformForwardToX1Coordinate(p3->x1, p3->x2, p3->x3); - double p3x2 = trafoFor.transformForwardToX2Coordinate(p3->x1, p3->x2, p3->x3); - double p3x3 = trafoFor.transformForwardToX3Coordinate(p3->x1, p3->x2, p3->x3); - p1->x1 = trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - p1->x2 = trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - p1->x3 = trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - p2->x1 = trafoBack.transformBackwardToX1Coordinate(p2x1, p2x2, p2x3); - p2->x2 = trafoBack.transformBackwardToX2Coordinate(p2x1, p2x2, p2x3); - p2->x3 = trafoBack.transformBackwardToX3Coordinate(p2x1, p2x2, p2x3); - p3->x1 = trafoBack.transformBackwardToX1Coordinate(p3x1, p3x2, p3x3); - p3->x2 = trafoBack.transformBackwardToX2Coordinate(p3x1, p3x2, p3x3); - p3->x3 = trafoBack.transformBackwardToX3Coordinate(p3x1, p3x2, p3x3); - } - this->calculateValues(); -} -/*======================================================================*/ - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbTriangularMesh3D::toString() -{ - stringstream ss; - ss<<"GbTriangularMesh3D["; - ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<(int)this->edges->size()<<"-Edges"<<endl; - //ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\""; - //ss<<", x1min="<<this->x1min; - //ss<<", x1max="<<this->x1max; - //ss<<", x2min="<<this->x2min; - //ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - //ss<<", x3max="<<this->x3max; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the name of this triangular mesh. - * @return the name of this triangular mesh - */ -//string GbTriangularMesh3D::getName(){ return(this->name); } - -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbPoint3D*>* GbTriangularMesh3D::getNodes() { return(this->nodes); } -/** - * Returns the triangles of this triangular mesh. - * @return the triangles of this triangular mesh - */ -vector<GbTriangle3D*>* GbTriangularMesh3D::getTriangles() { return(this->triangles); } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x1min+this->x1max)); -} -/** - * Returns the center x2 coordinate of this triangular mesh. - * @return the center x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x2min+this->x2max)); -} -/** -* Returns the center x3 coordinate of this triangular mesh. - * @return the center x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x3min+this->x3max)); -} - -/** - * Returns the minimum x1 coordinate of this triangular mesh. - * @return the minimum x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -/** - * Returns the maximum x1 coordinate of this triangular mesh. - * @return the maximum x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -/** - * Returns the minimum x2 coordinate of this triangular mesh. - * @return the minimum x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -/** - * Returns the maximum x2 coordinate of this triangular mesh. - * @return the maximum x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -/** - * Returns the minimum x3 coordinate of this triangular mesh. - * @return the minimum x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -/** - * Returns the maximum x3 coordinate of this triangular mesh. - * @return the maximum x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -void GbTriangularMesh3D::calculateValues() -{ - double x1, x2, x3; - - this->x1min = (*this->nodes)[0]->getX1Coordinate(); - this->x1max = (*this->nodes)[0]->getX1Coordinate(); - this->x2min = (*this->nodes)[0]->getX2Coordinate(); - this->x2max = (*this->nodes)[0]->getX2Coordinate(); - this->x3min = (*this->nodes)[0]->getX3Coordinate(); - this->x3max = (*this->nodes)[0]->getX3Coordinate(); - - for(int i=1; i<(int)this->nodes->size(); i++) - { - x1 = (*this->nodes)[i]->getX1Coordinate(); - x2 = (*this->nodes)[i]->getX2Coordinate(); - x3 = (*this->nodes)[i]->getX3Coordinate(); - if(x1 < this->x1min) this->x1min = x1; - if(x1 > this->x1max) this->x1max = x1; - if(x2 < this->x2min) this->x2min = x2; - if(x2 > this->x2max) this->x2max = x2; - if(x3 < this->x3min) this->x3min = x3; - if(x3 > this->x3max) this->x3max = x3; - } - this->consistent = true; -} - -/** - * Returns the total area of this triangular mesh. - * @return the total area of this triangular mesh - */ -double GbTriangularMesh3D::getArea() -{ - double area = 0.0; - for(int i=0; i<(int)this->triangles->size(); i++) area += (*this->triangles)[i]->getArea(); - return(area); -} -/** - * Returns the total volume of this triangular mesh. - * @return the total volume of this triangular mesh - */ -double GbTriangularMesh3D::getVolume() -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double volume = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - } - return volume; -} -/*===============================================*/ -UbTupleDouble3 GbTriangularMesh3D::calculateCenterOfGravity() -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - return UbTupleDouble3(rSP1, rSP2, rSP3); -} -/*===============================================*/ -UbTupleDouble6 GbTriangularMesh3D::calculateMomentOfInertia(double rhoP) -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double xx,yy,zz,xy,yz,zx; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - double top11 = 0.0;double top22 = 0.0;double top33 = 0.0; - double top12 = 0.0;double top23 = 0.0;double top13 = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - double x1s = 0.0;//rSP1;//0.0;// - double x2s = 0.0;//rSP2;//0.0;// - double x3s = 0.0;//rSP3;//0.0;// - - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate()-x1s; - y1 = p1->getX2Coordinate()-x2s; - z1 = p1->getX3Coordinate()-x3s; - x2 = p2->getX1Coordinate()-x1s; - y2 = p2->getX2Coordinate()-x2s; - z2 = p2->getX3Coordinate()-x3s; - x3 = p3->getX1Coordinate()-x1s; - y3 = p3->getX2Coordinate()-x2s; - z3 = p3->getX3Coordinate()-x3s; - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume); - //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume); - //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume); - xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1; - yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1; - zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1; - top11 = top11+(yy+zz)*rhoP*G3i/60.; - top22 = top22+(xx+zz)*rhoP*G3i/60.; - top33 = top33+(yy+xx)*rhoP*G3i/60.; - xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1; - yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1; - zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1; - top12 = top12-xy*rhoP*G3i/120.; - top23 = top23-yz*rhoP*G3i/120.; - top13 = top13-zx*rhoP*G3i/120.; - } - //Satz von Steiner ... - top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3); - top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1); - top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2); - top12 = top12+rhoP*volume*rSP1*rSP2; - top23 = top23+rhoP*volume*rSP2*rSP3; - top13 = top13+rhoP*volume*rSP3*rSP1; - - cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n"; - cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl; - cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl; - - return UbTupleDouble6(top11,top22,top33,top12,top23,top13); -} - - /** - * Returns the volume of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the volume of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not yet implemented"); - // GbPolygon2D polygon; - // double volume = 0.0; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - // double t1min, t1max, t2min, t2max; - // double x1, x2; - // boolean f = false; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // volume += this.triangles[i].getVolume(); - // area2 += this.triangles[i].getArea(); - // f = true; - // } - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // try - // { - // x1 = polygon.getX1Centroid(); - // x2 = polygon.getX2Centroid(); - // volume += this.triangles[i].getX3Coordinate(x1, x2) * Math.abs(polygon.getArea()); - // area2 += Math.abs(polygon.getArea()); - // f = true; - // } - // catch(Exception e){} - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - //} - // if(f) return(volume); - // else throw new NullPointerException(); -} - -/** - * Returns the triangles of this triangular mesh located within the specified rectangle (may be an empty array). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the triangles of this triangular mesh located within the specified rectangle - */ -vector<GbTriangle3D*>* GbTriangularMesh3D::getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not yet implemented"); - // QbList triangleList = new QbList(GbTriangle3D.class); - // GbPolygon2D polygon; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // try { triangleList.append(this.triangles[i]); } catch(Exception e){} - // area2 += this.triangles[i].getArea(); - // } - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - // if(polygon != null && polygon.size() > 2) - // { - // try { triangleList.append(this.triangles[i]); } catch(Exception e){} - // area2 += Math.abs(polygon.getArea()); - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - //} - // return((GbTriangle3D[])triangleList.getObjectArray()); -} -/** - * Returns the nodes of this triangular mesh located within the specified rectangle (may be an empty array). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the nodes of this triangular mesh located within the specified rectangle - */ -vector<GbPoint3D*>* GbTriangularMesh3D::getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); -// QbList nodeList = new QbList(GbPoint3D.class); - - // for(int i=0; i<this.edges.length; i++) - // { - //if(GbSystem.inClosedInterval(this.nodes[i].getX1Coordinate(), p1x1, p2x1) && GbSystem.inClosedInterval(this.nodes[i].getX2Coordinate(), p1x2, p2x2)) - //{ - // try { nodeList.append(this.nodes[i]); } catch(Exception e){} - //} - // } - // return((GbPoint3D[])nodeList.getObjectArray()); -} - -/** - * Returns the difference of maximum and minimum x3 coordinates - * of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the difference of maximum and minimum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3min = 0.0; - // double x3max = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // if(f) - // { - // if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum(); - // if(this.triangles[i].getX3Maximum() > x3max) x3max = this.triangles[i].getX3Maximum(); - // } - // else - // { - // x3min = this.triangles[i].getX3Minimum(); - // x3max = this.triangles[i].getX3Maximum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum(); - // if(polygon.getX3Maximum() > x3max) x3max = polygon.getX3Maximum(); - // } - // else - // { - // x3min = polygon.getX3Minimum(); - // x3max = polygon.getX3Maximum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3max-x3min); - // else throw new NullPointerException(); -} -/** - * Returns the minimum x3 coordinates of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the minimum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3min = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - //t1min = this.triangles[i].getX1Minimum(); - //t1max = this.triangles[i].getX1Maximum(); - //if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - //t2min = this.triangles[i].getX2Minimum(); - //t2max = this.triangles[i].getX2Maximum(); - //if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - //{ - // if(f) - // { - // if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum(); - // } - // else - // { - // x3min = this.triangles[i].getX3Minimum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - //else - //{ - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum(); - // } - // else - // { - // x3min = polygon.getX3Minimum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - //} - //if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3min); - // else throw new NullPointerException(); -} -/** - * Returns the maximum x3 coordinates of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the maximum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3max = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - //t1min = this.triangles[i].getX1Minimum(); - //t1max = this.triangles[i].getX1Maximum(); - //if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - //t2min = this.triangles[i].getX2Minimum(); - //t2max = this.triangles[i].getX2Maximum(); - //if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - //{ - // if(f) - // { - // if(this.triangles[i].getX3Maximum() < x3max) x3max = this.triangles[i].getX3Maximum(); - // } - // else - // { - // x3max = this.triangles[i].getX3Maximum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - //else - //{ - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Maximum() < x3max) x3max = polygon.getX3Maximum(); - // } - // else - // { - // x3max = polygon.getX3Maximum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - //} - //if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3max); - // else throw new NullPointerException(); -} -/*======================================================================*/ -vector<GbTriangle3D*> GbTriangularMesh3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> tris; - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = new GbPoint3D(triangle->getPoint1()); - p2 = new GbPoint3D(triangle->getPoint2()); - p3 = new GbPoint3D(triangle->getPoint3()); - tris.push_back(new GbTriangle3D(p1, p2, p3)); - } - return tris; -} -/*======================================================================*/ -/* -* Function to determine if the point is inside the polyhedron defined as a 3D object -* using the Halfspace algorithm -* @param xp the x-coordinate of the point -* @param yp the y-coordinate of the point -* @param zp the z-coordinate of the point -* @return true if point is inside else return false -*/ -bool GbTriangularMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp) -{ - vector<GbTriangle3D*> *Triangles = this->triangles; - int Trianglesize = (int)Triangles->size(); - //GbPoint3D Point(xp,yp,zp); - for (int i=0; i<Trianglesize; i++) - { - //GbPoint3D* point1 = (*Triangles)[i]->getPoint1(); - //GbPoint3D* point2 = (*Triangles)[i]->getPoint2(); - //GbPoint3D* point3 = (*Triangles)[i]->getPoint3(); - - //GbHalfSpace3D halfspace(point1, point2, point3); - GbHalfSpace3D halfspace((*Triangles)[i]); - if (halfspace.ptInside(xp,yp,zp)) return false; - } - return true; -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles) -{ - GbVector3D point(xp,yp,zp); - - if ( this->InPolyhedron(numTriangles, point, radius) ) return true; - else return false; - -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - double dX = (xmax-xmin)/100.; - double dY = (ymax-ymin)/100.; - double dZ = (zmax-zmin)/100.; - GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) { boundingCube.finalize(); return false; } - - // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm - GbVector3D bMin(boundingCube.getPoint1()); - GbVector3D bMax(boundingCube.getPoint2()); - - boundingCube.finalize(); - - bMin = bMax.Subtract(bMin); - int radius = (int)(bMin.Length()+1)+1; - - if(this->pointinobjecttest == HALFSPACE) return this->isPointInObject3DHalfSpace(x1,x2,x3); - else if(this->pointinobjecttest == RAYCROSSING) return this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->triangles->size()); - else throw UbException(UB_EXARGS,"no ptInObjTest"); -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -GbLine3D* GbTriangularMesh3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -void GbTriangularMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals) -{ - vector<UbTupleFloat3 > nodes(triangles->size()*3); - vector<UbTupleInt3 > tris(triangles->size()); - - for(size_t i=0; i<triangles->size(); i++) - { - GbTriangle3D& tri = *((*triangles)[i]); - GbPoint3D& node1 = *tri.getPoint(0); - GbPoint3D& node2 = *tri.getPoint(1); - GbPoint3D& node3 = *tri.getPoint(2); - - nodes[i*3 ] = makeUbTuple( (float)node1.getX1Coordinate() - ,(float)node1.getX2Coordinate() - ,(float)node1.getX3Coordinate()); - nodes[i*3+1] = makeUbTuple( (float)node2.getX1Coordinate() - ,(float)node2.getX2Coordinate() - ,(float)node2.getX3Coordinate()); - nodes[i*3+2] = makeUbTuple( (float)node3.getX1Coordinate() - ,(float)node3.getX2Coordinate() - ,(float)node3.getX3Coordinate()); - - tris[i] = makeUbTuple((int)i*3,(int)i*3+1,(int)i*3+2); - } - writer->writeTriangles(filename,nodes,tris); - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - GbVector3D vec = (*triangles)[i]->getNormal(); - lineNodes[i*2 ] = makeUbTuple( (float)(*triangles)[i]->getX1Centroid() - ,(float)(*triangles)[i]->getX2Centroid() - ,(float)(*triangles)[i]->getX3Centroid()); - lineNodes[i*2+1] = makeUbTuple( (float)((*triangles)[i]->getX1Centroid()+vec.X1()) - ,(float)((*triangles)[i]->getX2Centroid()+vec.X2()) - ,(float)((*triangles)[i]->getX3Centroid()+vec.X3())); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - writer->writeLines(filename+"_normals",lineNodes,lines); - } -} -/*======================================================================*/ -void GbTriangularMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbTriangularMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbTriangularMesh3D"); - //vector<GbPoint3D*> *nodes = this->getNodes(); - vector<GbTriangle3D*> *triangles = this->getTriangles(); - //int nodesize = (int)nodes->size(); - int trianglesize = (int)triangles->size(); - int nodesize = trianglesize*3; - if(normals) - { - out->writeInteger(nodesize+trianglesize*2); - out->writeInteger(trianglesize*2); - } - else - { - out->writeInteger(nodesize); - out->writeInteger(trianglesize); - } - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - GbPoint3D *node; - for(int i=0;i<trianglesize; i++) - { - node = (*triangles)[i]->getPoint(0); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(1); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(2); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - } - - if(normals) - { - for(int i=0;i<trianglesize; i++) - { - GbVector3D vec = (*triangles)[i]->getNormal(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()); - out->writeDouble((*triangles)[i]->getX2Centroid()); - out->writeDouble((*triangles)[i]->getX3Centroid()); - out->writeLine(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()+vec.X1()); - out->writeDouble((*triangles)[i]->getX2Centroid()+vec.X2()); - out->writeDouble((*triangles)[i]->getX3Centroid()+vec.X3()); - out->writeLine(); - } - } - nr=1; - int el=1; - for(int i=0;i<trianglesize; i++) - { - nr = 3*el-2; - out->writeInteger(el); - out->writeInteger(2); - out->writeString("tri"); - out->writeInteger(nr); - out->writeInteger(nr+1); - out->writeInteger(nr+2); - out->writeLine(); - el++; - } - if(normals) - { - nr = trianglesize*3+1; - for(int i=trianglesize;i<2*trianglesize; i++) - { - out->writeInteger(el); - out->writeInteger(2); - out->writeString("line"); - out->writeInteger(nr++); - out->writeInteger(nr++); - out->writeLine(); - el++; - } - } - cout<<"done\n"; -} - -/*======================================================================*/ -/* -This function returns a char: -'V': the query point a coincides with a Vertex of polyhedron P. -'E': the query point a is in the relative interior of an Edge of polyhedron P. -'F': the query point a is in the relative interior of a Face of polyhedron P. -'i': the query point a is strictly interior to polyhedron P. -'o': the query point a is strictly exterior to( or outside of) polyhedron P. -*/ -bool GbTriangularMesh3D::InPolyhedron( int F, GbVector3D& q, int radius ) -{ - GbVector3D r; /* Ray endpoint. */ - GbVector3D p; /* Intersection point; not used. */ - int f, k = 0, crossings = 0; - char code = '?'; - - while( k++ < F ) - { - crossings = 0; - - RandomRay( r, radius ); - r = q.Add(r); - // printf("Ray endpoint: (%d,%d,%d)\n", r[0],r[1],r[2] ); - - for ( f = 0; f < F; f++ ) /* Begin check each face */ - { - if( BoxTest( (*this->triangles)[f], q, r ) == false ) code = '0'; // printf("BoxTest = 0!\n"); - else code = SegTriInt( (*this->triangles)[f], q, r, p );// printf( "Face = %d: BoxTest/SegTriInt returns %c\n\n", f, code ); - - /* If ray is degenerate, then goto outer while to generate another. */ - if( code=='p' || code=='v' || code=='e' ) break; //goto LOOP; //printf("Degenerate ray\n"); - /* If ray hits face at interior point, increment crossings. */ - else if ( code=='f' ) crossings++; // printf( "crossings = %d\n", crossings ); - /* If query endpoint q sits on a V/E/F, return that code. */ - else if ( code=='V' || code=='E' || code=='F' ) return true; - /* If ray misses triangle, do nothing. */ - else if ( code=='0' ) { /*nothing to do*/ } - else throw UbException(UB_EXARGS,"Error" ); - } /* End check each face */ - - /* No degeneracies encountered: ray is generic, so finished. */ - if(f>=F) break; - } /* End while loop */ - - // printf( "Crossings = %d\n", crossings ); - /* q strictly interior to polyhedron iff an odd number of crossings. */ - if( (crossings%2) == 1 ) return true; - - return false; -} - -/* Return a random ray endpoint */ -void GbTriangularMesh3D::RandomRay( GbVector3D& ray, int radius ) -{ - double x, y, z, w, t; - - double MAX_INT = 2147483647; - /* Generate a random point on a sphere of radius 1. */ - /* the sphere is sliced at z, and a random point at angle t - generated on the circle of intersection. */ - z = 2.0 * (double) rand() / MAX_INT - 1.0; - t = 2.0 * UbMath::PI * (double) rand() / MAX_INT; - w = sqrt( 1 - z*z ); - x = w * cos( t ); - y = w * sin( t ); - - ray[0] = radius * x; - ray[1] = radius * y; - ray[2] = radius * z; - - /*printf( "RandomRay returns %6d %6d %6d\n", ray[X], ray[Y], ray[Z] );*/ -} - -/*--------------------------------------------------------------------- -'p': The segment lies wholly within the plane. -'q': The q endpoint is on the plane (but not 'p'). -'r': The r endpoint is on the plane (but not 'p'). -'0': The segment lies strictly to one side or the other of the plane. -'1': The segement intersects the plane, and 'p' does not hold. ----------------------------------------------------------------------*/ -char GbTriangularMesh3D::SegPlaneInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m) -{ - // cout<<"SegPlaneInt..\n"; - GbVector3D N; double D; - GbVector3D rq; - double num, denom, t; - int i; - - *m = PlaneCoeff( T, N, &D ); - /*printf("m=%d; plane=(%lf,%lf,%lf,%lf)\n", m, N[X],N[Y],N[Z],D);*/ - num = D - q.Dot( N ); - rq = r.Subtract( q ); - denom = rq.Dot( N ); - /*printf("SegPlaneInt: num=%lf, denom=%lf\n", num, denom );*/ - - if ( denom == 0.0 ) { /* Segment is parallel to plane. */ - if ( num == 0.0 ) /* q is on plane. */ - //if (UbMath::zero(denom)) { /* Segment is parallel to plane. */ - // if ( UbMath::zero(num)) /* q is on plane. */ - return 'p'; - else - return '0'; - } - else - t = num / denom; - /*printf("SegPlaneInt: t=%lf \n", t );*/ - - for( i = 0; i < 3; i++ ) - p[i] = q[i] + t * ( r[i] - q[i] ); - - if ( (0.0 < t) && (t < 1.0) ) - return '1'; - else if ( num == 0.0 ) /* t == 0 */ - return 'q'; - else if ( num == denom ) /* t == 1 */ - return 'r'; - else return '0'; - - //if ( (0.0 < t) && (t < 1.0) ) - // return '1'; - //else if ( UbMath::zero(num)) /* t == 0 */ - // return 'q'; - //else if ( UbMath::equal(num , denom) ) /* t == 1 */ - // return 'r'; - //else return '0'; - -} -/*--------------------------------------------------------------------- -Computes N & D and returns index m of largest component. ----------------------------------------------------------------------*/ -int GbTriangularMesh3D::PlaneCoeff( GbTriangle3D* T, GbVector3D& N, double *D ) -{ - int i; - double t; /* Temp storage */ - double biggest = 0.0; /* Largest component of normal vector. */ - int m = 0; /* Index of largest component. */ - - N = T->getNormal(); - /*printf("PlaneCoeff: N=(%lf,%lf,%lf)\n", N[X],N[Y],N[Z]);*/ - GbVector3D a(T->getPoint1()); - - *D = a.Dot( N ); - - /* Find the largest component of N. */ - for ( i = 0; i < 3; i++ ) - { - t = std::fabs( N[i] ); - if ( t > biggest ) - { - biggest = t; - m = i; - } - } - return m; -} - -/* Assumption: p lies in the plane containing T. -Returns a char: -'V': the query point p coincides with a Vertex of triangle T. -'E': the query point p is in the relative interior of an Edge of triangle T. -'F': the query point p is in the relative interior of a Face of triangle T. -'0': the query point p does not intersect (misses) triangle T. -*/ - -char GbTriangularMesh3D::InTri3D( GbTriangle3D* T, int m, GbVector3D& p ) -{ -// int i; /* Index for X,Y,Z */ - int j; /* Index for X,Y */ -// int k; /* Index for triangle vertex */ - GbVector3D pp; /* projected p */ - GbVector3D Tp[3]; /* projected T: three new vertices */ - - /* Project out coordinate m in both p and the triangular face */ - //j = 0; - //for ( i = 0; i < 3; i++ ) { - // if ( i != m ) { /* skip largest coordinate */ - // pp[j] = p[i]; - // //for ( k = 0; k < 3; k++ ) - // std::cout<<"aachtung###############################################"; - // // Tp[k][j] = Vertices[T[k]][i]; - // j++; - // } - //} - j=0; - if(m!=0) - { - Tp[0][j] = T->getPoint1()->getX1Coordinate(); - Tp[1][j] = T->getPoint2()->getX1Coordinate(); - Tp[2][j] = T->getPoint3()->getX1Coordinate(); - j++; - } - if(m!=1) - { - Tp[0][j] = T->getPoint1()->getX2Coordinate(); - Tp[1][j] = T->getPoint2()->getX2Coordinate(); - Tp[2][j] = T->getPoint3()->getX2Coordinate(); - j++; - } - if(m!=2) - { - Tp[0][j] = T->getPoint1()->getX3Coordinate(); - Tp[1][j] = T->getPoint2()->getX3Coordinate(); - Tp[2][j] = T->getPoint3()->getX3Coordinate(); - j++; - } - - return( InTri2D( Tp, pp ) ); -} - -char GbTriangularMesh3D::InTri2D( GbVector3D Tp[3], GbVector3D& pp ) -{ - double area0, area1, area2; - - /* compute three AreaSign() values for pp w.r.t. each edge of the face in 2D */ - area0 = AreaSign( pp, Tp[0], Tp[1] ); - area1 = AreaSign( pp, Tp[1], Tp[2] ); - area2 = AreaSign( pp, Tp[2], Tp[0] ); - // printf("area0=%f area1=%f area2=%f\n",area0,area1,area2); - - if ( ( area0 == 0. ) && ( area1 > 0. ) && ( area2 > 0. ) || - ( area1 == 0. ) && ( area0 > 0. ) && ( area2 > 0. ) || - ( area2 == 0. ) && ( area0 > 0. ) && ( area1 > 0. ) ) - return 'E'; - - if ( ( area0 == 0. ) && ( area1 < 0. ) && ( area2 < 0. ) || - ( area1 == 0. ) && ( area0 < 0. ) && ( area2 < 0. ) || - ( area2 == 0. ) && ( area0 < 0. ) && ( area1 < 0. ) ) - return 'E'; - - if ( ( area0 > 0. ) && ( area1 > 0. ) && ( area2 > 0. ) || - ( area0 < 0. ) && ( area1 < 0. ) && ( area2 < 0. ) ) - return 'F'; - - if ( ( area0 == 0.0 ) && ( area1 == 0.0 ) && ( area2 == 0.0 ) ) - fprintf( stderr, "Error in InTriD\n" ), exit(EXIT_FAILURE); - - if ( ( area0 == 0. ) && ( area1 == 0. ) || - ( area0 == 0. ) && ( area2 == 0. ) || - ( area1 == 0. ) && ( area2 == 0. ) ) - return 'V'; - - else - return '0'; -} - -double GbTriangularMesh3D::AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c ) -{ - double area2; - - area2 = ( b[0] - a[0] ) * ( c[1] - a[1] ) - - ( c[0] - a[0] ) * ( b[1] - a[1] ); - - return area2; - /* The area should be an integer. */ - if ( area2 > 0.5 ) return 1; - else if ( area2 < -0.5 ) return -1; - else return 0; -} - -char GbTriangularMesh3D::SegTriInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p ) -{ - int code = '?'; - int m = -1; - - code = SegPlaneInt( T, q, r, p, &m ); - // printf("SegPlaneInt code=%c, m=%d; p=(%lf,%lf,%lf)\n", code,m,p[0],p[1],p[2]); - - if ( code == '0') return '0'; - else if ( code == 'q') return InTri3D( T, m, q ); - else if ( code == 'r') return InTri3D( T, m, r ); - else if ( code == 'p' ) return InPlane( T, m, q, r, p ); - else if ( code == '1' ) return SegTriCross( T, q, r ); - else /* Error */ return code; -} - -char GbTriangularMesh3D::InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p) -{ - // cout<<"inplane\n"; - /* NOT IMPLEMENTED */ - return 'p'; -} - -/*--------------------------------------------------------------------- -The signed volumes of three tetrahedra are computed, determined -by the segment qr, and each edge of the triangle. -Returns a char: -'v': the open segment includes a vertex of T. -'e': the open segment includes a point in the relative interior of an edge -of T. -'f': the open segment includes a point in the relative interior of a face -of T. -'0': the open segment does not intersect triangle T. ----------------------------------------------------------------------*/ - -char GbTriangularMesh3D::SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r ) -{ - // cout<<"SegTriCross\n"; - double vol0, vol1, vol2; - GbVector3D vert0(T->getPoint1()); - GbVector3D vert1(T->getPoint2()); - GbVector3D vert2(T->getPoint3()); - - vol0 = VolumeSign( q, vert0, vert1, r ); - vol1 = VolumeSign( q, vert1, vert2, r ); - vol2 = VolumeSign( q, vert2, vert0, r ); - - // printf( "SegTriCross: vol0 = %d; vol1 = %d; vol2 = %d\n", vol0, vol1, vol2 ); - - /* Same sign: segment intersects interior of triangle. */ - if ( ( ( vol0 > 0. ) && ( vol1 > 0. ) && ( vol2 > 0. ) ) || - ( ( vol0 < 0. ) && ( vol1 < 0. ) && ( vol2 < 0. ) ) ) - //if ( ( UbMath::greater(vol0, 0. ) && UbMath::greater(vol1 , 0. ) && UbMath::greater(vol2 , 0. ) ) || - // ( UbMath::less(vol0, 0. ) && UbMath::less(vol1, 0. ) && UbMath::less(vol2, 0. ) ) ) - { - return 'f'; - } - - /* Opposite sign: no intersection between segment and triangle */ - if ( ( ( vol0 > 0. ) || ( vol1 > 0. ) || ( vol2 > 0. ) ) && - ( ( vol0 < 0. ) || ( vol1 < 0. ) || ( vol2 < 0. ) ) ) - { - return '0'; - } - else if ( ( vol0 == 0.0 ) && ( vol1 == 0.0 ) && ( vol2 == 0.0 ) ) - { - std::cout<<vol0<<" "<<vol1<<" "<<vol2<<std::endl; - fprintf( stderr, "Error 1 in SegTriCross\n" ), exit(EXIT_FAILURE); - } - - /* Two zeros: segment intersects vertex. */ - else if ( ( ( vol0 == 0. ) && ( vol1 == 0. ) ) || - ( ( vol0 == 0. ) && ( vol2 == 0. ) ) || - ( ( vol1 == 0. ) && ( vol2 == 0. ) ) ) - { - return 'v'; - } - - /* One zero: segment intersects edge. */ - else if ( ( vol0 == 0. ) || ( vol1 == 0. ) || ( vol2 == 0. ) ) - { - return 'e'; - } - - throw UbException(UB_EXARGS,"fprintf( stderr, Error 2 in SegTriCross\n ), exit(EXIT_FAILURE);"); -} - - -double GbTriangularMesh3D::VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d ) -{ - double vol; - double ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz; - double bxdx, bydy, bzdz, cxdx, cydy, czdz; - - ax = a[0]; ay = a[1]; az = a[2]; - bx = b[0]; by = b[1]; bz = b[2]; - cx = c[0]; cy = c[1]; cz = c[2]; - dx = d[0]; dy = d[1]; dz = d[2]; - - bxdx=bx-dx; - bydy=by-dy; - bzdz=bz-dz; - cxdx=cx-dx; - cydy=cy-dy; - czdz=cz-dz; - vol = (az-dz) * (bxdx*cydy - bydy*cxdx) - + (ay-dy) * (bzdz*cxdx - bxdx*czdz) - + (ax-dx) * (bydy*czdz - bzdz*cydy); - - //std::cout<< vol<<std::endl; - return vol; - - - /* The volume should be an integer. */ - if ( vol > 0.5 ) return 1; - else if ( vol < -0.5 ) return -1; - else return 0; -} - -bool GbTriangularMesh3D::BoxTest(GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR) -{ - double minX1 = triangle->getX1Minimum(); - double minX2 = triangle->getX2Minimum(); - double minX3 = triangle->getX3Minimum(); - - double maxX1 = triangle->getX1Maximum(); - double maxX2 = triangle->getX2Maximum(); - double maxX3 = triangle->getX3Maximum(); - - if((PointQ.X1() < minX1) && (PointR.X1() < minX1)) return false; - if((PointQ.X2() < minX2) && (PointR.X2() < minX2)) return false; - if((PointQ.X3() < minX3) && (PointR.X3() < minX3)) return false; - if((PointQ.X1() > maxX1) && (PointR.X1() > maxX1)) return false; - if((PointQ.X2() > maxX2) && (PointR.X2() > maxX2)) return false; - if((PointQ.X3() > maxX3) && (PointR.X3() > maxX3)) return false; - - return true; -} - diff --git a/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h b/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h deleted file mode 100644 index d8185e6e4a415c221632edc20541d01f828e59dd..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h +++ /dev/null @@ -1,183 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBTRIANGULARMESH_H -#define GBTRIANGULARMESH_H - -#include <sstream> -#include <iostream> - - -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> - -#include <basics/writer/WbWriter.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <basics/memory/MbSharedPointerDefines.h> -class GbTriangularMesh3D; -typedef VFSharedPtr<GbTriangularMesh3D> GbTriangularMesh3DPtr; - - - -/*=========================================================================*/ -/* GbTriangularMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class GbTriangularMesh3D : public GbObject3D -{ -public: - enum POINTINOBJECTTEST { RAYCROSSING, HALFSPACE}; - - GbTriangularMesh3D(); - GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles); - GbTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles); - GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles); - ~GbTriangularMesh3D(); - GbTriangularMesh3D* clone() { throw UbException(UB_EXARGS,"not implemented"); } - void finalize() - { - throw UbException("GbTriangularMesh3D::finalize() - toDo"); - } - void setPointInObjectTest(POINTINOBJECTTEST mode) { this->pointinobjecttest = mode; } - - std::string getClassName() {return "GbTriangularMesh3D"; } - - std::string toString(); - //std::string getName(); - std::vector<GbPoint3D*>* getNodes(); - std::vector<GbTriangle3D*>* getTriangles(); - double getX1Centroid(); - double getX2Centroid(); - double getX3Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Minimum(); - double getX3Maximum(); - - void rotate(const double& alpha, const double& beta, const double& gamma); - void translate(const double& x1, const double& x2, const double& x3); - - void calculateValues(); - void deleteRedundantNodes(); - - UbTupleDouble6 calculateMomentOfInertia(double rhoP); - UbTupleDouble3 calculateCenterOfGravity(); - - double getArea(); - double getVolume(); - double getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - std::vector<GbTriangle3D*>* getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - std::vector<GbPoint3D*>* getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - - virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp); //based on Halfspace algorithm - bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numTriangles); //based on Spherical polygon area method - - //should be checked !!! - bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles); //based on Ray tracing algorithm - - bool InPolyhedron( int F, GbVector3D& q, int radius ); - void RandomRay( GbVector3D& ray, int radius ); - char SegPlaneInt( GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m); - int PlaneCoeff( GbTriangle3D* Tri, GbVector3D& Normal, double *D ); - char InTri3D( GbTriangle3D* T, int m, GbVector3D& p ); - char InTri2D( GbVector3D Tp[3], GbVector3D& pp ); - double AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c ); - char SegTriInt(GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p ); - char InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p); - char SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r ); - double VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d ); - bool BoxTest ( GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR); - //till here !!! - - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); - - virtual void write(UbFileOutput* out) { std::cout<<"GbTriangularMesh3D::write - sorry not implemented\n"; } - virtual void read(UbFileInput* in) { std::cout<<"GbTriangularMesh3D::read - sorry not implemented\n"; } - - void writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false); - void writeAVSMesh(UbFileOutput* out, bool normals=false); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & triangles; - if(ArchiveTools::isWriting(ar)) - { - for(std::size_t t=0; t<triangles->size(); t++) - { - nodes->push_back((*triangles)[t]->getPoint(0)); - nodes->push_back((*triangles)[t]->getPoint(1)); - nodes->push_back((*triangles)[t]->getPoint(2)); - } - } - //ar & nodes; //<- problem redundanz - //ar & edges; - ar & pointinobjecttest; - ar & x1min; - ar & x1max; - ar & x2min; - ar & x2max; - ar & x3min; - ar & x3max; - ar & consistent; - } -#endif //CAB_RCF - -protected: - std::vector<GbPoint3D*>* nodes; - std::vector<GbLine3D*>* edges; - std::vector<GbTriangle3D*>* triangles; - -private: - POINTINOBJECTTEST pointinobjecttest; - void init(); - /*======================================================================*/ - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; -}; -/*=========================================================================*/ - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if CAB_RCF <= 903 - SF_SERIALIZE_ENUM(GbTriangularMesh3D::POINTINOBJECTTEST) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbTriangularMesh3D >("GbTriangularMesh3D ") , SF_GbTriangularMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangularMesh3D >() ), SF_GbTriangularMesh3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp deleted file mode 100644 index 7012909d2376a91a0eb399711cb5b3f81c3f8ed0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp +++ /dev/null @@ -1,643 +0,0 @@ -#include <numerics/geometry3d/GbVector3D.h> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <numerics/geometry3d/GbPoint3D.h> - -using namespace std; - - -const GbVector3D GbVector3D::ZERO(0.0,0.0,0.0); -const GbVector3D GbVector3D::UNIT_X1(1.0,0.0,0.0); -const GbVector3D GbVector3D::UNIT_X2(0.0,1.0,0.0); -const GbVector3D GbVector3D::UNIT_X3(0.0,0.0,1.0); - -//---------------------------------------------------------------------------- -GbVector3D::GbVector3D () -{ - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; -} -//---------------------------------------------------------------------------- -GbVector3D::GbVector3D (const double& fX, const double& fY, const double& fZ) -{ - m_afTuple[0] = fX; - m_afTuple[1] = fY; - m_afTuple[2] = fZ; -} -//---------------------------------------------------------------------------- -GbVector3D::GbVector3D (const GbVector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; -} -//---------------------------------------------------------------------------- - -GbVector3D::GbVector3D (const GbPoint3D& point) -{ - m_afTuple[0] = point.x1; - m_afTuple[1] = point.x2; - m_afTuple[2] = point.x3; -} - -//---------------------------------------------------------------------------- -string GbVector3D::toString() -{ - std::stringstream ss; - ss<< "GbVector3D["<<m_afTuple[0]<<","<<m_afTuple[1]<<","<<m_afTuple[2]<<"]"; - ss<<endl; - return((ss.str()).c_str()); -} -//---------------------------------------------------------------------------- -GbVector3D::operator const double* () const -{ - return m_afTuple; -} -//---------------------------------------------------------------------------- -GbVector3D::operator double* () -{ - return m_afTuple; -} -//---------------------------------------------------------------------------- -double GbVector3D::operator[] (int i) const -{ - assert( 0 <= i && i <= 2 ); - if ( i < 0 ) - i = 0; - else if ( i > 2 ) - i = 2; - - return m_afTuple[i]; -} -//---------------------------------------------------------------------------- -double& GbVector3D::operator[] (int i) -{ - assert( 0 <= i && i <= 2 ); - if ( i < 0 ) - i = 0; - else if ( i > 2 ) - i = 2; - - return m_afTuple[i]; -} -//---------------------------------------------------------------------------- -double GbVector3D::X1 () const -{ - return m_afTuple[0]; -} -//---------------------------------------------------------------------------- -double& GbVector3D::X1 () -{ - return m_afTuple[0]; -} -//---------------------------------------------------------------------------- -double GbVector3D::X2 () const -{ - return m_afTuple[1]; -} -//---------------------------------------------------------------------------- -double& GbVector3D::X2 () -{ - return m_afTuple[1]; -} -//---------------------------------------------------------------------------- -double GbVector3D::X3 () const -{ - return m_afTuple[2]; -} -//---------------------------------------------------------------------------- -double& GbVector3D::X3 () -{ - return m_afTuple[2]; -} -//---------------------------------------------------------------------------- -GbVector3D& GbVector3D::operator= (const GbVector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; - return *this; -} -//---------------------------------------------------------------------------- -int GbVector3D::CompareArrays (const GbVector3D& rkV) const -{ - return memcmp(m_afTuple,rkV.m_afTuple,3*sizeof(double)); -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator== (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) == 0; -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator!= (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) != 0; -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator< (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) < 0; -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator<= (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) <= 0; -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator> (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) > 0; -} -//---------------------------------------------------------------------------- -bool GbVector3D::operator>= (const GbVector3D& rkV) const -{ - return CompareArrays(rkV) >= 0; -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::operator+ (const GbVector3D& rkV) const -{ - return GbVector3D( - m_afTuple[0]+rkV.m_afTuple[0], - m_afTuple[1]+rkV.m_afTuple[1], - m_afTuple[2]+rkV.m_afTuple[2]); -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::Add(GbVector3D& vector) -{ - return GbVector3D( - m_afTuple[0]+vector.m_afTuple[0], - m_afTuple[1]+vector.m_afTuple[1], - m_afTuple[2]+vector.m_afTuple[2]); -} - -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::operator- (const GbVector3D& rkV) const -{ - return GbVector3D( - m_afTuple[0]-rkV.m_afTuple[0], - m_afTuple[1]-rkV.m_afTuple[1], - m_afTuple[2]-rkV.m_afTuple[2]); -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::Subtract(GbVector3D& vector) -{ - return GbVector3D( - m_afTuple[0]-vector.m_afTuple[0], - m_afTuple[1]-vector.m_afTuple[1], - m_afTuple[2]-vector.m_afTuple[2]); -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::operator* (const double& fScalar) const -{ - return GbVector3D( fScalar*m_afTuple[0], - fScalar*m_afTuple[1], - fScalar*m_afTuple[2]); -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::operator/ (const double& fScalar) const -{ - GbVector3D kQuot; - - if ( fScalar != 0.0 ) - { - double fInvScalar = 1.0/fScalar; - kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0]; - kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1]; - kQuot.m_afTuple[2] = fInvScalar*m_afTuple[2]; - } - else - { - kQuot.m_afTuple[0] = Ub::inf; - kQuot.m_afTuple[1] = Ub::inf; - kQuot.m_afTuple[2] = Ub::inf; - } - - return kQuot; -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::operator- () const -{ - return GbVector3D( - -m_afTuple[0], - -m_afTuple[1], - -m_afTuple[2]); -} -//---------------------------------------------------------------------------- -GbVector3D operator* (const double& fScalar, const GbVector3D& rkV) -{ - return GbVector3D( - fScalar*rkV[0], - fScalar*rkV[1], - fScalar*rkV[2]); -} -//---------------------------------------------------------------------------- -GbVector3D& GbVector3D::operator+= (const GbVector3D& rkV) -{ - m_afTuple[0] += rkV.m_afTuple[0]; - m_afTuple[1] += rkV.m_afTuple[1]; - m_afTuple[2] += rkV.m_afTuple[2]; - return *this; -} -//---------------------------------------------------------------------------- -GbVector3D& GbVector3D::operator-= (const GbVector3D& rkV) -{ - m_afTuple[0] -= rkV.m_afTuple[0]; - m_afTuple[1] -= rkV.m_afTuple[1]; - m_afTuple[2] -= rkV.m_afTuple[2]; - return *this; -} -//---------------------------------------------------------------------------- -GbVector3D& GbVector3D::operator*= (const double& fScalar) -{ - m_afTuple[0] *= fScalar; - m_afTuple[1] *= fScalar; - m_afTuple[2] *= fScalar; - return *this; -} -//---------------------------------------------------------------------------- -GbVector3D& GbVector3D::operator/= (const double& fScalar) -{ - if ( fScalar != (double)0.0 ) - { - double fInvScalar = ((double)1.0)/fScalar; - m_afTuple[0] *= fInvScalar; - m_afTuple[1] *= fInvScalar; - m_afTuple[2] *= fInvScalar; - } - else - { - m_afTuple[0] = Ub::inf; - m_afTuple[1] = Ub::inf; - m_afTuple[2] = Ub::inf; - } - - return *this; -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::Scale(const double& x) -{ - GbVector3D PointA(0.0,0.0,0.0); - PointA.m_afTuple[0] = x * m_afTuple[0]; - PointA.m_afTuple[1] = x * m_afTuple[1]; - PointA.m_afTuple[2] = x * m_afTuple[2]; - return PointA; -} - -//---------------------------------------------------------------------------- -double GbVector3D::Length () const -{ - return std::sqrt( - m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2]); -} -//---------------------------------------------------------------------------- -double GbVector3D::SquaredLength () const -{ - return - m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2]; -} -//---------------------------------------------------------------------------- -double GbVector3D::Dot (const GbVector3D& rkV) const -{ - return - m_afTuple[0]*rkV.m_afTuple[0] + - m_afTuple[1]*rkV.m_afTuple[1] + - m_afTuple[2]*rkV.m_afTuple[2]; -} -//---------------------------------------------------------------------------- -double GbVector3D::Normalize () -{ - double fLength = Length(); - - if ( fLength > UbMath::Epsilon<double>::val() ) - { - double fInvLength = ((double)1.0)/fLength; - m_afTuple[0] *= fInvLength; - m_afTuple[1] *= fInvLength; - m_afTuple[2] *= fInvLength; - } - else - { - fLength = 0.0; - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; - } - - return fLength; -} -//---------------------------------------------------------------------------- -GbVector3D GbVector3D::Cross (const GbVector3D& rkV) const -{ - return GbVector3D( - m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]); -} - -//---------------------------------------------------------------------------- - -GbVector3D GbVector3D::UnitCross (const GbVector3D& rkV) const -{ - GbVector3D kCross( - m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]); - kCross.Normalize(); - return kCross; -} -//---------------------------------------------------------------------------- -void GbVector3D::GetBarycentrics (const GbVector3D& rkV0, - const GbVector3D& rkV1, const GbVector3D& rkV2, - const GbVector3D& rkV3, double afBary[4]) const -{ - // compute the vectors relative to V3 of the tetrahedron - GbVector3D akDiff[4] = - { - rkV0 - rkV3, - rkV1 - rkV3, - rkV2 - rkV3, - *this - rkV3 - }; - - // If the vertices have large magnitude, the linear system of - // equations for computing barycentric coordinates can be - // ill-conditioned. To avoid this, uniformly scale the tetrahedron - // edges to be of order 1. The scaling of all differences does not - // change the barycentric coordinates. - double fMax = (double)0.0; - int i; - for (i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - double fValue = std::fabs(akDiff[i][j]); - if ( fValue > fMax ) - fMax = fValue; - } - } - - // scale down only large data - if ( fMax > (double)1.0 ) - { - double fInvMax = ((double)1.0)/fMax; - for (i = 0; i < 4; i++) - akDiff[i] *= fInvMax; - } - - double fDet = akDiff[0].Dot(akDiff[1].Cross(akDiff[2])); - GbVector3D kE1cE2 = akDiff[1].Cross(akDiff[2]); - GbVector3D kE2cE0 = akDiff[2].Cross(akDiff[0]); - GbVector3D kE0cE1 = akDiff[0].Cross(akDiff[1]); - if ( std::fabs(fDet) > UbMath::Epsilon<double>::val() ) - { - double fInvDet = ((double)1.0)/fDet; - afBary[0] = akDiff[3].Dot(kE1cE2)*fInvDet; - afBary[1] = akDiff[3].Dot(kE2cE0)*fInvDet; - afBary[2] = akDiff[3].Dot(kE0cE1)*fInvDet; - afBary[3] = (double)1.0 - afBary[0] - afBary[1] - afBary[2]; - } - else - { - // The tetrahedron is potentially flat. Determine the face of - // maximum area and compute barycentric coordinates with respect - // to that face. - GbVector3D kE02 = rkV0 - rkV2; - GbVector3D kE12 = rkV1 - rkV2; - GbVector3D kE02cE12 = kE02.Cross(kE12); - double fMaxSqrArea = kE02cE12.SquaredLength(); - int iMaxIndex = 3; - double fSqrArea = kE0cE1.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 0; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE1cE2.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 1; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE2cE0.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 2; - fMaxSqrArea = fSqrArea; - } - - if ( fMaxSqrArea > UbMath::Epsilon<double>::val() ) - { - double fInvSqrArea = ((double)1.0)/fMaxSqrArea; - GbVector3D kTmp; - if ( iMaxIndex == 0 ) - { - kTmp = akDiff[3].Cross(akDiff[1]); - afBary[0] = kE0cE1.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[0].Cross(akDiff[3]); - afBary[1] = kE0cE1.Dot(kTmp)*fInvSqrArea; - afBary[2] = (double)0.0; - afBary[3] = (double)1.0 - afBary[0] - afBary[1]; - } - else if ( iMaxIndex == 1 ) - { - afBary[0] = (double)0.0; - kTmp = akDiff[3].Cross(akDiff[2]); - afBary[1] = kE1cE2.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[1].Cross(akDiff[3]); - afBary[2] = kE1cE2.Dot(kTmp)*fInvSqrArea; - afBary[3] = (double)1.0 - afBary[1] - afBary[2]; - } - else if ( iMaxIndex == 2 ) - { - kTmp = akDiff[2].Cross(akDiff[3]); - afBary[0] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[1] = (double)0.0; - kTmp = akDiff[3].Cross(akDiff[0]); - afBary[2] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[3] = (double)1.0 - afBary[0] - afBary[2]; - } - else - { - akDiff[3] = *this - rkV2; - kTmp = akDiff[3].Cross(kE12); - afBary[0] = kE02cE12.Dot(kTmp)*fInvSqrArea; - kTmp = kE02.Cross(akDiff[3]); - afBary[1] = kE02cE12.Dot(kTmp)*fInvSqrArea; - afBary[2] = (double)1.0 - afBary[0] - afBary[1]; - afBary[3] = (double)0.0; - } - } - else - { - // The tetrahedron is potentially a sliver. Determine the edge of - // maximum length and compute barycentric coordinates with respect - // to that edge. - double fMaxSqrLength = akDiff[0].SquaredLength(); - iMaxIndex = 0; // <V0,V3> - double fSqrLength = akDiff[1].SquaredLength(); - if ( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 1; // <V1,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = akDiff[2].SquaredLength(); - if ( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 2; // <V2,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE02.SquaredLength(); - if ( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 3; // <V0,V2> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE12.SquaredLength(); - if ( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 4; // <V1,V2> - fMaxSqrLength = fSqrLength; - } - GbVector3D kE01 = rkV0 - rkV1; - fSqrLength = kE01.SquaredLength(); - if ( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 5; // <V0,V1> - fMaxSqrLength = fSqrLength; - } - - if ( fMaxSqrLength > UbMath::Epsilon<double>::val() ) - { - double fInvSqrLength = ((double)1.0)/fMaxSqrLength; - if ( iMaxIndex == 0 ) - { - // P-V3 = t*(V0-V3) - afBary[0] = akDiff[3].Dot(akDiff[0])*fInvSqrLength; - afBary[1] = (double)0.0; - afBary[2] = (double)0.0; - afBary[3] = (double)1.0 - afBary[0]; - } - else if ( iMaxIndex == 1 ) - { - // P-V3 = t*(V1-V3) - afBary[0] = (double)0.0; - afBary[1] = akDiff[3].Dot(akDiff[1])*fInvSqrLength; - afBary[2] = (double)0.0; - afBary[3] = (double)1.0 - afBary[1]; - } - else if ( iMaxIndex == 2 ) - { - // P-V3 = t*(V2-V3) - afBary[0] = (double)0.0; - afBary[1] = (double)0.0; - afBary[2] = akDiff[3].Dot(akDiff[2])*fInvSqrLength; - afBary[3] = (double)1.0 - afBary[2]; - } - else if ( iMaxIndex == 3 ) - { - // P-V2 = t*(V0-V2) - akDiff[3] = *this - rkV2; - afBary[0] = akDiff[3].Dot(kE02)*fInvSqrLength; - afBary[1] = (double)0.0; - afBary[2] = (double)1.0 - afBary[0]; - afBary[3] = (double)0.0; - } - else if ( iMaxIndex == 4 ) - { - // P-V2 = t*(V1-V2) - akDiff[3] = *this - rkV2; - afBary[0] = (double)0.0; - afBary[1] = akDiff[3].Dot(kE12)*fInvSqrLength; - afBary[2] = (double)1.0 - afBary[1]; - afBary[3] = (double)0.0; - } - else - { - // P-V1 = t*(V0-V1) - akDiff[3] = *this - rkV1; - afBary[0] = akDiff[3].Dot(kE01)*fInvSqrLength; - afBary[1] = (double)1.0 - afBary[0]; - afBary[2] = (double)0.0; - afBary[3] = (double)0.0; - } - } - else - { - // tetrahedron is a nearly a point, just return equal weights - afBary[0] = (double)0.25; - afBary[1] = afBary[0]; - afBary[2] = afBary[0]; - afBary[3] = afBary[0]; - } - } - } -} -//---------------------------------------------------------------------------- -void GbVector3D::Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW) -{ - // If the input vectors are v0, v1, and v2, then the Gram-Schmidt - // orthonormalization produces vectors u0, u1, and u2 as follows, - // - // u0 = v0/|v0| - // u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0| - // u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1| - // - // where |A| indicates length of vector A and A*B indicates dot - // product of vectors A and B. - - // compute u0 - rkU.Normalize(); - - // compute u1 - double fDot0 = rkU.Dot(rkV); - rkV -= fDot0*rkU; - rkV.Normalize(); - - // compute u2 - double fDot1 = rkV.Dot(rkW); - fDot0 = rkU.Dot(rkW); - rkW -= fDot0*rkU + fDot1*rkV; - rkW.Normalize(); -} -//---------------------------------------------------------------------------- -void GbVector3D::Orthonormalize (GbVector3D* akV) -{ - Orthonormalize(akV[0],akV[1],akV[2]); -} -//---------------------------------------------------------------------------- -void GbVector3D::GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV, - GbVector3D& rkW, bool bUnitLengthW) -{ - if ( !bUnitLengthW ) - rkW.Normalize(); - - double fInvLength; - - if ( std::fabs(rkW.m_afTuple[0]) >= - std::fabs(rkW.m_afTuple[1]) ) - { - // W.x or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[0]*rkW.m_afTuple[0] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = -rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[1] = (double)0.0; - rkU.m_afTuple[2] = +rkW.m_afTuple[0]*fInvLength; - } - else - { - // W.y or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[1]*rkW.m_afTuple[1] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = (double)0.0; - rkU.m_afTuple[1] = +rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[2] = -rkW.m_afTuple[1]*fInvLength; - } - - rkV = rkW.Cross(rkU); -} -//---------------------------------------------------------------------------- - diff --git a/ThirdParty/Library/numerics/geometry3d/GbVector3D.h b/ThirdParty/Library/numerics/geometry3d/GbVector3D.h deleted file mode 100644 index 9fe4c2698e77ce7788d0a8a273ff5213724af08f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbVector3D.h +++ /dev/null @@ -1,135 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBVECTOR3D_H -#define GBVECTOR3D_H - -#include <cfloat> -#include <cassert> -#include <string> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <basics/memory/MbSharedPointerDefines.h> -class GbVector3D; -typedef VFSharedPtr<GbVector3D> GbVector3DPtr; - - -class GbPoint3D; - -class GbVector3D -{ -public: - // construction - GbVector3D (); - GbVector3D (const double& fX1, const double& fX2, const double& fX3); - GbVector3D (const GbVector3D& rkV); - GbVector3D (const GbPoint3D& rkV); - - std::string toString(); - - // coordinate access - operator const double* () const; - operator double* (); - double operator[] (int i) const; - double& operator[] (int i); - double X1 () const; - double& X1 (); - double X2 () const; - double& X2 (); - double X3 () const; - double& X3 (); - - // assignment - GbVector3D& operator= (const GbVector3D& rkV); - - // comparison - bool operator== (const GbVector3D& rkV) const; - bool operator!= (const GbVector3D& rkV) const; - bool operator< (const GbVector3D& rkV) const; - bool operator<= (const GbVector3D& rkV) const; - bool operator> (const GbVector3D& rkV) const; - bool operator>= (const GbVector3D& rkV) const; - - // arithmetic operations - GbVector3D operator+ (const GbVector3D& rkV) const; - GbVector3D operator- (const GbVector3D& rkV) const; - GbVector3D operator* (const double& fScalar) const; - GbVector3D operator/ (const double& fScalar) const; - GbVector3D operator- () const; - - // arithmetic updates - GbVector3D& operator+= (const GbVector3D& rkV); - GbVector3D& operator-= (const GbVector3D& rkV); - GbVector3D& operator*= (const double& fScalar); - GbVector3D& operator/= (const double& fScalar); - - GbVector3D Add(GbVector3D& vector); - GbVector3D Subtract(GbVector3D& vector); - GbVector3D Scale(const double& x); - - // vector operations - double Length () const; - double SquaredLength () const; - double Dot (const GbVector3D& rkV) const; - double Normalize (); - - // The cross products are computed using the right-handed rule. Be aware - // that some graphics APIs use a left-handed rule. If you have to compute - // a cross product with these functions and send the result to the API - // that expects left-handed, you will need to change sign on the vector - // (replace each component value c by -c). - GbVector3D Cross (const GbVector3D& rkV) const; - GbVector3D UnitCross (const GbVector3D& rkV) const; - - // Compute the barycentric coordinates of the point with respect to the - // tetrahedron <V0,V1,V2,V3>, P = b0*V0 + b1*V1 + b2*V2 + b3*V3, where - // b0 + b1 + b2 + b3 = 1. - void GetBarycentrics (const GbVector3D& rkV0, - const GbVector3D& rkV1, const GbVector3D& rkV2, - const GbVector3D& rkV3, double afBary[4]) const; - - // Gram-Schmidt orthonormalization. Take linearly independent vectors - // U, V, and W and compute an orthonormal set (unit length, mutually - // perpendicular). - static void Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW); - static void Orthonormalize (GbVector3D* akV); - - // Input W must be initialized to a nonzero vector, output is {U,V,W}, - // an orthonormal basis. A hint is provided about whether or not W - // is already unit length. - static void GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV, - GbVector3D& rkW, bool bUnitLengthW); - - // special vectors - static const GbVector3D ZERO; - static const GbVector3D UNIT_X1; - static const GbVector3D UNIT_X2; - static const GbVector3D UNIT_X3; - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & m_afTuple; - } -#endif //CAB_RCF -private: - // support for comparisons - int CompareArrays (const GbVector3D& rkV) const; - - double m_afTuple[3]; -}; - -GbVector3D operator* (const double& fScalar, const GbVector3D& rkV); - -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbVector3D >("GbVector3D "), SF_GbVector3D ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GBVECTOR3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp b/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp deleted file mode 100644 index 93fe1064aa945c3f5491c7fff9442a9efec62f86..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -#include <numerics/geometry3d/GbVoxelMatrix3D.h> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbFileInputASCII.h> -#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> - -#include <basics/utilities/UbSystem.h> - -#ifdef MC_CUBES - #include <3rdParty/MarchingCubes/MarchingCubes.h> -#endif // MC_CUBES - -using namespace std; - -const float GbVoxelMatrix3D::SOLID = 1.0f; -const float GbVoxelMatrix3D::FLUID = 0.0f; - - -/*=======================================================*/ -ObObjectCreator* GbVoxelMatrix3D::getCreator() -{ - return GbVoxelMatrix3DCreator::getInstance(); -} -/*=======================================================*/ -// Konstruktor -GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold) - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , lowerThreshold(lowerThreshold) - , upperThreshold(upperThreshold) - , nodesX1(nx1) - , nodesX2(nx2) - , nodesX3(nx3) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) - , voxelMatrix(Matrix3D(nx1, nx2, nx3, initVal)) -{ - this->setName("VoxelMatrix3D"); -} -/*=======================================================*/ -GbVoxelMatrix3D::GbVoxelMatrix3D() - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , nodesX1(0) - , nodesX2(0) - , nodesX3(0) - , lowerThreshold(0.0) - , upperThreshold(0.0) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) -{ - this->setName("VoxelMatrix3D"); -} -/*=======================================================*/ -GbVoxelMatrix3D::GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold, double upperThreshold) - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , nodesX1((int)voxelMatrix.getNX1()) - , nodesX2((int)voxelMatrix.getNX2()) - , nodesX3((int)voxelMatrix.getNX3()) - , lowerThreshold(lowerThreshold) - , upperThreshold(upperThreshold) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) - , voxelMatrix(voxelMatrix) -{ - this->setName("VoxelMatrix3D"); -} -/*=======================================================*/ -GbVoxelMatrix3D* GbVoxelMatrix3D::clone() -{ - GbVoxelMatrix3D* vm = new GbVoxelMatrix3D(this->voxelMatrix, lowerThreshold, upperThreshold); - vm->setVoxelMatrixMininum(minX1, minX2, minX3); - vm->setVoxelMatrixDelta(deltaX1, deltaX2, deltaX3); - return vm; -} -/*=======================================================*/ -void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} -/*=======================================================*/ -void GbVoxelMatrix3D::translate(const double& tx1, const double& tx2, const double& tx3) -{ - this->minX1 += tx1; - this->minX2 += tx2; - this->minX3 += tx3; - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbVoxelMatrix3D::setClosedVoidSpaceToSolid() -{ - voxelMatrixTemp = Matrix3D(nodesX1, nodesX2, nodesX3, SOLID); - flagMatrix = CbArray3D<char>(nodesX1, nodesX2, nodesX3, 0); - - for (int x3 = 0; x3<nodesX3; x3++) - { - for (int x2 = 0; x2<nodesX2; x2++) - { - for (int x1 = 0; x1<nodesX1; x1++) - { - if (voxelMatrix(x1, x2, x3)==FLUID) - { - UBLOG(logINFO, "setClosedVoidSpaceToSolid:start"); - x1Nbr.push_back(x1); - x2Nbr.push_back(x2); - x3Nbr.push_back(x3); - int size = (int)x1Nbr.size(); - while (size > 0) - { - for (int i = 0; i < size; i++) - { - findFluidNeighbor(x1Nbr[i], x2Nbr[i], x3Nbr[i]); - } - - swap(x1Nbr, x1NbrTemp); - swap(x2Nbr, x2NbrTemp); - swap(x3Nbr, x3NbrTemp); - - x1NbrTemp.clear(); - x2NbrTemp.clear(); - x3NbrTemp.clear(); - size = x1Nbr.size(); - } - UBLOG(logINFO, "setClosedVoidSpaceToSolid:end"); - voxelMatrix = voxelMatrixTemp; - return; - } - - } - } - } -} -/*=======================================================*/ -void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3) -{ - for (int k3 = -1; k3<=1; k3++) - { - for (int k2 = -1; k2<=1; k2++) - { - for (int k1 = -1; k1<=1; k1++) - { - int j1 = x1+k1; - int j2 = x2+k2; - int j3 = x3+k3; - if (j1>=0 && j1<nodesX1 && j2>=0 && j2<nodesX2 && j3>=0 && j3<nodesX3) - { - if (voxelMatrix(j1, j2, j3)==FLUID) - { - if (flagMatrix(j1, j2, j3) == 0) - { - voxelMatrixTemp(j1, j2, j3) = FLUID; - flagMatrix(j1, j2, j3) = 1; - x1NbrTemp.push_back(j1); - x2NbrTemp.push_back(j2); - x3NbrTemp.push_back(j3); - } - } - } - } - } - } -} -/*=======================================================*/ -void GbVoxelMatrix3D::calculateNumberOfSolidAndFluid() -{ - numberOfSolid = 0; - - for (int x3 = 0; x3<nodesX3; x3++) - for (int x2 = 0; x2<nodesX2; x2++) - for (int x1 = 0; x1<nodesX1; x1++) - { - if (voxelMatrix(x1, x2, x3) == GbVoxelMatrix3D::SOLID) - { - numberOfSolid++; - } - } - - numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3 - numberOfSolid; -} -/*=======================================================*/ -long GbVoxelMatrix3D::getNumberOfSolid() -{ - return numberOfSolid; -} -/*=======================================================*/ -long GbVoxelMatrix3D::getNumberOfFluid() -{ - return numberOfFluid; -} -/*=======================================================*/ -double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - if( !( (UbMath::equal(rx1,0.0) || UbMath::equal(fabs(rx1),1.0) || UbMath::equal(fabs(rx1),UbMath::one_over_sqrt2) ) - && (UbMath::equal(rx2,0.0) || UbMath::equal(fabs(rx2),1.0) || UbMath::equal(fabs(rx2),UbMath::one_over_sqrt2) ) - && (UbMath::equal(rx3,0.0) || UbMath::equal(fabs(rx3),1.0) || UbMath::equal(fabs(rx3),UbMath::one_over_sqrt2) ) ) ) - { - throw UbException(UB_EXARGS,"nur fuer diskrete Boltzmannrichungen implementiert!!!"); - } - - //nachbarindex ermitteln - int ndx1 = 0, ndx2 = 0, ndx3 = 0; - if (UbMath::greater(rx1, 0.0)) ndx1 = 1; - else if (UbMath::less(rx1, 0.0)) ndx1 = -1; - if (UbMath::greater(rx2, 0.0)) ndx2 = 1; - else if (UbMath::less(rx2, 0.0)) ndx2 = -1; - if (UbMath::greater(rx3, 0.0)) ndx3 = 1; - else if (UbMath::less(rx3, 0.0)) ndx3 = -1; - - int nix1 = UbMath::integerRounding( (x1-minX1)/deltaX1 )+ndx1; - int nix2 = UbMath::integerRounding( (x2-minX2)/deltaX2 )+ndx2; - int nix3 = UbMath::integerRounding( (x3-minX3)/deltaX3 )+ndx3; - - //test ob nachbar solid - if( nix1>=0 - && nix2>=0 - && nix3>=0 - && nix1<voxelMatrix.getNX1() - && nix2<voxelMatrix.getNX2() - && nix3<voxelMatrix.getNX3() ) - { - if( UbMath::equal(voxelMatrix(nix1,nix2,nix3), SOLID) ) - { - //return halber abstand der beiden knoten - return 0.5*sqrt( (ndx1*deltaX1)*(ndx1*deltaX1) - + (ndx2*deltaX2)*(ndx2*deltaX2) - + (ndx3*deltaX3)*(ndx3*deltaX3) ); - } - } - - return 0.0; -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - //index ermitteln - int ix1 = UbMath::integerRounding( (x1p-minX1)/deltaX1 ); - int ix2 = UbMath::integerRounding( (x2p-minX2)/deltaX2 ); - int ix3 = UbMath::integerRounding( (x3p-minX3)/deltaX3 ); - - if( ix1>=0 - && ix2>=0 - && ix3>=0 - && ix1<voxelMatrix.getNX1() - && ix2<voxelMatrix.getNX2() - && ix3<voxelMatrix.getNX3() ) - { - if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), SOLID)) return true; - } - - return false; -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - pointIsOnBoundary = false; - - return isPointInGbObject3D(x1p,x2p,x3p); -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double& x1p1,const double& x2p1,const double& x3p1,const double& x1p2,const double& x2p2,const double& x3p2) -{ - return false; -//dass hängt von der Konfigration ab, aber meist ist der Block grösser wie etliche Poren ... - - //indizes ermitteln - int startix1 = (int)std::floor( (x1p1-minX1)/deltaX1+1E-13 ); - int startix2 = (int)std::floor( (x2p1-minX2)/deltaX2+1E-13 ); - int startix3 = (int)std::floor( (x3p1-minX3)/deltaX3+1E-13 ); - - if(startix1<0 ) return false; - if(startix2<0 ) return false; - if(startix3<0 ) return false; - - int maxiX1 = (int)voxelMatrix.getNX1()-1; - int maxiX2 = (int)voxelMatrix.getNX2()-1; - int maxiX3 = (int)voxelMatrix.getNX3()-1; - - int endix1 = (int)std::ceil( (x1p2-minX1)/deltaX1-1E-13 ); - int endix2 = (int)std::ceil( (x2p2-minX2)/deltaX2-1E-13 ); - int endix3 = (int)std::ceil( (x3p2-minX3)/deltaX3-1E-13 ); - - if(endix1>maxiX1 ) return false; - if(endix2>maxiX2 ) return false; - if(endix3>maxiX3 ) return false; - - for(int ix3=startix3; ix3<=endix3; ix3++) - for(int ix2=startix2; ix2<=endix2; ix2++) - for(int ix1=startix1; ix1<=endix1; ix1++) - if( UbMath::equal(voxelMatrix(ix1,ix2,ix3), FLUID ) ) - return false; - return true; -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung -//returns true: -// - cell cuts GbVoxelMatrix3D -// - cell boxes GbVoxelMatrix3D -//returns false: -// - cell completely inside GbVoxelMatrix3D -// - 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; - } - - return false; -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside cuboid3D ( = cuboid3D boxes cell) -// - cell cuts cuboid3D -// - cell boxes cuboid3D -//returns false: -// - 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! - - 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->getX3Centroid() - 0.5*(x3b+x3a) /*Tx3*/ ) - , 0.5*( this->getLengthX3() + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) ) - { - return true; - } - - return false; -} -/*=======================================================*/ -vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> triangles; - - #ifdef MC_CUBES - //MC - typedef McCubes::Matrix3DWrapper< Matrix3D > McMatrixWrapper; - typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; - typedef McMarchingCubesGenerator::Vertex McVertex; - typedef McMarchingCubesGenerator::Triangle McTriangle; - - McMatrixWrapper wrapper(&voxelMatrix);//,0,0,0,voxelMatrix.getNX1()-1,voxelMatrix.getNX2()-1,voxelMatrix.getNX3()-1); - McMarchingCubesGenerator mc(wrapper); - - mc.init_all(); - mc.run(0.5); - - //const int nofVertices = mc.nverts(); - const int nofTriangles = mc.ntrigs(); - - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); - - for(int t=0; t<nofTriangles; t++) - { - triangles.push_back(new GbTriangle3D( new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v1].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v1].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v1].z /*-1*/) ) - ,new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v2].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v2].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v2].z /*-1*/) ) - ,new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v3].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v3].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v3].z /*-1*/) ) ) ); - } - #else - cerr<<"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; - #endif // MC_CUBES - - return triangles; -} -/*=======================================================*/ -void GbVoxelMatrix3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet start") - if(!this->addSurfaceTriangleSetFlag) - { - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation") - return; - } - #ifdef MC_CUBES - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet MC defined") - - typedef McCubes::Matrix3DWrapper< Matrix3D > McMatrixWrapper; - typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; - typedef McMarchingCubesGenerator::Vertex McVertex; - typedef McMarchingCubesGenerator::Triangle McTriangle; - - //MC - { //standard( fuer voxelmatrix) - McMatrixWrapper wrapper(&voxelMatrix); - McMarchingCubesGenerator mc(wrapper); - - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet McMarchingCubesGenerator") - - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.init") - mc.init_all(); - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.run") - mc.run(0.5); - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.run done") - - const int nofVertices = mc.nverts(); - const int nofTriangles = mc.ntrigs(); - - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); - -UBLOG(logDEBUG1," GbVoxelMatrix3D node tuple") - for(int n=0; n<nofVertices; n++) - nodes.push_back( makeUbTuple( (float)(minX1 + deltaX1 * (mcvertices[n].x /*-1*/)), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt - (float)(minX2 + deltaX2 * (mcvertices[n].y /*-1*/)), - (float)(minX3 + deltaX3 * (mcvertices[n].z /*-1*/)) ) ); -UBLOG(logDEBUG1," GbVoxelMatrix3D triangles tuple") - for(int t=0; t<nofTriangles; t++) - triangles.push_back( makeUbTuple( mctriangles[t].v1, mctriangles[t].v2, mctriangles[t].v3 ) ); -UBLOG(logDEBUG1," GbVoxelMatrix3D triangles tuple done") - } - - //false - das scheint probleme bei der asphaltprobe zu machen 1500x600x100 - // da lief es bis C - evtl. memory voll - if(false) //extension... um die raender koerrekt abzubilden muesste man eine dummy FLUID reihe um - { //die matrix legen( lsg1: temp matrix mit 2 reihen pro richtung mehr -> zuviel speicher, 500^3 = 500MB - // lsg2: fuer jede flaeche eine dummy matrix -> wie folgt: - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); -UBLOG(logINFO," A ") - Matrix3D tmpX1Min( 2, nx2+2, nx3+2, FLUID ); - Matrix3D tmpX1Max( 2, nx2+2, nx3+2, FLUID ); - for(int x3=0; x3<nx3; x3++ ) - for(int x2=0; x2<nx2; x2++ ) - { - tmpX1Min(1, x2+1, x3+1) = voxelMatrix(0 , x2, x3); - tmpX1Max(0, x2+1, x3+1) = voxelMatrix(nx1-1, x2, x3); - } -UBLOG(logINFO," B") - Matrix3D tmpX2Min(nx1+2, 2, nx3+2, FLUID ); - Matrix3D tmpX2Max(nx1+2, 2, nx3+2, FLUID ); - for(int x3=0; x3<nx3; x3++ ) - for(int x1=0; x1<nx1; x1++ ) - { - tmpX2Min(x1+1, 1, x3+1) = voxelMatrix(x1, 0 , x3); - tmpX2Max(x1+1, 0, x3+1) = voxelMatrix(x1, nx2-1, x3); - } -UBLOG(logINFO," C ") - Matrix3D tmpX3Min(nx1+2, nx3+2, 2, FLUID ); - Matrix3D tmpX3Max(nx1+2, nx3+2, 2, FLUID ); - for(int x2=0; x2<nx2; x2++ ) - for(int x1=0; x1<nx1; x1++ ) - { - tmpX3Min(x1+1, x2+1, 1) = voxelMatrix(x1, x2, 0 ); - tmpX3Max(x1+1, x2+1, 0) = voxelMatrix(x1, x2, nx3-1); - } -UBLOG(logINFO," D") - Matrix3D* matrices[] = { &tmpX1Min, &tmpX1Max, &tmpX2Min, &tmpX2Max, &tmpX3Min, &tmpX3Max }; - int dx1[] = { -1, nx1-1, -1, -1, -1, -1 }; - int dx2[] = { -1, -1, -1, nx2-1, -1, -1 }; - int dx3[] = { -1, -1, -1, -1, -1, nx3-1 }; -UBLOG(logINFO," E") - for(int i=0; i<6; i++) - { - McMatrixWrapper wrapper(matrices[i]); - McMarchingCubesGenerator mc(wrapper); - - mc.init_all(); - mc.run(0.5); - - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); - - int deltaNodeNr = (int)nodes.size(); -UBLOG(logINFO," GbVoxelMatrix3D node tuple") - for(int n=0; n<mc.nverts(); n++) - nodes.push_back( makeUbTuple( (float)(minX1 + deltaX1 * (mcvertices[n].x + dx1[i])), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt - (float)(minX2 + deltaX2 * (mcvertices[n].y + dx2[i])), - (float)(minX3 + deltaX3 * (mcvertices[n].z + dx3[i])) ) ); - for(int t=0; t<mc.ntrigs(); t++) - triangles.push_back( makeUbTuple( deltaNodeNr+mctriangles[t].v1, deltaNodeNr+mctriangles[t].v2, deltaNodeNr+mctriangles[t].v3 ) ); - } - } - #else - cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; - #endif // MC_CUBES - - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet end") -} -/*=======================================================*/ -string GbVoxelMatrix3D::toString() -{ - return "GbVoxelMatrix3D"; -} -/*=======================================================*/ -void GbVoxelMatrix3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(minX1); - out->writeDouble(minX2); - out->writeDouble(minX3); - out->writeDouble(deltaX1); - out->writeDouble(deltaX2); - out->writeDouble(deltaX3); - out->writeInteger(nodesX1); - out->writeInteger(nodesX2); - out->writeInteger(nodesX3); - out->writeDouble(lowerThreshold); - out->writeDouble(upperThreshold); - out->writeBool(addSurfaceTriangleSetFlag); - out->writeBool(transferViaFilename); - if(!transferViaFilename) - { - throw UbException(UB_EXARGS,"void GbVoxelMatrix3D::write(UbFileOutput* out) - geht ned"); - } - else - { - out->writeString(filename); - } - - - //CbUniformMatrix3D<float> voxelMatrix; -} -/*=======================================================*/ -void GbVoxelMatrix3D::read(UbFileInput* in) -{ -#ifdef CAB_RCF - try - { -#endif - //!!! den string nimmt er vorher um das Object zu erstellen - //in->readString(); - minX1 = in->readDouble(); - minX2 = in->readDouble(); - minX3 = in->readDouble(); - deltaX1 = in->readDouble(); - deltaX2 = in->readDouble(); - deltaX3 = in->readDouble(); - nodesX1 = in->readInteger(); - nodesX2 = in->readInteger(); - nodesX3 = in->readInteger(); - lowerThreshold = in->readDouble(); - upperThreshold = in->readDouble(); - addSurfaceTriangleSetFlag = in->readBool(); - transferViaFilename = in->readBool(); - if(!transferViaFilename) - { - throw UbException(UB_EXARGS,"void GbVoxelMatrix3D::read(UbFileOutput* out) - geht ned"); - } - else - { - filename = in->readString(); - this->readMatrixFromVtiASCIIFile(filename); - } -#ifdef CAB_RCF - } - catch(std::exception& e) { UBLOGML(logERROR, UB_FUNCTION + (std::string)e.what()); throw RCF::Exception(1002, UB_FUNCTION + (std::string)e.what() ); } - catch(...) { UBLOGML(logERROR, UB_FUNCTION + (std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION + (std::string)"unknown error" ); } -#endif -} -/*=======================================================*/ -void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename) - -{ - UBLOG(logINFO," - create GbVoxelMatrix3D"); - UbFileInputASCII in(filename); - //ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - - voxelMatrix = Matrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); - - UBLOG(logINFO," - init values"); - int val; - int u=0; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - val = in.readInteger(); - //if( !UbMath::equal(val, 0.0f) ) - //if( UbMath::greater(val, threshold) ) - if( (double)val >= lowerThreshold && (double)val <= upperThreshold ) - { - (voxelMatrix)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - UBLOG(logINFO," - create GbVoxelMatrix3D done"); -} - -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3) -{ - double tempMinPunktX1 = minX1 - cX1; - double tempMinPunktX2 = minX2 - cX2; - double tempMinPunktX3 = getX3Maximum() - cX3; - - double tempMinPunktX1tf = tempMinPunktX1; - double tempMinPunktX2tf = -tempMinPunktX3; - double tempMinPunktX3tf = tempMinPunktX2; - - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; - - minX2 = minX2_temp; - minX3 = minX3_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx1; - int nx2_new = nx3; - int nx3_new = nx2; - - double delta_temp = deltaX2; - deltaX2 = deltaX3; - deltaX3 = delta_temp; - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(x1,nx3-x3-1,x2) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundX() -{ - double cX1 = this->getX1Centroid(); - double cX2 = this->getX2Centroid(); - double cX3 = this->getX3Centroid(); - - rotate90aroundX(cX1, cX2, cX3); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3) -{ - double tempMinPunktX1 = getX1Maximum() - cX1; - double tempMinPunktX2 = minX2 - cX2; - double tempMinPunktX3 = minX3 - cX3; - - double tempMinPunktX1tf = tempMinPunktX3; - double tempMinPunktX2tf = tempMinPunktX2; - double tempMinPunktX3tf = -tempMinPunktX1; - - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; - - minX1 = minX1_temp; - minX3 = minX3_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx3; - int nx2_new = nx2; - int nx3_new = nx1; - - double delta_temp = deltaX1; - deltaX1 = deltaX3; - deltaX3 = delta_temp; - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(x3,x2,nx1-x1-1) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundY() -{ - double cX1 = this->getX1Centroid(); - double cX2 = this->getX2Centroid(); - double cX3 = this->getX3Centroid(); - - rotate90aroundY(cX1, cX2, cX3); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3) -{ - double tempMinPunktX1 = minX1 - cX1; - double tempMinPunktX2 = getX2Maximum() - cX2; - double tempMinPunktX3 = minX3 - cX3; - - double tempMinPunktX1tf = -tempMinPunktX2; - double tempMinPunktX2tf = tempMinPunktX1; - double tempMinPunktX3tf = tempMinPunktX3; - - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; - - minX1 = minX1_temp; - minX2 = minX2_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx2; - int nx2_new = nx1; - int nx3_new = nx3; - - double delta_temp = deltaX1; - deltaX1 = deltaX2; - deltaX2 = delta_temp; - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(nx2-x2-1,x1,x3) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundZ() -{ - double cX1 = this->getX1Centroid(); - double cX2 = this->getX2Centroid(); - double cX3 = this->getX3Centroid(); - - rotate90aroundZ(cX1, cX2, cX3); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorX() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(nx1-x1-1,x2,x3) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorY() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(x1,nx2-x2-1,x3) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorZ() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - voxelMatrix_temp(x1,x2,nx3-x3-1) = this->voxelMatrix(x1,x2,x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKASCII( const std::string& fileName ) -{ - string fn = fileName +".ascii.vtk"; - - FILE *file; - file = fopen(fn.c_str(),"w"); - - if (file == NULL) - { - std::string pathf = UbSystem::getPathFromString(fn); - if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); - } - - if(file == NULL) - throw UbException(UB_EXARGS,"can not open "+fn); - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nn = nx1*nx2*nx3; - - fprintf(file,"# vtk DataFile Version 2.0\n"); - fprintf(file,"vtk output\n"); - fprintf(file,"ASCII\n"); - fprintf(file,"DATASET STRUCTURED_POINTS\n"); - fprintf(file,"DIMENSIONS %d %d %d\n", nx1, nx2, nx3); - fprintf(file,"ORIGIN %g %g %g\n", minX1, minX2, minX3); - fprintf(file,"SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); - fprintf(file,"POINT_DATA %d\n", nn); - fprintf(file,"SCALARS Geo float\n"); - fprintf(file,"LOOKUP_TABLE default\n"); - - for(int k=0 ; k<nx3 ; k++){ - for(int j=0 ; j<nx2 ; j++){ - for(int i=0 ; i<nx1 ; i++){ - fprintf(file,"%g ", voxelMatrix(i,j,k)); - } - } - } - - fprintf(file,"\n"); - - fclose(file); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKBinary( const std::string& fileName ) -{ - string fn = fileName +".binary.vtk"; - - FILE *file; - file = fopen(fn.c_str(),"w"); - - if (file == NULL) - { - std::string pathf = UbSystem::getPathFromString(fn); - if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); - } - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nn = nx1*nx2*nx3; - - char LF = 0x0A; - - fprintf(file,"# vtk DataFile Version 3.0\n"); - fprintf(file,"vtk output\n"); - fprintf(file,"BINARY\n"); - fprintf(file,"DATASET STRUCTURED_POINTS\n"); - fprintf(file,"DIMENSIONS %d %d %d\n", nx1, nx2, nx3); - fprintf(file,"ORIGIN %g %g %g\n", minX1, minX2, minX3); - fprintf(file,"SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); - fprintf(file,"POINT_DATA %d\n", nn); - fprintf(file,"SCALARS Geo float\n"); - fprintf(file,"LOOKUP_TABLE default"); - fclose(file); - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - - if (UbSystem::isLittleEndian()) - { - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) - { - float tmp = this->voxelMatrix(x1,x2,x3); - UbSystem::swapByteOrder((unsigned char*)(&(tmp)), sizeof(float)); - voxelMatrix_temp(x1,x2,x3) = tmp; - } - } - } - } - - file = fopen(fn.c_str(), "ab"); - - fwrite (&LF, sizeof(char), 1, file); - fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0,0,0), sizeof(float), voxelMatrix_temp.getDataVector().size(), file); - fwrite (&LF, sizeof(char), 1, file); - fclose(file); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToVTKImageDataASCII( const std::string& fileName ) -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - string fn = fileName +".ascii.vti"; - - FILE *file; - file = fopen(fn.c_str(),"w"); - - if (file == NULL) - { - std::string pathf = UbSystem::getPathFromString(fn); - if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); - } - - fprintf(file,"<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 - //fprintf(file,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); //paraview 3.1 - fprintf(file," <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); - fprintf(file," <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); - fprintf(file," <PointData Scalars=\"VoxelMatrix\">\n"); - fprintf(file," <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" RangeMax=\"1\">\n "); - - for(int k=0 ; k<nx3 ; k++){ - for(int j=0 ; j<nx2 ; j++){ - for(int i=0 ; i<nx1 ; i++){ - fprintf(file,"%g ",voxelMatrix(i,j,k)); - } - } - } - - fprintf(file,"\n </DataArray>\n"); - fprintf(file," </PointData>\n"); - fprintf(file," <CellData>\n"); - fprintf(file," </CellData>\n"); - fprintf(file," </Piece>\n"); - fprintf(file," </ImageData>\n"); - fprintf(file,"</VTKFile>\n"); - - fclose(file); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToVTKImageDataAppended( const std::string& fileName ) -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - string fn = fileName +".appended.vti"; - - FILE *file; - file = fopen(fn.c_str(),"w"); - - if (file == NULL) - { - std::string pathf = UbSystem::getPathFromString(fn); - if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); - } - - fprintf(file,"<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 - fprintf(file," <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); - fprintf(file," <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); - fprintf(file," <PointData Scalars=\"VoxelMatrix\">\n"); - fprintf(file," <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" RangeMax=\"1\" offset=\"0\" />\n"); - fprintf(file," </PointData>\n"); - fprintf(file," <CellData>\n"); - fprintf(file," </CellData>\n"); - fprintf(file," </Piece>\n"); - fprintf(file," </ImageData>\n"); - fprintf(file," <AppendedData encoding=\"raw\">\n"); - fprintf(file," _"); - fclose(file); - - file = fopen(fn.c_str(), "ab"); - int size = (int)voxelMatrix.getDataVector().size() * sizeof(float); - fwrite (&size, sizeof(int), 1, file); - fwrite(voxelMatrix.getStartAdressOfSortedArray(0,0,0), sizeof(float), voxelMatrix.getDataVector().size(), file); - fclose(file); - - file = fopen(fn.c_str(),"a"); - fprintf(file,"\n"); - fprintf(file," </AppendedData>\n"); - fprintf(file,"</VTKFile>\n"); - fclose(file); -} - - diff --git a/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h b/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h deleted file mode 100644 index 2c26ca05a2a6b008fe7391e8b27aed68803ee93b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h +++ /dev/null @@ -1,340 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBVOXELMATRIX3D_H -#define GBVOXELMATRIX3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> -#include <basics/container/CbArray3D.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class GbVoxelMatrix3D; -typedef VFSharedPtr<GbVoxelMatrix3D> GbVoxelMatrix3DPtr; - - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbVoxelMatrix3D : public GbObject3D, public UbObserver -{ -public: - typedef CbArray3D<float> Matrix3D; - static const float SOLID; - static const float FLUID; - enum Endian {BigEndian, LittleEndian}; - - GbVoxelMatrix3D(); - GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold=0, double upperThreshold=0); - GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold=0, double upperThreshold=0); - ~GbVoxelMatrix3D() {} - - void finalize() {}; - GbVoxelMatrix3D* clone(); - - /*=======================================================================*/ - Matrix3D::reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3) - { - return voxelMatrix(x1,x2,x3); - } - /*=======================================================================*/ - Matrix3D::const_reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3) const - { - return voxelMatrix(x1,x2,x3); - } - /*=======================================================================*/ - void setTransferViaFilename(bool transferViaFilename, std::string filename) - { - this->filename = filename; - this->transferViaFilename = transferViaFilename; - } - void setThreshold(double lowerThreshold, double upperThreshold) { this->lowerThreshold = lowerThreshold; this->upperThreshold = upperThreshold; } - void setAddSurfaceTriangleSetFlag(bool flag) { this->addSurfaceTriangleSetFlag = flag; } - - /*=======================================================================*/ - void setVoxelMatrixMininum(double minX1, double minX2, double minX3) { this->minX1 = minX1; this->minX2 = minX2; this->minX3 = minX3; } - void setVoxelMatrixMinX1(double minX1) { this->minX1 = minX1; } - void setVoxelMatrixMinX2(double minX2) { this->minX2 = minX2; } - void setVoxelMatrixMinX3(double minX3) { this->minX3 = minX3; } - - /*=======================================================================*/ - void setVoxelMatrixDelta(double deltaX1, double deltaX2, double deltaX3) { this->deltaX1 = deltaX1; this->deltaX2 = deltaX2; this->deltaX3 = deltaX3; } - void setVoxelMatrixDeltaX1(double deltaX1) { this->deltaX1 = deltaX1; } - void setVoxelMatrixDeltaX2(double deltaX2) { this->deltaX2 = deltaX2; } - void setVoxelMatrixDeltaX3(double deltaX3) { this->deltaX3 = deltaX3; } - - /*=======================================================================*/ - double getX1Centroid() { return 0.5 * ( minX1 + this->getX1Maximum() ); } - double getX1Minimum() { return minX1; } - double getX1Maximum() { return minX1 + deltaX1*voxelMatrix.getNX1(); } - - double getX2Centroid() { return 0.5 * ( minX2 + this->getX2Maximum() ); } - double getX2Minimum() { return minX2; } - double getX2Maximum() { return minX2 + deltaX2*voxelMatrix.getNX2(); } - - double getX3Centroid() { return 0.5 * ( this->getX3Minimum() + this->getX3Maximum() ); } - double getX3Minimum() { return minX3; } - double getX3Maximum() { return minX3 + deltaX3*voxelMatrix.getNX3(); } - - double getLengthX1() { return this->getX1Maximum() - minX1; } - double getLengthX2() { return this->getX2Maximum() - minX2; } - double getLengthX3() { return this->getX3Maximum() - minX3; } - - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - void translate(const double& tx1, const double& tx2, const double& tx3); - - 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) { throw UbException(__FILE__,__LINE__, UB_FUNCTION,"not implemented");} - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2){ throw UbException(__FILE__,__LINE__, UB_FUNCTION,"not implemented");} - - 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); - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) {} - void objectWillBeDeleted(UbObservable* objectForDeletion) {} - - template <class T> - void readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian); - template <class T> - void readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian); - void readMatrixFromVtiASCIIFile(std::string filename); - - void rotate90aroundX(); - void rotate90aroundY(); - void rotate90aroundZ(); - void rotate90aroundX(double cX1, double cX2, double cX3); - void rotate90aroundY(double cX1, double cX2, double cX3); - void rotate90aroundZ(double cX1, double cX2, double cX3); - void mirrorX(); - void mirrorY(); - void mirrorZ(); - - void writeToLegacyVTKASCII(const std::string& fileName); - void writeToLegacyVTKBinary( const std::string& fileName ); - void writeToVTKImageDataASCII(const std::string& fileName); - void writeToVTKImageDataAppended(const std::string& fileName); - - void setClosedVoidSpaceToSolid(); - - void calculateNumberOfSolidAndFluid(); - long getNumberOfSolid(); - long getNumberOfFluid(); - -protected: - void findFluidNeighbor(int cx1, int cx2, int cx3); - Matrix3D voxelMatrixTemp; - CbArray3D<char> flagMatrix; - - std::vector<int> x1Nbr; - std::vector<int> x2Nbr; - std::vector<int> x3Nbr; - - std::vector<int> x1NbrTemp; - std::vector<int> x2NbrTemp; - std::vector<int> x3NbrTemp; - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & minX1; - ar & minX2; - ar & minX3; - ar & deltaX1; - ar & deltaX2; - ar & deltaX3; - ar & nodesX1; - ar & nodesX2; - ar & nodesX3; - ar & threshold; - ar & transferViaFilename; - ar & addSurfaceTriangleSetFlag; - if(!transferViaFilename) - { - ar & voxelMatrix; - } - else - { - ar & filename; - if(ArchiveTools::isReading(ar) ) - { - this->readMatrixFromVtiASCIIFile(filename); - } - } - - } -#endif //CAB_RCF - -protected: - //for transfer - std::string filename; - bool transferViaFilename; - - bool addSurfaceTriangleSetFlag; - - int nodesX1; - int nodesX2; - int nodesX3; - double lowerThreshold, upperThreshold; - - double minX1; - double minX2; - double minX3; - double deltaX1; - double deltaX2; - double deltaX3; - - Matrix3D voxelMatrix; - - long numberOfSolid; - long numberOfFluid; -}; - -////////////////////////////////////////////////////////////////////////// -template <class T> -void GbVoxelMatrix3D::readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian) -{ - using namespace std; - UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, ios::end ); //Ende springen - fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, ios::beg ); //An den Anfang springen - - //UBLOG(logINFO,"number of nodes = "<<nodesX1*nodesX2*nodesX3*sizeof(T)<<" file size = "<<(long)length); - //if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length ) - unsigned long long nofn = nodesX1*nodesX2*nodesX3*sizeof(T); - if (nofn != (unsigned long long)length) - { - throw UbException(UB_EXARGS,"number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")"); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - //GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); - voxelMatrix = Matrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); - - UBLOG(logINFO," - init values"); - //float val; - T val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - //in.read((char*)&val,sizeof(float)); - in.read((char*)&val,sizeof(T)); - if (endian == BigEndian) - UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T)); - //if( UbMath::equal((double)val, threshold) ) - //if( UbMath::greater((double)val, threshold) ) - if( (double)val >= lowerThreshold && (double)val <= upperThreshold ) - { - (voxelMatrix)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - //(voxelMatrix)(x1, x2, x3) = (float)val; - } - - UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); -} - -////////////////////////////////////////////////////////////////////////// -template <class T> -void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian) -{ - using namespace std; - UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - - FILE *file; - file = fopen(filename.c_str(), "rb"); - if (file==NULL) - { - throw UbException(UB_EXARGS, "Could not open file "+filename); - } - - // obtain file size: - fseek(file, 0, SEEK_END); - unsigned long int length = ftell(file); - rewind(file); - - UBLOG(logINFO, "number of nodes = "<<(long)nodesX1*(long)nodesX2*(long)nodesX3<<" file size = "<<length); - - unsigned long int nofn = (long)nodesX1*(long)nodesX2*(long)nodesX3*(long)sizeof(T); - if (nofn != length) - { - //throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString(length)+")"); - } - - UBLOG(logINFO, " - create GbVoxelMatrix3D"); - voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - - CbArray3D<T> readMatrix(nodesX1, nodesX2, nodesX3); - - UBLOG(logINFO, " - read file to matrix"); - fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file); - fclose(file); - - UBLOG(logINFO, " - init values"); - - numberOfSolid = 0; - T val; - for (int x3 = 0; x3<nodesX3; x3++) - for (int x2 = 0; x2<nodesX2; x2++) - for (int x1 = 0; x1<nodesX1; x1++) - { - val = readMatrix(x1, x2, x3); - - if (endian == BigEndian) - { - UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T)); - } - - if ((double)val >= lowerThreshold && (double)val <= upperThreshold) - { - voxelMatrix(x1, x2, x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); -} - - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbVoxelMatrix3D>("GbVoxelMatrix3D") , SF_GbVoxelMatrix3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbVoxelMatrix3D >()), SF_GbVoxelMatrix3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbVoxelMatrix3D>() ), SF_GbVoxelMatrix3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt deleted file mode 100644 index 8d2943620ae0f1b9f1a22b47979b2a23b2523256..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt +++ /dev/null @@ -1,4 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/splitalgorithms ALL_SOURCES) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/intersectionhandler ALL_SOURCES) diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h deleted file mode 100644 index 0b38011b10a124ad1962f39680479d3142249e5d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h +++ /dev/null @@ -1,284 +0,0 @@ -#ifndef KDNODE_H -#define KDNODE_H - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/KdRay.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h> - - -#include <vector> -#include <string> - -namespace Kd -{ - template< typename T > - class Node - { - public: - Node( const T& x1, const T& y1, const T& z1 - , const T& x2, const T& y2, const T& z2 - , const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces - , std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes ) - : child1(NULL) - , child2(NULL) - , triFaces(triFaces) - , ptrNodes(ptrNodes) - { - if( x1 < x2 ) { this->x[0] = x1; this->x[1] = x2; } - else { this->x[0] = x2; this->x[1] = x1; } - - if( y1 < y2 ) { this->y[0] = y1; this->y[1] = y2; } - else { this->y[0] = y2; this->y[1] = y1; } - - if( z1 < z2 ) { this->z[0] = z1; this->z[1] = z2; } - else { this->z[0] = z2; this->z[1] = z1; } - } - /* ======================================================================================= */ - ~Node() - { - if(child1) { delete child1; child1 = NULL; } - if(child2) { delete child2; child2 = NULL; } - } - /* ======================================================================================= */ - bool isLeaf() - { - return child1 == NULL && child2 == NULL; - } - /* ======================================================================================= */ - void deleteTriFaces() - { - triFaces = MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >(); - } - /* ======================================================================================= */ - const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >& getTriFaces() - { - return triFaces; - } - /* ======================================================================================= */ - std::vector<GbTriFaceMesh3D::Vertex>& getNodes() - { - if(!ptrNodes) throw UbException(UB_EXARGS,"ups,no nodes"); - return *ptrNodes; - } - - /* ======================================================================================= */ - void buildTree(const int& level, const int& maxLevel, const SplitAlgorithm<T>& splitAlg) - { - SplitCandidate<T> splitCandidate = splitAlg.findBestSplitCandidate(level, maxLevel, *this); - - if( splitCandidate.isValid ) - { - - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild1( new std::vector<GbTriFaceMesh3D::TriFace> ); - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild2( new std::vector<GbTriFaceMesh3D::TriFace> ); - - splitAlg.distributeTriFaces(splitCandidate, *triFacesForChild1, *triFacesForChild2, *this); - - ////////////////////////////////////////////////////////////////////////// - // calculate center points and edges of new child nodes - T x1_l = x[0], y1_l = y[0], z1_l = z[0]; - T x2_l = x[1], y2_l = y[1], z2_l = z[1]; - T x1_r = x[0], y1_r = y[0], z1_r = z[0]; - T x2_r = x[1], y2_r = y[1], z2_r = z[1]; - - if (splitCandidate.axis == Axis::X) - { - x2_l = splitCandidate.position; - x1_r = splitCandidate.position; - } - else if (splitCandidate.axis == Axis::Y) - { - y2_l = splitCandidate.position; - y1_r = splitCandidate.position; - } - else - { - z2_l = splitCandidate.position; - z1_r = splitCandidate.position; - } - // ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- - - if (triFacesForChild1->size() > 0) - { - if( this->child1 ) delete this->child1; - this->child1 = new Node(x1_l, y1_l, z1_l, x2_l, y2_l, z2_l, triFacesForChild1, ptrNodes); - this->child1->buildTree(level + 1, maxLevel, splitAlg); - } - - if (triFacesForChild2->size() > 0) - { - if( this->child2 ) delete this->child2; - this->child2 = new Node(x1_r, y1_r, z1_r, x2_r, y2_r, z2_r, triFacesForChild2, ptrNodes); - this->child2->buildTree(level + 1, maxLevel, splitAlg); - } - } - } - /* ======================================================================================= */ - int intersectLineBoundingBox(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2) - { - const T& n1X = val<1>(n1); - const T& n1Y = val<2>(n1); - const T& n1Z = val<3>(n1); - - const T& n2X = val<1>(n2); - const T& n2Y = val<2>(n2); - const T& n2Z = val<3>(n2); - - double t_nah = UbMath::max( ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ); - - double t_fern = UbMath::min( ( (n1X > n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y > n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z > n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ); - - if ( UbMath::greater( UbMath::max( ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) - , UbMath::min( ( (n1X > n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y > n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z > n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) ) ) - { - return Intersection::NO_INTERSECTION; - } - else - { - return Intersection::INTERSECTION; - } - } - /* ======================================================================================= */ - int intersectRayBoundingBox(const Ray<T>& ray) - { - T tmin = (x[ ray.signX] - ray.originX) * ray.inv_directionX; - T tmax = (x[1-ray.signX] - ray.originX) * ray.inv_directionX; - - T tymin = (y[ ray.signY] - ray.originY) * ray.inv_directionY; - T tymax = (y[1-ray.signY] - ray.originY) * ray.inv_directionY; - - if( (tmin > tymax) || (tymin > tmax) ) - { - return false; - } - if( tymin > tmin ) tmin = tymin; - if( tymax < tmax ) tmax = tymax; - - T tzmin = (z[ ray.signZ] - ray.originZ) * ray.inv_directionZ; - T tzmax = (z[1-ray.signZ] - ray.originZ) * ray.inv_directionZ; - - //if( (UbMath::greater( tmin, tzmax) ) || ( UbMath::greater( tzmin, tmax) ) ) - if( ( tmin > tzmax) || ( tzmin > tmax) ) - { - return false; - } - //if(tzmin > tmin) tmin = tzmin; - if(tzmax < tmax) tmax = tzmax; - - //return ( (tmin =< t1) && (tmax >= t0) ); - if( UbMath::greaterEqual( tmax, T(0.0) ) ) - { - return Intersection::INTERSECTION; - } - else - { - return Intersection::NO_INTERSECTION; - } - } - /* ======================================================================================= */ - bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, const LineIntersectionHandler<T>& iHandler) - { - return iHandler.intersectLine(n1, n2, *this, child1, child2); - } - /* ======================================================================================= */ - int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler, std::set< UbKeys::Key3<int> >& mailbox) - { - return iHandler.intersectRay(ray, *this, child1, child2, mailbox); - } - /* ======================================================================================= */ - int getNumOfTriFaces() - { - if(!child1 && !child2) - { - if(triFaces) return (int)triFaces->size(); - else return 0; - } - else - { - int sum = 0; - - if(child1) sum += child1->getNumOfTriFaces(); - if(child2) sum += child2->getNumOfTriFaces(); - - return sum; - } - } - /* ======================================================================================= */ - int getNumOfNodes() - { - if( !child1 && !child2) - { - return 1; - } - else - { - int sum = 0; - if(child1) sum += child1->getNumOfNodes(); - if(child2) sum += child2->getNumOfNodes(); - - return 1 + sum; - } - } - /* ======================================================================================= */ - std::string toString() - { - return "";//"[" + x1 + "," + y1 + "," + z1 + "] -" + " [" + x2 + "," + y2 + "," + z2 + "]"; - } - /* ======================================================================================= */ - void addCubeInfo(std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata) - { - nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[0]) ) ); - - nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[1]) ) ); - - cells.push_back( makeUbTuple( int(nodes.size()-8), int(nodes.size()-7), int(nodes.size()-6), int(nodes.size()-5), - int(nodes.size()-4), int(nodes.size()-3), int(nodes.size()-2), int(nodes.size()-1) ) ); - datanames.resize(1); - datanames[0] = "childs"; - celldata.resize( datanames.size() ); - if ( child1 && child2 ) celldata[0].push_back(2); - else if( child1 || child2 ) celldata[0].push_back(1); - else celldata[0].push_back(0); - - if(child1) child1->addCubeInfo(nodes, cells, datanames, celldata); - if(child2) child2->addCubeInfo(nodes, cells, datanames, celldata); - } - - public: - T x[2], y[2], z[2]; - - private: - Node* child1; - Node* child2; - - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces; - std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes; //lediglich für Zugriff auf die Knoten!!! - }; -} -#endif //KDNODE_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h deleted file mode 100644 index c53dfa93fc5b0b99f9adb40cd556cce5756433aa..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef KDRAY_H -#define KDRAY_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> - - -namespace Kd -{ - /* - * Ray class, for use with the optimized ray-box intersection test - * described in: - * - * Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley - * "An Efficient and Robust Ray-Box Intersection Algorithm" - * Journal of graphics tools, 10(1):49-54, 2005 - * - */ - template< typename T> - class Ray - { - public: - Ray( const T& originX , const T& originY , const T& originZ - , const T& directionX, const T& directionY, const T& directionZ ) - { - this->originX = originX; - this->originY = originY; - this->originZ = originZ; - - //normierung (fuer ray-triangle-intersection) - T oneOverLength = T(1.0/std::sqrt( directionX*directionX - + directionY*directionY - + directionZ*directionZ ) ); - - this->directionX = directionX*oneOverLength; - this->directionY = directionY*oneOverLength; - this->directionZ = directionZ*oneOverLength; - - this->inv_directionX = T(1.0/this->directionX); //ACHTUNG: BEWUSST KEINE ==0 Abfrage - this->inv_directionY = T(1.0/this->directionY); //Alg verwendet exlitzit INF - this->inv_directionZ = T(1.0/this->directionZ); - - if(this->inv_directionX < 0.0) this->signX = 1; - else this->signX = 0; - if(this->inv_directionY < 0.0) this->signY = 1; - else this->signY = 0; - if(this->inv_directionZ < 0.0) this->signZ = 1; - else this->signZ = 0; - } - - T originX; - T originY; - T originZ; - - T directionX; - T directionY; - T directionZ; - - T inv_directionX; - T inv_directionY; - T inv_directionZ; - - int signX; - int signY; - int signZ; - }; -} //namespace Kd - -#endif //KDRAY_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h deleted file mode 100644 index 361550555498cf4d5eae0ef00d68a720895055ab..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef KDSPLITCANDIDATE_H -#define KDSPLITCANDIDATE_H - -#include <basics/utilities/UbMath.h> - -namespace Kd -{ - template< typename T > - class SplitCandidate - { - public: - SplitCandidate() - : axis(0) - , position(0.0) - , starting(0) - , ending(0) - , np_left(false) - , np_right(false) - , Cn(0.0) - , nr(0) - , nl(0) - , isValid(false) - { - - } - /* ======================================================================================= */ - SplitCandidate(const int& axis, const T& position, const int& starting, const int& ending, const int& insidePlane) - : np_left(false) - , np_right(false) - , axis(axis) - , position(position) - , starting(starting) - , ending(ending) - , np(insidePlane) - , Cn(0.0) - , nr(0) - , nl(0) - , isValid(true) - { - } - /* ======================================================================================= */ - bool operator!() const - { - return isValid; - } - /* ======================================================================================= */ - friend inline bool operator< (const SplitCandidate& lhs, const SplitCandidate& rhs) - { - return lhs.position < rhs.position; - } - /* ======================================================================================= */ - - public: - int axis; - T Cn; - T position; - int nl; - int nr; - int np; - int starting; - int ending; - bool np_left; - bool np_right; - bool isValid; - }; -} - -#endif //KDSPLITCANDIDATE_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h deleted file mode 100644 index 0278807f8dd3b97e8303f0935205060852adc6d4..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef KDSPLITCANDIDATEMANAGER_H -#define KDSPLITCANDIDATEMANAGER_H - -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> - -#include <map> -#include <vector> -#include <algorithm> - - -namespace Kd -{ - template< typename T > - class SplitCandidateManager - { - public: - SplitCandidateManager() - : objects_starting_outside_left(0) - , objects_fully_outside_node(0) - { - - } - /* ======================================================================================= */ - SplitCandidate<T>& operator[] (const int& i) - { - #ifdef DEBUG - return splitCandidatesVec.at(i); - #else - return splitCandidatesVec[i]; - #endif - } - /* ======================================================================================= */ - typename std::vector< SplitCandidate< T > >::size_type size() - { - return splitCandidatesVec.size(); - } - /* ======================================================================================= */ - void add(const T& pos, const int& axis, const int& starting, const int& ending, const int& np) - { - typename std::map<T, SplitCandidate<T> >::iterator it = splitCandidates.find(pos); - if ( it != splitCandidates.end() ) //split candidate is already available -> increase parameter (starting, ending and np) - { - SplitCandidate<T>& sc = it->second; - sc.np += np; - sc.starting += starting; - sc.ending += ending; - } - else // split candidate is not available -> add new split candidate - { - this->splitCandidates[pos] = SplitCandidate<T>(axis, pos, starting, ending, np); - } - } - /* ======================================================================================= */ - void createSortedArray() - { - splitCandidatesVec.clear(); - typename std::map<T, SplitCandidate<T> >::iterator it; - for( it=splitCandidates.begin(); it!=splitCandidates.end(); ++it) - splitCandidatesVec.push_back(it->second); - splitCandidates.clear(); - std::sort(splitCandidatesVec.begin(), splitCandidatesVec.end(), std::less< SplitCandidate<T> >() ); - } - /* ======================================================================================= */ - - public: - int objects_starting_outside_left; - int objects_fully_outside_node; - - private: - std::map<T, SplitCandidate<T> > splitCandidates; - std::vector< SplitCandidate<T> > splitCandidatesVec; - }; -} - -#endif //KDSPLITCANDIDATEMANAGER_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h deleted file mode 100644 index 83c33266cca0d38e5fbce8094bc2c30c07687f45..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef KDTREE_H -#define KDTREE_H - -#include <basics/memory/MbSmartPtr.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdRay.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -#include <string> - -namespace Kd -{ - template< typename T > - class Tree - { - public: - /* ======================================================================================= */ - Tree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg) - : rootNode(NULL) - { - this->buildTree(mesh, splitAlg); - } - /* ======================================================================================= */ - ~Tree() - { - if(rootNode) { delete rootNode; rootNode = NULL; } - } - /* ======================================================================================= */ - // the IntersectionHandler specifies how to handle the intersection - bool intersectLine(const UbTuple< T, T, T >& n1, const UbTuple< T, T, T >& n2, const LineIntersectionHandler<T>& iHandler) - { - return rootNode->intersectLine(n1, n2, iHandler); - } - /* ======================================================================================= */ - // the IntersectionHandler specifies how to handle the intersection - int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler) - { - std::set< UbKeys::Key3<int> > mailbox; - return rootNode->intersectRay(ray, iHandler, mailbox); - } - /* ======================================================================================= */ - int getNumOfNodes() - { - if(rootNode) return rootNode->getNumOfNodes(); - return 0; - } - /* ======================================================================================= */ - int getNumOfTriFaces() - { - if(rootNode) return rootNode->getNumOfTriFaces(); - return 0; - } - /* ======================================================================================= */ - std::string toString() - { - return "";//Tree:: num of nodes: " + rootNode.getNumOfNodes() + ", primitives:" + rootNode.getNumOfPrimitives() + ", root_primitives:" + getNumOfPrimitives() + ", max_level:" + max_level; - } - /* ======================================================================================= */ - void buildTree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg ) - { - if(rootNode) delete rootNode; - - // create a copy of triangles - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces(new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles() ) ); - - int maxLevel = (int)(8.0 + 1.3 * std::log( (double)triFaces->size() ) + 0.5); - - rootNode = new Node<T>( T( mesh.getX1Minimum() ) - , T( mesh.getX2Minimum() ) - , T( mesh.getX3Minimum() ) - , T( mesh.getX1Maximum() ) - , T( mesh.getX2Maximum() ) - , T( mesh.getX3Maximum() ) - , triFaces, mesh.getNodes() ); - - rootNode->buildTree(0, maxLevel, splitAlg); - } - void writeTree(const std::string& filename, WbWriter* writer = WbWriterVtkXmlBinary::getInstance()) - { - if(rootNode) - { - std::vector<UbTupleFloat3 > nodes; - std::vector<UbTupleInt8 > cubes; - std::vector<std::string > datanames; - std::vector<std::vector<double > > cubesdata; - rootNode->addCubeInfo(nodes, cubes, datanames, cubesdata); - writer->writeOctsWithCellData(filename,nodes,cubes,datanames,cubesdata); - } - } - private: - Node<T>* rootNode; - }; -} - -#endif //KDTREE_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp b/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp deleted file mode 100644 index efbdd580caa25bb09f8278bec078da6b0c4fecfb..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <numerics/geometry3d/KdTree/KdUtilities.h> - -namespace Kd -{ - const int Axis::X = 0; - const int Axis::Y = 1; - const int Axis::Z = 2; - - const int Intersection::ON_BOUNDARY = -2; - const int Intersection::INTERSECT_EDGE = -1; - const int Intersection::INTERSECTION = 1; -const int Intersection::NO_INTERSECTION = 0; -} //namespace Kd diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h b/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h deleted file mode 100644 index 39a700cc4e216e6349f5d15ddc28c4b6f93c663e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef KDUTILIES_H -#define KDUTILIES_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <algorithm> -#include <vector> - -namespace Kd -{ - struct Axis - { - static const int X;// = 0; - static const int Y;// = 1; - static const int Z;// = 2; - }; - /* ======================================================================================= */ - struct Intersection - { - static const int ON_BOUNDARY; // = -2; - static const int INTERSECT_EDGE; // = -1; - static const int INTERSECTION; // = 1; - static const int NO_INTERSECTION;// = 0; - }; - /* ======================================================================================= */ - template< typename T> - inline void project2Axis(GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes, const int& axis, std::vector<T>& projection) - { - projection.resize(3); - - if(axis==Axis::X) - { - projection[0] = triFace.getV1x(nodes); - projection[1] = triFace.getV2x(nodes); - projection[2] = triFace.getV3x(nodes); - } - else if(axis==Axis::Y) - { - projection[0] = triFace.getV1y(nodes); - projection[1] = triFace.getV2y(nodes); - projection[2] = triFace.getV3y(nodes); - } - else if(axis==Axis::Z) - { - projection[0] = triFace.getV1z(nodes); - projection[1] = triFace.getV2z(nodes); - projection[2] = triFace.getV3z(nodes); - } - else throw UbException(UB_EXARGS,"unknown axis"); - - std::sort( projection.begin(), projection.end(), std::less<double>() ); - } - /* ======================================================================================= */ - template< typename T> - inline bool isPointOnPlane(const T& px, const T& py, const T& pz, const T& precision, GbTriFaceMesh3D::Vertex& pointOfTriFace, GbTriFaceMesh3D::TriFace& triFace) - { - return std::fabs( (px - pointOfTriFace.x) * triFace.nx + (py - pointOfTriFace.y) * triFace.ny + (pz - pointOfTriFace.z) * triFace.nz ) < precision; - } - /* ======================================================================================= */ - template< typename T> - inline bool isPointOnTriangle( const T& px, const T& py, const T& pz, const T& precision - , GbTriFaceMesh3D::Vertex& p1, GbTriFaceMesh3D::Vertex& p2, GbTriFaceMesh3D::Vertex& p3 - , GbTriFaceMesh3D::TriFace& triFace ) - { - if( Kd::isPointOnPlane(px, py, pz, precision, p1, triFace) ) - { - T a_x = p1.x - px; - T a_y = p1.y - py; - T a_z = p1.z - pz; - T b_x = p2.x - px; - T b_y = p2.y - py; - T b_z = p2.z - pz; - T c_x = p3.x - px; - T c_y = p3.y - py; - T c_z = p3.z - pz; - - const T factor = 0.5; - T Q1_x = (a_y * b_z - a_z * b_y) * factor; - T Q1_y = (a_z * b_x - a_x * b_z) * factor; - T Q1_z = (a_x * b_y - a_y * b_x) * factor; - - T Q2_x = (b_y * c_z - b_z * c_y) * factor; - T Q2_y = (b_z * c_x - b_x * c_z) * factor; - T Q2_z = (b_x * c_y - b_y * c_x) * factor; - - T Q3_x = (c_y * a_z - c_z * a_y) * factor; - T Q3_y = (c_z * a_x - c_x * a_z) * factor; - T Q3_z = (c_x * a_y - c_y * a_x) * factor; - - T Q_x = Q1_x + Q2_x + Q3_x; - T Q_y = Q1_y + Q2_y + Q3_y; - T Q_z = Q1_z + Q2_z + Q3_z; - - - if ( UbMath::zero(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z ) ) return true; - else if( UbMath::zero(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z ) ) return true; - else if( UbMath::zero(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z ) ) return true; - else if( UbMath::less(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z, T(0.0) ) ) return false; - else if( UbMath::less(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z, T(0.0) ) ) return false; - else if( UbMath::less(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z, T(0.0) ) ) return false; - - return true; - } - - return false; - } - /* ======================================================================================= */ - template< typename T> - inline bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes) - { - GbTriFaceMesh3D::Vertex& p0=triFace.getNode(0,nodes); - - const T& n1X = val<1>(n1); - const T& n1Y = val<2>(n1); - const T& n1Z = val<3>(n1); - - const T& n2X = val<1>(n2); - const T& n2Y = val<2>(n2); - const T& n2Z = val<3>(n2); - - //if( Kd::isPointOnPlane(n1X, n1Y, n1Z, T(1.0E-6), p0, triFace) - // && Kd::isPointOnPlane(n2X, n2Y, n2Z, T(1.0E-6), p0, triFace)) - //{ - // return true; - //} - - T denom = ( n2X - n1X ) * triFace.nx + ( n2Y - n1Y ) * triFace.ny + ( n2Z - n1Z ) * triFace.nz; - - if( UbMath::zero( denom ) ) //line does not intersect the plane of the triangle ! - { - return false; - } - else - { - T d = - triFace.nx * p0.x - triFace.ny * p0.y - triFace.nz * p0.z; - T mu = T(-1.0 * (d + n1X * triFace.nx + n1Y * triFace.ny + n1Z * triFace.nz ) / denom); - - if( !UbMath::inClosedInterval( mu, T(0.0), T(1.0)) ) // Point of intersection of line and plane does not lie on the triangle - { - return false; - } - else - { - // intersection with plane - - //Test whether Point lies inside the triangle or not - GbTriFaceMesh3D::Vertex& p1=triFace.getNode(1,nodes); - GbTriFaceMesh3D::Vertex& p2=triFace.getNode(2,nodes); - - return Kd::isPointOnTriangle( n1X + ( (n2X - n1X) * mu ) //intersectionPointX - , n1Y + ( (n2Y - n1Y) * mu ) //intersectionPointY - , n1Z + ( (n2Z - n1Z) * mu ) //intersectionPointZ - , T(0.001) - , p0, p1, p2, triFace ); - } - } - } -} //namespace Kd - -#endif //KDUTILIES_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt b/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt deleted file mode 100644 index 1b2fd9ad9cd9a3ca227dce4499cb7d665289945a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(kdtree_pioTest) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/3rdParty/dirstream/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY) diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp b/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp deleted file mode 100644 index 0c0b9454745a3554ab32b7d81f6639749dd45545..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp +++ /dev/null @@ -1,542 +0,0 @@ -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbRandom.h> -#include <basics/utilities/UbTuple.h> - -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -#include <basics/container/CbUniformMatrix3D.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbHalfSpace3D.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -#include <stack> -#include <list> - -using namespace std; - -void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles = true, std::string outpath = "g:/temp"); -void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type); -void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type); - -#include <3rdParty/dirstream/dirstream.h> -#include <3rdParty/dirstream/filter_utils.h> // enthält die Definiton der bool'schen Ops für Filter - - -using namespace std; - -int main() -{ - try - { -// ////////////////////////////////////////////////////////////////////////// -// //STL File auswaehlen -// ////////////////////////////////////////////////////////////////////////// -// string pathname = "c:/temp"; -// string stlPath = "c:/temp"; -// dirstr::dirstream str(stlPath.c_str(), dirstr::op(dirstr::pattern_f("*.stl")) -// || dirstr::op(dirstr::pattern_f("*.ply")) || dirstr::op(dirstr::pattern_f("*.inp")) -// || dirstr::op(dirstr::pattern_f("*.mesh"))); -// -// // UbLog::setReportingLevel(logDEBUG5); -// UbLog::setReportingLevel(logINFO); -// -// vector<string> filenames; -// for(string entry; str >> entry;) -// { -// GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(entry,"mesh"); -// -// string fn = UbSystem::getFilenameFromString(entry); -// mesh->writeMeshPly(pathname+"/"+fn+".ply"); -// -// delete mesh; -// } -// -// exit(0); - - //createGrid("c:/temp/clumps.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/50spheres.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/Sphere5040.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/cooling_2.inp", 400, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/NDR-Konzertsaal.inp", 100, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/Campus-Details-W3.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/Boein707.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/dolphin.mesh", 400, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/flamingo.mesh", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/torus.inp", 256, Kd::SAHSplit<float>() , true, "g:/temp"); - createGrid("c:/temp/xzx_dragon.stl", 512, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/bunny_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/dragon_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/budda_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGridWithLines("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp"); - -// createGrid("c:/temp/beatle.mesh",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/atrium-30000tri.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/Buero.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/office_space.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); - - //createGrid("d:/meshes/50spheres.inp",200, Kd::SAHSplit<float>(), true, "d:/temp"); - - //createGrid("c:/temp/torus.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); - //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp"); - //createGrid("c:/temp/jetta.stl", 200, Kd::SAHSplit<float>(), true, "g:/temp"); - //createGrid("c:/temp/VW_body.ply", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/kugel.stl", 50, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/ship-2.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp/schiff2"); - } - catch(const std::exception& e) - { - UBLOG2( logERROR, std::cerr, "Caught exception:"); - UBLOG2( logERROR, std::cerr, "Type: " << typeid(e).name() ); - UBLOG2ML(logERROR, std::cerr, "What: " << e.what() ); - } - catch(...) - { - UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION) - } -} - -namespace Flag -{ - const short UNDEF = 2; - const short SOLID = 1; - const short FLUID = 0; -} - -////////////////////////////////////////////////////////////////////// -void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - std::list< UbTuple<string, double> > timerVals; - UbTimer timer; - timer.start(); - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",GbTriFaceMesh3D::KDTREE_SAHPLIT); - timerVals.push_back( UbTuple<string, double>("mesh", timer.stop() ) ); - UBLOG( logINFO, "read mesh in "<<val<2>(timerVals.back())<<"s" ); - - timer.start(); - Kd::Tree<float> kdTree( *mesh, splitAlg ); - timerVals.push_back( UbTuple<string, double>("kdTree", timer.stop() ) ); - UBLOG( logINFO, "build tree in "<<val<2>(timerVals.back())<<"s" ); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<kdTree.getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<kdTree.getNumOfNodes() ); - UBLOG(logINFO, ""); - - ////////////////////////////////////////////////////////////////////////// - // Ausgangs 3-D_Feld erstellen - ////////////////////////////////////////////////////////////////////////// - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*(float)UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 ); - const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 ); - const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 ); - - CbUniformMatrix3D<short> solids(nx1,nx2,nx3,Flag::UNDEF); - - ////////////////////////////////////////////////////////////////////////// - // Knoten typisieren - ////////////////////////////////////////////////////////////////////////// - const float orgx1 = (float)( -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum() ); - const float orgx2 = (float)( -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum() ); - const float orgx3 = (float)( -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum() ); - - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& vertices = *mesh->getNodes(); - - float x1center = float( mesh->getX1Centroid() ); - float x2center = float( mesh->getX2Centroid() ); - float x3center = float( mesh->getX3Centroid() ); - - UBLOG( logINFO, "performing point-in-object(PIO)-tests"); - long counter1=0, counter2 = 0; - float x1w, x2w, x3w; - int x1Min, x2Min, x3Min, x1Max, x2Max, x3Max; - float einflussBereichKnoten_sq = dx1*dx1+dx2*dx2+dx3*dx3; - - timer.start(); - for(size_t t=0; t<triFaces.size(); t++) - { - GbTriFaceMesh3D::TriFace& triangle = triFaces[t]; - GbTriFaceMesh3D::Vertex& v1 = vertices[triangle.v1]; - GbTriFaceMesh3D::Vertex& v2 = vertices[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = vertices[triangle.v3]; - - ////////////////////////////////////////////////////////////////////////// - // AABB riangle - ////////////////////////////////////////////////////////////////////////// - x1Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) ); - x2Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) ); - x3Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) ); - - x1Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) ); - x2Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) ); - x3Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) ); - - GbHalfSpace3D halfSpace( v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z ); - - for(int x3=x3Min; x3<=x3Max; x3++) - { - for(int x2=x2Min; x2<=x2Max; x2++) - { - for(int x1=x1Min; x1<=x1Max; x1++) - { - counter1++; - - short& solidVal = solids(x1,x2,x3); - - if( solidVal != Flag::UNDEF ) //doppeltes Testen vermeiden - { - continue; - } - - counter2++; - - //Weltkoords - x1w = orgx1+x1*dx1; - x2w = orgx2+x2*dx2; - x3w = orgx3+x3*dx3; - - float dist = (float)halfSpace.getDistance( x1w, x2w, x3w ); - if( UbMath::greater( dist, 0.0f) ) - { - continue; - } - if( UbMath::greater(dist*dist, einflussBereichKnoten_sq)) - { - continue; - } - - //eigentlicher PIO-Test - bool testFailed = true; - for(int i=0; i<100; i++ ) - { - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - solidVal = Flag::SOLID; - } - else - { - solidVal = (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - testFailed = false; - break; - } - else - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - } - if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - } - } - } - timerVals.push_back( UbTuple<string, double>("PiO-Test", timer.stop() ) ); - UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<val<2>(timerVals.back())<<"s" ); - UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" ); - - ////////////////////////////////////////////////////////////////////////// - // FLOOD FILL - ////////////////////////////////////////////////////////////////////////// - - if( false) //using just one seed point - { - //FUELL - bool foundSeedPoint = false; - int seedPointSearchCounter = 0; - int seedX1 = Ub::inf; - int seedX2 = Ub::inf; - int seedX3 = Ub::inf; - - timer.start(); - for(size_t t=0; t<triFaces.size(); t++) - { - GbTriFaceMesh3D::TriFace& triangle = triFaces[t]; - - float& nx = triangle.nx; - float& ny = triangle.ny; - float& nz = triangle.nz; - - float cx1 = triangle.getX1Centroid(vertices); - float cx2 = triangle.getX2Centroid(vertices); - float cx3 = triangle.getX3Centroid(vertices); - - for(int k=0; k<5; k++) - { - seedPointSearchCounter++; - - cx1 -= nx * dx1; - cx2 -= ny * dx2; - cx3 -= nz * dx3; - - int ix1 = UbMath::integerRounding( (cx1-orgx1)/dx1 ); - int ix2 = UbMath::integerRounding( (cx2-orgx2)/dx2 ); - int ix3 = UbMath::integerRounding( (cx3-orgx3)/dx3 ); - - if( solids.indicesInRange(ix1,ix2,ix3) - && solids(ix1, ix2, ix3 ) == Flag::UNDEF ) - { - x1w = orgx1+ix1*dx1; - x2w = orgx2+ix2*dx2; - x3w = orgx3+ix3*dx3; - - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - - if( iSec>0 && (iSec&1) ) - { - seedX1 = ix1; - seedX2 = ix2; - seedX3 = ix3; - foundSeedPoint = true; - break; - } - } - } - if(foundSeedPoint) break; - } - if(!foundSeedPoint) - throw UbException(UB_EXARGS,"fuck no seed point found"); - timerVals.push_back( UbTuple<string, double>("Seed found in", timer.stop() ) ); - UBLOG( logINFO,"found seed Point in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - - cout<<nx1<<","<<nx2<<","<<nx3<<endl; - bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 ); - if(recursiveFloodFill) - { - timer.start(); - recursiveGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - - CbUniformMatrix3D<short> solidsCpy(solids); - timer.start(); - iterativeGridFill(solidsCpy, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) ); - UBLOG( logINFO,"iterative flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - } - else - { - timer.start(); - iterativeGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - } - - UBLOG(logINFO, "############################################################"); - - } - else //verifying complete arry - { - bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 ); - int solidCounter = 0; - - timer.start(); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::UNDEF ) - { - x1w = orgx1+x1*dx1; - x2w = orgx2+x2*dx2; - x3w = orgx3+x3*dx3; - - int iSec = -1; - do{ - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - }while(iSec<0); - - if( iSec&1 ) - { - if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::SOLID); - else iterativeGridFill(solids,x1,x2,x3,Flag::SOLID); - } - else - { - if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::FLUID); - else iterativeGridFill(solids,x1,x2,x3,Flag::FLUID); - } - } - } - if(recursiveFloodFill) timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - else timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s " ); - } - - list< UbTuple< string, double > >::iterator iter; - for(iter = timerVals.begin(); iter!=timerVals.end(); ++iter) - { - UBLOG( logINFO, setw(16) << val<1>(*iter) << " in " << setw(8) << setprecision(8) << val<2>(*iter) << "s" ); - } - - int solidCounter = 0; - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::SOLID ) - { - solidCounter++; - } - } - - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(1,"data"); - datanames[0] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::SOLID ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - nodedata[0].push_back( solids(x1 ,x2 ,x3 ) ); - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance()); - kdTree.writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } - - delete mesh; -} - -namespace Dirs -{ - const int X1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 0 }; - const int X2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 0 }; - const int X3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 0 }; - - const int START = 0; - const int END6 = 5; - const int END18 = 17; -} -/*==================================================================*/ -bool floodFillCheck(CbUniformMatrix3D<short>& grid, const short& x, const short& y, const short& z) -{ - return grid.indicesInRange( x, y, z ) && grid(x,y,z)==Flag::UNDEF; -} -int g_counter = 0; -void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type) -{ - // Algorithmus zum Füllen eines Polyeders, ausgehend vom Saatpunkt xs,ys,zs - - //Saatknoten einfärben - short& val = grid(xs,ys,zs); - if( val==Flag::UNDEF ) - { - val = type; - } - if( floodFillCheck( grid, xs+1, ys , zs ) ) recursiveGridFill( grid, xs+1, ys , zs , type ); - if( floodFillCheck( grid, xs , ys+1, zs ) ) recursiveGridFill( grid, xs , ys+1, zs , type ); - if( floodFillCheck( grid, xs , ys , zs+1 ) ) recursiveGridFill( grid, xs , ys , zs+1, type ); - if( floodFillCheck( grid, xs-1, ys , zs ) ) recursiveGridFill( grid, xs-1, ys , zs , type ); - if( floodFillCheck( grid, xs , ys-1, zs ) ) recursiveGridFill( grid, xs , ys-1, zs , type ); - if( floodFillCheck( grid, xs , ys , zs-1 ) ) recursiveGridFill( grid, xs , ys , zs-1, type ); -} -/*==================================================================*/ -void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type) -{ - std::stack< UbTupleInt3 > stck; - stck.push( UbTupleInt3(xs,ys,zs) ); - - int x,y,z; - - while( !stck.empty() ) - { - x = val<1>( stck.top() ); - y = val<2>( stck.top() ); - z = val<3>( stck.top() ); - stck.pop(); - - short& flagType = grid( x, y, z ); - - if( flagType == Flag::UNDEF ) - { - flagType = type; - - if ( grid.indicesInRange( x+1, y , z ) ) stck.push( UbTupleInt3( x+1, y , z ) ); - if ( grid.indicesInRange( x , y+1, z ) ) stck.push( UbTupleInt3( x , y+1, z ) ); - if ( grid.indicesInRange( x , y , z+1 ) ) stck.push( UbTupleInt3( x , y , z+1 ) ); - if ( grid.indicesInRange( x-1, y , z ) ) stck.push( UbTupleInt3( x-1, y , z ) ); - if ( grid.indicesInRange( x , y-1, z ) ) stck.push( UbTupleInt3( x , y-1, z ) ); - if ( grid.indicesInRange( x , y , z-1 ) ) stck.push( UbTupleInt3( x , y , z-1 ) ); - } - } -} diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt b/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt deleted file mode 100644 index 98a64d3548e709895dc9e1eb8bb0e6eaa378ce7c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(kdtree_pioTest) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY) diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp b/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp deleted file mode 100644 index 265316c69c61c2c1265a4d4e6000a9f1397880cd..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp +++ /dev/null @@ -1,342 +0,0 @@ -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbRandom.h> - -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -#include <basics/container/CbUniformMatrix4D.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -using namespace std; - -void KdTreeTest (std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp"); -void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp"); - -int main() -{ - try - { - //KdTreeTest("c:/temp/clumps.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/50spheres.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/Sphere5040.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/cooling_2.inp", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/NDR-Konzertsaal.inp", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/Campus-Details-W3.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/Boein707.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/dolphin.mesh", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/flamingo.mesh", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTestWithLines("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - KdTreeTest("c:/temp/doppelwandbox.ply", 100, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT, true, "g:/temp"); - - //KdTreeTestWithLines("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp"); - - //KdTreeTestWithLines("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp"); - //KdTreeTest("c:/temp/VW_body.ply", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/kugel.stl", 50, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/ship-2.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp/schiff2"); - } - catch(const std::exception& e) - { - UBLOG2( logERROR, std::cerr, "Caught exception:"); - UBLOG2( logERROR, std::cerr, "Type: " << typeid(e).name() ); - UBLOG2ML(logERROR, std::cerr, "What: " << e.what() ); - } - catch(...) - { - UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION) - } - - - - -} - -////////////////////////////////////////////////////////////////////// -void KdTreeTest(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio); - mesh->scale(10000,10000,10000); - //dummy test, damit der baum erstellt wird - mesh->isPointInGbObject3D(0,0,0); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes() ); - UBLOG(logINFO, ""); - - - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 ); - const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 ); - const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 ); - - CbUniformMatrix4D<int> solids(nx1,nx2,nx3,1,0); - - const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum(); - const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum(); - const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum(); - - const float outX1 = 2*mesh->getX1Maximum(); - const float outX2 = 0;//2*mesh->getX2Maximum(); - const float outX3 = 0;//2*mesh->getX3Maximum(); - - UBLOG( logINFO, "performing " << nx1*nx2*nx3 <<" point-in-object(PIO)-tests"); - UbTimer ff; - ff.start(); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - solids(x1,x2,x3,0) = mesh->isPointInGbObject3D(orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3); - } - UBLOG( logINFO, nx1*nx2*nx3 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" ); - UBLOG(logINFO, "############################################################"); - - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(solids.getNX4(),"data"); - datanames[0] = "solid"; - //datanames[1] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 , 0) ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - - for(int i=0; i<solids.getNX4(); i++) - { - nodedata[i].push_back( solids(x1 ,x2 ,x3 ,i) ); - } - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance(),true); - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance(),true); - mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } -} - -////////////////////////////////////////////////////////////////////// -void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio); - - //dummy test, damit der baum erstellt wird - mesh->isPointInGbObject3D(0,0,0); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes() ); - UBLOG(logINFO, ""); - - - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1) ); - const int nx2 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2) ); - const int nx3 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3) ); - - CbUniformMatrix4D<int> solids(nx1,nx2,nx3,2,0); - - const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum(); - const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum(); - const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum(); - -// const float outX1 = 2*mesh->getX1Maximum(); -// const float outX2 = 2*mesh->getX2Maximum(); -// const float outX3 = 2*mesh->getX3Maximum(); - - - Kd::Tree<double>* kdTree = mesh->getKdTree(); - - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& vertices = *mesh->getNodes(); - - float x1center = float( mesh->getX1Centroid() ); - float x2center = float( mesh->getX2Centroid() ); - float x3center = float( mesh->getX3Centroid() ); - - UBLOG( logINFO, "performing point-in-object(PIO)-tests"); - UbTimer ff; - ff.start(); - long counter1=0, counter2 = 0; - for(size_t t=0; t<triFaces.size(); t++) - { - int x1Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinX(vertices)-orgx1) / dx1 ) ); - int x2Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinY(vertices)-orgx2) / dx2 ) ); - int x3Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinZ(vertices)-orgx3) / dx3 ) ); - - int x1Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxX(vertices)-orgx1) / dx1 ) ); - int x2Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxY(vertices)-orgx2) / dx2 ) ); - int x3Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxZ(vertices)-orgx3) / dx3 ) ); - - for(int x3=x3Min; x3<=x3Max; x3++) - for(int x2=x2Min; x2<=x2Max; x2++) - for(int x1=x1Min; x1<=x1Max; x1++) - { - counter1++; - - if( !solids.indicesInRange(x1,x2,x3,0) - || solids(x1,x2,x3,1) == 1 ) //doppeltes Testeb vermeiden - { - continue; - } - - counter2++; - - double x1w = orgx1+x1*dx1; - double x2w = orgx2+x2*dx2; - double x3w = orgx3+x3*dx3; - - //eigentlicher PIO-Test - bool testFailed = true; - for(int i=0; i<100; i++) - { - UbTupleDouble3 n1(x1w, x2w, x3w); - UbTupleDouble3 n2( double( x1w < x1center ? mesh->getX1Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() : mesh->getX1Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() ) - , double( x2w < x2center ? mesh->getX2Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() : mesh->getX2Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() ) - , double( x3w < x3center ? mesh->getX3Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() : mesh->getX3Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() ) ); - - int iSec = kdTree->intersectLine( n1, n2, Kd::CountLineIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - solids(x1,x2,x3,0) = true; - } - else - { - solids(x1,x2,x3,0) = (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - testFailed = false; - break; - } - else - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - } - if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - solids(x1,x2,x3,1) = 1; - } - } - UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" ); - UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" ); - UBLOG(logINFO, "############################################################"); - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(solids.getNX4(),"data"); - datanames[0] = "solid"; - //datanames[1] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 , 0) ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - - for(int i=0; i<solids.getNX4(); i++) - { - nodedata[i].push_back( solids(x1 ,x2 ,x3 ,i) ); - } - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance()); - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance()); - mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } -} diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h b/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h deleted file mode 100644 index eccfde3058e028c2239bcc81de1ebfe0f3306e99..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef KDCOUNTLINEINTERSECTIONHANDLER_H -#define KDCOUNTLINEINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h> - -#include <set> - -namespace Kd -{ - template< typename T > - class CountLineIntersectionHandler : public LineIntersectionHandler<T> - { - public: - bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const - { - if( parent.intersectLineBoundingBox(n1, n2) == Intersection::INTERSECTION) - { - if( parent.isLeaf() ) - { - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *parent.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& nodes = parent.getNodes(); - - for( std::size_t i=0; i<triFaces.size(); i++ ) - { - GbTriFaceMesh3D::TriFace& triFace = triFaces[i]; - - if( Kd::intersectLine(n1, n2, triFace, nodes) ) return true; - } - return false; - } - else - { - if( child1 ) - { - if (child1->intersectLine(n1, n2, *this)) return true; - } - if( child2 ) - { - if (child2->intersectLine(n1, n2, *this)) return true; - } - } - } - return false; - } - /* ======================================================================================= */ - }; -} - -#endif //KDCOUNTLINEINTERSECTIONHANDLER_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h b/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h deleted file mode 100644 index b95fc676ad04008b43b0ddf6db785887f941e7e0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef KDCOUNTRAYINTERSECTIONHANDLER_H -#define KDCOUNTRAYINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -//#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h> - -#include <set> - -namespace Kd -{ - template< typename T > - class CountRayIntersectionHandler : public RayIntersectionHandler<T> - { - public: - int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const - { - if( parent.intersectRayBoundingBox(ray) == Intersection::INTERSECTION) - { - if( parent.isLeaf() ) - { - return this->checkIntersectionWithTriFaces(ray, *parent.getTriFaces(), parent.getNodes(), mailbox); - } - else - { - int sum = 0; - if( child1 ) - { - int erg = child1->intersectRay(ray, *this, mailbox); - if(erg < 0) - { - return erg; - } - sum += erg; - } - if( child2 ) - { - int erg = child2->intersectRay(ray, *this, mailbox); - if(erg < 0) - { - return erg; - } - sum += erg; - } - return sum; - } - } - else - { - return 0; - } - } - /* ======================================================================================= */ - - private: - int checkIntersectionWithTriFaces(const Ray<T>& ray, std::vector<GbTriFaceMesh3D::TriFace>& triFaces, std::vector<GbTriFaceMesh3D::Vertex>& nodes, std::set< UbKeys::Key3<int> >& mailbox) const - { - T e1x,e1y,e1z,e2x,e2y,e2z,px,py,pz,a,f,sx,sy,sz,u,qx,qy,qz,v,factor; - - int counter = 0, iSec = 0; - - for( std::size_t i=0; i<triFaces.size(); i++ ) - { - GbTriFaceMesh3D::TriFace& triFace = triFaces[i]; - - if( mailbox.find( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) )==mailbox.end() ) - { - mailbox.insert( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) ); //schon hier rein, ansonsten muss man es unten bei JEDEm continue und am ende des ifs machen - - GbTriFaceMesh3D::Vertex& v1 = triFace.getNode(0, nodes); - GbTriFaceMesh3D::Vertex& v2 = triFace.getNode(1, nodes); - GbTriFaceMesh3D::Vertex& v3 = triFace.getNode(2, nodes); - - ////////////////////////////////////////////////////////////////////////// - //Raytracing - start( Anm.: prüft NUR in Strahlrichtung - // Grundidee: Schnittpunkt in Baryzentrischen Koordinaten besimmten - // t(u,v,w) = w*v0 + u*v1 + v*v2 - // mit w = 1.0-u-v, da fuer alle Punkte (u,v,w) im Dreick gilt u+v+w = 1 - // wenn u, v oder w == 0 -> Punkt liegt auf Kante - // wenn u, v oder w == 1 -> Punkt liegt auf Eckpunkt (-> die anderen Werte muessen 0 ) - - //e1 = v1 - v0 - e1x = v2.x-v1.x; - e1y = v2.y-v1.y; - e1z = v2.z-v1.z; - - //e2 = v2 - v0 - e2x = v3.x-v1.x; - e2y = v3.y-v1.y; - e2z = v3.z-v1.z; - - //p = d x e2 - px = ray.directionY*e2z - ray.directionZ*e2y; - py = ray.directionZ*e2x - ray.directionX*e2z; - pz = ray.directionX*e2y - ray.directionY*e2x; - - //a = e1 dot p - a = e1x*px + e1y*py + e1z*pz; - //if( fabs(a)<1.E-10 ) continue; - if( fabs(a) < UbMath::Epsilon<T>::val() ) continue; - f = T(1.0/a); - - //s = o - v0 - sx = ray.originX - v1.x; - sy = ray.originY - v1.y; - sz = ray.originZ - v1.z; - - //u = f * ( s dot p) - u = f * ( sx*px + sy*py + sz*pz ); - - //u ist nur gueltig in [0;1] - if( ( UbMath::less( u, T(0.0) ) ) || ( UbMath::greater(u, T(1.0) ) ) ) - { - continue; - } - - //q = s x e1 - qx = sy*e1z - sz*e1y; - qy = sz*e1x - sx*e1z; - qz = sx*e1y - sy*e1x; - - //v = f*(e2 dot q) - v = f * (ray.directionX*qx + ray.directionY*qy + ray.directionZ*qz); - - //v ist nur gueltig in [0;1] da aber v bereits gueltig ist -> u+v darf nicht > 1.0 sein ;-) - if( ( UbMath::less(v, T(0.0) ) ) || ( UbMath::greater(u+v, T(1.0) ) ) ) - { - continue; - } - - //t = f * (e2 dot q) - factor = f * (e2x*qx + e2y*qy + e2z*qz); - //Raytracing - end - ////////////////////////////////////////////////////////////////////////// - - if( UbMath::zero( factor ) ) - { - return Intersection::ON_BOUNDARY; //ray.Org liegt direkt auf einem dreieck --> boundary - } - if( factor < 0.0 ) - { - continue; //Schnittpunkt liegt in entgegengesetzter Strahlrichtung - } - - //edge tests - //wenn u, v oder w ==0 -> Punkt liegt auf Kante bzw. Eckpunkt - if( UbMath::zero(u) ) return Intersection::INTERSECT_EDGE; - if( UbMath::zero(v) ) return Intersection::INTERSECT_EDGE; - if( UbMath::zero(T(1.0)-u-v) ) return Intersection::INTERSECT_EDGE; - - counter++; - } - } - return counter; - } - }; -} - -#endif //KDCOUNTRAYLINEINTERSECTIONHANDLER_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h b/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h deleted file mode 100644 index 65f94876a94cffc6f6dd9615c4f77d7c73be9a02..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef KDLINEINTERSECTIONHANDLER_H -#define KDLINEINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -//#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <set> - -// #ifdef CAB_RCF -// # include <3rdParty/rcf/RcfSerializationIncludes.h> -// #end -namespace Kd -{ - template< typename T> - class Node; - - template< typename T> - class LineIntersectionHandler - { - public: - virtual bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const = 0; - virtual ~LineIntersectionHandler() {} - }; -} - -// #if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) -// SF_NO_CTOR(Kd::LineIntersectionHandler<float>); -// SF_NO_CTOR(Kd::LineIntersectionHandler<double>); -// #endif //RCF_USE_SF_SERIALIZATI -#endif //KDLINEINTERSECTIONHANDLER_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h b/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h deleted file mode 100644 index 7578d9046a68fc2a2b310204379df37f2c758c84..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef KDRAYINTERSECTIONHANDLER_H -#define KDRAYINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <numerics/geometry3d/KdTree/KdRay.h> - -#include <set> - -namespace Kd -{ - template< typename T> - class RayIntersectionHandler - { - public: - virtual int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const = 0; - virtual ~RayIntersectionHandler() {} - }; -} - -#endif //KDRAYINTERSECTIONHANDLER_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp b/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp deleted file mode 100644 index da4ff27465d87a8a6fff032d8f84e427a278255d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//#include <numerics/geometry3d/KdTree/SAHSplit.h> - - -// namespace Kd -// { -// const double SAHSplit::Ct = 3.0; //traversal cost -// const double SAHSplit::Ci = 4.0; //ray-patch-intersection-cost -// } - - diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h b/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h deleted file mode 100644 index 52e73ea714969df05098d7fed82f826357beeca5..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef KDSAHSPLIT_H -#define KDSAHSPLIT_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -#include <vector> -#include <cmath> - -namespace Kd -{ - template< typename T > - class SAHSplit : public SplitAlgorithm<T> - { - public: - /* ======================================================================================= */ - SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "triFace NULL pointer"); - - if( node.getTriFaces()->size() <= 1 //max triangles in node - || level >= maxLevel ) - { - return SplitCandidate<T>(); - } - - SplitCandidate<T> bestSplitCandidate; - T minCN = Ub::inf; - - for(int splitAxis = 0; splitAxis < 3; splitAxis++) - { - SplitCandidateManager<T> sc; - findPossibleSplitCandidates(splitAxis, node, sc); - - // incremental sweep to find best split position - for( std::size_t i = 0; i < sc.size(); i++) - { - if (i == 0) - { - sc[i].nl = sc.objects_starting_outside_left + sc.objects_fully_outside_node; - sc[i].nr = node.getTriFaces()->size() - sc[0].np - sc[0].ending; - } - else - { - sc[i].nl = sc[i - 1].nl + sc[i - 1].starting + sc[i - 1].np; - sc[i].nr = sc[i - 1].nr - sc[i ].ending - sc[i ].np; - } - - this->calcSAH(sc[i], node); - - if (sc[i].Cn < minCN) - { - minCN = sc[i].Cn; - bestSplitCandidate = sc[i]; - } - } - } - - // automatic termination criterion (SAH) - if ( bestSplitCandidate.isValid && bestSplitCandidate.Cn >= node.getTriFaces()->size() * Ci) - { - return SplitCandidate<T>(); - } - - return bestSplitCandidate; - } - /* ======================================================================================= */ - void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer at triface list"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - Kd::project2Axis(triFace, srcNodes, candidate.axis, projection); - - T& min = projection[0]; - T& max = projection[2]; - // --------------------------------------------------- // - // case 1 : object inside plane - if( UbMath::equal(min, max) ) - { - if( UbMath::equal(min, candidate.position) ) - { - if(candidate.np_left) - { - triFacesForChild1.push_back(triFace); - } - else if(candidate.np_right) - { - triFacesForChild2.push_back(triFace); - } - } - else if( UbMath::less(min, candidate.position) ) - { - triFacesForChild1.push_back(triFace); - } - else //if( UbMath::greater(min, candidate.position) - { - triFacesForChild2.push_back(triFace); - } - } // - // --------------------------------------------------- // - // case 2 : object on left side of plane - else if( UbMath::lessEqual(max,candidate.position) ) - { - triFacesForChild1.push_back(triFace); - } // --------------------------------------------------- // - // case 3 : object on right side of plane - else if ( UbMath::greaterEqual( min, candidate.position) ) - { - triFacesForChild2.push_back(triFace); - }// - // --------------------------------------------------- // - // case 4 : object in both nodes - else - { - triFacesForChild1.push_back(triFace); - triFacesForChild2.push_back(triFace); - }// - // --------------------------------------------------- // - } - - node.deleteTriFaces(); - } - - - private: - /* ======================================================================================= */ - // cost function - inline T calcCosts(const int& nl, const int& nr, const T& SA_VL, const T& SA_VR, const T& SA_V) const - { - return Ct + Ci * (nl * SA_VL / SA_V + nr * SA_VR / SA_V); - } - /* ======================================================================================= */ - void findPossibleSplitCandidates(const int& splitAxis, Node<T>& node, SplitCandidateManager<T>& splitCandidateManager) const - { - T p1_node = (splitAxis == Axis::X ? node.x[0] : splitAxis == Axis::Y ? node.y[0] : node.z[0]); - T p2_node = (splitAxis == Axis::X ? node.x[1] : splitAxis == Axis::Y ? node.y[1] : node.z[1]); - - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex >& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - - // project object to axis - Kd::project2Axis(triFace,srcNodes,splitAxis, projection); - // left point - T& p1 = projection[0]; - // right point - T& p2 = projection[2]; - - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 1 : object is fully inside the current node - if( UbMath::greaterEqual(p1, p1_node) - && UbMath::lessEqual(p2, p2_node) ) - { - if( UbMath::equal(p1, p2) ) - { - // object is inside the plane - splitCandidateManager.add(p1, splitAxis, 0, 0, 1); - } - else - { - splitCandidateManager.add(p1, splitAxis, 1, 0, 0); - splitCandidateManager.add(p2, splitAxis, 0, 1, 0); - } - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 2 : just the right point (p2) is inside the current node - else if( UbMath::less(p1, p1_node) - && UbMath::lessEqual(p2,p2_node) - && UbMath::greaterEqual(p2, p1_node) ) - { - splitCandidateManager.add(p2, splitAxis, 0, 1, 0); - splitCandidateManager.objects_starting_outside_left++; - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 3 : just the left point (p1) is inside the current node - else if( UbMath::greaterEqual(p1, p1_node) - && UbMath::greater(p2, p2_node) - && UbMath::lessEqual(p1, p2_node) ) - { - splitCandidateManager.add(p1, splitAxis, 1, 0, 0); - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 4 : left and right point are outside the current node - else if( UbMath::less(p1, p1_node) - && UbMath::greater(p2, p2_node) ) - { - splitCandidateManager.objects_fully_outside_node++; - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - } - - splitCandidateManager.createSortedArray(); - } - - - /* ======================================================================================= */ - // calculates the costs for a given splitCandidate based on the Surface Area Heuristic (SAH) - void calcSAH(SplitCandidate<T>& candidate, Node<T>& node) const - { - T p1_node = (candidate.axis == Axis::X ? node.x[0] : candidate.axis == Axis::Y ? node.y[0] : node.z[0]); - - // edges of (root) voxel - T dx = std::fabs(node.x[1] - node.x[0]); - T dy = std::fabs(node.y[1] - node.y[0]); - T dz = std::fabs(node.z[1] - node.z[0]); - - // surface area (root) voxel - T SA_V = T((2.0 * dx * dy) + (2.0 * dx * dz) + (2.0 * dy * dz)); - - T delta = (candidate.axis == Axis::X ? dx : candidate.axis == Axis::Y ? dy : dz); - T deltaL = std::fabs(candidate.position - p1_node); - T deltaR = std::fabs(delta - deltaL); - - // edges of sub voxel left - T dx_l = (candidate.axis == Axis::X ? deltaL : dx), dy_l = (candidate.axis == Axis::Y ? deltaL : dy), dz_l = (candidate.axis == Axis::Z ? deltaL : dz); - - // surface area sub voxel left - T SA_VL = T( (2.0 * dx_l * dy_l) + (2.0 * dx_l * dz_l) + (2.0 * dy_l * dz_l) ); - - // edges of sub voxel right - T dx_r = (candidate.axis == Axis::X ? deltaR : dx), dy_r = (candidate.axis == Axis::Y ? deltaR : dy), dz_r = (candidate.axis == Axis::Z ? deltaR : dz); - - // surface area sub voxel right - T SA_VR = T( (2.0 * dx_r * dy_r) + (2.0 * dx_r * dz_r) + (2.0 * dy_r * dz_r) ); - - if (candidate.np == 0) - { - candidate.Cn = calcCosts(candidate.nl, candidate.nr, SA_VL, SA_VR, SA_V); - return; - } - - // once putting np with nl, and once with nr - and select the one with lowest cost - // see: Wald, Havran: "On building fast kd-Trees for Ray Tracing, and doing that in O(N log N)", 2006 - T CP_L = calcCosts(candidate.nl + candidate.np, candidate.nr , SA_VL, SA_VR, SA_V); - T CP_R = calcCosts(candidate.nl , candidate.nr + candidate.np, SA_VL, SA_VR, SA_V); - - if(CP_L < CP_R) - { - candidate.Cn = CP_L; - candidate.np_right = true; - } - else - { - candidate.Cn = CP_R; - candidate.np_left = true; - } - } - /* ======================================================================================= */ - - protected: - static const T Ct;// = 3.0; traversal cost - static const T Ci;// = 4.0; ray-patch-intersection-cost - }; - - - template< typename T> - const T SAHSplit<T>::Ct = 3.0; //traversal cost - template< typename T> - const T SAHSplit<T>::Ci = 4.0; //ray-patch-intersection-cost -} - -#endif //KDSAHSPLIT_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h b/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h deleted file mode 100644 index b87c18b4817ab2c017cd76b66c220f5aa41ce90f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef SPATIALLMEDIANSPLIT_H -#define SPATIALLMEDIANSPLIT_H - -#include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -namespace Kd -{ - template< typename T > - class SpatialMedianSplit : public SplitAlgorithm<T> - { - /* ======================================================================================= */ - SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const - { - if( node.getTriFaces()->size() <= 24 //max triangles in node - || level >= maxLevel ) - { - return SplitCandidate<T>(); - } - - T dx = std::fabs(node.x[1] - node.x[0]); - T dy = std::fabs(node.y[1] - node.y[0]); - T dz = std::fabs(node.z[1] - node.z[0]); - - if ( UbMath::equal(dx, UbMath::max(dx, dy, dz) ) ) return SplitCandidate<T>(Axis::X, node.x[0] + 0.5 * dx, 0, 0, 0); - else if( UbMath::equal(dy, UbMath::max(dy, dz ) ) ) return SplitCandidate<T>(Axis::Y, node.y[0] + 0.5 * dy, 0, 0, 0); - - return SplitCandidate<T>(Axis::Z, node.z[0] + 0.5 * dz, 0, 0, 0); - - } - /* ======================================================================================= */ - void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& primitives_child1, std::vector<GbTriFaceMesh3D::TriFace>& primitives_child2, Node<T>& node) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - Kd::project2Axis(triFace, srcNodes, candidate.axis, projection); - - T& min = projection[0]; - T& max = projection[2]; - - // case 1 : object inside plane - if( UbMath::equal(min,max) ) - { - if( UbMath::equal(min,candidate.position) ) - { - primitives_child1.push_back(triFace); - primitives_child2.push_back(triFace); - } - else if( UbMath::less(min, candidate.position) ) - { - primitives_child1.push_back(triFace); - } - else if( UbMath::greater(min, candidate.position) ) - { - primitives_child2.push_back(triFace); - } - } - // case 2 : object on left side of plane - else if( UbMath::lessEqual(max, candidate.position) ) - { - primitives_child1.push_back(triFace); - } - // case 3 : object on right side of plane - else if( UbMath::greaterEqual(min, candidate.position) ) - { - primitives_child2.push_back(triFace); - } - // case 4 : object in both nodes - else - { - primitives_child1.push_back(triFace); - primitives_child2.push_back(triFace); - } - } - - node.deleteTriFaces(); - } - }; -} - -#endif //SPATIALLMEDIANSPLIT_H diff --git a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h b/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h deleted file mode 100644 index 16244300593b2de61738ade6f09cf8525504551f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef KDSPLITALGORITHM_H -#define KDSPLITALGORITHM_H - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -//#include <numerics/geometry3d/KdTree/Node.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> - -#include <vector> - -namespace Kd -{ - template< typename T > - class Node; - - template< typename T > - class SplitAlgorithm - { - public: - virtual SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const = 0; - virtual void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const=0; - virtual ~SplitAlgorithm() {} - }; -} - - -#endif //KDSPLITALGORITHM_H diff --git a/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt deleted file mode 100644 index 7fc2bbf84209dc05bd7aa85886b2250007c2a107..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt +++ /dev/null @@ -1,12 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) - -#SET(SUBDIRPATH numerics/geometry3d/creator) -#SET(OPTION_LABEL BUILD_GEOMETRY3DCREATOR) -# -#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH}) -# -#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON) -#IF(${OPTION_LABEL}) -# COLLECT_PACKAGE_DATA( ${CURRENT_DIR} ${SUBDIRPATH} ALL_SOURCES) -#ENDIF(${OPTION_LABEL}) diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h deleted file mode 100644 index 9b8478f8bdfaa680584e96e0f10b92a5b8726c3c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBCUBOID3DCREATOR_H -#define GBCUBOID3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbCuboid3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbCuboid3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbCuboid3D.h> -#endif - -class GbCuboid3DCreator : public GbObject3DCreator -{ -public: - static GbCuboid3DCreator* getInstance() - { - static GbCuboid3DCreator instance; - return &instance; - } - - GbCuboid3D* createGbObject3D() { return new GbCuboid3D(); } - - std::string getGbObject3DTypeID() { return "GbCuboid3D"; }; - std::string toString() { return "GbCuboid3DCreator"; } - -private: - GbCuboid3DCreator() : GbObject3DCreator() {} - - GbCuboid3DCreator( const GbCuboid3DCreator& ); //no copy allowed - const GbCuboid3DCreator& operator=( const GbCuboid3DCreator& ); //no copy allowed - -#ifdef CAB_QT -public: - GbCuboid3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = this->createGbObject3D(); - cuboid->getPoint2()->setX1(2.0); - cuboid->getPoint2()->setX2(2.0); - cuboid->getPoint2()->setX3(2.0); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - if (instrument.exec()) { return cuboid; } - delete cuboid; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbCuboid3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = dynamic_cast<GbCuboid3D*>(gbObj); - if(!cuboid) throw UbException(UB_EXARGS,"selected object to edit is no GbCuboid3D!"); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCuboid3D(dynamic_cast<GbCuboid3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCuboid3DCreator::getInstance()), CAB_GbCuboid3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h deleted file mode 100644 index ca9614d7d50f5ba8f32f9a7cc134503a5d9cf49b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBCYLINDER3DCREATOR_H -#define GBCYLINDER3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbCylinder3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbCylinder3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbCylinder3D.h> -#endif - - -class GbCylinder3DCreator : public GbObject3DCreator -{ -public: - static GbCylinder3DCreator* getInstance() - { - static GbCylinder3DCreator instance; - return &instance; - } - - GbCylinder3D* createGbObject3D() { return new GbCylinder3D(); } - - std::string getGbObject3DTypeID(){ return "GbCylinder3D"; } - std::string toString() { return "GbCylinder3DCreator"; } - -private: - GbCylinder3DCreator( const GbCylinder3DCreator& ); //no copy allowed - const GbCylinder3DCreator& operator=( const GbCylinder3DCreator& ); //no copy allowed -GbCylinder3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbCylinder3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = this->createGbObject3D(); - cylinder->setRadius(2.0); - cylinder->setPoint1(0.0, 0.0, 0.0); - cylinder->setPoint2(0.0, 5.0, 0.0); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - if (instrument.exec()){ return cylinder; } - delete cylinder; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) - { - return new QGbCylinder3DInstrument(parent, flags); - } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = dynamic_cast<GbCylinder3D*>(gbObj); - if(!cylinder) throw UbException(UB_EXARGS,"selected object to edit is no GbCylinder3D!"); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCylinder3D(dynamic_cast<GbCylinder3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCylinder3DCreator::getInstance()), CAB_GbCylinder3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h deleted file mode 100644 index 460613f8e3b65dbdad516a507501f7a035ccf13d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBLINE3DCREATOR_H -#define GBLINE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbLine3D.h> - -class GbLine3DCreator : public GbObject3DCreator -{ -public: - static GbLine3DCreator* getInstance() - { - static GbLine3DCreator instance; - return &instance; - } - - GbLine3D* createGbObject3D() { return new GbLine3D(); } - - std::string getGbObject3DTypeID(){ return "GbLine3D"; } - std::string toString() { return "GbLine3DCreator"; } - -private: - GbLine3DCreator( const GbLine3DCreator& ); //no copy allowed - const GbLine3DCreator& operator=( const GbLine3DCreator& ); //no copy allowed - GbLine3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbLine3DCreator::getInstance()), CAB_GbLine3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h deleted file mode 100644 index d1a8fd785fcc325ab78252f2034663d49df3c25c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBOBJECT3DCREATOR_H -#define GBOBJECT3DCREATOR_H - -#include <string> - -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbAutoRun.hpp> - -#include <numerics/geometry3d/GbObject3D.h> - -#ifdef CAB_QT -#include <qdialog.h> -#endif - -#ifdef CAB_VTK -#include <userinterface/presentation/vtkPoElement3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkPVSource.h" -#endif - -class GbObject3DCreator : public ObObjectCreator -{ -protected: - GbObject3DCreator() {} -private: - GbObject3DCreator( const GbObject3DCreator& ); //no copy allowed !!! - const GbObject3DCreator& operator=( const GbObject3DCreator& ); //no copy allowed -public: - virtual ~GbObject3DCreator(){} - - virtual std::string getTypeID() { return getGbObject3DTypeID();} - virtual ObObject* createObObject() - { - return this->createGbObject3D(); - } - - - virtual GbObject3D* createGbObject3D()=0; - virtual std::string getGbObject3DTypeID()=0; - virtual std::string toString() { return "GbObject3DCreator"; } - -#ifdef CAB_QT - virtual GbObject3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } - virtual void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } -#endif - //die Teile von ObObjectCreator ... -#ifdef CAB_QT - void showSpecificInstrument(ObObject* object,QWidget* parent=0) - { - GbObject3D* geoObj = dynamic_cast<GbObject3D*>(object); - this->editGbObject3DwithQt(geoObj, parent); - } - virtual ObObject* createObObjectWithQt() { return this->createGbObject3DwithQt();} - virtual QObObjectSpecificInstrument* getSpecificInstrument() { throw UbException(UB_EXARGS,"not implemented"); } - -#endif -#ifdef CAB_VTK - virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; } -#endif - - -#ifdef CAB_PARAVIEW - virtual vtkPVSource* createPVSource(vtkPVWindow *Window) { throw UbException(UB_EXARGS,"vtkPVSource* createPVSource"); } -#endif - - -}; - -#include <numerics/geometry3d/creator/GbObject3DFactory.h> - -/*=========================================================================*/ -#endif - - - diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp b/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp deleted file mode 100644 index eacc1cc086e46e0e3599dd1a318698d7d5fa2332..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include <numerics/geometry3d/creator/GbObject3DFactory.h> -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -//#include <numerics/geometry3d/creator/GbPoint3DCreator.h> -// #include <numerics/geometry3d/creator/GbCuboid3DCreator.h> -// #include <numerics/geometry3d/creator/GbSphere3DCreator.h> -// #include <numerics/geometry3d/creator/GbCylinder3DCreator.h> -// #include <numerics/geometry3d/creator/GbLine3DCreator.h> -// #include <numerics/geometry3d/creator/GbPolygon3DCreator.h> -// #include <numerics/geometry3d/creator/GbTriangle3DCreator.h> -// #include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> - -using namespace std; - -//GbObject3DFactory* GbObject3DFactory::instance = NULL; - -/*======================================================================*/ -GbObject3DFactory::GbObject3DFactory() - : ObObjectFactory() -{ -} -/*======================================================================*/ -GbObject3DFactory* GbObject3DFactory::getInstance() -{ - static GbObject3DFactory instance; - return &instance; -} - -///*======================================================================*/ -//void GbObject3DFactory::addGbObject3DCreator(GbObject3DCreator* creator) -//{ -// //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getGbObject3DTypeID()<<endl; -// creatorSet.insert(pair<string, GbObject3DCreator*>(creator->getGbObject3DTypeID(), creator)); -//} -// -//void GbObject3DFactory::deleteGbObject3DCreator(GbObject3DCreator* creator) -//{ -// throw UbException(UB_EXARGS,"GbObject3DFactory::deleteGbObject3DCreator not yet implemented"); -// // this.creatorSet.delete(creator); -//} - -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createGbObject3D(UbFileInput *in) -{ - string str = in->readString(); - //cout<<"GbObject3DFactory::createGbObject3D:"<<str<<endl; - - GbObject3D *gbObject3D = createEmptyGbObject3D(str); - - if(!gbObject3D) - throw UbException(UB_EXARGS,"creator for type available"); - - gbObject3D->read(in); - - return gbObject3D; -} -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createEmptyGbObject3D(string objectType) -{ - typedef std::map<string, ObObjectCreator*>::iterator CreatorIterator; - std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet(); - CreatorIterator creatorIterator = creatorSet->find(objectType); - - if(creatorIterator == creatorSet->end()) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - GbObject3DCreator *creator = dynamic_cast<GbObject3DCreator*>(creatorIterator->second); - - if(!creator) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - return creator->createGbObject3D(); -} -/*======================================================================*/ -//GbObject3DCreator* GbObject3DFactory::getCreator(string objectType) -//{ -// CreatorIterator creatorIterator = creatorSet.find(objectType); -// if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// GbObject3DCreator *creator = creatorIterator->second; -// if(!creator) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// return(creator); -//} -/*======================================================================*/ -string GbObject3DFactory::toString() -{ - stringstream ss; - ss<<"GbObject2DFactory"; - int a=1; - std::map<std::string, ObObjectCreator*>::iterator creatorIterator; - std::map<std::string, ObObjectCreator*>* tmp = this->getCreatorSet(); - for(creatorIterator=tmp->begin(); creatorIterator!=tmp->end(); creatorIterator++) - { - ss<<(a++)<<". "; - ss<<creatorIterator->second->getTypeID(); - ss<<endl; - } - return(ss.str()); -} diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h b/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h deleted file mode 100644 index f01d1dd45f7c766a4703c3d22cf10747a394e53c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GBOBJECT3DFACTORY_H -#define GBOBJECT3DFACTORY_H - -#include <string> -#include <sstream> -#include <map> - -#include <basics/objects/ObObjectFactory.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -class GbObject3D; -class GbObject3DCreator; - -class GbObject3DFactory : public ObObjectFactory -{ -private: - GbObject3DFactory(); - GbObject3DFactory( const GbObject3DFactory& ); //no copy allowed - const GbObject3DFactory& operator=( const GbObject3DFactory& ); //no copy allowed -public: - static GbObject3DFactory* getInstance(); - - GbObject3D* createGbObject3D(UbFileInput* in); - - //void addGbObject3DCreator(GbObject3DCreator* creator); - //void deleteGbObject3DCreator(GbObject3DCreator* creator); - //std::map<std::string, GbObject3DCreator*>* getCreatorSet() { return &creatorSet; } - - std::string toString(); - GbObject3D* createEmptyGbObject3D(std::string objectType); - //GbObject3DCreator* getCreator(std::string objectTypeID); - -private: - - - //std::map<std::string, GbObject3DCreator*> creatorSet; - //typedef std::map<std::string, GbObject3DCreator*>::iterator CreatorIterator; -}; -/*=========================================================================*/ -#endif - diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h deleted file mode 100644 index 40bb5835c3d9899cd63d18447c953eaa7a85d0b2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBPOINT3DCREATOR_H -#define GBPOINT3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> - -class GbPoint3DCreator : public GbObject3DCreator -{ -public: - static GbPoint3DCreator* getInstance() - { - static GbPoint3DCreator instance; - return &instance; - } - - GbPoint3D* createGbObject3D() { return new GbPoint3D(); } - - std::string getGbObject3DTypeID() { return "GbPoint3D"; } - std::string toString() { return "GbPoint3DCreator"; } - -private: - GbPoint3DCreator( const GbPoint3DCreator& ); //no copy allowed - const GbPoint3DCreator& operator=( const GbPoint3DCreator& ); //no copy allowed - GbPoint3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPoint3DCreator::getInstance()), CAB_GbPoint3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h deleted file mode 100644 index 703397747d8caa917fd2af14b36059db9e79a9cc..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GBPOLYGON3DCREATOR_H -#define GBPOLYGON3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> - -class GbPolygon3DCreator : public GbObject3DCreator -{ -public: - static GbPolygon3DCreator* getInstance() - { - static GbPolygon3DCreator instance; - return &instance; - } - - GbPolygon3D* createGbObject3D() { return new GbPolygon3D(); } - - std::string getGbObject3DTypeID() { return "GbPolygon3D"; } - std::string toString() { return "GbPolygon3DCreator"; } - -private: - GbPolygon3DCreator( const GbPolygon3DCreator& ); //no copy allowed - const GbPolygon3DCreator& operator=( const GbPolygon3DCreator& ); //no copy allowed - - GbPolygon3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPolygon3DCreator::getInstance()), CAB_GbPolygon3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp b/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp deleted file mode 100644 index f0d818aa7263f0dbf5ddcdf33dc92fe067a23709..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbQuadFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -using namespace std; - -/***************************************************************************/ -GbObject3D* GbQuadFaceMesh3DCreator::createGbObject3D() -{ - return new GbQuadFaceMesh3D(); -} -/***************************************************************************/ -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, string name) -{ - vector<GbQuadFaceMesh3D::Vertex> *vertices = new vector<GbQuadFaceMesh3D::Vertex>; - vector<GbQuadFaceMesh3D::QuadFace> *quads = new vector<GbQuadFaceMesh3D::QuadFace>; - for(int x1=0;x1<nodesX1;x1++) - { - for(int x2=0;x2<nodesX2;x2++) - { - vertices->push_back(GbQuadFaceMesh3D::Vertex((float)(x1*knotenabstandX1+startX1), (float)(x2*knotenabstandX2+startX2), nullNiveau)); - } - } - for(int x1=0;x1<nodesX1-1;x1++) - { - for(int x2=0;x2<nodesX2-1;x2++) - { - int index = x1*nodesX2+x2; - quads->push_back(GbQuadFaceMesh3D::QuadFace(index, index+nodesX2, index+nodesX2+1, index+1)); - } - } - - return (new GbQuadFaceMesh3D(name, vertices, quads)); -} - -/*============================================================*/ - -#ifdef CAB_QT - -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createGbObject3DwithQt() -{ - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - //QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - //UbFileInputASCII in( s.toAscii().data() ); - //stringstream stream; - //stream <<"TriangularMesh3D ";//<<_objCount++; - //GbQuadFaceMesh3D *mesh = NULL;//GbQuadFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - //return mesh; - return NULL; -} -//QDialog* getSpecificInstrument() { return 0;} -void GbQuadFaceMesh3DCreator::editGbObject3DwithQt(GbObject3D* gbObj) -{ - -} -#endif -#ifdef CAB_VTK -Presentator* GbQuadFaceMesh3DCreator::createObjectPresentator(ObObject *object) -{ - return NULL; -} -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h deleted file mode 100644 index ac43dd4fe141e9b8b6c0150b8968d4ebf178377b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef GBQUADFACEMESH3DCREATOR_H -#define GBQUADFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> - -class GbQuadFaceMesh3D; - -#ifdef CAB_QT - -#endif - -#ifdef CAB_VTK -//#include <numerics/geometry3d/presentation/vtkGbQuadangularMesh3D.h> -#endif - -class GbQuadFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbQuadFaceMesh3DCreator* getInstance() - { - static GbQuadFaceMesh3DCreator instance; - return &instance; - } - static GbQuadFaceMesh3D *createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, std::string name); - - GbObject3D* createGbObject3D(); - - std::string getGbObject3DTypeID() { return "GbQuadFaceMesh3D"; } - std::string toString() { return "GbQuadFaceMesh3DCreator"; } - -#ifdef CAB_QT - - GbQuadFaceMesh3D* createGbObject3DwithQt(); - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj); -#endif -#ifdef CAB_VTK - Presentator* createObjectPresentator(ObObject *object); -#endif - - -private: - GbQuadFaceMesh3DCreator( const GbQuadFaceMesh3DCreator& ); //no copy allowed - const GbQuadFaceMesh3DCreator& operator=( const GbQuadFaceMesh3DCreator& ); //no copy allowed - GbQuadFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbQuadFaceMesh3DCreator::getInstance()), CAB_GbQuadFaceMesh3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h deleted file mode 100644 index 81e70daf041d2c71fb090a0c2b0034552891ee4f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef GBSPHERE3DCREATOR_H -#define GBSPHERE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbSphere3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbSphere3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbSphere3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkSMSourceProxy.h" -#include "vtkSMProperty.h" -#include "vtkSMDoubleVectorProperty.h" -#endif - -class GbSphere3DCreator : public GbObject3DCreator -{ -public: - static GbSphere3DCreator* getInstance() - { - static GbSphere3DCreator instance; - return &instance; - } - - GbSphere3D* createGbObject3D() { return new GbSphere3D(); } - - std::string getGbObject3DTypeID() { return "GbSphere3D"; }; - std::string toString() { return "GbSphere3DCreator"; } - -private: - GbSphere3DCreator( const GbSphere3DCreator& ); //no copy allowed - const GbSphere3DCreator& operator=( const GbSphere3DCreator& ); //no copy allowed - GbSphere3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbSphere3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = this->createGbObject3D(); - sphere->setRadius(3.0); - sphere->setCenterX1Coordinate(6.0); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - if (instrument.exec()) { return sphere; } - delete sphere; - return NULL; - } - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbSphere3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = dynamic_cast<GbSphere3D*>(gbObj); - if(!sphere) throw UbException(UB_EXARGS,"selected object to edit is no GbSphere3D"); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbSphere3D(dynamic_cast<GbSphere3D*>(object)); } -#endif - - -#ifdef CAB_PARAVIEW - vtkPVSource* createPVSource(vtkPVWindow *Window); -#endif -}; - -#ifdef CAB_PARAVIEW -vtkPVSource* GbSphere3DCreator::createPVSource(vtkPVWindow *Window) -{ - GbSphere3D *mysphere = this->createGbObject3D(); - mysphere->setCenterX1Coordinate(2.0); - mysphere->setCenterX2Coordinate(1.0); - mysphere->setCenterX3Coordinate(3.0); - mysphere->setRadius(0.3); - - vtkPVSource* pvs = Window->CreatePVSource("SphereSource"); - pvs->CreateProperties(); - if (pvs) - { - pvs->IsPermanentOn(); - pvs->Accept(1, 1); - //pvs->SetTraceReferenceObject(this->GetWindow()); - pvs->SetTraceReferenceObject(Window); - } - //vtkPVDisplayGUI *settingsGUI= pvs->GetPVOutput(); - - vtkSMSourceProxy* proxy = pvs->GetProxy(); - vtkSMProperty *prop = proxy->GetProperty("Center"); - - vtkSMDoubleVectorProperty *doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Center")); - doubleprop->SetElement(0, mysphere->getX1Centroid()); - doubleprop->SetElement(1, mysphere->getX2Centroid()); - doubleprop->SetElement(2, mysphere->getX3Centroid()); - pvs->SetLabel("Kugel"); - - doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Radius")); - doubleprop->SetElement(0, mysphere->getRadius()); - - pvs->GetPVWidget("Center")->ResetInternal(); - pvs->GetPVWidget("Radius")->ResetInternal(); - - pvs->SetVisibility(TRUE); - pvs->AcceptCallback(); - pvs->Update(); - return pvs; -} -#endif - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbSphere3DCreator::getInstance()), CAB_GbSphere3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp deleted file mode 100644 index 8129dfeaf8f58d17d22220dc23c9b432995b7667..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbTiming.h> - -using namespace std; - -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist - - //UBLOG(logINFO, "GbTriFaceMesh3DCreator::readMeshFromFile - read " <<filename ); - - if ( !ext.compare("ply" ) ) return GbTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("stl" ) ) return GbTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("inp" ) ) return GbTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("mesh") ) return GbTriFaceMesh3DCreator::readMeshFromMeshFile(filename, meshName,splitAlg , removeRedundantNodes); - //else if( !ext.compare("raw") ) return GbTriFaceMesh3DCreator::readMeshFromRAWFile(filename,splitAlg , meshName); - else throw UbException(UB_EXARGS,"fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII meshfile(filename); - if(!meshfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromMeshFile(&meshfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Vertices") !=std::string::npos ) - break; - } - int numVertices = in->readInteger(); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - - nodes->resize(numVertices); - - float x, y, z; - for (int i=0; i<numVertices; i++) - { - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Triangles") !=std::string::npos ) - break; - } - int numFaces = in->readInteger(); - triangles->reserve(numFaces); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - int j,k,l; - for(int i=0; i<numFaces; i++) - { - j = in->readInteger()-1; - k = in->readInteger()-1; - l = in->readInteger()-1; - in->readLine(); - - (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes ); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII plyfile(filename); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - float x, y, z; - string dummy; - - int numVertices = in->readIntegerAfterString("element vertex"); - int numFaces = in->readIntegerAfterString("element face"); - in->setPosAfterLineWithString("end_header"); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - nodes->resize(numVertices); - triangles->reserve(numFaces); - - int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01)); - for (int i=0; i<numVertices; i++) - { - if( i%onePercent==0 ) - cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush; - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - int p,j,k,l,n; - onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); - for(int i=0; i<numFaces; i++) - { - if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush; - - p = in->readInteger(); - if(p==3) //Dreieck, alles andere wird stumpf ingnoriert - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) ) - { - throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - else if(p==4) //Viereck --> wird zu zwei Dreiecken! - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - n = in->readInteger(); - numFaces++; - i++; - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) - || !UbMath::inClosedInterval(n,0,numVertices-1) - ) - { - throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j)); - } - - in->readLine(); - - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - nr+=3; - //std::cout<<"read mesh "<< nr <<" \n"; - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - int numberNodes = in->readInteger(); - int numberTris = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - in->readInteger(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - in->readLine(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - in->readInteger(); - in->readString(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1)); - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - - in->readString(); - int numberNodes = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //cout<<u<<" - x,y,z:"<<x<<","<<y<<","<<z<<endl; - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //in->readLine(); - } - in->readLine(); - in->readString(); - int numberTris = in->readInteger(); - in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); - - - return mesh; -} diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h deleted file mode 100644 index 0fb144d8548b22c1e76999c22db0bc1a448a4ef6..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef GBTRIFACEMESH3DCREATOR_H -#define GBTRIFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriFaceMesh3DCreator* getInstance() - { - static GbTriFaceMesh3DCreator instance; - return &instance; - } - static GbTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromMeshFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriFaceMesh3D"; }; - std::string toString() { return "GbTriFaceMesh3DCreator"; } - -#ifdef CAB_QT - - - GbTriFaceMesh3D* createGbObject3DwithQt() - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriFaceMesh3D *mesh = NULL;//GbTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriFaceMesh3DCreator( const GbTriFaceMesh3DCreator& ); //no copy allowed - const GbTriFaceMesh3DCreator& operator=( const GbTriFaceMesh3DCreator& ); //no copy allowed - GbTriFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriFaceMesh3DCreator::getInstance()), CAB_GbTriFaceMesh3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h deleted file mode 100644 index 4c075d6a022824fbd59bc15f844b48bc80221f10..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBTRIANGLE3DCREATOR_H -#define GBTRIANGLE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -class GbTriangle3DCreator : public GbObject3DCreator -{ -public: - static GbTriangle3DCreator* getInstance() - { - static GbTriangle3DCreator instance; - return &instance; - } - - GbTriangle3D* createGbObject3D() { return new GbTriangle3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangle3D"; } - std::string toString() { return "GbTriangle3DCreator"; } - -private: - GbTriangle3DCreator( const GbTriangle3DCreator& ); //no copy allowed - const GbTriangle3DCreator& operator=( const GbTriangle3DCreator& ); //no copy allowed - GbTriangle3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangle3DCreator::getInstance()), CAB_GbTriangle3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp b/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp deleted file mode 100644 index bfb42296037a0b86bc374b083250e2889fa9e5ee..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> -#include <algorithm> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromFile(string filename, string meshName) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); - - if ( !ext.compare("ply") ) return GbTriangularMesh3DCreator::readMeshFromPLYFile(filename, meshName); - else if( !ext.compare("stl") ) return GbTriangularMesh3DCreator::readMeshFromSTLFile(filename, meshName); - else if( !ext.compare("gts") ) return GbTriangularMesh3DCreator::readMeshFromGTSFile(filename, meshName); - else if( !ext.compare("raw") ) return GbTriangularMesh3DCreator::readMeshFromRAWFile(filename, meshName); - else throw UbException(UB_EXARGS,"unrecognized fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(string filename, string meshName) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriangularMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(UbFileInput* in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - //int nr=0; - string dummy; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node1 = new GbPoint3D(x,y,z); nodes->push_back(node1); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node2 = new GbPoint3D(x,y,z); nodes->push_back(node2); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node3 = new GbPoint3D(x,y,z); nodes->push_back(node3); - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - } - return new GbTriangularMesh3D(meshName, nodes, triangles); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(string inputfile, string meshName) -{ - UbFileInputASCII gtlfile(inputfile); - if(!gtlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromGTSFile(>lfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int edgesize = in->readInteger(); - int trianglesize = in->readInteger(); - UBLOG(logINFO,"node-/edge-/trianglesize: "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<edgesize;i++) - { - in->readLine(); - point1=in->readInteger()-1; - point2=in->readInteger()-1; - edges->push_back(new GbLine3D((*nodes)[point1],(*nodes)[point2])); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - //triangles->push_back(new GbTriangle3D((*nodes)[point1-1],(*nodes)[point2-1],(*nodes)[point3-1])); - triangles->push_back(new GbTriangle3D((GbPoint3D*)(*edges)[point1-1]->getPoint1(),(GbPoint3D*)(*edges)[point2-1]->getPoint1(),(GbPoint3D*)(*edges)[point3-1]->getPoint1())); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(string inputfile, string meshName) -{ - UbFileInputASCII plyfile(inputfile); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(UbFileInput *in, string meshName) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int nr=0; - string dummy; - int numVertices, numFaces; - GbPoint3D *node = NULL; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numVertices = in->readInteger(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numFaces = in->readInteger(); in->readLine(); - in->readLine(); - in->readLine(); - UBLOG(logINFO,"Number of vertices "<<numVertices); - UBLOG(logINFO,"Number of faces "<<numFaces); - for (int i=0; i<numVertices; i++) - { - x = in->readDouble(); - y = in->readDouble(); - z = in->readDouble(); - // cout<<x<<y<<z; - // in->readString(); in->readString(); in->readString(); - in->readLine(); - node = new GbPoint3D(x,y,z); nodes->push_back(node); - } - nr=0; - - for (int i=0; i<numFaces; i++) - { - in->readString(); - int j,k,l; - j = in->readInteger(); k = in->readInteger(); l = in->readInteger(); - node1 = (*nodes)[j]; - node2 = (*nodes)[k]; - node3 = (*nodes)[l]; - in->readLine(); - nr++; - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - } - - return(new GbTriangularMesh3D(meshName, nodes, triangles)); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(string inputfile, string meshName) -{ - UbFileInputASCII stlfile(inputfile); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromRAWFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int trianglesize = in->readInteger(); - int edgesize = 0; - UBLOG(logINFO,"node-/edge-/trianglesize "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - triangles->push_back(new GbTriangle3D((*nodes)[point1],(*nodes)[point2],(*nodes)[point3])); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h deleted file mode 100644 index d090115e321256764dae67df8afcad2e07df2a7e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef GBTRIANGULARMESH3DCREATOR_H -#define GBTRIANGULARMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriangularMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriangularMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriangularMesh3DCreator* getInstance() - { - static GbTriangularMesh3DCreator instance; - return &instance; - } - - static GbTriangularMesh3D* readMeshFromFile(std::string filename, std::string meshName=""); - - static GbTriangularMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(std::string inputFile, std::string meshName); - - static GbTriangularMesh3D* readMeshFromSTLFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(UbFileInput* infile, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(UbFileInput* infile, std::string meshName); - - - GbTriangularMesh3D* createGbObject3D() { return new GbTriangularMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangularMesh3D"; }; - std::string toString() { return "GbTriangularMesh3DCreator"; } - -#ifdef CAB_QT - - GbTriangularMesh3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - mesh->deleteRedundantNodes(); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriangularMesh3DCreator( const GbTriangularMesh3DCreator& ); //no copy allowed - const GbTriangularMesh3DCreator& operator=( const GbTriangularMesh3DCreator& ); //no copy allowed - GbTriangularMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangularMesh3DCreator::getInstance()), CAB_GbTriangularMesh3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp b/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp deleted file mode 100644 index 52b09e9aeca68ec4f46e49edff4301782a690456..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h> -#include <numerics/geometry3d/GbVoxelMatrix3D.h> -#include <basics/utilities/UbFileInputASCII.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromRawFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, ios::end ); //Ende springen - fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, ios::beg ); //An den Anfang springen - if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize"); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - float val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - in.read((char*)&val,sizeof(float)); - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - UbFileInputASCII in(filename); - //ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - //in.readLine(); !!!manchmal hat das vti file noch die xml version dabei ... - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - int val; - int u=0; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - val = in.readInteger(); - - //u++; if(u>125000) UBLOG(logINFO,"val:"<<u<<" "<<val); - - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} - diff --git a/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h b/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h deleted file mode 100644 index 33e77c6bc8c8a434629f947f28c36ded6e8d2d86..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBVOXELMATRIX3DCREATOR_H -#define GBVOXELMATRIX3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbVoxelMatrix3D.h> -#include <iostream> -#include <fstream> - -class GbVoxelMatrix3DCreator : public GbObject3DCreator -{ -public: - enum DataType {t8bit, t16bit}; -public: - static GbVoxelMatrix3DCreator* getInstance() - { - static GbVoxelMatrix3DCreator instance; - return &instance; - } - - GbVoxelMatrix3D* createGbObject3D() { return new GbVoxelMatrix3D(); } - GbVoxelMatrix3D* createFromRawFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - GbVoxelMatrix3D* createFromVtiASCIIFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - - std::string getGbObject3DTypeID() { return "GbVoxelMatrix3D"; }; - std::string toString() { return "GbVoxelMatrix3DCreator"; } - -private: - GbVoxelMatrix3DCreator() : GbObject3DCreator() {} - - GbVoxelMatrix3DCreator( const GbVoxelMatrix3DCreator& ); //no copy allowed - const GbVoxelMatrix3DCreator& operator=( const GbVoxelMatrix3DCreator& ); //no copy allowed - -public: - template< typename T > - GbVoxelMatrix3D* createFromRawFile(std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) - { - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - - std::ifstream in(filename.c_str(), std::ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, std::ios::end ); //Ende springen - std::fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, std::ios::beg ); //An den Anfang springen - long m_size = (nodesX1*nodesX2*nodesX3)*sizeof(T); - if( m_size != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize: " + UbSystem::toString(length)); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - T val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - in.read((char*)&val,sizeof(T)); - //if( !UbMath::equal(val, 0.0f) ) - //if( UbMath::greater(val, (T)threshold) ) - if(val > (T)threshold) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; - } -}; - - - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbVoxelMatrix3DCreator::getInstance()), CAB_GbVoxelMatrix3DCreator); -#endif - -#endif //GBVOXELMATRIX3DCREATOR_H diff --git a/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt b/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt deleted file mode 100644 index 153431958236b26fc67f1103d742ae8169364653..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -INCLUDE("../../../../CMakeCABMacros.txt") -INCLUDE("../../../../CMakeSetCompilerFlags.txt") - -CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN") -SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake") - -IF(CAB_MACHINE AND EXISTS ${CMAKE_CONFIG_FILE} ) - - PROJECT(geo3dCellCutTests) - - SET(EXECUTABLE_NAME geo3dCellCutTests) - - #erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben) - INCLUDE(${CMAKE_CONFIG_FILE}) - - ################################################################# - ### PACKAGES ### - ################################################################# - INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) - - ################################################################# - ### OWN DEFINES ### - ################################################################# - FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - - - SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) - SOURCE_GROUP(example FILES ${SPECIFIC_FILES}) - - SET_COMPILER_SPECIFIC_FLAGS(${CAB_COMPILER} BINARY) - - ################################################################# - ### ADDITIONAL_MAKE_CLEAN_FILES ### - ################################################################# - SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}") - - ################################################################# - ### EXCECUTABLE ### - ################################################################# - ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} ) - - ################################################################# - ### ADDITIONAL LINK PROPERTIES ### - ################################################################# - IF(CAB_ADDITIONAL_LINK_FLAGS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS}) - ENDIF(CAB_ADDITIONAL_LINK_FLAGS) -ELSE() - IF(CAB_MACHINE) - MESSAGE("CAB_MACHINE error - following file is missing: \n ${CMAKE_CONFIG_FILE}") - ELSE() - MESSAGE("check CAB_MACHINE!!!") - ENDIF() -ENDIF() \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp b/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp deleted file mode 100644 index 911bc6965a1ee38a28b45d5e0e9f6874a2aa564d..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbSphere3D.h> -#include <numerics/geometry3d/GbCylinder3D.h> - -int main(int argc, char** argv) -{ - GbSphere3D test(10,10,10,8); - - bool cutSp1 /*false*/= test.isCellCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere - bool cutSp2 /*true */= test.isCellCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt sphere - bool cutSp3 /*true */= test.isCellCuttingGbObject3D(0,0,0,10,10,10); //cell cutted sphere - bool cutSp4 /*false*/= test.isCellCuttingGbObject3D(100,100,100,101,101,101); //cell nix sphere - - - bool cutInsSp1 /*true */= test.isCellInsideOrCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere - bool cutInsSp2 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt sphere - bool cutInsSp3 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,10,10,10); //cell cutted sphere - bool cutInsSp4 /*false*/= test.isCellInsideOrCuttingGbObject3D(100,100,100,101,101,101); //cell nix sphere - - GbCuboid3D test1(0,0,0,10,10,10); - - bool cutCu1 /*false*/= test1.isCellCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutCu2 /*true */= test1.isCellCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt cube - bool cutCu3 /*true */= test1.isCellCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cube - bool cutCu4 /*false*/= test1.isCellCuttingGbObject3D(12,12,12,15,15,15); //cell nix cube - - bool cutInsCu1 /*true */= test1.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutInsCu2 /*true */= test1.isCellInsideOrCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt cube - bool cutInsCu3 /*true */= test1.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cube - bool cutInsCu4 /*false*/= test1.isCellInsideOrCuttingGbObject3D(12,12,12,15,15,15); //cell nix cube - - GbCylinder3D test2( 0,0,0, 20, 0, 0, 10); - - bool cutCy1 /*false*/ = test2.isCellCuttingGbObject3D(1,-1,-1,4,1,1); //cell komplett IN cyl - bool cutCy2 /*true */ = test2.isCellCuttingGbObject3D(10,0,0,15,12,11); //cell umhuellt cyl - bool cutCy3a /*true */ = test2.isCellCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cyl im kreisbreich - bool cutCy3b /*true */ = test2.isCellCuttingGbObject3D(-5,-1,-1,5,1,1); //cell cutted cyl am stirn - bool cutCy4 /*false*/= test2.isCellCuttingGbObject3D(-10,-10,-10,-5,-5,-5); //cell nix cyl - - - bool cutInsCy1 /*true */= test2.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutInsCy2 /*true */= test2.isCellInsideOrCuttingGbObject3D(10,0,0,15,12,11); //cell umhuellt cyl - bool cutInsCy3a /*true */= test2.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cyl im kreisbreich - bool cutInsCy3b /*true */= test2.isCellInsideOrCuttingGbObject3D(-5,-1,-1,5,1,1); //cell cutted cube - bool cutInsCy4 /*false*/= test2.isCellInsideOrCuttingGbObject3D(-10,-10,-10,-5,-5,-5); //cell nix cube -} \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt deleted file mode 100644 index 37e3f930aa4a3c9ca9ce5d96206c2269e67636ef..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt +++ /dev/null @@ -1,140 +0,0 @@ -SET(SOURCE_ROOT $ENV{CAB_DIR} CACHE PATH "(e.g. d:/temp/source)" ) -STRING(REGEX REPLACE "\\\\" "/" SOURCE_ROOT ${SOURCE_ROOT}) # "\" --> "/" - -IF(EXISTS ${SOURCE_ROOT}) - IF(EXISTS ${SOURCE_ROOT}/basics) - - INCLUDE(${SOURCE_ROOT}/CMakeCABMacros.txt) - - PROJECT (STL2INP) - SET(EXECUTABLE_NAME stl2inp) - - ################################################################# - ### PACKAGES ### - ################################################################# - - INCLUDE(${SOURCE_ROOT}/basics/objects/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/basics/relation/CMakeLists.txt) - - - INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/creator/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/octree/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/octree/facette/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/quadtree/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/quadtree/nodeadaptation/CMakeLists.txt) - - - ################################################################# - ### OWN DEFINES ### - ################################################################# - # ADD_DEFINITIONS( -DCAB_QT ) - # ADD_DEFINITIONS( -DCAB_QTONLY ) - ADD_DEFINITIONS( -DMEMPOOL_A2PIIOCTNODEVD) - SET(SPECIFIC_FILES main.cpp stl2inp.h stl2inp.cpp QDefineUniformMesh.h QDefineUniformMesh.cpp) - SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) - SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES}) - - IF(WIN32) - ADD_CXX_FLAGS("/wd4996") - ELSE(WIN32) - ADD_CXX_FLAGS("-O3 -mcpu=athlon-4 -fomit-frame-pointer -finline-functions -funroll-all-loops") - ENDIF(WIN32) - - - - ################################################################# - ### QT SPECIFIC (only has effects if a QT source is included) ### - ################################################################# - #QT specific - SET(NEED_QT "YES") - INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt) - - IF(QT_FOUND) - INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} - ${QT_INCLUDE_PATH} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ) - LINK_LIBRARIES ( ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) - ADD_DEFINITIONS( ${QT_DEFINITIONS}) - ELSE(QT_FOUND) - IF(${NEED_QT} MATCHES "YES") - MESSAGE("Ups\nAt least one package needs Qt!\nPlease check Qt settings\n(e.g. librarys within Advanced Values)") - ENDIF(${NEED_QT} MATCHES "YES") - - - ENDIF(QT_FOUND) - - IF(QT_FOUND) - SET(SUBDIRPATH numerics/geometry3d/examples/stl2inp) - SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH}) - - ################################################################ - ### Qt4 UI FILES ### - ################################################################ - FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui) #collect ui files - QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES}) #wrap ui files - REMOVE(TEMP_FILES ${OUTFILES} ) - SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} ) - - #make subfolders for VS with new files - SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES}) - - IF(WIN32) - SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES}) - SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES}) - ENDIF(WIN32) - - ################################################################ - ### Qt4 HEADERS TO BE MOCED ### - ################################################################ - MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC}) - SET(MOC_FILES ) #empty MOC_FILES - #SET(MOC_CLASSES ${CURRENT_DIR}/stl2inp.h QDefineUniformMesh.ui ) - - QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES}) - REMOVE(TEMP_FILES ${MOC_FILES}) - SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES}) - SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES}) - - SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES}) - - ENDIF(QT_FOUND) - - - ################################################################# - ### ADDITIONAL_MAKE_CLEAN_FILES ### - ################################################################# - SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}") - - ################################################################# - ### EXCECUTABLE ### - ################################################################# - ADD_EXECUTABLE( ${EXECUTABLE_NAME} - ${ALL_SOURCES} - ) - - - ################################################################# - ### ADDITIONAL LINK PROPERTIES ### - ################################################################# - IF(CAB_ADDITIONAL_LINK_FLAGS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS}) - ENDIF(CAB_ADDITIONAL_LINK_FLAGS) - - ELSE(EXISTS ${SOURCE_ROOT}/basics) - MESSAGE("Set Path to \"source\" directory at\nSOURCE_ROOT\nis not correct") - ENDIF(EXISTS ${SOURCE_ROOT}/basics) -ELSE(EXISTS ${SOURCE_ROOT}) - SET(SOURCE_ROOT "CAB_DIR NOT FOUND" CACHE PATH "(e.g. d:/temp/source)" FORCE) - MESSAGE("Please Set Path to \"source\" directory at\nSOURCE_ROOT\n(e.g. D:/temp/source)") -ENDIF(EXISTS ${SOURCE_ROOT}) diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp deleted file mode 100644 index 278d021653712124e5f0bfb40eb5aaffd4291754..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "./QDefineUniformMesh.h" -#include <QtGui/QFileDialog> -#include <QString> -#include <QFile> -#include <QMessageBox> -#include <cstdio> - - -QDefineUniformMesh::QDefineUniformMesh(QWidget *parent, Qt::WFlags flags) -{ - ui.setupUi(this); -} - -QDefineUniformMesh::~QDefineUniformMesh() -{ - -} diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h deleted file mode 100644 index f470a8edce55e67e93d17cd5de52e0bebef9a281..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QDEFINEUNIFORMMESH_H -#define QDEFINEUNIFORMMESH_H - -#include <QtGui/QDialog> -#include "./QDefineUniformMeshUI.h" - -class QDefineUniformMesh : public QDialog -{ - Q_OBJECT - -public: - QDefineUniformMesh(QWidget *parent = 0, Qt::WFlags flags = 0); - ~QDefineUniformMesh(); - - void setStartLevel(int startLevel) { ui.spinBox_startLevel->setValue(startLevel); } - void setStopLevel(int stopLevel) { ui.spinBox_stopLevel->setValue(stopLevel); } - void setDelta(double delta) { ui.doubleSpinBox_delta->setValue(delta); } - void setNX1(int nx1) { ui.spinBox_nx1->setValue(nx1); } - void setNX2(int nx2) { ui.spinBox_nx2->setValue(nx2); } - void setNX3(int nx3) { ui.spinBox_nx3->setValue(nx3); } - - int getStartLevel() { return ui.spinBox_startLevel->value(); } - int getStopLevel() { return ui.spinBox_stopLevel->value(); } - double getDelta() { return ui.doubleSpinBox_delta->value(); } - int getNX1() { return ui.spinBox_nx1->value(); } - int getNX2() { return ui.spinBox_nx2->value(); } - int getNX3() { return ui.spinBox_nx3->value(); } - -private: - Ui::QDefineUniformMesh ui; - -//private slots: -}; - -#endif // QDEFINEUNIFORMMESH_H diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui deleted file mode 100644 index c03b2513f5b64cfb9a4e1a5ea3ce9cbab96e11b2..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui +++ /dev/null @@ -1,258 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QDefineUniformMesh</class> - <widget class="QDialog" name="QDefineUniformMesh" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>180</width> - <height>220</height> - </rect> - </property> - <property name="windowTitle" > - <string>Define Mesh Parameters</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="toolTip" > - <string>Stop-Level der Verfeinerung</string> - </property> - <property name="text" > - <string>Stop-Level</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_stopLevel" /> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_6" > - <property name="toolTip" > - <string>Start-Level der Verfeinerung</string> - </property> - <property name="text" > - <string>Start-Level</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_startLevel" /> - </item> - </layout> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_2" > - <property name="toolTip" > - <string>Größe der Zellen</string> - </property> - <property name="text" > - <string>Delta</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="doubleSpinBox_delta" /> - </item> - </layout> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>131</width> - <height>31</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="okButton" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_3" > - <property name="toolTip" > - <string>Anzahl Zellen in X-Richtung</string> - </property> - <property name="text" > - <string>nx1</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx1" /> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_4" > - <property name="toolTip" > - <string>Anzahl Zellen in Y-Richtung</string> - </property> - <property name="text" > - <string>nx2</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx2" /> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_5" > - <property name="toolTip" > - <string>Anzahl Zellen in Z-Richtung</string> - </property> - <property name="text" > - <string>nx3</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx3" /> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <pixmapfunction></pixmapfunction> - <resources/> - <connections> - <connection> - <sender>okButton</sender> - <signal>clicked()</signal> - <receiver>QDefineUniformMesh</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>286</x> - <y>257</y> - </hint> - <hint type="destinationlabel" > - <x>96</x> - <y>254</y> - </hint> - </hints> - </connection> - <connection> - <sender>cancelButton</sender> - <signal>clicked()</signal> - <receiver>QDefineUniformMesh</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>369</x> - <y>257</y> - </hint> - <hint type="destinationlabel" > - <x>179</x> - <y>282</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp deleted file mode 100644 index 17bf6a44174af3acbdd3d4d7a259235767b197ed..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <iostream> -#include <cstdlib> - -#include <QtGui/QApplication> -#include "./stl2inp.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - STL2INP w; - - w.show(); - a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - return a.exec(); -} diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp deleted file mode 100644 index 6d5e95f17a269cd716170f9a0a66d0b64273269b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include "stl2inp.h" -#include <QtGui/QFileDialog> -#include <QString> -#include <QFile> -#include <QMessageBox> -#include <cstdio> - -#include "./QDefineUniformMesh.h" - -#include "./../../../../../source/basics/utilities/UbFileInputASCII.h" -#include "./../../../../../source/basics/utilities/UbFileOutputASCII.h" -#include "./../../../../../source/basics/utilities/UbFileOutputBinary.h" -#include "./../../../../../source/numerics/geometry3d/GbTriangularMesh3D.h" -#include "./../../../../../source/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h" -#include "./../../../../../source/numerics/geometry3D/CoordinateTransformation3D.h" -#include "./../../../../../source/basics/utilities/UbTiming.h" -#include "./../../../../../source/octree/facette/OctFacettenGrid2.h" - -STL2INP::STL2INP(QWidget *parent, Qt::WFlags flags) -: QMainWindow(parent, flags) -{ - ui.setupUi(this); - startLevel = 0; - stopLevel = 3; - delta = 10.00; - nx1 = 30; - nx2 = 15; - nx3 = 5; - -} - -STL2INP::~STL2INP() -{ - -} - -void STL2INP::on_pBtn_Input_pressed() -{ - QString s = QFileDialog::getOpenFileName( - this, - "Choose a file", - "E:/", - "STL-Files (*.stl)"); - if(s != ""){ - ui.lineEdit_In->setText(s); - ui.statusBar->showMessage("Input-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Input-File: No file found", 3000); - -} - -void STL2INP::on_lineEdit_In_returnPressed(){ - QString s = ui.lineEdit_In->text(); - if(s != ""){ - if(!s.endsWith(".stl",Qt::CaseSensitivity(false))) - { - s.append(".stl"); - ui.lineEdit_In->setText(s); - } - if(QFile::exists(s)) - ui.statusBar->showMessage("Inputput-File: File found", 3000); - else - ui.statusBar->showMessage("Input-File: File does not exist", 3000); - } - else - ui.statusBar->showMessage("Input-File: no Filename", 3000); -} - -void STL2INP::on_pBtn_Output_pressed(){ - QString s = QFileDialog::getSaveFileName( - this, - "Choose a filename to save under", - "E:/", - "AVS-File (*.inp)"); - if(s != ""){ - ui.lineEdit_Out->setText(s); - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_lineEdit_Out_returnPressed(){ - QString s = ui.lineEdit_Out->text(); - if(s != ""){ - if(!s.endsWith(".inp",Qt::CaseSensitivity(false))) - { - s.append(".inp"); - ui.lineEdit_Out->setText(s); - } - if (QFile::exists(s)) - if(QMessageBox::question(this, - tr("Overwrite File? -- Application Name"), - tr("A file called %1 already exists." - "Do you want to overwrite it?") - .arg(s), - tr("&Yes"), tr("&No"), - QString(), 0, 1)) - ui.lineEdit_Out->setText(""); - else - ui.statusBar->showMessage("Output-File: overwrite existing File", 3000); - else - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_pBtn_Output_2_pressed(){ - QString s = QFileDialog::getSaveFileName( - this, - "Choose a filename to save under", - "E:/", - "Data-File (*.dat)"); - if(s != ""){ - ui.pBtn_EditMesh->setEnabled(true); - ui.lineEdit_Out_2->setText(s); - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - on_pBtn_EditMesh_pressed(); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_lineEdit_Out_2_returnPressed(){ - QString s = ui.lineEdit_Out_2->text(); - if(s != ""){ - ui.pBtn_EditMesh->setEnabled(true); - if(!s.endsWith(".dat",Qt::CaseSensitivity(false))) - { - s.append(".dat"); - ui.lineEdit_Out_2->setText(s); - } - if (QFile::exists(s)) - if(QMessageBox::question(this, - tr("Overwrite File? -- Application Name"), - tr("A file called %1 already exists." - "Do you want to overwrite it?") - .arg(s), - tr("&Yes"), tr("&No"), - QString(), 0, 1)){ - ui.lineEdit_Out_2->setText(""); - ui.pBtn_EditMesh->setEnabled(false); - } - else{ - ui.statusBar->showMessage("Output-File: overwrite existing File", 3000); - ui.pBtn_EditMesh->setEnabled(true); - } - else{ - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - on_pBtn_EditMesh_pressed(); - } - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_pBtn_Convert_pressed(){ - if(ui.lineEdit_In->text() == "") - QMessageBox::warning(this,"ERROR", "No Input-File defined!", - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - else if(ui.lineEdit_Out->text() == "" && ui.lineEdit_Out_2->text() == "") - QMessageBox::warning(this,"ERROR", "No Output-File defined!", - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - else - { - UbFileInputASCII *fileInput = new UbFileInputASCII(std::string(ui.lineEdit_In->text().toAscii())); - GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(fileInput, "Cube"); - ui.statusBar->showMessage("Input-File was read", 3000); - delete fileInput; - cout<<mesh->toString()<<endl; - if(ui.checkBox_writeAVS->isChecked()){ - if(ui.checkBox_Binary->isChecked()){ - UbFileOutputBinary *fileOutput_AVS = new UbFileOutputBinary(std::string(ui.lineEdit_Out->text().toAscii())); - mesh->writeAVSMesh(fileOutput_AVS); - delete fileOutput_AVS; - } - else{ - UbFileOutputASCII *fileOutput_AVS = new UbFileOutputASCII(std::string(ui.lineEdit_Out->text().toAscii())); - mesh->writeAVSMesh(fileOutput_AVS); - delete fileOutput_AVS; - } - ui.statusBar->showMessage("wrote AVS-Output-File"); - } - if(ui.checkBox_writeUM->isChecked()){ - cout<<"MinX:"<<mesh->getX1Minimum()<<endl; - cout<<"MaxX:"<<mesh->getX1Maximum()<<endl; - cout<<"MinY:"<<mesh->getX2Minimum()<<endl; - cout<<"MaxY:"<<mesh->getX2Maximum()<<endl; - cout<<"MinZ:"<<mesh->getX3Minimum()<<endl; - cout<<"MaxZ:"<<mesh->getX3Maximum()<<endl; - ui.statusBar->showMessage("start Writing Uniform-Mesh-File"); - double minX = 0.0; - double minY = 0.0; - double minZ = 0.0; - - CoordinateTransformation3D *trafo = new CoordinateTransformation3D(minX, minY, minZ, delta, delta, delta); - - UbTiming time; - time.initTiming(); - time.startTiming(); - - ui.statusBar->showMessage("start Building FacetteGrid", 3000); - OctFacettenGrid2 *facettegrid = new OctFacettenGrid2("FacettenGrid", nx1, nx2, nx3, startLevel, stopLevel, mesh, trafo); - ui.statusBar->showMessage("end Building FacetteGrid", 3000); - - UbFileOutputASCII out("E:/DATA/test.inp"); - facettegrid->writeCellsToAVS(&out); - - time.endTiming(); - cout<<"Dauer:"<<time.getDuration()<<endl; - cout<<"Number of cells:"<<facettegrid->getNumberOfCells()<<endl; - cout<<"after generation ..."<<endl<<endl; - double mydouble=0.0; - - time.initTiming(); - time.startTiming(); - ui.statusBar->showMessage("start writing", 3000); - UbFileOutputASCII *fileOutput_UM = new UbFileOutputASCII(std::string(ui.lineEdit_Out_2->text().toAscii())); - facettegrid->writeToUniformGridFile2(fileOutput_UM); - delete fileOutput_UM; - time.endTiming(); - cout<<"Dauer:"<<time.getDuration()<<endl; - int number = (int)facettegrid->getCells()->size(); - delete trafo; - delete mesh; - delete facettegrid; - cout<<"Ready!!!"<<endl; - ui.statusBar->showMessage("wrote Unstructured-Mesh Output-File", 3000); - } - } -} - -void STL2INP::on_checkBox_stateChanged(int) -{ - -} - -void STL2INP::on_pBtn_EditMesh_pressed() -{ - QDefineUniformMesh *meshdef = new QDefineUniformMesh(this); - meshdef->setStartLevel(startLevel); - meshdef->setStopLevel(stopLevel); - meshdef->setDelta(delta); - meshdef->setNX1(nx1); - meshdef->setNX2(nx2); - meshdef->setNX3(nx3); - meshdef->exec(); - - startLevel = meshdef->getStartLevel(); - stopLevel = meshdef->getStopLevel(); - //cout<<"Start-Level: "<<startLevel<<" Stop-Level: "<<stopLevel<<endl; - delta = meshdef->getDelta(); - //cout<<"Delta: "<<delta<<endl; - nx1 = meshdef->getNX1(); - nx2 = meshdef->getNX2(); - nx3 = meshdef->getNX3(); - //cout<<"nx1: "<<nx1<<" nx2: "<<nx2<<" nx3: "<<nx3<<endl; - delete meshdef; -} \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h deleted file mode 100644 index a48fd463a7bc7ebb9ad0a16b83c78368365d5630..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef STL2INP_H -#define STL2INP_H - -#include <QtGui/QMainWindow> -#include <QtGui/QProgressBar> -#include <QTimer> -#include "stl2inpUI.h" - -class STL2INP : public QMainWindow -{ - Q_OBJECT - -public: - STL2INP(QWidget *parent = 0, Qt::WFlags flags = 0); - ~STL2INP(); - - int startLevel, stopLevel; - double delta; - int nx1, nx2, nx3; - -private: - Ui::STL2INPClass ui; - - private slots: - void on_checkBox_stateChanged(int); - void on_pBtn_Input_pressed(); - void on_pBtn_Output_pressed(); - void on_pBtn_Output_2_pressed(); - void on_pBtn_Convert_pressed(); - void on_lineEdit_In_returnPressed(); - void on_lineEdit_Out_returnPressed(); - void on_lineEdit_Out_2_returnPressed(); - void on_pBtn_EditMesh_pressed(); -}; - -#endif // STL2INP_H diff --git a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.ui b/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.ui deleted file mode 100644 index 28d3ab49ca511a249430e804088b461320d72d0a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.ui +++ /dev/null @@ -1,452 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>STL2INPClass</class> - <widget class="QMainWindow" name="STL2INPClass" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>350</height> - </rect> - </property> - <property name="windowTitle" > - <string>STL2INP</string> - </property> - <property name="statusTip" > - <string>...</string> - </property> - <widget class="QWidget" name="centralWidget" > - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="4" column="0" colspan="2" > - <widget class="QGroupBox" name="groupBox_2" > - <property name="title" > - <string>Output-Files</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QCheckBox" name="checkBox_writeAVS" > - <property name="text" > - <string>write AVS-File</string> - </property> - </widget> - </item> - <item row="0" column="1" colspan="3" > - <widget class="QCheckBox" name="checkBox_Binary" > - <property name="text" > - <string>write *.inp to Binary</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QCheckBox" name="checkBox_writeUM" > - <property name="text" > - <string>write Uniform-Mesh-File</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="3" > - <widget class="QLineEdit" name="lineEdit_Out" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - <item row="5" column="3" > - <widget class="QPushButton" name="pBtn_Output_2" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="3" > - <widget class="QLineEdit" name="lineEdit_Out_2" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - <item row="1" column="3" > - <widget class="QPushButton" name="pBtn_Output" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item rowspan="2" row="2" column="0" colspan="4" > - <widget class="Line" name="line" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item rowspan="2" row="3" column="2" colspan="2" > - <widget class="QPushButton" name="pBtn_EditMesh" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>51</width> - <height>20</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>51</width> - <height>20</height> - </size> - </property> - <property name="text" > - <string>Edit Mesh</string> - </property> - </widget> - </item> - <item row="4" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="label_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>14</pointsize> - <weight>75</weight> - <italic>false</italic> - <bold>true</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>STL2INP</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="6" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pushButton_4" > - <property name="text" > - <string>EXIT</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtn_Convert" > - <property name="text" > - <string>Convert</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="5" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>21</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" > - <widget class="QGroupBox" name="groupBox" > - <property name="title" > - <string>Input-File</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QPushButton" name="pBtn_Input" > - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLineEdit" name="lineEdit_In" > - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QStatusBar" name="statusBar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>331</y> - <width>400</width> - <height>19</height> - </rect> - </property> - </widget> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction></pixmapfunction> - <tabstops> - <tabstop>lineEdit_In</tabstop> - <tabstop>pBtn_Input</tabstop> - <tabstop>lineEdit_Out</tabstop> - <tabstop>pBtn_Output</tabstop> - <tabstop>checkBox_Binary</tabstop> - <tabstop>pBtn_Convert</tabstop> - <tabstop>pushButton_4</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>pushButton_4</sender> - <signal>clicked()</signal> - <receiver>STL2INPClass</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel" > - <x>82</x> - <y>320</y> - </hint> - <hint type="destinationlabel" > - <x>222</x> - <y>349</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeAVS</sender> - <signal>clicked(bool)</signal> - <receiver>lineEdit_Out</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>43</x> - <y>189</y> - </hint> - <hint type="destinationlabel" > - <x>99</x> - <y>210</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeAVS</sender> - <signal>clicked(bool)</signal> - <receiver>pBtn_Output</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>130</x> - <y>189</y> - </hint> - <hint type="destinationlabel" > - <x>380</x> - <y>209</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeUM</sender> - <signal>clicked(bool)</signal> - <receiver>lineEdit_Out_2</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>74</x> - <y>237</y> - </hint> - <hint type="destinationlabel" > - <x>88</x> - <y>258</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeUM</sender> - <signal>clicked(bool)</signal> - <receiver>pBtn_Output_2</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>152</x> - <y>237</y> - </hint> - <hint type="destinationlabel" > - <x>380</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_In</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Input</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>236</x> - <y>105</y> - </hint> - <hint type="destinationlabel" > - <x>345</x> - <y>98</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_Out</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Output</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>302</x> - <y>203</y> - </hint> - <hint type="destinationlabel" > - <x>362</x> - <y>202</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_Out_2</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Output_2</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>256</x> - <y>249</y> - </hint> - <hint type="destinationlabel" > - <x>365</x> - <y>253</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt deleted file mode 100644 index fb2d6a4735aec73c8966db5d20f5b8ac29612b9e..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt +++ /dev/null @@ -1,37 +0,0 @@ -SET(SUBDIRPATH numerics/geometry3d/fem) -SET(OPTION_LABEL BUILD_GEO3D_FEM) - -SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH}) - -OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON) -IF(${OPTION_LABEL}) - SET(TEMP_FILES "") - FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h ) - FILE(GLOB CPP_FILES ${CURRENT_DIR}/*.cpp) - - - SET(TEMPO_FILES ${HEADER_FILES} ${CPP_FILES}) - IF(NOT ADHOC) - FILE(GLOB ADHOC_FILES ${CURRENT_DIR}/*Adhoc* ) - REMOVE(TEMPO_FILES ${ADHOC_FILES} ) - ENDIF(NOT ADHOC) - - IF(NOT EIGENVALUE) - FILE(GLOB EIGENVALUE_FILES ${CURRENT_DIR}/*Eigen* ) - REMOVE(TEMPO_FILES ${EIGENVALUE_FILES} ) - ENDIF(NOT EIGENVALUE) - -IF(CAB_PACKAGE_DEFINTIONS) - SET_SOURCE_FILES_PROPERTIES(${CPP_FILES} PROPERTIES COMPILE_FLAGS ${CAB_PACKAGE_DEFINTIONS}) -ENDIF(CAB_PACKAGE_DEFINTIONS) - - SET(ALL_SOURCES ${ALL_SOURCES} ${TEMPO_FILES}) - - IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES) - STRING(REGEX REPLACE "/" "\\\\" SG_PATH ${SUBDIRPATH}) - SOURCE_GROUP(${SG_PATH} FILES ${TEMPO_FILES}) - ELSE(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES) - SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMPO_FILES}) - ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES) - -ENDIF(${OPTION_LABEL}) diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp deleted file mode 100644 index 86b7cc239d0a33da9db6a6263d8959863bcfa0da..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "./FeAdhocTriFaceMesh3D.h" - -#include "./../GbPoint3D.h" -#include "./../GbTriangle3D.h" -#include "./../GbTriangularMesh3D.h" - -#include "./../../../basics/utilities/UbFileOutputASCII.h" -#include "./../../../basics/utilities/UbLogger.h" - -/*====================================================*/ -FeAdhocTriFaceMesh3D::FeAdhocTriFaceMesh3D():FeTriFaceMesh3D() -{ -} -/*====================================================*/ -FeAdhocTriFaceMesh3D::FeAdhocTriFaceMesh3D(std::string name, Mesh* mesh):FeTriFaceMesh3D() -{ - this->mesh = mesh; - this->setName(name); - - std::cout << "FeAdhocTriFaceMesh3D:Konstruktor !!!"<<std::endl; - std::cout << "num vertices: " << mesh->VL->nitem << ", num triangles: " << mesh->TL->nitem - << ", num quads: " << mesh->QL->nitem << std::endl; - - // this->writeAdhoCMeshForStefan("/scratch/geller/StudienMitAdhoC3D/mesh.inp"); - this->adhocVertices = new vector< ::Vertex*>; - - List *vertexlist = mesh->VL; - List *elementlist = mesh->TL; - - ListItem* LI; - ListItem* LI2; - Tri* triangle; - // double z1, z2, z3; - int id1, id2, id3; - ::Vertex *v1, *v2, *v3; - - //if (mesh->VL->status==open) close_Vertex_List(mesh->VL); - - FOR_ALL(vertexlist->first, LI, 0) - { - ::Vertex* V = get_Vertex(LI); - this->nodes->push_back(GbTriFaceMesh3D::Vertex((float)V->x, (float)V->y, (float)V->z)); - this->adhocVertices->push_back(V); - } - int countTris=0; - int fred=0; - FOR_ALL(elementlist->first, LI, 0) - { - triangle = get_Tri(LI); - if(triangle==NULL) UBLOG(logINFO, "hugo - dreieck ist NULL"); - v1 = triangle->V[0]; - v2 = triangle->V[1]; - v3 = triangle->V[2]; - int count=0; - id1=-1; id2=-1; id3=-1; - FOR_ALL(vertexlist->first, LI2, 0) - { - ::Vertex* V = get_Vertex(LI2); - if(v1==V) id1=count; - if(v2==V) id2=count; - if(v3==V) id3=count; - if((id1!=-1) && (id2!=-1) && (id3!=-1)) - { - break; - } - count++; - } - // this->triangles->push_back(GbTriFaceMesh3D::TriFace(v1->id, v2->id, v3->id)); - // das geht bei Winkelplatte und Bathe - this->triangles->push_back(GbTriFaceMesh3D::TriFace(id2, id1, id3)); - // this->triangles->push_back(GbTriFaceMesh3D::TriFace(id1, id2, id3)); - countTris++; - } - - std::cout<<"#################################"<<std::endl; - std::cout<<"countTris:"<<countTris<<std::endl; - std::cout<<"vecSize:"<<this->triangles->size()<<std::endl; - this->attributes->resize(nodes->size()); - - countTris=0; - for(int u=0;u<(int)this->triangles->size(); u++) - { - double area = (*this->triangles)[u].getArea(*this->nodes); - if(UbMath::zero(area)) countTris++; - } - std::cout<<"#################################"<<std::endl; - std::cout<<"Area 0 für:"<<countTris<<" Dreiecke"<<std::endl; - - this->calculateValues(); - - this->createVertexTriFaceMap(); -} -/*===============================================================================*/ -void FeAdhocTriFaceMesh3D::writeAdhoCMeshForStefan(string filename) -{ - std::cout << "FeAdhocTriFaceMesh3D::writeAdhoCMeshForStefan ...\n"; - List *elementlist = mesh->TL; - - ListItem* LI; - Tri* triangle; - - vector<GbPoint3D*>* tmnodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*>* tmtriangles = new vector<GbTriangle3D*>; - - FOR_ALL(elementlist->first, LI, 0) - { - triangle = get_Tri(LI); - - GbPoint3D *node1 = new GbPoint3D(triangle->V[0]->x, triangle->V[0]->y, triangle->V[0]->z); - GbPoint3D *node2 = new GbPoint3D(triangle->V[1]->x, triangle->V[1]->y, triangle->V[1]->z); - GbPoint3D *node3 = new GbPoint3D(triangle->V[2]->x, triangle->V[2]->y, triangle->V[2]->z); - - tmnodes->push_back(node1); - tmnodes->push_back(node2); - tmnodes->push_back(node3); - tmtriangles->push_back(new GbTriangle3D(node1, node2, node3)); - - } - - GbTriangularMesh3D tmmesh("Name", tmnodes, tmtriangles); - UbFileOutputASCII out(filename); - tmmesh.writeAVSMesh(&out); -} - diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h deleted file mode 100644 index e0f3e339aa742b7669e18ad84c50a078771da7ab..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef FEADHOCTRIFACEMESH3D_H -#define FEADHOCTRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> -using namespace std; - -//extern "C" -//{ - //#include "mshpi.h" - #include "fsi_interface.h" - #include "fsi_user_interface.h" -//} - -#include "./FeTriFaceMesh3D.h" - -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -/*=========================================================================*/ -/* FeAdhocTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FeAdhocTriFaceMesh3D : public FeTriFaceMesh3D -{ -public: - FeAdhocTriFaceMesh3D(); - FeAdhocTriFaceMesh3D(std::string name, Mesh *mesh); - - Mesh* getMesh() { return mesh; } - - void writeAdhoCMeshForStefan(string filename); - std::vector< ::Vertex*>* getAdhocVertices() { return this->adhocVertices; } - -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - serializeParent<FeTriFaceMesh3D>(ar, *this); - } -#endif //CAB_RCF - -private: - Mesh* mesh; - std::vector< ::Vertex*>* adhocVertices; -}; - -#ifdef RCF_USE_SF_SERIALIZATION -UB_AUTO_RUN_NAMED( SF::registerType<FeAdhocTriFaceMesh3D >("FeAdhocTriFaceMesh3D ") , SF_FeAdhocTriFaceMesh3D ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< FeTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD1 ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD2 ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD3 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //FEADHOCTRIFACEMESH3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp b/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp deleted file mode 100644 index 0b392588173b909338d025e7dc752f4decf95c66..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp +++ /dev/null @@ -1,622 +0,0 @@ -#include <numerics/geometry3d/fem/FeHalfDisc3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/fem/FePoint3D.h> -#include <basics/utilities/UbInfinity.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* FeHalfDisc3D::getCreator() -{ - return NULL;//FeHalfDisc3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D() -{ - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - mRad = 0.0; - cylinderType = FeHalfDisc3D::NOTPARALLELTOAXIS; -} -/*=======================================================*/ -FeHalfDisc3D::FeHalfDisc3D(FeHalfDisc3D* cylinder) -{ - mRad = cylinder->getRadius(); - cylinderType = cylinder->cylinderType; - mLine = cylinder->getLine()->clone(); - - this->mLine->addObserver(this); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad) -{ - mLine = new GbLine3D; - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - this->mLine->addObserver(this); - mRad = fabs(rad); - - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad) -{ - mRad = rad; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(GbLine3D* line, const double& rad) -{ - mRad = rad; - - this->mLine = line; - this->mLine->addObserver(this); - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -// Destruktor -FeHalfDisc3D::~FeHalfDisc3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void FeHalfDisc3D::initCylinderType() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->cylinderType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->cylinderType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->cylinderType = X3PARALLEL; - else this->cylinderType = NOTPARALLELTOAXIS; -} -/*=======================================================*/ -void FeHalfDisc3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double FeHalfDisc3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* FeHalfDisc3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* FeHalfDisc3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void FeHalfDisc3D::setRadius(const double& radius) -{ - this->mRad = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeHalfDisc3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->initCylinderType(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeHalfDisc3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->initCylinderType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void FeHalfDisc3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->initCylinderType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Centroid() -{ - return mLine->getX1Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Minimum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-mRad; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Maximum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+mRad; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Centroid() -{ - return mLine->getX2Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()-mRad; - else if(this->isParallelToX2Axis()) return mLine->getX2Minimum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()+mRad; - else if(this->isParallelToX2Axis()) return mLine->getX2Maximum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()+mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Centroid() -{ - return mLine->getX3Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()-mRad; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-mRad; - else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()+mRad; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+mRad; - else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*=======================================================*/ -bool FeHalfDisc3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} - -/*==========================================================*/ -string FeHalfDisc3D::toString() -{ - stringstream ss; - ss<<"FeHalfDisc3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", r="<<this->mRad; - ss<<"]"; - return(ss.str()); -} -/*==========================================================*/ -bool FeHalfDisc3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -bool FeHalfDisc3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -GbLine3D* FeHalfDisc3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -vector<GbTriangle3D*> FeHalfDisc3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder is not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 14; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma)); ///(double)0.5; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+mRad*std::sin(phiX1a); - x3a = x3m+mRad*std::cos(phiX1a); - x2b = x2m+mRad*std::sin(phiX1b); - x3b = x3m+mRad*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); - } - - } - } - - x2a = x2m; - x3a = x3m; - x2d = x2m; - x3d = x3m+mRad; - x3b = x3m; - x3c = x3m-mRad; - - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1ma,x2a,x3d))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2a,x3d))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3b),new FePoint3D(x1ma,x2a,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3c),new FePoint3D(x1mb,x2a,x3c))); - - for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m; - x3a = x3m; - x2b = x2m; - x3b = x3m; - x2c = x2m+mRad*std::sin(phiX1b); - x3c = x3m+mRad*std::cos(phiX1b); - x2d = x2m+mRad*std::sin(phiX1a); - x3d = x3m+mRad*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb))); - } - } - - return triangles; -} -/*==========================================================*/ -void FeHalfDisc3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void FeHalfDisc3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void FeHalfDisc3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible"); - this->mRad*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible"); - this->mRad*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible"); - this->mRad*=sx1; - } - else throw UbException(UB_EXARGS,"unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void FeHalfDisc3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(mRad); - out->writeInteger(cylinderType); -} -/*==========================================================*/ -void FeHalfDisc3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - mRad = in->readDouble(); - cylinderType = in->readInteger(); -} -/*==========================================================*/ -double FeHalfDisc3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - /* - Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 - dc = a*dx1 + b*dx2 + c*dx3 - dw = a*ox1 + b*ox2 + c*ox3 + d - D = - dw / dc - */ - double px1, px2, px3; - double d = Ub::inf; // Distance to Min or Max Plane of the Cylinder - // final distance should be less that d - - if( this->isParallelToX1Axis() ) - { - double minX1 = this->getX1Minimum(); - double maxX1 = this->getX1Maximum(); - - if (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1)) return -1.0; - else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1)) return -1.0; - - //falls die Linie nicht parallel zu den Seitenflächen ist - if( x1< minX1 || x1 > maxX1 ) //nur für punkte links und rechts des cylinders - { - px1 = (x1 < minX1 ? minX1 : maxX1); - //falls die Linie nicht parallel zu den Seitenflächen ist - if( !UbMath::zero(rx1) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1.0*(x1 - px1) / rx1; - px2 = x2 + d*rx2; - px3 = x3 + d*rx3; - - if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x1 < minX1 && rx1>0.0 ) d = Ub::inf; //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberfläche - else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1; - else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - } - } - else if( this->isParallelToX2Axis() ) - { - double minX2 = this->getX2Minimum(); - double maxX2 = this->getX2Maximum(); - - if (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2)) return -1; - else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2)) return -1; - - if( minX2 > x2 || x2 > maxX2 ) - { - px2 = (x2 < minX2 ? minX2 : maxX2); - //falls die Linie nicht parallel zu den Seitenflächen ist - if( !UbMath::zero(rx2) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1*(x2 - px2) / rx2; - px1 = x1 + d*rx1; - px3 = x3 + d*rx3; - - if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x2 < minX2 && rx2>0.0 ) d = Ub::inf; //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberfläche - else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2; - else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2; - } - } - else if( this->isParallelToX3Axis() ) - { - double minX3 = this->getX3Minimum(); - double maxX3 = this->getX3Maximum(); - - if (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; - else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; - - if(minX3 > x3 || x3 > maxX3 ) - { - px3 = (x3 < minX3 ? minX3 : maxX3); - //falls die Linie nicht parallel zu den Seitenflächen ist - if (!UbMath::zero(rx3)) - { - // Plane a= 0, b= 0, c=1 d= -1*px3 - d = -1.0*(x3 - px3) / rx3; - px2 = x2 + d*rx2; - px1 = x1 + d*rx1; - if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) ) - { - if (x3 < minX3 && rx3>0.0 ) d = Ub::inf; - else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3; - else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3; - } - } - else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder"); - ////////////////////////////////////////////////////////////////////////// - //Q berechnen für Infinity Cylinder - GbPoint3D* p1 = mLine->getPoint1(); - GbPoint3D* p2 = mLine->getPoint2(); - - double axisX1 = p2->x1 - p1->x1; /* Axis of the cylinder */ - double axisX2 = p2->x2 - p1->x2; /* mit p1 als base of cylinder */ - double axisX3 = p2->x3 - p1->x3; - - //double dirlen = mLine->getLength(); - //double abs, t, s; - - double RCx1 = x1 - p1->x1; - double RCx2 = x2 - p1->x2; - double RCx3 = x3 - p1->x3; - - //n = ray x axis - double nx1 = rx2*axisX3 - rx3*axisX2; - double nx2 = rx3*axisX1 - rx1*axisX3; - double nx3 = rx1*axisX2 - rx2*axisX1; - double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3; - - double abs; - if( UbMath::zero( nLength ) ) - { /* ray parallel to cyl */ - //abs = RC dot axis - double abs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3; - double dx1 = RCx1 - abs*axisX1; - double dx2 = RCx2 - abs*axisX2; - double dx3 = RCx3 - abs*axisX3; - //abs = sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3); - if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) - return -1.0; - } - - //normalize "n" - nLength = std::sqrt(nLength); - double invnLength = 1.0/nLength; - nx1*=invnLength; - nx2*=invnLength; - nx3*=invnLength; - - //shortest distance = fabs( RC dot n ) - abs = fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 ); - - if( UbMath::lessEqual(abs, mRad) ) - { /* if ray hits cylinder */ - //Ox1 = RC x axis - double Ox1 = RCx2*axisX3 - RCx3*axisX2; - double Ox2 = RCx3*axisX1 - RCx1*axisX3; - double Ox3 = RCx1*axisX2 - RCx2*axisX1; - //t = - O dot n / nLength; - double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength; - - //O = n x axis; - Ox1 = nx2*axisX3 - nx3*axisX2; - Ox2 = nx3*axisX1 - nx1*axisX3; - Ox3 = nx1*axisX2 - nx2*axisX1; - - //normalize O - invnLength = 1.0/sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3); - Ox1*=invnLength; - Ox2*=invnLength; - Ox3*=invnLength; - - double s = fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) ); - - if( UbMath::greater(t-s,d) ) return -1.0; - - return t - s; - } - - return -1.0; -} -/*==========================================================*/ diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h deleted file mode 100644 index 1f7ad43f816a073b8b39eaf0f2a4f8923b3647da..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h +++ /dev/null @@ -1,104 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef FEHALFDISC3D_H -#define FEHALFDISC3D_H - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -class FeHalfDisc3D : public GbObject3D , public UbObserver -{ -public: - FeHalfDisc3D(); - FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius); - FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius); - FeHalfDisc3D(GbLine3D* line, const double& rad); - FeHalfDisc3D(FeHalfDisc3D* cylinder); - ~FeHalfDisc3D(); - - FeHalfDisc3D* clone() { return new FeHalfDisc3D(this); } - void finalize(); - - double getRadius() { return this->mRad; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getX1Centroid(); - double getX1Minimum() ; - double getX1Maximum() ; - double getX2Centroid(); - double getX2Minimum() ; - double getX2Maximum() ; - double getX3Centroid(); - double getX3Minimum() ; - double getX3Maximum() ; - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - 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); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -protected: - void initCylinderType(); - - GbLine3D* mLine; - double mRad; - - int cylinderType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp deleted file mode 100644 index 82f053daa4c38de22c79466530e184858e91083f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include <numerics/geometry3d/fem/FePlateTriangularMesh3D.h> - -using namespace std; - -FePlateTriangularMesh3D::FePlateTriangularMesh3D() : GbTriangularMesh3D() -{ -} - -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, triangles) -{ -} - -/*=============================================================================================*/ - -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, triangles) -{ -} - -/*=============================================================================================*/ -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, edges, triangles) -{ -} -/*=============================================================================================*/ -FePlateTriangularMesh3D::~FePlateTriangularMesh3D() -{ - -} -/*======================================================================*/ - -/*======================================================================*/ -bool FePlateTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - //cout<<"GbTriangularMesh3D::isPointInGbObject3D"<<endl; - //Sebastian - //double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - // double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - // double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - // double dX = (xmax-xmin)/100.; - // double dY = (ymax-ymin)/100.; - // double dZ = (zmax-zmin)/100.; - // GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - // - //if(this->isPointInObject3DHalfSpace(x1,x2,x3)) - //{ - // return true; - //} - //if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) - //{ - // return false; - //} - - //return false; - //Marco - int inside = 0; - int nx1 = this->getNodesX1Dir()-1; - int nx2 = this->getNodesX2Dir()-1; - int maxTriangels = 2*nx1*nx2; - - //Überprüft, ob der Punkt innerhalb des Netzes liegt - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - if( x1<=xmax && x1>=xmin - && x2<=ymax && x2>=ymin - && x3<=zmax && x3>=zmin) - { - //Achtung Sonderfall - //Es wird nur gegen die obere Lage Dreiecke getestet, da die untere Lage um den Abstand 'height' verschoben ist! - //Die Seiten müssen somit auch nicht berücksichtigt werden - for(int i=0; i<int(maxTriangels);i++) - { - if( (triangles->at(i))->enclosesPoint2D(x1, x2) - && x3<triangles->at(i)->getX3Centroid() - && x3>triangles->at(i)->getX3Centroid() - this->height ) - { - inside++; - } - } - } - - if(inside!=0) - { - return true; - } - else return false; -} -/*======================================================================*/ -FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height) -{ - FePlateTriangularMesh3D* triMesh = FePlateTriangularMesh3D::createMeshByNodes(ElementsX1+1, ElementsX2+1, nulllevel, deltaX1, deltaX2, height); - return triMesh; -} -/*======================================================================*/ -FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height) -{ - cout<<"erstelle GbTriangularMesh3D -> "; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - double h1=nulllevel+0.5*height; - double h2=nulllevel-0.5*height; - GbPoint3D* point1; - GbPoint3D* point2; - GbPoint3D* point3; - GbPoint3D* point4; - //Erstelle Knoten - //oben - for(int i=0; i<nodesX1; i++) - { - for(int j=0; j<nodesX2; j++) - { - GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h1); - points->push_back(point); - } - } - //unten - for(int i=0; i<nodesX1; i++) - { - for(int j=0; j<nodesX2; j++) - { - GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h2); - points->push_back(point); - } - } - int size=int(points->size()); - //Erstelle Dreiecke - //oben - for(int i=0; i<(size/2)-nodesX2; i+=nodesX2) - { - for(int j=0; j<nodesX2-1; j++) - { - point1 = points->at(i+j); - point2 = points->at(i+j+1); - point3 = points->at(i+j+nodesX2); - point4 = points->at(i+j+nodesX2+1); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point3,point4); - GbTriangle3D* tri2 = new GbTriangle3D(point1,point4,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - } - //unten - for(int i=(size/2); i<size-nodesX2; i+=nodesX2) - { - for(int j=0; j<nodesX2-1; j++) - { - point1 = points->at(i+j); - point2 = points->at(i+j+1); - point3 = points->at(i+j+nodesX2); - point4 = points->at(i+j+nodesX2+1); - GbTriangle3D* tri1 = new GbTriangle3D(point4,point3,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point1); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - } - //Rand - //Nord - for(int i=0;i<nodesX1-1;i++) - { - int a = i*nodesX2+nodesX2-1; - int b = (i+1)*nodesX2+nodesX2-1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point3); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //Süd - for(int i=0;i<nodesX1-1;i++) - { - int a = i*nodesX2; - int b = (i+1)*nodesX2; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point3,point4,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //Ost - for(int j=0;j<nodesX2-1;j++) - { - int a = j; - int b = j+1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3); - GbTriangle3D* tri2 = new GbTriangle3D(point4,point3,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //West - for(int j=0;j<nodesX2-1;j++) - { - int a = j+(nodesX1-1)*nodesX2; - int b = j+(nodesX1-1)*nodesX2+1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point3,point4); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - string name = "TriMesh"; - FePlateTriangularMesh3D* triMesh = new FePlateTriangularMesh3D(name,points,triangles); - triMesh->setNullLevel((float)nulllevel); - triMesh->setHeight(height); - triMesh->setNodesX1Dir(nodesX1); - triMesh->setNodesX2Dir(nodesX2); - cout<<"done"<<endl; - return triMesh; -} - - diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h deleted file mode 100644 index a938503a2fff98c4d2b034b61f5f46e853adad89..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FEPLATETRIANGULARMESH_H -#define FEPLATETRIANGULARMESH_H - -#include <sstream> -#include <iostream> - -#include <numerics/geometry3d/GbTriangularMesh3D.h> - - -/*=========================================================================*/ -/* GbTriangularMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FePlateTriangularMesh3D : public GbTriangularMesh3D -{ -public: - FePlateTriangularMesh3D(); - FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles); - FePlateTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles); - FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles); - virtual ~FePlateTriangularMesh3D(); - - static FePlateTriangularMesh3D* createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height); - static FePlateTriangularMesh3D* createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height); - - - float getNullLevel() { return this->nulllevel; } - void setNullLevel(float nulllevel) { this->nulllevel = nulllevel; } - double getHeight() { return this->height; } - void setHeight(double height) { this->height = height; } - int getNodesX1Dir() { return this->nodesX1Dir; } - void setNodesX1Dir(int nodesX1Dir) { this->nodesX1Dir = nodesX1Dir; } - int getNodesX2Dir() { return this->nodesX2Dir; } - void setNodesX2Dir(int nodesX2Dir) { this->nodesX2Dir = nodesX2Dir; } - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - - /*======================================================================*/ -private: - float nulllevel; - double height; - int nodesX1Dir; - int nodesX2Dir; -}; -/*=========================================================================*/ -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h deleted file mode 100644 index c26ac282c0c6f054c2ec214f47e64b40044a3eb0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef FEPOINT3D_H -#define FEPOINT3D_H - -#include <sstream> -#include <numerics/geometry3d/GbPoint3D.h> - - -/*=========================================================================*/ -/* GbPoint3D */ -/* */ -/** - * This Class provides basic 3D point objects. - * <BR><BR><HR> - * @author <A HREF="mailto:geller@bauinf.tu-cottbus.de">S. Geller</A> - * @version 1.0 - 10.02.07 - * - */ -class FePoint3D : public GbPoint3D -{ -private: - - double Fx; - double Fy; - double Fz; - //double oldFx; - //double oldFy; - double sumFx; - double sumFy; - double sumFz; - double velocityX; - double velocityY; - double velocityZ; - //double accelerationX; - //double accelerationY; - UbTupleDouble6 stresses; - - double area; -public: - FePoint3D():GbPoint3D() - { - this->init(); - } - FePoint3D(double x, double y, double z):GbPoint3D(x,y,z) - { - this->init(); - } - FePoint3D(GbPoint3D *point):GbPoint3D(point) - { - this->init(); - } - - FePoint3D(FePoint3D *point):GbPoint3D(point) - { - this->Fx = point->Fx; - this->Fy = point->Fy; - this->Fz = point->Fz; - throw UbException(__FILE__,__LINE__,"spaeter fertig machen..."); - } - - virtual ~FePoint3D() - { - } - - void init() - { - this->Fx = 0.0; - this->Fy = 0.0; - this->Fz = 0.0; - //this->oldFx = 0.0; - //this->oldFy = 0.0; - this->sumFx = 0.0; - this->sumFy = 0.0; - this->sumFz = 0.0; - val<1>(stresses) = 0.0; - val<2>(stresses) = 0.0; - val<3>(stresses) = 0.0; - val<4>(stresses) = 0.0; - val<5>(stresses) = 0.0; - val<6>(stresses) = 0.0; - this->area = 0.0; - this->velocityX = 0.0; - this->velocityY = 0.0; - this->velocityZ = 0.0; - } - /*======================================================================*/ - FePoint3D* clone() - { - return(new FePoint3D(this)); - } - - double getVelocityX() { return(this->velocityX); } - double getVelocityY() { return(this->velocityY); } - double getVelocityZ() { return(this->velocityZ); } - void setVelocityX(double x) { this->velocityX = x; } - void setVelocityY(double y) { this->velocityY = y; } - void setVelocityZ(double z) { this->velocityZ = z; } - - double getFX() { return(this->Fx); } - double getFY() { return(this->Fy); } - double getFZ() { return(this->Fz); } - void setFX(double FX) { this->Fx = FX; } - void setFY(double FY) { this->Fy = FY; } - void setFZ(double FZ) { this->Fz = FZ; } - void addFX(double FX) { this->Fx += FX; } - void addFY(double FY) { this->Fy += FY; } - void addFZ(double FZ) { this->Fz += FZ; } - - double getSumFX() { return(this->sumFx); } - double getSumFY() { return(this->sumFy); } - double getSumFZ() { return(this->sumFz); } - void setSumFX(double FX) { this->sumFx = FX; } - void setSumFY(double FY) { this->sumFy = FY; } - void setSumFZ(double FZ) { this->sumFz = FZ; } - void addSumFX(double FX) { this->sumFx += FX; } - void addSumFY(double FY) { this->sumFy += FY; } - void addSumFZ(double FZ) { this->sumFz += FZ; } - - UbTupleDouble6& getStresses() { return this->stresses; } -// void setS11(double S11) { this->S11 = S11; } -// void setS12(double S12) { this->S12 = S12; } -// void setS22(double S22) { this->S22 = S22; } - double getArea() { return this->area; } - void setArea(double area) { this->area = area; } - void addArea(double area) { this->area += area; } - - /** - * Returns a string representation of this 3D fe-point. - * @return a string representation of this 3D fe-point - */ - std::string toString() - { - std::stringstream ss; - ss<<"FePoint3D["; - ss<<"x1="<<this->x1; - ss<<", x2="<<this->x2; - ss<<", x3="<<this->x3; - ss<<", Fx="<<this->Fx; - ss<<", Fy="<<this->Fy; - ss<<", Fz="<<this->Fz<<"]"; - return((ss.str()).c_str()); - } - /*======================================================================*/ -}; -/*=========================================================================*/ -#endif - - - diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp b/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp deleted file mode 100644 index 8b30959432d1003324ba4070aaba3679b926f346..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp +++ /dev/null @@ -1,468 +0,0 @@ -#include <numerics/geometry3d/fem/FeRing3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/fem/FePoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* FeRing3D::getCreator() -{ - return NULL; //FeRing3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -FeRing3D::FeRing3D() -{ - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - inRadius = 0.0; - outRadius = 0.0; - ringType = FeRing3D::NOTPARALLELTOAXIS; -} -/*=======================================================*/ -FeRing3D::FeRing3D(FeRing3D* ring) -{ - inRadius = ring->getInRadius(); - outRadius = ring->getOutRadius(); - ringType = ring->ringType; - mLine = ring->getLine()->clone(); - - this->mLine->addObserver(this); -} -/*==========================================================*/ -FeRing3D::FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius) -{ - mLine = new GbLine3D; - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - this->mLine->addObserver(this); - this->inRadius = inradius; - this->outRadius = outradius; - - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeRing3D::FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius) -{ - this->inRadius = inradius; - this->outRadius = outradius; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeRing3D::FeRing3D(GbLine3D* line, const double& inradius, const double& outradius) -{ - this->inRadius = inradius; - this->outRadius = outradius; - - this->mLine = line; - this->mLine->addObserver(this); - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -// Destruktor -FeRing3D::~FeRing3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void FeRing3D::initRingType() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->ringType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->ringType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->ringType = X3PARALLEL; - else this->ringType = NOTPARALLELTOAXIS; -} -/*=======================================================*/ -void FeRing3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double FeRing3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* FeRing3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* FeRing3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void FeRing3D::setInRadius(const double& radius) -{ - this->inRadius = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setOutRadius(const double& radius) -{ - this->outRadius = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->initRingType(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException("FeRing3D::setPoint1() - line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->initRingType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void FeRing3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException("FeRing3D::setPoint1() - line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->initRingType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -double FeRing3D::getX1Centroid() -{ - return mLine->getX1Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX1Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Minimum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX1Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Maximum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX2Centroid() -{ - return mLine->getX2Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX2Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()-outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX2Minimum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX2Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()+outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX2Maximum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()+outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX3Centroid() -{ - return mLine->getX3Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX3Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()-outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX3Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()+outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); - -} -/*==========================================================*/ -bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*=======================================================*/ -bool FeRing3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} - -/*==========================================================*/ -string FeRing3D::toString() -{ - stringstream ss; - ss<<"FeRing3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", inRadius="<<this->inRadius; - ss<<", outRadius="<<this->outRadius; - ss<<"]"; - return(ss.str()); -} -/*==========================================================*/ -bool FeRing3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -bool FeRing3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -GbLine3D* FeRing3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -vector<GbTriangle3D*> FeRing3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(__FILE__, __LINE__, "FeRing3D::getSurfaceTriangleSet() - ring not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 14; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - double x2aa,x3aa,x2bb,x3bb; - - double dXCylinder = fabs((x1mb-x1ma)); // /(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+this->outRadius*std::sin(phiX1a); - x3a = x3m+this->outRadius*std::cos(phiX1a); - x2b = x2m+this->outRadius*std::sin(phiX1b); - x3b = x3m+this->outRadius*std::cos(phiX1b); - - x2aa = x2m+this->inRadius*std::sin(phiX1a); - x3aa = x3m+this->inRadius*std::cos(phiX1a); - x2bb = x2m+this->inRadius*std::sin(phiX1b); - x3bb = x3m+this->inRadius*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2bb,x3bb),new FePoint3D(x1b,x2aa,x3aa),new FePoint3D(x1a,x2aa,x3aa))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2aa,x3aa),new FePoint3D(x1a,x2bb,x3bb),new FePoint3D(x1b,x2bb,x3bb))); - } - else if( this->isParallelToX2Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2bb,x1b,x3bb),new FePoint3D(x2aa,x1b,x3aa),new FePoint3D(x2aa,x1a,x3aa))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2aa,x1a,x3aa),new FePoint3D(x2bb,x1a,x3bb),new FePoint3D(x2bb,x1b,x3bb))); - } - else if( this->isParallelToX3Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3bb,x2bb,x1b),new FePoint3D(x3aa,x2aa,x1b),new FePoint3D(x3aa,x2aa,x1a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3aa,x2aa,x1a),new FePoint3D(x3bb,x2bb,x1a),new FePoint3D(x3bb,x2bb,x1b))); - } - - } - } - - //int segmentsSide = (int)(this->outRadius/dXCylinder); - - double radius0, radius1; - //for(int segCyl = 10; segCyl<segmentsSide; segCyl++) - //{ - radius0 = inRadius;//segCyl*dXCylinder; - radius1 = outRadius;//radius0+dXCylinder; - //if(segCyl==segmentsSide-1) radius1=outRadius; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+radius0*std::sin(phiX1a); - x3a = x3m+radius0*std::cos(phiX1a); - x2b = x2m+radius0*std::sin(phiX1b); - x3b = x3m+radius0*std::cos(phiX1b); - x2c = x2m+radius1*std::sin(phiX1b); - x3c = x3m+radius1*std::cos(phiX1b); - x2d = x2m+radius1*std::sin(phiX1a); - x3d = x3m+radius1*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2b,x3b),new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1ma,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2b,x3b),new FePoint3D(x1mb,x2c,x3c),new FePoint3D(x1mb,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb))); - } - } - // } - - return triangles; -} -/*==========================================================*/ -void FeRing3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void FeRing3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void FeRing3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException("FeRing3D::scale - || to x1 -> different scaling sx2 and sx3 not possible"); - this->inRadius*=sx2; - this->outRadius*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException("FeRing3D::scale - || to x2 -> different scaling sx1 and sx3 not possible"); - this->inRadius*=sx1; - this->outRadius*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException("FeRing3D::scale - || to x3 -> different scaling sx1 and sx2 not possible"); - this->inRadius*=sx1; - this->outRadius*=sx1; - } - else throw UbException("FeRing3D::scale - unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void FeRing3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(inRadius); - out->writeDouble(outRadius); - out->writeInteger(ringType); -} -/*==========================================================*/ -void FeRing3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - inRadius = in->readDouble(); - outRadius = in->readDouble(); - ringType = in->readInteger(); -} -/*==========================================================*/ -double FeRing3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ - diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h deleted file mode 100644 index e2d45f5339ff7028d03be9b97ad6cd45fc026a32..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h +++ /dev/null @@ -1,107 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef FERING3D_H -#define FERING3D_H - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -class FeRing3D : public GbObject3D , public UbObserver -{ -public: - FeRing3D(); - FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius); - FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius); - FeRing3D(GbLine3D* line, const double& inradius, const double& outradius); - FeRing3D(FeRing3D* ring); - ~FeRing3D(); - - FeRing3D* clone() { return new FeRing3D(this); } - void finalize(); - - double getInRadius() { return this->inRadius; }; - double getOutRadius() { return this->outRadius; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setInRadius(const double& radius); - void setOutRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->ringType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->ringType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->ringType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->ringType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getX1Centroid(); - double getX1Minimum() ; - double getX1Maximum() ; - double getX2Centroid(); - double getX2Minimum() ; - double getX2Maximum() ; - double getX3Centroid(); - double getX3Minimum() ; - double getX3Maximum() ; - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - 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); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -protected: - void initRingType(); - - GbLine3D* mLine; - double inRadius; - double outRadius; - - int ringType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp deleted file mode 100644 index f5b0a7835f0459609c15b7fa6bba7713dc800c16..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h> - -#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -using namespace std; - -FeTriFaceMesh3D::FeTriFaceMesh3D():GbTriFaceMesh3D() -{ - this->attributes = new vector<VertexAttributes>; -// this->createVertexTriFaceMap(); -} -/*====================================================*/ -FeTriFaceMesh3D::FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles):GbTriFaceMesh3D(name,nodes,triangles) -{ - this->attributes = new vector<VertexAttributes>; - this->attributes->resize(nodes->size()); -// this->createVertexTriFaceMap(); -} -/*======================================================================*/ -ObObjectCreator* FeTriFaceMesh3D::getCreator() -{ - return FeTriFaceMesh3DCreator::getInstance(); -} -/*====================================================*/ -void FeTriFaceMesh3D::resizeAttributes() -{ - this->attributes->resize(nodes->size()); -} -/*====================================================*/ -//void FeTriFaceMesh3D::createVertexTriFaceMap() -//{ -// vertexTriFaceMap.clear(); -// vector<TriFace>& tris = *this->triangles; -// vector<Vertex>& pts = *this->nodes; -// -// for(size_t t=0; t<tris.size(); t++) -// { -// TriFace& tri = tris[t]; -// Vertex& vert1 = pts[tri.v1]; -// Vertex& vert2 = pts[tri.v2]; -// Vertex& vert3 = pts[tri.v3]; -// vertexTriFaceMap.setVertexTriFaceRelation(&vert1,&tri); -// vertexTriFaceMap.setVertexTriFaceRelation(&vert2,&tri); -// vertexTriFaceMap.setVertexTriFaceRelation(&vert3,&tri); -// } -//} -/*====================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3D::createMeshByTriangles(std::string name, std::vector<GbTriangle3D*> *triangles) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *tris = new vector<GbTriFaceMesh3D::TriFace>; - int nr=0; - for(int u=0;u<(int)triangles->size();u++) - { - if(UbMath::zero((*triangles)[u]->getArea())) continue; - - GbPoint3D* p1 = (*triangles)[u]->getPoint1(); - GbPoint3D* p2 = (*triangles)[u]->getPoint2(); - GbPoint3D* p3 = (*triangles)[u]->getPoint3(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p1->getX1Coordinate(),(float)p1->getX2Coordinate(),(float)p1->getX3Coordinate())); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p2->getX1Coordinate(),(float)p2->getX2Coordinate(),(float)p2->getX3Coordinate())); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p3->getX1Coordinate(),(float)p3->getX2Coordinate(),(float)p3->getX3Coordinate())); - tris->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - nr+=3; - } - FeTriFaceMesh3D* triMesh = new FeTriFaceMesh3D(name, nodes, tris); - triMesh->deleteRedundantNodes(); - triMesh->resizeAttributes(); - return triMesh; -} - -/*======================================================================*/ -UbTuple<string,string> FeTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, std::vector< std::string >* datanames, std::vector< std::vector < double > >* nodedata) -{ - if(datanames || nodedata) - { - UBLOG(logWARNING,"FeTriFaceMesh3D::writeMesh - no support for extra datanames || nodedata"); - } - - UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - start"); - - UbTuple<string,string> filenames; - - if( dynamic_cast<WbWriterVtkXmlBinary*>(writer) || dynamic_cast<WbWriterVtkXmlASCII*>(writer)) - { - vector< UbTupleFloat3 > triNodes( nodes->size() ); - vector< UbTupleInt3 > tris( triangles->size() ); - - for(size_t i=0; i<nodes->size(); i++) - triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - - for(size_t i=0; i<triangles->size(); i++) - tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ; - - vector<string> localDataNames; - localDataNames.push_back("Fx" ); - localDataNames.push_back("Fy" ); - localDataNames.push_back("Fz" ); - localDataNames.push_back("sumFx" ); - localDataNames.push_back("sumFy" ); - localDataNames.push_back("sumFz" ); - localDataNames.push_back("vx" ); - localDataNames.push_back("vy" ); - localDataNames.push_back("vz" ); - localDataNames.push_back("S1" ); - localDataNames.push_back("S2" ); - localDataNames.push_back("S3" ); - localDataNames.push_back("S4" ); - localDataNames.push_back("S5" ); - localDataNames.push_back("S6" ); - localDataNames.push_back("Pressure"); - - std::vector< std::vector < double > > localNodedata( localDataNames.size(), std::vector<double>( nodes->size() ) ); - for(size_t n=0; n<nodes->size(); n++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n]; - - localNodedata[ 0][n] = attribut.getFX(); - localNodedata[ 1][n] = attribut.getFY(); - localNodedata[ 2][n] = attribut.getFZ(); - localNodedata[ 3][n] = attribut.getSumFX(); - localNodedata[ 4][n] = attribut.getSumFY(); - localNodedata[ 5][n] = attribut.getSumFZ(); - localNodedata[ 6][n] = attribut.getVelocityX(); - localNodedata[ 7][n] = attribut.getVelocityY(); - localNodedata[ 8][n] = attribut.getVelocityZ(); - localNodedata[ 9][n] = val<1>(attribut.getStresses()); - localNodedata[10][n] = val<2>(attribut.getStresses()); - localNodedata[11][n] = val<3>(attribut.getStresses()); - localNodedata[12][n] = val<4>(attribut.getStresses()); - localNodedata[13][n] = val<5>(attribut.getStresses()); - localNodedata[14][n] = val<6>(attribut.getStresses()); - localNodedata[15][n] = attribut.getPressure(); - } - val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,localDataNames,localNodedata); - } - else - { - string avsfilename = filename+writer->getFileExtension(); - val<1>(filenames)=avsfilename; - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(filename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - //cout<<"AvsASCII - writeLines to "<<avsfilename<<" ..."; - - int nofNodes = (int)nodes->size(); - int nofTrian = (int)triangles->size(); - int dataSize = 16; - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofTrian<<" "<<dataSize<<" 0 0 "<<endl; - - for(int i=0; i<nofNodes; i++) - out<<i+1<<" "<< (*nodes)[i].x<<" "<< (*nodes)[i].y<<" "<< (*nodes)[i].z<<" \n"; - - for(int i=0; i<nofTrian; i++) - out<<i+1<<" 2 tri "<<(*triangles)[i].v1+1<<" "<<(*triangles)[i].v2+1<<" "<<(*triangles)[i].v3+1<<" "<<endl; - - out<<dataSize; - for(int i=0;i<dataSize;i++) out<<" "<<1; - out<<endl; - - out<<"Fx, no_unit"<<endl; - out<<"Fy, no_unit"<<endl; - out<<"Fz, no_unit"<<endl; - out<<"sumFx, no_unit"<<endl; - out<<"sumFy, no_unit"<<endl; - out<<"sumFz, no_unit"<<endl; - out<<"vx, no_unit"<<endl; - out<<"vy, no_unit"<<endl; - out<<"vz, no_unit"<<endl; - out<<"S1, no_unit"<<endl; - out<<"S2, no_unit"<<endl; - out<<"S3, no_unit"<<endl; - out<<"S4, no_unit"<<endl; - out<<"S5, no_unit"<<endl; - out<<"S6, no_unit"<<endl; - out<<"Pressure, no_unit"<<endl; - - for(int n=0; n<nofNodes; n++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n]; - - double Fx = attribut.getFX(); - double Fy = attribut.getFY(); - double Fz = attribut.getFZ(); - double sumFx = attribut.getSumFX(); - double sumFy = attribut.getSumFY(); - double sumFz = attribut.getSumFZ(); - double vx = attribut.getVelocityX(); - double vy = attribut.getVelocityY(); - double vz = attribut.getVelocityZ(); - double p = attribut.getPressure(); - UbTupleDouble6& stresses = attribut.getStresses(); - out<<n+1<<" "<<Fx<<" "<<Fy<<" "<<Fz; - out<<" "<<sumFx<<" "<<sumFy<<" "<<sumFz; - out<<" "<<vx<<" "<<vy<<" "<<vz; - out<<" "<<val<1>(stresses)<<" "<<val<2>(stresses)<<" "<<val<3>(stresses); - out<<" "<<val<4>(stresses)<<" "<<val<5>(stresses)<<" "<<val<6>(stresses); - out<<" "<<p<<endl; - } - out.close(); - } - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - TriFace& triangle = (*triangles)[i]; - lineNodes[i*2 ] = makeUbTuple( triangle.getX1Centroid(*nodes) - ,triangle.getX2Centroid(*nodes) - ,triangle.getX3Centroid(*nodes)); - lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+triangle.nx) - ,(float)(triangle.getX2Centroid(*nodes)+triangle.ny) - ,(float)(triangle.getX3Centroid(*nodes)+triangle.nz)); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines); - } - - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(nodes->size()*2); - vector<UbTupleInt2 > lines(nodes->size()); - for(size_t i=0; i<nodes->size(); i++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[i]; - lineNodes[i*2 ] = makeUbTuple((*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - lineNodes[i*2+1] = makeUbTuple((*nodes)[i].x+(float)attribut.getNormalX() - ,(*nodes)[i].y+(float)attribut.getNormalY() - ,(*nodes)[i].z+(float)attribut.getNormalZ()); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - writer->writeLines(filename+"_PointNormals",lineNodes,lines); - } - - UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - end"); - - return filenames; -} diff --git a/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h b/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h deleted file mode 100644 index ae05f674aaae03d1407b1ebe980f1a3455eebd00..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h +++ /dev/null @@ -1,204 +0,0 @@ -#ifndef FETRIFACEMESH3D_H -#define FETRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> -#include <map> - -#include "./../GbTriFaceMesh3D.h" - -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -/*=========================================================================*/ -/* FeTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FeTriFaceMesh3D : public GbTriFaceMesh3D -{ -public: - class VertexAttributes - { - private: - double Fx; - double Fy; - double Fz; - double sumFx; - double sumFy; - double sumFz; - double velocityX; - double velocityY; - double velocityZ; - double normalX; - double normalY; - double normalZ; - UbTupleDouble6 stresses; - double area; - double p; //pressure - public: - VertexAttributes() - { - this->init(); - } - ~VertexAttributes() {} - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & Fx; ar & Fy; ar & Fz; - ar & velocityX; ar & velocityY; ar & velocityZ; - } -#endif //CAB_RCF - - void init() - { - this->Fx = 0.0; - this->Fy = 0.0; - this->Fz = 0.0; - this->sumFx = 0.0; - this->sumFy = 0.0; - this->sumFz = 0.0; - val<1>(stresses) = 0.0; - val<2>(stresses) = 0.0; - val<3>(stresses) = 0.0; - val<4>(stresses) = 0.0; - val<5>(stresses) = 0.0; - val<6>(stresses) = 0.0; - this->area = 0.0; - this->p = 0.0; - this->velocityX = 0.0; - this->velocityY = 0.0; - this->velocityZ = 0.0; - this->normalX = 0.0; - this->normalY = 0.0; - this->normalZ = 0.0; - } - double getVelocityX() { return this->velocityX; } - double getVelocityY() { return this->velocityY; } - double getVelocityZ() { return this->velocityZ; } - void setVelocityX(double x) { this->velocityX = x; } - void setVelocityY(double y) { this->velocityY = y; } - void setVelocityZ(double z) { this->velocityZ = z; } - - double getNormalX() { return this->normalX; } - double getNormalY() { return this->normalY; } - double getNormalZ() { return this->normalZ; } - void setNormalX(double x) { this->normalX = x; } - void setNormalY(double y) { this->normalY = y; } - void setNormalZ(double z) { this->normalZ = z; } - - double getFX() { return this->Fx; } - double getFY() { return this->Fy; } - double getFZ() { return this->Fz; } - void setFX(double FX) { this->Fx = FX; } - void setFY(double FY) { this->Fy = FY; } - void setFZ(double FZ) { this->Fz = FZ; } - void addFX(double FX) { this->Fx += FX; } - void addFY(double FY) { this->Fy += FY; } - void addFZ(double FZ) { this->Fz += FZ; } - - double getSumFX() { return this->sumFx; } - double getSumFY() { return this->sumFy; } - double getSumFZ() { return this->sumFz; } - void setSumFX(double FX) { this->sumFx = FX; } - void setSumFY(double FY) { this->sumFy = FY; } - void setSumFZ(double FZ) { this->sumFz = FZ; } - void addSumFX(double FX) { this->sumFx += FX; } - void addSumFY(double FY) { this->sumFy += FY; } - void addSumFZ(double FZ) { this->sumFz += FZ; } - - UbTupleDouble6& getStresses() { return this->stresses; } - - double getArea() { return this->area; } - void setArea(double area) { this->area = area; } - void addArea(double area) { this->area += area; } - - double getPressure() { return this->p; } - void setPressure(double p) { this->p = p; } - - }; -/*=========================================================================*/ -/*=========================================================================*/ -/*=========================================================================*/ - //class VertexTriFaceMap : public std::multimap<Vertex*, TriFace*> - //{ - //public: - // VertexTriFaceMap() {} - // /*=========================================================================*/ - // void setVertexTriFaceRelation(Vertex* v, TriFace* tri) - // { - // this->insert(std::pair<Vertex*,TriFace*>(v,tri)); - // } - // /*=========================================================================*/ - // int getNumberOfTriFaces(Vertex* v) - // { - // return((int)this->count(v)); - // } - // /*=========================================================================*/ - // std::vector<TriFace*> getTriFacesForVertex(Vertex* v) - // { - // std::vector<TriFace*> trivector; - // unsigned number = (unsigned)this->count(v); - // std::multimap<Vertex*,TriFace*>::iterator mapIterator = this->find(v); - // for(unsigned u =0; u<number; u++) - // { - // trivector.push_back(mapIterator->second); - // mapIterator ++; - // } - // return trivector; - // } - // //void deleteNeighbors(QtInteractor* interactor); - // ///*=========================================================================*/ - //}; -/*=========================================================================*/ -/*=========================================================================*/ -/*=========================================================================*/ -public: - //#ifndef SWIG - //VertexTriFaceMap vertexTriFaceMap; - //#endif - - FeTriFaceMesh3D(); - FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles); - - std::vector<VertexAttributes>* getAttributes() { return this->attributes; } - void resizeAttributes(); - //void createVertexTriFaceMap(); - - UbTuple<std::string,std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL); - - static FeTriFaceMesh3D* createMeshByTriangles(std::string name, std::vector<GbTriangle3D*>* triangles); - - virtual ObObjectCreator* getCreator(); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbTriFaceMesh3D>(ar, *this); - ar & attributes; - //if( ArchiveTools::isReading(ar) ) this->createVertexTriFaceMap(); - } -#endif //CAB_RCF - - -protected: - std::vector<VertexAttributes>* attributes; - -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<FeTriFaceMesh3D >("FeTriFaceMesh3D ") , SF_FeTriFaceMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - -#endif //FETRIFACEMESH3D_H diff --git a/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt deleted file mode 100644 index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp b/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp deleted file mode 100644 index 4e47547ad966b0de03f5590c45995cca7e983eaf..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp +++ /dev/null @@ -1,417 +0,0 @@ -#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbTiming.h> - -using namespace std; - -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, bool removeRedundantNodes) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist - - if ( !ext.compare("ply") ) return FeTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName, removeRedundantNodes); - else if( !ext.compare("stl") ) return FeTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName, removeRedundantNodes); - else if( !ext.compare("inp") ) return FeTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName, removeRedundantNodes); - //else if( !ext.compare("gts") ) return FeTriFaceMesh3DCreator::readMeshFromGTSFile(filename, meshName); - //else if( !ext.compare("raw") ) return FeTriFaceMesh3DCreator::readMeshFromRAWFile(filename, meshName); - else throw UbException(UB_EXARGS,"fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII plyfile(filename); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, bool removeRedundantNodes) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - float x, y, z; - string dummy; - - int numVertices = in->readIntegerAfterString("element vertex"); - int numFaces = in->readIntegerAfterString("element face"); - in->setPosAfterLineWithString("end_header"); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - nodes->resize(numVertices); - triangles->reserve(numFaces); - - int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01)); - for (int i=0; i<numVertices; i++) - { - if( i%onePercent==0 ) - cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush; - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - int p,j,k,l,n; - onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); - for(int i=0; i<numFaces; i++) - { - if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush; - - p = in->readInteger(); - if(p==3) //Dreieck, alles andere wird stumpf ingnoriert - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) ) - { - throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - else if(p==4) //Viereck --> wird zu zwei Dreiecken! - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - n = in->readInteger(); - numFaces++; - i++; - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) - || !UbMath::inClosedInterval(n,0,numVertices-1) - ) - { - throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j)); - } - - in->readLine(); - - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); - //mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, bool removeRedundantNodes) -{ - UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; - vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - nr+=3; - } - - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -// /*======================================================================*/ -// FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, bool removeRedundantNodes) -// { -// public static void read(String file, ArrayList<Node3d> nodeList, ArrayList<TrianglePatch> patches) throws FileReaderException { -// -// UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); -// -// vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; -// vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; -// string dummy; -// -// double x, y, z; -// int nr=0; -// -// in->readLine(); -// while(dummy!="endsolid") -// { -// in->readLine(); -// in->readLine(); -// dummy = in->readString(); -// if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// in->readLine(); -// in->readString(); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// in->readLine(); -// in->readString(); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); -// in->readLine(); -// in->readLine(); -// in->readLine(); -// dummy = in->readString(); -// nr+=3; -// } -// -// -// FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); -// -// if(removeRedundantNodes) mesh->deleteRedundantNodes(); -// -// return mesh; -// -// -// try { -// -// FileInput input = new FileInput(file); -// -// int line = 0; -// while(true) -// { -// if(line>1000) break; -// if(input.readLine().contains("Vertices")) -// break; -// line++; -// } -// -// int num_of_points = input.readInt(); -// -// for (int i = 0; i < num_of_points; i++) { -// float x = (float) input.readDouble(); -// float y = (float) input.readDouble(); -// float z = (float) input.readDouble(); -// int nr = input.readInt(); -// nodeList.add(new Node3d(x, y, z)); -// } -// -// input.skipLine(); -// input.skipLine(); -// int num_of_triangles = input.readInt(); -// -// for (int i = 0; i < num_of_triangles; i++) { -// -// int a = input.readInt(); -// int b = input.readInt(); -// int c = input.readInt(); -// int nr = input.readInt(); -// -// Node3d P1 = nodeList.get(a - 1); -// Node3d P2 = nodeList.get(b - 1); -// Node3d P3 = nodeList.get(c - 1); -// -// patches.add(new TrianglePatch(P1, P2, P3)); -// } -// -// // END reading mesh file -// } -// -// -- -// -// Dipl.-Ing. Sebastian Bindick -// -// Institute for Computational Modeling in Civil Engineering (iRMB) Technische Universität Braunschweig Pockelsstr. 3 (9th Floor) D-38106, Braunschweig, Germany -// -// phone +49 531/391-7598 -// fax +49 531/391-7599 -// email bindick@irmb.tu-bs.de -// web www.irmb.tu-bs.de -// -// -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, bool removeRedundantNodes) -{ - UBLOG(logINFO,"FeTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; - vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - int numberNodes = in->readInteger(); - int numberTris = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - in->readInteger(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - in->readLine(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - in->readInteger(); - in->readString(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(FeTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1)); - } - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - - in->readString(); - int numberNodes = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - in->readLine(); - in->readString(); - int numberTris = in->readInteger(); - in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); - - return mesh; -} diff --git a/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h b/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h deleted file mode 100644 index 43f25b99e1c08e188242e260bead0898896bb1e8..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef FETRIFACEMESH3DCREATOR_H -#define FETRIFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -//#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class FeTriFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static FeTriFaceMesh3DCreator* getInstance() - { - static FeTriFaceMesh3DCreator instance; - return &instance; - } - static FeTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - - FeTriFaceMesh3D* createGbObject3D() { return new FeTriFaceMesh3D(); } - - std::string getGbObject3DTypeID(){ return "FeTriFaceMesh3D"; }; - std::string toString() { return "FeTriFaceMesh3DCreator"; } - -#ifdef CAB_QT - - - FeTriFaceMesh3D* createGbObject3DwithQt() - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - FeTriFaceMesh3D *mesh = NULL;//FeTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - FeTriFaceMesh3DCreator( const FeTriFaceMesh3DCreator& ); //no copy allowed - const FeTriFaceMesh3DCreator& operator=( const FeTriFaceMesh3DCreator& ); //no copy allowed - FeTriFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(FeTriFaceMesh3DCreator::getInstance()), CAB_FeTriFaceMesh3DCreator); -#endif - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt b/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt deleted file mode 100644 index 56dbc3800e73aec047b6d09d2e5957bfbf2ef3e3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt +++ /dev/null @@ -1,93 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_QT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) - -#SET(SUBDIRPATH numerics/geometry3d/presentation) -#SET(OPTION_LABEL BUILD_GEOMETRY3DPRESENTATION) -# -#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH}) -# -#IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES) -# STRING(REGEX REPLACE "/" "\\\\" SUBDIRPATH ${SUBDIRPATH}) -#ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES) -# -#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON) -#IF(${OPTION_LABEL}) -# -# SET(TEMP_FILES "") -# ################################################################ -# ### GET HEADER AND SOURCE FILES ### -# ################################################################ -# FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h ) -# FILE(GLOB CPP_FILES ${CURRENT_DIR}/*.cpp) -# -# IF(NOT NEED_VTK) -# FILE(GLOB VTK_FILES ${CURRENT_DIR}/*vtk* ) -# REMOVE(HEADER_FILES ${VTK_FILES} ) -# REMOVE(CPP_FILES ${VTK_FILES} ) -# ENDIF(NOT NEED_VTK) -# -# SET(TEMP_FILES ${HEADER_FILES} ${CPP_FILES}) -# -# SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMP_FILES}) -# -# ################################################################ -# ### VTK STUFF ### -# ################################################################ -# -##GANZ SICHER NICHT!!!!! -> bitte NEED_VTK im globalen CMakeLists.txt definieren -##SET(NEED_VTK "TRUE") -# -# ################################################################ -# ### Qt STUFF ### -# ################################################################ -# SET(NEED_QT "YES") -# INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt) -# IF(QT_FOUND) -# ################################################################ -# ### Qt4 UI FILES ### -# ################################################################ -# FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui) #collect ui files -# QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES}) #wrap ui files -# REMOVE(TEMP_FILES ${OUTFILES} ) -# SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} ) -# -# #make subfolders for VS with new files -# SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES}) -# -# IF(WIN32) -# SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES}) -# SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES}) -# ENDIF(WIN32) -# -# ################################################################ -# ### Qt4 HEADERS TO BE MOCED ### -# ################################################################ -# MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC}) -# SET(HEADER_FILES_FOR_MOCCHECK ${HEADER_FILES}) -# REMOVE(HEADER_FILES_FOR_MOCCHECK ${OUTFILES} ) #bereits durch QT4_WRAP_UI bearbeitete Header-files entferne -# QT4_GET_TOBEMOCED_HEADERS(MOC_CLASSES ${HEADER_FILES_FOR_MOCCHECK}) -# IF(MOC_CLASSES) -# SET(MOC_FILES ) #empty MOC_FILES -# QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES}) -# REMOVE(TEMP_FILES ${MOC_FILES}) -# SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES}) -# SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES}) -# ENDIF(MOC_CLASSES) -# -# #MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC}) -# #SET(MOC_FILES ) #empty MOC_FILES -# #SET(MOC_CLASSES -# # ${CURRENT_DIR}/QGbObject2DViewer.h -# # ${CURRENT_DIR}/QGbObject2DMainWindow.h -# # ) -# -# #QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES}) -# #REMOVE(TEMP_FILES ${MOC_FILES}) -# #SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES}) -# #SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES}) -# -# ENDIF(QT_FOUND) -# -# SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES}) -# -#ENDIF(${OPTION_LABEL}) diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp deleted file mode 100644 index 81ea5bb168f179cdfc8837899e7cc6782907b137..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "./QGbCuboid3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> -#include <qstring.h> -#include <qcheckbox.h> - -/**** CAB ****/ -#include "./../GbCuboid3D.h" -#include "./../GbPoint3D.h" - - -QGbCuboid3DInstrument::QGbCuboid3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent, flags) -{ - ui.setupUi(this); - - this->gbCuboid = NULL; - -} - -QGbCuboid3DInstrument::~QGbCuboid3DInstrument() -{ -} - -void QGbCuboid3DInstrument::setGbCuboid3D(GbCuboid3D* cuboid) -{ - this->gbCuboid = cuboid; - ui.lineEditPoint1X->setText( QString("%1").arg(gbCuboid->getPoint1()->getX1Coordinate() ) ); - ui.lineEditPoint1Y->setText( QString("%1").arg(gbCuboid->getPoint1()->getX2Coordinate() ) ); - ui.lineEditPoint1Z->setText( QString("%1").arg(gbCuboid->getPoint1()->getX3Coordinate() ) ); - ui.lineEditPoint2X->setText( QString("%1").arg(gbCuboid->getPoint2()->getX1Coordinate() ) ); - ui.lineEditPoint2Y->setText( QString("%1").arg(gbCuboid->getPoint2()->getX2Coordinate() ) ); - ui.lineEditPoint2Z->setText( QString("%1").arg(gbCuboid->getPoint2()->getX3Coordinate() ) ); - //this->checkBoxActive->setChecked( cuboid->isActive() ); - ui.checkBoxActive->setChecked( true ); -} - -GbCuboid3D* QGbCuboid3DInstrument::getGbCuboid3D() -{ - return this->gbCuboid; -} - -//void QGbCuboid3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbCuboid3DInstrument::on_pBtnOK_clicked() -{ - this->gbCuboid->getPoint1()->setX1(ui.lineEditPoint1X->text().toDouble() ); - this->gbCuboid->getPoint1()->setX2(ui.lineEditPoint1Y->text().toDouble() ); - this->gbCuboid->getPoint1()->setX3(ui.lineEditPoint1Z->text().toDouble() ); - this->gbCuboid->getPoint2()->setX1(ui.lineEditPoint2X->text().toDouble() ); - this->gbCuboid->getPoint2()->setX2(ui.lineEditPoint2Y->text().toDouble() ); - this->gbCuboid->getPoint2()->setX3(ui.lineEditPoint2Z->text().toDouble() ); - //this->gbCuboid->setActive( this->checkBoxActive->isChecked() ); - - this->gbCuboid->notifyObserversObjectChanged(); - this->accept(); -} - - -void QGbCuboid3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h deleted file mode 100644 index 45555d457bc28da60c0107ae2491d1d95ffb0b69..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QGBCUBOID3DINSTRUMENT_H -#define QGBCUBOID3DINSTRUMENT_H - - -#include "./QGbCuboid3DInstrumentUI.h" - -class GbCuboid3D; -class GbObject3D; - -class QGbCuboid3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbCuboid3DInstrument( QWidget* parent = 0, Qt::WFlags fl = 0 ); - ~QGbCuboid3DInstrument(); - void setGbCuboid3D(GbCuboid3D* cuboid); - GbCuboid3D* getGbCuboid3D(); - -protected: - GbCuboid3D* gbCuboid; - -private: - Ui::QGbCuboid3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui deleted file mode 100644 index e584634af9e5b0ac129a66f4ce105d5cba6e86ee..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui +++ /dev/null @@ -1,347 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbCuboid3DInstrument</class> - <widget class="QDialog" name="QGbCuboid3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>252</width> - <height>239</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbCuboid3DInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>10</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Cuboid</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabelPoint1" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Point 1:</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1X" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1Y" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1Z" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabelPoint2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Point 2:</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_4" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2X" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2Y" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2Z" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </item> - <item row="0" column="2" colspan="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>90</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0" > - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item row="4" column="3" > - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>13</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="3" > - <widget class="QCheckBox" name="checkBoxActive" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp deleted file mode 100644 index 3a1cff7b94a1653db8ade52e20b43943a7a84d5b..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "./QGbCylinder3DInstrument.h" - -/**** Qt ****/ -#include <QtCore/QString> -#include <QtGui/QLineEdit> -#include <QtGui/QCheckBox> -#include <QtGui/QTabWidget> - -/**** CAB ****/ -#include "./../GbCylinder3D.h" -#include "./../GbPoint3D.h" - -QGbCylinder3DInstrument::QGbCylinder3DInstrument( QWidget* parent, Qt::WFlags flags ) -{ - ui.setupUi(this); - - /*JZ TODO daher Buttons noch ausgeschaltet (29.11.05)*/ - ui.rBtnXAxis->setEnabled(false); - ui.rBtnYAxis->setEnabled(false); - ui.rBtnZAxis->setEnabled(false); - - this->gbCylinder = NULL; -} - -QGbCylinder3DInstrument::~QGbCylinder3DInstrument(void) -{ -} - -void QGbCylinder3DInstrument::setGbCylinder3D(GbCylinder3D* cylinder) -{ - this->gbCylinder = cylinder; - ui.lineEdit1_X_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) ); - ui.lineEdit1_Y_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) ); - ui.lineEdit1_Z_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) ); - ui.lineEdit1_X_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x1 ) ); - ui.lineEdit1_Y_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x2 ) ); - ui.lineEdit1_Z_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x3 ) ); - ui.dSpBoxRadius1->setValue(gbCylinder->getRadius()); - ui.checkBoxActive1->setChecked( true ); - ui.lineEdit2_X->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) ); - ui.lineEdit2_Y->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) ); - ui.lineEdit2_Z->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) ); - ui.dSpBoxRadius2->setValue(gbCylinder->getRadius()); - ui.checkBoxActive2->setChecked( true ); - ui.lineEditLength->setText( QString("%1").arg(gbCylinder->getHeight()) ); - //if (!this->gbCylinder->isParallelToX1Axis()) - //{ - // if (!this->gbCylinder->isParallelToX2Axis()) - // { - // ui.rBtnZAxis->setChecked(true); - // } - // else ui.rBtnYAxis->setChecked(true); - //} - //else ui.rBtnXAxis->setChecked(true); -} - -GbCylinder3D* QGbCylinder3DInstrument::getGbCylinder3D(void) -{ - return this->gbCylinder; -} - -//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbCylinder3DInstrument::on_pBtnOK_clicked() -{ - if(ui.tabWidget->currentIndex()==0) - { - this->gbCylinder->setPoint1( ui.lineEdit1_X_1->text().toDouble(), - ui.lineEdit1_Y_1->text().toDouble(), - ui.lineEdit1_Z_1->text().toDouble()); - - this->gbCylinder->setPoint2( ui.lineEdit1_X_2->text().toDouble(), - ui.lineEdit1_Y_2->text().toDouble(), - ui.lineEdit1_Z_2->text().toDouble()); - this->gbCylinder->setRadius(ui.dSpBoxRadius1->value()); - - this->gbCylinder->notifyObserversObjectChanged(); - } - if(ui.tabWidget->currentIndex()==1) - { - this->gbCylinder->setPoint1( ui.lineEdit2_X->text().toDouble(), - ui.lineEdit2_Y->text().toDouble(), - ui.lineEdit2_Z->text().toDouble()); - this->gbCylinder->setPoint2( ui.lineEdit2_X->text().toDouble(), - ui.lineEdit2_Y->text().toDouble()+ui.lineEditLength->text().toDouble(), - ui.lineEdit2_Z->text().toDouble()); - this->gbCylinder->setRadius(ui.dSpBoxRadius2->value()); - - this->gbCylinder->notifyObserversObjectChanged(); - } - - this->accept(); -} - - -void QGbCylinder3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h deleted file mode 100644 index a22278cc427a3fcbf7104f9924a3d5c30fc38f5a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QGBCYLINDER3DINSTRUMENT_H -#define QGBCYLINDER3DINSTRUMENT_H - -#include <QtGui/QDialog> -#include <QtGui/QWidget> - -#include "./QGbCylinder3DInstrumentUI.h" -#include "./QGbObject3DInstrument.h" - -class GbCylinder3D; -class GbObject3D; - -class QGbCylinder3DInstrument : public QDialog -{ - - Q_OBJECT - -public: - QGbCylinder3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbCylinder3DInstrument(); - void setGbCylinder3D(GbCylinder3D* cylinder); - GbCylinder3D* getGbCylinder3D(); - -protected: - GbCylinder3D* gbCylinder; - -private: - Ui::QGbCylinder3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif \ No newline at end of file diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui b/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui deleted file mode 100644 index 18f74c5767165ca2f6621611bda9f26c7d630a27..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui +++ /dev/null @@ -1,682 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbCylinder3DInstrument</class> - <widget class="QDialog" name="QGbCylinder3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>457</width> - <height>347</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbCylinder3DInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="1" column="0" > - <widget class="QTabWidget" name="tabWidget" > - <widget class="QWidget" name="tabPoints" > - <attribute name="title" > - <string>Define by Points</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QGroupBox" name="groupBox" > - <property name="title" > - <string>Base Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Z_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_3" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Y_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_X_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="0" column="1" > - <widget class="QGroupBox" name="groupBox_2" > - <property name="title" > - <string>Top Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_3_2_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Z_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_2_2_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Y_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_4_2_2" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_X_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxActive1" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>51</width> - <height>60</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3_2" > - <property name="minimumSize" > - <size> - <width>16</width> - <height>60</height> - </size> - </property> - <property name="title" > - <string>Radius</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QDoubleSpinBox" name="dSpBoxRadius1" > - <property name="decimals" > - <number>1</number> - </property> - <property name="maximum" > - <double>100</double> - </property> - <property name="value" > - <double>3</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="tabLength" > - <attribute name="title" > - <string>Define by Length</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QGroupBox" name="groupBox_5" > - <property name="title" > - <string>Parameters</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QRadioButton" name="rBtnXAxis" > - <property name="text" > - <string>X - Axis</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="rBtnYAxis" > - <property name="text" > - <string>Y - Axis</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="rBtnZAxis" > - <property name="text" > - <string>Z - Axis</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5_2_2" > - <property name="text" > - <string>Length:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditLength" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Parallel to</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - <widget class="QWidget" name="widget_2" > - <property name="geometry" > - <rect> - <x>11</x> - <y>71</y> - <width>194</width> - <height>18</height> - </rect> - </property> - </widget> - </widget> - </item> - <item row="0" column="0" > - <widget class="QGroupBox" name="groupBox_4" > - <property name="title" > - <string>Base Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_Z" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_3_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_Y" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5_2" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_X" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxActive2" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>51</width> - <height>60</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3_2_2" > - <property name="minimumSize" > - <size> - <width>16</width> - <height>60</height> - </size> - </property> - <property name="title" > - <string>Radius</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QDoubleSpinBox" name="dSpBoxRadius2" > - <property name="decimals" > - <number>1</number> - </property> - <property name="maximum" > - <double>100</double> - </property> - <property name="value" > - <double>3</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - <widget class="QWidget" name="widget" > - <property name="geometry" > - <rect> - <x>9</x> - <y>9</y> - <width>415</width> - <height>101</height> - </rect> - </property> - </widget> - </widget> - </widget> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Cylinder</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <tabstops> - <tabstop>tabWidget</tabstop> - <tabstop>lineEdit1_X_1</tabstop> - <tabstop>lineEdit1_X_2</tabstop> - <tabstop>lineEdit1_Y_1</tabstop> - <tabstop>lineEdit1_Y_2</tabstop> - <tabstop>lineEdit1_Z_1</tabstop> - <tabstop>lineEdit1_Z_2</tabstop> - <tabstop>checkBoxActive1</tabstop> - <tabstop>dSpBoxRadius1</tabstop> - <tabstop>lineEdit2_X</tabstop> - <tabstop>lineEdit2_Y</tabstop> - <tabstop>lineEdit2_Z</tabstop> - <tabstop>lineEditLength</tabstop> - <tabstop>rBtnXAxis</tabstop> - <tabstop>rBtnYAxis</tabstop> - <tabstop>rBtnZAxis</tabstop> - <tabstop>checkBoxActive2</tabstop> - <tabstop>dSpBoxRadius2</tabstop> - <tabstop>pBtnOK</tabstop> - <tabstop>pBtnCancel</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp deleted file mode 100644 index 9d873fd905cf9a7c9b34210601168c0b4089dd1c..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "./QGbObject3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> - -/**** vtk ****/ -#include "./../GbObject3D.h" -#include "./../../../basics/utilities/UbMath.h" - -//#define PI 3.14159265358979323846 - -QGbObject3DInstrument::QGbObject3DInstrument( QWidget* parent, Qt::WFlags flags ) -{ - ui.setupUi(this); - - this->gbObject3D = NULL; -} - -QGbObject3DInstrument::~QGbObject3DInstrument() -{ -} - -void QGbObject3DInstrument::setGbObject3D(GbObject3D* obj) -{ - this->gbObject3D = obj; -} - -GbObject3D* QGbObject3DInstrument::getGbObject3D() -{ - return this->gbObject3D; -} - -void QGbObject3DInstrument::on_pBtnOK_clicked() -{ - double rx = ui.lineEditRotationX->text().toDouble(); - double ry = ui.lineEditRotationY->text().toDouble(); - double rz = ui.lineEditRotationZ->text().toDouble(); - - rx *= UbMath::PI /180; - ry *= UbMath::PI /180; - rz *= UbMath::PI /180; - - if ( rx != 0.0 || ry != 0.0 || rz != 0.0 ) this->gbObject3D->rotate(rx, ry, rz); - - double sx = ui.lineEditScalingX->text().toDouble(); - double sy = ui.lineEditScalingY->text().toDouble(); - double sz = ui.lineEditScalingZ->text().toDouble(); - - if ( sx != 0.0 || sy != 0.0 || sz != 0.0 ) this->gbObject3D->scale(sx, sy, sz); - - double x = ui.lineEditTranlationX->text().toDouble(); - double y = ui.lineEditTranlationY->text().toDouble(); - double z = ui.lineEditTranlationZ->text().toDouble(); - - if ( x != 0.0 || y != 0.0 || z != 0.0 ) this->gbObject3D->translate(x, y, z); - - this->gbObject3D->notifyObserversObjectChanged(); - - this->accept(); -} - - -void QGbObject3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h b/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h deleted file mode 100644 index 6165be7237f8eb83653a6c1089fc661859231ce0..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QGBOBJECT3DINSTRUMENT_H -#define QGBOBJECT3DINSTRUMENT_H - -#include <QDialog> -#include "./QGbObject3DInstrumentUI.h" - - -class GbObject3D; - -class QGbObject3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbObject3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbObject3DInstrument(); - void setGbObject3D(GbObject3D* gbObject); - GbObject3D* getGbObject3D(); - -protected: - GbObject3D *gbObject3D; - -private: - Ui::QGbObject3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.ui b/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.ui deleted file mode 100644 index 2fb6f96a9432533a5d7af0e71f3fcc6cbc5caf8a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.ui +++ /dev/null @@ -1,512 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbObject3DInstrument</class> - <widget class="QDialog" name="QGbObject3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>391</width> - <height>167</height> - </rect> - </property> - <property name="windowTitle" > - <string>GeneralModifyInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>10</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="1" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" colspan="3" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Translation:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationZ" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationX" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationY" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Rotation:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationZ" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationX" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationY" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Scaling:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingZ" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_3_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingX" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_3_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingY" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp deleted file mode 100644 index fdc1c6078a2ad3c59ae695e069d1440a6c9cf7b3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "./QGbSphere3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> -#include <qstring.h> -#include <qcheckbox.h> - -/**** CAB ****/ -#include "./../GbSphere3D.h" - -QGbSphere3DInstrument::QGbSphere3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent,flags) -{ - - ui.setupUi(this); - - this->gbSphere = NULL; -} - -QGbSphere3DInstrument::~QGbSphere3DInstrument(void) -{ -} - -void QGbSphere3DInstrument::setGbSphere3D(GbSphere3D* sphere) -{ - this->gbSphere = sphere; - ui.lineEditX->setText( QString("%1").arg(gbSphere->getX1Centroid() ) ); - ui.lineEditY->setText( QString("%1").arg(gbSphere->getX2Centroid() ) ); - ui.lineEditZ->setText( QString("%1").arg(gbSphere->getX3Centroid() ) ); - ui.lineEditName->setText( QString(gbSphere->getName().c_str()) ); - ui.lineEditRadius->setText( QString("%1").arg(gbSphere->getRadius() ) ); - ui.checkBoxActive->setChecked( true ); -} - -GbSphere3D* QGbSphere3DInstrument::getGbSphere3D(void) -{ - return this->gbSphere; -} - -//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbSphere3DInstrument::on_pBtnOK_clicked() -{ - this->gbSphere->setCenterX1Coordinate(ui.lineEditX->text().toDouble()); - this->gbSphere->setCenterX2Coordinate(ui.lineEditY->text().toDouble()); - this->gbSphere->setCenterX3Coordinate(ui.lineEditZ->text().toDouble()); - this->gbSphere->setRadius(ui.lineEditRadius->text().toDouble()); - this->gbSphere->setName(ui.lineEditName->text().toStdString()); - //this->gbSphere->setActive( this->checkBoxActive->isChecked() ); - this->gbSphere->notifyObserversObjectChanged(); - this->accept(); -} - - -void QGbSphere3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h b/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h deleted file mode 100644 index 95bb56b3ad635234df26c856c1404826c5239e1a..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QGBSPHERE3DINSTRUMENT_H -#define QGBSPHERE3DINSTRUMENT_H - -#include <QtGui/QDialog> -#include <QtGui/QWidget> - -#include "./QGbSphere3DInstrumentUI.h" -#include "./QGbObject3DInstrument.h" - -class GbSphere3D; -class GbObject3D; - - -class QGbSphere3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbSphere3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbSphere3DInstrument(); - void setGbSphere3D(GbSphere3D* sphere); - GbSphere3D* getGbSphere3D(); - //void SetGbObject3D(GbObject3D*); - -protected: - GbSphere3D* gbSphere; - -private: - Ui::QGbSphere3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui b/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui deleted file mode 100644 index dced5d31c34f6a58ac6c1c9b235f975cbc542a2f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui +++ /dev/null @@ -1,303 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbSphere3DInstrument</class> - <widget class="QDialog" name="QGbSphere3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>426</width> - <height>180</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbSphere3DInstrument</string> - </property> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>10</x> - <y>50</y> - <width>406</width> - <height>82</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditX" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditY" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditZ" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Radius:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRadius" > - <property name="text" > - <string>5</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QCheckBox" name="checkBoxActive" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>10</x> - <y>144</y> - <width>401</width> - <height>28</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>132</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="" > - <property name="geometry" > - <rect> - <x>12</x> - <y>12</y> - <width>401</width> - <height>35</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Sphere</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>101</width> - <height>33</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="textLabel1_3_3" > - <property name="text" > - <string>Name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditName" /> - </item> - </layout> - </widget> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp deleted file mode 100644 index 9ddd2d2e2277de467fef2204ce000aaa07cf7c04..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "./QVTKGbObject3DViewer.h" - -/**** Qt ****/ -#include <qtabwidget.h> -#include <qlabel.h> -/**** vtk ****/ - -#include <QVTKWidget.h> -//#include "QvtkWindow.h" - -/**** CAB ****/ -#include "./../../../basics/utilities/UbMath.h" -#include "./../GbObject3DManager.h" - - -#include "./../../../userinterface/instrument/QManagerPresentatorInstrument.h" -//#include "./QGbObject3DManagerInstrument.h" - - - -QVTKGbObject3DViewer::QVTKGbObject3DViewer():QVTKViewer3DApplication() -{ - //GbObjectManagerInstrument - this->gbObject3DManager = new GbObject3DManager(); - QManagerPresentatorInstrument* gbObjManInst = new QManagerPresentatorInstrument(gbObject3DManager); - //gbObjManInst->setQViewer(this->getViewer()); - - //Instrumente hinzufügen - this->addInstrument(gbObjManInst, "Geometries"); -} - -QVTKGbObject3DViewer::~QVTKGbObject3DViewer() -{ -} - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h b/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h deleted file mode 100644 index dc2e7ba4add517e22870cbcd097650338f267e0f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef QVTKGBOBJECT3DVIEWER_H -#define QVTGBOBJECT3DKVIEWER_H - -#include "./../../../userinterface/viewer3d/QVTKViewer3DApplication.h" - -class QVTKWindow; -class QVTKViewer3D; -class GbObject3DManager; -class OctNodeGridManager; - -class QVTKGbObject3DViewer : public QVTKViewer3DApplication -{ -public: - QVTKGbObject3DViewer(); - ~QVTKGbObject3DViewer(); - -protected: - - GbObject3DManager* gbObject3DManager; - -}; -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp deleted file mode 100644 index 2b8f66a91310bab57f97509ead907aef21c3be25..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "./vtkGbCuboid3D.h" - -#include "./../GbCuboid3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkCubeSource.h" -#include "vtkPolyDataMapper.h" -//#include "math.h" - -vtkGbCuboid3D::vtkGbCuboid3D(GbCuboid3D* gbObject) -{ - this->gbCuboid = gbObject; - this->gbCuboid->addObserver(this); - - this->setName("vtkGbCuboid3D"); - - this->source = vtkCubeSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); -} - -vtkGbCuboid3D::~vtkGbCuboid3D(void) -{ - this->gbCuboid->removeObserver(this); - if (this->source) this->source->Delete(); -} - -//void vtkGbCuboid3D::ModifiedEventFired() -//{ -// //double a_orien[3]; -// double a_pos[3]; -// this->actor->GetPosition(a_pos); -// //this->actor->GetOrientation(a_orien); -// this->actor->SetPosition(0.0,0.0,0.0); -// this->actor->SetOrientation(0.0,0.0,0.0); -// this->actor->SetScale(1.0,1.0,1.0); -// -// //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; -// //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; -// -// this->gbCuboid->translate(a_pos[0], a_pos[1], a_pos[2]); -// this->gbCuboid->notifyObserversObjectChanged(); -//} - -void vtkGbCuboid3D::applyActorModifications() -{ - if (isModified) - { - double pos[3]; - double scale[3]; - //double orien[3]; - this->actor->GetPosition(pos); - this->actor->GetScale(scale); - //this->actor->GetOrientation(orien); - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; - //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; - - - //////////////////////////////////////////////////////////////////////////// - ////Rotieren - ////[Cy x1 + Sy x3, x2, -Sy x1 + Cy x3, 1] - //double center[3]; - //center[0] = this->gbCuboid->getX1Centroid(); - //center[1] = this->gbCuboid->getX2Centroid(); - //center[2] = this->gbCuboid->getX3Centroid(); - - ////Punkt1 - //double p1x = this->gbCuboid->getPoint1()->getX1Coordinate(); - //double p1y = this->gbCuboid->getPoint1()->getX2Coordinate(); - //double p1z = this->gbCuboid->getPoint1()->getX3Coordinate(); - - //p1x = cos(orien[1]) * p1x + sin(orien[1]) * p1z; - ////p1y = p1y; - //p1z = -sin(orien[1]) * p1x + cos(orien[1]) * p1z; - - //this->gbCuboid->getPoint1()->setX1(p1x); - //this->gbCuboid->getPoint1()->setX2(p1y); - //this->gbCuboid->getPoint1()->setX3(p1z); - - // - ////Punkt2 - //double p2x = this->gbCuboid->getPoint2()->getX1Coordinate(); - //double p2y = this->gbCuboid->getPoint2()->getX2Coordinate(); - //double p2z = this->gbCuboid->getPoint2()->getX3Coordinate(); - - //p2x = cos(orien[1]) * p2x + sin(orien[1]) * p2z; - ////p1y = p1y; - //p2z = -sin(orien[1]) * p2x + cos(orien[1]) * p2z; - - //this->gbCuboid->getPoint2()->setX1(p2x); - //this->gbCuboid->getPoint2()->setX2(p2y); - //this->gbCuboid->getPoint2()->setX3(p2z); - // - //////////////////////////////////////////////////////////////////////////// - - if (scale[0] != 1.0) this->gbCuboid->scale(scale[0], scale[1], scale[2]); - else this->gbCuboid->translate(pos[0], pos[1], pos[2]); - this->gbCuboid->notifyObserversObjectChanged(); - - //Methode der Basisklasse aufrufen. - vtkPoElement3D::applyActorModifications(); - } -} - -void vtkGbCuboid3D::setValues(void) -{ - double bounds[6]; - bounds[0] = this->gbCuboid->getX1Minimum(); - bounds[1] = this->gbCuboid->getX1Maximum(); - bounds[2] = this->gbCuboid->getX2Minimum(); - bounds[3] = this->gbCuboid->getX2Maximum(); - bounds[4] = this->gbCuboid->getX3Minimum(); - bounds[5] = this->gbCuboid->getX3Maximum(); - this->source->SetBounds(bounds); - -// this->actor->SetVisibility( this->gbCuboid->isActive() ); -} - -bool vtkGbCuboid3D::isPointInObject(double const point[3]) -{ - return this->gbCuboid->isPointInGbObject3D(point[0], point[1], point[2]); -} - -void vtkGbCuboid3D::objectChanged(UbObservable*) -{ - this->setValues(); - this->source->Update(); -} - -void vtkGbCuboid3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbCuboid->removeObserver(this); - delete this; -} diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h deleted file mode 100644 index e70fb61c53412a1c81a0f97a422def19ca8e3095..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VTKGBCUBOID3D_H -#define VTKGBCUBOID3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -/**** vtk ****/ -class vtkCubeSource; -class vtkPolyDataMapper; - -class GbCuboid3D; - -class vtkGbCuboid3D : public vtkPoElement3D -{ -public: - vtkGbCuboid3D(GbCuboid3D*); - ~vtkGbCuboid3D(void); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); -protected: - void setValues(); - - GbCuboid3D* gbCuboid; - vtkCubeSource* source; - vtkPolyDataMapper* mapper; -}; -#endif diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp deleted file mode 100644 index 5f3c4111740f69e6af0d99ea8c0fa4e66d18ac51..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "./vtkGbCylinder3D.h" - -#include "./../GbCylinder3D.h" -#include "./../GbPoint3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkCylinderSource.h" -#include "vtkPolyDataMapper.h" - - -vtkGbCylinder3D::vtkGbCylinder3D(GbCylinder3D* gbObject) -{ - this->gbCylinder = gbObject; - this->gbCylinder->addObserver(this); - - this->setName("vtkGbCylinder3D"); - - this->source = vtkCylinderSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); - - //this->applyActorModifications(); -} - -vtkGbCylinder3D::~vtkGbCylinder3D(void) -{ - this->gbCylinder->removeObserver(this); - if (this->source) this->source->Delete(); -} - - -void vtkGbCylinder3D::setValues(void) -{ - //this->source->SetCenter( this->gbCylinder->getX1Centroid(), - // this->gbCylinder->getX2Centroid(), - // this->gbCylinder->getX3Centroid()); - //this->source->SetHeight(this->gbCylinder->getLength()); - //this->source->SetRadius( this->gbCylinder->getRadius()); - - /* JZ Attention not ready still some work TODO*/ - this->source->SetHeight(this->gbCylinder->getHeight()); - this->source->SetCenter(this->gbCylinder->getX1Centroid(), - this->gbCylinder->getX2Centroid(), - this->gbCylinder->getX3Centroid()); - this->source->SetRadius( this->gbCylinder->getRadius() ); - this->source->SetResolution(10); -} - -void vtkGbCylinder3D::applyActorModifications() -{ - //this->actor->SetScale(1.0, this->gbCylinder->getLength(), 1.0); - this->source->SetHeight(this->gbCylinder->getHeight()); - this->actor->SetPosition( this->gbCylinder->getPoint1()->x1, - this->gbCylinder->getPoint1()->x2, - this->gbCylinder->getPoint1()->x3); - this->source->SetRadius( this->gbCylinder->getRadius() ); - - - - //if (this->isModified) - //{ - // double pos[3]; - // double scale[3]; - // this->actor->GetPosition(pos); - // this->actor->GetScale(scale); - - // this->actor->SetPosition(0.0,0.0,0.0); - // this->actor->SetOrientation(0.0,0.0,0.0); - // this->actor->SetScale(1.0,1.0,1.0); - - - // if (scale[0] != 1.0) this->gbCylinder->scale(scale[0], scale[1], scale[2]); - // else this->gbCylinder->translate(pos[0], pos[1], pos[2]); - // this->gbCylinder->notifyObserversObjectChanged(); - - // vtkPoElement3D::applyActorModifications(); - //} -} - -bool vtkGbCylinder3D::isPointInObject(double const point[3]) -{ - return this->gbCylinder->isPointInGbObject3D(point[0], point[1], point[2]); -} - -//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert. -void vtkGbCylinder3D::objectChanged(UbObservable*) -{ - this->setValues(); -// this->applyActorModifications(); - this->source->Modified(); -} - -void vtkGbCylinder3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbCylinder->removeObserver(this); - delete this; -} - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h deleted file mode 100644 index b6a37f1979e7c170ec49f7d63cda5dd514f1557f..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef VTKGBCYLINDER3D_H -#define VTKGBCYLINDER3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -class GbCylinder3D; - -class vtkCylinderSource; -class vtkPolyDataMapper; - - -class vtkGbCylinder3D : public vtkPoElement3D -{ -public: - vtkGbCylinder3D(GbCylinder3D* cylinder); - ~vtkGbCylinder3D(); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); -protected: - void setValues(); - - GbCylinder3D* gbCylinder; - vtkCylinderSource* source; - vtkPolyDataMapper* mapper; -}; -#endif - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp deleted file mode 100644 index 3ab7b25da151d5408fc154a149a05444b36bc849..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "./vtkGbSphere3D.h" - -#include "./../GbSphere3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkSphereSource.h" -#include "vtkPolyDataMapper.h" - - -vtkGbSphere3D::vtkGbSphere3D(GbSphere3D* gbObject):vtkPoElement3D() -{ - this->gbSphere = gbObject; - this->gbSphere->addObserver(this); - - this->setName("vtkGbSphere3D"); - - - this->source = vtkSphereSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); -// this->actor->GetProperty()->SetRepresentationToWireframe(); -} - -vtkGbSphere3D::~vtkGbSphere3D(void) -{ - this->gbSphere->removeObserver(this); - if (this->source) this->source->Delete(); -} - -//void vtkGbSphere3D::ModifiedEventFired() -//{ -// ////double a_orien[3]; -// //double a_pos[3]; -// ////double a_scale[3]; -// //this->actor->GetPosition(a_pos); -// ////this->actor->GetOrientation(a_orien); -// ////this->actor->GetScale(a_scale); -// -// //this->actor->SetPosition(0.0,0.0,0.0); -// //this->actor->SetOrientation(0.0,0.0,0.0); -// //this->actor->SetScale(1.0,1.0,1.0); -// // -// ////cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; -// ////cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; -// ////cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl; -// -// //this->gbSphere->translate(a_pos[0], a_pos[1], a_pos[2]); -// //this->gbSphere->notifyObserversObjectChanged(); -// PoElement3D::ModifiedEventFired(); -//} - -void vtkGbSphere3D::setValues(void) -{ - this->source->SetCenter( this->gbSphere->getX1Centroid(), - this->gbSphere->getX2Centroid(), - this->gbSphere->getX3Centroid() ); - - this->source->SetRadius( this->gbSphere->getRadius() ); -// this->actor->SetVisibility( this->gbSphere->isActive() ); -} - -void vtkGbSphere3D::applyActorModifications() -{ - if (this->isModified) - { - //double a_orien[3]; - double pos[3]; - double scale[3]; - this->actor->GetPosition(pos); - //this->actor->GetOrientation(a_orien); - this->actor->GetScale(scale); - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; - //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; - //cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl; - - if (scale[0] != 1.0) this->gbSphere->scale(scale[0], scale[1], scale[2]); - else this->gbSphere->translate(pos[0], pos[1], pos[2]); - this->gbSphere->notifyObserversObjectChanged(); - - vtkPoElement3D::applyActorModifications(); - } -} - -bool vtkGbSphere3D::isPointInObject(double const point[3]) -{ - return this->gbSphere->isPointInGbObject3D(point[0], point[1], point[2]); -} - -//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert. -void vtkGbSphere3D::objectChanged(UbObservable*) -{ - this->setValues(); - this->source->Modified(); - this->actor->Modified(); -} - -void vtkGbSphere3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbSphere->removeObserver(this); - delete this; -} - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h deleted file mode 100644 index ec086a6470c0330dbeed2e0566c583f9ff3a50bf..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VTKGBSPHERE3D_H -#define VTKGBSPHERE3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" -//#include "./../../../../vtkEventListeners.h" - -class GbSphere3D; - -class vtkSphereSource; -class vtkPolyDataMapper; - -class vtkGbSphere3D : public vtkPoElement3D -{ -public: - vtkGbSphere3D(GbSphere3D*); - ~vtkGbSphere3D(void); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); - - virtual string toString() { return "vtkGbSphere3D"; } - -protected: - void setValues(); - - GbSphere3D* gbSphere; - vtkPolyDataMapper* mapper; - vtkSphereSource* source; -}; -#endif - diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp deleted file mode 100644 index 92f08be6390098e56a82d6382aa29c56250190e3..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include "./vtkGbTriangularMesh3D.h" - -/**** CAB ****/ -#include "./../GbTriangularMesh3D.h" -#include "./../GbTriangle3D.h" -#include "./../../../basics/utilities/UbMath.h" - -/**** vtk ****/ -#include "vtkUnstructuredGrid.h" -#include "vtkDataSetMapper.h" -#include "vtkPoints.h" -#include "vtkTriangle.h" -#include "vtkIdList.h" - -/*** temp ****/ -#include "./../GbPoint3D.h" -#include "vtkMatrix4x4.h" - -//#define PI 3.14159265358979323846 - -vtkGbTriangularMesh3D::vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh) -{ - this->gbTriangularMesh = mesh; - this->gbTriangularMesh->addObserver(this); - - this->setName("vtkGbTriangularMesh3D"); - - this->unstGrid = vtkUnstructuredGrid::New(); - this->buildGrid(); - - - this->dataSetMapper = vtkDataSetMapper::New(); - this->dataSetMapper->SetInput(unstGrid); - - this->actor->SetMapper( this->dataSetMapper ); -} - -vtkGbTriangularMesh3D::~vtkGbTriangularMesh3D(void) -{ - this->gbTriangularMesh->removeObserver(this); - this->unstGrid->Delete(); - this->dataSetMapper->Delete(); -} - -//void vtkGbTriangularMesh3D::ModifiedEventFired() -//{ -// double pos[3]; -// this->actor->GetPosition(pos); -// -// this->actor->SetPosition(0.0,0.0,0.0); -// this->actor->SetOrientation(0.0,0.0,0.0); -// this->actor->SetScale(1.0,1.0,1.0); -// -// double x1 = pos[0]; -// double x2 = pos[1]; -// double x3 = pos[3]; -// -// vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes(); -// for (int pos=0; pos<pointList->size(); pos++) -// { -// (*pointList)[pos]->translate(x1,x2,x3); -// //((*pointList)[pos])->translate(pos[0], pos[1], pos[3]); -// } -// this->gbTriangularMesh->notifyObserversObjectChanged(); -//} - -void vtkGbTriangularMesh3D::applyActorModifications() -{ - if (isModified) - { - double pos[3]; - double orien[3]; - double scale[3]; - this->actor->GetPosition(pos); - this->actor->GetOrientation(orien); - this->actor->GetScale(scale); - - orien[0] = orien[0] / 180 * UbMath::PI; - orien[1] = orien[1] / 180 * UbMath::PI; - orien[2] = orien[2] / 180 * UbMath::PI; - - //cout<<"Orien:"<<orien[0]<<","<<orien[1]<<","<<orien[3]<<endl; - //cout<<"Position:"<<pos[0]<<","<<pos[1]<<","<<pos[3]<<endl; - //cout<<"Scale:"<<scale[0]<<","<<scale[1]<<","<<scale[3]<<endl; - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes(); - for (int index=0; index<(int)pointList->size(); index++) - { - (*pointList)[index]->rotate(orien[0], orien[1], orien[2]); - (*pointList)[index]->scale(scale[0], scale[1], scale[2]); - (*pointList)[index]->translate(pos[0], pos[1], pos[2]); - } - this->gbTriangularMesh->notifyObserversObjectChanged(); - //Methode der Basisklasse aufrufen. - vtkPoElement3D::applyActorModifications(); - } -} - -void vtkGbTriangularMesh3D::buildGrid(void) -{ - this->unstGrid->Reset(); - - vector<GbTriangle3D*>* triangles = this->gbTriangularMesh->getTriangles(); - double xyz[3]; - //this.setContext(new PoContext3D()); - - vtkPoints* points = vtkPoints::New(); - vtkTriangle* triangle = vtkTriangle::New(); - for(int u=0; u<(int)triangles->size(); u++) - { - xyz[0] = (*triangles)[u]->getPoint(0)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(0)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(0)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(0, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - xyz[0] = (*triangles)[u]->getPoint(1)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(1)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(1)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(1, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - xyz[0] = (*triangles)[u]->getPoint(2)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(2)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(2)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(2, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - this->insertNextCell( triangle->GetCellType(), triangle->GetPointIds() ); // grid topology - - } - this->setPoints(points); - //this->source->SetCenter( this->gbSphere->getX1Centroid(), - // this->gbSphere->getX2Centroid(), - // this->gbSphere->getX3Centroid() ); - - //this->source->SetRadius( this->gbSphere->getRadius() ); - //this->actor->SetVisibility( this->gbSphere->isActive() ); - //this->unstGrid->Modified(); -} - -int vtkGbTriangularMesh3D::insertNextCell(int type, vtkIdList* idList) -{ - return this->unstGrid->InsertNextCell(type, idList); -} - -void vtkGbTriangularMesh3D::setPoints(vtkPoints* points) -{ - this->unstGrid->SetPoints(points); -} - -void vtkGbTriangularMesh3D::objectChanged(UbObservable*) -{ - this->buildGrid(); - this->unstGrid->Update(); -} - -void vtkGbTriangularMesh3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbTriangularMesh->removeObserver(this); - delete this; -} diff --git a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h b/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h deleted file mode 100644 index 6d59515f29789949e4cfd3094802d073a61690dc..0000000000000000000000000000000000000000 --- a/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VTKGBTRIANGULARMESH3D_H -#define VTKGBTRIANGULARMESH3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -class GbTriangularMesh3D; -class vtkUnstructuredGrid; -class vtkDataSetMapper; -class vtkIdList; -class vtkPoints; - -class vtkGbTriangularMesh3D : public vtkPoElement3D -{ -public: - vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh); - ~vtkGbTriangularMesh3D(); - void objectChanged(UbObservable* ); - void objectWillBeDeleted(UbObservable* ); - int insertNextCell(int, vtkIdList*); - void setPoints(vtkPoints*); - //void ModifiedEventFired(void); - void applyActorModifications(); -protected: - void buildGrid(); - - GbTriangularMesh3D* gbTriangularMesh; - vtkUnstructuredGrid* unstGrid; - vtkDataSetMapper* dataSetMapper; -}; -#endif - diff --git a/ThirdParty/MarchingCubes/CMakePackage.txt b/ThirdParty/MarchingCubes/CMakePackage.txt deleted file mode 100644 index bea0c0b7df77f75944c36260ff48bb9353fc8394..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/CMakePackage.txt +++ /dev/null @@ -1,6 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption outSourceGroupName) - -IF(${outOption}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DMC_CUBES ) -ENDIF() diff --git a/ThirdParty/MarchingCubes/MarchingCubes.h b/ThirdParty/MarchingCubes/MarchingCubes.h deleted file mode 100644 index 2854983888eaeb71f4011099d3cd58e6b5f66051..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/MarchingCubes.h +++ /dev/null @@ -1,1640 +0,0 @@ -#ifndef MARCHINGCUBES_H -#define MARCHINGCUBES_H -/** -* @file MarchingCubes.h -* @author Thomas Lewiner <thomas.lewiner@polytechnique.org> -* @author Math Dept, PUC-Rio -* @version 0.2 -* @date 12/08/2002 -* -* @brief MarchingCubes Algorithm -*/ -//________________________________________________ - -#include <3rdParty/MarchingCubes/McTypes.h> -#include <3rdParty/MarchingCubes/MatrixWrapper.h> -#include <3rdParty/MarchingCubes/Matrix3DWrapper.h> -#include <3rdParty/MarchingCubes/Matrix4DWrapper.h> -#include <3rdParty/MarchingCubes/McLookUpTable.h> -#include <3rdParty/MarchingCubes/McPly.h> - -#include <cmath> -#include <ctime> -#include <cfloat> -#include <iostream> - -namespace McCubes{ -//_____________________________________________________________________________ -/** Marching Cubes algorithm wrapper */ -/** \class MarchingCubes - * \brief Marching Cubes algorithm. - */ -template<typename DataWrapper = MatrixWrapper<real> > -class MarchingCubes -//----------------------------------------------------------------------------- -{ -public: - //nested classes - //----------------------------------------------------------------------------- - // Vertex structure - /** \struct Vertex "MarchingCubes.h" MarchingCubes - * Position and normal of a vertex - * \brief vertex structure - * \param x X coordinate - * \param y Y coordinate - * \param z Z coordinate - * \param nx X component of the normal - * \param ny Y component of the normal - * \param nz Z component of the normal - */ - typedef struct Vertex - { - real x, y, z ; /**< Vertex coordinates */ - real nx, ny, nz ; /**< Vertex normal */ - } Vertex ; - - //----------------------------------------------------------------------------- - // Triangle structure - /** \struct Triangle "MarchingCubes.h" MarchingCubes - * Indices of the oriented triange vertices - * \brief triangle structure - * \param v1 First vertex index - * \param v2 Second vertex index - * \param v3 Third vertex index - */ - typedef struct Triangle - { - int v1,v2,v3 ; /**< Triangle vertices */ - } Triangle ; - //_____________________________________________________________________________ - -public : - // Constructors - /** - * Main and default constructor - * \brief constructor - * \param size_x width of the grid - * \param size_y depth of the grid - * \param size_z height of the grid - */ - MarchingCubes ( const int size_x = -1, const int size_y = -1, const int size_z = -1 ) ; - MarchingCubes ( const DataWrapper& dataWrapper ); - /** Destructor */ - ~MarchingCubes() ; - -//----------------------------------------------------------------------------- -// Accessors -public : - /** accesses the number of vertices of the generated mesh */ - inline const int nverts() const { return _nverts ; } - /** accesses the number of triangles of the generated mesh */ - inline const int ntrigs() const { return _ntrigs ; } - /** accesses a specific vertex of the generated mesh */ - inline Vertex * vert( const int i ) const { if( i < 0 || i >= _nverts ) return ( Vertex *)NULL ; return _vertices + i ; } - /** accesses a specific triangle of the generated mesh */ - inline Triangle * trig( const int i ) const { if( i < 0 || i >= _ntrigs ) return (Triangle*)NULL ; return _triangles + i ; } - - /** accesses the vertex buffer of the generated mesh */ - inline Vertex *vertices () { return _vertices ; } - /** accesses the triangle buffer of the generated mesh */ - inline Triangle *triangles() { return _triangles ; } - - /** accesses the width of the grid */ - inline const int size_x() const { return dataWrapper.getNX1(); /*_size_x ;*/ } - /** accesses the depth of the grid */ - inline const int size_y() const { return dataWrapper.getNX2(); /*_size_y ;*/ } - /** accesses the height of the grid */ - inline const int size_z() const { return dataWrapper.getNX3(); /*_size_z ;*/ } - - /** - * changes the size of the grid - * \param size_x width of the grid - * \param size_y depth of the grid - * \param size_z height of the grid - */ - inline void set_resolution( const int size_x, const int size_y, const int size_z ) - { - dataWrapper.resize(size_x, size_y, size_z); - //throw UbException("MarchingCubes::set_resolution disabled by CAB"); - //_size_x = size_x ; _size_y = size_y ; _size_z = size_z ; - } - /** - * selects wether the algorithm will use the enhanced topologically controlled lookup table or the original MarchingCubes - * \param originalMC true for the original Marching Cubes - */ - inline void set_method ( const bool originalMC = false ) { _originalMC = originalMC ; } - /** - * selects to use data from another class - * \param data is the pointer to the external data, allocated as a size_x*size_y*size_z vector running in x first - */ - inline void set_ext_data ( real *data ) - { - throw UbException(UB_EXARGS, "disabled by CAB"); - //if( !_ext_data ) delete [] _data ; _ext_data = data != NULL ; if( _ext_data ) _data = data ; - } - /** - * selects to allocate data - */ - inline void set_int_data () - { - throw UbException(UB_EXARGS,"disabled by CAB"); - //_ext_data = false ; _data = NULL ; - } - - // Data access - /** - * accesses a specific cube of the grid - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - //MODIFIED BY CAB - inline const real get_data ( const int& i, const int& j, const int& k ) const - { - return dataWrapper.getData(i,j,k); - //return _data[ i + j*_size_x + k*_size_x*_size_y] ; - } - /** - * sets a specific cube of the grid - * \param val new value for the cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - //MODIFIED BY CAB - inline void set_data ( const real& val, const int& i, const int& j, const int& k ) - { - dataWrapper.setData(val,i,j,k); - //_data[ i + j*_size_x + k*_size_x*_size_y] = val ; - } - - // Data initialization - /** inits temporary structures (must set sizes before call) : the grid and the vertex index per cube */ - void init_temps () ; - /** inits all structures (must set sizes before call) : the temporary structures and the mesh buffers */ - void init_all () ; - /** clears temporary structures : the grid and the main */ - void clean_temps() ; - /** clears all structures : the temporary structures and the mesh buffers */ - void clean_all () ; - - -//----------------------------------------------------------------------------- -// Exportation -public : - /** - * PLY exportation of the generated mesh - * \param fn name of the PLY file to create - * \param bin if true, the PLY will be written in binary mode - */ - void writePLY( const char *fn, bool bin = false ) ; - - /** - * VRML / Open Inventor exportation of the generated mesh - * \param fn name of the IV file to create - */ - void writeIV ( const char *fn ) ; - - /** - * ISO exportation of the input grid - * \param fn name of the ISO file to create - */ - void writeISO( const char *fn ) ; - - - void writeUCD( std::string filename ); - void writeUCDwithNormals( std::string filename ); - -//----------------------------------------------------------------------------- -// Algorithm -public : - /** - * Main algorithm : must be called after init_all - * \param iso isovalue - */ - void run( real iso = (real)0.0 ) ; - -protected : - /** tesselates one cube */ - void process_cube () ; - /** tests if the components of the tesselation of the cube should be connected by the interior of an ambiguous face */ - bool test_face ( schar face ) ; - /** tests if the components of the tesselation of the cube should be connected through the interior of the cube */ - bool test_interior( schar s ) ; - - -//----------------------------------------------------------------------------- -// Operations -protected : - /** - * computes almost all the vertices of the mesh by interpolation along the cubes edges - * \param iso isovalue - */ - void compute_intersection_points( real iso ) ; - - /** - * routine to add a triangle to the mesh - * \param trig the code for the triangle as a sequence of edges index - * \param n the number of triangles to produce - * \param v12 the index of the interior vertex to use, if necessary - */ - void add_triangle ( const char* trig, char n, int v12 = -1 ) ; - - /** tests and eventually doubles the vertex buffer capacity for a new vertex insertion */ - void test_vertex_addition() ; - /** adds a vertex on the current horizontal edge */ - int add_x_vertex() ; - /** adds a vertex on the current longitudinal edge */ - int add_y_vertex() ; - /** adds a vertex on the current vertical edge */ - int add_z_vertex() ; - /** adds a vertex inside the current cube */ - int add_c_vertex() ; - - /** - * interpolates the horizontal gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_x_grad( const int i, const int j, const int k ) const ; - /** - * interpolates the longitudinal gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_y_grad( const int i, const int j, const int k ) const ; - /** - * interpolates the vertical gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_z_grad( const int i, const int j, const int k ) const ; - - /** - * accesses the pre-computed vertex index on the lower horizontal edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_x_vert( const int i, const int j, const int k ) const { return _x_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] ; } - /** - * accesses the pre-computed vertex index on the lower longitudinal edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_y_vert( const int i, const int j, const int k ) const { return _y_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] ; } - /** - * accesses the pre-computed vertex index on the lower vertical edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_z_vert( const int i, const int j, const int k ) const { return _z_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] ; } - - /** - * sets the pre-computed vertex index on the lower horizontal edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_x_vert( const int val, const int i, const int j, const int k ) { _x_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] = val ; } - /** - * sets the pre-computed vertex index on the lower longitudinal edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_y_vert( const int val, const int i, const int j, const int k ) { _y_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] = val ; } - /** - * sets the pre-computed vertex index on the lower vertical edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_z_vert( const int val, const int i, const int j, const int k ) { _z_verts[ i + j*dataWrapper.getNX1() + k*dataWrapper.getNX1()*dataWrapper.getNX2()] = val ; } - - /** prints cube for debug */ - void print_cube(std::ostream& os) ; - -//----------------------------------------------------------------------------- -// Elements -protected : - bool _originalMC ; /**< selects wether the algorithm will use the enhanced topologically controlled lookup table or the original MarchingCubes */ -// bool _ext_data ; /**< selects wether to allocate data or use data from another class */ - -//folgendes ist nun alles folgenden dataWrapper: -// int _size_x ; /**< width of the grid */ -// int _size_y ; /**< depth of the grid */ -// int _size_z ; /**< height of the grid */ -//real *_data ; /**< implicit function values sampled on the grid */ - DataWrapper dataWrapper; - - int *_x_verts ; /**< pre-computed vertex indices on the lower horizontal edge of each cube */ - int *_y_verts ; /**< pre-computed vertex indices on the lower longitudinal edge of each cube */ - int *_z_verts ; /**< pre-computed vertex indices on the lower vertical edge of each cube */ - - int _nverts ; /**< number of allocated vertices in the vertex buffer */ - int _ntrigs ; /**< number of allocated triangles in the triangle buffer */ - int _Nverts ; /**< size of the vertex buffer */ - int _Ntrigs ; /**< size of the triangle buffer */ - Vertex *_vertices ; /**< vertex buffer */ - Triangle *_triangles ; /**< triangle buffer */ - - int _i ; /**< abscisse of the active cube */ - int _j ; /**< height of the active cube */ - int _k ; /**< ordinate of the active cube */ - - real _cube[8] ; /**< values of the implicit function on the active cube */ - uchar _lut_entry ; /**< cube sign representation in [0..255] */ - uchar _case ; /**< case of the active cube in [0..15] */ - uchar _config ; /**< configuration of the active cube */ - uchar _subconfig ; /**< subconfiguration of the active cube */ - -private: - MarchingCubes ( const MarchingCubes & ); //no copy allowed - const MarchingCubes& operator=( const MarchingCubes& ); //no copy allowed -}; -//_____________________________________________________________________________ - - -// step size of the arrays of vertices and triangles -static const int ALLOC_SIZE = 65536; - -//_____________________________________________________________________________ -// print cube for debug -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::print_cube(std::ostream& os) -{ - os<<_cube[0]<<","<<_cube[1]<<","<<_cube[2]<<","<<_cube[3]<<"," - <<_cube[4]<<","<<_cube[5]<<","<<_cube[6]<<","<<_cube[7]; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Constructors - -template<typename DataWrapper > -MarchingCubes< DataWrapper >::MarchingCubes( const int size_x /*= -1*/, const int size_y /*= -1*/, const int size_z /*= -1*/ ) : -_originalMC(false), -//_ext_data (false), -// _size_x (size_x), -// _size_y (size_y), -// _size_z (size_z), -//_data ((real *)NULL), -_x_verts (( int *)NULL), -_y_verts (( int *)NULL), -_z_verts (( int *)NULL), -_nverts (0), -_ntrigs (0), -_Nverts (0), -_Ntrigs (0), -_vertices (( Vertex *)NULL), -_triangles ((Triangle*)NULL) -{ - this->dataWrapper = DataWrapper(size_x,size_y,size_z); -} - -template<typename DataWrapper > -MarchingCubes< DataWrapper >::MarchingCubes ( const DataWrapper& dataWrapper ) : -_originalMC(false), -//_ext_data (false), -// _size_x (size_x), -// _size_y (size_y), -// _size_z (size_z), -//_data ((real *)NULL), -_x_verts (( int *)NULL), -_y_verts (( int *)NULL), -_z_verts (( int *)NULL), -_nverts (0), -_ntrigs (0), -_Nverts (0), -_Ntrigs (0), -_vertices (( Vertex *)NULL), -_triangles ((Triangle*)NULL) -{ - this->dataWrapper = dataWrapper; -} - -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Destructor -template<typename DataWrapper > -MarchingCubes<DataWrapper >::~MarchingCubes() -//----------------------------------------------------------------------------- -{ - clean_all() ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// main algorithm -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::run( real iso ) -//----------------------------------------------------------------------------- -{ - //printf("Marching Cubes begin: cpu %ld\n", clock() ) ; - - compute_intersection_points( iso ) ; - - for( _k = dataWrapper.getMinX3(); _k < dataWrapper.getMaxX3(); _k++ ) - for( _j = dataWrapper.getMinX2(); _j < dataWrapper.getMaxX2(); _j++ ) - for( _i = dataWrapper.getMinX1(); _i < dataWrapper.getMaxX1(); _i++ ) - { - _lut_entry = 0 ; - for( int p = 0 ; p < 8 ; ++p ) - { - _cube[p] = get_data( _i+((p^(p>>1))&1), _j+((p>>1)&1), _k+((p>>2)&1) ) - iso ; - if( std::fabs( _cube[p] ) < FLT_EPSILON ) _cube[p] = FLT_EPSILON ; - if( _cube[p] > 0 ) _lut_entry += 1 << p ; - } - /* - if( ( _cube[0] = get_data( _i , _j , _k ) ) > 0 ) _lut_entry += 1 ; - if( ( _cube[1] = get_data(_i+1, _j , _k ) ) > 0 ) _lut_entry += 2 ; - if( ( _cube[2] = get_data(_i+1,_j+1, _k ) ) > 0 ) _lut_entry += 4 ; - if( ( _cube[3] = get_data( _i ,_j+1, _k ) ) > 0 ) _lut_entry += 8 ; - if( ( _cube[4] = get_data( _i , _j ,_k+1) ) > 0 ) _lut_entry += 16 ; - if( ( _cube[5] = get_data(_i+1, _j ,_k+1) ) > 0 ) _lut_entry += 32 ; - if( ( _cube[6] = get_data(_i+1,_j+1,_k+1) ) > 0 ) _lut_entry += 64 ; - if( ( _cube[7] = get_data( _i ,_j+1,_k+1) ) > 0 ) _lut_entry += 128 ; - */ - process_cube( ) ; - } - - // printf("Marching Cubes end: cpu %ld\n", clock() ) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// init temporary structures (must set sizes before call) -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::init_temps() -//----------------------------------------------------------------------------- -{ -// if( !_ext_data ) -// _data = new real [_size_x * _size_y * _size_z] ; - _x_verts = new int [dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3()] ; - _y_verts = new int [dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3()] ; - _z_verts = new int [dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3()] ; - - memset( _x_verts, -1, dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3() * sizeof( int ) ) ; - memset( _y_verts, -1, dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3() * sizeof( int ) ) ; - memset( _z_verts, -1, dataWrapper.getNX1() * dataWrapper.getNX2() * dataWrapper.getNX3() * sizeof( int ) ) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// init all structures (must set sizes before call) -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::init_all () -//----------------------------------------------------------------------------- -{ - init_temps() ; - - _nverts = _ntrigs = 0 ; - _Nverts = _Ntrigs = ALLOC_SIZE ; - _vertices = new Vertex [_Nverts] ; - _triangles = new Triangle[_Ntrigs] ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// clean temporary structures -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::clean_temps() -//----------------------------------------------------------------------------- -{ -// if( !_ext_data ) -// delete [] _data; - delete [] _x_verts; - delete [] _y_verts; - delete [] _z_verts; - -// if( !_ext_data ) -// _data = (real*)NULL ; - _x_verts = (int*)NULL ; - _y_verts = (int*)NULL ; - _z_verts = (int*)NULL ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// clean all structures -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::clean_all() -//----------------------------------------------------------------------------- -{ - clean_temps() ; - delete [] _vertices ; - delete [] _triangles ; - _vertices = (Vertex *)NULL ; - _triangles = (Triangle *)NULL ; - _nverts = _ntrigs = 0 ; - _Nverts = _Ntrigs = 0 ; - - //_size_x = _size_y = _size_z = -1 ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -// Compute the intersection points -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::compute_intersection_points( real iso ) -//----------------------------------------------------------------------------- -{ - for( _k = 0 ; _k < dataWrapper.getNX3() ; _k++ ) - for( _j = 0 ; _j < dataWrapper.getNX2() ; _j++ ) - for( _i = 0 ; _i < dataWrapper.getNX1() ; _i++ ) - { - _cube[0] = get_data( _i, _j, _k ) - iso ; - if( _i < dataWrapper.getNX1() - 1 ) _cube[1] = get_data(_i+1, _j , _k ) - iso ; - else _cube[1] = _cube[0] ; - - if( _j < dataWrapper.getNX2() - 1 ) _cube[3] = get_data( _i ,_j+1, _k ) - iso ; - else _cube[3] = _cube[0] ; - - if( _k < dataWrapper.getNX3() - 1 ) _cube[4] = get_data( _i , _j ,_k+1) - iso ; - else _cube[4] = _cube[0] ; - - if( std::fabs( _cube[0] ) < FLT_EPSILON ) _cube[0] = FLT_EPSILON ; - if( std::fabs( _cube[1] ) < FLT_EPSILON ) _cube[1] = FLT_EPSILON ; - if( std::fabs( _cube[3] ) < FLT_EPSILON ) _cube[3] = FLT_EPSILON ; - if( std::fabs( _cube[4] ) < FLT_EPSILON ) _cube[4] = FLT_EPSILON ; - - if( _cube[0] < 0 ) - { - if( _cube[1] > 0 ) set_x_vert( add_x_vertex( ), _i,_j,_k ) ; - if( _cube[3] > 0 ) set_y_vert( add_y_vertex( ), _i,_j,_k ) ; - if( _cube[4] > 0 ) set_z_vert( add_z_vertex( ), _i,_j,_k ) ; - } - else - { - if( _cube[1] < 0 ) set_x_vert( add_x_vertex( ), _i,_j,_k ) ; - if( _cube[3] < 0 ) set_y_vert( add_y_vertex( ), _i,_j,_k ) ; - if( _cube[4] < 0 ) set_z_vert( add_z_vertex( ), _i,_j,_k ) ; - } - } -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// Test a face -// if face>0 return true if the face contains a part of the surface -template<typename DataWrapper > -bool MarchingCubes<DataWrapper >::test_face( schar face ) -//----------------------------------------------------------------------------- -{ - real A,B,C,D ; - - switch( face ) - { - case -1 : case 1 : A = _cube[0] ; B = _cube[4] ; C = _cube[5] ; D = _cube[1] ; break ; - case -2 : case 2 : A = _cube[1] ; B = _cube[5] ; C = _cube[6] ; D = _cube[2] ; break ; - case -3 : case 3 : A = _cube[2] ; B = _cube[6] ; C = _cube[7] ; D = _cube[3] ; break ; - case -4 : case 4 : A = _cube[3] ; B = _cube[7] ; C = _cube[4] ; D = _cube[0] ; break ; - case -5 : case 5 : A = _cube[0] ; B = _cube[3] ; C = _cube[2] ; D = _cube[1] ; break ; - case -6 : case 6 : A = _cube[4] ; B = _cube[7] ; C = _cube[6] ; D = _cube[5] ; break ; - default : - std::cerr<<" MarchingCubes<DataWrapper >::test_face ["<<__LINE__<<"]:: Invalid face code "<< face <<std::endl; - print_cube(std::cerr); - A = B = C = D = 0 ; - }; - - if( std::fabs( A*C - B*D ) < FLT_EPSILON ) - return face >= 0 ; - return face * A * ( A*C - B*D ) >= 0 ; // face and A invert signs -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// Test the interior of a cube -// if s == 7, return true if the interior is empty -// if s ==-7, return false if the interior is empty -template<typename DataWrapper > -bool MarchingCubes<DataWrapper >::test_interior( schar s ) -//----------------------------------------------------------------------------- -{ - real t, At=0, Bt=0, Ct=0, Dt=0, a, b ; - char test = 0 ; - char edge = -1 ; // reference edge of the triangulation - - switch( _case ) - { - case 4 : - case 10 : - a = ( _cube[4] - _cube[0] ) * ( _cube[6] - _cube[2] ) - ( _cube[7] - _cube[3] ) * ( _cube[5] - _cube[1] ) ; - b = _cube[2] * ( _cube[4] - _cube[0] ) + _cube[0] * ( _cube[6] - _cube[2] ) - - _cube[1] * ( _cube[7] - _cube[3] ) - _cube[3] * ( _cube[5] - _cube[1] ) ; - t = - b / (2*a) ; - if( t<0 || t>1 ) return s>0 ; - - At = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Bt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Ct = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Dt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - break ; - - case 6 : - case 7 : - case 12 : - case 13 : - switch( _case ) - { - case 6 : edge = test6 [_config][2] ; break ; - case 7 : edge = test7 [_config][4] ; break ; - case 12 : edge = test12[_config][3] ; break ; - case 13 : edge = tiling13_5_1[_config][_subconfig][0] ; break ; - } - switch( edge ) - { - case 0 : - t = _cube[0] / ( _cube[0] - _cube[1] ) ; - At = 0 ; - Bt = _cube[3] + ( _cube[2] - _cube[3] ) * t ; - Ct = _cube[7] + ( _cube[6] - _cube[7] ) * t ; - Dt = _cube[4] + ( _cube[5] - _cube[4] ) * t ; - break ; - case 1 : - t = _cube[1] / ( _cube[1] - _cube[2] ) ; - At = 0 ; - Bt = _cube[0] + ( _cube[3] - _cube[0] ) * t ; - Ct = _cube[4] + ( _cube[7] - _cube[4] ) * t ; - Dt = _cube[5] + ( _cube[6] - _cube[5] ) * t ; - break ; - case 2 : - t = _cube[2] / ( _cube[2] - _cube[3] ) ; - At = 0 ; - Bt = _cube[1] + ( _cube[0] - _cube[1] ) * t ; - Ct = _cube[5] + ( _cube[4] - _cube[5] ) * t ; - Dt = _cube[6] + ( _cube[7] - _cube[6] ) * t ; - break ; - case 3 : - t = _cube[3] / ( _cube[3] - _cube[0] ) ; - At = 0 ; - Bt = _cube[2] + ( _cube[1] - _cube[2] ) * t ; - Ct = _cube[6] + ( _cube[5] - _cube[6] ) * t ; - Dt = _cube[7] + ( _cube[4] - _cube[7] ) * t ; - break ; - case 4 : - t = _cube[4] / ( _cube[4] - _cube[5] ) ; - At = 0 ; - Bt = _cube[7] + ( _cube[6] - _cube[7] ) * t ; - Ct = _cube[3] + ( _cube[2] - _cube[3] ) * t ; - Dt = _cube[0] + ( _cube[1] - _cube[0] ) * t ; - break ; - case 5 : - t = _cube[5] / ( _cube[5] - _cube[6] ) ; - At = 0 ; - Bt = _cube[4] + ( _cube[7] - _cube[4] ) * t ; - Ct = _cube[0] + ( _cube[3] - _cube[0] ) * t ; - Dt = _cube[1] + ( _cube[2] - _cube[1] ) * t ; - break ; - case 6 : - t = _cube[6] / ( _cube[6] - _cube[7] ) ; - At = 0 ; - Bt = _cube[5] + ( _cube[4] - _cube[5] ) * t ; - Ct = _cube[1] + ( _cube[0] - _cube[1] ) * t ; - Dt = _cube[2] + ( _cube[3] - _cube[2] ) * t ; - break ; - case 7 : - t = _cube[7] / ( _cube[7] - _cube[4] ) ; - At = 0 ; - Bt = _cube[6] + ( _cube[5] - _cube[6] ) * t ; - Ct = _cube[2] + ( _cube[1] - _cube[2] ) * t ; - Dt = _cube[3] + ( _cube[0] - _cube[3] ) * t ; - break ; - case 8 : - t = _cube[0] / ( _cube[0] - _cube[4] ) ; - At = 0 ; - Bt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Ct = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Dt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - break ; - case 9 : - t = _cube[1] / ( _cube[1] - _cube[5] ) ; - At = 0 ; - Bt = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Ct = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Dt = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - break ; - case 10 : - t = _cube[2] / ( _cube[2] - _cube[6] ) ; - At = 0 ; - Bt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - Ct = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Dt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - break ; - case 11 : - t = _cube[3] / ( _cube[3] - _cube[7] ) ; - At = 0 ; - Bt = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Ct = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - Dt = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - break ; - default : - std::cerr<<" MarchingCubes<DataWrapper >::test_interior ["<<__LINE__<<"]: Invalid edge "<< edge <<std::endl; - print_cube(std::cerr); - break; - } - break ; - - default : - std::cerr<<" MarchingCubes<DataWrapper >::test_interior ["<<__LINE__<<"]: Invalid ambiguous case "<< _case <<std::endl; - print_cube(std::cerr); - break; - } - - if( At >= 0 ) test ++ ; - if( Bt >= 0 ) test += 2 ; - if( Ct >= 0 ) test += 4 ; - if( Dt >= 0 ) test += 8 ; - switch( test ) - { - case 0 : return s>0 ; - case 1 : return s>0 ; - case 2 : return s>0 ; - case 3 : return s>0 ; - case 4 : return s>0 ; - case 5 : if( At * Ct - Bt * Dt < FLT_EPSILON ) return s>0 ; break ; - case 6 : return s>0 ; - case 7 : return s<0 ; - case 8 : return s>0 ; - case 9 : return s>0 ; - case 10 : if( At * Ct - Bt * Dt >= FLT_EPSILON ) return s>0 ; break ; - case 11 : return s<0 ; - case 12 : return s>0 ; - case 13 : return s<0 ; - case 14 : return s<0 ; - case 15 : return s<0 ; - } - - return s<0 ; -} -//_____________________________________________________________________________ - - - - -//_____________________________________________________________________________ -// Process a unit cube -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::process_cube( ) -//----------------------------------------------------------------------------- -{ - if( _originalMC ) - { - char nt = 0 ; - while( casesClassic[_lut_entry][3*nt] != -1 ) nt++ ; - add_triangle( casesClassic[_lut_entry], nt ) ; - return ; - } - - int v12 = -1 ; - _case = cases[_lut_entry][0] ; - _config = cases[_lut_entry][1] ; - _subconfig = 0 ; - - switch( _case ) - { - case 0 : - break ; - - case 1 : - add_triangle( tiling1[_config], 1 ) ; - break ; - - case 2 : - add_triangle( tiling2[_config], 2 ) ; - break ; - - case 3 : - if( test_face( test3[_config]) ) - add_triangle( tiling3_2[_config], 4 ) ; // 3.2 - else - add_triangle( tiling3_1[_config], 2 ) ; // 3.1 - break ; - - case 4 : - if( test_interior( test4[_config]) ) - add_triangle( tiling4_1[_config], 2 ) ; // 4.1.1 - else - add_triangle( tiling4_2[_config], 6 ) ; // 4.1.2 - break ; - - case 5 : - add_triangle( tiling5[_config], 3 ) ; - break ; - - case 6 : - if( test_face( test6[_config][0]) ) - add_triangle( tiling6_2[_config], 5 ) ; // 6.2 - else - { - if( test_interior( test6[_config][1]) ) - add_triangle( tiling6_1_1[_config], 3 ) ; // 6.1.1 - else - add_triangle( tiling6_1_2[_config], 7 ) ; // 6.1.2 - } - break ; - - case 7 : - if( test_face( test7[_config][0] ) ) _subconfig += 1 ; - if( test_face( test7[_config][1] ) ) _subconfig += 2 ; - if( test_face( test7[_config][2] ) ) _subconfig += 4 ; - switch( _subconfig ) - { - case 0 : - add_triangle( tiling7_1[_config], 3 ) ; break ; - case 1 : - add_triangle( tiling7_2[_config][0], 5 ) ; break ; - case 2 : - add_triangle( tiling7_2[_config][1], 5 ) ; break ; - case 3 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][0], 9, v12 ) ; break ; - case 4 : - add_triangle( tiling7_2[_config][2], 5 ) ; break ; - case 5 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][1], 9, v12 ) ; break ; - case 6 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][2], 9, v12 ) ; break ; - case 7 : - if( test_interior( test7[_config][3]) ) - add_triangle( tiling7_4_2[_config], 9 ) ; - else - add_triangle( tiling7_4_1[_config], 5 ) ; - break ; - }; - break ; - - case 8 : - add_triangle( tiling8[_config], 2 ) ; - break ; - - case 9 : - add_triangle( tiling9[_config], 4 ) ; - break ; - - case 10 : - if( test_face( test10[_config][0]) ) - { - if( test_face( test10[_config][1]) ) - add_triangle( tiling10_1_1_[_config], 4 ) ; // 10.1.1 - else - { - v12 = add_c_vertex() ; - add_triangle( tiling10_2[_config], 8, v12 ) ; // 10.2 - } - } - else - { - if( test_face( test10[_config][1]) ) - { - v12 = add_c_vertex() ; - add_triangle( tiling10_2_[_config], 8, v12 ) ; // 10.2 - } - else - { - if( test_interior( test10[_config][2]) ) - add_triangle( tiling10_1_1[_config], 4 ) ; // 10.1.1 - else - add_triangle( tiling10_1_2[_config], 8 ) ; // 10.1.2 - } - } - break ; - - case 11 : - add_triangle( tiling11[_config], 4 ) ; - break ; - - case 12 : - if( test_face( test12[_config][0]) ) - { - if( test_face( test12[_config][1]) ) - add_triangle( tiling12_1_1_[_config], 4 ) ; // 12.1.1 - else - { - v12 = add_c_vertex() ; - add_triangle( tiling12_2[_config], 8, v12 ) ; // 12.2 - } - } - else - { - if( test_face( test12[_config][1]) ) - { - v12 = add_c_vertex() ; - add_triangle( tiling12_2_[_config], 8, v12 ) ; // 12.2 - } - else - { - if( test_interior( test12[_config][2]) ) - add_triangle( tiling12_1_1[_config], 4 ) ; // 12.1.1 - else - add_triangle( tiling12_1_2[_config], 8 ) ; // 12.1.2 - } - } - break ; - - case 13 : - if( test_face( test13[_config][0] ) ) _subconfig += 1 ; - if( test_face( test13[_config][1] ) ) _subconfig += 2 ; - if( test_face( test13[_config][2] ) ) _subconfig += 4 ; - if( test_face( test13[_config][3] ) ) _subconfig += 8 ; - if( test_face( test13[_config][4] ) ) _subconfig += 16 ; - if( test_face( test13[_config][5] ) ) _subconfig += 32 ; - switch( subconfig13[_subconfig] ) - { - case 0 :/* 13.1 */ - add_triangle( tiling13_1[_config], 4 ) ; break ; - - case 1 :/* 13.2 */ - add_triangle( tiling13_2[_config][0], 6 ) ; break ; - case 2 :/* 13.2 */ - add_triangle( tiling13_2[_config][1], 6 ) ; break ; - case 3 :/* 13.2 */ - add_triangle( tiling13_2[_config][2], 6 ) ; break ; - case 4 :/* 13.2 */ - add_triangle( tiling13_2[_config][3], 6 ) ; break ; - case 5 :/* 13.2 */ - add_triangle( tiling13_2[_config][4], 6 ) ; break ; - case 6 :/* 13.2 */ - add_triangle( tiling13_2[_config][5], 6 ) ; break ; - - case 7 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][0], 10, v12 ) ; break ; - case 8 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][1], 10, v12 ) ; break ; - case 9 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][2], 10, v12 ) ; break ; - case 10 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][3], 10, v12 ) ; break ; - case 11 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][4], 10, v12 ) ; break ; - case 12 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][5], 10, v12 ) ; break ; - case 13 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][6], 10, v12 ) ; break ; - case 14 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][7], 10, v12 ) ; break ; - case 15 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][8], 10, v12 ) ; break ; - case 16 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][9], 10, v12 ) ; break ; - case 17 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][10], 10, v12 ) ; break ; - case 18 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][11], 10, v12 ) ; break ; - - case 19 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][0], 12, v12 ) ; break ; - case 20 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][1], 12, v12 ) ; break ; - case 21 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][2], 12, v12 ) ; break ; - case 22 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][3], 12, v12 ) ; break ; - - case 23 :/* 13.5 */ - _subconfig = 0 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][0], 6 ) ; - else - add_triangle( tiling13_5_2[_config][0], 10 ) ; - break ; - case 24 :/* 13.5 */ - _subconfig = 1 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][1], 6 ) ; - else - add_triangle( tiling13_5_2[_config][1], 10 ) ; - break ; - case 25 :/* 13.5 */ - _subconfig = 2 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][2], 6 ) ; - else - add_triangle( tiling13_5_2[_config][2], 10 ) ; - break ; - case 26 :/* 13.5 */ - _subconfig = 3 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][3], 6 ) ; - else - add_triangle( tiling13_5_2[_config][3], 10 ) ; - break ; - - case 27 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][0], 10, v12 ) ; break ; - case 28 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][1], 10, v12 ) ; break ; - case 29 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][2], 10, v12 ) ; break ; - case 30 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][3], 10, v12 ) ; break ; - case 31 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][4], 10, v12 ) ; break ; - case 32 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][5], 10, v12 ) ; break ; - case 33 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][6], 10, v12 ) ; break ; - case 34 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][7], 10, v12 ) ; break ; - case 35 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][8], 10, v12 ) ; break ; - case 36 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][9], 10, v12 ) ; break ; - case 37 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][10], 10, v12 ) ; break ; - case 38 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][11], 10, v12 ) ; break ; - - case 39 :/* 13.2 */ - add_triangle( tiling13_2_[_config][0], 6 ) ; break ; - case 40 :/* 13.2 */ - add_triangle( tiling13_2_[_config][1], 6 ) ; break ; - case 41 :/* 13.2 */ - add_triangle( tiling13_2_[_config][2], 6 ) ; break ; - case 42 :/* 13.2 */ - add_triangle( tiling13_2_[_config][3], 6 ) ; break ; - case 43 :/* 13.2 */ - add_triangle( tiling13_2_[_config][4], 6 ) ; break ; - case 44 :/* 13.2 */ - add_triangle( tiling13_2_[_config][5], 6 ) ; break ; - - case 45 :/* 13.1 */ - add_triangle( tiling13_1_[_config], 4 ) ; break ; - - default : - std::cerr<<" MarchingCubes<DataWrapper >::process_cube ["<<__LINE__<<"]: Impossible case 13?"<<std::endl; - print_cube(std::cerr); - } - break ; - - case 14 : - add_triangle( tiling14[_config], 4 ) ; - break ; - }; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Adding triangles -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::add_triangle( const char* trig, char n, int v12 ) -//----------------------------------------------------------------------------- -{ - int tv[3] ; - - for( int t = 0 ; t < 3*n ; t++ ) - { - switch( trig[t] ) - { - case 0 : tv[ t % 3 ] = get_x_vert( _i , _j , _k ) ; break ; - case 1 : tv[ t % 3 ] = get_y_vert(_i+1, _j , _k ) ; break ; - case 2 : tv[ t % 3 ] = get_x_vert( _i ,_j+1, _k ) ; break ; - case 3 : tv[ t % 3 ] = get_y_vert( _i , _j , _k ) ; break ; - case 4 : tv[ t % 3 ] = get_x_vert( _i , _j ,_k+1) ; break ; - case 5 : tv[ t % 3 ] = get_y_vert(_i+1, _j ,_k+1) ; break ; - case 6 : tv[ t % 3 ] = get_x_vert( _i ,_j+1,_k+1) ; break ; - case 7 : tv[ t % 3 ] = get_y_vert( _i , _j ,_k+1) ; break ; - case 8 : tv[ t % 3 ] = get_z_vert( _i , _j , _k ) ; break ; - case 9 : tv[ t % 3 ] = get_z_vert(_i+1, _j , _k ) ; break ; - case 10 : tv[ t % 3 ] = get_z_vert(_i+1,_j+1, _k ) ; break ; - case 11 : tv[ t % 3 ] = get_z_vert( _i ,_j+1, _k ) ; break ; - case 12 : tv[ t % 3 ] = v12 ; break ; - default : break ; - } - - if( tv[t%3] == -1 ) - { - std::cerr<<"Marching Cubes::add_triangle ["<<__LINE__<<"]: invalid triangle "<<_ntrigs+1<<std::endl; - print_cube(std::cerr) ; - } - - if( t%3 == 2 ) - { - if( _ntrigs >= _Ntrigs ) - { - Triangle *temp = _triangles ; - _triangles = new Triangle[ 2*_Ntrigs ] ; - memcpy( _triangles, temp, _Ntrigs*sizeof(Triangle) ) ; - delete[] temp ; - //std::cout<<_Ntrigs <<" allocated triangles"<<std::endl; - _Ntrigs *= 2 ; - } - - Triangle *T = _triangles + _ntrigs++ ; - T->v1 = tv[0] ; - T->v2 = tv[1] ; - T->v3 = tv[2] ; - } - } -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Calculating gradient - -template<typename DataWrapper > -real MarchingCubes<DataWrapper >::get_x_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( i > 0 ) - { - if ( i < dataWrapper.getNX1() - 1 ) - return ( get_data( i+1, j, k ) - get_data( i-1, j, k ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i-1, j, k ) ; - } - else - return get_data( i+1, j, k ) - get_data( i, j, k ) ; -} -//----------------------------------------------------------------------------- - -template<typename DataWrapper > -real MarchingCubes<DataWrapper >::get_y_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( j > 0 ) - { - if ( j < dataWrapper.getNX2() - 1 ) - return ( get_data( i, j+1, k ) - get_data( i, j-1, k ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i, j-1, k ) ; - } - else - return get_data( i, j+1, k ) - get_data( i, j, k ) ; -} -//----------------------------------------------------------------------------- - -template<typename DataWrapper > -real MarchingCubes<DataWrapper >::get_z_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( k > 0 ) - { - if ( k < dataWrapper.getNX3() - 1 ) - return ( get_data( i, j, k+1 ) - get_data( i, j, k-1 ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i, j, k-1 ) ; - } - else - return get_data( i, j, k+1 ) - get_data( i, j, k ) ; -} -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -// Adding vertices - -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::test_vertex_addition() -{ - if( _nverts >= _Nverts ) - { - Vertex *temp = _vertices ; - _vertices = new Vertex[ _Nverts*2 ] ; - memcpy( _vertices, temp, _Nverts*sizeof(Vertex) ) ; - delete[] temp ; - //std::cout<<_Nverts<<" allocated vertices"<<std::endl; - _Nverts *= 2 ; - } -} - - -template<typename DataWrapper > -int MarchingCubes<DataWrapper >::add_x_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[1] ) ; - - vert->x = (real)_i+u; - vert->y = (real) _j ; - vert->z = (real) _k ; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i+1,_j,_k) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i+1,_j,_k) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i+1,_j,_k) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - - return _nverts-1 ; -} -//----------------------------------------------------------------------------- - -template<typename DataWrapper > -int MarchingCubes<DataWrapper >::add_y_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[3] ) ; - - vert->x = (real) _i ; - vert->y = (real)_j+u; - vert->z = (real) _k ; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i,_j+1,_k) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i,_j+1,_k) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i,_j+1,_k) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} -//----------------------------------------------------------------------------- - -template<typename DataWrapper > -int MarchingCubes<DataWrapper >::add_z_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[4] ) ; - - vert->x = (real) _i ; - vert->y = (real) _j ; - vert->z = (real)_k+u; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i,_j,_k+1) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i,_j,_k+1) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i,_j,_k+1) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} - - -template<typename DataWrapper > -int MarchingCubes<DataWrapper >::add_c_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = 0 ; - int vid ; - - vert->x = vert->y = vert->z = vert->nx = vert->ny = vert->nz = 0 ; - - // Computes the average of the intersection points of the cube - vid = get_x_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert(_i+1, _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i ,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i , _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert(_i+1, _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i ,_j+1,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert( _i , _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert(_i+1, _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert(_i+1,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert( _i ,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - - vert->x /= u ; - vert->y /= u ; - vert->z /= u ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ - - - - -//_____________________________________________________________________________ -// Grid exportation -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::writeISO(const char *fn ) -//----------------------------------------------------------------------------- -{ - unsigned char buf[sizeof(float)] ; - - FILE *fp = fopen( fn, "wb" ) ; - - // header - * (int*) buf = dataWrapper.getNX1() ; - fwrite(buf, sizeof(float), 1, fp); - * (int*) buf = dataWrapper.getNX2() ; - fwrite(buf, sizeof(float), 1, fp); - * (int*) buf = dataWrapper.getNX3(); - fwrite(buf, sizeof(float), 1, fp); - - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - - for( int i = 0 ; i < dataWrapper.getNX1() ; i++ ) - { - for( int j = 0 ; j < dataWrapper.getNX2() ; j++ ) - { - for( int k = 0 ; k < dataWrapper.getNX3() ; k++ ) - { - * (float*) buf = (float)get_data( i,j,k ) ; - fwrite(buf, sizeof(float), 1, fp); - } - } - } - - fclose(fp) ; -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// PLY exportation - -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::writePLY(const char *fn, bool bin ) -//----------------------------------------------------------------------------- -{ - - typedef struct PlyFace { - unsigned char nverts; /* number of Vertex indices in list */ - int *verts; /* Vertex index list */ - } PlyFace; - - - PlyProperty vert_props[] = { /* list of property information for a PlyVertex */ - {"x", Float32, Float32, offsetof( Vertex,x ), 0, 0, 0, 0}, - {"y", Float32, Float32, offsetof( Vertex,y ), 0, 0, 0, 0}, - {"z", Float32, Float32, offsetof( Vertex,z ), 0, 0, 0, 0}, - {"nx", Float32, Float32, offsetof( Vertex,nx ), 0, 0, 0, 0}, - {"ny", Float32, Float32, offsetof( Vertex,ny ), 0, 0, 0, 0}, - {"nz", Float32, Float32, offsetof( Vertex,nz ), 0, 0, 0, 0} - }; - - PlyProperty face_props[] = { /* list of property information for a PlyFace */ - {"vertex_indices", Int32, Int32, offsetof( PlyFace,verts ), - 1, Uint8, Uint8, offsetof( PlyFace,nverts )}, - }; - - - PlyFile *ply; - FILE *fp = fopen( fn, "w" ); - - int i ; - PlyFace face ; - int verts[3] ; - char *elem_names[] = { "vertex", "face" }; - std::cout<<"McCubes.MarchingCubes<DataWrapper >.writePLY ("<<fn<<")..."; - ply = write_ply ( fp, 2, elem_names, bin? PLY_BINARY_LE : PLY_ASCII ); - - /* describe what properties go into the PlyVertex elements */ - describe_element_ply ( ply, "vertex", _nverts ); - describe_property_ply ( ply, &vert_props[0] ); - describe_property_ply ( ply, &vert_props[1] ); - describe_property_ply ( ply, &vert_props[2] ); - describe_property_ply ( ply, &vert_props[3] ); - describe_property_ply ( ply, &vert_props[4] ); - describe_property_ply ( ply, &vert_props[5] ); - - /* describe PlyFace properties (just list of PlyVertex indices) */ - describe_element_ply ( ply, "face", _ntrigs ); - describe_property_ply ( ply, &face_props[0] ); - - header_complete_ply ( ply ); - - /* set up and write the PlyVertex elements */ - put_element_setup_ply ( ply, "vertex" ); - for ( i = 0; i < _nverts; i++ ) - put_element_ply ( ply, ( void * ) &(_vertices[i]) ); - std::cout<<_nverts<<" vertices written\n"; - - /* set up and write the PlyFace elements */ - put_element_setup_ply ( ply, "face" ); - face.nverts = 3 ; - face.verts = verts ; - for ( i = 0; i < _ntrigs; i++ ) - { - face.verts[0] = _triangles[i].v1 ; - face.verts[1] = _triangles[i].v2 ; - face.verts[2] = _triangles[i].v3 ; - put_element_ply ( ply, ( void * ) &face ); - } - std::cout<<_ntrigs<<" triangles written\n"; - - close_ply ( ply ); - free_ply ( ply ); - fclose( fp ) ; -} -//_____________________________________________________________________________ - -//_____________________________________________________________________________ -// Open Inventor / VRML 1.0 ascii exportation -template<typename DataWrapper > -void MarchingCubes<DataWrapper >::writeIV(const char *fn ) -//----------------------------------------------------------------------------- -{ - FILE *fp = fopen( fn, "w" ) ; - int i ; - - std::cout<<"Marching Cubes::exportIV("<<fn<<")..."; - - fprintf( fp, "#Inventor V2.1 ascii \n\nSeparator { \n ShapeHints {\n vertexOrdering COUNTERCLOCKWISE\n shapeType UNKNOWN_SHAPE_TYPE\n creaseAngle 0.0\n }\n Coordinate3 { \n point [ \n" ) ; - for ( i = 0; i < _nverts; i++ ) - fprintf( fp, " %f %f %f,\n", _vertices[i].x, _vertices[i].y, _vertices[i].z ) ; - std::cout<<_nverts<<" vertices written\n"; - - fprintf( fp, "\n ] \n} \nNormal { \nvector [ \n" ) ; - for ( i = 0; i < _nverts; i++ ) - fprintf( fp, " %f %f %f,\n", _vertices[i].nx, _vertices[i].ny, _vertices[i].nz ) ; - - fprintf( fp, "\n ] \n} \nIndexedFaceSet { \ncoordIndex [ \n" ) ; - for ( i = 0; i < _ntrigs; i++ ) - fprintf( fp, "%d, %d, %d, -1,\n", _triangles[i].v1, _triangles[i].v2, _triangles[i].v3 ) ; - - fprintf( fp, " ] \n } \n } \n" ) ; - fclose( fp ) ; - std::cout<<_ntrigs<<" triangles written\n"; -} - -/*=======================================================================*/ -template<typename DataWrapper > -void MarchingCubes< DataWrapper >::writeUCD( std::string filename ) -{ - std::cout<<"MarchingCubes::writeUCD("<<filename<<")..."; - - //Dreiecke in UCD Datei schreiben - std::ofstream out(filename.c_str()); - if(!out) throw UbException(UB_EXARGS,"couldn't open "+filename); - - out<<"# UCD-File containing triangulated geometry data"<<std::endl; - out<<this->nverts()<<" "<<this->ntrigs()<<" 0 0 0"<<std::endl; - - int count = 1; - for(int k=0;k<this->nverts();k++) - out<<count++<<" "<<_vertices[k].x<<" "<<_vertices[k].y<<" "<<_vertices[k].z<<std::endl; - - count = 1; - for(int k=0;k<this->ntrigs();k++) - out<<count++<<" "<<"1"<<" tri "<<_triangles[k].v1+1<<" " <<_triangles[k].v2+1<<" "<<_triangles[k].v3+1<<std::endl; - - out.flush(); - out.close(); - std::cout<<"done\n"; - -} - -template<typename DataWrapper > -void MarchingCubes< DataWrapper >::writeUCDwithNormals( std::string filename) -{ - std::cout<<"MarchingCubes::writeUCDwithNormals("<<filename<<")..."; - - //Dreiecke in UCD Datei schreiben - std::ofstream out(filename.c_str()); - if(!out) throw UbException(UB_EXARGS,"couldn't open "+filename); - - out<<"# UCD-File containing triangulated geometry data an vertex normals"<<std::endl; - out<<2*this->nverts()<<" "<<this->ntrigs()+this->nverts()<<" 0 0 0"<<std::endl; - - int count = 1; - for(int k=0;k<this->nverts();k++) out<<count++<<" "<<_vertices[k].x+_vertices[k].nx<<" "<<_vertices[k].y+_vertices[k].ny<<" "<<_vertices[k].z+_vertices[k].nz<<std::endl; - for(int k=0;k<this->nverts();k++) out<<count++<<" "<<_vertices[k].x+_vertices[k].nx<<" "<<_vertices[k].y+_vertices[k].ny<<" "<<_vertices[k].z+_vertices[k].nz<<std::endl; - - count = 1; - for(int k=0;k<this->ntrigs();k++) - out<<count++<<" "<<"1"<<" tri "<<_triangles[k].v1+1<<" " <<_triangles[k].v2+1<<" "<<_triangles[k].v3+1<<std::endl; - - for(int k=0;k<this->nverts();k++) - out<<count++<<" "<< "1"<<" line "<<k+1<<" " <<this->nverts()+k+1<<" "<<std::endl; - - out.flush(); - out.close(); - std::cout<<"done\n"; -} - -} //namespace McCubes - -#endif // _MARCHINGCUBES_H_ diff --git a/ThirdParty/MarchingCubes/Matrix3DWrapper.h b/ThirdParty/MarchingCubes/Matrix3DWrapper.h deleted file mode 100644 index 84482fc1f9aef3ede9b5bc1b414c25348aa4b1e6..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/Matrix3DWrapper.h +++ /dev/null @@ -1,126 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MATRIX3DWRAPPER_H -#define MATRIX3DWRAPPER_H - -//extension by CAB -#include <vector> -#include <string> -#include <fstream> - -#include <basics/utilities/UbException.h> -#include <3rdParty/MarchingCubes/McTypes.h> - -//neu: matrix muss lediglich double operator()(int x1, int x2, int x3) überladen, dann kann man sie verwenden!! - -////////////////////////////////////////////////////////////////////////// -//Matrix3DWrapper-Wrapper -// CbUniformMatrix3D<double> data(10,8,5); -// for(int x3=0; x3<data.getNX3(); x3++) -// for(int x2=0; x2<data.getNX2(); x2++) -// for(int x1=0; x1<data.getNX1(); x1++) -// data(x1,x2,x3) = x1; -// -// Matrix3DWrapper< CbUniformMatrix3D<double> > wrapper(&data); -// MarchingCubes< Matrix3DWrapper< CbUniformMatrix3D<double> > > mc( wrapper ); -// -// mc.init_all(); -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); - -namespace McCubes{ - -template< typename Matrix3D > -class Matrix3DWrapper -{ -public: - Matrix3DWrapper() - : matrix(NULL) - , minX1(-1), minX2(-1), minX3(-1) - , maxX1(-1), maxX2(-1), maxX3(-1) - , nx1(-1) , nx2(-1) , nx3(-1) - { - //wird benötigt, damit MarchingCubes generell eine membervariabel erstellen kann - } - /*==========================================================*/ - Matrix3DWrapper( Matrix3D* matrix) - : matrix(matrix) - { - nx1 = (int)matrix->getNX1(); - nx2 = (int)matrix->getNX2(); - nx3 = (int)matrix->getNX3(); - - minX1 = minX2 = minX3 = 0; - maxX1 = nx1-1; - maxX2 = nx2-1; - maxX3 = nx3-1; - } - /*==========================================================*/ - Matrix3DWrapper( Matrix3D* matrix, const int& n1, const int& nx2, const int& nx3) - : matrix(matrix) - , nx1(nx1), nx2(nx2), nx3(nx3) - { - minX1 = minX2 = minX3 = 0; - maxX1 = nx1-1; - maxX2 = nx2-1; - maxX3 = nx3-1; - } - /*==========================================================*/ - Matrix3DWrapper( Matrix3D* matrix, const int& minX1, const int& minX2, const int& minX3 - , const int& maxX1, const int& maxX2, const int& maxX3 ) - : matrix(matrix) - , minX1(minX1), minX2(minX2), minX3(minX3) - , maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) - { - nx1 = matrix->getNX1(); - nx2 = matrix->getNX2(); - nx3 = matrix->getNX3(); - - if(minX1<0 || minX2<0 || minX3<0 || maxX1>=nx1 || maxX2>=nx2 || maxX3>=nx3) - throw UbException(UB_EXARGS,"range error"); - } - /*==========================================================*/ - //wenn man z.B. matrixX1 von[0..10] geht und man nur den bereich 1..9 fuer MC - //verwenden möchte -> minX1=1 und maxX2=2 - Matrix3DWrapper( Matrix3D* matrix, const int& minX1, const int& minX2, const int& minX3 - , const int& maxX1, const int& maxX2, const int& maxX3 - , const int& n1 , const int& nx2 , const int& nx3 ) - : matrix(matrix) - , minX1(minX1), minX2(minX2), minX3(minX3) - , maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) - , nx1(n1) , nx2(nx2) , nx3(nx3) - { - if(minX1<0 || minX2<0 || minX3<0 || maxX1>=nx1 || maxX2>=nx2 || maxX3>=nx3) - throw UbException(UB_EXARGS,"range error"); - } - /*==========================================================*/ - inline real getData(const int& x1, const int& x2, const int& x3 ) const - { - return static_cast<real>( (*matrix)(x1, x2, x3) ); - } - /*==========================================================*/ - inline int getMinX1() const { return minX1; } - inline int getMinX2() const { return minX2; } - inline int getMinX3() const { return minX3; } - - inline int getMaxX1() const { return maxX1; } - inline int getMaxX2() const { return maxX2; } - inline int getMaxX3() const { return maxX3; } - - inline int getNX1() const { return nx1; } - inline int getNX2() const { return nx2; } - inline int getNX3() const { return nx3; } - -protected: - Matrix3D* matrix; - int minX1, minX2, minX3, maxX1, maxX2, maxX3, nx1, nx2, nx3; -}; - -} //namespace McCubes - -#endif //MATRIX3DWRAPPER_H diff --git a/ThirdParty/MarchingCubes/Matrix4DWrapper.h b/ThirdParty/MarchingCubes/Matrix4DWrapper.h deleted file mode 100644 index d4dc16976d81184468d7f1dd42cac9b05010f5cc..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/Matrix4DWrapper.h +++ /dev/null @@ -1,131 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MATRIX4DWRAPPER_H -#define MATRIX4DWRAPPER_H - -//extension by CAB -#include <vector> -#include <string> -#include <fstream> - -#include <basics/utilities/UbException.h> -#include <3rdParty/MarchingCubes/McTypes.h> - -//neu: matrix muss lediglich double operator()(int x1, int x2, int x3, int x4) überladen, dann kann man sie verwenden!! - -////////////////////////////////////////////////////////////////////////// -//Matrix4DWrapper-Wrapper -//example: -// int indexForDataValue = 1; -// CbUniformMatrix4D<double> data(10,8,5,2); -// for(int x3=0; x3<data.getNX3(); x3++) -// for(int x2=0; x2<data.getNX2(); x2++) -// for(int x1=0; x1<data.getNX1(); x1++) -// data(x1,x2,x3,indexForDataValue) = x1; -// -// Matrix4DWrapper< CbUniformMatrix4D<double> > wrapper(&data,indexForDataValue); -// MarchingCubes< Matrix4DWrapper< CbUniformMatrix4D<double> > > mc( wrapper ); -// -// mc.init_all(); -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); - -namespace McCubes{ - -template< typename Matrix4D > -class Matrix4DWrapper -{ -public: - Matrix4DWrapper() - : valIndex(-1), matrix(NULL) - , minX1(-1), minX2(-1), minX3(-1) - , maxX1(-1), maxX2(-1), maxX3(-1) - , nx1(-1) , nx2(-1) , nx3(-1) - { - //wird benötigt, damit MarchingCubes generell eine membervariabel erstellen kann - } - /*==========================================================*/ - Matrix4DWrapper( Matrix4D* matrix, const int& valIndex,const int& n1, const int& nx2, const int& nx3) - : valIndex(valIndex), matrix(matrix) - , nx1(nx1), nx2(nx2), nx3(nx3) - { - minX1 = minX2 = minX3 = 0; - maxX1 = nx1-1; - maxX2 = nx2-1; - maxX3 = nx3-1; - } - /*==========================================================*/ - Matrix4DWrapper( Matrix4D* matrix, const int& valIndex) - : valIndex(valIndex), matrix(matrix) - { - nx1 = matrix->getNX1(); - nx2 = matrix->getNX2(); - nx3 = matrix->getNX3(); - - minX1 = minX2 = minX3 = 0; - maxX1 = nx1-1; - maxX2 = nx2-1; - maxX3 = nx3-1; - } - /*==========================================================*/ - //wenn man z.B. matrixX1 von[0..10] geht und man nur den bereich 1..9 fuer MC - //verwenden möchte -> minX1=1 und maxX2=2 - Matrix4DWrapper( Matrix4D* matrix, const int& valIndex, const int& minX1, const int& minX2, const int& minX3, - const int& maxX1, const int& maxX2, const int& maxX3) - : valIndex(valIndex), matrix(matrix) - , minX1(minX1), minX2(minX2), minX3(minX3) - , maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) - { - nx1 = matrix->getNX1(); - nx2 = matrix->getNX2(); - nx3 = matrix->getNX3(); - - if(minX1<0 || minX2<0 || minX3<0 || maxX1>=nx1 || maxX2>=nx2 || maxX3>=nx3) - throw UbException(UB_EXARGS,"range error"); - } - /*==========================================================*/ - //wenn man z.B. matrixX1 von[0..10] geht und man nur den bereich 1..9 fuer MC - //verwenden möchte -> minX1=1 und maxX2=2 - Matrix4DWrapper( Matrix4D* matrix, const int& valIndex, const int& minX1, const int& minX2, const int& minX3 - , const int& maxX1, const int& maxX2, const int& maxX3 - , const int& n1 , const int& nx2 , const int& nx3 ) - : valIndex(valIndex), matrix(matrix) - , minX1(minX1), minX2(minX2), minX3(minX3) - , maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) - , nx1(nx1) , nx2(nx2) , nx3(nx3) - { - if(minX1<0 || minX2<0 || minX3<0 || maxX1>=nx1 || maxX2>=nx2 || maxX3>=nx3) - throw UbException(UB_EXARGS,"range error"); - } - /*==========================================================*/ - inline real getData(const int& x1, const int& x2, const int& x3 ) const - { - return static_cast<real>( (*matrix)(x1, x2, x3, valIndex) ); - } - /*==========================================================*/ - inline int getMinX1() const { return minX1; } - inline int getMinX2() const { return minX2; } - inline int getMinX3() const { return minX3; } - - inline int getMaxX1() const { return maxX1; } - inline int getMaxX2() const { return maxX2; } - inline int getMaxX3() const { return maxX3; } - - inline int getNX1() const { return nx1; } - inline int getNX2() const { return nx2; } - inline int getNX3() const { return nx3; } - -protected: - int valIndex; - Matrix4D* matrix; - int minX1, minX2, minX3, maxX1, maxX2, maxX3, nx1, nx2, nx3; -}; - -} //namespace McCubes - -#endif //MATRIX4DWRAPPER_H diff --git a/ThirdParty/MarchingCubes/MatrixWrapper.h b/ThirdParty/MarchingCubes/MatrixWrapper.h deleted file mode 100644 index ab0c29de4b1f8da3d4b39889e95350f6552058c5..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/MatrixWrapper.h +++ /dev/null @@ -1,131 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MATRIXWRAPPER_H -#define MATRIXWRAPPER_H - -//extension by CAB -#include <vector> -#include <string> -#include <fstream> - -#include <basics/utilities/UbException.h> - -#include <3rdParty/MarchingCubes/McTypes.h> - -////////////////////////////////////////////////////////////////////////// -//Standard-Wrapper -// MarchingCubes<DataWrapper> mc( 10,8,5 ); -// for(int z=0; z<mc.size_z(); z++) -// for(int y=0; y<mc.size_y(); y++) -// for(int x=0; x<mc.size_x(); x++) -// mc.set_data(x,x,y,z); -// -// mc.init_all(); -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); - -namespace McCubes{ - -template< typename T=real > -class MatrixWrapper -{ -public: - typedef T value_type; - typedef typename std::vector< value_type >::reference reference; - typedef typename std::vector< value_type >::const_reference const_reference; - typedef typename std::vector< value_type >::pointer pointer; - typedef typename std::vector< value_type >::const_pointer const_pointer; - -public: - MatrixWrapper() : nx1(-1), nx2(-1), nx3(-1) - { - } - /*==========================================================*/ - MatrixWrapper(const int& nx1, const int& nx2, const int& nx3, const T& initVal=T()) - { - this->resize(nx1,nx2,nx3,initVal); - } - /*=======================================================================*/ - reference operator() (const int& x1, const int& x2, const int& x3) - { - #ifdef _DEBUG - return this->data.at(x1 + x2*nx1 + x3*nx1*nx2); - #else - return this->data[x1 + x2*nx1 + x3*nx1*nx2]; - #endif - } - /*=======================================================================*/ - const_reference operator() (const int& x1, const int& x2, const int& x3) const - { - #ifdef _DEBUG - return this->data.at(x1 + x2*nx1 + x3*nx1*nx2); - #else - return this->data[x1 + x2*nx1 + x3*nx1*nx2]; - #endif - } - /*==========================================================*/ - inline void setData( const T& val, const int& x1, const int& x2, const int& x3 ) - { - #ifdef _DEBUG - this->data.at(x1 + x2*nx1 + x3*nx1*nx2) = val; - #else - this->data[x1 + x2*nx1 + x3*nx1*nx2] = val; - #endif - } - /*==========================================================*/ - inline value_type getData(const int& x1, const int& x2, const int& x3 ) const - { - #ifdef _DEBUG - return this->data.at(x1 + x2*nx1 + x3*nx1*nx2); - #else - return this->data[x1 + x2*nx1 + x3*nx1*nx2]; - #endif - } - /*==========================================================*/ - inline void resize(const int& nx1, const int& nx2, const int& nx3) - { - if(nx1>0 && nx2>0 && nx3>0) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->data.resize(nx1*nx2*nx3); - } - } - /*==========================================================*/ - inline void resize(const int& nx1, const int& nx2, const int& nx3, const T& initVal) - { - if(nx1>0 && nx2>0 && nx3>0) - { - this->nx1 = nx1; - this->nx2 = nx2; - this->nx3 = nx3; - this->data.resize(nx1*nx2*nx3,initVal); - } - } - /*==========================================================*/ - inline int getMinX1() const { return 0; } - inline int getMinX2() const { return 0; } - inline int getMinX3() const { return 0; } - - inline int getMaxX1() const { return nx1-1; } - inline int getMaxX2() const { return nx2-1; } - inline int getMaxX3() const { return nx3-1; } - - inline int getNX1() const { return nx1; } - inline int getNX2() const { return nx2; } - inline int getNX3() const { return nx3; } - -protected: - std::vector<T> data; - int nx1, nx2, nx3; -}; - -} //namespace McCubes - -#endif //MATRIXWRAPPER_H diff --git a/ThirdParty/MarchingCubes/McLookUpTable.h b/ThirdParty/MarchingCubes/McLookUpTable.h deleted file mode 100644 index 9fed1e50175da325347559c5f137a2f5c66e1985..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/McLookUpTable.h +++ /dev/null @@ -1,2320 +0,0 @@ -/** - * @file LookUpTable.h - * @author Thomas Lewiner <thomas.lewiner@polytechnique.org> - * @author Math Dept, PUC-Rio - * @version 0.2 - * @date 12/08/2002 - * - * @brief LookUpTable for the MarchingCubes 33 Algorithm - */ -//________________________________________________ - - - -#ifndef MCLOOKUPTABLE_H -#define MCLOOKUPTABLE_H - -namespace McCubes{ - -//_____________________________________________________________________________ -/** - * \brief case mapping - * For each of the possible vertex states listed in this table there is a - * specific triangulation of the edge intersection points. The table lists - * all of them in the form of 0-5 edge triples with the list terminated by - * the invalid value -1. For example: case[3] list the 2 triangles - * formed when cube[0] and cube[1] are inside of the surface, but the rest of - * the cube is not. - * - * Cube description: - * 7 ________ 6 _____6__ ________ - * /| /| 7/| /| /| /| - * / | / | / | /5 | / 6 / | - * 4 /_______ / | /__4____ / 10 /_______3/ | - * | | |5 | | 11 | | | | | 2 | - * | 3|__|_____|2 | |__|__2__| | 4 |__|_____| - * | / | / 8 3/ 9 / | / | / - * | / | / | / | /1 | / 5 / - * |/_______|/ |/___0___|/ |/_1_____|/ - * 0 1 0 1 - */ -//----------------------------------------------------------------------------- -static const char cases[256][2] = { -/* 0: */ { 0, -1 }, -/* 1: 0, */ { 1, 0 }, -/* 2: 1, */ { 1, 1 }, -/* 3: 0, 1, */ { 2, 0 }, -/* 4: 2, */ { 1, 2 }, -/* 5: 0, 2, */ { 3, 0 }, -/* 6: 1, 2, */ { 2, 3 }, -/* 7: 0, 1, 2, */ { 5, 0 }, -/* 8: 3, */ { 1, 3 }, -/* 9: 0, 3, */ { 2, 1 }, -/* 10: 1, 3, */ { 3, 3 }, -/* 11: 0, 1, 3, */ { 5, 1 }, -/* 12: 2, 3, */ { 2, 5 }, -/* 13: 0, 2, 3, */ { 5, 4 }, -/* 14: 1, 2, 3, */ { 5, 9 }, -/* 15: 0, 1, 2, 3, */ { 8, 0 }, -/* 16: 4, */ { 1, 4 }, -/* 17: 0, 4, */ { 2, 2 }, -/* 18: 1, 4, */ { 3, 4 }, -/* 19: 0, 1, 4, */ { 5, 2 }, -/* 20: 2, 4, */ { 4, 2 }, -/* 21: 0, 2, 4, */ { 6, 2 }, -/* 22: 1, 2, 4, */ { 6, 9 }, -/* 23: 0, 1, 2, 4, */ { 11, 0 }, -/* 24: 3, 4, */ { 3, 8 }, -/* 25: 0, 3, 4, */ { 5, 5 }, -/* 26: 1, 3, 4, */ { 7, 3 }, -/* 27: 0, 1, 3, 4, */ { 9, 1 }, -/* 28: 2, 3, 4, */ { 6, 16 }, -/* 29: 0, 2, 3, 4, */ { 14, 3 }, -/* 30: 1, 2, 3, 4, */ { 12, 12 }, -/* 31: 0, 1, 2, 3, 4, */ { 5, 24 }, -/* 32: 5, */ { 1, 5 }, -/* 33: 0, 5, */ { 3, 1 }, -/* 34: 1, 5, */ { 2, 4 }, -/* 35: 0, 1, 5, */ { 5, 3 }, -/* 36: 2, 5, */ { 3, 6 }, -/* 37: 0, 2, 5, */ { 7, 0 }, -/* 38: 1, 2, 5, */ { 5, 10 }, -/* 39: 0, 1, 2, 5, */ { 9, 0 }, -/* 40: 3, 5, */ { 4, 3 }, -/* 41: 0, 3, 5, */ { 6, 4 }, -/* 42: 1, 3, 5, */ { 6, 11 }, -/* 43: 0, 1, 3, 5, */ { 14, 1 }, -/* 44: 2, 3, 5, */ { 6, 17 }, -/* 45: 0, 2, 3, 5, */ { 12, 4 }, -/* 46: 1, 2, 3, 5, */ { 11, 6 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 25 }, -/* 48: 4, 5, */ { 2, 8 }, -/* 49: 0, 4, 5, */ { 5, 7 }, -/* 50: 1, 4, 5, */ { 5, 12 }, -/* 51: 0, 1, 4, 5, */ { 8, 1 }, -/* 52: 2, 4, 5, */ { 6, 18 }, -/* 53: 0, 2, 4, 5, */ { 12, 5 }, -/* 54: 1, 2, 4, 5, */ { 14, 7 }, -/* 55: 0, 1, 2, 4, 5, */ { 5, 28 }, -/* 56: 3, 4, 5, */ { 6, 21 }, -/* 57: 0, 3, 4, 5, */ { 11, 4 }, -/* 58: 1, 3, 4, 5, */ { 12, 15 }, -/* 59: 0, 1, 3, 4, 5, */ { 5, 30 }, -/* 60: 2, 3, 4, 5, */ { 10, 5 }, -/* 61: 0, 2, 3, 4, 5, */ { 6, 32 }, -/* 62: 1, 2, 3, 4, 5, */ { 6, 39 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 2, 12 }, -/* 64: 6, */ { 1, 6 }, -/* 65: 0, 6, */ { 4, 0 }, -/* 66: 1, 6, */ { 3, 5 }, -/* 67: 0, 1, 6, */ { 6, 0 }, -/* 68: 2, 6, */ { 2, 6 }, -/* 69: 0, 2, 6, */ { 6, 3 }, -/* 70: 1, 2, 6, */ { 5, 11 }, -/* 71: 0, 1, 2, 6, */ { 14, 0 }, -/* 72: 3, 6, */ { 3, 9 }, -/* 73: 0, 3, 6, */ { 6, 5 }, -/* 74: 1, 3, 6, */ { 7, 4 }, -/* 75: 0, 1, 3, 6, */ { 12, 1 }, -/* 76: 2, 3, 6, */ { 5, 14 }, -/* 77: 0, 2, 3, 6, */ { 11, 3 }, -/* 78: 1, 2, 3, 6, */ { 9, 4 }, -/* 79: 0, 1, 2, 3, 6, */ { 5, 26 }, -/* 80: 4, 6, */ { 3, 10 }, -/* 81: 0, 4, 6, */ { 6, 6 }, -/* 82: 1, 4, 6, */ { 7, 5 }, -/* 83: 0, 1, 4, 6, */ { 12, 2 }, -/* 84: 2, 4, 6, */ { 6, 19 }, -/* 85: 0, 2, 4, 6, */ { 10, 1 }, -/* 86: 1, 2, 4, 6, */ { 12, 13 }, -/* 87: 0, 1, 2, 4, 6, */ { 6, 24 }, -/* 88: 3, 4, 6, */ { 7, 7 }, -/* 89: 0, 3, 4, 6, */ { 12, 9 }, -/* 90: 1, 3, 4, 6, */ { 13, 1 }, -/* 91: 0, 1, 3, 4, 6, */ { 7, 9 }, -/* 92: 2, 3, 4, 6, */ { 12, 20 }, -/* 93: 0, 2, 3, 4, 6, */ { 6, 33 }, -/* 94: 1, 2, 3, 4, 6, */ { 7, 13 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 3, 12 }, -/* 96: 5, 6, */ { 2, 10 }, -/* 97: 0, 5, 6, */ { 6, 7 }, -/* 98: 1, 5, 6, */ { 5, 13 }, -/* 99: 0, 1, 5, 6, */ { 11, 2 }, -/* 100: 2, 5, 6, */ { 5, 16 }, -/* 101: 0, 2, 5, 6, */ { 12, 7 }, -/* 102: 1, 2, 5, 6, */ { 8, 3 }, -/* 103: 0, 1, 2, 5, 6, */ { 5, 29 }, -/* 104: 3, 5, 6, */ { 6, 22 }, -/* 105: 0, 3, 5, 6, */ { 10, 2 }, -/* 106: 1, 3, 5, 6, */ { 12, 17 }, -/* 107: 0, 1, 3, 5, 6, */ { 6, 27 }, -/* 108: 2, 3, 5, 6, */ { 14, 9 }, -/* 109: 0, 2, 3, 5, 6, */ { 6, 34 }, -/* 110: 1, 2, 3, 5, 6, */ { 5, 39 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 2, 14 }, -/* 112: 4, 5, 6, */ { 5, 20 }, -/* 113: 0, 4, 5, 6, */ { 14, 5 }, -/* 114: 1, 4, 5, 6, */ { 9, 5 }, -/* 115: 0, 1, 4, 5, 6, */ { 5, 32 }, -/* 116: 2, 4, 5, 6, */ { 11, 10 }, -/* 117: 0, 2, 4, 5, 6, */ { 6, 35 }, -/* 118: 1, 2, 4, 5, 6, */ { 5, 41 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 2, 16 }, -/* 120: 3, 4, 5, 6, */ { 12, 23 }, -/* 121: 0, 3, 4, 5, 6, */ { 6, 37 }, -/* 122: 1, 3, 4, 5, 6, */ { 7, 14 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 3, 16 }, -/* 124: 2, 3, 4, 5, 6, */ { 6, 46 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 4, 6 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 3, 21 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 1, 8 }, -/* 128: 7, */ { 1, 7 }, -/* 129: 0, 7, */ { 3, 2 }, -/* 130: 1, 7, */ { 4, 1 }, -/* 131: 0, 1, 7, */ { 6, 1 }, -/* 132: 2, 7, */ { 3, 7 }, -/* 133: 0, 2, 7, */ { 7, 1 }, -/* 134: 1, 2, 7, */ { 6, 10 }, -/* 135: 0, 1, 2, 7, */ { 12, 0 }, -/* 136: 3, 7, */ { 2, 7 }, -/* 137: 0, 3, 7, */ { 5, 6 }, -/* 138: 1, 3, 7, */ { 6, 12 }, -/* 139: 0, 1, 3, 7, */ { 11, 1 }, -/* 140: 2, 3, 7, */ { 5, 15 }, -/* 141: 0, 2, 3, 7, */ { 9, 2 }, -/* 142: 1, 2, 3, 7, */ { 14, 6 }, -/* 143: 0, 1, 2, 3, 7, */ { 5, 27 }, -/* 144: 4, 7, */ { 2, 9 }, -/* 145: 0, 4, 7, */ { 5, 8 }, -/* 146: 1, 4, 7, */ { 6, 13 }, -/* 147: 0, 1, 4, 7, */ { 14, 2 }, -/* 148: 2, 4, 7, */ { 6, 20 }, -/* 149: 0, 2, 4, 7, */ { 12, 6 }, -/* 150: 1, 2, 4, 7, */ { 10, 3 }, -/* 151: 0, 1, 2, 4, 7, */ { 6, 25 }, -/* 152: 3, 4, 7, */ { 5, 18 }, -/* 153: 0, 3, 4, 7, */ { 8, 2 }, -/* 154: 1, 3, 4, 7, */ { 12, 16 }, -/* 155: 0, 1, 3, 4, 7, */ { 5, 31 }, -/* 156: 2, 3, 4, 7, */ { 11, 9 }, -/* 157: 0, 2, 3, 4, 7, */ { 5, 34 }, -/* 158: 1, 2, 3, 4, 7, */ { 6, 40 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 2, 13 }, -/* 160: 5, 7, */ { 3, 11 }, -/* 161: 0, 5, 7, */ { 7, 2 }, -/* 162: 1, 5, 7, */ { 6, 14 }, -/* 163: 0, 1, 5, 7, */ { 12, 3 }, -/* 164: 2, 5, 7, */ { 7, 6 }, -/* 165: 0, 2, 5, 7, */ { 13, 0 }, -/* 166: 1, 2, 5, 7, */ { 12, 14 }, -/* 167: 0, 1, 2, 5, 7, */ { 7, 8 }, -/* 168: 3, 5, 7, */ { 6, 23 }, -/* 169: 0, 3, 5, 7, */ { 12, 10 }, -/* 170: 1, 3, 5, 7, */ { 10, 4 }, -/* 171: 0, 1, 3, 5, 7, */ { 6, 28 }, -/* 172: 2, 3, 5, 7, */ { 12, 21 }, -/* 173: 0, 2, 3, 5, 7, */ { 7, 10 }, -/* 174: 1, 2, 3, 5, 7, */ { 6, 41 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 3, 13 }, -/* 176: 4, 5, 7, */ { 5, 21 }, -/* 177: 0, 4, 5, 7, */ { 9, 3 }, -/* 178: 1, 4, 5, 7, */ { 11, 8 }, -/* 179: 0, 1, 4, 5, 7, */ { 5, 33 }, -/* 180: 2, 4, 5, 7, */ { 12, 22 }, -/* 181: 0, 2, 4, 5, 7, */ { 7, 11 }, -/* 182: 1, 2, 4, 5, 7, */ { 6, 42 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 3, 14 }, -/* 184: 3, 4, 5, 7, */ { 14, 11 }, -/* 185: 0, 3, 4, 5, 7, */ { 5, 36 }, -/* 186: 1, 3, 4, 5, 7, */ { 6, 44 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 2, 17 }, -/* 188: 2, 3, 4, 5, 7, */ { 6, 47 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 3, 18 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 4, 7 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 1, 9 }, -/* 192: 6, 7, */ { 2, 11 }, -/* 193: 0, 6, 7, */ { 6, 8 }, -/* 194: 1, 6, 7, */ { 6, 15 }, -/* 195: 0, 1, 6, 7, */ { 10, 0 }, -/* 196: 2, 6, 7, */ { 5, 17 }, -/* 197: 0, 2, 6, 7, */ { 12, 8 }, -/* 198: 1, 2, 6, 7, */ { 11, 7 }, -/* 199: 0, 1, 2, 6, 7, */ { 6, 26 }, -/* 200: 3, 6, 7, */ { 5, 19 }, -/* 201: 0, 3, 6, 7, */ { 14, 4 }, -/* 202: 1, 3, 6, 7, */ { 12, 18 }, -/* 203: 0, 1, 3, 6, 7, */ { 6, 29 }, -/* 204: 2, 3, 6, 7, */ { 8, 4 }, -/* 205: 0, 2, 3, 6, 7, */ { 5, 35 }, -/* 206: 1, 2, 3, 6, 7, */ { 5, 40 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 2, 15 }, -/* 208: 4, 6, 7, */ { 5, 22 }, -/* 209: 0, 4, 6, 7, */ { 11, 5 }, -/* 210: 1, 4, 6, 7, */ { 12, 19 }, -/* 211: 0, 1, 4, 6, 7, */ { 6, 30 }, -/* 212: 2, 4, 6, 7, */ { 14, 10 }, -/* 213: 0, 2, 4, 6, 7, */ { 6, 36 }, -/* 214: 1, 2, 4, 6, 7, */ { 6, 43 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 4, 4 }, -/* 216: 3, 4, 6, 7, */ { 9, 7 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 37 }, -/* 218: 1, 3, 4, 6, 7, */ { 7, 15 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 3, 17 }, -/* 220: 2, 3, 4, 6, 7, */ { 5, 44 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 2, 19 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 3, 22 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 1, 10 }, -/* 224: 5, 6, 7, */ { 5, 23 }, -/* 225: 0, 5, 6, 7, */ { 12, 11 }, -/* 226: 1, 5, 6, 7, */ { 14, 8 }, -/* 227: 0, 1, 5, 6, 7, */ { 6, 31 }, -/* 228: 2, 5, 6, 7, */ { 9, 6 }, -/* 229: 0, 2, 5, 6, 7, */ { 7, 12 }, -/* 230: 1, 2, 5, 6, 7, */ { 5, 42 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 3, 15 }, -/* 232: 3, 5, 6, 7, */ { 11, 11 }, -/* 233: 0, 3, 5, 6, 7, */ { 6, 38 }, -/* 234: 1, 3, 5, 6, 7, */ { 6, 45 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 4, 5 }, -/* 236: 2, 3, 5, 6, 7, */ { 5, 45 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 3, 19 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 2, 21 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 1, 11 }, -/* 240: 4, 5, 6, 7, */ { 8, 5 }, -/* 241: 0, 4, 5, 6, 7, */ { 5, 38 }, -/* 242: 1, 4, 5, 6, 7, */ { 5, 43 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 2, 18 }, -/* 244: 2, 4, 5, 6, 7, */ { 5, 46 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 20 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 2, 22 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 1, 12 }, -/* 248: 3, 4, 5, 6, 7, */ { 5, 47 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 2, 20 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 3, 23 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 13 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 2, 23 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 1, 14 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 1, 15 }, -/* 255: 0, 1, 2, 3, 4, 5, 6, 7, */ { 0, -1 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling1[16][3] = { -/* 1: 0, */ { 0, 8, 3 }, -/* 2: 1, */ { 0, 1, 9 }, -/* 4: 2, */ { 1, 2, 10 }, -/* 8: 3, */ { 3, 11, 2 }, -/* 16: 4, */ { 4, 7, 8 }, -/* 32: 5, */ { 9, 5, 4 }, -/* 64: 6, */ { 10, 6, 5 }, -/* 128: 7, */ { 7, 6, 11 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 7, 11, 6 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 10, 5, 6 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 9, 4, 5 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 4, 8, 7 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 3, 2, 11 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 10, 2 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 0, 9, 1 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 0, 3, 8 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling2[24][6] = { -/* 3: 0, 1, */ { 1, 8, 3, 9, 8, 1 }, -/* 9: 0, 3, */ { 0, 11, 2, 8, 11, 0 }, -/* 17: 0, 4, */ { 4, 3, 0, 7, 3, 4 }, -/* 6: 1, 2, */ { 9, 2, 10, 0, 2, 9 }, -/* 34: 1, 5, */ { 0, 5, 4, 1, 5, 0 }, -/* 12: 2, 3, */ { 3, 10, 1, 11, 10, 3 }, -/* 68: 2, 6, */ { 1, 6, 5, 2, 6, 1 }, -/* 136: 3, 7, */ { 7, 2, 3, 6, 2, 7 }, -/* 48: 4, 5, */ { 9, 7, 8, 5, 7, 9 }, -/* 144: 4, 7, */ { 6, 8, 4, 11, 8, 6 }, -/* 96: 5, 6, */ { 10, 4, 9, 6, 4, 10 }, -/* 192: 6, 7, */ { 11, 5, 10, 7, 5, 11 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 11, 10, 5, 7, 11, 5 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 10, 9, 4, 6, 10, 4 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 6, 4, 8, 11, 6, 8 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 9, 8, 7, 5, 9, 7 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 7, 3, 2, 6, 7, 2 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 1, 5, 6, 2, 1, 6 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 3, 1, 10, 11, 3, 10 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 0, 4, 5, 1, 0, 5 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 9, 10, 2, 0, 9, 2 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 4, 0, 3, 7, 4, 3 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 0, 2, 11, 8, 0, 11 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 1, 3, 8, 9, 1, 8 } -}; -//_____________________________________________________________________________ - -//_____________________________________________________________________________ -/** - * \brief test table for case 3 - * One face to test - * When the test on the specified face is positive : 4 first triangles - * When the test on the specified face is negative : 2 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test3[24] = { -/* 5: 0, 2, */ 5, -/* 33: 0, 5, */ 1, -/* 129: 0, 7, */ 4, -/* 10: 1, 3, */ 5, -/* 18: 1, 4, */ 1, -/* 66: 1, 6, */ 2, -/* 36: 2, 5, */ 2, -/* 132: 2, 7, */ 3, -/* 24: 3, 4, */ 4, -/* 72: 3, 6, */ 3, -/* 80: 4, 6, */ 6, -/* 160: 5, 7, */ 6, -/* 95: 0, 1, 2, 3, 4, 6, */ -6, -/* 175: 0, 1, 2, 3, 5, 7, */ -6, -/* 183: 0, 1, 2, 4, 5, 7, */ -3, -/* 231: 0, 1, 2, 5, 6, 7, */ -4, -/* 123: 0, 1, 3, 4, 5, 6, */ -3, -/* 219: 0, 1, 3, 4, 6, 7, */ -2, -/* 189: 0, 2, 3, 4, 5, 7, */ -2, -/* 237: 0, 2, 3, 5, 6, 7, */ -1, -/* 245: 0, 2, 4, 5, 6, 7, */ -5, -/* 126: 1, 2, 3, 4, 5, 6, */ -4, -/* 222: 1, 2, 3, 4, 6, 7, */ -1, -/* 250: 1, 3, 4, 5, 6, 7, */ -5 -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 3.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling3_1[24][6] = { -/* 5: 0, 2, */ { 0, 8, 3, 1, 2, 10 }, -/* 33: 0, 5, */ { 9, 5, 4, 0, 8, 3 }, -/* 129: 0, 7, */ { 3, 0, 8, 11, 7, 6 }, -/* 10: 1, 3, */ { 1, 9, 0, 2, 3, 11 }, -/* 18: 1, 4, */ { 0, 1, 9, 8, 4, 7 }, -/* 66: 1, 6, */ { 9, 0, 1, 5, 10, 6 }, -/* 36: 2, 5, */ { 1, 2, 10, 9, 5, 4 }, -/* 132: 2, 7, */ { 10, 1, 2, 6, 11, 7 }, -/* 24: 3, 4, */ { 8, 4, 7, 3, 11, 2 }, -/* 72: 3, 6, */ { 2, 3, 11, 10, 6, 5 }, -/* 80: 4, 6, */ { 5, 10, 6, 4, 7, 8 }, -/* 160: 5, 7, */ { 4, 9, 5, 7, 6, 11 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 5, 9, 4, 11, 6, 7 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 6, 10, 5, 8, 7, 4 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 11, 3, 2, 5, 6, 10 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 7, 4, 8, 2, 11, 3 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 2, 1, 10, 7, 11, 6 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 10, 2, 1, 4, 5, 9 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 1, 0, 9, 6, 10, 5 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 9, 1, 0, 7, 4, 8 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 0, 9, 1, 11, 3, 2 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 8, 0, 3, 6, 7, 11 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 4, 5, 9, 3, 8, 0 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 3, 8, 0, 10, 2, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 3.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling3_2[24][12] = { -/* 5: 0, 2, */ { 10, 3, 2, 10, 8, 3, 10, 1, 0, 8, 10, 0 }, -/* 33: 0, 5, */ { 3, 4, 8, 3, 5, 4, 3, 0, 9, 5, 3, 9 }, -/* 129: 0, 7, */ { 6, 8, 7, 6, 0, 8, 6, 11, 3, 0, 6, 3 }, -/* 10: 1, 3, */ { 11, 0, 3, 11, 9, 0, 11, 2, 1, 9, 11, 1 }, -/* 18: 1, 4, */ { 7, 9, 4, 7, 1, 9, 7, 8, 0, 1, 7, 0 }, -/* 66: 1, 6, */ { 6, 1, 10, 6, 0, 1, 9, 0, 6, 9, 6, 5 }, -/* 36: 2, 5, */ { 4, 10, 5, 4, 2, 10, 4, 9, 1, 2, 4, 1 }, -/* 132: 2, 7, */ { 7, 2, 11, 7, 1, 2, 7, 6, 10, 1, 7, 10 }, -/* 24: 3, 4, */ { 2, 7, 11, 2, 4, 7, 2, 3, 8, 4, 2, 8 }, -/* 72: 3, 6, */ { 5, 11, 6, 5, 3, 11, 5, 10, 2, 3, 5, 2 }, -/* 80: 4, 6, */ { 8, 6, 7, 8, 10, 6, 8, 4, 5, 10, 8, 5 }, -/* 160: 5, 7, */ { 11, 5, 6, 11, 9, 5, 11, 7, 4, 9, 11, 4 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 6, 5, 11, 5, 9, 11, 4, 7, 11, 4, 11, 9 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 7, 6, 8, 6, 10, 8, 5, 4, 8, 5, 8, 10 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 6, 11, 5, 11, 3, 5, 2, 10, 5, 2, 5, 3 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 11, 7, 2, 7, 4, 2, 8, 3, 2, 8, 2, 4 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 11, 2, 7, 2, 1, 7, 10, 6, 7, 10, 7, 1 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 5, 10, 4, 10, 2, 4, 1, 9, 4, 1, 4, 2 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 10, 1, 6, 1, 0, 6, 6, 0, 9, 5, 6, 9 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 4, 9, 7, 9, 1, 7, 0, 8, 7, 0, 7, 1 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 0, 11, 0, 9, 11, 1, 2, 11, 1, 11, 9 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 7, 8, 6, 8, 0, 6, 3, 11, 6, 3, 6, 0 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 8, 4, 3, 4, 5, 3, 9, 0, 3, 9, 3, 5 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 2, 3, 10, 3, 8, 10, 0, 1, 10, 0, 10, 8 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 4 - * Interior to test - * When the test on the interior is negative : 2 first triangles - * When the test on the interior is positive : 6 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test4[8] = { -/* 65: 0, 6, */ 7, -/* 130: 1, 7, */ 7, -/* 20: 2, 4, */ 7, -/* 40: 3, 5, */ 7, -/* 215: 0, 1, 2, 4, 6, 7, */ -7, -/* 235: 0, 1, 3, 5, 6, 7, */ -7, -/* 125: 0, 2, 3, 4, 5, 6, */ -7, -/* 190: 1, 2, 3, 4, 5, 7, */ -7 -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 4.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling4_1[8][6] = { -/* 65: 0, 6, */ { 0, 8, 3, 5, 10, 6 }, -/* 130: 1, 7, */ { 0, 1, 9, 11, 7, 6 }, -/* 20: 2, 4, */ { 1, 2, 10, 8, 4, 7 }, -/* 40: 3, 5, */ { 9, 5, 4, 2, 3, 11 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 4, 5, 9, 11, 3, 2 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 10, 2, 1, 7, 4, 8 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 9, 1, 0, 6, 7, 11 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 3, 8, 0, 6, 10, 5 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 4.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling4_2[8][18] = { -/* 65: 0, 6, */ { 8, 5, 0, 5, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 5 }, -/* 130: 1, 7, */ { 9, 6, 1, 6, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 6 }, -/* 20: 2, 4, */ { 10, 7, 2, 7, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 7 }, -/* 40: 3, 5, */ { 11, 4, 3, 4, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 4 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 3, 4, 11, 5, 11, 4, 11, 5, 2, 9, 2, 5, 2, 9, 3, 4, 3, 9 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 2, 7, 10, 4, 10, 7, 10, 4, 1, 8, 1, 4, 1, 8, 2, 7, 2, 8 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 1, 6, 9, 7, 9, 6, 9, 7, 0, 11, 0, 7, 0, 11, 1, 6, 1, 11 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 0, 5, 8, 6, 8, 5, 8, 6, 3, 10, 3, 6, 3, 10, 0, 5, 0, 10 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 5 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling5[48][9] = { -/* 7: 0, 1, 2, */ { 2, 8, 3, 2, 10, 8, 10, 9, 8 }, -/* 11: 0, 1, 3, */ { 1, 11, 2, 1, 9, 11, 9, 8, 11 }, -/* 19: 0, 1, 4, */ { 4, 1, 9, 4, 7, 1, 7, 3, 1 }, -/* 35: 0, 1, 5, */ { 8, 5, 4, 8, 3, 5, 3, 1, 5 }, -/* 13: 0, 2, 3, */ { 0, 10, 1, 0, 8, 10, 8, 11, 10 }, -/* 25: 0, 3, 4, */ { 11, 4, 7, 11, 2, 4, 2, 0, 4 }, -/* 137: 0, 3, 7, */ { 7, 0, 8, 7, 6, 0, 6, 2, 0 }, -/* 49: 0, 4, 5, */ { 9, 3, 0, 9, 5, 3, 5, 7, 3 }, -/* 145: 0, 4, 7, */ { 3, 6, 11, 3, 0, 6, 0, 4, 6 }, -/* 14: 1, 2, 3, */ { 3, 9, 0, 3, 11, 9, 11, 10, 9 }, -/* 38: 1, 2, 5, */ { 5, 2, 10, 5, 4, 2, 4, 0, 2 }, -/* 70: 1, 2, 6, */ { 9, 6, 5, 9, 0, 6, 0, 2, 6 }, -/* 50: 1, 4, 5, */ { 0, 7, 8, 0, 1, 7, 1, 5, 7 }, -/* 98: 1, 5, 6, */ { 10, 0, 1, 10, 6, 0, 6, 4, 0 }, -/* 76: 2, 3, 6, */ { 6, 3, 11, 6, 5, 3, 5, 1, 3 }, -/* 140: 2, 3, 7, */ { 10, 7, 6, 10, 1, 7, 1, 3, 7 }, -/* 100: 2, 5, 6, */ { 1, 4, 9, 1, 2, 4, 2, 6, 4 }, -/* 196: 2, 6, 7, */ { 11, 1, 2, 11, 7, 1, 7, 5, 1 }, -/* 152: 3, 4, 7, */ { 8, 2, 3, 8, 4, 2, 4, 6, 2 }, -/* 200: 3, 6, 7, */ { 2, 5, 10, 2, 3, 5, 3, 7, 5 }, -/* 112: 4, 5, 6, */ { 7, 10, 6, 7, 8, 10, 8, 9, 10 }, -/* 176: 4, 5, 7, */ { 6, 9, 5, 6, 11, 9, 11, 8, 9 }, -/* 208: 4, 6, 7, */ { 5, 8, 4, 5, 10, 8, 10, 11, 8 }, -/* 224: 5, 6, 7, */ { 4, 11, 7, 4, 9, 11, 9, 10, 11 }, -/* 31: 0, 1, 2, 3, 4, */ { 4, 7, 11, 4, 11, 9, 9, 11, 10 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 4, 8, 5, 8, 10, 10, 8, 11 }, -/* 79: 0, 1, 2, 3, 6, */ { 6, 5, 9, 6, 9, 11, 11, 9, 8 }, -/* 143: 0, 1, 2, 3, 7, */ { 7, 6, 10, 7, 10, 8, 8, 10, 9 }, -/* 55: 0, 1, 2, 4, 5, */ { 2, 10, 5, 2, 5, 3, 3, 5, 7 }, -/* 103: 0, 1, 2, 5, 6, */ { 8, 3, 2, 8, 2, 4, 4, 2, 6 }, -/* 59: 0, 1, 3, 4, 5, */ { 11, 2, 1, 11, 1, 7, 7, 1, 5 }, -/* 155: 0, 1, 3, 4, 7, */ { 1, 9, 4, 1, 4, 2, 2, 4, 6 }, -/* 115: 0, 1, 4, 5, 6, */ { 10, 6, 7, 10, 7, 1, 1, 7, 3 }, -/* 179: 0, 1, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 5, 3, 1 }, -/* 157: 0, 2, 3, 4, 7, */ { 10, 1, 0, 10, 0, 6, 6, 0, 4 }, -/* 205: 0, 2, 3, 6, 7, */ { 0, 8, 7, 0, 7, 1, 1, 7, 5 }, -/* 185: 0, 3, 4, 5, 7, */ { 9, 5, 6, 9, 6, 0, 0, 6, 2 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 4, 2, 0 }, -/* 241: 0, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 11, 9, 10 }, -/* 110: 1, 2, 3, 5, 6, */ { 3, 11, 6, 3, 6, 0, 0, 6, 4 }, -/* 206: 1, 2, 3, 6, 7, */ { 9, 0, 3, 9, 3, 5, 5, 3, 7 }, -/* 118: 1, 2, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 6, 0, 2 }, -/* 230: 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 2, 4, 0 }, -/* 242: 1, 4, 5, 6, 7, */ { 0, 1, 10, 0, 10, 8, 8, 10, 11 }, -/* 220: 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 3, 5, 1 }, -/* 236: 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 7, 1, 3 }, -/* 244: 2, 4, 5, 6, 7, */ { 1, 2, 11, 1, 11, 9, 9, 11, 8 }, -/* 248: 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 10, 8, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief test table for case 6 - * 1 face to test + eventually the interior - * When the test on the specified face is positive : 5 first triangles - * When the test on the specified face is negative : - * - if the test on the interior is negative : 3 middle triangles - * - if the test on the interior is positive : 8 last triangles - * The support edge for the interior test is marked as the 3rd column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test6[48][3] = { -/* 67: 0, 1, 6, */ { 2, 7, 10 }, -/* 131: 0, 1, 7, */ { 4, 7, 11 }, -/* 21: 0, 2, 4, */ { 5, 7, 1 }, -/* 69: 0, 2, 6, */ { 5, 7, 3 }, -/* 41: 0, 3, 5, */ { 1, 7, 9 }, -/* 73: 0, 3, 6, */ { 3, 7, 10 }, -/* 81: 0, 4, 6, */ { 6, 7, 5 }, -/* 97: 0, 5, 6, */ { 1, 7, 8 }, -/* 193: 0, 6, 7, */ { 4, 7, 8 }, -/* 22: 1, 2, 4, */ { 1, 7, 8 }, -/* 134: 1, 2, 7, */ { 3, 7, 11 }, -/* 42: 1, 3, 5, */ { 5, 7, 2 }, -/* 138: 1, 3, 7, */ { 5, 7, 0 }, -/* 146: 1, 4, 7, */ { 1, 7, 9 }, -/* 162: 1, 5, 7, */ { 6, 7, 6 }, -/* 194: 1, 6, 7, */ { 2, 7, 9 }, -/* 28: 2, 3, 4, */ { 4, 7, 8 }, -/* 44: 2, 3, 5, */ { 2, 7, 9 }, -/* 52: 2, 4, 5, */ { 2, 7, 10 }, -/* 84: 2, 4, 6, */ { 6, 7, 7 }, -/* 148: 2, 4, 7, */ { 3, 7, 10 }, -/* 56: 3, 4, 5, */ { 4, 7, 11 }, -/* 104: 3, 5, 6, */ { 3, 7, 11 }, -/* 168: 3, 5, 7, */ { 6, 7, 4 }, -/* 87: 0, 1, 2, 4, 6, */ { -6, -7, 4 }, -/* 151: 0, 1, 2, 4, 7, */ { -3, -7, 11 }, -/* 199: 0, 1, 2, 6, 7, */ { -4, -7, 11 }, -/* 107: 0, 1, 3, 5, 6, */ { -3, -7, 10 }, -/* 171: 0, 1, 3, 5, 7, */ { -6, -7, 7 }, -/* 203: 0, 1, 3, 6, 7, */ { -2, -7, 10 }, -/* 211: 0, 1, 4, 6, 7, */ { -2, -7, 9 }, -/* 227: 0, 1, 5, 6, 7, */ { -4, -7, 8 }, -/* 61: 0, 2, 3, 4, 5, */ { -2, -7, 9 }, -/* 93: 0, 2, 3, 4, 6, */ { -6, -7, 6 }, -/* 109: 0, 2, 3, 5, 6, */ { -1, -7, 9 }, -/* 117: 0, 2, 4, 5, 6, */ { -5, -7, 0 }, -/* 213: 0, 2, 4, 6, 7, */ { -5, -7, 2 }, -/* 121: 0, 3, 4, 5, 6, */ { -3, -7, 11 }, -/* 233: 0, 3, 5, 6, 7, */ { -1, -7, 8 }, -/* 62: 1, 2, 3, 4, 5, */ { -4, -7, 8 }, -/* 158: 1, 2, 3, 4, 7, */ { -1, -7, 8 }, -/* 174: 1, 2, 3, 5, 7, */ { -6, -7, 5 }, -/* 182: 1, 2, 4, 5, 7, */ { -3, -7, 10 }, -/* 214: 1, 2, 4, 6, 7, */ { -1, -7, 9 }, -/* 186: 1, 3, 4, 5, 7, */ { -5, -7, 3 }, -/* 234: 1, 3, 5, 6, 7, */ { -5, -7, 1 }, -/* 124: 2, 3, 4, 5, 6, */ { -4, -7, 11 }, -/* 188: 2, 3, 4, 5, 7, */ { -2, -7, 10 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_1_1[48][9] = { -/* 67: 0, 1, 6, */ { 6, 5, 10, 3, 1, 8, 9, 8, 1 }, -/* 131: 0, 1, 7, */ { 11, 7, 6, 9, 3, 1, 3, 9, 8 }, -/* 21: 0, 2, 4, */ { 1, 2, 10, 7, 0, 4, 0, 7, 3 }, -/* 69: 0, 2, 6, */ { 3, 0, 8, 5, 2, 6, 2, 5, 1 }, -/* 41: 0, 3, 5, */ { 5, 4, 9, 2, 0, 11, 8, 11, 0 }, -/* 73: 0, 3, 6, */ { 10, 6, 5, 8, 2, 0, 2, 8, 11 }, -/* 81: 0, 4, 6, */ { 10, 6, 5, 0, 4, 3, 7, 3, 4 }, -/* 97: 0, 5, 6, */ { 3, 0, 8, 6, 4, 10, 9, 10, 4 }, -/* 193: 0, 6, 7, */ { 8, 3, 0, 10, 7, 5, 7, 10, 11 }, -/* 22: 1, 2, 4, */ { 8, 4, 7, 10, 0, 2, 0, 10, 9 }, -/* 134: 1, 2, 7, */ { 7, 6, 11, 0, 2, 9, 10, 9, 2 }, -/* 42: 1, 3, 5, */ { 2, 3, 11, 4, 1, 5, 1, 4, 0 }, -/* 138: 1, 3, 7, */ { 0, 1, 9, 6, 3, 7, 3, 6, 2 }, -/* 146: 1, 4, 7, */ { 9, 0, 1, 11, 4, 6, 4, 11, 8 }, -/* 162: 1, 5, 7, */ { 11, 7, 6, 1, 5, 0, 4, 0, 5 }, -/* 194: 1, 6, 7, */ { 0, 1, 9, 7, 5, 11, 10, 11, 5 }, -/* 28: 2, 3, 4, */ { 4, 7, 8, 1, 3, 10, 11, 10, 3 }, -/* 44: 2, 3, 5, */ { 9, 5, 4, 11, 1, 3, 1, 11, 10 }, -/* 52: 2, 4, 5, */ { 10, 1, 2, 8, 5, 7, 5, 8, 9 }, -/* 84: 2, 4, 6, */ { 8, 4, 7, 2, 6, 1, 5, 1, 6 }, -/* 148: 2, 4, 7, */ { 1, 2, 10, 4, 6, 8, 11, 8, 6 }, -/* 56: 3, 4, 5, */ { 2, 3, 11, 5, 7, 9, 8, 9, 7 }, -/* 104: 3, 5, 6, */ { 11, 2, 3, 9, 6, 4, 6, 9, 10 }, -/* 168: 3, 5, 7, */ { 9, 5, 4, 3, 7, 2, 6, 2, 7 }, -/* 87: 0, 1, 2, 4, 6, */ { 4, 5, 9, 2, 7, 3, 7, 2, 6 }, -/* 151: 0, 1, 2, 4, 7, */ { 3, 2, 11, 4, 6, 9, 10, 9, 6 }, -/* 199: 0, 1, 2, 6, 7, */ { 11, 3, 2, 9, 7, 5, 7, 9, 8 }, -/* 107: 0, 1, 3, 5, 6, */ { 10, 2, 1, 8, 6, 4, 6, 8, 11 }, -/* 171: 0, 1, 3, 5, 7, */ { 7, 4, 8, 1, 6, 2, 6, 1, 5 }, -/* 203: 0, 1, 3, 6, 7, */ { 2, 1, 10, 7, 5, 8, 9, 8, 5 }, -/* 211: 0, 1, 4, 6, 7, */ { 4, 5, 9, 3, 1, 11, 10, 11, 1 }, -/* 227: 0, 1, 5, 6, 7, */ { 8, 7, 4, 10, 3, 1, 3, 10, 11 }, -/* 61: 0, 2, 3, 4, 5, */ { 9, 1, 0, 11, 5, 7, 5, 11, 10 }, -/* 93: 0, 2, 3, 4, 6, */ { 6, 7, 11, 0, 5, 1, 5, 0, 4 }, -/* 109: 0, 2, 3, 5, 6, */ { 1, 0, 9, 6, 4, 11, 8, 11, 4 }, -/* 117: 0, 2, 4, 5, 6, */ { 9, 1, 0, 7, 3, 6, 2, 6, 3 }, -/* 213: 0, 2, 4, 6, 7, */ { 11, 3, 2, 5, 1, 4, 0, 4, 1 }, -/* 121: 0, 3, 4, 5, 6, */ { 11, 6, 7, 9, 2, 0, 2, 9, 10 }, -/* 233: 0, 3, 5, 6, 7, */ { 7, 4, 8, 2, 0, 10, 9, 10, 0 }, -/* 62: 1, 2, 3, 4, 5, */ { 0, 3, 8, 5, 7, 10, 11, 10, 7 }, -/* 158: 1, 2, 3, 4, 7, */ { 8, 0, 3, 10, 4, 6, 4, 10, 9 }, -/* 174: 1, 2, 3, 5, 7, */ { 5, 6, 10, 3, 4, 0, 4, 3, 7 }, -/* 182: 1, 2, 4, 5, 7, */ { 5, 6, 10, 0, 2, 8, 11, 8, 2 }, -/* 214: 1, 2, 4, 6, 7, */ { 9, 4, 5, 11, 0, 2, 0, 11, 8 }, -/* 186: 1, 3, 4, 5, 7, */ { 8, 0, 3, 6, 2, 5, 1, 5, 2 }, -/* 234: 1, 3, 5, 6, 7, */ { 10, 2, 1, 4, 0, 7, 3, 7, 0 }, -/* 124: 2, 3, 4, 5, 6, */ { 6, 7, 11, 1, 3, 9, 8, 9, 3 }, -/* 188: 2, 3, 4, 5, 7, */ { 10, 5, 6, 8, 1, 3, 1, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_1_2[48][21] = { -/* 67: 0, 1, 6, */ { 1, 10, 3, 6, 3, 10, 3, 6, 8, 5, 8, 6, 8, 5, 9, 1, 9, 5, 10, 1, 5 }, -/* 131: 0, 1, 7, */ { 1, 11, 3, 11, 1, 6, 9, 6, 1, 6, 9, 7, 8, 7, 9, 7, 8, 3, 7, 3, 11 }, -/* 21: 0, 2, 4, */ { 4, 1, 0, 1, 4, 10, 7, 10, 4, 10, 7, 2, 3, 2, 7, 2, 3, 0, 2, 0, 1 }, -/* 69: 0, 2, 6, */ { 6, 3, 2, 3, 6, 8, 5, 8, 6, 8, 5, 0, 1, 0, 5, 0, 1, 2, 0, 2, 3 }, -/* 41: 0, 3, 5, */ { 0, 9, 2, 5, 2, 9, 2, 5, 11, 4, 11, 5, 11, 4, 8, 0, 8, 4, 9, 0, 4 }, -/* 73: 0, 3, 6, */ { 0, 10, 2, 10, 0, 5, 8, 5, 0, 5, 8, 6, 11, 6, 8, 6, 11, 2, 6, 2, 10 }, -/* 81: 0, 4, 6, */ { 4, 5, 0, 10, 0, 5, 0, 10, 3, 6, 3, 10, 3, 6, 7, 4, 7, 6, 5, 4, 6 }, -/* 97: 0, 5, 6, */ { 4, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 9, 4, 9, 0, 8, 4, 0 }, -/* 193: 0, 6, 7, */ { 5, 8, 7, 8, 5, 0, 10, 0, 5, 0, 10, 3, 11, 3, 10, 3, 11, 7, 3, 7, 8 }, -/* 22: 1, 2, 4, */ { 2, 8, 0, 8, 2, 7, 10, 7, 2, 7, 10, 4, 9, 4, 10, 4, 9, 0, 4, 0, 8 }, -/* 134: 1, 2, 7, */ { 2, 11, 0, 7, 0, 11, 0, 7, 9, 6, 9, 7, 9, 6, 10, 2, 10, 6, 11, 2, 6 }, -/* 42: 1, 3, 5, */ { 5, 2, 1, 2, 5, 11, 4, 11, 5, 11, 4, 3, 0, 3, 4, 3, 0, 1, 3, 1, 2 }, -/* 138: 1, 3, 7, */ { 7, 0, 3, 0, 7, 9, 6, 9, 7, 9, 6, 1, 2, 1, 6, 1, 2, 3, 1, 3, 0 }, -/* 146: 1, 4, 7, */ { 6, 9, 4, 9, 6, 1, 11, 1, 6, 1, 11, 0, 8, 0, 11, 0, 8, 4, 0, 4, 9 }, -/* 162: 1, 5, 7, */ { 5, 6, 1, 11, 1, 6, 1, 11, 0, 7, 0, 11, 0, 7, 4, 5, 4, 7, 6, 5, 7 }, -/* 194: 1, 6, 7, */ { 5, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 10, 5, 10, 1, 9, 5, 1 }, -/* 28: 2, 3, 4, */ { 3, 8, 1, 4, 1, 8, 1, 4, 10, 7, 10, 4, 10, 7, 11, 3, 11, 7, 8, 3, 7 }, -/* 44: 2, 3, 5, */ { 3, 9, 1, 9, 3, 4, 11, 4, 3, 4, 11, 5, 10, 5, 11, 5, 10, 1, 5, 1, 9 }, -/* 52: 2, 4, 5, */ { 7, 10, 5, 10, 7, 2, 8, 2, 7, 2, 8, 1, 9, 1, 8, 1, 9, 5, 1, 5, 10 }, -/* 84: 2, 4, 6, */ { 6, 7, 2, 8, 2, 7, 2, 8, 1, 4, 1, 8, 1, 4, 5, 6, 5, 4, 7, 6, 4 }, -/* 148: 2, 4, 7, */ { 6, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 11, 6, 11, 2, 10, 6, 2 }, -/* 56: 3, 4, 5, */ { 7, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 8, 7, 8, 3, 11, 7, 3 }, -/* 104: 3, 5, 6, */ { 4, 11, 6, 11, 4, 3, 9, 3, 4, 3, 9, 2, 10, 2, 9, 2, 10, 6, 2, 6, 11 }, -/* 168: 3, 5, 7, */ { 7, 4, 3, 9, 3, 4, 3, 9, 2, 5, 2, 9, 2, 5, 6, 7, 6, 5, 4, 7, 5 }, -/* 87: 0, 1, 2, 4, 6, */ { 3, 4, 7, 4, 3, 9, 2, 9, 3, 9, 2, 5, 6, 5, 2, 5, 6, 7, 5, 7, 4 }, -/* 151: 0, 1, 2, 4, 7, */ { 6, 11, 4, 3, 4, 11, 4, 3, 9, 2, 9, 3, 9, 2, 10, 6, 10, 2, 11, 6, 2 }, -/* 199: 0, 1, 2, 6, 7, */ { 5, 11, 7, 11, 5, 2, 9, 2, 5, 2, 9, 3, 8, 3, 9, 3, 8, 7, 3, 7, 11 }, -/* 107: 0, 1, 3, 5, 6, */ { 4, 10, 6, 10, 4, 1, 8, 1, 4, 1, 8, 2, 11, 2, 8, 2, 11, 6, 2, 6, 10 }, -/* 171: 0, 1, 3, 5, 7, */ { 2, 7, 6, 7, 2, 8, 1, 8, 2, 8, 1, 4, 5, 4, 1, 4, 5, 6, 4, 6, 7 }, -/* 203: 0, 1, 3, 6, 7, */ { 5, 10, 7, 2, 7, 10, 7, 2, 8, 1, 8, 2, 8, 1, 9, 5, 9, 1, 10, 5, 1 }, -/* 211: 0, 1, 4, 6, 7, */ { 1, 9, 3, 4, 3, 9, 3, 4, 11, 5, 11, 4, 11, 5, 10, 1, 10, 5, 9, 1, 5 }, -/* 227: 0, 1, 5, 6, 7, */ { 1, 8, 3, 8, 1, 4, 10, 4, 1, 4, 10, 7, 11, 7, 10, 7, 11, 3, 7, 3, 8 }, -/* 61: 0, 2, 3, 4, 5, */ { 7, 9, 5, 9, 7, 0, 11, 0, 7, 0, 11, 1, 10, 1, 11, 1, 10, 5, 1, 5, 9 }, -/* 93: 0, 2, 3, 4, 6, */ { 1, 6, 5, 6, 1, 11, 0, 11, 1, 11, 0, 7, 4, 7, 0, 7, 4, 5, 7, 5, 6 }, -/* 109: 0, 2, 3, 5, 6, */ { 4, 9, 6, 1, 6, 9, 6, 1, 11, 0, 11, 1, 11, 0, 8, 4, 8, 0, 9, 4, 0 }, -/* 117: 0, 2, 4, 5, 6, */ { 3, 0, 7, 9, 7, 0, 7, 9, 6, 1, 6, 9, 6, 1, 2, 3, 2, 1, 0, 3, 1 }, -/* 213: 0, 2, 4, 6, 7, */ { 1, 2, 5, 11, 5, 2, 5, 11, 4, 3, 4, 11, 4, 3, 0, 1, 0, 3, 2, 1, 3 }, -/* 121: 0, 3, 4, 5, 6, */ { 0, 11, 2, 11, 0, 7, 9, 7, 0, 7, 9, 6, 10, 6, 9, 6, 10, 2, 6, 2, 11 }, -/* 233: 0, 3, 5, 6, 7, */ { 0, 8, 2, 7, 2, 8, 2, 7, 10, 4, 10, 7, 10, 4, 9, 0, 9, 4, 8, 0, 4 }, -/* 62: 1, 2, 3, 4, 5, */ { 7, 8, 5, 0, 5, 8, 5, 0, 10, 3, 10, 0, 10, 3, 11, 7, 11, 3, 8, 7, 3 }, -/* 158: 1, 2, 3, 4, 7, */ { 6, 8, 4, 8, 6, 3, 10, 3, 6, 3, 10, 0, 9, 0, 10, 0, 9, 4, 0, 4, 8 }, -/* 174: 1, 2, 3, 5, 7, */ { 0, 5, 4, 5, 0, 10, 3, 10, 0, 10, 3, 6, 7, 6, 3, 6, 7, 4, 6, 4, 5 }, -/* 182: 1, 2, 4, 5, 7, */ { 2, 10, 0, 5, 0, 10, 0, 5, 8, 6, 8, 5, 8, 6, 11, 2, 11, 6, 10, 2, 6 }, -/* 214: 1, 2, 4, 6, 7, */ { 2, 9, 0, 9, 2, 5, 11, 5, 2, 5, 11, 4, 8, 4, 11, 4, 8, 0, 4, 0, 9 }, -/* 186: 1, 3, 4, 5, 7, */ { 2, 3, 6, 8, 6, 3, 6, 8, 5, 0, 5, 8, 5, 0, 1, 2, 1, 0, 3, 2, 0 }, -/* 234: 1, 3, 5, 6, 7, */ { 0, 1, 4, 10, 4, 1, 4, 10, 7, 2, 7, 10, 7, 2, 3, 0, 3, 2, 1, 0, 2 }, -/* 124: 2, 3, 4, 5, 6, */ { 3, 11, 1, 6, 1, 11, 1, 6, 9, 7, 9, 6, 9, 7, 8, 3, 8, 7, 11, 3, 7 }, -/* 188: 2, 3, 4, 5, 7, */ { 3, 10, 1, 10, 3, 6, 8, 6, 3, 6, 8, 5, 9, 5, 8, 5, 9, 1, 5, 1, 10 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_2[48][15] = { -/* 67: 0, 1, 6, */ { 1, 10, 3, 6, 3, 10, 3, 6, 8, 5, 8, 6, 8, 5, 9 }, -/* 131: 0, 1, 7, */ { 1, 11, 3, 11, 1, 6, 9, 6, 1, 6, 9, 7, 8, 7, 9 }, -/* 21: 0, 2, 4, */ { 4, 1, 0, 1, 4, 10, 7, 10, 4, 10, 7, 2, 3, 2, 7 }, -/* 69: 0, 2, 6, */ { 6, 3, 2, 3, 6, 8, 5, 8, 6, 8, 5, 0, 1, 0, 5 }, -/* 41: 0, 3, 5, */ { 0, 9, 2, 5, 2, 9, 2, 5, 11, 4, 11, 5, 11, 4, 8 }, -/* 73: 0, 3, 6, */ { 0, 10, 2, 10, 0, 5, 8, 5, 0, 5, 8, 6, 11, 6, 8 }, -/* 81: 0, 4, 6, */ { 4, 5, 0, 10, 0, 5, 0, 10, 3, 6, 3, 10, 3, 6, 7 }, -/* 97: 0, 5, 6, */ { 4, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 9 }, -/* 193: 0, 6, 7, */ { 5, 8, 7, 8, 5, 0, 10, 0, 5, 0, 10, 3, 11, 3, 10 }, -/* 22: 1, 2, 4, */ { 2, 8, 0, 8, 2, 7, 10, 7, 2, 7, 10, 4, 9, 4, 10 }, -/* 134: 1, 2, 7, */ { 2, 11, 0, 7, 0, 11, 0, 7, 9, 6, 9, 7, 9, 6, 10 }, -/* 42: 1, 3, 5, */ { 5, 2, 1, 2, 5, 11, 4, 11, 5, 11, 4, 3, 0, 3, 4 }, -/* 138: 1, 3, 7, */ { 7, 0, 3, 0, 7, 9, 6, 9, 7, 9, 6, 1, 2, 1, 6 }, -/* 146: 1, 4, 7, */ { 6, 9, 4, 9, 6, 1, 11, 1, 6, 1, 11, 0, 8, 0, 11 }, -/* 162: 1, 5, 7, */ { 5, 6, 1, 11, 1, 6, 1, 11, 0, 7, 0, 11, 0, 7, 4 }, -/* 194: 1, 6, 7, */ { 5, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 10 }, -/* 28: 2, 3, 4, */ { 3, 8, 1, 4, 1, 8, 1, 4, 10, 7, 10, 4, 10, 7, 11 }, -/* 44: 2, 3, 5, */ { 3, 9, 1, 9, 3, 4, 11, 4, 3, 4, 11, 5, 10, 5, 11 }, -/* 52: 2, 4, 5, */ { 7, 10, 5, 10, 7, 2, 8, 2, 7, 2, 8, 1, 9, 1, 8 }, -/* 84: 2, 4, 6, */ { 6, 7, 2, 8, 2, 7, 2, 8, 1, 4, 1, 8, 1, 4, 5 }, -/* 148: 2, 4, 7, */ { 6, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 11 }, -/* 56: 3, 4, 5, */ { 7, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 8 }, -/* 104: 3, 5, 6, */ { 4, 11, 6, 11, 4, 3, 9, 3, 4, 3, 9, 2, 10, 2, 9 }, -/* 168: 3, 5, 7, */ { 7, 4, 3, 9, 3, 4, 3, 9, 2, 5, 2, 9, 2, 5, 6 }, -/* 87: 0, 1, 2, 4, 6, */ { 3, 4, 7, 4, 3, 9, 2, 9, 3, 9, 2, 5, 6, 5, 2 }, -/* 151: 0, 1, 2, 4, 7, */ { 6, 11, 4, 3, 4, 11, 4, 3, 9, 2, 9, 3, 9, 2, 10 }, -/* 199: 0, 1, 2, 6, 7, */ { 5, 11, 7, 11, 5, 2, 9, 2, 5, 2, 9, 3, 8, 3, 9 }, -/* 107: 0, 1, 3, 5, 6, */ { 4, 10, 6, 10, 4, 1, 8, 1, 4, 1, 8, 2, 11, 2, 8 }, -/* 171: 0, 1, 3, 5, 7, */ { 2, 7, 6, 7, 2, 8, 1, 8, 2, 8, 1, 4, 5, 4, 1 }, -/* 203: 0, 1, 3, 6, 7, */ { 5, 10, 7, 2, 7, 10, 7, 2, 8, 1, 8, 2, 8, 1, 9 }, -/* 211: 0, 1, 4, 6, 7, */ { 1, 9, 3, 4, 3, 9, 3, 4, 11, 5, 11, 4, 11, 5, 10 }, -/* 227: 0, 1, 5, 6, 7, */ { 1, 8, 3, 8, 1, 4, 10, 4, 1, 4, 10, 7, 11, 7, 10 }, -/* 61: 0, 2, 3, 4, 5, */ { 7, 9, 5, 9, 7, 0, 11, 0, 7, 0, 11, 1, 10, 1, 11 }, -/* 93: 0, 2, 3, 4, 6, */ { 1, 6, 5, 6, 1, 11, 0, 11, 1, 11, 0, 7, 4, 7, 0 }, -/* 109: 0, 2, 3, 5, 6, */ { 4, 9, 6, 1, 6, 9, 6, 1, 11, 0, 11, 1, 11, 0, 8 }, -/* 117: 0, 2, 4, 5, 6, */ { 3, 0, 7, 9, 7, 0, 7, 9, 6, 1, 6, 9, 6, 1, 2 }, -/* 213: 0, 2, 4, 6, 7, */ { 1, 2, 5, 11, 5, 2, 5, 11, 4, 3, 4, 11, 4, 3, 0 }, -/* 121: 0, 3, 4, 5, 6, */ { 0, 11, 2, 11, 0, 7, 9, 7, 0, 7, 9, 6, 10, 6, 9 }, -/* 233: 0, 3, 5, 6, 7, */ { 0, 8, 2, 7, 2, 8, 2, 7, 10, 4, 10, 7, 10, 4, 9 }, -/* 62: 1, 2, 3, 4, 5, */ { 7, 8, 5, 0, 5, 8, 5, 0, 10, 3, 10, 0, 10, 3, 11 }, -/* 158: 1, 2, 3, 4, 7, */ { 6, 8, 4, 8, 6, 3, 10, 3, 6, 3, 10, 0, 9, 0, 10 }, -/* 174: 1, 2, 3, 5, 7, */ { 0, 5, 4, 5, 0, 10, 3, 10, 0, 10, 3, 6, 7, 6, 3 }, -/* 182: 1, 2, 4, 5, 7, */ { 2, 10, 0, 5, 0, 10, 0, 5, 8, 6, 8, 5, 8, 6, 11 }, -/* 214: 1, 2, 4, 6, 7, */ { 2, 9, 0, 9, 2, 5, 11, 5, 2, 5, 11, 4, 8, 4, 11 }, -/* 186: 1, 3, 4, 5, 7, */ { 2, 3, 6, 8, 6, 3, 6, 8, 5, 0, 5, 8, 5, 0, 1 }, -/* 234: 1, 3, 5, 6, 7, */ { 0, 1, 4, 10, 4, 1, 4, 10, 7, 2, 7, 10, 7, 2, 3 }, -/* 124: 2, 3, 4, 5, 6, */ { 3, 11, 1, 6, 1, 11, 1, 6, 9, 7, 9, 6, 9, 7, 8 }, -/* 188: 2, 3, 4, 5, 7, */ { 3, 10, 1, 10, 3, 6, 8, 6, 3, 6, 8, 5, 9, 5, 8 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 7 - * 3 faces to test + eventually the interior - * When the tests on the 3 specified faces are positive : - * - if the test on the interior is positive : 5 first triangles - * - if the test on the interior is negative : 9 next triangles - * When the tests on the first and the second specified faces are positive : 9 next triangles - * When the tests on the first and the third specified faces are positive : 9 next triangles - * When the tests on the second and the third specified faces are positive : 9 next triangles - * When the test on the first specified face is positive : 5 next triangles - * When the test on the second specified face is positive : 5 next triangles - * When the test on the third specified face is positive : 5 next triangles - * When the tests on the 3 specified faces are negative : 3 last triangles - * The support edge for the interior test is marked as the 5th column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test7[16][5] = { -/* 37: 0, 2, 5, */ { 1, 2, 5, 7, 1 }, -/* 133: 0, 2, 7, */ { 3, 4, 5, 7, 3 }, -/* 161: 0, 5, 7, */ { 4, 1, 6, 7, 4 }, -/* 26: 1, 3, 4, */ { 4, 1, 5, 7, 0 }, -/* 74: 1, 3, 6, */ { 2, 3, 5, 7, 2 }, -/* 82: 1, 4, 6, */ { 1, 2, 6, 7, 5 }, -/* 164: 2, 5, 7, */ { 2, 3, 6, 7, 6 }, -/* 88: 3, 4, 6, */ { 3, 4, 6, 7, 7 }, -/* 167: 0, 1, 2, 5, 7, */ { -3, -4, -6, -7, 7 }, -/* 91: 0, 1, 3, 4, 6, */ { -2, -3, -6, -7, 6 }, -/* 173: 0, 2, 3, 5, 7, */ { -1, -2, -6, -7, 5 }, -/* 181: 0, 2, 4, 5, 7, */ { -2, -3, -5, -7, 2 }, -/* 229: 0, 2, 5, 6, 7, */ { -4, -1, -5, -7, 0 }, -/* 94: 1, 2, 3, 4, 6, */ { -4, -1, -6, -7, 4 }, -/* 122: 1, 3, 4, 5, 6, */ { -3, -4, -5, -7, 3 }, -/* 218: 1, 3, 4, 6, 7, */ { -1, -2, -5, -7, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_1[16][9] = { -/* 37: 0, 2, 5, */ { 9, 5, 4, 10, 1, 2, 8, 3, 0 }, -/* 133: 0, 2, 7, */ { 11, 7, 6, 8, 3, 0, 10, 1, 2 }, -/* 161: 0, 5, 7, */ { 3, 0, 8, 5, 4, 9, 7, 6, 11 }, -/* 26: 1, 3, 4, */ { 8, 4, 7, 9, 0, 1, 11, 2, 3 }, -/* 74: 1, 3, 6, */ { 10, 6, 5, 11, 2, 3, 9, 0, 1 }, -/* 82: 1, 4, 6, */ { 0, 1, 9, 6, 5, 10, 4, 7, 8 }, -/* 164: 2, 5, 7, */ { 1, 2, 10, 7, 6, 11, 5, 4, 9 }, -/* 88: 3, 4, 6, */ { 2, 3, 11, 4, 7, 8, 6, 5, 10 }, -/* 167: 0, 1, 2, 5, 7, */ { 11, 3, 2, 8, 7, 4, 10, 5, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 10, 2, 1, 11, 6, 7, 9, 4, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 9, 1, 0, 10, 5, 6, 8, 7, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 5, 6, 10, 3, 2, 11, 1, 0, 9 }, -/* 229: 0, 2, 5, 6, 7, */ { 7, 4, 8, 1, 0, 9, 3, 2, 11 }, -/* 94: 1, 2, 3, 4, 6, */ { 8, 0, 3, 9, 4, 5, 11, 6, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 6, 7, 11, 0, 3, 8, 2, 1, 10 }, -/* 218: 1, 3, 4, 6, 7, */ { 4, 5, 9, 2, 1, 10, 0, 3, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_2[16][3][15] = { -/* 37: 0, 2, 5, */ { - /* 1,0 */ { 1, 2, 10, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 0,1 */ { 3, 0, 8, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 1,1 */ { 9, 5, 4, 0, 10, 1, 10, 0, 8, 10, 8, 2, 3, 2, 8 } -}, -/* 133: 0, 2, 7, */ { - /* 1,0 */ { 3, 0, 8, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 0,1 */ { 1, 2, 10, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 1,1 */ { 11, 7, 6, 2, 8, 3, 8, 2, 10, 8, 10, 0, 1, 0, 10 } -}, -/* 161: 0, 5, 7, */ { - /* 1,0 */ { 9, 5, 4, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 0,1 */ { 11, 7, 6, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 1,1 */ { 3, 0, 8, 4, 9, 7, 11, 7, 9, 5, 11, 9, 11, 5, 6 } -}, -/* 26: 1, 3, 4, */ { - /* 1,0 */ { 0, 1, 9, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 0,1 */ { 2, 3, 11, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 1,1 */ { 8, 4, 7, 3, 9, 0, 9, 3, 11, 9, 11, 1, 2, 1, 11 } -}, -/* 74: 1, 3, 6, */ { - /* 1,0 */ { 2, 3, 11, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 0,1 */ { 0, 1, 9, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 1,1 */ { 6, 5, 10, 1, 11, 2, 11, 1, 9, 11, 9, 3, 0, 3, 9 } -}, -/* 82: 1, 4, 6, */ { - /* 1,0 */ { 6, 5, 10, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 0,1 */ { 8, 4, 7, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 1,1 */ { 0, 1, 9, 5, 10, 4, 8, 4, 10, 6, 8, 10, 8, 6, 7 } -}, -/* 164: 2, 5, 7, */ { - /* 1,0 */ { 11, 7, 6, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 0,1 */ { 9, 5, 4, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 1,1 */ { 1, 2, 10, 6, 11, 5, 9, 5, 11, 7, 9, 11, 9, 7, 4 } -}, -/* 88: 3, 4, 6, */ { - /* 1,0 */ { 8, 4, 7, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 0,1 */ { 6, 5, 10, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 1,1 */ { 2, 3, 11, 7, 8, 6, 10, 6, 8, 4, 10, 8, 10, 4, 5 } -}, -/* 167: 0, 1, 2, 5, 7, */ { - /* 1,0 */ { 7, 4, 8, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 0,1 */ { 10, 5, 6, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 1,1 */ { 11, 3, 2, 6, 8, 7, 8, 6, 10, 8, 10, 4, 5, 4, 10 } -}, -/* 91: 0, 1, 3, 4, 6, */ { - /* 1,0 */ { 6, 7, 11, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 0,1 */ { 4, 5, 9, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 1,1 */ { 10, 2, 1, 5, 11, 6, 11, 5, 9, 11, 9, 7, 4, 7, 9 } -}, -/* 173: 0, 2, 3, 5, 7, */ { - /* 1,0 */ { 10, 5, 6, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 0,1 */ { 7, 4, 8, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 1,1 */ { 9, 1, 0, 4, 10, 5, 10, 4, 8, 10, 8, 6, 7, 6, 8 } -}, -/* 181: 0, 2, 4, 5, 7, */ { - /* 1,0 */ { 11, 3, 2, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 0,1 */ { 9, 1, 0, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 1,1 */ { 10, 5, 6, 2, 11, 1, 9, 1, 11, 3, 9, 11, 9, 3, 0 } -}, -/* 229: 0, 2, 5, 6, 7, */ { - /* 1,0 */ { 9, 1, 0, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 0,1 */ { 11, 3, 2, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 1,1 */ { 7, 4, 8, 0, 9, 3, 11, 3, 9, 1, 11, 9, 11, 1, 2 } -}, -/* 94: 1, 2, 3, 4, 6, */ { - /* 1,0 */ { 4, 5, 9, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 0,1 */ { 6, 7, 11, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 1,1 */ { 8, 0, 3, 7, 9, 4, 9, 7, 11, 9, 11, 5, 6, 5, 11 } -}, -/* 122: 1, 3, 4, 5, 6, */ { - /* 1,0 */ { 8, 0, 3, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 0,1 */ { 10, 2, 1, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 1,1 */ { 6, 7, 11, 3, 8, 2, 10, 2, 8, 0, 10, 8, 10, 0, 1 } -}, -/* 218: 1, 3, 4, 6, 7, */ { - /* 1,0 */ { 10, 2, 1, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 0,1 */ { 8, 0, 3, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 1,1 */ { 4, 5, 9, 1, 10, 0, 8, 0, 10, 2, 8, 10, 8, 2, 3 } } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.3 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_3[16][3][27] = { -/* 37: 0, 2, 5, */ { - /* 1,0 */ { 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, - /* 0,1 */ { 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, - /* 1,1 */ { 5, 4, 12, 10, 5, 12, 2, 10, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 } -}, -/* 133: 0, 2, 7, */ { - /* 1,0 */ { 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 }, - /* 0,1 */ { 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, - /* 1,1 */ { 7, 6, 12, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 } -}, -/* 161: 0, 5, 7, */ { - /* 1,0 */ { 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12 }, - /* 0,1 */ { 3, 0, 12, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12, 8, 7, 12, 0, 8, 12 }, - /* 1,1 */ { 12, 3, 0, 12, 0, 9, 12, 9, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 } -}, -/* 26: 1, 3, 4, */ { - /* 1,0 */ { 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 }, - /* 0,1 */ { 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 8, 12, 8, 4 }, - /* 1,1 */ { 4, 7, 12, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 8, 0, 12, 7, 8, 12 } -}, -/* 74: 1, 3, 6, */ { - /* 1,0 */ { 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, - /* 0,1 */ { 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 10, 12, 10, 6 }, - /* 1,1 */ { 6, 5, 12, 11, 6, 12, 3, 11, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12 } -}, -/* 82: 1, 4, 6, */ { - /* 1,0 */ { 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12 }, - /* 0,1 */ { 0, 1, 12, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12, 9, 4, 12, 1, 9, 12 }, - /* 1,1 */ { 12, 0, 1, 12, 1, 10, 12, 10, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 } -}, -/* 164: 2, 5, 7, */ { - /* 1,0 */ { 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12 }, - /* 0,1 */ { 1, 2, 12, 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 6, 11, 12, 5, 6, 12, 10, 5, 12, 2, 10, 12 }, - /* 1,1 */ { 12, 1, 2, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 } -}, -/* 88: 3, 4, 6, */ { - /* 1,0 */ { 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12 }, - /* 0,1 */ { 2, 3, 12, 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 7, 8, 12, 6, 7, 12, 11, 6, 12, 3, 11, 12 }, - /* 1,1 */ { 12, 2, 3, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 } -}, -/* 167: 0, 1, 2, 5, 7, */ { - /* 1,0 */ { 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4 }, - /* 0,1 */ { 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 7, 12, 7, 6, 12, 6, 11, 12, 11, 3 }, - /* 1,1 */ { 3, 2, 12, 8, 3, 12, 4, 8, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 } -}, -/* 91: 0, 1, 3, 4, 6, */ { - /* 1,0 */ { 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7 }, - /* 0,1 */ { 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 6, 12, 6, 5, 12, 5, 10, 12, 10, 2 }, - /* 1,1 */ { 2, 1, 12, 11, 2, 12, 7, 11, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 } -}, -/* 173: 0, 2, 3, 5, 7, */ { - /* 1,0 */ { 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6 }, - /* 0,1 */ { 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 5, 12, 5, 4, 12, 4, 9, 12, 9, 1 }, - /* 1,1 */ { 1, 0, 12, 10, 1, 12, 6, 10, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 } -}, -/* 181: 0, 2, 4, 5, 7, */ { - /* 1,0 */ { 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, - /* 0,1 */ { 5, 6, 12, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 10, 1, 12, 6, 10, 12 }, - /* 1,1 */ { 12, 5, 6, 12, 6, 11, 12, 11, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5 } -}, -/* 229: 0, 2, 5, 6, 7, */ { - /* 1,0 */ { 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 2, 11, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12 }, - /* 0,1 */ { 7, 4, 12, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 8, 3, 12, 4, 8, 12 }, - /* 1,1 */ { 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 8, 12, 8, 7 } -}, -/* 94: 1, 2, 3, 4, 6, */ { - /* 1,0 */ { 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5 }, - /* 0,1 */ { 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 4, 12, 4, 7, 12, 7, 8, 12, 8, 0 }, - /* 1,1 */ { 0, 3, 12, 9, 0, 12, 5, 9, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 } -}, -/* 122: 1, 3, 4, 5, 6, */ { - /* 1,0 */ { 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, - /* 0,1 */ { 6, 7, 12, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, - /* 1,1 */ { 12, 6, 7, 12, 7, 8, 12, 8, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 } -}, -/* 218: 1, 3, 4, 6, 7, */ { - /* 1,0 */ { 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12 }, - /* 0,1 */ { 4, 5, 12, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, - /* 1,1 */ { 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 } } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.4.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_4_1[16][15] = { -/* 37: 0, 2, 5, */ { 3, 4, 8, 4, 3, 10, 2, 10, 3, 4, 10, 5, 9, 1, 0 }, -/* 133: 0, 2, 7, */ { 1, 6, 10, 6, 1, 8, 0, 8, 1, 6, 8, 7, 11, 3, 2 }, -/* 161: 0, 5, 7, */ { 11, 3, 6, 9, 6, 3, 6, 9, 5, 0, 9, 3, 7, 4, 8 }, -/* 26: 1, 3, 4, */ { 2, 7, 11, 7, 2, 9, 1, 9, 2, 7, 9, 4, 8, 0, 3 }, -/* 74: 1, 3, 6, */ { 0, 5, 9, 5, 0, 11, 3, 11, 0, 5, 11, 6, 10, 2, 1 }, -/* 82: 1, 4, 6, */ { 8, 0, 7, 10, 7, 0, 7, 10, 6, 1, 10, 0, 4, 5, 9 }, -/* 164: 2, 5, 7, */ { 9, 1, 4, 11, 4, 1, 4, 11, 7, 2, 11, 1, 5, 6, 10 }, -/* 88: 3, 4, 6, */ { 10, 2, 5, 8, 5, 2, 5, 8, 4, 3, 8, 2, 6, 7, 11 }, -/* 167: 0, 1, 2, 5, 7, */ { 5, 2, 10, 2, 5, 8, 4, 8, 5, 2, 8, 3, 11, 7, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 4, 1, 9, 1, 4, 11, 7, 11, 4, 1, 11, 2, 10, 6, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 7, 0, 8, 0, 7, 10, 6, 10, 7, 0, 10, 1, 9, 5, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 9, 5, 0, 11, 0, 5, 0, 11, 3, 6, 11, 5, 1, 2, 10 }, -/* 229: 0, 2, 5, 6, 7, */ { 11, 7, 2, 9, 2, 7, 2, 9, 1, 4, 9, 7, 3, 0, 8 }, -/* 94: 1, 2, 3, 4, 6, */ { 6, 3, 11, 3, 6, 9, 5, 9, 6, 3, 9, 0, 8, 4, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 10, 6, 1, 8, 1, 6, 1, 8, 0, 7, 8, 6, 2, 3, 11 }, -/* 218: 1, 3, 4, 6, 7, */ { 8, 4, 3, 10, 3, 4, 3, 10, 2, 5, 10, 4, 0, 1, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.4.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_4_2[16][27] = { -/* 37: 0, 2, 5, */ { 9, 4, 8, 4, 9, 5, 10, 5, 9, 1, 10, 9, 10, 1, 2, 0, 2, 1, 2, 0, 3, 8, 3, 0, 9, 8, 0 }, -/* 133: 0, 2, 7, */ { 11, 6, 10, 6, 11, 7, 8, 7, 11, 3, 8, 11, 8, 3, 0, 2, 0, 3, 0, 2, 1, 10, 1, 2, 11, 10, 2 }, -/* 161: 0, 5, 7, */ { 11, 3, 8, 0, 8, 3, 8, 0, 9, 8, 9, 4, 5, 4, 9, 4, 5, 7, 6, 7, 5, 7, 6, 11, 7, 11, 8 }, -/* 26: 1, 3, 4, */ { 8, 7, 11, 7, 8, 4, 9, 4, 8, 0, 9, 8, 9, 0, 1, 3, 1, 0, 1, 3, 2, 11, 2, 3, 8, 11, 3 }, -/* 74: 1, 3, 6, */ { 10, 5, 9, 5, 10, 6, 11, 6, 10, 2, 11, 10, 11, 2, 3, 1, 3, 2, 3, 1, 0, 9, 0, 1, 10, 9, 1 }, -/* 82: 1, 4, 6, */ { 8, 0, 9, 1, 9, 0, 9, 1, 10, 9, 10, 5, 6, 5, 10, 5, 6, 4, 7, 4, 6, 4, 7, 8, 4, 8, 9 }, -/* 164: 2, 5, 7, */ { 9, 1, 10, 2, 10, 1, 10, 2, 11, 10, 11, 6, 7, 6, 11, 6, 7, 5, 4, 5, 7, 5, 4, 9, 5, 9, 10 }, -/* 88: 3, 4, 6, */ { 10, 2, 11, 3, 11, 2, 11, 3, 8, 11, 8, 7, 4, 7, 8, 7, 4, 6, 5, 6, 4, 6, 5, 10, 6, 10, 11 }, -/* 167: 0, 1, 2, 5, 7, */ { 11, 2, 10, 2, 11, 3, 8, 3, 11, 7, 8, 11, 8, 7, 4, 6, 4, 7, 4, 6, 5, 10, 5, 6, 11, 10, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 10, 1, 9, 1, 10, 2, 11, 2, 10, 6, 11, 10, 11, 6, 7, 5, 7, 6, 7, 5, 4, 9, 4, 5, 10, 9, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 9, 0, 8, 0, 9, 1, 10, 1, 9, 5, 10, 9, 10, 5, 6, 4, 6, 5, 6, 4, 7, 8, 7, 4, 9, 8, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 9, 5, 10, 6, 10, 5, 10, 6, 11, 10, 11, 2, 3, 2, 11, 2, 3, 1, 0, 1, 3, 1, 0, 9, 1, 9, 10 }, -/* 229: 0, 2, 5, 6, 7, */ { 11, 7, 8, 4, 8, 7, 8, 4, 9, 8, 9, 0, 1, 0, 9, 0, 1, 3, 2, 3, 1, 3, 2, 11, 3, 11, 8 }, -/* 94: 1, 2, 3, 4, 6, */ { 8, 3, 11, 3, 8, 0, 9, 0, 8, 4, 9, 8, 9, 4, 5, 7, 5, 4, 5, 7, 6, 11, 6, 7, 8, 11, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 10, 6, 11, 7, 11, 6, 11, 7, 8, 11, 8, 3, 0, 3, 8, 3, 0, 2, 1, 2, 0, 2, 1, 10, 2, 10, 11 }, -/* 218: 1, 3, 4, 6, 7, */ { 8, 4, 9, 5, 9, 4, 9, 5, 10, 9, 10, 1, 2, 1, 10, 1, 2, 0, 3, 0, 2, 0, 3, 8, 0, 8, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 8 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling8[6][6] = { -/* 15: 0, 1, 2, 3, */ { 9, 8, 10, 10, 8, 11 }, -/* 51: 0, 1, 4, 5, */ { 1, 5, 3, 3, 5, 7 }, -/* 153: 0, 3, 4, 7, */ { 0, 4, 2, 4, 6, 2 }, -/* 102: 1, 2, 5, 6, */ { 0, 2, 4, 4, 2, 6 }, -/* 204: 2, 3, 6, 7, */ { 1, 3, 5, 3, 7, 5 }, -/* 240: 4, 5, 6, 7, */ { 9, 10, 8, 10, 11, 8 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 9 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling9[8][12] = { -/* 39: 0, 1, 2, 5, */ { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8 }, -/* 27: 0, 1, 3, 4, */ { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1 }, -/* 141: 0, 2, 3, 7, */ { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8 }, -/* 177: 0, 4, 5, 7, */ { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5 }, -/* 78: 1, 2, 3, 6, */ { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9 }, -/* 114: 1, 4, 5, 6, */ { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0 }, -/* 228: 2, 5, 6, 7, */ { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2 }, -/* 216: 3, 4, 6, 7, */ { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 10 - * 2 faces to test + eventually the interior - * When the tests on both specified faces are positive : 4 middle triangles (1) - * When the test on the first specified face is positive : 8 first triangles - * When the test on the second specified face is positive : 8 next triangles - * When the tests on both specified faces are negative : - * - if the test on the interior is negative : 4 middle triangles - * - if the test on the interior is positive : 8 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test10[6][3] = { -/* 195: 0, 1, 6, 7, */ { 2, 4, 7 }, -/* 85: 0, 2, 4, 6, */ { 5, 6, 7 }, -/* 105: 0, 3, 5, 6, */ { 1, 3, 7 }, -/* 150: 1, 2, 4, 7, */ { 1, 3, 7 }, -/* 170: 1, 3, 5, 7, */ { 5, 6, 7 }, -/* 60: 2, 3, 4, 5, */ { 2, 4, 7 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_1[6][12] = { -/* 195: 0, 1, 6, 7, */ { 5, 10, 7, 11, 7, 10, 8, 1, 9, 1, 8, 3 }, -/* 85: 0, 2, 4, 6, */ { 1, 2, 5, 6, 5, 2, 4, 3, 0, 3, 4, 7 }, -/* 105: 0, 3, 5, 6, */ { 11, 0, 8, 0, 11, 2, 4, 9, 6, 10, 6, 9 }, -/* 150: 1, 2, 4, 7, */ { 9, 0, 10, 2, 10, 0, 6, 8, 4, 8, 6, 11 }, -/* 170: 1, 3, 5, 7, */ { 7, 2, 3, 2, 7, 6, 0, 1, 4, 5, 4, 1 }, -/* 60: 2, 3, 4, 5, */ { 7, 9, 5, 9, 7, 8, 10, 1, 11, 3, 11, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_1_[6][12] = { -/* 195: 0, 1, 6, 7, */ { 5, 9, 7, 8, 7, 9, 11, 1, 10, 1, 11, 3 }, -/* 85: 0, 2, 4, 6, */ { 3, 2, 7, 6, 7, 2, 4, 1, 0, 1, 4, 5 }, -/* 105: 0, 3, 5, 6, */ { 10, 0, 9, 0, 10, 2, 4, 8, 6, 11, 6, 8 }, -/* 150: 1, 2, 4, 7, */ { 8, 0, 11, 2, 11, 0, 6, 9, 4, 9, 6, 10 }, -/* 170: 1, 3, 5, 7, */ { 5, 2, 1, 2, 5, 6, 0, 3, 4, 7, 4, 3 }, -/* 60: 2, 3, 4, 5, */ { 7, 10, 5, 10, 7, 11, 9, 1, 8, 3, 8, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_2[6][24] = { -/* 195: 0, 1, 6, 7, */ { 3, 11, 7, 3, 7, 8, 9, 8, 7, 5, 9, 7, 9, 5, 10, 9, 10, 1, 3, 1, 10, 11, 3, 10 }, -/* 85: 0, 2, 4, 6, */ { 7, 6, 5, 7, 5, 4, 0, 4, 5, 1, 0, 5, 0, 1, 2, 0, 2, 3, 7, 3, 2, 6, 7, 2 }, -/* 105: 0, 3, 5, 6, */ { 11, 2, 10, 6, 11, 10, 11, 6, 4, 11, 4, 8, 0, 8, 4, 9, 0, 4, 0, 9, 10, 0, 10, 2 }, -/* 150: 1, 2, 4, 7, */ { 11, 2, 10, 11, 10, 6, 4, 6, 10, 9, 4, 10, 4, 9, 0, 4, 0, 8, 11, 8, 0, 2, 11, 0 }, -/* 170: 1, 3, 5, 7, */ { 7, 6, 5, 4, 7, 5, 7, 4, 0, 7, 0, 3, 2, 3, 0, 1, 2, 0, 2, 1, 5, 2, 5, 6 }, -/* 60: 2, 3, 4, 5, */ { 7, 8, 3, 11, 7, 3, 7, 11, 10, 7, 10, 5, 9, 5, 10, 1, 9, 10, 9, 1, 3, 9, 3, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_2[6][24] = { -/* 195: 0, 1, 6, 7, */ { 12, 5, 9, 12, 9, 8, 12, 8, 3, 12, 3, 1, 12, 1, 10, 12, 10, 11, 12, 11, 7, 12, 7, 5 }, -/* 85: 0, 2, 4, 6, */ { 12, 1, 0, 12, 0, 4, 12, 4, 7, 12, 7, 3, 12, 3, 2, 12, 2, 6, 12, 6, 5, 12, 5, 1 }, -/* 105: 0, 3, 5, 6, */ { 4, 8, 12, 6, 4, 12, 10, 6, 12, 9, 10, 12, 0, 9, 12, 2, 0, 12, 11, 2, 12, 8, 11, 12 }, -/* 150: 1, 2, 4, 7, */ { 12, 9, 4, 12, 4, 6, 12, 6, 11, 12, 11, 8, 12, 8, 0, 12, 0, 2, 12, 2, 10, 12, 10, 9 }, -/* 170: 1, 3, 5, 7, */ { 0, 3, 12, 4, 0, 12, 5, 4, 12, 1, 5, 12, 2, 1, 12, 6, 2, 12, 7, 6, 12, 3, 7, 12 }, -/* 60: 2, 3, 4, 5, */ { 10, 5, 12, 11, 10, 12, 3, 11, 12, 1, 3, 12, 9, 1, 12, 8, 9, 12, 7, 8, 12, 5, 7, 12 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_2_[6][24] = { -/* 195: 0, 1, 6, 7, */ { 8, 7, 12, 9, 8, 12, 1, 9, 12, 3, 1, 12, 11, 3, 12, 10, 11, 12, 5, 10, 12, 7, 5, 12 }, -/* 85: 0, 2, 4, 6, */ { 4, 5, 12, 0, 4, 12, 3, 0, 12, 7, 3, 12, 6, 7, 12, 2, 6, 12, 1, 2, 12, 5, 1, 12 }, -/* 105: 0, 3, 5, 6, */ { 12, 11, 6, 12, 6, 4, 12, 4, 9, 12, 9, 10, 12, 10, 2, 12, 2, 0, 12, 0, 8, 12, 8, 11 }, -/* 150: 1, 2, 4, 7, */ { 6, 10, 12, 4, 6, 12, 8, 4, 12, 11, 8, 12, 2, 11, 12, 0, 2, 12, 9, 0, 12, 10, 9, 12 }, -/* 170: 1, 3, 5, 7, */ { 12, 7, 4, 12, 4, 0, 12, 0, 1, 12, 1, 5, 12, 5, 6, 12, 6, 2, 12, 2, 3, 12, 3, 7 }, -/* 60: 2, 3, 4, 5, */ { 12, 7, 11, 12, 11, 10, 12, 10, 1, 12, 1, 3, 12, 3, 8, 12, 8, 9, 12, 9, 5, 12, 5, 7 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 11 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling11[12][12] = { -/* 23: 0, 1, 2, 4, */ { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4 }, -/* 139: 0, 1, 3, 7, */ { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6 }, -/* 99: 0, 1, 5, 6, */ { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10 }, -/* 77: 0, 2, 3, 6, */ { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6 }, -/* 57: 0, 3, 4, 5, */ { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11 }, -/* 209: 0, 4, 6, 7, */ { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0 }, -/* 46: 1, 2, 3, 5, */ { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3 }, -/* 198: 1, 2, 6, 7, */ { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7 }, -/* 178: 1, 4, 5, 7, */ { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11 }, -/* 156: 2, 3, 4, 7, */ { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1 }, -/* 116: 2, 4, 5, 6, */ { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7 }, -/* 232: 3, 5, 6, 7, */ { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief test table for case 12 - * 2 faces to test + eventually the interior - * When the tests on both specified faces are positive : 4 middle triangles (1) - * When the test on the first specified face is positive : 8 first triangles - * When the test on the second specified face is positive : 8 next triangles - * When the tests on both specified faces are negative : - * - if the test on the interior is negative : 4 middle triangles - * - if the test on the interior is positive : 8 last triangles - * The support edge for the interior test is marked as the 4th column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test12[24][4] = { -/* 135: 0, 1, 2, 7, */ { 4, 3, 7, 11 }, -/* 75: 0, 1, 3, 6, */ { 3, 2, 7, 10 }, -/* 83: 0, 1, 4, 6, */ { 2, 6, 7, 5 }, -/* 163: 0, 1, 5, 7, */ { 6, 4, 7, 7 }, -/* 45: 0, 2, 3, 5, */ { 2, 1, 7, 9 }, -/* 53: 0, 2, 4, 5, */ { 5, 2, 7, 1 }, -/* 149: 0, 2, 4, 7, */ { 5, 3, 7, 2 }, -/* 101: 0, 2, 5, 6, */ { 5, 1, 7, 0 }, -/* 197: 0, 2, 6, 7, */ { 5, 4, 7, 3 }, -/* 89: 0, 3, 4, 6, */ { 6, 3, 7, 6 }, -/* 169: 0, 3, 5, 7, */ { 1, 6, 7, 4 }, -/* 225: 0, 5, 6, 7, */ { 1, 4, 7, 8 }, -/* 30: 1, 2, 3, 4, */ { 4, 1, 7, 8 }, -/* 86: 1, 2, 4, 6, */ { 6, 1, 7, 4 }, -/* 166: 1, 2, 5, 7, */ { 3, 6, 7, 6 }, -/* 58: 1, 3, 4, 5, */ { 4, 5, 7, 3 }, -/* 154: 1, 3, 4, 7, */ { 1, 5, 7, 0 }, -/* 106: 1, 3, 5, 6, */ { 3, 5, 7, 2 }, -/* 202: 1, 3, 6, 7, */ { 2, 5, 7, 1 }, -/* 210: 1, 4, 6, 7, */ { 1, 2, 7, 9 }, -/* 92: 2, 3, 4, 6, */ { 4, 6, 7, 7 }, -/* 172: 2, 3, 5, 7, */ { 6, 2, 7, 5 }, -/* 180: 2, 4, 5, 7, */ { 2, 3, 7, 10 }, -/* 120: 3, 4, 5, 6, */ { 3, 4, 7, 11 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_1[24][12] = { -/* 135: 0, 1, 2, 7, */ { 7, 6, 11, 10, 3, 2, 3, 10, 8, 9, 8, 10 }, -/* 75: 0, 1, 3, 6, */ { 6, 5, 10, 9, 2, 1, 2, 9, 11, 8, 11, 9 }, -/* 83: 0, 1, 4, 6, */ { 10, 6, 5, 7, 9, 4, 9, 7, 1, 3, 1, 7 }, -/* 163: 0, 1, 5, 7, */ { 7, 6, 11, 4, 8, 5, 3, 5, 8, 5, 3, 1 }, -/* 45: 0, 2, 3, 5, */ { 5, 4, 9, 8, 1, 0, 1, 8, 10, 11, 10, 8 }, -/* 53: 0, 2, 4, 5, */ { 1, 2, 10, 0, 9, 3, 5, 3, 9, 3, 5, 7 }, -/* 149: 0, 2, 4, 7, */ { 10, 1, 2, 0, 11, 3, 11, 0, 6, 4, 6, 0 }, -/* 101: 0, 2, 5, 6, */ { 8, 3, 0, 2, 9, 1, 9, 2, 4, 6, 4, 2 }, -/* 197: 0, 2, 6, 7, */ { 3, 0, 8, 2, 11, 1, 7, 1, 11, 1, 7, 5 }, -/* 89: 0, 3, 4, 6, */ { 6, 5, 10, 7, 11, 4, 2, 4, 11, 4, 2, 0 }, -/* 169: 0, 3, 5, 7, */ { 9, 5, 4, 6, 8, 7, 8, 6, 0, 2, 0, 6 }, -/* 225: 0, 5, 6, 7, */ { 8, 3, 0, 7, 4, 11, 9, 11, 4, 11, 9, 10 }, -/* 30: 1, 2, 3, 4, */ { 4, 7, 8, 11, 0, 3, 0, 11, 9, 10, 9, 11 }, -/* 86: 1, 2, 4, 6, */ { 4, 7, 8, 5, 9, 6, 0, 6, 9, 6, 0, 2 }, -/* 166: 1, 2, 5, 7, */ { 11, 7, 6, 4, 10, 5, 10, 4, 2, 0, 2, 4 }, -/* 58: 1, 3, 4, 5, */ { 11, 2, 3, 1, 8, 0, 8, 1, 7, 5, 7, 1 }, -/* 154: 1, 3, 4, 7, */ { 0, 1, 9, 3, 8, 2, 4, 2, 8, 2, 4, 6 }, -/* 106: 1, 3, 5, 6, */ { 2, 3, 11, 1, 10, 0, 6, 0, 10, 0, 6, 4 }, -/* 202: 1, 3, 6, 7, */ { 9, 0, 1, 3, 10, 2, 10, 3, 5, 7, 5, 3 }, -/* 210: 1, 4, 6, 7, */ { 9, 0, 1, 4, 5, 8, 10, 8, 5, 8, 10, 11 }, -/* 92: 2, 3, 4, 6, */ { 8, 4, 7, 5, 11, 6, 11, 5, 3, 1, 3, 5 }, -/* 172: 2, 3, 5, 7, */ { 5, 4, 9, 6, 10, 7, 1, 7, 10, 7, 1, 3 }, -/* 180: 2, 4, 5, 7, */ { 10, 1, 2, 5, 6, 9, 11, 9, 6, 9, 11, 8 }, -/* 120: 3, 4, 5, 6, */ { 11, 2, 3, 6, 7, 10, 8, 10, 7, 10, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_1_[24][12] = { -/* 135: 0, 1, 2, 7, */ { 3, 2, 11, 10, 7, 6, 7, 10, 8, 9, 8, 10 }, -/* 75: 0, 1, 3, 6, */ { 2, 1, 10, 9, 6, 5, 6, 9, 11, 8, 11, 9 }, -/* 83: 0, 1, 4, 6, */ { 9, 4, 5, 7, 10, 6, 10, 7, 1, 3, 1, 7 }, -/* 163: 0, 1, 5, 7, */ { 7, 4, 8, 6, 11, 5, 3, 5, 11, 5, 3, 1 }, -/* 45: 0, 2, 3, 5, */ { 1, 0, 9, 8, 5, 4, 5, 8, 10, 11, 10, 8 }, -/* 53: 0, 2, 4, 5, */ { 1, 0, 9, 2, 10, 3, 5, 3, 10, 3, 5, 7 }, -/* 149: 0, 2, 4, 7, */ { 11, 3, 2, 0, 10, 1, 10, 0, 6, 4, 6, 0 }, -/* 101: 0, 2, 5, 6, */ { 9, 1, 0, 2, 8, 3, 8, 2, 4, 6, 4, 2 }, -/* 197: 0, 2, 6, 7, */ { 3, 2, 11, 0, 8, 1, 7, 1, 8, 1, 7, 5 }, -/* 89: 0, 3, 4, 6, */ { 6, 7, 11, 5, 10, 4, 2, 4, 10, 4, 2, 0 }, -/* 169: 0, 3, 5, 7, */ { 8, 7, 4, 6, 9, 5, 9, 6, 0, 2, 0, 6 }, -/* 225: 0, 5, 6, 7, */ { 8, 7, 4, 3, 0, 11, 9, 11, 0, 11, 9, 10 }, -/* 30: 1, 2, 3, 4, */ { 0, 3, 8, 11, 4, 7, 4, 11, 9, 10, 9, 11 }, -/* 86: 1, 2, 4, 6, */ { 4, 5, 9, 7, 8, 6, 0, 6, 8, 6, 0, 2 }, -/* 166: 1, 2, 5, 7, */ { 10, 5, 6, 4, 11, 7, 11, 4, 2, 0, 2, 4 }, -/* 58: 1, 3, 4, 5, */ { 8, 0, 3, 1, 11, 2, 11, 1, 7, 5, 7, 1 }, -/* 154: 1, 3, 4, 7, */ { 0, 3, 8, 1, 9, 2, 4, 2, 9, 2, 4, 6 }, -/* 106: 1, 3, 5, 6, */ { 2, 1, 10, 3, 11, 0, 6, 0, 11, 0, 6, 4 }, -/* 202: 1, 3, 6, 7, */ { 10, 2, 1, 3, 9, 0, 9, 3, 5, 7, 5, 3 }, -/* 210: 1, 4, 6, 7, */ { 9, 4, 5, 0, 1, 8, 10, 8, 1, 8, 10, 11 }, -/* 92: 2, 3, 4, 6, */ { 11, 6, 7, 5, 8, 4, 8, 5, 3, 1, 3, 5 }, -/* 172: 2, 3, 5, 7, */ { 5, 6, 10, 4, 9, 7, 1, 7, 9, 7, 1, 3 }, -/* 180: 2, 4, 5, 7, */ { 10, 5, 6, 1, 2, 9, 11, 9, 2, 9, 11, 8 }, -/* 120: 3, 4, 5, 6, */ { 11, 6, 7, 2, 3, 10, 8, 10, 3, 10, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_2[24][24] = { -/* 135: 0, 1, 2, 7, */ { 7, 3, 11, 3, 7, 8, 9, 8, 7, 6, 9, 7, 9, 6, 10, 2, 10, 6, 11, 2, 6, 2, 11, 3 }, -/* 75: 0, 1, 3, 6, */ { 6, 2, 10, 2, 6, 11, 8, 11, 6, 5, 8, 6, 8, 5, 9, 1, 9, 5, 10, 1, 5, 1, 10, 2 }, -/* 83: 0, 1, 4, 6, */ { 10, 9, 5, 9, 10, 1, 3, 1, 10, 6, 3, 10, 3, 6, 7, 4, 7, 6, 5, 4, 6, 4, 5, 9 }, -/* 163: 0, 1, 5, 7, */ { 7, 8, 11, 3, 11, 8, 11, 3, 1, 11, 1, 6, 5, 6, 1, 6, 5, 4, 6, 4, 7, 8, 7, 4 }, -/* 45: 0, 2, 3, 5, */ { 5, 1, 9, 1, 5, 10, 11, 10, 5, 4, 11, 5, 11, 4, 8, 0, 8, 4, 9, 0, 4, 0, 9, 1 }, -/* 53: 0, 2, 4, 5, */ { 1, 9, 10, 5, 10, 9, 10, 5, 7, 10, 7, 2, 3, 2, 7, 2, 3, 0, 2, 0, 1, 9, 1, 0 }, -/* 149: 0, 2, 4, 7, */ { 10, 11, 2, 11, 10, 6, 4, 6, 10, 1, 4, 10, 4, 1, 0, 3, 0, 1, 2, 3, 1, 3, 2, 11 }, -/* 101: 0, 2, 5, 6, */ { 8, 9, 0, 9, 8, 4, 6, 4, 8, 3, 6, 8, 6, 3, 2, 1, 2, 3, 0, 1, 3, 1, 0, 9 }, -/* 197: 0, 2, 6, 7, */ { 3, 11, 8, 7, 8, 11, 8, 7, 5, 8, 5, 0, 1, 0, 5, 0, 1, 2, 0, 2, 3, 11, 3, 2 }, -/* 89: 0, 3, 4, 6, */ { 6, 11, 10, 2, 10, 11, 10, 2, 0, 10, 0, 5, 4, 5, 0, 5, 4, 7, 5, 7, 6, 11, 6, 7 }, -/* 169: 0, 3, 5, 7, */ { 9, 8, 4, 8, 9, 0, 2, 0, 9, 5, 2, 9, 2, 5, 6, 7, 6, 5, 4, 7, 5, 7, 4, 8 }, -/* 225: 0, 5, 6, 7, */ { 8, 4, 0, 9, 0, 4, 0, 9, 10, 0, 10, 3, 11, 3, 10, 3, 11, 7, 3, 7, 8, 4, 8, 7 }, -/* 30: 1, 2, 3, 4, */ { 4, 0, 8, 0, 4, 9, 10, 9, 4, 7, 10, 4, 10, 7, 11, 3, 11, 7, 8, 3, 7, 3, 8, 0 }, -/* 86: 1, 2, 4, 6, */ { 4, 9, 8, 0, 8, 9, 8, 0, 2, 8, 2, 7, 6, 7, 2, 7, 6, 5, 7, 5, 4, 9, 4, 5 }, -/* 166: 1, 2, 5, 7, */ { 11, 10, 6, 10, 11, 2, 0, 2, 11, 7, 0, 11, 0, 7, 4, 5, 4, 7, 6, 5, 7, 5, 6, 10 }, -/* 58: 1, 3, 4, 5, */ { 11, 8, 3, 8, 11, 7, 5, 7, 11, 2, 5, 11, 5, 2, 1, 0, 1, 2, 3, 0, 2, 0, 3, 8 }, -/* 154: 1, 3, 4, 7, */ { 0, 8, 9, 4, 9, 8, 9, 4, 6, 9, 6, 1, 2, 1, 6, 1, 2, 3, 1, 3, 0, 8, 0, 3 }, -/* 106: 1, 3, 5, 6, */ { 2, 10, 11, 6, 11, 10, 11, 6, 4, 11, 4, 3, 0, 3, 4, 3, 0, 1, 3, 1, 2, 10, 2, 1 }, -/* 202: 1, 3, 6, 7, */ { 9, 10, 1, 10, 9, 5, 7, 5, 9, 0, 7, 9, 7, 0, 3, 2, 3, 0, 1, 2, 0, 2, 1, 10 }, -/* 210: 1, 4, 6, 7, */ { 9, 5, 1, 10, 1, 5, 1, 10, 11, 1, 11, 0, 8, 0, 11, 0, 8, 4, 0, 4, 9, 5, 9, 4 }, -/* 92: 2, 3, 4, 6, */ { 8, 11, 7, 11, 8, 3, 1, 3, 8, 4, 1, 8, 1, 4, 5, 6, 5, 4, 7, 6, 4, 6, 7, 11 }, -/* 172: 2, 3, 5, 7, */ { 5, 10, 9, 1, 9, 10, 9, 1, 3, 9, 3, 4, 7, 4, 3, 4, 7, 6, 4, 6, 5, 10, 5, 6 }, -/* 180: 2, 4, 5, 7, */ { 10, 6, 2, 11, 2, 6, 2, 11, 8, 2, 8, 1, 9, 1, 8, 1, 9, 5, 1, 5, 10, 6, 10, 5 }, -/* 120: 3, 4, 5, 6, */ { 11, 7, 3, 8, 3, 7, 3, 8, 9, 3, 9, 2, 10, 2, 9, 2, 10, 6, 2, 6, 11, 7, 11, 6 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_2[24][24] = { -/* 135: 0, 1, 2, 7, */ { 9, 8, 12, 10, 9, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12 }, -/* 75: 0, 1, 3, 6, */ { 8, 11, 12, 9, 8, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12 }, -/* 83: 0, 1, 4, 6, */ { 3, 1, 12, 7, 3, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 }, -/* 163: 0, 1, 5, 7, */ { 12, 3, 1, 12, 1, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 }, -/* 45: 0, 2, 3, 5, */ { 11, 10, 12, 8, 11, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12 }, -/* 53: 0, 2, 4, 5, */ { 12, 5, 7, 12, 7, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, -/* 149: 0, 2, 4, 7, */ { 4, 6, 12, 0, 4, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 }, -/* 101: 0, 2, 5, 6, */ { 6, 4, 12, 2, 6, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 }, -/* 197: 0, 2, 6, 7, */ { 12, 7, 5, 12, 5, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, -/* 89: 0, 3, 4, 6, */ { 12, 2, 0, 12, 0, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 }, -/* 169: 0, 3, 5, 7, */ { 2, 0, 12, 6, 2, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 }, -/* 225: 0, 5, 6, 7, */ { 12, 9, 10, 12, 10, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9 }, -/* 30: 1, 2, 3, 4, */ { 10, 9, 12, 11, 10, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12 }, -/* 86: 1, 2, 4, 6, */ { 12, 0, 2, 12, 2, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 }, -/* 166: 1, 2, 5, 7, */ { 0, 2, 12, 4, 0, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 }, -/* 58: 1, 3, 4, 5, */ { 5, 7, 12, 1, 5, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, -/* 154: 1, 3, 4, 7, */ { 12, 4, 6, 12, 6, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 }, -/* 106: 1, 3, 5, 6, */ { 12, 6, 4, 12, 4, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 }, -/* 202: 1, 3, 6, 7, */ { 7, 5, 12, 3, 7, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, -/* 210: 1, 4, 6, 7, */ { 12, 10, 11, 12, 11, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10 }, -/* 92: 2, 3, 4, 6, */ { 1, 3, 12, 5, 1, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 }, -/* 172: 2, 3, 5, 7, */ { 12, 1, 3, 12, 3, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 }, -/* 180: 2, 4, 5, 7, */ { 12, 11, 8, 12, 8, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11 }, -/* 120: 3, 4, 5, 6, */ { 12, 8, 9, 12, 9, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_2_[24][24] = { -/* 135: 0, 1, 2, 7, */ { 12, 2, 11, 12, 11, 7, 12, 7, 6, 12, 6, 10, 12, 10, 9, 12, 9, 8, 12, 8, 3, 12, 3, 2 }, -/* 75: 0, 1, 3, 6, */ { 12, 1, 10, 12, 10, 6, 12, 6, 5, 12, 5, 9, 12, 9, 8, 12, 8, 11, 12, 11, 2, 12, 2, 1 }, -/* 83: 0, 1, 4, 6, */ { 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 3, 12, 3, 1, 12, 1, 9, 12, 9, 4 }, -/* 163: 0, 1, 5, 7, */ { 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 1, 5, 12, 3, 1, 12, 11, 3, 12, 6, 11, 12 }, -/* 45: 0, 2, 3, 5, */ { 12, 0, 9, 12, 9, 5, 12, 5, 4, 12, 4, 8, 12, 8, 11, 12, 11, 10, 12, 10, 1, 12, 1, 0 }, -/* 53: 0, 2, 4, 5, */ { 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 10, 5, 12, 2, 10, 12 }, -/* 149: 0, 2, 4, 7, */ { 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 4, 12, 4, 6, 12, 6, 10, 12, 10, 1 }, -/* 101: 0, 2, 5, 6, */ { 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 6, 12, 6, 4, 12, 4, 8, 12, 8, 3 }, -/* 197: 0, 2, 6, 7, */ { 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 8, 7, 12, 0, 8, 12 }, -/* 89: 0, 3, 4, 6, */ { 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 0, 4, 12, 2, 0, 12, 10, 2, 12, 5, 10, 12 }, -/* 169: 0, 3, 5, 7, */ { 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 2, 12, 2, 0, 12, 0, 8, 12, 8, 7 }, -/* 225: 0, 5, 6, 7, */ { 8, 7, 12, 0, 8, 12, 3, 0, 12, 11, 3, 12, 10, 11, 12, 9, 10, 12, 4, 9, 12, 7, 4, 12 }, -/* 30: 1, 2, 3, 4, */ { 12, 7, 8, 12, 8, 0, 12, 0, 3, 12, 3, 11, 12, 11, 10, 12, 10, 9, 12, 9, 4, 12, 4, 7 }, -/* 86: 1, 2, 4, 6, */ { 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 2, 6, 12, 0, 2, 12, 8, 0, 12, 7, 8, 12 }, -/* 166: 1, 2, 5, 7, */ { 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 0, 12, 0, 2, 12, 2, 10, 12, 10, 5 }, -/* 58: 1, 3, 4, 5, */ { 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 8, 12, 8, 0 }, -/* 154: 1, 3, 4, 7, */ { 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 6, 2, 12, 4, 6, 12, 8, 4, 12, 3, 8, 12 }, -/* 106: 1, 3, 5, 6, */ { 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 4, 0, 12, 6, 4, 12, 10, 6, 12, 1, 10, 12 }, -/* 202: 1, 3, 6, 7, */ { 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 10, 12, 10, 2 }, -/* 210: 1, 4, 6, 7, */ { 9, 0, 12, 5, 9, 12, 4, 5, 12, 8, 4, 12, 11, 8, 12, 10, 11, 12, 1, 10, 12, 0, 1, 12 }, -/* 92: 2, 3, 4, 6, */ { 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 1, 12, 1, 3, 12, 3, 11, 12, 11, 6 }, -/* 172: 2, 3, 5, 7, */ { 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 3, 7, 12, 1, 3, 12, 9, 1, 12, 4, 9, 12 }, -/* 180: 2, 4, 5, 7, */ { 10, 1, 12, 6, 10, 12, 5, 6, 12, 9, 5, 12, 8, 9, 12, 11, 8, 12, 2, 11, 12, 1, 2, 12 }, -/* 120: 3, 4, 5, 6, */ { 11, 2, 12, 7, 11, 12, 6, 7, 12, 10, 6, 12, 9, 10, 12, 8, 9, 12, 3, 8, 12, 2, 3, 12 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 13 - * All faces are to be tested - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13: face test */ -static const char test13[2][7] = { -/* 165: 0, 2, 5, 7, */ { 1,2,3,4,5,6,7 }, -/* 90: 1, 3, 4, 6, */ { 2,3,4,1,5,6,7 }, -}; - - - -//_____________________________________________________________________________ -/** - * \brief subconfiguration table for case 13 - * Hard-coded tests for the subconfiguration determination - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13: sub configs */ -static const char subconfig13[64] = { -/* 0: 0,0,0,0,0,0 */ 0, -/* 1: 1,0,0,0,0,0 */ 1, -/* 2: 0,1,0,0,0,0 */ 2, -/* 3: 1,1,0,0,0,0 */ 7, -/* 4: 0,0,1,0,0,0 */ 3, -/* 5: 1,0,1,0,0,0 */ -1, -/* 6: 0,1,1,0,0,0 */ 11, -/* 7: 1,1,1,0,0,0 */ -1, -/* 8: 0,0,0,1,0,0 */ 4, -/* 9: 1,0,0,1,0,0 */ 8, -/* 10: 0,1,0,1,0,0 */ -1, -/* 11: 1,1,0,1,0,0 */ -1, -/* 12: 0,0,1,1,0,0 */ 14, -/* 13: 1,0,1,1,0,0 */ -1, -/* 14: 0,1,1,1,0,0 */ -1, -/* 15: 1,1,1,1,0,0 */ -1, -/* 16: 0,0,0,0,1,0 */ 5, -/* 17: 1,0,0,0,1,0 */ 9, -/* 18: 0,1,0,0,1,0 */ 12, -/* 19: 1,1,0,0,1,0 */ 23, -/* 20: 0,0,1,0,1,0 */ 15, -/* 21: 1,0,1,0,1,0 */ -1, -/* 22: 0,1,1,0,1,0 */ 21, -/* 23: 1,1,1,0,1,0 */ 38, -/* 24: 0,0,0,1,1,0 */ 17, -/* 25: 1,0,0,1,1,0 */ 20, -/* 26: 0,1,0,1,1,0 */ -1, -/* 27: 1,1,0,1,1,0 */ 36, -/* 28: 0,0,1,1,1,0 */ 26, -/* 29: 1,0,1,1,1,0 */ 33, -/* 30: 0,1,1,1,1,0 */ 30, -/* 31: 1,1,1,1,1,0 */ 44, -/* 32: 0,0,0,0,0,1 */ 6, -/* 33: 1,0,0,0,0,1 */ 10, -/* 34: 0,1,0,0,0,1 */ 13, -/* 35: 1,1,0,0,0,1 */ 19, -/* 36: 0,0,1,0,0,1 */ 16, -/* 37: 1,0,1,0,0,1 */ -1, -/* 38: 0,1,1,0,0,1 */ 25, -/* 39: 1,1,1,0,0,1 */ 37, -/* 40: 0,0,0,1,0,1 */ 18, -/* 41: 1,0,0,1,0,1 */ 24, -/* 42: 0,1,0,1,0,1 */ -1, -/* 43: 1,1,0,1,0,1 */ 35, -/* 44: 0,0,1,1,0,1 */ 22, -/* 45: 1,0,1,1,0,1 */ 32, -/* 46: 0,1,1,1,0,1 */ 29, -/* 47: 1,1,1,1,0,1 */ 43, -/* 48: 0,0,0,0,1,1 */ -1, -/* 49: 1,0,0,0,1,1 */ -1, -/* 50: 0,1,0,0,1,1 */ -1, -/* 51: 1,1,0,0,1,1 */ 34, -/* 52: 0,0,1,0,1,1 */ -1, -/* 53: 1,0,1,0,1,1 */ -1, -/* 54: 0,1,1,0,1,1 */ 28, -/* 55: 1,1,1,0,1,1 */ 42, -/* 56: 0,0,0,1,1,1 */ -1, -/* 57: 1,0,0,1,1,1 */ 31, -/* 58: 0,1,0,1,1,1 */ -1, -/* 59: 1,1,0,1,1,1 */ 41, -/* 60: 0,0,1,1,1,1 */ 27, -/* 61: 1,0,1,1,1,1 */ 40, -/* 62: 0,1,1,1,1,1 */ 39, -/* 63: 1,1,1,1,1,1 */ 45, -}; - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.1 */ -static const char tiling13_1[2][12] = { -/* 165: 0, 2, 5, 7, */ { 11, 7, 6, 1, 2, 10, 8, 3, 0, 9, 5, 4 }, -/* 90: 1, 3, 4, 6, */ { 8, 4, 7, 2, 3, 11, 9, 0, 1, 10, 6, 5 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.1 */ -static const char tiling13_1_[2][12] = { -/* 165: 0, 2, 5, 7, */ { 7, 4, 8, 11, 3, 2, 1, 0, 9, 5, 6, 10 }, -/* 90: 1, 3, 4, 6, */ { 6, 7, 11, 10, 2, 1, 0, 3, 8, 4, 5, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.2 */ -static const char tiling13_2[2][6][18] = { -/* 165: 0, 2, 5, 7, */ { - /* 1 */ { 1, 2, 10, 11, 7, 6, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 2 */ { 8, 3, 0, 11, 7, 6, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 3 */ { 9, 5, 4, 8, 3, 0, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 4 */ { 9, 5, 4, 1, 2, 10, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 5 */ { 9, 5, 4, 11, 7, 6, 0, 10, 1, 10, 0, 8, 10, 8, 2, 3, 2, 8 }, - /* 6 */ { 1, 2, 10, 3, 0, 8, 4, 9, 7, 11, 7, 9, 5, 11, 9, 11, 5, 6 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1 */ { 2, 3, 11, 8, 4, 7, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 2 */ { 9, 0, 1, 8, 4, 7, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 3 */ { 6, 5, 10, 9, 0, 1, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 4 */ { 6, 5, 10, 2, 3, 11, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 5 */ { 6, 5, 10, 8, 4, 7, 1, 11, 2, 11, 1, 9, 11, 9, 3, 0, 3, 9 }, - /* 6 */ { 2, 3, 11, 0, 1, 9, 5, 10, 4, 8, 4, 10, 6, 8, 10, 8, 6, 7 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.2 */ -static const char tiling13_2_[2][6][18] = { -/* 165: 0, 2, 5, 7, */ { - /* 1 */ { 10, 5, 6, 11, 3, 2, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 2 */ { 11, 3, 2, 7, 4, 8, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 3 */ { 1, 0, 9, 7, 4, 8, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 4 */ { 10, 5, 6, 1, 0, 9, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 5 */ { 10, 5, 6, 7, 4, 8, 2, 11, 1, 9, 1, 11, 3, 9, 11, 9, 3, 0 }, - /* 6 */ { 11, 3, 2, 9, 1, 0, 4, 10, 5, 10, 4, 8, 10, 8, 6, 7, 6, 8 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1 */ { 6, 7, 11, 8, 0, 3, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 2 */ { 8, 0, 3, 4, 5, 9, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 3 */ { 2, 1, 10, 4, 5, 9, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 4 */ { 6, 7, 11, 2, 1, 10, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 5 */ { 6, 7, 11, 4, 5, 9, 3, 8, 2, 10, 2, 8, 0, 10, 8, 10, 0, 1 }, - /* 6 */ { 8, 0, 3, 10, 2, 1, 5, 11, 6, 11, 5, 9, 11, 9, 7, 4, 7, 9 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.3 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.3 */ -static const char tiling13_3[2][12][30] = { -/* 165: 0, 2, 5, 7, */ { - /* 1,2 */ { 11, 7, 6, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, - /* 1,4 */ { 1, 2, 10, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12 }, - /* 1,5 */ { 11, 7, 6, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, - /* 1,6 */ { 1, 2, 10, 12, 3, 0, 12, 0, 9, 12, 9, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 }, - /* 2,3 */ { 8, 3, 0, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12 }, - /* 2,5 */ { 11, 7, 6, 5, 4, 12, 10, 5, 12, 2, 10, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 }, - /* 2,6 */ { 8, 3, 0, 1, 2, 12, 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 6, 11, 12, 5, 6, 12, 10, 5, 12, 2, 10, 12 }, - /* 3,4 */ { 9, 5, 4, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 }, - /* 3,5 */ { 9, 5, 4, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, - /* 3,6 */ { 8, 3, 0, 12, 1, 2, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 }, - /* 4,5 */ { 9, 5, 4, 7, 6, 12, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 }, - /* 4,6 */ { 1, 2, 10, 3, 0, 12, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12, 8, 7, 12, 0, 8, 12 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1,2 */ { 8, 4, 7, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, - /* 1,4 */ { 2, 3, 11, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12 }, - /* 1,5 */ { 8, 4, 7, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 10, 12, 10, 6 }, - /* 1,6 */ { 2, 3, 11, 12, 0, 1, 12, 1, 10, 12, 10, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 }, - /* 2,3 */ { 0, 1, 9, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12 }, - /* 2,5 */ { 8, 4, 7, 6, 5, 12, 11, 6, 12, 3, 11, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12 }, - /* 2,6 */ { 9, 0, 1, 2, 3, 12, 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 7, 8, 12, 6, 7, 12, 11, 6, 12, 3, 11, 12 }, - /* 3,4 */ { 6, 5, 10, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 }, - /* 3,5 */ { 6, 5, 10, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 8, 12, 8, 4 }, - /* 3,6 */ { 9, 0, 1, 12, 2, 3, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 }, - /* 4,5 */ { 6, 5, 10, 4, 7, 12, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 8, 0, 12, 7, 8, 12 }, - /* 4,6 */ { 2, 3, 11, 0, 1, 12, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12, 9, 4, 12, 1, 9, 12 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.3, inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.3 */ -static const char tiling13_3_[2][12][30] = { -/* 165: 0, 2, 5, 7, */ { - /* 1,2 */ { 3, 2, 11, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 6, 10, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12 }, - /* 1,4 */ { 5, 6, 10, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2 }, - /* 1,5 */ { 10, 5, 6, 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 8, 12, 8, 7 }, - /* 1,6 */ { 11, 3, 2, 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 5, 12, 5, 4, 12, 4, 9, 12, 9, 1 }, - /* 2,3 */ { 7, 4, 8, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, - /* 2,5 */ { 7, 4, 8, 5, 6, 12, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 10, 1, 12, 6, 10, 12 }, - /* 2,6 */ { 11, 3, 2, 1, 0, 12, 10, 1, 12, 6, 10, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 }, - /* 3,4 */ { 1, 0, 9, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4 }, - /* 3,5 */ { 7, 4, 8, 12, 5, 6, 12, 6, 11, 12, 11, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5 }, - /* 3,6 */ { 1, 0, 9, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 7, 12, 7, 6, 12, 6, 11, 12, 11, 3 }, - /* 4,5 */ { 10, 5, 6, 7, 4, 12, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 8, 3, 12, 4, 8, 12 }, - /* 4,6 */ { 9, 1, 0, 3, 2, 12, 8, 3, 12, 4, 8, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1,2 */ { 0, 3, 8, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 7, 11, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12 }, - /* 1,4 */ { 11, 6, 7, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3 }, - /* 1,5 */ { 6, 7, 11, 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 }, - /* 1,6 */ { 8, 0, 3, 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 6, 12, 6, 5, 12, 5, 10, 12, 10, 2 }, - /* 2,3 */ { 4, 5, 9, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, - /* 2,5 */ { 4, 5, 9, 6, 7, 12, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, - /* 2,6 */ { 8, 0, 3, 2, 1, 12, 11, 2, 12, 7, 11, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 }, - /* 3,4 */ { 2, 1, 10, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5 }, - /* 3,5 */ { 4, 5, 9, 12, 6, 7, 12, 7, 8, 12, 8, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 }, - /* 3,6 */ { 2, 1, 10, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 4, 12, 4, 7, 12, 7, 8, 12, 8, 0 }, - /* 4,5 */ { 6, 7, 11, 4, 5, 12, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, - /* 4,6 */ { 10, 2, 1, 0, 3, 12, 9, 0, 12, 5, 9, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.4 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.4 */ -static const char tiling13_4[2][4][36] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,6 */ { 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, -/* 1,4,5 */ { 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, -/* 2,3,5 */ { 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12 }, -/* 3,4,6 */ { 12, 0, 8, 12, 8, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,6 */ { 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, -/* 1,4,5 */ { 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, -/* 2,3,5 */ { 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12 }, -/* 3,4,6 */ { 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.5.1 - * The support edge for the interior test is marked as the 1st column. - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.5.1 */ -static const char tiling13_5_1[2][4][18] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,5 */ { 7, 6, 11, 1, 0, 9, 10, 3, 2, 3, 10, 5, 3, 5, 8, 4, 8, 5 }, -/* 1,4,6 */ { 1, 2, 10, 7, 4, 8, 3, 0, 11, 6, 11, 0, 9, 6, 0, 6, 9, 5 }, -/* 2,3,6 */ { 3, 0, 8, 5, 6, 10, 1, 2, 9, 4, 9, 2, 11, 4, 2, 4, 11, 7 }, -/* 3,4,5 */ { 5, 4, 9, 3, 2, 11, 8, 1, 0, 1, 8, 7, 1, 7, 10, 6, 10, 7 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,5 */ { 4, 7, 8, 2, 1, 10, 11, 0, 3, 0, 11, 6, 0, 6, 9, 5, 9, 6 }, -/* 1,4,6 */ { 2, 3, 11, 4, 5, 9, 0, 1, 8, 7, 8, 1, 10, 7, 1, 7, 10, 6 }, -/* 2,3,6 */ { 0, 1, 9, 6, 7, 11, 2, 3, 10, 5, 10, 3, 8, 5, 3, 5, 8, 4 }, -/* 3,4,5 */ { 6, 5, 10, 0, 3, 8, 9, 2, 1, 2, 9, 4, 2, 4, 11, 7, 11, 4 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.5.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.5.2 */ -static const char tiling13_5_2[2][4][30] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,5 */ { 1, 0, 9, 7, 4, 8, 7, 8, 3, 7, 3, 11, 2, 11, 3, 11, 2, 10, 11, 10, 6, 5, 6, 10, 6, 5, 7, 4, 7, 5 }, -/* 1,4,6 */ { 7, 4, 8, 11, 3, 2, 6, 11, 2, 10, 6, 2, 6, 10, 5, 9, 5, 10, 1, 9, 10, 9, 1, 0, 2, 0, 1, 0, 2, 3 }, -/* 2,3,6 */ { 5, 6, 10, 9, 1, 0, 4, 9, 0, 8, 4, 0, 4, 8, 7, 11, 7, 8, 3, 11, 8, 11, 3, 2, 0, 2, 3, 2, 0, 1 }, -/* 3,4,5 */ { 3, 2, 11, 5, 6, 10, 5, 10, 1, 5, 1, 9, 0, 9, 1, 9, 0, 8, 9, 8, 4, 4, 8, 7, 4, 7, 5, 6, 5, 7 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,5 */ { 2, 1, 10, 4, 5, 9, 4, 9, 0, 4, 0, 8, 3, 8, 0, 8, 3, 11, 8, 11, 7, 6, 7, 11, 7, 6, 4, 5, 4, 6 }, -/* 1,4,6 */ { 4, 5, 9, 8, 0, 3, 7, 8, 3, 11, 7, 3, 7, 11, 6, 10, 6, 11, 2, 10, 11, 10, 2, 1, 3, 1, 2, 1, 3, 0 }, -/* 2,3,6 */ { 6, 7, 11, 10, 2, 1, 5, 10, 1, 9, 5, 1, 5, 9, 4, 8, 4, 9, 0, 8, 9, 8, 0, 3, 1, 3, 0, 3, 1, 2 }, -/* 3,4,5 */ { 0, 3, 8, 6, 7, 11, 6, 11, 2, 6, 2, 10, 1, 10, 2, 10, 1, 9, 10, 9, 5, 5, 9, 4, 5, 4, 6, 7, 6, 4 } -} }; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 14 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling14[12][12] = { -/* 71: 0, 1, 2, 6, */ { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8 }, -/* 43: 0, 1, 3, 5, */ { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5 }, -/* 147: 0, 1, 4, 7, */ { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6 }, -/* 29: 0, 2, 3, 4, */ { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4 }, -/* 201: 0, 3, 6, 7, */ { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5 }, -/* 113: 0, 4, 5, 6, */ { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10 }, -/* 142: 1, 2, 3, 7, */ { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7 }, -/* 54: 1, 2, 4, 5, */ { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2 }, -/* 226: 1, 5, 6, 7, */ { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11 }, -/* 108: 2, 3, 5, 6, */ { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3 }, -/* 212: 2, 4, 6, 7, */ { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8 }, -/* 184: 3, 4, 5, 7, */ { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief original Marching Cubes implementation - * For each of the possible vertex states listed in this table there is a - * specific triangulation of the edge intersection points. The table lists - * all of them in the form of 0-5 edge triples with the list terminated by - * the invalid value -1. For example: casesClassic[3] list the 2 triangles - * formed when cube[0] and cube[1] are inside of the surface, but the rest of - * the cube is not. - */ -//----------------------------------------------------------------------------- -static const char casesClassic[256][16] = { -/* 0: */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 1: 0, */ { 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 2: 1, */ { 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 3: 0, 1, */ { 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 4: 2, */ { 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 5: 0, 2, */ { 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 6: 1, 2, */ { 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 7: 0, 1, 2, */ { 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 8: 3, */ { 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 9: 0, 3, */ { 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 10: 1, 3, */ { 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 11: 0, 1, 3, */ { 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 12: 2, 3, */ { 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 13: 0, 2, 3, */ { 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 14: 1, 2, 3, */ { 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 15: 0, 1, 2, 3, */ { 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 16: 4, */ { 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 17: 0, 4, */ { 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 18: 1, 4, */ { 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 19: 0, 1, 4, */ { 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 20: 2, 4, */ { 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 21: 0, 2, 4, */ { 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 22: 1, 2, 4, */ { 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 23: 0, 1, 2, 4, */ { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1 }, -/* 24: 3, 4, */ { 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 25: 0, 3, 4, */ { 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 26: 1, 3, 4, */ { 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 27: 0, 1, 3, 4, */ { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1 }, -/* 28: 2, 3, 4, */ { 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 29: 0, 2, 3, 4, */ { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1 }, -/* 30: 1, 2, 3, 4, */ { 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, -/* 31: 0, 1, 2, 3, 4, */ { 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 32: 5, */ { 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 33: 0, 5, */ { 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 34: 1, 5, */ { 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 35: 0, 1, 5, */ { 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 36: 2, 5, */ { 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 37: 0, 2, 5, */ { 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 38: 1, 2, 5, */ { 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 39: 0, 1, 2, 5, */ { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1 }, -/* 40: 3, 5, */ { 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 41: 0, 3, 5, */ { 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 42: 1, 3, 5, */ { 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 43: 0, 1, 3, 5, */ { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1 }, -/* 44: 2, 3, 5, */ { 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 45: 0, 2, 3, 5, */ { 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1 }, -/* 46: 1, 2, 3, 5, */ { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 48: 4, 5, */ { 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 49: 0, 4, 5, */ { 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 50: 1, 4, 5, */ { 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 51: 0, 1, 4, 5, */ { 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 52: 2, 4, 5, */ { 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 53: 0, 2, 4, 5, */ { 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1 }, -/* 54: 1, 2, 4, 5, */ { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1 }, -/* 55: 0, 1, 2, 4, 5, */ { 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 56: 3, 4, 5, */ { 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 57: 0, 3, 4, 5, */ { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1 }, -/* 58: 1, 3, 4, 5, */ { 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1 }, -/* 59: 0, 1, 3, 4, 5, */ { 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 60: 2, 3, 4, 5, */ { 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1 }, -/* 61: 0, 2, 3, 4, 5, */ { 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1 }, -/* 62: 1, 2, 3, 4, 5, */ { 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 64: 6, */ { 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 65: 0, 6, */ { 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 66: 1, 6, */ { 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 67: 0, 1, 6, */ { 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 68: 2, 6, */ { 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 69: 0, 2, 6, */ { 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 70: 1, 2, 6, */ { 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 71: 0, 1, 2, 6, */ { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1 }, -/* 72: 3, 6, */ { 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 73: 0, 3, 6, */ { 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 74: 1, 3, 6, */ { 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 75: 0, 1, 3, 6, */ { 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1 }, -/* 76: 2, 3, 6, */ { 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 77: 0, 2, 3, 6, */ { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, -/* 78: 1, 2, 3, 6, */ { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1 }, -/* 79: 0, 1, 2, 3, 6, */ { 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 80: 4, 6, */ { 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 81: 0, 4, 6, */ { 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 82: 1, 4, 6, */ { 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 83: 0, 1, 4, 6, */ { 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1 }, -/* 84: 2, 4, 6, */ { 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 85: 0, 2, 4, 6, */ { 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1 }, -/* 86: 1, 2, 4, 6, */ { 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1 }, -/* 87: 0, 1, 2, 4, 6, */ { 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1 }, -/* 88: 3, 4, 6, */ { 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 89: 0, 3, 4, 6, */ { 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1 }, -/* 90: 1, 3, 4, 6, */ { 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1 }, -/* 91: 0, 1, 3, 4, 6, */ { 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1 }, -/* 92: 2, 3, 4, 6, */ { 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, -/* 93: 0, 2, 3, 4, 6, */ { 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1 }, -/* 94: 1, 2, 3, 4, 6, */ { 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1 }, -/* 96: 5, 6, */ { 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 97: 0, 5, 6, */ { 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 98: 1, 5, 6, */ { 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 99: 0, 1, 5, 6, */ { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, -/* 100: 2, 5, 6, */ { 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 101: 0, 2, 5, 6, */ { 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1 }, -/* 102: 1, 2, 5, 6, */ { 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 103: 0, 1, 2, 5, 6, */ { 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 104: 3, 5, 6, */ { 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 105: 0, 3, 5, 6, */ { 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1 }, -/* 106: 1, 3, 5, 6, */ { 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, -/* 107: 0, 1, 3, 5, 6, */ { 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1 }, -/* 108: 2, 3, 5, 6, */ { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1 }, -/* 109: 0, 2, 3, 5, 6, */ { 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1 }, -/* 110: 1, 2, 3, 5, 6, */ { 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 112: 4, 5, 6, */ { 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 113: 0, 4, 5, 6, */ { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1 }, -/* 114: 1, 4, 5, 6, */ { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1 }, -/* 115: 0, 1, 4, 5, 6, */ { 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 116: 2, 4, 5, 6, */ { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, -/* 117: 0, 2, 4, 5, 6, */ { 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1 }, -/* 118: 1, 2, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 120: 3, 4, 5, 6, */ { 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, -/* 121: 0, 3, 4, 5, 6, */ { 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1 }, -/* 122: 1, 3, 4, 5, 6, */ { 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1 }, -/* 124: 2, 3, 4, 5, 6, */ { 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 128: 7, */ { 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 129: 0, 7, */ { 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 130: 1, 7, */ { 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 131: 0, 1, 7, */ { 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 132: 2, 7, */ { 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 133: 0, 2, 7, */ { 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 134: 1, 2, 7, */ { 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 135: 0, 1, 2, 7, */ { 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1 }, -/* 136: 3, 7, */ { 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 137: 0, 3, 7, */ { 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 138: 1, 3, 7, */ { 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 139: 0, 1, 3, 7, */ { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1 }, -/* 140: 2, 3, 7, */ { 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 141: 0, 2, 3, 7, */ { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1 }, -/* 142: 1, 2, 3, 7, */ { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1 }, -/* 143: 0, 1, 2, 3, 7, */ { 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 144: 4, 7, */ { 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 145: 0, 4, 7, */ { 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 146: 1, 4, 7, */ { 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 147: 0, 1, 4, 7, */ { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1 }, -/* 148: 2, 4, 7, */ { 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 149: 0, 2, 4, 7, */ { 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1 }, -/* 150: 1, 2, 4, 7, */ { 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1 }, -/* 151: 0, 1, 2, 4, 7, */ { 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1 }, -/* 152: 3, 4, 7, */ { 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 153: 0, 3, 4, 7, */ { 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 154: 1, 3, 4, 7, */ { 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1 }, -/* 155: 0, 1, 3, 4, 7, */ { 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 156: 2, 3, 4, 7, */ { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1 }, -/* 157: 0, 2, 3, 4, 7, */ { 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 158: 1, 2, 3, 4, 7, */ { 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 160: 5, 7, */ { 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 161: 0, 5, 7, */ { 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 162: 1, 5, 7, */ { 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 163: 0, 1, 5, 7, */ { 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1 }, -/* 164: 2, 5, 7, */ { 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 165: 0, 2, 5, 7, */ { 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1 }, -/* 166: 1, 2, 5, 7, */ { 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1 }, -/* 167: 0, 1, 2, 5, 7, */ { 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1 }, -/* 168: 3, 5, 7, */ { 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 169: 0, 3, 5, 7, */ { 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1 }, -/* 170: 1, 3, 5, 7, */ { 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1 }, -/* 171: 0, 1, 3, 5, 7, */ { 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1 }, -/* 172: 2, 3, 5, 7, */ { 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1 }, -/* 173: 0, 2, 3, 5, 7, */ { 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1 }, -/* 174: 1, 2, 3, 5, 7, */ { 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1 }, -/* 176: 4, 5, 7, */ { 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 177: 0, 4, 5, 7, */ { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1 }, -/* 178: 1, 4, 5, 7, */ { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1 }, -/* 179: 0, 1, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 180: 2, 4, 5, 7, */ { 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1 }, -/* 181: 0, 2, 4, 5, 7, */ { 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1 }, -/* 182: 1, 2, 4, 5, 7, */ { 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1 }, -/* 184: 3, 4, 5, 7, */ { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1 }, -/* 185: 0, 3, 4, 5, 7, */ { 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 186: 1, 3, 4, 5, 7, */ { 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 188: 2, 3, 4, 5, 7, */ { 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 192: 6, 7, */ { 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 193: 0, 6, 7, */ { 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 194: 1, 6, 7, */ { 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 195: 0, 1, 6, 7, */ { 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1 }, -/* 196: 2, 6, 7, */ { 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 197: 0, 2, 6, 7, */ { 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1 }, -/* 198: 1, 2, 6, 7, */ { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1 }, -/* 199: 0, 1, 2, 6, 7, */ { 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1 }, -/* 200: 3, 6, 7, */ { 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 201: 0, 3, 6, 7, */ { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1 }, -/* 202: 1, 3, 6, 7, */ { 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1 }, -/* 203: 0, 1, 3, 6, 7, */ { 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1 }, -/* 204: 2, 3, 6, 7, */ { 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 205: 0, 2, 3, 6, 7, */ { 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 206: 1, 2, 3, 6, 7, */ { 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 208: 4, 6, 7, */ { 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 209: 0, 4, 6, 7, */ { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1 }, -/* 210: 1, 4, 6, 7, */ { 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1 }, -/* 211: 0, 1, 4, 6, 7, */ { 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1 }, -/* 212: 2, 4, 6, 7, */ { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1 }, -/* 213: 0, 2, 4, 6, 7, */ { 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1 }, -/* 214: 1, 2, 4, 6, 7, */ { 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 216: 3, 4, 6, 7, */ { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 218: 1, 3, 4, 6, 7, */ { 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1 }, -/* 220: 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 224: 5, 6, 7, */ { 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 225: 0, 5, 6, 7, */ { 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1 }, -/* 226: 1, 5, 6, 7, */ { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1 }, -/* 227: 0, 1, 5, 6, 7, */ { 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1 }, -/* 228: 2, 5, 6, 7, */ { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1 }, -/* 229: 0, 2, 5, 6, 7, */ { 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1 }, -/* 230: 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1 }, -/* 232: 3, 5, 6, 7, */ { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1 }, -/* 233: 0, 3, 5, 6, 7, */ { 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1 }, -/* 234: 1, 3, 5, 6, 7, */ { 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 236: 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 240: 4, 5, 6, 7, */ { 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 241: 0, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 242: 1, 4, 5, 6, 7, */ { 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 244: 2, 4, 5, 6, 7, */ { 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 248: 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 255: 0, 1, 2, 3, 4, 5, 6, 7, */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } -}; -//_____________________________________________________________________________ - -} //namespace McCubes - -#endif // _LOOKUPTABLE_H_ diff --git a/ThirdParty/MarchingCubes/McPly.cpp b/ThirdParty/MarchingCubes/McPly.cpp deleted file mode 100644 index 35b9b718eb60b259ca221135dbc4109582e1a057..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/McPly.cpp +++ /dev/null @@ -1,3320 +0,0 @@ -/* - -The interface routines for reading and writing PLY polygon files. - -Greg Turk - ---------------------------------------------------------------- - -A PLY file contains a single polygonal _object_. - -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. - -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties the floating-point values x,y,z and the three unsigned -chars representing red, green and blue. - ------------------------------------------------------------------------ - -Copyright (c) 1998 Georgia Institute of Technology. All rights reserved. - -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. - -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -*/ - -#include "./McPly.h" -#include <iostream> -#include <cstdio> - -namespace McCubes{ - -const char *type_names[] = { /* names of scalar types */ -"invalid", -"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64" -}; - -const char *old_type_names[] = { /* old names of types for backward compatability */ -"invalid", -"char", "short", "int", "uchar", "ushort", "uint", "float", "double" -}; - -int ply_type_size[] = { -0, 1, 2, 4, 1, 2, 4, 4, 8 -}; - -#define NO_OTHER_PROPS -1 - -#define DONT_STORE_PROP 0 -#define STORE_PROP 1 - -#define OTHER_PROP 0 -#define NAMED_PROP 1 - -/* returns 1 if strings are equal, 0 if not */ -int equal_strings( const char * , const char * ); - -/* find an element in a plyfile's list */ -PlyElement *find_element( PlyFile * , const char * ); - -/* find a property in an element's list */ -PlyProperty *find_property( PlyElement * , const char * , int * ); - -/* write to a file the word describing a PLY file data type */ -void write_scalar_type( FILE * , int ); - -/* read a line from a file and break it up into separate words */ -char* *get_words( FILE * , int * , char ** ); - -/* write an item to a file */ -void write_binary_item( FILE * , int, unsigned int, double, int ); -void write_ascii_item( FILE * , int, unsigned int, double, int ); - -/* add information to a PLY file descriptor */ -void add_element( PlyFile * , char ** , int ); -void add_property( PlyFile * , char ** , int ); -void add_comment( PlyFile * , const char * ); -void add_obj_info( PlyFile * , const char * ); - -/* copy a property */ -void copy_property( PlyProperty * , PlyProperty * ); - -/* store a value into where a pointer and a type specify */ -void store_item( char * , int, int, unsigned int, double ); - -/* return the value of a stored item */ -void get_stored_item( void * , int, int * , unsigned int * , double * ); - -/* return the value stored in an item, given ptr to it and its type */ -double get_item_value( const char * , int ); - -/* get binary or ascii item and store it according to ptr and type */ -void get_ascii_item( const char * , int, int * , unsigned int * , double * ); -void get_binary_item( FILE * , int, int * , unsigned int * , double * ); - -/* get a bunch of elements from a file */ -void ascii_get_element( PlyFile * , char * ); -void binary_get_element( PlyFile * , char * ); - -/* memory allocation */ -static char *my_alloc( int, int, const char * ); - - -/*************/ -/* Writing */ -/*************/ - - -/****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. - -Entry: -fp - the given file pointer -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_write( FILE *fp, int nelems, char **elem_names, int file_type ) -{ - int i; - PlyFile *plyfile; - PlyElement *elem; - - /* check for NULL file pointer */ - if ( fp == NULL ) - return ( NULL ); - - /* create a record for this object */ - - plyfile = ( PlyFile * ) myalloc ( sizeof ( PlyFile ) ); - plyfile->file_type = file_type; - plyfile->num_comments = 0; - plyfile->num_obj_info = 0; - plyfile->num_elem_types = nelems; - plyfile->version = 1.0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* tuck aside the names of the elements */ - - plyfile->elems = ( PlyElement * * ) myalloc ( sizeof ( PlyElement * ) * nelems ); - for ( i = 0; i < nelems; i++ ) - { - elem = ( PlyElement * ) myalloc ( sizeof ( PlyElement ) ); - plyfile->elems[i] = elem; - elem->name = strdup ( elem_names[i] ); - elem->num = 0; - elem->nprops = 0; - } - - /* return pointer to the file descriptor */ - return ( plyfile ); -} - - -/****************************************************************************** -Open a polygon file for writing. - -Entry: -filename - name of file to read from -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a file identifier, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *open_for_writing_ply( const char *filename, int nelems, char **elem_names, int file_type ) -{ - PlyFile *plyfile; - char *name; - FILE *fp; - - /* tack on the extension .ply, if necessary */ - - name = ( char * ) myalloc ( sizeof ( char ) * ( (int)strlen ( filename ) + 5 ) ); - strcpy ( name, filename ); - if ( strlen ( name ) < 4 || strcmp ( name + strlen ( name ) - 4, ".ply" ) != 0 ) - strcat ( name, ".ply" ); - - /* open the file for writing */ - - fp = fopen ( name, "w" ); - if ( fp == NULL ) - { - return ( NULL ); - } - - /* create the actual PlyFile structure */ - - plyfile = ply_write ( fp, nelems, elem_names, file_type ); - if ( plyfile == NULL ) - return ( NULL ); - - /* return pointer to the file descriptor */ - return ( plyfile ); -} - - -/****************************************************************************** -Describe an element, including its properties and how many will be written -to the file. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -nelems - number of elements of this type to be written -nprops - number of properties contained in the element -prop_list - list of properties -******************************************************************************/ - -void element_layout_ply( PlyFile *plyfile, const char *elem_name, int nelems, int nprops, PlyProperty *prop_list ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"element_layout_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; - - /* copy the list of properties */ - - elem->nprops = nprops; - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) * nprops ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * nprops ); - - for ( i = 0; i < nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[i] = prop; - elem->store_prop[i] = NAMED_PROP; - copy_property ( prop, &prop_list[i] ); - } -} - - -/****************************************************************************** -Describe a property of an element. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -prop - the new property -******************************************************************************/ - -void ply_describe_property( PlyFile *plyfile, const char *elem_name, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *elem_prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr, "ply_describe_property: can't find element '%s'\n", - elem_name ); - return; - } - - /* create room for new property */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) ); - elem->nprops = 1; - } - else - { - elem->nprops++; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * elem->nprops ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * elem->nprops ); - } - - /* copy the new property */ - - elem_prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property ( elem_prop, prop ); -} - - -/****************************************************************************** -State how many of a given element will be written. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -nelems - number of elements of this type to be written -******************************************************************************/ - -void element_count_ply( PlyFile *plyfile, const char *elem_name, int nelems ) -{ - PlyElement *elem; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"element_count_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; -} - - -/****************************************************************************** -Signal that we've described everything a PLY file's header and that the -header should be written to the file. - -Entry: -plyfile - file identifier -******************************************************************************/ - -void header_complete_ply( PlyFile *plyfile ) -{ - int i,j; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - - fprintf ( fp, "ply\n" ); - - switch ( plyfile->file_type ) - { - case PLY_ASCII: - fprintf ( fp, "format ascii 1.0\n" ); - break; - case PLY_BINARY_BE: - fprintf ( fp, "format binary_big_endian 1.0\n" ); - break; - case PLY_BINARY_LE: - fprintf ( fp, "format binary_little_endian 1.0\n" ); - break; - default: - fprintf ( stderr, "ply_header_complete: bad file type = %d\n", - plyfile->file_type ); - exit ( -1 ); - } - - /* write out the comments */ - - for ( i = 0; i < plyfile->num_comments; i++ ) - fprintf ( fp, "comment %s\n", plyfile->comments[i] ); - - /* write out object information */ - - for ( i = 0; i < plyfile->num_obj_info; i++ ) - fprintf ( fp, "obj_info %s\n", plyfile->obj_info[i] ); - - /* write out information about each element */ - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - { - elem = plyfile->elems[i]; - fprintf ( fp, "element %s %d\n", elem->name, elem->num ); - - /* write out each property */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - if ( prop->is_list == PLY_LIST ) - { - fprintf ( fp, "property list " ); - write_scalar_type ( fp, prop->count_external ); - fprintf ( fp, " " ); - write_scalar_type ( fp, prop->external_type ); - fprintf ( fp, " %s\n", prop->name ); - } - else if ( prop->is_list == PLY_STRING ) - { - fprintf ( fp, "property string" ); - fprintf ( fp, " %s\n", prop->name ); - } - else - { - fprintf ( fp, "property " ); - write_scalar_type ( fp, prop->external_type ); - fprintf ( fp, " %s\n", prop->name ); - } - } - } - - fprintf ( fp, "end_header\n" ); -} - - -/****************************************************************************** -Specify which elements are going to be written. This should be called -before a call to the routine ply_put_element(). - -Entry: -plyfile - file identifier -elem_name - name of element we're talking about -******************************************************************************/ - -void put_element_setup_ply( PlyFile *plyfile, const char *elem_name ) -{ - PlyElement *elem; - - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr, "put_element_setup_ply: can't find element '%s'\n", elem_name ); - exit ( -1 ); - } - - plyfile->which_elem = elem; -} - - -/****************************************************************************** -Write an element to the file. This routine assumes that we're -writing the type of element specified in the last call to the routine -put_element_setup_ply(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to the element -******************************************************************************/ - -void put_element_ply( PlyFile *plyfile, void *elem_ptr ) -{ - int j,k; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - char *item; - char *elem_data; - char* *item_ptr; - int list_count; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - char* *other_ptr; - - elem = plyfile->which_elem; - elem_data = ( char * ) elem_ptr; - other_ptr = ( char * * ) ( ( ( char * ) elem_ptr ) + elem->other_offset ); - - /* write out either to an ascii or binary file */ - - if ( plyfile->file_type == PLY_ASCII ) - { - /* write an ascii file */ - - /* write out each property of the element */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - - if ( elem->store_prop[j] == OTHER_PROP ) - elem_data = *other_ptr; - else - elem_data = ( char * ) elem_ptr; - - if ( prop->is_list == PLY_LIST ) - { - /* list */ - item = elem_data + prop->count_offset; - get_stored_item ( ( void * ) item, prop->count_internal, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->count_external ); - list_count = uint_val; - item_ptr = ( char * * ) ( elem_data + prop->offset ); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for ( k = 0; k < list_count; k++ ) - { - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - item += item_size; - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - char* *str; - item = elem_data + prop->offset; - str = ( char * * ) item; - fprintf ( fp, "\"%s\"", *str ); - } - else - { - /* scalar */ - item = elem_data + prop->offset; - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - } - } - - fprintf ( fp, "\n" ); - } - else - { - /* write a binary file */ - - /* write out each property of the element */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - if ( elem->store_prop[j] == OTHER_PROP ) - elem_data = *other_ptr; - else - elem_data = ( char * ) elem_ptr; - if ( prop->is_list == PLY_LIST ) - { - /* list */ - item = elem_data + prop->count_offset; - item_size = ply_type_size[prop->count_internal]; - get_stored_item ( ( void * ) item, prop->count_internal, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->count_external ); - list_count = uint_val; - item_ptr = ( char * * ) ( elem_data + prop->offset ); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for ( k = 0; k < list_count; k++ ) - { - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - item += item_size; - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - int len; - char* *str; - item = elem_data + prop->offset; - str = ( char * * ) item; - - /* write the length */ - len = (int)strlen( *str ) + 1; - fwrite ( &len, sizeof( int ), 1, fp ); - - /* write the string, including the null character */ - fwrite ( *str, len, 1, fp ); - } - else - { - /* scalar */ - item = elem_data + prop->offset; - item_size = ply_type_size[prop->internal_type]; - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - } - } - } -} - - - - - - -/*************/ -/* Reading */ -/*************/ - - - -/****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. - -Entry: -fp - the given file pointer - -Exit: -nelems - number of elements in object -elem_names - list of element names -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_read( FILE *fp, int *nelems, char ***elem_names ) -{ - int i,j; - PlyFile *plyfile; - int nwords; - char* *words; - int found_format = 0; - char* *elist; - PlyElement *elem; - char *orig_line; - - /* check for NULL file pointer */ - if ( fp == NULL ) - return ( NULL ); - - /* create record for this object */ - - plyfile = ( PlyFile * ) myalloc ( sizeof ( PlyFile ) ); - plyfile->num_elem_types = 0; - plyfile->comments = NULL; - plyfile->num_comments = 0; - plyfile->obj_info = NULL; - plyfile->num_obj_info = 0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - plyfile->rule_list = NULL; - - /* read and parse the file's header */ - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - if ( !words || !equal_strings ( words[0], "ply" ) ) - return ( NULL ); - - while ( words ) - { - /* parse words */ - - if ( equal_strings ( words[0], "format" ) ) - { - if ( nwords != 3 ) - return ( NULL ); - if ( equal_strings ( words[1], "ascii" ) ) - plyfile->file_type = PLY_ASCII; - else if ( equal_strings ( words[1], "binary_big_endian" ) ) - plyfile->file_type = PLY_BINARY_BE; - else if ( equal_strings ( words[1], "binary_little_endian" ) ) - plyfile->file_type = PLY_BINARY_LE; - else - return ( NULL ); - plyfile->version = ( float ) atof ( words[2] ); - found_format = 1; - } - else if ( equal_strings ( words[0], "element" ) ) - add_element ( plyfile, words, nwords ); - else if ( equal_strings ( words[0], "property" ) ) - add_property ( plyfile, words, nwords ); - else if ( equal_strings ( words[0], "comment" ) ) - add_comment ( plyfile, orig_line ); - else if ( equal_strings ( words[0], "obj_info" ) ) - add_obj_info ( plyfile, orig_line ); - else if ( equal_strings ( words[0], "end_header" ) ) - break; - - /* free up words space */ - free ( words ); - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - } - - /* create tags for each property of each element, to be used */ - /* later to say whether or not to store each property for the user */ - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - { - elem = plyfile->elems[i]; - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * elem->nprops ); - for ( j = 0; j < elem->nprops; j++ ) - elem->store_prop[j] = DONT_STORE_PROP; - elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ - } - - /* set return values about the elements */ - - elist = ( char * * ) myalloc ( sizeof ( char * ) * plyfile->num_elem_types ); - for ( i = 0; i < plyfile->num_elem_types; i++ ) - elist[i] = strdup ( plyfile->elems[i]->name ); - - *elem_names = elist; - *nelems = plyfile->num_elem_types; - - /* return a pointer to the file's information */ - - return ( plyfile ); -} - - -/****************************************************************************** -Open a polygon file for reading. - -Entry: -filename - name of file to read from - -Exit: -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary -version - version number of PLY file -returns a file identifier, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_open_for_reading( const char *filename, int *nelems, char ***elem_names, int *file_type, float *version ) -{ - FILE *fp; - PlyFile *plyfile; - char *name; - - /* tack on the extension .ply, if necessary */ - - name = ( char * ) myalloc ( sizeof ( char ) * ( (int)strlen ( filename ) + 5 ) ); - strcpy ( name, filename ); - if ( strlen ( name ) < 4 || strcmp ( name + strlen ( name ) - 4, ".ply" ) != 0 ) - strcat ( name, ".ply" ); - - /* open the file for reading */ - - fp = fopen ( name, "r" ); - if ( fp == NULL ) - return ( NULL ); - - /* create the PlyFile data structure */ - - plyfile = ply_read ( fp, nelems, elem_names ); - - /* determine the file type and version */ - - *file_type = plyfile->file_type; - *version = plyfile->version; - - /* return a pointer to the file's information */ - - return ( plyfile ); -} - - -/****************************************************************************** -Get information about a particular element. - -Entry: -plyfile - file identifier -elem_name - name of element to get information about - -Exit: -nelems - number of elements of this type in the file -nprops - number of properties -returns a list of properties, or NULL if the file doesn't contain that elem -******************************************************************************/ - -PlyProperty **get_element_description_ply( PlyFile *plyfile, const char *elem_name, int *nelems, int *nprops ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - PlyProperty* *prop_list; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - return ( NULL ); - - *nelems = elem->num; - *nprops = elem->nprops; - - /* make a copy of the element's property list */ - prop_list = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) * elem->nprops ); - for ( i = 0; i < elem->nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, elem->props[i] ); - prop_list[i] = prop; - } - - /* return this duplicate property list */ - return ( prop_list ); -} - - -/****************************************************************************** -Specify which properties of an element are to be returned. This should be -called before a call to the routine get_element_ply(). - -Entry: -plyfile - file identifier -elem_name - which element we're talking about -nprops - number of properties -prop_list - list of properties -******************************************************************************/ - -void get_element_setup_ply( PlyFile *plyfile, const char *elem_name, int nprops, PlyProperty *prop_list ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - int index; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - for ( i = 0; i < nprops; i++ ) - { - /* look for actual property */ - prop = find_property ( elem, prop_list[i].name, &index ); - if ( prop == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop_list[i].name, elem_name ); - continue; - } - - /* store its description */ - prop->internal_type = prop_list[i].internal_type; - prop->offset = prop_list[i].offset; - prop->count_internal = prop_list[i].count_internal; - prop->count_offset = prop_list[i].count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } -} - - -/****************************************************************************** -Specify a property of an element that is to be returned. This should be -called (usually multiple times) before a call to the routine ply_get_element(). -This routine should be used in preference to the less flexible old routine -called ply_get_element_setup(). - -Entry: -plyfile - file identifier -elem_name - which element we're talking about -prop - property to add to those that will be returned -******************************************************************************/ - -void ply_get_property( PlyFile *plyfile, const char *elem_name, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property ( elem, prop->name, &index ); - if ( prop_ptr == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem_name ); - return; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; -} - - -/****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -ply_get_element_setup(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to location where the element information should be put -******************************************************************************/ - -void ply_get_element( PlyFile *plyfile, void *elem_ptr ) -{ - if ( plyfile->file_type == PLY_ASCII ) - ascii_get_element ( plyfile, ( char * ) elem_ptr ); - else - binary_get_element ( plyfile, ( char * ) elem_ptr ); -} - - -/****************************************************************************** -Extract the comments from the header information of a PLY file. - -Entry: -plyfile - file identifier - -Exit: -num_comments - number of comments returned -returns a pointer to a list of comments -******************************************************************************/ - -char **get_comments_ply( PlyFile *plyfile, int *num_comments ) -{ - *num_comments = plyfile->num_comments; - return ( plyfile->comments ); -} - - -/****************************************************************************** -Extract the object information (arbitrary text) from the header information -of a PLY file. - -Entry: -plyfile - file identifier - -Exit: -num_obj_info - number of lines of text information returned -returns a pointer to a list of object info lines -******************************************************************************/ - -char **get_obj_info_ply( PlyFile *plyfile, int *num_obj_info ) -{ - *num_obj_info = plyfile->num_obj_info; - return ( plyfile->obj_info ); -} - - -/****************************************************************************** -ake ready for "other" properties of an element-- those properties that -the user has not explicitly asked for, but that are to be stashed away -in a special structure to be carried along with the element's other -information. - -Entry: -plyfile - file identifier -elem - element for which we want to save away other properties -******************************************************************************/ - -void setup_other_props( PlyFile *plyfile, PlyElement *elem ) -{ - int i; - PlyProperty *prop; - int size = 0; - int type_size; - - /* Examine each property in decreasing order of size. */ - /* We do this so that all data types will be aligned by */ - /* word, half-word, or whatever within the structure. */ - - for ( type_size = 8; type_size > 0; type_size /= 2 ) - { - /* add up the space taken by each property, and save this information */ - /* away in the property descriptor */ - - for ( i = 0; i < elem->nprops; i++ ) - { - /* don't bother with properties we've been asked to store explicitly */ - if ( elem->store_prop[i] ) - continue; - - prop = elem->props[i]; - - /* internal types will be same as external */ - prop->internal_type = prop->external_type; - prop->count_internal = prop->count_external; - - /* list case */ - if ( prop->is_list == PLY_LIST ) - { - /* pointer to list */ - if ( type_size == sizeof ( void * ) ) - { - prop->offset = size; - size += sizeof ( void * ); /* always use size of a pointer here */ - } - - /* count of number of list elements */ - if ( type_size == ply_type_size[prop->count_external] ) - { - prop->count_offset = size; - size += ply_type_size[prop->count_external]; - } - } - /* string */ - else if ( prop->is_list == PLY_STRING ) - { - /* pointer to string */ - if ( type_size == sizeof ( char * ) ) - { - prop->offset = size; - size += sizeof ( char * ); - } - } - /* scalar */ - else if ( type_size == ply_type_size[prop->external_type] ) - { - prop->offset = size; - size += ply_type_size[prop->external_type]; - } - } - } - - /* save the size for the other_props structure */ - elem->other_size = size; -} - - -/****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. - -Entry: -plyfile - file identifier -elem - the element that we want to store other_props in -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -static PlyOtherProp *get_other_properties( PlyFile *plyfile, PlyElement *elem, int offset ) -{ - int i; - PlyOtherProp *other; - PlyProperty *prop; - int nprops; - - /* remember that this is the "current" element */ - plyfile->which_elem = elem; - - /* save the offset to where to store the other_props */ - elem->other_offset = offset; - - /* place the appropriate pointers, etc. in the element's property list */ - setup_other_props ( plyfile, elem ); - - /* create structure for describing other_props */ - other = ( PlyOtherProp * ) myalloc ( sizeof ( PlyOtherProp ) ); - other->name = strdup ( elem->name ); -#if 0 -if (elem->other_offset == NO_OTHER_PROPS) { -other->size = 0; -other->props = NULL; -other->nprops = 0; -return (other); -} -#endif - other->size = elem->other_size; - other->props = ( PlyProperty * * ) myalloc ( sizeof( PlyProperty ) * elem->nprops ); - - /* save descriptions of each "other" property */ - nprops = 0; - for ( i = 0; i < elem->nprops; i++ ) - { - if ( elem->store_prop[i] ) - continue; - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, elem->props[i] ); - other->props[nprops] = prop; - nprops++; - } - other->nprops = nprops; - - /* set other_offset pointer appropriately if there are NO other properties */ - if ( other->nprops == 0 ) - { - elem->other_offset = NO_OTHER_PROPS; - } - - /* return structure */ - return ( other ); -} - - -/****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. The user needn't be concerned for how -these properties are stored. - -Entry: -plyfile - file identifier -elem_name - name of element that we want to store other_props in -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -PlyOtherProp *ply_get_other_properties( PlyFile *plyfile, const char *elem_name, int offset ) -{ - PlyElement *elem; - PlyOtherProp *other; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf ( stderr, "ply_get_other_properties: Can't find element '%s'\n", - elem_name ); - return ( NULL ); - } - - other = get_other_properties ( plyfile, elem, offset ); - return ( other ); -} - - - - -/*************************/ -/* Other Element Stuff */ -/*************************/ - - - - - -/****************************************************************************** -Grab all the data for the current element that a user does not want to -explicitly read in. Stores this in the PLY object's data structure. - -Entry: -plyfile - pointer to file - -Exit: -returns pointer to ALL the "other" element data for this PLY file -******************************************************************************/ - -PlyOtherElems *get_other_element_ply( PlyFile *plyfile ) -{ - int i; - PlyElement *elem; - char *elem_name; - int elem_count; - PlyOtherElems *other_elems; - OtherElem *other; - - elem = plyfile->which_elem; - elem_name = elem->name; - elem_count = elem->num; - - /* create room for the new "other" element, initializing the */ - /* other data structure if necessary */ - - if ( plyfile->other_elems == NULL ) - { - plyfile->other_elems = ( PlyOtherElems * ) myalloc ( sizeof ( PlyOtherElems ) ); - other_elems = plyfile->other_elems; - other_elems->other_list = ( OtherElem * ) myalloc ( sizeof ( OtherElem ) ); - other = &( other_elems->other_list[0] ); - other_elems->num_elems = 1; - } - else - { - other_elems = plyfile->other_elems; - other_elems->other_list = ( OtherElem * ) realloc ( other_elems->other_list, - sizeof ( OtherElem ) * other_elems->num_elems + 1 ); - other = &( other_elems->other_list[other_elems->num_elems] ); - other_elems->num_elems++; - } - - /* count of element instances in file */ - other->elem_count = elem_count; - - /* save name of element */ - other->elem_name = strdup ( elem_name ); - - /* create a list to hold all the current elements */ - other->other_data = ( OtherData * * ) - malloc ( sizeof ( OtherData * ) * other->elem_count ); - - /* set up for getting elements */ - other->other_props = ply_get_other_properties ( plyfile, elem_name, - offsetof( OtherData,other_props ) ); - - /* grab all these elements */ - for ( i = 0; i < other->elem_count; i++ ) - { - /* grab and element from the file */ - other->other_data[i] = ( OtherData * ) malloc ( sizeof ( OtherData ) ); - ply_get_element ( plyfile, ( void * ) other->other_data[i] ); - } - - /* return pointer to the other elements data */ - return ( other_elems ); -} - - -/****************************************************************************** -Write out the "other" elements specified for this PLY file. - -Entry: -plyfile - pointer to PLY file to write out other elements for -******************************************************************************/ - -void put_other_elements_ply( PlyFile *plyfile ) -{ - int i,j; - OtherElem *other; - - /* make sure we have other elements to write */ - if ( plyfile->other_elems == NULL ) - return; - - /* write out the data for each "other" element */ - - for ( i = 0; i < plyfile->other_elems->num_elems; i++ ) - { - other = &( plyfile->other_elems->other_list[i] ); - put_element_setup_ply ( plyfile, other->elem_name ); - - /* write out each instance of the current element */ - for ( j = 0; j < other->elem_count; j++ ) - put_element_ply ( plyfile, ( void * ) other->other_data[j] ); - } -} - - -/****************************************************************************** -Free up storage used by an "other" elements data structure. - -Entry: -other_elems - data structure to free up -******************************************************************************/ - -void free_other_elements_ply( PlyOtherElems *other_elems ) -{ -} - - - -/*******************/ -/* Miscellaneous */ -/*******************/ - - - -/****************************************************************************** -Close a PLY file. - -Entry: -plyfile - identifier of file to close -******************************************************************************/ - -void ply_close( PlyFile *plyfile ) -{ - fclose ( plyfile->fp ); - - /* free up memory associated with the PLY file */ - free ( plyfile ); -} - - -/****************************************************************************** -Get version number and file type of a PlyFile. - -Entry: -ply - pointer to PLY file - -Exit: -version - version of the file -file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE -******************************************************************************/ - -void get_info_ply( PlyFile *ply, float *version, int *file_type ) -{ - if ( ply == NULL ) - return; - - *version = ply->version; - *file_type = ply->file_type; -} - - -/****************************************************************************** -Compare two strings. Returns 1 if they are the same, 0 if not. -******************************************************************************/ - -int equal_strings( const char *s1, const char *s2 ) -{ - while ( *s1 && *s2 ) - if ( *s1++ != *s2++ ) - return ( 0 ); - - if ( *s1 != *s2 ) - return ( 0 ); - else - return ( 1 ); -} - - -/****************************************************************************** -Re-create the command line that was used to invoke this program. - -Entry: -argc - number of words in argv -argv - array of words in command line -******************************************************************************/ - -char *recreate_command_line( int argc, char *argv[] ) -{ - int i; - char *line; - int len = 0; - - /* count total number of characters needed, including separating spaces */ - for ( i = 0; i < argc; i++ ) - len += (int)strlen( argv[i] ) + 1; - - /* create empty line */ - line = ( char * ) malloc ( sizeof( char ) * len ); - line[0] = '\0'; - - /* repeatedly append argv */ - for ( i = 0; i < argc; i++ ) - { - strcat ( line, argv[i] ); - if ( i != argc - 1 ) - strcat ( line, " " ); - } - - return ( line ); -} - - -/****************************************************************************** -Find an element from the element list of a given PLY object. - -Entry: -plyfile - file id for PLY file -element - name of element we're looking for - -Exit: -returns the element, or NULL if not found -******************************************************************************/ - -PlyElement *find_element( PlyFile *plyfile, const char *element ) -{ - int i; - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - if ( equal_strings ( element, plyfile->elems[i]->name ) ) - return ( plyfile->elems[i] ); - - return ( NULL ); -} - - -/****************************************************************************** -Find a property in the list of properties of a given element. - -Entry: -elem - pointer to element in which we want to find the property -prop_name - name of property to find - -Exit: -index - index to position in list -returns a pointer to the property, or NULL if not found -******************************************************************************/ - -PlyProperty *find_property( PlyElement *elem, const char *prop_name, int *index ) -{ - int i; - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( prop_name, elem->props[i]->name ) ) - { - *index = i; - return ( elem->props[i] ); - } - - *index = -1; - return ( NULL ); -} - - -/****************************************************************************** -Read an element from an ascii file. - -Entry: -plyfile - file identifier -elem_ptr - pointer to element -******************************************************************************/ - -void ascii_get_element( PlyFile *plyfile, char *elem_ptr ) -{ - int j,k; - PlyElement *elem=NULL; - PlyProperty *prop=NULL; - char* *words=NULL; - int nwords; - int which_word; - char *elem_data=NULL,*item=NULL; - char *item_ptr=NULL; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char* *store_array=NULL; - char *orig_line=NULL; - char *other_data=NULL; - int other_flag; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if ( elem->other_offset != NO_OTHER_PROPS ) - { - char* *ptr; - other_flag = 1; - /* make room for other_props */ - other_data = ( char * ) myalloc ( elem->other_size ); - /* store pointer in user's structure to the other_props */ - ptr = ( char * * ) ( elem_ptr + elem->other_offset ); - *ptr = other_data; - } - else - other_flag = 0; - - /* read in the element */ - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - if ( words == NULL ) - { - fprintf ( stderr, "ply_get_element: unexpected end of file\n" ); - exit ( -1 ); - } - - which_word = 0; - - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - store_it = ( elem->store_prop[j] | other_flag ); - - /* store either in the user's structure or in other_props */ - if ( elem->store_prop[j] ) - elem_data = elem_ptr; - else - elem_data = other_data; - - if ( prop->is_list == PLY_LIST ) - { - /* a list */ - - /* get and store the number of items in the list */ - get_ascii_item ( words[which_word++], prop->count_external, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->count_offset; - store_item( item, prop->count_internal, int_val, uint_val, double_val ); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = ( char * * ) ( elem_data + prop->offset ); - - if ( list_count == 0 ) - { - if ( store_it ) - *store_array = NULL; - } - else - { - if ( store_it ) - { - item_ptr = ( char * ) myalloc ( sizeof ( char ) * item_size * list_count ); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for ( k = 0; k < list_count; k++ ) - { - get_ascii_item ( words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - store_item ( item, prop->internal_type, - int_val, uint_val, double_val ); - item += item_size; - } - } - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* a string */ - if ( store_it ) - { - char *str; - char* *str_ptr; - str = strdup ( words[which_word++] ); - item = elem_data + prop->offset; - str_ptr = ( char * * ) item; - *str_ptr = str; - } - else - { - which_word++; - } - } - else - { - /* a scalar */ - get_ascii_item ( words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->offset; - store_item ( item, prop->internal_type, int_val, uint_val, double_val ); - } - } - } - - free ( words ); -} - - -/****************************************************************************** -Read an element from a binary file. - -Entry: -plyfile - file identifier -elem_ptr - pointer to an element -******************************************************************************/ - -void binary_get_element( PlyFile *plyfile, char *elem_ptr ) -{ - int j,k; - PlyElement *elem= NULL; - PlyProperty *prop= NULL; - FILE *fp = plyfile->fp; - char *elem_data; - char *item = NULL; - char *item_ptr= NULL; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char* *store_array= NULL; - char *other_data= NULL; - int other_flag; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if ( elem->other_offset != NO_OTHER_PROPS ) - { - char* *ptr; - other_flag = 1; - /* make room for other_props */ - other_data = ( char * ) myalloc ( elem->other_size ); - /* store pointer in user's structure to the other_props */ - ptr = ( char * * ) ( elem_ptr + elem->other_offset ); - *ptr = other_data; - } - else - other_flag = 0; - - /* read in a number of elements */ - - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - store_it = ( elem->store_prop[j] | other_flag ); - - /* store either in the user's structure or in other_props */ - if ( elem->store_prop[j] ) - elem_data = elem_ptr; - else - elem_data = other_data; - - if ( prop->is_list == PLY_LIST ) - { - /* list */ - - /* get and store the number of items in the list */ - get_binary_item ( fp, prop->count_external, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->count_offset; - store_item( item, prop->count_internal, int_val, uint_val, double_val ); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = ( char * * ) ( elem_data + prop->offset ); - if ( list_count == 0 ) - { - if ( store_it ) - *store_array = NULL; - } - else - { - if ( store_it ) - { - item_ptr = ( char * ) myalloc ( sizeof ( char ) * item_size * list_count ); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for ( k = 0; k < list_count; k++ ) - { - get_binary_item ( fp, prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - store_item ( item, prop->internal_type, - int_val, uint_val, double_val ); - item += item_size; - } - } - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - int len; - char *str; - fread ( &len, sizeof( int ), 1, fp ); - str = ( char * ) myalloc ( len ); - fread ( str, len, 1, fp ); - if ( store_it ) - { - char* *str_ptr; - item = elem_data + prop->offset; - str_ptr = ( char * * ) item; - *str_ptr = str; - } - } - else - { - /* scalar */ - get_binary_item ( fp, prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->offset; - store_item ( item, prop->internal_type, int_val, uint_val, double_val ); - } - } - } -} - - -/****************************************************************************** -Write to a file the word that represents a PLY data type. - -Entry: -fp - file pointer -code - code for type -******************************************************************************/ - -void write_scalar_type( FILE *fp, int code ) -{ - /* make sure this is a valid code */ - - if ( code <= StartType || code >= EndType ) - { - fprintf ( stderr, "write_scalar_type: bad data code = %d\n", code ); - exit ( -1 ); - } - - /* write the code to a file */ - - fprintf ( fp, "%s", type_names[code] ); -} - - -/****************************************************************************** -Get a text line from a file and break it up into words. - -IMPORTANT: The calling routine should call "free" on the returned pointer once -finished with it. - -Entry: -fp - file to read from - -Exit: -nwords - number of words returned -orig_line - the original line of characters -returns a list of words from the line, or NULL if end-of-file -******************************************************************************/ - -char **get_words( FILE *fp, int *nwords, char **orig_line ) -{ -#define BIG_STRING 4096 - static char str[BIG_STRING]; - static char str_copy[BIG_STRING]; - char* *words; - int max_words = 10; - int num_words = 0; - char *ptr,*ptr2; - char *result; - - words = ( char * * ) myalloc ( sizeof ( char * ) * max_words ); - - /* read in a line */ - result = fgets ( str, BIG_STRING, fp ); - if ( result == NULL ) - { - *nwords = 0; - *orig_line = NULL; - return ( NULL ); - } - - /* convert line-feed and tabs into spaces */ - /* (this guarentees that there will be a space before the */ - /* null character at the end of the string) */ - - str[BIG_STRING - 2] = ' '; - str[BIG_STRING - 1] = '\0'; - - for ( ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++ ) - { - *ptr2 = *ptr; - if ( *ptr == '\t' ) - { - *ptr = ' '; - *ptr2 = ' '; - } - else if ( *ptr == '\n' ) - { - *ptr = ' '; - *ptr2 = ' '; - break; - } - else if ( *ptr == '\r' ) - { - *ptr = ' '; - *ptr2 = '\0'; - } - } - - /* find the words in the line */ - - ptr = str; - while ( *ptr != '\0' ) - { - /* jump over leading spaces */ - while ( *ptr == ' ' ) - ptr++; - - /* break if we reach the end */ - if ( *ptr == '\0' ) - break; - - /* allocate more room for words if necessary */ - if ( num_words >= max_words ) - { - max_words += 10; - words = ( char * * ) realloc ( words, sizeof ( char * ) * max_words ); - } - - if ( *ptr == '\"' ) - { - /* a quote indidicates that we have a string */ - - /* skip over leading quote */ - ptr++; - - /* save pointer to beginning of word */ - words[num_words++] = ptr; - - /* find trailing quote or end of line */ - while ( *ptr != '\"' && *ptr != '\0' ) - ptr++; - - /* replace quote with a null character to mark the end of the word */ - /* if we are not already at the end of the line */ - if ( *ptr != '\0' ) - *ptr++ = '\0'; - } - else - { - /* non-string */ - - /* save pointer to beginning of word */ - words[num_words++] = ptr; - - /* jump over non-spaces */ - while ( *ptr != ' ' ) - ptr++; - - /* place a null character here to mark the end of the word */ - *ptr++ = '\0'; - } - } - - /* return the list of words */ - *nwords = num_words; - *orig_line = str_copy; - return ( words ); -} - - -/****************************************************************************** -Return the value of an item, given a pointer to it and its type. - -Entry: -item - pointer to item -type - data type that "item" points to - -Exit: -returns a double-precision float that contains the value of the item -******************************************************************************/ - -double get_item_value( const char *item, int type ) -{ - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch ( type ) - { - case Int8: - pchar = ( char * ) item; - int_value = *pchar; - return ( ( double ) int_value ); - case Uint8: - puchar = ( unsigned char * ) item; - int_value = *puchar; - return ( ( double ) int_value ); - case Int16: - pshort = ( short int * ) item; - int_value = *pshort; - return ( ( double ) int_value ); - case Uint16: - pushort = ( unsigned short int * ) item; - int_value = *pushort; - return ( ( double ) int_value ); - case Int32: - pint = ( int * ) item; - int_value = *pint; - return ( ( double ) int_value ); - case Uint32: - puint = ( unsigned int * ) item; - uint_value = *puint; - return ( ( double ) uint_value ); - case Float32: - pfloat = ( float * ) item; - double_value = *pfloat; - return ( double_value ); - case Float64: - pdouble = ( double * ) item; - double_value = *pdouble; - return ( double_value ); - default: - fprintf ( stderr, "get_item_value: bad type = %d\n", type ); - exit ( -1 ); - } - - return ( 0.0 ); /* never actually gets here */ -} - - -/****************************************************************************** -Write out an item to a file as raw binary bytes. - -Entry: -fp - file to write to -int_val - integer version of item -uint_val - unsigned integer version of item -double_val - double-precision float version of item -type - data type to write out -******************************************************************************/ - -void write_binary_item( FILE *fp, int int_val, unsigned int uint_val, double double_val, int type ) -{ - unsigned char uchar_val; - char char_val; - unsigned short ushort_val; - short short_val; - float float_val; - - switch ( type ) - { - case Int8: - char_val = int_val; - fwrite ( &char_val, 1, 1, fp ); - break; - case Int16: - short_val = int_val; - fwrite ( &short_val, 2, 1, fp ); - break; - case Int32: - fwrite ( &int_val, 4, 1, fp ); - break; - case Uint8: - uchar_val = uint_val; - fwrite ( &uchar_val, 1, 1, fp ); - break; - case Uint16: - ushort_val = uint_val; - fwrite ( &ushort_val, 2, 1, fp ); - break; - case Uint32: - fwrite ( &uint_val, 4, 1, fp ); - break; - case Float32: - float_val = ( float ) double_val; - fwrite ( &float_val, 4, 1, fp ); - break; - case Float64: - fwrite ( &double_val, 8, 1, fp ); - break; - default: - fprintf ( stderr, "write_binary_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: -fp - file to write to -int_val - integer version of item -uint_val - unsigned integer version of item -double_val - double-precision float version of item -type - data type to write out -******************************************************************************/ - -void write_ascii_item( FILE *fp, int int_val, unsigned int uint_val, double double_val, int type ) -{ - switch ( type ) - { - case Int8: - case Int16: - case Int32: - fprintf ( fp, "%d ", int_val ); - break; - case Uint8: - case Uint16: - case Uint32: - fprintf ( fp, "%u ", uint_val ); - break; - case Float32: - case Float64: - fprintf ( fp, "%12f ", double_val ); - break; - default: - fprintf ( stderr, "write_ascii_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Get the value of an item that is in memory, and place the result -into an integer, an unsigned integer and a double. - -Entry: -ptr - pointer to the item -type - data type supposedly in the item - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_stored_item( void *ptr, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - switch ( type ) - { - case Int8: - *int_val = *( ( char * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint8: - *uint_val = *( ( unsigned char * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int16: - *int_val = *( ( short int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint16: - *uint_val = *( ( unsigned short int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int32: - *int_val = *( ( int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint32: - *uint_val = *( ( unsigned int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Float32: - *double_val = *( ( float * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - case Float64: - *double_val = *( ( double * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - default: - fprintf ( stderr, "get_stored_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Get the value of an item from a binary file, and place the result -into an integer, an unsigned integer and a double. - -Entry: -fp - file to get item from -type - data type supposedly in the word - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_binary_item( FILE *fp, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - char c[8]; - void *ptr; - - ptr = ( void * ) c; - - switch ( type ) - { - case Int8: - fread ( ptr, 1, 1, fp ); - *int_val = *( ( char * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint8: - fread ( ptr, 1, 1, fp ); - *uint_val = *( ( unsigned char * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int16: - fread ( ptr, 2, 1, fp ); - *int_val = *( ( short int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint16: - fread ( ptr, 2, 1, fp ); - *uint_val = *( ( unsigned short int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int32: - fread ( ptr, 4, 1, fp ); - *int_val = *( ( int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint32: - fread ( ptr, 4, 1, fp ); - *uint_val = *( ( unsigned int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Float32: - fread ( ptr, 4, 1, fp ); - *double_val = *( ( float * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - case Float64: - fread ( ptr, 8, 1, fp ); - *double_val = *( ( double * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - default: - fprintf ( stderr, "get_binary_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Extract the value of an item from an ascii word, and place the result -into an integer, an unsigned integer and a double. - -Entry: -word - word to extract value from -type - data type supposedly in the word - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_ascii_item( const char *word, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - switch ( type ) - { - case Int8: - case Uint8: - case Int16: - case Uint16: - case Int32: - *int_val = atoi ( word ); - *uint_val = *int_val; - *double_val = *int_val; - break; - - case Uint32: - *uint_val = strtoul ( word, ( char * * ) NULL, 10 ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - - case Float32: - case Float64: - *double_val = atof ( word ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - - default: - fprintf ( stderr, "get_ascii_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Store a value into a place being pointed to, guided by a data type. - -Entry: -item - place to store value -type - data type -int_val - integer version of value -uint_val - unsigned integer version of value -double_val - double version of value - -Exit: -item - pointer to stored value -******************************************************************************/ - -void store_item( char *item, int type, int int_val, unsigned int uint_val, double double_val ) -{ - unsigned char *puchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - - switch ( type ) - { - case Int8: - *item = int_val; - break; - case Uint8: - puchar = ( unsigned char * ) item; - *puchar = uint_val; - break; - case Int16: - pshort = ( short * ) item; - *pshort = int_val; - break; - case Uint16: - pushort = ( unsigned short * ) item; - *pushort = uint_val; - break; - case Int32: - pint = ( int * ) item; - *pint = int_val; - break; - case Uint32: - puint = ( unsigned int * ) item; - *puint = uint_val; - break; - case Float32: - pfloat = ( float * ) item; - *pfloat = ( float ) double_val; - break; - case Float64: - pdouble = ( double * ) item; - *pdouble = double_val; - break; - default: - fprintf ( stderr, "store_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Add an element to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -words - list of words describing the element -nwords - number of words in the list -******************************************************************************/ - -void add_element( PlyFile *plyfile, char **words, int nwords ) -{ - PlyElement *elem; - - /* create the new element */ - elem = ( PlyElement * ) myalloc ( sizeof ( PlyElement ) ); - elem->name = strdup ( words[1] ); - elem->num = atoi ( words[2] ); - elem->nprops = 0; - - /* make room for new element in the object's list of elements */ - if ( plyfile->num_elem_types == 0 ) - plyfile->elems = ( PlyElement * * ) myalloc ( sizeof ( PlyElement * ) ); - else - plyfile->elems = ( PlyElement * * ) realloc ( plyfile->elems, - sizeof ( PlyElement * ) * ( plyfile->num_elem_types + 1 ) ); - - /* add the new element to the object's list */ - plyfile->elems[plyfile->num_elem_types] = elem; - plyfile->num_elem_types++; -} - - -/****************************************************************************** -Return the type of a property, given the name of the property. - -Entry: -name - name of property type - -Exit: -returns integer code for property, or 0 if not found -******************************************************************************/ - -int get_prop_type( const char *type_name ) -{ - int i; - - /* try to match the type name */ - for ( i = StartType + 1; i < EndType; i++ ) - if ( equal_strings ( type_name, type_names[i] ) ) - return ( i ); - - /* see if we can match an old type name */ - for ( i = StartType + 1; i < EndType; i++ ) - if ( equal_strings ( type_name, old_type_names[i] ) ) - return ( i ); - - /* if we get here, we didn't find the type */ - return ( 0 ); -} - - -/****************************************************************************** -Add a property to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -words - list of words describing the property -nwords - number of words in the list -******************************************************************************/ - -void add_property( PlyFile *plyfile, char **words, int nwords ) -{ - PlyProperty *prop; - PlyElement *elem; - - /* create the new property */ - - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - - if ( equal_strings ( words[1], "list" ) ) - { - /* list */ - prop->count_external = get_prop_type ( words[2] ); - prop->external_type = get_prop_type ( words[3] ); - prop->name = strdup ( words[4] ); - prop->is_list = PLY_LIST; - } - else if ( equal_strings ( words[1], "string" ) ) - { - /* string */ - prop->count_external = Int8; - prop->external_type = Int8; - prop->name = strdup ( words[2] ); - prop->is_list = PLY_STRING; - } - else - { - /* scalar */ - prop->external_type = get_prop_type ( words[1] ); - prop->name = strdup ( words[2] ); - prop->is_list = PLY_SCALAR; - } - - /* add this property to the list of properties of the current element */ - - elem = plyfile->elems[plyfile->num_elem_types - 1]; - - if ( elem->nprops == 0 ) - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - else - elem->props = ( PlyProperty * * ) realloc ( elem->props, - sizeof ( PlyProperty * ) * ( elem->nprops + 1 ) ); - - elem->props[elem->nprops] = prop; - elem->nprops++; -} - - -/****************************************************************************** -Add a comment to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -line - line containing comment -******************************************************************************/ - -void add_comment( PlyFile *plyfile, const char *line ) -{ - int i; - - /* skip over "comment" and leading spaces and tabs */ - i = 7; - while ( line[i] == ' ' || line[i] == '\t' ) - i++; - - append_comment_ply ( plyfile, &line[i] ); -} - - -/****************************************************************************** -Add a some object information to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -line - line containing text info -******************************************************************************/ - -void add_obj_info( PlyFile *plyfile, const char *line ) -{ - int i; - - /* skip over "obj_info" and leading spaces and tabs */ - i = 8; - while ( line[i] == ' ' || line[i] == '\t' ) - i++; - - append_obj_info_ply ( plyfile, &line[i] ); -} - - -/****************************************************************************** -Copy a property. -******************************************************************************/ - -void copy_property( PlyProperty *dest, PlyProperty *src ) -{ - dest->name = strdup ( src->name ); - dest->external_type = src->external_type; - dest->internal_type = src->internal_type; - dest->offset = src->offset; - - dest->is_list = src->is_list; - dest->count_external = src->count_external; - dest->count_internal = src->count_internal; - dest->count_offset = src->count_offset; -} - - -/****************************************************************************** -Allocate some memory. - -Entry: -size - amount of memory requested (in bytes) -lnum - line number from which memory was requested -fname - file name from which memory was requested -******************************************************************************/ - -static char *my_alloc( int size, int lnum, const char *fname ) -{ - char *ptr; - - ptr = ( char * ) malloc ( size ); - - if ( ptr == 0 ) - { - fprintf( stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname ); - } - - return ( ptr ); -} - - -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ - - - -/****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. - -Entry: -fp - the given file pointer - -Exit: -nelems - number of elements in object -elem_names - list of element names -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *read_ply( FILE *fp ) -{ - PlyFile *ply; - int num_elems; - char* *elem_names; - - ply = ply_read ( fp, &num_elems, &elem_names ); - - return ( ply ); -} - - -/****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. - -Entry: -fp - the given file pointer -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *write_ply( FILE *fp, int nelems, char **elem_names, int file_type ) -{ - PlyFile *ply; - - ply = ply_write ( fp, nelems, elem_names, file_type ); - - return ( ply ); -} - - -/****************************************************************************** -Return a list of the names of the elements in a particular PLY file. - -Entry: -ply - PLY file whose element name list we want - -Exit: -num_elems - the number of element names in the list -returns the list of names -******************************************************************************/ - -char **get_element_list_ply( PlyFile *ply, int *num_elems ) -{ - int i; - char* *elist; - - /* create the list of element names */ - - elist = ( char * * ) myalloc ( sizeof ( char * ) * ply->num_elem_types ); - for ( i = 0; i < ply->num_elem_types; i++ ) - elist[i] = strdup ( ply->elems[i]->name ); - - /* return the number of elements and the list of element names */ - *num_elems = ply->num_elem_types; - return ( elist ); -} - - -/****************************************************************************** -Append a comment to a PLY file. - -Entry: -ply - file to append comment to -comment - the comment to append -******************************************************************************/ - -void append_comment_ply( PlyFile *ply, const char *comment ) -{ - /* (re)allocate space for new comment */ - if ( ply->num_comments == 0 ) - ply->comments = ( char * * ) myalloc ( sizeof ( char * ) ); - else - ply->comments = ( char * * ) realloc ( ply->comments, - sizeof ( char * ) * ( ply->num_comments + 1 ) ); - - /* add comment to list */ - ply->comments[ply->num_comments] = strdup ( comment ); - ply->num_comments++; -} - - -/****************************************************************************** -Copy the comments from one PLY file to another. - -Entry: -out_ply - destination file to copy comments to -in_ply - the source of the comments -******************************************************************************/ - -void copy_comments_ply( PlyFile *out_ply, PlyFile *in_ply ) -{ - int i; - - for ( i = 0; i < in_ply->num_comments; i++ ) - append_comment_ply ( out_ply, in_ply->comments[i] ); -} - - -/****************************************************************************** -Append object information (arbitrary text) to a PLY file. - -Entry: -ply - file to append object info to -obj_info - the object info to append -******************************************************************************/ - -void append_obj_info_ply( PlyFile *ply, const char *obj_info ) -{ - /* (re)allocate space for new info */ - if ( ply->num_obj_info == 0 ) - ply->obj_info = ( char * * ) myalloc ( sizeof ( char * ) ); - else - ply->obj_info = ( char * * ) realloc ( ply->obj_info, - sizeof ( char * ) * ( ply->num_obj_info + 1 ) ); - - /* add info to list */ - ply->obj_info[ply->num_obj_info] = strdup ( obj_info ); - ply->num_obj_info++; -} - - -/****************************************************************************** -Copy the object information from one PLY file to another. - -Entry: -out_ply - destination file to copy object information to -in_ply - the source of the object information -******************************************************************************/ - -void copy_obj_info_ply( PlyFile *out_ply, PlyFile *in_ply ) -{ - int i; - - for ( i = 0; i < in_ply->num_obj_info; i++ ) - append_obj_info_ply ( out_ply, in_ply->obj_info[i] ); -} - - -/****************************************************************************** -Close a PLY file. - -Entry: -plyfile - identifier of file to close -******************************************************************************/ - -void close_ply( PlyFile *plyfile ) -{ - fclose ( plyfile->fp ); -} - - -/****************************************************************************** -Free the memory used by a PLY file. - -Entry: -plyfile - identifier of file -******************************************************************************/ - -void free_ply( PlyFile *plyfile ) -{ - /* free up memory associated with the PLY file */ - free ( plyfile ); -} - - -/****************************************************************************** -Specify the index of the next element to be read in from a PLY file. - -Entry: -ply - file to read from -index - index of the element to be read - -Exit: -elem_count - the number of elements in the file -returns pointer to the name of this next element -******************************************************************************/ - -char *setup_element_read_ply( PlyFile *ply, int index, int *elem_count ) -{ - PlyElement *elem; - - if ( index < 0 || index > ply->num_elem_types ) - { - fprintf ( stderr, "Warning: No element with index %d\n", index ); - return ( 0 ); - } - - elem = ply->elems[index]; - - /* set this to be the current element */ - ply->which_elem = elem; - - /* return the number of such elements in the file and the element's name */ - *elem_count = elem->num; - return ( elem->name ); -} - - -/****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -setup_element_read_ply(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to location where the element information should be put -******************************************************************************/ - -void get_element_ply( PlyFile *plyfile, void *elem_ptr ) -{ - if ( plyfile->file_type == PLY_ASCII ) - ascii_get_element ( plyfile, ( char * ) elem_ptr ); - else - binary_get_element ( plyfile, ( char * ) elem_ptr ); -} - - -/****************************************************************************** -Specify one of several properties of the current element that is to be -read from a file. This should be called (usually multiple times) before a -call to the routine get_element_ply(). - -Entry: -plyfile - file identifier -prop - property to add to those that will be returned - -Exit: -0 if the property has not been found -1 if the property has been found -******************************************************************************/ - -int setup_property_ply( PlyFile *plyfile, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - elem = plyfile->which_elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property ( elem, prop->name, &index ); - if ( prop_ptr == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem->name ); - return 0; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - return 1 ; -} - - -/****************************************************************************** -Specify that we want the "other" properties of the current element to be tucked -away within the user's structure. - -Entry: -plyfile - file identifier -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -PlyOtherProp *get_other_properties_ply( PlyFile *plyfile, int offset ) -{ - PlyOtherProp *other; - - other = get_other_properties ( plyfile, plyfile->which_elem, offset ); - return ( other ); -} - - -/****************************************************************************** -Describe which element is to be written next and state how many of them will -be written. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being described -nelems - number of elements of this type to be written -******************************************************************************/ - -void describe_element_ply( PlyFile *plyfile, char *elem_name, int nelems ) -{ - PlyElement *elem; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"describe_element_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; - - /* now this element is the current element */ - plyfile->which_elem = elem; -} - - -/****************************************************************************** -Describe a property of an element. - -Entry: -plyfile - file identifier -prop - the new property -******************************************************************************/ - -void describe_property_ply( PlyFile *plyfile, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *elem_prop; - - elem = plyfile->which_elem; - - /* create room for new property */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) ); - elem->nprops = 1; - } - else - { - elem->nprops++; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * elem->nprops ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * elem->nprops ); - } - - /* copy the new property */ - - elem_prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property ( elem_prop, prop ); -} - - -/****************************************************************************** -Describe what the "other" properties are that are to be stored, and where -they are in an element. -******************************************************************************/ - -void describe_other_properties_ply( PlyFile *plyfile, PlyOtherProp *other, int offset ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, other->name ); - if ( elem == NULL ) - { - fprintf( stderr, "describe_other_properties_ply: can't find element '%s'\n", - other->name ); - return; - } - - /* create room for other properties */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) - myalloc ( sizeof ( PlyProperty * ) * other->nprops ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * other->nprops ); - elem->nprops = 0; - } - else - { - int newsize; - newsize = elem->nprops + other->nprops; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * newsize ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * newsize ); - } - - /* copy the other properties */ - - for ( i = 0; i < other->nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, other->props[i] ); - elem->props[elem->nprops] = prop; - elem->store_prop[elem->nprops] = OTHER_PROP; - elem->nprops++; - } - - /* save other info about other properties */ - elem->other_size = other->size; - elem->other_offset = offset; -} - - -/****************************************************************************** -Pass along a pointer to "other" elements that we want to save in a given -PLY file. These other elements were presumably read from another PLY file. - -Entry: -plyfile - file pointer in which to store this other element info -other_elems - info about other elements that we want to store -******************************************************************************/ - -void describe_other_elements_ply( PlyFile *plyfile, PlyOtherElems *other_elems ) -{ - int i; - OtherElem *other; - - /* ignore this call if there is no other element */ - if ( other_elems == NULL ) - return; - - /* save pointer to this information */ - plyfile->other_elems = other_elems; - - /* describe the other properties of this element */ - - for ( i = 0; i < other_elems->num_elems; i++ ) - { - other = &( other_elems->other_list[i] ); - element_count_ply ( plyfile, other->elem_name, other->elem_count ); - describe_other_properties_ply ( plyfile, other->other_props, - offsetof( OtherData,other_props ) ); - } -} - - - -/**** Property Propagation Rules ****/ - - -typedef struct RuleName { -int code; -const char *name; -} RuleName; - -const RuleName rule_name_list[] = { -{AVERAGE_RULE, "avg"}, -{RANDOM_RULE, "rnd"}, -{MINIMUM_RULE, "max"}, -{MAXIMUM_RULE, "min"}, -{MAJORITY_RULE, "major"}, -{SAME_RULE, "same"}, -{-1, "end_marker"}, -}; - - - -/****************************************************************************** -Initialize the property propagation rules for an element. Default is to -use averaging (AVERAGE_RULE) for creating all new properties. - -Entry: -ply - PLY object that this is for -elem_name - name of the element that we're making the rules for - -Exit: -returns pointer to the default rules -******************************************************************************/ - -PlyPropRules *init_rule_ply( PlyFile *ply, char *elem_name ) -{ - int i,j; - PlyElement *elem; - PlyPropRules *rules; - PlyRuleList *list; - int found_prop; - - elem = find_element ( ply, elem_name ); - if ( elem == NULL ) - { - fprintf ( stderr, "init_rule_ply: Can't find element '%s'\n", elem_name ); - exit ( -1 ); - } - - rules = ( PlyPropRules * ) myalloc ( sizeof ( PlyPropRules ) ); - rules->elem = elem; - rules->rule_list = ( int * ) myalloc ( sizeof( int ) * elem->nprops ); - rules->max_props = 0; - rules->nprops = 0; - - /* default is to use averaging rule */ - for ( i = 0; i < elem->nprops; i++ ) - rules->rule_list[i] = AVERAGE_RULE; - - /* see if there are other rules we should use */ - - if ( ply->rule_list == NULL ) - return ( rules ); - - /* try to match the element, property and rule name */ - - for ( list = ply->rule_list; list != NULL; list = list->next ) - { - if ( !equal_strings ( list->element, elem->name ) ) - continue; - - found_prop = 0; - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( list->property, elem->props[i]->name ) ) - { - found_prop = 1; - - /* look for matching rule name */ - for ( j = 0; rule_name_list[j].code != -1; j++ ) - if ( equal_strings ( list->name, rule_name_list[j].name ) ) - { - rules->rule_list[i] = rule_name_list[j].code; - break; - } - } - - if ( !found_prop ) - { - fprintf ( stderr, "Can't find property '%s' for rule '%s'\n", - list->property, list->name ); - continue; - } - } - - return ( rules ); -} - - -/****************************************************************************** -odify a property propagation rule. - -Entry: -rules - rules for the element -prop_name - name of the property whose rule we're modifying -rule_type - type of rule (MAXIMUM_RULE, MINIMUM_RULE, MAJORITY_RULE, etc.) -******************************************************************************/ - -void modify_rule_ply( PlyPropRules *rules, char *prop_name, int rule_type ) -{ - int i; - PlyElement *elem = rules->elem; - - /* find the property and modify its rule type */ - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( elem->props[i]->name, prop_name ) ) - { - rules->rule_list[i] = rule_type; - return; - } - - /* we didn't find the property if we get here */ - fprintf ( stderr, "modify_rule_ply: Can't find property '%s'\n", prop_name ); - exit ( -1 ); -} - - -/****************************************************************************** -Begin to create a set of properties from a set of propagation rules. - -Entry: -ply - PLY object whose rules we're preparing to use -rules - rules for the element -******************************************************************************/ - -void start_props_ply( PlyFile *ply, PlyPropRules *rules ) -{ - /* PlyElement *elem = rules->elem; */ - - /* save pointer to the rules in the PLY object */ - ply->current_rules = rules; - - /* get ready for new sets of properties to combine */ - rules->nprops = 0; -} - - -/****************************************************************************** -Remember a set of properties and their weights for creating a new set of -properties. - -Entry: -weight - weights for this set of properties -other_props - the properties to use -******************************************************************************/ - -void weight_props_ply( PlyFile *ply, float weight, void *other_props ) -{ - PlyPropRules *rules = ply->current_rules; - - /* allocate space for properties and weights, if necessary */ - if ( rules->max_props == 0 ) - { - rules->max_props = 6; - rules->props = ( void * * ) myalloc ( sizeof ( void * ) * rules->max_props ); - rules->weights = ( float * ) myalloc ( sizeof ( float ) * rules->max_props ); - } - if ( rules->nprops == rules->max_props ) - { - rules->max_props *= 2; - rules->props = ( void * * ) realloc ( rules->props, - sizeof ( void * ) * rules->max_props ); - rules->weights = ( float * ) realloc ( rules->weights, - sizeof ( float ) * rules->max_props ); - } - - /* remember these new properties and their weights */ - - rules->props[rules->nprops] = other_props; - rules->weights[rules->nprops] = weight; - rules->nprops++; -} - - -/****************************************************************************** -Return a pointer to a new set of properties that have been created using -a specified set of property combination rules and a given collection of -"other" properties. - -Exit: -returns a pointer to the new properties -******************************************************************************/ - -void *get_new_props_ply( PlyFile *ply ) -{ - int i,j; - static double *vals; - static int max_vals = 0; - PlyPropRules *rules = ply->current_rules; - PlyElement *elem = rules->elem; - PlyProperty *prop; - char *data; - char *new_data; - void *ptr; - int offset; - int type; - double double_val; - int int_val; - unsigned int uint_val; - int random_pick; - - /* return NULL if we've got no "other" properties */ - if ( elem->other_size == 0 ) - { - return ( NULL ); - } - - /* create room for combined other properties */ - new_data = ( char * ) myalloc ( sizeof ( char ) * elem->other_size ); - - /* make sure there is enough room to store values we're to combine */ - - if ( max_vals == 0 ) - { - max_vals = rules->nprops; - vals = ( double * ) myalloc ( sizeof ( double ) * rules->nprops ); - } - if ( rules->nprops >= max_vals ) - { - max_vals = rules->nprops; - vals = ( double * ) realloc ( vals, sizeof ( double ) * rules->nprops ); - } - - /* in case we need a random choice */ - random_pick = ( int ) floor ( (double)rules->nprops ); //* drand48()); - - /* calculate the combination for each "other" property of the element */ - - for ( i = 0; i < elem->nprops; i++ ) - { - /* don't bother with properties we've been asked to store explicitly */ - if ( elem->store_prop[i] ) - continue; - - prop = elem->props[i]; - offset = prop->offset; - type = prop->external_type; - - /* collect together all the values we're to combine */ - - for ( j = 0; j < rules->nprops; j++ ) - { - data = ( char * ) rules->props[j]; - ptr = ( void * ) ( data + offset ); - get_stored_item ( ( void * ) ptr, type, &int_val, &uint_val, &double_val ); - vals[j] = double_val; - } - - /* calculate the combined value */ - - switch ( rules->rule_list[i] ) - { - case AVERAGE_RULE: - { - double sum = 0; - double weight_sum = 0; - for ( j = 0; j < rules->nprops; j++ ) - { - sum += vals[j] * rules->weights[j]; - weight_sum += rules->weights[j]; - } - double_val = sum / weight_sum; - break; - } - case MINIMUM_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val > vals[j] ) - double_val = vals[j]; - break; - } - case MAXIMUM_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val < vals[j] ) - double_val = vals[j]; - break; - } - case RANDOM_RULE: - { - double_val = vals[random_pick]; - break; - } - case SAME_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val != vals[j] ) - { - fprintf ( stderr, - "get_new_props_ply: Error combining properties that should be the same.\n" ); - exit ( -1 ); - } - break; - } - default: - fprintf ( stderr, "get_new_props_ply: Bad rule = %d\n", - rules->rule_list[i] ); - exit ( -1 ); - } - - /* store the combined value */ - - int_val = ( int ) double_val; - uint_val = ( unsigned int ) double_val; - ptr = ( void * ) ( new_data + offset ); - store_item ( ( char * ) ptr, type, int_val, uint_val, double_val ); - } - - return ( ( void * ) new_data ); -} - - -/****************************************************************************** -Set the list of user-specified property combination rules. -******************************************************************************/ - -void set_prop_rules_ply( PlyFile *ply, PlyRuleList *prop_rules ) -{ - ply->rule_list = prop_rules; -} - - -/****************************************************************************** -Append a property rule to a growing list of user-specified rules. - -Entry: -rule_list - current rule list -name - name of property combination rule -property - "element.property" says which property the rule affects - -Exit: -returns pointer to the new rule list -******************************************************************************/ - -PlyRuleList* append_prop_rule( PlyRuleList *rule_list, char *name, char *property ) -{ - PlyRuleList *rule; - PlyRuleList *rule_ptr; - char *str,*str2; - char *ptr; - - /* find . */ - str = strdup ( property ); - for ( ptr = str; *ptr != '\0' && *ptr != '.'; ptr++ ) - ; - - /* split string at . */ - if ( *ptr == '.' ) - { - *ptr = '\0'; - str2 = ptr + 1; - } - else - { - fprintf ( stderr, "Can't find property '%s' for rule '%s'\n", - property, name ); - return ( rule_list ); - } - - rule = ( PlyRuleList * ) malloc ( sizeof ( PlyRuleList ) ); - rule->name = name; - rule->element = str; - rule->property = str2; - rule->next = NULL; - - /* either start rule list or append to it */ - - if ( rule_list == NULL ) - rule_list = rule; - else - { - /* append new rule to current list */ - rule_ptr = rule_list; - while ( rule_ptr->next != NULL ) - rule_ptr = rule_ptr->next; - rule_ptr->next = rule; - } - - /* return pointer to list */ - - return ( rule_list ); -} - - -/****************************************************************************** -See if a name matches the name of any property combination rules. - -Entry: -name - name of rule we're trying to match - -Exit: -returns 1 if we find a match, 0 if not -******************************************************************************/ - -int matches_rule_name( char* name ) -{ - int i; - - for ( i = 0; rule_name_list[i].code != -1; i++ ) - if ( equal_strings ( rule_name_list[i].name, name ) ) - return ( 1 ); - - return ( 0 ); -} - -} //namespace diff --git a/ThirdParty/MarchingCubes/McPly.h b/ThirdParty/MarchingCubes/McPly.h deleted file mode 100644 index b1cca17280f0d0bff88969a097b03ca891b39fcb..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/McPly.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - -Header for PLY polygon files. - -- Greg Turk - -A PLY file contains a single polygonal _object_. - -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. - -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties three floating-point values x,y,z and three unsigned -chars for red, green and blue. - ------------------------------------------------------------------------ - -Copyright (c) 1998 Georgia Institute of Technology. All rights reserved. - -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. - -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -*/ -#ifndef MCPLY_H -#define MCPLY_H - -#include <cmath> -#include <string> -#include <cstring> -#include <cstring> -#include <cstdlib> - -namespace McCubes{ - -static const int PLY_ASCII = 1; // ascii PLY file -static const int PLY_BINARY_BE = 2; // binary PLY file, big endian -static const int PLY_BINARY_LE = 3; // binary PLY file, little endian - -static const int PLY_OKAY = 0; // ply routine worked okay -static const int PLY_ERROR = -1; // error in ply routine - -/* scalar data types supported by PLY format */ - -static const int StartType = 0; -static const int Int8 = 1; -static const int Int16 = 2; -static const int Int32 = 3; -static const int Uint8 = 4; -static const int Uint16 = 5; -static const int Uint32 = 6; -static const int Float32 = 7; -static const int Float64 = 8; -static const int EndType = 9; - -static const int PLY_SCALAR = 0; -static const int PLY_LIST = 1; -static const int PLY_STRING = 2; - - -typedef struct PlyProperty { /* description of a property */ - -char *name; /* property name */ -int external_type; /* file's data type */ -int internal_type; /* program's data type */ -int offset; /* offset bytes of prop in a struct */ - -int is_list; /* 0 = scalar, 1 = list, 2 = char string */ -int count_external; /* file's count type */ -int count_internal; /* program's count type */ -int count_offset; /* offset byte for list count */ - -} PlyProperty; - -typedef struct PlyElement { /* description of an element */ -char *name; /* element name */ -int num; /* number of elements in this object */ -int size; /* size of element (bytes) or -1 if variable */ -int nprops; /* number of properties for this element */ -PlyProperty **props; /* list of properties in the file */ -char *store_prop; /* flags: property wanted by user? */ -int other_offset; /* offset to un-asked-for props, or -1 if none*/ -int other_size; /* size of other_props structure */ -} PlyElement; - -typedef struct PlyOtherProp { /* describes other properties in an element */ -char *name; /* element name */ -int size; /* size of other_props */ -int nprops; /* number of properties in other_props */ -PlyProperty **props; /* list of properties in other_props */ -} PlyOtherProp; - -typedef struct OtherData { /* for storing other_props for an other element */ -void *other_props; -} OtherData; - -typedef struct OtherElem { /* data for one "other" element */ -char *elem_name; /* names of other elements */ -int elem_count; /* count of instances of each element */ -OtherData **other_data; /* actual property data for the elements */ -PlyOtherProp *other_props; /* description of the property data */ -} OtherElem; - -typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */ -int num_elems; /* number of other elements */ -OtherElem *other_list; /* list of data for other elements */ -} PlyOtherElems; - -static const int AVERAGE_RULE = 1; -static const int MAJORITY_RULE = 2; -static const int MINIMUM_RULE = 3; -static const int MAXIMUM_RULE = 4; -static const int SAME_RULE = 5; -static const int RANDOM_RULE = 6; - -typedef struct PlyPropRules { /* rules for combining "other" properties */ -PlyElement *elem; /* element whose rules we are making */ -int *rule_list; /* types of rules (AVERAGE_PLY, MAJORITY_PLY, etc.) */ -int nprops; /* number of properties we're combining so far */ -int max_props; /* maximum number of properties we have room for now */ -void **props; /* list of properties we're combining */ -float *weights; /* list of weights of the properties */ -} PlyPropRules; - -typedef struct PlyRuleList { -char *name; /* name of the rule */ -char *element; /* name of element that rule applies to */ -char *property; /* name of property that rule applies to */ -struct PlyRuleList *next; /* pointer for linked list of rules */ -} PlyRuleList; - -typedef struct PlyFile { /* description of PLY file */ -FILE *fp; /* file pointer */ -int file_type; /* ascii or binary */ -float version; /* version number of file */ -int num_elem_types; /* number of element types of object */ -PlyElement **elems; /* list of elements */ -int num_comments; /* number of comments */ -char **comments; /* list of comments */ -int num_obj_info; /* number of items of object information */ -char **obj_info; /* list of object info items */ -PlyElement *which_elem; /* element we're currently reading or writing */ -PlyOtherElems *other_elems; /* "other" elements from a PLY file */ -PlyPropRules *current_rules; /* current propagation rules */ -PlyRuleList *rule_list; /* rule list from user */ -} PlyFile; - -// memory allocation -//extern char *my_alloc(); -#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__) - - -// old routines - -#if 0 -extern PlyFile *ply_write(FILE *, int, char **, int); -extern PlyFile *ply_read(FILE *, int *, char ***); -extern PlyFile *ply_open_for_reading( const char *, int *, char ***, int *, float *); -extern void ply_close(PlyFile *); -extern PlyOtherProp *ply_get_other_properties(PlyFile *, const char *, int); -#endif - -extern void ply_describe_property( PlyFile * , const char * , PlyProperty * ); -extern void ply_get_property( PlyFile * , const char * , PlyProperty * ); -extern void ply_get_element( PlyFile * , void * ); - - -//--- delcaration of routines --- - -PlyOtherElems *get_other_element_ply( PlyFile * ); - -PlyFile *read_ply( FILE * ); -PlyFile *write_ply( FILE * , int, char ** , int ); -extern PlyFile *open_for_writing_ply( const char * , int, char ** , int ); -void close_ply( PlyFile * ); -void free_ply( PlyFile * ); - -void get_info_ply( PlyFile * , float * , int * ); -void free_other_elements_ply( PlyOtherElems * ); - -void append_comment_ply( PlyFile *, const char * ); -void append_obj_info_ply( PlyFile * , const char * ); -void copy_comments_ply( PlyFile * , PlyFile * ); -void copy_obj_info_ply( PlyFile * , PlyFile * ); -char* *get_comments_ply( PlyFile * , int * ); -char* *get_obj_info_ply( PlyFile * , int * ); - -char* *get_element_list_ply( PlyFile * , int * ); -int setup_property_ply( PlyFile * , PlyProperty * ); -void get_element_ply( PlyFile * , void * ); -char *setup_element_read_ply( PlyFile * , int, int * ); -PlyOtherProp *get_other_properties_ply( PlyFile * , int ); - -void element_count_ply( PlyFile * , const char * , int ); -void describe_element_ply( PlyFile * , const char * , int ); -void describe_property_ply( PlyFile * , PlyProperty * ); -void describe_other_properties_ply( PlyFile * , PlyOtherProp * , int ); -void describe_other_elements_ply( PlyFile * , PlyOtherElems * ); -void get_element_setup_ply( PlyFile * , const char * , int, PlyProperty * ); -PlyProperty* *get_element_description_ply( PlyFile * , const char * , int * , int * ); -void element_layout_ply( PlyFile * , const char * , int, int, PlyProperty * ); - -void header_complete_ply( PlyFile * ); -void put_element_setup_ply( PlyFile * ,const char * ); -void put_element_ply( PlyFile * , void * ); -void put_other_elements_ply( PlyFile * ); - -PlyPropRules *init_rule_ply( PlyFile * , const char * ); -void modify_rule_ply( PlyPropRules * , const char * , int ); -void start_props_ply( PlyFile * , PlyPropRules * ); -void weight_props_ply( PlyFile * , float, void * ); -void *get_new_props_ply( PlyFile * ); -void set_prop_rules_ply( PlyFile * , PlyRuleList * ); -PlyRuleList *append_prop_rule( PlyRuleList * , const char * , const char * ); -int matches_rule_name( const char * ); - -int equal_strings( const char * , const char * ); -char *recreate_command_line( int, char *argv[] ); - -} //namespace McCubes - -#endif // PLY_H__ - diff --git a/ThirdParty/MarchingCubes/McTypes.h b/ThirdParty/MarchingCubes/McTypes.h deleted file mode 100644 index 9ff91d5a0b4f8457a6843ce0e957d383c04a2d9e..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/McTypes.h +++ /dev/null @@ -1,37 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MCTYPES_H -#define MCTYPES_H - -//extension by CAB -#include <vector> -#include <string> -#include <fstream> - -#include <basics/utilities/UbException.h> -#include <basics/container/CbArray3D.h> -#include <basics/container/CbArray4D.h> - -namespace McCubes -{ - - #if !defined(WIN32) || defined(__CYGWIN__) - #pragma interface - #endif // WIN32 - - //_____________________________________________________________________________ - // types - /** unsigned char alias */ - typedef unsigned char uchar; - /** signed char alias */ - typedef signed char schar; - /** isovalue alias */ - typedef double real; - -} //namespace McCubes - -#endif //MCTYPES_H diff --git a/ThirdParty/MarchingCubes/McWrapper.h b/ThirdParty/MarchingCubes/McWrapper.h deleted file mode 100644 index a60f18b6bc11cb867fe7d32352dfa221765f9f10..0000000000000000000000000000000000000000 --- a/ThirdParty/MarchingCubes/McWrapper.h +++ /dev/null @@ -1,305 +0,0 @@ -// _ ___ __ __________ _ __ -//| | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -//| | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -//| |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -//|___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -//#ifndef MCWRAPPER_H -//#define MCWRAPPER_H -// -//extension by CAB -//#include <vector> -//#include <string> -//#include <fstream> -// -//#include <basics/utilities/UbException.h> -//#include <basics/container/CbUniformMatrix3D.h> -//#include <basics/container/CbUniformMatrix4D.h> -// -//#include <3rdParty/MarchingCubes/McTypes.h> -// -//namespace McCubes{ -// -////////////////////////////////////////////////////////////////////////// -//Standard-Wrapper -// MarchingCubes<DataWrapper> mc( 10,8,5 ); -// for(int z=0; z<mc.size_z(); z++) -// for(int y=0; y<mc.size_y(); y++) -// for(int x=0; x<mc.size_x(); x++) -// mc.set_data(x,x,y,z); -// -// //mc.set_method(false) //<-MC methode, STD=false -// mc.init_all(); -// -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); - -//template< typename T=real > -//class McDataWrapper -//{ -//public: -// typedef T value_type; -// typedef typename std::vector< value_type >::reference reference; -// typedef typename std::vector< value_type >::const_reference const_reference; -// typedef typename std::vector< value_type >::pointer pointer; -// typedef typename std::vector< value_type >::const_pointer const_pointer; -// -//public: -// McDataWrapper() : size_x1(-1), size_x2(-1), size_x3(-1) -// { -// } -// /*==========================================================*/ -// McDataWrapper(const int& size_x1, const int& size_x2, const int& size_x3, const T& initVal=T()) -// { -// this->resize(size_x1,size_x2,size_x3,initVal); -// } -// /*=======================================================================*/ -// reference operator() (const int& x1, const int& x2, const int& x3) -// { -// #ifdef _DEBUG -// return this->data.at(x1 + x2*size_x1 + x3*size_x1*size_x2); -// #else -// return this->data[x1 + x2*size_x1 + x3*size_x1*size_x2]; -// #endif -// } -// /*=======================================================================*/ -// const_reference operator() (const int& x1, const int& x2, const int& x3) const -// { -// #ifdef _DEBUG -// return this->data.at(x1 + x2*size_x1 + x3*size_x1*size_x2); -// #else -// return this->data[x1 + x2*size_x1 + x3*size_x1*size_x2]; -// #endif -// } -// /*==========================================================*/ -// inline void setData( const T& val, const int& x1, const int& x2, const int& x3 ) -// { -// #ifdef _DEBUG -// this->data.at(x1 + x2*size_x1 + x3*size_x1*size_x2) = val; -// #else -// this->data[x1 + x2*size_x1 + x3*size_x1*size_x2] = val; -// #endif -// } -// /*==========================================================*/ -// inline value_type getData(const int& x1, const int& x2, const int& x3 ) const -// { -// #ifdef _DEBUG -// return this->data.at(x1 + x2*size_x1 + x3*size_x1*size_x2); -// #else -// return this->data[x1 + x2*size_x1 + x3*size_x1*size_x2]; -// #endif -// } -// /*==========================================================*/ -// inline void resize(const int& size_x1, const int& size_x2, const int& size_x3) -// { -// if(size_x1>0 && size_x2>0 && size_x3>0) -// { -// this->size_x1 = size_x1; -// this->size_x2 = size_x2; -// this->size_x3 = size_x3; -// this->data.resize(size_x1*size_x2*size_x3); -// } -// } -// /*==========================================================*/ -// inline void resize(const int& size_x1, const int& size_x2, const int& size_x3, const T& initVal) -// { -// if(size_x1>0 && size_x2>0 && size_x3>0) -// { -// this->size_x1 = size_x1; -// this->size_x2 = size_x2; -// this->size_x3 = size_x3; -// this->data.resize(size_x1*size_x2*size_x3,initVal); -// } -// } -// /*==========================================================*/ -// int getNX1() const { return size_x1; } -// int getNX2() const { return size_x2; } -// int getNX3() const { return size_x3; } -// -//protected: -// std::vector<T> data; -// int size_x1, size_x2, size_x3; -//}; -// -////////////////////////////////////////////////////////////////////////// -//Matrix4DWrapper-Wrapper -//example: -// int indexForDataValue = 1; -// CbUniformMatrix4D<double> data(10,8,5,2); -// for(int x3=0; x3<data.getNX3(); x3++) -// for(int x2=0; x2<data.getNX2(); x2++) -// for(int x1=0; x1<data.getNX1(); x1++) -// data(x1,x2,x3,indexForDataValue) = x1; -// -// Matrix4DWrapper< CbUniformMatrix4D<double> > wrapper(&data,indexForDataValue); -// MarchingCubes< Matrix4DWrapper< CbUniformMatrix4D<double> > > mc( wrapper ); -// -// mc.init_all(); -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); -//template< typename Matrix4D > -//class Matrix4DWrapper -//{ -//public: -// typedef typename Matrix4D::value_type value_type; -// -//public: -// Matrix4DWrapper() : valIndex(-1), matrix(NULL), minX1(-1), minX2(-1), minX3(-1), maxX1(-1), maxX2(-1), maxX3(-1) -// { -// //wird benötigt, damit MarchingCubes generell eine membervariabel erstellen kann -// } -// /*==========================================================*/ -// //fuer beliebige matrizen -// Matrix4DWrapper( Matrix4D* matrix, const int& valIndex) -// : valIndex(valIndex), matrix(matrix) -// { -// -// } -// /*==========================================================*/ -// Matrix4DWrapper( Matrix4D* matrix, const int& valIndex,const int& n1, const int& nx2, const int& nx3) -// : valIndex(valIndex), matrix(matrix), nx1(nx1), nx2(nx2), nx3(nx3) -// { -// minX1 = minX2 = minX3 = 0; -// maxX1 = nx1-1; -// maxX2 = nx2-1; -// maxX3 = nx3-1; -// } -// /*==========================================================*/ -// //wenn man z.B. matrixX1 von[0..10] geht und man nur den bereich 1..9 fuer MC -// //verwenden möchte -> minX1=1 und maxX2=2 -// Matrix4DWrapper( Matrix4D* matrix, const int& valIndex, const int& minX1, const int& minX2, const int& minX3, -// const int& maxX1, const int& maxX2, const int& maxX3) -// : valIndex(valIndex), matrix(matrix), minX1(minX1), minX2(minX2), minX3(minX3), maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) -// { -// nx1 = matrix->getNX1()-1; -// nx2 = matrix->getNX2()-1; -// nx3 = matrix->getNX3()-1; -// -// if(minX1<0 || minX2<0 || minX3<0 || maxX1>=nx1 || maxX2>=nx2 || maxX3>=nx3) -// throw UbException(UB_EXARGS,"range error"); -// } -// /*==========================================================*/ -// inline void setData( const real& val, const int& x1, const int& x2, const int& x3 ) -// { -// (*matrix)(minX1+x1, minX2+x2, minX3+x3, valIndex) = static_cast<value_type>(val); -// } -// /*==========================================================*/ -// inline value_type getData(const int& x1, const int& x2, const int& x3 ) const -// { -// return (*matrix)(minX1+x1, minX2+x2, minX3+x3, valIndex); -// } -// /*==========================================================*/ -// inline void resize(const int& size_x1, const int& size_x2, const int& size_x3) -// { -// throw UbException("Matrix4DWrapper::resize(int,int,int) - mit diesem wrapper nicht erlaubt"); -// } -// /*==========================================================*/ -// inline int getMinX1() const { return minX1; } -// inline int getMinX2() const { return minX2; } -// inline int getMinX3() const { return minX3; } -// -// inline int getMaxX1() const { return maxX1; } -// inline int getMaxX2() const { return maxX2; } -// inline int getMaxX3() const { return maxX3; } -// -// inline int getNX1() const { nx1; } -// inline int getNX2() const { nx2; } -// inline int getNX3() const { nx3; } -// -//protected: -// int valIndex; -// Matrix4D* matrix; -// int minX1, minX2, minX3, maxX1, maxX2, maxX3, nx1, nx2, nx3; -//}; -// -////////////////////////////////////////////////////////////////////////// -//Matrix3DWrapper-Wrapper -// CbUniformMatrix3D<double> data(10,8,5); -// for(int x3=0; x3<data.getNX3(); x3++) -// for(int x2=0; x2<data.getNX2(); x2++) -// for(int x1=0; x1<data.getNX1(); x1++) -// data(x1,x2,x3) = x1; -// -// Matrix3DWrapper< CbUniformMatrix3D<double> > wrapper(&data); -// MarchingCubes< Matrix3DWrapper< CbUniformMatrix3D<double> > > mc( wrapper ); -// -// mc.init_all(); -// mc.run(3.5); -// mc.writeUCD("c:/temp/triangles.inp"); -// mc.clean_all(); -//template< typename Matrix3D > -//class Matrix3DWrapper -//{ -//public: -// typedef typename Matrix3D::value_type value_type; -// -//public: -// Matrix3DWrapper() : matrix(NULL), minX1(-1), minX2(-1), minX3(-1), maxX1(-1), maxX2(-1), maxX3(-1) -// { -// //wird benötigt, damit MarchingCubes generell eine membervariabel erstellen kann -// } -// /*==========================================================*/ -// Matrix3DWrapper( Matrix3D* matrix) -// : matrix(matrix) -// { -// minX1 = minX2 = minX3 = 0; -// maxX1 = matrix->getNX1(); -// maxX2 = matrix->getNX2(); -// maxX3 = matrix->getNX3(); -// -// minX1 = minX2 = minX3 = 0; -// maxX1 = nx1-1; -// maxX2 = nx2-1; -// maxX3 = nx3-1; -// -// } -// /*==========================================================*/ -// Matrix3DWrapper( Matrix3D* matrix, const int& minX1, const int& minX2, const int& minX3 -// , const int& maxX1, const int& maxX2, const int& maxX3 ) -// : matrix(matrix), minX1(minX1), minX2(minX2), minX3(minX3), maxX1(maxX1), maxX2(maxX2), maxX3(maxX3) -// { -// -// } -// /*==========================================================*/ -// Matrix3DWrapper(const int& size_x1, const int& size_x2, const int& size_x3) -// { -// throw UbException("Matrix3DWrapper(int,int,int) - mit diesem wrapper nicht erlaubt"); -// } -// /*==========================================================*/ -// inline void setData( const real& val, const int& x1, const int& x2, const int& x3 ) -// { -// (*matrix)(minX1+x1, minX2+x2, minX3+x3) = static_cast<value_type>(val); -// } -// /*==========================================================*/ -// inline value_type getData(const int& x1, const int& x2, const int& x3 ) const -// { -// return (*matrix)(minX1+x1, minX2+x2, minX3+x3); -// } -// /*==========================================================*/ -// inline void resize(const int& size_x1, const int& size_x2, const int& size_x3) -// { -// throw UbException("Matrix3DWrapper::resize(int,int,int) - mit diesem wrapper nicht erlaubt"); -// } -// /*==========================================================*/ -// inline int getMinX1() const { return minX1; } -// inline int getMinX2() const { return minX2; } -// inline int getMinX3() const { return minX3; } -// -// inline int getMaxX1() const { return maxX1; } -// inline int getMaxX2() const { return maxX2; } -// inline int getMaxX3() const { return maxX3; } -// -// inline int getNX1() const { nx1; } -// inline int getNX2() const { nx2; } -// inline int getNX3() const { nx3; } -// -//protected: -// Matrix3D* matrix; -// int minX1, minX2, minX3, maxX1, maxX2, maxX3, nx1, nx2, nx3; -//}; -// -//} //namespace McCubes -// -//#endif //MCWRAPPER_H diff --git a/ThirdParty/MuParser/CMakePackage.txt b/ThirdParty/MuParser/CMakePackage.txt deleted file mode 100644 index 06a4d0073321441f85313c250a29581a31e1852c..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/CMakePackage.txt +++ /dev/null @@ -1,36 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption outSourceGroupName) - -IF( ${outOption} ) - - #verzeichnis als std-include adden - INCLUDE_DIRECTORIES( ${CURRENT_DIR}/include ) - - OPTION(USE_MUPARSER_AS_LIB "MuParser will be compiled as lib" ON) - - IF(USE_MUPARSER_AS_LIB) - FILE( GLOB muparser_HEADER_FILES ${CURRENT_DIR}/include/*.h ) - FILE( GLOB muparser_CXX_FILES ${CURRENT_DIR}/src/*.cpp ) - - SET(MUPARSER_SRC_FILES ${muparser_HEADER_FILES} ${muparser_CXX_FILES}) - - ADD_LIBRARY(muParserLib ${MUPARSER_SRC_FILES}) - - #lib projekt hinzufuegen - LIST(APPEND CAB_ADDITIONAL_LINK_LIBRARIES muParserLib) - - ADD_TARGET_PROPERTIES(muParserLib COMPILE_FLAGS "-I${CURRENT_DIR}/include") - - #compilerflags aktuellem projekt hinzufuegen - ADD_COMPILER_FLAGS_TO_PROJECT(${CAB_COMPILER} "muParserLib" "CXX" "STATIC") - - ELSE() #not as lib - SET( CURRENT_DIR_TMP ${CURRENT_DIR} ) #wird im nächsten befehl geaendert - INCLUDE( ${CURRENT_DIR_TMP}/include/CMakePackage.txt) - INCLUDE( ${CURRENT_DIR_TMP}/src/CMakePackage.txt) - ENDIF() - -ENDIF( ${outOption} ) - - - diff --git a/ThirdParty/MuParser/Changes.txt b/ThirdParty/MuParser/Changes.txt deleted file mode 100644 index abe969770b09170a50d8f9dfb8d26bfa2d3ba1fa..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/Changes.txt +++ /dev/null @@ -1,557 +0,0 @@ -####################################################################### -# # -# # -# __________ # -# _____ __ __\______ \_____ _______ ______ ____ _______ # -# / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ # -# | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ # -# |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| # -# \/ \/ \/ \/ # -# Fast math parser Library # -# # -# Copyright (C) 2015 Ingo Berg # -# # -# Web: muparser.beltoforion.de # -# e-mail: muparser@beltoforion.de # -# # -# # -####################################################################### - - -History: --------- - -Rev 2.2.5: 27.04.2015 ---------------------- - Changes: - * example2 extended to work with UNICODE character set - * Applied patch from Issue 9 - - Bugfixes: - * muChar_t in muParserDLL.h was not set properly when UNICODE was used - * muparser.dll did not build on UNICODE systems - -Rev 2.2.4: 02.10.2014 ---------------------- - Changes: - * explicit positive sign allowed - - Bugfixes: - * Fix for Issue 6 (https://code.google.com/p/muparser/issues/detail?id=6) - * String constants did not work properly. Using more than a single one - was impossible. - * Project Files for VS2008 and VS2010 removed from the repository - * Fix for Issue 4 (https://code.google.com/p/muparser/issues/detail?id=4) - * Fix for VS2013 64 bit build option - * return type of ParserError::GetPos changed to int - * OpenMP support enabled in the VS2013 project files and precompiled windows DLL's - * Bulkmode did not evaluate properly if "=" and "," operator was used in the expression - -Rev 2.2.3: 22.12.2012 ---------------------- - - Removed features: - * build files for msvc2005, borland and watcom compiler were removed - - Bugfixes: - * Bugfix for Intel Compilers added: The power operator did not work properly - with Intel C++ composer XE 2011. - (see https://sourceforge.net/projects/muparser/forums/forum/462843/topic/5117983/index/page/1) - * Issue 3509860: Callbacks of functions with string parameters called twice - (see http://sourceforge.net/tracker/?func=detail&aid=3509860&group_id=137191&atid=737979) - * Issue 3570423: example1 shows slot number in hexadecimal - (see https://sourceforge.net/tracker/?func=detail&aid=3570423&group_id=137191&atid=737979) - * Fixes for compiling with the "MUP_MATH_EXCEPTIONS" macro definition: - - division by zero in constant expressions was reported with the code "ec_GENERIC" - instead of "ecDIV_BY_ZERO" - - added throwing of "ecDOMAIN_ERROR" to sqrt and log functions - - -Rev 2.2.2: 18.02.2012 ---------------------- - Bugfixes: - * Optimizer did'nt work properly for division: - (see https://sourceforge.net/projects/muparser/forums/forum/462843/topic/5037825) - -Rev 2.2.1: 22.01.2012 ---------------------- - Bugfixes: - * Optimizer bug in 64 bit systems fixed - (see https://sourceforge.net/projects/muparser/forums/forum/462843/topic/4977977/index/page/1) - -Rev 2.2.0: 22.01.2012 ---------------------- - Improvements: - * Optimizer rewritten and improved. In general: more optimizations are - now applied to the bytecode. The downside is that callback Functions - can no longer be flagged as non-optimizable. (The flag is still present - but ignored) This is necessary since the optimizer had to call the - functions in order to precalculate the result (see Bugfixes). These calls - posed a problems for callback functions with side effects and if-then-else - clauses in general since they undermined the shortcut evaluation prinziple. - - Bugfixes: - * Infix operators where not properly detected in the presence of a constant - name starting with an underscore which is a valid character for infix - operators too (i.e. "-_pi"). - * Issue 3463353: Callback functions are called twice during the first call to eval. - * Issue 3447007: GetUsedVar unnecessaryly executes callback functions. - - -Rev 2.1.0: 19.11.2011 ---------------------- - New feature: - * Function atan2 added - - Bugfixes: - * Issue 3438380: Changed behaviour of tellg with GCC >4.6 led to failures - in value detection callbacks. - * Issue 3438715: only "double" is a valid MUP_BASETYPE - MUP_BASETYPE can now be any of: - float, - double, - long double, - short, - unsigned short, - unsigned int, - long, - unsigned long. - Previousely only floating point types were allowed. - Using "int" is still not allowed! - * Compiler issues with GCC 4.6 fixed - * Custom value recognition callbacks added with AddValIdent had lower - priority than built in functions. This was causing problems with - hex value recognition since detection of non hex values had priority - over the detection of hex values. The "0" in the hex prefix "0x" would - be read as a separate non-hex number leaving the rest of the expression - unparseable. - -Rev 2.0.0: 04.09.2011 ---------------------- -This release introduces a new version numbering scheme in order to make -future changes in the ABI apparent to users of the library. The number is -now based on the SONAME property as used by GNU/Linux. - - Changes: - * Beginning with this version all version numbers will be SONAME compliant - * Project files for MSVC2010 added - * Project files for MSVC2003 removed - * Bytecode parsing engine cleaned up and rewritten - * Retrieving all results of expressions made up of comma separate - subexpressions is now possible with a new Eval overload. - * Callback functions with fixed number of arguments can now have up to 10 - Parameters (previous limit was 5) - - New features: - * ternary if-then-else operator added (C++ like; "(...) ? ... : ..." ) - * new intrinsic binary operators: "&&", "||" (logical and, or) - * A new bulkmode allows submitting large arrays as variables to compute large - numbers of expressions with a single call. This can drastically improve - parsing performance when interfacing the library from managed languages like - C#. (It doesn't bring any performance benefit for C++ users though...) - - Removed features: - * intrinsic "and", "or" and "xor" operators have been removed. I'd like to let - users the freedom of defining them on their own versions (either as logical or bitwise - operators). - * Implementation for complex numbers removed. This was merely a hack. If you - need complex numbers try muParserX which provides native support for them. - (see: http://beltoforion.de/muparserx/math_expression_parser_en.html) - - Bugfixes: - * User defined operators could collide with built in operators that entirely - contained their identifier. i.e. user defined "&" would not work with the built - in "&&" operator since the user defined operator was detected with a higher - priority resulting in a syntax error. - * Detection of unknown variables did not work properly in case a postfix operator - was defined which was part of the undefined variable. - i.e. If a postfix operator "m" was defined expressions like "multi*1.0" did - not detect "multi" as an undefined variable. - (Reference: http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979) - * Postfix operators sharing the first few characters were causing bogus parsing exception. - (Reference: https://sourceforge.net/tracker/?func=detail&aid=3358571&group_id=137191&atid=737979) - -Rev 1.34: 04.09.2010 --------------------- - Changes: - * The prefix needed for parsing hex values is now "0x" and no longer "$". - * AddValIdent reintroduced into the DLL interface - - New features: - * The associativity of binary operators can now be changed. The pow operator - is now right associative. (This is what Mathematica is using) - * Seperator can now be used outside of functions. This allows compound - expressions like: - "a=10,b=20,c=a*b" The last "argument" will be taken as the return value - - Bugfixes: - * The copy constructor did not copy binary operator definitions. Those were lost - in the copied parser instance. - * Mixing special characters and alphabetic characters in binary operator names - led to inconsistent parsing behaviour when parsing expressions like "a ++ b" - and "a++b" when "++" is defined as a binary operator. Binary operators must - now consist entirely of special characters or of alphabetic ones. - (original bug report: https://sourceforge.net/projects/muparser/forums/forum/462843/topic/3696881/index/page/1) - * User defined operators were not exactly handled like built in operators. This - led to inconsistencies in expression evaluation when using them. The results - differed due to slightly different precedence rules. - * Using empty string arguments ("") would cause a crash of muParser - - -Rev 1.32: 29.01.2010 --------------------- - - Changes: - * "example3" renamed to "example2" - * Project/Makefiles files are now provided for: - - msvc2003 - - msvc2005 - - msvc2008 - - watcom (makefile) - - mingw (makefile) - - bcc (makefile) - * Project files for borland cpp builder were removed - - - New features: - * Added function returning muparsers version number - * Added function for resetting the locale - - - Bugfixes: - * Changes example1 in order to fix issues with irritating memory leak reports. - Added conditional code for memory leak detection with MSVC in example1. - (see: http://www.codeproject.com/KB/recipes/FastMathParser.aspx?msg=3286367#xx3286367xx) - * Fixed some warnings for gcc - - - -Rev 1.31cp: 15.01.2010 (Maintainance release for CodeProject) ----------------------- - - Changes: - * Archive structure changed - * C# wrapper added - * Fixed issued that prevented compiling with VS2010 Beta2 - - -Rev 1.30: 09.06.2008 --------------------- - - Changes: - * Epsilon of the numerical differentiation algorithm changed to allow greater accuracy. - - New features: - * Setting thousands separator and decimal separator is now possible - - Bugfixes: - * The dll interface did not provide a callback for functions without any arguments. - - -Rev 1.29: Januar 2008 ---------------------- - - Unrelease Version available only via SVN. - - -Rev 1.28: 02. July, 2007 ---------------------------- - - Library changes: - * Interface for the dynamic library changed and extended to create an interface - using pure C functions only. - * mupInit() removed - - Build system: - * MSVC7 Project files removed in favor of MSVC8 - - Bugfixes: - * The dynamic library did not build on other systems than linux due to a misplaced - preprocessor definition. This is fixed now. - - -Rev 1.27: ---------------------------- - - Build system: - * Modified build\ directory layout introducing some subfolders - for the various IDE supported - * Project files for BCB and MSVC7 added - * Switched to use bakefile 0.2.1 which now correctly creates the - "make uninstall" target for autoconf's Makefile.in - * Now the library debug builds are named "muparserd" instead of "muparser" - to allow multiple mixed release/debug builds to coexist; so e.g. on Windows - when building with DEBUG=1, you'll get "muparserd.lib" instead of "muparser.lib" - - New Features: - * Factory functions can now take a user defined pointer - * String functions can now be used with up to two additional - double parameters - * Support for UNICODE character types added - * Infix operator priority can now be changed by the user - - Bugfixes: - * An internal error was raised when evaluating an empty - expressions - * The error message raised in case of name collisions between - implicitely defined variables and postfix operators did contain - misleading data. - - -Rev 1.26: (unofficial release) ------------------------------- - - New Features: - * Unary operator precedence can now be changed by the user. - - -Rev 1.25: 5. February, 2006 ---------------------------- - - Build system: (special thanks to Francesco Montorsi for implementing it!) - * created a bakefile-based build system which adds support for the following win32 compilers: - -> MS visual C++ (6 and .NET) - -> BorlandC++ (5 or greater) - -> Mingw32 (tested with gcc 3.2) - -> Watcom (not tested) - and for GCC on Unix (using a standard autoconf's configure script). - - Compatibility improvements: - * fixed some small warnings when using -Wall with GCC on Unix - * added inclusion guards for win32-specific portions of code - * added fixes that remove compiler warnings on Intel C++ and the Solaris C++ compiler. - - -Rev 1.24: 29. October, 2005 ---------------------------- - -Changes: - - Compatibility improvements: - * parser now works on 64 bit compilers - * (bytecode base datatype can now be changed freely) - - -Rev 1.23: 19. October, 2005 ---------------------------- - -Changes: - - Bugfixes: - * Variable factory examples in Example1.cpp and Example3.cpp contained a subtle bug. - - New features: - * Added a MSVC6 project file and introduced muParserFixes.h in order to make it compile with MSVC6 - - -Rev 1.22: October, 2005 ------------------------ - -Release notes: - -All features of Version 1.22 are similar to Version 1.21. Version 1.22 fixes a compilation issue with -gcc 4.0. In order to fix this issue I rewrote part of the library to remove some unnecessary templates. -This should make the code cleaner. The Borland Project files were removed. If you want to use it -with Borland either use the dll version or create your own project files. I can't support it since I don't -have this compiler at hand. - -Changes: - - Project Changes: - * Borland project files removed - (The code should still compile with BCB but I cant provide you with project files) - - Internal Changes: - * unnecessary template files have been removed: - - new files: muParserError.cpp, muParserTokenReader.cpp, muParserCallback.cpp - - removed Files: muIParserTypes.h - - -Rev 1.2 / 1.21: April, 2005 ---------------------------- - -Release Notes: -First of all the interface has changed so this version is not backwards compatible. -After receiving a couple of questions about it, this version features support for -user defined binary operators. Consequently the built in operators can now be -turned off, thus you can deactivate them and write complete customized parser -subclasses that only contain the functionality you want. Another new feature is -the introduction of callback functions taking string arguments, implicit -generation of variables and the Assignement operator. - - Functionality - * New built in operator: xor; Logical xor. - * New built in operator: Assignement operator; Defining variables in terms of - other variables/constants - * New feature: Strings as arguments for callback functions - * New feature: User defined binary operators - * New feature: ParserInt a class with a sample implementation for - integer numbers. - * New feature: Callbacks to value regognition functions. - - * Removed: all predefined postfix operators have been removed. - * New project file: Now comes with a ready to use windows DLL. - * New project file: Makefile for cygwin now included. - * New example: Example3 shows usage of the DLL. - - Interface changes - * New member function: DefineOprt For adding user defined binary operators. - * New member function: EnableBuiltInOprt(bool) Enables/Disables built in - binary operators. - * New member function: AddValIdent(...) to add callbacks for custom value - recognition functions. - * Removed: SetVar(), SetConst(). - * Renamed: Most interface functions have been renamed - * Changed: The type for multiargument callbacks multfun_type has changed. - It no longer takes a std::vector as input. - - Internal changes - * new class muParserTokenReader.h encapsulates the token identification - and token assignement. - * Internal handling of function callbacks unified as a result the performance - of the bytecode evaluation increased. - - -Rev 1.10 : December 30, 2004 ----------------------------- - -Release Notes: -This version does not contain major new feature compared to V1.07 but its internal structure has -changed significantly. The String parsing routine is slower than the one of V1.07 but bytecode -parsing is equally fast. On the other hand the error messages of V1.09 are more flexible and you -can change its value datatype. It should work on 64-bit systems. For this reason I supply both -versions for download. If you use V1.07 and are happy with it there is no need for updating -your version. - - * New example program: Archive now contains two demo programs: One for standard C++ and one for - managed C++. - * New member function: RemoveVar(...) can be used for removing a single variable from the internal - storage. - * New member function: GetVar() can be used for querying the variable names and pointers of all - variables defined in the parser. - * New member function: GetConst() can be used for querying all defined constants and their values. - * New member function: GetFunDef() can be used for querying all defined functions and the number of - arguments they expect. - * Internal structure changed; hanging base datatype at compile time is now possible. - * Bugfix: Postfix operator parsing could fail in certain cases; This has been fixed now. - * Bugfix: Variable names must will now be tested if they conflict with constant or function names. - * Internal change: Removed most dependencies from the C-string libraries. - * Internal change: Bytecode is now stored in a separate class: ParserByteCode.h - * Internal change: GetUsedVar() does no longer require that variables are defined at time of call. - * Internal change: Error treatment changed. ParserException is no longer derived from - std::runtime_error; Internal treatment of Error messages changed. - * New functions in Parser interface: ValidNameChars(), ValidOprtChars() and ValidPrefixOprtChars() - they are used for defining the charset allowed for variable-, operator- and - function names. - - -Rev 1.09 : November 20, 2004 ----------------------------- - - * New member function: RemoveVar(...) can be used for removing a single variable from the internal - storage. - * Internal structure changed; changing base datatype at compile time is now possible. - * Bug fix: Postfix operator parsing could fail in certain cases; This has been fixed now. - * Internal change: Removed most dependencies from the C-string libraries. - * Internal change: Bytecode is now stored in a seperate class: ParserByteCode.h. - * Internal change: GetUsedVar() does no longer require that variables are defined at time of call. - * Internal change: Error treatment changed. ParserException is no longer derived from - std::runtime_error; Internal treatment of Error messages changed. - * New functions in Parser interface; ValidNameChars(), ValidOprtChars() and ValidPrefixOprtChars() - they are used for defining the charset allowed for variable-, operator- and function names. - - -Rev 1.08 : November, 2004 -------------------------- - - * unpublished; experimental template version with respect to data type and underlying string - type (string <-> widestring). The idea was dropped... - - -Rev 1.07 : September 4 2004 ---------------------------- - - * Improved portability; Changes to make life for MSVC 6 user easier, there are probably still some - issues left. - * Improved portability; Changes in order to allow compiling on BCB. - * New function; value_type Diff(value_type *a_Var, value_type a_fPos) 4th order Differentiation with - respect to a certain variable; added in muParser.h. - - -Rev 1.06 : August 20 2004 -------------------------- - - * Volatile functions added; All overloaded AddFun(...) functions can now take a third parameter - indicating that the function can not be optimized. - * Internal changes: muParserStack.h simplified; refactorings - * Parser is now distributed under the MIT License; all comments changed accordingly. - - -Rev 1.05 : August 20 2004 -------------------------- - - * Variable/constant names will now be checked for invalid characters. - * Querying the names of all variables used in an expression is now possible; new function: GetUsedVar(). - * Disabling bytecode parsing is now possible; new function: EnableByteCode(bool bStat). - * Predefined functions with variable number of arguments added: sum, avg, min, max. - * Unary prefix operators added; new functions: AddPrefixOp(...), ClearPrefixOp(). - * Postfix operator interface names changed; new function names: AddPostfixOp(...), ClearPostfixOp(). - * Hardcoded sign operators removed in favor of prefix operators; bytecode format changed accordingly. - * Internal changes: static array removed in Command code calculation routine; misc. changes. - - -Rev 1.04 : August 16 2004 -------------------------- - - * Support for functions with variable number of arguments added. - * Internal structure changed; new: ParserBase.h, ParserBase.cpp; removed: ParserException.h; - changed: Parser.h, Parser.cpp. - * Bug in the bytecode calculation function fixed (affected the unary minus operator). - * Optimizer can be deactivated; new function: EnableOptimizer(bool bStat). - - -Rev 1.03 : August 10 2004 -------------------------- - - * Support for user-defined unary postfix operators added; new functions: AddPostOp(), InitPostOp(), - ClearPostOp(). - * Minor changes to the bytecode parsing routine. - * User defined functions can now have up to four parameters. - * Performance optimized: simple formula optimization added; (precalculation of constant parts of the - expression). - * Bug fixes: Multi-arg function parameters, constant name lookup and unary minus did not work properly. - - -Rev 1.02 : July 30 2004 ------------------------ - - * Support for user defined constants added; new functions: InitConst(), AddConst(), SetConst(), - ClearConst(). - * Single variables can now be added using AddVar(); you have now the choice of adding them either - one by one or all at the same time using SetVar(const varmap_type &a_vVar). - * Internal handling of variables changed, is now similar to function handling. - * Virtual destructor added; InitFun(), InitConst() are now virtual too thus making it possible to - derive new parsers with a modified set of default functions and constants. - * Support for user defined functions with 2 or 3 parameters added; bytecode format changed to hold - function parameter count. - - -Rev 1.01 : July 23 2004 ------------------------ - - * Support for user defined functions has been added; new functions: AddFun(), ClearFun(), - InitFunctions(). - * Built in constants have been removed; the parser contained undocumented built in - constants pi, e. - There was the possibility of name conflicts with user defined variables. - * Setting multiple variables with SetVar can now be done with a map of names and pointers as the only - argument. For this reason, a new type Parser::varmap_type was added. The old version that took 3 - arguments (array of names, array of pointers, and array length) is now marked as deprecated. - * The names of logarithm functions have changed. The new names are: log2 for base 2, log10 or log for - base 10, and ln for base e. - - -Rev 1.00 : July 21 2004 ------------------------ - - * Initial release diff --git a/ThirdParty/MuParser/Install.txt b/ThirdParty/MuParser/Install.txt deleted file mode 100644 index 95d365de3ccd03b52a8ff3346fa6e4276346c3a2..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/Install.txt +++ /dev/null @@ -1,133 +0,0 @@ -####################################################################### -# # -# # -# __________ # -# _____ __ __\______ \_____ _______ ______ ____ _______ # -# / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ # -# | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ # -# |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| # -# \/ \/ \/ \/ # -# Fast math parser Library # -# # -# Copyright (C) 2012 Ingo Berg # -# # -# Web: muparser.beltoforion.de # -# e-mail: muparser@beltoforion.de # -# # -# # -####################################################################### - - - - Contents - ======== - - 1. Installation on win32 - 2. Installation on unix - 2.1 Other miscellaneous info Unix-specific - 3. Where to ask for help - - - - 1. Installation on win32 - ======================== - - muParser supports various win32 command-line compilers: - -> mingw - -> watcom - -> microsoft CL - and provides also the project files for MSVC6 IDE. - - In order to compile muParser from makefiles, open an MSDOS - prompt and then move to the muParser/build directory and - type: - - mingw32-make -fmakefile.mingw for mingw - nmake -fmakefile.vc for msvc - make -fmakefile.bcc for borland - wmake -fmakefile.wat for watcom - - All makefiles supports the following options: - - # Set to 1 to build debug version [0,1] - # 0 - Release - # 1 - Debug - DEBUG = 0 - - # Set to 1 to build shared (DLL) version [0,1] - # 0 - Static - # 1 - DLL - SHARED = 0 - - # Set to 1 to compile samples [0,1] - SAMPLES = 1 - - The muParser library is created in the 'lib' folder and the sample - binaries are created in samples\example1 or samples\example2. - - NOTE: samples\example1 can be compiled *only* when building - muParser as a STATIC library (SHARED=0). - samples\example2 can be compiled *only* when building - muParser as a SHARED library (SHARED=1). - - - - 2. Installation on Unix/Linux - ============================= - - muParser can be installed just extracting the sources somewhere - and then, from a terminal, typing: - - cd [path to muParser] - ./configure [--enable-shared=yes/no] [--enable-samples=yes/no] - [--enable-debug=yes/no] - make - [sudo*] make install - [sudo*] ldconfig - cd samples/example1 - ./example1 - - * = this command must be executed with root permissions and thus - you have to use 'sudo' or just 'su' to gain root access. - Note that installation and ldconfig are not strictly required unless - you built in shared mode. - - The "make" step will create the muParser library in 'lib' and the - sample binary in samples/example1. - The samples/example2 is win32-specific and thus won't be built. - - - - 2.1 Other miscellaneous info Unix-specific - ========================================== - - If you don't like to have your muParser folder filled by temporary - files created by GCC, then you can do the following: - - mkdir mybuild && cd mybuild && ../configure && make - - to put all object files in the "mybuild" directory. - - If you want to use muParser library in your programs, you can use - the pkg-config program (this works only if muParser was installed - with 'make install' !). The commands: - - pkg-config muparser --cflags - pkg-config muparser --libs - - will return all useful info you need to build your programs against - muParser ! - - - - 3. Where to ask for help - ======================== - - If you find problems with either compilation, installation or usage - of muParser, then you can ask in the muParser forum at: - - https://sourceforge.net/forum/forum.php?forum_id=462843 - - For more info about muParser, visit: - http://sourceforge.net/projects/muparser/ - http://muparser.sourceforge.net diff --git a/ThirdParty/MuParser/License.txt b/ThirdParty/MuParser/License.txt deleted file mode 100644 index c4c0d2b1313f5530c7357a6df9998fd0c418c49d..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/License.txt +++ /dev/null @@ -1,35 +0,0 @@ -####################################################################### -# # -# # -# __________ # -# _____ __ __\______ \_____ _______ ______ ____ _______ # -# / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ # -# | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ # -# |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| # -# \/ \/ \/ \/ # -# Fast math parser Library # -# # -# Copyright (C) 2011 Ingo Berg # -# # -# Web: muparser.beltoforion.de # -# e-mail: muparser@beltoforion.de # -# # -# # -####################################################################### - - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ThirdParty/MuParser/docs/Doxyfile b/ThirdParty/MuParser/docs/Doxyfile deleted file mode 100644 index 9793afe34369e1dc4c9300d19984a89952d06ee1..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/docs/Doxyfile +++ /dev/null @@ -1,1563 +0,0 @@ -# Doxyfile 1.6.3 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "muParser API -" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 1.35 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = html/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 16 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it parses. -# With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this tag. -# The format is ext=language, where ext is a file extension, and language is one of -# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, -# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), -# use: inc=Fortran f=C. Note that for custom extensions you also need to set -# FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = YES - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = NO - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command <command> <input-file>, where <command> is the value of -# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by -# doxygen. The layout file controls the global structure of the generated output files -# in an output format independent way. The create the layout file that represents -# doxygen's defaults, run doxygen with the -l option. You can optionally specify a -# file name after the option, if omitted DoxygenLayout.xml will be used as the name -# of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = html/misc/Main.txt \ - html/misc/example.txt \ - ../src/ \ - ../include/ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = html/misc/ - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command <filter> <input-file>, where <filter> -# is the value of the INPUT_FILTER tag, and <input-file> is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = YES - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = NO - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = NO - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = classdocu/ - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = html/misc/footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER -# are set, an additional index file will be generated that can be used as input for -# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated -# HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. -# For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see -# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's -# filter section matches. -# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = NO - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = jpg - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = "C:\Program Files (x86)\Graphviz2.20\bin" - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/ThirdParty/MuParser/docs/muparser_doc.html b/ThirdParty/MuParser/docs/muparser_doc.html deleted file mode 100644 index 09dbba14393dc6c06a6a64d126f8ad29439e4146..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/docs/muparser_doc.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE html> -<html style="height:100%;"> -<head> -</head> - -<body style="height:100%; overflow:hidden;"> - - <div style="border: 0px; position:absolute; top:0px; left:0px; width:100%; bottom:0px; padding:0px; margin:0px;"> - <iframe src="http://muparser.beltoforion.de" style="border: 0px; width:100%; height:100%;"> - Sorry, your browser doesn't support IFrames. Click <a href="http://muparser.beltoforion.de">here</a> to load the muparser documentation directly. - </iframe> - </div> -</body> - -</html> diff --git a/ThirdParty/MuParser/include/muParser.h b/ThirdParty/MuParser/include/muParser.h deleted file mode 100644 index 39fe137fe7386dc793aef31bff94296cfe6b6e12..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParser.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef MU_PARSER_H -#define MU_PARSER_H - -//--- Standard includes ------------------------------------------------------------------------ -#include <vector> - -//--- Parser includes -------------------------------------------------------------------------- -#include "muParserBase.h" -#include "muParserTemplateMagic.h" - -/** \file - \brief Definition of the standard floating point parser. -*/ - -namespace mu -{ - /** \brief Mathematical expressions parser. - - Standard implementation of the mathematical expressions parser. - Can be used as a reference implementation for subclassing the parser. - - <small> - (C) 2011 Ingo Berg<br> - muparser(at)beltoforion.de - </small> - */ - /* final */ class Parser : public ParserBase - { - public: - - Parser(); - - virtual void InitCharSets(); - virtual void InitFun(); - virtual void InitConst(); - virtual void InitOprt(); - virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); - - value_type Diff(value_type *a_Var, - value_type a_fPos, - value_type a_fEpsilon = 0) const; - - protected: - - // Trigonometric functions - static value_type Sin(value_type); - static value_type Cos(value_type); - static value_type Tan(value_type); - static value_type Tan2(value_type, value_type); - // arcus functions - static value_type ASin(value_type); - static value_type ACos(value_type); - static value_type ATan(value_type); - static value_type ATan2(value_type, value_type); - - // hyperbolic functions - static value_type Sinh(value_type); - static value_type Cosh(value_type); - static value_type Tanh(value_type); - // arcus hyperbolic functions - static value_type ASinh(value_type); - static value_type ACosh(value_type); - static value_type ATanh(value_type); - // Logarithm functions - static value_type Log2(value_type); // Logarithm Base 2 - static value_type Log10(value_type); // Logarithm Base 10 - static value_type Ln(value_type); // Logarithm Base e (natural logarithm) - // misc - static value_type Exp(value_type); - static value_type Abs(value_type); - static value_type Sqrt(value_type); - static value_type Rint(value_type); - static value_type Sign(value_type); - - // Prefix operators - // !!! Unary Minus is a MUST if you want to use negative signs !!! - static value_type UnaryMinus(value_type); - static value_type UnaryPlus(value_type); - - // Functions with variable number of arguments - static value_type Sum(const value_type*, int); // sum - static value_type Avg(const value_type*, int); // mean value - static value_type Min(const value_type*, int); // minimum - static value_type Max(const value_type*, int); // maximum - - static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal); - }; -} // namespace mu - -#endif - diff --git a/ThirdParty/MuParser/include/muParserBase.h b/ThirdParty/MuParser/include/muParserBase.h deleted file mode 100644 index beb15bb198080beb26543f131c65c7625b3134b3..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserBase.h +++ /dev/null @@ -1,317 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef MU_PARSER_BASE_H -#define MU_PARSER_BASE_H - -//--- Standard includes ------------------------------------------------------------------------ -#include <cmath> -#include <string> -#include <iostream> -#include <map> -#include <memory> -#include <locale> -#include <limits.h> - -//--- Parser includes -------------------------------------------------------------------------- -#include "muParserDef.h" -#include "muParserStack.h" -#include "muParserTokenReader.h" -#include "muParserBytecode.h" -#include "muParserError.h" - - -namespace mu -{ -/** \file - \brief This file contains the class definition of the muparser engine. -*/ - -//-------------------------------------------------------------------------------------------------- -/** \brief Mathematical expressions parser (base parser engine). - \author (C) 2013 Ingo Berg - - This is the implementation of a bytecode based mathematical expressions parser. - The formula will be parsed from string and converted into a bytecode. - Future calculations will be done with the bytecode instead the formula string - resulting in a significant performance increase. - Complementary to a set of internally implemented functions the parser is able to handle - user defined functions and variables. -*/ -class ParserBase -{ -friend class ParserTokenReader; - -private: - - /** \brief Typedef for the parse functions. - - The parse function do the actual work. The parser exchanges - the function pointer to the parser function depending on - which state it is in. (i.e. bytecode parser vs. string parser) - */ - typedef value_type (ParserBase::*ParseFunction)() const; - - /** \brief Type used for storing an array of values. */ - typedef std::vector<value_type> valbuf_type; - - /** \brief Type for a vector of strings. */ - typedef std::vector<string_type> stringbuf_type; - - /** \brief Typedef for the token reader. */ - typedef ParserTokenReader token_reader_type; - - /** \brief Type used for parser tokens. */ - typedef ParserToken<value_type, string_type> token_type; - - /** \brief Maximum number of threads spawned by OpenMP when using the bulk mode. */ - static const int s_MaxNumOpenMPThreads = 16; - - public: - - /** \brief Type of the error class. - - Included for backwards compatibility. - */ - typedef ParserError exception_type; - - static void EnableDebugDump(bool bDumpCmd, bool bDumpStack); - - ParserBase(); - ParserBase(const ParserBase &a_Parser); - ParserBase& operator=(const ParserBase &a_Parser); - - virtual ~ParserBase(); - - value_type Eval() const; - value_type* Eval(int &nStackSize) const; - void Eval(value_type *results, int nBulkSize); - - int GetNumResults() const; - - void SetExpr(const string_type &a_sExpr); - void SetVarFactory(facfun_type a_pFactory, void *pUserData = NULL); - - void SetDecSep(char_type cDecSep); - void SetThousandsSep(char_type cThousandsSep = 0); - void ResetLocale(); - - void EnableOptimizer(bool a_bIsOn=true); - void EnableBuiltInOprt(bool a_bIsOn=true); - - bool HasBuiltInOprt() const; - void AddValIdent(identfun_type a_pCallback); - - /** \fn void mu::ParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun, bool a_bAllowOpt = true) - \brief Define a parser function without arguments. - \param a_strName Name of the function - \param a_pFun Pointer to the callback function - \param a_bAllowOpt A flag indicating this function may be optimized - */ - template<typename T> - void DefineFun(const string_type &a_strName, T a_pFun, bool a_bAllowOpt = true) - { - AddCallback( a_strName, ParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars() ); - } - - void DefineOprt(const string_type &a_strName, - fun_type2 a_pFun, - unsigned a_iPri=0, - EOprtAssociativity a_eAssociativity = oaLEFT, - bool a_bAllowOpt = false); - void DefineConst(const string_type &a_sName, value_type a_fVal); - void DefineStrConst(const string_type &a_sName, const string_type &a_strVal); - void DefineVar(const string_type &a_sName, value_type *a_fVar); - void DefinePostfixOprt(const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true); - void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true); - - // Clear user defined variables, constants or functions - void ClearVar(); - void ClearFun(); - void ClearConst(); - void ClearInfixOprt(); - void ClearPostfixOprt(); - void ClearOprt(); - - void RemoveVar(const string_type &a_strVarName); - const varmap_type& GetUsedVar() const; - const varmap_type& GetVar() const; - const valmap_type& GetConst() const; - const string_type& GetExpr() const; - const funmap_type& GetFunDef() const; - string_type GetVersion(EParserVersionInfo eInfo = pviFULL) const; - - const char_type ** GetOprtDef() const; - void DefineNameChars(const char_type *a_szCharset); - void DefineOprtChars(const char_type *a_szCharset); - void DefineInfixOprtChars(const char_type *a_szCharset); - - const char_type* ValidNameChars() const; - const char_type* ValidOprtChars() const; - const char_type* ValidInfixOprtChars() const; - - void SetArgSep(char_type cArgSep); - char_type GetArgSep() const; - - void Error(EErrorCodes a_iErrc, - int a_iPos = (int)mu::string_type::npos, - const string_type &a_strTok = string_type() ) const; - - protected: - - void Init(); - - virtual void InitCharSets() = 0; - virtual void InitFun() = 0; - virtual void InitConst() = 0; - virtual void InitOprt() = 0; - - virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); - - static const char_type *c_DefaultOprt[]; - static std::locale s_locale; ///< The locale used by the parser - static bool g_DbgDumpCmdCode; - static bool g_DbgDumpStack; - - /** \brief A facet class used to change decimal and thousands separator. */ - template<class TChar> - class change_dec_sep : public std::numpunct<TChar> - { - public: - - explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) - :std::numpunct<TChar>() - ,m_nGroup(nGroup) - ,m_cDecPoint(cDecSep) - ,m_cThousandsSep(cThousandsSep) - {} - - protected: - - virtual char_type do_decimal_point() const - { - return m_cDecPoint; - } - - virtual char_type do_thousands_sep() const - { - return m_cThousandsSep; - } - - virtual std::string do_grouping() const - { - // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 - // courtesy of Jens Bartsch - // original code: - // return std::string(1, (char)m_nGroup); - // new code: - return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); - } - - private: - - int m_nGroup; - char_type m_cDecPoint; - char_type m_cThousandsSep; - }; - - private: - - void Assign(const ParserBase &a_Parser); - void InitTokenReader(); - void ReInit() const; - - void AddCallback( const string_type &a_strName, - const ParserCallback &a_Callback, - funmap_type &a_Storage, - const char_type *a_szCharSet ); - - void ApplyRemainingOprt(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal) const; - void ApplyBinOprt(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal) const; - - void ApplyIfElse(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal) const; - - void ApplyFunc(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal, - int iArgCount) const; - - token_type ApplyStrFunc(const token_type &a_FunTok, - const std::vector<token_type> &a_vArg) const; - - int GetOprtPrecedence(const token_type &a_Tok) const; - EOprtAssociativity GetOprtAssociativity(const token_type &a_Tok) const; - - void CreateRPN() const; - - value_type ParseString() const; - value_type ParseCmdCode() const; - value_type ParseCmdCodeBulk(int nOffset, int nThreadID) const; - - void CheckName(const string_type &a_strName, const string_type &a_CharSet) const; - void CheckOprt(const string_type &a_sName, - const ParserCallback &a_Callback, - const string_type &a_szCharSet) const; - - void StackDump(const ParserStack<token_type > &a_stVal, - const ParserStack<token_type > &a_stOprt) const; - - /** \brief Pointer to the parser function. - - Eval() calls the function whose address is stored there. - */ - mutable ParseFunction m_pParseFormula; - mutable ParserByteCode m_vRPN; ///< The Bytecode class. - mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments - stringbuf_type m_vStringVarBuf; - - std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object. - - funmap_type m_FunDef; ///< Map of function names and pointers. - funmap_type m_PostOprtDef; ///< Postfix operator callbacks - funmap_type m_InfixOprtDef; ///< unary infix operator. - funmap_type m_OprtDef; ///< Binary operator callbacks - valmap_type m_ConstDef; ///< user constants. - strmap_type m_StrVarDef; ///< user defined string constants - varmap_type m_VarDef; ///< user defind variables. - - bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off - - string_type m_sNameChars; ///< Charset for names - string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens - string_type m_sInfixOprtChars; ///< Charset for infix operator tokens - - mutable int m_nIfElseCounter; ///< Internal counter for keeping track of nested if-then-else clauses - - // items merely used for caching state information - mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine - mutable int m_nFinalResultIdx; -}; - -} // namespace mu - -#endif - diff --git a/ThirdParty/MuParser/include/muParserBytecode.h b/ThirdParty/MuParser/include/muParserBytecode.h deleted file mode 100644 index 39ab39d52d4afac1ffc766baa1cfe490e5d870e8..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserBytecode.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef MU_PARSER_BYTECODE_H -#define MU_PARSER_BYTECODE_H - -#include <cassert> -#include <string> -#include <stack> -#include <vector> - -#include "muParserDef.h" -#include "muParserError.h" -#include "muParserToken.h" - -/** \file - \brief Definition of the parser bytecode class. -*/ - - -namespace mu -{ - struct SToken - { - ECmdCode Cmd; - int StackPos; - - union - { - struct //SValData - { - value_type *ptr; - value_type data; - value_type data2; - } Val; - - struct //SFunData - { - // Note: generic_fun_type is merely a placeholder. The real type could be - // anything between gun_type1 and fun_type9. I can't use a void - // pointer due to constraints in the ANSI standard which allows - // data pointers and function pointers to differ in size. - generic_fun_type ptr; - int argc; - int idx; - } Fun; - - struct //SOprtData - { - value_type *ptr; - int offset; - } Oprt; - }; - }; - - - /** \brief Bytecode implementation of the Math Parser. - - The bytecode contains the formula converted to revers polish notation stored in a continious - memory area. Associated with this data are operator codes, variable pointers, constant - values and function pointers. Those are necessary in order to calculate the result. - All those data items will be casted to the underlying datatype of the bytecode. - - \author (C) 2004-2013 Ingo Berg -*/ -class ParserByteCode -{ -private: - - /** \brief Token type for internal use only. */ - typedef ParserToken<value_type, string_type> token_type; - - /** \brief Token vector for storing the RPN. */ - typedef std::vector<SToken> rpn_type; - - /** \brief Position in the Calculation array. */ - unsigned m_iStackPos; - - /** \brief Maximum size needed for the stack. */ - std::size_t m_iMaxStackSize; - - /** \brief The actual rpn storage. */ - rpn_type m_vRPN; - - bool m_bEnableOptimizer; - - void ConstantFolding(ECmdCode a_Oprt); - -public: - - ParserByteCode(); - ParserByteCode(const ParserByteCode &a_ByteCode); - ParserByteCode& operator=(const ParserByteCode &a_ByteCode); - void Assign(const ParserByteCode &a_ByteCode); - - void AddVar(value_type *a_pVar); - void AddVal(value_type a_fVal); - void AddOp(ECmdCode a_Oprt); - void AddIfElse(ECmdCode a_Oprt); - void AddAssignOp(value_type *a_pVar); - void AddFun(generic_fun_type a_pFun, int a_iArgc); - void AddBulkFun(generic_fun_type a_pFun, int a_iArgc); - void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx); - - void EnableOptimizer(bool bStat); - - void Finalize(); - void clear(); - std::size_t GetMaxStackSize() const; - std::size_t GetSize() const; - - const SToken* GetBase() const; - void AsciiDump(); -}; - -} // namespace mu - -#endif - - diff --git a/ThirdParty/MuParser/include/muParserCallback.h b/ThirdParty/MuParser/include/muParserCallback.h deleted file mode 100644 index ef32b4989e34b92c82ad06daf50014022781657c..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserCallback.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_CALLBACK_H -#define MU_PARSER_CALLBACK_H - -#include "muParserDef.h" - -/** \file - \brief Definition of the parser callback class. -*/ - -namespace mu -{ - -/** \brief Encapsulation of prototypes for a numerical parser function. - - Encapsulates the prototyp for numerical parser functions. The class - stores the number of arguments for parser functions as well - as additional flags indication the function is non optimizeable. - The pointer to the callback function pointer is stored as void* - and needs to be casted according to the argument count. - Negative argument counts indicate a parser function with a variable number - of arguments. - - \author (C) 2004-2011 Ingo Berg -*/ -class ParserCallback -{ -public: - ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC); - ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity); - ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti); - ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti); - - ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti); - ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti); - - ParserCallback(multfun_type a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti); - ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti); - ParserCallback(); - ParserCallback(const ParserCallback &a_Fun); - - ParserCallback* Clone() const; - - bool IsOptimizable() const; - void* GetAddr() const; - ECmdCode GetCode() const; - ETypeCode GetType() const; - int GetPri() const; - EOprtAssociativity GetAssociativity() const; - int GetArgc() const; - -private: - void *m_pFun; ///< Pointer to the callback function, casted to void - - /** \brief Number of numeric function arguments - - This number is negative for functions with variable number of arguments. in this cases - they represent the actual number of arguments found. - */ - int m_iArgc; - int m_iPri; ///< Valid only for binary and infix operators; Operator precedence. - EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators - ECmdCode m_iCode; - ETypeCode m_iType; - bool m_bAllowOpti; ///< Flag indication optimizeability -}; - -//------------------------------------------------------------------------------ -/** \brief Container for Callback objects. */ -typedef std::map<string_type, ParserCallback> funmap_type; - -} // namespace mu - -#endif - diff --git a/ThirdParty/MuParser/include/muParserDLL.h b/ThirdParty/MuParser/include/muParserDLL.h deleted file mode 100644 index 155ef8a06c449a3e834cb6c484f94a5398a7f9f8..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserDLL.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef MU_PARSER_DLL_H -#define MU_PARSER_DLL_H - -#if defined(WIN32) || defined(_WIN32) - #ifdef MUPARSERLIB_EXPORTS - #define API_EXPORT(TYPE) __declspec(dllexport) TYPE __cdecl - #else - #define API_EXPORT(TYPE) __declspec(dllimport) TYPE __cdecl - #endif -#else - #define API_EXPORT(TYPE) TYPE -#endif - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** \file - \brief This file contains the DLL interface of muparser. -*/ - -// Basic types -typedef void* muParserHandle_t; // parser handle - -#ifndef _UNICODE - typedef char muChar_t; // character type -#else - typedef wchar_t muChar_t; // character type -#endif - -typedef int muBool_t; // boolean type -typedef int muInt_t; // integer type -typedef double muFloat_t; // floating point type - -// function types for calculation -typedef muFloat_t (*muFun0_t )(); -typedef muFloat_t (*muFun1_t )(muFloat_t); -typedef muFloat_t (*muFun2_t )(muFloat_t, muFloat_t); -typedef muFloat_t (*muFun3_t )(muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun4_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun5_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun6_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun7_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun8_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun9_t )(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muFun10_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); - -// Function prototypes for bulkmode functions -typedef muFloat_t (*muBulkFun0_t )(int, int); -typedef muFloat_t (*muBulkFun1_t )(int, int, muFloat_t); -typedef muFloat_t (*muBulkFun2_t )(int, int, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun3_t )(int, int, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun4_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun5_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun6_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun7_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun8_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun9_t )(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); -typedef muFloat_t (*muBulkFun10_t)(int, int, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); - -typedef muFloat_t (*muMultFun_t)(const muFloat_t*, muInt_t); -typedef muFloat_t (*muStrFun1_t)(const muChar_t*); -typedef muFloat_t (*muStrFun2_t)(const muChar_t*, muFloat_t); -typedef muFloat_t (*muStrFun3_t)(const muChar_t*, muFloat_t, muFloat_t); - -// Functions for parser management -typedef void (*muErrorHandler_t)(muParserHandle_t a_hParser); // [optional] callback to an error handler -typedef muFloat_t* (*muFacFun_t)(const muChar_t*, void*); // [optional] callback for creating new variables -typedef muInt_t (*muIdentFun_t)(const muChar_t*, muInt_t*, muFloat_t*); // [optional] value identification callbacks - -//----------------------------------------------------------------------------------------------------- -// Constants -static const int muOPRT_ASCT_LEFT = 0; -static const int muOPRT_ASCT_RIGHT = 1; - -static const int muBASETYPE_FLOAT = 0; -static const int muBASETYPE_INT = 1; - -//----------------------------------------------------------------------------------------------------- -// -// -// muParser C compatible bindings -// -// -//----------------------------------------------------------------------------------------------------- - - -// Basic operations / initialization -API_EXPORT(muParserHandle_t) mupCreate(int nBaseType); -API_EXPORT(void) mupRelease(muParserHandle_t a_hParser); -API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser); -API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t *a_szExpr); -API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void* pUserData); -API_EXPORT(const muChar_t*) mupGetVersion(muParserHandle_t a_hParser); -API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser); -API_EXPORT(muFloat_t*) mupEvalMulti(muParserHandle_t a_hParser, int *nNum); -API_EXPORT(void) mupEvalBulk(muParserHandle_t a_hParser, muFloat_t *a_fResult, int nSize); - -// Defining callbacks / variables / constants -API_EXPORT(void) mupDefineFun0(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun0_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun1_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun2_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun3_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun4_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun5_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun6(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun6_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun7(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun7_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun8(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun8_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun9(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun9_t a_pFun, muBool_t a_bOptimize); -API_EXPORT(void) mupDefineFun10(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun10_t a_pFun, muBool_t a_bOptimize); - -// Defining bulkmode functions -API_EXPORT(void) mupDefineBulkFun0(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun0_t a_pFun); -API_EXPORT(void) mupDefineBulkFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun1_t a_pFun); -API_EXPORT(void) mupDefineBulkFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun2_t a_pFun); -API_EXPORT(void) mupDefineBulkFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun3_t a_pFun); -API_EXPORT(void) mupDefineBulkFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun4_t a_pFun); -API_EXPORT(void) mupDefineBulkFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun5_t a_pFun); -API_EXPORT(void) mupDefineBulkFun6(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun6_t a_pFun); -API_EXPORT(void) mupDefineBulkFun7(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun7_t a_pFun); -API_EXPORT(void) mupDefineBulkFun8(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun8_t a_pFun); -API_EXPORT(void) mupDefineBulkFun9(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun9_t a_pFun); -API_EXPORT(void) mupDefineBulkFun10(muParserHandle_t a_hParser, const muChar_t *a_szName, muBulkFun10_t a_pFun); - -// string functions -API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun1_t a_pFun); -API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun2_t a_pFun); -API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun3_t a_pFun); - -API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muMultFun_t a_pFun, - muBool_t a_bOptimize); - -API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun2_t a_pFun, - muInt_t a_nPrec, - muInt_t a_nOprtAsct, - muBool_t a_bOptimize); - -API_EXPORT(void) mupDefineConst( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFloat_t a_fVal ); - -API_EXPORT(void) mupDefineStrConst( muParserHandle_t a_hParser, - const muChar_t* a_szName, - const muChar_t *a_sVal ); - -API_EXPORT(void) mupDefineVar( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFloat_t *a_fVar); - -API_EXPORT(void) mupDefineBulkVar( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFloat_t *a_fVar); - -API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun1_t a_pOprt, - muBool_t a_bOptimize); - - -API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun1_t a_pOprt, - muBool_t a_bOptimize); - -// Define character sets for identifiers -API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); -API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); -API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); - -// Remove all / single variables -API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName); -API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser); -API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser); -API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser); -API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser); - -// Querying variables / expression variables / constants -API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser); -API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser); -API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser); -API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar); -API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar); -API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t* a_pVar); -API_EXPORT(void) mupSetArgSep(muParserHandle_t a_hParser, const muChar_t cArgSep); -API_EXPORT(void) mupSetDecSep(muParserHandle_t a_hParser, const muChar_t cArgSep); -API_EXPORT(void) mupSetThousandsSep(muParserHandle_t a_hParser, const muChar_t cArgSep); -API_EXPORT(void) mupResetLocale(muParserHandle_t a_hParser); - -// Add value recognition callbacks -API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, muIdentFun_t); - -// Error handling -API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser); -API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser); -API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pErrHandler); -API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser); -API_EXPORT(muInt_t) mupGetErrorCode(muParserHandle_t a_hParser); -API_EXPORT(muInt_t) mupGetErrorPos(muParserHandle_t a_hParser); -API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser); -//API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser); - -// This is used for .NET only. It creates a new variable allowing the dll to -// manage the variable rather than the .NET garbage collector. -API_EXPORT(muFloat_t*) mupCreateVar(); -API_EXPORT(void) mupReleaseVar(muFloat_t*); - -#ifdef __cplusplus -} -#endif - -#endif // include guard diff --git a/ThirdParty/MuParser/include/muParserDef.h b/ThirdParty/MuParser/include/muParserDef.h deleted file mode 100644 index 437f2eaf572c1971292e8ffe7df4b55f53b77ea3..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserDef.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2014 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#ifndef MUP_DEF_H -#define MUP_DEF_H - -#include <iostream> -#include <string> -#include <sstream> -#include <map> - -#include "muParserFixes.h" - -/** \file - \brief This file contains standard definitions used by the parser. -*/ - -#define MUP_VERSION _T("2.2.5") -#define MUP_VERSION_DATE _T("20150427; GC") - -#define MUP_CHARS _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") - -/** \brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ -//#define MUP_MATH_EXCEPTIONS - -/** \brief Define the base datatype for values. - - This datatype must be a built in value type. You can not use custom classes. - It should be working with all types except "int"! -*/ -#define MUP_BASETYPE double - -/** \brief Activate this option in order to compile with OpenMP support. - - OpenMP is used only in the bulk mode it may increase the performance a bit. -*/ -//#define MUP_USE_OPENMP - -#if defined(_UNICODE) - /** \brief Definition of the basic parser string type. */ - #define MUP_STRING_TYPE std::wstring - - #if !defined(_T) - #define _T(x) L##x - #endif // not defined _T -#else - #ifndef _T - #define _T(x) x - #endif - - /** \brief Definition of the basic parser string type. */ - #define MUP_STRING_TYPE std::string -#endif - -#if defined(_DEBUG) - /** \brief Debug macro to force an abortion of the programm with a certain message. - */ - #define MUP_FAIL(MSG) \ - { \ - bool MSG=false; \ - assert(MSG); \ - } - - /** \brief An assertion that does not kill the program. - - This macro is neutralised in UNICODE builds. It's - too difficult to translate. - */ - #define MUP_ASSERT(COND) \ - if (!(COND)) \ - { \ - stringstream_type ss; \ - ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \ - << __FILE__ << _T(" line ") \ - << __LINE__ << _T("."); \ - throw ParserError( ss.str() ); \ - } -#else - #define MUP_FAIL(MSG) - #define MUP_ASSERT(COND) -#endif - - -namespace mu -{ -#if defined(_UNICODE) - - //------------------------------------------------------------------------------ - /** \brief Encapsulate wcout. */ - inline std::wostream& console() - { - return std::wcout; - } - - /** \brief Encapsulate cin. */ - inline std::wistream& console_in() - { - return std::wcin; - } - -#else - - /** \brief Encapsulate cout. - - Used for supporting UNICODE more easily. - */ - inline std::ostream& console() - { - return std::cout; - } - - /** \brief Encapsulate cin. - - Used for supporting UNICODE more easily. - */ - inline std::istream& console_in() - { - return std::cin; - } - -#endif - - //------------------------------------------------------------------------------ - /** \brief Bytecode values. - - \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! - */ - enum ECmdCode - { - // The following are codes for built in binary operators - // apart from built in operators the user has the opportunity to - // add user defined operators. - cmLE = 0, ///< Operator item: less or equal - cmGE = 1, ///< Operator item: greater or equal - cmNEQ = 2, ///< Operator item: not equal - cmEQ = 3, ///< Operator item: equals - cmLT = 4, ///< Operator item: less than - cmGT = 5, ///< Operator item: greater than - cmADD = 6, ///< Operator item: add - cmSUB = 7, ///< Operator item: subtract - cmMUL = 8, ///< Operator item: multiply - cmDIV = 9, ///< Operator item: division - cmPOW = 10, ///< Operator item: y to the power of ... - cmLAND = 11, - cmLOR = 12, - cmASSIGN = 13, ///< Operator item: Assignment operator - cmBO = 14, ///< Operator item: opening bracket - cmBC = 15, ///< Operator item: closing bracket - cmIF = 16, ///< For use in the ternary if-then-else operator - cmELSE = 17, ///< For use in the ternary if-then-else operator - cmENDIF = 18, ///< For use in the ternary if-then-else operator - cmARG_SEP = 19, ///< function argument separator - cmVAR = 20, ///< variable item - cmVAL = 21, ///< value item - - // For optimization purposes - cmVARPOW2, - cmVARPOW3, - cmVARPOW4, - cmVARMUL, - cmPOW2, - - // operators and functions - cmFUNC, ///< Code for a generic function item - cmFUNC_STR, ///< Code for a function with a string parameter - cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index - cmSTRING, ///< Code for a string token - cmOPRT_BIN, ///< user defined binary operator - cmOPRT_POSTFIX, ///< code for postfix operators - cmOPRT_INFIX, ///< code for infix operators - cmEND, ///< end of formula - cmUNKNOWN ///< uninitialized item - }; - - //------------------------------------------------------------------------------ - /** \brief Types internally used by the parser. - */ - enum ETypeCode - { - tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) - tpDBL = 1, ///< Floating point variables - tpVOID = 2 ///< Undefined type. - }; - - //------------------------------------------------------------------------------ - enum EParserVersionInfo - { - pviBRIEF, - pviFULL - }; - - //------------------------------------------------------------------------------ - /** \brief Parser operator precedence values. */ - enum EOprtAssociativity - { - oaLEFT = 0, - oaRIGHT = 1, - oaNONE = 2 - }; - - //------------------------------------------------------------------------------ - /** \brief Parser operator precedence values. */ - enum EOprtPrecedence - { - // binary operators - prLOR = 1, - prLAND = 2, - prLOGIC = 3, ///< logic operators - prCMP = 4, ///< comparsion operators - prADD_SUB = 5, ///< addition - prMUL_DIV = 6, ///< multiplication/division - prPOW = 7, ///< power operator priority (highest) - - // infix operators - prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator - prPOSTFIX = 6 ///< Postfix operator priority (currently unused) - }; - - //------------------------------------------------------------------------------ - // basic types - - /** \brief The numeric datatype used by the parser. - - Normally this is a floating point type either single or double precision. - */ - typedef MUP_BASETYPE value_type; - - /** \brief The stringtype used by the parser. - - Depends on wether UNICODE is used or not. - */ - typedef MUP_STRING_TYPE string_type; - - /** \brief The character type used by the parser. - - Depends on wether UNICODE is used or not. - */ - typedef string_type::value_type char_type; - - /** \brief Typedef for easily using stringstream that respect the parser stringtype. */ - typedef std::basic_stringstream<char_type, - std::char_traits<char_type>, - std::allocator<char_type> > stringstream_type; - - // Data container types - - /** \brief Type used for storing variables. */ - typedef std::map<string_type, value_type*> varmap_type; - - /** \brief Type used for storing constants. */ - typedef std::map<string_type, value_type> valmap_type; - - /** \brief Type for assigning a string name to an index in the internal string table. */ - typedef std::map<string_type, std::size_t> strmap_type; - - // Parser callbacks - - /** \brief Callback type used for functions without arguments. */ - typedef value_type (*generic_fun_type)(); - - /** \brief Callback type used for functions without arguments. */ - typedef value_type (*fun_type0)(); - - /** \brief Callback type used for functions with a single arguments. */ - typedef value_type (*fun_type1)(value_type); - - /** \brief Callback type used for functions with two arguments. */ - typedef value_type (*fun_type2)(value_type, value_type); - - /** \brief Callback type used for functions with three arguments. */ - typedef value_type (*fun_type3)(value_type, value_type, value_type); - - /** \brief Callback type used for functions with four arguments. */ - typedef value_type (*fun_type4)(value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type5)(value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type8)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type9)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*fun_type10)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions without arguments. */ - typedef value_type (*bulkfun_type0)(int, int); - - /** \brief Callback type used for functions with a single arguments. */ - typedef value_type (*bulkfun_type1)(int, int, value_type); - - /** \brief Callback type used for functions with two arguments. */ - typedef value_type (*bulkfun_type2)(int, int, value_type, value_type); - - /** \brief Callback type used for functions with three arguments. */ - typedef value_type (*bulkfun_type3)(int, int, value_type, value_type, value_type); - - /** \brief Callback type used for functions with four arguments. */ - typedef value_type (*bulkfun_type4)(int, int, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type5)(int, int, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type7)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type8)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type9)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with five arguments. */ - typedef value_type (*bulkfun_type10)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); - - /** \brief Callback type used for functions with a variable argument list. */ - typedef value_type (*multfun_type)(const value_type*, int); - - /** \brief Callback type used for functions taking a string as an argument. */ - typedef value_type (*strfun_type1)(const char_type*); - - /** \brief Callback type used for functions taking a string and a value as arguments. */ - typedef value_type (*strfun_type2)(const char_type*, value_type); - - /** \brief Callback type used for functions taking a string and two values as arguments. */ - typedef value_type (*strfun_type3)(const char_type*, value_type, value_type); - - /** \brief Callback used for functions that identify values in a string. */ - typedef int (*identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal); - - /** \brief Callback used for variable creation factory functions. */ - typedef value_type* (*facfun_type)(const char_type*, void*); -} // end of namespace - -#endif - diff --git a/ThirdParty/MuParser/include/muParserError.h b/ThirdParty/MuParser/include/muParserError.h deleted file mode 100644 index 7f88e99192ebf61d3b546a17892681af53a4f5f9..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserError.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_ERROR_H -#define MU_PARSER_ERROR_H - -#include <cassert> -#include <stdexcept> -#include <string> -#include <sstream> -#include <vector> -#include <memory> - -#include "muParserDef.h" - -/** \file - \brief This file defines the error class used by the parser. -*/ - -namespace mu -{ - -/** \brief Error codes. */ -enum EErrorCodes -{ - // Formula syntax errors - ecUNEXPECTED_OPERATOR = 0, ///< Unexpected binary operator found - ecUNASSIGNABLE_TOKEN = 1, ///< Token cant be identified. - ecUNEXPECTED_EOF = 2, ///< Unexpected end of formula. (Example: "2+sin(") - ecUNEXPECTED_ARG_SEP = 3, ///< An unexpected comma has been found. (Example: "1,23") - ecUNEXPECTED_ARG = 4, ///< An unexpected argument has been found - ecUNEXPECTED_VAL = 5, ///< An unexpected value token has been found - ecUNEXPECTED_VAR = 6, ///< An unexpected variable token has been found - ecUNEXPECTED_PARENS = 7, ///< Unexpected Parenthesis, opening or closing - ecUNEXPECTED_STR = 8, ///< A string has been found at an inapropriate position - ecSTRING_EXPECTED = 9, ///< A string function has been called with a different type of argument - ecVAL_EXPECTED = 10, ///< A numerical function has been called with a non value type of argument - ecMISSING_PARENS = 11, ///< Missing parens. (Example: "3*sin(3") - ecUNEXPECTED_FUN = 12, ///< Unexpected function found. (Example: "sin(8)cos(9)") - ecUNTERMINATED_STRING = 13, ///< unterminated string constant. (Example: "3*valueof("hello)") - ecTOO_MANY_PARAMS = 14, ///< Too many function parameters - ecTOO_FEW_PARAMS = 15, ///< Too few function parameters. (Example: "ite(1<2,2)") - ecOPRT_TYPE_CONFLICT = 16, ///< binary operators may only be applied to value items of the same type - ecSTR_RESULT = 17, ///< result is a string - - // Invalid Parser input Parameters - ecINVALID_NAME = 18, ///< Invalid function, variable or constant name. - ecINVALID_BINOP_IDENT = 19, ///< Invalid binary operator identifier - ecINVALID_INFIX_IDENT = 20, ///< Invalid function, variable or constant name. - ecINVALID_POSTFIX_IDENT = 21, ///< Invalid function, variable or constant name. - - ecBUILTIN_OVERLOAD = 22, ///< Trying to overload builtin operator - ecINVALID_FUN_PTR = 23, ///< Invalid callback function pointer - ecINVALID_VAR_PTR = 24, ///< Invalid variable pointer - ecEMPTY_EXPRESSION = 25, ///< The Expression is empty - ecNAME_CONFLICT = 26, ///< Name conflict - ecOPT_PRI = 27, ///< Invalid operator priority - // - ecDOMAIN_ERROR = 28, ///< catch division by zero, sqrt(-1), log(0) (currently unused) - ecDIV_BY_ZERO = 29, ///< Division by zero (currently unused) - ecGENERIC = 30, ///< Generic error - ecLOCALE = 31, ///< Conflict with current locale - - ecUNEXPECTED_CONDITIONAL = 32, - ecMISSING_ELSE_CLAUSE = 33, - ecMISPLACED_COLON = 34, - - ecUNREASONABLE_NUMBER_OF_COMPUTATIONS = 35, - - // internal errors - ecINTERNAL_ERROR = 36, ///< Internal error of any kind. - - // The last two are special entries - ecCOUNT, ///< This is no error code, It just stores just the total number of error codes - ecUNDEFINED = -1 ///< Undefined message, placeholder to detect unassigned error messages -}; - -//--------------------------------------------------------------------------- -/** \brief A class that handles the error messages. -*/ -class ParserErrorMsg -{ -public: - typedef ParserErrorMsg self_type; - - ParserErrorMsg& operator=(const ParserErrorMsg &); - ParserErrorMsg(const ParserErrorMsg&); - ParserErrorMsg(); - - ~ParserErrorMsg(); - - static const ParserErrorMsg& Instance(); - string_type operator[](unsigned a_iIdx) const; - -private: - std::vector<string_type> m_vErrMsg; ///< A vector with the predefined error messages - static const self_type m_Instance; ///< The instance pointer -}; - -//--------------------------------------------------------------------------- -/** \brief Error class of the parser. - \author Ingo Berg - - Part of the math parser package. -*/ -class ParserError -{ -private: - - /** \brief Replace all ocuurences of a substring with another string. */ - void ReplaceSubString( string_type &strSource, - const string_type &strFind, - const string_type &strReplaceWith); - void Reset(); - -public: - - ParserError(); - explicit ParserError(EErrorCodes a_iErrc); - explicit ParserError(const string_type &sMsg); - ParserError( EErrorCodes a_iErrc, - const string_type &sTok, - const string_type &sFormula = string_type(), - int a_iPos = -1); - ParserError( EErrorCodes a_iErrc, - int a_iPos, - const string_type &sTok); - ParserError( const char_type *a_szMsg, - int a_iPos = -1, - const string_type &sTok = string_type()); - ParserError(const ParserError &a_Obj); - ParserError& operator=(const ParserError &a_Obj); - ~ParserError(); - - void SetFormula(const string_type &a_strFormula); - const string_type& GetExpr() const; - const string_type& GetMsg() const; - int GetPos() const; - const string_type& GetToken() const; - EErrorCodes GetCode() const; - -private: - string_type m_strMsg; ///< The message string - string_type m_strFormula; ///< Formula string - string_type m_strTok; ///< Token related with the error - int m_iPos; ///< Formula position related to the error - EErrorCodes m_iErrc; ///< Error code - const ParserErrorMsg &m_ErrMsg; -}; - -} // namespace mu - -#endif - diff --git a/ThirdParty/MuParser/include/muParserFixes.h b/ThirdParty/MuParser/include/muParserFixes.h deleted file mode 100644 index 1cd15e02edbf1af43c24a5490eca51e5e45bd05d..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserFixes.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_FIXES_H -#define MU_PARSER_FIXES_H - -/** \file - \brief This file contains compatibility fixes for some platforms. -*/ - -// -// Compatibility fixes -// - -//--------------------------------------------------------------------------- -// -// Intel Compiler -// -//--------------------------------------------------------------------------- - -#ifdef __INTEL_COMPILER - -// remark #981: operands are evaluated in unspecified order -// disabled -> completely pointless if the functions do not have side effects -// -#pragma warning(disable:981) - -// remark #383: value copied to temporary, reference to temporary used -#pragma warning(disable:383) - -// remark #1572: floating-point equality and inequality comparisons are unreliable -// disabled -> everyone knows it, the parser passes this problem -// deliberately to the user -#pragma warning(disable:1572) - -#endif - -#endif // include guard - - diff --git a/ThirdParty/MuParser/include/muParserInt.h b/ThirdParty/MuParser/include/muParserInt.h deleted file mode 100644 index 136de339714588c26d48430d9e17778d367d0a26..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserInt.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_INT_H -#define MU_PARSER_INT_H - -#include "muParserBase.h" -#include <vector> - - -/** \file - \brief Definition of a parser using integer value. -*/ - - -namespace mu -{ - -/** \brief Mathematical expressions parser. - - This version of the parser handles only integer numbers. It disables the built in operators thus it is - slower than muParser. Integer values are stored in the double value_type and converted if needed. -*/ -class ParserInt : public ParserBase -{ -private: - static int Round(value_type v) { return (int)(v + ((v>=0) ? 0.5 : -0.5) ); }; - - static value_type Abs(value_type); - static value_type Sign(value_type); - static value_type Ite(value_type, value_type, value_type); - // !! The unary Minus is a MUST, otherwise you cant use negative signs !! - static value_type UnaryMinus(value_type); - // Functions with variable number of arguments - static value_type Sum(const value_type* a_afArg, int a_iArgc); // sum - static value_type Min(const value_type* a_afArg, int a_iArgc); // minimum - static value_type Max(const value_type* a_afArg, int a_iArgc); // maximum - // binary operator callbacks - static value_type Add(value_type v1, value_type v2); - static value_type Sub(value_type v1, value_type v2); - static value_type Mul(value_type v1, value_type v2); - static value_type Div(value_type v1, value_type v2); - static value_type Mod(value_type v1, value_type v2); - static value_type Pow(value_type v1, value_type v2); - static value_type Shr(value_type v1, value_type v2); - static value_type Shl(value_type v1, value_type v2); - static value_type LogAnd(value_type v1, value_type v2); - static value_type LogOr(value_type v1, value_type v2); - static value_type And(value_type v1, value_type v2); - static value_type Or(value_type v1, value_type v2); - static value_type Xor(value_type v1, value_type v2); - static value_type Less(value_type v1, value_type v2); - static value_type Greater(value_type v1, value_type v2); - static value_type LessEq(value_type v1, value_type v2); - static value_type GreaterEq(value_type v1, value_type v2); - static value_type Equal(value_type v1, value_type v2); - static value_type NotEqual(value_type v1, value_type v2); - static value_type Not(value_type v1); - - static int IsHexVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); - static int IsBinVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); - static int IsVal (const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); - - /** \brief A facet class used to change decimal and thousands separator. */ - template<class TChar> - class change_dec_sep : public std::numpunct<TChar> - { - public: - - explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) - :std::numpunct<TChar>() - ,m_cDecPoint(cDecSep) - ,m_cThousandsSep(cThousandsSep) - ,m_nGroup(nGroup) - {} - - protected: - - virtual char_type do_decimal_point() const - { - return m_cDecPoint; - } - - virtual char_type do_thousands_sep() const - { - return m_cThousandsSep; - } - - virtual std::string do_grouping() const - { - // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 - // courtesy of Jens Bartsch - // original code: - // return std::string(1, (char)m_nGroup); - // new code: - return std::string(1, (char)(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); - } - - private: - - int m_nGroup; - char_type m_cDecPoint; - char_type m_cThousandsSep; - }; - -public: - ParserInt(); - - virtual void InitFun(); - virtual void InitOprt(); - virtual void InitConst(); - virtual void InitCharSets(); -}; - -} // namespace mu - -#endif - diff --git a/ThirdParty/MuParser/include/muParserStack.h b/ThirdParty/MuParser/include/muParserStack.h deleted file mode 100644 index f8437e30e43cec17465c09da0d10641d251dc550..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserStack.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_STACK_H -#define MU_PARSER_STACK_H - -#include <cassert> -#include <string> -#include <stack> -#include <vector> - -#include "muParserError.h" -#include "muParserToken.h" - -/** \file - \brief This file defines the stack used by muparser. -*/ - -namespace mu -{ - - /** \brief Parser stack implementation. - - Stack implementation based on a std::stack. The behaviour of pop() had been - slightly changed in order to get an error code if the stack is empty. - The stack is used within the Parser both as a value stack and as an operator stack. - - \author (C) 2004-2011 Ingo Berg - */ - template <typename TValueType> - class ParserStack - { - private: - - /** \brief Type of the underlying stack implementation. */ - typedef std::stack<TValueType, std::vector<TValueType> > impl_type; - - impl_type m_Stack; ///< This is the actual stack. - - public: - - //--------------------------------------------------------------------------- - ParserStack() - :m_Stack() - {} - - //--------------------------------------------------------------------------- - virtual ~ParserStack() - {} - - //--------------------------------------------------------------------------- - /** \brief Pop a value from the stack. - - Unlike the standard implementation this function will return the value that - is going to be taken from the stack. - - \throw ParserException in case the stack is empty. - \sa pop(int &a_iErrc) - */ - TValueType pop() - { - if (empty()) - throw ParserError( _T("stack is empty.") ); - - TValueType el = top(); - m_Stack.pop(); - return el; - } - - /** \brief Push an object into the stack. - - \param a_Val object to push into the stack. - \throw nothrow - */ - void push(const TValueType& a_Val) - { - m_Stack.push(a_Val); - } - - /** \brief Return the number of stored elements. */ - unsigned size() const - { - return (unsigned)m_Stack.size(); - } - - /** \brief Returns true if stack is empty false otherwise. */ - bool empty() const - { - return m_Stack.empty(); - } - - /** \brief Return reference to the top object in the stack. - - The top object is the one pushed most recently. - */ - TValueType& top() - { - return m_Stack.top(); - } - }; -} // namespace MathUtils - -#endif diff --git a/ThirdParty/MuParser/include/muParserTemplateMagic.h b/ThirdParty/MuParser/include/muParserTemplateMagic.h deleted file mode 100644 index 1626caea4eeee2238d2eb874e9173e079c9d4853..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserTemplateMagic.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef MU_PARSER_TEMPLATE_MAGIC_H -#define MU_PARSER_TEMPLATE_MAGIC_H - -#include <cmath> -#include "muParserError.h" - - -namespace mu -{ - //----------------------------------------------------------------------------------------------- - // - // Compile time type detection - // - //----------------------------------------------------------------------------------------------- - - /** \brief A class singling out integer types at compile time using - template meta programming. - */ - template<typename T> - struct TypeInfo - { - static bool IsInteger() { return false; } - }; - - template<> - struct TypeInfo<char> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<short> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<int> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<long> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<unsigned char> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<unsigned short> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<unsigned int> - { - static bool IsInteger() { return true; } - }; - - template<> - struct TypeInfo<unsigned long> - { - static bool IsInteger() { return true; } - }; - - - //----------------------------------------------------------------------------------------------- - // - // Standard math functions with dummy overload for integer types - // - //----------------------------------------------------------------------------------------------- - - /** \brief A template class for providing wrappers for essential math functions. - - This template is spezialized for several types in order to provide a unified interface - for parser internal math function calls regardless of the data type. - */ - template<typename T> - struct MathImpl - { - static T Sin(T v) { return sin(v); } - static T Cos(T v) { return cos(v); } - static T Tan(T v) { return tan(v); } - static T ASin(T v) { return asin(v); } - static T ACos(T v) { return acos(v); } - static T ATan(T v) { return atan(v); } - static T ATan2(T v1, T v2) { return atan2(v1, v2); } - static T Sinh(T v) { return sinh(v); } - static T Cosh(T v) { return cosh(v); } - static T Tanh(T v) { return tanh(v); } - static T ASinh(T v) { return log(v + sqrt(v * v + 1)); } - static T ACosh(T v) { return log(v + sqrt(v * v - 1)); } - static T ATanh(T v) { return ((T)0.5 * log((1 + v) / (1 - v))); } - static T Log(T v) { return log(v); } - static T Log2(T v) { return log(v)/log((T)2); } // Logarithm base 2 - static T Log10(T v) { return log10(v); } // Logarithm base 10 - static T Exp(T v) { return exp(v); } - static T Abs(T v) { return (v>=0) ? v : -v; } - static T Sqrt(T v) { return sqrt(v); } - static T Rint(T v) { return floor(v + (T)0.5); } - static T Sign(T v) { return (T)((v<0) ? -1 : (v>0) ? 1 : 0); } - static T Pow(T v1, T v2) { return std::pow(v1, v2); } - }; -} - -#endif diff --git a/ThirdParty/MuParser/include/muParserTest.h b/ThirdParty/MuParser/include/muParserTest.h deleted file mode 100644 index c02b0218a9b5a320f7e16d680d7e7def13a00eec..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserTest.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_TEST_H -#define MU_PARSER_TEST_H - -#include <string> -#include <cstdlib> -#include <numeric> // for accumulate -#include "muParser.h" -#include "muParserInt.h" - -/** \file - \brief This file contains the parser test class. -*/ - -namespace mu -{ - /** \brief Namespace for test cases. */ - namespace Test - { - //------------------------------------------------------------------------------ - /** \brief Test cases for unit testing. - - (C) 2004-2011 Ingo Berg - */ - class ParserTester // final - { - private: - static int c_iCount; - - // Multiarg callbacks - static value_type f1of1(value_type v) { return v;}; - - static value_type f1of2(value_type v, value_type ) {return v;}; - static value_type f2of2(value_type , value_type v) {return v;}; - - static value_type f1of3(value_type v, value_type , value_type ) {return v;}; - static value_type f2of3(value_type , value_type v, value_type ) {return v;}; - static value_type f3of3(value_type , value_type , value_type v) {return v;}; - - static value_type f1of4(value_type v, value_type, value_type , value_type ) {return v;} - static value_type f2of4(value_type , value_type v, value_type , value_type ) {return v;} - static value_type f3of4(value_type , value_type, value_type v, value_type ) {return v;} - static value_type f4of4(value_type , value_type, value_type , value_type v) {return v;} - - static value_type f1of5(value_type v, value_type, value_type , value_type , value_type ) { return v; } - static value_type f2of5(value_type , value_type v, value_type , value_type , value_type ) { return v; } - static value_type f3of5(value_type , value_type, value_type v, value_type , value_type ) { return v; } - static value_type f4of5(value_type , value_type, value_type , value_type v, value_type ) { return v; } - static value_type f5of5(value_type , value_type, value_type , value_type , value_type v) { return v; } - - static value_type Min(value_type a_fVal1, value_type a_fVal2) { return (a_fVal1<a_fVal2) ? a_fVal1 : a_fVal2; } - static value_type Max(value_type a_fVal1, value_type a_fVal2) { return (a_fVal1>a_fVal2) ? a_fVal1 : a_fVal2; } - - static value_type plus2(value_type v1) { return v1+2; } - static value_type times3(value_type v1) { return v1*3; } - static value_type sqr(value_type v1) { return v1*v1; } - static value_type sign(value_type v) { return -v; } - static value_type add(value_type v1, value_type v2) { return v1+v2; } - static value_type land(value_type v1, value_type v2) { return (int)v1 & (int)v2; } - - - static value_type FirstArg(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw mu::Parser::exception_type( _T("too few arguments for function FirstArg.") ); - - return a_afArg[0]; - } - - static value_type LastArg(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw mu::Parser::exception_type( _T("too few arguments for function LastArg.") ); - - return a_afArg[a_iArgc-1]; - } - - static value_type Sum(const value_type* a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw mu::Parser::exception_type( _T("too few arguments for function sum.") ); - - value_type fRes=0; - for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; - return fRes; - } - - static value_type Rnd(value_type v) - { - return (value_type)(1+(v*std::rand()/(RAND_MAX+1.0))); - } - - static value_type RndWithString(const char_type*) - { - return (value_type)( 1 + (1000.0f * std::rand() / (RAND_MAX + 1.0) ) ); - } - - static value_type Ping() - { - return 10; - } - - static value_type ValueOf(const char_type*) - { - return 123; - } - - static value_type StrFun1(const char_type* v1) - { - int val(0); - stringstream_type(v1) >> val; - return (value_type)val; - } - - static value_type StrFun2(const char_type* v1, value_type v2) - { - int val(0); - stringstream_type(v1) >> val; - return (value_type)(val + v2); - } - - static value_type StrFun3(const char_type* v1, value_type v2, value_type v3) - { - int val(0); - stringstream_type(v1) >> val; - return val + v2 + v3; - } - - static value_type StrToFloat(const char_type* a_szMsg) - { - value_type val(0); - stringstream_type(a_szMsg) >> val; - return val; - } - - // postfix operator callback - static value_type Mega(value_type a_fVal) { return a_fVal * (value_type)1e6; } - static value_type Micro(value_type a_fVal) { return a_fVal * (value_type)1e-6; } - static value_type Milli(value_type a_fVal) { return a_fVal / (value_type)1e3; } - - // Custom value recognition - static int IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal); - - int TestNames(); - int TestSyntax(); - int TestMultiArg(); - int TestPostFix(); - int TestExpression(); - int TestInfixOprt(); - int TestBinOprt(); - int TestVarConst(); - int TestInterface(); - int TestException(); - int TestStrArg(); - int TestIfThenElse(); - int TestBulkMode(); - - void Abort() const; - - public: - typedef int (ParserTester::*testfun_type)(); - - ParserTester(); - void Run(); - - private: - std::vector<testfun_type> m_vTestFun; - void AddTest(testfun_type a_pFun); - - // Test Double Parser - int EqnTest(const string_type& a_str, double a_fRes, bool a_fPass); - int EqnTestWithVarChange(const string_type& a_str, - double a_fRes1, - double a_fVar1, - double a_fRes2, - double a_fVar2); - int ThrowTest(const string_type& a_str, int a_iErrc, bool a_bFail = true); - - // Test Int Parser - int EqnTestInt(const string_type& a_str, double a_fRes, bool a_fPass); - - // Test Bulkmode - int EqnTestBulk(const string_type& a_str, double a_fRes[4], bool a_fPass); - }; - } // namespace Test -} // namespace mu - -#endif - - diff --git a/ThirdParty/MuParser/include/muParserToken.h b/ThirdParty/MuParser/include/muParserToken.h deleted file mode 100644 index fc91d7818c0648e8a79cecd489195e4ade5b927d..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserToken.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_TOKEN_H -#define MU_PARSER_TOKEN_H - -#include <cassert> -#include <string> -#include <stack> -#include <vector> -#include <memory> - -#include "muParserError.h" -#include "muParserCallback.h" - -/** \file - \brief This file contains the parser token definition. -*/ - -namespace mu -{ - /** \brief Encapsulation of the data for a single formula token. - - Formula token implementation. Part of the Math Parser Package. - Formula tokens can be either one of the following: - <ul> - <li>value</li> - <li>variable</li> - <li>function with numerical arguments</li> - <li>functions with a string as argument</li> - <li>prefix operators</li> - <li>infix operators</li> - <li>binary operator</li> - </ul> - - \author (C) 2004-2013 Ingo Berg - */ - template<typename TBase, typename TString> - class ParserToken - { - private: - - ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. - ETypeCode m_iType; - void *m_pTok; ///< Stores Token pointer; not applicable for all tokens - int m_iIdx; ///< An otional index to an external buffer storing the token data - TString m_strTok; ///< Token string - TString m_strVal; ///< Value for string variables - value_type m_fVal; ///< the value - std::auto_ptr<ParserCallback> m_pCallback; - - public: - - //--------------------------------------------------------------------------- - /** \brief Constructor (default). - - Sets token to an neutral state of type cmUNKNOWN. - \throw nothrow - \sa ECmdCode - */ - ParserToken() - :m_iCode(cmUNKNOWN) - ,m_iType(tpVOID) - ,m_pTok(0) - ,m_iIdx(-1) - ,m_strTok() - ,m_strVal() - ,m_fVal(0) - ,m_pCallback() - {} - - //------------------------------------------------------------------------------ - /** \brief Create token from another one. - - Implemented by calling Assign(...) - \throw nothrow - \post m_iType==cmUNKNOWN - \sa #Assign - */ - ParserToken(const ParserToken &a_Tok) - { - Assign(a_Tok); - } - - //------------------------------------------------------------------------------ - /** \brief Assignement operator. - - Copy token state from another token and return this. - Implemented by calling Assign(...). - \throw nothrow - */ - ParserToken& operator=(const ParserToken &a_Tok) - { - Assign(a_Tok); - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Copy token information from argument. - - \throw nothrow - */ - void Assign(const ParserToken &a_Tok) - { - m_iCode = a_Tok.m_iCode; - m_pTok = a_Tok.m_pTok; - m_strTok = a_Tok.m_strTok; - m_iIdx = a_Tok.m_iIdx; - m_strVal = a_Tok.m_strVal; - m_iType = a_Tok.m_iType; - m_fVal = a_Tok.m_fVal; - // create new callback object if a_Tok has one - m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0); - } - - //------------------------------------------------------------------------------ - /** \brief Assign a token type. - - Token may not be of type value, variable or function. Those have seperate set functions. - - \pre [assert] a_iType!=cmVAR - \pre [assert] a_iType!=cmVAL - \pre [assert] a_iType!=cmFUNC - \post m_fVal = 0 - \post m_pTok = 0 - */ - ParserToken& Set(ECmdCode a_iType, const TString &a_strTok=TString()) - { - // The following types cant be set this way, they have special Set functions - assert(a_iType!=cmVAR); - assert(a_iType!=cmVAL); - assert(a_iType!=cmFUNC); - - m_iCode = a_iType; - m_iType = tpVOID; - m_pTok = 0; - m_strTok = a_strTok; - m_iIdx = -1; - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Set Callback type. */ - ParserToken& Set(const ParserCallback &a_pCallback, const TString &a_sTok) - { - assert(a_pCallback.GetAddr()); - - m_iCode = a_pCallback.GetCode(); - m_iType = tpVOID; - m_strTok = a_sTok; - m_pCallback.reset(new ParserCallback(a_pCallback)); - - m_pTok = 0; - m_iIdx = -1; - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Make this token a value token. - - Member variables not necessary for value tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetVal(TBase a_fVal, const TString &a_strTok=TString()) - { - m_iCode = cmVAL; - m_iType = tpDBL; - m_fVal = a_fVal; - m_strTok = a_strTok; - m_iIdx = -1; - - m_pTok = 0; - m_pCallback.reset(0); - - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief make this token a variable token. - - Member variables not necessary for variable tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetVar(TBase *a_pVar, const TString &a_strTok) - { - m_iCode = cmVAR; - m_iType = tpDBL; - m_strTok = a_strTok; - m_iIdx = -1; - m_pTok = (void*)a_pVar; - m_pCallback.reset(0); - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Make this token a variable token. - - Member variables not necessary for variable tokens will be invalidated. - \throw nothrow - */ - ParserToken& SetString(const TString &a_strTok, std::size_t a_iSize) - { - m_iCode = cmSTRING; - m_iType = tpSTR; - m_strTok = a_strTok; - m_iIdx = static_cast<int>(a_iSize); - - m_pTok = 0; - m_pCallback.reset(0); - return *this; - } - - //------------------------------------------------------------------------------ - /** \brief Set an index associated with the token related data. - - In cmSTRFUNC - This is the index to a string table in the main parser. - \param a_iIdx The index the string function result will take in the bytecode parser. - \throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING - */ - void SetIdx(int a_iIdx) - { - if (m_iCode!=cmSTRING || a_iIdx<0) - throw ParserError(ecINTERNAL_ERROR); - - m_iIdx = a_iIdx; - } - - //------------------------------------------------------------------------------ - /** \brief Return Index associated with the token related data. - - In cmSTRFUNC - This is the index to a string table in the main parser. - - \throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING - \return The index the result will take in the Bytecode calculatin array (#m_iIdx). - */ - int GetIdx() const - { - if (m_iIdx<0 || m_iCode!=cmSTRING ) - throw ParserError(ecINTERNAL_ERROR); - - return m_iIdx; - } - - //------------------------------------------------------------------------------ - /** \brief Return the token type. - - \return #m_iType - \throw nothrow - */ - ECmdCode GetCode() const - { - if (m_pCallback.get()) - { - return m_pCallback->GetCode(); - } - else - { - return m_iCode; - } - } - - //------------------------------------------------------------------------------ - ETypeCode GetType() const - { - if (m_pCallback.get()) - { - return m_pCallback->GetType(); - } - else - { - return m_iType; - } - } - - //------------------------------------------------------------------------------ - int GetPri() const - { - if ( !m_pCallback.get()) - throw ParserError(ecINTERNAL_ERROR); - - if ( m_pCallback->GetCode()!=cmOPRT_BIN && m_pCallback->GetCode()!=cmOPRT_INFIX) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetPri(); - } - - //------------------------------------------------------------------------------ - EOprtAssociativity GetAssociativity() const - { - if (m_pCallback.get()==NULL || m_pCallback->GetCode()!=cmOPRT_BIN) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetAssociativity(); - } - - //------------------------------------------------------------------------------ - /** \brief Return the address of the callback function assoziated with - function and operator tokens. - - \return The pointer stored in #m_pTok. - \throw exception_type if token type is non of: - <ul> - <li>cmFUNC</li> - <li>cmSTRFUNC</li> - <li>cmPOSTOP</li> - <li>cmINFIXOP</li> - <li>cmOPRT_BIN</li> - </ul> - \sa ECmdCode - */ - generic_fun_type GetFuncAddr() const - { - return (m_pCallback.get()) ? (generic_fun_type)m_pCallback->GetAddr() : 0; - } - - //------------------------------------------------------------------------------ - /** \biref Get value of the token. - - Only applicable to variable and value tokens. - \throw exception_type if token is no value/variable token. - */ - TBase GetVal() const - { - switch (m_iCode) - { - case cmVAL: return m_fVal; - case cmVAR: return *((TBase*)m_pTok); - default: throw ParserError(ecVAL_EXPECTED); - } - } - - //------------------------------------------------------------------------------ - /** \brief Get address of a variable token. - - Valid only if m_iType==CmdVar. - \throw exception_type if token is no variable token. - */ - TBase* GetVar() const - { - if (m_iCode!=cmVAR) - throw ParserError(ecINTERNAL_ERROR); - - return (TBase*)m_pTok; - } - - //------------------------------------------------------------------------------ - /** \brief Return the number of function arguments. - - Valid only if m_iType==CmdFUNC. - */ - int GetArgCount() const - { - assert(m_pCallback.get()); - - if (!m_pCallback->GetAddr()) - throw ParserError(ecINTERNAL_ERROR); - - return m_pCallback->GetArgc(); - } - - //------------------------------------------------------------------------------ - /** \brief Return the token identifier. - - If #m_iType is cmSTRING the token identifier is the value of the string argument - for a string function. - \return #m_strTok - \throw nothrow - \sa m_strTok - */ - const TString& GetAsString() const - { - return m_strTok; - } - }; -} // namespace mu - -#endif diff --git a/ThirdParty/MuParser/include/muParserTokenReader.h b/ThirdParty/MuParser/include/muParserTokenReader.h deleted file mode 100644 index 9d96225d9a64c0c6e36c17dbad6c7624fe0ee1f2..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/include/muParserTokenReader.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef MU_PARSER_TOKEN_READER_H -#define MU_PARSER_TOKEN_READER_H - -#include <cassert> -#include <cstdio> -#include <cstring> -#include <list> -#include <map> -#include <memory> -#include <stack> -#include <string> - -#include "muParserDef.h" -#include "muParserToken.h" - -/** \file - \brief This file contains the parser token reader definition. -*/ - - -namespace mu -{ - // Forward declaration - class ParserBase; - - /** \brief Token reader for the ParserBase class. - - */ - class ParserTokenReader - { - private: - - typedef ParserToken<value_type, string_type> token_type; - - public: - - ParserTokenReader(ParserBase *a_pParent); - ParserTokenReader* Clone(ParserBase *a_pParent) const; - - void AddValIdent(identfun_type a_pCallback); - void SetVarCreator(facfun_type a_pFactory, void *pUserData); - void SetFormula(const string_type &a_strFormula); - void SetArgSep(char_type cArgSep); - - int GetPos() const; - const string_type& GetExpr() const; - varmap_type& GetUsedVar(); - char_type GetArgSep() const; - - void IgnoreUndefVar(bool bIgnore); - void ReInit(); - token_type ReadNextToken(); - - private: - - /** \brief Syntax codes. - - The syntax codes control the syntax check done during the first time parsing of - the expression string. They are flags that indicate which tokens are allowed next - if certain tokens are identified. - */ - enum ESynCodes - { - noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" - noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" - noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" - noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" - noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... - noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" - noOPT = 1 << 6, ///< to avoid i.e. "(+)" - noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" - noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" - noEND = 1 << 9, ///< to avoid unexpected end of formula - noSTR = 1 << 10, ///< to block numeric arguments on string functions - noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7" - noIF = 1 << 12, - noELSE = 1 << 13, - sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, - noANY = ~0 ///< All of he above flags set - }; - - ParserTokenReader(const ParserTokenReader &a_Reader); - ParserTokenReader& operator=(const ParserTokenReader &a_Reader); - void Assign(const ParserTokenReader &a_Reader); - - void SetParent(ParserBase *a_pParent); - int ExtractToken(const char_type *a_szCharSet, - string_type &a_strTok, - int a_iPos) const; - int ExtractOperatorToken(string_type &a_sTok, int a_iPos) const; - - bool IsBuiltIn(token_type &a_Tok); - bool IsArgSep(token_type &a_Tok); - bool IsEOF(token_type &a_Tok); - bool IsInfixOpTok(token_type &a_Tok); - bool IsFunTok(token_type &a_Tok); - bool IsPostOpTok(token_type &a_Tok); - bool IsOprt(token_type &a_Tok); - bool IsValTok(token_type &a_Tok); - bool IsVarTok(token_type &a_Tok); - bool IsStrVarTok(token_type &a_Tok); - bool IsUndefVarTok(token_type &a_Tok); - bool IsString(token_type &a_Tok); - void Error(EErrorCodes a_iErrc, - int a_iPos = -1, - const string_type &a_sTok = string_type() ) const; - - token_type& SaveBeforeReturn(const token_type &tok); - - ParserBase *m_pParser; - string_type m_strFormula; - int m_iPos; - int m_iSynFlags; - bool m_bIgnoreUndefVar; - - const funmap_type *m_pFunDef; - const funmap_type *m_pPostOprtDef; - const funmap_type *m_pInfixOprtDef; - const funmap_type *m_pOprtDef; - const valmap_type *m_pConstDef; - const strmap_type *m_pStrVarDef; - varmap_type *m_pVarDef; ///< The only non const pointer to parser internals - facfun_type m_pFactory; - void *m_pFactoryData; - std::list<identfun_type> m_vIdentFun; ///< Value token identification function - varmap_type m_UsedVar; - value_type m_fZero; ///< Dummy value of zero, referenced by undefined variables - int m_iBrackets; - token_type m_lastTok; - char_type m_cArgSep; ///< The character used for separating function arguments - }; -} // namespace mu - -#endif - - diff --git a/ThirdParty/MuParser/src/muParser.cpp b/ThirdParty/MuParser/src/muParser.cpp deleted file mode 100644 index 39ea8610c779ea6061ba1fde8f3c4497f56d63e6..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParser.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "muParser.h" -#include "muParserTemplateMagic.h" - -//--- Standard includes ------------------------------------------------------------------------ -#include <cmath> -#include <algorithm> -#include <numeric> - -/** \brief Pi (what else?). */ -#define PARSER_CONST_PI 3.141592653589793238462643 - -/** \brief The Eulerian number. */ -#define PARSER_CONST_E 2.718281828459045235360287 - -using namespace std; - -/** \file - \brief Implementation of the standard floating point parser. -*/ - - - -/** \brief Namespace for mathematical applications. */ -namespace mu -{ - - - //--------------------------------------------------------------------------- - // Trigonometric function - value_type Parser::Sin(value_type v) { return MathImpl<value_type>::Sin(v); } - value_type Parser::Cos(value_type v) { return MathImpl<value_type>::Cos(v); } - value_type Parser::Tan(value_type v) { return MathImpl<value_type>::Tan(v); } - value_type Parser::ASin(value_type v) { return MathImpl<value_type>::ASin(v); } - value_type Parser::ACos(value_type v) { return MathImpl<value_type>::ACos(v); } - value_type Parser::ATan(value_type v) { return MathImpl<value_type>::ATan(v); } - value_type Parser::ATan2(value_type v1, value_type v2) { return MathImpl<value_type>::ATan2(v1, v2); } - value_type Parser::Sinh(value_type v) { return MathImpl<value_type>::Sinh(v); } - value_type Parser::Cosh(value_type v) { return MathImpl<value_type>::Cosh(v); } - value_type Parser::Tanh(value_type v) { return MathImpl<value_type>::Tanh(v); } - value_type Parser::ASinh(value_type v) { return MathImpl<value_type>::ASinh(v); } - value_type Parser::ACosh(value_type v) { return MathImpl<value_type>::ACosh(v); } - value_type Parser::ATanh(value_type v) { return MathImpl<value_type>::ATanh(v); } - - //--------------------------------------------------------------------------- - // Logarithm functions - - // Logarithm base 2 - value_type Parser::Log2(value_type v) - { - #ifdef MUP_MATH_EXCEPTIONS - if (v<=0) - throw ParserError(ecDOMAIN_ERROR, _T("Log2")); - #endif - - return MathImpl<value_type>::Log2(v); - } - - // Logarithm base 10 - value_type Parser::Log10(value_type v) - { - #ifdef MUP_MATH_EXCEPTIONS - if (v<=0) - throw ParserError(ecDOMAIN_ERROR, _T("Log10")); - #endif - - return MathImpl<value_type>::Log10(v); - } - -// Logarithm base e (natural logarithm) - value_type Parser::Ln(value_type v) - { - #ifdef MUP_MATH_EXCEPTIONS - if (v<=0) - throw ParserError(ecDOMAIN_ERROR, _T("Ln")); - #endif - - return MathImpl<value_type>::Log(v); - } - - //--------------------------------------------------------------------------- - // misc - value_type Parser::Exp(value_type v) { return MathImpl<value_type>::Exp(v); } - value_type Parser::Abs(value_type v) { return MathImpl<value_type>::Abs(v); } - value_type Parser::Sqrt(value_type v) - { - #ifdef MUP_MATH_EXCEPTIONS - if (v<0) - throw ParserError(ecDOMAIN_ERROR, _T("sqrt")); - #endif - - return MathImpl<value_type>::Sqrt(v); - } - value_type Parser::Rint(value_type v) { return MathImpl<value_type>::Rint(v); } - value_type Parser::Sign(value_type v) { return MathImpl<value_type>::Sign(v); } - - //--------------------------------------------------------------------------- - /** \brief Callback for the unary minus operator. - \param v The value to negate - \return -v - */ - value_type Parser::UnaryMinus(value_type v) - { - return -v; - } - - //--------------------------------------------------------------------------- - /** \brief Callback for the unary minus operator. - \param v The value to negate - \return -v - */ - value_type Parser::UnaryPlus(value_type v) - { - return v; - } - - //--------------------------------------------------------------------------- - /** \brief Callback for adding multiple values. - \param [in] a_afArg Vector with the function arguments - \param [in] a_iArgc The size of a_afArg - */ - value_type Parser::Sum(const value_type *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw exception_type(_T("too few arguments for function sum.")); - - value_type fRes=0; - for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; - return fRes; - } - - //--------------------------------------------------------------------------- - /** \brief Callback for averaging multiple values. - \param [in] a_afArg Vector with the function arguments - \param [in] a_iArgc The size of a_afArg - */ - value_type Parser::Avg(const value_type *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw exception_type(_T("too few arguments for function sum.")); - - value_type fRes=0; - for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; - return fRes/(value_type)a_iArgc; - } - - - //--------------------------------------------------------------------------- - /** \brief Callback for determining the minimum value out of a vector. - \param [in] a_afArg Vector with the function arguments - \param [in] a_iArgc The size of a_afArg - */ - value_type Parser::Min(const value_type *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw exception_type(_T("too few arguments for function min.")); - - value_type fRes=a_afArg[0]; - for (int i=0; i<a_iArgc; ++i) - fRes = std::min(fRes, a_afArg[i]); - - return fRes; - } - - - //--------------------------------------------------------------------------- - /** \brief Callback for determining the maximum value out of a vector. - \param [in] a_afArg Vector with the function arguments - \param [in] a_iArgc The size of a_afArg - */ - value_type Parser::Max(const value_type *a_afArg, int a_iArgc) - { - if (!a_iArgc) - throw exception_type(_T("too few arguments for function min.")); - - value_type fRes=a_afArg[0]; - for (int i=0; i<a_iArgc; ++i) fRes = std::max(fRes, a_afArg[i]); - - return fRes; - } - - - //--------------------------------------------------------------------------- - /** \brief Default value recognition callback. - \param [in] a_szExpr Pointer to the expression - \param [in, out] a_iPos Pointer to an index storing the current position within the expression - \param [out] a_fVal Pointer where the value should be stored in case one is found. - \return 1 if a value was found 0 otherwise. - */ - int Parser::IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal) - { - value_type fVal(0); - - stringstream_type stream(a_szExpr); - stream.seekg(0); // todo: check if this really is necessary - stream.imbue(Parser::s_locale); - stream >> fVal; - stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading - - if (iEnd==(stringstream_type::pos_type)-1) - return 0; - - *a_iPos += (int)iEnd; - *a_fVal = fVal; - return 1; - } - - - //--------------------------------------------------------------------------- - /** \brief Constructor. - - Call ParserBase class constructor and trigger Function, Operator and Constant initialization. - */ - Parser::Parser() - :ParserBase() - { - AddValIdent(IsVal); - - InitCharSets(); - InitFun(); - InitConst(); - InitOprt(); - } - - //--------------------------------------------------------------------------- - /** \brief Define the character sets. - \sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars - - This function is used for initializing the default character sets that define - the characters to be useable in function and variable names and operators. - */ - void Parser::InitCharSets() - { - DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); - DefineOprtChars( _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") ); - DefineInfixOprtChars( _T("/+-*^?<>=#!$%&|~'_") ); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize the default functions. */ - void Parser::InitFun() - { - if (mu::TypeInfo<mu::value_type>::IsInteger()) - { - // When setting MUP_BASETYPE to an integer type - // Place functions for dealing with integer values here - // ... - // ... - // ... - } - else - { - // trigonometric functions - DefineFun(_T("sin"), Sin); - DefineFun(_T("cos"), Cos); - DefineFun(_T("tan"), Tan); - // arcus functions - DefineFun(_T("asin"), ASin); - DefineFun(_T("acos"), ACos); - DefineFun(_T("atan"), ATan); - DefineFun(_T("atan2"), ATan2); - // hyperbolic functions - DefineFun(_T("sinh"), Sinh); - DefineFun(_T("cosh"), Cosh); - DefineFun(_T("tanh"), Tanh); - // arcus hyperbolic functions - DefineFun(_T("asinh"), ASinh); - DefineFun(_T("acosh"), ACosh); - DefineFun(_T("atanh"), ATanh); - // Logarithm functions - DefineFun(_T("log2"), Log2); - DefineFun(_T("log10"), Log10); - DefineFun(_T("log"), Ln); - DefineFun(_T("ln"), Ln); - // misc - DefineFun(_T("exp"), Exp); - DefineFun(_T("sqrt"), Sqrt); - DefineFun(_T("sign"), Sign); - DefineFun(_T("rint"), Rint); - DefineFun(_T("abs"), Abs); - // Functions with variable number of arguments - DefineFun(_T("sum"), Sum); - DefineFun(_T("avg"), Avg); - DefineFun(_T("min"), Min); - DefineFun(_T("max"), Max); - } - } - - //--------------------------------------------------------------------------- - /** \brief Initialize constants. - - By default the parser recognizes two constants. Pi ("pi") and the Eulerian - number ("_e"). - */ - void Parser::InitConst() - { - DefineConst(_T("_pi"), (value_type)PARSER_CONST_PI); - DefineConst(_T("_e"), (value_type)PARSER_CONST_E); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize operators. - - By default only the unary minus operator is added. - */ - void Parser::InitOprt() - { - DefineInfixOprt(_T("-"), UnaryMinus); - DefineInfixOprt(_T("+"), UnaryPlus); - } - - //--------------------------------------------------------------------------- - void Parser::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) - { - // this is just sample code to illustrate modifying variable names on the fly. - // I'm not sure anyone really needs such a feature... - /* - - - string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); - string sRepl = std::string("_") + sVar + "_"; - - int nOrigVarEnd = nEnd; - cout << "variable detected!\n"; - cout << " Expr: " << *pExpr << "\n"; - cout << " Start: " << nStart << "\n"; - cout << " End: " << nEnd << "\n"; - cout << " Var: \"" << sVar << "\"\n"; - cout << " Repl: \"" << sRepl << "\"\n"; - nEnd = nStart + sRepl.length(); - cout << " End: " << nEnd << "\n"; - pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); - cout << " New expr: " << *pExpr << "\n"; - */ - } - - //--------------------------------------------------------------------------- - /** \brief Numerically differentiate with regard to a variable. - \param [in] a_Var Pointer to the differentiation variable. - \param [in] a_fPos Position at which the differentiation should take place. - \param [in] a_fEpsilon Epsilon used for the numerical differentiation. - - Numerical differentiation uses a 5 point operator yielding a 4th order - formula. The default value for epsilon is 0.00074 which is - numeric_limits<double>::epsilon() ^ (1/5) as suggested in the muparser - forum: - - http://sourceforge.net/forum/forum.php?thread_id=1994611&forum_id=462843 - */ - value_type Parser::Diff(value_type *a_Var, - value_type a_fPos, - value_type a_fEpsilon) const - { - value_type fRes(0), - fBuf(*a_Var), - f[4] = {0,0,0,0}, - fEpsilon(a_fEpsilon); - - // Backwards compatible calculation of epsilon inc case the user doesn't provide - // his own epsilon - if (fEpsilon==0) - fEpsilon = (a_fPos==0) ? (value_type)1e-10 : (value_type)1e-7 * a_fPos; - - *a_Var = a_fPos+2 * fEpsilon; f[0] = Eval(); - *a_Var = a_fPos+1 * fEpsilon; f[1] = Eval(); - *a_Var = a_fPos-1 * fEpsilon; f[2] = Eval(); - *a_Var = a_fPos-2 * fEpsilon; f[3] = Eval(); - *a_Var = fBuf; // restore variable - - fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon); - return fRes; - } -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserBase.cpp b/ThirdParty/MuParser/src/muParserBase.cpp deleted file mode 100644 index ea3699a12fc02cf7973adc145c1ce5667f4b5715..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserBase.cpp +++ /dev/null @@ -1,1778 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "muParserBase.h" -#include "muParserTemplateMagic.h" - -//--- Standard includes ------------------------------------------------------------------------ -#include <cassert> -#include <algorithm> -#include <cmath> -#include <memory> -#include <vector> -#include <deque> -#include <sstream> -#include <locale> - -#ifdef MUP_USE_OPENMP - #include <omp.h> -#endif - -using namespace std; - -/** \file - \brief This file contains the basic implementation of the muparser engine. -*/ - -namespace mu -{ - std::locale ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.')); - - bool ParserBase::g_DbgDumpCmdCode = false; - bool ParserBase::g_DbgDumpStack = false; - - //------------------------------------------------------------------------------ - /** \brief Identifiers for built in binary operators. - - When defining custom binary operators with #AddOprt(...) make sure not to choose - names conflicting with these definitions. - */ - const char_type* ParserBase::c_DefaultOprt[] = - { - _T("<="), _T(">="), _T("!="), - _T("=="), _T("<"), _T(">"), - _T("+"), _T("-"), _T("*"), - _T("/"), _T("^"), _T("&&"), - _T("||"), _T("="), _T("("), - _T(")"), _T("?"), _T(":"), 0 - }; - - //------------------------------------------------------------------------------ - /** \brief Constructor. - \param a_szFormula the formula to interpret. - \throw ParserException if a_szFormula is null. - */ - ParserBase::ParserBase() - :m_pParseFormula(&ParserBase::ParseString) - ,m_vRPN() - ,m_vStringBuf() - ,m_pTokenReader() - ,m_FunDef() - ,m_PostOprtDef() - ,m_InfixOprtDef() - ,m_OprtDef() - ,m_ConstDef() - ,m_StrVarDef() - ,m_VarDef() - ,m_bBuiltInOp(true) - ,m_sNameChars() - ,m_sOprtChars() - ,m_sInfixOprtChars() - ,m_nIfElseCounter(0) - ,m_vStackBuffer() - ,m_nFinalResultIdx(0) - { - InitTokenReader(); - } - - //--------------------------------------------------------------------------- - /** \brief Copy constructor. - - The parser can be safely copy constructed but the bytecode is reset during - copy construction. - */ - ParserBase::ParserBase(const ParserBase &a_Parser) - :m_pParseFormula(&ParserBase::ParseString) - ,m_vRPN() - ,m_vStringBuf() - ,m_pTokenReader() - ,m_FunDef() - ,m_PostOprtDef() - ,m_InfixOprtDef() - ,m_OprtDef() - ,m_ConstDef() - ,m_StrVarDef() - ,m_VarDef() - ,m_bBuiltInOp(true) - ,m_sNameChars() - ,m_sOprtChars() - ,m_sInfixOprtChars() - ,m_nIfElseCounter(0) - { - m_pTokenReader.reset(new token_reader_type(this)); - Assign(a_Parser); - } - - //--------------------------------------------------------------------------- - ParserBase::~ParserBase() - {} - - //--------------------------------------------------------------------------- - /** \brief Assignment operator. - - Implemented by calling Assign(a_Parser). Self assignment is suppressed. - \param a_Parser Object to copy to this. - \return *this - \throw nothrow - */ - ParserBase& ParserBase::operator=(const ParserBase &a_Parser) - { - Assign(a_Parser); - return *this; - } - - //--------------------------------------------------------------------------- - /** \brief Copy state of a parser object to this. - - Clears Variables and Functions of this parser. - Copies the states of all internal variables. - Resets parse function to string parse mode. - - \param a_Parser the source object. - */ - void ParserBase::Assign(const ParserBase &a_Parser) - { - if (&a_Parser==this) - return; - - // Don't copy bytecode instead cause the parser to create new bytecode - // by resetting the parse function. - ReInit(); - - m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants - m_VarDef = a_Parser.m_VarDef; // Copy user defined variables - m_bBuiltInOp = a_Parser.m_bBuiltInOp; - m_vStringBuf = a_Parser.m_vStringBuf; - m_vStackBuffer = a_Parser.m_vStackBuffer; - m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; - m_StrVarDef = a_Parser.m_StrVarDef; - m_vStringVarBuf = a_Parser.m_vStringVarBuf; - m_nIfElseCounter = a_Parser.m_nIfElseCounter; - m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); - - // Copy function and operator callbacks - m_FunDef = a_Parser.m_FunDef; // Copy function definitions - m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators - m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation - m_OprtDef = a_Parser.m_OprtDef; // binary operators - - m_sNameChars = a_Parser.m_sNameChars; - m_sOprtChars = a_Parser.m_sOprtChars; - m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; - } - - //--------------------------------------------------------------------------- - /** \brief Set the decimal separator. - \param cDecSep Decimal separator as a character value. - \sa SetThousandsSep - - By default muparser uses the "C" locale. The decimal separator of this - locale is overwritten by the one provided here. - */ - void ParserBase::SetDecSep(char_type cDecSep) - { - char_type cThousandsSep = std::use_facet< change_dec_sep<char_type> >(s_locale).thousands_sep(); - s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); - } - - //--------------------------------------------------------------------------- - /** \brief Sets the thousands operator. - \param cThousandsSep The thousands separator as a character - \sa SetDecSep - - By default muparser uses the "C" locale. The thousands separator of this - locale is overwritten by the one provided here. - */ - void ParserBase::SetThousandsSep(char_type cThousandsSep) - { - char_type cDecSep = std::use_facet< change_dec_sep<char_type> >(s_locale).decimal_point(); - s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); - } - - //--------------------------------------------------------------------------- - /** \brief Resets the locale. - - The default locale used "." as decimal separator, no thousands separator and - "," as function argument separator. - */ - void ParserBase::ResetLocale() - { - s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>('.')); - SetArgSep(','); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize the token reader. - - Create new token reader object and submit pointers to function, operator, - constant and variable definitions. - - \post m_pTokenReader.get()!=0 - \throw nothrow - */ - void ParserBase::InitTokenReader() - { - m_pTokenReader.reset(new token_reader_type(this)); - } - - //--------------------------------------------------------------------------- - /** \brief Reset parser to string parsing mode and clear internal buffers. - - Clear bytecode, reset the token reader. - \throw nothrow - */ - void ParserBase::ReInit() const - { - m_pParseFormula = &ParserBase::ParseString; - m_vStringBuf.clear(); - m_vRPN.clear(); - m_pTokenReader->ReInit(); - m_nIfElseCounter = 0; - } - - //--------------------------------------------------------------------------- - void ParserBase::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) - {} - - //--------------------------------------------------------------------------- - /** \brief Returns the version of muparser. - \param eInfo A flag indicating whether the full version info should be - returned or not. - - Format is as follows: "MAJOR.MINOR (COMPILER_FLAGS)" The COMPILER_FLAGS - are returned only if eInfo==pviFULL. - */ - string_type ParserBase::GetVersion(EParserVersionInfo eInfo) const - { - stringstream_type ss; - - ss << MUP_VERSION; - - if (eInfo==pviFULL) - { - ss << _T(" (") << MUP_VERSION_DATE; - ss << std::dec << _T("; ") << sizeof(void*)*8 << _T("BIT"); - -#ifdef _DEBUG - ss << _T("; DEBUG"); -#else - ss << _T("; RELEASE"); -#endif - -#ifdef _UNICODE - ss << _T("; UNICODE"); -#else - #ifdef _MBCS - ss << _T("; MBCS"); - #else - ss << _T("; ASCII"); - #endif -#endif - -#ifdef MUP_USE_OPENMP - ss << _T("; OPENMP"); -//#else -// ss << _T("; NO_OPENMP"); -#endif - -#if defined(MUP_MATH_EXCEPTIONS) - ss << _T("; MATHEXC"); -//#else -// ss << _T("; NO_MATHEXC"); -#endif - - ss << _T(")"); - } - - return ss.str(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a value parsing function. - - When parsing an expression muParser tries to detect values in the expression - string using different valident callbacks. Thus it's possible to parse - for hex values, binary values and floating point values. - */ - void ParserBase::AddValIdent(identfun_type a_pCallback) - { - m_pTokenReader->AddValIdent(a_pCallback); - } - - //--------------------------------------------------------------------------- - /** \brief Set a function that can create variable pointer for unknown expression variables. - \param a_pFactory A pointer to the variable factory. - \param pUserData A user defined context pointer. - */ - void ParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData) - { - m_pTokenReader->SetVarCreator(a_pFactory, pUserData); - } - - //--------------------------------------------------------------------------- - /** \brief Add a function or operator callback to the parser. */ - void ParserBase::AddCallback( const string_type &a_strName, - const ParserCallback &a_Callback, - funmap_type &a_Storage, - const char_type *a_szCharSet ) - { - if (a_Callback.GetAddr()==0) - Error(ecINVALID_FUN_PTR); - - const funmap_type *pFunMap = &a_Storage; - - // Check for conflicting operator or function names - if ( pFunMap!=&m_FunDef && m_FunDef.find(a_strName)!=m_FunDef.end() ) - Error(ecNAME_CONFLICT, -1, a_strName); - - if ( pFunMap!=&m_PostOprtDef && m_PostOprtDef.find(a_strName)!=m_PostOprtDef.end() ) - Error(ecNAME_CONFLICT, -1, a_strName); - - if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_InfixOprtDef.find(a_strName)!=m_InfixOprtDef.end() ) - Error(ecNAME_CONFLICT, -1, a_strName); - - if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_OprtDef.find(a_strName)!=m_OprtDef.end() ) - Error(ecNAME_CONFLICT, -1, a_strName); - - CheckOprt(a_strName, a_Callback, a_szCharSet); - a_Storage[a_strName] = a_Callback; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Check if a name contains invalid characters. - - \throw ParserException if the name contains invalid characters. - */ - void ParserBase::CheckOprt(const string_type &a_sName, - const ParserCallback &a_Callback, - const string_type &a_szCharSet) const - { - if ( !a_sName.length() || - (a_sName.find_first_not_of(a_szCharSet)!=string_type::npos) || - (a_sName[0]>='0' && a_sName[0]<='9')) - { - switch(a_Callback.GetCode()) - { - case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); - case cmOPRT_INFIX: Error(ecINVALID_INFIX_IDENT, -1, a_sName); - default: Error(ecINVALID_NAME, -1, a_sName); - } - } - } - - //--------------------------------------------------------------------------- - /** \brief Check if a name contains invalid characters. - - \throw ParserException if the name contains invalid characters. - */ - void ParserBase::CheckName(const string_type &a_sName, - const string_type &a_szCharSet) const - { - if ( !a_sName.length() || - (a_sName.find_first_not_of(a_szCharSet)!=string_type::npos) || - (a_sName[0]>='0' && a_sName[0]<='9')) - { - Error(ecINVALID_NAME); - } - } - - //--------------------------------------------------------------------------- - /** \brief Set the formula. - \param a_strFormula Formula as string_type - \throw ParserException in case of syntax errors. - - Triggers first time calculation thus the creation of the bytecode and - scanning of used variables. - */ - void ParserBase::SetExpr(const string_type &a_sExpr) - { - // Check locale compatibility - std::locale loc; - if (m_pTokenReader->GetArgSep()==std::use_facet<numpunct<char_type> >(loc).decimal_point()) - Error(ecLOCALE); - - // <ibg> 20060222: Bugfix for Borland-Kylix: - // adding a space to the expression will keep Borlands KYLIX from going wild - // when calling tellg on a stringstream created from the expression after - // reading a value at the end of an expression. (mu::Parser::IsVal function) - // (tellg returns -1 otherwise causing the parser to ignore the value) - string_type sBuf(a_sExpr + _T(" ") ); - m_pTokenReader->SetFormula(sBuf); - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Get the default symbols used for the built in operators. - \sa c_DefaultOprt - */ - const char_type** ParserBase::GetOprtDef() const - { - return (const char_type **)(&c_DefaultOprt[0]); - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - functions, variables, constants. - */ - void ParserBase::DefineNameChars(const char_type *a_szCharset) - { - m_sNameChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - binary operators and postfix operators. - */ - void ParserBase::DefineOprtChars(const char_type *a_szCharset) - { - m_sOprtChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Define the set of valid characters to be used in names of - infix operators. - */ - void ParserBase::DefineInfixOprtChars(const char_type *a_szCharset) - { - m_sInfixOprtChars = a_szCharset; - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in name identifiers. - \sa #ValidOprtChars, #ValidPrefixOprtChars - */ - const char_type* ParserBase::ValidNameChars() const - { - assert(m_sNameChars.size()); - return m_sNameChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in operator definitions. - \sa #ValidNameChars, #ValidPrefixOprtChars - */ - const char_type* ParserBase::ValidOprtChars() const - { - assert(m_sOprtChars.size()); - return m_sOprtChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Virtual function that defines the characters allowed in infix operator definitions. - \sa #ValidNameChars, #ValidOprtChars - */ - const char_type* ParserBase::ValidInfixOprtChars() const - { - assert(m_sInfixOprtChars.size()); - return m_sInfixOprtChars.c_str(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined operator. - \post Will reset the Parser to string parsing mode. - */ - void ParserBase::DefinePostfixOprt(const string_type &a_sName, - fun_type1 a_pFun, - bool a_bAllowOpt) - { - AddCallback(a_sName, - ParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), - m_PostOprtDef, - ValidOprtChars() ); - } - - //--------------------------------------------------------------------------- - /** \brief Initialize user defined functions. - - Calls the virtual functions InitFun(), InitConst() and InitOprt(). - */ - void ParserBase::Init() - { - InitCharSets(); - InitFun(); - InitConst(); - InitOprt(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined operator. - \post Will reset the Parser to string parsing mode. - \param [in] a_sName operator Identifier - \param [in] a_pFun Operator callback function - \param [in] a_iPrec Operator Precedence (default=prSIGN) - \param [in] a_bAllowOpt True if operator is volatile (default=false) - \sa EPrec - */ - void ParserBase::DefineInfixOprt(const string_type &a_sName, - fun_type1 a_pFun, - int a_iPrec, - bool a_bAllowOpt) - { - AddCallback(a_sName, - ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), - m_InfixOprtDef, - ValidInfixOprtChars() ); - } - - - //--------------------------------------------------------------------------- - /** \brief Define a binary operator. - \param [in] a_sName The identifier of the operator. - \param [in] a_pFun Pointer to the callback function. - \param [in] a_iPrec Precedence of the operator. - \param [in] a_eAssociativity The associativity of the operator. - \param [in] a_bAllowOpt If this is true the operator may be optimized away. - - Adds a new Binary operator the the parser instance. - */ - void ParserBase::DefineOprt( const string_type &a_sName, - fun_type2 a_pFun, - unsigned a_iPrec, - EOprtAssociativity a_eAssociativity, - bool a_bAllowOpt ) - { - // Check for conflicts with built in operator names - for (int i=0; m_bBuiltInOp && i<cmENDIF; ++i) - if (a_sName == string_type(c_DefaultOprt[i])) - Error(ecBUILTIN_OVERLOAD, -1, a_sName); - - AddCallback(a_sName, - ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, a_eAssociativity), - m_OprtDef, - ValidOprtChars() ); - } - - //--------------------------------------------------------------------------- - /** \brief Define a new string constant. - \param [in] a_strName The name of the constant. - \param [in] a_strVal the value of the constant. - */ - void ParserBase::DefineStrConst(const string_type &a_strName, const string_type &a_strVal) - { - // Test if a constant with that names already exists - if (m_StrVarDef.find(a_strName)!=m_StrVarDef.end()) - Error(ecNAME_CONFLICT); - - CheckName(a_strName, ValidNameChars()); - - m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer - m_StrVarDef[a_strName] = m_vStringVarBuf.size()-1; // bind buffer index to variable name - - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined variable. - \param [in] a_sName the variable name - \param [in] a_pVar A pointer to the variable value. - \post Will reset the Parser to string parsing mode. - \throw ParserException in case the name contains invalid signs or a_pVar is NULL. - */ - void ParserBase::DefineVar(const string_type &a_sName, value_type *a_pVar) - { - if (a_pVar==0) - Error(ecINVALID_VAR_PTR); - - // Test if a constant with that names already exists - if (m_ConstDef.find(a_sName)!=m_ConstDef.end()) - Error(ecNAME_CONFLICT); - - CheckName(a_sName, ValidNameChars()); - m_VarDef[a_sName] = a_pVar; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Add a user defined constant. - \param [in] a_sName The name of the constant. - \param [in] a_fVal the value of the constant. - \post Will reset the Parser to string parsing mode. - \throw ParserException in case the name contains invalid signs. - */ - void ParserBase::DefineConst(const string_type &a_sName, value_type a_fVal) - { - CheckName(a_sName, ValidNameChars()); - m_ConstDef[a_sName] = a_fVal; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Get operator priority. - \throw ParserException if a_Oprt is no operator code - */ - int ParserBase::GetOprtPrecedence(const token_type &a_Tok) const - { - switch (a_Tok.GetCode()) - { - // built in operators - case cmEND: return -5; - case cmARG_SEP: return -4; - case cmASSIGN: return -1; - case cmELSE: - case cmIF: return 0; - case cmLAND: return prLAND; - case cmLOR: return prLOR; - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: return prCMP; - case cmADD: - case cmSUB: return prADD_SUB; - case cmMUL: - case cmDIV: return prMUL_DIV; - case cmPOW: return prPOW; - - // user defined binary operators - case cmOPRT_INFIX: - case cmOPRT_BIN: return a_Tok.GetPri(); - default: Error(ecINTERNAL_ERROR, 5); - return 999; - } - } - - //--------------------------------------------------------------------------- - /** \brief Get operator priority. - \throw ParserException if a_Oprt is no operator code - */ - EOprtAssociativity ParserBase::GetOprtAssociativity(const token_type &a_Tok) const - { - switch (a_Tok.GetCode()) - { - case cmASSIGN: - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: return oaLEFT; - case cmPOW: return oaRIGHT; - case cmOPRT_BIN: return a_Tok.GetAssociativity(); - default: return oaNONE; - } - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing the used variables only. */ - const varmap_type& ParserBase::GetUsedVar() const - { - try - { - m_pTokenReader->IgnoreUndefVar(true); - CreateRPN(); // try to create bytecode, but don't use it for any further calculations since it - // may contain references to nonexisting variables. - m_pParseFormula = &ParserBase::ParseString; - m_pTokenReader->IgnoreUndefVar(false); - } - catch(exception_type & /*e*/) - { - // Make sure to stay in string parse mode, dont call ReInit() - // because it deletes the array with the used variables - m_pParseFormula = &ParserBase::ParseString; - m_pTokenReader->IgnoreUndefVar(false); - throw; - } - - return m_pTokenReader->GetUsedVar(); - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing the used variables only. */ - const varmap_type& ParserBase::GetVar() const - { - return m_VarDef; - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing all parser constants. */ - const valmap_type& ParserBase::GetConst() const - { - return m_ConstDef; - } - - //--------------------------------------------------------------------------- - /** \brief Return prototypes of all parser functions. - \return #m_FunDef - \sa FunProt - \throw nothrow - - The return type is a map of the public type #funmap_type containing the prototype - definitions for all numerical parser functions. String functions are not part of - this map. The Prototype definition is encapsulated in objects of the class FunProt - one per parser function each associated with function names via a map construct. - */ - const funmap_type& ParserBase::GetFunDef() const - { - return m_FunDef; - } - - //--------------------------------------------------------------------------- - /** \brief Retrieve the formula. */ - const string_type& ParserBase::GetExpr() const - { - return m_pTokenReader->GetExpr(); - } - - //--------------------------------------------------------------------------- - /** \brief Execute a function that takes a single string argument. - \param a_FunTok Function token. - \throw exception_type If the function token is not a string function - */ - ParserBase::token_type ParserBase::ApplyStrFunc(const token_type &a_FunTok, - const std::vector<token_type> &a_vArg) const - { - if (a_vArg.back().GetCode()!=cmSTRING) - Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); - - token_type valTok; - generic_fun_type pFunc = a_FunTok.GetFuncAddr(); - assert(pFunc); - - try - { - // Check function arguments; write dummy value into valtok to represent the result - switch(a_FunTok.GetArgCount()) - { - case 0: valTok.SetVal(1); a_vArg[0].GetAsString(); break; - case 1: valTok.SetVal(1); a_vArg[1].GetAsString(); a_vArg[0].GetVal(); break; - case 2: valTok.SetVal(1); a_vArg[2].GetAsString(); a_vArg[1].GetVal(); a_vArg[0].GetVal(); break; - default: Error(ecINTERNAL_ERROR); - } - } - catch(ParserError& ) - { - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); - } - - // string functions won't be optimized - m_vRPN.AddStrFun(pFunc, a_FunTok.GetArgCount(), a_vArg.back().GetIdx()); - - // Push dummy value representing the function result to the stack - return valTok; - } - - //--------------------------------------------------------------------------- - /** \brief Apply a function token. - \param iArgCount Number of Arguments actually gathered used only for multiarg functions. - \post The result is pushed to the value stack - \post The function token is removed from the stack - \throw exception_type if Argument count does not match function requirements. - */ - void ParserBase::ApplyFunc( ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal, - int a_iArgCount) const - { - assert(m_pTokenReader.get()); - - // Operator stack empty or does not contain tokens with callback functions - if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr()==0 ) - return; - - token_type funTok = a_stOpt.pop(); - assert(funTok.GetFuncAddr()); - - // Binary operators must rely on their internal operator number - // since counting of operators relies on commas for function arguments - // binary operators do not have commas in their expression - int iArgCount = (funTok.GetCode()==cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; - - // determine how many parameters the function needs. To remember iArgCount includes the - // string parameter whilst GetArgCount() counts only numeric parameters. - int iArgRequired = funTok.GetArgCount() + ((funTok.GetType()==tpSTR) ? 1 : 0); - - // Thats the number of numerical parameters - int iArgNumerical = iArgCount - ((funTok.GetType()==tpSTR) ? 1 : 0); - - if (funTok.GetCode()==cmFUNC_STR && iArgCount-iArgNumerical>1) - Error(ecINTERNAL_ERROR); - - if (funTok.GetArgCount()>=0 && iArgCount>iArgRequired) - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); - - if (funTok.GetCode()!=cmOPRT_BIN && iArgCount<iArgRequired ) - Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); - - if (funTok.GetCode()==cmFUNC_STR && iArgCount>iArgRequired ) - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); - - // Collect the numeric function arguments from the value stack and store them - // in a vector - std::vector<token_type> stArg; - for (int i=0; i<iArgNumerical; ++i) - { - stArg.push_back( a_stVal.pop() ); - if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); - } - - switch(funTok.GetCode()) - { - case cmFUNC_STR: - stArg.push_back(a_stVal.pop()); - - if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) - Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); - - ApplyStrFunc(funTok, stArg); - break; - - case cmFUNC_BULK: - m_vRPN.AddBulkFun(funTok.GetFuncAddr(), (int)stArg.size()); - break; - - case cmOPRT_BIN: - case cmOPRT_POSTFIX: - case cmOPRT_INFIX: - case cmFUNC: - if (funTok.GetArgCount()==-1 && iArgCount==0) - Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), funTok.GetAsString()); - - m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount()==-1) ? -iArgNumerical : iArgNumerical); - break; - } - - // Push dummy value representing the function result to the stack - token_type token; - token.SetVal(1); - a_stVal.push(token); - } - - //--------------------------------------------------------------------------- - void ParserBase::ApplyIfElse(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal) const - { - // Check if there is an if Else clause to be calculated - while (a_stOpt.size() && a_stOpt.top().GetCode()==cmELSE) - { - token_type opElse = a_stOpt.pop(); - MUP_ASSERT(a_stOpt.size()>0); - - // Take the value associated with the else branch from the value stack - token_type vVal2 = a_stVal.pop(); - - MUP_ASSERT(a_stOpt.size()>0); - MUP_ASSERT(a_stVal.size()>=2); - - // it then else is a ternary operator Pop all three values from the value s - // tack and just return the right value - token_type vVal1 = a_stVal.pop(); - token_type vExpr = a_stVal.pop(); - - a_stVal.push( (vExpr.GetVal()!=0) ? vVal1 : vVal2); - - token_type opIf = a_stOpt.pop(); - MUP_ASSERT(opElse.GetCode()==cmELSE); - MUP_ASSERT(opIf.GetCode()==cmIF); - - m_vRPN.AddIfElse(cmENDIF); - } // while pending if-else-clause found - } - - //--------------------------------------------------------------------------- - /** \brief Performs the necessary steps to write code for - the execution of binary operators into the bytecode. - */ - void ParserBase::ApplyBinOprt(ParserStack<token_type> &a_stOpt, - ParserStack<token_type> &a_stVal) const - { - // is it a user defined binary operator? - if (a_stOpt.top().GetCode()==cmOPRT_BIN) - { - ApplyFunc(a_stOpt, a_stVal, 2); - } - else - { - MUP_ASSERT(a_stVal.size()>=2); - token_type valTok1 = a_stVal.pop(), - valTok2 = a_stVal.pop(), - optTok = a_stOpt.pop(), - resTok; - - if ( valTok1.GetType()!=valTok2.GetType() || - (valTok1.GetType()==tpSTR && valTok2.GetType()==tpSTR) ) - Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); - - if (optTok.GetCode()==cmASSIGN) - { - if (valTok2.GetCode()!=cmVAR) - Error(ecUNEXPECTED_OPERATOR, -1, _T("=")); - - m_vRPN.AddAssignOp(valTok2.GetVar()); - } - else - m_vRPN.AddOp(optTok.GetCode()); - - resTok.SetVal(1); - a_stVal.push(resTok); - } - } - - //--------------------------------------------------------------------------- - /** \brief Apply a binary operator. - \param a_stOpt The operator stack - \param a_stVal The value stack - */ - void ParserBase::ApplyRemainingOprt(ParserStack<token_type> &stOpt, - ParserStack<token_type> &stVal) const - { - while (stOpt.size() && - stOpt.top().GetCode() != cmBO && - stOpt.top().GetCode() != cmIF) - { - token_type tok = stOpt.top(); - switch (tok.GetCode()) - { - case cmOPRT_INFIX: - case cmOPRT_BIN: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmLT: - case cmGT: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmLAND: - case cmLOR: - case cmASSIGN: - if (stOpt.top().GetCode()==cmOPRT_INFIX) - ApplyFunc(stOpt, stVal, 1); - else - ApplyBinOprt(stOpt, stVal); - break; - - case cmELSE: - ApplyIfElse(stOpt, stVal); - break; - - default: - Error(ecINTERNAL_ERROR); - } - } - } - - //--------------------------------------------------------------------------- - /** \brief Parse the command code. - \sa ParseString(...) - - Command code contains precalculated stack positions of the values and the - associated operators. The Stack is filled beginning from index one the - value at index zero is not used at all. - */ - value_type ParserBase::ParseCmdCode() const - { - return ParseCmdCodeBulk(0, 0); - } - - //--------------------------------------------------------------------------- - /** \brief Evaluate the RPN. - \param nOffset The offset added to variable addresses (for bulk mode) - \param nThreadID OpenMP Thread id of the calling thread - */ - value_type ParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const - { - assert(nThreadID<=s_MaxNumOpenMPThreads); - - // Note: The check for nOffset==0 and nThreadID here is not necessary but - // brings a minor performance gain when not in bulk mode. - value_type *Stack = ((nOffset==0) && (nThreadID==0)) ? &m_vStackBuffer[0] : &m_vStackBuffer[nThreadID * (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; - value_type buf; - int sidx(0); - for (const SToken *pTok = m_vRPN.GetBase(); pTok->Cmd!=cmEND ; ++pTok) - { - switch (pTok->Cmd) - { - // built in binary operators - case cmLE: --sidx; Stack[sidx] = Stack[sidx] <= Stack[sidx+1]; continue; - case cmGE: --sidx; Stack[sidx] = Stack[sidx] >= Stack[sidx+1]; continue; - case cmNEQ: --sidx; Stack[sidx] = Stack[sidx] != Stack[sidx+1]; continue; - case cmEQ: --sidx; Stack[sidx] = Stack[sidx] == Stack[sidx+1]; continue; - case cmLT: --sidx; Stack[sidx] = Stack[sidx] < Stack[sidx+1]; continue; - case cmGT: --sidx; Stack[sidx] = Stack[sidx] > Stack[sidx+1]; continue; - case cmADD: --sidx; Stack[sidx] += Stack[1+sidx]; continue; - case cmSUB: --sidx; Stack[sidx] -= Stack[1+sidx]; continue; - case cmMUL: --sidx; Stack[sidx] *= Stack[1+sidx]; continue; - case cmDIV: --sidx; - - #if defined(MUP_MATH_EXCEPTIONS) - if (Stack[1+sidx]==0) - Error(ecDIV_BY_ZERO); - #endif - Stack[sidx] /= Stack[1+sidx]; - continue; - - case cmPOW: - --sidx; Stack[sidx] = MathImpl<value_type>::Pow(Stack[sidx], Stack[1+sidx]); - continue; - - case cmLAND: --sidx; Stack[sidx] = Stack[sidx] && Stack[sidx+1]; continue; - case cmLOR: --sidx; Stack[sidx] = Stack[sidx] || Stack[sidx+1]; continue; - - case cmASSIGN: - // Bugfix for Bulkmode: - // for details see: - // https://groups.google.com/forum/embed/?place=forum/muparser-dev&showsearch=true&showpopout=true&showtabs=false&parenturl=http://muparser.beltoforion.de/mup_forum.html&afterlogin&pli=1#!topic/muparser-dev/szgatgoHTws - --sidx; Stack[sidx] = *(pTok->Oprt.ptr + nOffset) = Stack[sidx + 1]; continue; - // original code: - //--sidx; Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; continue; - - //case cmBO: // unused, listed for compiler optimization purposes - //case cmBC: - // MUP_FAIL(INVALID_CODE_IN_BYTECODE); - // continue; - - case cmIF: - if (Stack[sidx--]==0) - pTok += pTok->Oprt.offset; - continue; - - case cmELSE: - pTok += pTok->Oprt.offset; - continue; - - case cmENDIF: - continue; - - //case cmARG_SEP: - // MUP_FAIL(INVALID_CODE_IN_BYTECODE); - // continue; - - // value and variable tokens - case cmVAR: Stack[++sidx] = *(pTok->Val.ptr + nOffset); continue; - case cmVAL: Stack[++sidx] = pTok->Val.data2; continue; - - case cmVARPOW2: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf; - continue; - - case cmVARPOW3: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf*buf; - continue; - - case cmVARPOW4: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf*buf*buf; - continue; - - case cmVARMUL: Stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2; - continue; - - // Next is treatment of numeric functions - case cmFUNC: - { - int iArgCount = pTok->Fun.argc; - - // switch according to argument count - switch(iArgCount) - { - case 0: sidx += 1; Stack[sidx] = (*(fun_type0)pTok->Fun.ptr)(); continue; - case 1: Stack[sidx] = (*(fun_type1)pTok->Fun.ptr)(Stack[sidx]); continue; - case 2: sidx -= 1; Stack[sidx] = (*(fun_type2)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1]); continue; - case 3: sidx -= 2; Stack[sidx] = (*(fun_type3)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue; - case 4: sidx -= 3; Stack[sidx] = (*(fun_type4)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue; - case 5: sidx -= 4; Stack[sidx] = (*(fun_type5)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue; - case 6: sidx -= 5; Stack[sidx] = (*(fun_type6)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue; - case 7: sidx -= 6; Stack[sidx] = (*(fun_type7)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue; - case 8: sidx -= 7; Stack[sidx] = (*(fun_type8)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue; - case 9: sidx -= 8; Stack[sidx] = (*(fun_type9)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue; - case 10:sidx -= 9; Stack[sidx] = (*(fun_type10)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue; - default: - if (iArgCount>0) // function with variable arguments store the number as a negative value - Error(ecINTERNAL_ERROR, 1); - - sidx -= -iArgCount - 1; - Stack[sidx] =(*(multfun_type)pTok->Fun.ptr)(&Stack[sidx], -iArgCount); - continue; - } - } - - // Next is treatment of string functions - case cmFUNC_STR: - { - sidx -= pTok->Fun.argc -1; - - // The index of the string argument in the string table - int iIdxStack = pTok->Fun.idx; - MUP_ASSERT( iIdxStack>=0 && iIdxStack<(int)m_vStringBuf.size() ); - - switch(pTok->Fun.argc) // switch according to argument count - { - case 0: Stack[sidx] = (*(strfun_type1)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str()); continue; - case 1: Stack[sidx] = (*(strfun_type2)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx]); continue; - case 2: Stack[sidx] = (*(strfun_type3)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx], Stack[sidx+1]); continue; - } - - continue; - } - - case cmFUNC_BULK: - { - int iArgCount = pTok->Fun.argc; - - // switch according to argument count - switch(iArgCount) - { - case 0: sidx += 1; Stack[sidx] = (*(bulkfun_type0 )pTok->Fun.ptr)(nOffset, nThreadID); continue; - case 1: Stack[sidx] = (*(bulkfun_type1 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx]); continue; - case 2: sidx -= 1; Stack[sidx] = (*(bulkfun_type2 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1]); continue; - case 3: sidx -= 2; Stack[sidx] = (*(bulkfun_type3 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue; - case 4: sidx -= 3; Stack[sidx] = (*(bulkfun_type4 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue; - case 5: sidx -= 4; Stack[sidx] = (*(bulkfun_type5 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue; - case 6: sidx -= 5; Stack[sidx] = (*(bulkfun_type6 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue; - case 7: sidx -= 6; Stack[sidx] = (*(bulkfun_type7 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue; - case 8: sidx -= 7; Stack[sidx] = (*(bulkfun_type8 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue; - case 9: sidx -= 8; Stack[sidx] = (*(bulkfun_type9 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue; - case 10:sidx -= 9; Stack[sidx] = (*(bulkfun_type10)pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue; - default: - Error(ecINTERNAL_ERROR, 2); - continue; - } - } - - default: - Error(ecINTERNAL_ERROR, 3); - return 0; - } // switch CmdCode - } // for all bytecode tokens - - return Stack[m_nFinalResultIdx]; - } - - //--------------------------------------------------------------------------- - void ParserBase::CreateRPN() const - { - if (!m_pTokenReader->GetExpr().length()) - Error(ecUNEXPECTED_EOF, 0); - - ParserStack<token_type> stOpt, stVal; - ParserStack<int> stArgCount; - token_type opta, opt; // for storing operators - token_type val, tval; // for storing value - - ReInit(); - - // The outermost counter counts the number of separated items - // such as in "a=10,b=20,c=c+a" - stArgCount.push(1); - - for(;;) - { - opt = m_pTokenReader->ReadNextToken(); - - switch (opt.GetCode()) - { - // - // Next three are different kind of value entries - // - case cmSTRING: - opt.SetIdx((int)m_vStringBuf.size()); // Assign buffer index to token - stVal.push(opt); - m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer - break; - - case cmVAR: - stVal.push(opt); - m_vRPN.AddVar( static_cast<value_type*>(opt.GetVar()) ); - break; - - case cmVAL: - stVal.push(opt); - m_vRPN.AddVal( opt.GetVal() ); - break; - - case cmELSE: - m_nIfElseCounter--; - if (m_nIfElseCounter<0) - Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); - - ApplyRemainingOprt(stOpt, stVal); - m_vRPN.AddIfElse(cmELSE); - stOpt.push(opt); - break; - - - case cmARG_SEP: - if (stArgCount.empty()) - Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); - - ++stArgCount.top(); - // fallthrough intentional (no break!) - - case cmEND: - ApplyRemainingOprt(stOpt, stVal); - break; - - case cmBC: - { - // The argument count for parameterless functions is zero - // by default an opening bracket sets parameter count to 1 - // in preparation of arguments to come. If the last token - // was an opening bracket we know better... - if (opta.GetCode()==cmBO) - --stArgCount.top(); - - ApplyRemainingOprt(stOpt, stVal); - - // Check if the bracket content has been evaluated completely - if (stOpt.size() && stOpt.top().GetCode()==cmBO) - { - // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check - // if there is either a function or a sign pending - // neither the opening nor the closing bracket will be pushed back to - // the operator stack - // Check if a function is standing in front of the opening bracket, - // if yes evaluate it afterwards check for infix operators - assert(stArgCount.size()); - int iArgCount = stArgCount.pop(); - - stOpt.pop(); // Take opening bracket from stack - - if (iArgCount>1 && ( stOpt.size()==0 || - (stOpt.top().GetCode()!=cmFUNC && - stOpt.top().GetCode()!=cmFUNC_BULK && - stOpt.top().GetCode()!=cmFUNC_STR) ) ) - Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); - - // The opening bracket was popped from the stack now check if there - // was a function before this bracket - if (stOpt.size() && - stOpt.top().GetCode()!=cmOPRT_INFIX && - stOpt.top().GetCode()!=cmOPRT_BIN && - stOpt.top().GetFuncAddr()!=0) - { - ApplyFunc(stOpt, stVal, iArgCount); - } - } - } // if bracket content is evaluated - break; - - // - // Next are the binary operator entries - // - //case cmAND: // built in binary operators - //case cmOR: - //case cmXOR: - case cmIF: - m_nIfElseCounter++; - // fallthrough intentional (no break!) - - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmASSIGN: - case cmOPRT_BIN: - - // A binary operator (user defined or built in) has been found. - while ( stOpt.size() && - stOpt.top().GetCode() != cmBO && - stOpt.top().GetCode() != cmELSE && - stOpt.top().GetCode() != cmIF) - { - int nPrec1 = GetOprtPrecedence(stOpt.top()), - nPrec2 = GetOprtPrecedence(opt); - - if (stOpt.top().GetCode()==opt.GetCode()) - { - - // Deal with operator associativity - EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); - if ( (eOprtAsct==oaRIGHT && (nPrec1 <= nPrec2)) || - (eOprtAsct==oaLEFT && (nPrec1 < nPrec2)) ) - { - break; - } - } - else if (nPrec1 < nPrec2) - { - // In case the operators are not equal the precedence decides alone... - break; - } - - if (stOpt.top().GetCode()==cmOPRT_INFIX) - ApplyFunc(stOpt, stVal, 1); - else - ApplyBinOprt(stOpt, stVal); - } // while ( ... ) - - if (opt.GetCode()==cmIF) - m_vRPN.AddIfElse(opt.GetCode()); - - // The operator can't be evaluated right now, push back to the operator stack - stOpt.push(opt); - break; - - // - // Last section contains functions and operators implicitly mapped to functions - // - case cmBO: - stArgCount.push(1); - stOpt.push(opt); - break; - - case cmOPRT_INFIX: - case cmFUNC: - case cmFUNC_BULK: - case cmFUNC_STR: - stOpt.push(opt); - break; - - case cmOPRT_POSTFIX: - stOpt.push(opt); - ApplyFunc(stOpt, stVal, 1); // this is the postfix operator - break; - - default: Error(ecINTERNAL_ERROR, 3); - } // end of switch operator-token - - opta = opt; - - if ( opt.GetCode() == cmEND ) - { - m_vRPN.Finalize(); - break; - } - - if (ParserBase::g_DbgDumpStack) - { - StackDump(stVal, stOpt); - m_vRPN.AsciiDump(); - } - } // while (true) - - if (ParserBase::g_DbgDumpCmdCode) - m_vRPN.AsciiDump(); - - if (m_nIfElseCounter>0) - Error(ecMISSING_ELSE_CLAUSE); - - // get the last value (= final result) from the stack - MUP_ASSERT(stArgCount.size()==1); - m_nFinalResultIdx = stArgCount.top(); - if (m_nFinalResultIdx==0) - Error(ecINTERNAL_ERROR, 9); - - if (stVal.size()==0) - Error(ecEMPTY_EXPRESSION); - - if (stVal.top().GetType()!=tpDBL) - Error(ecSTR_RESULT); - - m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads); - } - - //--------------------------------------------------------------------------- - /** \brief One of the two main parse functions. - \sa ParseCmdCode(...) - - Parse expression from input string. Perform syntax checking and create - bytecode. After parsing the string and creating the bytecode the function - pointer #m_pParseFormula will be changed to the second parse routine the - uses bytecode instead of string parsing. - */ - value_type ParserBase::ParseString() const - { - try - { - CreateRPN(); - m_pParseFormula = &ParserBase::ParseCmdCode; - return (this->*m_pParseFormula)(); - } - catch(ParserError &exc) - { - exc.SetFormula(m_pTokenReader->GetExpr()); - throw; - } - } - - //--------------------------------------------------------------------------- - /** \brief Create an error containing the parse error position. - - This function will create an Parser Exception object containing the error text and - its position. - - \param a_iErrc [in] The error code of type #EErrorCodes. - \param a_iPos [in] The position where the error was detected. - \param a_strTok [in] The token string representation associated with the error. - \throw ParserException always throws thats the only purpose of this function. - */ - void ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type &a_sTok) const - { - throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined variables. - \throw nothrow - - Resets the parser to string parsing mode by calling #ReInit. - */ - void ParserBase::ClearVar() - { - m_VarDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Remove a variable from internal storage. - \throw nothrow - - Removes a variable if it exists. If the Variable does not exist nothing will be done. - */ - void ParserBase::RemoveVar(const string_type &a_strVarName) - { - varmap_type::iterator item = m_VarDef.find(a_strVarName); - if (item!=m_VarDef.end()) - { - m_VarDef.erase(item); - ReInit(); - } - } - - //------------------------------------------------------------------------------ - /** \brief Clear all functions. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearFun() - { - m_FunDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined constants. - - Both numeric and string constants will be removed from the internal storage. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearConst() - { - m_ConstDef.clear(); - m_StrVarDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined postfix operators. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearPostfixOprt() - { - m_PostOprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear all user defined binary operators. - \post Resets the parser to string parsing mode. - \throw nothrow - */ - void ParserBase::ClearOprt() - { - m_OprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Clear the user defined Prefix operators. - \post Resets the parser to string parser mode. - \throw nothrow - */ - void ParserBase::ClearInfixOprt() - { - m_InfixOprtDef.clear(); - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Enable or disable the formula optimization feature. - \post Resets the parser to string parser mode. - \throw nothrow - */ - void ParserBase::EnableOptimizer(bool a_bIsOn) - { - m_vRPN.EnableOptimizer(a_bIsOn); - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Enable the dumping of bytecode and stack content on the console. - \param bDumpCmd Flag to enable dumping of the current bytecode to the console. - \param bDumpStack Flag to enable dumping of the stack content is written to the console. - - This function is for debug purposes only! - */ - void ParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack) - { - ParserBase::g_DbgDumpCmdCode = bDumpCmd; - ParserBase::g_DbgDumpStack = bDumpStack; - } - - //------------------------------------------------------------------------------ - /** \brief Enable or disable the built in binary operators. - \throw nothrow - \sa m_bBuiltInOp, ReInit() - - If you disable the built in binary operators there will be no binary operators - defined. Thus you must add them manually one by one. It is not possible to - disable built in operators selectively. This function will Reinitialize the - parser by calling ReInit(). - */ - void ParserBase::EnableBuiltInOprt(bool a_bIsOn) - { - m_bBuiltInOp = a_bIsOn; - ReInit(); - } - - //------------------------------------------------------------------------------ - /** \brief Query status of built in variables. - \return #m_bBuiltInOp; true if built in operators are enabled. - \throw nothrow - */ - bool ParserBase::HasBuiltInOprt() const - { - return m_bBuiltInOp; - } - - //------------------------------------------------------------------------------ - /** \brief Get the argument separator character. - */ - char_type ParserBase::GetArgSep() const - { - return m_pTokenReader->GetArgSep(); - } - - //------------------------------------------------------------------------------ - /** \brief Set argument separator. - \param cArgSep the argument separator character. - */ - void ParserBase::SetArgSep(char_type cArgSep) - { - m_pTokenReader->SetArgSep(cArgSep); - } - - //------------------------------------------------------------------------------ - /** \brief Dump stack content. - - This function is used for debugging only. - */ - void ParserBase::StackDump(const ParserStack<token_type> &a_stVal, - const ParserStack<token_type> &a_stOprt) const - { - ParserStack<token_type> stOprt(a_stOprt), - stVal(a_stVal); - - mu::console() << _T("\nValue stack:\n"); - while ( !stVal.empty() ) - { - token_type val = stVal.pop(); - if (val.GetType()==tpSTR) - mu::console() << _T(" \"") << val.GetAsString() << _T("\" "); - else - mu::console() << _T(" ") << val.GetVal() << _T(" "); - } - mu::console() << "\nOperator stack:\n"; - - while ( !stOprt.empty() ) - { - if (stOprt.top().GetCode()<=cmASSIGN) - { - mu::console() << _T("OPRT_INTRNL \"") - << ParserBase::c_DefaultOprt[stOprt.top().GetCode()] - << _T("\" \n"); - } - else - { - switch(stOprt.top().GetCode()) - { - case cmVAR: mu::console() << _T("VAR\n"); break; - case cmVAL: mu::console() << _T("VAL\n"); break; - case cmFUNC: mu::console() << _T("FUNC \"") - << stOprt.top().GetAsString() - << _T("\"\n"); break; - case cmFUNC_BULK: mu::console() << _T("FUNC_BULK \"") - << stOprt.top().GetAsString() - << _T("\"\n"); break; - case cmOPRT_INFIX: mu::console() << _T("OPRT_INFIX \"") - << stOprt.top().GetAsString() - << _T("\"\n"); break; - case cmOPRT_BIN: mu::console() << _T("OPRT_BIN \"") - << stOprt.top().GetAsString() - << _T("\"\n"); break; - case cmFUNC_STR: mu::console() << _T("FUNC_STR\n"); break; - case cmEND: mu::console() << _T("END\n"); break; - case cmUNKNOWN: mu::console() << _T("UNKNOWN\n"); break; - case cmBO: mu::console() << _T("BRACKET \"(\"\n"); break; - case cmBC: mu::console() << _T("BRACKET \")\"\n"); break; - case cmIF: mu::console() << _T("IF\n"); break; - case cmELSE: mu::console() << _T("ELSE\n"); break; - case cmENDIF: mu::console() << _T("ENDIF\n"); break; - default: mu::console() << stOprt.top().GetCode() << _T(" "); break; - } - } - stOprt.pop(); - } - - mu::console() << dec << endl; - } - - //------------------------------------------------------------------------------ - /** \brief Evaluate an expression containing comma separated subexpressions - \param [out] nStackSize The total number of results available - \return Pointer to the array containing all expression results - - This member function can be used to retrieve all results of an expression - made up of multiple comma separated subexpressions (i.e. "x+y,sin(x),cos(y)") - */ - value_type* ParserBase::Eval(int &nStackSize) const - { - (this->*m_pParseFormula)(); - nStackSize = m_nFinalResultIdx; - - // (for historic reasons the stack starts at position 1) - return &m_vStackBuffer[1]; - } - - //--------------------------------------------------------------------------- - /** \brief Return the number of results on the calculation stack. - - If the expression contains comma separated subexpressions (i.e. "sin(y), x+y"). - There may be more than one return value. This function returns the number of - available results. - */ - int ParserBase::GetNumResults() const - { - return m_nFinalResultIdx; - } - - //--------------------------------------------------------------------------- - /** \brief Calculate the result. - - A note on const correctness: - I consider it important that Calc is a const function. - Due to caching operations Calc changes only the state of internal variables with one exception - m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making - Calc non const GetUsedVar is non const because it explicitly calls Eval() forcing this update. - - \pre A formula must be set. - \pre Variables must have been set (if needed) - - \sa #m_pParseFormula - \return The evaluation result - \throw ParseException if no Formula is set or in case of any other error related to the formula. - */ - value_type ParserBase::Eval() const - { - return (this->*m_pParseFormula)(); - } - - //--------------------------------------------------------------------------- - void ParserBase::Eval(value_type *results, int nBulkSize) - { -/* <ibg 2014-09-24/> Commented because it is making a unit test impossible - - // Parallelization does not make sense for fewer than 10000 computations - // due to thread creation overhead. If the bulk size is below 2000 - // computation is refused. - if (nBulkSize<2000) - { - throw ParserError(ecUNREASONABLE_NUMBER_OF_COMPUTATIONS); - } -*/ - CreateRPN(); - - int i = 0; - -#ifdef MUP_USE_OPENMP -//#define DEBUG_OMP_STUFF - #ifdef DEBUG_OMP_STUFF - int *pThread = new int[nBulkSize]; - int *pIdx = new int[nBulkSize]; - #endif - - int nMaxThreads = std::min(omp_get_max_threads(), s_MaxNumOpenMPThreads); - int nThreadID = 0, ct = 0; - omp_set_num_threads(nMaxThreads); - - #pragma omp parallel for schedule(static, nBulkSize/nMaxThreads) private(nThreadID) - for (i=0; i<nBulkSize; ++i) - { - nThreadID = omp_get_thread_num(); - results[i] = ParseCmdCodeBulk(i, nThreadID); - - #ifdef DEBUG_OMP_STUFF - #pragma omp critical - { - pThread[ct] = nThreadID; - pIdx[ct] = i; - ct++; - } - #endif - } - -#ifdef DEBUG_OMP_STUFF - FILE *pFile = fopen("bulk_dbg.txt", "w"); - for (i=0; i<nBulkSize; ++i) - { - fprintf(pFile, "idx: %d thread: %d \n", pIdx[i], pThread[i]); - } - - delete [] pIdx; - delete [] pThread; - - fclose(pFile); -#endif - -#else - for (i=0; i<nBulkSize; ++i) - { - results[i] = ParseCmdCodeBulk(i, 0); - } -#endif - - } -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserBytecode.cpp b/ThirdParty/MuParser/src/muParserBytecode.cpp deleted file mode 100644 index 3964998fdd27fa6a4484b3900b16e589298dfa54..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserBytecode.cpp +++ /dev/null @@ -1,588 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "muParserBytecode.h" - -#include <algorithm> -#include <cassert> -#include <string> -#include <stack> -#include <vector> -#include <iostream> - -#include "muParserDef.h" -#include "muParserError.h" -#include "muParserToken.h" -#include "muParserStack.h" -#include "muParserTemplateMagic.h" - - -namespace mu -{ - //--------------------------------------------------------------------------- - /** \brief Bytecode default constructor. */ - ParserByteCode::ParserByteCode() - :m_iStackPos(0) - ,m_iMaxStackSize(0) - ,m_vRPN() - ,m_bEnableOptimizer(true) - { - m_vRPN.reserve(50); - } - - //--------------------------------------------------------------------------- - /** \brief Copy constructor. - - Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) - */ - ParserByteCode::ParserByteCode(const ParserByteCode &a_ByteCode) - { - Assign(a_ByteCode); - } - - //--------------------------------------------------------------------------- - /** \brief Assignment operator. - - Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) - */ - ParserByteCode& ParserByteCode::operator=(const ParserByteCode &a_ByteCode) - { - Assign(a_ByteCode); - return *this; - } - - //--------------------------------------------------------------------------- - void ParserByteCode::EnableOptimizer(bool bStat) - { - m_bEnableOptimizer = bStat; - } - - //--------------------------------------------------------------------------- - /** \brief Copy state of another object to this. - - \throw nowthrow - */ - void ParserByteCode::Assign(const ParserByteCode &a_ByteCode) - { - if (this==&a_ByteCode) - return; - - m_iStackPos = a_ByteCode.m_iStackPos; - m_vRPN = a_ByteCode.m_vRPN; - m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; - m_bEnableOptimizer = a_ByteCode.m_bEnableOptimizer; - } - - //--------------------------------------------------------------------------- - /** \brief Add a Variable pointer to bytecode. - \param a_pVar Pointer to be added. - \throw nothrow - */ - void ParserByteCode::AddVar(value_type *a_pVar) - { - ++m_iStackPos; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - // optimization does not apply - SToken tok; - tok.Cmd = cmVAR; - tok.Val.ptr = a_pVar; - tok.Val.data = 1; - tok.Val.data2 = 0; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - /** \brief Add a Variable pointer to bytecode. - - Value entries in byte code consist of: - <ul> - <li>value array position of the value</li> - <li>the operator code according to ParserToken::cmVAL</li> - <li>the value stored in #mc_iSizeVal number of bytecode entries.</li> - </ul> - - \param a_pVal Value to be added. - \throw nothrow - */ - void ParserByteCode::AddVal(value_type a_fVal) - { - ++m_iStackPos; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - // If optimization does not apply - SToken tok; - tok.Cmd = cmVAL; - tok.Val.ptr = NULL; - tok.Val.data = 0; - tok.Val.data2 = a_fVal; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - void ParserByteCode::ConstantFolding(ECmdCode a_Oprt) - { - std::size_t sz = m_vRPN.size(); - value_type &x = m_vRPN[sz-2].Val.data2, - &y = m_vRPN[sz-1].Val.data2; - switch (a_Oprt) - { - case cmLAND: x = (int)x && (int)y; m_vRPN.pop_back(); break; - case cmLOR: x = (int)x || (int)y; m_vRPN.pop_back(); break; - case cmLT: x = x < y; m_vRPN.pop_back(); break; - case cmGT: x = x > y; m_vRPN.pop_back(); break; - case cmLE: x = x <= y; m_vRPN.pop_back(); break; - case cmGE: x = x >= y; m_vRPN.pop_back(); break; - case cmNEQ: x = x != y; m_vRPN.pop_back(); break; - case cmEQ: x = x == y; m_vRPN.pop_back(); break; - case cmADD: x = x + y; m_vRPN.pop_back(); break; - case cmSUB: x = x - y; m_vRPN.pop_back(); break; - case cmMUL: x = x * y; m_vRPN.pop_back(); break; - case cmDIV: - -#if defined(MUP_MATH_EXCEPTIONS) - if (y==0) - throw ParserError(ecDIV_BY_ZERO, _T("0")); -#endif - - x = x / y; - m_vRPN.pop_back(); - break; - - case cmPOW: x = MathImpl<value_type>::Pow(x, y); - m_vRPN.pop_back(); - break; - - default: - break; - } // switch opcode - } - - //--------------------------------------------------------------------------- - /** \brief Add an operator identifier to bytecode. - - Operator entries in byte code consist of: - <ul> - <li>value array position of the result</li> - <li>the operator code according to ParserToken::ECmdCode</li> - </ul> - - \sa ParserToken::ECmdCode - */ - void ParserByteCode::AddOp(ECmdCode a_Oprt) - { - bool bOptimized = false; - - if (m_bEnableOptimizer) - { - std::size_t sz = m_vRPN.size(); - - // Check for foldable constants like: - // cmVAL cmVAL cmADD - // where cmADD can stand fopr any binary operator applied to - // two constant values. - if (sz>=2 && m_vRPN[sz-2].Cmd == cmVAL && m_vRPN[sz-1].Cmd == cmVAL) - { - ConstantFolding(a_Oprt); - bOptimized = true; - } - else - { - switch(a_Oprt) - { - case cmPOW: - // Optimization for polynomials of low order - if (m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-1].Cmd == cmVAL) - { - if (m_vRPN[sz-1].Val.data2==2) - m_vRPN[sz-2].Cmd = cmVARPOW2; - else if (m_vRPN[sz-1].Val.data2==3) - m_vRPN[sz-2].Cmd = cmVARPOW3; - else if (m_vRPN[sz-1].Val.data2==4) - m_vRPN[sz-2].Cmd = cmVARPOW4; - else - break; - - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmSUB: - case cmADD: - // Simple optimization based on pattern recognition for a shitload of different - // bytecode combinations of addition/subtraction - if ( (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAL) || - (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) || - (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL) || - (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAL) || - (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || - (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || - (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || - (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ) - { - assert( (m_vRPN[sz-2].Val.ptr==NULL && m_vRPN[sz-1].Val.ptr!=NULL) || - (m_vRPN[sz-2].Val.ptr!=NULL && m_vRPN[sz-1].Val.ptr==NULL) || - (m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ); - - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr)); // variable - m_vRPN[sz-2].Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data2; // offset - m_vRPN[sz-2].Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data; // multiplicand - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmMUL: - if ( (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAL) || - (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) ) - { - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr)); - m_vRPN[sz-2].Val.data = m_vRPN[sz-2].Val.data2 + m_vRPN[sz-1].Val.data2; - m_vRPN[sz-2].Val.data2 = 0; - m_vRPN.pop_back(); - bOptimized = true; - } - else if ( (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL) || - (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAL) ) - { - // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr)); - if (m_vRPN[sz-1].Cmd == cmVAL) - { - m_vRPN[sz-2].Val.data *= m_vRPN[sz-1].Val.data2; - m_vRPN[sz-2].Val.data2 *= m_vRPN[sz-1].Val.data2; - } - else - { - m_vRPN[sz-2].Val.data = m_vRPN[sz-1].Val.data * m_vRPN[sz-2].Val.data2; - m_vRPN[sz-2].Val.data2 = m_vRPN[sz-1].Val.data2 * m_vRPN[sz-2].Val.data2; - } - m_vRPN.pop_back(); - bOptimized = true; - } - else if (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && - m_vRPN[sz-1].Val.ptr == m_vRPN[sz-2].Val.ptr) - { - // Optimization: a*a -> a^2 - m_vRPN[sz-2].Cmd = cmVARPOW2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - case cmDIV: - if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-1].Val.data2!=0) - { - // Optimization: 4*a/2 -> 2*a - m_vRPN[sz-2].Val.data /= m_vRPN[sz-1].Val.data2; - m_vRPN[sz-2].Val.data2 /= m_vRPN[sz-1].Val.data2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - - } // switch a_Oprt - } - } - - // If optimization can't be applied just write the value - if (!bOptimized) - { - --m_iStackPos; - SToken tok; - tok.Cmd = a_Oprt; - m_vRPN.push_back(tok); - } - } - - //--------------------------------------------------------------------------- - void ParserByteCode::AddIfElse(ECmdCode a_Oprt) - { - SToken tok; - tok.Cmd = a_Oprt; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - /** \brief Add an assignment operator - - Operator entries in byte code consist of: - <ul> - <li>cmASSIGN code</li> - <li>the pointer of the destination variable</li> - </ul> - - \sa ParserToken::ECmdCode - */ - void ParserByteCode::AddAssignOp(value_type *a_pVar) - { - --m_iStackPos; - - SToken tok; - tok.Cmd = cmASSIGN; - tok.Oprt.ptr = a_pVar; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - /** \brief Add function to bytecode. - - \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. - \param a_pFun Pointer to function callback. - */ - void ParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) - { - if (a_iArgc>=0) - { - m_iStackPos = m_iStackPos - a_iArgc + 1; - } - else - { - // function with unlimited number of arguments - m_iStackPos = m_iStackPos + a_iArgc + 1; - } - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - SToken tok; - tok.Cmd = cmFUNC; - tok.Fun.argc = a_iArgc; - tok.Fun.ptr = a_pFun; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - /** \brief Add a bulk function to bytecode. - - \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. - \param a_pFun Pointer to function callback. - */ - void ParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) - { - m_iStackPos = m_iStackPos - a_iArgc + 1; - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - - SToken tok; - tok.Cmd = cmFUNC_BULK; - tok.Fun.argc = a_iArgc; - tok.Fun.ptr = a_pFun; - m_vRPN.push_back(tok); - } - - //--------------------------------------------------------------------------- - /** \brief Add Strung function entry to the parser bytecode. - \throw nothrow - - A string function entry consists of the stack position of the return value, - followed by a cmSTRFUNC code, the function pointer and an index into the - string buffer maintained by the parser. - */ - void ParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx) - { - m_iStackPos = m_iStackPos - a_iArgc + 1; - - SToken tok; - tok.Cmd = cmFUNC_STR; - tok.Fun.argc = a_iArgc; - tok.Fun.idx = a_iIdx; - tok.Fun.ptr = a_pFun; - m_vRPN.push_back(tok); - - m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); - } - - //--------------------------------------------------------------------------- - /** \brief Add end marker to bytecode. - - \throw nothrow - */ - void ParserByteCode::Finalize() - { - SToken tok; - tok.Cmd = cmEND; - m_vRPN.push_back(tok); - rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit - - // Determine the if-then-else jump offsets - ParserStack<int> stIf, stElse; - int idx; - for (int i=0; i<(int)m_vRPN.size(); ++i) - { - switch(m_vRPN[i].Cmd) - { - case cmIF: - stIf.push(i); - break; - - case cmELSE: - stElse.push(i); - idx = stIf.pop(); - m_vRPN[idx].Oprt.offset = i - idx; - break; - - case cmENDIF: - idx = stElse.pop(); - m_vRPN[idx].Oprt.offset = i - idx; - break; - - default: - break; - } - } - } - - //--------------------------------------------------------------------------- - const SToken* ParserByteCode::GetBase() const - { - if (m_vRPN.size()==0) - throw ParserError(ecINTERNAL_ERROR); - else - return &m_vRPN[0]; - } - - //--------------------------------------------------------------------------- - std::size_t ParserByteCode::GetMaxStackSize() const - { - return m_iMaxStackSize+1; - } - - //--------------------------------------------------------------------------- - /** \brief Returns the number of entries in the bytecode. */ - std::size_t ParserByteCode::GetSize() const - { - return m_vRPN.size(); - } - - //--------------------------------------------------------------------------- - /** \brief Delete the bytecode. - - \throw nothrow - - The name of this function is a violation of my own coding guidelines - but this way it's more in line with the STL functions thus more - intuitive. - */ - void ParserByteCode::clear() - { - m_vRPN.clear(); - m_iStackPos = 0; - m_iMaxStackSize = 0; - } - - //--------------------------------------------------------------------------- - /** \brief Dump bytecode (for debugging only!). */ - void ParserByteCode::AsciiDump() - { - if (!m_vRPN.size()) - { - mu::console() << _T("No bytecode available\n"); - return; - } - - mu::console() << _T("Number of RPN tokens:") << (int)m_vRPN.size() << _T("\n"); - for (std::size_t i=0; i<m_vRPN.size() && m_vRPN[i].Cmd!=cmEND; ++i) - { - mu::console() << std::dec << i << _T(" : \t"); - switch (m_vRPN[i].Cmd) - { - case cmVAL: mu::console() << _T("VAL \t"); - mu::console() << _T("[") << m_vRPN[i].Val.data2 << _T("]\n"); - break; - - case cmVAR: mu::console() << _T("VAR \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW2: mu::console() << _T("VARPOW2 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW3: mu::console() << _T("VARPOW3 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARPOW4: mu::console() << _T("VARPOW4 \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); - break; - - case cmVARMUL: mu::console() << _T("VARMUL \t"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]"); - mu::console() << _T(" * [") << m_vRPN[i].Val.data << _T("]"); - mu::console() << _T(" + [") << m_vRPN[i].Val.data2 << _T("]\n"); - break; - - case cmFUNC: mu::console() << _T("CALL\t"); - mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); - mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Fun.ptr << _T("]"); - mu::console() << _T("\n"); - break; - - case cmFUNC_STR: - mu::console() << _T("CALL STRFUNC\t"); - mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); - mu::console() << _T("[IDX:") << std::dec << m_vRPN[i].Fun.idx << _T("]"); - mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Fun.ptr << _T("]\n"); - break; - - case cmLT: mu::console() << _T("LT\n"); break; - case cmGT: mu::console() << _T("GT\n"); break; - case cmLE: mu::console() << _T("LE\n"); break; - case cmGE: mu::console() << _T("GE\n"); break; - case cmEQ: mu::console() << _T("EQ\n"); break; - case cmNEQ: mu::console() << _T("NEQ\n"); break; - case cmADD: mu::console() << _T("ADD\n"); break; - case cmLAND: mu::console() << _T("&&\n"); break; - case cmLOR: mu::console() << _T("||\n"); break; - case cmSUB: mu::console() << _T("SUB\n"); break; - case cmMUL: mu::console() << _T("MUL\n"); break; - case cmDIV: mu::console() << _T("DIV\n"); break; - case cmPOW: mu::console() << _T("POW\n"); break; - - case cmIF: mu::console() << _T("IF\t"); - mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); - break; - - case cmELSE: mu::console() << _T("ELSE\t"); - mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n"); - break; - - case cmENDIF: mu::console() << _T("ENDIF\n"); break; - - case cmASSIGN: - mu::console() << _T("ASSIGN\t"); - mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Oprt.ptr << _T("]\n"); - break; - - default: mu::console() << _T("(unknown code: ") << m_vRPN[i].Cmd << _T(")\n"); - break; - } // switch cmdCode - } // while bytecode - - mu::console() << _T("END") << std::endl; - } -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserCallback.cpp b/ThirdParty/MuParser/src/muParserCallback.cpp deleted file mode 100644 index 2044fe1c38a543bd3513b6fc24789754a9a45227..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserCallback.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "muParserCallback.h" - -/** \file - \brief Implementation of the parser callback class. -*/ - - -namespace mu -{ - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(0) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode) - :m_pFun((void*)a_pFun) - ,m_iArgc(1) - ,m_iPri(a_iPrec) - ,m_eOprtAsct(oaNONE) - ,m_iCode(a_iCode) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - /** \brief Constructor for constructing function callbacks taking two arguments. - \throw nothrow - */ - ParserCallback::ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(2) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - /** \brief Constructor for constructing binary operator callbacks. - \param a_pFun Pointer to a static function taking two arguments - \param a_bAllowOpti A flag indicating this function can be optimized - \param a_iPrec The operator precedence - \param a_eOprtAsct The operators associativity - \throw nothrow - */ - ParserCallback::ParserCallback(fun_type2 a_pFun, - bool a_bAllowOpti, - int a_iPrec, - EOprtAssociativity a_eOprtAsct) - :m_pFun((void*)a_pFun) - ,m_iArgc(2) - ,m_iPri(a_iPrec) - ,m_eOprtAsct(a_eOprtAsct) - ,m_iCode(cmOPRT_BIN) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(3) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(4) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(5) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(6) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(7) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(8) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(9) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(10) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(0) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(1) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - /** \brief Constructor for constructing function callbacks taking two arguments. - \throw nothrow - */ - ParserCallback::ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(2) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(3) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(4) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(5) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(6) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(7) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(8) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(9) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(10) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_BULK) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(multfun_type a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(-1) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC) - ,m_iType(tpDBL) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(0) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_STR) - ,m_iType(tpSTR) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(1) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_STR) - ,m_iType(tpSTR) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - ParserCallback::ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti) - :m_pFun((void*)a_pFun) - ,m_iArgc(2) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmFUNC_STR) - ,m_iType(tpSTR) - ,m_bAllowOpti(a_bAllowOpti) - {} - - - //--------------------------------------------------------------------------- - /** \brief Default constructor. - \throw nothrow - */ - ParserCallback::ParserCallback() - :m_pFun(0) - ,m_iArgc(0) - ,m_iPri(-1) - ,m_eOprtAsct(oaNONE) - ,m_iCode(cmUNKNOWN) - ,m_iType(tpVOID) - ,m_bAllowOpti(0) - {} - - - //--------------------------------------------------------------------------- - /** \brief Copy constructor. - \throw nothrow - */ - ParserCallback::ParserCallback(const ParserCallback &ref) - { - m_pFun = ref.m_pFun; - m_iArgc = ref.m_iArgc; - m_bAllowOpti = ref.m_bAllowOpti; - m_iCode = ref.m_iCode; - m_iType = ref.m_iType; - m_iPri = ref.m_iPri; - m_eOprtAsct = ref.m_eOprtAsct; - } - - //--------------------------------------------------------------------------- - /** \brief Clone this instance and return a pointer to the new instance. */ - ParserCallback* ParserCallback::Clone() const - { - return new ParserCallback(*this); - } - - //--------------------------------------------------------------------------- - /** \brief Return tru if the function is conservative. - - Conservative functions return always the same result for the same argument. - \throw nothrow - */ - bool ParserCallback::IsOptimizable() const - { - return m_bAllowOpti; - } - - //--------------------------------------------------------------------------- - /** \brief Get the callback address for the parser function. - - The type of the address is void. It needs to be recasted according to the - argument number to the right type. - - \throw nothrow - \return #pFun - */ - void* ParserCallback::GetAddr() const - { - return m_pFun; - } - - //--------------------------------------------------------------------------- - /** \brief Return the callback code. */ - ECmdCode ParserCallback::GetCode() const - { - return m_iCode; - } - - //--------------------------------------------------------------------------- - ETypeCode ParserCallback::GetType() const - { - return m_iType; - } - - - //--------------------------------------------------------------------------- - /** \brief Return the operator precedence. - \throw nothrown - - Only valid if the callback token is an operator token (binary or infix). - */ - int ParserCallback::GetPri() const - { - return m_iPri; - } - - //--------------------------------------------------------------------------- - /** \brief Return the operators associativity. - \throw nothrown - - Only valid if the callback token is a binary operator token. - */ - EOprtAssociativity ParserCallback::GetAssociativity() const - { - return m_eOprtAsct; - } - - //--------------------------------------------------------------------------- - /** \brief Returns the number of function Arguments. */ - int ParserCallback::GetArgc() const - { - return m_iArgc; - } -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserDLL.cpp b/ThirdParty/MuParser/src/muParserDLL.cpp deleted file mode 100644 index 15c88003cb907ad54740145190a48c53776bbbac..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserDLL.cpp +++ /dev/null @@ -1,1096 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2004-2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#if defined(MUPARSER_DLL) - -#if defined(_WIN32) -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - -#include "muParserDLL.h" -#include "muParser.h" -#include "muParserInt.h" -#include "muParserError.h" - - -#define MU_TRY \ - try \ - { - -#define MU_CATCH \ - } \ - catch (muError_t &e) \ - { \ - ParserTag *pTag = static_cast<ParserTag*>(a_hParser); \ - pTag->exc = e; \ - pTag->bError = true; \ -if (pTag->errHandler) \ - (pTag->errHandler)(a_hParser); \ - } \ - catch (...) \ - { \ - ParserTag *pTag = static_cast<ParserTag*>(a_hParser); \ - pTag->exc = muError_t(mu::ecINTERNAL_ERROR); \ - pTag->bError = true; \ -if (pTag->errHandler) \ - (pTag->errHandler)(a_hParser); \ - } - -/** \file - \brief This file contains the implementation of the DLL interface of muparser. - */ - -//--------------------------------------------------------------------------- -// private types -typedef mu::ParserBase::exception_type muError_t; -typedef mu::ParserBase muParser_t; - -int g_nBulkSize; - -//--------------------------------------------------------------------------- -class ParserTag -{ -public: - ParserTag(int nType) - :pParser((nType == muBASETYPE_FLOAT) ? (mu::ParserBase*)new mu::Parser() : - (nType == muBASETYPE_INT) ? (mu::ParserBase*)new mu::ParserInt() : NULL) - , exc() - , errHandler(NULL) - , bError(false) - , m_nParserType(nType) - {} - - ~ParserTag() - { - delete pParser; - } - - mu::ParserBase *pParser; - mu::ParserBase::exception_type exc; - muErrorHandler_t errHandler; - bool bError; - -private: - ParserTag(const ParserTag &ref); - ParserTag& operator=(const ParserTag &ref); - - int m_nParserType; -}; - -static muChar_t s_tmpOutBuf[2048]; - -//--------------------------------------------------------------------------- -// -// -// unexported functions -// -// -//--------------------------------------------------------------------------- - -//--------------------------------------------------------------------------- -muParser_t* AsParser(muParserHandle_t a_hParser) -{ - return static_cast<ParserTag*>(a_hParser)->pParser; -} - -//--------------------------------------------------------------------------- -ParserTag* AsParserTag(muParserHandle_t a_hParser) -{ - return static_cast<ParserTag*>(a_hParser); -} - -//--------------------------------------------------------------------------- -#if defined(_WIN32) -#define _CRT_SECURE_NO_DEPRECATE - -BOOL APIENTRY DllMain(HANDLE /*hModule*/, - DWORD ul_reason_for_call, - LPVOID /*lpReserved*/) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - break; - - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - - return TRUE; -} - -#endif - -//--------------------------------------------------------------------------- -// -// -// exported functions -// -// -//--------------------------------------------------------------------------- - -API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void *pUserData) -{ - MU_TRY - muParser_t* p(AsParser(a_hParser)); - p->SetVarFactory(a_pFactory, pUserData); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Create a new Parser instance and return its handle. -*/ -API_EXPORT(muParserHandle_t) mupCreate(int nBaseType) -{ - switch (nBaseType) - { - case muBASETYPE_FLOAT: return (void*)(new ParserTag(muBASETYPE_FLOAT)); - case muBASETYPE_INT: return (void*)(new ParserTag(muBASETYPE_INT)); - default: return NULL; - } -} - -//--------------------------------------------------------------------------- -/** \brief Release the parser instance related with a parser handle. -*/ -API_EXPORT(void) mupRelease(muParserHandle_t a_hParser) -{ - MU_TRY - ParserTag* p = static_cast<ParserTag*>(a_hParser); - delete p; - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(const muChar_t*) mupGetVersion(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - -#ifndef _UNICODE - sprintf(s_tmpOutBuf, "%s", p->GetVersion().c_str()); -#else - wsprintf(s_tmpOutBuf, _T("%s"), p->GetVersion().c_str()); -#endif - - return s_tmpOutBuf; - MU_CATCH - - return _T(""); -} - -//--------------------------------------------------------------------------- -/** \brief Evaluate the expression. -*/ -API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - return p->Eval(); - MU_CATCH - - return 0; -} - -//--------------------------------------------------------------------------- -API_EXPORT(muFloat_t*) mupEvalMulti(muParserHandle_t a_hParser, int *nNum) -{ - MU_TRY - assert(nNum != NULL); - - muParser_t* const p(AsParser(a_hParser)); - return p->Eval(*nNum); - MU_CATCH - - return 0; -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupEvalBulk(muParserHandle_t a_hParser, muFloat_t *a_res, int nSize) -{ - MU_TRY - muParser_t* p(AsParser(a_hParser)); - p->Eval(a_res, nSize); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t* a_szExpr) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->SetExpr(a_szExpr); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->RemoveVar(a_szName); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Release all parser variables. - \param a_hParser Handle to the parser instance. - */ -API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->ClearVar(); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Release all parser variables. - \param a_hParser Handle to the parser instance. - */ -API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->ClearConst(); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Clear all user defined operators. - \param a_hParser Handle to the parser instance. - */ -API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->ClearOprt(); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->ClearFun(); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun0(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun0_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun1_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun2_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun3_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun4_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun5_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun6(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun6_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun7(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun7_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun8(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun8_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun9(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun9_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineFun10(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFun10_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun0(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muBulkFun0_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun1(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muBulkFun1_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun2(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muBulkFun2_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun3(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun3_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun4(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun4_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun5(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun5_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun6(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun6_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun7(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun7_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun8(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun8_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun9(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun9_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkFun10(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muBulkFun10_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muStrFun1_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muStrFun2_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muStrFun3_t a_pFun) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, false); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineMultFun(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muMultFun_t a_pFun, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineFun(a_szName, a_pFun, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineOprt(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun2_t a_pFun, - muInt_t a_nPrec, - muInt_t a_nOprtAsct, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineOprt(a_szName, - a_pFun, - a_nPrec, - (mu::EOprtAssociativity)a_nOprtAsct, - a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineVar(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFloat_t *a_pVar) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineVar(a_szName, a_pVar); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineBulkVar(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFloat_t *a_pVar) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineVar(a_szName, a_pVar); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineConst(muParserHandle_t a_hParser, - const muChar_t *a_szName, - muFloat_t a_fVal) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineConst(a_szName, a_fVal); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineStrConst(muParserHandle_t a_hParser, - const muChar_t *a_szName, - const muChar_t *a_szVal) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineStrConst(a_szName, a_szVal); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - - // C# explodes when pMsg is returned directly. For some reason it can't access - // the memory where the message lies directly. -#ifndef _UNICODE - sprintf(s_tmpOutBuf, "%s", p->GetExpr().c_str()); -#else - wsprintf(s_tmpOutBuf, _T("%s"), p->GetExpr().c_str()); -#endif - - return s_tmpOutBuf; - - MU_CATCH - - return _T(""); -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefinePostfixOprt(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun1_t a_pOprt, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefinePostfixOprt(a_szName, a_pOprt, a_bAllowOpt != 0); - MU_CATCH -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineInfixOprt(muParserHandle_t a_hParser, - const muChar_t* a_szName, - muFun1_t a_pOprt, - muBool_t a_bAllowOpt) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->DefineInfixOprt(a_szName, a_pOprt, a_bAllowOpt != 0); - MU_CATCH -} - -// Define character sets for identifiers -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, - const muChar_t* a_szCharset) -{ - muParser_t* const p(AsParser(a_hParser)); - p->DefineNameChars(a_szCharset); -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, - const muChar_t* a_szCharset) -{ - muParser_t* const p(AsParser(a_hParser)); - p->DefineOprtChars(a_szCharset); -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, - const muChar_t *a_szCharset) -{ - muParser_t* const p(AsParser(a_hParser)); - p->DefineInfixOprtChars(a_szCharset); -} - -//--------------------------------------------------------------------------- -/** \brief Get the number of variables defined in the parser. - \param a_hParser [in] Must be a valid parser handle. - \return The number of used variables. - \sa mupGetExprVar - */ -API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::varmap_type VarMap = p->GetVar(); - return (int)VarMap.size(); - MU_CATCH - - return 0; // never reached -} - -//--------------------------------------------------------------------------- -/** \brief Return a variable that is used in an expression. - \param a_hParser [in] A valid parser handle. - \param a_iVar [in] The index of the variable to return. - \param a_szName [out] Pointer to the variable name. - \param a_pVar [out] Pointer to the variable. - \throw nothrow - - Prior to calling this function call mupGetExprVarNum in order to get the - number of variables in the expression. If the parameter a_iVar is greater - than the number of variables both a_szName and a_pVar will be set to zero. - As a side effect this function will trigger an internal calculation of the - expression undefined variables will be set to zero during this calculation. - During the calculation user defined callback functions present in the expression - will be called, this is unavoidable. - */ -API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, - unsigned a_iVar, - const muChar_t **a_szName, - muFloat_t **a_pVar) -{ - // A static buffer is needed for the name since i cant return the - // pointer from the map. - static muChar_t szName[1024]; - - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::varmap_type VarMap = p->GetVar(); - - if (a_iVar >= VarMap.size()) - { - *a_szName = 0; - *a_pVar = 0; - return; - } - mu::varmap_type::const_iterator item; - - item = VarMap.begin(); - for (unsigned i = 0; i < a_iVar; ++i) - ++item; - -#ifndef _UNICODE - strncpy(szName, item->first.c_str(), sizeof(szName)); -#else - wcsncpy(szName, item->first.c_str(), sizeof(szName)); -#endif - - szName[sizeof(szName)-1] = 0; - - *a_szName = &szName[0]; - *a_pVar = item->second; - return; - - MU_CATCH - - *a_szName = 0; - *a_pVar = 0; -} - -//--------------------------------------------------------------------------- -/** \brief Get the number of variables used in the expression currently set in the parser. - \param a_hParser [in] Must be a valid parser handle. - \return The number of used variables. - \sa mupGetExprVar - */ -API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::varmap_type VarMap = p->GetUsedVar(); - return (int)VarMap.size(); - MU_CATCH - - return 0; // never reached -} - -//--------------------------------------------------------------------------- -/** \brief Return a variable that is used in an expression. - - Prior to calling this function call mupGetExprVarNum in order to get the - number of variables in the expression. If the parameter a_iVar is greater - than the number of variables both a_szName and a_pVar will be set to zero. - As a side effect this function will trigger an internal calculation of the - expression undefined variables will be set to zero during this calculation. - During the calculation user defined callback functions present in the expression - will be called, this is unavoidable. - - \param a_hParser [in] A valid parser handle. - \param a_iVar [in] The index of the variable to return. - \param a_szName [out] Pointer to the variable name. - \param a_pVar [out] Pointer to the variable. - \throw nothrow - */ -API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, - unsigned a_iVar, - const muChar_t **a_szName, - muFloat_t **a_pVar) -{ - // A static buffer is needed for the name since i cant return the - // pointer from the map. - static muChar_t szName[1024]; - - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::varmap_type VarMap = p->GetUsedVar(); - - if (a_iVar >= VarMap.size()) - { - *a_szName = 0; - *a_pVar = 0; - return; - } - mu::varmap_type::const_iterator item; - - item = VarMap.begin(); - for (unsigned i = 0; i < a_iVar; ++i) - ++item; - -#ifndef _UNICODE - strncpy(szName, item->first.c_str(), sizeof(szName)); -#else - wcsncpy(szName, item->first.c_str(), sizeof(szName)); -#endif - - szName[sizeof(szName)-1] = 0; - - *a_szName = &szName[0]; - *a_pVar = item->second; - return; - - MU_CATCH - - *a_szName = 0; - *a_pVar = 0; -} - -//--------------------------------------------------------------------------- -/** \brief Return the number of constants defined in a parser. */ -API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::valmap_type ValMap = p->GetConst(); - return (int)ValMap.size(); - MU_CATCH - - return 0; // never reached -} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(void) mupSetArgSep(muParserHandle_t a_hParser, const muChar_t cArgSep) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->SetArgSep(cArgSep); - MU_CATCH -} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(void) mupResetLocale(muParserHandle_t a_hParser) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->ResetLocale(); - MU_CATCH -} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(void) mupSetDecSep(muParserHandle_t a_hParser, const muChar_t cDecSep) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->SetDecSep(cDecSep); - MU_CATCH -} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(void) mupSetThousandsSep(muParserHandle_t a_hParser, const muChar_t cThousandsSep) -{ - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - p->SetThousandsSep(cThousandsSep); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Retrieve name and value of a single parser constant. - \param a_hParser [in] a valid parser handle - \param a_iVar [in] Index of the constant to query - \param a_pszName [out] pointer to a null terminated string with the constant name - \param [out] The constant value - */ -API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, - unsigned a_iVar, - const muChar_t **a_pszName, - muFloat_t *a_fVal) -{ - // A static buffer is needed for the name since i cant return the - // pointer from the map. - static muChar_t szName[1024]; - - MU_TRY - muParser_t* const p(AsParser(a_hParser)); - const mu::valmap_type ValMap = p->GetConst(); - - if (a_iVar >= ValMap.size()) - { - *a_pszName = 0; - *a_fVal = 0; - return; - } - - mu::valmap_type::const_iterator item; - item = ValMap.begin(); - for (unsigned i = 0; i < a_iVar; ++i) - ++item; - -#ifndef _UNICODE - strncpy(szName, item->first.c_str(), sizeof(szName)); -#else - wcsncpy(szName, item->first.c_str(), sizeof(szName)); -#endif - - szName[sizeof(szName)-1] = 0; - - *a_pszName = &szName[0]; - *a_fVal = item->second; - return; - - MU_CATCH - - *a_pszName = 0; - *a_fVal = 0; -} - -//--------------------------------------------------------------------------- -/** \brief Add a custom value recognition function. -*/ -API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, - muIdentFun_t a_pFun) -{ - MU_TRY - muParser_t* p(AsParser(a_hParser)); - p->AddValIdent(a_pFun); - MU_CATCH -} - -//--------------------------------------------------------------------------- -/** \brief Query if an error occurred. - - After querying the internal error bit will be reset. So a consecutive call - will return false. - */ -API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser) -{ - bool bError(AsParserTag(a_hParser)->bError); - AsParserTag(a_hParser)->bError = false; - return bError; -} - -//--------------------------------------------------------------------------- -/** \brief Reset the internal error flag. -*/ -API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser) -{ - AsParserTag(a_hParser)->bError = false; -} - -//--------------------------------------------------------------------------- -API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pHandler) -{ - AsParserTag(a_hParser)->errHandler = a_pHandler; -} - -//--------------------------------------------------------------------------- -/** \brief Return the message associated with the last error. -*/ -API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser) -{ - ParserTag* const p(AsParserTag(a_hParser)); - const muChar_t *pMsg = p->exc.GetMsg().c_str(); - - // C# explodes when pMsg is returned directly. For some reason it can't access - // the memory where the message lies directly. -#ifndef _UNICODE - sprintf(s_tmpOutBuf, "%s", pMsg); -#else - wsprintf(s_tmpOutBuf, _T("%s"), pMsg); -#endif - - return s_tmpOutBuf; -} - -//--------------------------------------------------------------------------- -/** \brief Return the message associated with the last error. -*/ -API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser) -{ - ParserTag* const p(AsParserTag(a_hParser)); - const muChar_t *pToken = p->exc.GetToken().c_str(); - - // C# explodes when pMsg is returned directly. For some reason it can't access - // the memory where the message lies directly. -#ifndef _UNICODE - sprintf(s_tmpOutBuf, "%s", pToken); -#else - wsprintf(s_tmpOutBuf, _T("%s"), pToken); -#endif - - return s_tmpOutBuf; -} - -//--------------------------------------------------------------------------- -/** \brief Return the code associated with the last error. -*/ -API_EXPORT(int) mupGetErrorCode(muParserHandle_t a_hParser) -{ - return AsParserTag(a_hParser)->exc.GetCode(); -} - -//--------------------------------------------------------------------------- -/** \brief Return the position associated with the last error. */ -API_EXPORT(int) mupGetErrorPos(muParserHandle_t a_hParser) -{ - return (int)AsParserTag(a_hParser)->exc.GetPos(); -} - -////----------------------------------------------------------------------------------------------------- -//API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser) -//{ -// return AsParserTag(a_hParser)->exc.GetExpr().c_str(); -//} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(muFloat_t*) mupCreateVar() -{ - return new muFloat_t(0); -} - -//----------------------------------------------------------------------------------------------------- -API_EXPORT(void) mupReleaseVar(muFloat_t *ptr) -{ - delete ptr; -} - -#endif // MUPARSER_DLL diff --git a/ThirdParty/MuParser/src/muParserError.cpp b/ThirdParty/MuParser/src/muParserError.cpp deleted file mode 100644 index 6fe4e1d2cca91e2cd8bcc8a25677f52317f72fe4..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserError.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "muParserError.h" - - -namespace mu -{ - const ParserErrorMsg ParserErrorMsg::m_Instance; - - //------------------------------------------------------------------------------ - const ParserErrorMsg& ParserErrorMsg::Instance() - { - return m_Instance; - } - - //------------------------------------------------------------------------------ - string_type ParserErrorMsg::operator[](unsigned a_iIdx) const - { - return (a_iIdx<m_vErrMsg.size()) ? m_vErrMsg[a_iIdx] : string_type(); - } - - //--------------------------------------------------------------------------- - ParserErrorMsg::~ParserErrorMsg() - {} - - //--------------------------------------------------------------------------- - /** \brief Assignement operator is deactivated. - */ - ParserErrorMsg& ParserErrorMsg::operator=(const ParserErrorMsg& ) - { - assert(false); - return *this; - } - - //--------------------------------------------------------------------------- - ParserErrorMsg::ParserErrorMsg(const ParserErrorMsg&) - {} - - //--------------------------------------------------------------------------- - ParserErrorMsg::ParserErrorMsg() - :m_vErrMsg(0) - { - m_vErrMsg.resize(ecCOUNT); - - m_vErrMsg[ecUNASSIGNABLE_TOKEN] = _T("Unexpected token \"$TOK$\" found at position $POS$."); - m_vErrMsg[ecINTERNAL_ERROR] = _T("Internal error"); - m_vErrMsg[ecINVALID_NAME] = _T("Invalid function-, variable- or constant name: \"$TOK$\"."); - m_vErrMsg[ecINVALID_BINOP_IDENT] = _T("Invalid binary operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_INFIX_IDENT] = _T("Invalid infix operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_POSTFIX_IDENT] = _T("Invalid postfix operator identifier: \"$TOK$\"."); - m_vErrMsg[ecINVALID_FUN_PTR] = _T("Invalid pointer to callback function."); - m_vErrMsg[ecEMPTY_EXPRESSION] = _T("Expression is empty."); - m_vErrMsg[ecINVALID_VAR_PTR] = _T("Invalid pointer to variable."); - m_vErrMsg[ecUNEXPECTED_OPERATOR] = _T("Unexpected operator \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_EOF] = _T("Unexpected end of expression at position $POS$"); - m_vErrMsg[ecUNEXPECTED_ARG_SEP] = _T("Unexpected argument separator at position $POS$"); - m_vErrMsg[ecUNEXPECTED_PARENS] = _T("Unexpected parenthesis \"$TOK$\" at position $POS$"); - m_vErrMsg[ecUNEXPECTED_FUN] = _T("Unexpected function \"$TOK$\" at position $POS$"); - m_vErrMsg[ecUNEXPECTED_VAL] = _T("Unexpected value \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_VAR] = _T("Unexpected variable \"$TOK$\" found at position $POS$"); - m_vErrMsg[ecUNEXPECTED_ARG] = _T("Function arguments used without a function (position: $POS$)"); - m_vErrMsg[ecMISSING_PARENS] = _T("Missing parenthesis"); - m_vErrMsg[ecTOO_MANY_PARAMS] = _T("Too many parameters for function \"$TOK$\" at expression position $POS$"); - m_vErrMsg[ecTOO_FEW_PARAMS] = _T("Too few parameters for function \"$TOK$\" at expression position $POS$"); - m_vErrMsg[ecDIV_BY_ZERO] = _T("Divide by zero"); - m_vErrMsg[ecDOMAIN_ERROR] = _T("Domain error"); - m_vErrMsg[ecNAME_CONFLICT] = _T("Name conflict"); - m_vErrMsg[ecOPT_PRI] = _T("Invalid value for operator priority (must be greater or equal to zero)."); - m_vErrMsg[ecBUILTIN_OVERLOAD] = _T("user defined binary operator \"$TOK$\" conflicts with a built in operator."); - m_vErrMsg[ecUNEXPECTED_STR] = _T("Unexpected string token found at position $POS$."); - m_vErrMsg[ecUNTERMINATED_STRING] = _T("Unterminated string starting at position $POS$."); - m_vErrMsg[ecSTRING_EXPECTED] = _T("String function called with a non string type of argument."); - m_vErrMsg[ecVAL_EXPECTED] = _T("String value used where a numerical argument is expected."); - m_vErrMsg[ecOPRT_TYPE_CONFLICT] = _T("No suitable overload for operator \"$TOK$\" at position $POS$."); - m_vErrMsg[ecSTR_RESULT] = _T("Function result is a string."); - m_vErrMsg[ecGENERIC] = _T("Parser error."); - m_vErrMsg[ecLOCALE] = _T("Decimal separator is identic to function argument separator."); - m_vErrMsg[ecUNEXPECTED_CONDITIONAL] = _T("The \"$TOK$\" operator must be preceeded by a closing bracket."); - m_vErrMsg[ecMISSING_ELSE_CLAUSE] = _T("If-then-else operator is missing an else clause"); - m_vErrMsg[ecMISPLACED_COLON] = _T("Misplaced colon at position $POS$"); - m_vErrMsg[ecUNREASONABLE_NUMBER_OF_COMPUTATIONS] = _T("Number of computations to small for bulk mode. (Vectorisation overhead too costly)"); - - #if defined(_DEBUG) - for (int i=0; i<ecCOUNT; ++i) - if (!m_vErrMsg[i].length()) - assert(false); - #endif - } - - //--------------------------------------------------------------------------- - // - // ParserError class - // - //--------------------------------------------------------------------------- - - /** \brief Default constructor. */ - ParserError::ParserError() - :m_strMsg() - ,m_strFormula() - ,m_strTok() - ,m_iPos(-1) - ,m_iErrc(ecUNDEFINED) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - } - - //------------------------------------------------------------------------------ - /** \brief This Constructor is used for internal exceptions only. - - It does not contain any information but the error code. - */ - ParserError::ParserError(EErrorCodes a_iErrc) - :m_strMsg() - ,m_strFormula() - ,m_strTok() - ,m_iPos(-1) - ,m_iErrc(a_iErrc) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error from a message text. */ - ParserError::ParserError(const string_type &sMsg) - :m_ErrMsg(ParserErrorMsg::Instance()) - { - Reset(); - m_strMsg = sMsg; - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] a_iErrc the error code. - \param [in] sTok The token string related to this error. - \param [in] sExpr The expression related to the error. - \param [in] a_iPos the position in the expression where the error occurred. - */ - ParserError::ParserError( EErrorCodes iErrc, - const string_type &sTok, - const string_type &sExpr, - int iPos ) - :m_strMsg() - ,m_strFormula(sExpr) - ,m_strTok(sTok) - ,m_iPos(iPos) - ,m_iErrc(iErrc) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] iErrc the error code. - \param [in] iPos the position in the expression where the error occurred. - \param [in] sTok The token string related to this error. - */ - ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok) - :m_strMsg() - ,m_strFormula() - ,m_strTok(sTok) - ,m_iPos(iPos) - ,m_iErrc(iErrc) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - m_strMsg = m_ErrMsg[m_iErrc]; - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Construct an error object. - \param [in] szMsg The error message text. - \param [in] iPos the position related to the error. - \param [in] sTok The token string related to this error. - */ - ParserError::ParserError(const char_type *szMsg, int iPos, const string_type &sTok) - :m_strMsg(szMsg) - ,m_strFormula() - ,m_strTok(sTok) - ,m_iPos(iPos) - ,m_iErrc(ecGENERIC) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - stringstream_type stream; - stream << (int)m_iPos; - ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); - ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); - } - - //------------------------------------------------------------------------------ - /** \brief Copy constructor. */ - ParserError::ParserError(const ParserError &a_Obj) - :m_strMsg(a_Obj.m_strMsg) - ,m_strFormula(a_Obj.m_strFormula) - ,m_strTok(a_Obj.m_strTok) - ,m_iPos(a_Obj.m_iPos) - ,m_iErrc(a_Obj.m_iErrc) - ,m_ErrMsg(ParserErrorMsg::Instance()) - { - } - - //------------------------------------------------------------------------------ - /** \brief Assignment operator. */ - ParserError& ParserError::operator=(const ParserError &a_Obj) - { - if (this==&a_Obj) - return *this; - - m_strMsg = a_Obj.m_strMsg; - m_strFormula = a_Obj.m_strFormula; - m_strTok = a_Obj.m_strTok; - m_iPos = a_Obj.m_iPos; - m_iErrc = a_Obj.m_iErrc; - return *this; - } - - //------------------------------------------------------------------------------ - ParserError::~ParserError() - {} - - //------------------------------------------------------------------------------ - /** \brief Replace all occurrences of a substring with another string. - \param strFind The string that shall be replaced. - \param strReplaceWith The string that should be inserted instead of strFind - */ - void ParserError::ReplaceSubString( string_type &strSource, - const string_type &strFind, - const string_type &strReplaceWith) - { - string_type strResult; - string_type::size_type iPos(0), iNext(0); - - for(;;) - { - iNext = strSource.find(strFind, iPos); - strResult.append(strSource, iPos, iNext-iPos); - - if( iNext==string_type::npos ) - break; - - strResult.append(strReplaceWith); - iPos = iNext + strFind.length(); - } - - strSource.swap(strResult); - } - - //------------------------------------------------------------------------------ - /** \brief Reset the erro object. */ - void ParserError::Reset() - { - m_strMsg = _T(""); - m_strFormula = _T(""); - m_strTok = _T(""); - m_iPos = -1; - m_iErrc = ecUNDEFINED; - } - - //------------------------------------------------------------------------------ - /** \brief Set the expression related to this error. */ - void ParserError::SetFormula(const string_type &a_strFormula) - { - m_strFormula = a_strFormula; - } - - //------------------------------------------------------------------------------ - /** \brief gets the expression related tp this error.*/ - const string_type& ParserError::GetExpr() const - { - return m_strFormula; - } - - //------------------------------------------------------------------------------ - /** \brief Returns the message string for this error. */ - const string_type& ParserError::GetMsg() const - { - return m_strMsg; - } - - //------------------------------------------------------------------------------ - /** \brief Return the formula position related to the error. - - If the error is not related to a distinct position this will return -1 - */ - int ParserError::GetPos() const - { - return m_iPos; - } - - //------------------------------------------------------------------------------ - /** \brief Return string related with this token (if available). */ - const string_type& ParserError::GetToken() const - { - return m_strTok; - } - - //------------------------------------------------------------------------------ - /** \brief Return the error code. */ - EErrorCodes ParserError::GetCode() const - { - return m_iErrc; - } -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserInt.cpp b/ThirdParty/MuParser/src/muParserInt.cpp deleted file mode 100644 index 8b5aae60346f3e87a3d539282fe1944c0d80f184..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserInt.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2011 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "muParserInt.h" - -#include <cmath> -#include <algorithm> -#include <numeric> - -using namespace std; - -/** \file - \brief Implementation of a parser using integer value. -*/ - -/** \brief Namespace for mathematical applications. */ -namespace mu -{ -value_type ParserInt::Abs(value_type v) { return (value_type)Round(fabs((double)v)); } -value_type ParserInt::Sign(value_type v) { return (Round(v)<0) ? -1 : (Round(v)>0) ? 1 : 0; } -value_type ParserInt::Ite(value_type v1, - value_type v2, - value_type v3) { return (Round(v1)==1) ? Round(v2) : Round(v3); } -value_type ParserInt::Add(value_type v1, value_type v2) { return Round(v1) + Round(v2); } -value_type ParserInt::Sub(value_type v1, value_type v2) { return Round(v1) - Round(v2); } -value_type ParserInt::Mul(value_type v1, value_type v2) { return Round(v1) * Round(v2); } -value_type ParserInt::Div(value_type v1, value_type v2) { return Round(v1) / Round(v2); } -value_type ParserInt::Mod(value_type v1, value_type v2) { return Round(v1) % Round(v2); } -value_type ParserInt::Shr(value_type v1, value_type v2) { return Round(v1) >> Round(v2); } -value_type ParserInt::Shl(value_type v1, value_type v2) { return Round(v1) << Round(v2); } -value_type ParserInt::LogAnd(value_type v1, value_type v2) { return Round(v1) & Round(v2); } -value_type ParserInt::LogOr(value_type v1, value_type v2) { return Round(v1) | Round(v2); } -value_type ParserInt::And(value_type v1, value_type v2) { return Round(v1) && Round(v2); } -value_type ParserInt::Or(value_type v1, value_type v2) { return Round(v1) || Round(v2); } -value_type ParserInt::Less(value_type v1, value_type v2) { return Round(v1) < Round(v2); } -value_type ParserInt::Greater(value_type v1, value_type v2) { return Round(v1) > Round(v2); } -value_type ParserInt::LessEq(value_type v1, value_type v2) { return Round(v1) <= Round(v2); } -value_type ParserInt::GreaterEq(value_type v1, value_type v2) { return Round(v1) >= Round(v2); } -value_type ParserInt::Equal(value_type v1, value_type v2) { return Round(v1) == Round(v2); } -value_type ParserInt::NotEqual(value_type v1, value_type v2) { return Round(v1) != Round(v2); } -value_type ParserInt::Not(value_type v) { return !Round(v); } - -value_type ParserInt::Pow(value_type v1, value_type v2) -{ - return std::pow((double)Round(v1), (double)Round(v2)); -} - -//--------------------------------------------------------------------------- -// Unary operator Callbacks: Infix operators -value_type ParserInt::UnaryMinus(value_type v) -{ - return -Round(v); -} - -//--------------------------------------------------------------------------- -value_type ParserInt::Sum(const value_type* a_afArg, int a_iArgc) -{ - if (!a_iArgc) - throw ParserError(_T("too few arguments for function sum.")); - - value_type fRes=0; - for (int i=0; i<a_iArgc; ++i) - fRes += a_afArg[i]; - - return fRes; -} - -//--------------------------------------------------------------------------- -value_type ParserInt::Min(const value_type* a_afArg, int a_iArgc) -{ - if (!a_iArgc) - throw ParserError( _T("too few arguments for function min.") ); - - value_type fRes=a_afArg[0]; - for (int i=0; i<a_iArgc; ++i) - fRes = std::min(fRes, a_afArg[i]); - - return fRes; -} - -//--------------------------------------------------------------------------- -value_type ParserInt::Max(const value_type* a_afArg, int a_iArgc) -{ - if (!a_iArgc) - throw ParserError(_T("too few arguments for function min.")); - - value_type fRes=a_afArg[0]; - for (int i=0; i<a_iArgc; ++i) - fRes = std::max(fRes, a_afArg[i]); - - return fRes; -} - -//--------------------------------------------------------------------------- -// Default value recognition callback -int ParserInt::IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) -{ - string_type buf(a_szExpr); - std::size_t pos = buf.find_first_not_of(_T("0123456789")); - - if (pos==std::string::npos) - return 0; - - stringstream_type stream( buf.substr(0, pos ) ); - int iVal(0); - - stream >> iVal; - if (stream.fail()) - return 0; - - stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading - if (stream.fail()) - iEnd = stream.str().length(); - - if (iEnd==(stringstream_type::pos_type)-1) - return 0; - - *a_iPos += (int)iEnd; - *a_fVal = (value_type)iVal; - return 1; -} - -//--------------------------------------------------------------------------- -/** \brief Check a given position in the expression for the presence of - a hex value. - \param a_szExpr Pointer to the expression string - \param [in/out] a_iPos Pointer to an integer value holding the current parsing - position in the expression. - \param [out] a_fVal Pointer to the position where the detected value shall be stored. - - Hey values must be prefixed with "0x" in order to be detected properly. -*/ -int ParserInt::IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) -{ - if (a_szExpr[1]==0 || (a_szExpr[0]!='0' || a_szExpr[1]!='x') ) - return 0; - - unsigned iVal(0); - - // New code based on streams for UNICODE compliance: - stringstream_type::pos_type nPos(0); - stringstream_type ss(a_szExpr + 2); - ss >> std::hex >> iVal; - nPos = ss.tellg(); - - if (nPos==(stringstream_type::pos_type)0) - return 1; - - *a_iPos += (int)(2 + nPos); - *a_fVal = (value_type)iVal; - return 1; -} - -//--------------------------------------------------------------------------- -int ParserInt::IsBinVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) -{ - if (a_szExpr[0]!='#') - return 0; - - unsigned iVal(0), - iBits(sizeof(iVal)*8), - i(0); - - for (i=0; (a_szExpr[i+1]=='0' || a_szExpr[i+1]=='1') && i<iBits; ++i) - iVal |= (int)(a_szExpr[i+1]=='1') << ((iBits-1)-i); - - if (i==0) - return 0; - - if (i==iBits) - throw exception_type(_T("Binary to integer conversion error (overflow).")); - - *a_fVal = (unsigned)(iVal >> (iBits-i) ); - *a_iPos += i+1; - - return 1; -} - -//--------------------------------------------------------------------------- -/** \brief Constructor. - - Call ParserBase class constructor and trigger Function, Operator and Constant initialization. -*/ -ParserInt::ParserInt() - :ParserBase() -{ - AddValIdent(IsVal); // lowest priority - AddValIdent(IsBinVal); - AddValIdent(IsHexVal); // highest priority - - InitCharSets(); - InitFun(); - InitOprt(); -} - -//--------------------------------------------------------------------------- -void ParserInt::InitConst() -{ -} - -//--------------------------------------------------------------------------- -void ParserInt::InitCharSets() -{ - DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); - DefineOprtChars( _T("+-*^/?<>=!%&|~'_") ); - DefineInfixOprtChars( _T("/+-*^?<>=!%&|~'_") ); -} - -//--------------------------------------------------------------------------- -/** \brief Initialize the default functions. */ -void ParserInt::InitFun() -{ - DefineFun( _T("sign"), Sign); - DefineFun( _T("abs"), Abs); - DefineFun( _T("if"), Ite); - DefineFun( _T("sum"), Sum); - DefineFun( _T("min"), Min); - DefineFun( _T("max"), Max); -} - -//--------------------------------------------------------------------------- -/** \brief Initialize operators. */ -void ParserInt::InitOprt() -{ - // disable all built in operators, not all of them useful for integer numbers - // (they don't do rounding of values) - EnableBuiltInOprt(false); - - // Disable all built in operators, they wont work with integer numbers - // since they are designed for floating point numbers - DefineInfixOprt( _T("-"), UnaryMinus); - DefineInfixOprt( _T("!"), Not); - - DefineOprt( _T("&"), LogAnd, prLOGIC); - DefineOprt( _T("|"), LogOr, prLOGIC); - DefineOprt( _T("&&"), And, prLOGIC); - DefineOprt( _T("||"), Or, prLOGIC); - - DefineOprt( _T("<"), Less, prCMP); - DefineOprt( _T(">"), Greater, prCMP); - DefineOprt( _T("<="), LessEq, prCMP); - DefineOprt( _T(">="), GreaterEq, prCMP); - DefineOprt( _T("=="), Equal, prCMP); - DefineOprt( _T("!="), NotEqual, prCMP); - - DefineOprt( _T("+"), Add, prADD_SUB); - DefineOprt( _T("-"), Sub, prADD_SUB); - - DefineOprt( _T("*"), Mul, prMUL_DIV); - DefineOprt( _T("/"), Div, prMUL_DIV); - DefineOprt( _T("%"), Mod, prMUL_DIV); - - DefineOprt( _T("^"), Pow, prPOW, oaRIGHT); - DefineOprt( _T(">>"), Shr, prMUL_DIV+1); - DefineOprt( _T("<<"), Shl, prMUL_DIV+1); -} - -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserTest.cpp b/ThirdParty/MuParser/src/muParserTest.cpp deleted file mode 100644 index 4006b27c716b14342b5f3ebee61fb9c4c14aa29f..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserTest.cpp +++ /dev/null @@ -1,1552 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "muParserTest.h" - -#include <cstdio> -#include <cmath> -#include <iostream> -#include <limits> - -#define PARSER_CONST_PI 3.141592653589793238462643 -#define PARSER_CONST_E 2.718281828459045235360287 - -using namespace std; - -/** \file - \brief This file contains the implementation of parser test cases. -*/ - -namespace mu -{ - namespace Test - { - int ParserTester::c_iCount = 0; - - //--------------------------------------------------------------------------------------------- - ParserTester::ParserTester() - :m_vTestFun() - { - AddTest(&ParserTester::TestNames); - AddTest(&ParserTester::TestSyntax); - AddTest(&ParserTester::TestPostFix); - AddTest(&ParserTester::TestInfixOprt); - AddTest(&ParserTester::TestVarConst); - AddTest(&ParserTester::TestMultiArg); - AddTest(&ParserTester::TestExpression); - AddTest(&ParserTester::TestIfThenElse); - AddTest(&ParserTester::TestInterface); - AddTest(&ParserTester::TestBinOprt); - AddTest(&ParserTester::TestException); - AddTest(&ParserTester::TestStrArg); - AddTest(&ParserTester::TestBulkMode); - - ParserTester::c_iCount = 0; - } - - //--------------------------------------------------------------------------------------------- - int ParserTester::IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) - { - if (a_szExpr[1]==0 || (a_szExpr[0]!='0' || a_szExpr[1]!='x') ) - return 0; - - unsigned iVal(0); - - // New code based on streams for UNICODE compliance: - stringstream_type::pos_type nPos(0); - stringstream_type ss(a_szExpr + 2); - ss >> std::hex >> iVal; - nPos = ss.tellg(); - - if (nPos==(stringstream_type::pos_type)0) - return 1; - - *a_iPos += (int)(2 + nPos); - *a_fVal = (value_type)iVal; - return 1; - } - - //--------------------------------------------------------------------------------------------- - int ParserTester::TestInterface() - { - int iStat = 0; - mu::console() << _T("testing member functions..."); - - // Test RemoveVar - value_type afVal[3] = {1,2,3}; - Parser p; - - try - { - p.DefineVar( _T("a"), &afVal[0]); - p.DefineVar( _T("b"), &afVal[1]); - p.DefineVar( _T("c"), &afVal[2]); - p.SetExpr( _T("a+b+c") ); - p.Eval(); - } - catch(...) - { - iStat += 1; // this is not supposed to happen - } - - try - { - p.RemoveVar( _T("c") ); - p.Eval(); - iStat += 1; // not supposed to reach this, nonexisting variable "c" deleted... - } - catch(...) - { - // failure is expected... - } - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------------------------- - int ParserTester::TestStrArg() - { - int iStat = 0; - mu::console() << _T("testing string arguments..."); - - iStat += EqnTest(_T("valueof(\"\")"), 123, true); // empty string arguments caused a crash - iStat += EqnTest(_T("valueof(\"aaa\")+valueof(\"bbb\") "), 246, true); - iStat += EqnTest(_T("2*(valueof(\"aaa\")-23)+valueof(\"bbb\")"), 323, true); - // use in expressions with variables - iStat += EqnTest(_T("a*(atof(\"10\")-b)"), 8, true); - iStat += EqnTest(_T("a-(atof(\"10\")*b)"), -19, true); - // string + numeric arguments - iStat += EqnTest(_T("strfun1(\"100\")"), 100, true); - iStat += EqnTest(_T("strfun2(\"100\",1)"), 101, true); - iStat += EqnTest(_T("strfun3(\"99\",1,2)"), 102, true); - // string constants - iStat += EqnTest(_T("atof(str1)+atof(str2)"), 3.33, true); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------------------------- - int ParserTester::TestBulkMode() - { - int iStat = 0; - mu::console() << _T("testing bulkmode..."); - -#define EQN_TEST_BULK(EXPR, R1, R2, R3, R4, PASS) \ - { \ - double res[] = { R1, R2, R3, R4 }; \ - iStat += EqnTestBulk(_T(EXPR), res, (PASS)); \ - } - - // Bulk Variables for the test: - // a: 1,2,3,4 - // b: 2,2,2,2 - // c: 3,3,3,3 - // d: 5,4,3,2 - EQN_TEST_BULK("a", 1, 1, 1, 1, false) - EQN_TEST_BULK("a", 1, 2, 3, 4, true) - EQN_TEST_BULK("b=a", 1, 2, 3, 4, true) - EQN_TEST_BULK("b=a, b*10", 10, 20, 30, 40, true) - EQN_TEST_BULK("b=a, b*10, a", 1, 2, 3, 4, true) - EQN_TEST_BULK("a+b", 3, 4, 5, 6, true) - EQN_TEST_BULK("c*(a+b)", 9, 12, 15, 18, true) -#undef EQN_TEST_BULK - - if (iStat == 0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------------------------- - int ParserTester::TestBinOprt() - { - int iStat = 0; - mu::console() << _T("testing binary operators..."); - - // built in operators - // xor operator - - iStat += EqnTest(_T("a++b"), 3, true); - iStat += EqnTest(_T("a ++ b"), 3, true); - iStat += EqnTest(_T("1++2"), 3, true); - iStat += EqnTest(_T("1 ++ 2"), 3, true); - iStat += EqnTest(_T("a add b"), 3, true); - iStat += EqnTest(_T("1 add 2"), 3, true); - iStat += EqnTest(_T("a<b"), 1, true); - iStat += EqnTest(_T("b>a"), 1, true); - iStat += EqnTest(_T("a>a"), 0, true); - iStat += EqnTest(_T("a<a"), 0, true); - iStat += EqnTest(_T("a>a"), 0, true); - iStat += EqnTest(_T("a<=a"), 1, true); - iStat += EqnTest(_T("a<=b"), 1, true); - iStat += EqnTest(_T("b<=a"), 0, true); - iStat += EqnTest(_T("a>=a"), 1, true); - iStat += EqnTest(_T("b>=a"), 1, true); - iStat += EqnTest(_T("a>=b"), 0, true); - - // Test logical operators, especially if user defined "&" and the internal "&&" collide - iStat += EqnTest(_T("1 && 1"), 1, true); - iStat += EqnTest(_T("1 && 0"), 0, true); - iStat += EqnTest(_T("(a<b) && (b>a)"), 1, true); - iStat += EqnTest(_T("(a<b) && (a>b)"), 0, true); - //iStat += EqnTest(_T("12 and 255"), 12, true); - //iStat += EqnTest(_T("12 and 0"), 0, true); - iStat += EqnTest(_T("12 & 255"), 12, true); - iStat += EqnTest(_T("12 & 0"), 0, true); - iStat += EqnTest(_T("12&255"), 12, true); - iStat += EqnTest(_T("12&0"), 0, true); - - // Assignment operator - iStat += EqnTest(_T("a = b"), 2, true); - iStat += EqnTest(_T("a = sin(b)"), 0.909297, true); - iStat += EqnTest(_T("a = 1+sin(b)"), 1.909297, true); - iStat += EqnTest(_T("(a=b)*2"), 4, true); - iStat += EqnTest(_T("2*(a=b)"), 4, true); - iStat += EqnTest(_T("2*(a=b+1)"), 6, true); - iStat += EqnTest(_T("(a=b+1)*2"), 6, true); - iStat += EqnTest(_T("a=c, a*10"), 30, true); - - iStat += EqnTest(_T("2^2^3"), 256, true); - iStat += EqnTest(_T("1/2/3"), 1.0/6.0, true); - - // reference: http://www.wolframalpha.com/input/?i=3%2B4*2%2F%281-5%29^2^3 - iStat += EqnTest(_T("3+4*2/(1-5)^2^3"), 3.0001220703125, true); - - // Test user defined binary operators - iStat += EqnTestInt(_T("1 | 2"), 3, true); - iStat += EqnTestInt(_T("1 || 2"), 1, true); - iStat += EqnTestInt(_T("123 & 456"), 72, true); - iStat += EqnTestInt(_T("(123 & 456) % 10"), 2, true); - iStat += EqnTestInt(_T("1 && 0"), 0, true); - iStat += EqnTestInt(_T("123 && 456"), 1, true); - iStat += EqnTestInt(_T("1 << 3"), 8, true); - iStat += EqnTestInt(_T("8 >> 3"), 1, true); - iStat += EqnTestInt(_T("9 / 4"), 2, true); - iStat += EqnTestInt(_T("9 % 4"), 1, true); - iStat += EqnTestInt(_T("if(5%2,1,0)"), 1, true); - iStat += EqnTestInt(_T("if(4%2,1,0)"), 0, true); - iStat += EqnTestInt(_T("-10+1"), -9, true); - iStat += EqnTestInt(_T("1+2*3"), 7, true); - iStat += EqnTestInt(_T("const1 != const2"), 1, true); - iStat += EqnTestInt(_T("const1 != const2"), 0, false); - iStat += EqnTestInt(_T("const1 == const2"), 0, true); - iStat += EqnTestInt(_T("const1 == 1"), 1, true); - iStat += EqnTestInt(_T("10*(const1 == 1)"), 10, true); - iStat += EqnTestInt(_T("2*(const1 | const2)"), 6, true); - iStat += EqnTestInt(_T("2*(const1 | const2)"), 7, false); - iStat += EqnTestInt(_T("const1 < const2"), 1, true); - iStat += EqnTestInt(_T("const2 > const1"), 1, true); - iStat += EqnTestInt(_T("const1 <= 1"), 1, true); - iStat += EqnTestInt(_T("const2 >= 2"), 1, true); - iStat += EqnTestInt(_T("2*(const1 + const2)"), 6, true); - iStat += EqnTestInt(_T("2*(const1 - const2)"), -2, true); - iStat += EqnTestInt(_T("a != b"), 1, true); - iStat += EqnTestInt(_T("a != b"), 0, false); - iStat += EqnTestInt(_T("a == b"), 0, true); - iStat += EqnTestInt(_T("a == 1"), 1, true); - iStat += EqnTestInt(_T("10*(a == 1)"), 10, true); - iStat += EqnTestInt(_T("2*(a | b)"), 6, true); - iStat += EqnTestInt(_T("2*(a | b)"), 7, false); - iStat += EqnTestInt(_T("a < b"), 1, true); - iStat += EqnTestInt(_T("b > a"), 1, true); - iStat += EqnTestInt(_T("a <= 1"), 1, true); - iStat += EqnTestInt(_T("b >= 2"), 1, true); - iStat += EqnTestInt(_T("2*(a + b)"), 6, true); - iStat += EqnTestInt(_T("2*(a - b)"), -2, true); - iStat += EqnTestInt(_T("a + (a << b)"), 5, true); - iStat += EqnTestInt(_T("-2^2"), -4, true); - iStat += EqnTestInt(_T("3--a"), 4, true); - iStat += EqnTestInt(_T("3+-3^2"), -6, true); - - // Test reading of hex values: - iStat += EqnTestInt(_T("0xff"), 255, true); - iStat += EqnTestInt(_T("10+0xff"), 265, true); - iStat += EqnTestInt(_T("0xff+10"), 265, true); - iStat += EqnTestInt(_T("10*0xff"), 2550, true); - iStat += EqnTestInt(_T("0xff*10"), 2550, true); - iStat += EqnTestInt(_T("10+0xff+1"), 266, true); - iStat += EqnTestInt(_T("1+0xff+10"), 266, true); - -// incorrect: '^' is yor here, not power -// iStat += EqnTestInt("-(1+2)^2", -9, true); -// iStat += EqnTestInt("-1^3", -1, true); - - // Test precedence - // a=1, b=2, c=3 - iStat += EqnTestInt(_T("a + b * c"), 7, true); - iStat += EqnTestInt(_T("a * b + c"), 5, true); - iStat += EqnTestInt(_T("a<b && b>10"), 0, true); - iStat += EqnTestInt(_T("a<b && b<10"), 1, true); - - iStat += EqnTestInt(_T("a + b << c"), 17, true); - iStat += EqnTestInt(_T("a << b + c"), 7, true); - iStat += EqnTestInt(_T("c * b < a"), 0, true); - iStat += EqnTestInt(_T("c * b == 6 * a"), 1, true); - iStat += EqnTestInt(_T("2^2^3"), 256, true); - - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------------------------- - /** \brief Check muParser name restriction enforcement. */ - int ParserTester::TestNames() - { - int iStat= 0, - iErr = 0; - - mu::console() << "testing name restriction enforcement..."; - - Parser p; - - #define PARSER_THROWCHECK(DOMAIN, FAIL, EXPR, ARG) \ - iErr = 0; \ - ParserTester::c_iCount++; \ - try \ - { \ - p.Define##DOMAIN(EXPR, ARG); \ - } \ - catch(Parser::exception_type&) \ - { \ - iErr = (FAIL==false) ? 0 : 1; \ - } \ - iStat += iErr; - - // constant names - PARSER_THROWCHECK(Const, false, _T("0a"), 1) - PARSER_THROWCHECK(Const, false, _T("9a"), 1) - PARSER_THROWCHECK(Const, false, _T("+a"), 1) - PARSER_THROWCHECK(Const, false, _T("-a"), 1) - PARSER_THROWCHECK(Const, false, _T("a-"), 1) - PARSER_THROWCHECK(Const, false, _T("a*"), 1) - PARSER_THROWCHECK(Const, false, _T("a?"), 1) - PARSER_THROWCHECK(Const, true, _T("a"), 1) - PARSER_THROWCHECK(Const, true, _T("a_min"), 1) - PARSER_THROWCHECK(Const, true, _T("a_min0"), 1) - PARSER_THROWCHECK(Const, true, _T("a_min9"), 1) - // variable names - value_type a; - p.ClearConst(); - PARSER_THROWCHECK(Var, false, _T("123abc"), &a) - PARSER_THROWCHECK(Var, false, _T("9a"), &a) - PARSER_THROWCHECK(Var, false, _T("0a"), &a) - PARSER_THROWCHECK(Var, false, _T("+a"), &a) - PARSER_THROWCHECK(Var, false, _T("-a"), &a) - PARSER_THROWCHECK(Var, false, _T("?a"), &a) - PARSER_THROWCHECK(Var, false, _T("!a"), &a) - PARSER_THROWCHECK(Var, false, _T("a+"), &a) - PARSER_THROWCHECK(Var, false, _T("a-"), &a) - PARSER_THROWCHECK(Var, false, _T("a*"), &a) - PARSER_THROWCHECK(Var, false, _T("a?"), &a) - PARSER_THROWCHECK(Var, true, _T("a"), &a) - PARSER_THROWCHECK(Var, true, _T("a_min"), &a) - PARSER_THROWCHECK(Var, true, _T("a_min0"), &a) - PARSER_THROWCHECK(Var, true, _T("a_min9"), &a) - PARSER_THROWCHECK(Var, false, _T("a_min9"), 0) - // Postfix operators - // fail - PARSER_THROWCHECK(PostfixOprt, false, _T("(k"), f1of1) - PARSER_THROWCHECK(PostfixOprt, false, _T("9+"), f1of1) - PARSER_THROWCHECK(PostfixOprt, false, _T("+"), 0) - // pass - PARSER_THROWCHECK(PostfixOprt, true, _T("-a"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("?a"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("_"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("#"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("&&"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("||"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("&"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("|"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("++"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("--"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("?>"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("?<"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("**"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("xor"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("and"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("or"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("not"), f1of1) - PARSER_THROWCHECK(PostfixOprt, true, _T("!"), f1of1) - // Binary operator - // The following must fail with builtin operators activated - // p.EnableBuiltInOp(true); -> this is the default - p.ClearPostfixOprt(); - PARSER_THROWCHECK(Oprt, false, _T("+"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("-"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("*"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("/"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("^"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("&&"), f1of2) - PARSER_THROWCHECK(Oprt, false, _T("||"), f1of2) - // without activated built in operators it should work - p.EnableBuiltInOprt(false); - PARSER_THROWCHECK(Oprt, true, _T("+"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("-"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("*"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("/"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("^"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("&&"), f1of2) - PARSER_THROWCHECK(Oprt, true, _T("||"), f1of2) - #undef PARSER_THROWCHECK - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------- - int ParserTester::TestSyntax() - { - int iStat = 0; - mu::console() << _T("testing syntax engine..."); - - iStat += ThrowTest(_T("1,"), ecUNEXPECTED_EOF); // incomplete hex definition - iStat += ThrowTest(_T("a,"), ecUNEXPECTED_EOF); // incomplete hex definition - iStat += ThrowTest(_T("sin(8),"), ecUNEXPECTED_EOF); // incomplete hex definition - iStat += ThrowTest(_T("(sin(8)),"), ecUNEXPECTED_EOF); // incomplete hex definition - iStat += ThrowTest(_T("a{m},"), ecUNEXPECTED_EOF); // incomplete hex definition - - iStat += EqnTest(_T("(1+ 2*a)"), 3, true); // Spaces within formula - iStat += EqnTest(_T("sqrt((4))"), 2, true); // Multiple brackets - iStat += EqnTest(_T("sqrt((2)+2)"), 2, true);// Multiple brackets - iStat += EqnTest(_T("sqrt(2+(2))"), 2, true);// Multiple brackets - iStat += EqnTest(_T("sqrt(a+(3))"), 2, true);// Multiple brackets - iStat += EqnTest(_T("sqrt((3)+a)"), 2, true);// Multiple brackets - iStat += EqnTest(_T("order(1,2)"), 1, true); // May not cause name collision with operator "or" - iStat += EqnTest(_T("(2+"), 0, false); // missing closing bracket - iStat += EqnTest(_T("2++4"), 0, false); // unexpected operator - iStat += EqnTest(_T("2+-4"), 0, false); // unexpected operator - iStat += EqnTest(_T("(2+)"), 0, false); // unexpected closing bracket - iStat += EqnTest(_T("--2"), 0, false); // double sign - iStat += EqnTest(_T("ksdfj"), 0, false); // unknown token - iStat += EqnTest(_T("()"), 0, false); // empty bracket without a function - iStat += EqnTest(_T("5+()"), 0, false); // empty bracket without a function - iStat += EqnTest(_T("sin(cos)"), 0, false); // unexpected function - iStat += EqnTest(_T("5t6"), 0, false); // unknown token - iStat += EqnTest(_T("5 t 6"), 0, false); // unknown token - iStat += EqnTest(_T("8*"), 0, false); // unexpected end of formula - iStat += EqnTest(_T(",3"), 0, false); // unexpected comma - iStat += EqnTest(_T("3,5"), 0, false); // unexpected comma - iStat += EqnTest(_T("sin(8,8)"), 0, false); // too many function args - iStat += EqnTest(_T("(7,8)"), 0, false); // too many function args - iStat += EqnTest(_T("sin)"), 0, false); // unexpected closing bracket - iStat += EqnTest(_T("a)"), 0, false); // unexpected closing bracket - iStat += EqnTest(_T("pi)"), 0, false); // unexpected closing bracket - iStat += EqnTest(_T("sin(())"), 0, false); // unexpected closing bracket - iStat += EqnTest(_T("sin()"), 0, false); // unexpected closing bracket - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------- - int ParserTester::TestVarConst() - { - int iStat = 0; - mu::console() << _T("testing variable/constant detection..."); - - // Test if the result changes when a variable changes - iStat += EqnTestWithVarChange( _T("a"), 1, 1, 2, 2 ); - iStat += EqnTestWithVarChange( _T("2*a"), 2, 4, 3, 6 ); - - // distinguish constants with same basename - iStat += EqnTest( _T("const"), 1, true); - iStat += EqnTest( _T("const1"), 2, true); - iStat += EqnTest( _T("const2"), 3, true); - iStat += EqnTest( _T("2*const"), 2, true); - iStat += EqnTest( _T("2*const1"), 4, true); - iStat += EqnTest( _T("2*const2"), 6, true); - iStat += EqnTest( _T("2*const+1"), 3, true); - iStat += EqnTest( _T("2*const1+1"), 5, true); - iStat += EqnTest( _T("2*const2+1"), 7, true); - iStat += EqnTest( _T("const"), 0, false); - iStat += EqnTest( _T("const1"), 0, false); - iStat += EqnTest( _T("const2"), 0, false); - - // distinguish variables with same basename - iStat += EqnTest( _T("a"), 1, true); - iStat += EqnTest( _T("aa"), 2, true); - iStat += EqnTest( _T("2*a"), 2, true); - iStat += EqnTest( _T("2*aa"), 4, true); - iStat += EqnTest( _T("2*a-1"), 1, true); - iStat += EqnTest( _T("2*aa-1"), 3, true); - - // custom value recognition - iStat += EqnTest( _T("0xff"), 255, true); - iStat += EqnTest( _T("0x97 + 0xff"), 406, true); - - // Finally test querying of used variables - try - { - int idx; - mu::Parser p; - mu::value_type vVarVal[] = { 1, 2, 3, 4, 5}; - p.DefineVar( _T("a"), &vVarVal[0]); - p.DefineVar( _T("b"), &vVarVal[1]); - p.DefineVar( _T("c"), &vVarVal[2]); - p.DefineVar( _T("d"), &vVarVal[3]); - p.DefineVar( _T("e"), &vVarVal[4]); - - // Test lookup of defined variables - // 4 used variables - p.SetExpr( _T("a+b+c+d") ); - mu::varmap_type UsedVar = p.GetUsedVar(); - int iCount = (int)UsedVar.size(); - if (iCount!=4) - throw false; - - // the next check will fail if the parser - // erroneously creates new variables internally - if (p.GetVar().size()!=5) - throw false; - - mu::varmap_type::const_iterator item = UsedVar.begin(); - for (idx=0; item!=UsedVar.end(); ++item) - { - if (&vVarVal[idx++]!=item->second) - throw false; - } - - // Test lookup of undefined variables - p.SetExpr( _T("undef1+undef2+undef3") ); - UsedVar = p.GetUsedVar(); - iCount = (int)UsedVar.size(); - if (iCount!=3) - throw false; - - // the next check will fail if the parser - // erroneously creates new variables internally - if (p.GetVar().size()!=5) - throw false; - - for (item = UsedVar.begin(); item!=UsedVar.end(); ++item) - { - if (item->second!=0) - throw false; // all pointers to undefined variables must be null - } - - // 1 used variables - p.SetExpr( _T("a+b") ); - UsedVar = p.GetUsedVar(); - iCount = (int)UsedVar.size(); - if (iCount!=2) throw false; - item = UsedVar.begin(); - for (idx=0; item!=UsedVar.end(); ++item) - if (&vVarVal[idx++]!=item->second) throw false; - - } - catch(...) - { - iStat += 1; - } - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------- - int ParserTester::TestMultiArg() - { - int iStat = 0; - mu::console() << _T("testing multiarg functions..."); - - // Compound expressions - iStat += EqnTest( _T("1,2,3"), 3, true); - iStat += EqnTest( _T("a,b,c"), 3, true); - iStat += EqnTest( _T("a=10,b=20,c=a*b"), 200, true); - iStat += EqnTest( _T("1,\n2,\n3"), 3, true); - iStat += EqnTest( _T("a,\nb,\nc"), 3, true); - iStat += EqnTest( _T("a=10,\nb=20,\nc=a*b"), 200, true); - iStat += EqnTest( _T("1,\r\n2,\r\n3"), 3, true); - iStat += EqnTest( _T("a,\r\nb,\r\nc"), 3, true); - iStat += EqnTest( _T("a=10,\r\nb=20,\r\nc=a*b"), 200, true); - - // picking the right argument - iStat += EqnTest( _T("f1of1(1)"), 1, true); - iStat += EqnTest( _T("f1of2(1, 2)"), 1, true); - iStat += EqnTest( _T("f2of2(1, 2)"), 2, true); - iStat += EqnTest( _T("f1of3(1, 2, 3)"), 1, true); - iStat += EqnTest( _T("f2of3(1, 2, 3)"), 2, true); - iStat += EqnTest( _T("f3of3(1, 2, 3)"), 3, true); - iStat += EqnTest( _T("f1of4(1, 2, 3, 4)"), 1, true); - iStat += EqnTest( _T("f2of4(1, 2, 3, 4)"), 2, true); - iStat += EqnTest( _T("f3of4(1, 2, 3, 4)"), 3, true); - iStat += EqnTest( _T("f4of4(1, 2, 3, 4)"), 4, true); - iStat += EqnTest( _T("f1of5(1, 2, 3, 4, 5)"), 1, true); - iStat += EqnTest( _T("f2of5(1, 2, 3, 4, 5)"), 2, true); - iStat += EqnTest( _T("f3of5(1, 2, 3, 4, 5)"), 3, true); - iStat += EqnTest( _T("f4of5(1, 2, 3, 4, 5)"), 4, true); - iStat += EqnTest( _T("f5of5(1, 2, 3, 4, 5)"), 5, true); - // Too few arguments / Too many arguments - iStat += EqnTest( _T("1+ping()"), 11, true); - iStat += EqnTest( _T("ping()+1"), 11, true); - iStat += EqnTest( _T("2*ping()"), 20, true); - iStat += EqnTest( _T("ping()*2"), 20, true); - iStat += EqnTest( _T("ping(1,2)"), 0, false); - iStat += EqnTest( _T("1+ping(1,2)"), 0, false); - iStat += EqnTest( _T("f1of1(1,2)"), 0, false); - iStat += EqnTest( _T("f1of1()"), 0, false); - iStat += EqnTest( _T("f1of2(1, 2, 3)"), 0, false); - iStat += EqnTest( _T("f1of2(1)"), 0, false); - iStat += EqnTest( _T("f1of3(1, 2, 3, 4)"), 0, false); - iStat += EqnTest( _T("f1of3(1)"), 0, false); - iStat += EqnTest( _T("f1of4(1, 2, 3, 4, 5)"), 0, false); - iStat += EqnTest( _T("f1of4(1)"), 0, false); - iStat += EqnTest( _T("(1,2,3)"), 0, false); - iStat += EqnTest( _T("1,2,3"), 0, false); - iStat += EqnTest( _T("(1*a,2,3)"), 0, false); - iStat += EqnTest( _T("1,2*a,3"), 0, false); - - // correct calculation of arguments - iStat += EqnTest( _T("min(a, 1)"), 1, true); - iStat += EqnTest( _T("min(3*2, 1)"), 1, true); - iStat += EqnTest( _T("min(3*2, 1)"), 6, false); - iStat += EqnTest( _T("firstArg(2,3,4)"), 2, true); - iStat += EqnTest( _T("lastArg(2,3,4)"), 4, true); - iStat += EqnTest( _T("min(3*a+1, 1)"), 1, true); - iStat += EqnTest( _T("max(3*a+1, 1)"), 4, true); - iStat += EqnTest( _T("max(3*a+1, 1)*2"), 8, true); - iStat += EqnTest( _T("2*max(3*a+1, 1)+2"), 10, true); - - // functions with Variable argument count - iStat += EqnTest( _T("sum(a)"), 1, true); - iStat += EqnTest( _T("sum(1,2,3)"), 6, true); - iStat += EqnTest( _T("sum(a,b,c)"), 6, true); - iStat += EqnTest( _T("sum(1,-max(1,2),3)*2"), 4, true); - iStat += EqnTest( _T("2*sum(1,2,3)"), 12, true); - iStat += EqnTest( _T("2*sum(1,2,3)+2"), 14, true); - iStat += EqnTest( _T("2*sum(-1,2,3)+2"), 10, true); - iStat += EqnTest( _T("2*sum(-1,2,-(-a))+2"), 6, true); - iStat += EqnTest( _T("2*sum(-1,10,-a)+2"), 18, true); - iStat += EqnTest( _T("2*sum(1,2,3)*2"), 24, true); - iStat += EqnTest( _T("sum(1,-max(1,2),3)*2"), 4, true); - iStat += EqnTest( _T("sum(1*3, 4, a+2)"), 10, true); - iStat += EqnTest( _T("sum(1*3, 2*sum(1,2,2), a+2)"), 16, true); - iStat += EqnTest( _T("sum(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2)"), 24, true); - - // some failures - iStat += EqnTest( _T("sum()"), 0, false); - iStat += EqnTest( _T("sum(,)"), 0, false); - iStat += EqnTest( _T("sum(1,2,)"), 0, false); - iStat += EqnTest( _T("sum(,1,2)"), 0, false); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - - //--------------------------------------------------------------------------- - int ParserTester::TestInfixOprt() - { - int iStat(0); - mu::console() << "testing infix operators..."; - - iStat += EqnTest( _T("+1"), +1, true); - iStat += EqnTest( _T("-(+1)"), -1, true); - iStat += EqnTest( _T("-(+1)*2"), -2, true); - iStat += EqnTest( _T("-(+2)*sqrt(4)"), -4, true); - iStat += EqnTest( _T("3-+a"), 2, true); - iStat += EqnTest( _T("+1*3"), 3, true); - - iStat += EqnTest( _T("-1"), -1, true); - iStat += EqnTest( _T("-(-1)"), 1, true); - iStat += EqnTest( _T("-(-1)*2"), 2, true); - iStat += EqnTest( _T("-(-2)*sqrt(4)"), 4, true); - iStat += EqnTest( _T("-_pi"), -PARSER_CONST_PI, true); - iStat += EqnTest( _T("-a"), -1, true); - iStat += EqnTest( _T("-(a)"), -1, true); - iStat += EqnTest( _T("-(-a)"), 1, true); - iStat += EqnTest( _T("-(-a)*2"), 2, true); - iStat += EqnTest( _T("-(8)"), -8, true); - iStat += EqnTest( _T("-8"), -8, true); - iStat += EqnTest( _T("-(2+1)"), -3, true); - iStat += EqnTest( _T("-(f1of1(1+2*3)+1*2)"), -9, true); - iStat += EqnTest( _T("-(-f1of1(1+2*3)+1*2)"), 5, true); - iStat += EqnTest( _T("-sin(8)"), -0.989358, true); - iStat += EqnTest( _T("3-(-a)"), 4, true); - iStat += EqnTest( _T("3--a"), 4, true); - iStat += EqnTest( _T("-1*3"), -3, true); - - // Postfix / infix priorities - iStat += EqnTest( _T("~2#"), 8, true); - iStat += EqnTest( _T("~f1of1(2)#"), 8, true); - iStat += EqnTest( _T("~(b)#"), 8, true); - iStat += EqnTest( _T("(~b)#"), 12, true); - iStat += EqnTest( _T("~(2#)"), 8, true); - iStat += EqnTest( _T("~(f1of1(2)#)"), 8, true); - // - iStat += EqnTest( _T("-2^2"),-4, true); - iStat += EqnTest( _T("-(a+b)^2"),-9, true); - iStat += EqnTest( _T("(-3)^2"),9, true); - iStat += EqnTest( _T("-(-2^2)"),4, true); - iStat += EqnTest( _T("3+-3^2"),-6, true); - // The following assumes use of sqr as postfix operator ("§") together - // with a sign operator of low priority: - iStat += EqnTest( _T("-2'"), -4, true); - iStat += EqnTest( _T("-(1+1)'"),-4, true); - iStat += EqnTest( _T("2+-(1+1)'"),-2, true); - iStat += EqnTest( _T("2+-2'"), -2, true); - // This is the classic behaviour of the infix sign operator (here: "$") which is - // now deprecated: - iStat += EqnTest( _T("$2^2"),4, true); - iStat += EqnTest( _T("$(a+b)^2"),9, true); - iStat += EqnTest( _T("($3)^2"),9, true); - iStat += EqnTest( _T("$($2^2)"),-4, true); - iStat += EqnTest( _T("3+$3^2"),12, true); - - // infix operators sharing the first few characters - iStat += EqnTest( _T("~ 123"), 123+2, true); - iStat += EqnTest( _T("~~ 123"), 123+2, true); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - - //--------------------------------------------------------------------------- - int ParserTester::TestPostFix() - { - int iStat = 0; - mu::console() << _T("testing postfix operators..."); - - // application - iStat += EqnTest( _T("3{m}+5"), 5.003, true); - iStat += EqnTest( _T("1000{m}"), 1, true); - iStat += EqnTest( _T("1000 {m}"), 1, true); - iStat += EqnTest( _T("(a){m}"), 1e-3, true); - iStat += EqnTest( _T("a{m}"), 1e-3, true); - iStat += EqnTest( _T("a {m}"), 1e-3, true); - iStat += EqnTest( _T("-(a){m}"), -1e-3, true); - iStat += EqnTest( _T("-2{m}"), -2e-3, true); - iStat += EqnTest( _T("-2 {m}"), -2e-3, true); - iStat += EqnTest( _T("f1of1(1000){m}"), 1, true); - iStat += EqnTest( _T("-f1of1(1000){m}"), -1, true); - iStat += EqnTest( _T("-f1of1(-1000){m}"), 1, true); - iStat += EqnTest( _T("f4of4(0,0,0,1000){m}"), 1, true); - iStat += EqnTest( _T("2+(a*1000){m}"), 3, true); - - // can postfix operators "m" und "meg" be told apart properly? - iStat += EqnTest( _T("2*3000meg+2"), 2*3e9+2, true); - - // some incorrect results - iStat += EqnTest( _T("1000{m}"), 0.1, false); - iStat += EqnTest( _T("(a){m}"), 2, false); - // failure due to syntax checking - iStat += ThrowTest(_T("0x"), ecUNASSIGNABLE_TOKEN); // incomplete hex definition - iStat += ThrowTest(_T("3+"), ecUNEXPECTED_EOF); - iStat += ThrowTest( _T("4 + {m}"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("{m}4"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("sin({m})"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("{m} {m}"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("{m}(8)"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("4,{m}"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("-{m}"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest( _T("2(-{m})"), ecUNEXPECTED_PARENS); - iStat += ThrowTest( _T("2({m})"), ecUNEXPECTED_PARENS); - - iStat += ThrowTest( _T("multi*1.0"), ecUNASSIGNABLE_TOKEN); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------- - int ParserTester::TestExpression() - { - int iStat = 0; - mu::console() << _T("testing expression samples..."); - - value_type b = 2; - - // Optimization - iStat += EqnTest( _T("2*b*5"), 20, true); - iStat += EqnTest( _T("2*b*5 + 4*b"), 28, true); - iStat += EqnTest( _T("2*a/3"), 2.0/3.0, true); - - // Addition auf cmVARMUL - iStat += EqnTest( _T("3+b"), b+3, true); - iStat += EqnTest( _T("b+3"), b+3, true); - iStat += EqnTest( _T("b*3+2"), b*3+2, true); - iStat += EqnTest( _T("3*b+2"), b*3+2, true); - iStat += EqnTest( _T("2+b*3"), b*3+2, true); - iStat += EqnTest( _T("2+3*b"), b*3+2, true); - iStat += EqnTest( _T("b+3*b"), b+3*b, true); - iStat += EqnTest( _T("3*b+b"), b+3*b, true); - - iStat += EqnTest( _T("2+b*3+b"), 2+b*3+b, true); - iStat += EqnTest( _T("b+2+b*3"), b+2+b*3, true); - - iStat += EqnTest( _T("(2*b+1)*4"), (2*b+1)*4, true); - iStat += EqnTest( _T("4*(2*b+1)"), (2*b+1)*4, true); - - // operator precedences - iStat += EqnTest( _T("1+2-3*4/5^6"), 2.99923, true); - iStat += EqnTest( _T("1^2/3*4-5+6"), 2.33333333, true); - iStat += EqnTest( _T("1+2*3"), 7, true); - iStat += EqnTest( _T("1+2*3"), 7, true); - iStat += EqnTest( _T("(1+2)*3"), 9, true); - iStat += EqnTest( _T("(1+2)*(-3)"), -9, true); - iStat += EqnTest( _T("2/4"), 0.5, true); - - iStat += EqnTest( _T("exp(ln(7))"), 7, true); - iStat += EqnTest( _T("e^ln(7)"), 7, true); - iStat += EqnTest( _T("e^(ln(7))"), 7, true); - iStat += EqnTest( _T("(e^(ln(7)))"), 7, true); - iStat += EqnTest( _T("1-(e^(ln(7)))"), -6, true); - iStat += EqnTest( _T("2*(e^(ln(7)))"), 14, true); - iStat += EqnTest( _T("10^log(5)"), pow(10.0, log(5.0)), true); - iStat += EqnTest( _T("10^log10(5)"), 5, true); - iStat += EqnTest( _T("2^log2(4)"), 4, true); - iStat += EqnTest( _T("-(sin(0)+1)"), -1, true); - iStat += EqnTest( _T("-(2^1.1)"), -2.14354692, true); - - iStat += EqnTest( _T("(cos(2.41)/b)"), -0.372056, true); - iStat += EqnTest( _T("(1*(2*(3*(4*(5*(6*(a+b)))))))"), 2160, true); - iStat += EqnTest( _T("(1*(2*(3*(4*(5*(6*(7*(a+b))))))))"), 15120, true); - iStat += EqnTest( _T("(a/((((b+(((e*(((((pi*((((3.45*((pi+a)+pi))+b)+b)*a))+0.68)+e)+a)/a))+a)+b))+b)*a)-pi))"), 0.00377999, true); - - // long formula (Reference: Matlab) - iStat += EqnTest( - _T("(((-9))-e/(((((((pi-(((-7)+(-3)/4/e))))/(((-5))-2)-((pi+(-0))*(sqrt((e+e))*(-8))*(((-pi)+(-pi)-(-9)*(6*5))") - _T("/(-e)-e))/2)/((((sqrt(2/(-e)+6)-(4-2))+((5/(-2))/(1*(-pi)+3))/8)*pi*((pi/((-2)/(-6)*1*(-1))*(-6)+(-e)))))/") - _T("((e+(-2)+(-e)*((((-3)*9+(-e)))+(-9)))))))-((((e-7+(((5/pi-(3/1+pi)))))/e)/(-5))/(sqrt((((((1+(-7))))+((((-") - _T("e)*(-e)))-8))*(-5)/((-e)))*(-6)-((((((-2)-(-9)-(-e)-1)/3))))/(sqrt((8+(e-((-6))+(9*(-9))))*(((3+2-8))*(7+6") - _T("+(-5))+((0/(-e)*(-pi))+7)))+(((((-e)/e/e)+((-6)*5)*e+(3+(-5)/pi))))+pi))/sqrt((((9))+((((pi))-8+2))+pi))/e") - _T("*4)*((-5)/(((-pi))*(sqrt(e)))))-(((((((-e)*(e)-pi))/4+(pi)*(-9)))))))+(-pi)"), -12.23016549, true); - - // long formula (Reference: Matlab) - iStat += EqnTest( - _T("(atan(sin((((((((((((((((pi/cos((a/((((0.53-b)-pi)*e)/b))))+2.51)+a)-0.54)/0.98)+b)*b)+e)/a)+b)+a)+b)+pi)/e") - _T(")+a)))*2.77)"), -2.16995656, true); - - // long formula (Reference: Matlab) - iStat += EqnTest( _T("1+2-3*4/5^6*(2*(1-5+(3*7^9)*(4+6*7-3)))+12"), -7995810.09926, true); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - - - //--------------------------------------------------------------------------- - int ParserTester::TestIfThenElse() - { - int iStat = 0; - mu::console() << _T("testing if-then-else operator..."); - - // Test error detection - iStat += ThrowTest(_T(":3"), ecUNEXPECTED_CONDITIONAL); - iStat += ThrowTest(_T("? 1 : 2"), ecUNEXPECTED_CONDITIONAL); - iStat += ThrowTest(_T("(a<b) ? (b<c) ? 1 : 2"), ecMISSING_ELSE_CLAUSE); - iStat += ThrowTest(_T("(a<b) ? 1"), ecMISSING_ELSE_CLAUSE); - iStat += ThrowTest(_T("(a<b) ? a"), ecMISSING_ELSE_CLAUSE); - iStat += ThrowTest(_T("(a<b) ? a+b"), ecMISSING_ELSE_CLAUSE); - iStat += ThrowTest(_T("a : b"), ecMISPLACED_COLON); - iStat += ThrowTest(_T("1 : 2"), ecMISPLACED_COLON); - iStat += ThrowTest(_T("(1) ? 1 : 2 : 3"), ecMISPLACED_COLON); - iStat += ThrowTest(_T("(true) ? 1 : 2 : 3"), ecUNASSIGNABLE_TOKEN); - - iStat += EqnTest(_T("1 ? 128 : 255"), 128, true); - iStat += EqnTest(_T("1<2 ? 128 : 255"), 128, true); - iStat += EqnTest(_T("a<b ? 128 : 255"), 128, true); - iStat += EqnTest(_T("(a<b) ? 128 : 255"), 128, true); - iStat += EqnTest(_T("(1) ? 10 : 11"), 10, true); - iStat += EqnTest(_T("(0) ? 10 : 11"), 11, true); - iStat += EqnTest(_T("(1) ? a+b : c+d"), 3, true); - iStat += EqnTest(_T("(0) ? a+b : c+d"), 1, true); - iStat += EqnTest(_T("(1) ? 0 : 1"), 0, true); - iStat += EqnTest(_T("(0) ? 0 : 1"), 1, true); - iStat += EqnTest(_T("(a<b) ? 10 : 11"), 10, true); - iStat += EqnTest(_T("(a>b) ? 10 : 11"), 11, true); - iStat += EqnTest(_T("(a<b) ? c : d"), 3, true); - iStat += EqnTest(_T("(a>b) ? c : d"), -2, true); - - iStat += EqnTest(_T("(a>b) ? 1 : 0"), 0, true); - iStat += EqnTest(_T("((a>b) ? 1 : 0) ? 1 : 2"), 2, true); - iStat += EqnTest(_T("((a>b) ? 1 : 0) ? 1 : sum((a>b) ? 1 : 2)"), 2, true); - iStat += EqnTest(_T("((a>b) ? 0 : 1) ? 1 : sum((a>b) ? 1 : 2)"), 1, true); - - iStat += EqnTest(_T("sum((a>b) ? 1 : 2)"), 2, true); - iStat += EqnTest(_T("sum((1) ? 1 : 2)"), 1, true); - iStat += EqnTest(_T("sum((a>b) ? 1 : 2, 100)"), 102, true); - iStat += EqnTest(_T("sum((1) ? 1 : 2, 100)"), 101, true); - iStat += EqnTest(_T("sum(3, (a>b) ? 3 : 10)"), 13, true); - iStat += EqnTest(_T("sum(3, (a<b) ? 3 : 10)"), 6, true); - iStat += EqnTest(_T("10*sum(3, (a>b) ? 3 : 10)"), 130, true); - iStat += EqnTest(_T("10*sum(3, (a<b) ? 3 : 10)"), 60, true); - iStat += EqnTest(_T("sum(3, (a>b) ? 3 : 10)*10"), 130, true); - iStat += EqnTest(_T("sum(3, (a<b) ? 3 : 10)*10"), 60, true); - iStat += EqnTest(_T("(a<b) ? sum(3, (a<b) ? 3 : 10)*10 : 99"), 60, true); - iStat += EqnTest(_T("(a>b) ? sum(3, (a<b) ? 3 : 10)*10 : 99"), 99, true); - iStat += EqnTest(_T("(a<b) ? sum(3, (a<b) ? 3 : 10,10,20)*10 : 99"), 360, true); - iStat += EqnTest(_T("(a>b) ? sum(3, (a<b) ? 3 : 10,10,20)*10 : 99"), 99, true); - iStat += EqnTest(_T("(a>b) ? sum(3, (a<b) ? 3 : 10,10,20)*10 : sum(3, (a<b) ? 3 : 10)*10"), 60, true); - - // todo: auch für muParserX hinzufügen! - iStat += EqnTest(_T("(a<b)&&(a<b) ? 128 : 255"), 128, true); - iStat += EqnTest(_T("(a>b)&&(a<b) ? 128 : 255"), 255, true); - iStat += EqnTest(_T("(1<2)&&(1<2) ? 128 : 255"), 128, true); - iStat += EqnTest(_T("(1>2)&&(1<2) ? 128 : 255"), 255, true); - iStat += EqnTest(_T("((1<2)&&(1<2)) ? 128 : 255"), 128, true); - iStat += EqnTest(_T("((1>2)&&(1<2)) ? 128 : 255"), 255, true); - iStat += EqnTest(_T("((a<b)&&(a<b)) ? 128 : 255"), 128, true); - iStat += EqnTest(_T("((a>b)&&(a<b)) ? 128 : 255"), 255, true); - - iStat += EqnTest(_T("1>0 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 64"), 255, true); - iStat += EqnTest(_T("1>0 ? 1>2 ? 128 : 255 :(1>0 ? 32 : 64)"), 255, true); - iStat += EqnTest(_T("1>0 ? 1>0 ? 128 : 255 : 1>2 ? 32 : 64"), 128, true); - iStat += EqnTest(_T("1>0 ? 1>0 ? 128 : 255 :(1>2 ? 32 : 64)"), 128, true); - iStat += EqnTest(_T("1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 64"), 32, true); - iStat += EqnTest(_T("1>2 ? 1>0 ? 128 : 255 : 1>2 ? 32 : 64"), 64, true); - iStat += EqnTest(_T("1>0 ? 50 : 1>0 ? 128 : 255"), 50, true); - iStat += EqnTest(_T("1>0 ? 50 : (1>0 ? 128 : 255)"), 50, true); - iStat += EqnTest(_T("1>0 ? 1>0 ? 128 : 255 : 50"), 128, true); - iStat += EqnTest(_T("1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 1>2 ? 64 : 16"), 32, true); - iStat += EqnTest(_T("1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 :(1>2 ? 64 : 16)"), 32, true); - iStat += EqnTest(_T("1>0 ? 1>2 ? 128 : 255 : 1>0 ? 32 :1>2 ? 64 : 16"), 255, true); - iStat += EqnTest(_T("1>0 ? 1>2 ? 128 : 255 : (1>0 ? 32 :1>2 ? 64 : 16)"), 255, true); - iStat += EqnTest(_T("1 ? 0 ? 128 : 255 : 1 ? 32 : 64"), 255, true); - - // assignment operators - iStat += EqnTest(_T("a= 0 ? 128 : 255, a"), 255, true); - iStat += EqnTest(_T("a=((a>b)&&(a<b)) ? 128 : 255, a"), 255, true); - iStat += EqnTest(_T("c=(a<b)&&(a<b) ? 128 : 255, c"), 128, true); - iStat += EqnTest(_T("0 ? a=a+1 : 666, a"), 1, true); - iStat += EqnTest(_T("1?a=10:a=20, a"), 10, true); - iStat += EqnTest(_T("0?a=10:a=20, a"), 20, true); - iStat += EqnTest(_T("0?a=sum(3,4):10, a"), 1, true); // a should not change its value due to lazy calculation - - iStat += EqnTest(_T("a=1?b=1?3:4:5, a"), 3, true); - iStat += EqnTest(_T("a=1?b=1?3:4:5, b"), 3, true); - iStat += EqnTest(_T("a=0?b=1?3:4:5, a"), 5, true); - iStat += EqnTest(_T("a=0?b=1?3:4:5, b"), 2, true); - - iStat += EqnTest(_T("a=1?5:b=1?3:4, a"), 5, true); - iStat += EqnTest(_T("a=1?5:b=1?3:4, b"), 2, true); - iStat += EqnTest(_T("a=0?5:b=1?3:4, a"), 3, true); - iStat += EqnTest(_T("a=0?5:b=1?3:4, b"), 3, true); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - //--------------------------------------------------------------------------- - int ParserTester::TestException() - { - int iStat = 0; - mu::console() << _T("testing error codes..."); - - iStat += ThrowTest(_T("3+"), ecUNEXPECTED_EOF); - iStat += ThrowTest(_T("3+)"), ecUNEXPECTED_PARENS); - iStat += ThrowTest(_T("()"), ecUNEXPECTED_PARENS); - iStat += ThrowTest(_T("3+()"), ecUNEXPECTED_PARENS); - iStat += ThrowTest(_T("sin(3,4)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest(_T("sin()"), ecTOO_FEW_PARAMS); - iStat += ThrowTest(_T("(1+2"), ecMISSING_PARENS); - iStat += ThrowTest(_T("sin(3)3"), ecUNEXPECTED_VAL); - iStat += ThrowTest(_T("sin(3)xyz"), ecUNASSIGNABLE_TOKEN); - iStat += ThrowTest(_T("sin(3)cos(3)"), ecUNEXPECTED_FUN); - iStat += ThrowTest(_T("a+b+c=10"), ecUNEXPECTED_OPERATOR); - iStat += ThrowTest(_T("a=b=3"), ecUNEXPECTED_OPERATOR); - -#if defined(MUP_MATH_EXCEPTIONS) - // divide by zero whilst constant folding - iStat += ThrowTest(_T("1/0"), ecDIV_BY_ZERO); - // square root of a negative number - iStat += ThrowTest(_T("sqrt(-1)"), ecDOMAIN_ERROR); - // logarithms of zero - iStat += ThrowTest(_T("ln(0)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log2(0)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log10(0)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log(0)"), ecDOMAIN_ERROR); - // logarithms of negative values - iStat += ThrowTest(_T("ln(-1)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log2(-1)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log10(-1)"), ecDOMAIN_ERROR); - iStat += ThrowTest(_T("log(-1)"), ecDOMAIN_ERROR); -#endif - - // functions without parameter - iStat += ThrowTest( _T("3+ping(2)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("3+ping(a+2)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("3+ping(sin(a)+2)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("3+ping(1+sin(a))"), ecTOO_MANY_PARAMS); - - // String function related - iStat += ThrowTest( _T("valueof(\"xxx\")"), 999, false); - iStat += ThrowTest( _T("valueof()"), ecUNEXPECTED_PARENS); - iStat += ThrowTest( _T("1+valueof(\"abc\""), ecMISSING_PARENS); - iStat += ThrowTest( _T("valueof(\"abc\""), ecMISSING_PARENS); - iStat += ThrowTest( _T("valueof(\"abc"), ecUNTERMINATED_STRING); - iStat += ThrowTest( _T("valueof(\"abc\",3)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("valueof(3)"), ecSTRING_EXPECTED); - iStat += ThrowTest( _T("sin(\"abc\")"), ecVAL_EXPECTED); - iStat += ThrowTest( _T("valueof(\"\\\"abc\\\"\")"), 999, false); - iStat += ThrowTest( _T("\"hello world\""), ecSTR_RESULT); - iStat += ThrowTest( _T("(\"hello world\")"), ecSTR_RESULT); - iStat += ThrowTest( _T("\"abcd\"+100"), ecOPRT_TYPE_CONFLICT); - iStat += ThrowTest( _T("\"a\"+\"b\""), ecOPRT_TYPE_CONFLICT); - iStat += ThrowTest( _T("strfun1(\"100\",3)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("strfun2(\"100\",3,5)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("strfun3(\"100\",3,5,6)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("strfun2(\"100\")"), ecTOO_FEW_PARAMS); - iStat += ThrowTest( _T("strfun3(\"100\",6)"), ecTOO_FEW_PARAMS); - iStat += ThrowTest( _T("strfun2(1,1)"), ecSTRING_EXPECTED); - iStat += ThrowTest( _T("strfun2(a,1)"), ecSTRING_EXPECTED); - iStat += ThrowTest( _T("strfun2(1,1,1)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("strfun2(a,1,1)"), ecTOO_MANY_PARAMS); - iStat += ThrowTest( _T("strfun3(1,2,3)"), ecSTRING_EXPECTED); - iStat += ThrowTest( _T("strfun3(1, \"100\",3)"), ecSTRING_EXPECTED); - iStat += ThrowTest( _T("strfun3(\"1\", \"100\",3)"), ecVAL_EXPECTED); - iStat += ThrowTest( _T("strfun3(\"1\", 3, \"100\")"), ecVAL_EXPECTED); - iStat += ThrowTest( _T("strfun3(\"1\", \"100\", \"100\", \"100\")"), ecTOO_MANY_PARAMS); - - // assignment operator - iStat += ThrowTest( _T("3=4"), ecUNEXPECTED_OPERATOR); - iStat += ThrowTest( _T("sin(8)=4"), ecUNEXPECTED_OPERATOR); - iStat += ThrowTest( _T("\"test\"=a"), ecUNEXPECTED_OPERATOR); - - // <ibg 20090529> - // this is now legal, for reference see: - // https://sourceforge.net/forum/message.php?msg_id=7411373 - // iStat += ThrowTest( _T("sin=9"), ecUNEXPECTED_OPERATOR); - // </ibg> - - iStat += ThrowTest( _T("(8)=5"), ecUNEXPECTED_OPERATOR); - iStat += ThrowTest( _T("(a)=5"), ecUNEXPECTED_OPERATOR); - iStat += ThrowTest( _T("a=\"tttt\""), ecOPRT_TYPE_CONFLICT); - - if (iStat==0) - mu::console() << _T("passed") << endl; - else - mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; - - return iStat; - } - - - //--------------------------------------------------------------------------- - void ParserTester::AddTest(testfun_type a_pFun) - { - m_vTestFun.push_back(a_pFun); - } - - //--------------------------------------------------------------------------- - void ParserTester::Run() - { - int iStat = 0; - try - { - for (int i=0; i<(int)m_vTestFun.size(); ++i) - iStat += (this->*m_vTestFun[i])(); - } - catch(Parser::exception_type &e) - { - mu::console() << "\n" << e.GetMsg() << endl; - mu::console() << e.GetToken() << endl; - Abort(); - } - catch(std::exception &e) - { - mu::console() << e.what() << endl; - Abort(); - } - catch(...) - { - mu::console() << "Internal error"; - Abort(); - } - - if (iStat==0) - { - mu::console() << "Test passed (" << ParserTester::c_iCount << " expressions)" << endl; - } - else - { - mu::console() << "Test failed with " << iStat - << " errors (" << ParserTester::c_iCount - << " expressions)" << endl; - } - ParserTester::c_iCount = 0; - } - - - //--------------------------------------------------------------------------- - int ParserTester::ThrowTest(const string_type &a_str, int a_iErrc, bool a_bFail) - { - ParserTester::c_iCount++; - - try - { - value_type fVal[] = {1,1,1}; - Parser p; - - p.DefineVar( _T("a"), &fVal[0]); - p.DefineVar( _T("b"), &fVal[1]); - p.DefineVar( _T("c"), &fVal[2]); - p.DefinePostfixOprt( _T("{m}"), Milli); - p.DefinePostfixOprt( _T("m"), Milli); - p.DefineFun( _T("ping"), Ping); - p.DefineFun( _T("valueof"), ValueOf); - p.DefineFun( _T("strfun1"), StrFun1); - p.DefineFun( _T("strfun2"), StrFun2); - p.DefineFun( _T("strfun3"), StrFun3); - p.SetExpr(a_str); - p.Eval(); - } - catch(ParserError &e) - { - // output the formula in case of an failed test - if (a_bFail==false || (a_bFail==true && a_iErrc!=e.GetCode()) ) - { - mu::console() << _T("\n ") - << _T("Expression: ") << a_str - << _T(" Code:") << e.GetCode() << _T("(") << e.GetMsg() << _T(")") - << _T(" Expected:") << a_iErrc; - } - - return (a_iErrc==e.GetCode()) ? 0 : 1; - } - - // if a_bFail==false no exception is expected - bool bRet((a_bFail==false) ? 0 : 1); - if (bRet==1) - { - mu::console() << _T("\n ") - << _T("Expression: ") << a_str - << _T(" did evaluate; Expected error:") << a_iErrc; - } - - return bRet; - } - - //--------------------------------------------------------------------------- - /** \brief Evaluate a tet expression. - - \return 1 in case of a failure, 0 otherwise. - */ - int ParserTester::EqnTestWithVarChange(const string_type &a_str, - double a_fVar1, - double a_fRes1, - double a_fVar2, - double a_fRes2) - { - ParserTester::c_iCount++; - - try - { - value_type fVal[2] = {-999, -999 }; // should be equal - - Parser p; - value_type var = 0; - - // variable - p.DefineVar( _T("a"), &var); - p.SetExpr(a_str); - - var = a_fVar1; - fVal[0] = p.Eval(); - - var = a_fVar2; - fVal[1] = p.Eval(); - - if ( fabs(a_fRes1-fVal[0]) > 0.0000000001) - throw std::runtime_error("incorrect result (first pass)"); - - if ( fabs(a_fRes2-fVal[1]) > 0.0000000001) - throw std::runtime_error("incorrect result (second pass)"); - } - catch(Parser::exception_type &e) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.GetMsg() << _T(")"); - return 1; - } - catch(std::exception &e) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.what() << _T(")"); - return 1; // always return a failure since this exception is not expected - } - catch(...) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); - return 1; // exceptions other than ParserException are not allowed - } - - return 0; - } - - //--------------------------------------------------------------------------- - /** \brief Evaluate a tet expression. - - \return 1 in case of a failure, 0 otherwise. - */ - int ParserTester::EqnTest(const string_type &a_str, double a_fRes, bool a_fPass) - { - ParserTester::c_iCount++; - int iRet(0); - value_type fVal[5] = {-999, -998, -997, -996, -995}; // initially should be different - - try - { - std::auto_ptr<Parser> p1; - Parser p2, p3; // three parser objects - // they will be used for testing copy and assignment operators - // p1 is a pointer since i'm going to delete it in order to test if - // parsers after copy construction still refer to members of it. - // !! If this is the case this function will crash !! - - p1.reset(new mu::Parser()); - // Add constants - p1->DefineConst( _T("pi"), (value_type)PARSER_CONST_PI); - p1->DefineConst( _T("e"), (value_type)PARSER_CONST_E); - p1->DefineConst( _T("const"), 1); - p1->DefineConst( _T("const1"), 2); - p1->DefineConst( _T("const2"), 3); - // string constants - p1->DefineStrConst( _T("str1"), _T("1.11")); - p1->DefineStrConst( _T("str2"), _T("2.22")); - // variables - value_type vVarVal[] = { 1, 2, 3, -2}; - p1->DefineVar( _T("a"), &vVarVal[0]); - p1->DefineVar( _T("aa"), &vVarVal[1]); - p1->DefineVar( _T("b"), &vVarVal[1]); - p1->DefineVar( _T("c"), &vVarVal[2]); - p1->DefineVar( _T("d"), &vVarVal[3]); - - // custom value ident functions - p1->AddValIdent(&ParserTester::IsHexVal); - - // functions - p1->DefineFun( _T("ping"), Ping); - p1->DefineFun( _T("f1of1"), f1of1); // one parameter - p1->DefineFun( _T("f1of2"), f1of2); // two parameter - p1->DefineFun( _T("f2of2"), f2of2); - p1->DefineFun( _T("f1of3"), f1of3); // three parameter - p1->DefineFun( _T("f2of3"), f2of3); - p1->DefineFun( _T("f3of3"), f3of3); - p1->DefineFun( _T("f1of4"), f1of4); // four parameter - p1->DefineFun( _T("f2of4"), f2of4); - p1->DefineFun( _T("f3of4"), f3of4); - p1->DefineFun( _T("f4of4"), f4of4); - p1->DefineFun( _T("f1of5"), f1of5); // five parameter - p1->DefineFun( _T("f2of5"), f2of5); - p1->DefineFun( _T("f3of5"), f3of5); - p1->DefineFun( _T("f4of5"), f4of5); - p1->DefineFun( _T("f5of5"), f5of5); - - // binary operators - p1->DefineOprt( _T("add"), add, 0); - p1->DefineOprt( _T("++"), add, 0); - p1->DefineOprt( _T("&"), land, prLAND); - - // sample functions - p1->DefineFun( _T("min"), Min); - p1->DefineFun( _T("max"), Max); - p1->DefineFun( _T("sum"), Sum); - p1->DefineFun( _T("valueof"), ValueOf); - p1->DefineFun( _T("atof"), StrToFloat); - p1->DefineFun( _T("strfun1"), StrFun1); - p1->DefineFun( _T("strfun2"), StrFun2); - p1->DefineFun( _T("strfun3"), StrFun3); - p1->DefineFun( _T("lastArg"), LastArg); - p1->DefineFun( _T("firstArg"), FirstArg); - p1->DefineFun( _T("order"), FirstArg); - - // infix / postfix operator - // Note: Identifiers used here do not have any meaning - // they are mere placeholders to test certain features. - p1->DefineInfixOprt( _T("$"), sign, prPOW+1); // sign with high priority - p1->DefineInfixOprt( _T("~"), plus2); // high priority - p1->DefineInfixOprt( _T("~~"), plus2); - p1->DefinePostfixOprt( _T("{m}"), Milli); - p1->DefinePostfixOprt( _T("{M}"), Mega); - p1->DefinePostfixOprt( _T("m"), Milli); - p1->DefinePostfixOprt( _T("meg"), Mega); - p1->DefinePostfixOprt( _T("#"), times3); - p1->DefinePostfixOprt( _T("'"), sqr); - p1->SetExpr(a_str); - - // Test bytecode integrity - // String parsing and bytecode parsing must yield the same result - fVal[0] = p1->Eval(); // result from stringparsing - fVal[1] = p1->Eval(); // result from bytecode - if (fVal[0]!=fVal[1]) - throw Parser::exception_type( _T("Bytecode / string parsing mismatch.") ); - - // Test copy and assignment operators - try - { - // Test copy constructor - std::vector<mu::Parser> vParser; - vParser.push_back(*(p1.get())); - mu::Parser p2 = vParser[0]; // take parser from vector - - // destroy the originals from p2 - vParser.clear(); // delete the vector - p1.reset(0); - - fVal[2] = p2.Eval(); - - // Test assignment operator - // additionally disable Optimizer this time - mu::Parser p3; - p3 = p2; - p3.EnableOptimizer(false); - fVal[3] = p3.Eval(); - - // Test Eval function for multiple return values - // use p2 since it has the optimizer enabled! - int nNum; - value_type *v = p2.Eval(nNum); - fVal[4] = v[nNum-1]; - } - catch(std::exception &e) - { - mu::console() << _T("\n ") << e.what() << _T("\n"); - } - - // limited floating point accuracy requires the following test - bool bCloseEnough(true); - for (unsigned i=0; i<sizeof(fVal)/sizeof(value_type); ++i) - { - bCloseEnough &= (fabs(a_fRes-fVal[i]) <= fabs(fVal[i]*0.00001)); - - // The tests equations never result in infinity, if they do thats a bug. - // reference: - // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/5037825 - #pragma warning(push) - #pragma warning(disable:4127) - if (std::numeric_limits<value_type>::has_infinity) - #pragma warning(pop) - { - bCloseEnough &= (fabs(fVal[i]) != numeric_limits<value_type>::infinity()); - } - } - - iRet = ((bCloseEnough && a_fPass) || (!bCloseEnough && !a_fPass)) ? 0 : 1; - - - if (iRet==1) - { - mu::console() << _T("\n fail: ") << a_str.c_str() - << _T(" (incorrect result; expected: ") << a_fRes - << _T(" ;calculated: ") << fVal[0] << _T(",") - << fVal[1] << _T(",") - << fVal[2] << _T(",") - << fVal[3] << _T(",") - << fVal[4] << _T(")."); - } - } - catch(Parser::exception_type &e) - { - if (a_fPass) - { - if (fVal[0]!=fVal[2] && fVal[0]!=-999 && fVal[1]!=-998) - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (copy construction)"); - else - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.GetMsg() << _T(")"); - return 1; - } - } - catch(std::exception &e) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.what() << _T(")"); - return 1; // always return a failure since this exception is not expected - } - catch(...) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); - return 1; // exceptions other than ParserException are not allowed - } - - return iRet; - } - - //--------------------------------------------------------------------------- - int ParserTester::EqnTestInt(const string_type &a_str, double a_fRes, bool a_fPass) - { - ParserTester::c_iCount++; - - value_type vVarVal[] = {1, 2, 3}; // variable values - int iRet(0); - - try - { - value_type fVal[2] = {-99, -999}; // results: initially should be different - ParserInt p; - p.DefineConst( _T("const1"), 1); - p.DefineConst( _T("const2"), 2); - p.DefineVar( _T("a"), &vVarVal[0]); - p.DefineVar( _T("b"), &vVarVal[1]); - p.DefineVar( _T("c"), &vVarVal[2]); - - p.SetExpr(a_str); - fVal[0] = p.Eval(); // result from stringparsing - fVal[1] = p.Eval(); // result from bytecode - - if (fVal[0]!=fVal[1]) - throw Parser::exception_type( _T("Bytecode corrupt.") ); - - iRet = ( (a_fRes==fVal[0] && a_fPass) || - (a_fRes!=fVal[0] && !a_fPass) ) ? 0 : 1; - if (iRet==1) - { - mu::console() << _T("\n fail: ") << a_str.c_str() - << _T(" (incorrect result; expected: ") << a_fRes - << _T(" ;calculated: ") << fVal[0]<< _T(")."); - } - } - catch(Parser::exception_type &e) - { - if (a_fPass) - { - mu::console() << _T("\n fail: ") << e.GetExpr() << _T(" : ") << e.GetMsg(); - iRet = 1; - } - } - catch(...) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); - iRet = 1; // exceptions other than ParserException are not allowed - } - - return iRet; - } - - //--------------------------------------------------------------------------- - /** \brief Test an expression in Bulk Mode. */ - int ParserTester::EqnTestBulk(const string_type &a_str, double a_fRes[4], bool a_fPass) - { - ParserTester::c_iCount++; - - // Define Bulk Variables - int nBulkSize = 4; - value_type vVariableA[] = { 1, 2, 3, 4 }; // variable values - value_type vVariableB[] = { 2, 2, 2, 2 }; // variable values - value_type vVariableC[] = { 3, 3, 3, 3 }; // variable values - value_type vResults[] = { 0, 0, 0, 0 }; // variable values - int iRet(0); - - try - { - Parser p; - p.DefineConst(_T("const1"), 1); - p.DefineConst(_T("const2"), 2); - p.DefineVar(_T("a"), vVariableA); - p.DefineVar(_T("b"), vVariableB); - p.DefineVar(_T("c"), vVariableC); - - p.SetExpr(a_str); - p.Eval(vResults, nBulkSize); - - bool bCloseEnough(true); - for (int i = 0; i < nBulkSize; ++i) - { - bCloseEnough &= (fabs(a_fRes[i] - vResults[i]) <= fabs(a_fRes[i] * 0.00001)); - } - - iRet = ((bCloseEnough && a_fPass) || (!bCloseEnough && !a_fPass)) ? 0 : 1; - if (iRet == 1) - { - mu::console() << _T("\n fail: ") << a_str.c_str() - << _T(" (incorrect result; expected: {") << a_fRes[0] << _T(",") << a_fRes[1] << _T(",") << a_fRes[2] << _T(",") << a_fRes[3] << _T("}") - << _T(" ;calculated: ") << vResults[0] << _T(",") << vResults[1] << _T(",") << vResults[2] << _T(",") << vResults[3] << _T("}"); - } - } - catch (Parser::exception_type &e) - { - if (a_fPass) - { - mu::console() << _T("\n fail: ") << e.GetExpr() << _T(" : ") << e.GetMsg(); - iRet = 1; - } - } - catch (...) - { - mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); - iRet = 1; // exceptions other than ParserException are not allowed - } - - return iRet; - } - - //--------------------------------------------------------------------------- - /** \brief Internal error in test class Test is going to be aborted. */ - void ParserTester::Abort() const - { - mu::console() << _T("Test failed (internal error in test class)") << endl; - while (!getchar()); - exit(-1); - } - } // namespace test -} // namespace mu diff --git a/ThirdParty/MuParser/src/muParserTokenReader.cpp b/ThirdParty/MuParser/src/muParserTokenReader.cpp deleted file mode 100644 index 8da1e40247b638bafbd1be328575bf98bf32d87b..0000000000000000000000000000000000000000 --- a/ThirdParty/MuParser/src/muParserTokenReader.cpp +++ /dev/null @@ -1,958 +0,0 @@ -/* - __________ - _____ __ __\______ \_____ _______ ______ ____ _______ - / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ - | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ - |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| - \/ \/ \/ \/ - Copyright (C) 2013 Ingo Berg - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <cassert> -#include <cstdio> -#include <cstring> -#include <map> -#include <stack> -#include <string> - -#include "muParserTokenReader.h" -#include "muParserBase.h" - -/** \file - \brief This file contains the parser token reader implementation. -*/ - - -namespace mu -{ - - // Forward declaration - class ParserBase; - - //--------------------------------------------------------------------------- - /** \brief Copy constructor. - - \sa Assign - \throw nothrow - */ - ParserTokenReader::ParserTokenReader(const ParserTokenReader &a_Reader) - { - Assign(a_Reader); - } - - //--------------------------------------------------------------------------- - /** \brief Assignment operator. - - Self assignment will be suppressed otherwise #Assign is called. - - \param a_Reader Object to copy to this token reader. - \throw nothrow - */ - ParserTokenReader& ParserTokenReader::operator=(const ParserTokenReader &a_Reader) - { - if (&a_Reader!=this) - Assign(a_Reader); - - return *this; - } - - //--------------------------------------------------------------------------- - /** \brief Assign state of a token reader to this token reader. - - \param a_Reader Object from which the state should be copied. - \throw nothrow - */ - void ParserTokenReader::Assign(const ParserTokenReader &a_Reader) - { - m_pParser = a_Reader.m_pParser; - m_strFormula = a_Reader.m_strFormula; - m_iPos = a_Reader.m_iPos; - m_iSynFlags = a_Reader.m_iSynFlags; - - m_UsedVar = a_Reader.m_UsedVar; - m_pFunDef = a_Reader.m_pFunDef; - m_pConstDef = a_Reader.m_pConstDef; - m_pVarDef = a_Reader.m_pVarDef; - m_pStrVarDef = a_Reader.m_pStrVarDef; - m_pPostOprtDef = a_Reader.m_pPostOprtDef; - m_pInfixOprtDef = a_Reader.m_pInfixOprtDef; - m_pOprtDef = a_Reader.m_pOprtDef; - m_bIgnoreUndefVar = a_Reader.m_bIgnoreUndefVar; - m_vIdentFun = a_Reader.m_vIdentFun; - m_pFactory = a_Reader.m_pFactory; - m_pFactoryData = a_Reader.m_pFactoryData; - m_iBrackets = a_Reader.m_iBrackets; - m_cArgSep = a_Reader.m_cArgSep; - m_fZero = a_Reader.m_fZero; - m_lastTok = a_Reader.m_lastTok; - } - - //--------------------------------------------------------------------------- - /** \brief Constructor. - - Create a Token reader and bind it to a parser object. - - \pre [assert] a_pParser may not be NULL - \post #m_pParser==a_pParser - \param a_pParent Parent parser object of the token reader. - */ - ParserTokenReader::ParserTokenReader(ParserBase *a_pParent) - :m_pParser(a_pParent) - ,m_strFormula() - ,m_iPos(0) - ,m_iSynFlags(0) - ,m_bIgnoreUndefVar(false) - ,m_pFunDef(NULL) - ,m_pPostOprtDef(NULL) - ,m_pInfixOprtDef(NULL) - ,m_pOprtDef(NULL) - ,m_pConstDef(NULL) - ,m_pStrVarDef(NULL) - ,m_pVarDef(NULL) - ,m_pFactory(NULL) - ,m_pFactoryData(NULL) - ,m_vIdentFun() - ,m_UsedVar() - ,m_fZero(0) - ,m_iBrackets(0) - ,m_lastTok() - ,m_cArgSep(',') - { - assert(m_pParser); - SetParent(m_pParser); - } - - //--------------------------------------------------------------------------- - /** \brief Create instance of a ParserTokenReader identical with this - and return its pointer. - - This is a factory method the calling function must take care of the object destruction. - - \return A new ParserTokenReader object. - \throw nothrow - */ - ParserTokenReader* ParserTokenReader::Clone(ParserBase *a_pParent) const - { - std::auto_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this)); - ptr->SetParent(a_pParent); - return ptr.release(); - } - - //--------------------------------------------------------------------------- - ParserTokenReader::token_type& ParserTokenReader::SaveBeforeReturn(const token_type &tok) - { - m_lastTok = tok; - return m_lastTok; - } - - //--------------------------------------------------------------------------- - void ParserTokenReader::AddValIdent(identfun_type a_pCallback) - { - // Use push_front is used to give user defined callbacks a higher priority than - // the built in ones. Otherwise reading hex numbers would not work - // since the "0" in "0xff" would always be read first making parsing of - // the rest impossible. - // reference: - // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/4824956 - m_vIdentFun.push_front(a_pCallback); - } - - //--------------------------------------------------------------------------- - void ParserTokenReader::SetVarCreator(facfun_type a_pFactory, void *pUserData) - { - m_pFactory = a_pFactory; - m_pFactoryData = pUserData; - } - - //--------------------------------------------------------------------------- - /** \brief Return the current position of the token reader in the formula string. - - \return #m_iPos - \throw nothrow - */ - int ParserTokenReader::GetPos() const - { - return m_iPos; - } - - //--------------------------------------------------------------------------- - /** \brief Return a reference to the formula. - - \return #m_strFormula - \throw nothrow - */ - const string_type& ParserTokenReader::GetExpr() const - { - return m_strFormula; - } - - //--------------------------------------------------------------------------- - /** \brief Return a map containing the used variables only. */ - varmap_type& ParserTokenReader::GetUsedVar() - { - return m_UsedVar; - } - - //--------------------------------------------------------------------------- - /** \brief Initialize the token Reader. - - Sets the formula position index to zero and set Syntax flags to default for initial formula parsing. - \pre [assert] triggered if a_szFormula==0 - */ - void ParserTokenReader::SetFormula(const string_type &a_strFormula) - { - m_strFormula = a_strFormula; - ReInit(); - } - - //--------------------------------------------------------------------------- - /** \brief Set Flag that controls behaviour in case of undefined variables being found. - - If true, the parser does not throw an exception if an undefined variable is found. - otherwise it does. This variable is used internally only! - It suppresses a "undefined variable" exception in GetUsedVar(). - Those function should return a complete list of variables including - those the are not defined by the time of it's call. - */ - void ParserTokenReader::IgnoreUndefVar(bool bIgnore) - { - m_bIgnoreUndefVar = bIgnore; - } - - //--------------------------------------------------------------------------- - /** \brief Reset the token reader to the start of the formula. - - The syntax flags will be reset to a value appropriate for the - start of a formula. - \post #m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR - \throw nothrow - \sa ESynCodes - */ - void ParserTokenReader::ReInit() - { - m_iPos = 0; - m_iSynFlags = sfSTART_OF_LINE; - m_iBrackets = 0; - m_UsedVar.clear(); - m_lastTok = token_type(); - } - - //--------------------------------------------------------------------------- - /** \brief Read the next token from the string. */ - ParserTokenReader::token_type ParserTokenReader::ReadNextToken() - { - assert(m_pParser); - - const char_type *szFormula = m_strFormula.c_str(); - token_type tok; - - // Ignore all non printable characters when reading the expression - while (szFormula[m_iPos]>0 && szFormula[m_iPos]<=0x20) - ++m_iPos; - - if ( IsEOF(tok) ) return SaveBeforeReturn(tok); // Check for end of formula - if ( IsOprt(tok) ) return SaveBeforeReturn(tok); // Check for user defined binary operator - if ( IsFunTok(tok) ) return SaveBeforeReturn(tok); // Check for function token - if ( IsBuiltIn(tok) ) return SaveBeforeReturn(tok); // Check built in operators / tokens - if ( IsArgSep(tok) ) return SaveBeforeReturn(tok); // Check for function argument separators - if ( IsValTok(tok) ) return SaveBeforeReturn(tok); // Check for values / constant tokens - if ( IsVarTok(tok) ) return SaveBeforeReturn(tok); // Check for variable tokens - if ( IsStrVarTok(tok) ) return SaveBeforeReturn(tok); // Check for string variables - if ( IsString(tok) ) return SaveBeforeReturn(tok); // Check for String tokens - if ( IsInfixOpTok(tok) ) return SaveBeforeReturn(tok); // Check for unary operators - if ( IsPostOpTok(tok) ) return SaveBeforeReturn(tok); // Check for unary operators - - // Check String for undefined variable token. Done only if a - // flag is set indicating to ignore undefined variables. - // This is a way to conditionally avoid an error if - // undefined variables occur. - // (The GetUsedVar function must suppress the error for - // undefined variables in order to collect all variable - // names including the undefined ones.) - if ( (m_bIgnoreUndefVar || m_pFactory) && IsUndefVarTok(tok) ) - return SaveBeforeReturn(tok); - - // Check for unknown token - // - // !!! From this point on there is no exit without an exception possible... - // - string_type strTok; - int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); - if (iEnd!=m_iPos) - Error(ecUNASSIGNABLE_TOKEN, m_iPos, strTok); - - Error(ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.substr(m_iPos)); - return token_type(); // never reached - } - - //--------------------------------------------------------------------------- - void ParserTokenReader::SetParent(ParserBase *a_pParent) - { - m_pParser = a_pParent; - m_pFunDef = &a_pParent->m_FunDef; - m_pOprtDef = &a_pParent->m_OprtDef; - m_pInfixOprtDef = &a_pParent->m_InfixOprtDef; - m_pPostOprtDef = &a_pParent->m_PostOprtDef; - m_pVarDef = &a_pParent->m_VarDef; - m_pStrVarDef = &a_pParent->m_StrVarDef; - m_pConstDef = &a_pParent->m_ConstDef; - } - - //--------------------------------------------------------------------------- - /** \brief Extract all characters that belong to a certain charset. - - \param a_szCharSet [in] Const char array of the characters allowed in the token. - \param a_strTok [out] The string that consists entirely of characters listed in a_szCharSet. - \param a_iPos [in] Position in the string from where to start reading. - \return The Position of the first character not listed in a_szCharSet. - \throw nothrow - */ - int ParserTokenReader::ExtractToken(const char_type *a_szCharSet, - string_type &a_sTok, - int a_iPos) const - { - int iEnd = (int)m_strFormula.find_first_not_of(a_szCharSet, a_iPos); - - if (iEnd==(int)string_type::npos) - iEnd = (int)m_strFormula.length(); - - // Assign token string if there was something found - if (a_iPos!=iEnd) - a_sTok = string_type( m_strFormula.begin()+a_iPos, m_strFormula.begin()+iEnd); - - return iEnd; - } - - //--------------------------------------------------------------------------- - /** \brief Check Expression for the presence of a binary operator token. - - Userdefined binary operator "++" gives inconsistent parsing result for - the equations "a++b" and "a ++ b" if alphabetic characters are allowed - in operator tokens. To avoid this this function checks specifically - for operator tokens. - */ - int ParserTokenReader::ExtractOperatorToken(string_type &a_sTok, - int a_iPos) const - { - // Changed as per Issue 6: https://code.google.com/p/muparser/issues/detail?id=6 - int iEnd = (int)m_strFormula.find_first_not_of(m_pParser->ValidOprtChars(), a_iPos); - if (iEnd==(int)string_type::npos) - iEnd = (int)m_strFormula.length(); - - // Assign token string if there was something found - if (a_iPos!=iEnd) - { - a_sTok = string_type( m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); - return iEnd; - } - else - { - // There is still the chance of having to deal with an operator consisting exclusively - // of alphabetic characters. - return ExtractToken(MUP_CHARS, a_sTok, a_iPos); - } - } - - //--------------------------------------------------------------------------- - /** \brief Check if a built in operator or other token can be found - \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. - \return true if an operator token has been found. - */ - bool ParserTokenReader::IsBuiltIn(token_type &a_Tok) - { - const char_type **const pOprtDef = m_pParser->GetOprtDef(), - *const szFormula = m_strFormula.c_str(); - - // Compare token with function and operator strings - // check string for operator/function - for (int i=0; pOprtDef[i]; i++) - { - std::size_t len( std::char_traits<char_type>::length(pOprtDef[i]) ); - if ( string_type(pOprtDef[i]) == string_type(szFormula + m_iPos, szFormula + m_iPos + len) ) - { - switch(i) - { - //case cmAND: - //case cmOR: - //case cmXOR: - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmASSIGN: - //if (len!=sTok.length()) - // continue; - - // The assignment operator need special treatment - if (i==cmASSIGN && m_iSynFlags & noASSIGN) - Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); - - if (!m_pParser->HasBuiltInOprt()) continue; - if (m_iSynFlags & noOPT) - { - // Maybe its an infix operator not an operator - // Both operator types can share characters in - // their identifiers - if ( IsInfixOpTok(a_Tok) ) - return true; - - Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); - } - - m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE | noEND; - break; - - case cmBO: - if (m_iSynFlags & noBO) - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - - if (m_lastTok.GetCode()==cmFUNC) - m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - else - m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN| noIF | noELSE; - - ++m_iBrackets; - break; - - case cmBC: - if (m_iSynFlags & noBC) - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; - - if (--m_iBrackets<0) - Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); - break; - - case cmELSE: - if (m_iSynFlags & noELSE) - Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; - break; - - case cmIF: - if (m_iSynFlags & noIF) - Error(ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef[i]); - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; - break; - - default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... - Error(ecINTERNAL_ERROR); - } // switch operator id - - m_iPos += (int)len; - a_Tok.Set( (ECmdCode)i, pOprtDef[i] ); - return true; - } // if operator string found - } // end of for all operator strings - - return false; - } - - //--------------------------------------------------------------------------- - bool ParserTokenReader::IsArgSep(token_type &a_Tok) - { - const char_type* szFormula = m_strFormula.c_str(); - - if (szFormula[m_iPos]==m_cArgSep) - { - // copy the separator into null terminated string - char_type szSep[2]; - szSep[0] = m_cArgSep; - szSep[1] = 0; - - if (m_iSynFlags & noARG_SEP) - Error(ecUNEXPECTED_ARG_SEP, m_iPos, szSep); - - m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; - m_iPos++; - a_Tok.Set(cmARG_SEP, szSep); - return true; - } - - return false; - } - - //--------------------------------------------------------------------------- - /** \brief Check for End of Formula. - - \return true if an end of formula is found false otherwise. - \param a_Tok [out] If an eof is found the corresponding token will be stored there. - \throw nothrow - \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok - */ - bool ParserTokenReader::IsEOF(token_type &a_Tok) - { - const char_type* szFormula = m_strFormula.c_str(); - - // check for EOF - if ( !szFormula[m_iPos] /*|| szFormula[m_iPos] == '\n'*/) - { - if ( m_iSynFlags & noEND ) - Error(ecUNEXPECTED_EOF, m_iPos); - - if (m_iBrackets>0) - Error(ecMISSING_PARENS, m_iPos, _T(")")); - - m_iSynFlags = 0; - a_Tok.Set(cmEND); - return true; - } - - return false; - } - - //--------------------------------------------------------------------------- - /** \brief Check if a string position contains a unary infix operator. - \return true if a function token has been found false otherwise. - */ - bool ParserTokenReader::IsInfixOpTok(token_type &a_Tok) - { - string_type sTok; - int iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, m_iPos); - if (iEnd==m_iPos) - return false; - - // iterate over all postfix operator strings - funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin(); - for ( ; it!=m_pInfixOprtDef->rend(); ++it) - { - if (sTok.find(it->first)!=0) - continue; - - a_Tok.Set(it->second, it->first); - m_iPos += (int)it->first.length(); - - if (m_iSynFlags & noINFIXOP) - Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - - m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; - return true; - } - - return false; - -/* - a_Tok.Set(item->second, sTok); - m_iPos = (int)iEnd; - - if (m_iSynFlags & noINFIXOP) - Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - - m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; - return true; -*/ - } - - //--------------------------------------------------------------------------- - /** \brief Check whether the token at a given position is a function token. - \param a_Tok [out] If a value token is found it will be placed here. - \throw ParserException if Syntaxflags do not allow a function at a_iPos - \return true if a function token has been found false otherwise. - \pre [assert] m_pParser!=0 - */ - bool ParserTokenReader::IsFunTok(token_type &a_Tok) - { - string_type strTok; - int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); - if (iEnd==m_iPos) - return false; - - funmap_type::const_iterator item = m_pFunDef->find(strTok); - if (item==m_pFunDef->end()) - return false; - - // Check if the next sign is an opening bracket - const char_type *szFormula = m_strFormula.c_str(); - if (szFormula[iEnd]!='(') - return false; - - a_Tok.Set(item->second, strTok); - - m_iPos = (int)iEnd; - if (m_iSynFlags & noFUN) - Error(ecUNEXPECTED_FUN, m_iPos-(int)a_Tok.GetAsString().length(), a_Tok.GetAsString()); - - m_iSynFlags = noANY ^ noBO; - return true; - } - - //--------------------------------------------------------------------------- - /** \brief Check if a string position contains a binary operator. - \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. - \return true if an operator token has been found. - */ - bool ParserTokenReader::IsOprt(token_type &a_Tok) - { - const char_type *const szExpr = m_strFormula.c_str(); - string_type strTok; - - int iEnd = ExtractOperatorToken(strTok, m_iPos); - if (iEnd==m_iPos) - return false; - - // Check if the operator is a built in operator, if so ignore it here - const char_type **const pOprtDef = m_pParser->GetOprtDef(); - for (int i=0; m_pParser->HasBuiltInOprt() && pOprtDef[i]; ++i) - { - if (string_type(pOprtDef[i])==strTok) - return false; - } - - // Note: - // All tokens in oprt_bin_maptype are have been sorted by their length - // Long operators must come first! Otherwise short names (like: "add") that - // are part of long token names (like: "add123") will be found instead - // of the long ones. - // Length sorting is done with ascending length so we use a reverse iterator here. - funmap_type::const_reverse_iterator it = m_pOprtDef->rbegin(); - for ( ; it!=m_pOprtDef->rend(); ++it) - { - const string_type &sID = it->first; - if ( sID == string_type(szExpr + m_iPos, szExpr + m_iPos + sID.length()) ) - { - a_Tok.Set(it->second, strTok); - - // operator was found - if (m_iSynFlags & noOPT) - { - // An operator was found but is not expected to occur at - // this position of the formula, maybe it is an infix - // operator, not a binary operator. Both operator types - // can share characters in their identifiers. - if ( IsInfixOpTok(a_Tok) ) - return true; - else - { - // nope, no infix operator - return false; - //Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); - } - - } - - m_iPos += (int)sID.length(); - m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noASSIGN; - return true; - } - } - - return false; - } - - //--------------------------------------------------------------------------- - /** \brief Check if a string position contains a unary post value operator. */ - bool ParserTokenReader::IsPostOpTok(token_type &a_Tok) - { - // <ibg 20110629> Do not check for postfix operators if they are not allowed at - // the current expression index. - // - // This will fix the bug reported here: - // - // http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979 - // - if (m_iSynFlags & noPOSTOP) - return false; - // </ibg> - - // Tricky problem with equations like "3m+5": - // m is a postfix operator, + is a valid sign for postfix operators and - // for binary operators parser detects "m+" as operator string and - // finds no matching postfix operator. - // - // This is a special case so this routine slightly differs from the other - // token readers. - - // Test if there could be a postfix operator - string_type sTok; - int iEnd = ExtractToken(m_pParser->ValidOprtChars(), sTok, m_iPos); - if (iEnd==m_iPos) - return false; - - // iterate over all postfix operator strings - funmap_type::const_reverse_iterator it = m_pPostOprtDef->rbegin(); - for ( ; it!=m_pPostOprtDef->rend(); ++it) - { - if (sTok.find(it->first)!=0) - continue; - - a_Tok.Set(it->second, sTok); - m_iPos += (int)it->first.length(); - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN; - return true; - } - - return false; - } - - //--------------------------------------------------------------------------- - /** \brief Check whether the token at a given position is a value token. - - Value tokens are either values or constants. - - \param a_Tok [out] If a value token is found it will be placed here. - \return true if a value token has been found. - */ - bool ParserTokenReader::IsValTok(token_type &a_Tok) - { - assert(m_pConstDef); - assert(m_pParser); - - string_type strTok; - value_type fVal(0); - int iEnd(0); - - // 2.) Check for user defined constant - // Read everything that could be a constant name - iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); - if (iEnd!=m_iPos) - { - valmap_type::const_iterator item = m_pConstDef->find(strTok); - if (item!=m_pConstDef->end()) - { - m_iPos = iEnd; - a_Tok.SetVal(item->second, strTok); - - if (m_iSynFlags & noVAL) - Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - } - - // 3.call the value recognition functions provided by the user - // Call user defined value recognition functions - std::list<identfun_type>::const_iterator item = m_vIdentFun.begin(); - for (item = m_vIdentFun.begin(); item!=m_vIdentFun.end(); ++item) - { - int iStart = m_iPos; - if ( (*item)(m_strFormula.c_str() + m_iPos, &m_iPos, &fVal)==1 ) - { - // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 - strTok.assign(m_strFormula.c_str(), iStart, m_iPos-iStart); - - if (m_iSynFlags & noVAL) - Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); - - a_Tok.SetVal(fVal, strTok); - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - } - - return false; - } - - //--------------------------------------------------------------------------- - /** \brief Check wheter a token at a given position is a variable token. - \param a_Tok [out] If a variable token has been found it will be placed here. - \return true if a variable token has been found. - */ - bool ParserTokenReader::IsVarTok(token_type &a_Tok) - { - if (m_pVarDef->empty()) - return false; - - string_type strTok; - int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); - if (iEnd==m_iPos) - return false; - - varmap_type::const_iterator item = m_pVarDef->find(strTok); - if (item==m_pVarDef->end()) - return false; - - if (m_iSynFlags & noVAR) - Error(ecUNEXPECTED_VAR, m_iPos, strTok); - - m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd); - - m_iPos = iEnd; - a_Tok.SetVar(item->second, strTok); - m_UsedVar[item->first] = item->second; // Add variable to used-var-list - - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR; - -// Zur Info hier die SynFlags von IsVal(): -// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; - return true; - } - - //--------------------------------------------------------------------------- - bool ParserTokenReader::IsStrVarTok(token_type &a_Tok) - { - if (!m_pStrVarDef || m_pStrVarDef->empty()) - return false; - - string_type strTok; - int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); - if (iEnd==m_iPos) - return false; - - strmap_type::const_iterator item = m_pStrVarDef->find(strTok); - if (item==m_pStrVarDef->end()) - return false; - - if (m_iSynFlags & noSTR) - Error(ecUNEXPECTED_VAR, m_iPos, strTok); - - m_iPos = iEnd; - if (!m_pParser->m_vStringVarBuf.size()) - Error(ecINTERNAL_ERROR); - - a_Tok.SetString(m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() ); - - m_iSynFlags = noANY ^ ( noBC | noOPT | noEND | noARG_SEP); - return true; - } - - - //--------------------------------------------------------------------------- - /** \brief Check wheter a token at a given position is an undefined variable. - - \param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here. - \return true if a variable token has been found. - \throw nothrow - */ - bool ParserTokenReader::IsUndefVarTok(token_type &a_Tok) - { - string_type strTok; - int iEnd( ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos) ); - if ( iEnd==m_iPos ) - return false; - - if (m_iSynFlags & noVAR) - { - // <ibg/> 20061021 added token string strTok instead of a_Tok.GetAsString() as the - // token identifier. - // related bug report: - // http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979 - Error(ecUNEXPECTED_VAR, m_iPos - (int)a_Tok.GetAsString().length(), strTok); - } - - // If a factory is available implicitely create new variables - if (m_pFactory) - { - value_type *fVar = m_pFactory(strTok.c_str(), m_pFactoryData); - a_Tok.SetVar(fVar, strTok ); - - // Do not use m_pParser->DefineVar( strTok, fVar ); - // in order to define the new variable, it will clear the - // m_UsedVar array which will kill previously defined variables - // from the list - // This is safe because the new variable can never override an existing one - // because they are checked first! - (*m_pVarDef)[strTok] = fVar; - m_UsedVar[strTok] = fVar; // Add variable to used-var-list - } - else - { - a_Tok.SetVar((value_type*)&m_fZero, strTok); - m_UsedVar[strTok] = 0; // Add variable to used-var-list - } - - m_iPos = iEnd; - - // Call the variable factory in order to let it define a new parser variable - m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR; - return true; - } - - - //--------------------------------------------------------------------------- - /** \brief Check wheter a token at a given position is a string. - \param a_Tok [out] If a variable token has been found it will be placed here. - \return true if a string token has been found. - \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok - \throw nothrow - */ - bool ParserTokenReader::IsString(token_type &a_Tok) - { - if (m_strFormula[m_iPos]!='"') - return false; - - string_type strBuf(&m_strFormula[m_iPos+1]); - std::size_t iEnd(0), iSkip(0); - - // parser over escaped '\"' end replace them with '"' - for(iEnd=(int)strBuf.find( _T("\"") ); iEnd!=0 && iEnd!=string_type::npos; iEnd=(int)strBuf.find( _T("\""), iEnd)) - { - if (strBuf[iEnd-1]!='\\') break; - strBuf.replace(iEnd-1, 2, _T("\"") ); - iSkip++; - } - - if (iEnd==string_type::npos) - Error(ecUNTERMINATED_STRING, m_iPos, _T("\"") ); - - string_type strTok(strBuf.begin(), strBuf.begin()+iEnd); - - if (m_iSynFlags & noSTR) - Error(ecUNEXPECTED_STR, m_iPos, strTok); - - m_pParser->m_vStringBuf.push_back(strTok); // Store string in internal buffer - a_Tok.SetString(strTok, m_pParser->m_vStringBuf.size()); - - m_iPos += (int)strTok.length() + 2 + (int)iSkip; // +2 wg Anführungszeichen; +iSkip für entfernte escape zeichen - m_iSynFlags = noANY ^ ( noARG_SEP | noBC | noOPT | noEND ); - - return true; - } - - //--------------------------------------------------------------------------- - /** \brief Create an error containing the parse error position. - - This function will create an Parser Exception object containing the error text and its position. - - \param a_iErrc [in] The error code of type #EErrorCodes. - \param a_iPos [in] The position where the error was detected. - \param a_strTok [in] The token string representation associated with the error. - \throw ParserException always throws thats the only purpose of this function. - */ - void ParserTokenReader::Error( EErrorCodes a_iErrc, - int a_iPos, - const string_type &a_sTok) const - { - m_pParser->Error(a_iErrc, a_iPos, a_sTok); - } - - //--------------------------------------------------------------------------- - void ParserTokenReader::SetArgSep(char_type cArgSep) - { - m_cArgSep = cArgSep; - } - - //--------------------------------------------------------------------------- - char_type ParserTokenReader::GetArgSep() const - { - return m_cArgSep; - } -} // namespace mu -