Beispiel #1
0
        public async Task <IActionResult> ImportRVM(string file)
        {
            var currentObjectName = "";
            var modelArr          = System.IO.File.ReadAllLines(@"D:\" + file);

            ProjectTreeNode currentNode = null;

            for (int k = 0; k < modelArr.Length; k++)
            {
                if (modelArr[k] == "CNTB")
                {
                    var pnr = new ProjectTreeNode();
                    pnr.Parent = currentNode;
                    pnr.Name   = modelArr[k + 2];
                    pnr.Childs = new List <ProjectTreeNode>();
                    if (currentNode != null)
                    {
                        currentNode.Childs.Add(pnr);
                    }
                    pnr.ProjectTreeNodeID = await _dataAccessProvider.AddProjectTreeNode(pnr);

                    currentNode = pnr;
                }
                else if (modelArr[k] == "PRIM")
                {
                    var grPosArr = "";
                    if (modelArr[k - 5] == "CNTB")
                    {
                        grPosArr = modelArr[k - 2];
                        if (modelArr[k + 9] == "CNTB")
                        {
                            currentObjectName = (modelArr[k - 3]);
                        }
                        else
                        {
                            currentObjectName = (modelArr[k - 3]);
                        }
                    }

                    //var textArray = new List<string>();
                    string textArray = "";

                    if (modelArr[k + 2] != "    11")
                    {
                        for (int l = k + 2; l < k + 9; l++)
                        {
                            textArray += (modelArr[l]) + '|';
                        }
                    }
                    else
                    {
                        var l = k + 2;
                        while (modelArr[l] != "CNTE")
                        {
                            textArray += (modelArr[l]) + '|';
                            l++;
                        }

                        //var mesh = createMeshFromPrim(textArray, material, grPosArr);
                        //mesh.receiveShadow = true;
                    }

                    try
                    {
                        var entity = new EntityInstance(0);
                        entity.Name     = currentObjectName;
                        entity.Position = textArray.TrimEnd('|');
                        entity.Normal   = grPosArr;
                        await _dataAccessProvider.AddEntityAsync(entity);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else if (modelArr[k] == "CNTE")
                {
                    currentNode = currentNode.Parent;
                }
            }

            return(new EmptyResult());
        }