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

Method DoMedianFind

Common/DataModel/vtkKdTree.cxx:1316–1346  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Rearrange the point array. Try dim1 first. If there's a problem go to dim2, then dim3.

Source from the content-addressed store, hash-verified

1314// go to dim2, then dim3.
1315//
1316void vtkKdTree::DoMedianFind(vtkKdNode* kd, float* c1, int* ids, int dim1, int dim2, int dim3)
1317{
1318 double coord;
1319 int dim;
1320 int midpt;
1321
1322 int npoints = kd->GetNumberOfPoints();
1323
1324 int dims[3] = { dim1, dim2, dim3 };
1325
1326 for (dim = 0; dim < 3; dim++)
1327 {
1328 if (dims[dim] < 0)
1329 {
1330 break;
1331 }
1332
1333 midpt = vtkKdTree::Select(dims[dim], c1, ids, npoints, coord);
1334
1335 if (midpt == 0)
1336 {
1337 continue; // fatal
1338 }
1339
1340 kd->SetDim(dims[dim]);
1341
1342 vtkKdTree::AddNewRegions(kd, c1, midpt, dims[dim], coord);
1343
1344 break; // division is fine
1345 }
1346}
1347
1348//------------------------------------------------------------------------------
1349void vtkKdTree::AddNewRegions(vtkKdNode* kd, float* c1, int midpt, int dim, double coord)

Callers 1

DivideRegionMethod · 0.95

Calls 3

SetDimMethod · 0.80
SelectClass · 0.50
GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected