Пример #1
0
        public static void Processor()
        {
            Console.Title = "DOF Converter";
            Program.Choose(1, "dft", out string[] fileNames);
            if (fileNames.Length < 1)
            {
                return;
            }

            string filepath, ext;
            DOF    dft;

            foreach (string file in fileNames)
            {
                using (dft = new DOF())
                {
                    ext      = Path.GetExtension(file);
                    filepath = file.Replace(ext, "");
                    ext      = ext.ToLower();

                    Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
                    if (ext == ".dft")
                    {
                        dft.DFTReader(filepath); dft.TXTWriter(filepath);
                    }
                }
            }
        }
Пример #2
0
 public Node(double x, double z, DOF restraints)
 {
     X          = x;
     Z          = z;
     Restraints = restraints;
     Loads      = new List <NodeLoad>();
 }
Пример #3
0
 public Node(double x, double z, DOF restraints)
 {
     X = x;
     Z = z;
     Restraints = restraints;
     Loads = new List<NodeLoad>();
 }
Пример #4
0
        void Start()
        {
            this.AddInput(GetInput, CB_Order, false);

            foreach (var curve in UIClip.I.clip.curves)
            {
                curve.ast.coord.originPos = curve.ast.transform.localPosition;
            }

            dofSet.Load(); // 强制从文件里读取
                           //avatar.LoadFromDOFMgr(); // 从内存里读取
            dof = dofSet[bone];
            ast = avatar[bone];

            InitUI();

            UITimeLine.I.onFrameIdxChanged = OnFrameIdxChanged;

            UpdateDOF();
            var astOther = avatar[Bone.other];

            if (astOther.transform != null)
            {
                exBone = astOther.transform;
            }
        }
Пример #5
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Hinge(float xMin, float xMax)
    {
        var dof = new DOF();

        dof.count     = 1;
        dof.swingXMin = xMin;
        dof.swingXMax = xMax;
        return(dof);
    }
Пример #6
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Twist(float yMin, float yMax)
    {
        var dof = new DOF();

        dof.count    = 1;
        dof.twistMin = yMin;
        dof.twistMax = yMax;
        return(dof);
    }
Пример #7
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Twist(float range)
    {
        var dof = new DOF();

        dof.count    = 1;
        dof.twistMin = -range;
        dof.twistMax = +range;
        return(dof);
    }
Пример #8
0
        public static Vector3 LimitDOF(Vector3 V, DOF dof)
        {
            var x      = Mathf.Clamp(V.x, dof.swingXMin, dof.swingXMax);
            var y      = Mathf.Clamp(V.y, dof.twistMin, dof.twistMax);
            var z      = Mathf.Clamp(V.z, dof.swingZMin, dof.swingZMax);
            var result = new Vector3(x, y, z);

            return(result);
        }
Пример #9
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Ball(float zMin, float zMax, float xMin, float xMax)
    {
        var dof = new DOF();

        dof.count     = 2;
        dof.swingXMin = xMin;
        dof.swingXMax = xMax;
        dof.swingZMin = zMin;
        dof.swingZMax = zMax;
        return(dof);
    }
Пример #10
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Hinge2D(float xMin, float xMax, float tMin, float tMax)
    {
        var dof = new DOF();

        dof.count     = 2;
        dof.twistMin  = tMin;
        dof.twistMax  = tMax;
        dof.swingXMin = xMin;
        dof.swingXMax = xMax;
        return(dof);
    }
Пример #11
0
 public Task(int Id, BodyPosition Body, ArmPosition Arm, DOF dof, InputType Input = InputType.TRIGGER)
 {
     this.Id              = Id;
     this.Round           = 0;
     this.BodyPos         = Body;
     this.ArmPos          = Arm;
     this.DegreeOfFreedom = dof;
     this.Input           = Input;
     this.Circles         = new List <Circle>();
     this.Stack           = new List <Position>();
 }
Пример #12
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Mirror(DOF origin)
    {
        var dof = new DOF();

        dof.twistMax  = -origin.twistMin;
        dof.twistMin  = -origin.twistMax;
        dof.swingXMax = -origin.swingXMin;
        dof.swingXMin = -origin.swingXMax;
        dof.swingZMax = origin.swingZMax;
        dof.swingZMin = origin.swingZMin;
        return(dof);
    }
Пример #13
0
Файл: DOF.cs Проект: wjk17/WSA
    public static DOF Ball3D(float zMin, float zMax, float xMin, float xMax, float tMin, float tMax)
    {
        var dof = new DOF();

        dof.count     = 3;
        dof.twistMin  = tMin;
        dof.twistMax  = tMax;
        dof.swingXMin = xMin;
        dof.swingXMax = xMax;
        dof.swingZMin = zMin;
        dof.swingZMax = zMax;
        return(dof);
    }
Пример #14
0
        private static DOF finger(int index)
        {
            DOF dof;

            switch (index)
            {
            case 0: dof = DOF.Ball(-10, +10, -80, 30); break; //第一截手指

            case 1: dof = DOF.Hinge(-100, 30); break;         //第二截手指

            case 2: dof = DOF.Hinge(-80, 30); break;          //第三届(末尾)手指

            default: throw new Exception();
            }
            return(dof);
        }
Пример #15
0
    public static List <Task> CreateTasks(LatinSquare LTC, LatinSquare LTT)
    {
        /**string file = Path.Combine(Application.streamingAssetsPath, "latinsquares.txt");
         * for (int r = 0; r <= 12; r++) {*/
        int[] column = LTC.GetColumn(Config.UserId % 8);
        int   start  = (Config.UserId * LTC.GetSize()) % LTT.GetSize();
        //int[] column = LTC.GetColumn(r % 8);
        //int start = (r * LTC.GetSize()) % LTT.GetSize();
        List <Task> Tasks = new List <Task>();

        for (int i = 0; i < column.Length; i++)
        {
            // Get states from LatinSquare for Tasks
            int          state = column[i];
            BodyPosition Body  = state <= 4 ? BodyPosition.SITTING : BodyPosition.STANDING;
            ArmPosition  Arm   = new List <int>()
            {
                1, 2, 5, 6
            }.IndexOf(state) != -1 ? ArmPosition.STRECHED : ArmPosition.APPLIED;
            DOF dof = state % 2 == 0 ? DOF.THREE : DOF.SIX;

            Task tmp = new Task(i, Body, Arm, dof);
            tmp.CreateCircles(LTT, (i * column.Length) % LTT.GetSize());
            Debug.Log(tmp.PrintCommand(i));

            /**if (!File.Exists(file)) {
             *   using (StreamWriter w = File.CreateText(file)) {
             *       w.WriteLine("UserId: " + r + " | TaskNo. " + i + " | Command: " + tmp.PrintCommand(i));
             *   }
             * } else {
             *   using (StreamWriter w = File.AppendText(file)) {
             *       w.WriteLine("UserId: " + r + " | TaskNo. " + i + " | Command: " + tmp.PrintCommand(i));
             *   }
             * }*/

            Tasks.Add(tmp);

            start = start < LTC.GetSize() ? start + 1 : 0;
            //}
        }

        return(Tasks);
    }
Пример #16
0
        void Start()
        {
            this.AddInputCB(null, CB_Order);

            foreach (var curve in UIClip.I.clip.curves)
            {
                curve.ast.coord.originPos = curve.ast.transform.localPosition;
            }

            dofSet.Load(); // 强制从文件里读取
                           //avatar.LoadFromDOFMgr(); // 从内存里读取
            dof = dofSet[bone];
            ast = avatar[bone];

            ASUI.parent = transform.Search("Area");

            InitUI();

            UITimeLine.I.onFrameIdxChanged = OnFrameIdxChanged;

            UpdateDOF();
            exBone = avatar[Bone.other].transform;
        }
Пример #17
0
 /// <summary>
 /// Called by the DOF class when creating an OpenFlight DOF node from file.
 /// </summary>
 /// <param name="switchData"></param>
 public virtual void OnDOFNode(DOF dofData)
 {
     origin                       = new Vector3((float)dofData.Origin[0], (float)dofData.Origin[1], (float)dofData.Origin[2]);
     pointOnXAxis                 = new Vector3((float)dofData.PointOnXAxis[0], (float)dofData.PointOnXAxis[1], (float)dofData.PointOnXAxis[2]);
     pointInXYPlane               = new Vector3((float)dofData.PointInXYPlane[0], (float)dofData.PointInXYPlane[1], (float)dofData.PointInXYPlane[2]);
     minMaxCurrentIncrementX      = new Vector4((float)dofData.MinMaxCurrentIncrementX[0], (float)dofData.MinMaxCurrentIncrementX[1], (float)dofData.MinMaxCurrentIncrementX[2], (float)dofData.MinMaxCurrentIncrementX[3]);
     minMaxCurrentIncrementY      = new Vector4((float)dofData.MinMaxCurrentIncrementY[0], (float)dofData.MinMaxCurrentIncrementY[1], (float)dofData.MinMaxCurrentIncrementY[2], (float)dofData.MinMaxCurrentIncrementY[3]);
     minMaxCurrentIncrementZ      = new Vector4((float)dofData.MinMaxCurrentIncrementZ[0], (float)dofData.MinMaxCurrentIncrementZ[1], (float)dofData.MinMaxCurrentIncrementZ[2], (float)dofData.MinMaxCurrentIncrementZ[3]);
     minMaxCurrentIncrementPitch  = new Vector4((float)dofData.MinMaxCurrentIncrementPitch[0], (float)dofData.MinMaxCurrentIncrementPitch[1], (float)dofData.MinMaxCurrentIncrementPitch[2], (float)dofData.MinMaxCurrentIncrementPitch[3]);
     minMaxCurrentIncrementRoll   = new Vector4((float)dofData.MinMaxCurrentIncrementRoll[0], (float)dofData.MinMaxCurrentIncrementRoll[1], (float)dofData.MinMaxCurrentIncrementRoll[2], (float)dofData.MinMaxCurrentIncrementRoll[3]);
     minMaxCurrentIncrementYaw    = new Vector4((float)dofData.MinMaxCurrentIncrementYaw[0], (float)dofData.MinMaxCurrentIncrementYaw[1], (float)dofData.MinMaxCurrentIncrementYaw[2], (float)dofData.MinMaxCurrentIncrementYaw[3]);
     minMaxCurrentIncrementScaleZ = new Vector4((float)dofData.MinMaxCurrentIncrementScaleZ[0], (float)dofData.MinMaxCurrentIncrementScaleZ[1], (float)dofData.MinMaxCurrentIncrementScaleZ[2], (float)dofData.MinMaxCurrentIncrementScaleZ[3]);
     minMaxCurrentIncrementScaleY = new Vector4((float)dofData.MinMaxCurrentIncrementScaleY[0], (float)dofData.MinMaxCurrentIncrementScaleY[1], (float)dofData.MinMaxCurrentIncrementScaleY[2], (float)dofData.MinMaxCurrentIncrementScaleY[3]);
     minMaxCurrentIncrementScaleX = new Vector4((float)dofData.MinMaxCurrentIncrementScaleX[0], (float)dofData.MinMaxCurrentIncrementScaleX[1], (float)dofData.MinMaxCurrentIncrementScaleX[2], (float)dofData.MinMaxCurrentIncrementScaleX[3]);
     xTranslationLimited          = dofData.FlagsXTranslationLimited;
     yTranslationLimited          = dofData.FlagsYTranslationLimited;
     zTranslationLimited          = dofData.FlagsYTranslationLimited;
     pitchLimited                 = dofData.FlagsPitchLimited;
     rollLimited                  = dofData.FlagsRollLimited;
     yawLimited                   = dofData.FlagsYawLimited;
     scaleXLimited                = dofData.FlagsScaleXLimited;
     scaleYLimited                = dofData.FlagsScaleYLimited;
     scaleZLimited                = dofData.FlagsScaleZLimited;
 }
Пример #18
0
    private void HandleIncomingMessage(TCPServer.ByteCast msg, bool manualControl = false)
    {
        DOF CloseControl  = DOF_ArmList.Where(x => x.ID == 0x09).ElementAt(0);
        DOF PincerControl = DOF_ArmList.Where(x => x.ID == 0x0C).ElementAt(0);
        DOF IndexControl  = DOF_ArmList.Where(x => x.ID == 0x0A).ElementAt(0);
        DOF KeyControl    = DOF_ArmList.Where(x => x.ID == 0x0D).ElementAt(0);

        if (!UseManualControl || manualControl || msg.Operation != 0x01)
        {
            switch (msg.Operation)
            {
            //Control main arm
            case 0x01:

                //update heatmap only if heat is true to prevent errors
                if (MuscularActivityMap && msg.heatmap != null)
                {
                    UpdateMuscularActivityMap  = true;
                    CurrentMuscularActivityMap = msg.heatmap;
                }

                DOF dofArm = DOF_ArmList.Where(x => x.ID == msg.val1).ElementAt(0);

                if (!BlockedMovment.Contains(serverInstance.movement))
                {
                    if (CloseMovement.Contains(msg.val1) && CloseControl.CurrentValue > 0)
                    {
                        CloseControl.Move(msg.val3, 0x0);
                    }
                    else if (msg.val1 == 0x09 && msg.val2 == 0x01 && (PincerControl.CurrentValue > 0 || CloseControl.CurrentValue < 0 || IndexControl.CurrentValue > 0 || KeyControl.CurrentValue > 0))
                    {
                        if (PincerControl.CurrentValue > 0)
                        {
                            PincerControl.Move(msg.val3, 0x0);
                        }

                        if (CloseControl.CurrentValue < 0)
                        {
                            CloseControl.Move(msg.val3, 0x01);
                        }
                        if (IndexControl.CurrentValue > 0)
                        {
                            IndexControl.Move(msg.val3, 0x0);
                        }

                        if (KeyControl.CurrentValue > 0)
                        {
                            KeyControl.Move(msg.val3, 0x0);
                        }
                    }
                    else
                    {
                        dofArm.Move(msg.val3, msg.val2);
                    }
                }
                //fire event OnMotion. Check if someone registered to this event. //this can be simplified by OnMotion?.Invoke(...); If performance drops try the simplification!
                if (OnMotion != null)
                {
                    OnMotion(new HandMotion(serverInstance.movement, dofArm.CurrentValue, msg.val3 / 100f));
                }
                break;

            //Control TAC arm
            case 0x02:
                throw new Exception("TAC-Test not supported");

            // Control the training phase
            case 0x03:
                //TODO
                break;

            //Reset the main arm
            case 0x72:

                switch (msg.val1)
                {
                case 0x74:
                    throw new Exception("TAC-Test not supported");

                default:
                    foreach (var dof in DOF_ArmList)
                    {
                        dof.RestValue();
                    }
                    break;
                }
                break;

            // Configurations
            case 0x63:
                usePalmarGrasp = false;

                switch (msg.val1)
                {
                case 0x01:
                    // Select upper limb or lower limb
                    //TODO
                    new NotImplementedException("Selecting upper limb or lower limb");
                    break;

                case 0x02:
                    throw new Exception("TAC-Test not supported");

                case 0x03:
                    throw new Exception("TAC-Test not supported");

                case 0x05:
                    // Switch between right and left limb
                    RotateArm = true;
                    break;

                default:        //TODO
                    break;
                }
                break;

            default:    //TODO
                break;
            }
        }
        serverInstance.SendAck(0x01);

        //set current movement and current movement's velocity
        currentMovement = serverInstance.movement;
        currentForce    = msg.val3 / 100f; //maybe this is a source for errors. Needs to be tested!
    }
Пример #19
0
 public Constraint(DOF constraintDOFs, params Node[] constraintNodes)
 {
     ConstrainedDOFs = constraintDOFs;
     nodes.AddRange(constraintNodes);
 }
Пример #20
0
        public static void Main()
        {
            /* Declare variables to contain all inputs
             * We can assign initial values (or not) that are either indicative or sensible */
            List <Rhino.Geometry.Line> lines = new List <Line>();

            StormCloud.Types.MaterialType materialtype = new StormCloud.Types.MaterialType(); //PROBLEM HERE???
            String sectiontype = "";

            Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            Line line2 = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 1));
            Line line3 = new Line(new Point3d(0, 0, 1), new Point3d(0, 0, 2));

            lines.Add(line1);
            lines.Add(line2);
            lines.Add(line3);



            // material

            StructureEngine.Model.Material material = new Material(29, 29, 29, 29, ""); // modify to get in solver to get output structure
            materialtype.CastTo <Material>(ref material);

            //if (!DA.GetData(1, ref Material)) { return; }
            //if (!DA.GetData(2, ref Section)) { return; }
            // if (!DA.GetData(1, ref tolerance)) { return; }

            /* If the tolerance is not a valid number, abort */
            // if (!Rhino.RhinoMath.IsValidDouble(tolerance)) { return; }

            /*Retrieve coordinates of start and end points*/
            List <Rhino.Geometry.Point3d> pts = new List <Rhino.Geometry.Point3d>();
            List <Node>   Nodes   = new List <Node>();
            List <Member> Members = new List <Member>();

            ISection SectionType = new RodSection();

            if (sectiontype == "Square")
            {
                SectionType = new SquareSection();
            }



            foreach (Rhino.Geometry.Line line in lines)
            {
                pts.Add(line.From);
                pts.Add(line.To);

                int n1Index = pts.Count - 2;
                int n2Index = pts.Count - 1;

                // Define start node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 2);
                        n1Index = i;
                        n2Index = n2Index - 1; // test
                    }
                }

                DOF x1 = new DOF(pts[n1Index].X);
                DOF y1 = new DOF(pts[n1Index].Y);
                DOF z1 = new DOF(pts[n1Index].Z);

                DOF[] coor1 = new DOF[] { x1, y1, z1, new DOF(0), new DOF(0), new DOF(0) };

                Node n1 = new Node(coor1);
                n1.Index = n1Index;

                // Define end node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 1; i++)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 1);
                        n2Index = i;
                    }
                }

                DOF x2 = new DOF(pts[n2Index].X);
                DOF y2 = new DOF(pts[n2Index].Y);
                DOF z2 = new DOF(pts[n2Index].Z);

                DOF[] coor2 = new DOF[] { x2, y2, z2, new DOF(0), new DOF(0), new DOF(0) };

                Node n2 = new Node(coor2);
                n2.Index = n2Index;

                // Define member

                Member m = new Member(n1, n2);

                m.Material    = material;
                m.SectionType = SectionType;

                //m.Material = Material.MaterialValue;
                //m.Section = Section.SectionValue;

                // Add member and nodes to respective lists

                Nodes.Add(n1);
                Nodes.Add(n2);
                Members.Add(m);
            }

            Structure         Structure     = new Structure(Nodes, Members);
            ComputedStructure CompStructure = new ComputedStructure(Structure);

            Console.ReadLine();
            StormCloud.Types.StructureType Structure_GHrep = new StormCloud.Types.StructureType(CompStructure);  //PROBLEM HERE?????
            /*Assign the outputs via the DA object*/
            //DA.SetDataList(0, pts);
            //DA.SetData(1, Structure_GHrep);

            //           // CONNECTIVITY

            //           /* Declare variables to contain all inputs
            //* We can assign initial values (or not) that are either indicative or sensible */
            //           List<Rhino.Geometry.Line> lines = new List<Line>();
            //           Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            //           Line line2 = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 1));
            //           Line line3 = new Line(new Point3d(0, 0, 1), new Point3d(0, 0, 2));

            //           lines.Add(line1);
            //           lines.Add(line2);
            //           lines.Add(line3);


            //           //CustomTypes.MaterialType Material;
            //           //CustomTypes.SectionType Section;
            //           // double tolerance = double.NaN ;



            //           /*Retrieve coordinates of start and end points*/
            //           List<Rhino.Geometry.Point3d> pts = new List<Rhino.Geometry.Point3d>();
            //           List<Node> Nodes = new List<Node>();
            //           List<Member> Members = new List<Member>();

            //           //////////////

            //           Material mat = new Material(29000, 0.3, 7500, 50, "steel");
            //           ISection SectionType = new RodSection();


            //           foreach (Rhino.Geometry.Line line in lines)
            //           {
            //               pts.Add(line.From);
            //               pts.Add(line.To);

            //               int n1Index = pts.Count - 2;
            //               int n2Index = pts.Count - 1;

            //               // Define start node, eliminate dup if necessary

            //               for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
            //               {
            //                   if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
            //                   {
            //                       pts.RemoveAt(pts.Count - 2);
            //                       n1Index = i;
            //                       n2Index = n2Index - 1; // test
            //                   }
            //               }

            //               DOF x1 = new DOF(pts[n1Index].X);
            //               DOF y1 = new DOF(pts[n1Index].Y);
            //               DOF z1 = new DOF(pts[n1Index].Z);

            //               DOF[] coor1 = new DOF[] { x1, y1, z1, new DOF(0), new DOF(0), new DOF(0) };

            //               Node n1 = new Node(coor1);
            //               n1.Index = n1Index;

            //               // Define end node, eliminate dup if necessary

            //               for (int i = 0; i < pts.Count - 1; i++)
            //               {
            //                   if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
            //                   {
            //                       pts.RemoveAt(pts.Count - 1);
            //                       n2Index = i;
            //                   }
            //               }

            //               DOF x2 = new DOF(pts[n2Index].X);
            //               DOF y2 = new DOF(pts[n2Index].Y);
            //               DOF z2 = new DOF(pts[n2Index].Z);

            //               DOF[] coor2 = new DOF[] { x2, y2, z2, new DOF(0), new DOF(0), new DOF(0) };

            //               Node n2 = new Node(coor2);
            //               n2.Index = n2Index;

            //               // Define member

            //               Member m = new Member(n1, n2);

            //               m.Material = mat;
            //               m.SectionType = SectionType;

            //               //m.Material = Material.MaterialValue;
            //               //m.Section = Section.SectionValue;

            //               // Add member and nodes to respective lists

            //               Nodes.Add(n1);
            //               Nodes.Add(n2);
            //               Members.Add(m);

            //           }

            //           ////////////

            //           // Material


            //           //foreach (Rhino.Geometry.Line line in lines)
            //           //{
            //           //    pts.Add(line.From);
            //           //    pts.Add(line.To);

            //           //    int n1Index = pts.Count - 2;
            //           //    int n2Index = pts.Count - 1;

            //           //    // Define start node, eliminate dup if necessary

            //           //    for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
            //           //    {
            //           //        if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
            //           //        {
            //           //            pts.RemoveAt(pts.Count - 2);
            //           //            n1Index = i;
            //           //            n2Index = n2Index - 1; // test
            //           //        }
            //           //    }

            //           //    DOF x1 = new DOF(pts[n1Index].X);
            //           //    DOF y1 = new DOF(pts[n1Index].Y);
            //           //    DOF z1 = new DOF(pts[n1Index].Z);

            //           //    DOF[] coor1 = new DOF[] { x1, y1, z1 };

            //           //    Node n1 = new Node(coor1);
            //           //    n1.Index = n1Index;

            //           //    // Define end node, eliminate dup if necessary

            //           //    for (int i = 0; i < pts.Count - 1; i++)
            //           //    {
            //           //        if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
            //           //        {
            //           //            pts.RemoveAt(pts.Count - 1);
            //           //            n2Index = i;
            //           //        }
            //           //    }

            //           //    DOF x2 = new DOF(pts[n2Index].X);
            //           //    DOF y2 = new DOF(pts[n2Index].Y);
            //           //    DOF z2 = new DOF(pts[n2Index].Z);

            //           //    DOF[] coor2 = new DOF[] { x2, y2, z2, new DOF(0), new DOF(0), new DOF(0) };

            //           //    Node n2 = new Node(coor2);
            //           //    n2.Index = n2Index;

            //           //    // Define member

            //           //    Member m = new Member(n1, n2);
            //           //    m.Material = mat;

            //           //    //m.Material = Material.MaterialValue;
            //           //    //m.Section = Section.SectionValue;

            //           //    // Add member and nodes to respective lists

            //           //    Nodes.Add(n1);
            //           //    Nodes.Add(n2);
            //           //    Members.Add(m);

            //           //}

            //           foreach (DOF d in Nodes[0].DOFs)
            //           {
            //               d.Fixed = true;
            //           }

            //           foreach (DOF d in Nodes[2].DOFs)
            //           {
            //               d.Fixed = true;
            //           }

            //           Structure structure = new Structure(Nodes, Members);

            //           LoadCase lc = new LoadCase("lc1");

            //           double lx = -1.00;

            //           foreach (Member m in structure.Members)
            //           {
            //               Console.WriteLine(1);
            //               Console.WriteLine(Members[0].NodeI.DOFs.Length);
            //           }


            //           foreach (StructureEngine.Model.Node node in structure.Nodes)
            //               {

            //                       Load loadx = new Load(lx, lc, node.DOFs[0]);
            //                       lc.Loads.Add(loadx);
            //               }
            //               //points.Remove(point); collection was modified each time -> error
            //           structure.LoadCases.Add(lc);
            //           ComputedStructure comp = new ComputedStructure(structure);

            //           Structure Structure = new Structure(Nodes, Members);
            //           ComputedStructure CompStructure = new ComputedStructure(Structure);

            //           // Add Loadcase to structure

            //           FrameAnalysis analysis = new FrameAnalysis();
            //           analysis.RunAnalysis(comp);

            //StormCloudAnalysis.Types.StructureType Structure_GHrep = new StormCloudAnalysis.Types.StructureType(CompStructure);
            /*Assign the outputs via the DA object*/
            //DA.SetDataList(0, pts);
            //DA.SetData(1, Structure_GHrep);

            // LOAD
        }
        public static void Main()
        {
            /* Declare variables to contain all inputs
             * We can assign initial values (or not) that are either indicative or sensible */
            List <Rhino.Geometry.Line> lines = new List <Line>();
            Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            Line line2 = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 1));

            lines.Add(line1);
            lines.Add(line2);


            //CustomTypes.MaterialType Material;
            //CustomTypes.SectionType Section;
            // double tolerance = double.NaN ;



            /*Retrieve coordinates of start and end points*/
            List <Rhino.Geometry.Point3d> pts = new List <Rhino.Geometry.Point3d>();
            List <Node>   Nodes   = new List <Node>();
            List <Member> Members = new List <Member>();

            foreach (Rhino.Geometry.Line line in lines)
            {
                pts.Add(line.From);
                pts.Add(line.To);

                int n1Index = pts.Count - 2;
                int n2Index = pts.Count - 1;

                // Define start node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 2);
                        n1Index = i;
                    }
                }

                DOF x1 = new DOF(pts[n1Index].X);
                DOF y1 = new DOF(pts[n1Index].Y);
                DOF z1 = new DOF(pts[n1Index].Z);

                DOF[] coor1 = new DOF[] { x1, y1, z1 };

                Node n1 = new Node(coor1);
                n1.Index = n1Index;

                // Define end node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 1; i++)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 1);
                        n2Index = i;
                    }
                }

                DOF x2 = new DOF(pts[n2Index].X);
                DOF y2 = new DOF(pts[n2Index].Y);
                DOF z2 = new DOF(pts[n2Index].Z);

                DOF[] coor2 = new DOF[] { x2, y2, z2 };

                Node n2 = new Node(coor2);
                n2.Index = n2Index;

                // Define member

                Member m = new Member(n1, n2);

                //m.Material = Material.MaterialValue;
                //m.Section = Section.SectionValue;

                // Add member and nodes to respective lists

                Nodes.Add(n1);
                Nodes.Add(n2);
                Members.Add(m);
            }

            Structure         Structure     = new Structure(Nodes, Members);
            ComputedStructure CompStructure = new ComputedStructure(Structure);

            Types.StructureType Structure_GHrep = new Types.StructureType(CompStructure);
            /*Assign the outputs via the DA object*/
            //DA.SetDataList(0, pts);
            //DA.SetData(1, Structure_GHrep);
        }
Пример #22
0
 public TransDOF this[DOF dof]
 {
     get { return(this[dof.bone]); }
 }
 public float GetJointValue(DOF joint)
 {
     return(this[joint]);
 }
Пример #24
0
        private static DOF HumanDOF(Bone key, bool mirror)
        {
            DOF dof;

            switch (key)
            {
            //第三截手指
            case Bone.thumb3_l:
            case Bone.index3_l:
            case Bone.middle3_l:
            case Bone.ring3_l:
            case Bone.pinky3_l: dof = finger(2); break;

            //第二截手指
            case Bone.thumb2_l: dof = DOF.Ball(-20, +20, -80, +40); break;

            case Bone.index2_l:
            case Bone.middle2_l:
            case Bone.ring2_l:
            case Bone.pinky2_l: dof = finger(1); break;

            //第一截手指
            case Bone.thumb1_l: dof = DOF.Ball(-15, +15, -30, +15); break;

            case Bone.index1_l: dof = DOF.Hinge(-100, 0); break;

            case Bone.middle1_l:
            case Bone.ring1_l:
            case Bone.pinky1_l: dof = finger(0); break;

            //掌骨(固定)
            case Bone.palm1_l:
            case Bone.palm2_l:
            case Bone.palm3_l:
            case Bone.palm4_l: dof = new DOF(); break;

            //四肢
            case Bone.hand_l: dof = DOF.Ball(-25, +55, -90, +90); break;

            case Bone.forearm_l: dof = DOF.Hinge2D(-150, +0, -145, +10); break;

            case Bone.upperarm_l: dof = DOF.Ball3D(-140, +40, -135, +90, -90, +90); break;

            case Bone.shoulder_l: dof = DOF.Ball(-20, +20, -20, +20); break;

            case Bone.head: dof = DOF.Hinge(-35, +40); break;

            case Bone.neck: dof = DOF.Ball3D(-55, +55, -50, +60, -70, +70); break;

            case Bone.chest: dof = DOF.Ball3D(-25, +25, -15, +40, -40, +40); break;

            case Bone.spine: dof = DOF.Ball3D(-25, +25, -15, +40, -40, +40); break;

            case Bone.heel2_l: dof = new DOF(); break;

            case Bone.heel1_l: dof = new DOF(); break;

            case Bone.toe_l: dof = DOF.Hinge(-40, +50); break;

            case Bone.foot_l: dof = DOF.Ball(-35, +20, -45, +20); break;

            case Bone.shin_l: dof = DOF.Hinge(0, 150); break;

            //case HumanSkeleton.thigh: dof = DOF.Ball3D( -25, +125, -25, +45, -45, +45); dof.Offset(15, 180, 180); break;
            case Bone.thigh_l: dof = DOF.Hinge(-125, +25); break;

            case Bone.hips: dof = new DOF(); break;

            case Bone.root: dof = new DOF(); break;

            case Bone.other: dof = DOF.NoLimit; break;

            default:
                if (!mirror)                         //first time goto left bones(guess is a right bone)
                {
                    return(HumanDOF(key - 1, true)); //second time come to default will fail to else
                }
                else
                {
                    throw new Exception("unknown HumanSkeleton");
                }
            }
            return(dof);
        }
Пример #25
0
 public TransDOF GetTransDOF(DOF dof)
 {
     return(GetTransDOF(dof.bone));
 }
    float this[DOF jointType]
    {
        get
        {
            switch (jointType)
            {
            case DOF.alpha1:
                return(alpha1);

            case DOF.alpha2:
                return(alpha2);

            case DOF.beta:
                return(beta);

            case DOF.gamma1:
                return(gamma1);

            case DOF.gamma2:
                return(gamma2);

            case DOF.gamma3:
                return(gamma3);

            default:
                return(0);
            }
        }
        set
        {
            switch (jointType)
            {
            case DOF.alpha1:
                alpha1 = value;
                break;

            case DOF.alpha2:
                alpha2 = value;
                break;

            case DOF.beta:
                beta = value;
                break;

            case DOF.gamma1:
                gamma1 = value;
                break;

            case DOF.gamma2:
                gamma2 = value;
                break;

            case DOF.gamma3:
                gamma3 = value;
                break;

            default:
                break;
            }
            StartCoroutine(UpdateJointObjTransformAsync());
        }
    }
 public void SetJointValue(DOF joint, float value)
 {
     this[joint] = value;
 }
Пример #28
0
 public static void LimitDOF(TransDOF ast, DOF dof)
 {
     ast.euler = LimitDOF(ast.euler, dof);
 }
Пример #29
0
 public Constraint(DOF constraintDOFs, params Node[] constraintNodes)
 {
     ConstrainedDOFs = constraintDOFs;
     nodes.AddRange(constraintNodes);
 }
Пример #30
0
 private void debugTimer_Tick(object sender, EventArgs e)
 {
     STF.SetStats(Manager.FPS, Manager.UsedMem, Manager.FreeMem, DebugSocket.State);
     DOF.SetText(Manager.DebugOutput);
 }
Пример #31
0
        public static void Processor(bool json)
        {
            Console.Title = "DOF Converter";
            Program.Choose(1, "dft", out string[] fileNames);
            if (fileNames.Length < 1)
            {
                return;
            }

            bool cc = false;

            foreach (string file in fileNames)
            {
                if (file.EndsWith(".dft"))
                {
                    cc = true; break;
                }
            }

            string choose = "";

            if (cc)
            {
                Console.Clear();
                Program.ConsoleDesign(true);
                Program.ConsoleDesign("          Choose type of format to export:");
                Program.ConsoleDesign(false);
                Program.ConsoleDesign("1. JSON");
                Program.ConsoleDesign("2. TXT");
                Program.ConsoleDesign(false);
                Program.ConsoleDesign(true);
                Console.WriteLine();
                choose = Console.ReadLine().ToUpper();
            }

            string filepath, ext;
            DOF    dft;

            foreach (string file in fileNames)
            {
                using (dft = new DOF())
                {
                    filepath = Path.RemoveExtension(file);
                    ext      = Path.GetExtension(file).ToLower();

                    Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
                    if (ext == ".dft")
                    {
                        dft.DFTReader(filepath);
                        if (choose == "2" && !dft.IsX)
                        {
                            dft.TXTWriter(filepath);
                        }
                        else
                        {
                            dft.MsgPackWriter(filepath, json);
                        }
                    }
                    else if (ext == ".json" || ext == ".mp")
                    {
                        dft.MsgPackReader(filepath, json);
                        dft.DFTWriter(filepath);
                    }
                }
            }
        }
        public static void Main()
        {
            /* Declare variables to contain all inputs
             * We can assign initial values (or not) that are either indicative or sensible */
            List <Rhino.Geometry.Line> lines = new List <Line>();
            ///Types.MaterialType materialtype = null; PROBLEM HERE???
            String sectiontype = "";

            Line line1 = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            Line line2 = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 1));
            Line line3 = new Line(new Point3d(0, 0, 1), new Point3d(0, 0, 2));

            lines.Add(line1);
            lines.Add(line2);
            lines.Add(line3);



            // material

            StructureEngine.Model.Material material = new Material(29, 29, 29, 29, ""); // modify to get in solver to get output structure
            //materialtype.CastTo<Material>(ref material);

            //if (!DA.GetData(1, ref Material)) { return; }
            //if (!DA.GetData(2, ref Section)) { return; }
            // if (!DA.GetData(1, ref tolerance)) { return; }

            /* If the tolerance is not a valid number, abort */
            // if (!Rhino.RhinoMath.IsValidDouble(tolerance)) { return; }

            /*Retrieve coordinates of start and end points*/
            List <Rhino.Geometry.Point3d> pts = new List <Rhino.Geometry.Point3d>();
            List <Node>   Nodes   = new List <Node>();
            List <Member> Members = new List <Member>();

            ISection SectionType = new RodSection();

            if (sectiontype == "Square")
            {
                SectionType = new SquareSection();
            }



            foreach (Rhino.Geometry.Line line in lines)
            {
                pts.Add(line.From);
                pts.Add(line.To);

                int n1Index = pts.Count - 2;
                int n2Index = pts.Count - 1;

                // Define start node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 2; i++) // < should become <= (or not?)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 2], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 2);
                        n1Index = i;
                        n2Index = n2Index - 1; // test
                    }
                }

                DOF x1 = new DOF(pts[n1Index].X);
                DOF y1 = new DOF(pts[n1Index].Y);
                DOF z1 = new DOF(pts[n1Index].Z);

                DOF[] coor1 = new DOF[] { x1, y1, z1, new DOF(0), new DOF(0), new DOF(0) };

                Node n1 = new Node(coor1);
                n1.Index = n1Index;

                // Define end node, eliminate dup if necessary

                for (int i = 0; i < pts.Count - 1; i++)
                {
                    if (Rhino.Geometry.Point3d.Equals(pts[pts.Count - 1], pts[i]))
                    {
                        pts.RemoveAt(pts.Count - 1);
                        n2Index = i;
                    }
                }

                DOF x2 = new DOF(pts[n2Index].X);
                DOF y2 = new DOF(pts[n2Index].Y);
                DOF z2 = new DOF(pts[n2Index].Z);

                DOF[] coor2 = new DOF[] { x2, y2, z2, new DOF(0), new DOF(0), new DOF(0) };

                Node n2 = new Node(coor2);
                n2.Index = n2Index;

                // Define member

                Member m = new Member(n1, n2);

                m.Material    = material;
                m.SectionType = SectionType;

                //m.Material = Material.MaterialValue;
                //m.Section = Section.SectionValue;

                // Add member and nodes to respective lists

                Nodes.Add(n1);
                Nodes.Add(n2);
                Members.Add(m);
            }

            Structure         Structure     = new Structure(Nodes, Members);
            ComputedStructure CompStructure = new ComputedStructure(Structure);

            StormCloudAnalysis.Types.StructureType Structure_GHrep = new StormCloudAnalysis.Types.StructureType(CompStructure);  //PROBLEM HERE?????
            /*Assign the outputs via the DA object*/
            //DA.SetDataList(0, pts);
            //DA.SetData(1, Structure_GHrep);
        }