1 /* -------------------------------------------------------------------------- *
2 * OpenSim: example1.cpp *
3 * -------------------------------------------------------------------------- *
4 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation. *
5 * See http://opensim.stanford.edu and the NOTICE file for more information. *
6 * OpenSim is developed at Stanford University and supported by the US *
7 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA *
8 * through the Warrior Web program. *
9 * *
10 * Copyright (c) 2005-2017 Stanford University and the Authors *
11 * Authors: *
12 * *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may *
14 * not use this file except in compliance with the License. You may obtain a *
15 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
16 * *
17 * Unless required by applicable law or agreed to in writing, software *
18 * distributed under the License is distributed on an "AS IS" BASIS, *
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
20 * See the License for the specific language governing permissions and *
21 * limitations under the License. *
22 * -------------------------------------------------------------------------- */
23
24 #include "OpenSim/Common/TimeSeriesTable.h"
25
26 #include <vector>
27 #include <iostream>
28
main()29 int main() {
30 using namespace OpenSim;
31
32 DataTable table{};
33
34 // Add column labels to the table.
35 table.setColumnLabels({"0", "1", "2", "3", "4"});
36
37 // Append rows to the table.
38
39 SimTK::RowVector_<double> row0{5, double{0}};
40
41 table.appendRow(0.00, row0);
42
43 auto row1 = row0 + 1;
44
45 table.appendRow(0.25, row1);
46
47 auto row2 = row1 + 1;
48
49 table.appendRow(0.50, row2);
50
51 auto row3 = row2 + 1;
52
53 table.appendRow(0.75, row3);
54
55 auto row4 = row3 + 1;
56
57 table.appendRow(1.00, row4);
58
59 // Retrieve a column by its label.
60 table.getDependentColumn("3");
61
62 // Print the DataTable to console. This is for debugging only. Do not
63 // rely on this output.
64 std::cout << table << std::endl;
65
66 return 0;
67 }
68