|
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 |
|
|
Toshihiro Shimizu |
890ddd |
int Tw = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool areTwEqual(double x, double y)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(Tw != 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return (int)(Tw * x) == (int)(Tw * y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool areTwEqual(TPointD p0, TPointD p1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(Tw != 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return areTwEqual(p0.x, p1.x) && areTwEqual(p0.y, p1.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const wstring TFlash::ConstantLines = L"Low: Constant Thickness";
|
|
Toshihiro Shimizu |
890ddd |
const wstring TFlash::MixedLines = L"Medium: Mixed Thickness";
|
|
Toshihiro Shimizu |
890ddd |
const wstring TFlash::VariableLines = L"High: Variable Thickness";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Tiio::SwfWriterProperties::SwfWriterProperties()
|
|
Toshihiro Shimizu |
890ddd |
: m_lineQuality("Curve Quality"), m_isCompressed("File Compression", true), m_autoplay("Autoplay", true), m_looping("Looping", true), m_jpgQuality("Jpg Quality", 0, 100, 90), m_url("URL", wstring()), m_preloader("Insert Preloader", false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_lineQuality.addValue(TFlash::MixedLines);
|
|
Toshihiro Shimizu |
890ddd |
m_lineQuality.addValue(TFlash::ConstantLines);
|
|
Toshihiro Shimizu |
890ddd |
m_lineQuality.addValue(TFlash::VariableLines);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bind(m_lineQuality);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_isCompressed);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_autoplay);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_looping);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_jpgQuality);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_url);
|
|
Toshihiro Shimizu |
890ddd |
bind(m_preloader);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty::Range range = m_lineQuality.getRange();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum PolyType { None,
|
|
Toshihiro Shimizu |
890ddd |
Centerline,
|
|
Toshihiro Shimizu |
890ddd |
Solid,
|
|
Toshihiro Shimizu |
890ddd |
Texture,
|
|
Toshihiro Shimizu |
890ddd |
LinearGradient,
|
|
Toshihiro Shimizu |
890ddd |
RadialGradient };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PolyStyle
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PolyType m_type;
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 m_color1; //only if type!=Texture
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 m_color2; //only if type==LinearGradient || type==RadialGradient
|
|
Toshihiro Shimizu |
890ddd |
double m_smooth; //only if type==RadialGradient
|
|
Toshihiro Shimizu |
890ddd |
double m_thickness; //only if type==Centerline
|
|
Toshihiro Shimizu |
890ddd |
TAffine m_matrix; //only if type==Texture
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P m_texture; //only if type==Texture
|
|
Toshihiro Shimizu |
890ddd |
//bool m_isRegion; //only if type!=Centerline
|
|
Toshihiro Shimizu |
890ddd |
//bool m_isHole; //only if type!=Centerline && m_isRegion==true
|
|
Toshihiro Shimizu |
890ddd |
PolyStyle() : m_type(None), m_color1(), m_color2(), m_smooth(0), m_thickness(0), m_matrix(), m_texture() /*, m_isRegion(false), m_isHole(false)*/ {}
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const PolyStyle &p) const;
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const PolyStyle &p) const;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class FlashPolyline
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UINT m_depth;
|
|
Toshihiro Shimizu |
890ddd |
bool m_skip;
|
|
Toshihiro Shimizu |
890ddd |
bool m_toBeDeleted;
|
|
Toshihiro Shimizu |
890ddd |
bool m_isPoint;
|
|
Toshihiro Shimizu |
890ddd |
vector<tquadratic *=""> m_quads;</tquadratic>
|
|
Toshihiro Shimizu |
890ddd |
PolyStyle m_fillStyle1;
|
|
Toshihiro Shimizu |
890ddd |
PolyStyle m_fillStyle2;
|
|
Toshihiro Shimizu |
890ddd |
PolyStyle m_lineStyle;
|
|
Toshihiro Shimizu |
890ddd |
//PolyStyle m_bgStyle;
|
|
Toshihiro Shimizu |
890ddd |
FlashPolyline() : m_depth(0), m_skip(false), m_toBeDeleted(false), m_isPoint(false), m_fillStyle1(), m_fillStyle2(), m_lineStyle() {}
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const FlashPolyline &p) const { return m_depth < p.m_depth; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class biPoint
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TPointD p0, p1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
biPoint(TPointD _p0, TPointD _p1) : p0(_p0), p1(_p1) {}
|
|
Toshihiro Shimizu |
890ddd |
biPoint() {}
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const biPoint &b) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
biPoint aux;
|
|
Toshihiro Shimizu |
890ddd |
aux.p0.x = areTwEqual(p0.x, b.p0.x) ? p0.x : b.p0.x;
|
|
Toshihiro Shimizu |
890ddd |
aux.p0.y = areTwEqual(p0.y, b.p0.y) ? p0.y : b.p0.y;
|
|
Toshihiro Shimizu |
890ddd |
aux.p1.x = areTwEqual(p1.x, b.p1.x) ? p1.x : b.p1.x;
|
|
Toshihiro Shimizu |
890ddd |
aux.p1.y = areTwEqual(p1.y, b.p1.y) ? p1.y : b.p1.y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return (p0.x == aux.p0.x) ? ((p0.y == aux.p0.y) ? ((p1.x == aux.p1.x) ? (p1.y < aux.p1.y) : (p1.x < aux.p1.x)) : (p0.y < aux.p0.y)) : p0.x < aux.p0.x;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void revert() { tswap(p0, p1); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class wChunk
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
double w0, w1;
|
|
Toshihiro Shimizu |
890ddd |
wChunk(double _w0, double _w1) : w0(_w0), w1(_w1) {}
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const wChunk &b) const { return (w1 < b.w0); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const int c_soundRate = 5512; // 5512; //11025
|
|
Toshihiro Shimizu |
890ddd |
const int c_soundBps = 16;
|
|
Toshihiro Shimizu |
890ddd |
const bool c_soundIsSigned = false;
|
|
Toshihiro Shimizu |
890ddd |
const int c_soundChannelNum = 1;
|
|
Toshihiro Shimizu |
890ddd |
const int c_soundCompression = 3; //per compatibilita' con MAC!!!
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class FlashImageData
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
FlashImageData(TAffine aff, TImageP img, const TColorFunction *cf, bool isMask, bool isMasked)
|
|
Toshihiro Shimizu |
890ddd |
: m_aff(aff), m_img(img), m_cf(cf), m_isMask(isMask), m_isMasked(isMasked)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(!isMask || !isMasked);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TAffine m_aff;
|
|
Toshihiro Shimizu |
890ddd |
const TColorFunction *m_cf;
|
|
Toshihiro Shimizu |
890ddd |
bool m_isMask, m_isMasked;
|
|
Toshihiro Shimizu |
890ddd |
TImageP m_img;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double computeAverageThickness(const TStroke *s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int count = s->getControlPointCount();
|
|
Toshihiro Shimizu |
890ddd |
double resThick = 0;
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < s->getControlPointCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
double thick = s->getControlPoint(i).thick;
|
|
Toshihiro Shimizu |
890ddd |
if (i >= 2 && i < s->getControlPointCount() - 2)
|
|
Toshihiro Shimizu |
890ddd |
resThick += thick;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (count < 6)
|
|
Toshihiro Shimizu |
890ddd |
return s->getControlPoint(count / 2 + 1).thick;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return resThick / (s->getControlPointCount() - 4);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void putquads(const TStroke *s, double w0, double w1, vector<tquadratic *=""> &quads)</tquadratic>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int chunkIndex0, chunkIndex1, i;
|
|
Toshihiro Shimizu |
890ddd |
double dummy;
|
|
Toshihiro Shimizu |
890ddd |
bool ret;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ret = s->getChunkAndT(w0, chunkIndex0, dummy);
|
|
Toshihiro Shimizu |
890ddd |
assert(!ret);
|
|
Toshihiro Shimizu |
890ddd |
ret = s->getChunkAndT(w1, chunkIndex1, dummy);
|
|
Toshihiro Shimizu |
890ddd |
assert(!ret);
|
|
Toshihiro Shimizu |
890ddd |
assert(chunkIndex0 <= chunkIndex1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (i = chunkIndex0; i <= chunkIndex1; i++)
|
|
Toshihiro Shimizu |
890ddd |
quads.push_back((TQuadratic *)s->getChunk(i));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void computeOutlineBoundary(vector<tstroke *=""> &outlines, list<flashpolyline> &polylinesArray, const TPixel &color)</flashpolyline></tstroke>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
UINT size = polylinesArray.size();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vector<vector<tquadratic *="">> quads;</vector<tquadratic>
|
|
Toshihiro Shimizu |
890ddd |
computeSweepBoundary(outlines, quads);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
outlines.clear();
|
|
Toshihiro Shimizu |
890ddd |
std::list<flashpolyline>::iterator it = polylinesArray.begin();</flashpolyline>
|
|
Toshihiro Shimizu |
890ddd |
std::advance(it, size);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)quads.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
vector<tquadratic *=""> &q = quads[i];</tquadratic>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
polylinesArray.push_back(FlashPolyline());
|
|
Toshihiro Shimizu |
890ddd |
polylinesArray.back().m_quads = quads[i];
|
|
Toshihiro Shimizu |
890ddd |
polylinesArray.back().m_toBeDeleted = true;
|
|
Toshihiro Shimizu |
890ddd |
polylinesArray.back().m_fillStyle1.m_type = Solid;
|
|
Toshihiro Shimizu |
890ddd |
polylinesArray.back().m_fillStyle1.m_color1 = color;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
|
|
kusano |
a0ab5d |
void TFlash::drawSegments(const vector<tsegment> segmentArray, bool isGradientColor)</tsegment>
|
|
kusano |
a0ab5d |
{
|
|
kusano |
a0ab5d |
}
|
|
kusano |
a0ab5d |
|
|
kusano |
a0ab5d |
void TFlash::drawquads(const vector<tquadratic> quadsArray)</tquadratic>
|
|
kusano |
a0ab5d |
{
|
|
kusano |
a0ab5d |
}
|
|
kusano |
a0ab5d |
|
|
kusano |
a0ab5d |
//-------------------------------------------------------------------
|
|
kusano |
a0ab5d |
|
|
Toshihiro Shimizu |
890ddd |
bool PolyStyle::operator==(const PolyStyle &p) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_type != p.m_type)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
switch (m_type) {
|
|
Toshihiro Shimizu |
890ddd |
case Centerline:
|
|
Toshihiro Shimizu |
890ddd |
return m_thickness == p.m_thickness && m_color1 == p.m_color1;
|
|
Toshihiro Shimizu |
890ddd |
CASE Solid : return m_color1 == p.m_color1;
|
|
Toshihiro Shimizu |
890ddd |
CASE Texture : return m_matrix == p.m_matrix && m_texture.getPointer() == p.m_texture.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
CASE LinearGradient : __OR RadialGradient : return m_color1 == p.m_color1 && m_color2 == p.m_color2 && m_matrix == p.m_matrix && m_smooth == p.m_smooth;
|
|
Toshihiro Shimizu |
890ddd |
DEFAULT:
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool affineMinorThen(const TAffine &m0, const TAffine &m1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m0.a11 == m1.a11) {
|
|
Toshihiro Shimizu |
890ddd |
if (m0.a12 == m1.a12) {
|
|
Toshihiro Shimizu |
890ddd |
if (m0.a13 == m1.a13) {
|
|
Toshihiro Shimizu |
890ddd |
if (m0.a21 == m1.a21) {
|
|
Toshihiro Shimizu |
890ddd |
if (m0.a22 == m1.a22)
|
|
Toshihiro Shimizu |
890ddd |
return m0.a23 < m1.a23;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return m0.a22 < m1.a22;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return m0.a21 < m1.a21;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return m0.a13 < m1.a13;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return m0.a12 < m1.a12;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return m0.a11 < m1.a11;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool PolyStyle::operator<(const PolyStyle &p) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_type == p.m_type)
|
|
Toshihiro Shimizu |
890ddd |
switch (m_type) {
|
|
Toshihiro Shimizu |
890ddd |
case Centerline:
|
|
Toshihiro Shimizu |
890ddd |
return (m_thickness == p.m_thickness) ? m_color1 < p.m_color1 : m_thickness < p.m_thickness;
|
|
Toshihiro Shimizu |
890ddd |
CASE Solid : return m_color1 < p.m_color1;
|
|
Toshihiro Shimizu |
890ddd |
CASE Texture : return m_texture.getPointer() < p.m_texture.getPointer(); //ignoro la matrice!!!!
|
|
Toshihiro Shimizu |
890ddd |
CASE LinearGradient : __OR RadialGradient : return (m_smooth == p.m_smooth) ? ((m_color1 == p.m_color1) ? ((m_color2 == p.m_color2) ? affineMinorThen(m_matrix, p.m_matrix) : m_color2 < p.m_color2) : m_color1 < p.m_color1) : m_smooth < p.m_smooth;
|
|
Toshihiro Shimizu |
890ddd |
DEFAULT:
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return m_type < p.m_type;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
brly |
9e73b8 |
void computeQuadChain(const TEdge &e,
|
|
brly |
9e73b8 |
vector<tquadratic *=""> &quadArray, vector<tquadratic *=""> &toBeDeleted)</tquadratic></tquadratic>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
brly |
9e73b8 |
int chunk_b, chunk_e, chunk = -1;
|
|
brly |
9e73b8 |
double t_b, t_e, w0, w1;
|
|
brly |
9e73b8 |
TThickQuadratic *q_b = 0, *q_e = 0;
|
|
brly |
9e73b8 |
TThickQuadratic dummy;
|
|
brly |
9e73b8 |
bool reversed = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
brly |
9e73b8 |
if (e.m_w0 > e.m_w1) {
|
|
brly |
9e73b8 |
reversed = true;
|
|
brly |
9e73b8 |
w0 = e.m_w1;
|
|
brly |
9e73b8 |
w1 = e.m_w0;
|
|
brly |
9e73b8 |
} else {
|
|
brly |
9e73b8 |
w0 = e.m_w0;
|
|
brly |
9e73b8 |
w1 = e.m_w1;
|
|
brly |
9e73b8 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
brly |
9e73b8 |
if (w0 == 0.0)
|
|
brly |
9e73b8 |
chunk_b = 0;
|
|
brly |
9e73b8 |
else {
|
|
brly |
9e73b8 |
if (e.m_s->getChunkAndT(w0, chunk, t_b))
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
brly |
9e73b8 |
q_b = new TThickQuadratic();
|
|
brly |
9e73b8 |
toBeDeleted.push_back(q_b);
|
|
brly |
9e73b8 |
e.m_s->getChunk(chunk)->split(t_b, dummy, *q_b);
|
|
brly |
9e73b8 |
chunk_b = chunk + 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
brly |
9e73b8 |
if (w1 == 1.0)
|
|
brly |
9e73b8 |
chunk_e = e.m_s->getChunkCount() - 1;
|
|
brly |
9e73b8 |
else {
|
|
brly |
9e73b8 |
if (e.m_s->getChunkAndT(w1, chunk_e, t_e))
|
|
brly |
9e73b8 |
assert(false);
|
|
brly |
9e73b8 |
q_e = new TThickQuadratic();
|
|
brly |
9e73b8 |
toBeDeleted.push_back(q_e);
|
|
brly |
9e73b8 |
if (chunk_e == chunk) {
|
|
brly |
9e73b8 |
if (q_b) {
|
|
brly |
9e73b8 |
t_e = q_b->getT(e.m_s->getChunk(chunk)->getPoint(t_e));
|
|
brly |
9e73b8 |
q_b->split(t_e, *q_e, dummy);
|
|
brly |
9e73b8 |
} else
|
|
brly |
9e73b8 |
e.m_s->getChunk(0)->split(t_e, *q_e, dummy);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!reversed)
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(q_e);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(new TQuadratic(q_e->getP2(), q_e->getP1(), q_e->getP0()));
|
|
Toshihiro Shimizu |
890ddd |
toBeDeleted.push_back(quadArray.back());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
e.m_s->getChunk(chunk_e)->split(t_e, *q_e, dummy);
|
|
Toshihiro Shimizu |
890ddd |
chunk_e--;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
assert(chunk_e >= chunk_b - 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (reversed) {
|
|
Toshihiro Shimizu |
890ddd |
if (q_e) {
|
|
Toshihiro Shimizu |
890ddd |
q_e->reverse();
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(q_e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
for (i = chunk_e; i >= chunk_b; i--) {
|
|
Toshihiro Shimizu |
890ddd |
const TThickQuadratic *qAux = e.m_s->getChunk(i);
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(new TQuadratic(qAux->getP2(), qAux->getP1(), qAux->getP0()));
|
|
Toshihiro Shimizu |
890ddd |
toBeDeleted.push_back(quadArray.back());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (q_b) {
|
|
Toshihiro Shimizu |
890ddd |
q_b->reverse();
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(q_b);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (q_b)
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(q_b);
|
|
Toshihiro Shimizu |
890ddd |
for (i = chunk_b; i <= chunk_e; i++)
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back((TQuadratic *)e.m_s->getChunk(i));
|
|
Toshihiro Shimizu |
890ddd |
if (q_e)
|
|
Toshihiro Shimizu |
890ddd |
quadArray.push_back(q_e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|