Skip to content
Snippets Groups Projects
Commit 192daf2b authored by Julien Fausty's avatar Julien Fausty
Browse files

HTGGeometry: add PassThroughCellIds option for hardware picking

parent fb090077
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,23 @@
#include <set>
#include <vector>
namespace
{
bool PassCellId(vtkDataArray* cellIds, vtkIdType inId, vtkIdType outId)
{
auto typedCellIds = vtkIdTypeArray::SafeDownCast(cellIds);
if (!typedCellIds)
{
vtkErrorWithObjectMacro(nullptr, "Pass cell ids array has wrong type.");
return false;
}
typedCellIds->InsertValue(outId, inId);
return true;
}
}
VTK_ABI_NAMESPACE_BEGIN
static constexpr unsigned int VonNeumannCursors3D[] = { 0, 1, 2, 4, 5, 6 };
static constexpr unsigned int VonNeumannOrientations3D[] = { 2, 1, 0, 0, 1, 2 };
......@@ -292,6 +309,14 @@ int vtkHyperTreeGridGeometry::ProcessTrees(vtkHyperTreeGrid* input, vtkDataObjec
this->OutData = output->GetCellData();
this->OutData->CopyAllocate(this->InData);
if (this->PassThroughCellIds)
{
vtkNew<vtkIdTypeArray> originalCellIds;
originalCellIds->SetName(this->OriginalCellIdArrayName.c_str());
originalCellIds->SetNumberOfComponents(1);
this->OutData->AddArray(originalCellIds);
}
// Retrieve material mask
this->Mask = input->HasMask() ? input->GetMask() : nullptr;
......@@ -495,6 +520,10 @@ void vtkHyperTreeGridGeometry::ProcessLeaf1D(vtkHyperTreeGridNonOrientedGeometry
// Copy edge data from that of the cell from which it comes
this->OutData->CopyData(this->InData, inId, outId);
if (this->PassThroughCellIds)
{
::PassCellId(this->OutData->GetArray(this->OriginalCellIdArrayName.c_str()), inId, outId);
}
}
//------------------------------------------------------------------------------
......@@ -797,6 +826,10 @@ void vtkHyperTreeGridGeometry::ProcessLeaf3D(
// Copy face data from that of the cell from which it comes
this->OutData->CopyData(this->InData, inId, outId);
if (this->PassThroughCellIds)
{
::PassCellId(this->OutData->GetArray(this->OriginalCellIdArrayName.c_str()), inId, outId);
}
} // if ( nA > 0 )
// Create face B when its vertices are present
......@@ -840,6 +873,10 @@ void vtkHyperTreeGridGeometry::ProcessLeaf3D(
// Copy face data from that of the cell from which it comes
this->OutData->CopyData(this->InData, inId, outId);
if (this->PassThroughCellIds)
{
::PassCellId(this->OutData->GetArray(this->OriginalCellIdArrayName.c_str()), inId, outId);
}
} // if ( nB > 0 )
} // if ( this->HasInterface )
}
......@@ -942,6 +979,10 @@ void vtkHyperTreeGridGeometry::AddFace(vtkIdType useId, const double* origin, co
// Copy face data from that of the cell from which it comes
this->OutData->CopyData(this->InData, useId, outId);
if (this->PassThroughCellIds)
{
::PassCellId(this->OutData->GetArray(this->OriginalCellIdArrayName.c_str()), useId, outId);
}
}
//------------------------------------------------------------------------------
void vtkHyperTreeGridGeometry::AddFace2(vtkIdType inId, vtkIdType useId, const double* origin,
......@@ -1273,6 +1314,10 @@ void vtkHyperTreeGridGeometry::AddFace2(vtkIdType inId, vtkIdType useId, const d
// Copy face data from that of the cell from which it comes
this->OutData->CopyData(this->InData, useId, outId);
if (this->PassThroughCellIds)
{
::PassCellId(this->OutData->GetArray(this->OriginalCellIdArrayName.c_str()), inId, outId);
}
} // if ( create )
}
VTK_ABI_NAMESPACE_END
......@@ -64,6 +64,32 @@ public:
vtkGetMacro(Merging, bool);
///@}
//@{
/**
* Set/Get for the PassThroughCellIds boolean.
*
* When set to true this boolean ensures an array named with whatever is
* in `OriginalCellIdArrayName` gets created in the output holding the
* original cell ids
*
* default is false
*/
vtkSetMacro(PassThroughCellIds, bool);
vtkGetMacro(PassThroughCellIds, bool);
vtkBooleanMacro(PassThroughCellIds, bool);
/**
* Set/Get the OriginalCellIdArrayName string.
*
* When PassThroughCellIds is set to true, the name of the generated
* array is whatever is set in this variable.
*
* default to vtkOriginalCellIds
*/
vtkSetMacro(OriginalCellIdArrayName, std::string);
vtkGetMacro(OriginalCellIdArrayName, std::string);
//@}
protected:
vtkHyperTreeGridGeometry();
~vtkHyperTreeGridGeometry() override;
......@@ -143,6 +169,18 @@ protected:
*/
vtkCellArray* Cells;
/**
* Boolean for passing cell ids to poly data
*
* default is false
*/
bool PassThroughCellIds = false;
/**
* Name of the array holding original cell ids in output if PassThroughCellIds is true
*/
std::string OriginalCellIdArrayName = "vtkOriginalCellIds";
/**
*JB Un locator est utilise afin de produire un maillage avec moins
*JB de points. Le gain en 3D est de l'ordre d'un facteur 4 !
......
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