Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example code for using the C3DFileAdapter in C++ is found below. This code is part of a test script that runs the C3D reader and writes the resulting tables to files. 

OpenSim 4.4

Expand


Code Block
languagecpp
titleUse C3DFileAdapter
collapsetrue
    using namespace OpenSim;
    using namespace std;
    
    C3DFileAdapter c3dFileAdapter{};
    auto tables = c3dFileAdapter.read(filename);
    std::shared_ptr<TimeSeriesTableVec3> marker_table = c3dFileAdapter.getMarkersTable(tables);
    std::shared_ptr<TimeSeriesTableVec3> force_table = c3dFileAdapter.getForcesTable(tables);
    std::shared_ptr<TimeSeriesTable> analog_table = c3dFileAdapter.getAnalogDataTable(tables);
    const std::string marker_file = base + "_markers.trc";
    const std::string forces_file = base + "_grfs.sto";
    const std::string analogs_file = base + "_analog.sto";

    TRCFileAdapter trc_adapter{};
    trc_adapter.write(*marker_table, marker_file);
    force_table->updTableMetaData().setValueForKey("Units", 
                                                    std::string{"mm"});
    STOFileAdapter sto_adapter{};
    sto_adapter.write((force_table->flatten()), forces_file);
    sto_adapter.write(*analog_table, analogs_file);





Importing Force Data:  COP and NaNs

...