Esempio n. 1
0
            /// <summary>
            /// Adds a list of vertices.
            /// </summary>
            /// <param name="tks">the vertices to be added. Null values are allowed, leaving empty entries that can be filled later.</param>
            /// <returns>the ids assigned to the vertices</returns>
            public virtual int[] Insert(Vertex[] vxs)
            {
                int n  = Items.Length;
                int dn = vxs.Length;

                SySal.TotalScan.Vertex[] newitems = new SySal.TotalScan.Vertex[n + dn];
                int i;

                int[] newids = new int[dn];
                for (i = 0; i < n; i++)
                {
                    newitems[i] = Items[i];
                }
                for (i = 0; i < dn; i++)
                {
                    newitems[i + n] = vxs[i];
                    if (vxs[i] != null)
                    {
                        vxs[i].SetId(i + n);
                    }
                    newids[i] = i + n;
                }
                Items = newitems;
                return(newids);
            }
Esempio n. 2
0
            /// <summary>
            /// Removes the vertices at the specified positions.
            /// </summary>
            /// <param name="pos">the position hosting the vertex to be removed.</param>
            /// <remarks>the ids of the vertices are recomputed.</remarks>
            public virtual void Remove(int[] pos)
            {
                int n  = Items.Length;
                int dn = 0;

                SySal.TotalScan.Vertex zvx = new SySal.TotalScan.Vertex();
                foreach (int tki in pos)
                {
                    if (Items[tki] != zvx)
                    {
                        Items[tki] = zvx;
                        dn++;
                    }
                }
                SySal.TotalScan.Vertex[] newitems = new SySal.TotalScan.Vertex[n - dn];
                int i, j;

                for (i = j = 0; i < n; i++)
                {
                    if (Items[i] != zvx)
                    {
                        newitems[j] = Items[i];
                        if (newitems[j] != null)
                        {
                            ((Vertex)newitems[j]).SetId(j);
                        }
                        j++;
                    }
                }
                Items = newitems;
            }
Esempio n. 3
0
 /// <summary>
 /// Builds an empty list.
 /// </summary>
 public VertexList() : base()
 {
     Items = new SySal.TotalScan.Vertex[0];
 }
Esempio n. 4
0
        /// <summary>
        /// Imports a TotalScan Volume.
        /// </summary>
        /// <param name="ds">the dataset to which the volume to be imported belongs.</param>
        /// <param name="v">the volume to be imported.</param>
        /// <param name="fds">the dataset that should be imported; if this parameter is <c>null</c>, all datasets are imported.</param>
        /// <remarks>The dataset filter only applies to tracks and vertices. All segments are always imported. Track/Vertex dataset consistency should be guaranteed by the user.</remarks>
        public virtual void ImportVolume(DataSet ds, SySal.TotalScan.Volume v, DataSet fds)
        {
            System.Collections.ArrayList dsa = new System.Collections.ArrayList();
            dsa.Add(ds);
            SySal.BasicTypes.Cuboid c = v.Extents;
            if (c.MinX < m_Extents.MinX)
            {
                m_Extents.MinX = c.MinX;
            }
            if (c.MaxX > m_Extents.MaxX)
            {
                m_Extents.MaxX = c.MaxX;
            }
            if (c.MinY < m_Extents.MinY)
            {
                m_Extents.MinY = c.MinY;
            }
            if (c.MaxY > m_Extents.MaxY)
            {
                m_Extents.MaxY = c.MaxY;
            }
            if (c.MinZ < m_Extents.MinZ)
            {
                m_Extents.MinZ = c.MinZ;
            }
            if (c.MaxZ > m_Extents.MaxZ)
            {
                m_Extents.MaxZ = c.MaxZ;
            }
            if (m_Layers.Length == 0)
            {
                m_RefCenter = v.RefCenter;
            }
            int i, j;

            Layer[] tl         = new Layer[v.Layers.Length];
            bool[]  isnewlayer = new bool[v.Layers.Length];
            int[]   oldlength  = new int[v.Layers.Length];
            for (i = 0; i < v.Layers.Length; i++)
            {
                for (j = 0; j < Layers.Length && (Layers[j].BrickId != v.Layers[i].BrickId || Layers[j].SheetId != v.Layers[i].SheetId || Layers[j].Side != v.Layers[i].Side); j++)
                {
                    ;
                }
                if (j == Layers.Length)
                {
                    isnewlayer[i] = true;
                    tl[i]         = new Layer(v.Layers[i], ds);
                    ((LayerList)m_Layers).Insert(tl[i]);
                }
                else
                {
                    isnewlayer[i] = false;
                    tl[i]         = (SySal.TotalScan.Flexi.Layer)Layers[j];
                    oldlength[i]  = tl[i].Length;
                    SySal.TotalScan.Flexi.Segment[] segs = new SySal.TotalScan.Flexi.Segment[v.Layers[i].Length];
                    SySal.TotalScan.Layer           li   = v.Layers[i];
                    for (j = 0; j < segs.Length; j++)
                    {
                        segs[j] = SySal.TotalScan.Flexi.Segment.Copy(li[j], ds);                               //new SySal.TotalScan.Flexi.Segment(li[j], ds);
                    }
                    tl[i].Add(segs);
                }
            }

            Track[] tt = null;// = new Track[v.Tracks.Length];
            System.Collections.ArrayList ato = new System.Collections.ArrayList();
            int[] ixremap = new int[v.Tracks.Length];
            for (i = 0; i < v.Tracks.Length; i++)
            {
                SySal.TotalScan.Track otk = v.Tracks[i];
                if (otk is SySal.TotalScan.Flexi.Track)
                {
                    if (fds != null && SySal.TotalScan.Flexi.DataSet.AreEqual(fds, ((SySal.TotalScan.Flexi.Track)otk).DataSet) == false)
                    {
                        ixremap[i] = -1;
                        continue;
                    }
                }
                ixremap[i] = m_Tracks.Length + i;
                Track tk = new Track(ds, ixremap[i]);
                SySal.TotalScan.Flexi.DataSet tds = null;
                if (otk is SySal.TotalScan.Flexi.Track)
                {
                    tds = ((SySal.TotalScan.Flexi.Track)otk).DataSet;
                }
                SySal.TotalScan.Attribute[] a = otk.ListAttributes();
                foreach (SySal.TotalScan.Attribute a1 in a)
                {
                    if (tds == null && a1.Index is SySal.TotalScan.NamedAttributeIndex && ((SySal.TotalScan.NamedAttributeIndex)a1.Index).Name.StartsWith(DataSetString))
                    {
                        tds          = new DataSet();
                        tds.DataType = ((SySal.TotalScan.NamedAttributeIndex)a1.Index).Name.Substring(DataSetString.Length);
                        tds.DataId   = (long)a1.Value;
                    }
                    else
                    {
                        tk.SetAttribute(a1.Index, a1.Value);
                    }
                }
                if (fds != null && (tds == null || SySal.TotalScan.Flexi.DataSet.AreEqual(fds, tds)))
                {
                    tds = ds;
                }
                if (tds != null)
                {
                    bool found = false;
                    foreach (SySal.TotalScan.Flexi.DataSet dsi in dsa)
                    {
                        if (SySal.TotalScan.Flexi.DataSet.AreEqual(dsi, tds))
                        {
                            tds   = dsi;
                            found = true;
                            break;
                        }
                    }
                    if (found == false)
                    {
                        dsa.Add(tds);
                    }
                    tk.DataSet = tds;
                }
                SySal.TotalScan.Flexi.Segment[] segs = new SySal.TotalScan.Flexi.Segment[otk.Length];
                for (j = 0; j < segs.Length; j++)
                {
                    if (otk[j].PosInLayer >= 0)
                    {
                        /*
                         * segs[j] = (SySal.TotalScan.Flexi.Segment)v.Layers[otk[j].LayerOwner.Id][otk[j].PosInLayer];
                         * segs[j].DataSet = tk.DataSet;
                         */
                        if (isnewlayer[otk[j].LayerOwner.Id])
                        {
                            segs[j] = (SySal.TotalScan.Flexi.Segment)tl[otk[j].LayerOwner.Id][otk[j].PosInLayer];
                        }
                        else
                        {
                            segs[j] = (SySal.TotalScan.Flexi.Segment)tl[otk[j].LayerOwner.Id][oldlength[otk[j].LayerOwner.Id] + otk[j].PosInLayer];
                        }
                        segs[j].DataSet = tk.DataSet;
                    }
                    else
                    {
                        (segs[j] = SySal.TotalScan.Flexi.Segment.Copy(otk[j], tk.DataSet)).SetLayer(tl[otk[j].LayerOwner.Id], -1);
                        tl[otk[j].LayerOwner.Id].Add(new SySal.TotalScan.Flexi.Segment[1] {
                            segs[j]
                        });
                        segs[j].DataSet = tk.DataSet;
                    }
                }
                tk.AddSegments(segs);
                ato.Add(tk);
            }
            tt = (SySal.TotalScan.Flexi.Track [])ato.ToArray(typeof(SySal.TotalScan.Flexi.Track));
            ato.Clear();
            Vertex[] tv = null; // new Vertex[v.Vertices.Length];
            for (i = 0; i < v.Vertices.Length; i++)
            {
                SySal.TotalScan.Vertex ovx = v.Vertices[i];
                if (ovx is SySal.TotalScan.Flexi.Vertex)
                {
                    if (fds != null && SySal.TotalScan.Flexi.DataSet.AreEqual(fds, ((SySal.TotalScan.Flexi.Vertex)ovx).DataSet) == false)
                    {
                        continue;
                    }
                }
                Vertex vx = new Vertex(ds, m_Vertices.Length + i);
                SySal.TotalScan.Flexi.DataSet tds = null;
                if (ovx is SySal.TotalScan.Flexi.Vertex)
                {
                    tds = ((SySal.TotalScan.Flexi.Vertex)ovx).DataSet;
                }
                SySal.TotalScan.Attribute[] a = ovx.ListAttributes();
                foreach (SySal.TotalScan.Attribute a1 in a)
                {
                    if (tds == null && a1.Index is SySal.TotalScan.NamedAttributeIndex && ((SySal.TotalScan.NamedAttributeIndex)a1.Index).Name.StartsWith(DataSetString))
                    {
                        tds          = new DataSet();
                        tds.DataType = ((SySal.TotalScan.NamedAttributeIndex)a1.Index).Name.Substring(DataSetString.Length);
                        tds.DataId   = (long)a1.Value;
                    }
                    else
                    {
                        vx.SetAttribute(a1.Index, a1.Value);
                    }
                }
                if (fds != null && (tds == null || SySal.TotalScan.Flexi.DataSet.AreEqual(fds, tds)))
                {
                    tds = ds;
                }
                if (tds != null)
                {
                    bool found = false;
                    foreach (SySal.TotalScan.Flexi.DataSet dsi in dsa)
                    {
                        if (SySal.TotalScan.Flexi.DataSet.AreEqual(dsi, tds))
                        {
                            tds   = dsi;
                            found = true;
                            break;
                        }
                    }
                    if (found == false)
                    {
                        dsa.Add(tds);
                    }
                    vx.DataSet = tds;
                }
                for (j = 0; j < ovx.Length; j++)
                {
                    SySal.TotalScan.Track otk = ovx[j];
                    if (ixremap[otk.Id] < 0)
                    {
                        break;
                    }
                    if (otk.Upstream_Vertex == ovx)
                    {
                        vx.AddTrack(tt[ixremap[otk.Id]], false);
                        tt[ixremap[otk.Id]].SetUpstreamVertex(vx);
                    }
                    else
                    {
                        vx.AddTrack(tt[ixremap[otk.Id]], true);
                        tt[ixremap[otk.Id]].SetDownstreamVertex(vx);
                    }
                }
                if (j < ovx.Length)
                {
                    continue;
                }
                vx.SetPos(ovx.X, ovx.Y, ovx.Z, ovx.DX, ovx.DY, ovx.AverageDistance);
                ato.Add(vx);
            }
            tv = (SySal.TotalScan.Flexi.Vertex[])ato.ToArray(typeof(SySal.TotalScan.Flexi.Vertex));
            ato.Clear();
            ixremap = null;
            ((TrackList)m_Tracks).Insert(tt);
            ((VertexList)m_Vertices).Insert(tv);
        }
Esempio n. 5
0
 public IsolatedTrackEventExtraTrackFilter(SySal.TotalScan.Vertex v)
 {
     m_MainVertexPos.X = v.X;
     m_MainVertexPos.Y = v.Y;
     m_MainVertexPos.Z = v.Z;
 }
Esempio n. 6
0
 public ZeroMu123ProngEventExtraTrackFilter(SySal.TotalScan.Vertex v)
 {
     m_MainVertexPos.X = v.X;
     m_MainVertexPos.Y = v.Y;
     m_MainVertexPos.Z = v.Z;
 }
Esempio n. 7
0
 public OneMuOrMultiProngZeroEventExtraTrackFilter(SySal.TotalScan.Vertex v)
 {
     m_MainVertexPos.X = v.X;
     m_MainVertexPos.Y = v.Y;
     m_MainVertexPos.Z = v.Z;
 }
Esempio n. 8
0
        private void cmdToVertex_Click(object sender, EventArgs e)
        {
            if (m_VF.Count <= 0)
            {
                return;
            }
            SySal.TotalScan.Track [] tklist = new SySal.TotalScan.Track[m_VF.Count];
            int i;

            System.Collections.ArrayList vtxaltered = new System.Collections.ArrayList();
            for (i = 0; i < tklist.Length; i++)
            {
                SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i);
                tklist[i] = m_V.Tracks[((SySal.TotalScan.BaseTrackIndex)tf.Id).Id];
                tklist[i].SetAttribute(SySal.TotalScan.Vertex.TrackWeightAttribute, tf.Weight);
                bool isupstream             = (tklist[i].Downstream_Z + tklist[i].Upstream_Z) > (tf.MaxZ + tf.MinZ);
                SySal.TotalScan.Vertex vtxa = isupstream ? tklist[i].Upstream_Vertex : tklist[i].Downstream_Vertex;
                if (vtxa != null)
                {
                    if (vtxaltered.Contains(vtxa) == false)
                    {
                        vtxaltered.Add(vtxa);
                    }
                    vtxa.RemoveTrack(tklist[i]);
                }
            }
            int[] ids = new int[vtxaltered.Count];
            for (i = 0; i < ids.Length; i++)
            {
                ids[i] = ((SySal.TotalScan.Vertex)vtxaltered[i]).Id;
            }
            System.Collections.ArrayList vtxremove = new System.Collections.ArrayList();
            foreach (SySal.TotalScan.Vertex vtx in vtxaltered)
            {
                try
                {
                    vtx.NotifyChanged();
                    if (vtx.AverageDistance >= 0.0)
                    {
                        continue;
                    }
                }
                catch (Exception)
                {
                    vtxremove.Add(vtx.Id);
                }
            }

            ((SySal.TotalScan.Flexi.Volume.VertexList)m_V.Vertices).Remove((int[])vtxremove.ToArray(typeof(int)));
            SySal.TotalScan.Flexi.Vertex nv = new SySal.TotalScan.Flexi.Vertex(((SySal.TotalScan.Flexi.Track)tklist[0]).DataSet, m_V.Vertices.Length);
            nv.SetId(m_V.Vertices.Length);
            for (i = 0; i < tklist.Length; i++)
            {
                SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i);
                if ((tklist[i].Downstream_Z + tklist[i].Upstream_Z) > (tf.MaxZ + tf.MinZ))
                {
                    nv.AddTrack(tklist[i], false);
                    tklist[i].SetUpstreamVertex(nv);
                }
                else
                {
                    nv.AddTrack(tklist[i], true);
                    tklist[i].SetDownstreamVertex(nv);
                }
            }
            try
            {
                nv.NotifyChanged();
                if (nv.AverageDistance >= 0.0)
                {
                    ((SySal.TotalScan.Flexi.Volume.VertexList)m_V.Vertices).Insert(new SySal.TotalScan.Flexi.Vertex[1] {
                        nv
                    });
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Can't create new vertex - check geometry/topology.", "Vertex error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                nv.SetId(-1);
            }
            if (nv.Id >= 0)
            {
                string s = "";
                if (ids.Length > 0)
                {
                    s += "\r\nVertices altered: {";
                    for (i = 0; i < ids.Length; i++)
                    {
                        if (i == 0)
                        {
                            s += ids[i].ToString();
                        }
                        else
                        {
                            s += ", " + ids[i].ToString();
                        }
                    }
                    s += "}";
                }
                if (vtxremove.Count > 0)
                {
                    s += "\r\nVertices removed: {";
                    for (i = 0; i < vtxremove.Count; i++)
                    {
                        if (i == 0)
                        {
                            s += vtxremove[i].ToString();
                        }
                        else
                        {
                            s += ", " + vtxremove[i].ToString();
                        }
                    }
                    s += "}";
                }
                MessageBox.Show("New vertex " + nv.Id + " created." + s + "\r\nPlease regenerate the plot to see the changes.", "Vertex created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            TrackBrowser.RefreshAll();
            VertexBrowser.RefreshAll();
        }