Esempio n. 1
0
        /* find groups of nodes connected by wires and map them to the same node.  this speeds things
         * /* up considerably by reducing the size of the matrix */
        void calculateWireClosure()
        {
            int mergeCount = 0;

            mNodeMap      = new Dictionary <Point, NodeMapEntry>();
            mWireInfoList = new List <WireInfo>();
            for (int i = 0; i != mSim.ElmList.Count; i++)
            {
                var ce = mSim.getElm(i);
                if (!(ce is WireElm))
                {
                    continue;
                }
                var we = (WireElm)ce;
                we.HasWireInfo = false;
                mWireInfoList.Add(new WireInfo(we));
                var p1  = ce.GetPost(0);
                var p2  = ce.GetPost(1);
                var cp1 = mNodeMap.ContainsKey(p1);
                var cp2 = mNodeMap.ContainsKey(p2);
                if (cp1 && cp2)
                {
                    var cn1 = mNodeMap[p1];
                    var cn2 = mNodeMap[p2];
                    /* merge nodes; go through map and change all keys pointing to cn2 to point to cn */
                    var tmp = new Dictionary <Point, NodeMapEntry>();
                    foreach (var entry in mNodeMap)
                    {
                        if (entry.Value.Equals(cn2))
                        {
                            tmp.Add(entry.Key, cn1);
                        }
                    }
                    foreach (var entry in tmp)
                    {
                        mNodeMap[entry.Key] = entry.Value;
                    }
                    tmp.Clear();
                    mergeCount++;
                    continue;
                }
                if (cp1)
                {
                    var cn1 = mNodeMap[p1];
                    mNodeMap.Add(ce.GetPost(1), cn1);
                    continue;
                }
                if (cp2)
                {
                    var cn2 = mNodeMap[p2];
                    mNodeMap.Add(ce.GetPost(0), cn2);
                    continue;
                }
                /* new entry */
                var cn = new NodeMapEntry();
                mNodeMap.Add(ce.GetPost(0), cn);
                mNodeMap.Add(ce.GetPost(1), cn);
            }
            /*Console.WriteLine("groups with " + mNodeMap.Count + " nodes " + mergeCount);*/
        }
Esempio n. 2
0
        public Adjustable(StringTokenizer st, CirSim sim)
        {
            int e = st.nextTokenInt();

            if (e == -1)
            {
                return;
            }
            Elm        = sim.getElm(e);
            EditItem   = st.nextTokenInt();
            MinValue   = st.nextTokenDouble();
            MaxValue   = st.nextTokenDouble();
            SliderText = CustomLogicModel.unescape(st.nextToken());
        }