KWStyle - itkTreeContainer.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkTreeContainer.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
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      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 __itkTreeContainer_h
18 #define __itkTreeContainer_h
19
20 #include "itkMacro.h"
21 #include <itkTreeContainerBase.h>
22 #include <itkPreOrderTreeIterator.h>
23
24 namespace itk
25 {
26
27 /** \class TreeContainer
28  *  \brief TreeContainer class
29  * 
30  * This class derives from the TreeContainerBase class.
31  *
32  * The class is templated over the type of the elements.
33  *
34  * Template parameters for class TreeContainer:
35  *
36  * - TValueType = Element type stored at each location in the Tree.
37  *
38  * \ingroup DataRepresentation 
39  */
40 template <class TValueType>
41 class TreeContainer : public TreeContainerBase<TValueType>
42 {
43
44 public:
45
46   /** Standard typedefs */
47   typedef TreeContainerBase<TValueType> Superclass;
48 TDA   typedef TreeContainer<TValueType> Self;
49 TDA   typedef SmartPointer<Self>  Pointer;
50 TDA   typedef SmartPointer<const Self>  ConstPointer;
51 TDA   typedef TValueType ValueType;
52 TDA   typedef TreeNode<ValueType> TreeNodeType;
53
54   /** Iterators typedef */ 
55   typedef TreeIteratorBase<Self> IteratorType;
56 TDA   typedef PreOrderTreeIterator<Self> PreOrderIteratorType;
57
58   /** Method for creation through the object factory. */
59   itkNewMacro(Self);
60
61   /** Run-time type information (and related methods). */
62   itkTypeMacro(TreeContainer, TreeContainerBase);
63  
64   /** Constructor */
65   TreeContainer( int defaultChildrenCount );
66
67   /** Constructor */
68   TreeContainer( TreeContainer<TValueType>& tree );
69
70   /** Set the root as an element */
71   virtual bool SetRoot( TValueType element);
72
73   /** The the root as an iterator position */
74   bool SetRoot( IteratorType& pos );
75
76   /** Set the root as a tree node */
77   virtual bool SetRoot( TreeNode<TValueType>* node);
78
79   /** Return true if the element is in the tree*/
80 SEM   bool Contains( const TValueType element ) ;
81
82   /** Return the number of elements in the tree */
83   int Count() const;
84
85   /** Return true if the element is a leaf */
86   bool IsLeaf( const TValueType element );
87
88   /** Return true if the element is a root */
89   bool IsRoot( const TValueType element );
90
91   /** Clear the tree */
92   bool Clear();
93
94   /** operator equal */
95   bool operator==( TreeContainer<TValueType>& tree );
96
97   /** Swap the iterators */
98   bool Swap( IteratorType& v, IteratorType& w );
99
100   /** Get the root */
101   const TreeNodeType* GetRoot() const {return m_Root.GetPointer();}
102
103   /** Add a child to a given parent using values*/
104   bool Add(const TValueType child, const TValueType parent);
105
106   /** Get node given a value */
107   const TreeNodeType* GetNode(TValueType val) const;
108
109 protected:
110   
111   TreeContainer(); 
112   virtual ~TreeContainer();
113
114   typename TreeNodeType::Pointer    m_Root;
115   int   m_DefaultChildrenCount;
116
117   void PrintSelf(std::ostream& os, Indent indent) const;
118
119 };
120
121 // namespace itk
122
123
124 #ifndef ITK_MANUAL_INSTANTIATION
125 #include "itkTreeContainer.txx"
126 #endif
127
128
129 #endif
130

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:50PM
© Kitware Inc.