Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        //保存先のファイル名
        string fileName = @"area_info.xml";


        //XmlSerializerオブジェクトを作成
        System.Xml.Serialization.XmlSerializer serializer2 =
            new System.Xml.Serialization.XmlSerializer(typeof(AreaInfoData[]));
        //読み込むファイルを開く
        System.IO.StreamReader sr = new System.IO.StreamReader(
            fileName, new System.Text.UTF8Encoding(false));
        //XMLファイルから読み込み、逆シリアル化する
        AreaInfoData[] objs = (AreaInfoData[])serializer2.Deserialize(sr);
        //ファイルを閉じる
        sr.Close();

        foreach (AreaInfoData aid in objs)
        {
            AreaElement ae = Instantiate(_elementPrefab, transform);
            ae.transform.position = new Vector3(
                (float)Math.Sin(aid.Lng * Math.PI / 180.0f) * 0.45f,
                (float)Math.Sin(aid.Lat * Math.PI / 180.0f) * 0.45f,
                (float)Math.Cos(aid.Lng * Math.PI / 180.0f) * 0.45f);
        }
    }
Пример #2
0
        private void getDeformationAt(AreaElement area, AbstractCase abstractCase, Vector3 request, ref Vector3 deformation)
        {
            Random myRandomizer = new Random(0);

            float max = 0.5f;

            deformation.X += max * (float)myRandomizer.NextDouble();
            deformation.Y += max * (float)myRandomizer.NextDouble();
            deformation.Z += max * (float)myRandomizer.NextDouble();
        }
Пример #3
0
        private static bool equals(AreaElement j, AreaElement i)
        {
            return(((j.J4 != null && i.J4 != null) && (j.J1.Id == i.J1.Id || j.J1.Id == i.J2.Id || j.J1.Id == i.J3.Id || j.J1.Id == i.J4.Id) &&
                    (j.J2.Id == i.J1.Id || j.J2.Id == i.J2.Id || j.J2.Id == i.J3.Id || j.J2.Id == i.J4.Id) &&
                    (j.J3.Id == i.J1.Id || j.J3.Id == i.J2.Id || j.J3.Id == i.J3.Id || j.J3.Id == i.J4.Id) &&
                    (j.J4.Id == i.J1.Id || j.J4.Id == i.J2.Id || j.J4.Id == i.J3.Id || j.J4.Id == i.J4.Id)) ||

                   ((j.J4 == null && i.J4 == null) && (j.J1.Id == i.J1.Id || j.J1.Id == i.J2.Id || j.J1.Id == i.J3.Id) &&
                    (j.J2.Id == i.J1.Id || j.J2.Id == i.J2.Id || j.J2.Id == i.J3.Id) &&
                    (j.J3.Id == i.J1.Id || j.J3.Id == i.J2.Id || j.J3.Id == i.J3.Id) &&
                    (j.J4.Id == i.J1.Id || j.J4.Id == i.J2.Id || j.J4.Id == i.J3.Id)));
        }
Пример #4
0
        public bool GetDeformationVectors(AreaElement area, Vector3[] localAxes, AbstractCase abstractCase, Vector3[] ctrlPoints, Vector3[] deformations)
        {
            // Dummy routine

            int verticesInList = ctrlPoints.Length;

            for (int i = 0; i < verticesInList; ++i)
            {
                getDeformationAt(area, abstractCase, ctrlPoints[i], ref deformations[i]);
            }

            return(true);
        }
    protected virtual IEnumerator UseArea(ChipData chipData)
    {
        m_goChip = ObjectPool.GetInst().GetObject(chipData.objType);
        yield return(null);

        AreaElement areaTmp = m_goChip.GetComponent <AreaElement> ();

        areaTmp.SetUnit(this);
        areaTmp.SetValue(chipData.nValue);
        yield return(null);

        m_goChip = null;
        ResetIdle();

        yield return(null);
    }
Пример #6
0
        /// <summary>
        /// Executes the command.
        /// Creates one AreaElement.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            AreaElement        area;
            List <Joint>       joints = new List <Joint>();
            Joint              joint1, joint2, joint3, joint4;
            AreaProps          props    = new AreaProps();
            List <LineElement> newLines = new List <LineElement>();

            try
            {
                services.GetProperties(Culture.Get("addAreaProps"), props);

                joint1 = services.GetJoint(newLines);
                services.TrackingService = PolygonTrackingService.Instance;
                services.TrackingService.SetPoint(joint1.Position);
                services.Model.ChangeModel();

                joint2 = services.GetJoint(newLines);
                services.TrackingService.SetPoint(joint2.Position);
                services.Model.ChangeModel();

                joint3 = services.GetJoint(newLines);
                services.TrackingService.SetPoint(joint3.Position);
                services.Model.ChangeModel();

                joint4 = services.GetJoint(newLines);
                if (joint4 != null)
                {
                    services.TrackingService.SetPoint(joint4.Position);
                }

                services.Model.AreaList.Add(area = new AreaElement(props, joint1, joint2, joint3, joint4));
                services.Model.ChangeModel();
            }
            catch (Canguro.Controller.CancelCommandException) { }
            //if (newLines.Count == 0)
            //    services.Model.Undo.Rollback();
            //else
            //    JoinCmd.Join(services.Model, new List<Joint>(), newLines);
        }
Пример #7
0
 public float[] GetCurvedPoint(AreaElement area, AbstractCase ac, DeformationAxis component, float xPos)
 {
     return(null);
 }
Пример #8
0
        //public override void Run(Canguro.Controller.CommandServices services)
        //{
        //    objectCount = 0;
        //    if (Clipboard.ContainsData("Canguro"))
        //    {
        //        Stream stream = (Stream)Clipboard.GetData("Canguro");
        //        Magnet magnet = services.GetPoint(Culture.Get("pasteCmdTitle"));

        //        BinaryFormatter bformatter = new BinaryFormatter();
        //        Microsoft.DirectX.Vector3 pivot = (Microsoft.DirectX.Vector3)bformatter.Deserialize(stream);
        //        Microsoft.DirectX.Vector3 v = magnet.SnapPosition - pivot;
        //        List<Joint> newJoints = new List<Joint>();
        //        List<LineElement> newLines = new List<LineElement>();
        //        ItemList<Joint> jList = services.Model.JointList;
        //        ItemList<LineElement> lList = services.Model.LineList;
        //        Dictionary<uint, Joint> jSelection = new Dictionary<uint, Joint>();
        //        Joint nJoint;
        //        LineElement nLine;

        //        objectCount = (int) bformatter.Deserialize(stream);
        //        for (int i = 0; i < objectCount; i++)
        //        {
        //            Element elem = (Element)bformatter.Deserialize(stream);

        //            if (elem is Joint)
        //            {
        //                Joint j = (Joint)elem;
        //                jList.Add(nJoint = new Joint(j.X + v.X, j.Y + v.Y, j.Z + v.Z));
        //                nJoint.Masses = j.Masses;
        //                nJoint.DoF = j.DoF;
        //                jSelection.Add(j.Id, nJoint);
        //                newJoints.Add(nJoint);
        //                CopyLoads(services.Model, j, nJoint);
        //            }
        //            if (elem is LineElement)
        //            {
        //                LineElement l = (LineElement)elem;
        //                lList.Add(nLine = new LineElement(l.Properties));
        //                nLine.I = jSelection[l.I.Id];
        //                nLine.J = jSelection[l.J.Id];
        //                nLine.Angle = l.Angle;
        //                newLines.Add(nLine);
        //                CopyLoads(services.Model, l, nLine);
        //            }
        //            JoinCmd.Join(services.Model, newJoints, newLines);
        //        }
        //    }
        //}

        /// <summary>
        /// Executes the command.
        /// Pastes the Items in the Clpboard under the key Canguro, in the current Model.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            objectCount = 0;
            if (Clipboard.ContainsData("Canguro"))
            {
                object[] data = (object[])Clipboard.GetData("Canguro");
                Dictionary <uint, Joint>  joints     = (Dictionary <uint, Joint>)data[0];
                Dictionary <uint, Joint>  jSelection = new Dictionary <uint, Joint>();
                IList <LineElement>       lines      = (IList <LineElement>)data[1];
                IList <AreaElement>       areas      = (IList <AreaElement>)data[2];
                Microsoft.DirectX.Vector3 pivot      = (Microsoft.DirectX.Vector3)data[3];

                ItemList <Joint>       jList = services.Model.JointList;
                ItemList <LineElement> lList = services.Model.LineList;
                ItemList <AreaElement> aList = services.Model.AreaList;

                Joint       nJoint;
                LineElement nLine;
                AreaElement nArea;
                Magnet      magnet = services.GetPoint(Culture.Get("pasteCmdTitle"));
                if (magnet == null)
                {
                    objectCount = 0;
                }
                else
                {
                    objectCount = joints.Count + lines.Count;
                    Microsoft.DirectX.Vector3 v  = magnet.SnapPosition - pivot;
                    List <Joint>       newJoints = new List <Joint>();
                    List <LineElement> newLines  = new List <LineElement>();
                    List <AreaElement> newAreas  = new List <AreaElement>();

                    Dictionary <string, Layer> layers = new Dictionary <string, Layer>();
                    foreach (Layer l in services.Model.Layers)
                    {
                        if (l != null)
                        {
                            layers.Add(l.Name, l);
                        }
                    }


                    foreach (uint jid in joints.Keys)
                    {
                        Joint j = (joints[jid] == null) ? jList[jid] : joints[jid];
                        jList.Add(nJoint = new Joint(j.X + v.X, j.Y + v.Y, j.Z + v.Z));
                        nJoint.Masses    = j.Masses;
                        if (!layers.ContainsKey(j.Layer.Name))
                        {
                            Layer lay = new Layer(j.Layer.Name);
                            services.Model.Layers.Add(lay);
                            layers.Add(lay.Name, lay);
                        }
                        nJoint.Layer = layers[j.Layer.Name];
                        nJoint.DoF   = j.DoF;
                        jSelection.Add(jid, nJoint);
                        newJoints.Add(nJoint);
                        CopyLoads(services.Model, j, nJoint);
                    }
                    foreach (LineElement l in lines)
                    {
                        if (!layers.ContainsKey(l.Layer.Name))
                        {
                            Layer lay = new Layer(l.Layer.Name);
                            services.Model.Layers.Add(lay);
                            layers.Add(lay.Name, lay);
                        }
                        lList.Add(nLine = new LineElement(l, jSelection[l.I.Id], jSelection[l.J.Id]));
                        nLine.Layer     = layers[l.Layer.Name];
                        newLines.Add(nLine);
                        CopyLoads(services.Model, l, nLine);
                    }
                    foreach (AreaElement a in areas)
                    {
                        if (!layers.ContainsKey(a.Layer.Name))
                        {
                            Layer lay = new Layer(a.Layer.Name);
                            services.Model.Layers.Add(lay);
                            layers.Add(lay.Name, lay);
                        }

                        aList.Add(nArea = new AreaElement(a, jSelection[a.J1.Id], jSelection[a.J2.Id], jSelection[a.J3.Id], (a.J4 != null) ? jSelection[a.J4.Id] : null));
                        if (a.J4 != null)
                        {
                            nArea.J4 = jSelection[a.J4.Id];
                        }
                        nArea.Layer = layers[a.Layer.Name];
                        newAreas.Add(nArea);
                        CopyLoads(services.Model, a, nArea);
                    }
                    JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
                }
            }
        }
Пример #9
0
 public Point TransformToDeviceDPI(Point dragPosition)
 {
     return(AreaElement.TransformToDeviceDPI(dragPosition));
 }
Пример #10
0
        /// <summary>
        /// Executes the command.
        /// Asks for selected Items repetitions and a Vector, and makes the copies.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary <Joint, Joint> joints     = new Dictionary <Joint, Joint>();
            Dictionary <Joint, Joint> jSelection = new Dictionary <Joint, Joint>();
            List <LineElement>        lines      = new List <LineElement>();
            List <LineElement>        lSelection = new List <LineElement>();
            List <AreaElement>        areas      = new List <AreaElement>();
            List <AreaElement>        aSelection = new List <AreaElement>();
            ItemList <Joint>          jList      = services.Model.JointList;
            ItemList <LineElement>    lList      = services.Model.LineList;
            ItemList <AreaElement>    aList      = services.Model.AreaList;
            Joint       nJoint;
            LineElement nLine;
            AreaElement nArea;

            List <Item> selection = services.GetSelection();

            if (selection.Count == 0)
            {
                return;
            }

            foreach (Item item in selection)
            {
                if (item is Joint)
                {
                    jSelection.Add((Joint)item, null);
                    joints.Add((Joint)item, null);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    lSelection.Add(l);
                    lines.Add(l);
                    if (!jSelection.ContainsKey(l.I))
                    {
                        jSelection.Add(l.I, null);
                        joints.Add(l.I, null);
                    }
                    if (!jSelection.ContainsKey(l.J))
                    {
                        jSelection.Add(l.J, null);
                        joints.Add(l.J, null);
                    }
                }
                else if (item is AreaElement)
                {
                    AreaElement a = (AreaElement)item;
                    aSelection.Add(a);
                    areas.Add(a);
                    for (int i = 0; i < ((a.J4 != null) ? 4 : 3); i++)
                    {
                        if (!jSelection.ContainsKey(a[i]))
                        {
                            jSelection.Add(a[i], null);
                            joints.Add(a[i], null);
                        }
                    }
                }
            }

            Microsoft.DirectX.Vector3 v;
            services.GetVector(out v);

            uint   n;
            string str = services.GetString(Culture.Get("getArrayRepetition"));

            n = Convert.ToUInt32(str);

            List <Joint>       newJoints = new List <Joint>();
            List <LineElement> newLines  = new List <LineElement>();
            List <AreaElement> newAreas  = new List <AreaElement>();

            for (int i = 1; i <= n; i++)
            {
                foreach (Joint j in joints.Keys)
                {
                    jList.Add(nJoint = new Joint(j.X + i * v.X, j.Y + i * v.Y, j.Z + i * v.Z));
                    nJoint.Masses    = j.Masses;
                    nJoint.DoF       = j.DoF;
                    jSelection[j]    = nJoint;
                    newJoints.Add(nJoint);
                }
                foreach (LineElement l in lines)
                {
                    lList.Add(nLine = new LineElement(l, jSelection[l.I], jSelection[l.J]));
                    newLines.Add(nLine);
                }
                foreach (AreaElement a in areas)
                {
                    aList.Add(nArea = new AreaElement(a, jSelection[a.J1], jSelection[a.J2], jSelection[a.J3], jSelection[a.J4]));
                    newAreas.Add(nArea);
                }
                services.ReportProgress((uint)(100 * i / n));
                System.Windows.Forms.Application.DoEvents();
            }
            JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
        }
Пример #11
0
 private void store(OleDbConnection cn, AreaElement obj)
 {
     throw new NotImplementedException("Not implemented until version 2.0");
 }
Пример #12
0
        /// <summary>
        /// Finds repeated Joints and Line Elements and deletes them. Deletes only Items in the
        /// parameters and keeps the Item with the smallest ID.
        /// </summary>
        /// <param name="model">The Model object</param>
        /// <param name="joints">List of Joints to check</param>
        /// <param name="lines">List of Line Elements to check</param>
        /// <param name="areas">List of Area Elements to check</param>
        public static void Join(Canguro.Model.Model model, IList <Joint> joints, IList <LineElement> lines, IList <AreaElement> areas)
        {
            System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            try
            {
                Dictionary <uint, uint> deleteJoints = new Dictionary <uint, uint>();
                ItemList <Joint>        jList        = model.JointList;
                ItemList <LineElement>  lList        = model.LineList;
                ItemList <AreaElement>  aList        = model.AreaList;
                bool[] usedJoints = new bool[jList.Count];

                // Find repeated joints
                for (uint ii = 0; ii < joints.Count; ii++)
                {
                    Joint j = joints[(int)ii];
                    if (j != null)
                    {
                        for (uint jj = 0; jj < j.Id; jj++)
                        {
                            Joint mj = jList[jj];
                            if (mj != null && equals(j, mj) &&
                                !deleteJoints.ContainsKey(j.Id))
                            {
                                deleteJoints.Add(j.Id, jj);
                                break;
                            }
                        }
                    }
                    System.Windows.Forms.Application.DoEvents();
                }

                // Move lines to current joints.
                foreach (LineElement l in lines)
                {
                    if (l != null && l.I != null && deleteJoints.ContainsKey(l.I.Id))
                    {
                        l.I = jList[deleteJoints[l.I.Id]];
                    }
                    if (l != null && l.J != null && deleteJoints.ContainsKey(l.J.Id))
                    {
                        l.J = jList[deleteJoints[l.J.Id]];
                    }
                }

                // Delete repeated and Zero-lenght lines.
                for (int i = 0; i < lines.Count; i++)
                {
                    LineElement l = lines[i];
                    if (l != null)
                    {
                        if (l.I.Id == l.J.Id || l.Length < 0.0001F)
                        {
                            lList.RemoveAt((int)l.Id);
                        }
                        else
                        {
                            for (int j = 0; j < (int)l.Id; j++)
                            {
                                LineElement ml = lList[j];
                                if (ml != null && (ml.Id < l.Id && equals(l, ml)))
                                {
                                    lList.RemoveAt((int)l.Id);
                                    ml.IsVisible = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                // Move areas to current joints.
                foreach (AreaElement a in areas)
                {
                    if (a != null && a.J1 != null && deleteJoints.ContainsKey(a.J1.Id))
                    {
                        a.J1 = jList[deleteJoints[a.J1.Id]];
                    }
                    if (a != null && a.J2 != null && deleteJoints.ContainsKey(a.J2.Id))
                    {
                        a.J2 = jList[deleteJoints[a.J2.Id]];
                    }
                    if (a != null && a.J3 != null && deleteJoints.ContainsKey(a.J3.Id))
                    {
                        a.J3 = jList[deleteJoints[a.J3.Id]];
                    }
                    if (a != null && a.J4 != null && deleteJoints.ContainsKey(a.J4.Id))
                    {
                        a.J4 = jList[deleteJoints[a.J4.Id]];
                    }
                }

                // Delete repeated and Zero-area Areas.
                for (int i = 0; i < areas.Count; i++)
                {
                    AreaElement a = areas[i];
                    if (a != null)
                    {
                        if ((a.J4 != null && (a.J1.Id == a.J2.Id || a.J1.Id == a.J3.Id || a.J1.Id == a.J4.Id || a.J2.Id == a.J3.Id || a.J2.Id == a.J4.Id || a.J3.Id == a.J4.Id)) ||
                            (a.J1.Id == a.J2.Id || a.J1.Id == a.J3.Id || a.J2.Id == a.J3.Id) || a.Area < 0.0001F)
                        {
                            aList.RemoveAt((int)a.Id);
                        }
                        else
                        {
                            for (int j = 0; j < (int)a.Id; j++)
                            {
                                AreaElement ml = aList[j];
                                if (ml != null && (ml.Id < a.Id && equals(a, ml)))
                                {
                                    aList.RemoveAt((int)a.Id);
                                    ml.IsVisible = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                // Delete repeated joints.
                foreach (int id in deleteJoints.Keys)
                {
                    jList.RemoveAt(id);
                }

                // Delete unused joints only if lines or areas are used.
                if (lines.Count > 0 || areas.Count > 0)
                {
                    foreach (LineElement l in lList)
                    {
                        if (l != null)
                        {
                            usedJoints[l.I.Id] = true;
                            usedJoints[l.J.Id] = true;
                        }
                    }
                    foreach (AreaElement a in aList)
                    {
                        if (a != null)
                        {
                            usedJoints[a.J1.Id] = true;
                            usedJoints[a.J2.Id] = true;
                            usedJoints[a.J3.Id] = true;
                            usedJoints[a.J4.Id] = true;
                        }
                    }
                    for (int i = 0; i < joints.Count; i++)
                    {
                        Joint j = joints[i];
                        if (j != null && !usedJoints[j.Id] && jList[j.Id] == j)
                        {
                            jList.RemoveAt((int)j.Id);
                        }
                    }
                }
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = cursor;
            }
        }
Пример #13
0
        public static new Element FromObj(object instance)
        {
            if (instance == null)
            {
                return(null);
            }
            try{
                string tagUrn  = (string)GetProperty(instance, "tagUrn");
                string tagName = (string)GetProperty(instance, "tagName");
                if (tagUrn == null || tagUrn == "")
                {
                    switch (tagName.ToLower())
                    {
                    case "!":                       return(CommentElement.FromObj(instance));

                    case "a":                       return(AElement.FromObj(instance));

                    case "area":            return(AreaElement.FromObj(instance));

                    case "base":            return(BaseElement.FromObj(instance));

                    case "basefont":        return(BaseFontElement.FromObj(instance));

                    case "bgsound":         return(BgsoundElement.FromObj(instance));

                    case "address":
                    case "pre":
                    case "center":
                    case "listing":
                    case "xmp":
                    case "plaintext":
                    case "blockquote":      return(BlockElement.FromObj(instance));

                    case "body":            return(BodyElement.FromObj(instance));

                    case "br":                      return(BrElement.FromObj(instance));

                    case "button":          return(ButtonElement.FromObj(instance));

                    case "dd":                      return(DdElement.FromObj(instance));

                    case "div":                     return(DivElement.FromObj(instance));

                    case "dl":                      return(DlElement.FromObj(instance));

                    case "dt":                      return(DtElement.FromObj(instance));

                    case "embed":           return(EmbedElement.FromObj(instance));

                    case "fieldset":        return(FieldsetElement.FromObj(instance));

                    case "font":            return(FontElement.FromObj(instance));

                    case "form":            return(FormElement.FromObj(instance));

                    case "frame":           return(FrameElement.FromObj(instance));

                    case "frameset":        return(FramesetElement.FromObj(instance));

                    case "head":            return(HeadElement.FromObj(instance));

                    case "h1":
                    case "h2":
                    case "h3":
                    case "h4":
                    case "h5":
                    case "h6":
                        return(HnElement.FromObj(instance));

                    case "hr":                      return(HrElement.FromObj(instance));

                    case "html":            return(HtmlElement.FromObj(instance));

                    case "iframe":          return(IframeElement.FromObj(instance));

                    case "img":                     return(ImgElement.FromObj(instance));

                    case "input":           return(InputElement.FromObj(instance));

                    case "isindex":         return(IsindexElement.FromObj(instance));

                    case "legend":          return(LegendElement.FromObj(instance));

                    case "label":           return(LabelElement.FromObj(instance));

                    case "li":                      return(LiElement.FromObj(instance));

                    case "link":            return(LinkElement.FromObj(instance));

                    case "map":                     return(MapElement.FromObj(instance));

                    case "marquee":         return(MarqueeElement.FromObj(instance));

                    case "meta":            return(MetaElement.FromObj(instance));

                    case "nextid":          return(NextidElement.FromObj(instance));

                    case "noembed":
                    case "noframes":
                    case "nolayer":
                    case "noscript":        return(NoshowElement.FromObj(instance));

                    case "applet":
                    case "object":          return(ObjectElement.FromObj(instance));

                    case "ol":                      return(OlElement.FromObj(instance));

                    case "optgroup":
                    case "option":          return(OptionElement.FromObj(instance));

                    case "p":                       return(PElement.FromObj(instance));

                    case "param":           return(ParamElement.FromObj(instance));

                    case "i":
                    case "u":
                    case "b":
                    case "q":
                    case "s":
                    case "strong":
                    case "del":
                    case "strike":
                    case "em":
                    case "small":
                    case "big":
                    case "ruby":
                    case "rp":
                    case "sub":
                    case "sup":
                    case "acronym":
                    case "bdo":
                    case "cite":
                    case "dfn":
                    case "ins":
                    case "code":
                    case "kbd":
                    case "samp":
                    case "var":
                    case "nobr":            return(PhraseElement.FromObj(instance));

                    case "script":          return(ScriptElement.FromObj(instance));

                    case "select":          return(SelectElement.FromObj(instance));

                    case "span":            return(SpanElement.FromObj(instance));

                    case "style":           return(StyleElement.FromObj(instance));

                    case "caption":         return(CaptionElement.FromObj(instance));

                    case "td":
                    case "th":                      return(TableCellElement.FromObj(instance));

                    case "table":           return(TableElement.FromObj(instance));

                    case "colgroup":
                    case "col":                     return(ColElement.FromObj(instance));

                    case "tr":                      return(TrElement.FromObj(instance));

                    case "thead":
                    case "tbody":
                    case "tfoot":           return(TableSectionElement.FromObj(instance));

                    case "textarea":        return(TextAreaElement.FromObj(instance));

                    case "wbr": return(TextElement.FromObj(instance));

                    case "title":           return(TitleElement.FromObj(instance));

                    case "dir":
                    case "menu":
                    case "ul":                      return(UlElement.FromObj(instance));
                        // optionbutton ?
                        // spanflow ?
                        // default:			return UnknownElement.FromObj(instance);
                    }
                }
            }catch {
                // IHTMLElement でない可能性
            }

            return(new Element(instance));
        }
Пример #14
0
        /// <summary>
        /// Executes the command.
        /// Deletes all the selected items except joints connected to undeleted elements.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List <Item>            selection = services.GetSelection();
            ItemList <Joint>       jList     = Canguro.Model.Model.Instance.JointList;
            ItemList <LineElement> lList     = Canguro.Model.Model.Instance.LineList;
            ItemList <AreaElement> aList     = Canguro.Model.Model.Instance.AreaList;

            bool[] hasElement = new bool[jList.Count];
            int    size;

            size = lList.Count;
            for (int i = 1; i < size; i++)
            {
                LineElement obj = lList[i];
                if (obj != null)
                {
                    if (obj.IsSelected)
                    {
                        lList.Remove(obj);
                    }
                    else
                    {
                        hasElement[obj.I.Id] = true;
                        hasElement[obj.J.Id] = true;
                    }
                }
            }

            size = aList.Count;
            for (int i = 1; i < size; i++)
            {
                AreaElement obj = aList[i];
                if (obj != null)
                {
                    if (obj.IsSelected)
                    {
                        aList.Remove(obj);
                    }
                    else
                    {
                        hasElement[obj.J1.Id] = true;
                        hasElement[obj.J2.Id] = true;
                        hasElement[obj.J3.Id] = true;
                        hasElement[obj.J4.Id] = true;
                    }
                }
            }

            size = jList.Count;
            for (int i = 1; i < size; i++)
            {
                Joint obj = jList[i];
                if (i == 500)
                {
                    i = 500;
                }
                if (obj != null && obj.IsSelected && !hasElement[obj.Id])
                {
                    jList.Remove(obj);
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Executes the command.
        /// Makes a copy of the selected items with inverted positions with respect to a mirror plane, defined by 3 points.
        /// If the points are colinear, the 3rd point is taken to be perpendicular to the view.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary <uint, Joint> joints = new Dictionary <uint, Joint>();
            List <LineElement>       lines  = new List <LineElement>();
            List <AreaElement>       areas  = new List <AreaElement>();

            services.GetSelection(joints, lines, areas);

            Dictionary <uint, Joint> jSelection = new Dictionary <uint, Joint>();

            Microsoft.DirectX.Vector3[] pivots = new Microsoft.DirectX.Vector3[3];

            // Get 3 Points
            Magnet m = services.GetPoint(Culture.Get("selectPlainPoints"));

            pivots[0] = m.SnapPosition;

            m         = services.GetPoint(Culture.Get("selectPlainPoints"));
            pivots[1] = m.SnapPosition;

            m         = services.GetPoint(Culture.Get("selectPlainPoints"));
            pivots[2] = m.SnapPosition;
            Vector3 v1 = pivots[0] - pivots[1];
            Vector3 v2 = pivots[1] - pivots[2];

            if (Vector3.Cross(v1, v2).LengthSq() < 0.0001)     // If Colinear, take perpendicular to the active view.
            {
                Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
                v1 = new Vector3(0, 0, 0);
                v2 = new Vector3(0, 0, 1);
                view.Unproject(ref v1);
                view.Unproject(ref v2);
                pivots[2] = pivots[2] + v1 - v2;
            }

            ItemList <Joint>       jList = services.Model.JointList;
            ItemList <LineElement> lList = services.Model.LineList;
            ItemList <AreaElement> aList = services.Model.AreaList;

            Joint              nJoint;
            LineElement        nLine;
            AreaElement        nArea;
            List <Joint>       newJoints = new List <Joint>();
            List <LineElement> newLines  = new List <LineElement>();
            List <AreaElement> newAreas  = new List <AreaElement>();

            foreach (uint jid in joints.Keys)
            {
                Joint   j          = jList[jid];
                Vector3 currentPos = new Vector3(j.X, j.Y, j.Z);
                Vector3 newPos     = Mirror(currentPos, pivots);
                jList.Add(nJoint = new Joint(newPos.X, newPos.Y, newPos.Z));
                nJoint.Masses    = j.Masses;
                nJoint.DoF       = j.DoF;
                jSelection.Add(jid, nJoint);
                newJoints.Add(nJoint);
            }
            foreach (LineElement l in lines)
            {
                lList.Add(nLine = new LineElement(l, jSelection[l.I.Id], jSelection[l.J.Id]));
                newLines.Add(nLine);
            }
            foreach (AreaElement a in areas)
            {
                aList.Add(nArea = new AreaElement(a, jSelection[a.J1.Id], jSelection[a.J2.Id], jSelection[a.J3.Id], (a.J4 != null) ? jSelection[a.J4.Id] : null));
                newAreas.Add(nArea);
            }
            JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
        }
Пример #16
0
 public float[,] GetCurvedAxis(AreaElement area, AbstractCase ac, DeformationAxis component, int numPoints)
 {
     return(null);
 }
Пример #17
0
 private void getCurvedAxis(AreaElement area, AbstractCase ac, DeformationAxis component, float[,] controlPoints)
 {
 }
Пример #18
0
 public Vector3[] GetCurve(AreaElement area, AbstractCase ac, int numPoints, float deformationScale, float paintScaleFactorTranslation, out float[] xPos)
 {
     xPos = null;
     return(null);
 }
Пример #19
0
        /// <summary>
        /// Executes the command.
        /// Copies the selected Items in a series around a given rotation axis.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary <Joint, Joint> joints     = new Dictionary <Joint, Joint>();
            Dictionary <Joint, Joint> jSelection = new Dictionary <Joint, Joint>();
            List <LineElement>        lines      = new List <LineElement>();
            List <LineElement>        lSelection = new List <LineElement>();
            List <AreaElement>        areas      = new List <AreaElement>();
            List <AreaElement>        aSelection = new List <AreaElement>();
            ItemList <Joint>          jList      = services.Model.JointList;
            ItemList <LineElement>    lList      = services.Model.LineList;
            ItemList <AreaElement>    aList      = services.Model.AreaList;
            Joint       nJoint;
            LineElement nLine;
            AreaElement nArea;

            List <Item> selection = services.GetSelection();

            if (selection.Count == 0)
            {
                return;
            }

            foreach (Item item in selection)
            {
                if (item is Joint)
                {
                    jSelection.Add((Joint)item, null);
                    joints.Add((Joint)item, null);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    lSelection.Add(l);
                    lines.Add(l);
                    if (!jSelection.ContainsKey(l.I))
                    {
                        jSelection.Add(l.I, null);
                        joints.Add(l.I, null);
                    }
                    if (!jSelection.ContainsKey(l.J))
                    {
                        jSelection.Add(l.J, null);
                        joints.Add(l.J, null);
                    }
                }
                else if (item is AreaElement)
                {
                    AreaElement a = (AreaElement)item;
                    aSelection.Add(a);
                    areas.Add(a);
                    if (!jSelection.ContainsKey(a.J1))
                    {
                        jSelection.Add(a.J1, null);
                        joints.Add(a.J1, null);
                    }
                    if (!jSelection.ContainsKey(a.J2))
                    {
                        jSelection.Add(a.J2, null);
                        joints.Add(a.J2, null);
                    }
                    if (!jSelection.ContainsKey(a.J3))
                    {
                        jSelection.Add(a.J3, null);
                        joints.Add(a.J3, null);
                    }
                    if (a.J4 != null && !jSelection.ContainsKey(a.J4))
                    {
                        jSelection.Add(a.J4, null);
                        joints.Add(a.J4, null);
                    }
                }
            }

            Microsoft.DirectX.Vector3 v, v2;
            uint n = (uint)services.GetSingle(Culture.Get("getArrayRepetition"));

            float dAngle = float.Parse(services.GetString(Culture.Get("getPolarArrayAngle")));

            dAngle *= (float)Math.PI / 180.0F;
            float angle = 0.0F;

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
            if (m == null)
            {
                return;
            }
            v = m.SnapPosition;

            services.TrackingService = LineTrackingService.Instance;
            services.TrackingService.SetPoint(m.SnapPositionInt);

            m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
            if (m == null)
            {
                return;
            }
            v2 = m.SnapPosition;
            if (v2.Equals(v))
            {
                Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
                Vector3 v1Tmp = new Vector3(0, 0, 0);
                Vector3 v2Tmp = new Vector3(0, 0, 1);
                view.Unproject(ref v1Tmp);
                view.Unproject(ref v2Tmp);
                v2 = v2 + v1Tmp - v2Tmp;
            }
            services.TrackingService = null;

            List <Joint>       newJoints = new List <Joint>();
            List <LineElement> newLines  = new List <LineElement>();
            List <AreaElement> newAreas  = new List <AreaElement>();


            for (int i = 1; i <= n; i++)
            {
                angle += dAngle;

                Matrix trans1 = new Matrix();
                trans1.Translate(-v);
                Matrix rot = new Matrix();
                rot.RotateAxis(v2 - v, angle);
                Matrix trans2 = new Matrix();
                trans2.Translate(v);
                rot = trans1 * rot * trans2;

                foreach (Joint j in joints.Keys)
                {
                    Vector3 pos = new Vector3(j.X, j.Y, j.Z);
                    pos.TransformCoordinate(rot);

                    jList.Add(nJoint = new Joint(pos.X, pos.Y, pos.Z));
                    nJoint.Masses    = j.Masses;
                    nJoint.DoF       = j.DoF;
                    jSelection[j]    = nJoint;
                    newJoints.Add(nJoint);
                }
                foreach (LineElement l in lines)
                {
                    lList.Add(nLine = new LineElement(l, jSelection[l.I], jSelection[l.J]));
                    newLines.Add(nLine);
                }
                foreach (AreaElement a in areas)
                {
                    aList.Add(nArea = new AreaElement(a, jSelection[a.J1], jSelection[a.J2], jSelection[a.J3], (a.J4 != null) ? jSelection[a.J4] : null));
                    newAreas.Add(nArea);
                }
            }
            JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
        }
Пример #20
0
 public void add(AreaElement elem, object before)
 {
     this.Invoke("add", elem, before);
 }