| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkPointSet.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:44 $ |
| 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 |
DEF |
#ifndef _itkPointSet_txx |
| 21 |
DEF |
#define _itkPointSet_txx |
| 22 |
|
|
| 23 |
|
#include "itkPointSet.h" |
| 24 |
|
#include "itkProcessObject.h" |
| 25 |
|
#include <algorithm> |
| 26 |
|
|
| 27 |
|
namespace itk |
| 28 |
|
{ |
| 29 |
|
|
| 30 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 31 |
|
void |
| 32 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 33 |
|
::PrintSelf(std::ostream& os, Indent indent) const |
| 34 |
|
{ |
| 35 |
|
Superclass::PrintSelf(os, indent); |
| 36 |
|
os << indent << "Number Of Points: " |
| 37 |
|
<< this->GetNumberOfPoints() << std::endl; |
| 38 |
|
|
| 39 |
|
os << indent << "Requested Number Of Regions: " |
| 40 |
|
<< m_RequestedNumberOfRegions << std::endl; |
| 41 |
|
os << indent << "Requested Region: " << m_RequestedRegion << std::endl; |
| 42 |
|
os << indent << "Buffered Region: " << m_BufferedRegion << std::endl; |
| 43 |
|
os << indent << "Maximum Number Of Regions: " |
| 44 |
|
<< m_MaximumNumberOfRegions << std::endl; |
| 45 |
|
|
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
/** |
| 50 |
|
* Access routine to set the points container. |
| 51 |
|
*/ |
| 52 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 53 |
|
void |
| 54 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 55 |
|
::SetPoints(PointsContainer* points) |
| 56 |
|
{ |
| 57 |
|
itkDebugMacro("setting Points container to " << points); |
| 58 |
|
if(m_PointsContainer != points) |
| 59 |
|
{ |
| 60 |
|
m_PointsContainer = points; |
| 61 |
|
this->Modified(); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
EML |
|
| 67 |
|
/** |
| 68 |
|
* Access routine to get the points container. |
| 69 |
|
*/ |
| 70 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 71 |
|
typename PointSet<TPixelType, VDimension, TMeshTraits>::PointsContainer * |
| 72 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 73 |
|
::GetPoints(void) |
| 74 |
|
{ |
| 75 |
|
itkDebugMacro("Starting GetPoints()"); |
| 76 |
|
if( !m_PointsContainer ) |
| 77 |
|
{ |
| 78 |
|
this->SetPoints(PointsContainer::New()); |
| 79 |
|
} |
| 80 |
|
itkDebugMacro("returning Points container of " << m_PointsContainer ); |
| 81 |
|
return m_PointsContainer; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
/** |
| 86 |
|
* Access routine to get the points container. |
| 87 |
|
*/ |
| 88 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 89 |
|
const typename PointSet<TPixelType, VDimension, TMeshTraits>::PointsContainer * |
| 90 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 91 |
|
::GetPoints(void) const |
| 92 |
|
{ |
| 93 |
|
itkDebugMacro("returning Points container of " << m_PointsContainer ); |
| 94 |
|
return m_PointsContainer.GetPointer(); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
/** |
| 99 |
|
* Access routine to set the point data container. |
| 100 |
|
*/ |
| 101 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 102 |
|
void |
| 103 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 104 |
|
::SetPointData(PointDataContainer* pointData) |
| 105 |
|
{ |
| 106 |
|
itkDebugMacro("setting PointData container to " << pointData); |
| 107 |
|
if(m_PointDataContainer != pointData) |
| 108 |
|
{ |
| 109 |
|
m_PointDataContainer = pointData; |
| 110 |
|
this->Modified(); |
| 111 |
|
} |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
/** |
| 116 |
|
* Access routine to get the point data container. |
| 117 |
|
*/ |
| 118 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 119 |
|
typename PointSet<TPixelType, VDimension, TMeshTraits>::PointDataContainer * |
| 120 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 121 |
|
::GetPointData(void) |
| 122 |
|
{ |
| 123 |
|
itkDebugMacro("returning PointData container of " |
| 124 |
|
<< m_PointDataContainer ); |
| 125 |
|
return m_PointDataContainer; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
EML |
|
| 130 |
|
/** |
| 131 |
|
* Access routine to get the point data container. |
| 132 |
|
*/ |
| 133 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 134 |
LEN |
const typename PointSet<TPixelType, VDimension, TMeshTraits>::PointDataContainer * |
| 135 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 136 |
|
::GetPointData(void) const |
| 137 |
|
{ |
| 138 |
|
itkDebugMacro("returning PointData container of " |
| 139 |
|
<< m_PointDataContainer ); |
| 140 |
|
return m_PointDataContainer.GetPointer(); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
/** |
| 145 |
|
* Assign a point to a point identifier. If a spot for the point identifier |
| 146 |
|
* does not exist, it will be created automatically. |
| 147 |
|
*/ |
| 148 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 149 |
|
void |
| 150 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 151 |
|
::SetPoint(PointIdentifier ptId, PointType point) |
| 152 |
|
{ |
| 153 |
|
/** |
| 154 |
|
* Make sure a points container exists. |
| 155 |
|
*/ |
| 156 |
|
if( !m_PointsContainer ) |
| 157 |
|
{ |
| 158 |
|
this->SetPoints(PointsContainer::New()); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
/** |
| 162 |
|
* Insert the point into the container with the given identifier. |
| 163 |
|
*/ |
| 164 |
|
m_PointsContainer->InsertElement(ptId, point); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
|
| 168 |
|
/** |
| 169 |
|
* Check if a point exists for a given point identifier. If a spot for |
| 170 |
|
* the point identifier exists, "point" is set, and true is returned. |
| 171 |
|
* Otherwise, false is returned, and "point" is not modified. |
| 172 |
|
* If "point" is NULL, then it is never set, but the existence of the point |
| 173 |
|
* is still returned. |
| 174 |
|
*/ |
| 175 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 176 |
|
bool |
| 177 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 178 |
|
::GetPoint(PointIdentifier ptId, PointType* point) const |
| 179 |
|
{ |
| 180 |
|
/** |
| 181 |
|
* If the points container doesn't exist, then the point doesn't either. |
| 182 |
|
*/ |
| 183 |
|
if( !m_PointsContainer ) |
| 184 |
|
{ |
| 185 |
|
return false; |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
/** |
| 189 |
|
* Ask the container if the point identifier exists. |
| 190 |
|
*/ |
| 191 |
|
return m_PointsContainer->GetElementIfIndexExists(ptId, point); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 195 |
|
/** |
| 196 |
|
* Assign data to a point identifier. If a spot for the point identifier |
| 197 |
|
* does not exist, it will be created automatically. There is no check if |
| 198 |
|
* a point with the same identifier exists. |
| 199 |
|
*/ |
| 200 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 201 |
|
void |
| 202 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 203 |
|
::SetPointData(PointIdentifier ptId, PixelType data) |
| 204 |
|
{ |
| 205 |
|
/** |
| 206 |
|
* Make sure a point data container exists. |
| 207 |
|
*/ |
| 208 |
|
if( !m_PointDataContainer ) |
| 209 |
|
{ |
| 210 |
|
this->SetPointData(PointDataContainer::New()); |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
/** |
| 214 |
|
* Insert the point data into the container with the given identifier. |
| 215 |
|
*/ |
| 216 |
|
m_PointDataContainer->InsertElement(ptId, data); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
/** |
| 221 |
|
* Check if point data exists for a given point identifier. If a spot for |
| 222 |
|
* the point identifier exists, "data" is set, and true is returned. |
| 223 |
|
* Otherwise, false is returned, and "data" is not modified. |
| 224 |
|
* If "data" is NULL, then it is never set, but the existence of the point |
| 225 |
|
* data is still returned. |
| 226 |
|
*/ |
| 227 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 228 |
|
bool |
| 229 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 230 |
|
::GetPointData(PointIdentifier ptId, PixelType* data) const |
| 231 |
|
{ |
| 232 |
|
/** |
| 233 |
|
* If the point data container doesn't exist, then the point data doesn't |
| 234 |
|
* either. |
| 235 |
|
*/ |
| 236 |
|
if( !m_PointDataContainer ) |
| 237 |
IND |
****return false; |
| 238 |
|
|
| 239 |
|
/** |
| 240 |
|
* Ask the container if the point identifier exists. |
| 241 |
|
*/ |
| 242 |
|
return m_PointDataContainer->GetElementIfIndexExists(ptId, data); |
| 243 |
|
} |
| 244 |
|
|
| 245 |
|
/** |
| 246 |
|
* Copy the geometric and topological structure of the given input pointSet. |
| 247 |
|
* The copying is done via reference counting. |
| 248 |
|
*/ |
| 249 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 250 |
|
void |
| 251 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 252 |
|
::PassStructure(Self*) |
| 253 |
|
{ |
| 254 |
|
// IMPLEMENT ME |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
|
/** |
| 259 |
|
* Get the number of points in the PointsContainer. |
| 260 |
|
*/ |
| 261 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 262 |
|
unsigned long |
| 263 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 264 |
|
::GetNumberOfPoints(void) const |
| 265 |
|
{ |
| 266 |
|
if( m_PointsContainer ) |
| 267 |
|
{ |
| 268 |
|
return m_PointsContainer->Size(); |
| 269 |
|
} |
| 270 |
|
return 0; |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
/** |
| 274 |
|
* Get the bounding box of the entire pointSet. |
| 275 |
|
*/ |
| 276 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 277 |
|
const typename PointSet<TPixelType, VDimension, TMeshTraits>::BoundingBoxType * |
| 278 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 279 |
|
::GetBoundingBox(void) const |
| 280 |
|
{ |
| 281 |
|
m_BoundingBox->SetPoints( this->GetPoints() ); |
| 282 |
|
if( m_BoundingBox->GetMTime() > this->GetMTime() ) |
| 283 |
|
{ |
| 284 |
|
m_BoundingBox->ComputeBoundingBox(); |
| 285 |
|
} |
| 286 |
|
return m_BoundingBox; |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
|
| 290 |
|
/** |
| 291 |
|
* Find the closest point in the pointSet to the given point |
| 292 |
|
* (coords[PointDimension]). Returns whether a closest point was found. If |
| 293 |
|
* a point is found, its PointIdentifier is set through the "pointId" pointer |
| 294 |
|
* (if it isn't NULL). |
| 295 |
|
*/ |
| 296 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 297 |
|
bool |
| 298 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 299 |
|
::FindClosestPoint(CoordRepType*, |
| 300 |
|
PointIdentifier*) |
| 301 |
|
{ |
| 302 |
|
m_BoundingBox->SetPoints(this->GetPoints()); |
| 303 |
|
m_PointLocator->InitPointInsertion(m_PointsContainer, m_BoundingBox); |
| 304 |
|
|
| 305 |
|
return bool(); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
/** |
| 309 |
|
* Restore the PointSet to its initial state. Useful for data pipeline updates |
| 310 |
|
* without memory re-allocation. |
| 311 |
|
*/ |
| 312 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 313 |
|
void |
| 314 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 315 |
|
::Initialize(void) |
| 316 |
|
{ |
| 317 |
|
Superclass::Initialize(); |
| 318 |
|
|
| 319 |
|
m_PointsContainer = 0; |
| 320 |
|
m_PointDataContainer = 0; |
| 321 |
|
m_PointLocator = 0; |
| 322 |
|
|
| 323 |
|
} |
| 324 |
|
|
| 325 |
|
/****************************************************************************** |
| 326 |
|
* PROTECTED METHOD DEFINITIONS |
| 327 |
|
*****************************************************************************/ |
| 328 |
|
|
| 329 |
|
/** |
| 330 |
|
* A protected default constructor allows the New() routine to create an |
| 331 |
|
* instance of PointSet. All the containers are initialized to non-existent. |
| 332 |
|
*/ |
| 333 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 334 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 335 |
|
::PointSet(): |
| 336 |
IND |
**m_PointsContainer(0), |
| 337 |
IND |
**m_PointDataContainer(0) |
| 338 |
|
{ |
| 339 |
|
m_PointLocator = PointLocatorType::New(); |
| 340 |
|
m_BoundingBox = BoundingBoxType::New(); |
| 341 |
|
|
| 342 |
|
// If we used unstructured regions instead of structured regions, then |
| 343 |
|
// assume this object was created by the user and this is region 0 of |
| 344 |
|
// 1 region. |
| 345 |
|
m_MaximumNumberOfRegions = 1; |
| 346 |
|
m_NumberOfRegions = 1; |
| 347 |
|
m_BufferedRegion = -1; |
| 348 |
|
m_RequestedNumberOfRegions = 0; |
| 349 |
|
m_RequestedRegion = -1; |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
|
| 353 |
|
//---------------------------------------------------------------------------- |
| 354 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 355 |
|
void |
| 356 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 357 |
|
::UpdateOutputInformation() |
| 358 |
|
{ |
| 359 |
|
if (this->GetSource()) |
| 360 |
|
{ |
| 361 |
|
this->GetSource()->UpdateOutputInformation(); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
// Now we should know what our largest possible region is. If our |
| 365 |
|
// requested region was not set yet, (or has been set to something |
| 366 |
|
// invalid - with no data in it ) then set it to the largest |
| 367 |
|
// possible region. |
| 368 |
|
if ( m_RequestedRegion == -1 && m_RequestedNumberOfRegions == 0 ) |
| 369 |
|
{ |
| 370 |
|
this->SetRequestedRegionToLargestPossibleRegion(); |
| 371 |
|
} |
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
//---------------------------------------------------------------------------- |
| 375 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 376 |
|
void |
| 377 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 378 |
|
::SetRequestedRegionToLargestPossibleRegion() |
| 379 |
|
{ |
| 380 |
|
m_RequestedNumberOfRegions = 1; |
| 381 |
|
m_RequestedRegion = 0; |
| 382 |
|
} |
| 383 |
|
|
| 384 |
|
//---------------------------------------------------------------------------- |
| 385 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 386 |
|
void |
| 387 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 388 |
|
::CopyInformation(const DataObject *data) |
| 389 |
|
{ |
| 390 |
|
const PointSet * pointSet = NULL; |
| 391 |
|
|
| 392 |
|
try |
| 393 |
|
{ |
| 394 |
|
pointSet = dynamic_cast<const PointSet*>(data); |
| 395 |
|
} |
| 396 |
|
catch( ... ) |
| 397 |
|
{ |
| 398 |
|
// pointer could not be cast back down |
| 399 |
|
itkExceptionMacro(<< "itk::PointSet::CopyInformation() cannot cast " |
| 400 |
|
<< typeid(data).name() << " to " |
| 401 |
|
<< typeid(PointSet*).name() ); |
| 402 |
|
} |
| 403 |
|
|
| 404 |
|
if ( !pointSet ) |
| 405 |
|
{ |
| 406 |
|
// pointer could not be cast back down |
| 407 |
|
itkExceptionMacro(<< "itk::PointSet::CopyInformation() cannot cast " |
| 408 |
|
<< typeid(data).name() << " to " |
| 409 |
|
<< typeid(PointSet*).name() ); |
| 410 |
|
} |
| 411 |
|
|
| 412 |
|
m_MaximumNumberOfRegions = pointSet->GetMaximumNumberOfRegions(); |
| 413 |
|
|
| 414 |
|
// Copy the bounding box by value in order to avoid dependencies between the |
| 415 |
|
// source and destination. |
| 416 |
|
m_BoundingBox = pointSet->GetBoundingBox()->DeepCopy(); |
| 417 |
|
|
| 418 |
|
m_NumberOfRegions = pointSet->m_NumberOfRegions; |
| 419 |
|
m_RequestedNumberOfRegions = pointSet->m_RequestedNumberOfRegions; |
| 420 |
|
m_BufferedRegion = pointSet->m_BufferedRegion; |
| 421 |
|
m_RequestedRegion = pointSet->m_RequestedRegion; |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
//---------------------------------------------------------------------------- |
| 425 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 426 |
|
void |
| 427 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 428 |
|
::Graft(const DataObject *data) |
| 429 |
|
{ |
| 430 |
|
// Copy Meta Data |
| 431 |
|
this->CopyInformation( data ); |
| 432 |
|
|
| 433 |
|
const Self * pointSet = NULL; |
| 434 |
|
|
| 435 |
|
try |
| 436 |
|
{ |
| 437 |
|
pointSet = dynamic_cast<const Self*>(data); |
| 438 |
|
} |
| 439 |
|
catch( ... ) |
| 440 |
|
{ |
| 441 |
|
// pointer could not be cast back down |
| 442 |
|
itkExceptionMacro(<< "itk::PointSet::CopyInformation() cannot cast " |
| 443 |
|
<< typeid(data).name() << " to " |
| 444 |
|
<< typeid(Self*).name() ); |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
if ( !pointSet ) |
| 448 |
|
{ |
| 449 |
|
// pointer could not be cast back down |
| 450 |
|
itkExceptionMacro(<< "itk::PointSet::CopyInformation() cannot cast " |
| 451 |
|
<< typeid(data).name() << " to " |
| 452 |
|
<< typeid(Self*).name() ); |
| 453 |
|
} |
| 454 |
|
|
| 455 |
|
|
| 456 |
|
this->SetPoints( pointSet->m_PointsContainer ); |
| 457 |
|
this->SetPointData( pointSet->m_PointDataContainer ); |
| 458 |
|
} |
| 459 |
|
|
| 460 |
|
//---------------------------------------------------------------------------- |
| 461 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 462 |
|
void |
| 463 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 464 |
|
::SetRequestedRegion(DataObject *data) |
| 465 |
|
{ |
| 466 |
|
Self *pointSet; |
| 467 |
|
|
| 468 |
|
pointSet = dynamic_cast<Self*>(data); |
| 469 |
|
|
| 470 |
|
if ( pointSet ) |
| 471 |
|
{ |
| 472 |
|
// only copy the RequestedRegion if the parameter is another PointSet |
| 473 |
|
m_RequestedRegion = pointSet->m_RequestedRegion; |
| 474 |
|
m_RequestedNumberOfRegions = pointSet->m_RequestedNumberOfRegions; |
| 475 |
|
} |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
|
| 479 |
|
//---------------------------------------------------------------------------- |
| 480 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 481 |
|
void |
| 482 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 483 |
|
::SetRequestedRegion(const RegionType ®ion) |
| 484 |
|
{ |
| 485 |
|
if (m_RequestedRegion != region) |
| 486 |
|
{ |
| 487 |
|
m_RequestedRegion = region; |
| 488 |
|
} |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
|
| 492 |
|
//---------------------------------------------------------------------------- |
| 493 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 494 |
|
void |
| 495 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 496 |
|
::SetBufferedRegion(const RegionType ®ion) |
| 497 |
|
{ |
| 498 |
|
if (m_BufferedRegion != region) |
| 499 |
|
{ |
| 500 |
|
m_BufferedRegion = region; |
| 501 |
|
this->Modified(); |
| 502 |
|
} |
| 503 |
|
} |
| 504 |
|
|
| 505 |
|
|
| 506 |
|
//---------------------------------------------------------------------------- |
| 507 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 508 |
|
bool |
| 509 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 510 |
|
::RequestedRegionIsOutsideOfTheBufferedRegion() |
| 511 |
|
{ |
| 512 |
|
if ( m_RequestedRegion != m_BufferedRegion || |
| 513 |
|
m_RequestedNumberOfRegions != m_NumberOfRegions ) |
| 514 |
|
{ |
| 515 |
|
return true; |
| 516 |
|
} |
| 517 |
|
|
| 518 |
|
return false; |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> |
| 522 |
|
bool |
| 523 |
|
PointSet<TPixelType, VDimension, TMeshTraits> |
| 524 |
|
::VerifyRequestedRegion() |
| 525 |
|
{ |
| 526 |
|
bool retval = true; |
| 527 |
|
|
| 528 |
|
// Are we asking for more regions than we can get? |
| 529 |
|
if ( m_RequestedNumberOfRegions > m_MaximumNumberOfRegions ) |
| 530 |
|
{ |
| 531 |
|
itkExceptionMacro( << "Cannot break object into " << |
| 532 |
|
m_RequestedNumberOfRegions << ". The limit is " << |
| 533 |
|
m_MaximumNumberOfRegions ); |
| 534 |
|
retval = false; |
| 535 |
|
} |
| 536 |
|
|
| 537 |
|
if ( m_RequestedRegion >= m_RequestedNumberOfRegions || |
| 538 |
|
m_RequestedRegion < 0 ) |
| 539 |
|
{ |
| 540 |
|
itkExceptionMacro( << "Invalid update region " << m_RequestedRegion |
| 541 |
|
<< ". Must be between 0 and " |
| 542 |
|
<< m_RequestedNumberOfRegions - 1); |
| 543 |
|
retval = false; |
| 544 |
|
} |
| 545 |
|
|
| 546 |
|
return retval; |
| 547 |
|
} |
| 548 |
|
|
| 549 |
|
} // end namespace itk |
| 550 |
|
|
| 551 |
|
#endif |
| 552 |
|
|