Write Cell Array of Structs into a VTK Structured Grid

버전 1.2.0.0 (3.35 KB) 작성자: Daniel Hornung
Takes a 3D cell array with (nested) structs and exports it as a VTK structured grid.
다운로드 수: 642
업데이트 날짜: 2013/5/28

라이선스 보기

Each cell of the input cell array must be a struct, possibly nested, and for each point of the input, three properties (or alternatively the cell array indices) are used as VTK coordinates. An arbitrary number of properties are used as values of these points.

The resulting VTK file (which is in ascii encoding) can then be opened and viewed with VTK compatible applications, e.g. ParaView.

The "help" text:
% WriteCellToVTKStructured (FILENAME, CELL, COORDINATES, VALUES, ...)
% Writes the content of a cell array into an ascii vtk-file 'FILENAME'
% as a structured grid.
%
% For details about this kind of data see
% http://www.itk.org/Wiki/ParaView/Users_Guide/VTK_Data_Model#Curvilinear_Grid_.28Structured_Grid.29
% and
% www.vtk.org/VTK/img/file-formats.pdf
%
% This function takes a 3D cell array of structs. For each struct, it then
% uses either given fields of the struct or its indices as VTK coordinates,
% and other fields as the values of the grid.
%
% Input:
% filename destination (string)
% cell N1xN2xN3 cell array of structs
% coordinates Cell with three cells of strings. These define what to use
% for the points' coordinates. (Details below)
% values Cell with cells of strings. These define the scalar values
% at each point. (details below)
%
% Optional input parameters of the form ..., 'name', value, ...:
% header Name of the dataset, will be saved into the file.
% valuenames Names of the values. The defaults are their field names.
% spacing 3x1 matrix of inter-point spacings if indices are used as
% coordinates.
% offset 3x1 matrix of offsets for this case.
%
% Example usage:
%
% This example assumes that 'results' is a cell array of structs, where
% each struct has (at least) the following valid fields:
% 'vw', 'effects.energy' and 'effects.charge'
%
% WriteCellToVTKStructured('test.vtk', results, ...
% {{}, {}, {'effects', 'energy'}}, ...
% {{'vw'}, {'effects' 'charge'}}, ...
% 'offset', [1 0.4 0.1], ...
% 'spacing', [1 0.05 0.1])
%
% Then use e.g. ParaView to view the resultin file 'test.vtk'.

인용 양식

Daniel Hornung (2024). Write Cell Array of Structs into a VTK Structured Grid (https://www.mathworks.com/matlabcentral/fileexchange/34738-write-cell-array-of-structs-into-a-vtk-structured-grid), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2011a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Structures에 대해 자세히 알아보기
도움

받음: WriteToVTK, writeVTK

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

Added doctext

1.0.0.0