Skip to content
Snippets Groups Projects
Commit fcea8788 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Make MeshItemType::type enum to an MeshItemType enum class.

This improves type safety. Also add an operator<<().
parent a12e8891
No related branches found
No related tags found
No related merge requests found
......@@ -16,11 +16,23 @@
#ifndef MESHITEM_H_
#define MESHITEM_H_
#include "MeshItemType.h"
namespace VecMatOnMeshLib
{
enum class MeshItemType { Node, Edge, Face, Cell };
inline std::ostream& operator<<(std::ostream& os, MeshItemType const& t)
{
switch (t)
{
case MeshItemType::Node: return os << "N";
case MeshItemType::Edge: return os << "E";
case MeshItemType::Face: return os << "F";
case MeshItemType::Cell: return os << "C";
};
return os;
}
/** Spatial location description.
*
* The spatial location is given by a mesh by its \c mesh_id, item's type (face,
......@@ -29,10 +41,10 @@ namespace VecMatOnMeshLib
struct Location
{
std::size_t mesh_id;
MeshItemType::type item_type;
MeshItemType item_type;
std::size_t item_id;
Location(std::size_t meshid, MeshItemType::type itemtype, std::size_t itemid)
Location(std::size_t meshid, MeshItemType itemtype, std::size_t itemid)
: mesh_id(meshid), item_type(itemtype), item_id(itemid){};
};
......
/**
* \file
* \author Norihiro Watanabe
* \date 2013-04-16
* \brief
*
* \copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef MESHITEMTYPE_H_
#define MESHITEMTYPE_H_
namespace VecMatOnMeshLib
{
struct MeshItemType
{
enum type
{
Node,
Edge,
Face,
Cell
};
};
}
#endif /* MESHITEMTYPE_H_ */
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