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
00425 vtkIdType FindVertex(const vtkVariant& pedigreeID);
00426
00428
00431 virtual void ShallowCopy(vtkDataObject *obj);
00432
00435 virtual void DeepCopy(vtkDataObject *obj);
00436
00439 virtual void CopyStructure(vtkGraph *g);
00440
00443 virtual bool CheckedShallowCopy(vtkGraph *g);
00444
00447 virtual bool CheckedDeepCopy(vtkGraph *g);
00448
00450 virtual void Squeeze();
00451
00452
00454
00455 static vtkGraph *GetData(vtkInformation *info);
00456 static vtkGraph *GetData(vtkInformationVector *v, int i=0);
00457
00459
00464 void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
00465
00468 bool IsSameStructure(vtkGraph *other);
00469
00471
00477 vtkIdType GetSourceVertex(vtkIdType e);
00478 vtkIdType GetTargetVertex(vtkIdType e);
00480
00481
00483
00486 void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
00487 void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
00488
00490
00492 vtkIdType GetNumberOfEdgePoints(vtkIdType e);
00493
00495 double* GetEdgePoint(vtkIdType e, vtkIdType i);
00496
00498 void ClearEdgePoints(vtkIdType e);
00499
00501
00503 void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
00504 void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
00505 { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
00507
00509
00511 void AddEdgePoint(vtkIdType e, double x[3]);
00512 void AddEdgePoint(vtkIdType e, double x, double y, double z)
00513 { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
00515
00517
00519 void ShallowCopyEdgePoints(vtkGraph* g);
00520 void DeepCopyEdgePoints(vtkGraph* g);
00522
00526 vtkGraphInternals *GetGraphInternals(bool modifying);
00527
00528 protected:
00529
00530 vtkGraph();
00531 ~vtkGraph();
00532
00534
00539 void AddVertexInternal(vtkVariantArray *propertyArr = 0,
00540 vtkIdType *vertex = 0);
00542
00547 void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
00548
00550
00554 void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
00555 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00556 void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
00557 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00558 void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
00559 vtkVariantArray *propertyArr, vtkEdgeType *edge);
00560 void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
00561 bool directed, vtkVariantArray *propertyArr,
00562 vtkEdgeType *edge);
00563
00565
00568 virtual bool IsStructureValid(vtkGraph *g) = 0;
00569
00571 virtual void CopyInternal(vtkGraph *g, bool deep);
00572
00574 vtkGraphInternals *Internals;
00575
00577 vtkDistributedGraphHelper *DistributedHelper;
00578
00580 void SetInternals(vtkGraphInternals* internals);
00581
00583 vtkGraphEdgePoints *EdgePoints;
00584
00586 void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
00587
00590 void ForceOwnership();
00591
00593
00594 virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
00595 virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
00597
00599 void BuildEdgeList();
00600
00602
00603 friend class vtkAdjacentVertexIterator;
00604 friend class vtkEdgeListIterator;
00605 friend class vtkInEdgeIterator;
00606 friend class vtkOutEdgeIterator;
00607 friend class boost::vtk_edge_iterator;
00608 friend class boost::vtk_in_edge_pointer_iterator;
00609 friend class boost::vtk_out_edge_pointer_iterator;
00610
00612
00614
00615 vtkDataSetAttributes *VertexData;
00616 vtkDataSetAttributes *EdgeData;
00618
00620 double Bounds[6];
00621
00623 vtkTimeStamp ComputeTime;
00624
00626
00627 vtkPoints *Points;
00628 static double DefaultPoint[3];
00630
00632
00633 vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
00634 virtual void SetEdgeList(vtkIdTypeArray* list);
00635 vtkIdTypeArray *EdgeList;
00636
00638 private:
00639 vtkGraph(const vtkGraph&);
00640 void operator=(const vtkGraph&);
00641 };
00642
00643
00644 bool VTK_FILTERING_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
00645 bool VTK_FILTERING_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
00646 VTK_FILTERING_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
00647
00648
00649 #endif