VTKFIG  0.20.20181114
Easy VTK based in situ visualization
template<class IV >
void vtkfig::DataSet::SetSimplexGridBoundaryCells ( const IV &  cells)
inline

Set boundary cells for simplex grids.

Template Parameters
IVVector class counting from zero with member functions size() and operator[]. std::vector will work.
Parameters
crCell region numbers
nameName of function

Definition at line 393 of file vtkfigDataSet.h.

394  {
395  if (this->boundary_data==NULL)
396  this->boundary_data=vtkSmartPointer<vtkUnstructuredGrid>::New();
397 
398  auto budata=vtkUnstructuredGrid::SafeDownCast(this->boundary_data);
399  budata->Reset();
400 
401  auto bgridpoints = vtkSmartPointer<vtkPoints>::New();
402  budata->SetPoints(bgridpoints);
403 
404  auto udata=vtkUnstructuredGrid::SafeDownCast(this->data);
405  auto pdata=udata->GetPoints();
406 
407  int np=pdata->GetNumberOfPoints();
408  std::vector<int>pmask(np);
409  for (size_t i=0;i<pmask.size(); i++)
410  {
411  pmask[i]=-1;
412  }
413 
414 
415 
416  int ip=0;
417  for (int icell=0;icell<cells.size();icell+=this->spacedim)
418  {
419  for (int id=0;id<this->spacedim;id++)
420  {
421  if (pmask[cells[icell+id]]==-1)
422  {
423  pmask[cells[icell+id]]=ip++;
424  double point[3];
425  pdata->GetPoint(cells[icell+id],point);
426  bgridpoints->InsertNextPoint(point[0],point[1],point[2]);
427  }
428 
429  }
430  if (this->spacedim==2)
431  {
432  vtkIdType c[2]={pmask[cells[icell+0]],pmask[cells[icell+1]]};
433  budata->InsertNextCell(VTK_LINE,2,c);
434  }
435  else
436  {
437  vtkIdType c[3]={pmask[cells[icell+0]],pmask[cells[icell+1]],pmask[cells[icell+2]]};
438  budata->InsertNextCell(VTK_TRIANGLE,3,c);
439  }
440 
441  }
442 
443  }
vtkSmartPointer< vtkDataSet > data
vtkSmartPointer< vtkDataSet > boundary_data