MCPcopy Create free account
hub / github.com/Kitware/VTK / Reduce

Method Reduce

Filters/General/vtkTableBasedClipDataSet.cxx:735–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

733 }
734
735 void Reduce()
736 {
737 // trim batches with 0 cells in-place
738 this->CellBatches.TrimBatches(
739 [](const TableBasedCellBatch& batch) { return batch.Data.CellsOffset == 0; });
740
741 // assign beginCellsOffset/BeginCellsConnectivity/BeginCentroid for each batch
742 const auto globalSum = this->CellBatches.BuildOffsetsAndGetGlobalSum();
743 this->NumberOfOutputCells = globalSum.CellsOffset;
744 this->ConnectivitySize = globalSum.CellsConnectivityOffset;
745 this->NumberOfCentroids = globalSum.CentroidsOffset;
746
747 // store TLEdges in vector
748 using TLEdgesIterator = decltype(this->TLEdges.begin());
749 std::vector<TLEdgesIterator> tlEdgesVector;
750 for (auto iter = this->TLEdges.begin(); iter != this->TLEdges.end(); ++iter)
751 {
752 tlEdgesVector.push_back(iter);
753 }
754 // compute total size of edges
755 size_t totalSizeOfEdges = 0;
756 for (auto& tlEdges : tlEdgesVector)
757 {
758 totalSizeOfEdges += tlEdges->size();
759 }
760
761 // compute begin indices
762 std::vector<size_t> beginIndices(this->TLEdges.size(), 0);
763 for (size_t i = 1; i < tlEdgesVector.size(); ++i)
764 {
765 beginIndices[i] = beginIndices[i - 1] + tlEdgesVector[i - 1]->size();
766 }
767
768 // merge thread local edges
769 this->Edges.resize(totalSizeOfEdges);
770 vtkSMPTools::For(0, static_cast<vtkIdType>(tlEdgesVector.size()),
771 [&](vtkIdType begin, vtkIdType end)
772 {
773 for (vtkIdType threadId = begin; threadId < end; ++threadId)
774 {
775 auto& edges = *tlEdgesVector[threadId];
776 std::copy(edges.begin(), edges.end(), this->Edges.begin() + beginIndices[threadId]);
777 }
778 });
779
780 // merge not supported cell types
781 std::unordered_set<int> unsupportedCellTypes;
782 for (auto& tlUnsupportedCellTypes : this->TLUnsupportedCellTypes)
783 {
784 unsupportedCellTypes.insert(tlUnsupportedCellTypes.begin(), tlUnsupportedCellTypes.end());
785 }
786 this->UnsupportedCells.clear();
787 // if there are any not supported cell types, find the ids of the cells
788 if (!unsupportedCellTypes.empty())
789 {
790 // this loop is done sequentially to avoid sorting the ids later on
791 // when passed to vtkExtractCells
792 int cellType;

Callers

nothing calls this directly

Calls 12

ForFunction · 0.50
copyFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
GetCellTypeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected