コード例 #1
0
        protected int FindEdge(int currentNode, int nxt, out bool rev)
        {
            NodeAddress node    = m_top.NodeAt(currentNode);
            double      minDist = double.MaxValue;
            int         bestEi  = -1;

            rev = false;

            for (int j = 0; j < node.EdgeCount; j++)
            {
                var ei   = node.EdgeIndexAt(j, m_top);
                var edge = m_top.EdgeAt(ei);
                if (edge.OtherVertex(currentNode) == nxt)
                {
                    if (m_dist[ei] < minDist)
                    {
                        rev     = node.RevAt(j, m_top);
                        bestEi  = ei;
                        minDist = m_dist[ei];
                    }
                }
            }

            if (bestEi == -1)
            {
                throw new KeyNotFoundException("Vertex currentNode is not linked to nxt");
            }

            return(bestEi);
        }
コード例 #2
0
        /// <summary>
        /// Marks all edges and nodes of this graph and returns the result as an array of Guids
        /// </summary>
        /// <returns>The resulting array of Guids</returns>
        public static Guid[] Mark(CurvesTopology top, Color verticesColor, Color edgesColor, Color diverterColor)
        {
            Guid[]           dots = new Guid[top.VertexLength + top.EdgeLength];
            ObjectAttributes oa   = RhinoDoc.ActiveDoc.CreateDefaultAttributes();

            oa.ColorSource = ObjectColorSource.ColorFromObject;

            //Graph vertices color
            for (int i = 0; i < top.VertexLength; i++)
            {
                if (top.NodeAt(i).IsDiverter)
                {
                    oa.ObjectColor = diverterColor;
                    dots[i]        = RhinoDoc.ActiveDoc.Objects.AddTextDot(i.ToString(), top.VertexAt(i), oa);
                    var sette = top.VertexAt(i);
                }
                else
                {
                    oa.ObjectColor = verticesColor;
                    dots[i]        = RhinoDoc.ActiveDoc.Objects.AddTextDot(i.ToString(), top.VertexAt(i), oa);
                    var sette = top.VertexAt(i);
                }
            }

            //Graph edges
            oa.ObjectColor = edgesColor;
            for (int i = 0; i < top.EdgeLength; i++)
            {
                var p = top.CurveAt(i).PointAtNormalizedLength(0.5);
                dots[i + top.VertexLength] = RhinoDoc.ActiveDoc.Objects.AddTextDot(i.ToString(), p, oa);
            }

            RhinoDoc.ActiveDoc.Views.Redraw();
            return(dots);
        }