Beispiel #1
0
        public static void Run()
        {
            var query = TestRepository.GetAllPerson();

            var reportDataSource = query.ToReportDataSource("Persons");
            var reportDefinition = ReportDefinition.FromJson(
                EmbeddedResource.GetResourceTextFile("Sample3ReportDefinition.json"));

            var report = SimpleExporter.CreateReport(reportDefinition, reportDataSource);

            report.SetTextBlock("titleId", "Titulo de Prueba");
            report.SetTextBlock("subtitleId", "Subtitulo");
            var table = (Table)reportDefinition.Body[2];

            table.Columns = GetColumns(query);

            //CSV
            using (var fs = File.Create("Sample3.csv"))
            {
                var writer = new DelimitedTextReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(CSV) Sample 3 created: {0}", fs.Name);
            }

            //Xlsx
            using (var fs = File.Create("Sample3.xlsx"))
            {
                var writer = new XlsxReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(Xlsx) Sample 3 created: {0}", fs.Name);
            }
        }
Beispiel #2
0
        public void CollapseEdge_Should_Work_On_Simple_Quad() // How would a collapsed edge on a quad look like?
        {
            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(1, 0, 0),
                new Vec3d(1, 1, 0),
                new Vec3d(0, 1, 0),
            };
            var rand = new Random();

            Mesh.Core.Mesh mesh = null;

            for (int i = 0; i < 4; i++)
            {
                mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

                // Act
                var index = rand.Next(0, 4);
                mesh.CollapseEdge(0, index);

                // Assert
                Assert.AreEqual(1, mesh.FaceCount);
                Assert.AreEqual(3, mesh.VertexCount);
                Assert.AreEqual(6, mesh.HalfEdgeCount);
            }

            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #3
0
        public static void Run()
        {
            var query = TestRepository.GetAllProducts();

            var reportDataSource = query.ToReportDataSource("Products");
            var reportDefinition = ReportDefinition.FromJson(
                EmbeddedResource.GetResourceTextFile("Sample2ReportDefinition.json"));

            var report = SimpleExporter.CreateReport(reportDefinition, reportDataSource);

            report.SetTextBlock("titleId", "Titulo de Prueba");
            report.SetTextBlock("subtitleId", "Other text for the sample");

            //CSV
            using (var fs = File.Create("Sample2.csv"))
            {
                var writer = new DelimitedTextReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(CSV) Sample 2 created: {0}", fs.Name);
            }

            //Xlsx
            using (var fs = File.Create("Sample2.xlsx"))
            {
                var writer = new XlsxReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(Xlsx) Sample 2 created: {0}", fs.Name);
            }
        }
Beispiel #4
0
        public void SplitEdge_ShouldWorkOnSimpleQuad()
        {
            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(1, 0, 0),
                new Vec3d(1, 1, 0),
                new Vec3d(0, 1, 0),
            };
            var rand = new Random();

            Mesh.Core.Mesh mesh = null;

            for (int i = 0; i < 100; i++)
            {
                mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

                // Act
                var index = rand.Next(0, 4);
                var param = rand.Next(2, 8) / 10.0;
                mesh.SplitEdge(index, param, out _);

                // Assert
                Assert.AreEqual(1, mesh.FaceCount);
                Assert.AreEqual(5, mesh.VertexCount);
                Assert.AreEqual(10, mesh.HalfEdgeCount);
            }

            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #5
0
        public static void Run()
        {
            var query = TestRepository.GetAllProducts();

            var reportDataSource = query.ToReportDataSource("Products");
            var reportDefinition = ReportDefinition.FromJson(
                EmbeddedResource.GetResourceTextFile("Sample1ReportDefinition.json"));

            var report = SimpleExporter.CreateReport(reportDefinition, reportDataSource);

            //CSV
            using (var fs = File.Create("Sample1.csv"))
            {
                var writer = new DelimitedTextReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(CSV) Sample 1 created: {0}", fs.Name);
            }

            //Xlsx
            using (var fs = File.Create("Sample1.xlsx"))
            {
                var writer = new XlsxReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(Xlsx) Sample 1 created: {0}", fs.Name);
            }

            //PDF
            using (var fs = File.Create("Sample1.pdf"))
            {
                var writer = new PdfReportWriter();
                report.WriteReport(fs, writer);
                Console.WriteLine("(PDF) Sample 1 created: {0}", fs.Name);
            }
        }
        public void WriteReport(SimpleExporter simpleExporter, Stream destination)
        {
            SimpleExporter = simpleExporter;
            Destination    = destination;

            if (!string.IsNullOrWhiteSpace(simpleExporter.ReportDefinition.CultureName))
            {
                CultureInfo = new CultureInfo(simpleExporter.ReportDefinition.CultureName);
            }

            WriteReport();
        }
Beispiel #7
0
        public void SplitFace_And_SplitEdge_Together_Can_Create_Complex_Mesh()
        {
            // building the mesh from this: https://w3.cs.jmu.edu/bowersjc/page/courses/spring17/cs480/labs/images/final_dcel.png

            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(2, 0, 0),
                new Vec3d(2, 1, 0),
                new Vec3d(0, 1, 0),
            };

            Mesh.Core.Mesh mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

            // Act
            // split in half
            mesh.SplitEdge(0, 0, 0.5, out var firstEdgeIndices);
            mesh.SplitEdge(0, 3, 0.5, out var secondEdgeIndices);
            mesh.SplitFace(0, firstEdgeIndices.Item2, secondEdgeIndices.Item2, out _);

            // split right quad in two triangles
            mesh.SplitFace(0, 0, 2, out _);

            // split left quad in three triangles
            mesh.SplitEdge(1, 0, 0.5, out firstEdgeIndices);
            mesh.SplitFace(1, firstEdgeIndices.Item2, 3, out var facePartIndices);
            mesh.SplitFace(facePartIndices.Item2, 1, 3, out facePartIndices);

            // split middle triangle of split left quad in half
            mesh.SplitEdge(facePartIndices.Item2, 0, 0.5, out firstEdgeIndices);
            mesh.SplitEdge(facePartIndices.Item2, 3, 0.5, out secondEdgeIndices);
            mesh.SplitFace(facePartIndices.Item2, firstEdgeIndices.Item2, secondEdgeIndices.Item2, out facePartIndices);

            // split lower quad of split triangle in half
            mesh.SplitEdge(facePartIndices.Item1, 0, 0.5, out firstEdgeIndices);
            mesh.SplitEdge(facePartIndices.Item1, 3, 0.5, out secondEdgeIndices);
            mesh.SplitFace(facePartIndices.Item1, firstEdgeIndices.Item2, secondEdgeIndices.Item2, out _);

            // Assert
            Assert.AreEqual(11, mesh.VertexCount);
            Assert.AreEqual(7, mesh.FaceCount);
            Assert.AreEqual(38, mesh.HalfEdgeCount); // i think it should be 34 instead
            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #8
0
        public void SplitFace_ShouldWorkForComplicatedFile()
        {
            // Arrange
            var path = "D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\torus.obj";
            var vecs = SimpleParser.Parse(path, out var faces);
            var mesh = Mesh.Core.Mesh.CreateFromPositions(vecs, faces);

            // Act
            var initialFaces    = mesh.FaceCount;
            var initialVertices = mesh.VertexCount;

            for (int i = 0; i < initialFaces; i++)
            {
                mesh.SplitFace(i);
            }

            // Assert
            Assert.AreEqual(initialVertices, mesh.VertexCount);
            Assert.AreEqual(initialFaces * 2, mesh.FaceCount);
            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #9
0
        public void SplitFace_ShouldWorkForSimpleQuad()
        {
            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(1, 0, 0),
                new Vec3d(1, 1, 0),
                new Vec3d(0, 1, 0),
            };
            var mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

            // Act
            mesh.SplitFace(0);

            // Assert
            Assert.AreEqual(2, mesh.FaceCount);
            Assert.AreEqual(4, mesh.VertexCount);
            Assert.AreEqual(10, mesh.HalfEdgeCount);
            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #10
0
        public void Kis_Should_Work_On_Simple_Quad()
        {
            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(1, 0, 0),
                new Vec3d(1, 1, 0),
                new Vec3d(0, 1, 0),
            };

            Mesh.Core.Mesh mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

            // Act
            mesh.Kis();

            // Assert
            Assert.AreEqual(5, mesh.VertexCount);
            Assert.AreEqual(4, mesh.FaceCount);
            Assert.AreEqual(16, mesh.HalfEdgeCount);
            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
Beispiel #11
0
        public void SplitFace_And_SplitEdge_Together_Can_Turn_Simple_Quad_Into_Two_Rectangles()
        {
            // Arrange
            var positions = new[]
            {
                new Vec3d(0, 0, 0),
                new Vec3d(1, 0, 0),
                new Vec3d(1, 1, 0),
                new Vec3d(0, 1, 0),
            };

            Mesh.Core.Mesh mesh = Mesh.Core.Mesh.CreateSingleFace(positions);

            // Act
            mesh.SplitEdge(0, 0, 0.5, out _);
            mesh.SplitEdge(0, 3, 0.5, out _);
            mesh.SplitFace(0, 1, 4, out _);

            // Assert
            //Assert.AreEqual(6, mesh.VertexCount);
            //Assert.AreEqual(14, mesh.HalfEdgeCount);
            //Assert.AreEqual(2, mesh.FaceCount);
            SimpleExporter.Export("D:\\Git\\PolygonMesh\\PolygonMesh.Library.Tests\\Resources\\test.obj", mesh);
        }
        protected override void PrivateExport(IImportExportProgress iIImportExportProgress, CancellationToken? iCancellationToken)
        {
            if (!Directory.Exists(FileDirectory))
            {
                iIImportExportProgress.SafeReport(new ExportDirectoryNotFound(FileDirectory));
                return;
            }

            _IIC.Error += ((o, e) => iIImportExportProgress.SafeReport(e));
 

            using (_IIC.SessionLock())
            {
                SizeChecker sc = new SizeChecker(FileDirectory);

                foreach (IInternalAlbum Al in AlbumToExport)
                {
                    Al.Visit(sc);
                }

                if (!sc.End())
                {
                    iIImportExportProgress.SafeReport(new NotEnougthSpace(sc.Checker.ToString()));
                    return;
                }

                var listener = new IEventListenerAdaptor(iIImportExportProgress, _IIC);
                IAlbumVisitor exp = null;

                if (CompactFiles == MusicExportType.Directory)
                    exp = new SimpleExporter(this, FileDirectory, listener);
                else
                    exp = new FileCompactor(this, FileDirectory, (CompactFiles == MusicExportType.Custo), listener);

                foreach (IInternalAlbum Al in AlbumToExport)
                {
                    Al.Visit(exp);
                }

                if (!exp.End())
                {
                    iIImportExportProgress.SafeReport(new UnableToCreateFile(string.Join(Environment.NewLine, AlbumToExport)));
                    return;
                }

            }

            _IIC.FireFactorizedEvents();
            iIImportExportProgress.SafeReport(new EndExport(AlbumToExport));

        }