| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkSimplexMesh.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkSimplexMesh_h |
| 18 |
|
#define __itkSimplexMesh_h |
| 19 |
|
|
| 20 |
|
#if defined(_MSC_VER) |
| 21 |
|
#pragma warning ( disable : 4786 ) |
| 22 |
|
#endif |
| 23 |
|
|
| 24 |
|
#include "itkMesh.h" |
| 25 |
|
#include "itkSimplexMeshGeometry.h" |
| 26 |
|
#include "itkVertexCell.h" |
| 27 |
|
#include "itkTriangleCell.h" |
| 28 |
|
#include "itkCellInterface.h" |
| 29 |
|
#include "itkMapContainer.h" |
| 30 |
|
#include "itkFixedArray.h" |
| 31 |
|
#include "itkNumericTraits.h" |
| 32 |
|
#include <vector> |
| 33 |
|
#include <algorithm> |
| 34 |
|
#include <set> |
| 35 |
|
|
| 36 |
|
namespace itk |
| 37 |
IND |
**{ |
| 38 |
IND |
**/** \class SimplexMesh |
| 39 |
IND |
*** \brief The class represents a 2-simplex mesh. |
| 40 |
IND |
*** |
| 41 |
LEN,IND |
*** A simplex mesh can be used for deformable model segmentation of 3D image data. |
| 42 |
IND |
*** To create a simplex mesh one needs a triangle mesh, which can be converted |
| 43 |
IND |
*** to using the class itkTriangleMeshToSimplexMeshFilter. The back filtering |
| 44 |
LEN,IND |
*** (from simplex to trinagle mesh)is done through a itkSimplexMeshToTriangleMeshFilter. |
| 45 |
IND |
*** |
| 46 |
IND |
*** |
| 47 |
IND |
*** |
| 48 |
LEN,IND |
*** \author Thomas Boettger. Division Medical and Biological Informatics, German Cancer Research Center, Heidelberg. |
| 49 |
IND |
***/ |
| 50 |
IND |
**template <typename TPixelType, unsigned int VDimension = 3, |
| 51 |
LEN |
typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension, TPixelType , TPixelType , TPixelType > |
| 52 |
IND |
**> |
| 53 |
|
class SimplexMesh : public Mesh<TPixelType, VDimension, TMeshTraits> |
| 54 |
IND |
**{ |
| 55 |
IND |
**public: |
| 56 |
IND |
****/** Standard typedefs. */ |
| 57 |
IND |
****typedef SimplexMesh Self; |
| 58 |
|
|
| 59 |
IND |
****/** Standard typedefs. */ |
| 60 |
IND |
****typedef Mesh<TPixelType, VDimension, TMeshTraits> Superclass; |
| 61 |
|
|
| 62 |
IND |
****/** Standard typedefs. */ |
| 63 |
IND |
****typedef SmartPointer<Self> Pointer; |
| 64 |
|
|
| 65 |
IND |
****/** Standard typedefs. */ |
| 66 |
IND |
****typedef SmartPointer<const Self> ConstPointer; |
| 67 |
|
|
| 68 |
IND |
****/** definition for array of indices*/ |
| 69 |
IND |
****typedef typename SimplexMeshGeometry::IndexArray IndexArray; |
| 70 |
|
|
| 71 |
IND |
****/** definition for a set of neighbor indices */ |
| 72 |
IND |
****typedef std::set<unsigned long> NeighborSetType; |
| 73 |
|
|
| 74 |
IND |
****/** */ |
| 75 |
LEN,IND |
****typedef typename NeighborSetType::iterator NeighborSetIterator; |
| 76 |
|
|
| 77 |
IND |
****/** */ |
| 78 |
LEN,IND |
****typedef std::vector<unsigned long> NeighborListType; |
| 79 |
|
|
| 80 |
IND |
****/** */ |
| 81 |
IND |
****typedef typename TMeshTraits::PointType PointType; |
| 82 |
|
|
| 83 |
IND |
****/** */ |
| 84 |
IND |
****typedef typename TMeshTraits::PointIdentifier PointIdentifier; |
| 85 |
|
|
| 86 |
IND |
****/** */ |
| 87 |
IND |
****typedef typename PointType::VectorType VectorType; |
| 88 |
|
|
| 89 |
IND |
****/** */ |
| 90 |
IND |
****typedef typename Superclass::CellType CellType; |
| 91 |
|
|
| 92 |
IND |
****/** */ |
| 93 |
IND |
****typedef typename CellType::CellAutoPointer CellAutoPointer; |
| 94 |
IND |
****/** */ |
| 95 |
IND |
****typedef itk::LineCell<CellType> LineType; |
| 96 |
|
|
| 97 |
IND |
****/** map containing a SimplexMeshGeometry data object for each mesh point*/ |
| 98 |
LEN,IND |
****typedef itk::MapContainer<unsigned long, SimplexMeshGeometry *> GeometryMapType; |
| 99 |
|
|
| 100 |
IND |
****/** smartpointer def for the geometry map */ |
| 101 |
IND |
****typedef typename GeometryMapType::Pointer GeometryMapPointer; |
| 102 |
|
|
| 103 |
IND |
****/** iterator definition for iterating over a geometry map */ |
| 104 |
IND |
****typedef typename GeometryMapType::Iterator GeometryMapIterator; |
| 105 |
|
|
| 106 |
|
|
| 107 |
IND |
****/** Method for creation through the object factory. */ |
| 108 |
IND |
****itkNewMacro(Self); |
| 109 |
|
|
| 110 |
IND |
****/** Standard part of every itk Object. */ |
| 111 |
IND |
****itkTypeMacro(SimplexMesh, Mesh); |
| 112 |
|
|
| 113 |
IND |
****/** Hold on to the type information specified by the template parameters. */ |
| 114 |
IND |
****typedef TMeshTraits MeshTraits; |
| 115 |
IND |
****typedef typename MeshTraits::PixelType PixelType; |
| 116 |
LEN,IND |
****typedef typename MeshTraits::PointsContainer PointsContainer; |
| 117 |
LEN,IND |
****typedef typename Superclass::PointsContainerPointer PointsContainerPointer; |
| 118 |
LEN,IND |
****typedef typename Superclass::PointsContainer::Iterator PointsContainerIterator; |
| 119 |
LEN,IND |
****typedef typename Superclass::PointsContainerConstIterator PointsContainerConstIterator; |
| 120 |
LEN,IND |
****typedef typename Superclass::CellsContainerPointer CellsContainerPointer; |
| 121 |
LEN,IND |
****typedef typename Superclass::CellsContainerIterator CellsContainerIterator; |
| 122 |
IND |
****/** set the map of geometrydata to the new pointer */ |
| 123 |
IND |
****itkSetMacro(GeometryData, GeometryMapPointer ); |
| 124 |
|
|
| 125 |
IND |
****/** returns the current map of geometrydata */ |
| 126 |
IND |
****itkGetConstReferenceMacro(GeometryData, GeometryMapPointer ); |
| 127 |
|
|
| 128 |
IND |
****/** Get the first free id for new cells*/ |
| 129 |
IND |
****itkSetMacro(LastCellId, unsigned long); |
| 130 |
|
|
| 131 |
IND |
****/** Set the id value valid for new cells */ |
| 132 |
IND |
****itkGetMacro(LastCellId, unsigned long); |
| 133 |
|
|
| 134 |
IND |
****/** |
| 135 |
IND |
***** copy all necessary information from passed object |
| 136 |
IND |
***** to the mesh |
| 137 |
IND |
*****/ |
| 138 |
IND |
****virtual void CopyInformation(const DataObject *data); |
| 139 |
|
|
| 140 |
|
|
| 141 |
IND |
****/** |
| 142 |
IND |
***** Add a new edge to the simplex mesh by specifying the ids of the start |
| 143 |
IND |
***** and end point of the edge |
| 144 |
IND |
***** Note: This can destroy the simplex mesh structure! Better use the |
| 145 |
IND |
***** simplex mesh modification or creation filters |
| 146 |
IND |
*****/ |
| 147 |
IND |
****unsigned long AddEdge(unsigned long startPointId, unsigned long endPointId); |
| 148 |
|
|
| 149 |
|
|
| 150 |
IND |
****/** |
| 151 |
IND |
***** Add a new simplex mesh cell to the mesh by passing an AutoPointer of a |
| 152 |
IND |
***** previously created simplex mesh cell |
| 153 |
IND |
***** |
| 154 |
IND |
***** Note: This can destroy the simplex mesh structure! You should use the |
| 155 |
IND |
***** simplex mesh modification or creation filters. |
| 156 |
IND |
*****/ |
| 157 |
IND |
****unsigned long AddFace(CellAutoPointer &cellPointer); |
| 158 |
|
|
| 159 |
IND |
****/** |
| 160 |
LEN,IND |
***** Replaces the cell specified by replaceIndex with the new cell passed by its |
| 161 |
IND |
***** AutoPopinter |
| 162 |
IND |
*****/ |
| 163 |
LEN,IND |
****unsigned long ReplaceFace(unsigned long replaceIndex, CellAutoPointer &cellPointer); |
| 164 |
|
|
| 165 |
IND |
****/** |
| 166 |
IND |
***** Get the three direct neighbors of a point |
| 167 |
IND |
*****/ |
| 168 |
IND |
****IndexArray GetNeighbors(unsigned long pointId) const; |
| 169 |
|
|
| 170 |
IND |
****/** |
| 171 |
IND |
***** Get all neighbor points with a specified radius |
| 172 |
IND |
*****/ |
| 173 |
LEN,IND |
****NeighborListType* GetNeighbors(unsigned long pointId, unsigned int radius, NeighborListType* list = NULL) const; |
| 174 |
|
|
| 175 |
IND |
****/** |
| 176 |
IND |
***** Add a neighbor to a point. |
| 177 |
IND |
***** Note: This can destroy the simplex mesh topology! |
| 178 |
IND |
***** Better use te simplex mesh creation filters. |
| 179 |
IND |
*****/ |
| 180 |
IND |
****void AddNeighbor(unsigned long pointId, unsigned long neighborId); |
| 181 |
|
|
| 182 |
IND |
****/** |
| 183 |
IND |
***** Replace a neighbor of a specific point by a new one |
| 184 |
IND |
*****/ |
| 185 |
LEN,IND |
****void ReplaceNeighbor(unsigned long pointId, unsigned long oldNeighborId,unsigned long newNeighborIdx); |
| 186 |
|
|
| 187 |
IND |
****/** |
| 188 |
IND |
***** Swap the order of two neighbors |
| 189 |
IND |
*****/ |
| 190 |
LEN,IND |
****void SwapNeighbors(unsigned long pointId, unsigned long firstNeighborId,unsigned long secondNeighborId); |
| 191 |
|
|
| 192 |
IND |
****/** |
| 193 |
IND |
***** Set the geometry data for a specified point |
| 194 |
IND |
*****/ |
| 195 |
IND |
****void SetGeometryData(unsigned long pointId, SimplexMeshGeometry*); |
| 196 |
|
|
| 197 |
IND |
****/** |
| 198 |
IND |
***** Set the geometry data for a specified point |
| 199 |
IND |
*****/ |
| 200 |
IND |
****void SetBarycentricCoordinates(unsigned long idx, PointType values); |
| 201 |
|
|
| 202 |
IND |
****/** |
| 203 |
IND |
***** Set the barycentric coordinates for a specified point |
| 204 |
IND |
*****/ |
| 205 |
IND |
****PointType GetBarycentricCoordinates(unsigned long idx) const; |
| 206 |
|
|
| 207 |
IND |
****/** |
| 208 |
IND |
***** Set the reference metrics for a specified point |
| 209 |
IND |
*****/ |
| 210 |
IND |
****void SetReferenceMetrics(unsigned long idx, PointType values); |
| 211 |
|
|
| 212 |
IND |
****/** |
| 213 |
IND |
***** Return the reference metrics for the specified point |
| 214 |
IND |
*****/ |
| 215 |
IND |
****PointType GetReferenceMetrics(unsigned long idx) const; |
| 216 |
|
|
| 217 |
IND |
****/** |
| 218 |
IND |
***** Set the simplex angle for the specified point |
| 219 |
IND |
*****/ |
| 220 |
IND |
****void SetPhi(unsigned long idx, double values); |
| 221 |
|
|
| 222 |
IND |
****/** |
| 223 |
IND |
***** Get the simplex angle for the specified point |
| 224 |
IND |
*****/ |
| 225 |
IND |
****double GetPhi(unsigned long idx) const; |
| 226 |
|
|
| 227 |
IND |
****/** |
| 228 |
IND |
***** Set the mean curvature for the specified point |
| 229 |
IND |
*****/ |
| 230 |
IND |
****void SetMeanCurvature(unsigned long idx, double values); |
| 231 |
|
|
| 232 |
IND |
****/** |
| 233 |
IND |
***** Get the mean curvature for the specified point |
| 234 |
IND |
*****/ |
| 235 |
IND |
****double GetMeanCurvature(unsigned long idx) const; |
| 236 |
|
|
| 237 |
IND |
****/** |
| 238 |
IND |
***** Set the circum circles radius for the specified point |
| 239 |
IND |
*****/ |
| 240 |
IND |
****void SetRadius(unsigned long idx, double values); |
| 241 |
|
|
| 242 |
IND |
****/** |
| 243 |
IND |
***** Get the circum circles radius for the specified point |
| 244 |
IND |
*****/ |
| 245 |
IND |
****double GetRadius(unsigned long idx) const; |
| 246 |
|
|
| 247 |
IND |
****/** |
| 248 |
IND |
***** Set the distance to the foot point for the specified point |
| 249 |
IND |
*****/ |
| 250 |
IND |
****void SetDistance(unsigned long idx, double values); |
| 251 |
|
|
| 252 |
IND |
****/** |
| 253 |
IND |
***** Get the distance to the foot point for the specified point |
| 254 |
IND |
*****/ |
| 255 |
IND |
****double GetDistance(unsigned long idx) const; |
| 256 |
|
|
| 257 |
IND |
****/** compute the normal vector in the specified mesh point */ |
| 258 |
IND |
****PointType ComputeNormal(unsigned long idx ) const; |
| 259 |
|
|
| 260 |
IND |
**protected: |
| 261 |
IND |
****// /** Constructor for use by New() method. */ |
| 262 |
IND |
****SimplexMesh(); |
| 263 |
IND |
****virtual ~SimplexMesh(); |
| 264 |
IND |
****void PrintSelf(std::ostream& os, Indent indent) const; |
| 265 |
|
|
| 266 |
IND |
****/** |
| 267 |
IND |
***** The map stores a SimplexMeshGeometry object for each mesh point |
| 268 |
IND |
*****/ |
| 269 |
IND |
****GeometryMapPointer m_GeometryData; |
| 270 |
|
|
| 271 |
IND |
****/* */ |
| 272 |
IND |
****/** |
| 273 |
IND |
***** The last cell id is the index which is used for insertion of new |
| 274 |
IND |
***** cells. It increases during mesh creation. This is done because |
| 275 |
IND |
***** one cannot rely on the size of the map or the highest index when |
| 276 |
IND |
***** cells are removed. |
| 277 |
IND |
*****/ |
| 278 |
IND |
****unsigned long m_LastCellId; |
| 279 |
|
|
| 280 |
|
|
| 281 |
IND |
**private: |
| 282 |
IND |
****SimplexMesh(const Self&); //purposely not implemented |
| 283 |
IND |
****// void operator=(const Self&); //purposely not implemented |
| 284 |
|
|
| 285 |
|
|
| 286 |
EML |
|
| 287 |
IND |
**}; // End Class: SimplexMesh |
| 288 |
|
|
| 289 |
IND |
**} // end namespace itk |
| 290 |
|
|
| 291 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 292 |
|
#include "itkSimplexMesh.txx" |
| 293 |
|
#endif |
| 294 |
|
|
| 295 |
|
#endif |
| 296 |
|
|