From 6111a500e70f3e0df3935ea320c3b1a2b40b0dc6 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 2 Aug 2018 15:57:44 -0700 Subject: [PATCH] Move unused member from Object3D to IObject3D extension --- DesignTools/Operations/Object3DExtensions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/DesignTools/Operations/Object3DExtensions.cs b/DesignTools/Operations/Object3DExtensions.cs index 994bc234a..be9501e13 100644 --- a/DesignTools/Operations/Object3DExtensions.cs +++ b/DesignTools/Operations/Object3DExtensions.cs @@ -30,7 +30,9 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Text; using ClipperLib; using MatterHackers.Agg; using MatterHackers.Agg.Transform; @@ -88,6 +90,19 @@ namespace MatterHackers.MatterControl.DesignTools.Operations return object3D.Parent == null; } + public static string ComputeSHA1(this IObject3D object3D) + { + // ******************************************************************************************************************************* + // TODO: We must ensure we always compute with a stream that marks for UTF encoding with BOM, irrelevant of in-memory or on disk + // ******************************************************************************************************************************* + + // SHA1 value is based on UTF8 encoded file contents + using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(object3D.ToJson()))) + { + return Object3D.ComputeSHA1(memoryStream); + } + } + public static void CopyProperties(this IObject3D copyTo, IObject3D copyFrom, Object3DPropertyFlags flags) { if (flags.HasFlag(Object3DPropertyFlags.Matrix))