Skip to content
Snippets Groups Projects
Commit 08c08f9a authored by Soeren Peters's avatar Soeren Peters
Browse files

Merge pull request 'feature/update_cpu_to_open_source' (#27) from...

Merge pull request 'feature/update_cpu_to_open_source' (#27) from peters/VirtualFluids_dev:feature/update_cpu_to_open_source into develop
parents 600bf61d 7019a319
No related branches found
No related tags found
No related merge requests found
Showing
with 9158 additions and 9148 deletions
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
*.cpp text
*.hpp text
*.cuh text
*.cu text
*.cmake text
\ No newline at end of file
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 VF_COMPILER_DEFINITION MC_CUBES)
ENDIF()
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 VF_COMPILER_DEFINITION MC_CUBES)
ENDIF()
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIX3DWRAPPER_H
#define MATRIX3DWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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 bentigt, 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 mchte -> 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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIX3DWRAPPER_H
#define MATRIX3DWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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 bentigt, 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 mchte -> 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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIX4DWRAPPER_H
#define MATRIX4DWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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 bentigt, 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 mchte -> 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 mchte -> 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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIX4DWRAPPER_H
#define MATRIX4DWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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 bentigt, 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 mchte -> 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 mchte -> 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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIXWRAPPER_H
#define MATRIXWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#ifndef MATRIXWRAPPER_H
#define MATRIXWRAPPER_H
//extension by CAB
#include <vector>
#include <string>
#include <fstream>
#include <basics/utilities/UbException.h>
#include <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
This diff is collapsed.
This diff is collapsed.
/*
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__
/*
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__
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#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
// _ ___ __ __________ _ __
// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____
// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/
// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ )
// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/
//
#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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
###############################################################
# set hostname -> CAB_MACHINE and load an optional config file
###############################################################
macro(loadMachineFile)
IF(NOT CAB_MACHINE)
SET(CAB_MACHINE $ENV{CAB_MACHINE})
IF( CAB_MACHINE )
STRING(TOUPPER "${CAB_MACHINE}" CAB_MACHINE)
ELSE()
EXECUTE_PROCESS( COMMAND hostname OUTPUT_VARIABLE CAB_MACHINE)
STRING(REGEX REPLACE "[ ]*([A-Za-z0-9]+).*[\\\\n]*" "\\1" CAB_MACHINE "${CAB_MACHINE}" )
STRING(TOUPPER "${CAB_MACHINE}" CAB_MACHINE)
ENDIF()
ENDIF()
LIST(APPEND VF_COMPILER_DEFINITION CAB_MACHINE=${CAB_MACHINE})
SET(CMAKE_CONFIG_FILE "${VF_CMAKE_DIR}/cmake_config_files/${CAB_MACHINE}.config.cmake")
IF(NOT EXISTS ${CMAKE_CONFIG_FILE})
status("No configuration file found.")
ELSE()
status("Load configuration file ${CAB_MACHINE}.config.cmake")
include(${CMAKE_CONFIG_FILE})
ENDIF()
endmacro()
################################################################
### SET_COMPILER_SPECIFIC_FLAGS ###
### determines compiler flags variables ###
################################################################
macro(loadCompilerFlags)
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "")
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG "")
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE "")
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_<LANG>_COMPILER_ID
IF( SPECIFIC_COMPILER_FLAG_FILE )
include( ${SPECIFIC_COMPILER_FLAG_FILE})
ELSEIF( EXISTS "${VF_CMAKE_DIR}/compilerflags/${CMAKE_CXX_COMPILER_ID}.cmake" )
status("Load compiler file: ${CMAKE_CXX_COMPILER_ID}.cmake")
include(${VF_CMAKE_DIR}/compilerflags/${CMAKE_CXX_COMPILER_ID}.cmake)
ELSE()
MESSAGE(FATAL_ERROR "compiler=${CMAKE_CXX_COMPILER_ID} seems to be a not supported compiler")
ENDIF()
endmacro()
################################################################
### ADD_COMPILER_FLAGS_TO_PROJECT ###
################################################################
function(addAdditionalFlags project_name)
status_lib("additional compiler flags CXX: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS}")
status_lib("additional compiler flags CXX debug: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG}")
status_lib("additional compiler flags CXX release: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE}")
status_lib("additional compiler definitions: ${VF_COMPILER_DEFINITION}")
status_lib("additional linker flags: ${VF_LINK_OPTIONS}")
# compile definitions
foreach(flag IN LISTS VF_COMPILER_DEFINITION)
target_compile_definitions(${library_name} PRIVATE ${flag})
endforeach()
# link options
foreach(flag IN LISTS VF_LINK_OPTIONS) #TODO: check what happens when lib is static
target_link_options(${library_name} PRIVATE ${flag})
endforeach()
# compile options
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS)
target_compile_options(${project_name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${flag}>")
endforeach()
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG)
target_compile_options(${project_name} PRIVATE "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:${flag}>")
endforeach()
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE)
target_compile_options(${project_name} PRIVATE "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:${flag}>")
endforeach()
###############################################################
# set hostname -> CAB_MACHINE and load an optional config file
###############################################################
macro(loadMachineFile)
IF(NOT CAB_MACHINE)
SET(CAB_MACHINE $ENV{CAB_MACHINE})
IF( CAB_MACHINE )
STRING(TOUPPER "${CAB_MACHINE}" CAB_MACHINE)
ELSE()
EXECUTE_PROCESS( COMMAND hostname OUTPUT_VARIABLE CAB_MACHINE)
STRING(REGEX REPLACE "[ ]*([A-Za-z0-9]+).*[\\\\n]*" "\\1" CAB_MACHINE "${CAB_MACHINE}" )
STRING(TOUPPER "${CAB_MACHINE}" CAB_MACHINE)
ENDIF()
ENDIF()
LIST(APPEND VF_COMPILER_DEFINITION CAB_MACHINE=${CAB_MACHINE})
SET(CMAKE_CONFIG_FILE "${VF_CMAKE_DIR}/cmake_config_files/${CAB_MACHINE}.config.cmake")
IF(NOT EXISTS ${CMAKE_CONFIG_FILE})
status("No configuration file found.")
ELSE()
status("Load configuration file ${CAB_MACHINE}.config.cmake")
include(${CMAKE_CONFIG_FILE})
ENDIF()
endmacro()
################################################################
### SET_COMPILER_SPECIFIC_FLAGS ###
### determines compiler flags variables ###
################################################################
macro(loadCompilerFlags)
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "")
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG "")
SET(CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE "")
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_<LANG>_COMPILER_ID
IF( SPECIFIC_COMPILER_FLAG_FILE )
include( ${SPECIFIC_COMPILER_FLAG_FILE})
ELSEIF( EXISTS "${VF_CMAKE_DIR}/compilerflags/${CMAKE_CXX_COMPILER_ID}.cmake" )
status("Load compiler file: ${CMAKE_CXX_COMPILER_ID}.cmake")
include(${VF_CMAKE_DIR}/compilerflags/${CMAKE_CXX_COMPILER_ID}.cmake)
ELSE()
MESSAGE(FATAL_ERROR "compiler=${CMAKE_CXX_COMPILER_ID} seems to be a not supported compiler")
ENDIF()
endmacro()
################################################################
### ADD_COMPILER_FLAGS_TO_PROJECT ###
################################################################
function(addAdditionalFlags project_name)
status_lib("additional compiler flags CXX: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS}")
status_lib("additional compiler flags CXX debug: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG}")
status_lib("additional compiler flags CXX release: ${CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE}")
status_lib("additional compiler definitions: ${VF_COMPILER_DEFINITION}")
status_lib("additional linker flags: ${VF_LINK_OPTIONS}")
# compile definitions
foreach(flag IN LISTS VF_COMPILER_DEFINITION)
target_compile_definitions(${library_name} PRIVATE ${flag})
endforeach()
# link options
foreach(flag IN LISTS VF_LINK_OPTIONS) #TODO: check what happens when lib is static
target_link_options(${library_name} PRIVATE ${flag})
endforeach()
# compile options
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS)
target_compile_options(${project_name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${flag}>")
endforeach()
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_DEBUG)
target_compile_options(${project_name} PRIVATE "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>:${flag}>")
endforeach()
foreach(flag IN LISTS CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS_RELEASE)
target_compile_options(${project_name} PRIVATE "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:${flag}>")
endforeach()
endfunction()
\ No newline at end of file
......@@ -84,8 +84,6 @@ function (vf_get_library_test_name library_test_name)
endfunction()
#################################################################################
## Add a target, link the libraries and add the compiler flags to the target
##
......@@ -118,7 +116,7 @@ function(vf_add_library)
collectFiles(sourceFiles "${ARG_FILES}" "${ARG_FOLDER}" "${ARG_EXCLUDE}")
includeProductionFiles(${library_name} "${sourceFiles}")
includeProductionFiles (${library_name} "${sourceFiles}")
#################################################################
### EXCECUTABLE ###
......
This diff is collapsed.
#################################################################################
# VirtualFluids MACHINE FILE
# Responsible: Konstantin Kutscher
# OS: ???
#################################################################################
#################################################################################
# BOOST
#################################################################################
SET(BOOST_VERSION "1.47")
SET(BOOST_USE_MULTITHREAD ON)
SET(BOOST_USE_STATIC_LIBS ON)
SET(BOOST_ROOT "/host/tools/boost/boost_1_47_0")
SET(BOOST_LIBRARYDIR "/host/tools/boost/boost_1_47_0/stageLinux/lib")
#################################################################################
# METIS
#################################################################################
SET(METIS_INCLUDEDIR "c:/Tools/metis-5.0.1/include")
SET(METIS_DEBUG_LIBRARY "c:/Tools/metis-5.0.1/build/libmetis/Debug/metis.lib")
SET(METIS_RELEASE_LIBRARY "c:/Tools/metis-5.0.1/build/libmetis/Release/metis.lib")
#################################################################################
# VirtualFluids MACHINE FILE
# Responsible: Konstantin Kutscher
# OS: ???
#################################################################################
#################################################################################
# BOOST
#################################################################################
SET(BOOST_VERSION "1.47")
SET(BOOST_USE_MULTITHREAD ON)
SET(BOOST_USE_STATIC_LIBS ON)
SET(BOOST_ROOT "/host/tools/boost/boost_1_47_0")
SET(BOOST_LIBRARYDIR "/host/tools/boost/boost_1_47_0/stageLinux/lib")
#################################################################################
# METIS
#################################################################################
SET(METIS_INCLUDEDIR "c:/Tools/metis-5.0.1/include")
SET(METIS_DEBUG_LIBRARY "c:/Tools/metis-5.0.1/build/libmetis/Debug/metis.lib")
SET(METIS_RELEASE_LIBRARY "c:/Tools/metis-5.0.1/build/libmetis/Release/metis.lib")
#################################################################################
# VirtualFluids MACHINE FILE
# Responsible: Soeren Peters
# OS: Windows 10
#################################################################################
SET(BOOST_ROOT "C:\\Libraries\\boost_1_65_1" CACHE PATH "BOOST_ROOT")
SET(BOOST_LIBRARYDIR "C:\\Libraries\\boost_1_65_1\\lib" CACHE PATH "BOOST_LIBRARYDIR")
SET(VTK_DIR "C:/Libraries/VTK-8.0.1/build")
#################################################################################
# METIS
#################################################################################
SET(METIS_INCLUDEDIR "C:/Libraries/metis-5.1.0//include")
SET(METIS_DEBUG_LIBRARY "C:/Libraries/metis-5.1.0/build/libmetis/Debug/metis.lib")
SET(METIS_RELEASE_LIBRARY "C:/Libraries/metis-5.1.0/build/libmetis/Release/metis.lib")
#################################################################################
# VirtualFluids MACHINE FILE
# Responsible: Soeren Peters
# OS: Windows 10
#################################################################################
SET(BOOST_ROOT "C:\\Libraries\\boost_1_65_1" CACHE PATH "BOOST_ROOT")
SET(BOOST_LIBRARYDIR "C:\\Libraries\\boost_1_65_1\\lib" CACHE PATH "BOOST_LIBRARYDIR")
SET(VTK_DIR "C:/Libraries/VTK-8.0.1/build")
#################################################################################
# METIS
#################################################################################
SET(METIS_INCLUDEDIR "C:/Libraries/metis-5.1.0//include")
SET(METIS_DEBUG_LIBRARY "C:/Libraries/metis-5.1.0/build/libmetis/Debug/metis.lib")
SET(METIS_RELEASE_LIBRARY "C:/Libraries/metis-5.1.0/build/libmetis/Release/metis.lib")
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
########################################################
## C++ PROJECT ###
########################################################
PROJECT(AcousticPulse)
INCLUDE(${APPS_ROOT}/IncludsList.cmake)
#################################################################
### LOCAL FILES ###
#################################################################
FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp )
SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
SOURCE_GROUP(src FILES ${SPECIFIC_FILES})
SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids)
#################################################################
### CREATE PROJECT ###
#################################################################
CREATE_CAB_PROJECT(ap BINARY)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
########################################################
## C++ PROJECT ###
########################################################
PROJECT(AcousticPulse)
INCLUDE(${APPS_ROOT}/IncludsList.cmake)
#################################################################
### LOCAL FILES ###
#################################################################
FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp )
SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
SOURCE_GROUP(src FILES ${SPECIFIC_FILES})
SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids)
#################################################################
### CREATE PROJECT ###
#################################################################
CREATE_CAB_PROJECT(ap BINARY)
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment