|
Toshihiro Shimizu |
890ddd |
#include <sstream> /* std::ostringstream */</sstream>
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ino_common.h"
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
class ino_motion_wind : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(ino_motion_wind)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_refer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_direction;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_dark;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_alpha_rendering;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_length_min;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_length_max;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_length_bias;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_length_seed;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_length_ref;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_force_min;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_force_max;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_force_bias;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_force_seed;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_force_ref;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_density_min;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_density_max;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_density_bias;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_density_seed;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_density_ref;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TBoolParamP m_spread;
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_ref_mode;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ino_motion_wind()
|
|
Toshihiro Shimizu |
890ddd |
: m_direction(new TIntEnumParam(0, "Right")), m_dark(false), m_alpha_rendering(true)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_length_min(0.0), m_length_max(18.0), m_length_bias(1.0 * ino::param_range()), m_length_seed(1.0), m_length_ref(false)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_force_min(1.0 * ino::param_range()), m_force_max(1.0 * ino::param_range()), m_force_bias(1.0 * ino::param_range()), m_force_seed(1.0), m_force_ref(false)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_density_min(1.0 * ino::param_range()), m_density_max(1.0 * ino::param_range()), m_density_bias(1.0 * ino::param_range()), m_density_seed(1.0), m_density_ref(false)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// , m_spread(true)
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_ref_mode(new TIntEnumParam(0, "Red"))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_min->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_max->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", this->m_input);
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Reference", this->m_refer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "direction", this->m_direction);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "dark", this->m_dark);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "alpha_rendering", this->m_alpha_rendering);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "length_min", this->m_length_min);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "length_max", this->m_length_max);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "length_bias", this->m_length_bias);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "length_seed", this->m_length_seed);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "length_ref", this->m_length_ref);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "force_min", this->m_force_min);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "force_max", this->m_force_max);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "force_bias", this->m_force_bias);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "force_seed", this->m_force_seed);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "force_ref", this->m_force_ref);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "density_min", this->m_density_min);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "density_max", this->m_density_max);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "density_bias", this->m_density_bias);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "density_seed", this->m_density_seed);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "density_ref", this->m_density_ref);
|
|
Toshihiro Shimizu |
890ddd |
// bindParam(this,"spread", this->m_spread);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "reference", this->m_ref_mode);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_direction->addItem(1, "Up");
|
|
Toshihiro Shimizu |
890ddd |
this->m_direction->addItem(2, "Left");
|
|
Toshihiro Shimizu |
890ddd |
this->m_direction->addItem(3, "Down");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_min->setValueRange(0.0, 1000.0);
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_max->setValueRange(0.0, 1000.0);
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_bias->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_seed->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0, std::numeric_limits<unsigned long="">::max());</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_force_min->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_force_max->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_force_bias->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_force_seed->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0, std::numeric_limits<unsigned long="">::max());</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_min->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.0 * ino::param_range(), 100.0 * ino::param_range());
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_max->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.0 * ino::param_range(), 100.0 * ino::param_range());
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_bias->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_seed->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0, std::numeric_limits<unsigned long="">::max());</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_ref_mode->addItem(1, "Green");
|
|
Toshihiro Shimizu |
890ddd |
this->m_ref_mode->addItem(2, "Blue");
|
|
Toshihiro Shimizu |
890ddd |
this->m_ref_mode->addItem(3, "Alpha");
|
|
Toshihiro Shimizu |
890ddd |
this->m_ref_mode->addItem(4, "Luminance");
|
|
Toshihiro Shimizu |
890ddd |
this->m_ref_mode->addItem(-1, "Nothing");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(
|
|
Toshihiro Shimizu |
890ddd |
double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (this->m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
const bool ret = this->m_input->doGetBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
// if ( this->m_spread->getValue() ) {
|
|
Toshihiro Shimizu |
890ddd |
const double min = this->m_length_min->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
const double max = this->m_length_max->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
const double margin = ceil(
|
|
Toshihiro Shimizu |
890ddd |
ino::pixel_per_mm() * ((min < max) ? max : min));
|
|
Toshihiro Shimizu |
890ddd |
if (0.0 < margin) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = bBox.enlarge(margin);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
// }
|
|
Toshihiro Shimizu |
890ddd |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//return true;
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rect, double frame, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const double mm2scale_shrink_pixel =
|
|
Toshihiro Shimizu |
890ddd |
ino::pixel_per_mm() * sqrt(fabs(info.m_affine.det())) / ((info.m_shrinkX + info.m_shrinkY) / 2.0);
|
|
Toshihiro Shimizu |
890ddd |
const double length_min = this->m_length_min->getValue(frame) * mm2scale_shrink_pixel;
|
|
Toshihiro Shimizu |
890ddd |
const double length_max = this->m_length_max->getValue(frame) * mm2scale_shrink_pixel;
|
|
Toshihiro Shimizu |
890ddd |
const int enlarge_pixel = (int)(ceil(
|
|
Toshihiro Shimizu |
890ddd |
(length_min < length_max) ? length_max : length_min) +
|
|
Toshihiro Shimizu |
890ddd |
0.5);
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(
|
|
Toshihiro Shimizu |
890ddd |
rect.enlarge(enlarge_pixel), info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rend_sets);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(ino_motion_wind, "inoMotionWindFx");
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include "igs_motion_wind.h"
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
void fx_(
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP in_ras // with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP refer_ras // with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int ref_mode, const int margin, TRasterP out_ras // no margin
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int direction, const bool dark_sw, const bool alpha_rendering_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double length_min, const double length_max, const double length_bias, const unsigned long length_seed, const bool length_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double force_min, const double force_max, const double force_bias, const unsigned long force_seed, const bool force_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double density_min, const double density_max, const double density_bias, const unsigned long density_seed, const bool density_ref_sw)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/***std::vector<unsigned char=""> in_vec;</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_vec( in_ras, ino::channels(), in_vec );
|
|
Toshihiro Shimizu |
890ddd |
std::vector<unsigned char=""> refer_vec;</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_vec( refer_ras, ino::channels(), refer_vec );***/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterGR8P in_gr8(
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy(), in_ras->getLx() * ino::channels() *
|
|
Toshihiro Shimizu |
890ddd |
((TRaster64P)in_ras ? sizeof(unsigned short) : sizeof(unsigned char)));
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->lock();
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_arr(in_ras, ino::channels(), in_gr8->getRawData());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (0 != refer_ras) {
|
|
Toshihiro Shimizu |
890ddd |
TRasterGR8P refer_gr8(
|
|
Toshihiro Shimizu |
890ddd |
refer_ras->getLy(), refer_ras->getLx() * ino::channels() *
|
|
Toshihiro Shimizu |
890ddd |
((TRaster64P)refer_ras ? sizeof(unsigned short) : sizeof(unsigned char)));
|
|
Toshihiro Shimizu |
890ddd |
refer_gr8->lock();
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_arr(
|
|
Toshihiro Shimizu |
890ddd |
refer_ras, ino::channels(), refer_gr8->getRawData());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
igs::motion_wind::change(
|
|
Toshihiro Shimizu |
890ddd |
//in_ras->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
//&in_vec.at(0) // RGBA
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
refer_gr8->getRawData()
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
refer_ras->getLy(), refer_ras->getLx(), ino::channels(), ino::bits(refer_ras)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
ref_mode
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
direction, dark_sw, alpha_rendering_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
length_seed, length_min, length_max, length_bias, length_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
force_seed, force_min, force_max, force_bias, force_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
density_seed, density_min, density_max, density_bias, density_ref_sw);
|
|
Toshihiro Shimizu |
890ddd |
/***ino::vec_to_ras( refer_vec, 0, 0 );
|
|
Toshihiro Shimizu |
890ddd |
ino::vec_to_ras( in_vec, ino::channels(), out_ras, margin );***/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ino::arr_to_ras(
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->getRawData(), ino::channels(), out_ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
refer_gr8->unlock();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
igs::motion_wind::change(
|
|
Toshihiro Shimizu |
890ddd |
//in_ras->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
//&in_vec.at(0) // RGBA
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
0
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
0, 0, 0, 0
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
0
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
direction, dark_sw, alpha_rendering_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
length_seed, length_min, length_max, length_bias, length_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
force_seed, force_min, force_max, force_bias, force_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
density_seed, density_min, density_max, density_bias, density_ref_sw);
|
|
Toshihiro Shimizu |
890ddd |
/***ino::vec_to_ras( refer_vec, 0, 0 );
|
|
Toshihiro Shimizu |
890ddd |
ino::vec_to_ras( in_vec, ino::channels(), out_ras, margin );***/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ino::arr_to_ras(
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->getRawData(), ino::channels(), out_ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
in_gr8->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
void ino_motion_wind::doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rend_sets)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 接続していなければ処理しない -------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!this->m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear(); /* 塗りつぶしクリア */
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ サポートしていないPixelタイプはエラーを投げる --- */
|
|
Toshihiro Shimizu |
890ddd |
if (!((TRaster32P)tile.getRaster()) &&
|
|
Toshihiro Shimizu |
890ddd |
!((TRaster64P)tile.getRaster())) {
|
|
Toshihiro Shimizu |
890ddd |
throw TRopException("unsupported input pixel type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ Pixel単位で動作パラメータを得る ----------------- */
|
|
Toshihiro Shimizu |
890ddd |
/* 単位変換用スケーリング
|
|
Toshihiro Shimizu |
890ddd |
外積(面積)
|
|
Toshihiro Shimizu |
890ddd |
rend_sets.m_affine.det() = a11*a22-a12*a21 // double
|
|
Toshihiro Shimizu |
890ddd |
シュリンク値
|
|
Toshihiro Shimizu |
890ddd |
rend_sets.m_shrinkX // int
|
|
Toshihiro Shimizu |
890ddd |
rend_sets.m_shrinkY // int
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
const double mm2scale_shrink_pixel =
|
|
Toshihiro Shimizu |
890ddd |
ino::pixel_per_mm() * sqrt(fabs(rend_sets.m_affine.det())) / ((rend_sets.m_shrinkX + rend_sets.m_shrinkY) / 2.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 動作パラメータを得る */
|
|
Toshihiro Shimizu |
890ddd |
const int direction = this->m_direction->getValue();
|
|
Toshihiro Shimizu |
890ddd |
const bool dark_sw = this->m_dark->getValue();
|
|
Toshihiro Shimizu |
890ddd |
const bool alp_rend_sw = this->m_alpha_rendering->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const double length_min = this->m_length_min->getValue(frame) * mm2scale_shrink_pixel;
|
|
Toshihiro Shimizu |
890ddd |
const double length_max = this->m_length_max->getValue(frame) * mm2scale_shrink_pixel;
|
|
Toshihiro Shimizu |
890ddd |
const double length_bias = this->m_length_bias->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const unsigned long length_seed =
|
|
Toshihiro Shimizu |
890ddd |
this->m_length_seed->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
const bool length_ref_sw = this->m_length_ref->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const double force_min = this->m_force_min->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const double force_max = this->m_force_max->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const double force_bias = this->m_force_bias->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const unsigned long force_seed =
|
|
Toshihiro Shimizu |
890ddd |
this->m_force_seed->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
const bool force_ref_sw = this->m_force_ref->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const double density_min = this->m_density_min->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const double density_max = this->m_density_max->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const double density_bias =
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_bias->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const unsigned long density_seed =
|
|
Toshihiro Shimizu |
890ddd |
this->m_density_seed->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
const bool density_ref_sw = this->m_density_ref->getValue();
|
|
Toshihiro Shimizu |
890ddd |
const int ref_mode = this->m_ref_mode->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 参照マージン含めた画像生成 ---------------------- */
|
|
Toshihiro Shimizu |
890ddd |
/* Rendering画像のBBox値 --> Pixel単位のdouble値 */
|
|
Toshihiro Shimizu |
890ddd |
/* typedef TRectT<double> TRectD;</double>
|
|
Toshihiro Shimizu |
890ddd |
inline TRectT<double>::TRectT(</double>
|
|
Toshihiro Shimizu |
890ddd |
const TPointT<double> &bottomLeft</double>
|
|
Toshihiro Shimizu |
890ddd |
, const TDimensionT<double> &d</double>
|
|
Toshihiro Shimizu |
890ddd |
) : x0(bottomLeft.x)
|
|
Toshihiro Shimizu |
890ddd |
, y0(bottomLeft.y)
|
|
Toshihiro Shimizu |
890ddd |
, x1(bottomLeft.x+d.lx)
|
|
Toshihiro Shimizu |
890ddd |
, y1(bottomLeft.y+d.ly)
|
|
Toshihiro Shimizu |
890ddd |
{}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
TRectD enlarge_rect = TRectD(
|
|
Toshihiro Shimizu |
890ddd |
tile.m_pos /* TPointD */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
TDimensionD(/* int --> doubleにしてセット */
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->getLx(), tile.getRaster()->getLy()));
|
|
Toshihiro Shimizu |
890ddd |
/* BBoxの拡大 Pixel単位 */
|
|
Toshihiro Shimizu |
890ddd |
const int enlarge_pixel = (int)(ceil(
|
|
Toshihiro Shimizu |
890ddd |
(length_min < length_max) ? length_max : length_min) +
|
|
Toshihiro Shimizu |
890ddd |
0.5);
|
|
Toshihiro Shimizu |
890ddd |
enlarge_rect = enlarge_rect.enlarge(enlarge_pixel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* void TRasterFx::allocateAndCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &pos, const TDimension &size,
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP &templateRas, double frame,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &info
|
|
Toshihiro Shimizu |
890ddd |
) {
|
|
Toshihiro Shimizu |
890ddd |
if (templateRas) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster() = templateRas->create(size.lx, size.ly);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster() = TRaster32P(size.lx, size.ly);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tile.m_pos = pos;
|
|
Toshihiro Shimizu |
890ddd |
compute(tile, frame, info);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
TTile enlarge_tile;
|
|
Toshihiro Shimizu |
890ddd |
this->m_input->allocateAndCompute(
|
|
Toshihiro Shimizu |
890ddd |
enlarge_tile, enlarge_rect.getP00(), TDimensionI(/* Pixel単位のdouble -> intにしてセット */
|
|
Toshihiro Shimizu |
890ddd |
(int)(enlarge_rect.getLx() + 0.5), (int)(enlarge_rect.getLy() + 0.5)),
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster(), frame, rend_sets);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear(); /* 塗りつぶしクリア */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 参照画像生成 ------------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
TTile refer_tile;
|
|
Toshihiro Shimizu |
890ddd |
const bool refer_cn_is = this->m_refer.isConnected();
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_refer->allocateAndCompute(
|
|
Toshihiro Shimizu |
890ddd |
refer_tile
|
|
Toshihiro Shimizu |
890ddd |
// tile.m_pos,
|
|
Toshihiro Shimizu |
890ddd |
// tile.getRaster()->getSize(),
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
enlarge_rect.getP00(), TDimensionI(/* Pixel単位のdouble -> intにしてセット */
|
|
Toshihiro Shimizu |
890ddd |
(int)(enlarge_rect.getLx() + 0.5), (int)(enlarge_rect.getLy() + 0.5)),
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster(), frame, rend_sets);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ (app_begin)log記憶 ------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
const bool log_sw = ino::log_enable_sw();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::ostringstream os;
|
|
Toshihiro Shimizu |
890ddd |
os << "params"
|
|
Toshihiro Shimizu |
890ddd |
<< " dir " << direction
|
|
Toshihiro Shimizu |
890ddd |
<< " dark_sw " << dark_sw
|
|
Toshihiro Shimizu |
890ddd |
<< " alp_rend_sw " << alp_rend_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
<< " len_min " << length_min
|
|
Toshihiro Shimizu |
890ddd |
<< " len_max " << length_max
|
|
Toshihiro Shimizu |
890ddd |
<< " len_bias " << length_bias
|
|
Toshihiro Shimizu |
890ddd |
<< " len_seed " << length_seed
|
|
Toshihiro Shimizu |
890ddd |
<< " len_ref_sw " << length_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
<< " for_min " << force_min
|
|
Toshihiro Shimizu |
890ddd |
<< " for_max " << force_max
|
|
Toshihiro Shimizu |
890ddd |
<< " for_bias " << force_bias
|
|
Toshihiro Shimizu |
890ddd |
<< " for_seed " << force_seed
|
|
Toshihiro Shimizu |
890ddd |
<< " for_ref_sw " << force_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
<< " den_min " << density_min
|
|
Toshihiro Shimizu |
890ddd |
<< " den_max " << density_max
|
|
Toshihiro Shimizu |
890ddd |
<< " den_bias " << density_bias
|
|
Toshihiro Shimizu |
890ddd |
<< " den_seed " << density_seed
|
|
Toshihiro Shimizu |
890ddd |
<< " den_ref_sw " << density_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
<< " reference " << ref_mode
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
<< " tile w " << tile.getRaster()->getLx()
|
|
Toshihiro Shimizu |
890ddd |
<< " h " << tile.getRaster()->getLy()
|
|
Toshihiro Shimizu |
890ddd |
<< " pixbits " << ino::pixel_bits(tile.getRaster());
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
os
|
|
Toshihiro Shimizu |
890ddd |
<< " rtile w " << refer_tile.getRaster()->getLx()
|
|
Toshihiro Shimizu |
890ddd |
<< " h " << refer_tile.getRaster()->getLy();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os
|
|
Toshihiro Shimizu |
890ddd |
<< " frame " << frame
|
|
Toshihiro Shimizu |
890ddd |
<< " rand_sets affine_det " << rend_sets.m_affine.det()
|
|
Toshihiro Shimizu |
890ddd |
<< " shrink x " << rend_sets.m_shrinkX
|
|
Toshihiro Shimizu |
890ddd |
<< " y " << rend_sets.m_shrinkY;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ fx処理 ------------------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->lock();
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
refer_tile.getRaster()->lock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
fx_(
|
|
Toshihiro Shimizu |
890ddd |
enlarge_tile.getRaster() // in with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
(refer_cn_is ? refer_tile.getRaster() : nullptr) // with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
ref_mode, enlarge_pixel // margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster() // out with no margin
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
direction, dark_sw, alp_rend_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
length_min, length_max, length_bias, length_seed, length_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
force_min, force_max, force_bias, force_seed, force_ref_sw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
density_min, density_max, density_bias, density_seed, density_ref_sw);
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
refer_tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ error処理 --------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
catch (std::bad_alloc &e) {
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
refer_tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("std::bad_alloc <");
|
|
Toshihiro Shimizu |
890ddd |
str += e.what();
|
|
Toshihiro Shimizu |
890ddd |
str += '>';
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
} catch (std::exception &e) {
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
refer_tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("exception <");
|
|
Toshihiro Shimizu |
890ddd |
str += e.what();
|
|
Toshihiro Shimizu |
890ddd |
str += '>';
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
} catch (...) {
|
|
Toshihiro Shimizu |
890ddd |
if (refer_cn_is) {
|
|
Toshihiro Shimizu |
890ddd |
refer_tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("other exception");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|