/// <summary> /// Выполняем перед началом операций изменения контента /// </summary> /// <param name="operationName"></param> public void OnStartOperation(string operationName) { // сначала запоминаем копию контекста по значению в локальной переменной _snapshot = _root.DeepClone(); // запоминаем также наименование операции _operationName = operationName; }
private static ModelRoot _LoadModel(string f, bool tryFix = false) { var perf = System.Diagnostics.Stopwatch.StartNew(); ModelRoot model = null; var settings = tryFix ? Validation.ValidationMode.TryFix : Validation.ValidationMode.Strict; try { model = ModelRoot.Load(f, settings); Assert.NotNull(model); } catch (Exception ex) { TestContext.Progress.WriteLine($"Failed {f.ToShortDisplayPath()}"); Assert.Fail(ex.Message); } var perf_load = perf.ElapsedMilliseconds; // do a model clone and compare it _AssertAreEqual(model, model.DeepClone()); var perf_clone = perf.ElapsedMilliseconds; var unsupportedExtensions = new[] { "MSFT_lod", "EXT_lights_image_based" }; // check extensions used if (unsupportedExtensions.All(uex => !model.ExtensionsUsed.Contains(uex))) { var detectedExtensions = model.GatherUsedExtensions().ToArray(); CollectionAssert.AreEquivalent(model.ExtensionsUsed, detectedExtensions); } // Save models model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(f), ".obj")); var perf_wavefront = perf.ElapsedMilliseconds; model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(f), ".glb")); var perf_glb = perf.ElapsedMilliseconds; TestContext.Progress.WriteLine($"processed {f.ToShortDisplayPath()} - Load:{perf_load}ms Clone:{perf_clone}ms S.obj:{perf_wavefront}ms S.glb:{perf_glb}ms"); return(model); }