Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
exception.h File Reference
#include <fmt/format.h>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  momentum
namespace  momentum::detail

Macros

#define MT_THROW_T(Exception, ...)
 Throws an exception of a specified type with a formatted message.
#define MT_THROW(...)
 Throws a std::runtime_error with a formatted message.
#define MT_THROW_IF_T(Condition, Exception, ...)
 Conditionally throws an exception of a specified type with a formatted message if the condition is true.
#define MT_THROW_IF(Condition, ...)
 Conditionally throws a std::runtime_error with a formatted message if the condition is true.

Typedefs

using momentum::detail::DefaultException = std::runtime_error

Functions

template<typename Exception = DefaultException, typename... Args>
void momentum::detail::throwImpl (fmt::format_string< Args... > format, Args &&... args)
 Fallback when exceptions are disabled: write the formatted message to stderr and abort.
template<typename Exception>
void momentum::detail::throwImpl ()

Macro Definition Documentation

◆ MT_THROW

#define MT_THROW ( ...)
Value:
#define MT_THROW_T(Exception,...)
Throws an exception of a specified type with a formatted message.
Definition exception.h:24
std::runtime_error DefaultException
Definition exception.h:60

Throws a std::runtime_error with a formatted message.

Parameters
...The message and format specifiers.
MT_THROW("Error occurred: {}", errorDetail);
#define MT_THROW(...)
Throws a std::runtime_error with a formatted message.
Definition exception.h:31

Definition at line 31 of file exception.h.

Referenced by momentum::FbxBuilder::addAnimatedMesh(), momentum::FbxBuilder::addAnimatedMesh(), momentum::FbxBuilder::addCharacter(), momentum::FbxBuilder::addMarkerSequence(), momentum::FbxBuilder::addMotion(), momentum::FbxBuilder::addMotionWithJointParams(), momentum::FbxBuilder::addRigidBody(), momentum::createCollisionBox(), momentum::createCollisionCapsule(), momentum::createCollisionEllipsoid(), momentum::fbx_internal::createCollisionGeometryNodes(), momentum::createLocator(), momentum::FullyDifferentiableMotionErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::FullyDifferentiableOrientationErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::FullyDifferentiablePositionErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::FullyDifferentiableStateErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::FbxBuilder::FbxBuilder(), momentum::SkeletonErrorFunctionT< float >::getHessian(), momentum::SolverFunctionT< T >::getHessian(), momentum::FullyDifferentiableMotionErrorFunctionT< T >::getInputImp(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::getInputImp(), momentum::FullyDifferentiableStateErrorFunctionT< T >::getInputImp(), momentum::FullyDifferentiableMotionErrorFunctionT< T >::getInputSize(), momentum::FullyDifferentiableOrientationErrorFunctionT< T >::getInputSize(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::getInputSize(), momentum::FullyDifferentiablePositionErrorFunctionT< T >::getInputSize(), momentum::FullyDifferentiableStateErrorFunctionT< T >::getInputSize(), momentum::LimitErrorFunctionT< T >::getJacobianSize(), momentum::loadCharacterWithMotionCommon(), momentum::loadCharacterWithMotionModelParameterScales(), momentum::loadFbxBlendShapeWeights(), momentum::loadGltfCharacterInternal(), momentum::loadLocatorsFromBuffer(), momentum::loadMotion(), momentum::loadMotionFromModel(), momentum::loadMotionTimestamps(), momentum::loadMppca(), momentum::loadUrdfCharacter(), momentum::loadUrdfCharacter(), momentum::loadUrdfCharacter(), momentum::parameterLimitsFromJson(), momentum::parseParameterLimits(), momentum::FbxBuilder::save(), momentum::saveCharacter(), momentum::saveCharacter(), momentum::saveFbx(), momentum::saveFbxModel(), momentum::saveFbxWithJointParams(), momentum::saveFbxWithSkeletonStates(), momentum::setAccessorType(), momentum::FullyDifferentiableMotionErrorFunctionT< T >::setInputImp(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::setInputImp(), momentum::FullyDifferentiableStateErrorFunctionT< T >::setInputImp(), momentum::subsetParameterTransform(), momentum::fbx_internal::toFbx(), momentum::fbx_internal::toFbx(), momentum::fbx_internal::toFbx(), and momentum::spanstreambuf::xsputn().

◆ MT_THROW_IF

#define MT_THROW_IF ( Condition,
... )
Value:
#define MT_THROW_IF_T(Condition, Exception,...)
Conditionally throws an exception of a specified type with a formatted message if the condition is tr...
Definition exception.h:42

Conditionally throws a std::runtime_error with a formatted message if the condition is true.

Parameters
ConditionThe condition to evaluate.
...The message and format specifiers.
MT_THROW_IF(x == nullptr, "x cannot be nullptr");
#define MT_THROW_IF(Condition,...)
Conditionally throws a std::runtime_error with a formatted message if the condition is true.
Definition exception.h:55

Definition at line 55 of file exception.h.

Referenced by momentum::addGloveBones(), momentum::addGloveCalibrationParameters(), momentum::GltfBuilder::addMotion(), momentum::fbx_internal::addPhysicalProperties(), momentum::applyModelParameterScales(), momentum::applyPassiveJointParameterLimits(), momentum::buildCalibBodySets(), momentum::buildHierarchicalPaths(), momentum::calculateDWorldPos(), momentum::calibrateLocators(), momentum::calibrateMarkers(), momentum::calibrateModel(), momentum::checkAlignment(), momentum::classifyTrianglesByTexture(), momentum::closestPointOnMeshMatchingParent(), momentum::computeConvexHull2d(), momentum::computeFloorLocatorSupportContacts(), momentum::computePlaneCollisionSupportContacts(), momentum::computeSupportContactPositions(), momentum::computeSupportPolygonFromWorldPoints(), momentum::fbx_internal::createCollisionGeometryNodes(), momentum::fbx_internal::createLocatorNodes(), momentum::fbx_internal::createMarkerNodes(), momentum::fbx_internal::createMeshNode(), momentum::fbx_internal::createSkeletonNodes(), momentum::createSkinnedConstraintData(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::UnionErrorFunctionT< T >::d_gradient_d_input_dot(), momentum::extractLocatorsFromCharacter(), momentum::FullyDifferentiableSkeletonErrorFunctionT< T >::getInput(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::getInputImp(), momentum::UnionErrorFunctionT< T >::getInputImp(), momentum::UnionErrorFunctionT< T >::getInputSize(), momentum::ParameterTransformT< T >::getParameterSet(), momentum::getSkinnedLocatorPosition(), momentum::jointPhysicalPropertiesFromJson(), momentum::jointPhysicalPropertiesToJson(), momentum::loadBlendShape(), momentum::loadBlendShapeBase(), momentum::loadBvhCharacter(), momentum::loadBvhCharacterWithMotion(), momentum::loadCharacterFromLegacyJson(), momentum::loadCharacterFromLegacyJsonString(), momentum::loadCharacterWithMotionModelParameterScales(), momentum::loadCharacterWithMotionModelParameterScales(), momentum::loadFullCharacter(), momentum::loadFullCharacterFromBuffer(), momentum::loadHierarchy(), momentum::loadLocators(), momentum::loadLocatorsFromBuffer(), momentum::loadModelDefinition(), momentum::loadModelDefinition(), momentum::loadMomentumModel(), momentum::loadMppca(), momentum::loadMppca(), momentum::loadObj(), momentum::loadOpenFbxMarkerSequence(), momentum::loadSkeletonFromUsd(), momentum::loadTrc(), momentum::loadUsdCharacter(), momentum::loadUsdCharacterWithMotion(), momentum::loadUsdCharacterWithSkeletonStates(), momentum::loadUsdMarkerSequence(), momentum::parameterTransformFromJson(), momentum::parseParameterLimits(), momentum::parseParameterSets(), momentum::parseParameterTransform(), momentum::parsePoseConstraints(), momentum::PointTriangleVertexErrorFunctionT< T >::PointTriangleVertexErrorFunctionT(), momentum::processMarkers(), momentum::refineMotion(), momentum::removeJoints(), momentum::replaceSkeletonHierarchy(), momentum::saveBlendShapesToUsd(), momentum::saveBvhCharacter(), momentum::saveBvhCharacterWithMotion(), momentum::saveCharacter(), momentum::saveCharacter(), momentum::saveCharacterToLegacyJson(), momentum::saveCollisionGeometryToUsd(), momentum::saveLocatorsToUsd(), momentum::MppcaT< T >::set(), momentum::FullyDifferentiableSkeletonErrorFunctionT< T >::setInput(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::setInputImp(), momentum::UnionErrorFunctionT< T >::setInputImp(), momentum::FullyDifferentiablePosePriorErrorFunctionT< T >::setPosePrior(), momentum::Character::simplifySkeleton(), momentum::SkinnedLocatorTriangleErrorFunctionT< T >::SkinnedLocatorTriangleErrorFunctionT(), momentum::splitMeshByTextureRegion(), momentum::SupportPlaneT< T >::SupportPlaneT(), momentum::triangulate(), momentum::UnionErrorFunctionT< T >::UnionErrorFunctionT(), and momentum::writeParameterTransform().

◆ MT_THROW_IF_T

#define MT_THROW_IF_T ( Condition,
Exception,
... )
Value:
do { \
if (Condition) { \
MT_THROW_T(Exception, ##__VA_ARGS__); \
} \
} while (0)

Conditionally throws an exception of a specified type with a formatted message if the condition is true.

Parameters
ConditionThe condition to evaluate.
ExceptionThe type of exception to throw.
...The message and format specifiers.
MT_THROW_IF_T(x > y, std::out_of_range, "x ({}) is greater than y ({})", x, y);
MT_THROW_IF_T(x > y, std::bad_array_new_length); // No message

Definition at line 42 of file exception.h.

Referenced by momentum::alignedAlloc(), momentum::SkeletonT< T >::getChildrenJoints(), and momentum::roundUpToAlignment().

◆ MT_THROW_T

#define MT_THROW_T ( Exception,
... )
Value:

Throws an exception of a specified type with a formatted message.

Parameters
ExceptionThe type of exception to throw.
...The message and format specifiers.
MT_THROW_T(std::invalid_argument, "Invalid argument: {}", arg);
MT_THROW_T(std::bad_array_new_length); // No message

Definition at line 24 of file exception.h.