Orfeo Toolbox  3.16
itkSpatialObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSpatialObject.h,v $
5  Language: C++
6  Date: $Date: 2009-04-07 14:34:16 $
7  Version: $Revision: 1.68 $
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 
18 #ifndef __itkSpatialObject_h
19 #define __itkSpatialObject_h
20 
21 // Disable warning for long symbol names in this file only
22 #ifdef _MSC_VER
23 #pragma warning ( disable : 4786 )
24 #endif
25 
26 #include "itkAffineGeometryFrame.h"
27 #include "itkDataObject.h"
28 #include "itkBoundingBox.h"
29 #include "itkPoint.h"
31 #include "itkSmartPointer.h"
32 #include "itkVector.h"
33 #include "itkCovariantVector.h"
34 #include "itkExceptionObject.h"
35 #include <list>
37 #include "itkProcessObject.h"
38 #include "itkIndex.h"
39 #include "itkSize.h"
40 #include "itkImageRegion.h"
41 #include "itkObjectFactory.h"
43 
44 namespace itk
45 {
46 
66 template <unsigned int TDimension> class SpatialObjectTreeNode;
67 
68 template< unsigned int TDimension = 3>
70  :public DataObject
71 {
72 
73 public:
74 
75  typedef double ScalarType;
76 
77  itkStaticConstMacro(MaximumDepth, unsigned int, 9999999);
78 
81  unsigned int GetMaximumDepth() { return MaximumDepth; }
82 
85 
88 
90  // Spatial Function Iterator needs the following typedef
92  typedef PointType * PointPointer;
93 
97 
98  typedef double * SpacingType;
99 
102 
106 
108 
109  typedef BoundingBox< unsigned long int, TDimension, ScalarType,
112 
115 
117  typedef std::list< Pointer > ChildrenListType;
119 
120 
124 
133 
135 
138  virtual bool HasParent( void ) const;
139 
141  virtual const char* GetTypeName(void) const {return m_TypeName.c_str();}
142 
146  itkStaticConstMacro(ObjectDimension, unsigned int, TDimension);
147 
149  unsigned int GetObjectDimension(void) const {return TDimension;}
150 
152  itkNewMacro( Self );
153 
155  itkTypeMacro( SpatialObject, DataObject );
156 
158  itkGetConstObjectMacro(AffineGeometryFrame,AffineGeometryFrameType);
159  itkSetObjectMacro(AffineGeometryFrame,AffineGeometryFrameType);
160 
163  void SetObjectToWorldTransform( TransformType * transform );
164  itkGetObjectMacro(ObjectToWorldTransform,TransformType);
165  itkGetConstObjectMacro(ObjectToWorldTransform,TransformType);
166  itkGetObjectMacro(IndexToWorldTransform,TransformType);
167  itkGetConstObjectMacro(IndexToWorldTransform,TransformType);
168 
173 
176 
178  unsigned long GetTransformMTime( void );
179 
181  unsigned long GetWorldTransformMTime( void );
182 
184  virtual bool ValueAt( const PointType & point, double & value,
185  unsigned int depth=0,
186  char * name = NULL) const;
187 
194  virtual bool IsEvaluableAt( const PointType & point,
195  unsigned int depth=0,
196  char * name = NULL) const;
197 
199  virtual bool IsInside( const PointType & point,
200  unsigned int depth=0,
201  char * name = NULL) const;
202 
207  bool Evaluate( const PointType & point ) const
208  {
209  return this->IsInside( point );
210  };
211 
213  virtual void DerivativeAt( const PointType & point,
214  short unsigned int order,
215  OutputVectorType & value,
216  unsigned int depth=0,
217  char * name = NULL);
218 
219 
222  unsigned long GetMTime( void ) const;
223 
226  unsigned long GetObjectMTime( void ) const
227  {
228  return Superclass::GetMTime();
229  }
230 
237  virtual void SetLargestPossibleRegion(const RegionType &region);
238 
245  virtual const RegionType& GetLargestPossibleRegion() const
246  { return m_LargestPossibleRegion;};
247 
251  virtual void SetBufferedRegion(const RegionType &region);
252 
256  virtual const RegionType& GetBufferedRegion() const
257  { return m_BufferedRegion;};
258 
263  virtual void SetRequestedRegion(const RegionType &region);
264 
269  virtual void SetRequestedRegion(DataObject *data);
270 
275  virtual const RegionType& GetRequestedRegion() const
276  { return m_RequestedRegion;};
277 
287  const OffsetValueType *GetOffsetTable() const { return m_OffsetTable; };
288 
292  {
293  // need to add bounds checking for the region/buffer?
294  OffsetValueType offset=0;
295  const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
296 
297  // data is arranged as [][][][slice][row][col]
298  // with Index[0] = col, Index[1] = row, Index[2] = slice
299  for (int i=TDimension-1; i > 0; i--)
300  {
301  offset += (ind[i] - bufferedRegionIndex[i])*m_OffsetTable[i];
302  }
303  offset += (ind[0] - bufferedRegionIndex[0]);
304 
305  return offset;
306  }
307 
311  {
312  IndexType index;
313  const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
314 
315  for (int i=TDimension-1; i > 0; i--)
316  {
317  index[i] = static_cast<IndexValueType>(offset / m_OffsetTable[i]);
318  offset -= (index[i] * m_OffsetTable[i]);
319  index[i] += bufferedRegionIndex[i];
320  }
321  index[0] = bufferedRegionIndex[0] + static_cast<IndexValueType>(offset);
322 
323  return index;
324  }
325 
335  virtual void CopyInformation(const DataObject *data);
336 
344  virtual void UpdateOutputInformation();
345 
350 
361 
370  virtual bool VerifyRequestedRegion();
371 
372 
374  PropertyType * GetProperty( void );
375  const PropertyType * GetProperty( void ) const {return m_Property;}
376 
378  void SetProperty( PropertyType * property );
379 
381  itkGetConstReferenceMacro(Id,int);
382  itkSetMacro(Id,int);
383 
385  itkSetMacro(ParentId, int);
386  itkGetConstReferenceMacro(ParentId, int);
387 
389  virtual void Update(void);
390 
392  itkSetObjectMacro(TreeNode, TreeNodeType)
393 
394 
395  itkGetObjectMacro(TreeNode, TreeNodeType);
396  itkGetConstObjectMacro(TreeNode, TreeNodeType);
397 
400  void SetSpacing( const double
401  spacing[itkGetStaticConstMacro(ObjectDimension)] )
402  { this->GetIndexToObjectTransform()->SetScale(spacing);}
404  virtual const double * GetSpacing() const
405  {return this->GetIndexToObjectTransform()->GetScale();}
406 
407 
414  const TransformType * GetIndexToObjectTransform( void ) const;
415 
419  void SetObjectToParentTransform( TransformType * transform );
421  const TransformType * GetObjectToParentTransform( void ) const;
422 
427  const TransformType * GetObjectToNodeTransform( void ) const;
428 
433  void AddSpatialObject( Self * pointer );
434 
439  void RemoveSpatialObject( Self * object );
440 
442  virtual const Self * GetParent( void ) const;
443 
445  virtual Self * GetParent( void );
446 
452  virtual ChildrenListType * GetChildren( unsigned int depth=0,
453  char * name=NULL ) const;
454 
456  unsigned int GetNumberOfChildren( unsigned int depth=0,
457  char * name=NULL ) const;
458 
460  void SetChildren( ChildrenListType & children );
461 
464  virtual void Clear( void );
465 
488  virtual bool ComputeBoundingBox() const;
489  virtual bool ComputeLocalBoundingBox() const
490  {
491  std::cerr << "SpatialObject::ComputeLocalBoundingBox Not Implemented!"
492  << std::endl;
493  return false;
494  }
495 
498  virtual BoundingBoxType * GetBoundingBox() const;
499 
500 
502  itkSetMacro(BoundingBoxChildrenDepth, unsigned int);
503  itkGetConstReferenceMacro(BoundingBoxChildrenDepth, unsigned int);
504 
507  itkSetMacro(BoundingBoxChildrenName, std::string);
508  itkGetConstReferenceMacro(BoundingBoxChildrenName, std::string);
509 
512  void SetParent(Self * parent);
513 
514 
516  void SetNodeToParentNodeTransform( TransformType * transform );
518  const TransformType * GetNodeToParentNodeTransform( void ) const;
519 
522  itkSetMacro(DefaultInsideValue,double);
523  itkGetConstMacro(DefaultInsideValue,double);
524 
527  itkSetMacro(DefaultOutsideValue,double);
528  itkGetConstMacro(DefaultOutsideValue,double);
529 
532  virtual std::string GetSpatialObjectTypeAsString() const;
533 
534 protected:
535 
537  SpatialObject();
538 
540  virtual ~SpatialObject();
541 
542  virtual void PrintSelf( std::ostream& os, Indent indent ) const;
543 
548  void ComputeOffsetTable();
549 
550  itkSetMacro(Dimension,unsigned int);
551  itkGetConstReferenceMacro(Dimension,unsigned int)
552  itkSetMacro(TypeName,std::string);
553  itkGetConstObjectMacro(Bounds,BoundingBoxType);
554  itkGetConstObjectMacro(InternalInverseTransform,TransformType);
555 
563 
564 private:
565 
566  SpatialObject(const Self&); //purposely not implemented
567  void operator=(const Self&); //purposely not implemented
568 
570  mutable unsigned long m_BoundsMTime;
571 
575 
577  std::string m_TypeName;
578 
579  unsigned int m_Dimension;
580 
582 
586 
590 
592  int m_Id;
594 
597 
600 
604 
608 
611 
614 };
615 
616 } // end of namespace itk
617 
618 #if !defined(CABLE_CONFIGURATION)
619 #ifndef ITK_MANUAL_INSTANTIATION
620 #include "itkSpatialObject.txx"
621 #endif
622 #endif
623 
624 #endif // __itkSpatialObject_h

Generated at Sun May 19 2013 00:08:41 for Orfeo Toolbox with doxygen 1.8.3.1