-
Notifications
You must be signed in to change notification settings - Fork 27
/
tripod.m
164 lines (143 loc) · 4.9 KB
/
tripod.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
function [varargout] = tripod(opts)
%TRIPOD an interface to the JIGSAW's "restricted" Delaunay
%tessellator TRIPOD.
%
% MESH = TRIPOD(OPTS);
%
% Call the rDT tessellator TRIPOD using the confg. options
% specified in the OPTS structure. See the SAVEMSH/LOADMSH
% routines for a description of the MESH output structure.
%
% OPTS is a user-defined set of meshing options:
%
% REQUIRED fields:
% ---------------
%
% OPTS.INIT_FILE - 'INITNAME.MSH', a string containing the
% name of the initial distribution file (is required
% at input). See SAVEMSH for additional details regar-
% ding the creation of *.MSH files.
%
% OPTS.JCFG_FILE - 'JCFGNAME.JIG', a string containing the
% name of the cofig. file (will be created on output).
%
% OPTS.MESH_FILE - 'MESHNAME.MSH', a string containing the
% name of the output file (will be created on output).
%
% OPTIONAL fields (GEOM):
% ----------------------
%
% OPTS.GEOM_FILE - 'GEOMNAME.MSH', a string containing the
% name of the geometry file (is required at input).
% When a non-null geometry is passed, MESH is computed
% as a "restricted" Delaunay tessellation, including
% various 1-, 2- and/or 3-dimensional sub-meshes that
% approximate the geometry definition.
%
% OPTS.GEOM_FEAT - {default=false} attempt to auto-detect
% "sharp-features" in the input geometry. Features can
% lie adjacent to 1-dim. entities, (i.e. geometry
% "edges") and/or 2-dim. entities, (i.e. geometry
% "faces") based on both geometrical and/or topologic-
% al constraints. Geometrically, features are located
% between any neighbouring entities that subtend
% angles less than GEOM_ETAX degrees, where "X" is the
% (topological) dimension of the feature. Topological-
% ly, features are located at the apex of any non-man-
% ifold connections.
%
% OPTS.GEOM_ETA1 - {default=45deg} 1-dim. feature-angle,
% features are located between any neighbouring
% "edges" that subtend angles less than ETA1 deg.
%
% OPTS.GEOM_ETA2 - {default=45deg} 2-dim. feature angle,
% features are located between any neighbouring
% "faces" that subtend angles less than ETA2 deg.
%
% OPTIONAL fields (MESH):
% ----------------------
%
% OPTS.MESH_DIMS - {default=3} number of "topological" di-
% mensions to mesh. DIMS=K meshes K-dimensional featu-
% res, irrespective of the number of spatial dim.'s of
% the problem (i.e. if the geometry is 3-dimensional
% and DIMS=2 a surface mesh will be produced).
%
% OPTIONAL fields (MISC):
% ----------------------
%
% OPTS.VERBOSITY - {default=0} verbosity of log-file gene-
% rated by JIGSAW. Set VERBOSITY >= 1 for more output.
%
% See also LOADMSH, SAVEMSH
%
%-----------------------------------------------------------
% Darren Engwirda
% github.com/dengwirda/jigsaw-matlab
% 18-Apr-2021
%-----------------------------------------------------------
%
jexename = '' ;
if ( isempty(opts))
error('TRIPOD: insufficient inputs!!') ;
end
if (~isempty(opts) && ~isstruct(opts))
error('TRIPOD: invalid input types!!') ;
end
savejig(opts.jcfg_file,opts);
%---------------------------- set-up path for "local" binary
if (strcmp(jexename,''))
filename = ...
mfilename('fullpath') ;
filepath = ...
fileparts( filename ) ;
if (ispc())
jexename = [filepath, ...
'\external\jigsaw\bin\tripod.exe'];
elseif (ismac ())
jexename = [filepath, ...
'/external/jigsaw/bin/tripod'];
elseif (isunix())
jexename = [filepath, ...
'/external/jigsaw/bin/tripod'];
end
end
if (exist(jexename,'file')~=2), jexename=''; end
%---------------------------- search machine path for binary
if (strcmp(jexename,''))
if (ispc())
jexename = 'tripod.exe' ;
elseif (ismac ())
jexename = 'tripod' ;
elseif (isunix())
jexename = 'tripod' ;
end
end
if (exist(jexename,'file')~=2), jexename=''; end
%---------------------------- call TRIPOD and capture stdout
if (exist(jexename,'file')==2)
[status, result] = system( ...
['"',jexename,'"',' ','"',opts.jcfg_file,'"'], ...
'-echo') ;
%---------------------------- OCTAVE doesn't handle '-echo'!
if (exist('OCTAVE_VERSION', 'builtin') > 0)
fprintf(1, '%s', result) ;
end
else
%---------------------------- couldn't find JIGSAW's backend
error([ ...
'TRIPOD''s executable not found -- ', ...
'has JIGSAW been compiled from src?', ...
'See COMPILE for additional detail.', ...
] ) ;
end
if (nargout == +1)
%---------------------------- read mesh if output requested!
if (status == +0)
varargout{1} = loadmsh (opts.mesh_file) ;
else
varargout{1} = [];
end
end
end