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

Method DetectOverlappingCells

Filters/ParallelDIY2/vtkOverlappingCellsDetector.cxx:687–826  ·  view source on GitHub ↗

---------------------------------------------------------------------------- Main collision detection algorithm.

Source from the content-addressed store, hash-verified

685//----------------------------------------------------------------------------
686// Main collision detection algorithm.
687bool vtkOverlappingCellsDetector::DetectOverlappingCells(vtkDataSet* queryCellDataSet,
688 vtkPointSet* queryPointCloud, const std::vector<vtkBoundingBox>& queryCellBoundingBoxes,
689 vtkDataSet* cellDataSet, vtkPointSet* pointCloud,
690 const std::vector<vtkBoundingBox>& cellBoundingBoxes,
691 std::unordered_map<vtkIdType, std::set<vtkIdType>>& collisionListMap, bool updateProgress)
692{
693 assert(cellDataSet->GetNumberOfCells() == pointCloud->GetNumberOfPoints() &&
694 static_cast<vtkIdType>(cellBoundingBoxes.size()) == pointCloud->GetNumberOfPoints());
695 assert(queryCellDataSet->GetNumberOfCells() == queryPointCloud->GetNumberOfPoints() &&
696 static_cast<vtkIdType>(queryCellBoundingBoxes.size()) == queryPointCloud->GetNumberOfPoints());
697
698 vtkAbstractPointLocator* locator = pointCloud->GetPointLocator();
699 if (!locator)
700 {
701 pointCloud->BuildPointLocator();
702 locator = pointCloud->GetPointLocator();
703 }
704
705 vtkDataArray* querySphereRadiusArray =
706 queryPointCloud->GetPointData()->GetArray(SPHERE_RADIUS_ARRAY_NAME);
707
708 vtkIdType querySize = queryPointCloud->GetNumberOfPoints();
709 vtkIdType twentieth = querySize / 20 + 1;
710 double decimal = 0.0;
711
712 vtkNew<vtkIdTypeArray> queryNumberOfOverlapsPerCellsArray;
713 queryNumberOfOverlapsPerCellsArray->SetNumberOfComponents(1);
714 queryNumberOfOverlapsPerCellsArray->SetNumberOfTuples(querySize);
715 queryNumberOfOverlapsPerCellsArray->SetName(this->GetNumberOfOverlapsPerCellArrayName());
716 queryNumberOfOverlapsPerCellsArray->Fill(0.0);
717
718 // Handling case where both input data sets point to the same address.
719 vtkIdTypeArray* numberOfCollisionPerCellsArray = queryCellDataSet != cellDataSet
720 ? vtkArrayDownCast<vtkIdTypeArray>(
721 cellDataSet->GetCellData()->GetArray(this->GetNumberOfOverlapsPerCellArrayName()))
722 : queryNumberOfOverlapsPerCellsArray;
723
724 vtkNew<vtkIdList> neighborIds;
725
726 // We want to discard ghost cells, so we have to acknowledge them.
727 vtkUnsignedCharArray* queryCellGhostArray = queryCellDataSet->GetCellGhostArray();
728 vtkUnsignedCharArray* cellGhostArray = cellDataSet->GetCellGhostArray();
729
730 // local cell bank to avoid calling ::New() too many times.
731 std::map<int, vtkSmartPointer<vtkCell>> cellBank, neighborCellBank;
732 for (vtkIdType id = 0; id < querySize; ++id)
733 {
734 if (updateProgress)
735 {
736 // Update progress
737 if (!(id % twentieth))
738 {
739 decimal += 0.05;
740 this->UpdateProgress(decimal);
741 }
742 }
743 if (queryCellGhostArray && queryCellGhostArray->GetValue(id))
744 {

Callers 1

Calls 15

TakeFunction · 0.85
ComputeEpsilonFunction · 0.85
BuildPointLocatorMethod · 0.80
GetCellGhostArrayMethod · 0.80
GetTuple1Method · 0.80
IntersectWithCellMethod · 0.80
assertFunction · 0.50
sqrtFunction · 0.50
maxFunction · 0.50
GetNumberOfCellsMethod · 0.45
GetNumberOfPointsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected