Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkHierarchicalDataSetInternal.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkHierarchicalDataSetInternal.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00016 00017 #ifndef __vtkHierarchicalDataSetInternal_h 00018 #define __vtkHierarchicalDataSetInternal_h 00019 00020 #include <vtkstd/vector> 00021 #include <vtkstd/algorithm> 00022 00023 #include "vtkDataObject.h" 00024 #include "vtkSmartPointer.h" 00025 00026 class vtkHDSNode; 00027 00028 struct vtkHierarchicalDataSetInternal 00029 { 00030 typedef vtkstd::vector<vtkHDSNode*> LevelDataSetsType; 00031 typedef LevelDataSetsType::iterator LevelDataSetsIterator; 00032 typedef vtkstd::vector<LevelDataSetsType> DataSetsType; 00033 typedef DataSetsType::iterator DataSetsIterator; 00034 00035 DataSetsType DataSets; 00036 }; 00037 00038 struct vtkHDSNodeRef 00039 { 00040 vtkHDSNodeRef(int level, int index) : Level(level), Index(index) {} 00041 00042 vtkstd_bool operator==(const vtkHDSNodeRef& rhs) 00043 { 00044 return (this->Level == rhs.Level) && (this->Index == rhs.Index); 00045 } 00046 vtkstd_bool operator!=(const vtkHDSNodeRef& rhs) 00047 { 00048 return (this->Level != rhs.Level) || (this->Index != rhs.Index); 00049 } 00050 00051 int Level; 00052 int Index; 00053 }; 00054 00055 class vtkHDSNode 00056 { 00057 public: 00058 00059 vtkHDSNode() : DataSet(0) {} 00060 vtkSmartPointer<vtkDataObject> DataSet; 00061 00062 void AddParent(const vtkHDSNodeRef& parent); 00063 void AddChild (const vtkHDSNodeRef& child ); 00064 00065 void RemoveParent(const vtkHDSNodeRef& parent); 00066 void RemoveChild (const vtkHDSNodeRef& child ); 00067 00068 void DisconnectFromParent(const vtkHDSNodeRef& self, 00069 const vtkHDSNodeRef& parent, 00070 vtkHierarchicalDataSetInternal::DataSetsType& ds); 00071 void DisconnectFromChild (const vtkHDSNodeRef& self, 00072 const vtkHDSNodeRef& child, 00073 vtkHierarchicalDataSetInternal::DataSetsType& ds); 00074 void ConnectToParent(const vtkHDSNodeRef& self, 00075 const vtkHDSNodeRef& parent, 00076 vtkHierarchicalDataSetInternal::DataSetsType& ds); 00077 void ConnectToChild (const vtkHDSNodeRef& self, 00078 const vtkHDSNodeRef& child, 00079 vtkHierarchicalDataSetInternal::DataSetsType& ds); 00080 00081 void DisconnectAll(const vtkHDSNodeRef& self, 00082 vtkHierarchicalDataSetInternal::DataSetsType& ds); 00083 00084 protected: 00085 vtkstd::vector<vtkHDSNodeRef> Parents; 00086 vtkstd::vector<vtkHDSNodeRef> Children; 00087 }; 00088 00089 inline void vtkHDSNode::AddParent(const vtkHDSNodeRef& parent) 00090 { 00091 this->Parents.push_back(parent); 00092 } 00093 00094 inline void vtkHDSNode::AddChild(const vtkHDSNodeRef& child) 00095 { 00096 this->Children.push_back(child); 00097 } 00098 00099 inline void vtkHDSNode::RemoveParent(const vtkHDSNodeRef& parent) 00100 { 00101 vtkstd::vector<vtkHDSNodeRef>::iterator it = 00102 vtkstd::find(this->Parents.begin(), this->Parents.end(), parent); 00103 if (it != this->Parents.end()) 00104 { 00105 this->Parents.erase(it); 00106 } 00107 } 00108 00109 inline void vtkHDSNode::RemoveChild (const vtkHDSNodeRef& child) 00110 { 00111 vtkstd::vector<vtkHDSNodeRef>::iterator it = 00112 vtkstd::find(this->Children.begin(), this->Children.end(), child); 00113 if (it != this->Children.end()) 00114 { 00115 this->Children.erase(it); 00116 } 00117 } 00118 00119 inline void vtkHDSNode::ConnectToParent( 00120 const vtkHDSNodeRef& self, 00121 const vtkHDSNodeRef& parent, 00122 vtkHierarchicalDataSetInternal::DataSetsType& ds) 00123 { 00124 this->AddParent(parent); 00125 ds[parent.Level][parent.Index]->AddChild(self); 00126 } 00127 00128 inline void vtkHDSNode::ConnectToChild( 00129 const vtkHDSNodeRef& self, 00130 const vtkHDSNodeRef& child, 00131 vtkHierarchicalDataSetInternal::DataSetsType& ds) 00132 { 00133 this->AddChild(child); 00134 ds[child.Level][child.Index]->AddParent(self); 00135 } 00136 00137 inline void vtkHDSNode::DisconnectFromParent( 00138 const vtkHDSNodeRef& self, 00139 const vtkHDSNodeRef& parent, 00140 vtkHierarchicalDataSetInternal::DataSetsType& ds) 00141 { 00142 this->RemoveParent(parent); 00143 ds[parent.Level][parent.Index]->RemoveChild(self); 00144 } 00145 00146 inline void vtkHDSNode::DisconnectFromChild( 00147 const vtkHDSNodeRef& self, 00148 const vtkHDSNodeRef& child, 00149 vtkHierarchicalDataSetInternal::DataSetsType& ds) 00150 { 00151 this->RemoveChild(child); 00152 ds[child.Level][child.Index]->RemoveParent(self); 00153 } 00154 00155 inline void vtkHDSNode::DisconnectAll( 00156 const vtkHDSNodeRef& self, vtkHierarchicalDataSetInternal::DataSetsType& ds) 00157 { 00158 vtkstd::vector<vtkHDSNodeRef>::iterator it; 00159 00160 for(it=this->Parents.begin(); it!=this->Parents.end(); ++it) 00161 { 00162 this->DisconnectFromParent(self, *it, ds); 00163 } 00164 00165 for(it=this->Children.begin(); it!=this->Children.end(); ++it) 00166 { 00167 this->DisconnectFromChild(self, *it, ds); 00168 } 00169 00170 } 00171 00172 #endif