public override void writeDescription(MCacheFormatDescription description, string descriptionFileLocation, string baseFileName) { string fileName = descriptionFileLocation + baseFileName + ".txt"; XmlDocument xmlDoc = new XmlDocument(); XmlNode root = xmlDoc.CreateElement(Autodesk_Cache_File); xmlDoc.AppendChild(root); XmlNode cacheType = xmlDoc.CreateElement(cacheType_Type); MCacheFormatDescription.CacheFileDistribution destribution = description.getDistribution(); switch (destribution) { case MCacheFormatDescription.CacheFileDistribution.kOneFile: cacheType.InnerText = OneFile; break; case MCacheFormatDescription.CacheFileDistribution.kOneFilePerFrame: cacheType.InnerText = OneFilePerFrame; break; } root.AppendChild(cacheType); XmlNode cacheFormat = xmlDoc.CreateElement(cacheType_Format); cacheFormat.InnerText = fCacheFormatName; root.AppendChild(cacheFormat); MTime startTime = new MTime(0.0, MTime.Unit.k6000FPS); MTime endTime = new MTime(0.0, MTime.Unit.k6000FPS); description.getStartAndEndTimes(startTime, endTime); XmlNode startTimeNode = xmlDoc.CreateElement(startTimeTag); startTimeNode.InnerText = Convert.ToString(startTime.value); root.AppendChild(startTimeNode); XmlNode endTimeNode = xmlDoc.CreateElement(endTimeTag); endTimeNode.InnerText = Convert.ToString(endTime.value); root.AppendChild(endTimeNode); MTime timePerFrame = description.timePerFrame; XmlNode timePerFrameNode = xmlDoc.CreateElement(cacheTimePerFrame_TimePerFrame); timePerFrameNode.InnerText = Convert.ToString(timePerFrame.value); root.AppendChild(timePerFrameNode); XmlNode version = xmlDoc.CreateElement(cacheVersion_Version); version.InnerText = "2.0"; root.AppendChild(version); MStringArray info = description.getDescriptionInfo(); for (int i = 0; i < info.length; i++) { XmlNode extraNode = xmlDoc.CreateElement(extra); extraNode.InnerText = info[i]; root.AppendChild(extraNode); } XmlNode channelsNode = xmlDoc.CreateElement(Channels); uint channelNum = description.numChannels; root.AppendChild(channelsNode); for (uint i = 0; i < channelNum; i++) { string channelName = description.getChannelName(i); string interpretation = description.getChannelInterpretation(i); MCacheFormatDescription.CacheDataType dataType = description.getChannelDataType(i); MCacheFormatDescription.CacheSamplingType sampleType = description.getChannelSamplingType(i); MTime sampleRate = description.getChannelSamplingRate(i); MTime channelStartTime = description.getChannelStartTime(i); MTime channelEndTime = description.getChannelEndTime(i); XmlNode channelNode = xmlDoc.CreateElement(channelTag); XmlAttribute channelNameAtrr = xmlDoc.CreateAttribute(ChannelNameTag); channelNameAtrr.InnerText = channelName; channelNode.Attributes.Append(channelNameAtrr); string dataTypeStr = ""; switch (dataType) { case MCacheFormatDescription.CacheDataType.kDouble: dataTypeStr = Double; break; case MCacheFormatDescription.CacheDataType.kDoubleArray: dataTypeStr = DoubleArray; break; case MCacheFormatDescription.CacheDataType.kDoubleVectorArray: dataTypeStr = DoubleVectorArray; break; case MCacheFormatDescription.CacheDataType.kInt32Array: dataTypeStr = Int32Array; break; case MCacheFormatDescription.CacheDataType.kFloatArray: dataTypeStr = FloatArray; break; case MCacheFormatDescription.CacheDataType.kFloatVectorArray: dataTypeStr = FloatVectorArray; break; } XmlAttribute channelTypeAtrr = xmlDoc.CreateAttribute(ChannelTypeTag); channelTypeAtrr.InnerText = dataTypeStr; channelNode.Attributes.Append(channelTypeAtrr); XmlAttribute channelInterpAtrr = xmlDoc.CreateAttribute(ChannelInterpretation); channelInterpAtrr.InnerText = interpretation; channelNode.Attributes.Append(channelInterpAtrr); XmlAttribute channelSampleTypeAtrr = xmlDoc.CreateAttribute(SamplingType); switch (sampleType) { case MCacheFormatDescription.CacheSamplingType.kIrregular: channelSampleTypeAtrr.InnerText = Irregular; break; case MCacheFormatDescription.CacheSamplingType.kRegular: channelSampleTypeAtrr.InnerText = Regular; break; } channelNode.Attributes.Append(channelSampleTypeAtrr); XmlAttribute sampleRateAtrr = xmlDoc.CreateAttribute(SamplingRate); sampleRateAtrr.InnerText = Convert.ToString(sampleRate.value); channelNode.Attributes.Append(sampleRateAtrr); XmlAttribute startTimeAtrr = xmlDoc.CreateAttribute(StartTime); startTimeAtrr.InnerText = Convert.ToString(channelStartTime.value); channelNode.Attributes.Append(startTimeAtrr); XmlAttribute endTimeAtrr = xmlDoc.CreateAttribute(EndTime); endTimeAtrr.InnerText = Convert.ToString(channelEndTime.value); channelNode.Attributes.Append(endTimeAtrr); channelsNode.AppendChild(channelNode); } xmlDoc.Save(fileName); return; }
public override void readDescription(MCacheFormatDescription description, string descriptionFileLocation, string baseFileName) { string filename = descriptionFileLocation + baseFileName + ".txt"; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(filename); XmlNode root = xmldoc.SelectSingleNode(Autodesk_Cache_File); XmlNode cacheTypeNode = root.SelectSingleNode(cacheType_Type); string cacheTypeStr = cacheTypeNode.InnerText; if (cacheTypeStr.Equals(OneFile)) description.setDistribution(MCacheFormatDescription.CacheFileDistribution.kOneFile); else description.setDistribution(MCacheFormatDescription.CacheFileDistribution.kOneFilePerFrame); XmlNode timePerFrameNode = root.SelectSingleNode(cacheTimePerFrame_TimePerFrame); MTime timePerFrame = new MTime(0.0, MTime.Unit.k6000FPS); double dTime = Convert.ToDouble(timePerFrameNode.InnerText); timePerFrame.value = dTime; description.timePerFrame = timePerFrame; XmlNodeList extraNodes = root.SelectNodes(extra); foreach (XmlNode node in extraNodes) { description.addDescriptionInfo(node.InnerText); } XmlNode channelsNodes = root.SelectSingleNode(Channels); XmlNodeList channelNodeList = channelsNodes.SelectNodes(channelTag); foreach (XmlNode node in channelNodeList) { XmlElement elem = (XmlElement)node; string channelName = elem.GetAttribute(ChannelNameTag); string interPretionStr = elem.GetAttribute(ChannelInterpretation); string dataType = elem.GetAttribute(ChannelTypeTag); MCacheFormatDescription.CacheDataType cacheDataType = MCacheFormatDescription.CacheDataType.kDouble; if (dataType.Equals(Double)) cacheDataType = MCacheFormatDescription.CacheDataType.kDouble; else if (dataType.Equals(DoubleArray)) cacheDataType = MCacheFormatDescription.CacheDataType.kDoubleArray; else if (dataType.Equals(DoubleVectorArray)) cacheDataType = MCacheFormatDescription.CacheDataType.kDoubleVectorArray; else if (dataType.Equals(Int32Array)) cacheDataType = MCacheFormatDescription.CacheDataType.kInt32Array; else if (dataType.Equals(FloatArray)) cacheDataType = MCacheFormatDescription.CacheDataType.kFloatArray; else if (dataType.Equals(FloatVectorArray)) cacheDataType = MCacheFormatDescription.CacheDataType.kFloatVectorArray; string sampleTypeStr = elem.GetAttribute(SamplingType); MCacheFormatDescription.CacheSamplingType sample_type = MCacheFormatDescription.CacheSamplingType.kRegular; if (sampleTypeStr.Equals(Irregular)) sample_type = MCacheFormatDescription.CacheSamplingType.kIrregular; string sampleRateStr = elem.GetAttribute(SamplingRate); MTime sampleRateTime = new MTime(0.0, MTime.Unit.k6000FPS); sampleRateTime.value = Convert.ToDouble(sampleRateStr); string startTimeStr = elem.GetAttribute(StartTime); MTime startTimeTime = new MTime(0.0, MTime.Unit.k6000FPS); startTimeTime.value = Convert.ToDouble(startTimeStr); string endTimeStr = elem.GetAttribute(EndTime); MTime endTimeTime = new MTime(0.0, MTime.Unit.k6000FPS); endTimeTime.value = Convert.ToDouble(endTimeStr); description.addChannel(channelName, interPretionStr, cacheDataType, sample_type, sampleRateTime, startTimeTime, endTimeTime); } return; }
public override void readDescription(MCacheFormatDescription description, string descriptionFileLocation, string baseFileName) { string filename = descriptionFileLocation + baseFileName + ".txt"; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(filename); XmlNode root = xmldoc.SelectSingleNode(Autodesk_Cache_File); XmlNode cacheTypeNode = root.SelectSingleNode(cacheType_Type); string cacheTypeStr = cacheTypeNode.InnerText; if (cacheTypeStr.Equals(OneFile)) { description.setDistribution(MCacheFormatDescription.CacheFileDistribution.kOneFile); } else { description.setDistribution(MCacheFormatDescription.CacheFileDistribution.kOneFilePerFrame); } XmlNode timePerFrameNode = root.SelectSingleNode(cacheTimePerFrame_TimePerFrame); MTime timePerFrame = new MTime(0.0, MTime.Unit.k6000FPS); double dTime = Convert.ToDouble(timePerFrameNode.InnerText); timePerFrame.value = dTime; description.timePerFrame = timePerFrame; XmlNodeList extraNodes = root.SelectNodes(extra); foreach (XmlNode node in extraNodes) { description.addDescriptionInfo(node.InnerText); } XmlNode channelsNodes = root.SelectSingleNode(Channels); XmlNodeList channelNodeList = channelsNodes.SelectNodes(channelTag); foreach (XmlNode node in channelNodeList) { XmlElement elem = (XmlElement)node; string channelName = elem.GetAttribute(ChannelNameTag); string interPretionStr = elem.GetAttribute(ChannelInterpretation); string dataType = elem.GetAttribute(ChannelTypeTag); MCacheFormatDescription.CacheDataType cacheDataType = MCacheFormatDescription.CacheDataType.kDouble; if (dataType.Equals(Double)) { cacheDataType = MCacheFormatDescription.CacheDataType.kDouble; } else if (dataType.Equals(DoubleArray)) { cacheDataType = MCacheFormatDescription.CacheDataType.kDoubleArray; } else if (dataType.Equals(DoubleVectorArray)) { cacheDataType = MCacheFormatDescription.CacheDataType.kDoubleVectorArray; } else if (dataType.Equals(Int32Array)) { cacheDataType = MCacheFormatDescription.CacheDataType.kInt32Array; } else if (dataType.Equals(FloatArray)) { cacheDataType = MCacheFormatDescription.CacheDataType.kFloatArray; } else if (dataType.Equals(FloatVectorArray)) { cacheDataType = MCacheFormatDescription.CacheDataType.kFloatVectorArray; } string sampleTypeStr = elem.GetAttribute(SamplingType); MCacheFormatDescription.CacheSamplingType sample_type = MCacheFormatDescription.CacheSamplingType.kRegular; if (sampleTypeStr.Equals(Irregular)) { sample_type = MCacheFormatDescription.CacheSamplingType.kIrregular; } string sampleRateStr = elem.GetAttribute(SamplingRate); MTime sampleRateTime = new MTime(0.0, MTime.Unit.k6000FPS); sampleRateTime.value = Convert.ToDouble(sampleRateStr); string startTimeStr = elem.GetAttribute(StartTime); MTime startTimeTime = new MTime(0.0, MTime.Unit.k6000FPS); startTimeTime.value = Convert.ToDouble(startTimeStr); string endTimeStr = elem.GetAttribute(EndTime); MTime endTimeTime = new MTime(0.0, MTime.Unit.k6000FPS); endTimeTime.value = Convert.ToDouble(endTimeStr); description.addChannel(channelName, interPretionStr, cacheDataType, sample_type, sampleRateTime, startTimeTime, endTimeTime); } return; }