コード例 #1
0
ファイル: GtPack.cs プロジェクト: princeton-vl/PackIt_Extra
    public List <StepAction> GetGtStepAction(ref Pack pack, bool rotBeforeMov = false)
    {
        TightConPack(ref pack);
        List <int> shapeOrder = ShapeOrderMixedBFSDFS(pack);

        // remove as the first shape represents the bottom of the box
        shapeOrder.RemoveAt(0);
        List <StepAction> stepActList = new List <StepAction>();
        int step    = 2;
        int stepNum = 0;

        while (step != -1)
        {
            Vector3Int curAct      = Vector3Int.zero;
            int        curShapeIdx = shapeOrder.ElementAt(stepNum);
            switch (step)
            {
            case 2:
                curAct.x = curShapeIdx;
                break;

            case 3:
                if (rotBeforeMov)
                {
                    Tuple <int, int> _curAct = packEvol.RotationR1R2(pack.rotations[curShapeIdx]);
                    curAct.x = (_curAct.Item1 * packEvol.r2Value.Count) + _curAct.Item2;
                }
                else
                {
                    curAct = packingAgent.ConToIdxPos(pack.positions[curShapeIdx], isStart0: true);
                }
                break;

            case 4:
                if (rotBeforeMov)
                {
                    curAct = packingAgent.ConToIdxPos(pack.positions[curShapeIdx], isStart0: true);
                }
                else
                {
                    Tuple <int, int> _curAct = packEvol.RotationR1R2(pack.rotations[curShapeIdx]);
                    curAct.x = (_curAct.Item1 * packEvol.r2Value.Count) + _curAct.Item2;
                }
                break;
            }

            stepActList.Add(new StepAction(step, stepNum, curAct));
            Tuple <int, int> temp = packingAgent.UpdateStepStepNum(step, stepNum, pack.sources.Length);
            step    = temp.Item1;
            stepNum = temp.Item2;
        }

        return(stepActList);
    }