------------------------------------------------------------------------------
| 56 | |
| 57 | //------------------------------------------------------------------------------ |
| 58 | void vtkExtentRCBPartitioner::Partition() |
| 59 | { |
| 60 | // Short-circuit here since the given global extent has already been |
| 61 | // partitioned |
| 62 | if (this->ExtentIsPartitioned) |
| 63 | { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | // STEP 0: Get the data description according to the given global extent |
| 68 | this->AcquireDataDescription(); |
| 69 | if (this->DataDescription == vtkStructuredData::VTK_STRUCTURED_EMPTY || |
| 70 | this->DataDescription == vtkStructuredData::VTK_STRUCTURED_SINGLE_POINT) |
| 71 | { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | // STEP 1: Insert the global extent to the workQueue |
| 76 | vtkPriorityQueue* wrkQueue = vtkPriorityQueue::New(); |
| 77 | assert("pre: work queue is nullptr" && (wrkQueue != nullptr)); |
| 78 | |
| 79 | this->AddExtent(this->GlobalExtent); |
| 80 | wrkQueue->Insert(this->GetNumberOfNodes(this->GlobalExtent), 0); |
| 81 | |
| 82 | int ex[6]; // temporary buffer to store the current extent |
| 83 | int s1[6]; // temporary buffer to store the sub-extent s1 |
| 84 | int s2[6]; // temporary buffer to store the sub-extent s2 |
| 85 | |
| 86 | // STEP 2: Loop until number of partitions is attained |
| 87 | while (this->NumExtents < this->NumberOfPartitions) |
| 88 | { |
| 89 | vtkIdType extentIdx = wrkQueue->Pop(wrkQueue->GetNumberOfItems() - 1); |
| 90 | this->GetExtent(extentIdx, ex); |
| 91 | int ldim = this->GetLongestDimension(ex); |
| 92 | |
| 93 | this->SplitExtent(ex, s1, s2, ldim); |
| 94 | this->ReplaceExtent(extentIdx, s1); |
| 95 | this->AddExtent(s2); |
| 96 | |
| 97 | wrkQueue->Insert(this->GetNumberOfNodes(s1), extentIdx); |
| 98 | wrkQueue->Insert(this->GetNumberOfNodes(s2), this->NumExtents - 1); |
| 99 | } |
| 100 | |
| 101 | // STEP 3: Clear priority data-structures |
| 102 | wrkQueue->Delete(); |
| 103 | |
| 104 | // STEP 4: Loop through all the extents and add ghost layers |
| 105 | if (this->NumberOfGhostLayers > 0) |
| 106 | { |
| 107 | int ext[6]; |
| 108 | for (int i = 0; i < this->NumExtents; ++i) |
| 109 | { |
| 110 | this->GetExtent(i, ext); |
| 111 | this->ExtendGhostLayers(ext); |
| 112 | this->ReplaceExtent(i, ext); |
| 113 | } // END for all extents |
| 114 | } |
| 115 |
no test coverage detected