Orfeo Toolbox  4.0
itkSpatialObject.h
Go to the documentation of this file.
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 __itkSpatialObject_h
19 #define __itkSpatialObject_h
20 
21 // Disable warning for lengthy symbol names in this file only
22 
23 #include "itkAffineGeometryFrame.h"
24 #include "itkCovariantVector.h"
25 #include "itkExceptionObject.h"
26 #include <list>
28 #include "itkProcessObject.h"
29 #include "itkIndex.h"
30 #include "itkImageRegion.h"
32 
33 namespace itk
34 {
55 template< unsigned int VDimension >
57 
58 template< unsigned int VDimension = 3 >
60  public DataObject
61 {
62 public:
63 
64  typedef double ScalarType;
65 
66  itkStaticConstMacro(MaximumDepth, unsigned int, 9999999);
67 
70  unsigned int GetMaximumDepth() const { return MaximumDepth; }
71 
74 
77 
79  // Spatial Function Iterator needs the following typedef
82 
86 
87  typedef double *SpacingType;
88 
91 
95 
97 
100 
103 
105  typedef std::list< Pointer > ChildrenListType;
107 
110 
118 
120 
123  virtual bool HasParent(void) const;
124 
126  virtual const char * GetTypeName(void) const { return m_TypeName.c_str(); }
127 
131  itkStaticConstMacro(ObjectDimension, unsigned int, VDimension);
132 
134  unsigned int GetObjectDimension(void) const { return VDimension; }
135 
137  itkNewMacro(Self);
138 
140  itkTypeMacro(SpatialObject, DataObject);
141 
143  itkSetObjectMacro(AffineGeometryFrame, AffineGeometryFrameType);
145 
148  void SetObjectToWorldTransform(TransformType *transform);
149  itkGetModifiableObjectMacro(ObjectToWorldTransform, TransformType);
150 
151  itkGetModifiableObjectMacro(IndexToWorldTransform, TransformType);
152 
157 
160 
162  unsigned long GetTransformMTime(void);
163 
165  unsigned long GetWorldTransformMTime(void);
166 
168  virtual bool ValueAt(const PointType & point, double & value,
169  unsigned int depth = 0,
170  char *name = NULL) const;
171 
178  virtual bool IsEvaluableAt(const PointType & point,
179  unsigned int depth = 0,
180  char *name = NULL) const;
181 
183  virtual bool IsInside(const PointType & point,
184  unsigned int depth = 0,
185  char *name = NULL) const;
186 
191  bool Evaluate(const PointType & point) const
192  {
193  return this->IsInside(point);
194  }
195 
197  virtual void DerivativeAt(const PointType & point,
198  short unsigned int order,
199  OutputVectorType & value,
200  unsigned int depth = 0,
201  char *name = NULL);
202 
205  ModifiedTimeType GetMTime(void) const;
206 
209  unsigned long GetObjectMTime(void) const
210  {
211  return Superclass::GetMTime();
212  }
213 
220  virtual void SetLargestPossibleRegion(const RegionType & region);
221 
228  virtual const RegionType & GetLargestPossibleRegion() const
229  { return m_LargestPossibleRegion; }
230 
234  virtual void SetBufferedRegion(const RegionType & region);
235 
239  virtual const RegionType & GetBufferedRegion() const
240  { return m_BufferedRegion; }
241 
246  virtual void SetRequestedRegion(const RegionType & region);
247 
252  virtual void SetRequestedRegion(const DataObject *data);
253 
258  virtual const RegionType & GetRequestedRegion() const
259  { return m_RequestedRegion; }
260 
270  const OffsetValueType * GetOffsetTable() const { return m_OffsetTable; }
271 
275  {
276  // need to add bounds checking for the region/buffer?
277  OffsetValueType offset = 0;
278  const IndexType & bufferedRegionIndex = m_BufferedRegion.GetIndex();
279 
280  // data is arranged as [][][][slice][row][col]
281  // with Index[0] = col, Index[1] = row, Index[2] = slice
282  for ( int i = VDimension - 1; i > 0; i-- )
283  {
284  offset += ( ind[i] - bufferedRegionIndex[i] ) * m_OffsetTable[i];
285  }
286  offset += ( ind[0] - bufferedRegionIndex[0] );
287 
288  return offset;
289  }
290 
294  {
295  IndexType index;
296  const IndexType & bufferedRegionIndex = m_BufferedRegion.GetIndex();
297 
298  for ( int i = VDimension - 1; i > 0; i-- )
299  {
300  index[i] = static_cast< IndexValueType >( offset / m_OffsetTable[i] );
301  offset -= ( index[i] * m_OffsetTable[i] );
302  index[i] += bufferedRegionIndex[i];
303  }
304  index[0] = bufferedRegionIndex[0] + static_cast< IndexValueType >( offset );
305 
306  return index;
307  }
308 
318  virtual void CopyInformation(const DataObject *data);
319 
327  virtual void UpdateOutputInformation();
328 
333 
344 
353  virtual bool VerifyRequestedRegion();
354 
356  PropertyType * GetProperty(void);
357 
358  const PropertyType * GetProperty(void) const { return m_Property; }
359 
361  void SetProperty(PropertyType *property);
362 
364  itkGetConstReferenceMacro(Id, int);
365  itkSetMacro(Id, int);
366 
368  itkSetMacro(ParentId, int);
369  itkGetConstReferenceMacro(ParentId, int);
370 
372  virtual void Update(void);
373 
375  itkSetObjectMacro(TreeNode, TreeNodeType)
376 
377 
379 
382  void SetSpacing(const double spacing[itkGetStaticConstMacro(ObjectDimension)])
383  {
384  m_AffineGeometryFrame->GetModifiableIndexToObjectTransform()->SetScale(spacing);
385  this->Modified();
386  }
388  virtual const double * GetSpacing() const
389  {
390  return this->GetIndexToObjectTransform()->GetScale();
391  }
392 
398  const TransformType * GetIndexToObjectTransform(void) const;
399 
401  {
402  return m_AffineGeometryFrame->GetModifiableIndexToObjectTransform();
403  }
405  {
406  return m_AffineGeometryFrame->GetModifiableIndexToObjectTransform();
407  }
408 
409 
413  void SetObjectToParentTransform(TransformType *transform);
414 
416 
417  const TransformType * GetObjectToParentTransform(void) const;
418 
423 
424  const TransformType * GetObjectToNodeTransform(void) const;
425 
430  void AddSpatialObject(Self *pointer);
431 
436  void RemoveSpatialObject(Self *object);
437 
439  virtual const Self * GetParent(void) const;
440 
442  virtual Self * GetParent(void);
443 
449  virtual ChildrenListType * GetChildren(unsigned int depth = 0,
450  char *name = NULL) const;
451 
453  unsigned int GetNumberOfChildren(unsigned int depth = 0,
454  char *name = NULL) const;
455 
457  void SetChildren(ChildrenListType & children);
458 
461  virtual void Clear(void);
462 
485  virtual bool ComputeBoundingBox() const;
486 
487  virtual bool ComputeLocalBoundingBox() const
488  {
489  std::cerr << "SpatialObject::ComputeLocalBoundingBox Not Implemented!"
490  << std::endl;
491  return false;
492  }
493 
496  virtual BoundingBoxType * GetBoundingBox() const;
497 
499  itkSetMacro(BoundingBoxChildrenDepth, unsigned int);
500  itkGetConstReferenceMacro(BoundingBoxChildrenDepth, unsigned int);
501 
504  itkSetMacro(BoundingBoxChildrenName, std::string);
505  itkGetConstReferenceMacro(BoundingBoxChildrenName, std::string);
506 
509  void SetParent(Self *parent);
510 
513 
515 
516  const TransformType * GetNodeToParentNodeTransform(void) const;
517 
520  itkSetMacro(DefaultInsideValue, double);
521  itkGetConstMacro(DefaultInsideValue, double);
522 
525  itkSetMacro(DefaultOutsideValue, double);
526  itkGetConstMacro(DefaultOutsideValue, double);
527 
530  virtual std::string GetSpatialObjectTypeAsString() const;
531 
532 protected:
533 
535  SpatialObject();
536 
538  virtual ~SpatialObject();
539 
540  virtual void PrintSelf(std::ostream & os, Indent indent) const;
541 
546  void ComputeOffsetTable();
547 
548  itkSetMacro(Dimension, unsigned int);
549  itkGetConstReferenceMacro(Dimension, unsigned int)
550  itkSetMacro(TypeName, std::string);
552  itkGetModifiableObjectMacro(InternalInverseTransform, TransformType);
553 
561 
562 private:
563 
564  SpatialObject(const Self &); //purposely not implemented
565  void operator=(const Self &); //purposely not implemented
566 
569 
573 
575  std::string m_TypeName;
576 
577  unsigned int m_Dimension;
578 
580 
584 
588 
590  int m_Id;
592 
595 
598 
602 
606 
609 
612 };
613 } // end of namespace itk
614 
615 #if !defined( CABLE_CONFIGURATION )
616 #ifndef ITK_MANUAL_INSTANTIATION
617 #include "itkSpatialObject.hxx"
618 #endif
619 #endif
620 
621 #endif // __itkSpatialObject_h

Generated at Sat Mar 8 2014 15:34:46 for Orfeo Toolbox with doxygen 1.8.3.1