コード例 #1
0
void ModelComponent::addGeometry(OpenSim::Geometry& geom) {
    // Check that name exists and is unique as it's used to form PathName
    if (geom.getName().empty()){
        bool nameFound = false;
        int index = 1;
        while (!nameFound){
            std::stringstream ss;
            // generate candidate name
            ss << getName() << "_geom_" << index;
            std::string candidate = ss.str();
            bool exists = false;
            for (int idx = 0; idx < getProperty_geometry().size() && !exists; idx++){
                if (get_geometry(idx).getName() == candidate){
                    exists = true;
                    break;
                }
            }
            if (!exists){
                nameFound = true;
                geom.setName(candidate);
            }
            else
                index++;
        }
        
    }

    int ix = append_geometry(geom);
    finalizeFromProperties();

    extendAddGeometry(upd_geometry(ix));
}
コード例 #2
0
void ModelComponent::extendFinalizeFromProperties()
{
    Super::extendFinalizeFromProperties();
    int geomSize = getProperty_geometry().size();
    if (geomSize > 0){
        for (int i = 0; i < geomSize; ++i){
            addComponent(&upd_geometry(i));
        }
    }
}