public async Task DoesReadColorFromPlyFile()
        {
            string filePath = Path.Combine(TestConstants.ResourcesFolderPath, "small_point_cloud_with_color.ply");
            var    scene    = await _importerExporter.ImportFileAsync(filePath);

            var mesh     = scene.Meshes.First();
            var vertices = new List <Vertex>();

            for (int i = 0; i < scene.Meshes.First().Points.Count; ++i)
            {
                var vertex = new Vertex(mesh.Points[i], mesh.Normals[i], mesh.Colors[i].ToSystemColor());
                vertices.Add(vertex);
            }

            var outputFilePath = Path.ChangeExtension(filePath, ".new_color.ply");

            try
            {
                var pointCloud       = new PointCloud(vertices.ToArray());
                var transformedScene = PointCloudToSceneAdapter.GenerateSceneFromPointCloud(pointCloud);
                await _importerExporter.ExportFileAsync(transformedScene, outputFilePath, true);

                Assert.IsTrue(File.Exists(outputFilePath));
            }
            finally
            {
                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }
            }
        }
        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 CanExportEdges()
        {
            var vertices = new List <Vector3>
            {
                new Vector3(0, 0, 0),
                new Vector3(1, 1, 1)
            };

            var pointCloud = new PointCloud(vertices.Select(p => new Vertex(p)).ToArray());
            var scene      = PointCloudToSceneAdapter.GenerateSceneFromPointCloud(pointCloud);

            var mesh = scene.Meshes.First();

            mesh.Edges.Add(new Edge(0, 1, System.Drawing.Color.Red.ToCustomColor()));

            string filePath = Path.Combine(TestConstants.ResourcesFolderPath, "tmp.ply");

            try
            {
                await _importerExporter.ExportFileAsync(scene, filePath, true);

                var importedScene = await _importerExporter.ImportFileAsync(filePath);

                var importedMesh = importedScene.Meshes.First();

                Assert.AreEqual(mesh.Edges.Count, importedMesh.Edges.Count);
                Assert.AreEqual(mesh.Edges[0].StartIndex, importedMesh.Edges[0].StartIndex);
                Assert.AreEqual(mesh.Edges[0].EndIndex, importedMesh.Edges[0].EndIndex);

                var expectedColor = System.Drawing.Color.Red.ToCustomColor();

                Assert.AreEqual(expectedColor.Red, importedMesh.Edges[0].Color.Red);
                Assert.AreEqual(expectedColor.Green, importedMesh.Edges[0].Color.Green);
                Assert.AreEqual(expectedColor.Blue, importedMesh.Edges[0].Color.Blue);
                Assert.AreEqual(expectedColor.Alpha, importedMesh.Edges[0].Color.Alpha);
            }
            finally
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }
        public virtual Task WritePointCloudToFileAsync(IAssetImporterExporter assetImporterExporter, IPointCloud pointCloud, string filePath)
        {
            var scene = PointCloudToSceneAdapter.GenerateSceneFromPointCloud(pointCloud);

            return(assetImporterExporter.ExportFileAsync(scene, filePath, true));
        }