public void ReferenceValues() { Bnd_Box2d box = new Bnd_Box2d(); box.Add(new Pnt2d(1, 2)); box.Add(new Pnt2d(-1, -2)); double xmin = 0, ymin = 0, xmax = 0, ymax = 0; box.Get(ref xmin, ref ymin, ref xmax, ref ymax); Assert.AreEqual(-1, xmin); Assert.AreEqual(1, xmax); Assert.AreEqual(-2, ymin); Assert.AreEqual(2, ymax); }
//-------------------------------------------------------------------------------------------------- MemoryStream _Export(VectorExportLayer[] layers) { // Create group var group = new SvgGroupElement { ID = _Template.ToString(), IsLayer = _Template == VectorExportTemplate.Contours }; BoundingBox = new Bnd_Box2d(); // Export foreach (var layer in layers) { var subgroup = _ExportLayer(layer); if (subgroup != null) { group.Children.Add(subgroup); } } // Scale double width = 100; double height = 100; if (!BoundingBox.IsVoid()) { BoundingBox.SetGap(10.0); // 1cm on each side double xmin = 0, xmax = 0, ymin = 0, ymax = 0; BoundingBox.Get(ref xmin, ref ymin, ref xmax, ref ymax); width = xmax - xmin; height = ymax - ymin; group.Transforms.Add(new SvgTranslateTransform(-xmin, -ymax)); } // Create Document var doc = new SvgDocument { DotsPerInch = DotsPerInch, Width = width, Height = height }; doc.Children.Add(group); return(doc.WriteToStream()); }