|
a |
|
b/MATLAB/private/isBodyInModel.m |
|
|
1 |
%-------------------------------------------------------------------------% |
|
|
2 |
% Copyright (c) 2019 Modenese L. % |
|
|
3 |
% % |
|
|
4 |
% Licensed under the Apache License, Version 2.0 (the "License"); % |
|
|
5 |
% you may not use this file except in compliance with the License. % |
|
|
6 |
% You may obtain a copy of the License at % |
|
|
7 |
% http://www.apache.org/licenses/LICENSE-2.0. % |
|
|
8 |
% % |
|
|
9 |
% Unless required by applicable law or agreed to in writing, software % |
|
|
10 |
% distributed under the License is distributed on an "AS IS" BASIS, % |
|
|
11 |
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or % |
|
|
12 |
% implied. See the License for the specific language governing % |
|
|
13 |
% permissions and limitations under the License. % |
|
|
14 |
% % |
|
|
15 |
% Author: Luca Modenese % |
|
|
16 |
% email: l.modenese@imperial.ac.uk % |
|
|
17 |
% ----------------------------------------------------------------------- % |
|
|
18 |
% This script checks if a body of interest is included in an OpenSim model. |
|
|
19 |
% |
|
|
20 |
% INPUTS: |
|
|
21 |
% - osimModel: an OpenSim model as API object. |
|
|
22 |
% - bone_of_interest: a string with the name of the body of interest. |
|
|
23 |
% |
|
|
24 |
% OUTPUT: |
|
|
25 |
% - out: a flag. Flag value 1 means test is passed, otherwise the script |
|
|
26 |
% throws an error. |
|
|
27 |
% |
|
|
28 |
% last modified: |
|
|
29 |
% 23 Jun 2017: comments (LM). |
|
|
30 |
% 16 Feb 2018: changed function name (LM). |
|
|
31 |
% 29 Nov 2018: changed name, recommented, included in MFD toolbox (LM). |
|
|
32 |
% ----------------------------------------------------------------------- % |
|
|
33 |
function out = isBodyInModel(osimModel, aBodyName) |
|
|
34 |
|
|
|
35 |
% load Library |
|
|
36 |
import org.opensim.modeling.*; |
|
|
37 |
|
|
|
38 |
% check if a body with the specified name is part of model. |
|
|
39 |
if osimModel.getBodySet.getIndex(aBodyName)<0 |
|
|
40 |
|
|
|
41 |
% throws error if body is not part of the model |
|
|
42 |
error(['isBodyInModel.m The body ',aBodyName,' is not included in the OpenSim model.']) |
|
|
43 |
|
|
|
44 |
else |
|
|
45 |
|
|
|
46 |
out = 1; |
|
|
47 |
return |
|
|
48 |
end |
|
|
49 |
|
|
|
50 |
end |