| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkPointSet.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:43 $ |
| 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 |
|
Portions of this code are covered under the VTK copyright. |
| 13 |
|
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. |
| 14 |
|
|
| 15 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 16 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 17 |
IND |
*****PURPOSE. See the above copyright notices for more information. |
| 18 |
|
|
| 19 |
|
=========================================================================*/ |
| 20 |
|
#ifndef __itkPointSet_h |
| 21 |
|
#define __itkPointSet_h |
| 22 |
|
|
| 23 |
|
#include "itkDataObject.h" |
| 24 |
|
#include "itkPoint.h" |
| 25 |
|
#include "itkDefaultStaticMeshTraits.h" |
| 26 |
|
#include "itkPointLocator.h" |
| 27 |
|
#include "itkBoundingBox.h" |
| 28 |
|
#include <vector> |
| 29 |
|
#include <set> |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
namespace itk |
| 33 |
|
{ |
| 34 |
|
|
| 35 |
|
/** |
| 36 |
|
* Due to a bug in MSVC, an enum value cannot be accessed out of a template |
| 37 |
|
* parameter until the template class opens. In order for templated classes |
| 38 |
|
* to access the dimension of an image template parameter in defining their |
| 39 |
|
* own dimension, this class is needed as a work-around. |
| 40 |
|
*/ |
| 41 |
|
template <typename TPointSet> |
| 42 |
|
struct GetPointSetDimension |
| 43 |
|
{ |
| 44 |
IND |
itkStaticConstMacro(PointDimension, unsigned int, TPointSet::PointDimension); |
| 45 |
|
}; |
| 46 |
|
|
| 47 |
|
/** \class PointSet |
| 48 |
|
* \brief A superclass of the N-dimensional mesh structure; |
| 49 |
|
* supports point (geometric coordinate and attribute) definition. |
| 50 |
|
* |
| 51 |
|
* PointSet is a superclass of the N-dimensional mesh structure (itk::Mesh). |
| 52 |
|
* It provides the portion of the mesh definition for geometric coordinates |
| 53 |
|
* (and associated attribute or pixel information). The defined API provides |
| 54 |
|
* operations on points but does not tie down the underlying implementation |
| 55 |
|
* and storage. A "MeshTraits" structure is used to define the container |
| 56 |
|
* and identifier to access the points. See DefaultStaticMeshTraits |
| 57 |
|
* for the set of type definitions needed. All types that are defined |
| 58 |
|
* in the "MeshTraits" structure will have duplicate typedefs in the resulting |
| 59 |
|
* mesh itself. |
| 60 |
|
* |
| 61 |
|
* PointSet has two template parameters. The first is the pixel type, or the |
| 62 |
|
* type of data stored (optionally) with the points. |
| 63 |
|
* The second is the "MeshTraits" structure controlling type information |
| 64 |
|
* characterizing the point set. Most users will be happy with the |
| 65 |
|
* defaults, and will not have to worry about this second argument. |
| 66 |
|
* |
| 67 |
|
* Template parameters for PointSet: |
| 68 |
|
* |
| 69 |
|
* TPixelType = |
| 70 |
|
* The type stored as data for the point. |
| 71 |
|
* |
| 72 |
|
* TMeshTraits = |
| 73 |
|
* Type information structure for the point set. |
| 74 |
|
* |
| 75 |
|
* \example DataRepresentation/Mesh/PointSet1.cxx |
| 76 |
|
* \example DataRepresentation/Mesh/PointSet2.cxx |
| 77 |
|
* \example DataRepresentation/Mesh/PointSet3.cxx |
| 78 |
|
* \example DataRepresentation/Mesh/RGBPointSet.cxx |
| 79 |
|
* \example DataRepresentation/Mesh/PointSetWithVectors.cxx |
| 80 |
|
* \example DataRepresentation/Mesh/PointSetWithCovariantVectors.cxx |
| 81 |
|
* |
| 82 |
|
* \ingroup MeshObjects |
| 83 |
|
* \ingroup DataRepresentation |
| 84 |
|
*/ |
| 85 |
|
|
| 86 |
|
template < |
| 87 |
|
typename TPixelType, |
| 88 |
|
unsigned int VDimension = 3, |
| 89 |
LEN |
typename TMeshTraits = DefaultStaticMeshTraits< TPixelType, VDimension, VDimension > |
| 90 |
IND |
**> |
| 91 |
|
class ITK_EXPORT PointSet: public DataObject |
| 92 |
|
{ |
| 93 |
|
public: |
| 94 |
|
/** Standard class typedefs. */ |
| 95 |
|
typedef PointSet Self; |
| 96 |
TDA |
typedef DataObject Superclass; |
| 97 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 98 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 99 |
|
|
| 100 |
|
/** Method for creation through the object factory. */ |
| 101 |
|
itkNewMacro(Self); |
| 102 |
|
|
| 103 |
|
/** Standard part of every itk Object. */ |
| 104 |
|
itkTypeMacro(PointSet, Object); |
| 105 |
|
|
| 106 |
|
/** Hold on to the type information specified by the template parameters. */ |
| 107 |
|
typedef TMeshTraits MeshTraits; |
| 108 |
TDA |
typedef typename MeshTraits::PixelType PixelType; |
| 109 |
|
|
| 110 |
|
/** Convenient typedefs obtained from TMeshTraits template parameter. */ |
| 111 |
|
typedef typename MeshTraits::CoordRepType CoordRepType; |
| 112 |
|
typedef typename MeshTraits::PointIdentifier PointIdentifier; |
| 113 |
|
typedef typename MeshTraits::PointType PointType; |
| 114 |
|
typedef typename MeshTraits::PointsContainer PointsContainer; |
| 115 |
|
typedef typename MeshTraits::PointDataContainer PointDataContainer; |
| 116 |
|
|
| 117 |
|
/** Convenient typedefs obtained from TMeshTraits template parameter. */ |
| 118 |
|
itkStaticConstMacro(PointDimension, unsigned int, |
| 119 |
|
TMeshTraits::PointDimension); |
| 120 |
|
|
| 121 |
|
/** Used to support geometric operations on PointSet's such as locating |
| 122 |
|
* points quickly, and intersecting a point with a ray. */ |
| 123 |
|
typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension), |
| 124 |
|
CoordRepType,PointsContainer> PointLocatorType; |
| 125 |
|
typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension), |
| 126 |
|
CoordRepType,PointsContainer> BoundingBoxType; |
| 127 |
|
|
| 128 |
|
/** Create types that are pointers to each of the container types. */ |
| 129 |
|
typedef typename PointsContainer::Pointer PointsContainerPointer; |
| 130 |
LEN |
typedef typename PointsContainer::ConstPointer PointsContainerConstPointer; |
| 131 |
|
typedef typename PointDataContainer::Pointer PointDataContainerPointer; |
| 132 |
LEN |
typedef typename PointDataContainer::ConstPointer PointDataContainerConstPointer; |
| 133 |
|
typedef typename PointLocatorType::Pointer PointLocatorPointer; |
| 134 |
|
typedef typename BoundingBoxType::Pointer BoundingBoxPointer; |
| 135 |
|
|
| 136 |
|
/** Create types that are iterators for each of the container types. */ |
| 137 |
|
typedef typename |
| 138 |
IND |
**********PointsContainer::ConstIterator PointsContainerConstIterator; |
| 139 |
|
typedef typename |
| 140 |
IND |
**********PointsContainer::Iterator PointsContainerIterator; |
| 141 |
|
typedef typename |
| 142 |
IND |
**********PointDataContainer::ConstIterator PointDataContainerIterator; |
| 143 |
|
|
| 144 |
|
/** Type used to define Regions */ |
| 145 |
|
typedef long RegionType; |
| 146 |
|
|
| 147 |
|
/** Get the maximum number of regions that this data can be |
| 148 |
|
* separated into. */ |
| 149 |
|
itkGetConstMacro( MaximumNumberOfRegions, RegionType ); |
| 150 |
|
|
| 151 |
|
protected: |
| 152 |
|
/** An object containing points used by the mesh. Individual points are |
| 153 |
|
* accessed through point identifiers. */ |
| 154 |
|
PointsContainerPointer m_PointsContainer; |
| 155 |
|
|
| 156 |
|
/** An object containing data associated with the mesh's points. |
| 157 |
|
* Optionally, this can be NULL, indicating that no data are associated with |
| 158 |
|
* the points. The data for a point can be accessed through its point |
| 159 |
|
* identifier. */ |
| 160 |
|
PointDataContainerPointer m_PointDataContainer; |
| 161 |
|
|
| 162 |
|
/** PointLocator is used to accelerate the search for points. This |
| 163 |
|
* supports the FindClosestPoint() method. */ |
| 164 |
|
PointLocatorPointer m_PointLocator; |
| 165 |
|
|
| 166 |
|
/** The bounding box (xmin,xmax, ymin,ymax, ...) of the mesh. The |
| 167 |
|
* bounding box is used for searching, picking, display, etc. */ |
| 168 |
|
BoundingBoxPointer m_BoundingBox; |
| 169 |
|
|
| 170 |
|
public: |
| 171 |
|
/** PointSet-level operation interface. */ |
| 172 |
|
void PassStructure(Self* inputPointSet); |
| 173 |
|
virtual void Initialize(void); |
| 174 |
|
unsigned long GetNumberOfPoints(void) const; |
| 175 |
|
|
| 176 |
|
/** Define Set/Get access routines for each internal container. |
| 177 |
|
* Methods also exist to add points, cells, etc. one at a time |
| 178 |
|
* rather than through an entire container. */ |
| 179 |
|
void SetPoints(PointsContainer*); |
| 180 |
|
PointsContainer * GetPoints(void); |
| 181 |
|
const PointsContainer * GetPoints(void) const; |
| 182 |
|
void SetPointData(PointDataContainer*); |
| 183 |
|
PointDataContainer * GetPointData(void); |
| 184 |
|
const PointDataContainer * GetPointData(void) const; |
| 185 |
|
|
| 186 |
|
/** Access routines to fill the Points container, and get information |
| 187 |
|
* from it. */ |
| 188 |
|
void SetPoint(PointIdentifier, PointType); |
| 189 |
|
bool GetPoint(PointIdentifier, PointType*) const; |
| 190 |
|
|
| 191 |
|
/** Access routines to fill the PointData container, and get information |
| 192 |
|
* from it. */ |
| 193 |
|
void SetPointData(PointIdentifier, PixelType); |
| 194 |
|
bool GetPointData(PointIdentifier, PixelType*) const; |
| 195 |
|
|
| 196 |
|
/** Get the bounding box of the mesh. The methods return a pointer to |
| 197 |
|
* the user-supplied bounding box as a convenience. */ |
| 198 |
|
const BoundingBoxType * GetBoundingBox(void) const; |
| 199 |
|
|
| 200 |
|
/** Geometric operations convert between coordinate systems, perform |
| 201 |
|
* interpolation, and locate points and cells. */ |
| 202 |
|
bool FindClosestPoint(CoordRepType* /*coords[PointDimension]*/, |
| 203 |
|
PointIdentifier* pointId); |
| 204 |
|
|
| 205 |
|
/** Methods to manage streaming. */ |
| 206 |
|
virtual void UpdateOutputInformation(); |
| 207 |
|
virtual void SetRequestedRegionToLargestPossibleRegion(); |
| 208 |
|
virtual void CopyInformation(const DataObject *data); |
| 209 |
|
virtual void Graft(const DataObject *data); |
| 210 |
|
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); |
| 211 |
|
virtual bool VerifyRequestedRegion(); |
| 212 |
|
|
| 213 |
|
/** Set the requested region from this data object to match the requested |
| 214 |
|
* region of the data object passed in as a parameter. This method |
| 215 |
|
* implements the API from DataObject. The data object parameter must be |
| 216 |
|
* castable to a PointSet. */ |
| 217 |
|
virtual void SetRequestedRegion(DataObject *data); |
| 218 |
|
|
| 219 |
|
/** Set/Get the Requested region */ |
| 220 |
|
virtual void SetRequestedRegion( const RegionType & region ); |
| 221 |
|
itkGetMacro( RequestedRegion, RegionType ); |
| 222 |
|
|
| 223 |
|
/** Set/Get the Buffered region */ |
| 224 |
|
virtual void SetBufferedRegion( const RegionType & region ); |
| 225 |
|
itkGetMacro( BufferedRegion, RegionType ); |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
protected: |
| 229 |
|
/** Constructor for use by New() method. */ |
| 230 |
|
PointSet(); |
| 231 |
|
~PointSet() {} |
| 232 |
|
virtual void PrintSelf(std::ostream& os, Indent indent) const; |
| 233 |
|
|
| 234 |
|
// If the RegionType is ITK_UNSTRUCTURED_REGION, then the following |
| 235 |
|
// variables represent the maximum number of region that the data |
| 236 |
|
// object can be broken into, which region out of how many is |
| 237 |
|
// currently in the buffered region, and the number of regions and |
| 238 |
|
// the specific region requested for the update. Data objects that |
| 239 |
|
// do not support any division of the data can simply leave the |
| 240 |
|
// MaximumNumberOfRegions as 1. The RequestedNumberOfRegions and |
| 241 |
|
// RequestedRegion are used to define the currently requested |
| 242 |
|
// region. The LargestPossibleRegion is always requested region = 0 |
| 243 |
|
// and number of regions = 1; |
| 244 |
|
RegionType m_MaximumNumberOfRegions; |
| 245 |
|
RegionType m_NumberOfRegions; |
| 246 |
|
RegionType m_RequestedNumberOfRegions; |
| 247 |
|
RegionType m_BufferedRegion; |
| 248 |
|
RegionType m_RequestedRegion; |
| 249 |
|
|
| 250 |
|
private: |
| 251 |
|
PointSet(const Self&); //purposely not implemented |
| 252 |
|
void operator=(const Self&); //purposely not implemented |
| 253 |
|
|
| 254 |
|
}; // End Class: PointSet |
| 255 |
|
|
| 256 |
|
} // end namespace itk |
| 257 |
|
|
| 258 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 259 |
|
#include "itkPointSet.txx" |
| 260 |
|
#endif |
| 261 |
|
|
| 262 |
|
#endif |
| 263 |
|
|