2014-09-09 14:42:13 -04:00
|
|
|
#ifndef MESH_INC
|
|
|
|
|
#define MESH_INC
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "common/PointList.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace IO {
|
|
|
|
|
|
|
|
|
|
|
2014-11-06 14:23:57 -05:00
|
|
|
//! Possible variable types
|
|
|
|
|
enum class VariableType : unsigned char { NodeVariable=1, EdgeVariable=2, SurfaceVariable=2, VolumeVariable=3, Null=0 };
|
|
|
|
|
|
|
|
|
|
|
2014-09-09 14:42:13 -04:00
|
|
|
/*! \class Mesh
|
|
|
|
|
\brief A base class for meshes
|
|
|
|
|
*/
|
|
|
|
|
class Mesh
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//! Destructor
|
|
|
|
|
virtual ~Mesh();
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Mesh class name (eg. PointList)
|
|
|
|
|
virtual std::string className() const = 0;
|
2014-11-06 14:23:57 -05:00
|
|
|
//! Number of points for the given variable type
|
|
|
|
|
virtual size_t numberPointsVar( VariableType type ) const = 0;
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Pack the data
|
|
|
|
|
virtual std::pair<size_t,void*> pack( int level ) const = 0;
|
|
|
|
|
//! Unpack the data
|
|
|
|
|
virtual void unpack( const std::pair<size_t,void*>& data ) = 0;
|
2014-09-09 14:42:13 -04:00
|
|
|
protected:
|
|
|
|
|
//! Empty constructor
|
|
|
|
|
Mesh();
|
|
|
|
|
Mesh(const Mesh&);
|
|
|
|
|
Mesh& operator=(const Mesh&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class PointList
|
|
|
|
|
\brief A class used to hold a list of verticies
|
|
|
|
|
*/
|
|
|
|
|
class PointList: public Mesh
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//! Empty constructor
|
|
|
|
|
PointList();
|
|
|
|
|
//! Constructor for N points
|
|
|
|
|
PointList( size_t N );
|
|
|
|
|
//! Destructor
|
|
|
|
|
virtual ~PointList();
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Mesh class name
|
|
|
|
|
virtual std::string className() const { return "PointList"; }
|
2014-11-06 14:23:57 -05:00
|
|
|
//! Number of points for the given variable type
|
|
|
|
|
virtual size_t numberPointsVar( VariableType type ) const;
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Pack the data
|
|
|
|
|
virtual std::pair<size_t,void*> pack( int level ) const;
|
|
|
|
|
//! Unpack the data
|
|
|
|
|
virtual void unpack( const std::pair<size_t,void*>& data );
|
2014-09-09 14:42:13 -04:00
|
|
|
public:
|
|
|
|
|
std::vector<Point> points; //!< List of points vertex
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class TriMesh
|
|
|
|
|
\brief A class used to hold a list of trianges specified by their vertex number and list of coordiantes
|
|
|
|
|
*/
|
|
|
|
|
class TriList;
|
|
|
|
|
class TriMesh: public Mesh
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//! TriMesh constructor
|
|
|
|
|
TriMesh();
|
|
|
|
|
//! Constructor for Nt triangles and Np points
|
|
|
|
|
TriMesh( size_t N_tri, size_t N_point );
|
|
|
|
|
//! Constructor for Nt triangles and the given points
|
|
|
|
|
TriMesh( size_t N_tri, std::shared_ptr<PointList> points );
|
|
|
|
|
//! Constructor from TriList
|
|
|
|
|
TriMesh( const TriList& );
|
|
|
|
|
//! Destructor
|
|
|
|
|
virtual ~TriMesh();
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Mesh class name
|
|
|
|
|
virtual std::string className() const { return "TriMesh"; }
|
2014-11-06 14:23:57 -05:00
|
|
|
//! Number of points for the given variable type
|
|
|
|
|
virtual size_t numberPointsVar( VariableType type ) const;
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Pack the data
|
|
|
|
|
virtual std::pair<size_t,void*> pack( int level ) const;
|
|
|
|
|
//! Unpack the data
|
|
|
|
|
virtual void unpack( const std::pair<size_t,void*>& data );
|
2014-09-09 14:42:13 -04:00
|
|
|
public:
|
|
|
|
|
std::shared_ptr<PointList> vertices; //!< List of verticies
|
|
|
|
|
std::vector<int> A; //!< First vertex
|
|
|
|
|
std::vector<int> B; //!< Second vertex
|
|
|
|
|
std::vector<int> C; //!< Third vertex
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class TriList
|
|
|
|
|
\brief A class used to hold a list of triangles specified by their vertex coordinates
|
|
|
|
|
*/
|
|
|
|
|
class TriList: public Mesh
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//! Empty constructor
|
|
|
|
|
TriList();
|
|
|
|
|
//! Constructor for N triangles
|
|
|
|
|
TriList( size_t N_tri );
|
|
|
|
|
//! Constructor from TriMesh
|
|
|
|
|
TriList( const TriMesh& );
|
|
|
|
|
//! Destructor
|
|
|
|
|
virtual ~TriList();
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Mesh class name
|
|
|
|
|
virtual std::string className() const { return "TriList"; }
|
2014-11-06 14:23:57 -05:00
|
|
|
//! Number of points for the given variable type
|
|
|
|
|
virtual size_t numberPointsVar( VariableType type ) const;
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Pack the data
|
|
|
|
|
virtual std::pair<size_t,void*> pack( int level ) const;
|
|
|
|
|
//! Unpack the data
|
|
|
|
|
virtual void unpack( const std::pair<size_t,void*>& data );
|
2014-09-09 14:42:13 -04:00
|
|
|
public:
|
|
|
|
|
std::vector<Point> A; //!< First vertex
|
|
|
|
|
std::vector<Point> B; //!< Second vertex
|
|
|
|
|
std::vector<Point> C; //!< Third vertex
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-04 21:58:20 -05:00
|
|
|
/*! \class Variable
|
|
|
|
|
\brief A base class fore variables
|
|
|
|
|
*/
|
|
|
|
|
struct Variable
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-11-05 16:54:18 -05:00
|
|
|
// Internal variables
|
|
|
|
|
unsigned int dim; //!< Number of points per grid point (1: scalar, 3: vector, ...)
|
|
|
|
|
VariableType type; //!< Variable type
|
|
|
|
|
std::string name; //!< Variable name
|
|
|
|
|
std::vector<double> data; //!< Variable data
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Empty constructor
|
2014-11-05 16:54:18 -05:00
|
|
|
Variable(): type(VariableType::Null) {}
|
2014-11-04 21:58:20 -05:00
|
|
|
//! Destructor
|
|
|
|
|
virtual ~Variable() {}
|
|
|
|
|
protected:
|
|
|
|
|
//! Empty constructor
|
|
|
|
|
Variable(const Variable&);
|
|
|
|
|
Variable& operator=(const Variable&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-09 14:42:13 -04:00
|
|
|
/*! \class MeshDataStruct
|
|
|
|
|
\brief A class used to hold database info for saving a mesh
|
|
|
|
|
*/
|
|
|
|
|
struct MeshDataStruct {
|
|
|
|
|
std::string meshName;
|
|
|
|
|
std::shared_ptr<Mesh> mesh;
|
2014-11-04 21:58:20 -05:00
|
|
|
std::vector<std::shared_ptr<Variable> > vars;
|
2014-09-09 14:42:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Convert the mesh to a TriMesh (will return NULL if this is invalid)
|
|
|
|
|
std::shared_ptr<PointList> getPointList( std::shared_ptr<Mesh> mesh );
|
|
|
|
|
std::shared_ptr<TriMesh> getTriMesh( std::shared_ptr<Mesh> mesh );
|
|
|
|
|
std::shared_ptr<TriList> getTriList( std::shared_ptr<Mesh> mesh );
|
2014-11-06 14:23:57 -05:00
|
|
|
std::shared_ptr<const PointList> getPointList( std::shared_ptr<const Mesh> mesh );
|
|
|
|
|
std::shared_ptr<const TriMesh> getTriMesh( std::shared_ptr<const Mesh> mesh );
|
|
|
|
|
std::shared_ptr<const TriList> getTriList( std::shared_ptr<const Mesh> mesh );
|
2014-09-09 14:42:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
} // IO namespace
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|