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 -------------------------------------------------------------------------*/
216 #ifndef vtkGraph_h
217 #define vtkGraph_h
218 
219 #include "vtkCommonDataModelModule.h" // For export macro
220 #include "vtkDataObject.h"
221 
223 class vtkCellArray;
224 class vtkEdgeListIterator;
226 class vtkDirectedGraph;
227 class vtkGraphEdge;
228 class vtkGraphEdgePoints;
230 class vtkGraphInternals;
231 class vtkIdTypeArray;
232 class vtkInEdgeIterator;
233 class vtkOutEdgeIterator;
234 class vtkPoints;
235 class vtkUndirectedGraph;
237 class vtkVariant;
238 class vtkVariantArray;
239 
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 
287 class VTKCOMMONDATAMODEL_EXPORT vtkGraph : public vtkDataObject
288 {
289 public:
290  vtkTypeMacro(vtkGraph, vtkDataObject);
291  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
292 
294 
297  vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
298  vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
300 
304  int GetDataObjectType() VTK_OVERRIDE {return VTK_GRAPH;}
305 
309  void Initialize() VTK_OVERRIDE;
310 
312 
318  double *GetPoint(vtkIdType ptId);
319  void GetPoint(vtkIdType ptId, double x[3]);
321 
323 
330  vtkPoints* GetPoints();
331  virtual void SetPoints(vtkPoints *points);
333 
338  void ComputeBounds();
339 
341 
346  double *GetBounds();
347  void GetBounds(double bounds[6]);
349 
353  vtkMTimeType GetMTime() VTK_OVERRIDE;
354 
361  virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
362 
369  virtual vtkIdType GetDegree(vtkIdType v);
370 
376  virtual vtkIdType GetOutDegree(vtkIdType v);
377 
381  virtual vtkOutEdgeType GetOutEdge(vtkIdType v, vtkIdType index);
382 
389  virtual void GetOutEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
390 
397  virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
398 
404  virtual vtkIdType GetInDegree(vtkIdType v);
405 
409  virtual vtkInEdgeType GetInEdge(vtkIdType v, vtkIdType index);
410 
417  virtual void GetInEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
418 
425  virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
426 
433  virtual void GetEdges(vtkEdgeListIterator *it);
434 
439  virtual vtkIdType GetNumberOfEdges();
440 
446  virtual void GetVertices(vtkVertexListIterator *it);
447 
452  virtual vtkIdType GetNumberOfVertices();
453 
459  void SetDistributedGraphHelper(vtkDistributedGraphHelper *helper);
460 
464  vtkDistributedGraphHelper *GetDistributedGraphHelper();
465 
474  vtkIdType FindVertex(const vtkVariant& pedigreeID);
475 
480  void ShallowCopy(vtkDataObject *obj) VTK_OVERRIDE;
481 
486  void DeepCopy(vtkDataObject *obj) VTK_OVERRIDE;
487 
492  virtual void CopyStructure(vtkGraph *g);
493 
499  virtual bool CheckedShallowCopy(vtkGraph *g);
500 
506  virtual bool CheckedDeepCopy(vtkGraph *g);
507 
511  virtual void Squeeze();
512 
514 
517  static vtkGraph *GetData(vtkInformation *info);
518  static vtkGraph *GetData(vtkInformationVector *v, int i=0);
520 
528  void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
529 
534  bool IsSameStructure(vtkGraph *other);
535 
537 
546  vtkIdType GetSourceVertex(vtkIdType e);
547  vtkIdType GetTargetVertex(vtkIdType e);
549 
551 
556  void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
557  void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
559 
563  vtkIdType GetNumberOfEdgePoints(vtkIdType e);
564 
568  double* GetEdgePoint(vtkIdType e, vtkIdType i);
569 
573  void ClearEdgePoints(vtkIdType e);
574 
580  void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
581  void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
582  { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
583 
587  void AddEdgePoint(vtkIdType e, double x[3]);
588  void AddEdgePoint(vtkIdType e, double x, double y, double z)
589  { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
590 
592 
596  void ShallowCopyEdgePoints(vtkGraph* g);
597  void DeepCopyEdgePoints(vtkGraph* g);
599 
605  vtkGraphInternals *GetGraphInternals(bool modifying);
606 
611  void GetInducedEdges(vtkIdTypeArray* verts, vtkIdTypeArray* edges);
612 
619  vtkFieldData* GetAttributesAsFieldData(int type) VTK_OVERRIDE;
620 
624  vtkIdType GetNumberOfElements(int type) VTK_OVERRIDE;
625 
629  void Dump();
630 
639  vtkIdType GetEdgeId(vtkIdType a, vtkIdType b);
640 
644  bool ToDirectedGraph(vtkDirectedGraph* g);
645 
649  bool ToUndirectedGraph(vtkUndirectedGraph* g);
650 
651 protected:
652 
653  vtkGraph();
654  ~vtkGraph() VTK_OVERRIDE;
655 
663  void AddVertexInternal(vtkVariantArray *propertyArr = 0,
664  vtkIdType *vertex = 0);
665 
672  void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
673 
675 
681  void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
682  vtkVariantArray *propertyArr, vtkEdgeType *edge);
683  void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
684  vtkVariantArray *propertyArr, vtkEdgeType *edge);
685  void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
686  vtkVariantArray *propertyArr, vtkEdgeType *edge);
687  void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
688  bool directed, vtkVariantArray *propertyArr,
689  vtkEdgeType *edge);
691 
696  void RemoveVertexInternal(vtkIdType v, bool directed);
697 
702  void RemoveEdgeInternal(vtkIdType e, bool directed);
703 
707  void RemoveVerticesInternal(vtkIdTypeArray* arr, bool directed);
708 
712  void RemoveEdgesInternal(vtkIdTypeArray* arr, bool directed);
713 
718  virtual bool IsStructureValid(vtkGraph *g) = 0;
719 
723  virtual void CopyInternal(vtkGraph *g, bool deep);
724 
728  vtkGraphInternals *Internals;
729 
733  vtkDistributedGraphHelper *DistributedHelper;
734 
738  void SetInternals(vtkGraphInternals* internals);
739 
743  vtkGraphEdgePoints *EdgePoints;
744 
748  void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
749 
754  void ForceOwnership();
755 
757 
760  virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
761  virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
763 
767  void BuildEdgeList();
768 
770 
774  friend class vtkEdgeListIterator;
775  friend class vtkInEdgeIterator;
776  friend class vtkOutEdgeIterator;
777  friend class boost::vtk_edge_iterator;
778  friend class boost::vtk_in_edge_pointer_iterator;
779  friend class boost::vtk_out_edge_pointer_iterator;
781 
783 
786  vtkDataSetAttributes *VertexData;
789 
793  double Bounds[6];
794 
798  vtkTimeStamp ComputeTime;
799 
801 
804  vtkPoints *Points;
805  static double DefaultPoint[3];
807 
809 
812  vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
813  virtual void SetEdgeList(vtkIdTypeArray* list);
814  vtkIdTypeArray *EdgeList;
816 
817 private:
818  vtkGraph(const vtkGraph&) VTK_DELETE_FUNCTION;
819  void operator=(const vtkGraph&) VTK_DELETE_FUNCTION;
820 };
821 
822 bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
823 bool VTKCOMMONDATAMODEL_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
824 VTKCOMMONDATAMODEL_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
825 
826 #endif
helper for the vtkGraph class that allows the graph to be distributed across multiple memory spaces...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Returns the attributes of the data object as a vtkFieldData.
Forward declaration required for Boost serialization.
An array holding vtkVariants.
Store vtkAlgorithm input/output information.
Iterates through adjacent vertices in a graph.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Iterates through all edges in a graph.
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
An undirected graph.
Representation of a single graph edge.
Definition: vtkGraphEdge.h:39
vtkEdgeBase(vtkIdType id)
Definition: vtkGraph.h:253
virtual void Initialize()
Restore data object to initial state,.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
void GetPoint(const int i, const int j, const int k, double pnt[3])
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
A directed graph.
Base class for graph data types.
Definition: vtkGraph.h:287
vtkIdType Source
Definition: vtkGraph.h:283
a simple class to control print indentation
Definition: vtkIndent.h:39
std::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
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
vtkIdType Target
Definition: vtkGraph.h:264
virtual vtkIdType GetNumberOfElements(int type)
Get the number of elements for a specific attribute type (POINT, CELL, etc.).
object to represent cell connectivity
Definition: vtkCellArray.h:50
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.
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkGraph.h:304
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
vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:279
vtkIdType Target
Definition: vtkGraph.h:284
represent and manipulate 3D points
Definition: vtkPoints.h:39
void AddEdgePoint(vtkIdType e, double x, double y, double z)
Definition: vtkGraph.h:588
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
#define VTK_GRAPH
Definition: vtkType.h:107
represent and manipulate fields of data
Definition: vtkFieldData.h:56