Blame toonz/sources/tnzext/Potential.cpp
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/Potential.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <algorithm></algorithm>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(WIN32) && (_MSC_VER <= 1200)
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(push)
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4290)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::Potential::Potential()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
isValid_ = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::Potential::setParameters(const TStroke *ref,
|
|
Toshihiro Shimizu |
890ddd |
double w,
|
|
Toshihiro Shimizu |
890ddd |
double actionLength)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
isValid_ = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(ref);
|
|
Toshihiro Shimizu |
890ddd |
if (!ref)
|
|
Toshihiro Shimizu |
890ddd |
throw std::invalid_argument("Not valid stroke!!!");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(actionLength != 0.0);
|
|
Toshihiro Shimizu |
890ddd |
if (actionLength == 0.0)
|
|
Toshihiro Shimizu |
890ddd |
actionLength = TConsts::epsilon;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(0.0 <= w &&
|
|
Toshihiro Shimizu |
890ddd |
w <= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (0.0 > w ||
|
|
Toshihiro Shimizu |
890ddd |
w > 1.0) {
|
|
Toshihiro Shimizu |
890ddd |
throw std::invalid_argument("Not valid parameter!!!");
|
|
Toshihiro Shimizu |
890ddd |
// w = std::min(std::max(0.0,w),1.0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->setParameters_(ref,
|
|
Toshihiro Shimizu |
890ddd |
w,
|
|
Toshihiro Shimizu |
890ddd |
actionLength);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::Potential::value(double at) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!isValid_)
|
|
Toshihiro Shimizu |
890ddd |
throw std::range_error("Not yet initialized potential!");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(0.0 <= at &&
|
|
Toshihiro Shimizu |
890ddd |
at <= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (0 > at ||
|
|
Toshihiro Shimizu |
890ddd |
at > 1.0)
|
|
Toshihiro Shimizu |
890ddd |
at = std::min(std::max(at, 0.0), 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return this->value_(at);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
// End Of File
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(WIN32) && (_MSC_VER <= 1200)
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(pop)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|