VTK
vtkGraph.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGraph.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
215 #ifndef vtkGraph_h
216 #define vtkGraph_h
217 
218 #include "vtkCommonDataModelModule.h" // For export macro
219 #include "vtkDataObject.h"
220 
222 class vtkCellArray;
223 class vtkEdgeListIterator;
225 class vtkDirectedGraph;
226 class vtkGraphEdge;
227 class vtkGraphEdgePoints;
229 class vtkGraphInternals;
230 class vtkIdTypeArray;
231 class vtkInEdgeIterator;
232 class vtkOutEdgeIterator;
233 class vtkPoints;
234 class vtkUndirectedGraph;
236 class vtkVariant;
237 class vtkVariantArray;
238 
239 //BTX
240 // Forward declare some boost stuff even if boost wrappers
241 // are turned off.
242 namespace boost
243 {
244  class vtk_edge_iterator;
245  class vtk_out_edge_pointer_iterator;
246  class vtk_in_edge_pointer_iterator;
247 }
248 
249 // Edge structures.
251 {
254  Id(id) { }
256 };
257 
259 {
262  vtkEdgeBase(id),
263  Target(t) { }
265 };
266 
268 {
271  vtkEdgeBase(id),
272  Source(s) { }
274 };
275 
277 {
280  vtkEdgeBase(id),
281  Source(s),
282  Target(t) { }
285 };
286 //ETX
287 
289 {
290 public:
291  vtkTypeMacro(vtkGraph, vtkDataObject);
292  void PrintSelf(ostream& os, vtkIndent indent);
293 
295 
296  vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
297  vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
299 
301  virtual int GetDataObjectType() {return VTK_GRAPH;}
302 
304  virtual void Initialize();
305 
307 
310  double *GetPoint(vtkIdType ptId);
311  void GetPoint(vtkIdType ptId, double x[3]);
313 
315 
319  vtkPoints* GetPoints();
320  virtual void SetPoints(vtkPoints *points);
322 
325  void ComputeBounds();
326 
328 
331  double *GetBounds();
332  void GetBounds(double bounds[6]);
334 
336  unsigned long int GetMTime();
337 
341  virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
342 
346  virtual vtkIdType GetDegree(vtkIdType v);
347 
351  virtual vtkIdType GetOutDegree(vtkIdType v);
352 
353  //BTX
355 
356  virtual vtkOutEdgeType GetOutEdge(vtkIdType v, vtkIdType index);
357  //ETX
359 
364  virtual void GetOutEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
365 
369  virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
370 
374  virtual vtkIdType GetInDegree(vtkIdType v);
375 
376  //BTX
378 
379  virtual vtkInEdgeType GetInEdge(vtkIdType v, vtkIdType index);
380  //ETX
382 
387  virtual void GetInEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
388 
393  virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
394 
398  virtual void GetEdges(vtkEdgeListIterator *it);
399 
402  virtual vtkIdType GetNumberOfEdges();
403 
407  virtual void GetVertices(vtkVertexListIterator *it);
408 
411  virtual vtkIdType GetNumberOfVertices();
412 
413  // BTX
417  void SetDistributedGraphHelper(vtkDistributedGraphHelper *helper);
418 
420 
421  vtkDistributedGraphHelper *GetDistributedGraphHelper();
422  //ETX
424 
431  vtkIdType FindVertex(const vtkVariant& pedigreeID);
432 
435  virtual void ShallowCopy(vtkDataObject *obj);
436 
439  virtual void DeepCopy(vtkDataObject *obj);
440 
443  virtual void CopyStructure(vtkGraph *g);
444 
447  virtual bool CheckedShallowCopy(vtkGraph *g);
448 
451  virtual bool CheckedDeepCopy(vtkGraph *g);
452 
454  virtual void Squeeze();
455 
456  //BTX
458 
460  static vtkGraph *GetData(vtkInformationVector *v, int i=0);
461  //ETX
463 
468  void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
469 
472  bool IsSameStructure(vtkGraph *other);
473 
475 
481  vtkIdType GetSourceVertex(vtkIdType e);
482  vtkIdType GetTargetVertex(vtkIdType e);
484 
485  //BTX
487 
490  void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
491  void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
492  //ETX
494 
496  vtkIdType GetNumberOfEdgePoints(vtkIdType e);
497 
499  double* GetEdgePoint(vtkIdType e, vtkIdType i);
500 
502  void ClearEdgePoints(vtkIdType e);
503 
505 
507  void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
508  void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
509  { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
511 
513 
515  void AddEdgePoint(vtkIdType e, double x[3]);
516  void AddEdgePoint(vtkIdType e, double x, double y, double z)
517  { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
519 
521 
523  void ShallowCopyEdgePoints(vtkGraph* g);
524  void DeepCopyEdgePoints(vtkGraph* g);
526 
530  vtkGraphInternals *GetGraphInternals(bool modifying);
531 
534  void GetInducedEdges(vtkIdTypeArray* verts, vtkIdTypeArray* edges);
535 
541 
544  virtual vtkIdType GetNumberOfElements(int type);
545 
547  void Dump();
548 
555  vtkIdType GetEdgeId(vtkIdType a, vtkIdType b);
556 
558  bool ToDirectedGraph(vtkDirectedGraph* g);
559 
561  bool ToUndirectedGraph(vtkUndirectedGraph* g);
562 
563 protected:
564  //BTX
565  vtkGraph();
566  ~vtkGraph();
567 
569 
574  void AddVertexInternal(vtkVariantArray *propertyArr = 0,
575  vtkIdType *vertex = 0);
577 
582  void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
583 
585 
589  void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
590  vtkVariantArray *propertyArr, vtkEdgeType *edge);
591  void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
592  vtkVariantArray *propertyArr, vtkEdgeType *edge);
593  void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
594  vtkVariantArray *propertyArr, vtkEdgeType *edge);
595  void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
596  bool directed, vtkVariantArray *propertyArr,
597  vtkEdgeType *edge);
599 
602  void RemoveVertexInternal(vtkIdType v, bool directed);
603 
606  void RemoveEdgeInternal(vtkIdType e, bool directed);
607 
610  void RemoveVerticesInternal(vtkIdTypeArray* arr, bool directed);
611 
613 
614  void RemoveEdgesInternal(vtkIdTypeArray* arr, bool directed);
615  //ETX
617 
620  virtual bool IsStructureValid(vtkGraph *g) = 0;
621 
623  virtual void CopyInternal(vtkGraph *g, bool deep);
624 
627 
630 
632  void SetInternals(vtkGraphInternals* internals);
633 
635  vtkGraphEdgePoints *EdgePoints;
636 
638  void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
639 
642  void ForceOwnership();
643 
645 
646  virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
647  virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
649 
651  void BuildEdgeList();
652 
653  //BTX
655 
657  friend class vtkEdgeListIterator;
658  friend class vtkInEdgeIterator;
659  friend class vtkOutEdgeIterator;
663  //ETX
665 
667 
671 
673  double Bounds[6];
674 
677 
679 
681  static double DefaultPoint[3];
683 
685 
686  vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
687  virtual void SetEdgeList(vtkIdTypeArray* list);
689  //ETX
690 private:
691  vtkGraph(const vtkGraph&); // Not implemented.
692  void operator=(const vtkGraph&); // Not implemented.
693 };
695 
696 //BTX
699 VTKCOMMONDATAMODEL_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
700 //ETX
701 
702 #endif
virtual int GetDataObjectType()
Definition: vtkGraph.h:301
helper for the vtkGraph class that allows the graph to be distributed across multiple memory spaces...
static vtkDataObject * GetData(vtkInformation *info)
vtkDataSetAttributes * VertexData
Definition: vtkGraph.h:668
vtkDataSetAttributes * EdgeData
Definition: vtkGraph.h:669
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Forward declaration required for Boost serialization.
An array holding vtkVariants.
vtkIdTypeArray * EdgeList
Definition: vtkGraph.h:688
vtksys_stl::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
Store vtkAlgorithm input/output information.
vtksys_stl::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
Iterates through adjacent vertices in a graph.
bool VTKCOMMONDATAMODEL_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2)
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Iterates through all edges in a graph.
unsigned long int GetMTime()
An undirected graph.
Representation of a single graph edge.
Definition: vtkGraphEdge.h:38
vtkEdgeBase(vtkIdType id)
Definition: vtkGraph.h:253
virtual void Initialize()
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkDistributedGraphHelper * DistributedHelper
Definition: vtkGraph.h:629
vtkTimeStamp ComputeTime
Definition: vtkGraph.h:676
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
A directed graph.
Base class for graph data types.
Definition: vtkGraph.h:288
bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2)
vtkIdType Source
Definition: vtkGraph.h:283
a simple class to control print indentation
Definition: vtkIndent.h:38
VTKCOMMONDATAMODEL_EXPORT ostream & operator<<(ostream &out, vtkEdgeBase e)
vtkGraphEdgePoints * EdgePoints
Definition: vtkGraph.h:635
void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
Definition: vtkGraph.h:508
Iterates through all incoming edges to a vertex.
Internal representation of vtkGraph.
vtkIdType Id
Definition: vtkGraph.h:255
represent and manipulate attribute data in a dataset
void PrintSelf(ostream &os, vtkIndent indent)
vtkIdType Target
Definition: vtkGraph.h:264
virtual vtkIdType GetNumberOfElements(int type)
vtkPoints * Points
Definition: vtkGraph.h:680
object to represent cell connectivity
Definition: vtkCellArray.h:49
vtkIdType Source
Definition: vtkGraph.h:273
Iterates all vertices in a graph.
vtkOutEdgeType(vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:261
Store zero or more vtkInformation instances.
vtkGraphInternals * Internals
Definition: vtkGraph.h:626
Iterates through all outgoing edges from a vertex.
general representation of visualization data
Definition: vtkDataObject.h:64
vtkInEdgeType(vtkIdType s, vtkIdType id)
Definition: vtkGraph.h:270
virtual void DeepCopy(vtkDataObject *src)
vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:279
vtkIdType Target
Definition: vtkGraph.h:284
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:38
void AddEdgePoint(vtkIdType e, double x, double y, double z)
Definition: vtkGraph.h:516
#define VTK_GRAPH
Definition: vtkType.h:86
virtual void ShallowCopy(vtkDataObject *src)
represent and manipulate fields of data
Definition: vtkFieldData.h:55