ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
141 stars 17 forks source link

Refactor `getSize` `size` etc. from OpenSim/SimTK classes to use `osc::size` and `osc::ssize` #757

Closed adamkewley closed 1 year ago

adamkewley commented 1 year ago

This is part of an overall push to remove OpenSim- and SimTK- specific indexing methods/types from downstream code. Instead of patterns like:

for (int i = 0; i < array.getSize(); ++i)
{
    someStdLibVector[static_cast<size_t>(i)] = true;
}

Define osc::size as (e.g.) size_t size(OpenSim::Set<T> const& s) { return static_cast<size_t>(s.getSize); } so that downstream code can be written in a stdlib-like style, rather than having to cast between int, size_t, and ptrdiff_t.