[Paraview-developers] Individual glyphs per point

anton.piccardo-selg at stfc.ac.uk anton.piccardo-selg at stfc.ac.uk
Fri Feb 20 03:02:13 EST 2015


Hi,

We found a way of having an individual glyph per point in a vtkDataSet. Just for reference reasons and to close this thread, I will briefly explain how we do it. The way we do it seems quite inefficient and there is probably a much more elegant and better way out there.

Instead of creating a vtkDataSet and then passing this to a vktPVGlyphFilter to append our glyphes, we append the glyphes while we create the data in the first place, i.e. one by one. A mocked code example looks something like this:

vtkAppendPolyData* appendFilter = vtkAppendPolyData::New();
const int resolution = 6;
for (int i = 0; i < numPoints; i++)
{
      vtkPoints *point = vtkPoints::New();
      point->Allocate(1);

      vtkFloatArray * signal = vtkFloatArray::New();
      sgnal->Allocate(1);
      signal->SetName("myName");
      signal->SetNumberOfComponents(1);

      vtkUnstructuredGrid *dataSet = vtkUnstructuredGrid::New();
      dataSet >Allocate(1);
      dataSet ->SetPoints(point);
      dataSet >GetCellData()->SetScalars(signal);

      vtkVertex * vertex = vtkVertex::New();
      vtkIdType id_xyz = point->InsertNextPoint(x,y,z);
      vertex->GetPointIds()->SetId(0, id_xyz);

      dataSet->InsertNextCell(VTK_VERTEX, vertex->GetPointIds());

      // The integrated intensity = the signal on that point.
      signal->InsertNextValue(static_cast<float>( myData.getIntensity(i) ));
      peakPoint->Squeeze();
      peakDataSet->Squeeze();
      
      std::vector<double> radii = myData.getRadii(i);
      vtkParametricEllipsoid* ellipsoid = vtkParametricEllipsoid::New();
      ellipsoid->SetXRadius(radii[0]);
      ellipsoid->SetYRadius(radii[1]);
      ellipsoid->SetZRadius(radii[2]);

      vtkParametricFunctionSource* ellipsoidSource = vtkParametricFunctionSource::New();
      ellipsoidSource->SetParametricFunction(ellipsoid);
      ellipsoidSource->SetUResolution(resolution);
      ellipsoidSource->SetVResolution(resolution);
      ellipsoidSource->SetWResolution(resolution);
      ellipsoidSource->Update();

       // Here we add more filters and transforms but this should be the same
       ....

      vtkPVGlyphFilter *glyphFilter = vtkPVGlyphFilter::New();
      glyphFilter->SetInputData(peakDataSet);
      glyphFilter->SetSourceConnection(ellipsoidSource-->GetOutputPort());
      glyphFilter->Update();
      vtkPolyData *glyphed = glyphFilter->GetOutput();

      appendFilter->AddInputData(glyphed);
}

vtkPolyData* polyData = appendFilter->GetOutput();


Our code is along these lines. As we have only comparably few data points, it is not too bad to work with this method. If there are any suggestions, regarding a better way of achieving this, we would be happy to hear about it.

Best regards, 

Anton

________________________________________
From: anton.piccardo-selg at stfc.ac.uk [anton.piccardo-selg at stfc.ac.uk]
Sent: 18 February 2015 17:06
To: paraview-developers at paraview.org
Subject: [Paraview-developers] Individual glyphs per point

Hi,

I am currently writing a  filter for our ParaView customization. I am running into a conceptual issue when I try to connect my vtkDataSet with ellipsoidal glyphs.

Our vtkDataSet  contains VTK_VERTEX cells. Each point corresponds to some data which I would like to represent with an Ellipsoid, essentially representing our data. This ellipsoid is different for each point.

The entire data set can be set to one type of ellipsoid-glyph, via:
 ...
vtkPVGlyphFilter *glyphFilter = vtkPVGlyphFilter::New();
glyphFilter->SetInputData(myInputVtkDataSet);
glyphFilter->SetSourceConnection(myOneEllipsoid->GetOutputPort());
glyphFilter->Update();
myVtkPolyData->ShallowCopy(glyphFilter->GetOutput());

But I am puzzeled how I could set a each point in the vtkDataSet to its individual glyph. If anyone has an idea  or opinon about how this can be implemented,  I would be happy to hear about it.

Many thanks and best regards,

Anton






More information about the Paraview-developers mailing list