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
223class vtkCellArray;
226class vtkDirectedGraph;
227class vtkGraphEdge;
228class vtkGraphEdgePoints;
231class vtkIdTypeArray;
234class vtkPoints;
237class vtkVariant;
238class vtkVariantArray;
239
240// Forward declare some boost stuff even if boost wrappers
241// are turned off.
242namespace 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
287class VTKCOMMONDATAMODEL_EXPORT vtkGraph : public vtkDataObject
288{
289public:
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
599
606
612
620
625
629 void Dump();
630
640
645
650
651protected:
652
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
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
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
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
817private:
818 vtkGraph(const vtkGraph&) VTK_DELETE_FUNCTION;
819 void operator=(const vtkGraph&) VTK_DELETE_FUNCTION;
820};
821
822bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2);
823bool VTKCOMMONDATAMODEL_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2);
824VTKCOMMONDATAMODEL_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
825
826#endif
void GetPoint(const int i, const int j, const int k, double pnt[3])
Iterates through adjacent vertices in a graph.
object to represent cell connectivity
Definition: vtkCellArray.h:51
general representation of visualization data
Definition: vtkDataObject.h:65
represent and manipulate attribute data in a dataset
A directed graph.
helper for the vtkGraph class that allows the graph to be distributed across multiple memory spaces.
Iterates through all edges in a graph.
represent and manipulate fields of data
Definition: vtkFieldData.h:57
Representation of a single graph edge.
Definition: vtkGraphEdge.h:40
Internal representation of vtkGraph.
Base class for graph data types.
Definition: vtkGraph.h:288
void AddEdgePoint(vtkIdType e, double x, double y, double z)
Definition: vtkGraph.h:588
void AddEdgePoint(vtkIdType e, double x[3])
Adds a point to the end of the list of edge points for a certain edge.
~vtkGraph() override
void Initialize() override
Initialize to an empty graph.
void GetInducedEdges(vtkIdTypeArray *verts, vtkIdTypeArray *edges)
Fills a list of edge indices with the edges contained in the induced subgraph formed by the vertices ...
bool ToUndirectedGraph(vtkUndirectedGraph *g)
Convert the graph to an undirected graph.
vtkIdType GetEdgeId(vtkIdType a, vtkIdType b)
Returns the Id of the edge between vertex a and vertex b.
bool ToDirectedGraph(vtkDirectedGraph *g)
Convert the graph to a directed graph.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DeepCopyEdgePoints(vtkGraph *g)
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the attributes of the data object as a vtkFieldData.
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkGraph.h:304
vtkGraphInternals * GetGraphInternals(bool modifying)
Returns the internal representation of the graph.
void ShallowCopyEdgePoints(vtkGraph *g)
Copy the internal edge point data from another graph into this graph.
void Dump()
Dump the contents of the graph to standard output.
vtkIdType GetNumberOfElements(int type) override
Get the number of elements for a specific attribute type (VERTEX, EDGE, etc.).
dynamic, self-adjusting array of vtkIdType
Iterates through all incoming edges to a vertex.
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Iterates through all outgoing edges from a vertex.
represent and manipulate 3D points
Definition: vtkPoints.h:40
record modification and/or execution time
Definition: vtkTimeStamp.h:36
An undirected graph.
An array holding vtkVariants.
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
Iterates all vertices in a graph.
Forward declaration required for Boost serialization.
@ points
Definition: vtkX3D.h:446
@ info
Definition: vtkX3D.h:376
@ type
Definition: vtkX3D.h:516
@ index
Definition: vtkX3D.h:246
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkIdType Id
Definition: vtkGraph.h:255
vtkEdgeBase(vtkIdType id)
Definition: vtkGraph.h:253
vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:279
vtkIdType Target
Definition: vtkGraph.h:284
vtkIdType Source
Definition: vtkGraph.h:283
vtkIdType Source
Definition: vtkGraph.h:273
vtkInEdgeType(vtkIdType s, vtkIdType id)
Definition: vtkGraph.h:270
vtkIdType Target
Definition: vtkGraph.h:264
vtkOutEdgeType(vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:261
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
std::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:287
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
#define VTK_GRAPH
Definition: vtkType.h:107