Skip to content
Snippets Groups Projects
Commit ebc7d73d authored by Jean Fechter's avatar Jean Fechter Committed by Kitware Robot
Browse files

Merge topic 'htg-gen-fields-fix'


b87af858 Init cell center strategy array with zeros and compute for coarse cells

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Tested-by: default avatarbuildbot <buildbot@kitware.com>
Reviewed-by: default avatarLouis Gombert <louis.gombert@kitware.com>
Reviewed-by: default avatarGuillaume Gisbert <guillaume.gisbert@kitware.com>
Merge-request: !11962
parents c23eec7a b87af858
No related branches found
No related tags found
No related merge requests found
...@@ -282,6 +282,57 @@ bool TestCellCenter() ...@@ -282,6 +282,57 @@ bool TestCellCenter()
return false; return false;
} }
// CellCenter should be computed even for coarse cells
pt = cellCenterArray->GetTuple3(0);
if (pt[0] != 0.5 || pt[1] != 0.5)
{
vtkLogF(ERROR, "CellCenter is %f %f but expected 0.5 0.5\n", pt[0], pt[1]);
return false;
}
// CellCenter should NOT be computed for masked cells
pt = cellCenterArray->GetTuple3(9);
if (pt[0] != 0.0 || pt[1] != 0.0)
{
vtkLogF(ERROR, "CellCenter should not be computed for masked cells\n");
return false;
}
return true;
}
bool TestValidCell()
{
// Create a HTG
vtkNew<vtkHyperTreeGridSource> source;
source->SetDimensions(3, 4, 1);
source->SetMaxDepth(2);
source->SetDescriptor("RRRRR.|.... .... .... .... ....");
source->UseMaskOn();
source->SetMask("111111|1110 1111 1111 1111 1111");
source->Update();
// Apply our filter
vtkNew<vtkHyperTreeGridGenerateFields> generateFields;
generateFields->SetInputConnection(source->GetOutputPort());
generateFields->Update();
vtkHyperTreeGrid* outputHTG = generateFields->GetHyperTreeGridOutput();
auto validCellArray =
vtkBitArray::SafeDownCast(outputHTG->GetCellData()->GetAbstractArray("ValidCell"));
if (validCellArray->GetTuple1(8) == 0)
{
vtkLogF(ERROR, "Unmasked leaf should be valid");
return false;
}
if (validCellArray->GetTuple1(9) == 1)
{
vtkLogF(ERROR, "Masked cell should be invalid");
return false;
}
return true; return true;
} }
...@@ -379,6 +430,7 @@ int TestHyperTreeGridGenerateFields(int argc, char* argv[]) ...@@ -379,6 +430,7 @@ int TestHyperTreeGridGenerateFields(int argc, char* argv[])
result &= ::TestTotalVolume(); result &= ::TestTotalVolume();
result &= ::TestCellCenter(); result &= ::TestCellCenter();
result &= ::TestArrayDisabling(); result &= ::TestArrayDisabling();
result &= ::TestValidCell();
return result ? EXIT_SUCCESS : EXIT_FAILURE; return result ? EXIT_SUCCESS : EXIT_FAILURE;
} }
...@@ -21,8 +21,6 @@ vtkHyperTreeGridCellCenterStrategy::~vtkHyperTreeGridCellCenterStrategy() = defa ...@@ -21,8 +21,6 @@ vtkHyperTreeGridCellCenterStrategy::~vtkHyperTreeGridCellCenterStrategy() = defa
void vtkHyperTreeGridCellCenterStrategy::PrintSelf(ostream& os, vtkIndent indent) void vtkHyperTreeGridCellCenterStrategy::PrintSelf(ostream& os, vtkIndent indent)
{ {
this->Superclass::PrintSelf(os, indent); this->Superclass::PrintSelf(os, indent);
os << indent << "InputMask size: " << (this->InputMask ? this->InputMask->GetNumberOfTuples() : 0)
<< "\n";
os << indent os << indent
<< "InputGhost size: " << (this->InputGhost ? this->InputGhost->GetNumberOfTuples() : 0) << "InputGhost size: " << (this->InputGhost ? this->InputGhost->GetNumberOfTuples() : 0)
<< "\n"; << "\n";
...@@ -36,35 +34,28 @@ void vtkHyperTreeGridCellCenterStrategy::Initialize(vtkHyperTreeGrid* inputHTG) ...@@ -36,35 +34,28 @@ void vtkHyperTreeGridCellCenterStrategy::Initialize(vtkHyperTreeGrid* inputHTG)
this->CellCentersArray->SetName(this->ArrayName.c_str()); this->CellCentersArray->SetName(this->ArrayName.c_str());
this->CellCentersArray->SetNumberOfComponents(3); this->CellCentersArray->SetNumberOfComponents(3);
this->CellCentersArray->SetNumberOfTuples(inputHTG->GetNumberOfCells()); this->CellCentersArray->SetNumberOfTuples(inputHTG->GetNumberOfCells());
this->CellCentersArray->Fill(0);
this->InputMask = inputHTG->HasMask() ? inputHTG->GetMask() : nullptr;
this->InputGhost = inputHTG->GetGhostCells(); this->InputGhost = inputHTG->GetGhostCells();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void vtkHyperTreeGridCellCenterStrategy::Compute(vtkHyperTreeGridNonOrientedGeometryCursor* cursor) void vtkHyperTreeGridCellCenterStrategy::Compute(vtkHyperTreeGridNonOrientedGeometryCursor* cursor)
{ {
if (cursor->IsLeaf()) vtkIdType currentId = cursor->GetGlobalNodeIndex();
if (cursor->IsMasked())
{
return;
}
if (this->InputGhost != nullptr && this->InputGhost->GetTuple1(currentId) != 0)
{ {
vtkIdType currentId = cursor->GetGlobalNodeIndex(); return;
bool validity = true; }
if (this->InputMask != nullptr && this->InputMask->GetTuple1(currentId) != 0)
{
validity = false;
}
if (this->InputGhost != nullptr && this->InputGhost->GetTuple1(currentId) != 0)
{
validity = false;
}
if (validity) double pt[3];
{ cursor->GetPoint(pt);
double pt[3];
cursor->GetPoint(pt);
this->CellCentersArray->SetTuple3(currentId, pt[0], pt[1], pt[2]); this->CellCentersArray->SetTuple(currentId, pt);
}
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -51,7 +51,6 @@ private: ...@@ -51,7 +51,6 @@ private:
~vtkHyperTreeGridCellCenterStrategy() override; ~vtkHyperTreeGridCellCenterStrategy() override;
// Input data // Input data
vtkBitArray* InputMask = nullptr;
vtkUnsignedCharArray* InputGhost = nullptr; vtkUnsignedCharArray* InputGhost = nullptr;
// Output array // Output array
......
...@@ -20,8 +20,6 @@ vtkHyperTreeGridValidCellStrategy::~vtkHyperTreeGridValidCellStrategy() = defaul ...@@ -20,8 +20,6 @@ vtkHyperTreeGridValidCellStrategy::~vtkHyperTreeGridValidCellStrategy() = defaul
void vtkHyperTreeGridValidCellStrategy::PrintSelf(ostream& os, vtkIndent indent) void vtkHyperTreeGridValidCellStrategy::PrintSelf(ostream& os, vtkIndent indent)
{ {
this->Superclass::PrintSelf(os, indent); this->Superclass::PrintSelf(os, indent);
os << indent << "InputMask size: " << (this->InputMask ? this->InputMask->GetNumberOfTuples() : 0)
<< "\n";
os << indent os << indent
<< "InputGhost size: " << (this->InputGhost ? this->InputGhost->GetNumberOfTuples() : 0) << "InputGhost size: " << (this->InputGhost ? this->InputGhost->GetNumberOfTuples() : 0)
<< "\n"; << "\n";
...@@ -29,21 +27,6 @@ void vtkHyperTreeGridValidCellStrategy::PrintSelf(ostream& os, vtkIndent indent) ...@@ -29,21 +27,6 @@ void vtkHyperTreeGridValidCellStrategy::PrintSelf(ostream& os, vtkIndent indent)
<< (this->ValidCellsArray ? this->ValidCellsArray->GetNumberOfTuples() : 0) << "\n"; << (this->ValidCellsArray ? this->ValidCellsArray->GetNumberOfTuples() : 0) << "\n";
} }
//------------------------------------------------------------------------------
void vtkHyperTreeGridValidCellStrategy::SetLeafValidity(const vtkIdType& index)
{
bool validity = true;
if (this->InputMask != nullptr && this->InputMask->GetTuple1(index) != 0)
{
validity = false;
}
if (this->InputGhost != nullptr && this->InputGhost->GetTuple1(index) != 0)
{
validity = false;
}
this->ValidCellsArray->SetTuple1(index, validity ? 1 : 0);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void vtkHyperTreeGridValidCellStrategy::Initialize(vtkHyperTreeGrid* inputHTG) void vtkHyperTreeGridValidCellStrategy::Initialize(vtkHyperTreeGrid* inputHTG)
{ {
...@@ -52,7 +35,6 @@ void vtkHyperTreeGridValidCellStrategy::Initialize(vtkHyperTreeGrid* inputHTG) ...@@ -52,7 +35,6 @@ void vtkHyperTreeGridValidCellStrategy::Initialize(vtkHyperTreeGrid* inputHTG)
this->ValidCellsArray->SetNumberOfTuples(inputHTG->GetNumberOfCells()); this->ValidCellsArray->SetNumberOfTuples(inputHTG->GetNumberOfCells());
this->ValidCellsArray->Fill(0); this->ValidCellsArray->Fill(0);
this->InputMask = inputHTG->HasMask() ? inputHTG->GetMask() : nullptr;
this->InputGhost = inputHTG->GetGhostCells(); this->InputGhost = inputHTG->GetGhostCells();
} }
...@@ -61,8 +43,16 @@ void vtkHyperTreeGridValidCellStrategy::Compute(vtkHyperTreeGridNonOrientedGeome ...@@ -61,8 +43,16 @@ void vtkHyperTreeGridValidCellStrategy::Compute(vtkHyperTreeGridNonOrientedGeome
{ {
if (cursor->IsLeaf()) if (cursor->IsLeaf())
{ {
vtkIdType currentId = cursor->GetGlobalNodeIndex(); const vtkIdType currentId = cursor->GetGlobalNodeIndex();
this->SetLeafValidity(currentId); if (cursor->IsMasked())
{
return;
}
if (this->InputGhost != nullptr && this->InputGhost->GetTuple1(currentId) != 0)
{
return;
}
this->ValidCellsArray->SetTuple1(currentId, 1);
} }
} }
......
...@@ -53,14 +53,7 @@ private: ...@@ -53,14 +53,7 @@ private:
vtkHyperTreeGridValidCellStrategy(); vtkHyperTreeGridValidCellStrategy();
~vtkHyperTreeGridValidCellStrategy() override; ~vtkHyperTreeGridValidCellStrategy() override;
/**
* Set the valid cell array value to true if the HTG leaf cell `index` is a non-ghost and
* non-masked cell.
*/
void SetLeafValidity(const vtkIdType& index);
// Input data // Input data
vtkBitArray* InputMask = nullptr;
vtkUnsignedCharArray* InputGhost = nullptr; vtkUnsignedCharArray* InputGhost = nullptr;
// Output array // Output array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment