public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var cond    = new SingleSelectParameter("Condition", new[] { "Greatest", "Least", "First Not Empty" });
            var operand = new SequenceMultiSelectParameter("Other Candidates", (v) => v.Type != SequenceType.Label);

            return(new ProcParam <SequenceProcEnv>[] { cond, operand });
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter mode = args[0] as SingleSelectParameter;
            List <MotionObject>   ret  = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                LineObject line = frame[info] as LineObject;
                if (line != null)
                {
                    switch (mode.Value)
                    {
                    case 0:
                        ret.Add(new LineObject(line.Position + line.Edge, -line.Edge));
                        break;

                    case 1:
                        ret.Add(new LineObject(line.Position, -line.Edge));
                        break;

                    default:
                        ret.Add((LineObject)line.Clone());
                        break;
                    }
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
        public SequenceData Operate(IList <ProcParam <SequenceProcEnv> > args, SequenceProcEnv env)
        {
            NumberParameter       offset = args[0] as NumberParameter;
            NumberParameter       scale  = args[1] as NumberParameter;
            SingleSelectParameter mode   = args[2] as SingleSelectParameter;

            bool offsetFirst = mode.Value == 0;

            TimeSeriesValues ret = new TimeSeriesValues(env.SelectedSequence.Values.ColumnNames);

            foreach (var pair in env.SelectedSequence.Values.Enumerate())
            {
                decimal?[] row = new decimal?[pair.Value.Length];
                for (int i = 0; i < row.Length; i++)
                {
                    decimal?tmp = pair.Value[i];
                    if (tmp.HasValue)
                    {
                        if (offsetFirst)
                        {
                            tmp = tmp.Value + offset.Value;
                        }
                        tmp = tmp.Value * scale.Value;
                        if (!offsetFirst)
                        {
                            tmp = tmp.Value + offset.Value;
                        }
                    }
                    row[i] = tmp;
                }
                ret[pair.Key] = row;
            }
            return(new SequenceData(ret, null, PathEx.GiveName("OffsetScale", env.SelectedSequence.Title)));
        }
예제 #4
0
        public bool ValidateArguments(IList <ProcParam <MotionProcEnv> > args, ref string errorMessage)
        {
            MotionObjectSingleSelectParameter main = args[0] as MotionObjectSingleSelectParameter;
            SingleSelectParameter             unit = args[1] as SingleSelectParameter;

            return(true);
        }
예제 #5
0
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            MotionObjectSingleSelectParameter main = new MotionObjectSingleSelectParameter("First Axis", new Predicate <MotionObjectInfo>(info => info.IsTypeOf(typeof(LineObject))), true);
            SingleSelectParameter             unit = new SingleSelectParameter("Unit", new string[] { "線分の長さに対する比", "単位長さ" });

            return(new ProcParam <MotionProcEnv>[] { main, unit });
        }
        public bool ValidateArguments(IList <ProcParam <MotionProcEnv> > args, ref string errorMessage)
        {
            SingleSelectParameter mode  = args[0] as SingleSelectParameter;
            NumberParameter       limit = args[1] as NumberParameter;

            return(true);
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var arith   = new SingleSelectParameter("Operation", new[] { "Add", "Subtract", "Multiply", "Divide", "Max", "Min" });
            var operand = new SequenceMultiSelectParameter("Other operands", (v) => v.Type != SequenceType.Label);

            return(new ProcParam <SequenceProcEnv>[] { arith, operand });
        }
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            SingleSelectParameter mode  = new SingleSelectParameter("Mode", new string[] { "上書き", "追加" });
            NumberParameter       limit = new NumberParameter("連続する欠落を補完するのフレーム数の上限", 0, 1000000, 0);

            limit.Value = 60;
            return(new ProcParam <MotionProcEnv>[] { mode, limit });
        }
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            SingleSelectParameter mode  = new SingleSelectParameter("Mode ", new string[] { "倍率", "長さ指定", "長さ加算" });
            NumberParameter       value = new NumberParameter("Value", -100000, 100000, 3);

            value.Value = 1;
            return(new ProcParam <MotionProcEnv>[] { mode, value });
        }
예제 #10
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            MotionObjectSingleSelectParameter main = args[0] as MotionObjectSingleSelectParameter;
            SingleSelectParameter             unit = args[1] as SingleSelectParameter;

            bool                     useRatio      = unit.Value == 0;
            MotionObjectInfo         firstAxis     = main.Value;
            MotionObjectInfo         secondAxis    = selected.Where(info => info.IsTypeOf(typeof(LineObject)) && info != firstAxis).First();
            IList <MotionObjectInfo> pointInfoList = selected.Where(info => info.IsTypeOf(typeof(PointObject))).ToList();
            List <SequenceData>      ret           = new List <SequenceData>();

            foreach (MotionObjectInfo pointInfo in pointInfoList)
            {
                TimeSeriesValues values = new TimeSeriesValues("axis1", "axis2", "axis3");
                foreach (var frame in frames)
                {
                    PointObject point     = frame[pointInfo] as PointObject;
                    LineObject  line1     = frame[firstAxis] as LineObject;
                    LineObject  line2     = frame[secondAxis] as LineObject;
                    decimal?[]  relValues = null;
                    if (point != null && line1 != null && line2 != null)
                    {
                        Vector3 anchor      = line1.Position;
                        Vector3 pointRelPos = point.Position - anchor;
                        Vector3 axis1       = line1.Edge;
                        Vector3 axis2       = line2.Edge;
                        Vector3 axis1norm   = Vector3.Normalize(axis1);
                        Vector3 axis2norm   = Vector3.Normalize(axis2);
                        Vector3 axis3       = Vector3.Cross(axis1norm, axis2norm) * (float)Math.Sqrt(axis1.Length() * axis2.Length());

                        if (!useRatio)
                        {
                            axis1 = Vector3.Normalize(axis1);
                            axis2 = Vector3.Normalize(axis2);
                            axis3 = Vector3.Normalize(axis3);
                        }
                        float[,] mat = new float[, ] {
                            { axis1.X, axis2.X, axis3.X }, { axis1.Y, axis2.Y, axis3.Y }, { axis1.Z, axis2.Z, axis3.Z }
                        };
                        float[] vec = new float[] { pointRelPos.X, pointRelPos.Y, pointRelPos.Z };
                        SimultaneousEquations solve = SimultaneousEquations.Solve(mat, vec);
                        if (solve.Answers.Length == 3)
                        {
                            relValues = new decimal?[3];
                            try {
                                relValues[0] = (decimal)solve.Answers[0];
                                relValues[1] = (decimal)solve.Answers[1];
                                relValues[2] = (decimal)solve.Answers[2];
                            } catch (OverflowException) { relValues = null; }
                        }
                    }
                    values.SetValue(frame.Time, relValues);
                }
                SequenceData data = new SequenceData(values, null, PathEx.GiveName("RelPos", pointInfo.Name));
                ret.Add(data);
            }
            return(ret);
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter modeRad   = args[0] as SingleSelectParameter;
            NumberParameter       valueRad  = args[1] as NumberParameter;
            SingleSelectParameter modeAxis  = args[2] as SingleSelectParameter;
            NumberParameter       valueAxis = args[3] as NumberParameter;
            List <MotionObject>   ret       = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                CylinderObject cylinder = frame[info] as CylinderObject;
                if (cylinder != null)
                {
                    float radius = cylinder.Radius;
                    float axis   = cylinder.AxisLength();
                    try {
                        switch (modeRad.Value)
                        {
                        case 0:
                            radius *= (float)valueRad.Value;
                            break;

                        case 1:
                            radius = (float)valueRad.Value;
                            break;

                        case 2:
                            radius += (float)valueRad.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    try {
                        switch (modeAxis.Value)
                        {
                        case 0:
                            axis *= (float)valueAxis.Value;
                            break;

                        case 1:
                            axis = (float)valueAxis.Value;
                            break;

                        case 2:
                            axis += (float)valueAxis.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    ret.Add(new CylinderObject(cylinder.Position, cylinder.AxisDirection() * axis, radius));
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var glue = new StringParameter("Text to Concat");

            glue.Value = "-TO-";
            var type = new SingleSelectParameter("Type", new[] { "Previous-Current", "Current-Next" });
            var skip = new BooleanParameter("Skip Empty Label");

            return(new ProcParam <SequenceProcEnv>[] { glue, type, skip });
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var mode      = new SingleSelectParameter("Mode", new[] { "Per Time", "Per Correct Label Count", "Per Obtained Label Count" });
            var threshold = new NumberParameter("Threshold for Ratio of Label Coverage for Matching", 0.001M, 1, 3);

            threshold.Value = 0.001M;
            var correct = new SequenceSingleSelectParameter("Correct Label", (v) => v.Type != SequenceType.Numeric);

            return(new ProcParam <SequenceProcEnv>[] { mode, threshold, correct });
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            NumberParameter offset = new NumberParameter("Offset", -10000000, 10000000, 3, 1);
            NumberParameter scale  = new NumberParameter("Scale", -10000000, 10000000, 3, 1);

            scale.Value = 1M;
            SingleSelectParameter mode = new SingleSelectParameter("Mode", new String[] { "offset後にscale", "scale後にoffset" });

            return(new ProcParam <SequenceProcEnv>[] { offset, scale, mode });
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var target = new LabelSelectParameter("対象のラベル", true);
            var length = new NumberParameter("秒数", 0, 10000, 3);
            var action = new SingleSelectParameter("大小", new[] { "「秒数」より短いものを置換", "「秒数」より長いものを置換" });
            var border = new BooleanParameter("「秒数」に一致するものを置換");
            var glue   = new SingleSelectParameter("置換結果", new[] { "空ラベル", "前後のラベルが等しければそのラベル", "直前のラベル", "直後のラベル" });

            return(new ProcParam <SequenceProcEnv>[] { target, length, action, border, glue });
        }
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            SingleSelectParameter modeRad  = new SingleSelectParameter("Mode for Radius", new string[] { "倍率", "半径指定", "半径加算" });
            NumberParameter       valueRad = new NumberParameter("Value for Radius", -10000, 10000, 3);

            valueRad.Value = 1;
            SingleSelectParameter modeAxis  = new SingleSelectParameter("Mode for Thickness", new string[] { "倍率", "厚さ指定", "厚さ加算" });
            NumberParameter       valueAxis = new NumberParameter("Value for Thickness", -10000, 10000, 3);

            valueAxis.Value = 1;
            return(new ProcParam <MotionProcEnv>[] { modeRad, valueRad, modeAxis, valueAxis });
        }
        public bool ValidateArguments(IList <ProcParam <MotionProcEnv> > args, ref string errorMessage)
        {
            SingleSelectParameter mode  = args[0] as SingleSelectParameter;
            NumberParameter       value = args[1] as NumberParameter;

            if (mode.Value == 0 || mode.Value == 1)
            {
                if (value.Value < 0)
                {
                    errorMessage = "負のサイズを指定できません";
                    return(false);
                }
            }
            return(true);
        }
예제 #18
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            SingleSelectParameter unit = args[0] as SingleSelectParameter;
            bool degree = unit.Value == 0;

            MotionObjectInfo info1  = selected[0];
            MotionObjectInfo info2  = selected[1];
            TimeSeriesValues values = new TimeSeriesValues(degree ? "degree" : "radian");

            foreach (ReadOnlyMotionFrame frame in frames)
            {
                LineObject line1 = frame[info1] as LineObject;
                LineObject line2 = frame[info2] as LineObject;
                if (line1 != null && line2 != null)
                {
                    float  cos    = Vector3.Dot(line1.Direction(), line2.Direction());
                    double radian = 0;
                    if (cos <= -1)
                    {
                        radian = Math.PI;
                    }
                    else if (cos < 1)
                    {
                        radian = Math.Acos(cos);
                    }
                    if (degree)
                    {
                        values.SetValue(frame.Time, (decimal)(radian * 180 / Math.PI));
                    }
                    else
                    {
                        values.SetValue(frame.Time, (decimal)radian);
                    }
                }
                else
                {
                    values.SetValue(frame.Time, null);
                }
            }
            SequenceData data = new SequenceData(values, null, PathEx.GiveName("Angle", info1.Name, info2.Name));

            return(new SequenceData[] { data });
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter mode  = args[0] as SingleSelectParameter;
            NumberParameter       value = args[1] as NumberParameter;
            List <MotionObject>   ret   = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                LineObject line = frame[info] as LineObject;
                if (line != null)
                {
                    float length = line.Edge.Length();
                    try {
                        switch (mode.Value)
                        {
                        case 0:
                            length *= (float)value.Value;
                            break;

                        case 1:
                            length = (float)value.Value;
                            break;

                        case 2:
                            length += (float)value.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    ret.Add(new LineObject(line.Position, line.Direction() * length));
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter mode  = args[0] as SingleSelectParameter;
            NumberParameter       value = args[1] as NumberParameter;
            List <MotionObject>   ret   = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                SphereObject sphere = frame[info] as SphereObject;
                if (sphere != null)
                {
                    float radius = sphere.Radius;
                    try {
                        switch (mode.Value)
                        {
                        case 0:
                            radius *= (float)value.Value;
                            break;

                        case 1:
                            radius = (float)value.Value;
                            break;

                        case 2:
                            radius += (float)value.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    ret.Add(new SphereObject(sphere.Position, radius));
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            SingleSelectParameter mode = new SingleSelectParameter("Mode", new string[] { "始点と終点を反転", "終点の向きを反転" });

            return(new ProcParam <MotionProcEnv>[] { mode });
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            SingleSelectParameter mode = new SingleSelectParameter("Operator", new string[] { "Square", "Square root", "Negate", "Inverse", "Sine", "Cosine", "Tangent", "Arcsine", "Arccosine", "Arctangent", "Exponential", "Logarithm" });

            return(new ProcParam <SequenceProcEnv>[] { mode });
        }
        public SequenceData Operate(IList <ProcParam <SequenceProcEnv> > args, SequenceProcEnv env)
        {
            SingleSelectParameter     mode = args[0] as SingleSelectParameter;
            Func <decimal?, decimal?> ope  = new Func <decimal?, decimal?>(x => x);
            string title = "";

            switch (mode.Value)
            {
            case 0:
                ope   = x => x.HasValue ? x * x : null;
                title = "Sq";
                break;

            case 1:
                ope   = x => x.HasValue ? (decimal?)Math.Sqrt((double)x.Value) : null;
                title = "Sqrt";
                break;

            case 2:
                ope   = x => x.HasValue ? -x : null;
                title = "Neg";
                break;

            case 3:
                ope   = x => x.HasValue && x.Value != 0 ? (decimal?)1M / x.Value : null;
                title = "Inv";
                break;

            case 4:
                ope   = x => x.HasValue ? (decimal?)Math.Sin((double)x.Value) : null;
                title = "Sin";
                break;

            case 5:
                ope   = x => x.HasValue ? (decimal?)Math.Cos((double)x.Value) : null;
                title = "Cos";
                break;

            case 6:
                ope   = x => x.HasValue ? (decimal?)Math.Tan((double)x.Value) : null;
                title = "Tan";
                break;

            case 7:
                ope   = x => x.HasValue && -1M <= x.Value && x.Value <= 1M ? (decimal?)Math.Asin((double)x.Value) : null;
                title = "Asin";
                break;

            case 8:
                ope   = x => x.HasValue && -1M <= x.Value && x.Value <= 1M ? (decimal?)Math.Acos((double)x.Value) : null;
                title = "Acos";
                break;

            case 9:
                ope   = x => x.HasValue ? (decimal?)Math.Atan((double)x.Value) : null;
                title = "Atan";
                break;

            case 10:
                ope   = x => x.HasValue ? (decimal?)Math.Exp((double)x.Value) : null;
                title = "Exp";
                break;

            case 11:
                ope   = x => x.HasValue && x.Value > 0M ? (decimal?)Math.Log((double)x.Value) : null;
                title = "Log";
                break;
            }
            TimeSeriesValues ret = new TimeSeriesValues(env.SelectedSequence.Values.ColumnNames.Select(n => title + " " + n).ToArray());

            foreach (var pair in env.SelectedSequence.Values.Enumerate())
            {
                decimal?[] row = new decimal?[ret.ColumnCount];
                for (int i = 0; i < row.Length; i++)
                {
                    try {
                        row[i] = ope(pair.Value[i]);
                    } catch (ArithmeticException) { }
                }
                ret[pair.Key] = row;
            }
            return(new SequenceData(ret, null, PathEx.GiveName(title, env.SelectedSequence.Title)));
        }
        public IList <ProcParam <SequenceProcEnv> > GetParameters()
        {
            var check = new SingleSelectParameter("抽出結果", new[] { "「On」ラベル", "直前のラベル名", "直後のラベル名" });

            return(new[] { check });
        }
예제 #25
0
        public IList <ProcParam <MotionProcEnv> > GetParameters()
        {
            SingleSelectParameter unit = new SingleSelectParameter("Unit", new string[] { "Degree", "Radian" });

            return(new ProcParam <MotionProcEnv>[] { unit });
        }
예제 #26
0
        public void Operate(IList <MotionObjectInfo> selectedInfoList, IList <ProcParam <MotionProcEnv> > args, MotionDataSet dataSet, ProgressInformation progressInfo)
        {
            SingleSelectParameter mode   = args[0] as SingleSelectParameter;
            NumberParameter       limit2 = args[1] as NumberParameter;
            bool addMode = mode.Value == 1;
            int  limit   = (int)limit2.Value;

            progressInfo.Initialize(selectedInfoList.Count, "Interpolate");
            foreach (var info in selectedInfoList)
            {
                // 欠落範囲の集合
                RangeSet <int> missings = new RangeSet <int>();

                bool exist = true;
                int  begin = 0;
                // 最初のフレームからかけている部分,最後のかけている部分は無視
                for (int i = 0; i < dataSet.FrameLength; i++)
                {
                    if (dataSet.GetFrameByIndex(i)[info] == null)
                    {
                        if (exist)
                        {
                            begin = i;
                            exist = false;
                        }
                    }
                    else
                    {
                        if (!exist)
                        {
                            if (begin != 0)
                            {
                                missings.Add(new RangeSet <int> .Range(begin, i));
                                exist = true;
                            }
                        }
                    }
                }
                // 別オブジェクトにするとき用に入力オブジェクトと出力オブジェクトを分ける
                MotionObjectInfo addInfo = info;
                if (addMode)
                {
                    // 別オブジェクトにするオプション
                    addInfo      = new MotionObjectInfo(info.ObjectType, info);
                    addInfo.Name = PathEx.GiveName("interpolate", info.Name);
                    dataSet.AddObject(addInfo);
                }
                // 線形補間
                foreach (var range in missings)
                {
                    if (limit == 0 || range.End - range.Start <= limit)
                    {
                        int          pre       = range.Start - 1;
                        int          post      = range.End;
                        MotionFrame  preFrame  = dataSet.GetFrameByIndex(pre);
                        MotionFrame  postFrame = dataSet.GetFrameByIndex(post);
                        MotionObject preObject = preFrame[info];
                        if (preObject != null)
                        {
                            for (int index = range.Start; index < range.End; index++)
                            {
                                float       interpolater = (float)(index - pre) / (post - pre);
                                MotionFrame frame        = dataSet.GetFrameByIndex(index);
                                frame[addInfo] = preObject.InterpolateLinear(postFrame[info], interpolater);
                            }
                        }
                    }
                }
                progressInfo.CurrentValue++;
            }

            dataSet.DoFrameListChanged();
            if (addMode)
            {
                dataSet.DoObjectInfoSetChanged();
            }
        }