Toshihiro Shimizu 890ddd
#include <sstream> /* std::ostringstream */</sstream>
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Shinya Kitaoka 120a6e
#include "tparamset.h"  // TPointParamP
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Shinya Kitaoka 120a6e
#include "tparamuiconcept.h"  //add 20140130
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ino_common.h"
Toshihiro Shimizu 890ddd
#include "igs_rotate_blur.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka d1f6c4
class ino_spin_blur final : public TStandardRasterFx {
Shinya Kitaoka 120a6e
  FX_PLUGIN_DECLARATION(ino_spin_blur)
Shinya Kitaoka 120a6e
  TRasterFxPort m_input;
Shinya Kitaoka 120a6e
  TRasterFxPort m_refer;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointParamP m_center;
Shinya Kitaoka 120a6e
  TDoubleParamP m_blur;
Shinya Kitaoka 120a6e
  TDoubleParamP m_radius;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_type;
Shinya Kitaoka 120a6e
  TBoolParamP m_alpha_rendering;
Shinya Kitaoka 120a6e
  TBoolParamP m_anti_alias;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_ref_mode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ino_spin_blur()
Shinya Kitaoka 120a6e
      : m_center(TPointD(0.0, 0.0))
Shinya Kitaoka 120a6e
      , m_blur(1)
Shinya Kitaoka 120a6e
      , m_radius(0.0)
Shinya Kitaoka 120a6e
      , m_type(new TIntEnumParam(0, "Accelerator"))
Shinya Kitaoka 120a6e
      , m_alpha_rendering(true)
Shinya Kitaoka 120a6e
      , m_anti_alias(false)
Shinya Kitaoka 120a6e
      , m_ref_mode(new TIntEnumParam(0, "Red")) {
Shinya Kitaoka 120a6e
    this->m_center->getX()->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    this->m_center->getY()->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    this->m_radius->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    addInputPort("Source", this->m_input);
Shinya Kitaoka 120a6e
    addInputPort("Reference", this->m_refer);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bindParam(this, "center", this->m_center);
Shinya Kitaoka 120a6e
    bindParam(this, "blur", this->m_blur);
Shinya Kitaoka 120a6e
    bindParam(this, "radius", this->m_radius);
Shinya Kitaoka 120a6e
    bindParam(this, "type", this->m_type);
Shinya Kitaoka 120a6e
    bindParam(this, "alpha_rendering", this->m_alpha_rendering);
Shinya Kitaoka 120a6e
    bindParam(this, "anti_alias", this->m_anti_alias);
Shinya Kitaoka 120a6e
    bindParam(this, "reference", this->m_ref_mode);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    this->m_radius->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Shinya Kitaoka 120a6e
    /* 拡大のしすぎを防ぐためにMaxを制限する */
Shinya Kitaoka 120a6e
    this->m_blur->setValueRange(0.0, 180.0);
Shinya Kitaoka 120a6e
    this->m_type->addItem(1, "Uniform");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(1, "Green");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(2, "Blue");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(3, "Alpha");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(4, "Luminance");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(-1, "Nothing");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //------------------------------------------------------------
Shinya Kitaoka 120a6e
  TPointD get_render_center(const double frame, const TPointD &pos,
Shinya Kitaoka 120a6e
                            const TAffine affine) {
Shinya Kitaoka 120a6e
    /*--- 表示画像の中心をゼロとしたミリメートル単位の位置 ---*/
Shinya Kitaoka 120a6e
    TPointD center = this->m_center->getValue(frame);
Shinya Kitaoka 120a6e
    /*--- 単位変換(mm --> render用pixel) ---*/
Shinya Kitaoka 120a6e
    center = center * ino::pixel_per_mm();
Shinya Kitaoka 120a6e
    /*--- Affine変換(Geometry&Shrink&原点を中心から左下へ) ---*/
Shinya Kitaoka 120a6e
    center = affine * center;
Shinya Kitaoka 120a6e
    /*--- カメラ座標をrender画像座標の原点に ---*/
Shinya Kitaoka 120a6e
    return center - pos;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  int get_render_int_margin(const double frame, const TRectD &bBox,
Shinya Kitaoka 120a6e
                            const TAffine affine, TPointD center) {
Shinya Kitaoka 120a6e
    /*--- 単位変換(mm-->render用pixel)と長さ(scale)変換 ---*/
Shinya Kitaoka 120a6e
    const double scale = ino::pixel_per_mm() * sqrt(fabs(affine.det()));
Shinya Kitaoka 120a6e
    /*--- margin計算...Twist時正確でない ---*/
Shinya Kitaoka 120a6e
    return igs::rotate_blur::reference_margin(
Shinya Kitaoka 120a6e
        static_cast<int>(ceil(bBox.getLy())),</int>
Shinya Kitaoka 120a6e
        static_cast<int>(ceil(bBox.getLx())), center.x, center.y,</int>
Shinya Kitaoka 120a6e
        this->m_blur->getValue(frame), this->m_radius->getValue(frame) * scale,
Shinya Kitaoka 120a6e
        ((0 < this->m_type->getValue()) ? 0.0 : (bBox.getLy() / 2.0)),
Shinya Kitaoka 120a6e
        (this->m_anti_alias->getValue() ? 4 : 1));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void get_render_enlarge(const double frame, const TAffine affine,
Shinya Kitaoka 120a6e
                          TRectD &bBox) {
Shinya Kitaoka 120a6e
    TPointD center(this->get_render_center(frame, bBox.getP00(), affine));
Shinya Kitaoka 120a6e
    int margin = this->get_render_int_margin(frame, bBox, affine, center);
Shinya Kitaoka 120a6e
    if (0 < margin) {
Shinya Kitaoka 120a6e
      /* 拡大のしすぎを防ぐテキトーな制限 */
Shinya Kitaoka 120a6e
      if (4096 < margin) {
Shinya Kitaoka 120a6e
        margin = 4096;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      bBox = bBox.enlarge(margin);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //------------------------------------------------------------
Shinya Kitaoka 38fd86
  bool doGetBBox(double frame, TRectD &bBox,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    if (!this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
      bBox = TRectD();
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    const bool ret = this->m_input->doGetBBox(frame, bBox, info);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return ret;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  int getMemoryRequirement(const TRectD &rect, double frame,
Shinya Kitaoka 473e70
                           const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    TRectD bBox(rect);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return TRasterFx::memorySize(bBox, info.m_bpp);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void transform(double frame, int port, const TRectD &rectOnOutput,
Shinya Kitaoka 120a6e
                 const TRenderSettings &infoOnOutput, TRectD &rectOnInput,
Shinya Kitaoka 473e70
                 TRenderSettings &infoOnInput) override {
Shinya Kitaoka 120a6e
    rectOnInput = rectOnOutput;
Shinya Kitaoka 120a6e
    infoOnInput = infoOnOutput;
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, infoOnOutput.m_affine, rectOnInput);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 120a6e
    // return false; // toonz has geometry control
Shinya Kitaoka 120a6e
    // return true;
Shinya Kitaoka 120a6e
    /* 2012-11-14:
Shinya Kitaoka 120a6e
     * trueのとき、Fx処理がジオメトリ変換の最後にまとめられてしまう。 */
Shinya Kitaoka 120a6e
    return m_blur->getValue(frame) == 0 ? true
Shinya Kitaoka 120a6e
                                        : isAlmostIsotropic(info.m_affine);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // add 20140130
Shinya Kitaoka 473e70
  void getParamUIs(TParamUIConcept *&concepts, int &length) override {
Shinya Kitaoka 120a6e
    concepts = new TParamUIConcept[length = 2];
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    concepts[0].m_type  = TParamUIConcept::POINT;
Shinya Kitaoka 120a6e
    concepts[0].m_label = "Center";
Shinya Kitaoka 120a6e
    concepts[0].m_params.push_back(m_center);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    concepts[1].m_type  = TParamUIConcept::RADIUS;
Shinya Kitaoka 120a6e
    concepts[1].m_label = "Radius";
Shinya Kitaoka 120a6e
    concepts[1].m_params.push_back(m_radius);
Shinya Kitaoka 120a6e
    concepts[1].m_params.push_back(m_center);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // add 20140130
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(ino_spin_blur, "inoSpinBlurFx");
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
void fx_(const TRasterP in_ras  // with margin
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const int margin
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
         /* ここではinとrefは同サイズで使用している */
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const TRasterP refer_ras  // no margin
Shinya Kitaoka 120a6e
         ,
masafumi-inoue 26f824
         const int refer_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         TRasterP out_ras  // no margin
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const double xp, const double yp, const int type, const double blur,
Shinya Kitaoka 120a6e
         const double radius, const bool alpha_rendering_sw,
Shinya Kitaoka 120a6e
         const bool anti_alias_sw) {
Shinya Kitaoka 120a6e
  TRasterGR8P in_gr8(in_ras->getLy(),
Shinya Kitaoka 120a6e
                     in_ras->getLx() * ino::channels() *
Shinya Kitaoka 120a6e
                         ((TRaster64P)in_ras ? sizeof(unsigned short)
Shinya Kitaoka 120a6e
                                             : sizeof(unsigned char)));
Shinya Kitaoka 120a6e
  in_gr8->lock();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  igs::rotate_blur::convert(
Shinya Kitaoka 120a6e
      in_ras->getRawData()  // BGRA
Shinya Kitaoka 120a6e
      ,
Shinya Kitaoka 120a6e
      0 /* margin機能は使っていない、のでinとref画像は同サイズ */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      ,
masafumi-inoue 26f824
      (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData()
masafumi-inoue 26f824
                                                     : nullptr)  // BGRA
Shinya Kitaoka 120a6e
      ,
masafumi-inoue 26f824
      (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras)
masafumi-inoue 26f824
                                                     : 0),
masafumi-inoue 26f824
      refer_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      ,
Shinya Kitaoka 120a6e
      in_gr8->getRawData()  // BGRA
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      ,
Shinya Kitaoka 120a6e
      in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(out_ras)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
                                                             ,
masafumi-inoue 26f824
      xp + margin, yp + margin, blur /*degree*/
masafumi-inoue 26f824
      ,
masafumi-inoue 26f824
      radius, ((0 < type) ? 0.0 : (out_ras->getLy() / 2.0))
Toshihiro Shimizu 890ddd
masafumi-inoue 26f824
                  ,
Shinya Kitaoka 120a6e
      (anti_alias_sw ? 4 : 1), alpha_rendering_sw);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ino::arr_to_ras(in_gr8->getRawData(), ino::channels(), out_ras, margin);
Shinya Kitaoka 120a6e
  in_gr8->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka 120a6e
void ino_spin_blur::doCompute(TTile &tile, double frame,
Shinya Kitaoka 120a6e
                              const TRenderSettings &ri) {
Shinya Kitaoka 120a6e
  /*------ 接続していなければ処理しない ----------------------*/
Shinya Kitaoka 120a6e
  if (!this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
    tile.getRaster()->clear(); /* 塗りつぶしクリア */
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ サポートしていないPixelタイプはエラーを投げる -----*/
Shinya Kitaoka 120a6e
  if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster())) {
Shinya Kitaoka 120a6e
    throw TRopException("unsupported input pixel type");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ パラメータを得る ----------------------------------*/
Shinya Kitaoka 120a6e
  const double scale  = ino::pixel_per_mm() * sqrt(fabs(ri.m_affine.det()));
Shinya Kitaoka 120a6e
  const double blur   = this->m_blur->getValue(frame);
Shinya Kitaoka 120a6e
  const double radius = this->m_radius->getValue(frame) * scale;
Shinya Kitaoka 120a6e
  const int type      = this->m_type->getValue();
Shinya Kitaoka 120a6e
  const bool alpha_rend_sw = this->m_alpha_rendering->getValue();
Shinya Kitaoka 120a6e
  const bool anti_alias_sw = this->m_anti_alias->getValue();
masafumi-inoue 26f824
  const int refer_mode     = this->m_ref_mode->getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointD center = this->m_center->getValue(frame);
Shinya Kitaoka 120a6e
  TPointD render_center(
Shinya Kitaoka 120a6e
      this->get_render_center(frame, tile.m_pos, ri.m_affine));
Shinya Kitaoka 120a6e
  /*------ 入力画像の範囲を得る ------------------------------*/
Shinya Kitaoka 120a6e
  TRectD bBox =
Shinya Kitaoka 120a6e
      TRectD(tile.m_pos /* Render画像上(Pixel単位)の位置 */
Shinya Kitaoka 120a6e
             ,
Shinya Kitaoka 120a6e
             TDimensionD(/* Render画像上(Pixel単位)のサイズ */
Shinya Kitaoka 120a6e
                         tile.getRaster()->getLx(), tile.getRaster()->getLy()));
Shinya Kitaoka 120a6e
  /*------ 入力画像のエリアの拡大 ----------------------------*/
Shinya Kitaoka 120a6e
  int margin =
Shinya Kitaoka 120a6e
      this->get_render_int_margin(frame, bBox, ri.m_affine, render_center);
Shinya Kitaoka 120a6e
  if (0 < margin) {
Shinya Kitaoka 120a6e
    /* 拡大のしすぎを防ぐテキトーな制限 */
Shinya Kitaoka 120a6e
    if (4096 < margin) {
Shinya Kitaoka 120a6e
      margin = 4096;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    bBox = bBox.enlarge(margin);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ 入力画像生成 --------------------------------------*/
masafumi-inoue 26f824
  TTile enlarge_tile;
Shinya Kitaoka 120a6e
  this->m_input->allocateAndCompute(
masafumi-inoue 26f824
      enlarge_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
      TDimensionI(/* Pixel単位で四捨五入 */
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLx() + 0.5),</int>
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLy() + 0.5)),</int>
Shinya Kitaoka 120a6e
      tile.getRaster(), frame, ri);
Shinya Kitaoka 120a6e
  /*------ 参照画像生成 --------------------------------------*/
masafumi-inoue 26f824
  TTile refer_tile;
masafumi-inoue 26f824
  bool refer_sw = false;
Shinya Kitaoka 120a6e
  if (this->m_refer.isConnected()) {
masafumi-inoue 26f824
    refer_sw = true;
Shinya Kitaoka 120a6e
    this->m_refer->allocateAndCompute(
masafumi-inoue 26f824
        refer_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
        TDimensionI(/* Pixel単位で四捨五入 */
Shinya Kitaoka 120a6e
                    static_cast<int>(bBox.getLx() + 0.5),</int>
Shinya Kitaoka 120a6e
                    static_cast<int>(bBox.getLy() + 0.5)),</int>
Shinya Kitaoka 120a6e
        tile.getRaster(), frame, ri);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
Shinya Kitaoka 120a6e
  tile.getRaster()->clear(); /* 塗りつぶしクリア */
Shinya Kitaoka 120a6e
  /* ------ (app_begin)log記憶 ------------------------------ */
Shinya Kitaoka 120a6e
  const bool log_sw = ino::log_enable_sw();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (log_sw) {
Shinya Kitaoka 120a6e
    std::ostringstream os;
Shinya Kitaoka 120a6e
    os << "params"
Shinya Kitaoka 120a6e
       << "  cx " << center.x << "  cy " << center.y << "  blur " << blur
Shinya Kitaoka 120a6e
       << "  radius " << radius << "  type " << type << "  reference "
masafumi-inoue 26f824
       << refer_mode << "  alpha_rendering " << alpha_rend_sw << "  anti_alias "
Shinya Kitaoka 120a6e
       << anti_alias_sw << "  rend_cx " << render_center.x << "  rend_cy "
Shinya Kitaoka 120a6e
       << render_center.y << "  tx " << tile.m_pos.x << "  ty " << tile.m_pos.y
Shinya Kitaoka 120a6e
       << "  tw " << tile.getRaster()->getLx() << "  th "
Shinya Kitaoka 120a6e
       << tile.getRaster()->getLy() << "  tb "
Shinya Kitaoka 120a6e
       << ino::pixel_bits(tile.getRaster()) << "  margin " << margin << "  bx0 "
Shinya Kitaoka 120a6e
       << bBox.x0 << "  by0 " << bBox.y0 << "  bx1 " << bBox.x1 << "  by1 "
masafumi-inoue 26f824
       << bBox.y1 << "  ix " << enlarge_tile.m_pos.x << "  iy "
masafumi-inoue 26f824
       << enlarge_tile.m_pos.y << "  iw " << enlarge_tile.getRaster()->getLx()
masafumi-inoue 26f824
       << "  ih " << enlarge_tile.getRaster()->getLy();
masafumi-inoue 26f824
    if (refer_sw) {
masafumi-inoue 26f824
      os << "  rx " << refer_tile.m_pos.x << "  ry " << refer_tile.m_pos.y
masafumi-inoue 26f824
         << "  rw " << refer_tile.getRaster()->getLx() << "  rh "
masafumi-inoue 26f824
         << refer_tile.getRaster()->getLy();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    os << "  frame " << frame << "  ri_aff_det " << ri.m_affine.det()
Shinya Kitaoka 120a6e
       << "  shrink_x " << ri.m_shrinkX << "  shrink_y " << ri.m_shrinkY;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ fx処理 ------------------------------------------ */
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    tile.getRaster()->lock();
masafumi-inoue 26f824
    enlarge_tile.getRaster()->lock();
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->lock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    fx_(enlarge_tile.getRaster(), margin
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
masafumi-inoue 26f824
        refer_tile.getRaster(), refer_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        tile.getRaster()
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
            ,
Shinya Kitaoka 120a6e
        render_center.x, render_center.y, type, blur, radius, alpha_rend_sw,
Shinya Kitaoka 120a6e
        anti_alias_sw);
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ error処理 --------------------------------------- */
Shinya Kitaoka 120a6e
  catch (std::bad_alloc &e) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("std::bad_alloc <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (std::exception &e) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("exception <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (...) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("other exception");
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}