Exemplo n.º 1
0
        public void Parallel_Test()
        {
            var counter  = 0;
            var counter2 = 0;

            Parallel.Execute(() => { counter = counter + 1; }, () => { counter2 = counter2 + 1; });
            Assert.NotEqual(0, counter);
            Assert.NotEqual(0, counter2);
        }
Exemplo n.º 2
0
    public void SetupSegment(List <Wall2D> wallList, float wallThick, VectorLine outline, Parallel parallel)
    {
        //this.walls.AddRange(wallList);

        List <Color> colors = new List <Color>();

        foreach (Wall2D wall in wallList)
        {
            this.walls.Add(wall);
            colors.Add(wall.Color);
        }

        Vector2[] room = DrawHelper.DiscreteToContinue(wallList);

        //		bool isClose = false;
        //		if(wallList[0].StartPos == wallList[wallList.Count-1].EndPos){
        //			isClose = true;
        //		}

        bool isClose = false;

        if (room[0] == room[room.Length - 1])
        {
            isClose = true;
        }

        if (isClose)
        {
//			List<Vector3> outter;
//			RoomQuad.GetPoint(room, true, out outter);
//			List<Vector3> inner;
//			RoomQuad.GetPoint(room, false, out inner);

            List <Vector2> outter = parallel.Execute(room, wallThick, false, true);
            List <Vector2> inner  = parallel.Execute(room, wallThick, true, true);

            Add(outter, inner, colors);

            if (inner.Count > 0)
            {
                SetupOutLine(outline, inner);
            }

            if (outter.Count > 0)
            {
                SetupOutLine(outline, outter);
            }
        }
        else
        {
            List <Vector2> outter = parallel.Execute(room, wallThick, false);
            List <Vector2> inner  = parallel.Execute(room, wallThick, true);

            Add(outter, inner, colors);

            if (inner.Count > 0)
            {
                SetupOutLine(outline, inner);
            }

            if (outter.Count > 0)
            {
                SetupOutLine(outline, outter);
            }
        }
    }
Exemplo n.º 3
0
    public void SetupSegment(List<Wall2D> wallList, float wallThick, VectorLine outline, Parallel parallel)
    {
        //this.walls.AddRange(wallList);

        List<Color> colors = new List<Color>();
        foreach(Wall2D wall in wallList){
            this.walls.Add(wall);
            colors.Add(wall.Color);
        }

        Vector2[] room = DrawHelper.DiscreteToContinue(wallList);

        //		bool isClose = false;
        //		if(wallList[0].StartPos == wallList[wallList.Count-1].EndPos){
        //			isClose = true;
        //		}

        bool isClose = false;
        if(room[0] == room[room.Length-1]){
            isClose = true;
        }

        if(isClose){

        //			List<Vector3> outter;
        //			RoomQuad.GetPoint(room, true, out outter);
        //			List<Vector3> inner;
        //			RoomQuad.GetPoint(room, false, out inner);

            List<Vector2> outter = parallel.Execute(room, wallThick, false, true);
            List<Vector2> inner = parallel.Execute(room, wallThick, true, true);

            Add(outter, inner, colors);

            if(inner.Count > 0){
                SetupOutLine(outline, inner);
            }

            if(outter.Count > 0){
                SetupOutLine(outline, outter);
            }
        }
        else{
            List<Vector2> outter = parallel.Execute(room, wallThick, false);
            List<Vector2> inner = parallel.Execute(room, wallThick, true);

            Add(outter, inner, colors);

            if(inner.Count > 0){
                SetupOutLine(outline, inner);
            }

            if(outter.Count > 0){
                SetupOutLine(outline, outter);
            }
        }
    }
Exemplo n.º 4
0
    void DrawWall(Vector2[] room)
    {
        bool isClose = false;
        if(room[0] == room[room.Length-1]){
            isClose = true;
        }

        if(isClose){
            List<Vector2> outter;
            RoomQuad.GetPoint(room, true, out outter);
            List<Vector2> inner;
            RoomQuad.GetPoint(room, false, out inner);

            WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
            wallFill.Add(outter, inner);
            wallFill.Draw();

            if(inner.Count > 0){
                VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.Weld);
                roomInner.SetColor(Color.black);
                roomInner.Draw3D();
            }

            if(outter.Count > 0){
                VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld);
                roomOutter.SetColor(Color.black);
                roomOutter.Draw3D();
            }
        }
        else {

            Parallel parallel = new Parallel();
            List<Vector2> outter = parallel.Execute(room, wallThick, false);
            List<Vector2> inner = parallel.Execute(room, wallThick, true);

            WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
            wallFill.Add(outter, inner);
            wallFill.Draw();

        //			if(inner.Count > 0){
        //				VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.None);
        //				roomInner.SetColor(Color.black);
        //				roomInner.Draw3D();
        //			}
        //
        //			if(outter.Count > 0){
        //				VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.None);
        //				roomOutter.SetColor(Color.black);
        //				roomOutter.Draw3D();
        //			}

        //			List<Vector3> outter;
        //			bool counterClockwise = RoomQuad.GetPoint(room, isClose, true, out outter);
        //
        //			int length = outter.Count-1;
        //
        //			int startA = -1;
        //			int startB = -1;
        //			int endC = -1;
        //			int endD = -1;
        //			for(int i=0; i < length; i++){
        //				Vector2 dist = outter[i] - room[0];
        //				float wallThick = (float)RoomQuad.WallThick;
        //				if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){
        //					if(startA == -1){
        //						startA = i;
        //					}
        //					else{
        //						startB = i;
        //					}
        //				}
        //
        //				dist = outter[i] - room[room.Length-1];
        //				if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){
        //					if(endC == -1){
        //						endC = i;
        //					}
        //					else{
        //						endD = i;
        //					}
        //				}
        //			}
        //
        //			Debug.Log(string.Format("start index: ({0}, {1}), ", startA, startB));
        //
        //			Debug.Log("orientation: " + counterClockwise);
        //
        //			List<Vector3> a = new List<Vector3>();
        //			List<Vector3> b = new List<Vector3>();
        //
        //			if(counterClockwise){
        //
        //				Vector3[] tmp = new Vector3[length+1];
        //				outter.CopyTo(0, tmp, 0, length);
        //
        ////				if(length%2 == 1){
        ////					tmp[length] = tmp[length-1];
        ////					length++;
        ////				}
        //
        //				for(int i = startA; i > startA - length/2; i--){
        //					b.Add(tmp[(i+length)%length]);
        //				}
        //
        //				for(int i = startB; i < startB + length/2; i++){
        //					a.Add(tmp[i%length]);
        //				}
        //
        //				WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
        //				wallFill.Draw(a, b);
        //			}

        //			if(outter.Count > 0){
        //				VectorLine roomInner = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld);
        //				roomInner.SetColor(Color.blue);
        //				roomInner.Draw3D();
        //			}
        }
    }
Exemplo n.º 5
0
    void DrawWall(Vector2[] room)
    {
        bool isClose = false;

        if (room[0] == room[room.Length - 1])
        {
            isClose = true;
        }

        if (isClose)
        {
            List <Vector2> outter;
            RoomQuad.GetPoint(room, true, out outter);
            List <Vector2> inner;
            RoomQuad.GetPoint(room, false, out inner);

            WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
            wallFill.Add(outter, inner);
            wallFill.Draw();

            if (inner.Count > 0)
            {
                VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.Weld);
                roomInner.SetColor(Color.black);
                roomInner.Draw3D();
            }

            if (outter.Count > 0)
            {
                VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld);
                roomOutter.SetColor(Color.black);
                roomOutter.Draw3D();
            }
        }
        else
        {
            Parallel       parallel = new Parallel();
            List <Vector2> outter   = parallel.Execute(room, wallThick, false);
            List <Vector2> inner    = parallel.Execute(room, wallThick, true);

            WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
            wallFill.Add(outter, inner);
            wallFill.Draw();

//			if(inner.Count > 0){
//				VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.None);
//				roomInner.SetColor(Color.black);
//				roomInner.Draw3D();
//			}
//
//			if(outter.Count > 0){
//				VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.None);
//				roomOutter.SetColor(Color.black);
//				roomOutter.Draw3D();
//			}

//			List<Vector3> outter;
//			bool counterClockwise = RoomQuad.GetPoint(room, isClose, true, out outter);
//
//			int length = outter.Count-1;
//
//			int startA = -1;
//			int startB = -1;
//			int endC = -1;
//			int endD = -1;
//			for(int i=0; i < length; i++){
//				Vector2 dist = outter[i] - room[0];
//				float wallThick = (float)RoomQuad.WallThick;
//				if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){
//					if(startA == -1){
//						startA = i;
//					}
//					else{
//						startB = i;
//					}
//				}
//
//				dist = outter[i] - room[room.Length-1];
//				if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){
//					if(endC == -1){
//						endC = i;
//					}
//					else{
//						endD = i;
//					}
//				}
//			}
//
//			Debug.Log(string.Format("start index: ({0}, {1}), ", startA, startB));
//
//			Debug.Log("orientation: " + counterClockwise);
//
//			List<Vector3> a = new List<Vector3>();
//			List<Vector3> b = new List<Vector3>();
//
//			if(counterClockwise){
//
//				Vector3[] tmp = new Vector3[length+1];
//				outter.CopyTo(0, tmp, 0, length);
//
////				if(length%2 == 1){
////					tmp[length] = tmp[length-1];
////					length++;
////				}
//
//				for(int i = startA; i > startA - length/2; i--){
//					b.Add(tmp[(i+length)%length]);
//				}
//
//				for(int i = startB; i < startB + length/2; i++){
//					a.Add(tmp[i%length]);
//				}
//
//				WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill");
//				wallFill.Draw(a, b);
//			}

//			if(outter.Count > 0){
//				VectorLine roomInner = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld);
//				roomInner.SetColor(Color.blue);
//				roomInner.Draw3D();
//			}
        }
    }