public async Task CanWriteAndReadSimplisticPointCloud(PlyFileFormat plyFileFormat) { var point = new List <Vector3> { new Vector3(0, 0, 0), new Vector3(1, 1, 1) }; var pointCloud = new PointCloud(point.Select(p => new Vertex(p)).ToArray()); var scene = PointCloudToSceneAdapter.GenerateSceneFromPointCloud(pointCloud); string filePath = Path.Combine(TestConstants.ResourcesFolderPath, "tmp.ply"); try { _mockSettings.Object.DefaultPlyFileFormat = plyFileFormat; _importerExporter = new PlyAssetImporterExporter(_mockSettings.Object, null); await _importerExporter.ExportFileAsync(scene, filePath, true); var importedScene = await _importerExporter.ImportFileAsync(filePath); var importedMesh = importedScene.Meshes.First(); Assert.AreEqual(point.Count, importedMesh.Points.Count); Assert.AreEqual(point[0], importedMesh.Points[0]); Assert.AreEqual(point[1], importedMesh.Points[1]); } finally { if (File.Exists(filePath)) { File.Delete(filePath); } } }
public async Task ReadWriteAndEnsureStructureIsCorrect() { Scene correctScene = await _importerExporter.ImportFileAsync(_basicPlyFilePath); string tmpPath = Path.Combine(Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "tmp.ply")); try { await _importerExporter.ExportFileAsync(correctScene, tmpPath, true); Scene tmpScene = await _importerExporter.ImportFileAsync(tmpPath); Assert.AreEqual(correctScene.Meshes.Count, tmpScene.Meshes.Count); Mesh correctMesh = correctScene.Meshes[0]; Mesh tmpMesh = tmpScene.Meshes[0]; Assert.AreEqual(correctMesh.Points.Count, tmpMesh.Points.Count); } finally { File.Delete(tmpPath); } }