00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00042 #ifndef __vtkPKdTree_h
00043 #define __vtkPKdTree_h
00044
00045 #include "vtkKdTree.h"
00046
00047 class vtkMultiProcessController;
00048 class vtkCommunicator;
00049 class vtkSubGroup;
00050 class vtkIntArray;
00051 class vtkKdNode;
00052
00053 class VTK_PARALLEL_EXPORT vtkPKdTree : public vtkKdTree
00054 {
00055 public:
00056 vtkTypeMacro(vtkPKdTree, vtkKdTree);
00057
00058
00059 void PrintSelf(ostream& os, vtkIndent indent);
00060 void PrintTiming(ostream& os, vtkIndent indent);
00061 void PrintTables(ostream& os, vtkIndent indent);
00062
00063 static vtkPKdTree *New();
00064
00068 void BuildLocator();
00069
00073 vtkIdType GetTotalNumberOfCells(){return this->TotalNumCells;}
00074
00080 int CreateProcessCellCountData();
00081
00087 int CreateGlobalDataArrayBounds();
00088
00090
00091 void SetController(vtkMultiProcessController *c);
00092 vtkGetObjectMacro(Controller, vtkMultiProcessController);
00094
00096
00103 vtkGetMacro(RegionAssignment, int);
00105
00106 static const int NoRegionAssignment;
00107 static const int ContiguousAssignment;
00108 static const int UserDefinedAssignment;
00109 static const int RoundRobinAssignment;
00110
00114 int AssignRegions(int *map, int numRegions);
00115
00119 int AssignRegionsRoundRobin();
00120
00126 int AssignRegionsContiguous();
00127
00129
00131 const int* GetRegionAssignmentMap()
00132 { return this->RegionAssignmentMap; }
00134
00136
00137 vtkGetMacro(RegionAssignmentMapLength, int);
00139
00143 int GetRegionAssignmentList(int procId, vtkIntArray *list);
00144
00146
00151 void GetAllProcessesBorderingOnPoint(float x, float y, float z,
00152 vtkIntArray *list);
00154
00156 int GetProcessAssignedToRegion(int regionId);
00157
00159 int HasData(int processId, int regionId);
00160
00163 int GetProcessCellCountForRegion(int processId, int regionId);
00164
00167 int GetTotalProcessesInRegion(int regionId);
00168
00171 int GetProcessListForRegion(int regionId, vtkIntArray *processes);
00172
00177 int GetProcessesCellCountForRegion(int regionId, int *count, int len);
00178
00181 int GetTotalRegionsForProcess(int processId);
00182
00185 int GetRegionListForProcess(int processId, vtkIntArray *regions);
00186
00191 int GetRegionsCellCountForProcess(int ProcessId, int *count, int len);
00192
00194
00211 vtkIdType GetCellListsForProcessRegions(int ProcessId, int set,
00212 vtkIdList *inRegionCells, vtkIdList *onBoundaryCells);
00213 vtkIdType GetCellListsForProcessRegions(int ProcessId, vtkDataSet *set,
00214 vtkIdList *inRegionCells, vtkIdList *onBoundaryCells);
00215 vtkIdType GetCellListsForProcessRegions(int ProcessId,
00216 vtkIdList *inRegionCells,
00217 vtkIdList *onBoundaryCells);
00219
00221
00224 VTK_LEGACY(int DepthOrderAllProcesses(double *directionOfProjection,
00225 vtkIntArray *orderedList));
00227
00229
00234 int ViewOrderAllProcessesInDirection(const double directionOfProjection[3],
00235 vtkIntArray *orderedList);
00237
00239
00244 int ViewOrderAllProcessesFromPosition(const double cameraPosition[3],
00245 vtkIntArray *orderedList);
00247
00253 int GetCellArrayGlobalRange(const char *name, float range[2]);
00254 int GetPointArrayGlobalRange(const char *name, float range[2]);
00255 int GetCellArrayGlobalRange(const char *name, double range[2]);
00256 int GetPointArrayGlobalRange(const char *name, double range[2]);
00257
00258 int GetCellArrayGlobalRange(int arrayIndex, double range[2]);
00259 int GetPointArrayGlobalRange(int arrayIndex, double range[2]);
00260 int GetCellArrayGlobalRange(int arrayIndex, float range[2]);
00261 int GetPointArrayGlobalRange(int arrayIndex, float range[2]);
00262
00263 protected:
00264
00265 vtkPKdTree();
00266 ~vtkPKdTree();
00267
00268 void SingleProcessBuildLocator();
00269 int MultiProcessBuildLocator(double *bounds);
00270
00271 private:
00272
00273 int RegionAssignment;
00274
00275 vtkMultiProcessController *Controller;
00276
00277 vtkSubGroup *SubGroup;
00278
00279 static char *StrDupWithNew(const char *s);
00280
00281 int NumProcesses;
00282 int MyId;
00283
00284
00285
00286
00287 int *RegionAssignmentMap;
00288 int RegionAssignmentMapLength;
00289 int **ProcessAssignmentMap;
00290 int *NumRegionsAssigned;
00291
00292 int UpdateRegionAssignment();
00293
00294
00295
00296
00297 char *DataLocationMap;
00298
00299 int *NumProcessesInRegion;
00300 int **ProcessList;
00301
00302 int *NumRegionsInProcess;
00303 int **RegionList;
00304
00305 vtkIdType **CellCountList;
00306
00307 double *CellDataMin;
00308 double *CellDataMax;
00309 double *PointDataMin;
00310 double *PointDataMax;
00311 char **CellDataName;
00312 char **PointDataName;
00313 int NumCellArrays;
00314 int NumPointArrays;
00315
00316
00317
00318 int BuildGlobalIndexLists(vtkIdType ncells);
00319
00320 vtkIdType *StartVal;
00321 vtkIdType *EndVal;
00322 vtkIdType *NumCells;
00323 vtkIdType TotalNumCells;
00324
00325
00326
00327 int WhoHas(int pos);
00328 int _whoHas(int L, int R, int pos);
00329 float *GetLocalVal(int pos);
00330 float *GetLocalValNext(int pos);
00331 void SetLocalVal(int pos, float *val);
00332 void ExchangeVals(int pos1, int pos2);
00333 void ExchangeLocalVals(int pos1, int pos2);
00334
00335 float *PtArray;
00336 float *PtArray2;
00337 float *CurrentPtArray;
00338 float *NextPtArray;
00339 int PtArraySize;
00340
00341 int *SelectBuffer;
00342
00343
00344
00345 int AllCheckForFailure(int rc, const char *where, const char *how);
00346 void AllCheckParameters();
00347 double *VolumeBounds();
00348 int DivideRegion(vtkKdNode *kd, int L, int level, int tag);
00349 int BreadthFirstDivide(double *bounds);
00350 void enQueueNode(vtkKdNode *kd, int L, int level, int tag);
00351
00352 int Select(int dim, int L, int R);
00353 void _select(int L, int R, int K, int dim);
00354 void DoTransfer(int from, int to, int fromIndex, int toIndex, int count);
00355
00356 int *PartitionAboutMyValue(int L, int R, int K, int dim);
00357 int *PartitionAboutOtherValue(int L, int R, float T, int dim);
00358 int *PartitionSubArray(int L, int R, int K, int dim, int p1, int p2);
00359
00360 int CompleteTree();
00361 #ifdef YIELDS_INCONSISTENT_REGION_BOUNDARIES
00362 void RetrieveData(vtkKdNode *kd, int *buf);
00363 #else
00364 void ReduceData(vtkKdNode *kd, int *sources);
00365 void BroadcastData(vtkKdNode *kd);
00366 #endif
00367
00368 float *DataBounds(int L, int K, int R);
00369 void GetLocalMinMax(int L, int R, int me, float *min, float *max);
00370
00371 static int FillOutTree(vtkKdNode *kd, int level);
00372 static int ComputeDepth(vtkKdNode *kd);
00373 static void PackData(vtkKdNode *kd, double *data);
00374 static void UnpackData(vtkKdNode *kd, double *data);
00375 static void CheckFixRegionBoundaries(vtkKdNode *tree);
00376
00377
00378
00379 int AllocateDoubleBuffer();
00380 void FreeDoubleBuffer();
00381 void SwitchDoubleBuffer();
00382 int AllocateSelectBuffer();
00383 void FreeSelectBuffer();
00384
00385 void InitializeGlobalIndexLists();
00386 int AllocateAndZeroGlobalIndexLists();
00387 void FreeGlobalIndexLists();
00388 void InitializeRegionAssignmentLists();
00389 int AllocateAndZeroRegionAssignmentLists();
00390 void FreeRegionAssignmentLists();
00391 void InitializeProcessDataLists();
00392 int AllocateAndZeroProcessDataLists();
00393 void FreeProcessDataLists();
00394 void InitializeFieldArrayMinMax();
00395 int AllocateAndZeroFieldArrayMinMax();
00396 void FreeFieldArrayMinMax();
00397
00398 void ReleaseTables();
00399
00400
00401
00402 void AddProcessRegions(int procId, vtkKdNode *kd);
00403 void BuildRegionListsForProcesses();
00404
00405
00406
00407 int *CollectLocalRegionProcessData();
00408 int BuildRegionProcessTables();
00409 int BuildFieldArrayMinMax();
00410 void AddEntry(int *list, int len, int id);
00411 #ifdef VTK_USE_64BIT_IDS
00412 void AddEntry(vtkIdType *list, int len, vtkIdType id);
00413 #endif
00414 static int BinarySearch(vtkIdType *list, int len, vtkIdType which);
00415
00416 static int FindNextLocalArrayIndex(const char *n, const char **names, int len, int start=0);
00417
00418 vtkPKdTree(const vtkPKdTree&);
00419 void operator=(const vtkPKdTree&);
00420 };
00421
00422 #endif