本文整理汇总了C++中ComponentList类的典型用法代码示例。如果您正苦于以下问题:C++ ComponentList类的具体用法?C++ ComponentList怎么用?C++ ComponentList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComponentList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearComponentList
//----------------------------------------------------------------------------//
void RenderedString::clearComponentList(ComponentList& list)
{
for (size_t i = 0; i < list.size(); ++i)
delete list[i];
list.clear();
}
示例2: clearComponentList
//----------------------------------------------------------------------------//
void RenderedString::clearComponentList(ComponentList& list)
{
for (size_t i = 0; i < list.size(); ++i)
CEGUI_DELETE_AO list[i];
list.clear();
}
示例3:
/**
* @param componentList 带参数构造函数.
*
* 通过一个组件列表来构造模型.
* 此时所有组件都是由外部创建,
* 所以置m_SelfOwn为false.
*/
Model::Model(ComponentList &componentList, ConnectorList &connectorList)
{
for (UINT32 i = 0; i < componentList.size(); ++i)
{
IComponent *component = componentList[i]->Clone();
m_ComponentList.push_back(component);
}
for (UINT32 i = 0; i < connectorList.size(); ++i)
{
Connector connector = connectorList[i], connectorClone;
for (UINT32 i = 0; i < componentList.size(); ++i)
{
if (connector.Source == componentList[i])
{
connectorClone.Source = m_ComponentList[i];
}
if (connector.Target == componentList[i])
{
connectorClone.Target = m_ComponentList[i];
}
}
if (connectorClone.Source != NULL && connectorClone.Target != NULL)
{
m_ConnectorList.push_back(connectorClone);
}
}
}
示例4: LogComponentEnableAll
void
LogComponentEnableAll (enum LogLevel level)
{
ComponentList *components = GetComponentList ();
for (ComponentListI i = components->begin ();
i != components->end ();
i++)
{
i->second->Enable (level);
}
}
示例5: reparent
Component::~Component()
{
reparent(0);
ComponentList childListCopy = childList; // need to work on a copy of the set due to iterator problems when deleting the children which attempt to remove themselves from the set..
// clear these two to make the below delete call (which ultimately calls
// reparent and childAdded()) peppier..
childList.clear();
childNameMap.clear();
for (ComponentList::iterator it = childListCopy.begin(); it != childListCopy.end(); ++it)
delete (*it);
idCompMap.erase(id());
NameMap::iterator it = nameCompMap.find(nam);
if (it != nameCompMap.end() && it->second == this) nameCompMap.erase(it);
}
示例6: LogComponentDisable
void
LogComponentDisable (char const *name, enum LogLevel level)
{
ComponentList *components = GetComponentList ();
for (ComponentListI i = components->begin ();
i != components->end ();
i++)
{
if (i->first.compare (name) == 0)
{
i->second->Disable (level);
break;
}
}
}
示例7: m_levels
LogComponent::LogComponent (char const * name)
: m_levels (0), m_name (name)
{
//EnvVarCheck (name);
ComponentList *components = GetComponentList ();
for (ComponentListI i = components->begin ();
i != components->end ();
i++)
{
if (i->first == name)
{
std::cerr << "Log component \""<<name<<"\" has already been registered once." << std::endl;
}
}
components->push_back (std::make_pair (name, this));
}
示例8: getName
void PathWrap::extendConnectToModel(Model& model)
{
Super::extendConnectToModel(model);
_path = dynamic_cast<const GeometryPath*>(&getParent());
std::string msg = "PathWrap '" + getName()
+ "' must have a GeometryPath as its parent.";
OPENSIM_THROW_IF(_path == nullptr, Exception, msg);
ComponentList<const PhysicalFrame> bodiesList =
model.getComponentList<PhysicalFrame>();
for (ComponentList<PhysicalFrame>::const_iterator it = bodiesList.begin();
it != bodiesList.end(); ++it) {
const WrapObject* wo = it->getWrapObject(getWrapObjectName());
if (wo) {
_wrapObject = wo;
updWrapPoint1().setBody(wo->getFrame());
updWrapPoint1().setWrapObject(wo);
updWrapPoint2().setBody(wo->getFrame());
updWrapPoint2().setWrapObject(wo);
break;
}
}
if (get_method() == "hybrid" || get_method() == "Hybrid" || get_method() == "HYBRID")
_method = hybrid;
else if (get_method() == "midpoint" || get_method() == "Midpoint" || get_method() == "MIDPOINT")
_method = midpoint;
else if (get_method() == "axial" || get_method() == "Axial" || get_method() == "AXIAL")
_method = axial;
else if (get_method() == "Unassigned") { // method was not specified in wrap object definition; use default
_method = hybrid;
upd_method() = "hybrid";
} else { // method was specified incorrectly in wrap object definition; throw an exception
string errorMessage = "Error: wrapping method for wrap object " + getName() + " was either not specified, or specified incorrectly.";
throw Exception(errorMessage);
}
}
示例9: GetAllComponentsFor
void EntityManager::GetAllComponentsFor(const Entity *entity, ComponentList &list) const
{
ASSERT(entity != NULL);
if (!IsValid(entity))
return;
for (ComponentStore::const_iterator i = m_components.begin(); i != m_components.end(); ++i)
{
const EntityComponentsMap &entitiesWithComponent = i->second;
EntityComponentsMap::const_iterator j = entitiesWithComponent.find(entity);
if (j != entitiesWithComponent.end())
list.push_back(j->second);
}
}
示例10: findComponents
//---------------------------------------------------------------------------
void Avatar::fireWeaponGroup(int /*groupId*/)
{
// for now, fire everything
ComponentList list;
findComponents(EquipmentSlotComponent::getClassDef(), list);
for (ComponentList::iterator it = list.begin(); it != list.end(); ++it)
{
EquipmentSlotComponent* pSlot = static_cast<EquipmentSlotComponent*>(*it);
if (pSlot)
{
size_t numEquipment = pSlot->getNumEquipment();
for (size_t i=0; i<numEquipment; ++i)
{
Mountable* pMountable = pSlot->getEquipment(i);
if (pMountable && pMountable->isOfType(Weapon::getClassDef()))
{
Weapon* pWeapon = static_cast<Weapon*>(pMountable);
pWeapon->fire();
}
}
}
}
}
示例11: LogComponentEnable
void
LogComponentEnable (char const *name, enum LogLevel level)
{
ComponentList *components = GetComponentList ();
ComponentListI i;
for (i = components->begin ();
i != components->end ();
i++)
{
if (i->first.compare (name) == 0)
{
i->second->Enable (level);
return;
}
}
if (i == components->end())
{
// nothing matched
LogComponentPrintList();
NS_FATAL_ERROR ("Logging component \"" << name <<
"\" not found. See above for a list of available log components");
}
}
示例12: connectToModelAndPath
void PathWrap::connectToModelAndPath(Model& aModel, GeometryPath& aPath)
{
_path = &aPath;
ComponentList<PhysicalFrame> bodiesList = aModel.getComponentList<PhysicalFrame>();
for (ComponentList<PhysicalFrame>::const_iterator it = bodiesList.begin();
it != bodiesList.end(); ++it) {
const WrapObject* wo = it->getWrapObject(getWrapObjectName());
if (wo) {
_wrapObject = wo;
updWrapPoint1().setBody(wo->getBody());
updWrapPoint1().setWrapObject(wo);
updWrapPoint2().setBody(wo->getBody());
updWrapPoint2().setWrapObject(wo);
break;
}
}
// connectToModelAndPath() must be called after setBody() because it requires
// that _bodyName already be assigned.
updWrapPoint1().connectToModelAndPath(aModel, aPath);
updWrapPoint2().connectToModelAndPath(aModel, aPath);
if (get_method() == "hybrid" || get_method() == "Hybrid" || get_method() == "HYBRID")
_method = hybrid;
else if (get_method() == "midpoint" || get_method() == "Midpoint" || get_method() == "MIDPOINT")
_method = midpoint;
else if (get_method() == "axial" || get_method() == "Axial" || get_method() == "AXIAL")
_method = axial;
else if (get_method() == "Unassigned") { // method was not specified in wrap object definition; use default
_method = hybrid;
upd_method() = "hybrid";
} else { // method was specified incorrectly in wrap object definition; throw an exception
string errorMessage = "Error: wrapping method for wrap object " + getName() + " was either not specified, or specified incorrectly.";
throw Exception(errorMessage);
}
}
示例13: testComponentList
void testComponentList()
{
if (os_) *os_ << "testComponentList()\n";
ComponentList componentList;
componentList.push_back(Component(ComponentType_Source, 1));
componentList.push_back(Component(ComponentType_Analyzer, 2));
componentList.push_back(Component(ComponentType_Detector, 3));
componentList.source(0).paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pg")));
componentList.analyzer(0).paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pg")));
componentList.detector(0).paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pg")));
MSData msd;
msd.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pg")));
msd.paramGroupPtrs.back()->userParams.push_back(UserParam("user"));
References::resolve(componentList, msd);
unit_assert(!componentList.source(0).paramGroupPtrs[0]->userParams.empty());
unit_assert(!componentList.analyzer(0).paramGroupPtrs[0]->userParams.empty());
unit_assert(!componentList.detector(0).paramGroupPtrs[0]->userParams.empty());
}
示例14: main
int main()
{
try {
LoadOpenSimLibrary("osimActuators");
std::string filename = "arm26.osim";
Model model(filename);
model.dumpSubcomponents();
ComponentList<Component> componentsList = model.getComponentList();
std::cout << "list begin: " << componentsList.begin()->getName() << std::endl;
int numComponents = 0;
for (ComponentList<Component>::const_iterator it = componentsList.begin();
it != componentsList.end();
++it) {
std::cout << "Iterator is at: " << it->getFullPathName() << " <" << it->getConcreteClassName() << ">" << std::endl;
numComponents++;
}
ComponentList<OpenSim::Body> bodiesList = model.getComponentList<OpenSim::Body>();
int numBodies = 0;
std::cout << "Bodies list begin: " << bodiesList.begin()->getName() << std::endl;
for (ComponentList<OpenSim::Body>::const_iterator it = bodiesList.begin();
it != bodiesList.end();
++it) {
std::cout << "Iterator is at Body: " << it->getName() << std::endl;
numBodies++;
}
// Now we try the post increment variant of the iterator
std::cout << "Bodies list begin, using post increment: " << bodiesList.begin()->getName() << std::endl;
int numBodiesPost = 0;
for (ComponentList<OpenSim::Body>::const_iterator itPost = bodiesList.begin();
itPost != bodiesList.end();
itPost++) {
std::cout << "Iterator is at Body: " << itPost->getName() << std::endl;
numBodiesPost++;
}
int numMuscles = 0;
std::cout << "Using range-for loop over Muscles: " << std::endl;
ComponentList<Muscle> musclesList = model.getComponentList<Muscle>();
for (const Muscle& muscle : musclesList) {
std::cout << "Iterator is at muscle: " << muscle.getName() << std::endl;
numMuscles++;
}
int numGeomPaths = 0;
ComponentList<GeometryPath> geomPathList = model.getComponentList<GeometryPath>();
for (const GeometryPath& gpath : geomPathList) {
(void)gpath; // Suppress unused variable warning.
numGeomPaths++;
}
const OpenSim::Joint& shoulderJnt = model.getJointSet().get(0);
// cycle through components under shoulderJnt should return the Joint itself and the Coordinate
int numJntComponents = 0;
ComponentList<Component> jComponentsList = shoulderJnt.getComponentList();
std::cout << "Components/subComponents under Shoulder Joint:" << std::endl;
for (ComponentList<Component>::const_iterator it = jComponentsList.begin();
it != jComponentsList.end();
++it) {
std::cout << "Iterator is at: " << it->getConcreteClassName() << " " << it->getFullPathName() << std::endl;
numJntComponents++;
}
cout << "Num all components = " << numComponents << std::endl;
cout << "Num bodies = " << numBodies << std::endl;
cout << "Num Muscles = " << numMuscles << std::endl;
cout << "Num GeometryPath components = " << numGeomPaths << std::endl;
// Components = Model+3Body+3Marker+2(Joint+Coordinate)+6(Muscle+GeometryPath)
// Should test against 1+#Bodies+#Markers+#Joints+#Constraints+#Coordinates+#Forces+#ForcesWithPath+..
// Would that account for internal (split-bodies etc.?)
// To test states we must have added the components to the system
// which is done when the model creates and initializes the system
SimTK::State state = model.initSystem();
int numJointsWithStateVariables = 0;
ComponentList<Joint> jointsWithStates = model.getComponentList<Joint>();
ComponentWithStateVariables myFilter;
jointsWithStates.setFilter(myFilter);
for (const Joint& comp : jointsWithStates) {
cout << comp.getConcreteClassName() << ":" << comp.getFullPathName() << endl;
numJointsWithStateVariables++;
}
int numModelComponentsWithStateVariables = 0;
ComponentList<ModelComponent> comps = model.getComponentList<ModelComponent>();
comps.setFilter(myFilter);
for (const ModelComponent& comp : comps) {
cout << comp.getConcreteClassName() << ":" << comp.getFullPathName() << endl;
numModelComponentsWithStateVariables++;
}
//Now test a std::iterator method
ComponentList<Frame> allFrames = model.getComponentList<Frame>();
ComponentList<Frame>::const_iterator skipIter = allFrames.begin();
int countSkipFrames = 0;
while (skipIter != allFrames.end()){
cout << skipIter->getConcreteClassName() << ":" << skipIter->getFullPathName() << endl;
std::advance(skipIter, 2);
countSkipFrames++;
}
//.........这里部分代码省略.........
示例15: unity
/**
* This method scales a model based on user-specified XYZ body scale factors
* and/or a set of marker-to-marker distance measurements.
*
* @param aModel the model to scale.
* @param aSubjectMass the final mass of the model after scaling.
* @return Whether the scaling process was successful or not.
*/
bool ModelScaler::processModel(Model* aModel, const string& aPathToSubject, double aSubjectMass)
{
if (!getApply()) return false;
int i;
ScaleSet theScaleSet;
Vec3 unity(1.0);
cout << endl << "Step 2: Scaling generic model" << endl;
ComponentList<PhysicalFrame> segments
= aModel->getComponentList<PhysicalFrame>();
ComponentList<PhysicalFrame>::const_iterator it = segments.begin();
/* Make a scale set with a Scale for each physical frame.
* Initialize all factors to 1.0.
*/
for (; it != segments.end(); ++it) {
Scale* segmentScale = new Scale();
segmentScale->setSegmentName(it->getName());
segmentScale->setScaleFactors(unity);
segmentScale->setApply(true);
theScaleSet.adoptAndAppend(segmentScale);
}
SimTK::State& s = aModel->initSystem();
aModel->getMultibodySystem().realize(s, SimTK::Stage::Position);
try
{
/* Make adjustments to theScaleSet, in the user-specified order. */
for (i = 0; i < _scalingOrder.getSize(); i++)
{
/* For measurements, measure the distance between a pair of markers
* in the model, and in the static pose. The latter divided by the
* former is the scale factor. Put that scale factor in theScaleSet,
* using the body/axis names specified in the measurement to
* determine in what place[s] to put the factor.
*/
if (_scalingOrder[i] == "measurements")
{
/* Load the static pose marker file, and convert units.
*/
MarkerData *markerData = 0;
if(!_markerFileName.empty() && _markerFileName!=PropertyStr::getDefaultStr()) {
markerData = new MarkerData(aPathToSubject + _markerFileName);
markerData->convertToUnits(aModel->getLengthUnits());
}
/* Now take and apply the measurements. */
for (int j = 0; j < _measurementSet.getSize(); j++)
{
if (_measurementSet.get(j).getApply())
{
if(!markerData)
throw Exception("ModelScaler.processModel: ERROR- "+_markerFileNameProp.getName()+
" not set but measurements are used",__FILE__,__LINE__);
double scaleFactor = computeMeasurementScaleFactor(s,*aModel, *markerData, _measurementSet.get(j));
if (!SimTK::isNaN(scaleFactor))
_measurementSet.get(j).applyScaleFactor(scaleFactor, theScaleSet);
else
cout << "___WARNING___: " << _measurementSet.get(j).getName() << " measurement not used to scale " << aModel->getName() << endl;
}
}
}
/* For manual scales, just copy the XYZ scale factors from
* the manual scale into theScaleSet.
*/
else if (_scalingOrder[i] == "manualScale")
{
for (int j = 0; j < _scaleSet.getSize(); j++)
{
if (_scaleSet[j].getApply())
{
const string& bodyName = _scaleSet[j].getSegmentName();
Vec3 factors(1.0);
_scaleSet[j].getScaleFactors(factors);
for (int k = 0; k < theScaleSet.getSize(); k++)
{
if (theScaleSet[k].getSegmentName() == bodyName)
theScaleSet[k].setScaleFactors(factors);
}
}
}
}
else
{
throw Exception("ModelScaler: ERR- Unrecognized string '"+_scalingOrder[i]+"' in "+_scalingOrderProp.getName()+" property (expecting 'measurements' or 'manualScale').",__FILE__,__LINE__);
}
}
/* Now scale the model. */
//.........这里部分代码省略.........