Commit 0faa45e8 authored by Yohann Bearzi's avatar Yohann Bearzi

Optimization of overlapping cell detector

Bounding sphere are slightly tighter than previously.
They now rely on new API `vtkCell::ComputeBoudingSphere`
parent b90f56fa
...@@ -231,9 +231,7 @@ double vtkCell::ComputeBoundingSphere(double center[3]) const ...@@ -231,9 +231,7 @@ double vtkCell::ComputeBoundingSphere(double center[3]) const
dist2 = 0.0; dist2 = 0.0;
for (vtkIdType id = 0; id < points.size(); ++id) for (vtkIdType id = 0; id < points.size(); ++id)
{ {
std::cout << "avant " << std::endl;
double tmpdist2 = vtkMath::Distance2BetweenPoints(points[id], y); double tmpdist2 = vtkMath::Distance2BetweenPoints(points[id], y);
std::cout << "apres " << std::endl;
if (tmpdist2 > dist2) if (tmpdist2 > dist2)
{ {
dist2 = tmpdist2; dist2 = tmpdist2;
......
...@@ -49,8 +49,6 @@ ...@@ -49,8 +49,6 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "vtkXMLDataObjectWriter.h"
// clang-format off // clang-format off
#include "vtk_diy2.h" #include "vtk_diy2.h"
#include VTK_DIY2(diy/mpi.hpp) #include VTK_DIY2(diy/mpi.hpp)
...@@ -103,12 +101,12 @@ vtkPointSet* ConvertCellsToBoundingSpheres(vtkDataSet* ds, std::vector<vtkBoundi ...@@ -103,12 +101,12 @@ vtkPointSet* ConvertCellsToBoundingSpheres(vtkDataSet* ds, std::vector<vtkBoundi
for (vtkIdType id = 0; id < size; ++id) for (vtkIdType id = 0; id < size; ++id)
{ {
bboxes.emplace_back(ds->GetCell(id)->GetBounds()); vtkCell* cell = ds->GetCell(id);
vtkBoundingBox& bbox = bboxes[id]; bboxes.emplace_back(ds->GetBounds());
double center[3]; double center[3];
bbox.GetCenter(center); double radius2 = cell->ComputeBoundingSphere(center);
SphereRadiusArray->SetValue(id, std::sqrt(radius2));
points->SetPoint(id, center); points->SetPoint(id, center);
SphereRadiusArray->SetValue(id, bbox.GetDiagonalLength() * 0.5);
} }
pointCloud->GetPointData()->AddArray(SphereRadiusArray); pointCloud->GetPointData()->AddArray(SphereRadiusArray);
...@@ -440,7 +438,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet* ...@@ -440,7 +438,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet*
} }
// We share overlapping candidates with neighbor blocks. // We share overlapping candidates with neighbor blocks.
master.foreach ([&output, &overlappingCellCandidatesDataSets]( master.foreach ([&overlappingCellCandidatesDataSets](
void*, const diy::Master::ProxyWithLink& cp) { void*, const diy::Master::ProxyWithLink& cp) {
// enqueue // enqueue
for (int i = 0; i < static_cast<int>(cp.link()->size()); ++i) for (int i = 0; i < static_cast<int>(cp.link()->size()); ++i)
...@@ -450,8 +448,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet* ...@@ -450,8 +448,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet*
} }
}); });
master.exchange(); master.exchange();
master.foreach ([&output, &overlappingCellCandidatesDataSets]( master.foreach ([](detail::Block* block, const diy::Master::ProxyWithLink& cp) {
detail::Block* block, const diy::Master::ProxyWithLink& cp) {
// dequeue // dequeue
std::vector<int> incoming; std::vector<int> incoming;
cp.incoming(incoming); cp.incoming(incoming);
...@@ -527,7 +524,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet* ...@@ -527,7 +524,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet*
// We need to send back collision information to the original block, so they // We need to send back collision information to the original block, so they
// can add the collisions they couldn't detect. // can add the collisions they couldn't detect.
master.foreach ([&output, &collisionListMapList](void*, const diy::Master::ProxyWithLink& cp) { master.foreach ([&collisionListMapList](void*, const diy::Master::ProxyWithLink& cp) {
// enqueue // enqueue
for (int i = 0; i < static_cast<int>(cp.link()->size()); ++i) for (int i = 0; i < static_cast<int>(cp.link()->size()); ++i)
{ {
...@@ -536,7 +533,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet* ...@@ -536,7 +533,7 @@ int vtkOverlappingCellsDetector::ExposeOverlappingCellsAmongBlocks(vtkPointSet*
} }
}); });
master.exchange(); master.exchange();
master.foreach ([&output](detail::Block* block, const diy::Master::ProxyWithLink& cp) { master.foreach ([](detail::Block* block, const diy::Master::ProxyWithLink& cp) {
// dequeue // dequeue
std::vector<int> incoming; std::vector<int> incoming;
cp.incoming(incoming); cp.incoming(incoming);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment