/// <summary> /// Generates the unique footer code based on the document's timestamp /// </summary> /// <param name="document"></param> /// <returns>A 16-byte code</returns> protected static byte[] GenerateFooterCode(FbxNodeList document) { var timestamp = document.GetRelative(timePath1 + "/" + timePath2); if (timestamp == null) { throw new FbxException(timePath, -1, "No creation timestamp"); } try { return(GenerateFooterCode( GetTimestampVar(timestamp, "Year"), GetTimestampVar(timestamp, "Month"), GetTimestampVar(timestamp, "Day"), GetTimestampVar(timestamp, "Hour"), GetTimestampVar(timestamp, "Minute"), GetTimestampVar(timestamp, "Second"), GetTimestampVar(timestamp, "Millisecond") )); } catch (ArgumentOutOfRangeException) { throw new FbxException(timePath, -1, "Invalid timestamp"); } }
public override bool Diff(FbxNodeList rNode) { int? n = Properties?.Count; int? n2 = (rNode as FbxNode)?.Properties?.Count; bool ret = n != n2; if (ret) { string m = $"different Properties counts node1:{n} vs node2:{n2}"; Console.WriteLine(m); return(true); } for (int i = 0; i < n; ++i) { var prop1 = Properties[i]; var prop2 = (rNode as FbxNode)?.Properties?[i]; if (prop1 != prop2) { ret = true; string m = $"difference found in properties: {prop1} != {prop2}\n" + $"node1:{this}\n" + $"node2:{rNode}"; Console.WriteLine(m); break; } } ret |= base.Diff(rNode); if (ret) { Console.WriteLine("difference found between\n - " + this + "\n - and " + rNode); } return(ret); }
public virtual bool Diff(FbxNodeList rNode) { Type t1 = this.GetType(); Type t2 = rNode.GetType(); bool ret = t1 != t2; if (ret) { string m = $"node type mismatch node1:{t1} node2:{t2}"; Console.WriteLine(m); return(true); } int n = Nodes.Count; int n2 = rNode.Nodes.Count; if (n != n2) { string m = $"different node counts node1:{n} vs node2:{n2}"; Console.WriteLine(m); return(true); } for (int i = 0; i < n; ++i) { FbxNode node1 = Nodes[i]; FbxNode node2 = rNode.Nodes[i]; if (node1.Diff(node2)) { ret = true; string m = $"difference found:\n\t" + node1 + "\t\n" + node2; Console.WriteLine(m); return(true); // comment out to see all differences. } } return(ret); }
static List <NodeLink> FindNodes(FbxNodeList parent, string name) { var list = new List <NodeLink>(); foreach (var node in parent.Nodes) { if (node == null) { continue; } if (node.Name == name) { list.Add(new NodeLink(parent, node)); } if (node.Nodes.Count > 0) { var foundNodes = FindNodes(node, name); if (foundNodes != null) { list.AddRange(foundNodes); } } } return(list); }
public override bool Diff(FbxNodeList rNode) { bool ret = Version != (rNode as FbxDocument)?.Version; ret |= base.Diff(rNode); if (ret) { System.Console.WriteLine("difference found between:\n - " + this + "\n - and " + rNode); } return(ret); }
static NodeLink FindNode(FbxNodeList parent, string name) { var l = FindNodes(parent, name); if (l == null || l.Count == 0) { return(null); } return(l[0]); }
/// <summary> /// Gets a child node, using a '/' separated path /// </summary> /// <param name="path"></param> /// <returns>The child node, or null</returns> public FbxNode GetRelative(string path) { var tokens = path.Split('/'); FbxNodeList n = this; foreach (var t in tokens) { if (t == "") { continue; } n = n[t]; if (n == null) { break; } } return(n as FbxNode); }
/// <summary> /// Generates the unique footer code based on the document's timestamp /// </summary> /// <param name="document"></param> /// <returns>A 16-byte code</returns> protected static byte[] GenerateFooterCode(FbxNodeList document) { var timestamp = document.GetRelative(timePath1 + "/" + timePath2); if (timestamp == null) throw new FbxException(timePath, -1, "No creation timestamp"); try { return GenerateFooterCode( GetTimestampVar(timestamp, "Year"), GetTimestampVar(timestamp, "Month"), GetTimestampVar(timestamp, "Day"), GetTimestampVar(timestamp, "Hour"), GetTimestampVar(timestamp, "Minute"), GetTimestampVar(timestamp, "Second"), GetTimestampVar(timestamp, "Millisecond") ); } catch (ArgumentOutOfRangeException) { throw new FbxException(timePath, -1, "Invalid timestamp"); } }
public NodeLink(FbxNodeList parent, FbxNode node) { this.parent = parent; this.node = node; }