Commit af6f2b76 authored by Nicolas CHEVAUGEON's avatar Nicolas CHEVAUGEON
Browse files

[Xfiles] removing using xxx in global namespace in headers.

    - lot of using std or using xfem or using std::string etc ..  were still present in global namespace in some header. Following a discussion with A. Salzman, I removed most of them.

    - In the transition from mPoint to xPoint, Some using point = xtensor::xPoint were defined inside some class (xMapping, xElementfor example... ). They were identifyed as confusing by A. Salzman and are now removed.

    Most of the changes in this commit reflect the previous change. The guideline is to avoid hiding namespace at least at global scope in header-file. This can avoid some confusion and some surprising and hard to track effects where some stuff compil or not depending on the order of inclusion of header files.
parent a645d0e7
/****************************************************************************
/****************************************************************************
Copyright (C) 2004
Rensselaer Polytechnic Institute
This file is part of the Algorithm-Oriented Mesh Database (AOMD) written
and maintained by the Scientific Computation Research Center (SCOREC) at
This file is part of the Algorithm-Oriented Mesh Database (AOMD) written
and maintained by the Scientific Computation Research Center (SCOREC) at
Rensselaer Polytechnic Intitute, Troy, NY, USA.
This program is free software; you can redistribute it and/or modify it
under the terms of the Rensselaer SCOREC Public License.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
license text for more details.
You should have received a copy of the Rensselaer SCOREC Public License
along with this program; if not, write to Rensselaer Polytechnic Institure,
110 8th Street, SCOREC, Troy, NY 12180, USA
......@@ -31,373 +31,365 @@
#endif
#include <algorithm>
#include <vector>
#include <iosfwd>
namespace AOMD {
namespace AOMD
{
class mMesh;
class mMirrorVertex;
class mEntity;
class mMesh;
class mMirrorVertex;
class mEntity;
/**
Base class for attachable data's
*/
class mAttachableData
{
public:
virtual ~mAttachableData() = default;
};
/**
Base class for attachable data's
*/
class mAttachableData
{
public :
virtual ~mAttachableData()= default;;
};
/**
Vector of ints as attachable data
*/
class mAttachableIntVector : public mAttachableData
{
public :
~mAttachableIntVector() override= default;
std::vector<int> v;
};
/**
Vector of ints as attachable data
*/
class mAttachablePointVector : public mAttachableData
{
public :
~mAttachablePointVector() override= default;
std::vector<Trellis_Util::mPoint> v;
};
/**
Vector of ints as attachable data
*/
class mAttachableIntVector : public mAttachableData
{
public:
~mAttachableIntVector() override = default;
std::vector<int> v;
};
/**
Vector of ints as attachable data
*/
class mAttachablePointVector : public mAttachableData
{
public:
~mAttachablePointVector() override = default;
std::vector<Trellis_Util::mPoint> v;
};
/**
Int as attachable data
*/
class mAttachableInt : public mAttachableData
{
public :
~mAttachableInt() override= default;
int i;
};
/**
Double as attachable data
*/
class mAttachableDouble : public mAttachableData
{
public :
~mAttachableDouble() override= default;
double d;
};
/**
Point as attachable data
*/
class mAttachablePoint : public mAttachableData
{
public :
Trellis_Util::mPoint p;
};
/**
Point as attachable data
*/
class mAttachable_mVector : public mAttachableData
{
public :
Trellis_Util::mVector v;
};
/**
Point as attachable data
*/
class mAttachable_mTensor2 : public mAttachableData
{
public :
Trellis_Util::mTensor2 t;
};
/**
Mesh as attachable data
*/
class mAttachableMesh : public mAttachableData
{
public :
mMesh *m;
};
/**
Mesh as attachable data
*/
class mAttachableMirrorVertex : public mAttachableData
{
public :
mMirrorVertex *e;
};
/**
mesh entity as attachable data
*/
class mAttachableEntity : public mAttachableData
{
public :
mEntity *e;
};
/**
Int as attachable data
*/
class mAttachableInt : public mAttachableData
{
public:
~mAttachableInt() override = default;
int i;
};
#ifdef TSTT_
class mAttachableOpaque : public mAttachableData
{
public :
char *o;
int size;
};
#endif
/**
Container for attachable data's Internal, mEntity and mMesh provides interfaces.
*/
class mAttachableDataContainer
{
public :
typedef std::pair <unsigned int, mAttachableData *> info;
// typedef std::map< unsigned int, mAttachableData *> container;
typedef std::vector< info > container;
typedef container::iterator iter_attachdata;
typedef container::const_iterator citer_attachdata;
private :
container tab;
/**
Double as attachable data
*/
class mAttachableDouble : public mAttachableData
{
public:
mAttachableDataContainer(){}
~mAttachableDataContainer();
inline void attachData(unsigned int, mAttachableData *);
inline void deleteData(unsigned int);
inline mAttachableData * getData(unsigned int) const;
inline citer_attachdata begin_attachdata() const {return tab.begin();};
inline citer_attachdata end_attachdata() const {return tab.end();};
/// specific data types for mEntity
inline void attachEntity(unsigned int,mEntity *);
/// specific data types for int
inline void attachInt(unsigned int, int);
/// specific data types for int
inline int getAttachedInt(unsigned int) const;
inline int getAttachedInt(unsigned int, int*);
/// specific data types for mEntity
inline mEntity* getAttachedEntity(unsigned int);
/// specific data types for double
inline void attachDouble(unsigned int, double);
/// specific data types for double
inline double getAttachedDouble(unsigned int);
inline int getAttachedDouble(unsigned int, double*);
/// specific data types for vector
inline void attachVector(unsigned int, const Trellis_Util::mVector &t);
/// specific data types for vector
inline Trellis_Util::mVector getAttachedVector(unsigned int);
/// specific data types for tensor
inline void attachTensor(unsigned int, const Trellis_Util::mTensor2 &t);
/// specific data types for tensor
inline Trellis_Util::mTensor2 getAttachedTensor(unsigned int);
#ifdef TSTT_
inline void attachOpaque(unsigned int c, const char*o, int size);
// inline int getAttachedEntity(unsigned int c, mEntity* d);
inline int getSizeAttachedOpaque(unsigned int c);
inline int getAttachedOpaque(unsigned int c, char* d);
#endif
};
class equalInfoPred
{
const unsigned int c;
public:
equalInfoPred ( unsigned int i ) :c(i) {}
inline bool operator () (const mAttachableDataContainer::info &i) const
{
return (i.first == c);
}
};
inline mAttachableDataContainer::~mAttachableDataContainer()
{
if(!tab.size())return;
citer_attachdata it = begin_attachdata();
citer_attachdata itEnd = end_attachdata();
for(;it!=itEnd;++it)
{
mAttachableData *a = (*it).second;
if (a){
delete a;
a = nullptr;
}
}
}
~mAttachableDouble() override = default;
double d;
};
/**
Point as attachable data
*/
class mAttachablePoint : public mAttachableData
{
public:
Trellis_Util::mPoint p;
};
/**
Point as attachable data
*/
class mAttachable_mVector : public mAttachableData
{
public:
Trellis_Util::mVector v;
};
/**
Point as attachable data
*/
class mAttachable_mTensor2 : public mAttachableData
{
public:
Trellis_Util::mTensor2 t;
};
/**
Mesh as attachable data
*/
class mAttachableMesh : public mAttachableData
{
public:
mMesh *m;
};
/**
Mesh as attachable data
*/
class mAttachableMirrorVertex : public mAttachableData
{
public:
mMirrorVertex *e;
};
/**
mesh entity as attachable data
*/
class mAttachableEntity : public mAttachableData
{
public:
mEntity *e;
};
inline mAttachableData *mAttachableDataContainer::getData(unsigned int c) const
{
citer_attachdata it = std::find_if (tab.begin(),tab.end(),equalInfoPred(c));
if(it == tab.end())return nullptr;
return (*it).second;
}
inline void mAttachableDataContainer::attachData(unsigned int c, mAttachableData *v)
{
tab.emplace_back(c,v);
}
inline void mAttachableDataContainer::deleteData(unsigned int c)
{
#ifdef TSTT_
if (AOMD_Util::Instance()->typeMeshDataId(c)==3)
{
mAttachableOpaque *data = (mAttachableOpaque *)getData(c);
delete [] data->o;
delete data;
}
else
{
class mAttachableOpaque : public mAttachableData
{
public:
char *o;
int size;
};
#endif
mAttachableData *data = getData (c);
if (data)delete data;
#ifdef TSTT_
}
#endif
tab.erase ( std::remove_if (tab.begin(),tab.end(),equalInfoPred(c)) ,
tab.end () );
}
inline void mAttachableDataContainer::attachInt(unsigned int c, int i)
{
mAttachableInt *ai = (mAttachableInt *)getData(c);
if(!ai)
{
ai = new mAttachableInt;
attachData(c,ai);
}
ai->i = i;
}
inline int mAttachableDataContainer::getAttachedInt (unsigned int c) const
{
mAttachableInt *ai = (mAttachableInt *)getData(c);
if(!ai)return 0;
return ai->i;
}
/**
Container for attachable data's Internal, mEntity and mMesh provides interfaces.
*/
inline void mAttachableDataContainer::attachDouble(unsigned int c, double d)
{
mAttachableDouble *ai = (mAttachableDouble *)getData(c);
if(!ai)
{
ai = new mAttachableDouble;
attachData(c,ai);
}
ai->d = d;
}
class mAttachableDataContainer
{
public:
typedef std::pair<unsigned int, mAttachableData *> info;
// typedef std::map< unsigned int, mAttachableData *> container;
typedef std::vector<info> container;
typedef container::iterator iter_attachdata;
typedef container::const_iterator citer_attachdata;
inline double mAttachableDataContainer::getAttachedDouble (unsigned int c)
{
mAttachableDouble *ai = (mAttachableDouble *)getData(c);
if(!ai)return 0;
return ai->d;
}
private:
container tab;
inline void mAttachableDataContainer::attachEntity(unsigned int c, mEntity *e)
{
mAttachableEntity *ai = (mAttachableEntity *)getData(c);
if(!ai)
{
ai = new mAttachableEntity;
attachData(c,ai);
}
ai->e = e;
}
public:
mAttachableDataContainer() {}
~mAttachableDataContainer();
inline void attachData(unsigned int, mAttachableData *);
inline void deleteData(unsigned int);
inline mAttachableData *getData(unsigned int) const;
inline citer_attachdata begin_attachdata() const { return tab.begin(); };
inline citer_attachdata end_attachdata() const { return tab.end(); };
/// specific data types for mEntity
inline void attachEntity(unsigned int, mEntity *);
/// specific data types for int
inline void attachInt(unsigned int, int);
/// specific data types for int
inline int getAttachedInt(unsigned int) const;
inline int getAttachedInt(unsigned int, int *);
/// specific data types for mEntity
inline mEntity *getAttachedEntity(unsigned int);
/// specific data types for double
inline void attachDouble(unsigned int, double);
/// specific data types for double
inline double getAttachedDouble(unsigned int);
inline int getAttachedDouble(unsigned int, double *);
/// specific data types for vector
inline void attachVector(unsigned int, const Trellis_Util::mVector &t);
/// specific data types for vector
inline Trellis_Util::mVector getAttachedVector(unsigned int);
/// specific data types for tensor
inline void attachTensor(unsigned int, const Trellis_Util::mTensor2 &t);
/// specific data types for tensor
inline Trellis_Util::mTensor2 getAttachedTensor(unsigned int);
#ifdef TSTT_
inline void attachOpaque(unsigned int c, const char *o, int size);
// inline int getAttachedEntity(unsigned int c, mEntity* d);
inline int getSizeAttachedOpaque(unsigned int c);
inline int getAttachedOpaque(unsigned int c, char *d);
#endif
};
inline mEntity* mAttachableDataContainer::getAttachedEntity (unsigned int c)
{
mAttachableEntity *ai = (mAttachableEntity *)getData(c);
if(!ai)return nullptr;
return ai->e;
}
class equalInfoPred
{
const unsigned int c;
inline void mAttachableDataContainer::attachVector(unsigned int c, const Trellis_Util::mVector &d)
{
mAttachable_mVector *ai = (mAttachable_mVector *)getData(c);
if(!ai)
public:
equalInfoPred(unsigned int i) : c(i) {}
inline bool operator()(const mAttachableDataContainer::info &i) const { return (i.first == c); }
};
inline mAttachableDataContainer::~mAttachableDataContainer()
{
if (!tab.size()) return;
citer_attachdata it = begin_attachdata();
citer_attachdata itEnd = end_attachdata();
for (; it != itEnd; ++it)
{
mAttachableData *a = (*it).second;
if (a)
{
ai = new mAttachable_mVector;
attachData(c,ai);
delete a;
a = nullptr;
}
ai->v = d;
}
}
}
inline Trellis_Util::mVector mAttachableDataContainer::getAttachedVector (unsigned int c)
{
mAttachable_mVector *ai = (mAttachable_mVector *)getData(c);
if(!ai)return 0;
return ai->v;
}
inline mAttachableData *mAttachableDataContainer::getData(unsigned int c) const
{
citer_attachdata it = std::find_if(tab.begin(), tab.end(), equalInfoPred(c));
if (it == tab.end()) return nullptr;
return (*it).second;
}
inline void mAttachableDataContainer::attachTensor(unsigned int c, const Trellis_Util::mTensor2 &d)
{
mAttachable_mTensor2 *ai = (mAttachable_mTensor2 *)getData(c);
if(!ai)
{
ai = new mAttachable_mTensor2;
attachData(c,ai);
}
ai->t = d;
}
inline void mAttachableDataContainer::attachData(unsigned int c, mAttachableData *v) { tab.emplace_back(c, v); }
inline Trellis_Util::mTensor2 mAttachableDataContainer::getAttachedTensor (unsigned int c)
{
mAttachable_mTensor2 *ai = (mAttachable_mTensor2 *)getData(c);
if(!ai)return 0;
return ai->t;
}
inline void mAttachableDataContainer::deleteData(unsigned int c)
{
#ifdef TSTT_
if (AOMD_Util::Instance()->typeMeshDataId(c) == 3)
{
mAttachableOpaque *data = (mAttachableOpaque *)getData(c);
delete[] data->o;
delete data;
}
else
{
#endif
mAttachableData *data = getData(c);
if (data) delete data;
#ifdef TSTT_
}
#endif
tab.erase(std::remove_if(tab.begin(), tab.end(), equalInfoPred(c)), tab.end());
}
inline void mAttachableDataContainer::attachInt(unsigned int c, int i)
{
mAttachableInt *ai = (mAttachableInt *)getData(c);
if (!ai)
{
ai = new mAttachableInt;
attachData(c, ai);
}
ai->i = i;
}
inline int mAttachableDataContainer::getAttachedInt(unsigned int c) const
{
mAttachableInt *ai = (mAttachableInt *)getData(c);
if (!ai) return 0;
return ai->i;
}
inline void mAttachableDataContainer::attachDouble(unsigned int c, double d)
{
mAttachableDouble *ai = (mAttachableDouble *)getData(c);
if (!ai)
{
ai = new mAttachableDouble;
attachData(c, ai);
}
ai->d = d;
}
inline double mAttachableDataContainer::getAttachedDouble(unsigned int c)
{
mAttachableDouble *ai = (mAttachableDouble *)getData(c);
if (!ai