00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00215 #ifndef __vtkGraph_h
00216 #define __vtkGraph_h
00217
00218 #include "vtkDataObject.h"
00219
00220 class vtkAdjacentVertexIterator;
00221 class vtkCellArray;
00222 class vtkEdgeListIterator;
00223 class vtkDataSetAttributes;
00224 class vtkGraphEdge;
00225 class vtkGraphEdgePoints;
00226 class vtkDistributedGraphHelper;
00227 class vtkGraphInternals;
00228 class vtkIdTypeArray;
00229 class vtkInEdgeIterator;
00230 class vtkOutEdgeIterator;
00231 class vtkPoints;
00232 class vtkVertexListIterator;
00233 class vtkVariant;
00234 class vtkVariantArray;
00235
00236
00237
00238
00239 namespace boost
00240 {
00241 class vtk_edge_iterator;
00242 class vtk_out_edge_pointer_iterator;
00243 class vtk_in_edge_pointer_iterator;
00244 }
00245
00246
00247 struct vtkEdgeBase
00248 {
00249 vtkEdgeBase() { }
00250 vtkEdgeBase(vtkIdType id) :
00251 Id(id) { }
00252 vtkIdType Id;
00253 };
00254
00255 struct vtkOutEdgeType : vtkEdgeBase
00256 {
00257 vtkOutEdgeType() { }
00258 vtkOutEdgeType(vtkIdType t, vtkIdType id) :
00259 vtkEdgeBase(id),
00260 Target(t) { }
00261 vtkIdType Target;
00262 };
00263
00264 struct vtkInEdgeType : vtkEdgeBase
00265 {
00266 vtkInEdgeType() { }
00267 vtkInEdgeType(vtkIdType s, vtkIdType id) :
00268 vtkEdgeBase(id),
00269 Source(s) { }
00270 vtkIdType Source;
00271 };
00272
00273 struct vtkEdgeType : vtkEdgeBase
00274 {
00275 vtkEdgeType() { }
00276 vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id) :
00277 vtkEdgeBase(id),
00278 Source(s),
00279 Target(t) { }
00280 vtkIdType Source;
00281 vtkIdType Target;
00282 };
00283
00284
00285 class VTK_FILTERING_EXPORT vtkGraph : public vtkDataObject
00286 {
00287 public:
00288 vtkTypeMacro(vtkGraph, vtkDataObject);
00289 void PrintSelf(ostream& os, vtkIndent indent);
00290
00292
00293 vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
00294 vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
00296
00298 virtual int GetDataObjectType() {return VTK_GRAPH;}
00299
00301 virtual void Initialize();
00302
00304
00307 double *GetPoint(vtkIdType ptId);
00308 void GetPoint(vtkIdType ptId, double x[3]);
00310
00312
00316 vtkPoints* GetPoints();
00317 virtual void SetPoints(vtkPoints *points);
00319
00322 void ComputeBounds();
00323
00325
00328 double *GetBounds();
00329 void GetBounds(double bounds[6]);
00331
00333 unsigned long int GetMTime();
00334
00338 virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
00339
00343 virtual vtkIdType GetDegree(vtkIdType v);
00344
00348 virtual vtkIdType GetOutDegree(vtkIdType v);
00349
00350
00352
00353 virtual vtkOutEdgeType GetOutEdge(vtkIdType v, vtkIdType index);
00354
00356
00361 virtual void GetOutEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
00362
00366 virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
00367
00371 virtual vtkIdType GetInDegree(vtkIdType v);
00372
00373
00375
00376 virtual vtkInEdgeType GetInEdge(vtkIdType v, vtkIdType index);
00377
00379
00384 virtual void GetInEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
00385
00390 virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
00391
00395 virtual void GetEdges(vtkEdgeListIterator *it);
00396
00399 virtual vtkIdType GetNumberOfEdges();
00400
00404 virtual void GetVertices(vtkVertexListIterator *it);
00405
00408 virtual vtkIdType GetNumberOfVertices();
00409
00410
00414 void SetDistributedGraphHelper(vtkDistributedGraphHelper *helper);
00415
00417
00418 vtkDistributedGraphHelper *GetDistributedGraphHelper();
00419
00421
00422
00424
00430 vtkIdType FindVertex(const vtkVariant& pedigreeID);
00431
00433
00436 virtual void ShallowCopy(vtkDataObject *obj);
00437
00440 virtual void DeepCopy(vtkDataObject *obj);
00441
00444 virtual void CopyStructure(vtkGraph *g);
00445
00448 virtual bool CheckedShallowCopy(vtkGraph *g);
00449
00452 virtual bool CheckedDeepCopy(vtkGraph *g);
00453
00455 virtual void Squeeze();
00456
00457
00459
00460 static vtkGraph *GetData(vtkInformation *info);
00461 static vtkGraph *GetData(vtkInformationVector *v, int i=0);
00462
00464
00469 void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
00470
00473 bool IsSameStructure(vtkGraph *other);
00474
00476
00482 vtkIdType GetSourceVertex(vtkIdType e);
00483 vtkIdType GetTargetVertex(vtkIdType e);
00485
00486
00488
00491 void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
00492 void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
00493
00495
00497 vtkIdType GetNumberOfEdgePoints(vtkIdType e);
00498
00500 double* GetEdgePoint(vtkIdType e, vtkIdType i);
00501
00503 void ClearEdgePoints(vtkIdType e);
00504
00506
00508 void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
00509 void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
00510 { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
00512
00514
00516 void AddEdgePoint(vtkIdType e, double x[3]);
00517 void AddEdgePoint(vtkIdType e, double x, double y, double z)
00518 { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
00520
00522
00524 void ShallowCopyEdgePoints(vtkGraph* g);
00525 void DeepCopyEdgePoints(vtkGraph* g);
00527
00531 vtkGraphInternals *GetGraphInternals(bool modifying);
00532
00535 void GetInducedEdges(vtkIdTypeArray* verts, vtkIdTypeArray* edges);
00536
00541 virtual vtkFieldData* GetAttributesAsFieldData(int type);
00542
00545 virtual vtkIdType GetNumberOfElements(int type);
00546
00548 void Dump();
00549
00550 protected:
00551
00552 vtkGraph();
00553 ~vtkGraph();
00554
00556
00561 void AddVertexInternal(vtkVariantArray *propertyArr = 0,
00562 vtkIdType *vertex = 0);
00564
00569 void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
00570
00572
00576 void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
00577 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00578 void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
00579 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00580 void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
00581 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00582 void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
00583 bool directed, vtkVariantArray *propertyArr,
00584 vtkEdgeType *edge);
00586
00589 void RemoveVertexInternal(vtkIdType v, bool directed);
00590
00593 void RemoveEdgeInternal(vtkIdType e, bool directed);
00594
00597 void RemoveVerticesInternal(vtkIdTypeArray* arr, bool directed);
00598
00600
00601 void RemoveEdgesInternal(vtkIdTypeArray* arr, bool directed);
00602
00604
00607 virtual bool IsStructureValid(vtkGraph *g) = 0;
00608
00610 virtual void CopyInternal(vtkGraph *g, bool deep);
00611
00613 vtkGraphInternals *Internals;
00614
00616 vtkDistributedGraphHelper *DistributedHelper;
00617
00619 void SetInternals(vtkGraphInternals* internals);
00620
00622 vtkGraphEdgePoints *EdgePoints;
00623
00625 void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
00626
00629 void ForceOwnership();
00630
00632
00633 virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
00634 virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
00636
00638 void BuildEdgeList();
00639
00641
00642 friend class vtkAdjacentVertexIterator;
00643 friend class vtkEdgeListIterator;
00644 friend class vtkInEdgeIterator;
00645 friend class vtkOutEdgeIterator;
00646 friend class boost::vtk_edge_iterator;
00647 friend class boost::vtk_in_edge_pointer_iterator;
00648 friend class boost::vtk_out_edge_pointer_iterator;
00649
00651
00653
00654 vtkDataSetAttributes *VertexData;
00655 vtkDataSetAttributes *EdgeData;
00657
00659 double Bounds[6];
00660
00662 vtkTimeStamp ComputeTime;
00663
00665
00666 vtkPoints *Points;
00667 static double DefaultPoint[3];
00669
00671
00672 vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
00673 virtual void SetEdgeList(vtkIdTypeArray* list);
00674 vtkIdTypeArray *EdgeList;
00675
00677 private:
00678 vtkGraph(const vtkGraph&);
00679 void operator=(const vtkGraph&);
00680 };
00681
00682
00683 bool VTK_FILTERING_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
00684 bool VTK_FILTERING_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
00685 VTK_FILTERING_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
00686
00687
00688 #endif