| | function mesh = fixpos(mesh, recurse) |
| |
|
| | |
| |
|
| | if nargin==1 |
| | recurse = 1; |
| | end |
| |
|
| | if isa(mesh, 'delaunayTriangulation') |
| | |
| | ws = warning('off', 'MATLAB:structOnObject'); |
| | mesh = struct(mesh); |
| | warning(ws); |
| | end |
| |
|
| | if ~isa(mesh, 'struct') |
| | return; |
| | end |
| |
|
| | if numel(mesh)>1 |
| | |
| | clear tmp |
| | for i=1:numel(mesh) |
| | |
| | tmp(i) = fixpos(mesh(i)); |
| | end |
| | mesh = tmp; |
| | clear tmp |
| | return |
| | end |
| |
|
| | |
| | if isfield(mesh, 'Points') && isfield(mesh, 'ConnectivityList') |
| | mesh.pos = mesh.Points; |
| | switch size(mesh.ConnectivityList,2) |
| | case 2 |
| | mesh.edge = mesh.ConnectivityList; |
| | case 3 |
| | mesh.tri = mesh.ConnectivityList; |
| | case 4 |
| | mesh.tet = mesh.ConnectivityList; |
| | case 8 |
| | mesh.hex = mesh.ConnectivityList; |
| | otherwise |
| | error('unsupported ConnectivityList') |
| | end |
| | mesh = rmfield(mesh, {'Points', 'ConnectivityList', 'Constraints'}); |
| | end |
| |
|
| | |
| | if isfield(mesh, 'vertices') && isfield(mesh, 'faces') |
| | mesh.pos = mesh.vertices; |
| | mesh.tri = mesh.faces; |
| | mesh = rmfield(mesh, {'faces', 'vertices'}); |
| | elseif isfield(mesh, 'Vertices') && isfield(mesh, 'Faces') |
| | mesh.pos = mesh.Vertices; |
| | mesh.tri = mesh.Faces; |
| | mesh = rmfield(mesh, {'Faces', 'Vertices'}); |
| | end |
| |
|
| | |
| | if isfield(mesh, 'pnt') |
| | mesh.pos = mesh.pnt; |
| | mesh = rmfield(mesh, 'pnt'); |
| | end |
| |
|
| | if recurse<3 |
| | |
| | fn = fieldnames(mesh); |
| | fn = setdiff(fn, {'cfg'}); |
| | for i=1:length(fn) |
| | if isstruct(mesh.(fn{i})) |
| | mesh.(fn{i}) = fixpos(mesh.(fn{i}), recurse+1); |
| | end |
| | end |
| | end |
| |
|