public void ReadXml(XmlReader reader) { if (reader.IsEmptyElement) { reader.Skip(); return; } reader.ReadStartElement("MotionDataPlane"); this.Exists = false; while (reader.NodeType != XmlNodeType.None) { if (reader.NodeType == XmlNodeType.EndElement) { break; } switch (reader.Name) { case "Points": string lengthStr; if (reader.IsEmptyElement || (lengthStr = reader.GetAttribute("Length")) == null) { reader.Skip(); } else { reader.ReadStartElement("Points"); int length; if (int.TryParse(lengthStr, out length) && length >= 3) { this.Exists = true; this.Points = new Vector3[length]; string[] values = reader.ReadString().Split('\t'); for (int i = 0; i < length; i++) { Vector3 tmp; if (VectorEx.TryParse(values, i * 3, out tmp)) { this.Points[i] = tmp; } else { this.Exists = false; break; } } } reader.ReadEndElement(); } break; default: reader.Skip(); break; } } reader.ReadEndElement(); }
protected void readPointsFromString(int length, string value) { string[] values = value.Split('\t'); this.Points = new MotionDataPoint[length]; for (int i = 0; i < length; i++) { Vector3 tmp; if (VectorEx.TryParse(values, i * 3, out tmp)) { this.Points[i].Exists = true; this.Points[i].Position = tmp; } } }
protected void readLinesFromString(int length, string value) { string[] values = value.Split('\t'); this.Lines = new MotionDataLine[length]; for (int i = 0; i < length; i++) { Vector3 tmp1, tmp2; if (VectorEx.TryParse(values, i * 6, out tmp1) && VectorEx.TryParse(values, i * 6 + 3, out tmp2)) { this.Lines[i].Exists = true; this.Lines[i].End = tmp1; this.Lines[i].DirectionAndLength = tmp2; } } }
protected void ReadSpheresFromString(int length, string value) { string[] values = value.Split('\t'); this.Spheres = new MotionDataSphere[length]; for (int i = 0; i < length; i++) { Vector3 tmp1; float tmp2; if (VectorEx.TryParse(values, i * 4, out tmp1) && values.Length >= i * 4 + 3 && float.TryParse(values[i * 4 + 3], out tmp2)) { this.Spheres[i].Exists = true; this.Spheres[i].Center = tmp1; this.Spheres[i].Radius = tmp2; } } }
protected void readCylindersFromString(int length, string value) { string[] values = value.Split('\t'); this.Cylinders = new MotionDataCylinder[length]; for (int i = 0; i < length; i++) { Vector3 tmp1, tmp2; float tmp3; if (VectorEx.TryParse(values, i * 7, out tmp1) && VectorEx.TryParse(values, i * 7 + 3, out tmp2) && values.Length >= i * 7 + 6 && float.TryParse(values[i * 7 + 6], out tmp3)) { this.Cylinders[i].Exists = true; this.Cylinders[i].End = tmp1; this.Cylinders[i].Axis = tmp2; this.Cylinders[i].Radius = tmp3; } } }