/// <summary> /// Converts a G25.SMV to an XML string representation. /// </summary> /// <param name="S"></param> /// <param name="smv"></param> /// <returns>XML string representation of 'smv'.</returns> public static string SMVtoXmlString(Specification S, G25.SMV smv) { StringBuilder SB = new StringBuilder(); bool constant = smv.IsConstant() && (S.GetMatchingConstant(smv) != null); string name = smv.Name; // remove the extra constant suffix? if (constant && name.EndsWith(Specification.CONSTANT_TYPE_SUFFIX)) name = name.Substring(0, name.Length - Specification.CONSTANT_TYPE_SUFFIX.Length); SB.Append("<" + XML_SMV); // name SB.Append(" " + XML_NAME + "=\"" + name + "\""); // constant? if (constant) SB.Append(" " + XML_CONST + "=\"" + XML_TRUE + "\""); // type SB.Append(" " + XML_TYPE + "=\"" + smv.MvTypeString + "\""); // end of XML_SMV tag SB.Append(">"); { // emit coordinate order: string[] bvNames = (string[])S.m_basisVectorNames.ToArray(); // loop over all basis blades for (int b = 0; b < smv.Group(0).Length; b++) { if (b > 0) SB.Append(" "); string bbStr = BasisBladeToString(smv.BasisBlade(0, b), bvNames); SB.Append(bbStr); // if constant, add '=....' if (smv.IsCoordinateConstant(b)) SB.Append("=" + smv.ConstBasisBladeValue(smv.BladeIdxToConstBladeIdx(b)).ToString()); } if (smv.Comment.Length > 0) SB.Append(" <" + XML_COMMENT + ">" + smv.Comment + "</" + XML_COMMENT + ">"); } SB.Append("</" + XML_SMV + ">\n"); return SB.ToString(); }