00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00212 #ifndef __vtkGraph_h
00213 #define __vtkGraph_h
00214
00215 #include "vtkDataObject.h"
00216
00217 class vtkAdjacentVertexIterator;
00218 class vtkCellArray;
00219 class vtkEdgeListIterator;
00220 class vtkDataSetAttributes;
00221 class vtkGraphEdge;
00222 class vtkGraphEdgePoints;
00223 class vtkDistributedGraphHelper;
00224 class vtkGraphInternals;
00225 class vtkIdTypeArray;
00226 class vtkInEdgeIterator;
00227 class vtkOutEdgeIterator;
00228 class vtkPoints;
00229 class vtkVertexListIterator;
00230 class vtkVariant;
00231 class vtkVariantArray;
00232
00233
00234
00235
00236 namespace boost
00237 {
00238 class vtk_edge_iterator;
00239 class vtk_out_edge_pointer_iterator;
00240 class vtk_in_edge_pointer_iterator;
00241 }
00242
00243
00244 struct vtkEdgeBase
00245 {
00246 vtkEdgeBase() { }
00247 vtkEdgeBase(vtkIdType id) :
00248 Id(id) { }
00249 vtkIdType Id;
00250 };
00251
00252 struct vtkOutEdgeType : vtkEdgeBase
00253 {
00254 vtkOutEdgeType() { }
00255 vtkOutEdgeType(vtkIdType t, vtkIdType id) :
00256 vtkEdgeBase(id),
00257 Target(t) { }
00258 vtkIdType Target;
00259 };
00260
00261 struct vtkInEdgeType : vtkEdgeBase
00262 {
00263 vtkInEdgeType() { }
00264 vtkInEdgeType(vtkIdType s, vtkIdType id) :
00265 vtkEdgeBase(id),
00266 Source(s) { }
00267 vtkIdType Source;
00268 };
00269
00270 struct vtkEdgeType : vtkEdgeBase
00271 {
00272 vtkEdgeType() { }
00273 vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id) :
00274 vtkEdgeBase(id),
00275 Source(s),
00276 Target(t) { }
00277 vtkIdType Source;
00278 vtkIdType Target;
00279 };
00280
00281
00282 class VTK_FILTERING_EXPORT vtkGraph : public vtkDataObject
00283 {
00284 public:
00285 vtkTypeRevisionMacro(vtkGraph, vtkDataObject);
00286 void PrintSelf(ostream& os, vtkIndent indent);
00287
00289
00290 vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
00291 vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
00293
00295 virtual int GetDataObjectType() {return VTK_GRAPH;}
00296
00298 virtual void Initialize();
00299
00301
00304 double *GetPoint(vtkIdType ptId);
00305 void GetPoint(vtkIdType ptId, double x[3]);
00307
00309
00313 vtkPoints* GetPoints();
00314 virtual void SetPoints(vtkPoints *points);
00316
00319 void ComputeBounds();
00320
00322
00325 double *GetBounds();
00326 void GetBounds(double bounds[6]);
00328
00330 unsigned long int GetMTime();
00331
00335 virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
00336
00340 virtual vtkIdType GetDegree(vtkIdType v);
00341
00345 virtual vtkIdType GetOutDegree(vtkIdType v);
00346
00347
00349
00350 virtual vtkOutEdgeType GetOutEdge(vtkIdType v, vtkIdType index);
00351
00353
00358 virtual void GetOutEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
00359
00363 virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
00364
00368 virtual vtkIdType GetInDegree(vtkIdType v);
00369
00370
00372
00373 virtual vtkInEdgeType GetInEdge(vtkIdType v, vtkIdType index);
00374
00376
00381 virtual void GetInEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
00382
00387 virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
00388
00392 virtual void GetEdges(vtkEdgeListIterator *it);
00393
00396 virtual vtkIdType GetNumberOfEdges();
00397
00401 virtual void GetVertices(vtkVertexListIterator *it);
00402
00405 virtual vtkIdType GetNumberOfVertices();
00406
00407
00411 void SetDistributedGraphHelper(vtkDistributedGraphHelper *helper);
00412
00414
00415 vtkDistributedGraphHelper *GetDistributedGraphHelper();
00416
00418
00419
00421
00427 vtkIdType FindVertex(const vtkVariant& pedigreeID);
00428
00430
00433 virtual void ShallowCopy(vtkDataObject *obj);
00434
00437 virtual void DeepCopy(vtkDataObject *obj);
00438
00441 virtual void CopyStructure(vtkGraph *g);
00442
00445 virtual bool CheckedShallowCopy(vtkGraph *g);
00446
00449 virtual bool CheckedDeepCopy(vtkGraph *g);
00450
00452 virtual void Squeeze();
00453
00454
00456
00457 static vtkGraph *GetData(vtkInformation *info);
00458 static vtkGraph *GetData(vtkInformationVector *v, int i=0);
00459
00461
00466 void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
00467
00470 bool IsSameStructure(vtkGraph *other);
00471
00473
00479 vtkIdType GetSourceVertex(vtkIdType e);
00480 vtkIdType GetTargetVertex(vtkIdType e);
00482
00483
00485
00488 void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
00489 void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
00490
00492
00494 vtkIdType GetNumberOfEdgePoints(vtkIdType e);
00495
00497 double* GetEdgePoint(vtkIdType e, vtkIdType i);
00498
00500 void ClearEdgePoints(vtkIdType e);
00501
00503
00505 void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
00506 void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
00507 { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
00509
00511
00513 void AddEdgePoint(vtkIdType e, double x[3]);
00514 void AddEdgePoint(vtkIdType e, double x, double y, double z)
00515 { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
00517
00519
00521 void ShallowCopyEdgePoints(vtkGraph* g);
00522 void DeepCopyEdgePoints(vtkGraph* g);
00524
00528 vtkGraphInternals *GetGraphInternals(bool modifying);
00529
00532 void GetInducedEdges(vtkIdTypeArray* verts, vtkIdTypeArray* edges);
00533
00538 virtual vtkFieldData* GetAttributesAsFieldData(int type);
00539
00542 virtual vtkIdType GetNumberOfElements(int type);
00543
00545 void Dump();
00546
00547 protected:
00548
00549 vtkGraph();
00550 ~vtkGraph();
00551
00553
00558 void AddVertexInternal(vtkVariantArray *propertyArr = 0,
00559 vtkIdType *vertex = 0);
00561
00566 void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
00567
00569
00573 void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
00574 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00575 void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
00576 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00577 void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
00578 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00579 void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
00580 bool directed, vtkVariantArray *propertyArr,
00581 vtkEdgeType *edge);
00583
00586 void RemoveVertexInternal(vtkIdType v, bool directed);
00587
00590 void RemoveEdgeInternal(vtkIdType e, bool directed);
00591
00594 void RemoveVerticesInternal(vtkIdTypeArray* arr, bool directed);
00595
00597
00598 void RemoveEdgesInternal(vtkIdTypeArray* arr, bool directed);
00599
00601
00604 virtual bool IsStructureValid(vtkGraph *g) = 0;
00605
00607 virtual void CopyInternal(vtkGraph *g, bool deep);
00608
00610 vtkGraphInternals *Internals;
00611
00613 vtkDistributedGraphHelper *DistributedHelper;
00614
00616 void SetInternals(vtkGraphInternals* internals);
00617
00619 vtkGraphEdgePoints *EdgePoints;
00620
00622 void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
00623
00626 void ForceOwnership();
00627
00629
00630 virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
00631 virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
00633
00635 void BuildEdgeList();
00636
00638
00639 friend class vtkAdjacentVertexIterator;
00640 friend class vtkEdgeListIterator;
00641 friend class vtkInEdgeIterator;
00642 friend class vtkOutEdgeIterator;
00643 friend class boost::vtk_edge_iterator;
00644 friend class boost::vtk_in_edge_pointer_iterator;
00645 friend class boost::vtk_out_edge_pointer_iterator;
00646
00648
00650
00651 vtkDataSetAttributes *VertexData;
00652 vtkDataSetAttributes *EdgeData;
00654
00656 double Bounds[6];
00657
00659 vtkTimeStamp ComputeTime;
00660
00662
00663 vtkPoints *Points;
00664 static double DefaultPoint[3];
00666
00668
00669 vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
00670 virtual void SetEdgeList(vtkIdTypeArray* list);
00671 vtkIdTypeArray *EdgeList;
00672
00674 private:
00675 vtkGraph(const vtkGraph&);
00676 void operator=(const vtkGraph&);
00677 };
00678
00679
00680 bool VTK_FILTERING_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
00681 bool VTK_FILTERING_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
00682 VTK_FILTERING_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
00683
00684
00685 #endif