Я использую C ++ vtk для визуализации полей в ParaView через UnctructuredGrid.
Если я использую SetVectors дважды, VTK Напишите только последнее векторное поле. < /p>
как написать более одного данных Массив в. с двумя массивами ячеек.
paraview показывает, что файл out.vtu содержит только одну массив поля напряжения сдвига. < /p>
//VTK heaaders
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main () {
vtkNew points;
// Make 4 points
points->InsertNextPoint(0., 0., 0.);
points->InsertNextPoint(1., 0., 0.);
points->InsertNextPoint(1., 1, 0);
points->InsertNextPoint(0., 1., 0.);
vtkNew cellArray;
vtkNew quad;
// make single quad
quad->GetPointIds()->SetId(0, 0);
quad->GetPointIds()->SetId(1, 1);
quad->GetPointIds()->SetId(2, 2);
quad->GetPointIds()->SetId(3, 3);
cellArray->InsertNextCell(quad);
vtkNew unstructuredGrid;
unstructuredGrid->SetPoints(points);
unstructuredGrid->SetCells(VTK_QUAD, cellArray);
// Data Arrays
vtkSmartPointer Sigma = vtkSmartPointer::New();
Sigma->SetName("Normal Stress");
Sigma->SetNumberOfComponents(3);
vtkSmartPointer Tau = vtkSmartPointer::New();
Tau->SetName("Shear Stress ");
Tau->SetNumberOfComponents(3);
// insert values to arrays
Sigma->InsertNextValue(100.);
Sigma->InsertNextValue(100.);
Sigma->InsertNextValue(100.);
Tau->InsertNextValue(100.);
Tau->InsertNextValue(100.);
Tau->InsertNextValue(100.);
// insert data array to grid
unstructuredGrid->GetCellData()->SetVectors(Sigma);
// Tau will overwright sigma field
// How to fix it
unstructuredGrid->GetCellData()->SetVectors(Tau);
vtkNew writer;
writer->SetFileName("out.vtu");
writer->SetInputData(unstructuredGrid);
writer->Write();
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... cturedgrid