00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00115 #ifndef __vtkGraph_h
00116 #define __vtkGraph_h
00117
00118 #include "vtkDataObject.h"
00119
00120 class vtkAdjacentVertexIterator;
00121 class vtkEdgeListIterator;
00122 class vtkDataSetAttributes;
00123 class vtkGraphInternals;
00124 class vtkIdTypeArray;
00125 class vtkInEdgeIterator;
00126 class vtkOutEdgeIterator;
00127 class vtkPoints;
00128 class vtkVertexListIterator;
00129
00130
00131
00132
00133 namespace boost
00134 {
00135 class vtk_edge_iterator;
00136 class vtk_out_edge_pointer_iterator;
00137 class vtk_in_edge_pointer_iterator;
00138 }
00139
00140
00141 struct vtkEdgeBase
00142 {
00143 vtkEdgeBase() { }
00144 vtkEdgeBase(vtkIdType id) :
00145 Id(id) { }
00146 vtkIdType Id;
00147 };
00148
00149 struct vtkOutEdgeType : vtkEdgeBase
00150 {
00151 vtkOutEdgeType() { }
00152 vtkOutEdgeType(vtkIdType t, vtkIdType id) :
00153 vtkEdgeBase(id),
00154 Target(t) { }
00155 vtkIdType Target;
00156 };
00157
00158 struct vtkInEdgeType : vtkEdgeBase
00159 {
00160 vtkInEdgeType() { }
00161 vtkInEdgeType(vtkIdType s, vtkIdType id) :
00162 vtkEdgeBase(id),
00163 Source(s) { }
00164 vtkIdType Source;
00165 };
00166
00167 struct vtkEdgeType : vtkEdgeBase
00168 {
00169 vtkEdgeType() { }
00170 vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id) :
00171 vtkEdgeBase(id),
00172 Source(s),
00173 Target(t) { }
00174 vtkIdType Source;
00175 vtkIdType Target;
00176 };
00177
00178
00179 class VTK_FILTERING_EXPORT vtkGraph : public vtkDataObject
00180 {
00181 public:
00182 vtkTypeRevisionMacro(vtkGraph, vtkDataObject);
00183 void PrintSelf(ostream& os, vtkIndent indent);
00184
00186
00187 vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
00188 vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
00190
00192 virtual int GetDataObjectType() {return VTK_GRAPH;}
00193
00195 virtual void Initialize();
00196
00198
00200 double *GetPoint(vtkIdType ptId);
00201 void GetPoint(vtkIdType ptId, double x[3]);
00203
00205
00208 vtkPoints* GetPoints();
00209 virtual void SetPoints(vtkPoints *points);
00211
00213 void ComputeBounds();
00214
00216
00218 double *GetBounds();
00219 void GetBounds(double bounds[6]);
00221
00223 unsigned long int GetMTime();
00224
00227 virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
00228
00231 virtual vtkIdType GetDegree(vtkIdType v);
00232
00235 virtual vtkIdType GetOutDegree(vtkIdType v);
00236
00239 virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
00240
00243 virtual vtkIdType GetInDegree(vtkIdType v);
00244
00248 virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
00249
00252 virtual void GetEdges(vtkEdgeListIterator *it);
00253
00255 virtual vtkIdType GetNumberOfEdges();
00256
00259 virtual void GetVertices(vtkVertexListIterator *it);
00260
00262 virtual vtkIdType GetNumberOfVertices();
00263
00266 virtual void ShallowCopy(vtkDataObject *obj);
00267
00270 virtual void DeepCopy(vtkDataObject *obj);
00271
00274 virtual void CopyStructure(vtkGraph *g);
00275
00278 virtual bool CheckedShallowCopy(vtkGraph *g);
00279
00282 virtual bool CheckedDeepCopy(vtkGraph *g);
00283
00285 virtual void Squeeze();
00286
00287
00289
00290 static vtkGraph *GetData(vtkInformation *info);
00291 static vtkGraph *GetData(vtkInformationVector *v, int i=0);
00292
00294
00298 void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
00299
00302 bool IsSameStructure(vtkGraph *other);
00303
00305
00311 vtkIdType GetSourceVertex(vtkIdType e);
00312 vtkIdType GetTargetVertex(vtkIdType e);
00314
00315 protected:
00316
00317 vtkGraph();
00318 ~vtkGraph();
00319
00321 vtkIdType AddVertexInternal();
00322
00325 vtkEdgeType AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed);
00326
00329 virtual bool IsStructureValid(vtkGraph *g) = 0;
00330
00332 virtual void CopyInternal(vtkGraph *g, bool deep);
00333
00335 vtkGraphInternals *Internals;
00336
00338 void SetInternals(vtkGraphInternals* internals);
00339
00342 void ForceOwnership();
00343
00345
00346 virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
00347 virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
00349
00351 void BuildEdgeList();
00352
00354
00355 friend class vtkAdjacentVertexIterator;
00356 friend class vtkEdgeListIterator;
00357 friend class vtkInEdgeIterator;
00358 friend class vtkOutEdgeIterator;
00359 friend class boost::vtk_edge_iterator;
00360 friend class boost::vtk_in_edge_pointer_iterator;
00361 friend class boost::vtk_out_edge_pointer_iterator;
00363
00365
00366 vtkDataSetAttributes *VertexData;
00367 vtkDataSetAttributes *EdgeData;
00369
00371 double Bounds[6];
00372
00374 vtkTimeStamp ComputeTime;
00375
00377
00378 vtkPoints *Points;
00379 static double DefaultPoint[3];
00381
00383
00384 vtkIdTypeArray *EdgeList;
00385
00387 private:
00388 vtkGraph(const vtkGraph&);
00389 void operator=(const vtkGraph&);
00390 };
00391
00392
00393 bool VTK_FILTERING_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
00394 bool VTK_FILTERING_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
00395 VTK_FILTERING_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
00396
00397
00398 #endif