Orfeo Toolbox  3.16
itkSpatialObjectTreeNode.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSpatialObjectTreeNode.h,v $
5  Language: C++
6  Date: $Date: 2009-04-07 14:34:17 $
7  Version: $Revision: 1.15 $
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 __itkSpatialObjectTreeNode_h
18 #define __itkSpatialObjectTreeNode_h
19 
20 #include "itkTreeNode.h"
21 #include "itkSpatialObject.h"
23 
24 namespace itk
25 {
26 
27 template <unsigned int TDimension> class SpatialObject;
28 
32 template <unsigned int TDimension>
33 class ITK_EXPORT SpatialObjectTreeNode : public TreeNode< SpatialObject<TDimension> * >
34 {
35 
36 public:
37 
48  typedef typename Superclass::ChildrenListType ChildrenListType;
49 
51  itkNewMacro( Self );
52 
54  itkTypeMacro( SpatialObjectTreeNode, TreeNode );
55 
57  virtual void SetData(SpatialObjectType* data);
58 
60  itkSetObjectMacro(NodeToParentNodeTransform,TransformType);
61  itkGetConstReferenceObjectMacro(NodeToParentNodeTransform,TransformType);
62 
64  itkSetObjectMacro(NodeToWorldTransform,TransformType);
65  itkGetConstReferenceObjectMacro(NodeToWorldTransform,TransformType);
66 
68  void ComputeNodeToWorldTransform();
69 
71 #if !defined(CABLE_CONFIGURATION)
72  virtual ChildrenListType* GetChildren( unsigned int depth=0,
73  char * name=NULL) const;
74 #endif
75 
76 protected:
77 
81  void PrintSelf(std::ostream &os, Indent indent) const
82  {
83  this->Superclass::PrintSelf(os, indent);
84  os << indent << "NodeToParentNodeTransform: "
85  << m_NodeToParentNodeTransform << std::endl;
86  os << indent << "NodeToWorldTransform: "
87  << m_NodeToWorldTransform << std::endl;
88  }
89 
92 
93 private:
94 
95  SpatialObjectTreeNode(const Self&); //purposely not implemented
96  void operator=(const Self&); //purposely not implemented
97 
98 };
99 
101 template <unsigned int TDimension>
104 {
105  m_NodeToParentNodeTransform = TransformType::New();
106  m_NodeToParentNodeTransform->SetIdentity();
107  m_NodeToWorldTransform = TransformType::New();
108  m_NodeToWorldTransform->SetIdentity();
109  this->m_Parent = NULL;
110 }
111 
112 
114 template <unsigned int TDimension>
115 void
118 {
119  Superclass::Set(data);
120  data->SetTreeNode(this); // give the pointer to the node to the spatial object
121 }
122 
124 template <unsigned int TDimension>
127 {
128  m_NodeToWorldTransform->SetMatrix(m_NodeToParentNodeTransform->GetMatrix());
129  m_NodeToWorldTransform->SetOffset(m_NodeToParentNodeTransform->GetOffset());
130  if(this->HasParent())
131  {
132  static_cast<Self*>(this->GetParent())->ComputeNodeToWorldTransform();
133  m_NodeToWorldTransform->Compose( static_cast<Self*>(this->GetParent())
134  ->GetNodeToWorldTransform(), false);
135  }
136 }
137 
138 
140 #if !defined(CABLE_CONFIGURATION)
141 template <unsigned int TDimension>
144 ::GetChildren( unsigned int depth, char * name) const
145 {
146  ChildrenListType * children = new ChildrenListType;
147 
148  typename ChildrenListType::const_iterator childrenListIt =
149  this->m_Children.begin();
150  typename ChildrenListType::const_iterator childrenListEnd =
151  this->m_Children.end();
152 
153  while( childrenListIt != childrenListEnd )
154  {
155  if( name == NULL || strstr(typeid(*((*childrenListIt)->Get())).name(),
156  name) )
157  {
158  children->push_back(*childrenListIt);
159  }
160  if( depth > 0 )
161  {
162  ChildrenListType * nextchildren =
163  (**childrenListIt).GetChildren(depth-1, name);
164  // Add the child to the current list
165  typename ChildrenListType::const_iterator nextIt = nextchildren->begin();
166  while(nextIt != nextchildren->end())
167  {
168  children->push_back(*nextIt);
169  nextIt++;
170  }
171  delete nextchildren;
172  }
173  childrenListIt++;
174  }
175 
176  return children;
177 }
178 #endif
179 
180 } // end namespace itk
181 
182 
183 #endif

Generated at Sun Feb 3 2013 00:08:18 for Orfeo Toolbox with doxygen 1.8.1.1