Пример #1
0
    public void SmoothSharedPathPoint(SPData SPData)
    {
        var node = SPData.Selections._PathPoint;

        //cach data for restore procedure
        SPData.SmoothData.InitNodePos = node.Point.position;
        var sharedPathPointIndex = SPData.Selections._SharedPathPointIndex;

        SPData.SmoothData.Nodes           = new Node[SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches.Count];
        SPData.SmoothData.BranchesIndices = SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches.ToArray();

        //shared path point breaking
        for (int i = 0; i < SPData.SmoothData.Nodes.Length; i++)
        {
            var branchKey  = SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches[i];
            var localIndex = node.LocalIndex(SPData, branchKey);

            var duplicate = SplinePlusAPI.DuplicatePathPoint(SPData, node);
            SPData.SmoothData.Nodes[i] = duplicate;
            SPData.DictBranches[branchKey].Nodes[localIndex] = duplicate;
            if (localIndex != 0)
            {
                BranchesClass.FlipHandles(SPData, branchKey, localIndex);
            }
        }
        SPData.SmoothData.newBranchesIndices = new List <int>();
        //path points welding
        for (int i = 0; i < SPData.SmoothData.Nodes.Length; i++)// path points created after chamfer,
        {
            for (int n = i; n < SPData.SmoothData.Nodes.Length; n++)
            {
                if (n == i)
                {
                    continue;
                }
                //UpdateAllLinks
                var t = SplinePlusAPI.ConnectTwoNodes(SPData, SPData.SmoothData.Nodes[n], SPData.SmoothData.Nodes[i]);
                SPData.SmoothData.newBranchesIndices.Add(t);
                BranchesClass.FlipHandles(SPData, t, 0);
                BranchesClass.FlipHandles(SPData, t, 1);
            }
        }
        EditSmoothNodePoint(SPData, SPData.SmoothRadius);
    }
Пример #2
0
    public void SmoothNode(SPData SPData)
    {
        var node      = SPData.Selections._PathPoint;
        var branch    = SPData.DictBranches[SPData.Selections._BranchKey];
        var nodeIndex = SPData.Selections._LocalNodeIndex;

        SPData.SmoothData.Nodes = new Node[2];

        if (branch.Nodes.Count > 2 && nodeIndex > 0 && nodeIndex < (branch.Nodes.Count - 1))
        {
            SPData.SmoothData.InitNodePos       = node.Point.position;
            SPData.SmoothData.InitNodePoint1Pos = node.Point1.position;
            SPData.SmoothData.Nodes[0]          = node;

            SPData.SmoothData.Nodes[1] = SplinePlusAPI.DuplicatePathPoint(SPData, node);

            branch.Nodes.Insert(nodeIndex + 1, SPData.SmoothData.Nodes[1]);
        }

        EditSmoothNode(SPData, SPData.SmoothRadius);
    }