Пример #1
0
        public override void OnButtonDownEvent(InputEvent evt)
        {
            Renderer renderer = GetRenderer();
            m_Step += 1;
            if (m_Step == (int)EditStep.ES_Finish)
            {
                m_Step = (int)EditStep.ES_Init;

                LineNode lineNode = new LineNode();
                lineNode.Set(m_StartPos, ToWorldPoint(evt.GetMousePosition()));

                renderer.GetSceneManager().AddNode(lineNode);
                tempLineNode.SetVisible(false);

                renderer.RequestDraw(1);
                return;
            }

            if (evt.IsLButtonDown())
            {
                m_StartPos = ToWorldPoint(evt.GetMousePosition());
                tempLineNode.SetVisible(true);
                renderer.RequestDraw(1);
            }
        }
        public override void OnButtonDownEvent(InputEvent evt)
        {
            TopoShape shape = GetSelectedShape((int)evt.GetMousePosition().X, (int)evt.GetMousePosition().Y);
            if(shape == null)
                return;

            Renderer renderer = GetRenderer();
            m_Step += 1;
            if (m_Step == (int)EditStep.ES_Finish)
            {
                m_Step = (int)EditStep.ES_Init;

                MeasureTools mt = new MeasureTools();
                MeasureResult rt = mt.ComputeMinDistance(m_Shape1, shape);

                LineNode lineNode = new LineNode();
                lineNode.SetShowText(true);
                lineNode.Set(rt.GetPointOnShape1(), rt.GetPointOnShape2());

                renderer.GetSceneManager().AddNode(lineNode);
                renderer.RequestDraw(1);
                return;
            }

            if (evt.IsLButtonDown())
            {
                
                m_Shape1 = shape;
            }
        }
Пример #3
0
		public LineWidthState (LineWidthAction action, CCNode target, float endWidth) : base (action, target)
		{
			castedTarget = target as LineNode;

			if (castedTarget == null) {
				throw new InvalidOperationException ("The argument target must be a LineNode");
			}

			startWidth = castedTarget.Width;
			deltaWidth = endWidth - startWidth;
		}
        public override void OnButtonDownEvent(InputEvent evt)
        {

            if (evt.IsRButtonDown())
            {
                this.Exit(1);
                return;
            }
            this.RemoveAllTempNodes();

            Renderer rv = GetRenderer();

            PickHelper pickHelper = new PickHelper();
            pickHelper.Initialize(rv);

            if (!pickHelper.Pick(evt.GetMousePosition()))
                return;


            TopoShape shape = pickHelper.GetGeometry();
            GeomSurface surface = new GeomSurface();
            if (!surface.Initialize(shape))
                return;

            IntersectionLineSurface intersector = new IntersectionLineSurface();
            intersector.SetSurface(shape);
            if (!intersector.Perform(rv.ComputeScreenRay(evt.GetMousePosition())))
            {
                return;
            }

            int nCount = intersector.GetPointCount();
            if(nCount < 1)
                return;

            float u = intersector.GetParameterU(1);
            float v = intersector.GetParameterV(1);

            Vector3 pt = surface.Value(u, v);
            Vector3 normal = surface.GetNormal(u, v);

            LineNode lineNode = new LineNode();
            lineNode.Set(pt, pt + normal);

            this.ShowTempNode(lineNode);
            rv.RequestDraw(1);
        }
Пример #5
0
        /// <summary>
        ///     Rebuild the tree, in O(n).
        /// </summary>
        public void RebuildTree(List <DocumentLine> documentLines)
        {
            var nodes = new LineNode[documentLines.Count];

            for (var i = 0; i < documentLines.Count; i++)
            {
                var ls   = documentLines[i];
                var node = ls.InitLineNode();
                nodes[i] = node;
            }
            Debug.Assert(nodes.Length > 0);
            // now build the corresponding balanced tree
            var height = GetTreeHeight(nodes.Length);

            Debug.WriteLine("DocumentLineTree will have height: " + height);
            root       = BuildTree(nodes, 0, nodes.Length, height);
            root.color = BLACK;
#if DEBUG
            CheckProperties();
#endif
        }
Пример #6
0
        void RotateRight(LineNode p)
        {
            // let q be p's left child
            LineNode q = p.left;

            Debug.Assert(q != null);
            Debug.Assert(q.parent == p);
            // set q to be the new root
            ReplaceNode(p, q);

            // set p's left child to be q's right child
            p.left = q.right;
            if (p.left != null)
            {
                p.left.parent = p;
            }
            // set q's right child to be p
            q.right  = p;
            p.parent = q;
            UpdateAfterRotateRight(p);
        }
Пример #7
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfRequiredOrScript();

        LineNode     line = target as LineNode;
        Conversation conv = line.graph as Conversation;

        string[] characters = conv.characters;

        SerializedProperty characterProperty = serializedObject.FindProperty("m_character");
        int selectedCharacter = Array.IndexOf(characters, characterProperty.stringValue);

        if (selectedCharacter < 0)
        {
            selectedCharacter = 0;
        }
        selectedCharacter             = EditorGUILayout.Popup("Character", selectedCharacter, characters);
        characterProperty.stringValue = characters[selectedCharacter];

        DrawPropertiesExcluding(serializedObject, "m_Script", "graph", "position", "previous", "next", "m_character");
        serializedObject.ApplyModifiedProperties();
    }
Пример #8
0
        internal static int GetIndexFromNodeExtended(LineNode node)
        {
            int      index = (node.left != null) ? node.left.nodeTotalCountExtended : 0;
            LineNode ns    = node;

            //if(node.parent != null && node.parent.left == node)
            {
                //if(node.obs == null)
                //index++;
            }
            while (node.parent != null)
            {
                if (node == node.parent.right)
                {
                    if (node.parent.left != null)
                    {
                        index += node.parent.left.nodeTotalCountExtended;
                        if (node.parent.obs == null)
                        {
                            index++;
                        }
                    }

                    //if (node.parent.obs == null)
                    //    index++;

                    //if (node != ns && node.obs == null)
                    //    index++;
                    //if (node.obs == null)
                    //{
                    //    index++;
                    //}
                }
                //if (node.parent.obs == null)
                //    index++;
                node = node.parent;
            }
            return(index);
        }
Пример #9
0
        internal static void UpdateAfterChildrenChange(LineNode node)
        {
            int totalCount         = 1;
            int totalCountExtended = 1;

            if (node.obs != null)
            {
                totalCountExtended = 0;
            }
            int totalLength = node.TotalLength;

            if (node.left != null)
            {
                totalCount += node.left.nodeTotalCount;

                totalCountExtended += node.left.nodeTotalCountExtended;
                totalLength        += node.left.nodeTotalLength;
            }
            if (node.right != null)
            {
                totalCount         += node.right.nodeTotalCount;
                totalCountExtended += node.right.nodeTotalCountExtended;

                totalLength += node.right.nodeTotalLength;
            }
            //if (totalCount != node.nodeTotalCount
            //    || totalLength != node.nodeTotalLength || totalCountExtended != node.nodeTotalCountExtended/* || node.obs != null*/)
            {
                node.nodeTotalCount = totalCount;

                node.nodeTotalCountExtended = totalCountExtended;

                node.nodeTotalLength = totalLength;
                if (node.parent != null)
                {
                    UpdateAfterChildrenChange(node.parent);
                }
            }
        }
Пример #10
0
		LineNode GetNodeByOffset(int offset)
		{
			Debug.Assert(offset >= 0);
			Debug.Assert(offset <= root.nodeTotalLength);
			if (offset == root.nodeTotalLength) {
				return root.RightMost;
			}
			LineNode node = root;
			while (true) {
				if (node.left != null && offset < node.left.nodeTotalLength) {
					node = node.left;
				} else {
					if (node.left != null) {
						offset -= node.left.nodeTotalLength;
					}
					offset -= node.TotalLength;
					if (offset < 0)
						return node;
					node = node.right;
				}
			}
		}
Пример #11
0
		/*
		1. A node is either red or black.
		2. The root is black.
		3. All leaves are black. (The leaves are the NIL children.)
		4. Both children of every red node are black. (So every red node must have a black parent.)
		5. Every simple path from a node to a descendant leaf contains the same number of black nodes. (Not counting the leaf node.)
		 */
		void CheckNodeProperties(LineNode node, LineNode parentNode, bool parentColor, int blackCount, ref int expectedBlackCount)
		{
			if (node == null) return;
			
			Debug.Assert(node.parent == parentNode);
			
			if (parentColor == RED) {
				Debug.Assert(node.color == BLACK);
			}
			if (node.color == BLACK) {
				blackCount++;
			}
			if (node.left == null && node.right == null) {
				// node is a leaf node:
				if (expectedBlackCount == -1)
					expectedBlackCount = blackCount;
				else
					Debug.Assert(expectedBlackCount == blackCount);
			}
			CheckNodeProperties(node.left, node, node.color, blackCount, ref expectedBlackCount);
			CheckNodeProperties(node.right, node, node.color, blackCount, ref expectedBlackCount);
		}
Пример #12
0
        /// <summary>
        /// WIKITEXT
        /// </summary>
        /// <remarks>An empty WIKITEXT contains nothing. Thus the parsing should always be successful.</remarks>
        private Wikitext ParseWikitext()
        {
            cancellationToken.ThrowIfCancellationRequested();
            ParseStart();
            var      node     = new Wikitext();
            LineNode lastLine = null;

            if (NeedsTerminate())
            {
                return(ParseSuccessful(node));
            }
NEXT_LINE:
            var line = ParseLine(lastLine);

            if (line != EMPTY_LINE_NODE)
            {
                lastLine = line;
                node.Lines.Add(line);
            }
            var extraPara = ParseLineEnd(lastLine);

            if (extraPara == null)
            {
                // Failed to read a \n , which means we've reached a terminator.
                // This is guaranteed in ParseLineEnd
                Debug.Assert(NeedsTerminate());
                return(ParseSuccessful(node));
            }
            // Otherwise, check whether we meet a terminator before reading another line.
            if (extraPara != EMPTY_LINE_NODE)
            {
                node.Lines.Add(extraPara);
            }
            if (NeedsTerminate())
            {
                return(ParseSuccessful(node));
            }
            goto NEXT_LINE;
        }
Пример #13
0
        public void HitTest_Should_Be_False()
        {
            var lineNode = new LineNode(
                Matrix.Identity,
                new Pen(Brushes.Black, 3),
                new Point(15, 10),
                new Point(150, 73));

            var pointsOutside = new List <Point>()
            {
                new Point(14, 8),
                new Point(14, 8.8),
                new Point(30, 15.3),
                new Point(30, 18.7),
                new Point(151, 71.8),
                new Point(155, 75),
            };

            foreach (var point in pointsOutside)
            {
                Assert.False(lineNode.HitTest(point));
            }
        }
Пример #14
0
        public void HitTest_Should_Be_True()
        {
            var lineNode = new LineNode(
                Matrix.Identity,
                new Pen(Brushes.Black, 3),
                new Point(15, 10),
                new Point(150, 73));

            var pointsInside = new List <Point>()
            {
                new Point(14, 8.9),
                new Point(15, 10),
                new Point(30, 15.5),
                new Point(30, 18.5),
                new Point(150, 73),
                new Point(151, 71.9),
            };

            foreach (var point in pointsInside)
            {
                Assert.True(lineNode.HitTest(point));
            }
        }
Пример #15
0
 // Token: 0x06000BDB RID: 3035 RVA: 0x0011429C File Offset: 0x0011249C
 public void UpdateLineTag(int LineTableID)
 {
     if (DataManager.CompareStr(DataManager.MapDataController.MapLineTable[LineTableID].playerName, DataManager.Instance.RoleAttr.Name) == 0)
     {
         DataManager.Instance.RoleAlliance.Tag.ClearString();
         DataManager.Instance.RoleAlliance.Tag.Append(DataManager.MapDataController.MapLineTable[LineTableID].allianceTag);
         if (DataManager.Instance.RoleAlliance.Tag.Length == 0)
         {
             DataManager.Instance.RoleAlliance.Id        = 0u;
             DataManager.Instance.RoleAlliance.KingdomID = 0;
         }
         LineNode lineValue = this.mapLineController.getLineValue(DataManager.MapDataController.MapLineTable[LineTableID].lineObject);
         lineValue.NodeName.updateName(DataManager.MapDataController.MapLineTable[LineTableID].playerName, DataManager.MapDataController.MapLineTable[LineTableID].allianceTag, 0, null);
     }
     else
     {
         bool       bEase    = true;
         ELineColor color    = ELineColor.BLUE;
         EUnitSide  unitSide = EUnitSide.BLUE;
         DataManager.checkLineColorID(LineTableID, out color, out unitSide, out bEase);
         this.mapLineController.setLineColor(DataManager.MapDataController.MapLineTable[LineTableID].lineObject, color, unitSide, DataManager.MapDataController.MapLineTable[LineTableID].playerName, DataManager.MapDataController.MapLineTable[LineTableID].allianceTag, bEase);
     }
 }
Пример #16
0
        protected override Measurement MeasureOverride(Size availableSize)
        {
            //var doc = Document ?? throw new LayoutException("Document was not set");

            var ms = new Measurement(this);

            lineNodes = new List <LineNode>();
            foreach (var leaf in Leaves)
            {
                leaf.Measure(availableSize);
                var nodes = leaf.GetNodes();
                if (nodes.Length > 0)
                {
                    lineNodes.AddRange(nodes);
                }
            }
            LineNodeTransformer.Clean(lineNodes);
            if (lineNodes.Count > 0)
            {
                var indent = Style.Get(StyleKeys.ParagraphIndent);

                if (indent.Value > 0)
                {
                    lineNodes.Insert(0, LineNode.Box(indent.Point, string.Empty));
                }

                var linebreak       = new Linebreak();
                var breaks          = linebreak.BreakLines(lineNodes, new double[] { availableSize.Width }, new LinebreakOptions());
                var positionedItems = linebreak.PositionItems(lineNodes, new double[] { availableSize.Width }, breaks, false);
                lines = ProduceLines(positionedItems);
                double totalHeight = 0;

                for (int i = 0; i < lines.Length; i++)
                {
                    var line        = lines[i];
                    var height      = 0.0;
                    var lastElement = line[^ 1];
        private bool SpawnVehicle(TrafficVolume.VehicleSpawnedEventArgs e)
        {
            LineNode start = e.tv.startNodes.nodes[GlobalRandom.Instance.Next(e.tv.startNodes.nodes.Count)];

            if (start.nextConnections.Count > 0)
            {
                int            foo = GlobalRandom.Instance.Next(start.nextConnections.Count);
                NodeConnection nc  = start.nextConnections[foo];

                e.vehicleToSpawn.state = new IVehicle.State(nc, 0);
                if (e.vehicleToSpawn.GetType() == typeof(Car))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(carTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, carTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Truck))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(truckTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, truckTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Tram))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(tramTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, tramTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Bus))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(busTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, busTargetVelocity), 0);
                }

                if (start.nextConnections[foo].AddVehicle(e.vehicleToSpawn))
                {
                    e.vehicleToSpawn.targetNodes  = e.tv.destinationNodes.nodes;
                    e.vehicleToSpawn.VehicleDied += new IVehicle.VehicleDiedEventHandler(e.tv.SpawnedVehicleDied);
                    return(true);
                }
            }

            return(false);
        }
Пример #18
0
        public void LineNode()
        {
            var tc = new TestCore(new Configuration());

            tc.Init();

            var line1 = new LineNode()
            {
                Color     = new Color(255, 0, 0),
                Point1    = new Vector2F(100f, 100f),
                Point2    = new Vector2F(200f, 200f),
                Thickness = 10f,
            };
            var line2 = new LineNode()
            {
                Color     = new Color(0, 255, 0),
                Point1    = new Vector2F(50f, 450f),
                Point2    = new Vector2F(600f, 50f),
                Thickness = 5.0f,
            };
            var line3 = new LineNode()
            {
                Color     = new Color(0, 0, 255),
                Point1    = new Vector2F(100f, 150f),
                Point2    = new Vector2F(100f, 350f),
                Thickness = 15.0f,
            };

            Engine.AddNode(line1);
            Engine.AddNode(line2);
            Engine.AddNode(line3);

            tc.LoopBody(null, null);

            tc.End();
        }
Пример #19
0
    //Creates a LineNode for the body part joint, the node lasts timeToFinish seconds,
    //travels for timeLine seconds, from spawnPosition to pos1 to pos2
    public GameObject CreateLineNode(Joint joint, float timeToFinish, float timeLine, Vector3 spawnPosition, Vector3[] pathPositions)
    {
        switch (joint)
        {
        case Joint.RightHand:
            nodeInstance = Object.Instantiate(nodePrefabLRH, spawnPosition, Quaternion.Euler(0, 0, 0));
            break;

        case Joint.LeftHand:
            nodeInstance = Object.Instantiate(nodePrefabLLH, spawnPosition, Quaternion.Euler(0, 0, 0));
            break;

        default:
            Debug.Log("Error");
            break;
        }
        LineNode obj = nodeInstance.GetComponent <LineNode>();

        obj.timeToFinish     = timeToFinish;
        obj.timeLine         = timeLine;
        obj.pathPositions    = pathPositions;
        obj.transform.parent = main.transform;
        return(nodeInstance);
    }
Пример #20
0
        /// <summary>
        /// Parses LINE.
        /// </summary>
        private LineNode ParseLine(LineNode lastLine)
        {
            ParseStart(@"\n", false);       // We want to set a terminator, so we need to call ParseStart
            // LIST_ITEM / HEADING automatically closes the previous PARAGRAPH
            var node = ParseListItem() ?? ParseHeading() ?? ParseCompactParagraph(lastLine);

            if (lastLine is IInlineContainer lastLineContainer)
            {
                if (lastLineContainer.Inlines.LastNode is PlainText pt && pt.Content.Length == 0)
                {
                    // This can happen because we appended a PlainText("") at (A) in ParseLineEnd
                    pt.Remove();
                }
            }
            if (node != null)
            {
                Accept();
            }
            else
            {
                Fallback();
            }
            return(node);
        }
Пример #21
0
 private void ReplaceNode(LineNode replacedNode, LineNode newNode)
 {
     if (replacedNode.parent == null)
     {
         Debug.Assert(replacedNode == root);
         root = newNode;
     }
     else
     {
         if (replacedNode.parent.left == replacedNode)
         {
             replacedNode.parent.left = newNode;
         }
         else
         {
             replacedNode.parent.right = newNode;
         }
     }
     if (newNode != null)
     {
         newNode.parent = replacedNode.parent;
     }
     replacedNode.parent = null;
 }
Пример #22
0
        private void customGridToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WorkingPlane wp = renderView.Renderer.GetWorkingPlane();
            GridNode gridNode = new GridNode();
            Vector3 modelSize = renderView.SceneManager.GetBBox().Size();
            Vector2 cellSize = gridNode.GetCellSize();
            int nCountX = (int)(modelSize.X / cellSize.X + 0.5f) + 1;
            int nCountY = (int)(modelSize.Y / cellSize.Y + 0.5f) + 1;
            if (nCountX < 2)
                nCountX = 2;
            if (nCountY < 2)
                nCountY = 2;

            gridNode.SetCellCount(nCountX, nCountY);

            LineStyle lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(1.0f, 1.0f, 1.0f));
            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DotLine);
            {
                //Z
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, 0, -1000), new Vector3(0, 0, 1000));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //X
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-1000, 0, 0), new Vector3(1000, 0, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //Y
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, -1000, 0), new Vector3(0, 1000, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }

            lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(0.9f, 0.9f, 0.9f));
            gridNode.SetLineStyle(lineStyle);
            for (int ii = -1; ii <= nCountX; ++ii)
            {
                if (ii == 0)
                    continue;

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(ii * cellSize.X, cellSize.Y, 0), new Vector3(ii * cellSize.X, -nCountY * cellSize.Y, 0));

                gridNode.AddNode(lineNode);
            }
            for (int ii = -1; ii <= nCountY; ++ii)
            {
                if (ii == 0)
                    continue;

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-cellSize.X, -ii * cellSize.Y, 0), new Vector3(nCountX * cellSize.X, -ii * cellSize.Y, 0));
                gridNode.AddNode(lineNode);
            }
            gridNode.Update();
            wp.SetGridNode(gridNode);



            {
                AxesWidget xwh = new AxesWidget();
                xwh.EnableLeftHandCS();
                xwh.SetArrowText((int)EnumAxesDirection.Axes_Y, "w");
                xwh.SetArrowText((int)EnumAxesDirection.Axes_Z, "h");
                ScreenWidget coordWidget = new ScreenWidget();
                coordWidget.SetNode(xwh);
                coordWidget.SetWidgetPosition((int)EnumWidgetPosition.WP_BottomLeft);
                renderView.Renderer.AddWidgetNode(coordWidget);
            }
            {
                AxesWidget yz = new AxesWidget();
                yz.ShowArrow((int)EnumAxesDirection.Axes_X, false);
                ScreenWidget coordWidget = new ScreenWidget();
                coordWidget.SetNode(yz);
                coordWidget.SetWidgetPosition((int)EnumWidgetPosition.WP_BottomRight);
                renderView.Renderer.AddWidgetNode(coordWidget);
            }

            renderView.ShowCoordinateAxis(false);

            renderView.RequestDraw();
        }
Пример #23
0
        static void Main(string[] args)
        {
            // Altseed2 を初期化します。
            Engine.Initialize("ShapeNode", 640, 480);

            // 円を描画するノード
            var circle = new CircleNode()
            {
                Color    = new Color(255, 100, 100),
                Radius   = 30f,
                Position = new Vector2F(100f, 300f),
                VertNum  = 30
            };

            // 円弧を描画するノード
            var arc = new ArcNode()
            {
                Color       = new Color(100, 255, 100),
                Radius      = 25f,
                Position    = new Vector2F(300f, 100f),
                StartDegree = 30f,
                EndDegree   = 150f,
                VertNum     = 30
            };

            // 直線を描画するノード
            var line = new LineNode()
            {
                Color     = new Color(100, 100, 255),
                Point1    = new Vector2F(200f, 150f),
                Point2    = new Vector2F(400f, 350f),
                Thickness = 5f
            };

            // 短形を描画するノード
            var rectangle = new RectangleNode()
            {
                Color         = new Color(255, 255, 100),
                Position      = new Vector2F(300f, 400f),
                RectangleSize = new Vector2F(50f, 50f)
            };

            // 三角形を描画するノード
            var triangle = new TriangleNode()
            {
                Color  = new Color(255, 100, 255),
                Point1 = new Vector2F(50f, 50f),
                Point2 = new Vector2F(100f, 50f),
                Point3 = new Vector2F(50f, 100f),
            };

            // エンジンにノードを追加します。
            Engine.AddNode(circle);
            Engine.AddNode(arc);
            Engine.AddNode(line);
            Engine.AddNode(rectangle);
            Engine.AddNode(triangle);

            // メインループ。
            // Altseed のウインドウが閉じられると終了します。
            while (Engine.DoEvents())
            {
                // Altseed を更新します。
                Engine.Update();
            }

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
 void addHorizontalLineToolStripMenuItem_Click(object sender, EventArgs e)
 {
     LineNode stockNode = new LineNode("LINE_0", this.indicatorMenuStrip, new Pen(Color.Black), 0);
      this.treeView1.SelectedNode.Nodes.Add(stockNode);
      this.treeView1.SelectedNode = stockNode;
 }
Пример #25
0
 /// <summary>
 /// Prüfe, ob ich den LineNode ln von allen Richtungen anfahren darf
 /// </summary>
 /// <param name="ln">zu überprüfender LineNode</param>
 /// <returns>true, falls für alle NodeConnection sin ln.prevConnections CheckNodeConnectionForSuitability() = true gilt</returns>
 public bool CheckLineNodeForIncomingSuitability(LineNode ln)
 {
     foreach (NodeConnection nc in ln.prevConnections)
         {
         if (!CheckNodeConnectionForSuitability(nc))
             return false;
         }
     return true;
 }
Пример #26
0
 // Token: 0x06000A98 RID: 2712 RVA: 0x000E43F0 File Offset: 0x000E25F0
 public virtual void RunSpecialSimuMode(LineNode node)
 {
 }
Пример #27
0
 private static bool GetColor(LineNode node)
 {
     return(node != null ? node.color : BLACK);
 }
 public void Visit(LineNode lineNode)
 {
     _currentIndent = 0;
     lineNode.Indents?.Accept(this);
     lineNode.Names?.Accept(this);
 }
Пример #29
0
        private void queryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectedShapeQuery context = new SelectedShapeQuery();

            renderView.QuerySelection(context);

            TopoShape subShape = context.GetSubGeometry();
            SceneNode topoNode = context.GetSubNode();


            if (subShape != null)
            {
                Console.WriteLine(subShape.GetShapeType());
            }

            Matrix4 shapeTransform = topoNode.GetTransform();
            //surface
            GeomSurface surface = new GeomSurface();

            if (surface.Initialize(subShape))
            {
                List <Vector3> ptVecList  = new List <Vector3>();
                List <Vector3> norVecList = new List <Vector3>();
                Console.Write("surface");
                //double firstU = surface.FirstUParameter();
                //double lastU = surface.LastUParameter();
                //double firstV = surface.FirstVParameter();
                //double lastV = surface.LastVParameter();
                double firstU  = surface.FirstUParameter();
                double lastU   = surface.LastUParameter();
                double firstV  = surface.FirstVParameter();
                double lastV   = surface.LastVParameter();
                double offSetU = lastU - firstU;
                double offSetV = lastV - firstV;

                double stepU   = 0.10;
                double stepV   = 10;
                int    stepNoU = (int)(offSetU / stepU);
                int    stepNoV = (int)(offSetV / stepV);
                for (int v_i = 3; v_i < stepNoV - 5; v_i++)
                {
                    for (int u_i = 0; u_i < stepNoU; u_i++)
                    {
                        double tempV = firstV + stepV * v_i;
                        double tempU = firstU + stepU * (v_i % 2 == 0 ? u_i : stepNoU - u_i);
                        //double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i);
                        Vector3 ptVec_1     = surface.Value(tempU, tempV);
                        Vector3 ptVec       = shapeTransform.Transform(ptVec_1);
                        Vector3 normalVec_1 = surface.GetNormal(tempU, tempV);
                        //Vector3 normalVec =shapeTransform.Transform(normalVec_1);//matrix3  3*3
                        Vector3 normalVec = RotateDirVector(shapeTransform, normalVec_1);
                        ptVecList.Add(ptVec);
                        norVecList.Add(normalVec);
                        pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec));
                        ShowStatusMessage("path pts No: " + pathPqList.Count);

                        //LineNode tempLineNode = new LineNode();
                        //LineStyle lineStyle = new LineStyle();
                        //lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
                        //lineStyle.SetColor(100, 0, 100);
                        //tempLineNode.SetLineStyle(lineStyle);
                        //tempLineNode.Set(ptVec, ptVec + normalVec);
                        //tempLineNode.SetVisible(true);
                        //renderView.SceneManager.AddNode(tempLineNode);
                        //renderView.RequestDraw();
                    }
                }

                //for (int u_i = 0; u_i < stepNoU; u_i++)
                //{
                //    for (int v_i = 0; v_i < stepNoV-0; v_i++)
                //    {

                //        double tempU = firstU + stepU * u_i;
                //        double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i);

                //        Vector3 ptVec =shapeTransform.Transform(surface.Value(tempU,tempV ));
                //        Vector3 normalVec = surface.GetNormal(tempU,tempV);
                //        ptVecList.Add(ptVec);
                //        norVecList.Add(normalVec);
                //        pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec));
                //    }
                //}
                int a = 0;
            }
            //curve
            GeomCurve curve = new GeomCurve();

            if (curve.Initialize(subShape))
            {
                Vector3 startPt = shapeTransform.Transform(curve.D0(curve.FirstParameter()));
                //Vector3 startPt_ = shapeTransform.Transform(startPt);
                Vector3 pt1   = curve.GetStartPoint();
                Vector3 endPt = shapeTransform.Transform(curve.D0(curve.LastParameter()));
                Vector3 pt2   = curve.GetEndPoint();
                switch ((EnumCurveType)curve.GetCurveType())
                {
                case EnumCurveType.CurveType_OtherCurve:
                    Console.Write("other");
                    break;

                case EnumCurveType.CurveType_BSplineCurve:
                    break;

                case EnumCurveType.CurveType_BezierCurve:
                    break;

                case EnumCurveType.CurveType_Parabola:
                    break;

                case EnumCurveType.CurveType_Hyperbola:
                    break;

                case EnumCurveType.CurveType_Ellipse:
                    break;

                case EnumCurveType.CurveType_Circle:
                    Console.Write("Circle");
                    break;

                case EnumCurveType.CurveType_Line:
                    Console.Write("Line");

                    //path
                    double[] startPt_ = new double[3] {
                        startPt.X, startPt.Y, startPt.Z
                    };
                    double[] endPt_ = new double[3] {
                        endPt.X, endPt.Y, endPt.Z
                    };
                    Path_U.Interpolation(startPt_, endPt_, 0.01, ref pathPtList);
                    //show pick result
                    LineNode  tempLineNode = new LineNode();
                    LineStyle lineStyle    = new LineStyle();
                    lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
                    lineStyle.SetColor(100, 0, 100);
                    tempLineNode.SetLineStyle(lineStyle);
                    tempLineNode.Set(new Vector3(startPt.X + 0.1, startPt.Y + 10, startPt.Z + 0.1), endPt);
                    tempLineNode.SetVisible(true);
                    renderView.SceneManager.AddNode(tempLineNode);
                    renderView.RequestDraw();
                    break;

                default:
                    break;
                }



                ElementId id = context.GetNodeId();
                MessageBox.Show(id.AsInt().ToString());
                //...
            }
        }
Пример #30
0
        /// <summary>
        /// Parses a PARAGRPAH_CLOSE .
        /// </summary>
        /// <param name="lastNode">The lastest parsed node.</param>
        /// <returns>The extra paragraph, or <see cref="EMPTY_LINE_NODE"/>. If parsing attempt failed, <c>null</c>.</returns>
        private LineNode ParseLineEnd(LineNode lastNode)
        {
            Debug.Assert(lastNode != null);
            var unclosedParagraph = lastNode as Paragraph;

            if (unclosedParagraph != null && !unclosedParagraph.Compact)
            {
                unclosedParagraph = null;
            }
            // 2 line breaks (\n\n) or \n Terminator closes the paragraph,
            // so do a look-ahead here. Note that a \n will be consumed in ParseWikitext .
            // Note that this look-ahead will also bypass the \n terminator defined in WIKITEXT

            // For the last non-empty line
            // TERM     Terminators
            // PC       Compact/unclosed paragraph
            // P        Closed paragraph
            // abc TERM             PC[|abc|]
            // abc\n TERM           P[|abc|]
            // abc\n\s*?\n TERM     P[|abc|]PC[||]
            // Note that MediaWiki editor will automatically trim the trailing whitespaces,
            // leaving a \n after the content. This one \n will be removed when the page is transcluded.
            var lastLinePosition = linePosition;

            // Here we consume a \n without fallback.
            if (ConsumeToken(@"\n") == null)
            {
                return(null);
            }
            ParseStart();
            // Whitespaces between 2 \n, assuming there's a second \n or TERM after trailingWs
            var trailingWs = ConsumeToken(@"[\f\r\t\v\x85\p{Z}]+");

            if (unclosedParagraph != null)
            {
                // We're going to consume another \n or TERM to close the paragraph.
                // Already consumed a \n, attempt to consume another \n
                var trailingWsEndsAt = linePosition;
                if (ConsumeToken(@"\n") != null)
                {
                    // Close the last paragraph.
                    unclosedParagraph.AppendWithLineInfo("\n" + trailingWs,
                                                         // don't forget the position of leading '\n'
                                                         CurrentContext.StartingLineNumber - 1, lastLinePosition,
                                                         CurrentContext.StartingLineNumber, trailingWsEndsAt);
                    // 2 Line breaks received.
                    // Check for the special case. Note here TERM excludes \n
                    if (NeedsTerminate(Terminator.Get(@"\n")))
                    {
                        // This is a special case.
                        // abc \n trailingWs \n TERM --> P[|abc\ntrailingWs|]PC[||]
                        //                      ^ We are here.
                        // When the function returns, WIKITEXT parsing will stop
                        // because a TERM will be received.
                        // We need to correct this.
                        var anotherparagraph = new Paragraph();
                        anotherparagraph.SetLineInfo(lineNumber, linePosition, lineNumber, linePosition);
                        return(ParseSuccessful(anotherparagraph, false));
                    }
                    // The last paragraph will be closed now.
                    return(ParseSuccessful(EMPTY_LINE_NODE, false));
                }
                // The attempt to consume the 2nd \n failed.
                if (NeedsTerminate())
                {
                    // abc \n trailingWs TERM   P[|abc|]
                    //                   ^ We are here.
                    // If we need to terminate, then close the last paragraph.
                    unclosedParagraph.AppendWithLineInfo("\n" + trailingWs,
                                                         // don't forget the position of leading '\n'
                                                         CurrentContext.StartingLineNumber - 1, lastLinePosition,
                                                         lineNumber, linePosition);
                    return(ParseSuccessful(EMPTY_LINE_NODE, false));
                }
                // The last paragraph is still not closed (i.e. compact paragraph).
                // (A)
                // Note here we have still consumed the first '\n', while the last paragraph has no trailing '\n'.
                // For continued PlainText, we will add a '\n' in ParseCompactParagraph.
                // Add an empty node so ParseCompactParagraph can add a '\n' with LineInfo.
                unclosedParagraph.AppendWithLineInfo("", CurrentContext.StartingLineNumber - 1, lastLinePosition,
                                                     CurrentContext.StartingLineNumber - 1, lastLinePosition);
                // Fallback so we can either continue parsing PlainText,
                // or discover the next, for example, Heading, and leave the last paragraph compact.
                Fallback();
                return(EMPTY_LINE_NODE);
            }
            else
            {
                // Last node cannot be a closed paragraph.
                // It can't because ParseLineEnd is invoked immediately after a last node is parsed,
                // and only ParseLineEnd can close a paragraph.
                Debug.Assert(!(lastNode is Paragraph), "Last node cannot be a closed paragraph.");
                // Rather, last node is LINE node of other type (LIST_ITEM/HEADING).
                // Remember we've already consumed a '\n' , and the spaces after it.
                // The situation here is just like the "special case" mentioned above.
                if (NeedsTerminate(Terminator.Get(@"\n")))
                {
                    // abc \n WHITE_SPACE TERM  -->  [|abc|] PC[|WHITE_SPACE|]
                    //        ^ CurCntxt  ^ We are here now.
                    // Note here TERM excludes \n
                    var anotherparagraph = new Paragraph();
                    if (trailingWs != null)
                    {
                        var pt = new PlainText(trailingWs);
                        // Actually the same as what we do in ParseSuccessful for PlainText.
                        pt.SetLineInfo(CurrentContext.StartingLineNumber, CurrentContext.StartingLinePosition,
                                       lineNumber, linePosition);
                        anotherparagraph.Inlines.Add(pt);
                    }
                    return(ParseSuccessful(anotherparagraph));
                }
            }
            // abc \n def
            // That's not the end of a prargraph. Fallback to before the 1st \n .
            // Note here we have already consumed a \n .
            Fallback();
            return(EMPTY_LINE_NODE);
        }
Пример #31
0
        private void surfaceSectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShape oCircle1 = GlobalInstance.BrepTools.MakeCircle(Vector3.ZERO, 20, Vector3.UNIT_Z);
            TopoShape Pipe01_Surf = GlobalInstance.BrepTools.Extrude(oCircle1, 100, Vector3.UNIT_Z);
            renderView.ShowGeometry(Pipe01_Surf, ++shapeId);

            TopoShape oCircle2 = GlobalInstance.BrepTools.MakeCircle(new Vector3(0.0f, 0.0f, 50.0f), 10, Vector3.UNIT_Y);
            TopoShape Pipe02_Surf = GlobalInstance.BrepTools.Extrude(oCircle2, 80, Vector3.UNIT_Y);
            renderView.ShowGeometry(Pipe02_Surf, ++shapeId);

            TopoShape Inters1 = GlobalInstance.BrepTools.SurfaceSection(Pipe01_Surf, Pipe02_Surf);
            if (Inters1 != null)
            {
                SceneNode node = renderView.ShowGeometry(Inters1, ++shapeId);
                LineStyle ls = new LineStyle();
                ls.SetLineWidth(3);
                ls.SetColor(ColorValue.RED);
                node.SetLineStyle(ls);

                GeomCurve curve = new GeomCurve();
                if (curve.Initialize(Inters1))
                {
                    LineStyle ls2 = new LineStyle();
                    ls2.SetColor(ColorValue.GREEN);

                    float start = curve.FirstParameter();
                    float end = curve.LastParameter();
                    for (float ii = start; ii <= end; ii += 0.1f)
                    {
                        List<Vector3> rt = curve.D1(ii);
                        LineNode ln = new LineNode();
                        ln.SetLineStyle(ls2);
                        ln.Set(rt[0], rt[0] + rt[1]);
                        renderView.ShowSceneNode(ln);
                    }
                }
            }
            renderView.RequestDraw();
        }
Пример #32
0
 // Token: 0x060027A3 RID: 10147 RVA: 0x0043E280 File Offset: 0x0043C480
 public void SetSpecialBox(bool bShow, byte type = 0)
 {
     if (bShow)
     {
         Door door = GUIManager.Instance.FindMenu(EGUIWindow.Door) as Door;
         if (door == null)
         {
             return;
         }
         if (door.m_GroundInfo.TileMapMat == null)
         {
             door.m_GroundInfo.TileMapMat             = (UnityEngine.Object.Instantiate(door.TileMapController.TileSprites.m_Image.material) as Material);
             door.m_GroundInfo.TileMapMat.renderQueue = 3000;
         }
         this.TextBoxTrans.gameObject.SetActive(true);
         this.TextBoxTrans.sizeDelta = new Vector2(500f, 150f);
         Vector2 a = GUIManager.Instance.pDVMgr.CanvasRT.sizeDelta * 0.5f;
         this.TextBoxTrans.anchoredPosition = a + new Vector2(0f, 60f);
         for (int i = 0; i < 3; i++)
         {
             this.m_ImageEx[i].gameObject.SetActive(true);
             this.m_ImageEx[i].material = door.m_GroundInfo.TileMapMat;
         }
         if (type == 0)
         {
             door.TileMapController.getTileMapSprite(ref this.m_ImageEx[0], POINT_KIND.PK_CITY, 25, CITY_OUTWARD.CO_PLAYER);
             this.m_ImageEx[0].SetNativeSize();
             this.m_ImageExTrans[0].anchoredPosition = new Vector2(95f, 70f);
             door.TileMapController.getTileMapSprite(ref this.m_ImageEx[2], POINT_KIND.PK_FOOD, 0, CITY_OUTWARD.CO_PLAYER);
             this.m_ImageEx[2].SetNativeSize();
             this.m_ImageExTrans[2].anchoredPosition = new Vector2(396.5f, 70f);
             this.m_ImageExTrans[1].anchoredPosition = new Vector2(95f, 60f);
             Vector3 position = this.m_ImageExTrans[1].position;
             this.m_ImageExTrans[1].anchoredPosition = new Vector2(396.5f, 60f);
             Vector3 position2 = this.m_ImageExTrans[1].position;
             this.m_ImageEx[1].gameObject.SetActive(false);
             CHAOS chaos = GameManager.ActiveGameplay as CHAOS;
             if (chaos != null && chaos.realmController != null)
             {
                 if (this.m_FlowLineFactoryNewbie == null)
                 {
                     this.m_FlowLineFactoryNewbie = new FlowLineFactoryNewbie(chaos.realmController.RealmGroup_3DTransform, chaos.realmController.mapTileController.TileBaseScale);
                 }
                 MapLine mapLine = new MapLine();
                 mapLine.lineID   = uint.MaxValue;
                 mapLine.begin    = (ulong)DataManager.Instance.ServerTime;
                 mapLine.during   = 5u;
                 mapLine.lineFlag = 0;
                 this.m_FlowLineFactoryNewbie.createLine(mapLine, position, position2, ELineColor.DEEPBLUE, EUnitSide.BLUE, false, true, EMonsterFace.LEFT, 1);
             }
         }
         else if (type == 1)
         {
             door.TileMapController.getTileMapSprite(ref this.m_ImageEx[0], POINT_KIND.PK_CITY, 25, CITY_OUTWARD.CO_PLAYER);
             this.m_ImageEx[0].SetNativeSize();
             this.m_ImageExTrans[0].anchoredPosition = new Vector2(95f, 70f);
             door.TileMapController.getTileMapSprite(ref this.m_ImageEx[2], POINT_KIND.PK_CITY, 24, CITY_OUTWARD.CO_PLAYER);
             this.m_ImageEx[2].SetNativeSize();
             this.m_ImageExTrans[2].anchoredPosition = new Vector2(412.4f, 70f);
             this.m_ImageExTrans[1].anchoredPosition = new Vector2(95f, 60f);
             Vector3 position3 = this.m_ImageExTrans[1].position;
             this.m_ImageExTrans[1].anchoredPosition = new Vector2(412.4f, 60f);
             Vector3 position4 = this.m_ImageExTrans[1].position;
             this.m_ImageEx[1].gameObject.SetActive(false);
             CHAOS chaos2 = GameManager.ActiveGameplay as CHAOS;
             if (chaos2 != null && chaos2.realmController != null)
             {
                 if (this.m_FlowLineFactoryNewbie == null)
                 {
                     this.m_FlowLineFactoryNewbie = new FlowLineFactoryNewbie(chaos2.realmController.RealmGroup_3DTransform, chaos2.realmController.mapTileController.TileBaseScale);
                 }
                 MapLine mapLine2 = new MapLine();
                 mapLine2.lineID   = uint.MaxValue;
                 mapLine2.begin    = (ulong)DataManager.Instance.ServerTime;
                 mapLine2.during   = 2u;
                 mapLine2.lineFlag = 5;
                 this.m_FlowLineFactoryNewbie.createLine(mapLine2, position3, position4, ELineColor.DEEPBLUE, EUnitSide.BLUE, false, true, EMonsterFace.LEFT, 1);
                 this.m_FlowLineFactoryNewbie.MoveUnitToEndPoint(EMarchEventType.EMET_AttackRetreat);
             }
         }
         else if (type == 2)
         {
             door.TileMapController.getTileMapSprite(ref this.m_ImageEx[0], POINT_KIND.PK_CITY, 25, CITY_OUTWARD.CO_PLAYER);
             this.m_ImageEx[0].SetNativeSize();
             this.m_ImageExTrans[0].anchoredPosition = new Vector2(95f, 70f);
             this.m_ImageEx[1].gameObject.SetActive(false);
             this.m_ImageExTrans[2].anchoredPosition = new Vector2(412.4f, 70f);
             Vector2 inipos   = this.m_ImageExTrans[2].transform.position;
             float   iniscale = 1f / GUIManager.Instance.pDVMgr.CanvasRT.localScale.x;
             this.Npc_Parent = new GameObject("NPC");
             Transform transform = this.Npc_Parent.transform;
             transform.parent     = this.m_ImageExTrans[2].parent;
             transform.position   = Vector3.zero;
             transform.localScale = Vector3.one;
             this.Npc_Node        = new NPC(inipos, iniscale, 1, 2, NPCState.NPC_Idle, transform, ref this.Npc_ABKey);
             this.Npc_Node.SetActive(true);
             this.m_ImageExTrans[2].anchoredPosition = new Vector2(95f, 60f);
             Vector3 position5 = this.m_ImageEx[2].transform.position;
             this.m_ImageExTrans[2].anchoredPosition = new Vector2(395f, 60f);
             Vector3 position6 = this.m_ImageEx[2].transform.position;
             this.m_ImageEx[2].gameObject.SetActive(false);
             CHAOS chaos3 = GameManager.ActiveGameplay as CHAOS;
             if (chaos3 != null && chaos3.realmController != null)
             {
                 if (this.m_FlowLineFactoryNewbie == null)
                 {
                     this.m_FlowLineFactoryNewbie = new FlowLineFactoryNewbie(chaos3.realmController.RealmGroup_3DTransform, chaos3.realmController.mapTileController.TileBaseScale);
                 }
                 MapLine mapLine3 = new MapLine();
                 mapLine3.lineID   = uint.MaxValue;
                 mapLine3.begin    = (ulong)DataManager.Instance.ServerTime;
                 mapLine3.during   = 2u;
                 mapLine3.lineFlag = 9;
                 LineNode lineNode = this.m_FlowLineFactoryNewbie.createLine(mapLine3, position5, position6, ELineColor.DEEPBLUE, EUnitSide.BLUE, false, true, EMonsterFace.LEFT, 1);
                 this.m_FlowLineFactoryNewbie.MoveUnitToEndPoint(EMarchEventType.EMET_HitMonsterRetreat);
             }
         }
     }
     else
     {
         for (int j = 0; j < 3; j++)
         {
             this.m_ImageEx[j].gameObject.SetActive(false);
         }
         if (this.m_FlowLineFactoryNewbie != null)
         {
             this.m_FlowLineFactoryNewbie.ClearLine();
         }
         if (this.Npc_Node != null)
         {
             this.Npc_Node.Release();
             this.Npc_Node = null;
             AssetManager.UnloadAssetBundle(this.Npc_ABKey, true);
         }
         if (this.Npc_Parent != null)
         {
             UnityEngine.Object.Destroy(this.Npc_Parent);
             this.Npc_Parent = null;
         }
     }
 }
Пример #33
0
        private void planeAngleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // plane
            Vector3 planeDir = Vector3.UNIT_Z;
            TopoShape plane1 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, planeDir, -100, 100, -100, 100);

            {
                GeomSurface gs = new GeomSurface();
                gs.Initialize(plane1);
                List<Vector3> rst = gs.D1(gs.FirstUParameter(), gs.FirstVParameter());
                Vector3 dir2 = rst[1].CrossProduct(rst[2]);

                MessageBox.Show(dir2.ToString());
            }
    

            Vector3 normal = new Vector3(0,1,1);
            normal.Normalize();
            TopoShape plane2 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, normal, -100, 100, -100, 100);

            renderView.ShowGeometry(plane1, ++shapeId);
            renderView.ShowGeometry(plane2, ++shapeId);

            LineStyle style = new LineStyle();
            style.SetColor(ColorValue.GREEN);
            // witness
            Vector3 end1 =  new Vector3(0, 0, 100);
            LineNode line1 = new LineNode();
            line1.Set(Vector3.ZERO, end1);
            line1.SetLineStyle(style);
            renderView.ShowSceneNode(line1);

            Vector3 end2 = normal * 100;
            LineNode line2 = new LineNode();
            line2.Set(Vector3.ZERO, end2);
            line2.SetLineStyle(style);
            renderView.ShowSceneNode(line2);

            // angle
            float angle = normal.AngleBetween(planeDir);

            Vector3 dir = normal.CrossProduct(planeDir);
            dir.Normalize();
            TopoShape arc = GlobalInstance.BrepTools.MakeArc(end2, end1, Vector3.ZERO, dir);
            SceneNode arcNode = renderView.ShowGeometry(arc, ++shapeId);
            arcNode.SetLineStyle(style);

            // text
            TextNode text = new TextNode();
            text.SetText(angle.ToString());
            Vector3 pos = end2 + end1;
            pos = pos * 0.5f;
            text.SetPosition(pos);
            renderView.ShowSceneNode(text);

            renderView.RequestDraw();
        }
Пример #34
0
        private void FixTreeOnInsert(LineNode node)
        {
            Debug.Assert(node != null);
            Debug.Assert(node.color == RED);
            Debug.Assert(node.left == null || node.left.color == BLACK);
            Debug.Assert(node.right == null || node.right.color == BLACK);

            LineNode parentNode = node.parent;

            if (parentNode == null)
            {
                // we inserted in the root -> the node must be black
                // since this is a root node, making the node black increments the number of black nodes
                // on all paths by one, so it is still the same for all paths.
                node.color = BLACK;
                return;
            }
            if (parentNode.color == BLACK)
            {
                // if the parent node where we inserted was black, our red node is placed correctly.
                // since we inserted a red node, the number of black nodes on each path is unchanged
                // -> the tree is still balanced
                return;
            }
            // parentNode is red, so there is a conflict here!

            // because the root is black, parentNode is not the root -> there is a grandparent node
            LineNode grandparentNode = parentNode.parent;
            LineNode uncleNode       = Sibling(parentNode);

            if (uncleNode != null && uncleNode.color == RED)
            {
                parentNode.color      = BLACK;
                uncleNode.color       = BLACK;
                grandparentNode.color = RED;
                FixTreeOnInsert(grandparentNode);
                return;
            }
            // now we know: parent is red but uncle is black
            // First rotation:
            if (node == parentNode.right && parentNode == grandparentNode.left)
            {
                RotateLeft(parentNode);
                node = node.left;
            }
            else if (node == parentNode.left && parentNode == grandparentNode.right)
            {
                RotateRight(parentNode);
                node = node.right;
            }
            // because node might have changed, reassign variables:
            parentNode      = node.parent;
            grandparentNode = parentNode.parent;

            // Now recolor a bit:
            parentNode.color      = BLACK;
            grandparentNode.color = RED;
            // Second rotation:
            if (node == parentNode.left && parentNode == grandparentNode.left)
            {
                RotateRight(grandparentNode);
            }
            else
            {
                // because of the first rotation, this is guaranteed:
                Debug.Assert(node == parentNode.right && parentNode == grandparentNode.right);
                RotateLeft(grandparentNode);
            }
        }
Пример #35
0
 public override void VisitLine(LineNode node)
 {
     JoinChildren(node, " ");
     WriteLine();
 }
Пример #36
0
		static bool GetColor(LineNode node)
		{
			return node != null ? node.color : BLACK;
		}
Пример #37
0
 /// <summary>
 /// д��VCT��ʵ��ڵ�
 /// </summary>
 /// <param name="lineNode">VCT��ʵ��ڵ�</param>
 public bool WriteLineNode(LineNode lineNode)
 {
     if (this.m_streamWriter != null)
     {
         if (this.m_bFoundLineBegin == false)
         {
             if (this.m_bFoundPointBegin == false)
             {
                 this.m_streamWriter.WriteLine("PointBegin");
                 this.m_bFoundPointBegin = true;
             }
             this.m_streamWriter.WriteLine("PointEnd");
             this.m_streamWriter.WriteLine("LineBegin");
             this.m_bFoundLineBegin = true;
         }
         //lineNode.StreamWriter = m_streamWriter;
         this.m_streamWriter.WriteLine(lineNode);
         this.m_streamWriter.Flush();
         return true;
     }
     return false;
 }
Пример #38
0
 static bool GetColor(LineNode node) => node != null ? node.color : BLACK;
Пример #39
0
        /// <summary>
        /// ��ȡVCT��ʵ��ڵ�
        /// </summary>
        public override EntityNode GetEntityNode()
        {
            try
            {
                LineNode pLineNode = new LineNode();
                pLineNode.SegmentNodes = new SegmentNodes();

                IFeature pFeature = this.Feature as IFeature;

                //��������ͳһ����Ϊ1
                pLineNode.LineType = 1;

                ///��ʶ�븳ֵ
                int dBSMIndex = -1;
                dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                if (dBSMIndex != -1)
                    pLineNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));

                ///Ҫ�ش��븳ֵ
                //int dSYDMIndex = -1;
                //dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                //if (dSYDMIndex != -1)
                //    pLineNode.FeatureCode = this.Feature.get_Value(dSYDMIndex).ToString();
                //string sAttriTableName = (pFeature.Class as IDataset).Name;
                //pLineNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);
                pLineNode.FeatureCode = this.FeatureCode;

                ///ͼ�α��ֱ���
                //pLineNode.Representation = pFeature.Class.AliasName;
                ///add by ��ƽ 2011-9-7 ��Ӳ���
                IGeometry pFeatureGeometry = null;
                if (m_bCut)
                {
                    pFeatureGeometry = GetSubGeometry();
                    if (pFeatureGeometry == null)
                    {
                        pFeatureGeometry = pFeature.Shape;
                    }
                }
                else
                {
                    pFeatureGeometry = pFeature.Shape;
                }

                IPolyline pPolygon =pFeatureGeometry as IPolyline;
                ///����ڵ�����
                IPointCollection pPointCollection = pPolygon as IPointCollection;
                BrokenLineNode pBLineNode = new BrokenLineNode();
                pBLineNode.PointInfoNodes = new PointInfoNodes();
                for (int i = 0; i < pPointCollection.PointCount; i++)
                {

                    IPoint pPoint = pPointCollection.get_Point(i);
                    PointInfoNode pInfoNode1 = new PointInfoNode(pPoint.X, pPoint.Y);
                    pBLineNode.PointInfoNodes.Add(pInfoNode1);

                }

                pLineNode.SegmentNodes.Add(pBLineNode);
                return pLineNode;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }
Пример #40
0
        //public override void GetEntityNodeByDataRow(DataRow dataRow, ref EntityNode entityNode)
        //{
        //    GetLineNodeByDataRow(dataRow, entityNode, false);
        //}
        public void GetLineNodeByDataRow(DataRow dataRow, ref LineNode lineNode, bool bReverse)
        {
            if (dataRow != null)
            {
                EntityNode entityNode = lineNode as EntityNode;
                base.GetEntityNodeByDataRow(dataRow, ref entityNode);

                lineNode.IndexID = dataRow[FieldName_LineNodeID] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[FieldName_LineNodeID]);
                //lineNode.EntityID = dataRow[FieldName_EntityID] == null ? -1 : Convert.ToInt32(dataRow[FieldName_EntityID]);
                //lineNode.FeatureCode = dataRow[FieldName_FeatureCode] == null ? "" : dataRow[FieldName_FeatureCode].ToString();
                lineNode.LineType = dataRow[FieldName_LineType] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[FieldName_LineType]);
                //lineNode.Representation = dataRow[FieldName_Representation] == null ? "" : dataRow[FieldName_Representation].ToString();

                if (entityNode.EntityID != 0)
                {
                    SegmentNodes segmentNodes = new SegmentNodes();
                    BrokenLineNode brokenLineNode = new BrokenLineNode();
                    PointInfoNodes pointInfoNodes = new PointInfoNodes();
                    double dX1 = dataRow[FieldName_X1] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_X1]);
                    double dY1 = dataRow[FieldName_Y1] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_Y1]);
                    PointInfoNode pointInfoNode1 = new PointInfoNode(dX1, dY1);

                    double dX2 = dataRow[FieldName_X2] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_X2]);
                    double dY2 = dataRow[FieldName_Y2] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_Y2]);
                    PointInfoNode pointInfoNode2 = new PointInfoNode(dX2, dY2);

                    if (bReverse == true)
                    {
                        pointInfoNodes.Add(pointInfoNode2);
                        pointInfoNodes.Add(pointInfoNode1);
                    }
                    else
                    {
                        pointInfoNodes.Add(pointInfoNode1);
                        pointInfoNodes.Add(pointInfoNode2);
                    }
                    brokenLineNode.PointInfoNodes = pointInfoNodes;
                    segmentNodes.Add(brokenLineNode);
                    lineNode.SegmentNodes = segmentNodes;
                }
            }
        }
Пример #41
0
		void FixTreeOnDelete(LineNode node, LineNode parentNode)
		{
			Debug.Assert(node == null || node.parent == parentNode);
			if (parentNode == null)
				return;
			
			// warning: node may be null
			LineNode sibling = Sibling(node, parentNode);
			if (sibling.color == RED) {
				parentNode.color = RED;
				sibling.color = BLACK;
				if (node == parentNode.left) {
					RotateLeft(parentNode);
				} else {
					RotateRight(parentNode);
				}
				
				sibling = Sibling(node, parentNode); // update value of sibling after rotation
			}
			
			if (parentNode.color == BLACK
			    && sibling.color == BLACK
			    && GetColor(sibling.left) == BLACK
			    && GetColor(sibling.right) == BLACK)
			{
				sibling.color = RED;
				FixTreeOnDelete(parentNode, parentNode.parent);
				return;
			}
			
			if (parentNode.color == RED
			    && sibling.color == BLACK
			    && GetColor(sibling.left) == BLACK
			    && GetColor(sibling.right) == BLACK)
			{
				sibling.color = RED;
				parentNode.color = BLACK;
				return;
			}
			
			if (node == parentNode.left &&
			    sibling.color == BLACK &&
			    GetColor(sibling.left) == RED &&
			    GetColor(sibling.right) == BLACK)
			{
				sibling.color = RED;
				sibling.left.color = BLACK;
				RotateRight(sibling);
			}
			else if (node == parentNode.right &&
			         sibling.color == BLACK &&
			         GetColor(sibling.right) == RED &&
			         GetColor(sibling.left) == BLACK)
			{
				sibling.color = RED;
				sibling.right.color = BLACK;
				RotateLeft(sibling);
			}
			sibling = Sibling(node, parentNode); // update value of sibling after rotation
			
			sibling.color = parentNode.color;
			parentNode.color = BLACK;
			if (node == parentNode.left) {
				if (sibling.right != null) {
					Debug.Assert(sibling.right.color == RED);
					sibling.right.color = BLACK;
				}
				RotateLeft(parentNode);
			} else {
				if (sibling.left != null) {
					Debug.Assert(sibling.left.color == RED);
					sibling.left.color = BLACK;
				}
				RotateRight(parentNode);
			}
		}
        private void ActivateLineConfigPanel(LineNode lineNode)
        {
            this.MakeVisible(lineConfigBox);

             this.lineTypeComboBox.Enabled = true;
             this.lineTypeComboBox.Parent = lineConfigBox;
             this.thicknessComboBox.Parent = lineConfigBox;
             this.lineColorPanel.Parent = lineConfigBox;

             this.lineTypeComboBox.SelectedItem = lineNode.CurvePen.DashStyle.ToString();
             this.thicknessComboBox.SelectedItem = (int)lineNode.CurvePen.Width;
             this.lineColorPanel.BackColor = lineNode.CurvePen.Color;
             this.lineValueTextBox.Text = lineNode.LineValue.ToString();
        }
Пример #43
0
 static void UpdateAfterRotateRight(LineNode node) => UpdateAfterChildrenChange(node);
Пример #44
0
        /// <summary>
        /// Calculates driving parameters and new acceleration of the vehicle.
        /// </summary>
        /// <param name="route">Route of the Vehicle.</param>
        /// <param name="arcPos">Current arc position of the vehicle on the first NodeConnection on <paramref name="route"/>.</param>
        /// <param name="onlySimpleCalculations">Perform only simple calculations (e.g. no free line changes).</param>
        /// <param name="tickLength">Length of a tick in seconds.</param>
        /// <returns></returns>
        public double Think(List<NodeConnection> route, double arcPos, bool onlySimpleCalculations, double tickLength)
        {
            if (route.Count == 0)
                return 0;

            double lookaheadDistance = Constants.lookaheadDistance;
            double intersectionLookaheadDistance = Constants.intersectionLookaheadDistance;
            double stopDistance = -1;
            _state._freeDrive = true;

            bool thinkAboutLineChange = false;
            double lowestAcceleration = 0;

            #region LineChangeVehicleInteraction

            // if necessary, wait for other vehicle to change line
            if (_state.letVehicleChangeLine)
                {
                double percentOfLCILeft = (lci == null) ? 0.2 : Math.Max(0.2, (lci.endArcPos - currentPosition - Constants.breakPointBeforeForcedLineChange) / (lci.length - Constants.breakPointBeforeForcedLineChange));
                lookaheadDistance = Math.Max(3 * percentOfLCILeft * s0, _state.tailPositionOfOtherVehicle - currentPosition);
                thinkAboutLineChange = false;
                lowestAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lookaheadDistance, physics.velocity);
                _state._freeDrive = false;
                }

            #endregion

            #region Vehicles in front

            // Determine the next vehicle in front.
            VehicleDistance theVehicleInFrontOfMe = GetNextVehicleOnMyTrack(route[0], arcPos, lookaheadDistance);

            // The stored distance is to the front of the vehicle. All following calculations need the distance
            // to its tail. Hence, substract the vehicle length.
            if (theVehicleInFrontOfMe != null && theVehicleInFrontOfMe.distance < lookaheadDistance)
                {
                lookaheadDistance = theVehicleInFrontOfMe.distance;
                thinkAboutLineChange = true;
                lowestAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, theVehicleInFrontOfMe.distance, physics.velocity - theVehicleInFrontOfMe.vehicle.physics.velocity);
                if (lowestAcceleration < 0.1)
                    _state._freeDrive = false;

                if (    (theVehicleInFrontOfMe.vehicle.physics.velocity < 2.5)
                     || (theVehicleInFrontOfMe.vehicle.physics.velocity < 5 && theVehicleInFrontOfMe.vehicle.physics.acceleration < 0.1))
                    {
                    stopDistance = theVehicleInFrontOfMe.distance;
                    }
                }
            else
                {
                lowestAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lookaheadDistance, physics.velocity);
                }

            #endregion

            #region Stop Signs

            Pair<LineNode, double> nextStopSign = GetDistanceToNextStopSignOnRoute(route, arcPos,lookaheadDistance);
            if (nextStopSign.Left != null && nextStopSign.Left != _stopSignToIgnore)
                {
                if (isStopped)
                    {
                    _stopSignToIgnore = nextStopSign.Left;
                    }
                else
                    {
                    lookaheadDistance = nextStopSign.Right;
                    thinkAboutLineChange = false;
                    lowestAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, nextStopSign.Right, physics.velocity);
                    _state._freeDrive = false;
                    }
                }

            #endregion

            #region Traffic lights

            // Check for red traffic lights on route
            double distanceToTrafficLight = GetDistanceToNextTrafficLightOnRoute(route, arcPos, Constants.lookaheadDistance, true);
            intersectionLookaheadDistance = distanceToTrafficLight;

            // If the next TrafficLight is closer than the next vehicle, no free line change shall be performed
            if (distanceToTrafficLight < lookaheadDistance)
                {
                lookaheadDistance = distanceToTrafficLight;
                thinkAboutLineChange = false;
                lowestAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lookaheadDistance, physics.velocity);
                _state._freeDrive = false;
                }

            #endregion

            #region Intersections

            // Registration target for intersections.
            // (When doing simple calculations, we do not want to unregister at all intersections. Hence, we use a temporary regsitration):
            LinkedList<SpecificIntersection> registrationTarget = (onlySimpleCalculations ? temporaryRegisteredIntersections : registeredIntersections);

            // gather all upcoming intersections (and update the ones we are already registered at)
            GatherNextIntersectionsOnMyTrack(route, arcPos, registrationTarget, intersectionLookaheadDistance);
            double distanceToIntersection = HandleIntersections(registrationTarget, stopDistance);

            // If there is an intersection where I should wait, I should do so...
            if (!Double.IsPositiveInfinity(distanceToIntersection))// && distanceToIntersection < lookaheadDistance)
                {
                lookaheadDistance = distanceToIntersection;
                double newAcceleration = CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, distanceToIntersection, physics.velocity);
                lowestAcceleration = Math.Min(lowestAcceleration, newAcceleration);
                }

            // In case of simple calculations we need to unregister the vehicle from all intersections. Otherwise
            // some other vehicle might wait for this vehicle even if it will never pass the intersection.
            // (simple calculations are only hypothetical)
            if (onlySimpleCalculations)
                {
                foreach (SpecificIntersection si in registrationTarget)
                    {
                    si.intersection.UnregisterVehicle(this, si.nodeConnection);
                    }
                registrationTarget.Clear();
                }

            #endregion

            #region Line changes

            // simple calculation do not consider line changes
            if (!onlySimpleCalculations)
                {
                #region Forced line changes

                // our route forces to perform a line change
                if (lineChangeNeeded && !currentlyChangingLine && lci != null)
                    {
                    thinkAboutLineChange = false;
                    lastLineChangeCheck.Left = GlobalTime.Instance.currentTime;
                    lastLineChangeCheck.Right = currentPosition;

                    // get current LineChangePoint and check, whether it's leading to our target
                    NodeConnection.LineChangePoint lcp = route[0].GetPrevLineChangePoint(arcPos);
                    if (lci.targetNode.prevConnections.Contains(lcp.target.nc))
                        {
                        bool slowDownToBreakPoint = false;
                        double myArcPositionOnOtherConnection = lcp.otherStart.arcPosition + (arcPos - lcp.start.arcPosition);

                        // check if found LineChangePoint is not too far away to perform the line change
                        if ((myArcPositionOnOtherConnection >= 0) && (Math.Abs(arcPos - lcp.start.arcPosition) < Constants.maxDistanceToLineChangePoint * 1.25))
                            {
                            // Check the relation to my surrounding vehicles on the target NodeConnection
                            Pair<VehicleDistance> otherVehicles = lcp.otherStart.nc.GetVehiclesAroundArcPosition(myArcPositionOnOtherConnection, Constants.lookaheadDistance);

                            // the new vehicle in front wouldn't be too close
                            if (   otherVehicles.Right == null
                                || otherVehicles.Right.distance > otherVehicles.Right.vehicle.length + CalculateWantedDistance(physics.velocity, physics.velocity - otherVehicles.Right.vehicle.physics.velocity)/2)
                                {
                                // the new vehicle behind wouldn't be too close
                                if (   otherVehicles.Left == null
                                    || otherVehicles.Left.distance > length + otherVehicles.Left.vehicle.CalculateWantedDistance(otherVehicles.Left.vehicle.physics.velocity, otherVehicles.Left.vehicle.physics.velocity - physics.velocity)/2)
                                    {
                                    // calculate my necessary acceleration in case of a line change
                                    double myAccelerationOnOtherConnection = (otherVehicles.Right != null)
                                        ? CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, otherVehicles.Right.vehicle.currentPosition - myArcPositionOnOtherConnection, physics.velocity - otherVehicles.Right.vehicle.physics.velocity)
                                        : CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lookaheadDistance, physics.velocity);

                                    // calculate the necessary acceleration of the vehicle behind in case of a line change
                                    double forcedAccelerationOfVehicleBehindMeOnOtherConnection = (otherVehicles.Left != null)
                                        ? CalculateAcceleration(otherVehicles.Left.vehicle.physics.velocity, otherVehicles.Left.vehicle.effectiveDesiredVelocity, otherVehicles.Left.distance, otherVehicles.Left.vehicle.physics.velocity - physics.velocity)
                                        : 0;

                                    double currentAccelerationOfVehicleBehindMeOnOtherConnection = (otherVehicles.Left != null) ? otherVehicles.Left.vehicle.physics.acceleration : 0;

                                    // Final check:
                                    //  - The new vehicle behind must not break harder than bSave
                                    //  - My line change must be sufficiently necessary. The closer I come to the end of the LineChangeInterval, the more I may thwart the vehicle behind.
                                    if (   (forcedAccelerationOfVehicleBehindMeOnOtherConnection > bSave)
                                        && ((arcPos - lci.startArcPos) / lci.length >= (currentAccelerationOfVehicleBehindMeOnOtherConnection - forcedAccelerationOfVehicleBehindMeOnOtherConnection)))
                                        {
                                        // return to normal velocity
                                        _physics.multiplierTargetVelocity = 1;

                                        // initiate the line change
                                        InitiateLineChange(lcp, arcPos - lcp.start.arcPosition);
                                        lowestAcceleration = myAccelerationOnOtherConnection;
                                        }
                                    // I do not want to change line yet, but I could position myself better between the two other vehicles on the parallel line.
                                    else if (true)
                                        {
                                        // TODO: implement
                                        slowDownToBreakPoint = true;
                                        }
                                    }
                                // the new vehicle behind would too close but I can accelerate and are at least as fast as him
                                else if (   otherVehicles.Left.vehicle.physics.velocity / this.physics.velocity < 1.2  // I am not significantly slower than him
                                         && (otherVehicles.Right == null || otherVehicles.Right.distance > 1.5 * length) // the new vehicle in front is far enough away
                                         && lookaheadDistance > 2 * length			// no vehicle/traffic light/intersection in front
                                         && lci.endArcPos - arcPos > 2 * length		// enough space left in LineChangeInterval
                                         && lowestAcceleration >= -0.1)				// currently not braking
                                    {
                                    // accelerate to get in front
                                    _physics.multiplierTargetVelocity = 1.75;
                                    lowestAcceleration = Math.Min(lowestAcceleration, CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lookaheadDistance, physics.velocity));

                                    _state.SetLineChangeVehicleInteraction(this, otherVehicles.Left.vehicle, lcp.otherStart.nc, myArcPositionOnOtherConnection - _length);
                                    }
                                // There is no way to perform a line change now => slow down
                                else
                                    {
                                    slowDownToBreakPoint = true;
                                    }
                                }
                            // The new vehicle in front is too close => slow down
                            else
                                {
                                slowDownToBreakPoint = true;
                                }
                            }

                        if (slowDownToBreakPoint)
                            {
                            double percentOfLCILeft = Math.Max(0.2, (lci.endArcPos - currentPosition - Constants.breakPointBeforeForcedLineChange) / (lci.length - Constants.breakPointBeforeForcedLineChange));

                            // slow down a bit
                            _physics.multiplierTargetVelocity = Math.Min(0.9, 1.5 * percentOfLCILeft);

                            // When reaching the end of the LineChangeInterval, check whether there are other possibilities to reach the target:
                            if (percentOfLCILeft < 0.5)
                                {
                                Routing newRTT = Routing.CalculateShortestConenction(route[0].endNode, _targetNodes, _vehicleType);
                                // The alternative route does not cost too much -> choose it
                                if (newRTT.SegmentCount() > 0 && newRTT.costs / _wayToGo.costs < Constants.maxRatioForEnforcedLineChange)
                                    {
                                    _wayToGo = newRTT;
                                    _physics.multiplierTargetVelocity = 1;
                                    lineChangeNeeded = false;
                                    lci = null;
                                    }
                                }
                            // Line change still necessacy => stop at break point
                            if (lineChangeNeeded)
                                {
                                if (! _state.letVehicleChangeLine && percentOfLCILeft < 0.8)
                                    {
                                    VehicleDistance otherBehind = lcp.otherStart.nc.GetVehicleBeforeArcPosition(myArcPositionOnOtherConnection - ((_length + s0)), Constants.lookaheadDistance);

                                    // In rare cases deadlocks may appear when a very long and a short vehicle are driving parallel to each other (and both want to change line):
                                    // Then, none of the two finds a vehicle behind on the parallel connection. Hence, none of the two will wait for the other one
                                    // and both might drive to the end of the line change interval and there block each other.
                                    // To avoid this case, if there is no otherBehind, we also look for a parallel vehicle in front of our back (there should be one, otherwise
                                    // something went terribly wrong above). The longer one of the two will wait for the shorter one to make sure, no deadlock will occur.
                                    if (otherBehind == null)
                                        {
                                        VehicleDistance otherFront = lcp.otherStart.nc.GetVehicleBehindArcPosition(myArcPositionOnOtherConnection - ((_length + s0)), Constants.lookaheadDistance);
                                        if (otherFront.vehicle.lineChangeNeeded && otherFront.vehicle._length > _length)
                                            {
                                            otherBehind = otherFront;
                                            otherBehind.distance *= -1;
                                            }
                                        }

                                    //Pair<VehicleDistance> vd = lcp.otherStart.nc.GetVehiclesAroundArcPosition(myArcPositionOnOtherConnection - ( (_length + s0)), Constants.lookaheadDistance);
                                    if (otherBehind != null)// && otherBehind.vehicle.p >= p)
                                        {
                                        // tell the vehicle behind my back to wait for me
                                        _state.SetLineChangeVehicleInteraction(this, otherBehind.vehicle, lcp.otherStart.nc, myArcPositionOnOtherConnection - _length);

                                        // In addition, I need to get behind the vehicle in front of the vehicle which waits for me. Therefore I adapt the desired velocity
                                        if (_state.vehicleThatLetsMeChangeLine != null)
                                            {
                                            VehicleDistance otherBehindForman = _state.vehicleThatLetsMeChangeLine.currentNodeConnection.GetVehicleBehindArcPosition(_state.vehicleThatLetsMeChangeLine.currentPosition, 2 * (length + s0));
                                            if (otherBehindForman != null)
                                                {
                                                //_physics.multiplierTargetVelocity = Math2.Clamp(Math2.Cubic((otherBehindForman.distance - otherBehind.distance - s0) / (_length + 4 * s0)), 0.3, 1);
                                                double multPerDistance = 1 - Math2.Clamp((otherBehind.distance + _length + s0 - otherBehindForman.distance + otherBehindForman.vehicle._length + s0) / (otherBehindForman.vehicle._length), 0.2, 0.75);
                                                double multPerSpeedDiff = Math2.Clamp((otherBehindForman.vehicle._physics.velocity - _physics.velocity) / 2, 0.25, 0.8);
                                                _physics.multiplierTargetVelocity = Math.Min(multPerDistance, multPerSpeedDiff);
                                                }
                                            }
                                        }
                                    }

                                lowestAcceleration = Math.Min(lowestAcceleration, CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, lci.endArcPos - Constants.breakPointBeforeForcedLineChange - arcPos, physics.velocity));
                                }
                            }
                        }
                    }
                else if (_state.vehicleThatLetsMeChangeLine != null)
                    {
                    _state.UnsetLineChangeVehicleInteraction();
                    }

                #endregion

                #region freiwillig

                thinkAboutLineChange &= ((GlobalTime.Instance.currentTime - lastLineChangeCheck.Left > 1) || (currentPosition - lastLineChangeCheck.Right > 50));

                if (thinkAboutLineChange && !currentlyChangingLine)
                    {
                    lastLineChangeCheck.Left = GlobalTime.Instance.currentTime;
                    lastLineChangeCheck.Right = currentPosition;

                    // get current LineChangePoint and check, whether it's reachable
                    NodeConnection.LineChangePoint lcp = route[0].GetPrevLineChangePoint(arcPos);
                    if ((lcp.target.nc != null) && (Math.Abs(arcPos - lcp.start.arcPosition) < Constants.maxDistanceToLineChangePoint * 0.67))
                        {
                        // check whether there is an alternative route that is not too costly
                        Routing alternativeRoute = Routing.CalculateShortestConenction(lcp.target.nc.endNode, targetNodes, _vehicleType);
                        if (alternativeRoute.SegmentCount() > 0 && alternativeRoute.costs / wayToGo.costs < Constants.maxRatioForVoluntaryLineChange && !alternativeRoute.Top().lineChangeNeeded)
                            {
                            double myArcPositionOnOtherConnection = lcp.otherStart.arcPosition + (arcPos - lcp.start.arcPosition);
                            if (myArcPositionOnOtherConnection >= 0)
                                {
                                // Check the relation to my surrounding vehicles on the target NodeConnection
                                Pair<VehicleDistance> otherVehicles = lcp.otherStart.nc.GetVehiclesAroundArcPosition(myArcPositionOnOtherConnection, Constants.lookaheadDistance);

                                // the new vehicle in front wouldn't be too close
                                if (   otherVehicles.Right == null
                                    || otherVehicles.Right.distance > otherVehicles.Right.vehicle.length + 2 * lcp.length)
                                    {
                                    // the new vehicle behind wouldn't be too close
                                    if (   otherVehicles.Left == null
                                        || otherVehicles.Left.distance > length + otherVehicles.Left.vehicle.CalculateWantedDistance(otherVehicles.Left.vehicle.physics.velocity, otherVehicles.Left.vehicle.physics.velocity - physics.velocity)/2)
                                        {
                                        List<NodeConnection> l = new List<NodeConnection>();
                                        l.Add(lcp.target.nc);
                                        foreach (Routing.RouteSegment rs in alternativeRoute)
                                            l.Add(rs.startConnection);

                                        // calculate my necessary acceleration in case of a line change
                                        double myAccelerationOnOtherConnection = (otherVehicles.Right != null)
                                            ? CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, otherVehicles.Right.vehicle.currentPosition - myArcPositionOnOtherConnection, physics.velocity - otherVehicles.Right.vehicle.physics.velocity)
                                            : CalculateAcceleration(physics.velocity, effectiveDesiredVelocity, GetDistanceToNextTrafficLightOnRoute(l, myArcPositionOnOtherConnection, Constants.lookaheadDistance, true), physics.velocity);

                                        // calculate the necessary acceleration of the vehicle behind in case of a line change
                                        double forcedAccelerationOfVehicleBehindMeOnOtherConnection = (otherVehicles.Left != null)
                                            ? CalculateAcceleration(otherVehicles.Left.vehicle.physics.velocity, otherVehicles.Left.vehicle.effectiveDesiredVelocity, otherVehicles.Left.distance, otherVehicles.Left.vehicle.physics.velocity - physics.velocity)
                                            : 0;

                                        double currentAccelerationOfVehicleBehindMeOnOtherConnection = (otherVehicles.Left != null) ? otherVehicles.Left.vehicle.physics.acceleration : 0;

                                        // simplified implementation of MOBIL: http://www.vwi.tu-dresden.de/~treiber/MicroApplet/MOBIL.html
                                        if (forcedAccelerationOfVehicleBehindMeOnOtherConnection > bSave)
                                            {
                                            if (myAccelerationOnOtherConnection - lowestAcceleration > p * (currentAccelerationOfVehicleBehindMeOnOtherConnection - forcedAccelerationOfVehicleBehindMeOnOtherConnection) + lineChangeThreshold)
                                                {
                                                // initiate the line change
                                                InitiateLineChange(lcp, arcPos - lcp.start.arcPosition);
                                                lowestAcceleration = myAccelerationOnOtherConnection;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                #endregion

                }

            #endregion

            return lowestAcceleration;
        }