1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkHyperTreeGridGeometrySmallDimensionsImpl.h"
#include "vtkCellArray.h"
#include "vtkDataSetAttributes.h"
#include "vtkHyperTreeGrid.h"
#include "vtkHyperTreeGridNonOrientedGeometryCursor.h"
#include "vtkPoints.h"
#include <string>
VTK_ABI_NAMESPACE_BEGIN
//----------------------------------------------------------------------------------------------
vtkHyperTreeGridGeometrySmallDimensionsImpl::vtkHyperTreeGridGeometrySmallDimensionsImpl(
vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells,
vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes,
bool passThroughCellIds, const std::string& originalCellIdArrayName, bool fillMaterial)
: vtkHyperTreeGridGeometryImpl(input, outPoints, outCells, inCellDataAttributes,
outCellDataAttributes, passThroughCellIds, originalCellIdArrayName, fillMaterial)
{
}
//----------------------------------------------------------------------------------------------
void vtkHyperTreeGridGeometrySmallDimensionsImpl::GenerateGeometry()
{
// initialize iterator on HypterTrees (HT) of an HyperTreeGrid (HTG)
vtkHyperTreeGrid::vtkHyperTreeGridIterator it;
this->Input->InitializeTreeIterator(it);
// index of current HT
vtkIdType hyperTreeId;
// non oriented geometry cursor describe one cell on HT
vtkNew<vtkHyperTreeGridNonOrientedGeometryCursor> cursor;
// traversal on HTG for describe a current HT
while (it.GetNextTree(hyperTreeId))
{
// initialize cursor on first cell (root) of current HT
this->Input->InitializeNonOrientedGeometryCursor(cursor, hyperTreeId);
// traversal recursively
this->RecursivelyProcessTree(cursor);
} // it
}
//----------------------------------------------------------------------------------------------
void vtkHyperTreeGridGeometrySmallDimensionsImpl::RecursivelyProcessTree(
vtkHyperTreeGridNonOrientedGeometryCursor* cursor)
{
if (this->IsMaskedOrGhost(cursor->GetGlobalNodeIndex()))
{
return;
}
// case leaf cell
if (cursor->IsLeaf())
{
if (this->HasInterface)
{
this->ProcessLeafCellWithInterface(cursor);
}
else
{
this->ProcessLeafCellWithoutInterface(cursor);
}
return;
}
// case coarse cell
for (unsigned int ichild = 0; ichild < cursor->GetNumberOfChildren(); ++ichild)
{
cursor->ToChild(ichild);
this->RecursivelyProcessTree(cursor);
cursor->ToParent();
}
}
//----------------------------------------------------------------------------------------------
void vtkHyperTreeGridGeometrySmallDimensionsImpl::ProcessLeafCellWithoutInterface(
vtkHyperTreeGridNonOrientedGeometryCursor* cursor)
{
// As no interface cross the cell, we simply build it and add it as-it to the output surface.
this->BuildCellPoints(cursor);
std::vector<vtkIdType> outputIndexPoints;
for (int ptId = 0; ptId < this->CellPoints->GetNumberOfPoints(); ptId++)
{
auto outPtId = this->OutPoints->InsertNextPoint(this->CellPoints->GetPoint(ptId));
outputIndexPoints.emplace_back(outPtId);
}
this->CreateNewCellAndCopyData(outputIndexPoints, cursor->GetGlobalNodeIndex());
}
//----------------------------------------------------------------------------------------------
void vtkHyperTreeGridGeometrySmallDimensionsImpl::ProcessLeafCellWithInterface(
vtkHyperTreeGridNonOrientedGeometryCursor* cursor)
{
if (!this->ProbeForCellInterface(cursor->GetGlobalNodeIndex(), false))
{ // case type >= 2, pure cell
if (this->FillMaterial)
{
this->ProcessLeafCellWithoutInterface(cursor);
}
return;
}
this->BuildCellPoints(cursor);
unsigned int nbPts = this->CellPoints->GetNumberOfPoints();
// compute distance point to interface
std::vector<double> scalarsInterfaceA(nbPts);
std::vector<double> scalarsInterfaceB(nbPts);
for (unsigned int iPt = 0; iPt < nbPts; ++iPt)
{
// Retrieve vertex coordinates
double* xyz = this->CellPoints->GetPoint(iPt);
// Set face scalars
if (this->CellInterfaceType != 1.)
{
scalarsInterfaceA[iPt] = this->ComputeDistanceToInterfaceA(xyz);
}
if (this->CellInterfaceType != -1.)
{
scalarsInterfaceB[iPt] = this->ComputeDistanceToInterfaceB(xyz);
}
}
if (!this->CellInterfaceType)
{ // case intermediate interface with A and B
this->ProcessLeafCellWithDoubleInterface(cursor, scalarsInterfaceA, scalarsInterfaceB);
}
else
{
// case type == 1 just "right" interface with B
// case type == -1, case just "left" interface with A
double dist = (this->CellInterfaceType == 1 ? -1.0 : 1.0);
auto scalarsInterface = (this->CellInterfaceType == 1 ? scalarsInterfaceB : scalarsInterfaceA);
this->ProcessLeafCellWithOneInterface(cursor, dist, scalarsInterface);
}
}
VTK_ABI_NAMESPACE_END
|