Skip to content

Commit

Permalink
Merge branch 'main' into feature_add-mesh-refcounting
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley authored Feb 5, 2025
2 parents 56f8ea1 + 061f942 commit b0dbfec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ v4.6
- It will now check for NaNed vectors coming from the underlying expression, skipping emission
if one is detected (previously: it would emit decorations with `NaN`ed transforms).
- `PolynomialPathFitter` now allows fitting paths that depend on more than 6 coordinates, matching recent changes to `MultivariatePolynomialFunction` (#4001).
- If an `Object` cannot be found when loading a list property from XML, a warning will now be emitted to the log (previously: it was emitted to `std::cerr`, #4009).
- `OpenSim::Mesh` now retains a reference-counted copy of the mesh data when it's copied, which should make
copying + re-finalizing `OpenSim::Model`s faster.

Expand Down
8 changes: 4 additions & 4 deletions OpenSim/Common/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ try {

// NOT RECOGNIZED
default :
cout<<"Object.UpdateObject: WARN- unrecognized property type."<<endl;
log_warn("Object.UpdateObject: WARN- unrecognized property type.");
break;
}
}
Expand Down Expand Up @@ -1033,7 +1033,7 @@ void Object::updateXMLNode(SimTK::Xml::Element& aParent,
// If object is not inlined we don't want to generate node in original document
// Handle not-inlined objects first.
if (!aParent.isValid()) {
cout<<"Root node must be inlined"<<*this<<endl;
log_warn("Root node of an OpenSim::Object must be inlined, skipping XML reading.");
}
else {
// Can we make this more efficient than recreating the node again?
Expand Down Expand Up @@ -1211,8 +1211,8 @@ void Object::updateXMLNode(SimTK::Xml::Element& aParent,
break;

// NOT RECOGNIZED
default :
cout<<"Object.UpdateObject: WARN- unrecognized property type."<<endl;
default:
log_warn("Object.UpdateObject: WARN- unrecognized property type.");
break;
}
}
Expand Down
30 changes: 13 additions & 17 deletions OpenSim/Common/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -1406,19 +1406,13 @@ ObjectProperty<T>::readFromXMLElement
Object::getDefaultInstanceOfType(objTypeTag);

if (!registeredObj) {
std::cerr
<< "Encountered unrecognized Object typename "
<< objTypeTag << " while reading property " << this->getName()
<< ". There is no registered Object of this type; ignoring.\n";
continue;
log_error("Encountered unrecognized Object typename {} while reading property {}. There is no registered Object of this type. Ignoring.", objTypeTag, this->getName());
continue;
}

// Check that the object type found is derived from T.
if (!dynamic_cast<const T*>(registeredObj)) {
std::cerr << "Object type " << objTypeTag
<< " wrong for " << objectClassName
<< " property " << this->getName()
<< "; ignoring.\n";
log_error("Object type {} wrong for {} property {}. Ignoring.", objTypeTag, objectClassName, this->getName());
continue;
}
++objectsFound;
Expand All @@ -1437,16 +1431,18 @@ ObjectProperty<T>::readFromXMLElement
}

if (objectsFound < this->getMinListSize()) {
std::cerr << "Got " << objectsFound
<< " object values for Property "
<< this->getName() << " but the minimum is "
<< this->getMinListSize() << ". Continuing anyway.\n";
log_error("Got {} object values for Property {} but the minimum is {}. Continuing anyway.",
objectsFound ,
this->getName() ,
this->getMinListSize()
);
}
if (objectsFound > this->getMaxListSize()) {
std::cerr << "Got " << objectsFound
<< " object values for Property "
<< this->getName() << " but the maximum is "
<< this->getMaxListSize() << ". Ignoring the rest.\n";
log_error("Got {} object values for Property {} but the maximum is {}. Ignoring the rest.",
objectsFound,
this->getName(),
this->getMaxListSize()
);
}
}

Expand Down

0 comments on commit b0dbfec

Please sign in to comment.