[390c2f]: / Cobiveco / examples / example_inputPreparation.m

Download this file

49 lines (33 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
addpath('../utilities');
addpath('../utilities/inputPreparation');
addpath('../functions');
%% Read original mesh
% vol = vtkRead('geo3/DTI003.vtk');
%% Estimate the normal vector and the origin of a basal plane
% sur = vtkRead('geo3/1000037-SUR.vtk');
sur = vtkDataSetSurfaceFilter(vol);
[baseNormal,baseOrigin,debug] = cobiveco_estimateBaseNormalAndOrigin(sur);
vtkWrite(debug, 'geo3/debug1.vtp');
%% Adjust baseNormal and baseOrigin, if needed
baseShift = -7;
baseOrigin = baseOrigin + baseShift*baseNormal;
%% Clip mesh at the basal plane
vol = cobiveco_clipBase(vol, baseNormal, baseOrigin);
vtkWrite(vol, 'geo3/debug2.vtu');
%% Create surface classes
sur = vtkDataSetSurfaceFilter(vol);
maxAngle = 40; % max angle of face normals wrt baseNormal for defining the base class
numSubdiv = 2; % can help for coarse meshes (interpolation of face normals)
[sur,debug] = cobiveco_createClasses(sur, baseNormal, maxAngle, numSubdiv);
vtkWrite(debug, 'geo3/debug3.vtp');
% %% Remove bridges
%
% [vol,debug,mmgOutput] = cobiveco_removeBridges(vol, sur, baseNormal, 'rv', true);
% vtkWrite(debug, 'geo3/debug4.vtp');
%% Recreate surface classes
% sur = vtkDataSetSurfaceFilter(vol);
% [sur,debug] = cobiveco_createClasses(sur, baseNormal, maxAngle, numSubdiv);
% vtkWrite(debug, 'geo3/debug5.vtp');
%% Write result
vtkWrite(sur, 'geo3/heart.vtp');
vtkWrite(vol, 'geo3/heart.vtu');