Commit ed39bf23 authored by Berk Geveci's avatar Berk Geveci
Browse files

BUG: Added support for adding a selection id on all processes. When using...

BUG: Added support for adding a selection id on all processes. When using global ids, it is not possible to specify a process.
parent 80590fe6
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "vtkstd/vector" #include "vtkstd/vector"
#include "vtkstd/set" #include "vtkstd/set"
vtkCxxRevisionMacro(vtkSelectionSource, "1.5"); vtkCxxRevisionMacro(vtkSelectionSource, "1.6");
vtkStandardNewMacro(vtkSelectionSource); vtkStandardNewMacro(vtkSelectionSource);
struct vtkSelectionSourceInternals struct vtkSelectionSourceInternals
...@@ -61,6 +61,9 @@ void vtkSelectionSource::RemoveAllIDs() ...@@ -61,6 +61,9 @@ void vtkSelectionSource::RemoveAllIDs()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkSelectionSource::AddID(vtkIdType proc, vtkIdType id) void vtkSelectionSource::AddID(vtkIdType proc, vtkIdType id)
{ {
// proc == -1 means all processes. All other are stored at index proc+1
proc++;
if (proc >= (vtkIdType)this->Internal->IDs.size()) if (proc >= (vtkIdType)this->Internal->IDs.size())
{ {
this->Internal->IDs.resize(proc+1); this->Internal->IDs.resize(proc+1);
...@@ -152,33 +155,47 @@ int vtkSelectionSource::RequestData( ...@@ -152,33 +155,47 @@ int vtkSelectionSource::RequestData(
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()); vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
} }
if (piece >= (vtkIdType)this->Internal->IDs.size()) // Number of selected items common to all pieces
vtkIdType numCommonElems = 0;
if (!this->Internal->IDs.empty())
{
numCommonElems = this->Internal->IDs[0].size();
}
if (piece+1 >= (int)this->Internal->IDs.size() &&
numCommonElems == 0)
{ {
vtkDebugMacro("No selection for piece: " << piece); vtkDebugMacro("No selection for piece: " << piece);
return 1; return 1;
} }
vtkSelectionSourceInternals::IDSetType& selSet = // idx == 0 is the list for all pieces
this->Internal->IDs[piece]; // idx == piece+1 is the list for the current piece
int pids[2] = {0, piece+1};
if (selSet.size() > 0) for(int i=0; i<2; i++)
{ {
output->GetProperties()->Set(vtkSelection::CONTENT_TYPE(), int idx = pids[i];
this->ContentType); vtkSelectionSourceInternals::IDSetType& selSet =
output->GetProperties()->Set(vtkSelection::FIELD_TYPE(), this->Internal->IDs[idx];
this->FieldType);
// Create the selection list if (selSet.size() > 0)
vtkIdTypeArray* selectionList = vtkIdTypeArray::New();
selectionList->SetNumberOfTuples(selSet.size());
// iterate over ids and insert to the selection list
vtkSelectionSourceInternals::IDSetType::iterator iter =
selSet.begin();
for (vtkIdType idx=0; iter != selSet.end(); iter++, idx++)
{ {
selectionList->SetValue(idx, *iter); output->GetProperties()->Set(vtkSelection::CONTENT_TYPE(),
this->ContentType);
output->GetProperties()->Set(vtkSelection::FIELD_TYPE(),
this->FieldType);
// Create the selection list
vtkIdTypeArray* selectionList = vtkIdTypeArray::New();
selectionList->SetNumberOfTuples(selSet.size());
// iterate over ids and insert to the selection list
vtkSelectionSourceInternals::IDSetType::iterator iter =
selSet.begin();
for (vtkIdType idx2=0; iter != selSet.end(); iter++, idx2++)
{
selectionList->SetValue(idx2, *iter);
}
output->SetSelectionList(selectionList);
selectionList->Delete();
} }
output->SetSelectionList(selectionList);
selectionList->Delete();
} }
return 1; return 1;
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
// Description: // Description:
// Add a (piece, id) to the selection set. The source will generate // Add a (piece, id) to the selection set. The source will generate
// only the ids for which piece == UPDATE_PIECE_NUMBER. // only the ids for which piece == UPDATE_PIECE_NUMBER.
// If piece == -1, the id applies to all pieces.
void AddID(vtkIdType piece, vtkIdType id); void AddID(vtkIdType piece, vtkIdType id);
// Description: // Description:
......
Markdown is supported
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