示例#1
0
            public void ReorderConnections()
            {
                int A = 0;
                int B = 0;
                int C = 0;
                sConnection[] NewOrder = new sConnection[ConnectionCount];
                double[] AwayAngles = new double[ConnectionCount];
                clsPassageNode OtherNode = default(clsPassageNode);
                sXY_int XY_int = new sXY_int();
                double AwayAngle = 0;

                for ( A = 0; A <= ConnectionCount - 1; A++ )
                {
                    OtherNode = Connections[A].GetOther();
                    XY_int.X = OtherNode.Pos.X - Pos.X;
                    XY_int.Y = OtherNode.Pos.Y - Pos.Y;
                    AwayAngle = XY_int.ToDoubles().GetAngle();
                    for ( B = 0; B <= A - 1; B++ )
                    {
                        if ( AwayAngle < AwayAngles[B] )
                        {
                            break;
                        }
                    }
                    for ( C = A - 1; C >= B; C-- )
                    {
                        NewOrder[C + 1] = NewOrder[C];
                        AwayAngles[C + 1] = AwayAngles[C];
                    }
                    NewOrder[B] = Connections[A];
                    AwayAngles[B] = AwayAngle;
                }
                for ( A = 0; A <= ConnectionCount - 1; A++ )
                {
                    Connections[A] = NewOrder[A];
                    if ( Connections[A].IsB )
                    {
                        Connections[A].Connection.PassageNodeB_ConnectionNum = A;
                    }
                    else
                    {
                        Connections[A].Connection.PassageNodeA_ConnectionNum = A;
                    }
                }
            }
示例#2
0
        private bool CheckRampNodeLevelAngles(clsPassageNode RampPassageNode, double RampAwayAngle, double MinSpacingAngle)
        {
            int ConnectionNum = 0;
            clsConnection tmpConnection;
            clsPassageNode OtherPassageNode = default(clsPassageNode);
            int OtherNum = 0;
            bool NarrowConnection = default(bool);
            sXY_int XY_int = new sXY_int();
            bool HasRamp = PassageNodeHasRamp(RampPassageNode);

            for ( ConnectionNum = 0; ConnectionNum <= RampPassageNode.ConnectionCount - 1; ConnectionNum++ )
            {
                tmpConnection = RampPassageNode.Connections[ConnectionNum].Connection;
                OtherPassageNode = RampPassageNode.Connections[ConnectionNum].GetOther();
                if ( OtherPassageNode.Level == RampPassageNode.Level )
                {
                    NarrowConnection = true;
                    if ( ConnectionNum == 0 )
                    {
                        OtherNum = RampPassageNode.ConnectionCount - 1;
                    }
                    else
                    {
                        OtherNum = ConnectionNum - 1;
                    }
                    if ( OtherNum != ConnectionNum )
                    {
                        if ( RampPassageNode.Connections[OtherNum].GetOther().Level == OtherPassageNode.Level )
                        {
                            NarrowConnection = false;
                        }
                    }
                    else
                    {
                        NarrowConnection = false;
                    }
                    if ( ConnectionNum == RampPassageNode.ConnectionCount - 1 )
                    {
                        OtherNum = 0;
                    }
                    else
                    {
                        OtherNum = ConnectionNum + 1;
                    }
                    if ( OtherNum != ConnectionNum )
                    {
                        if ( RampPassageNode.Connections[OtherNum].GetOther().Level == OtherPassageNode.Level )
                        {
                            NarrowConnection = false;
                        }
                    }
                    else
                    {
                        NarrowConnection = false;
                    }
                    if ( NarrowConnection )
                    {
                        XY_int.X = OtherPassageNode.Pos.X - RampPassageNode.Pos.X;
                        XY_int.Y = OtherPassageNode.Pos.Y - RampPassageNode.Pos.Y;
                        //If HasRamp Then
                        //    Return False
                        //End If
                        if ( Math.Abs(MathUtil.AngleClamp(XY_int.ToDoubles().GetAngle() - RampAwayAngle)) < MinSpacingAngle )
                        {
                            return false;
                        }
                        //If PassageNodeHasRamp(OtherPassageNode) Then
                        //    Return False
                        //End If
                    }
                }
            }
            return true;
        }
示例#3
0
        private bool CheckRampNodeRampAngles(clsPassageNode RampPassageNode, clsPassageNode OtherRampPassageNode, double RampAwayAngle, double MinSpacingAngle,
            double MinSpacingAngle2)
        {
            int ConnectionNum = 0;
            clsConnection tmpConnection = default(clsConnection);
            clsPassageNode OtherNode = default(clsPassageNode);
            sXY_int XY_int = new sXY_int();
            double SpacingAngle = 0;
            int RampDifference = 0;

            for ( ConnectionNum = 0; ConnectionNum <= RampPassageNode.ConnectionCount - 1; ConnectionNum++ )
            {
                tmpConnection = RampPassageNode.Connections[ConnectionNum].Connection;
                if ( tmpConnection.IsRamp )
                {
                    OtherNode = RampPassageNode.Connections[ConnectionNum].GetOther();
                    XY_int.X = OtherNode.Pos.X - RampPassageNode.Pos.X;
                    XY_int.Y = OtherNode.Pos.Y - RampPassageNode.Pos.Y;
                    SpacingAngle = Math.Abs(MathUtil.AngleClamp(RampAwayAngle - XY_int.ToDoubles().GetAngle()));
                    RampDifference = Math.Abs(OtherNode.Level - OtherRampPassageNode.Level);
                    if ( RampDifference >= 2 )
                    {
                        if ( SpacingAngle < MinSpacingAngle2 )
                        {
                            return false;
                        }
                    }
                    else if ( RampDifference == 0 )
                    {
                        if ( SpacingAngle < MinSpacingAngle )
                        {
                            return false;
                        }
                    }
                    else
                    {
                        Debugger.Break();
                        return false;
                    }
                }
            }
            return true;
        }
示例#4
0
        private bool CheckRampAngles(clsConnection NewRampConnection, double MinSpacingAngle, double MinSpacingAngle2, double MinPassageSpacingAngle)
        {
            sXY_int XY_int = new sXY_int();
            double NodeAAwayAngle = 0;
            double NodeBAwayAngle = 0;

            XY_int.X = NewRampConnection.PassageNodeB.Pos.X - NewRampConnection.PassageNodeA.Pos.X;
            XY_int.Y = NewRampConnection.PassageNodeB.Pos.Y - NewRampConnection.PassageNodeA.Pos.Y;
            if ( NewRampConnection.PassageNodeA.Connections[NewRampConnection.PassageNodeA_ConnectionNum].IsB )
            {
                NodeBAwayAngle = XY_int.ToDoubles().GetAngle();
                NodeAAwayAngle = MathUtil.AngleClamp(NodeBAwayAngle - Math.PI);
            }
            else
            {
                NodeAAwayAngle = XY_int.ToDoubles().GetAngle();
                NodeBAwayAngle = MathUtil.AngleClamp(NodeBAwayAngle - Math.PI);
            }
            if ( !CheckRampNodeRampAngles(NewRampConnection.PassageNodeA, NewRampConnection.PassageNodeB, NodeAAwayAngle, MinSpacingAngle, MinSpacingAngle2) )
            {
                return false;
            }
            if ( !CheckRampNodeRampAngles(NewRampConnection.PassageNodeB, NewRampConnection.PassageNodeA, NodeBAwayAngle, MinSpacingAngle, MinSpacingAngle2) )
            {
                return false;
            }
            if ( !CheckRampNodeLevelAngles(NewRampConnection.PassageNodeA, NodeAAwayAngle, MinPassageSpacingAngle) )
            {
                return false;
            }
            if ( !CheckRampNodeLevelAngles(NewRampConnection.PassageNodeB, NodeBAwayAngle, MinPassageSpacingAngle) )
            {
                return false;
            }
            return true;
        }