|
1 |
| -function vtk = remeshTriangleMesh(vtk, numPoints, creaseAngle) |
| 1 | +function vtk = remeshTriangleMesh(vtk, numPoints, extraFlags) |
2 | 2 |
|
3 |
| -if nargin < 3 |
4 |
| - creaseAngle = []; |
| 3 | +if nargin < 3 || isempty(extraFlags) |
| 4 | + extraFlags = ''; |
| 5 | +end |
| 6 | +if ~isempty(numPoints) |
| 7 | + extraFlags = sprintf('%s -v %i', extraFlags, round(numPoints)); |
5 | 8 | end
|
6 | 9 |
|
7 | 10 | % make sure the source mesh contains at least 4 times as many triangles as
|
8 | 11 | % the target mesh (needed for good results with Instant Meshes)
|
9 | 12 | numPointsSource = size(vtk.cells,1);
|
10 | 13 | numSubdiv = max(1-floor(log(numPointsSource/numPoints)/log(4)),0);
|
11 | 14 | if numSubdiv
|
12 |
| - vtk = vtkLinearSubdivisionFilter(vtk, numSubdiv); |
| 15 | + try |
| 16 | + vtk = vtkLinearSubdivisionFilter(vtk, numSubdiv); |
| 17 | + catch |
| 18 | + warning('Skipping subdivision before remeshing.'); |
| 19 | + end |
13 | 20 | end
|
14 | 21 |
|
15 | 22 | tmpfile = [tempname '.ply'];
|
|
21 | 28 | instantmeshes = '/Applications/Instant Meshes.app/Contents/MacOS/Instant Meshes';
|
22 | 29 | end
|
23 | 30 | if ~exist(instantmeshes, 'file')
|
24 |
| - instantmeshes = '/Volumes/ServerApps/Instant Meshes.app/Contents/MacOS/Instant Meshes'; |
| 31 | + instantmeshes = '/Users/ss029/Applications/Instant Meshes.app/Contents/MacOS/Instant Meshes'; |
| 32 | +% instantmeshes = '/Volumes/ServerApps/Instant Meshes.app/Contents/MacOS/Instant Meshes'; |
25 | 33 | end
|
26 | 34 | if ~exist(instantmeshes, 'file')
|
27 | 35 | error('Instant Meshes could not be found.');
|
28 | 36 | end
|
29 | 37 |
|
30 |
| -if isempty(creaseAngle) |
31 |
| - system(sprintf('''%s'' %s -v %i -o %s -r 6 -p 6 -S 0 -d', instantmeshes, tmpfile, round(numPoints), tmpfile)); |
32 |
| -else |
33 |
| - system(sprintf('''%s'' %s -v %i -o %s -r 6 -p 6 -S 0 -d -c %.1f', instantmeshes, tmpfile, round(numPoints), tmpfile, creaseAngle)); |
34 |
| -end |
| 38 | +system(sprintf('''%s'' %s -o %s -r 6 -p 6 -S 0 -d %s', instantmeshes, tmpfile, tmpfile, extraFlags)); |
35 | 39 |
|
36 | 40 | vtk = vtkRead(tmpfile);
|
37 | 41 | delete(tmpfile);
|
|
0 commit comments