1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkDefaultDynamicMeshTraits_h
19 #define itkDefaultDynamicMeshTraits_h
20 
21 #include "itkCellInterface.h"
22 #include "itkMapContainer.h"
23 #include "itkPoint.h"
24 #include "itkIntTypes.h"
25 #include <set>
26 
27 namespace itk
28 {
29 /** \class DefaultDynamicMeshTraits
30  *  \brief A simple structure that holds type information for a mesh and its cells.
31  *
32  * DefaultDynamicMeshTraits is a simple structure that holds type information
33  * for a mesh and its cells.  It is used to avoid the passing of many
34  * template parameters while still enjoying the benefits of generic
35  * programming.
36  *
37  * Unlike DefaultStaticMeshTraits, this version of the MeshTraits structure
38  * is designed to create Mesh instances that will have many insert and delete
39  * operations done on them.
40  *
41  * \tparam TPixelType The type stored as data for an entity (cell, point,
42  * or boundary).
43  *
44  * \tparam VPointDimension Geometric dimension of space.
45  *
46  * \tparam VMaxTopologicalDimension Max topological dimension of a cell
47  * that can be inserted into this mesh.
48  *
49  * \tparam TCoordRep Numerical type to store each coordinate value.
50  *
51  * \tparam TInterpolationWeight Numerical type to store interpolation
52  * weights.
53  *
54  * \ingroup MeshObjects
55  * \ingroup ITKCommon
56  */
57 template<
58   typename TPixelType,
59   unsigned int VPointDimension = 3,
60   unsigned int VMaxTopologicalDimension = VPointDimension,
61   typename TCoordRep = float,
62   typename TInterpolationWeight = float,
63   typename TCellPixelType = TPixelType
64   >
65 class DefaultDynamicMeshTraits
66 {
67 public:
68   /** Standard class type aliases. */
69   using Self = DefaultDynamicMeshTraits;
70 
71   /** Just save all the template parameters. */
72   using PixelType = TPixelType;
73   using CellPixelType = TCellPixelType;
74   using CoordRepType = TCoordRep;
75   using InterpolationWeightType = TInterpolationWeight;
76 
77   /** Just save all the template parameters. */
78   static constexpr unsigned int PointDimension = VPointDimension;
79   static constexpr unsigned int MaxTopologicalDimension = VMaxTopologicalDimension;
80 
81   /** The type to be used to identify a point.  This should be the index type
82    * to the PointsContainer. */
83   using PointIdentifier = IdentifierType;
84 
85   /** The type to be used to identify a cell.  This should be the index type
86    * to the CellsContainer. */
87   using CellIdentifier = IdentifierType;
88 
89   /** A type that can be used to identifiy individual boundary features on
90    * the cells.  Since this will probably be an index into a static array,
91    * this will probably never change from an integer setting. */
92   using CellFeatureIdentifier = IdentifierType;
93 
94   /** The type of point used by the mesh. */
95   using PointType = Point< CoordRepType, VPointDimension >;
96 
97   /** The type of point used for hashing.  This should never change from
98    * this setting, regardless of the mesh type. */
99   using PointHashType = Point< CoordRepType, VPointDimension >;
100 
101   /** The container type for use in storing points.  It must conform to
102    * the IndexedContainerInterface. */
103   using PointsContainer = MapContainer< PointIdentifier, PointType >;
104 
105   /** The container type that will be used to store boundary links
106    * back to cells.  This must conform to the STL "set" interface. */
107   using UsingCellsContainer = std::set< CellIdentifier >;
108 
109   /** The information needed for a cell type is now defined, so we can
110    * define the cell type. */
111   using CellTraits = itkMakeCellTraitsMacro;
112 
113   /** The interface to cells to be used by the mesh.
114    * This should not be changed. */
115   using CellType = CellInterface< CellPixelType, CellTraits >;
116   using CellAutoPointer = typename CellType::CellAutoPointer;
117 
118   /** The container type for use in storing cells.  It must conform to
119    * the IndexedContainerInterface. */
120   using CellsContainer = MapContainer< CellIdentifier, CellType * >;
121 
122   /** The CellLinks container should be a container of PointCellLinksContainer,
123    * which should be a container conforming to the STL "set" interface. */
124   using PointCellLinksContainer = std::set< CellIdentifier >;
125 
126   /** The container type for use in storing point links back to cells.]
127    * It must conform to the IndexedContainerInterface. */
128   using CellLinksContainer = MapContainer<
129     PointIdentifier, PointCellLinksContainer >;
130 
131   /** The container type for use in storing point data.  It must conform to
132    * the IndexedContainerInterface. */
133   using PointDataContainer = MapContainer< PointIdentifier, PixelType >;
134 
135   /** The container type for use in storing cell data.  It must conform to
136    * the IndexedContainerInterface. */
137   using CellDataContainer = MapContainer<
138     CellIdentifier, CellPixelType >;
139 };
140 } // end namespace itk
141 
142 #endif
143