@@ -48,9 +48,8 @@ function i2m_OpeningFcn(hObject, eventdata, handles, varargin)
48
48
49
49
cm = uicontextmenu ;
50
50
uimenu(cm ,' Label' ,' Plot' ,' CallBack' ,{@processdata ,handles });
51
- uimenu(cm ,' Label' ,' Refresh all ' ,' CallBack' ,{@miRefresh_Callback ,handles });
51
+ uimenu(cm ,' Label' ,' Rename ' ,' CallBack' ,{@processdata ,handles });
52
52
uimenu(cm ,' Label' ,' Delete' ,' CallBack' ,{@processdata ,handles });
53
- uimenu(cm ,' Label' ,' Export to JMesh' ,' CallBack' ,{@processdata ,handles });
54
53
55
54
mimeshing = uimenu(cm ,' Label' ,' Meshing' );
56
55
miv2s = uimenu(mimeshing ,' Label' ,' Volume to surface' ,' CallBack' ,{@processdata ,handles });
@@ -83,8 +82,12 @@ function i2m_OpeningFcn(hObject, eventdata, handles, varargin)
83
82
uimenu(mireport ,' Label' ,' Element volume histogram' ,' CallBack' ,{@processdata ,handles });
84
83
uimenu(mireport ,' Label' ,' Total volume' ,' CallBack' ,{@processdata ,handles });
85
84
85
+ mirefresh= uimenu(cm ,' Label' ,' Refresh' ,' CallBack' ,{@miRefresh_Callback ,handles });
86
+ uimenu(cm ,' Label' ,' Save as' ,' CallBack' ,{@processdata ,handles });
87
+
86
88
miv2s.Separator= ' on' ;
87
89
mimeshing.Separator= ' on' ;
90
+ mirefresh.Separator= ' on' ;
88
91
89
92
root= get(handles .fgI2M ,' userdata' );
90
93
@@ -133,17 +136,21 @@ function processdata(source,callbackdata,handles)
133
136
[newdata ,newtype ]=v2sgui(nodedata );
134
137
prefix= ' Vol2Surf' ;
135
138
else
136
- warndlg (' no volume data found' );
139
+ error (' no volume data found' );
137
140
end
138
141
case ' Volume to mesh'
139
142
if (nodetype .hasvol )
140
143
[newdata ,newtype ]=v2mgui(nodedata );
141
144
prefix= ' Vol2Mesh' ;
145
+ else
146
+ error(' no volume data found' );
142
147
end
143
148
case ' Surface to mesh'
144
149
if (nodetype .hasnode && nodetype .hasface )
145
150
[newdata ,newtype ]=s2mgui(nodedata );
146
151
prefix= ' Surf2Mesh' ;
152
+ else
153
+ error(' no surface data found' );
147
154
end
148
155
case ' Surface to volume'
149
156
if (nodetype .hasnode && nodetype .hasface )
@@ -155,13 +162,17 @@ function processdata(source,callbackdata,handles)
155
162
newdata.vol= s2v(nodedata .node ,nodedata .face ,str2num(ndiv{1 }));
156
163
newtype.hasvol= 1 ;
157
164
prefix= ' Surf2Vol' ;
165
+ else
166
+ error(' no surface data found' );
158
167
end
159
168
case ' Close and fill volume'
160
169
if (nodetype .hasvol )
161
170
rad= inputdlg(' maximum gap length in voxel (scalar)' ,' Close and fill a volume' ,1 ,{' 1' });
162
171
newdata.vol= fillholes3d(nodedata .vol ,str2num(rad{1 }));
163
172
newtype= nodetype ;
164
173
prefix= ' FillVol' ;
174
+ else
175
+ error(' no volume data found' );
165
176
end
166
177
case ' Extract surface'
167
178
if (isstruct(nodetype ) && isfield(nodetype ,' hasvol' ) && nodetype .hasvol )
@@ -183,12 +194,16 @@ function processdata(source,callbackdata,handles)
183
194
[newdata .node ,newdata .face ]=meshcheckrepair(nodedata .node ,nodedata .face ,' deep' );
184
195
newtype= nodetype ;
185
196
prefix= ' CleanSurf' ;
197
+ else
198
+ error(' no surface data found' );
186
199
end
187
200
case ' Repair surface'
188
201
if (nodetype .hasnode && nodetype .hasface )
189
202
[newdata .node ,newdata .face ]=meshcheckrepair(nodedata .node ,nodedata .face ,' meshfix' );
190
203
newtype= nodetype ;
191
204
prefix= ' RepairSurf' ;
205
+ else
206
+ error(' no surface data found' );
192
207
end
193
208
case ' Smooth surface'
194
209
if (nodetype .hasnode && nodetype .hasface )
@@ -201,6 +216,8 @@ function processdata(source,callbackdata,handles)
201
216
newtype= nodetype ;
202
217
newdata.node= sms(nodedata .node ,nodedata .face ,str2num(res{2 }),str2num(res{3 }),res{1 });
203
218
prefix= ' SmoothSurf' ;
219
+ else
220
+ error(' no surface data found' );
204
221
end
205
222
case ' Simplify surface'
206
223
if (nodetype .hasnode && nodetype .hasface )
@@ -212,6 +229,8 @@ function processdata(source,callbackdata,handles)
212
229
[newdata .node ,newdata .face ]=meshresample(nodedata .node ,nodedata .face ,str2num(res{1 }));
213
230
newtype= nodetype ;
214
231
prefix= ' SimplifySurf' ;
232
+ else
233
+ error(' no surface data found' );
215
234
end
216
235
case ' Remesh surface'
217
236
if (nodetype .hasnode && nodetype .hasface )
@@ -227,6 +246,8 @@ function processdata(source,callbackdata,handles)
227
246
newtype.hasnode= 1 ;
228
247
newtype.hasface= 1 ;
229
248
prefix= ' RemeshSurf' ;
249
+ else
250
+ error(' no surface data found' );
230
251
end
231
252
case ' Tessellate surface'
232
253
if (nodetype .hasnode && nodetype .hasface )
@@ -235,6 +256,8 @@ function processdata(source,callbackdata,handles)
235
256
newtype= nodetype ;
236
257
newtype.haselem= 1 ;
237
258
prefix= ' TessMesh' ;
259
+ else
260
+ error(' no surface data found' );
238
261
end
239
262
case ' Reorient mesh elements'
240
263
if (nodetype .hasnode && nodetype .haselem )
@@ -245,6 +268,8 @@ function processdata(source,callbackdata,handles)
245
268
[newdata .node ,newdata .face ]=surfreorient(nodedata .node ,nodedata .face );
246
269
newtype= nodetype ;
247
270
prefix= ' ReorientSurf' ;
271
+ else
272
+ error(' no surface or tetrahedral mesh data found' );
248
273
end
249
274
case ' Mesh quality histogram'
250
275
if (nodetype .hasnode && nodetype .haselem )
@@ -296,14 +321,16 @@ function processdata(source,callbackdata,handles)
296
321
msgbox(msg ,' Mesh data report' );
297
322
return ;
298
323
case ' Plot'
299
- if (isstruct(nodetype ) && isfield(nodetype ,' hasnode' ))
324
+ if (isstruct(nodetype ) && isfield(nodetype ,' hasnode' ) && nodetype . hasnode )
300
325
if (isfield(nodetype ,' haselem' ) && nodetype .haselem )
301
326
figure ;plotmesh(nodedata .node ,[],nodedata .elem );
302
327
else
303
328
figure ;plotmesh(nodedata .node ,nodedata .face );
304
329
end
305
330
else
306
- hs= slice(double(nodedata .vol ),[],[ceil(size(nodedata .vol ,2 )*0.5 )],ceil(size(nodedata .vol ,3 )*0.5 ),' parent' ,ax );
331
+ figure ;
332
+ hs= slice(double(nodedata .vol ),[],[ceil(size(nodedata .vol ,2 )*0.5 )],ceil(size(nodedata .vol ,3 )*0.5 ));
333
+ set(hs ,' linestyle' ,' none' );
307
334
end
308
335
case {' Or' ,' And' ,' Diff' ,' All' ,' First' ,' Second' }
309
336
if (isstruct(nodetype ) && isfield(nodetype ,' hasnode' ))
@@ -339,7 +366,18 @@ function processdata(source,callbackdata,handles)
339
366
end
340
367
root.graph= rmnode(root .graph ,root.graph.Nodes.Name{nodeid });
341
368
updategraph(root ,handles );
342
- case ' Export to JMesh'
369
+ case ' Rename'
370
+ newname = inputdlg(' Define a new name:' ,...
371
+ ' Rename' ,1 ,{root.graph.Nodes.Name{nodeid }});
372
+ if (isempty(newname ))
373
+ return ;
374
+ end
375
+ if (isempty(newname{1 }) || ~isempty(cell2mat(regexp( root .graph .Nodes .Name , [' ^' newname{1 } ' $' ]))))
376
+ error(' empty or duplicated node name' );
377
+ end
378
+ root.graph.Nodes.Name{nodeid }=newname{1 };
379
+ updategraph(root ,handles );
380
+ case ' Save as'
343
381
if (~nodetype .haselem && ~nodetype .hasnode )
344
382
error(' selected data does not have a mesh' );
345
383
return ;
@@ -368,8 +406,10 @@ function processdata(source,callbackdata,handles)
368
406
end
369
407
370
408
catch ME
371
- msg= sprintf(' Error: \n%s\n\n File: %s\n Function: %s\n Line: %d ' ,...
372
- ME .message ,ME .stack .file ,ME .stack .name ,ME .stack .line );
409
+ msg= sprintf(' Error: \n%s\n ' ,ME .message );
410
+ for e= 1 : length(ME .stack )
411
+ msg= sprintf(' %s\n File: %s\n Function: %s\n Line: %d\n\n ' ,msg ,ME .stack(e ).file,ME .stack(e ).name,ME .stack(e ).line);
412
+ end
373
413
uiwait(warndlg(msg ,' I2M ERROR' ));
374
414
updategraph(root ,handles );
375
415
end
0 commit comments