Commit c304d3f0 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

ENH: It is now possible to perform block selection on hierarchical box datasets.

parent 78f5d4d9
......@@ -30,7 +30,7 @@
#include <vtkstd/vector>
#include <assert.h>
vtkCxxRevisionMacro(vtkHierarchicalBoxDataSet, "1.20");
vtkCxxRevisionMacro(vtkHierarchicalBoxDataSet, "1.21");
vtkStandardNewMacro(vtkHierarchicalBoxDataSet);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,BOX,IntegerVector);
......@@ -389,6 +389,28 @@ void vtkHierarchicalBoxDataSet::PrintSelf(ostream& os, vtkIndent indent)
*/
}
//----------------------------------------------------------------------------
unsigned int vtkHierarchicalBoxDataSet::GetFlatIndex(unsigned int level,
unsigned int index)
{
if (level > this->GetNumberOfLevels() || index > this->GetNumberOfDataSets(level))
{
// invalid level, index.
vtkErrorMacro("Invalid level (" << level << ") or index (" << index << ")");
return 0;
}
unsigned int findex=0;
for (unsigned int l=0; l < level; l++)
{
findex += 1;
findex += this->GetNumberOfDataSets(l);
}
findex += 1;
findex += (index + 1);
return findex;
}
//----------------------------------------------------------------------------
vtkHierarchicalBoxDataSet* vtkHierarchicalBoxDataSet::GetData(
vtkInformation* info)
......
......@@ -187,7 +187,12 @@ public:
// Unhiding superclass method.
virtual int HasMetaData(vtkCompositeDataIterator* iter)
{ return this->Superclass::HasMetaData(iter); }
// Description:
// Given the level and dataset index, returns the flat index provided level
// and dataset index are valid.
unsigned int GetFlatIndex(unsigned int level, unsigned int index);
protected:
vtkHierarchicalBoxDataSet();
~vtkHierarchicalBoxDataSet();
......
......@@ -29,6 +29,7 @@
#include "vtkFieldData.h"
#include "vtkGraph.h"
#include "vtkHierarchicalBoxDataIterator.h"
#include "vtkHierarchicalBoxDataSet.h"
#include "vtkIdList.h"
#include "vtkIdTypeArray.h"
#include "vtkInformation.h"
......@@ -51,7 +52,7 @@
vtkCxxSetObjectMacro(vtkConvertSelection, ArrayNames, vtkStringArray);
vtkCxxRevisionMacro(vtkConvertSelection, "1.14");
vtkCxxRevisionMacro(vtkConvertSelection, "1.15");
vtkStandardNewMacro(vtkConvertSelection);
//----------------------------------------------------------------------------
vtkConvertSelection::vtkConvertSelection()
......@@ -265,7 +266,19 @@ int vtkConvertSelection::ConvertToBlockSelection(
indices.insert(static_cast<unsigned int>(
properties->Get(vtkSelection::COMPOSITE_INDEX())));
}
// TODO: is has HIERARCHICAL_INDEX() & HIERARCHICAL_LEVEL.
else if (properties->Has(vtkSelection::CONTENT_TYPE()) &&
properties->Has(vtkSelection::HIERARCHICAL_INDEX()) &&
properties->Has(vtkSelection::HIERARCHICAL_LEVEL()) &&
data->IsA("vtkHierarchicalBoxDataSet"))
{
// convert hierarchical index to composite index.
vtkHierarchicalBoxDataSet* hbox = static_cast<vtkHierarchicalBoxDataSet*>(data);
indices.insert(
hbox->GetFlatIndex(
static_cast<unsigned int>(properties->Get(vtkSelection::HIERARCHICAL_LEVEL())),
static_cast<unsigned int>(properties->Get(vtkSelection::HIERARCHICAL_INDEX()))));
}
}
VTK_CREATE(vtkUnsignedIntArray, selectionList);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment