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 "vtkDataObject.h"
219 
220 class vtkAdjacentVertexIterator;
221 class vtkCellArray;
222 class vtkEdgeListIterator;
224 class vtkDirectedGraph;
225 class vtkGraphEdge;
226 class vtkGraphEdgePoints;
227 class vtkDistributedGraphHelper;
228 class vtkGraphInternals;
229 class vtkIdTypeArray;
230 class vtkInEdgeIterator;
231 class vtkOutEdgeIterator;
232 class vtkPoints;
233 class vtkUndirectedGraph;
234 class vtkVertexListIterator;
235 class vtkVariant;
236 class vtkVariantArray;
237 
238 //BTX
239 // Forward declare some boost stuff even if boost wrappers
240 // are turned off.
241 namespace boost
242 {
243  class vtk_edge_iterator;
244  class vtk_out_edge_pointer_iterator;
245  class vtk_in_edge_pointer_iterator;
246 }
247 
248 // Edge structures.
250 {
253  Id(id) { }
255 };
256 
258 {
261  vtkEdgeBase(id),
262  Target(t) { }
264 };
265 
267 {
270  vtkEdgeBase(id),
271  Source(s) { }
273 };
274 
276 {
279  vtkEdgeBase(id),
280  Source(s),
281  Target(t) { }
284 };
285 //ETX
286 
288 {
289 public:
290  vtkTypeMacro(vtkGraph, vtkDataObject);
291  void PrintSelf(ostream& os, vtkIndent indent);
292 
294 
295  vtkGetObjectMacro(VertexData, vtkDataSetAttributes);
296  vtkGetObjectMacro(EdgeData, vtkDataSetAttributes);
298 
300  virtual int GetDataObjectType() {return VTK_GRAPH;}
301 
303  virtual void Initialize();
304 
306 
309  double *GetPoint(vtkIdType ptId);
310  void GetPoint(vtkIdType ptId, double x[3]);
312 
314 
318  vtkPoints* GetPoints();
319  virtual void SetPoints(vtkPoints *points);
321 
324  void ComputeBounds();
325 
327 
330  double *GetBounds();
331  void GetBounds(double bounds[6]);
333 
335  unsigned long int GetMTime();
336 
340  virtual void GetOutEdges(vtkIdType v, vtkOutEdgeIterator *it);
341 
345  virtual vtkIdType GetDegree(vtkIdType v);
346 
350  virtual vtkIdType GetOutDegree(vtkIdType v);
351 
352  //BTX
354 
355  virtual vtkOutEdgeType GetOutEdge(vtkIdType v, vtkIdType index);
356  //ETX
358 
363  virtual void GetOutEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
364 
368  virtual void GetInEdges(vtkIdType v, vtkInEdgeIterator *it);
369 
373  virtual vtkIdType GetInDegree(vtkIdType v);
374 
375  //BTX
377 
378  virtual vtkInEdgeType GetInEdge(vtkIdType v, vtkIdType index);
379  //ETX
381 
386  virtual void GetInEdge(vtkIdType v, vtkIdType index, vtkGraphEdge* e);
387 
392  virtual void GetAdjacentVertices(vtkIdType v, vtkAdjacentVertexIterator *it);
393 
397  virtual void GetEdges(vtkEdgeListIterator *it);
398 
401  virtual vtkIdType GetNumberOfEdges();
402 
406  virtual void GetVertices(vtkVertexListIterator *it);
407 
410  virtual vtkIdType GetNumberOfVertices();
411 
412  // BTX
416  void SetDistributedGraphHelper(vtkDistributedGraphHelper *helper);
417 
419 
420  vtkDistributedGraphHelper *GetDistributedGraphHelper();
421  //ETX
423 
430  vtkIdType FindVertex(const vtkVariant& pedigreeID);
431 
434  virtual void ShallowCopy(vtkDataObject *obj);
435 
438  virtual void DeepCopy(vtkDataObject *obj);
439 
442  virtual void CopyStructure(vtkGraph *g);
443 
446  virtual bool CheckedShallowCopy(vtkGraph *g);
447 
450  virtual bool CheckedDeepCopy(vtkGraph *g);
451 
453  virtual void Squeeze();
454 
455  //BTX
457 
458  static vtkGraph *GetData(vtkInformation *info);
459  static vtkGraph *GetData(vtkInformationVector *v, int i=0);
460  //ETX
462 
467  void ReorderOutVertices(vtkIdType v, vtkIdTypeArray *vertices);
468 
471  bool IsSameStructure(vtkGraph *other);
472 
474 
480  vtkIdType GetSourceVertex(vtkIdType e);
481  vtkIdType GetTargetVertex(vtkIdType e);
483 
484  //BTX
486 
489  void SetEdgePoints(vtkIdType e, vtkIdType npts, double* pts);
490  void GetEdgePoints(vtkIdType e, vtkIdType& npts, double*& pts);
491  //ETX
493 
495  vtkIdType GetNumberOfEdgePoints(vtkIdType e);
496 
498  double* GetEdgePoint(vtkIdType e, vtkIdType i);
499 
501  void ClearEdgePoints(vtkIdType e);
502 
504 
506  void SetEdgePoint(vtkIdType e, vtkIdType i, double x[3]);
507  void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
508  { double p[3] = {x, y, z}; this->SetEdgePoint(e, i, p); }
510 
512 
514  void AddEdgePoint(vtkIdType e, double x[3]);
515  void AddEdgePoint(vtkIdType e, double x, double y, double z)
516  { double p[3] = {x, y, z}; this->AddEdgePoint(e, p); }
518 
520 
522  void ShallowCopyEdgePoints(vtkGraph* g);
523  void DeepCopyEdgePoints(vtkGraph* g);
525 
529  vtkGraphInternals *GetGraphInternals(bool modifying);
530 
533  void GetInducedEdges(vtkIdTypeArray* verts, vtkIdTypeArray* edges);
534 
539  virtual vtkFieldData* GetAttributesAsFieldData(int type);
540 
543  virtual vtkIdType GetNumberOfElements(int type);
544 
546  void Dump();
547 
554  vtkIdType GetEdgeId(vtkIdType a, vtkIdType b);
555 
557  bool ToDirectedGraph(vtkDirectedGraph* g);
558 
560  bool ToUndirectedGraph(vtkUndirectedGraph* g);
561 
562 protected:
563  //BTX
564  vtkGraph();
565  ~vtkGraph();
566 
568 
573  void AddVertexInternal(vtkVariantArray *propertyArr = 0,
574  vtkIdType *vertex = 0);
576 
581  void AddVertexInternal(const vtkVariant& pedigree, vtkIdType *vertex);
582 
584 
588  void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
589  vtkVariantArray *propertyArr, vtkEdgeType *edge);
590  void AddEdgeInternal(const vtkVariant& uPedigree, vtkIdType v, bool directed,
591  vtkVariantArray *propertyArr, vtkEdgeType *edge);
592  void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigree, bool directed,
593  vtkVariantArray *propertyArr, vtkEdgeType *edge);
594  void AddEdgeInternal(const vtkVariant& uPedigree, const vtkVariant& vPedigree,
595  bool directed, vtkVariantArray *propertyArr,
596  vtkEdgeType *edge);
598 
601  void RemoveVertexInternal(vtkIdType v, bool directed);
602 
605  void RemoveEdgeInternal(vtkIdType e, bool directed);
606 
609  void RemoveVerticesInternal(vtkIdTypeArray* arr, bool directed);
610 
612 
613  void RemoveEdgesInternal(vtkIdTypeArray* arr, bool directed);
614  //ETX
616 
619  virtual bool IsStructureValid(vtkGraph *g) = 0;
620 
622  virtual void CopyInternal(vtkGraph *g, bool deep);
623 
625  vtkGraphInternals *Internals;
626 
628  vtkDistributedGraphHelper *DistributedHelper;
629 
631  void SetInternals(vtkGraphInternals* internals);
632 
634  vtkGraphEdgePoints *EdgePoints;
635 
637  void SetEdgePoints(vtkGraphEdgePoints* edgePoints);
638 
641  void ForceOwnership();
642 
644 
645  virtual void GetOutEdges(vtkIdType v, const vtkOutEdgeType *& edges, vtkIdType & nedges);
646  virtual void GetInEdges(vtkIdType v, const vtkInEdgeType *& edges, vtkIdType & nedges);
648 
650  void BuildEdgeList();
651 
652  //BTX
654 
655  friend class vtkAdjacentVertexIterator;
656  friend class vtkEdgeListIterator;
657  friend class vtkInEdgeIterator;
658  friend class vtkOutEdgeIterator;
659  friend class boost::vtk_edge_iterator;
660  friend class boost::vtk_in_edge_pointer_iterator;
661  friend class boost::vtk_out_edge_pointer_iterator;
662  //ETX
664 
666 
670 
672  double Bounds[6];
673 
676 
678 
680  static double DefaultPoint[3];
682 
684 
685  vtkGetObjectMacro(EdgeList, vtkIdTypeArray);
686  virtual void SetEdgeList(vtkIdTypeArray* list);
688  //ETX
689 private:
690  vtkGraph(const vtkGraph&); // Not implemented.
691  void operator=(const vtkGraph&); // Not implemented.
692 };
694 
695 //BTX
698 VTK_FILTERING_EXPORT ostream& operator<<(ostream& out, vtkEdgeBase e);
699 //ETX
700 
701 #endif
virtual int GetDataObjectType()
Definition: vtkGraph.h:300
vtkDataSetAttributes * VertexData
Definition: vtkGraph.h:667
vtkDataSetAttributes * EdgeData
Definition: vtkGraph.h:668
An array holding vtkVariants.
vtkIdTypeArray * EdgeList
Definition: vtkGraph.h:687
Store vtkAlgorithm input/output information.
#define VTK_FILTERING_EXPORT
record modification and/or execution time
Definition: vtkTimeStamp.h:33
vtkEdgeBase(vtkIdType id)
Definition: vtkGraph.h:252
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:255
vtkDistributedGraphHelper * DistributedHelper
Definition: vtkGraph.h:628
vtkTimeStamp ComputeTime
Definition: vtkGraph.h:675
A atomic type representing the union of many types.
Definition: vtkVariant.h:72
Base class for graph data types.
Definition: vtkGraph.h:287
vtkIdType Source
Definition: vtkGraph.h:282
bool VTK_FILTERING_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2)
a simple class to control print indentation
Definition: vtkIndent.h:37
vtkGraphEdgePoints * EdgePoints
Definition: vtkGraph.h:634
void SetEdgePoint(vtkIdType e, vtkIdType i, double x, double y, double z)
Definition: vtkGraph.h:507
Iterates through all incoming edges to a vertex.
vtkIdType Id
Definition: vtkGraph.h:254
represent and manipulate attribute data in a dataset
vtkIdType Target
Definition: vtkGraph.h:263
vtkPoints * Points
Definition: vtkGraph.h:679
object to represent cell connectivity
Definition: vtkCellArray.h:48
vtkIdType Source
Definition: vtkGraph.h:272
vtkOutEdgeType(vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:260
Store zero or more vtkInformation instances.
vtkGraphInternals * Internals
Definition: vtkGraph.h:625
Iterates through all outgoing edges from a vertex.
helper class to get VTK data object types as string and instantiate them
vtkInEdgeType(vtkIdType s, vtkIdType id)
Definition: vtkGraph.h:269
VTK_FILTERING_EXPORT ostream & operator<<(ostream &out, vtkEdgeBase e)
vtkEdgeType(vtkIdType s, vtkIdType t, vtkIdType id)
Definition: vtkGraph.h:278
vtkIdType Target
Definition: vtkGraph.h:283
represent and manipulate 3D points
Definition: vtkPoints.h:38
void AddEdgePoint(vtkIdType e, double x, double y, double z)
Definition: vtkGraph.h:515
bool VTK_FILTERING_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2)
#define VTK_GRAPH
Definition: vtkType.h:86
represent and manipulate fields of data
Definition: vtkFieldData.h:58