public string CorrectSide(SideView sideLeft, SideView sideRight)
        {
            if (sideLeft.isActive != false || sideRight.isActive != false)
            {
                if (sideLeft.isActive == true)
                {
                    sideRight.isActive = false;
                    lastActive         = sideLeft;
                }
                if (sideRight.isActive == true)
                {
                    sideLeft.isActive = false;
                    lastActive        = sideRight;
                }
            }

            else
            {
                if (lastActive == sideLeft)
                {
                    sideLeft.isActive = true;
                }
                else
                {
                    sideRight.isActive = true;
                }
            }

            selectedSite = sideLeft.isActive == true ? SelectedSide.left : SelectedSide.right;

            string side = selectedSite.ToString();

            return(side);
        }
        Dictionary <int, LoadVector> SetLoadedNodes(SelectedSide side, bool isPositive, bool isFlag)
        {
            Dictionary <int, LoadVector> result = new Dictionary <int, LoadVector>();
            var    nodesToLoad = new List <Node>();
            double value       = isPositive ? (-1) * Value : Value;
            double boundZ      = 0.0;

            switch (side)
            {
            case SelectedSide.TOP:
                boundZ = nodes.Max(nd => nd.Z);

                break;

            case SelectedSide.BOTTOM:
                boundZ = nodes.Min(nd => nd.Z);
                break;
            }
            nodesToLoad.AddRange(nodes.Where(nd => nd.Z <= boundZ + step && nd.Z >= boundZ - step).ToList());

            double maxX = nodesToLoad.Max(nd => nd.X);
            double minX = nodesToLoad.Min(nd => nd.X);
            double maxY = nodesToLoad.Max(nd => nd.Y);
            double minY = nodesToLoad.Min(nd => nd.Y);

            double centerX = (maxX + minX) / 2.0;
            double centerY = (maxY + minY) / 2.0;

            Node   node = nodesToLoad[0];
            double min  = Distance(nodesToLoad[0], new Node(centerX, centerY, 0.0));

            for (int i = 0; i < nodesToLoad.Count; i++)
            {
                if (min > Distance(nodesToLoad[i], new Node(centerX, centerY, 0.0)))
                {
                    min  = Distance(nodesToLoad[i], new Node(centerX, centerY, 0.0));
                    node = nodesToLoad[i];
                }
            }

            var centerNodes = nodesToLoad.Where(nd => nd.X == node.X && nd.Y == node.Y).ToList();

            node = centerNodes[0];
            min  = Math.Sqrt(Math.Pow(centerNodes[0].Z - boundZ, 2));
            for (int i = 0; i < centerNodes.Count; i++)
            {
                if (min > Math.Sqrt(Math.Pow(centerNodes[i].Z - boundZ, 2)))
                {
                    min  = Math.Sqrt(Math.Pow(centerNodes[i].Z - boundZ, 2));
                    node = centerNodes[i];
                }
            }

            result.Add(node.GlobalIndex, new LoadVector(value, VectorDirection.Z));

            return(result);
        }
        private void Move_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }

            DiscElement presentElement = selectedSite == SelectedSide.left ? sideLeft.SelectedElement : sideRight.SelectedElement;
            string      dirName        = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.Path : sideRight.SelectedElement.Path;
            string      fileName       = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.getName() : sideRight.SelectedElement.getName();
            string      sourcePath     = selectedSite == SelectedSide.left ? sideLeft.mainPath.Text : sideRight.mainPath.Text;
            string      targetPath     = selectedSite == SelectedSide.left ? sideRight.mainPath.Text : sideLeft.mainPath.Text;
            string      sourceFile     = System.IO.Path.Combine(sourcePath, fileName);
            string      destFile       = System.IO.Path.Combine(targetPath, fileName);

            if (sourcePath == targetPath)
            {
                return;
            }

            if (presentElement.isFile())
            {
                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }

                var paths = new PathToMove(sourceFile, destFile, presentElement.isFile());
                var bW    = new BackgroundWorker();
                bW.DoWork             += asyncMove;
                bW.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
                bW.RunWorkerAsync(paths);
            }

            else
            {
                if (!Directory.Exists(destFile))
                {
                    var paths = new PathToMove(dirName, destFile, presentElement.isFile());
                    var bW    = new BackgroundWorker();
                    bW.DoWork             += asyncMove;
                    bW.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
                    bW.RunWorkerAsync(paths);
                }
                else
                {
                    MessageBox.Show("Папка с указанным именем уже существует");
                    return;
                }
            }
        }
Example #4
0
        public Pressure(SelectedSide loadedSide, Node point, double value, bool isPositive, List <Triangle> triangles)
        {
            this.triangles = triangles;
            List <Triangle> trngls = SetLoadedTriangles(point);
            double          area   = trngls.Sum(tr => tr.Area());

            this.value      = value / area;
            LoadedTriangles = trngls;

            loadVectors = SetLoadedNodes(loadedSide, isPositive, trngls);
        }
Example #5
0
 VectorDirection GetDirection(List <Node> nodes, Node curent, SelectedSide side)
 {
     if (side == SelectedSide.TOP || side == SelectedSide.BOTTOM)
     {
         return(VectorDirection.Z);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
        Dictionary <int, LoadVector> SetLoadedNodes(SelectedSide side, bool isPositive, List <Triangle> loadedTriangles)
        {
            Dictionary <int, LoadVector> result = new Dictionary <int, LoadVector>();

            double value = 0;

            switch (side)
            {
            case SelectedSide.TOP:
                value = isPositive ? (-1) * Value : Value;
                break;

            case SelectedSide.BOTTOM:
                value = isPositive ? Value : (-1) * Value;
                break;

            default:
                throw new NotImplementedException();
            }

            HashSet <Node> nodeSet = new HashSet <Node>();

            loadedTriangles.ForEach(trn => trn.Nodes.ForEach(nd => nodeSet.Add(nd)));

            double maxX = nodeSet.Max(nd => nd.X);
            double minX = nodeSet.Min(nd => nd.X);
            double maxY = nodeSet.Max(nd => nd.Y);
            double minY = nodeSet.Min(nd => nd.Y);

            double centerX = (maxX + minX) / 2.0;
            double centerY = (maxY + minY) / 2.0;

            Node   node = nodeSet.ElementAt(0);
            double min  = Distance(nodeSet.ElementAt(0), new Node(centerX, centerY, 0.0));

            for (int i = 0; i < nodeSet.Count; i++)
            {
                if (min > Distance(nodeSet.ElementAt(i), new Node(centerX, centerY, 0.0)))
                {
                    min  = Distance(nodeSet.ElementAt(i), new Node(centerX, centerY, 0.0));
                    node = nodeSet.ElementAt(i);
                }
            }

            result.Add(node.GlobalIndex, new LoadVector(value, VectorDirection.Z));

            return(result);
        }
Example #7
0
        Dictionary <int, LoadVector> SetLoadedNodes(SelectedSide side, bool isPositive)
        {
            Dictionary <int, LoadVector> result = new Dictionary <int, LoadVector>();
            double value = 0;

            switch (side)
            {
            case SelectedSide.TOP:
                value = isPositive ? (-1) * Value : Value;
                for (int i = 0; i < nodes.Count; i++)
                {
                    if (topPlanes[0].GetProjection(nodes[i]) != null)
                    {
                        Node projection = topPlanes[0].GetProjection(nodes[i]);
                        bool isEquals   = (Math.Round(projection.X, 2) == Math.Round(nodes[i].X, 2)) &&
                                          (Math.Round(projection.Y, 2) == Math.Round(nodes[i].Y, 2)) &&
                                          (Math.Round(projection.Z, 2) == Math.Round(nodes[i].Z, 2));

                        if (projection.Equals(nodes[i]) || isEquals)
                        {
                            result.Add(nodes[i].GlobalIndex, new LoadVector(value, VectorDirection.Z));
                        }
                    }
                }
                break;

            case SelectedSide.BOTTOM:
                value = isPositive ? Value : (-1) * Value;
                nodes.ForEach(n =>
                {
                    bottomPlanes.ForEach(pl =>
                    {
                        if (pl.GetProjection(n).Equals(n))
                        {
                            result.Add(n.GlobalIndex, new LoadVector(value, VectorDirection.Z));
                        }
                    });
                });
                break;
                //case SelectedSide.BOUNDARIES:
                //    throw new NotImplementedException();
            }
            return(result);
        }
        private void delete_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }

            if (selectedSite == SelectedSide.left)
            {
                try
                {
                    var paths = new PathToMove(sideLeft.SelectedElement.Path, "", sideLeft.SelectedElement.isFile());
                    var bW    = new BackgroundWorker();
                    bW.DoWork             += asyncDelete;
                    bW.RunWorkerCompleted += afterAsyncDelete;
                    bW.RunWorkerAsync(paths);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            else
            {
                try
                {
                    var paths = new PathToMove(sideRight.SelectedElement.Path, "", sideRight.SelectedElement.isFile());
                    var bW    = new BackgroundWorker();
                    bW.DoWork             += asyncDelete;
                    bW.RunWorkerCompleted += afterAsyncDelete;
                    bW.RunWorkerAsync(paths);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #9
0
        double SetValue(double value, SelectedSide side)
        {
            double area = 0;

            switch (side)
            {
            case SelectedSide.TOP:
                area = topPlanes.Sum(pl => pl.Area());
                break;

            case SelectedSide.BOTTOM:
                area = bottomPlanes.Sum(pl => pl.Area());
                break;
                //case SelectedSide.BOUNDARIES:
                //    throw new NotImplementedException();
            }

            return(value / area);
        }
        private void rename_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }
            DiscElement presentElement = selectedSite == SelectedSide.left ? sideLeft.SelectedElement : sideRight.SelectedElement;
            string      path           = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.Path : sideRight.SelectedElement.Path;
            string      sourcePath     = selectedSite == SelectedSide.left ? sideLeft.mainPath.Text : sideRight.mainPath.Text;

            string fileName = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.getName() : sideRight.SelectedElement.getName();
            var    dialog   = new RenamePanel(path, sourcePath, presentElement.isFile(), fileName);

            dialog.Show();
            dialog.RenameObject += RefreshAllList;
        }