Skip to content
Snippets Groups Projects
Commit c5736dde authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

VTKWriter: improved implementation to avoid specializations by GridEntity

parent 93fd2bec
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@
#pragma once
#include <type_traits>
#include <TNL/Meshes/Writers/VTKWriter.h>
#include <TNL/Meshes/Readers/EntityShape.h>
......@@ -19,68 +21,63 @@ namespace Writers {
namespace __impl {
template< typename Entity >
struct VerticesPerEntity
template< typename T, typename R = void >
struct enable_if_type
{
static constexpr int count = Entity::getVerticesCount();
using type = R;
};
template< typename MeshConfig, typename Device >
struct VerticesPerEntity< MeshEntity< MeshConfig, Device, Topologies::Vertex > >
{
static constexpr int count = 1;
};
template< typename T, typename Enable = void >
struct has_entity_topology : std::false_type {};
template< typename Grid, typename Config >
struct VerticesPerEntity< GridEntity< Grid, 0, Config > >
{
static constexpr int count = 1;
};
template< typename T >
struct has_entity_topology< T, typename enable_if_type< typename T::EntityTopology >::type >
: std::true_type
{};
template< typename Grid, typename Config >
struct VerticesPerEntity< GridEntity< Grid, 1, Config > >
{
static constexpr int count = 2;
};
template< typename Grid, typename Config >
struct VerticesPerEntity< GridEntity< Grid, 2, Config > >
template< typename Entity,
bool _is_mesh_entity = has_entity_topology< Entity >::value >
struct VerticesPerEntity
{
static constexpr int count = 4;
static constexpr int count = Entity::getVerticesCount();
};
template< typename Grid, typename Config >
struct VerticesPerEntity< GridEntity< Grid, 3, Config > >
template< typename MeshConfig, typename Device >
struct VerticesPerEntity< MeshEntity< MeshConfig, Device, Topologies::Vertex >, true >
{
static constexpr int count = 8;
static constexpr int count = 1;
};
template< typename GridEntity >
struct GridEntityShape {};
template< typename Grid, typename Config >
struct GridEntityShape< GridEntity< Grid, 0, Config > >
struct VerticesPerEntity< GridEntity, false >
{
static constexpr Readers::EntityShape shape = Readers::EntityShape::Vertex;
private:
static constexpr int dim = GridEntity::getEntityDimension();
static_assert( dim >= 0 && dim <= 3, "unexpected dimension of the grid entity" );
public:
static constexpr int count =
(dim == 0) ? 1 :
(dim == 1) ? 2 :
(dim == 2) ? 4 :
8;
};
template< typename Grid, typename Config >
struct GridEntityShape< GridEntity< Grid, 1, Config > >
{
static constexpr Readers::EntityShape shape = Readers::EntityShape::Line;
};
template< typename Grid, typename Config >
struct GridEntityShape< GridEntity< Grid, 2, Config > >
{
static constexpr Readers::EntityShape shape = Readers::EntityShape::Pixel;
};
template< typename Grid, typename Config >
struct GridEntityShape< GridEntity< Grid, 3, Config > >
template< typename GridEntity >
struct GridEntityShape
{
static constexpr Readers::EntityShape shape = Readers::EntityShape::Voxel;
private:
static constexpr int dim = GridEntity::getEntityDimension();
static_assert( dim >= 0 && dim <= 3, "unexpected dimension of the grid entity" );
public:
static constexpr Readers::EntityShape shape =
(dim == 0) ? Readers::EntityShape::Vertex :
(dim == 1) ? Readers::EntityShape::Line :
(dim == 2) ? Readers::EntityShape::Pixel :
Readers::EntityShape::Voxel;
};
......
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