public void Parse_ParsesListPropertiesCorrectly() { var stream = GetStream(FullyFeaturedValidHeader); var bufferedStreamReader = new BufferedStreamReader(stream); var headerParser = new PlyHeaderReader(bufferedStreamReader); var header = headerParser.Read(); var properties = header.Elements[1].Properties; Assert.AreEqual("p1", properties[0].Name); Assert.AreEqual("p2", properties[1].Name); Assert.AreEqual("p3", properties[2].Name); Assert.AreEqual("p4", properties[3].Name); Assert.AreEqual("p5", properties[4].Name); Assert.AreEqual("p6", properties[5].Name); Action <int> testType = (int i) => { var arrayProperty = properties[i] as PlyArrayProperty; Assert.NotNull(arrayProperty); }; Assert.AreEqual(PlyType.Char, ((PlyArrayProperty)properties[0]).ArraySizeType); Assert.AreEqual(PlyType.Int, ((PlyArrayProperty)properties[1]).ArraySizeType); Assert.AreEqual(PlyType.Short, ((PlyArrayProperty)properties[2]).ArraySizeType); Assert.AreEqual(PlyType.Uchar, ((PlyArrayProperty)properties[3]).ArraySizeType); Assert.AreEqual(PlyType.Uint, ((PlyArrayProperty)properties[4]).ArraySizeType); Assert.AreEqual(PlyType.Ushort, ((PlyArrayProperty)properties[5]).ArraySizeType); }
public void Parse_ParsesPropertiesCorrectly() { var stream = GetStream(FullyFeaturedValidHeader); var bufferedStreamReader = new BufferedStreamReader(stream); var headerParser = new PlyHeaderReader(bufferedStreamReader); var header = headerParser.Read(); var properties = header.Elements[0].Properties; Assert.AreEqual("p1", properties[0].Name); Assert.AreEqual("p2", properties[1].Name); Assert.AreEqual("p3", properties[2].Name); Assert.AreEqual("p4", properties[3].Name); Assert.AreEqual("p5", properties[4].Name); Assert.AreEqual("p6", properties[5].Name); Assert.AreEqual("p7", properties[6].Name); Assert.AreEqual("p8", properties[7].Name); Assert.AreEqual(PlyType.Char, properties[0].ValueType); Assert.AreEqual(PlyType.Double, properties[1].ValueType); Assert.AreEqual(PlyType.Float, properties[2].ValueType); Assert.AreEqual(PlyType.Int, properties[3].ValueType); Assert.AreEqual(PlyType.Short, properties[4].ValueType); Assert.AreEqual(PlyType.Uchar, properties[5].ValueType); Assert.AreEqual(PlyType.Uint, properties[6].ValueType); Assert.AreEqual(PlyType.Ushort, properties[7].ValueType); }
public void Parse_ParsesBasicHeaderInfoCorrectly() { var stream = GetStream(FullyFeaturedValidHeader); var bufferedStreamReader = new BufferedStreamReader(stream); var headerParser = new PlyHeaderReader(bufferedStreamReader); var header = headerParser.Read(); Assert.AreEqual(PlyFormat.Ascii, header.Format); Assert.AreEqual("model\nv1", header.Comment); Assert.AreEqual("scale=1.0\nauthor=admin", header.ObjectInfo); }
public void Parse_ParsesElementsCorrectly() { var stream = GetStream(FullyFeaturedValidHeader); var bufferedStreamReader = new BufferedStreamReader(stream); var headerParser = new PlyHeaderReader(bufferedStreamReader); var header = headerParser.Read(); var elements = header.Elements; Assert.AreEqual(2, elements.Count); Assert.AreEqual("vertex", elements[0].Name); Assert.AreEqual(3, elements[0].InstanceCount); Assert.AreEqual("face", elements[1].Name); Assert.AreEqual(100000000, elements[1].InstanceCount); }
public void Load(string path) { using (var fileStream = new FileStream(path, FileMode.Open)) { using (var streamReader = new BufferedStreamReader(fileStream)) { var plyHeaderReader = new PlyHeaderReader(streamReader); var plyHeader = plyHeaderReader.Read(); var plyReader = plyHeader.GetDataReader(streamReader); var converter = new PlyReaderToMeshDataConverter(); MeshData = converter.Convert(plyReader, plyHeader); } } }
public void Parse_ParsesBasicDataCorrectly() { var content = @"ply format ascii 1.0 element vertex 3 property float32 x property float32 y property float32 z element face 4 property list uint8 int32 vertex_indices end_header 1.13927 0.985002 0.534429 1.11738 0.998603 0.513986 1.17148 1.02159 0.494923 3 0 1 2 3 0 2 3 3 4 5 1 6 4 1 0 1 2 3"; using (var stream = GetStream(content)) { var streamReader = new BufferedStreamReader(stream); var headerReader = new PlyHeaderReader(streamReader); var header = headerReader.Read(); var reader = header.GetDataReader(streamReader); Assert.AreEqual(1.13927f, reader.ReadProperty <float>()); Assert.AreEqual(0.985002f, reader.ReadProperty <float>()); Assert.AreEqual(0.534429f, reader.ReadProperty <float>()); Assert.AreEqual(1.11738f, reader.ReadProperty <float>()); reader.SkipProperty(5); CollectionAssert.AreEqual(new int[] { 0, 1, 2 }, reader.ReadArray <int>().ToList()); reader.SkipProperty(2); CollectionAssert.AreEqual(new int[] { 4, 1, 0, 1, 2, 3 }, reader.ReadArray <int>().ToList()); } }