VTK
dox/Common/DataModel/vtkDistributedGraphHelper.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDistributedGraphHelper.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*
00016  * Copyright (C) 2008 The Trustees of Indiana University.
00017  * Use, modification and distribution is subject to the Boost Software
00018  * License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)
00019  */
00020 
00055 #ifndef __vtkDistributedGraphHelper_h
00056 #define __vtkDistributedGraphHelper_h
00057 
00058 #include "vtkCommonDataModelModule.h" // For export macro
00059 #include "vtkObject.h"
00060 
00061 class vtkDistributedGraphHelperInternals;
00062 struct vtkEdgeType;
00063 class vtkGraph;
00064 class vtkVariant;
00065 class vtkVariantArray;
00066 class vtkInformationIntegerKey;
00067 
00068 // .NAME vtkVertexPedigreeIdDistributionFunction - The type of a
00069 // function used to determine how to distribute vertex pedigree IDs
00070 // across processors in a vtkGraph. The pedigree ID distribution
00071 // function takes the pedigree ID of the vertex and a user-supplied
00072 // void pointer and returns a hash value V. A vertex with that
00073 // pedigree ID will reside on processor V % P, where P is the number
00074 // of processors. This type is used in conjunction with the
00075 // vtkDistributedGraphHelper class.
00076 typedef vtkIdType (*vtkVertexPedigreeIdDistribution)
00077           (const vtkVariant& pedigreeId, void* userData);
00078 
00079 class VTKCOMMONDATAMODEL_EXPORT vtkDistributedGraphHelper : public vtkObject
00080 {
00081  public:
00082   vtkTypeMacro(vtkDistributedGraphHelper,vtkObject);
00083   void PrintSelf(ostream& os, vtkIndent indent);
00084 
00086   vtkIdType GetVertexOwner(vtkIdType v) const;
00087 
00090   vtkIdType GetVertexIndex(vtkIdType v) const;
00091 
00094   vtkIdType GetEdgeOwner(vtkIdType e_id) const;
00095 
00098   vtkIdType GetEdgeIndex(vtkIdType e_id) const;
00099 
00102   vtkIdType MakeDistributedId(int owner, vtkIdType local);
00103 
00104   //BTX
00106 
00111   void SetVertexPedigreeIdDistribution(vtkVertexPedigreeIdDistribution Func,
00112                                        void *userData);
00113   //ETX
00115 
00117   vtkIdType GetVertexOwnerByPedigreeId(const vtkVariant& pedigreeId);
00118 
00125   virtual void Synchronize() = 0;
00126 
00129   virtual vtkDistributedGraphHelper *Clone() = 0;
00130 
00132 
00137   static vtkInformationIntegerKey * DISTRIBUTEDVERTEXIDS();
00138   static vtkInformationIntegerKey * DISTRIBUTEDEDGEIDS();
00140 
00141  protected:
00142   vtkDistributedGraphHelper();
00143   virtual ~vtkDistributedGraphHelper();
00144 
00146 
00151   virtual void AddVertexInternal(vtkVariantArray *propertyArr,
00152                          vtkIdType *vertex) = 0;
00154 
00157   virtual void AddVertexInternal(const vtkVariant& pedigreeId, vtkIdType *vertex) = 0;
00158 
00160 
00164   virtual void AddEdgeInternal(vtkIdType u, vtkIdType v, bool directed,
00165                                vtkVariantArray *propertyArr,
00166                                vtkEdgeType *edge) = 0;
00168 
00170 
00176   virtual void AddEdgeInternal(const vtkVariant& uPedigreeId, vtkIdType v,
00177                                bool directed, vtkVariantArray *propertyArr,
00178                                vtkEdgeType *edge) = 0;
00180 
00182 
00188   virtual void AddEdgeInternal(vtkIdType u, const vtkVariant& vPedigreeId,
00189                                bool directed, vtkVariantArray *propertyArr,
00190                                vtkEdgeType *edge) = 0;
00192 
00194 
00201   virtual void AddEdgeInternal(const vtkVariant& uPedigreeId,
00202                                const vtkVariant& vPedigreeId,
00203                                bool directed, vtkVariantArray *propertyArr,
00204                                vtkEdgeType *edge) = 0;
00206 
00210   virtual vtkIdType FindVertex(const vtkVariant& pedigreeId) = 0;
00211 
00213 
00216   virtual void
00217   FindEdgeSourceAndTarget(vtkIdType id,
00218                           vtkIdType *source, vtkIdType *target) = 0;
00220 
00223   virtual void AttachToGraph(vtkGraph *graph);
00224 
00226   vtkGraph *Graph;
00227 
00228   //BTX
00230   vtkVertexPedigreeIdDistribution VertexDistribution;
00231 
00234   void *VertexDistributionUserData;
00235 
00237   vtkIdType signBitMask;
00238 
00240   vtkIdType highBitShiftMask;
00241 
00243   int procBits;
00244 
00246 
00247   int indexBits;
00248   //ETX
00250 
00251  private:
00252   vtkDistributedGraphHelper(const vtkDistributedGraphHelper&); // Not implemented
00253   void operator=(const vtkDistributedGraphHelper&); // Not implemented
00254 
00255   //BTX
00256   friend class vtkGraph;
00257   //ETX
00258 };
00259 
00260 #endif // __vtkDistributedGraphHelper_h