示例#1
0
        public static Va3cContainer ToVa3c(this VimScene vim)
        {
            var r = new Va3cContainer();

            r.geometries   = vim.Geometries.Select(ToGeometry).ToList();
            r.obj.children = vim.VimNodes.Select(ToObject).ToList();
            return(r);
        }
示例#2
0
        public VimHelper(IRenderApi api, VimScene vim)
        {
            (Vim, Api) = (vim, api);
            Api.Scene.GetNodeToInstanceTable(ref NodeIndices, ref Instances);
            Debug.Assert(NodeIndices.Length == Instances.Length);
            Flags = new bool[NodeIndices.Length];
            for (var i = 0; i < NodeIndices.Length; ++i)
            {
                NodeIndexToInstanceIndex.Add(NodeIndices[i], i);
                InstanceToNodeIndex.Add(Instances[i], NodeIndices[i]);
            }

            ElementIndexToSceneNode = Vim.GetElementIndexToSceneNodeMap();
        }
示例#3
0
 public static void Equivalent(VimScene left, VimScene right)
 {
     Assert.AreEqual(left.Nodes.Count, right.Nodes.Count);
     // TODO: Validate that other assets are equivalent (all tables etc)
     // can we cast a DocumentBuilder to a
     for (var i = 0; i < left.Nodes.Count; i++)
     {
         var ln = left.Nodes[i] as VimSceneNode;
         var rn = right.Nodes[i] as VimSceneNode;
         Assert.AreEqual(ln.ElementIndex, rn.ElementIndex);
         // These two meshes should be more-or-less the same
         var lg = ln.TransformedGeometry();
         var rg = rn.TransformedGeometry();
         MeshAlmostEquals(lg, rg);
     }
 }
示例#4
0
        public static string TestVimToJsonToVim(string filePath)
        {
            // Check we can open the VIM
            var vim = VimScene.LoadVim(filePath);

            // Save the VIM as JSON
            var outputJson = Path.ChangeExtension(filePath, ".json");

            vim.SaveAsVa3c(outputJson);

            // Now try reloading thw new JSON and saving again as VIM
            var va3c      = LoadVa3c(outputJson);
            var outputVim = Util.ChangeDirectoryAndExt(filePath, TestOutputFolder, ".resaved.vim");

            va3c.SaveAsVim(outputVim);
            return(outputVim);
        }
        public IEnumerable <string> GroupingNames(VimScene vim, GroupingType gt)
        {
            switch (gt)
            {
            // TODO: this should only show names where we can find a node with geometry that uses it.
            case GroupingType.Category:
                return(vim.Model.CategoryList.Select(x => x.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Family:
                return(vim.Model.FamilyList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Room:
                return(vim.Model.RoomList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Level:
                return(vim.Model.LevelList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Model:
                return(vim.Model.ModelList.Select(x => x.Title ?? "<unnamed>").ToEnumerable());

            case GroupingType.Workset:
                return(vim.Model.WorksetList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.DesignOption:
                return(vim.Model.DesignOptionList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Assembly:
                return(vim.Model.AssemblyInstanceList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Element:
                return(vim.Model.ElementList.Select(x => x?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Node:
            default:
                return(vim.Model.NodeList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());
            }
        }
        public IArray <int> NodesToId(VimScene vim, GroupingType gt)
        {
            switch (gt)
            {
            case GroupingType.Category:
                return(vim.VimNodes.Select(n => n.Category?.Index ?? -1));

            case GroupingType.Family:
                return(vim.VimNodes.Select(n => n.Family?.Index ?? -1));

            case GroupingType.Room:
                return(vim.VimNodes.Select(GetRoom));

            case GroupingType.Level:
                return(vim.VimNodes.Select(n => n.Element?._Level.Index ?? -1));

            case GroupingType.Model:
                return(vim.VimNodes.Select(n => n.Element?._Model.Index ?? -1));

            case GroupingType.Workset:
                return(vim.VimNodes.Select(n => n.Element?._Workset.Index ?? -1));

            case GroupingType.DesignOption:
                return(vim.VimNodes.Select(n => n.Element?._DesignOption.Index ?? -1));

            case GroupingType.Assembly:
                return(vim.VimNodes.Select(n => n.Element?._AssemblyInstance.Index ?? -1));

            case GroupingType.Element:
                return(vim.VimNodes.Select(n => n.Element?.Index ?? -1));

            case GroupingType.Node:
            default:
                return(vim.VimNodes.Select(n => n.Id));
            }
        }
示例#7
0
 public static string TestVimToObj(string filePath, string objFilePath = null)
 {
     objFilePath = objFilePath ?? Util.ChangeDirectoryAndExt(filePath, TestOutputFolder, ".obj");
     VimScene.LoadVim(filePath).ToIMesh().WriteObj(objFilePath);
     return(objFilePath);
 }
示例#8
0
 public static void SaveAsVa3c(this VimScene vim, string filePath)
 => vim.ToVa3c().Write(filePath);
示例#9
0
        public override void OnOpenFile(string fileName)
        {
            var vim = VimScene.LoadVim(fileName);

            SliderListView.Init(new VimHelper(RenderApi, vim));
        }