|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/vectorizerparameters.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace strings
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const char *s_version = "version",
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
*s_generalConfiguration = "generalConfiguration",
|
|
Shinya Kitaoka |
120a6e |
*s_outline = "outline", *s_threshold = "threshold",
|
|
Shinya Kitaoka |
120a6e |
*s_leaveUnpainted = "leaveUnpainted",
|
|
Shinya Kitaoka |
120a6e |
*s_visibilityBits = "visibilityBits",
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*s_Centerline = "Centerline", *s_despeckling = "despeckling",
|
|
Shinya Kitaoka |
120a6e |
*s_maxThickness = "maxThickness", *s_penalty = "penalty",
|
|
Shinya Kitaoka |
120a6e |
*s_thicknessRatio = "thicknessRatio", *s_makeFrame = "makeFrame",
|
|
Shinya Kitaoka |
120a6e |
*s_naaSource = "naaSource",
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
21f942 |
*s_accuracy = "accuracy",
|
|
shun-iwasawa |
21f942 |
*s_thicknessRatioFirst = "thicknessRatioFirst",
|
|
shun-iwasawa |
21f942 |
*s_thicknessRatioLast = "thicknessRatioLast",
|
|
shun-iwasawa |
21f942 |
*s_paintFill = "paintFill",
|
|
shun-iwasawa |
21f942 |
*s_alignBoundaryStrokesDirection = "alignBoundaryStrokesDirection",
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*s_Outline = "Outline", *s_adherenceTol = "adherenceTol",
|
|
Shinya Kitaoka |
120a6e |
*s_angleTol = "angleTol", *s_relativeTol = "relativeTol",
|
|
Shinya Kitaoka |
120a6e |
*s_mergeTol = "mergeTol", *s_maxColors = "maxColors",
|
|
Shinya Kitaoka |
120a6e |
*s_transparentColor = "transparentColor", *s_toneTol = "toneTol",
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*s_adherence = "adherence", *s_angle = "angle",
|
|
Shinya Kitaoka |
120a6e |
*s_relative = "relative", *s_toneThreshold = "toneThreshold";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const VersionNumber l_versionNumber(71, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=======================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void saveData(const VectorizerConfiguration &conf, TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
int leaveUnpainted = conf.m_leaveUnpainted ? 1 : 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
os.child(s_threshold) << conf.m_threshold;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_leaveUnpainted) << leaveUnpainted;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void loadData(VectorizerConfiguration &conf, TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_threshold)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_threshold, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_leaveUnpainted) {
|
|
Shinya Kitaoka |
120a6e |
int leaveUnpainted;
|
|
Shinya Kitaoka |
120a6e |
is >> leaveUnpainted,
|
|
Shinya Kitaoka |
120a6e |
conf.m_leaveUnpainted = (leaveUnpainted == 0) ? false : true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void saveData(const CenterlineConfiguration &conf, TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(s_generalConfiguration);
|
|
Shinya Kitaoka |
120a6e |
saveData(static_cast<const &="" vectorizerconfiguration="">(conf), os);</const>
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int makeFrame = conf.m_makeFrame ? 1 : 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
os.child(s_despeckling) << conf.m_despeckling;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_maxThickness) << conf.m_maxThickness;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_penalty) << conf.m_penalty;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_thicknessRatio) << conf.m_thicknessRatio;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_makeFrame) << makeFrame;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_naaSource) << (conf.m_naaSource ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void loadData(CenterlineConfiguration &conf, TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_generalConfiguration)
|
|
Shinya Kitaoka |
120a6e |
loadData(static_cast<vectorizerconfiguration &="">(conf), is),</vectorizerconfiguration>
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_despeckling)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_despeckling, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_maxThickness)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_maxThickness, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_penalty)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_penalty, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_thicknessRatio)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_thicknessRatio, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_makeFrame) {
|
|
Shinya Kitaoka |
120a6e |
int makeFrame;
|
|
Shinya Kitaoka |
120a6e |
is >> makeFrame, conf.m_makeFrame = (makeFrame == 0) ? false : true;
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == s_naaSource) {
|
|
Shinya Kitaoka |
120a6e |
int naaSource;
|
|
Shinya Kitaoka |
120a6e |
is >> naaSource, conf.m_naaSource = (naaSource == 0) ? false : true;
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void saveData(const NewOutlineConfiguration &conf, TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
os.openChild(s_generalConfiguration);
|
|
Shinya Kitaoka |
120a6e |
saveData(static_cast<const &="" vectorizerconfiguration="">(conf), os);</const>
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.child(s_despeckling) << conf.m_despeckling;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_adherenceTol) << conf.m_adherenceTol;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_angleTol) << conf.m_angleTol;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_relativeTol) << conf.m_relativeTol;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_mergeTol) << conf.m_mergeTol;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_maxColors) << conf.m_maxColors;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_transparentColor) << conf.m_transparentColor;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_toneTol) << conf.m_toneTol;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void loadData(NewOutlineConfiguration &conf, TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_generalConfiguration)
|
|
Shinya Kitaoka |
120a6e |
loadData(static_cast<vectorizerconfiguration &="">(conf), is),</vectorizerconfiguration>
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_despeckling)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_despeckling, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_adherenceTol)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_adherenceTol, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_angleTol)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_angleTol, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_relativeTol)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_relativeTol, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_mergeTol)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_mergeTol, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_maxColors)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_maxColors, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_transparentColor)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_transparentColor, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_toneTol)
|
|
Shinya Kitaoka |
120a6e |
is >> conf.m_toneTol, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void convert(const CenterlineConfiguration &conf,
|
|
Shinya Kitaoka |
120a6e |
VectorizerParameters ¶ms) {
|
|
Shinya Kitaoka |
120a6e |
params.m_cThreshold = conf.m_threshold / 25.0;
|
|
Shinya Kitaoka |
120a6e |
params.m_cAccuracy = 10 - conf.m_penalty;
|
|
Shinya Kitaoka |
120a6e |
params.m_cDespeckling = conf.m_despeckling / 2.0;
|
|
Shinya Kitaoka |
120a6e |
params.m_cMaxThickness = conf.m_maxThickness * 2;
|
|
Shinya Kitaoka |
120a6e |
// params.m_cThicknessRatio = centConf.m_thicknessRatio;
|
|
Shinya Kitaoka |
120a6e |
params.m_cThicknessRatioFirst = conf.m_thicknessRatio;
|
|
Shinya Kitaoka |
120a6e |
params.m_cThicknessRatioLast = conf.m_thicknessRatio;
|
|
Shinya Kitaoka |
120a6e |
params.m_cMakeFrame = conf.m_makeFrame;
|
|
Shinya Kitaoka |
120a6e |
params.m_cPaintFill = !conf.m_leaveUnpainted;
|
|
shun-iwasawa |
21f942 |
params.m_cAlignBoundaryStrokesDirection =
|
|
shun-iwasawa |
21f942 |
conf.m_alignBoundaryStrokesDirection;
|
|
shun-iwasawa |
21f942 |
params.m_cNaaSource = conf.m_naaSource;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void convert(const NewOutlineConfiguration &conf,
|
|
Shinya Kitaoka |
120a6e |
VectorizerParameters ¶ms) {
|
|
Shinya Kitaoka |
120a6e |
params.m_oDespeckling = conf.m_despeckling;
|
|
Shinya Kitaoka |
120a6e |
params.m_oAccuracy = tround((5.0 - conf.m_mergeTol) * 2.0);
|
|
Shinya Kitaoka |
120a6e |
params.m_oAdherence = tround(conf.m_adherenceTol * 100.0);
|
|
Shinya Kitaoka |
120a6e |
params.m_oAngle = tround(conf.m_angleTol * 180.0);
|
|
Shinya Kitaoka |
120a6e |
params.m_oRelative = tround(conf.m_relativeTol * 100.0);
|
|
Shinya Kitaoka |
120a6e |
params.m_oMaxColors = conf.m_maxColors;
|
|
Shinya Kitaoka |
120a6e |
params.m_oToneThreshold = conf.m_toneTol;
|
|
Shinya Kitaoka |
120a6e |
params.m_oTransparentColor = conf.m_transparentColor;
|
|
Shinya Kitaoka |
120a6e |
params.m_oPaintFill = !conf.m_leaveUnpainted;
|
|
shun-iwasawa |
21f942 |
params.m_oAlignBoundaryStrokesDirection =
|
|
shun-iwasawa |
21f942 |
conf.m_alignBoundaryStrokesDirection;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// VectorizerConfiguration implementation
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(VectorizerParameters, "vectorizerParameters")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
VectorizerParameters::VectorizerParameters()
|
|
Shinya Kitaoka |
120a6e |
: m_visibilityBits(-1) // All visible by default
|
|
Shinya Kitaoka |
120a6e |
, m_isOutline(false) {
|
|
Shinya Kitaoka |
120a6e |
CenterlineConfiguration cConf;
|
|
Shinya Kitaoka |
120a6e |
convert(cConf, *this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
NewOutlineConfiguration oConf;
|
|
Shinya Kitaoka |
120a6e |
convert(oConf, *this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CenterlineConfiguration VectorizerParameters::getCenterlineConfiguration(
|
|
Shinya Kitaoka |
120a6e |
double frame) const {
|
|
Shinya Kitaoka |
120a6e |
CenterlineConfiguration conf;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
conf.m_outline = false;
|
|
Shinya Kitaoka |
120a6e |
conf.m_threshold = m_cThreshold * 25;
|
|
Shinya Kitaoka |
120a6e |
conf.m_penalty = 10 - m_cAccuracy; // m_cAccuracy in [1,10]
|
|
Shinya Kitaoka |
120a6e |
conf.m_despeckling = m_cDespeckling * 2;
|
|
Shinya Kitaoka |
120a6e |
conf.m_maxThickness = m_cMaxThickness / 2.0;
|
|
Shinya Kitaoka |
120a6e |
// conf.m_thicknessRatio = m_cThicknessRatio;
|
|
Shinya Kitaoka |
120a6e |
conf.m_thicknessRatio =
|
|
Shinya Kitaoka |
120a6e |
(1 - frame) * m_cThicknessRatioFirst + frame * m_cThicknessRatioLast;
|
|
shun-iwasawa |
21f942 |
conf.m_leaveUnpainted = !m_cPaintFill;
|
|
shun-iwasawa |
21f942 |
conf.m_alignBoundaryStrokesDirection = m_cAlignBoundaryStrokesDirection;
|
|
shun-iwasawa |
21f942 |
conf.m_makeFrame = m_cMakeFrame;
|
|
shun-iwasawa |
21f942 |
conf.m_naaSource = m_cNaaSource;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return conf;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
NewOutlineConfiguration VectorizerParameters::getOutlineConfiguration(
|
|
Shinya Kitaoka |
120a6e |
double frame) const {
|
|
Shinya Kitaoka |
120a6e |
NewOutlineConfiguration conf;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
21f942 |
conf.m_outline = true;
|
|
shun-iwasawa |
21f942 |
conf.m_despeckling = m_oDespeckling;
|
|
shun-iwasawa |
21f942 |
conf.m_adherenceTol = m_oAdherence * 0.01;
|
|
shun-iwasawa |
21f942 |
conf.m_angleTol = m_oAngle / 180.0;
|
|
shun-iwasawa |
21f942 |
conf.m_relativeTol = m_oRelative * 0.01;
|
|
shun-iwasawa |
21f942 |
conf.m_mergeTol = 5.0 - m_oAccuracy * 0.5;
|
|
shun-iwasawa |
21f942 |
conf.m_leaveUnpainted = !m_oPaintFill;
|
|
shun-iwasawa |
21f942 |
conf.m_alignBoundaryStrokesDirection = m_oAlignBoundaryStrokesDirection;
|
|
shun-iwasawa |
21f942 |
conf.m_maxColors = m_oMaxColors;
|
|
shun-iwasawa |
21f942 |
conf.m_transparentColor = m_oTransparentColor;
|
|
shun-iwasawa |
21f942 |
conf.m_toneTol = m_oToneThreshold;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return conf;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void VectorizerParameters::saveData(TOStream &os) {
|
|
Shinya Kitaoka |
120a6e |
os.child(s_version) << l_versionNumber.first << l_versionNumber.second;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_outline) << (m_isOutline ? 1 : 0);
|
|
Shinya Kitaoka |
120a6e |
os.child(s_visibilityBits) << int(m_visibilityBits);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(s_Centerline);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
os.child(s_threshold) << m_cThreshold;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_accuracy) << m_cAccuracy;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_despeckling) << m_cDespeckling;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_maxThickness) << m_cMaxThickness;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_thicknessRatioFirst) << m_cThicknessRatioFirst;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_thicknessRatioLast) << m_cThicknessRatioLast;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_makeFrame) << (m_cMakeFrame ? 1 : 0);
|
|
Shinya Kitaoka |
120a6e |
os.child(s_paintFill) << (m_cPaintFill ? 1 : 0);
|
|
shun-iwasawa |
21f942 |
os.child(s_alignBoundaryStrokesDirection)
|
|
shun-iwasawa |
21f942 |
<< (m_cAlignBoundaryStrokesDirection ? 1 : 0);
|
|
Shinya Kitaoka |
120a6e |
os.child(s_naaSource) << (m_cNaaSource ? 1 : 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os.openChild(s_Outline);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
os.child(s_despeckling) << m_oDespeckling;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_accuracy) << m_oAccuracy;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_adherence) << m_oAdherence;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_angle) << m_oAngle;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_relative) << m_oRelative;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_maxColors) << m_oMaxColors;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_toneThreshold) << m_oToneThreshold;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_transparentColor) << m_oTransparentColor;
|
|
Shinya Kitaoka |
120a6e |
os.child(s_paintFill) << (m_oPaintFill ? 1 : 0);
|
|
shun-iwasawa |
21f942 |
os.child(s_alignBoundaryStrokesDirection)
|
|
shun-iwasawa |
21f942 |
<< (m_oAlignBoundaryStrokesDirection ? 1 : 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void VectorizerParameters::loadData(TIStream &is) {
|
|
Shinya Kitaoka |
120a6e |
VersionNumber version;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
int val;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_version)
|
|
Shinya Kitaoka |
120a6e |
is >> version.first >> version.second, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_outline)
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_isOutline = (val != 0), is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_visibilityBits) {
|
|
Shinya Kitaoka |
120a6e |
is >> val, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (version ==
|
|
Shinya Kitaoka |
120a6e |
l_versionNumber) // Restore visibility bits only if the parameters
|
|
Shinya Kitaoka |
120a6e |
m_visibilityBits =
|
|
Shinya Kitaoka |
120a6e |
val; // version is current - defaulting them is no big deal.
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == s_Centerline) {
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_threshold)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cThreshold, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_accuracy)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cAccuracy, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_despeckling)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cDespeckling, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_maxThickness)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cMaxThickness, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_thicknessRatioFirst)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cThicknessRatioFirst, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_thicknessRatioLast)
|
|
Shinya Kitaoka |
120a6e |
is >> m_cThicknessRatioLast, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_makeFrame)
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_cMakeFrame = (val != 0), is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_paintFill)
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_cPaintFill = (val != 0), is.matchEndTag();
|
|
shun-iwasawa |
21f942 |
else if (tagName == s_alignBoundaryStrokesDirection)
|
|
shun-iwasawa |
21f942 |
is >> val, m_cAlignBoundaryStrokesDirection = (val != 0),
|
|
shun-iwasawa |
21f942 |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_naaSource)
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_cNaaSource = (val != 0), is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == s_Outline) {
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == s_despeckling)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oDespeckling, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_accuracy)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oAccuracy, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_adherence)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oAdherence, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_angle)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oAngle, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_relative)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oRelative, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_maxColors)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oMaxColors, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_toneThreshold)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oToneThreshold, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_transparentColor)
|
|
Shinya Kitaoka |
120a6e |
is >> m_oTransparentColor, is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else if (tagName == s_paintFill)
|
|
Shinya Kitaoka |
120a6e |
is >> val, m_oPaintFill = (val != 0), is.matchEndTag();
|
|
shun-iwasawa |
21f942 |
else if (tagName == s_alignBoundaryStrokesDirection)
|
|
shun-iwasawa |
21f942 |
is >> val, m_oAlignBoundaryStrokesDirection = (val != 0),
|
|
shun-iwasawa |
21f942 |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName ==
|
|
Shinya Kitaoka |
120a6e |
"CenterlineConfiguration") // Old tags, not saved anymore
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
CenterlineConfiguration conf;
|
|
Shinya Kitaoka |
120a6e |
::loadData(conf, is), is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
convert(conf, *this);
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == "NewOutlineConfiguration") //
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
NewOutlineConfiguration conf;
|
|
Shinya Kitaoka |
120a6e |
::loadData(conf, is), is.matchEndTag();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
convert(conf, *this);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
is.skipCurrentTag();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|