VTKFIG  0.20.20181114
Easy VTK based in situ visualization
template<class V >
void vtkfig::DataSet::SetPointScalar ( const V &  f,
const std::string  name 
)
inline

Set data of a scalar function defined on the points of the grid.

Template Parameters
VVector class counting from zero with member functions size() and operator[]. std::vector will work.
Parameters
fVector of function values
nameName of function

Definition at line 684 of file vtkfigDataSet.h.

685  {
686  assert(this->data!=NULL);
687  int npoints=this->data->GetNumberOfPoints();
688  assert(npoints==values.size());
689  vtkSmartPointer<vtkDoubleArray>gridvalues;
690 
691  if (this->data->GetPointData()->HasArray(name.c_str()))
692  gridvalues=vtkDoubleArray::SafeDownCast(this->data->GetPointData()->GetAbstractArray(name.c_str()));
693  else
694  {
695  gridvalues=vtkSmartPointer<vtkDoubleArray>::New();
696  gridvalues->SetNumberOfComponents(1);
697  gridvalues->SetNumberOfTuples(npoints);
698  gridvalues->SetName(name.c_str());
699  this->data->GetPointData()->AddArray(gridvalues);
700  }
701 
702  for (int i=0;i<npoints; i++)
703  gridvalues->InsertComponent(i,0,values[i]);
704  gridvalues->Modified();
705  }
vtkSmartPointer< vtkDataSet > data