forked from lisapankewitz/Cobiveco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_inputPreparation.m
48 lines (34 loc) · 1.37 KB
/
example_inputPreparation.m
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/heart_original.vtu');
%% Estimate the normal vector and the origin of a basal plane
sur = vtkDataSetSurfaceFilter(vol);
[baseNormal,baseOrigin,debug] = cobiveco_estimateBaseNormalAndOrigin(sur);
vtkWrite(debug, 'geo3/debug1.vtp');
%% Adjust baseNormal and baseOrigin, if needed
baseShift = -7;
%baseShift = -15;
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
%keyboard
[vol,debug,mmgOutput] = cobiveco_removeBridges(vol, sur, baseNormal, 'rv', true);
vtkWrite(debug, 'geo3/debug4.vtp');
%% Recreate surface classes
%keyboard
sur = vtkDataSetSurfaceFilter(vol);
[sur,debug] = cobiveco_createClasses(sur, baseNormal, maxAngle, numSubdiv);
vtkWrite(debug, 'geo3/debug5.vtp');
%% Write result
vtkWrite(sur, 'geo3/test_clipping_heart.vtp');
vtkWrite(vol, 'geo3/test_clipping_heart.vtu');