/usr/include/InsightToolkit/SpatialObject/itkSpatialObjectTreeNode.h is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkSpatialObjectTreeNode.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkSpatialObjectTreeNode_h
#define __itkSpatialObjectTreeNode_h
#include "itkTreeNode.h"
#include "itkSpatialObject.h"
#include "itkScalableAffineTransform.h"
namespace itk
{
template <unsigned int TDimension> class SpatialObject;
/** \class SpatialObjectTreeNode
* \brief TODO
*/
template <unsigned int TDimension>
class ITK_EXPORT SpatialObjectTreeNode : public TreeNode< SpatialObject<TDimension> * >
{
public:
/** Standard typedefs */
typedef SpatialObject<TDimension> SpatialObjectType;
typedef TreeNode< SpatialObject<TDimension> *> Superclass;
typedef SpatialObjectTreeNode<TDimension> Self;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef ScalableAffineTransform< double, TDimension>
TransformType;
typedef typename TransformType::Pointer TransformPointer;
typedef const TransformType* TransformConstPointer;
typedef typename Superclass::ChildrenListType ChildrenListType;
/** Method for creation through the object factory. */
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro( SpatialObjectTreeNode, TreeNode );
/** Set the SpatialObject pointer */
virtual void SetData(SpatialObjectType* data);
/** Set/Get the NodeToParenNode transform */
itkSetObjectMacro(NodeToParentNodeTransform,TransformType);
itkGetConstReferenceObjectMacro(NodeToParentNodeTransform,TransformType);
/** Set/Get the NodeToParenNode transform */
itkSetObjectMacro(NodeToWorldTransform,TransformType);
itkGetConstReferenceObjectMacro(NodeToWorldTransform,TransformType);
/** Compute the NodeToWorld transform based on the parent */
void ComputeNodeToWorldTransform();
/** Return a list of children (the list should be deleted by the user */
#if !defined(CABLE_CONFIGURATION)
virtual ChildrenListType* GetChildren( unsigned int depth=0,
char * name=NULL) const;
#endif
protected:
/** Constructor */
SpatialObjectTreeNode();
virtual ~SpatialObjectTreeNode(){};
void PrintSelf(std::ostream &os, Indent indent) const
{
this->Superclass::PrintSelf(os, indent);
os << indent << "NodeToParentNodeTransform: "
<< m_NodeToParentNodeTransform << std::endl;
os << indent << "NodeToWorldTransform: "
<< m_NodeToWorldTransform << std::endl;
}
TransformPointer m_NodeToParentNodeTransform;
TransformPointer m_NodeToWorldTransform;
private:
SpatialObjectTreeNode(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
/** Constructor */
template <unsigned int TDimension>
SpatialObjectTreeNode<TDimension>
::SpatialObjectTreeNode() : TreeNode<SpatialObject<TDimension> *>()
{
m_NodeToParentNodeTransform = TransformType::New();
m_NodeToParentNodeTransform->SetIdentity();
m_NodeToWorldTransform = TransformType::New();
m_NodeToWorldTransform->SetIdentity();
this->m_Parent = NULL;
}
/** Set the data */
template <unsigned int TDimension>
void
SpatialObjectTreeNode<TDimension>
::SetData(SpatialObjectType* data)
{
Superclass::Set(data);
data->SetTreeNode(this); // give the pointer to the node to the spatial object
}
/** Compute the NodeToWorld transform based on the parent */
template <unsigned int TDimension>
void SpatialObjectTreeNode<TDimension>
::ComputeNodeToWorldTransform()
{
m_NodeToWorldTransform->SetMatrix(m_NodeToParentNodeTransform->GetMatrix());
m_NodeToWorldTransform->SetOffset(m_NodeToParentNodeTransform->GetOffset());
if(this->HasParent())
{
static_cast<Self*>(this->GetParent())->ComputeNodeToWorldTransform();
m_NodeToWorldTransform->Compose( static_cast<Self*>(this->GetParent())
->GetNodeToWorldTransform(), false);
}
}
/** Get children given a name and a depth */
#if !defined(CABLE_CONFIGURATION)
template <unsigned int TDimension>
typename SpatialObjectTreeNode<TDimension>::ChildrenListType*
SpatialObjectTreeNode<TDimension>
::GetChildren( unsigned int depth, char * name) const
{
ChildrenListType * children = new ChildrenListType;
typename ChildrenListType::const_iterator childrenListIt =
this->m_Children.begin();
typename ChildrenListType::const_iterator childrenListEnd =
this->m_Children.end();
while( childrenListIt != childrenListEnd )
{
if( name == NULL || strstr(typeid(*((*childrenListIt)->Get())).name(),
name) )
{
children->push_back(*childrenListIt);
}
if( depth > 0 )
{
ChildrenListType * nextchildren =
(**childrenListIt).GetChildren(depth-1, name);
// Add the child to the current list
typename ChildrenListType::const_iterator nextIt = nextchildren->begin();
while(nextIt != nextchildren->end())
{
children->push_back(*nextIt);
nextIt++;
}
delete nextchildren;
}
childrenListIt++;
}
return children;
}
#endif
} // end namespace itk
#endif
|