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

Method SubdivideFromQuadric

Filters/Sources/vtkHyperTreeGridSource.cxx:1308–1513  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1306
1307//------------------------------------------------------------------------------
1308void vtkHyperTreeGridSource::SubdivideFromQuadric(vtkHyperTreeGrid* output,
1309 vtkHyperTreeGridNonOrientedCursor* cursor, unsigned int level, int treeIdx, const int idx[3],
1310 double origin[3], double size[3])
1311{
1312 // Get handle on point data
1313 vtkCellData* outData = output->GetCellData();
1314
1315 // Calculate the node global index
1316 vtkIdType id = cursor->GetTree()->GetGlobalIndexFromLocal(cursor->GetVertexId());
1317 ++this->LevelBitsIndexCnt[0];
1318
1319 // Compute cell origin coordinates
1320 double O[] = { 0., 0., 0. };
1321 for (unsigned int d = 0; d < this->Dimension; ++d)
1322 {
1323 O[d] = origin[d] + idx[d] * size[d];
1324 }
1325
1326 // Iterate over all vertices
1327 int nPos = 0;
1328 int nNeg = 0;
1329 double sum = 0.;
1330 double nVert = 1 << this->Dimension;
1331 for (int v = 0; v < nVert; ++v)
1332 {
1333 // Transform flat index into triple
1334 div_t d1 = div(v, 2);
1335 div_t d2 = div(d1.quot, 2);
1336
1337 // Compute vertex coordinates
1338 double pt[3];
1339 pt[0] = O[0] + d1.rem * size[0];
1340 pt[1] = O[1] + d2.rem * size[1];
1341 pt[2] = O[2] + d2.quot * size[2];
1342
1343 // Evaluate quadric at current vertex
1344 double qv = this->Quadric->EvaluateFunction(pt);
1345 if (qv > 0)
1346 {
1347 // Found positive value at this vertex
1348 ++nPos;
1349
1350 // Update integral
1351 sum += qv;
1352 }
1353 else if (qv < 0)
1354 {
1355 // Found negative value at this vertex
1356 ++nNeg;
1357
1358 // Update integral
1359 sum += qv;
1360 }
1361 } // v
1362
1363 // Subdivide iff quadric changes sign within cell
1364 bool subdivide = nPos != nVert && nNeg != nVert;
1365

Callers 1

ProcessTreesMethod · 0.95

Calls 12

InsertTuple1Method · 0.80
InsertTuple3Method · 0.80
GetCellDataMethod · 0.45
GetTreeMethod · 0.45
GetVertexIdMethod · 0.45
EvaluateFunctionMethod · 0.45
GetArrayMethod · 0.45
SetMaskMethod · 0.45
SubdivideLeafMethod · 0.45
ToChildMethod · 0.45
ToParentMethod · 0.45

Tested by

no test coverage detected