<commit_before>/* -------------------------------------------------------------------------- *
 *                             OpenSim:  Frame.cpp                             *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2012 Stanford University and the Authors                *
 * Author(s): <NAME> & <NAME>                                       *
 *                                                                            *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
 * not use this file except in compliance with the License. You may obtain a  *
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 * -------------------------------------------------------------------------- */

//=============================================================================
// INCLUDES
//=============================================================================
#include "Frame.h"

//=============================================================================
// STATICS
//=============================================================================
using namespace std;
using namespace OpenSim;
using SimTK::Mat33;
using SimTK::Vec3;
using SimTK::State;
using SimTK::SpatialVec;

//=============================================================================
// CONSTRUCTOR(S)
//=============================================================================
Frame::Frame() : ModelComponent()
{
    setAuthors("<NAME>, <NAME>");

    constructProperty_attached_geometry();
    FrameGeometry* default_geometry = new FrameGeometry();
    default_geometry->setName("frame_geometry");
    updProperty_attached_geometry().adoptAndAppendValue(default_geometry);
    updProperty_attached_geometry().setValueIsDefault(true);
}

void Frame::extendConnectToModel(Model& model)
{
    int naf = getProperty_attached_geometry().size();
    for (int i = 0; i < naf; ++i) {
        upd_attached_geometry(i).updInput("transform")
            .connect(getOutput("transform"));
    }
}

void Frame::extendAddToSystem(SimTK::MultibodySystem& system) const
{
    SimTK::Transform x;
    SpatialVec v;
    // If the properties, topology or coordinate values change, 
    // Stage::Position and above will be invalid.
    addCacheVariable("transform_in_g", x, SimTK::Stage::Position);
    // if a speed (u) changes then Stage::Velocity will also be invalid<commit_msg>When connecting up attached geometry, make sure to disconnect first.<commit_after>/* -------------------------------------------------------------------------- *
 *                             OpenSim:  Frame.cpp                             *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2012 Stanford University and the Authors                *
 * Author(s): <NAME> & <NAME>                                       *
 *                                                                            *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
 * not use this file except in compliance with the License. You may obtain a  *
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 * -------------------------------------------------------------------------- */

//=============================================================================
// INCLUDES
//=============================================================================
#include "Frame.h"

//=============================================================================
// STATICS
//=============================================================================
using namespace std;
using namespace OpenSim;
using SimTK::Mat33;
using SimTK::Vec3;
using SimTK::State;
using SimTK::SpatialVec;

//=============================================================================
// CONSTRUCTOR(S)
//=============================================================================
Frame::Frame() : ModelComponent()
{
    setAuthors("<NAME>, <NAME>");

    constructProperty_attached_geometry();
    FrameGeometry* default_geometry = new FrameGeometry();
    default_geometry->setName("frame_geometry");
    updProperty_attached_geometry().adoptAndAppendValue(default_geometry);
    updProperty_attached_geometry().setValueIsDefault(true);
}

void Frame::extendConnectToModel(Model& model)
{
    int nag = getProperty_attached_geometry().size();
    for (int i = 0; i < nag; ++i) {
        upd_attached_geometry(i).updInput("transform").disconnect();
        upd_attached_geometry(i).updInput("transform")
            .connect(getOutput("transform"));
    }
}

void Frame::extendAddToSystem(SimTK::MultibodySystem& system) const
{
    SimTK::Transform x;
    SpatialVec v;
    // If the properties, topology or coordinate values change, 
    // Stage::Position and above will be invalid.
    addCacheVariable("transform_in_g", x, SimTK::Stage::Position);
    // if a speed (u) changes then Stage::Velocity will also be invalid
{'fraction_non_alphanumeric': 0.2721410146173689, 'fraction_numerical': 0.009171682430495844, 'mean_word_length': 2.013385146804836, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5304916', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1405, 'n_words': 451}