2015-02-09 22:04:09 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
|
|
|
// Copyright 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-06-03 19:06:43 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2015-02-09 22:04:09 +00:00
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
2015-08-16 18:53:44 +00:00
|
|
|
#ifndef vtk_m_CellShape_h
|
|
|
|
#define vtk_m_CellShape_h
|
2015-02-09 22:04:09 +00:00
|
|
|
|
2015-09-17 19:45:35 +00:00
|
|
|
#include <vtkm/StaticAssert.h>
|
2015-08-16 21:31:36 +00:00
|
|
|
#include <vtkm/Types.h>
|
|
|
|
|
|
|
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
|
|
|
#include <boost/type_traits/integral_constant.hpp>
|
|
|
|
VTKM_THIRDPARTY_POST_INCLUDE
|
|
|
|
|
2015-02-09 22:04:09 +00:00
|
|
|
namespace vtkm {
|
|
|
|
|
2015-08-16 18:53:44 +00:00
|
|
|
/// CellShapeId identifies the type of each cell. Currently these are designed
|
|
|
|
/// to match up with VTK cell types.
|
2015-02-09 22:04:09 +00:00
|
|
|
///
|
2015-08-16 21:31:36 +00:00
|
|
|
enum CellShapeIdEnum
|
2015-02-09 22:04:09 +00:00
|
|
|
{
|
|
|
|
// Linear cells
|
2015-08-16 18:53:44 +00:00
|
|
|
CELL_SHAPE_EMPTY = 0,
|
|
|
|
CELL_SHAPE_VERTEX = 1,
|
|
|
|
//CELL_SHAPE_POLY_VERTEX = 2,
|
|
|
|
CELL_SHAPE_LINE = 3,
|
|
|
|
//CELL_SHAPE_POLY_LINE = 4,
|
|
|
|
CELL_SHAPE_TRIANGLE = 5,
|
|
|
|
//CELL_SHAPE_TRIANGLE_STRIP = 6,
|
|
|
|
CELL_SHAPE_POLYGON = 7,
|
2015-11-17 16:32:19 +00:00
|
|
|
//CELL_SHAPE_PIXEL = 8,
|
2015-08-16 18:53:44 +00:00
|
|
|
CELL_SHAPE_QUAD = 9,
|
|
|
|
CELL_SHAPE_TETRA = 10,
|
2015-11-17 16:32:19 +00:00
|
|
|
//CELL_SHAPE_VOXEL = 11,
|
2015-08-16 18:53:44 +00:00
|
|
|
CELL_SHAPE_HEXAHEDRON = 12,
|
|
|
|
CELL_SHAPE_WEDGE = 13,
|
|
|
|
CELL_SHAPE_PYRAMID = 14,
|
2015-02-09 22:04:09 +00:00
|
|
|
|
2015-08-16 18:53:44 +00:00
|
|
|
NUMBER_OF_CELL_SHAPES
|
2015-02-09 22:04:09 +00:00
|
|
|
};
|
|
|
|
|
2015-08-16 21:31:36 +00:00
|
|
|
// If you wish to add cell shapes to this list, in addition to adding an index
|
2015-08-19 16:01:26 +00:00
|
|
|
// to the enum above, you at a minimum need to define an associated tag with
|
2015-08-16 21:31:36 +00:00
|
|
|
// VTKM_DEFINE_CELL_TAG and add a condition to the vtkmGenericCellShapeMacro.
|
2015-08-19 16:01:26 +00:00
|
|
|
// There are also many other cell-specific features that code might expect such
|
|
|
|
// as \c CellTraits and interpolations.
|
2015-08-16 21:31:36 +00:00
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
/// A class that can be used to determine if a class is a CellShapeTag or not.
|
|
|
|
/// The class will be either boost::true_type or boost::false_type.
|
|
|
|
///
|
|
|
|
template<typename T>
|
|
|
|
struct CellShapeTagCheck : boost::false_type { };
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
/// Checks that the argument is a proper cell shape tag. This is a handy
|
|
|
|
/// concept check to make sure that a template argument is a proper cell shape
|
|
|
|
/// tag.
|
|
|
|
///
|
|
|
|
#define VTKM_IS_CELL_SHAPE_TAG(tag) \
|
2015-09-17 19:45:35 +00:00
|
|
|
VTKM_STATIC_ASSERT_MSG( \
|
2015-08-16 21:31:36 +00:00
|
|
|
::vtkm::internal::CellShapeTagCheck<tag>::value, \
|
2015-09-17 19:45:35 +00:00
|
|
|
"Provided type is not a valid VTK-m cell shape tag.")
|
2015-08-16 21:31:36 +00:00
|
|
|
|
|
|
|
/// A traits-like class to get an CellShapeId known at compile time to a tag.
|
|
|
|
///
|
|
|
|
template<vtkm::IdComponent Id>
|
|
|
|
struct CellShapeIdToTag {
|
|
|
|
// If you get a compile error for this class about Id not being defined, that
|
|
|
|
// probably means you are using an ID that does not have a defined cell
|
|
|
|
// shape.
|
|
|
|
|
|
|
|
typedef boost::false_type valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Define a tag for each cell shape as well as the support structs to go
|
|
|
|
// between tags and ids. The following macro is only valid here.
|
|
|
|
|
|
|
|
#define VTKM_DEFINE_CELL_TAG(name, idname) \
|
|
|
|
struct CellShapeTag ## name { \
|
|
|
|
static const vtkm::IdComponent Id = vtkm::idname; \
|
|
|
|
}; \
|
|
|
|
namespace internal { \
|
|
|
|
template<> \
|
|
|
|
struct CellShapeTagCheck<vtkm::CellShapeTag ## name> : boost::true_type { }; \
|
|
|
|
} \
|
|
|
|
VTKM_EXEC_CONT_EXPORT \
|
|
|
|
const char *GetCellShapeName(vtkm::CellShapeTag ## name) { \
|
|
|
|
return #name; \
|
|
|
|
} \
|
|
|
|
template<> \
|
|
|
|
struct CellShapeIdToTag<vtkm::idname> { \
|
|
|
|
typedef boost::true_type valid; \
|
|
|
|
typedef vtkm::CellShapeTag ## name Tag; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VTKM_DEFINE_CELL_TAG(Empty, CELL_SHAPE_EMPTY);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Vertex, CELL_SHAPE_VERTEX);
|
|
|
|
//VTKM_DEFINE_CELL_TAG(PolyVertex, CELL_SHAPE_POLY_VERTEX);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Line, CELL_SHAPE_LINE);
|
|
|
|
//VTKM_DEFINE_CELL_TAG(PolyLine, CELL_SHAPE_POLY_LINE);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Triangle, CELL_SHAPE_TRIANGLE);
|
|
|
|
//VTKM_DEFINE_CELL_TAG(TriangleStrip, CELL_SHAPE_TRIANGLE_STRIP);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Polygon, CELL_SHAPE_POLYGON);
|
2015-08-27 23:03:13 +00:00
|
|
|
//VTKM_DEFINE_CELL_TAG(Pixel, CELL_SHAPE_PIXEL);
|
2015-08-16 21:31:36 +00:00
|
|
|
VTKM_DEFINE_CELL_TAG(Quad, CELL_SHAPE_QUAD);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Tetra, CELL_SHAPE_TETRA);
|
2015-08-27 23:03:13 +00:00
|
|
|
//VTKM_DEFINE_CELL_TAG(Voxel, CELL_SHAPE_VOXEL);
|
2015-08-16 21:31:36 +00:00
|
|
|
VTKM_DEFINE_CELL_TAG(Hexahedron, CELL_SHAPE_HEXAHEDRON);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Wedge, CELL_SHAPE_WEDGE);
|
|
|
|
VTKM_DEFINE_CELL_TAG(Pyramid, CELL_SHAPE_PYRAMID);
|
|
|
|
|
|
|
|
#undef VTKM_DEFINE_CELL_TAG
|
|
|
|
|
|
|
|
|
|
|
|
/// A special cell shape tag that holds a cell shape that is not known at
|
|
|
|
/// compile time. Unlike other cell set tags, the Id field is set at runtime
|
|
|
|
/// so its value cannot be used in template parameters. You need to use
|
|
|
|
/// \c vtkmGenericCellShapeMacro to specialize on the cell type.
|
|
|
|
///
|
|
|
|
struct CellShapeTagGeneric {
|
2015-08-27 23:34:28 +00:00
|
|
|
VTKM_EXEC_CONT_EXPORT
|
2015-08-16 21:31:36 +00:00
|
|
|
CellShapeTagGeneric(vtkm::IdComponent shape) : Id(shape) { }
|
|
|
|
|
2015-10-07 18:14:00 +00:00
|
|
|
vtkm::IdComponent Id;
|
2015-08-16 21:31:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define vtkmGenericCellShapeMacroCase(cellShapeId, call) \
|
|
|
|
case vtkm::cellShapeId: \
|
|
|
|
{ \
|
|
|
|
typedef \
|
2015-11-17 16:32:19 +00:00
|
|
|
vtkm::CellShapeIdToTag<vtkm::cellShapeId>::Tag CellShapeTag; \
|
2015-08-16 21:31:36 +00:00
|
|
|
call; \
|
|
|
|
} \
|
|
|
|
break
|
|
|
|
|
|
|
|
/// \brief A macro used in a \c switch statement to determine cell shape.
|
|
|
|
///
|
|
|
|
/// The \c vtkmGenericCellShapeMacro is a series of case statements for all
|
|
|
|
/// of the cell shapes supported by VTK-m. This macro is intended to be used
|
|
|
|
/// inside of a switch statement on a cell type. For each cell shape condition,
|
|
|
|
/// a \c CellShapeTag typedef is created and the given \c call is executed.
|
|
|
|
///
|
|
|
|
/// A typical use case of this class is to create the specialization of a
|
|
|
|
/// function overloaded on a cell shape tag for the generic cell shape like as
|
|
|
|
/// following.
|
|
|
|
///
|
|
|
|
/// \code{.cpp}
|
|
|
|
/// template<typename WorkletType>
|
|
|
|
/// VTKM_EXEC_EXPORT
|
|
|
|
/// void MyCellOperation(vtkm::CellShapeTagGeneric cellShape,
|
|
|
|
/// const vtkm::exec::FunctorBase &worklet)
|
|
|
|
/// {
|
|
|
|
/// switch(cellShape.CellShapeId)
|
|
|
|
/// {
|
|
|
|
/// vtkmGenericCellShapeMacro(
|
|
|
|
/// MyCellOperation(CellShapeTag())
|
|
|
|
/// );
|
|
|
|
/// default: worklet.RaiseError("Encountered unknown cell shape."); break
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// Note that \c vtkmGenericCellShapeMacro does not have a default case. You
|
|
|
|
/// should consider adding one that gives a
|
|
|
|
///
|
|
|
|
#define vtkmGenericCellShapeMacro(call) \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_EMPTY, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_VERTEX, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_LINE, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_TRIANGLE, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_POLYGON, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_QUAD, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_TETRA, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_HEXAHEDRON, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_WEDGE, call); \
|
|
|
|
vtkmGenericCellShapeMacroCase(CELL_SHAPE_PYRAMID, call)
|
2015-02-09 22:04:09 +00:00
|
|
|
|
|
|
|
} // namespace vtkm
|
|
|
|
|
2015-08-16 18:53:44 +00:00
|
|
|
#endif //vtk_m_CellShape_h
|