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