Dear vtk-users, vtk-developers<br />I'm trying to write parallel visualizer with vtkUnstructuredGrid, code sample<br />(cellArray is std::shared_ptr of tbb::concurrent_vector<unsigned> <br />(it contains 8*numCells Id's of points of mesh) <br />and Grids is <br />std::map<std::string, vtkSmartPointer<vtkCPUnstructuredGridBuilder>>) :<br /><hr /><br /><blockquote>Grids[name] = vtkSmartPointer<vtkCPUnstructuredGridBuilder>::New();<br /><br />  vtkSmartPointer<vtkPoints> TmpPoints = vtkSmartPointer<vtkPoints>::New();<br />  TmpPoints->SetNumberOfPoints(numPts);<br /><br />  tbb::blocked_range<vtkIdType> PtsRange(0, numPts, 10000);<br />  tbb::parallel_for(PtsRange, [&](const tbb::blocked_range<vtkIdType>& r) {<br />    vtkIdType Offset{3*r.begin()};<br />    for(vtkIdType i  = r.begin() ; i < r.end(); ++i, Offset += 3)<br />    {<br />      TmpPoints->SetPoint(i, coords[Offset], coords[Offset+1], coords[Offset+2]);<br />    }<br />  });<br /><br />  Grids[name]->SetPoints(TmpPoints.Get());<br /><br />  vtkSmartPointer<vtkCellArray> CellsArray =<br />    vtkSmartPointer<vtkCellArray>::New();<br />  CellsArray->SetNumberOfCells(cellArray->size()/8);<br /><br />  vtkIdTypeArray* IdArray = CellsArray->GetData();<br />  IdArray->SetNumberOfComponents(8);<br />  IdArray->SetNumberOfTuples(cellArray->size()/8);<br /><br />  vtkSmartPointer<vtkIdTypeArray> CellsLocations =<br />    vtkSmartPointer<vtkIdTypeArray>::New();<br />  CellsLocations->SetNumberOfComponents(1);<br />  CellsLocations->SetNumberOfTuples(cellArray->size()/8);<br /><br />  vtkSmartPointer<vtkUnsignedCharArray> CellsTypes =<br />    vtkSmartPointer<vtkUnsignedCharArray>::New();<br />  CellsTypes->SetNumberOfComponents(1);<br />  CellsTypes->SetNumberOfTuples(cellArray->size()/8);<br /><br />  tbb::blocked_range<unsigned> CellsRange(0, cellArray->size(),<br />    HUGE_NUMBER); // I test it in sequential manner<br />  tbb::parallel_for(CellsRange, [&](const tbb::blocked_range<unsigned>& r) {<br />    for(auto offset  = r.begin() ; offset < r.end(); offset += 8)<br />    {<br /><br />      vtkIdType IdList[] {<br />        cellArray->operator[](offset),<br />        cellArray->operator[](offset + 1),<br />        cellArray->operator[](offset + 2),<br />        cellArray->operator[](offset + 3),<br />        cellArray->operator[](offset + 4),<br />        cellArray->operator[](offset + 5),<br />        cellArray->operator[](offset + 6),<br />        cellArray->operator[](offset + 7)<br />      };<br />        <br />//      Grids[name]->InsertNextCell(12, 8, IdList); // OK, but not parallelizable.<br />//      Grids[name]->GetUnstructuredGrid()->InsertNextCell(12, 8, IdList); // OK, but not parallelizable.<br /><br />      IdArray->SetTupleValue(offset/8, IdList);<br />      vtkIdType TmpTab[] {offset};<br />      CellsLocations->SetTupleValue(offset/8, TmpTab);<br />      CellsTypes->SetTuple1(offset/8, 12);<br />    }<br />  });<br />// I tested CellsLocations and CellsArray and they contain proper numbers (printed with program and during<br />// GDB session)<br /><br />  Grids[name]->GetUnstructuredGrid()->SetCells(CellsTypes.GetPointer(),<br />    CellsLocations.GetPointer(), CellsArray.GetPointer());<br /><br /><i><b>// Returns nullptr 0oa</b></i><br /><i><b>  vtkIdTypeArray* Tmp = Grids[name]->GetUnstructuredGrid()->GetCellLocationsArray();</b></i><br /><i><b>// Returns nullptr 0oa</b></i><br /><i><b>  vtkCellArray* TmpCell = Grids[name]->GetUnstructuredGrid()->GetCells(); </b></i><br />}<br /></blockquote><hr /><br />So after setting Connectivity and Locations I'm still having empty these members, and when I use<br />vtkXMLUnstructuredGridWriter, only Points, and CellTypes are contained in .vtu file. (connectivity is empty, and<br />locations contains rubish numbers). This function works when I use InsertNextCell but this is not parallelizable.<br />Is it solvable? Thank you for any hint.<br />Best Regards,<br />Kotu