Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tflash.h"
Toshihiro Shimizu 890ddd
//#include "tstroke.h"
Toshihiro Shimizu 890ddd
#include "tcurves.h"
Toshihiro Shimizu 890ddd
#include "tregion.h"
Toshihiro Shimizu 890ddd
#include "tstrokeprop.h"
Toshihiro Shimizu 890ddd
#include "tregionprop.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tpalette.h"
Toshihiro Shimizu 890ddd
#include "tvectorimage.h"
Toshihiro Shimizu 890ddd
#include "tmachine.h"
Toshihiro Shimizu 890ddd
#include "trasterimage.h"
Toshihiro Shimizu 890ddd
#include "tsimplecolorstyles.h"
Toshihiro Shimizu 890ddd
#include "tcolorfunctions.h"
Toshihiro Shimizu 890ddd
#include "tsop.h"
Toshihiro Shimizu 890ddd
#include "tropcm.h"
Toshihiro Shimizu 890ddd
#include "tsweepboundary.h"
Toshihiro Shimizu 890ddd
#include "tiio_jpg_util.h"
Toshihiro Shimizu 890ddd
#include "zlib.h"
Toshihiro Shimizu 890ddd
//#include "trop.h"
Toshihiro Shimizu 890ddd
#include "ttoonzimage.h"
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "timage_io.h"
Toshihiro Shimizu 890ddd
#include "tsystem.h"
Toshihiro Shimizu 890ddd
#include <stack></stack>
Toshihiro Shimizu 890ddd
#include <fstream></fstream>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if !defined(TNZ_LITTLE_ENDIAN)
Toshihiro Shimizu 890ddd
TNZ_LITTLE_ENDIAN undefined !!
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    int Tw = 0;
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static bool areTwEqual(double x, double y) {
Shinya Kitaoka 120a6e
  assert(Tw != 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return (int)(Tw * x) == (int)(Tw * y);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static bool areTwEqual(TPointD p0, TPointD p1) {
Shinya Kitaoka 120a6e
  assert(Tw != 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return areTwEqual(p0.x, p1.x) && areTwEqual(p0.y, p1.y);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
const std::wstring TFlash::ConstantLines = L"Low: Constant Thickness";
Shinya Kitaoka 120a6e
const std::wstring TFlash::MixedLines    = L"Medium: Mixed Thickness";
Shinya Kitaoka 3bfa54
const std::wstring TFlash::VariableLines = L"High: Variable Thickness";
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Tiio::SwfWriterProperties::SwfWriterProperties()
Shinya Kitaoka 120a6e
    : m_lineQuality("Curve Quality")
Shinya Kitaoka 120a6e
    , m_isCompressed("File Compression", true)
Shinya Kitaoka 120a6e
    , m_autoplay("Autoplay", true)
Shinya Kitaoka 120a6e
    , m_looping("Looping", true)
Shinya Kitaoka 120a6e
    , m_jpgQuality("Jpg Quality", 0, 100, 90)
Shinya Kitaoka 120a6e
    , m_url("URL", std::wstring())
Shinya Kitaoka 120a6e
    , m_preloader("Insert Preloader", false) {
Shinya Kitaoka 120a6e
  m_lineQuality.addValue(TFlash::MixedLines);
Shinya Kitaoka 120a6e
  m_lineQuality.addValue(TFlash::ConstantLines);
Shinya Kitaoka 120a6e
  m_lineQuality.addValue(TFlash::VariableLines);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bind(m_lineQuality);
Shinya Kitaoka 120a6e
  bind(m_isCompressed);
Shinya Kitaoka 120a6e
  bind(m_autoplay);
Shinya Kitaoka 120a6e
  bind(m_looping);
Shinya Kitaoka 120a6e
  bind(m_jpgQuality);
Shinya Kitaoka 120a6e
  bind(m_url);
Shinya Kitaoka 120a6e
  bind(m_preloader);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TEnumProperty::Range range = m_lineQuality.getRange();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum PolyType {
Shinya Kitaoka 120a6e
  None,
Shinya Kitaoka 120a6e
  Centerline,
Shinya Kitaoka 120a6e
  Solid,
Shinya Kitaoka 120a6e
  Texture,
Shinya Kitaoka 120a6e
  LinearGradient,
Shinya Kitaoka 120a6e
  RadialGradient
Shinya Kitaoka 120a6e
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class PolyStyle {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  PolyType m_type;
Shinya Kitaoka 120a6e
  TPixel32 m_color1;     // only if type!=Texture
Shinya Kitaoka 120a6e
  TPixel32 m_color2;     // only if type==LinearGradient || type==RadialGradient
Shinya Kitaoka 120a6e
  double m_smooth;       // only if type==RadialGradient
Shinya Kitaoka 120a6e
  double m_thickness;    // only if type==Centerline
Shinya Kitaoka 120a6e
  TAffine m_matrix;      // only if type==Texture
Shinya Kitaoka 120a6e
  TRaster32P m_texture;  // only if type==Texture
Shinya Kitaoka 120a6e
  // bool m_isRegion;            //only if type!=Centerline
Shinya Kitaoka 120a6e
  // bool m_isHole;              //only if type!=Centerline && m_isRegion==true
Shinya Kitaoka 120a6e
  PolyStyle()
Shinya Kitaoka 120a6e
      : m_type(None)
Shinya Kitaoka 120a6e
      , m_color1()
Shinya Kitaoka 120a6e
      , m_color2()
Shinya Kitaoka 120a6e
      , m_smooth(0)
Shinya Kitaoka 120a6e
      , m_thickness(0)
Shinya Kitaoka 120a6e
      , m_matrix()
Shinya Kitaoka 120a6e
      , m_texture() /*, m_isRegion(false), m_isHole(false)*/ {}
Shinya Kitaoka 120a6e
  bool operator==(const PolyStyle &p) const;
Shinya Kitaoka 120a6e
  bool operator<(const PolyStyle &p) const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class FlashPolyline {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UINT m_depth;
Shinya Kitaoka 120a6e
  bool m_skip;
Shinya Kitaoka 120a6e
  bool m_toBeDeleted;
Shinya Kitaoka 120a6e
  bool m_isPoint;
Shinya Kitaoka 120a6e
  std::vector<tquadratic *=""> m_quads;</tquadratic>
Shinya Kitaoka 120a6e
  PolyStyle m_fillStyle1;
Shinya Kitaoka 120a6e
  PolyStyle m_fillStyle2;
Shinya Kitaoka 120a6e
  PolyStyle m_lineStyle;
Shinya Kitaoka 120a6e
  // PolyStyle m_bgStyle;
Shinya Kitaoka 120a6e
  FlashPolyline()
Shinya Kitaoka 120a6e
      : m_depth(0)
Shinya Kitaoka 120a6e
      , m_skip(false)
Shinya Kitaoka 120a6e
      , m_toBeDeleted(false)
Shinya Kitaoka 120a6e
      , m_isPoint(false)
Shinya Kitaoka 120a6e
      , m_fillStyle1()
Shinya Kitaoka 120a6e
      , m_fillStyle2()
Shinya Kitaoka 120a6e
      , m_lineStyle() {}
Shinya Kitaoka 120a6e
  bool operator<(const FlashPolyline &p) const { return m_depth < p.m_depth; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class biPoint {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TPointD p0, p1;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  biPoint(TPointD _p0, TPointD _p1) : p0(_p0), p1(_p1) {}
Shinya Kitaoka 120a6e
  biPoint() {}
Shinya Kitaoka 120a6e
  bool operator<(const biPoint &b) const {
Shinya Kitaoka 120a6e
    biPoint aux;
Shinya Kitaoka 120a6e
    aux.p0.x = areTwEqual(p0.x, b.p0.x) ? p0.x : b.p0.x;
Shinya Kitaoka 120a6e
    aux.p0.y = areTwEqual(p0.y, b.p0.y) ? p0.y : b.p0.y;
Shinya Kitaoka 120a6e
    aux.p1.x = areTwEqual(p1.x, b.p1.x) ? p1.x : b.p1.x;
Shinya Kitaoka 120a6e
    aux.p1.y = areTwEqual(p1.y, b.p1.y) ? p1.y : b.p1.y;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return (p0.x == aux.p0.x)
Shinya Kitaoka 120a6e
               ? ((p0.y == aux.p0.y) ? ((p1.x == aux.p1.x) ? (p1.y < aux.p1.y)
Shinya Kitaoka 120a6e
                                                           : (p1.x < aux.p1.x))
Shinya Kitaoka 120a6e
                                     : (p0.y < aux.p0.y))
Shinya Kitaoka 120a6e
               : p0.x < aux.p0.x;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void revert() { tswap(p0, p1); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class wChunk {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  double w0, w1;
Shinya Kitaoka 120a6e
  wChunk(double _w0, double _w1) : w0(_w0), w1(_w1) {}
Shinya Kitaoka 120a6e
  bool operator<(const wChunk &b) const { return (w1 < b.w0); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 38fd86
const int c_soundRate        = 5512;  //  5512; //11025
Shinya Kitaoka 38fd86
const int c_soundBps         = 16;
Shinya Kitaoka 38fd86
const bool c_soundIsSigned   = false;
Shinya Kitaoka 38fd86
const int c_soundChannelNum  = 1;
Shinya Kitaoka 120a6e
const int c_soundCompression = 3;  // per compatibilita' con MAC!!!
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class FlashImageData {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FlashImageData(TAffine aff, TImageP img, const TColorFunction *cf,
Shinya Kitaoka 120a6e
                 bool isMask, bool isMasked)
Shinya Kitaoka 120a6e
      : m_aff(aff)
Shinya Kitaoka 120a6e
      , m_img(img)
Shinya Kitaoka 120a6e
      , m_cf(cf)
Shinya Kitaoka 120a6e
      , m_isMask(isMask)
Shinya Kitaoka 120a6e
      , m_isMasked(isMasked) {
Shinya Kitaoka 120a6e
    assert(!isMask || !isMasked);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  TAffine m_aff;
Shinya Kitaoka 120a6e
  const TColorFunction *m_cf;
Shinya Kitaoka 120a6e
  bool m_isMask, m_isMasked;
Shinya Kitaoka 120a6e
  TImageP m_img;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static double computeAverageThickness(const TStroke *s) {
Shinya Kitaoka 120a6e
  int count       = s->getControlPointCount();
Shinya Kitaoka 120a6e
  double resThick = 0;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  for (i = 0; i < s->getControlPointCount(); i++) {
Shinya Kitaoka 120a6e
    double thick = s->getControlPoint(i).thick;
Shinya Kitaoka 120a6e
    if (i >= 2 && i < s->getControlPointCount() - 2) resThick += thick;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (count < 6) return s->getControlPoint(count / 2 + 1).thick;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  return resThick / (s->getControlPointCount() - 4);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static void putquads(const TStroke *s, double w0, double w1,
Campbell Barton 8c6c57
                     std::vector<tquadratic *=""> &quads) {</tquadratic>
Shinya Kitaoka 120a6e
  int chunkIndex0, chunkIndex1, i;
Shinya Kitaoka 120a6e
  double dummy;
Shinya Kitaoka 120a6e
  bool ret;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ret = s->getChunkAndT(w0, chunkIndex0, dummy);
Shinya Kitaoka 120a6e
  assert(!ret);
Shinya Kitaoka 120a6e
  ret = s->getChunkAndT(w1, chunkIndex1, dummy);
Shinya Kitaoka 120a6e
  assert(!ret);
Shinya Kitaoka 120a6e
  assert(chunkIndex0 <= chunkIndex1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  for (i = chunkIndex0; i <= chunkIndex1; i++)
Shinya Kitaoka 120a6e
    quads.push_back((TQuadratic *)s->getChunk(i));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static void computeOutlineBoundary(std::vector<tstroke *=""> &outlines,</tstroke>
Campbell Barton 8c6c57
                                   std::list<flashpolyline> &polylinesArray,</flashpolyline>
Campbell Barton 8c6c57
                                   const TPixel &color) {
Shinya Kitaoka 120a6e
  UINT size = polylinesArray.size();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  std::vector<std::vector<tquadratic *="">> quads;</std::vector<tquadratic>
Shinya Kitaoka 120a6e
  computeSweepBoundary(outlines, quads);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  outlines.clear();
Shinya Kitaoka 120a6e
  std::list<flashpolyline>::iterator it = polylinesArray.begin();</flashpolyline>
Shinya Kitaoka 120a6e
  std::advance(it, size);
Shinya Kitaoka 120a6e
  for (int i = 0; i < (int)quads.size(); i++) {
Shinya Kitaoka 120a6e
    std::vector<tquadratic *=""> &q = quads[i];</tquadratic>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    polylinesArray.push_back(FlashPolyline());
Shinya Kitaoka 120a6e
    polylinesArray.back().m_quads               = quads[i];
Shinya Kitaoka 120a6e
    polylinesArray.back().m_toBeDeleted         = true;
Shinya Kitaoka 120a6e
    polylinesArray.back().m_fillStyle1.m_type   = Solid;
Shinya Kitaoka 120a6e
    polylinesArray.back().m_fillStyle1.m_color1 = color;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
kusano a0ab5d
//	TFlash::drawSegments and TFlash::drawquads cannot be inline defined
kusano a0ab5d
//	since size of TSegment and TQuadratic are unkown in the header
kusano a0ab5d
Shinya Kitaoka 120a6e
void TFlash::drawSegments(const std::vector<tsegment> segmentArray,</tsegment>
Shinya Kitaoka 120a6e
                          bool isGradientColor) {}
kusano a0ab5d
Shinya Kitaoka 120a6e
void TFlash::drawquads(const std::vector<tquadratic> quadsArray) {}</tquadratic>
kusano a0ab5d
kusano a0ab5d
//-------------------------------------------------------------------
kusano a0ab5d
Shinya Kitaoka 120a6e
bool PolyStyle::operator==(const PolyStyle &p) const {
Shinya Kitaoka 120a6e
  if (m_type != p.m_type) return false;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  switch (m_type) {
Shinya Kitaoka 120a6e
  case Centerline:
Shinya Kitaoka 120a6e
    return m_thickness == p.m_thickness && m_color1 == p.m_color1;
Shinya Kitaoka 120a6e
  case Solid:
Shinya Kitaoka 120a6e
    return m_color1 == p.m_color1;
Shinya Kitaoka 120a6e
  case Texture:
Shinya Kitaoka 120a6e
    return m_matrix == p.m_matrix &&
Shinya Kitaoka 120a6e
           m_texture.getPointer() == p.m_texture.getPointer();
Shinya Kitaoka 120a6e
  case LinearGradient:
Shinya Kitaoka 120a6e
  case RadialGradient:
Shinya Kitaoka 120a6e
    return m_color1 == p.m_color1 && m_color2 == p.m_color2 &&
Shinya Kitaoka 120a6e
           m_matrix == p.m_matrix && m_smooth == p.m_smooth;
Shinya Kitaoka 120a6e
  default:
Shinya Kitaoka 120a6e
    assert(false);
Shinya Kitaoka 120a6e
    return false;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
static bool affineMinorThen(const TAffine &m0, const TAffine &m1) {
Shinya Kitaoka 120a6e
  if (m0.a11 == m1.a11) {
Shinya Kitaoka 120a6e
    if (m0.a12 == m1.a12) {
Shinya Kitaoka 120a6e
      if (m0.a13 == m1.a13) {
Shinya Kitaoka 120a6e
        if (m0.a21 == m1.a21) {
Shinya Kitaoka 120a6e
          if (m0.a22 == m1.a22)
Shinya Kitaoka 120a6e
            return m0.a23 < m1.a23;
Shinya Kitaoka 120a6e
          else
Shinya Kitaoka 120a6e
            return m0.a22 < m1.a22;
Shinya Kitaoka 120a6e
        } else
Shinya Kitaoka 120a6e
          return m0.a21 < m1.a21;
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        return m0.a13 < m1.a13;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return m0.a12 < m1.a12;
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    return m0.a11 < m1.a11;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool PolyStyle::operator<(const PolyStyle &p) const {
Shinya Kitaoka 120a6e
  if (m_type == p.m_type) switch (m_type) {
Shinya Kitaoka 120a6e
    case Centerline:
Shinya Kitaoka 120a6e
      return (m_thickness == p.m_thickness) ? m_color1 < p.m_color1
Shinya Kitaoka 120a6e
                                            : m_thickness < p.m_thickness;
Shinya Kitaoka 120a6e
    case Solid:
Shinya Kitaoka 120a6e
      return m_color1 < p.m_color1;
Shinya Kitaoka 120a6e
    case Texture:
Shinya Kitaoka 120a6e
      return m_texture.getPointer() <
Shinya Kitaoka 120a6e
             p.m_texture.getPointer();  // ignoro la matrice!!!!
Shinya Kitaoka 120a6e
    case LinearGradient:
Shinya Kitaoka 120a6e
    case RadialGradient:
Shinya Kitaoka 120a6e
      return (m_smooth == p.m_smooth)
Shinya Kitaoka 120a6e
                 ? ((m_color1 == p.m_color1)
Shinya Kitaoka 120a6e
                        ? ((m_color2 == p.m_color2)
Shinya Kitaoka 120a6e
                               ? affineMinorThen(m_matrix, p.m_matrix)
Shinya Kitaoka 120a6e
                               : m_color2 < p.m_color2)
Shinya Kitaoka 120a6e
                        : m_color1 < p.m_color1)
Shinya Kitaoka 120a6e
                 : m_smooth < p.m_smooth;
Shinya Kitaoka 120a6e
    default:
Shinya Kitaoka 120a6e
      assert(false);
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    return m_type < p.m_type;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 27b0cf
static void computeQuadChain(const TEdge &e,
shun-iwasawa 27b0cf
                             std::vector<tquadratic *=""> &quadArray,</tquadratic>
Campbell Barton 8c6c57
                             std::vector<tquadratic *=""> &toBeDeleted) {</tquadratic>
Shinya Kitaoka 120a6e
  int chunk_b, chunk_e, chunk = -1;
Shinya Kitaoka 120a6e
  double t_b, t_e, w0, w1;
Shinya Kitaoka 120a6e
  TThickQuadratic *q_b = 0, *q_e = 0;
Shinya Kitaoka 120a6e
  TThickQuadratic dummy;
Shinya Kitaoka 120a6e
  bool reversed = false;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (e.m_w0 > e.m_w1) {
Shinya Kitaoka 120a6e
    reversed = true;
Shinya Kitaoka 120a6e
    w0       = e.m_w1;
Shinya Kitaoka 120a6e
    w1       = e.m_w0;
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    w0 = e.m_w0;
Shinya Kitaoka 120a6e
    w1 = e.m_w1;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (w0 == 0.0)
Shinya Kitaoka 120a6e
    chunk_b = 0;
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    if (e.m_s->getChunkAndT(w0, chunk, t_b)) assert(false);
Shinya Kitaoka 120a6e
    q_b = new TThickQuadratic();
Shinya Kitaoka 120a6e
    toBeDeleted.push_back(q_b);
Shinya Kitaoka 120a6e
    e.m_s->getChunk(chunk)->split(t_b, dummy, *q_b);
Shinya Kitaoka 120a6e
    chunk_b = chunk + 1;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (w1 == 1.0)
Shinya Kitaoka 120a6e
    chunk_e = e.m_s->getChunkCount() - 1;
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    if (e.m_s->getChunkAndT(w1, chunk_e, t_e)) assert(false);
Shinya Kitaoka 120a6e
    q_e = new TThickQuadratic();
Shinya Kitaoka 120a6e
    toBeDeleted.push_back(q_e);
Shinya Kitaoka 120a6e
    if (chunk_e == chunk) {
Shinya Kitaoka 120a6e
      if (q_b) {
Shinya Kitaoka 120a6e
        t_e = q_b->getT(e.m_s->getChunk(chunk)->getPoint(t_e));
Shinya Kitaoka 120a6e
        q_b->split(t_e, *q_e, dummy);
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        e.m_s->getChunk(0)->split(t_e, *q_e, dummy);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      if (!reversed)
Shinya Kitaoka 120a6e
        quadArray.push_back(q_e);
Shinya Kitaoka 120a6e
      else {
Shinya Kitaoka 120a6e
        quadArray.push_back(
Shinya Kitaoka 120a6e
            new TQuadratic(q_e->getP2(), q_e->getP1(), q_e->getP0()));
Shinya Kitaoka 120a6e
        toBeDeleted.push_back(quadArray.back());
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      return;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    e.m_s->getChunk(chunk_e)->split(t_e, *q_e, dummy);
Shinya Kitaoka 120a6e
    chunk_e--;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  assert(chunk_e >= chunk_b - 1);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (reversed) {
Shinya Kitaoka 120a6e
    if (q_e) {
Shinya Kitaoka 120a6e
      q_e->reverse();
Shinya Kitaoka 120a6e
      quadArray.push_back(q_e);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    for (i = chunk_e; i >= chunk_b; i--) {
Shinya Kitaoka 120a6e
      const TThickQuadratic *qAux = e.m_s->getChunk(i);
Shinya Kitaoka 120a6e
      quadArray.push_back(
Shinya Kitaoka 120a6e
          new TQuadratic(qAux->getP2(), qAux->getP1(), qAux->getP0()));
Shinya Kitaoka 120a6e
      toBeDeleted.push_back(quadArray.back());
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (q_b) {
Shinya Kitaoka 120a6e
      q_b->reverse();
Shinya Kitaoka 120a6e
      quadArray.push_back(q_b);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    if (q_b) quadArray.push_back(q_b);
Shinya Kitaoka 120a6e
    for (i = chunk_b; i <= chunk_e; i++)
Shinya Kitaoka 120a6e
      quadArray.push_back((TQuadratic *)e.m_s->getChunk(i));
Shinya Kitaoka 120a6e
    if (q_e) quadArray.push_back(q_e);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------