コード例 #1
0
        protected void ComputePlane(Plane plane, LinkedListTriangle tri, Map map)
        {
            var point1 = tri.Point1;
            var point2 = tri.Point2;
            var point3 = tri.Point3;

            var vec1 = new Vector3(point1, map[point1.X, point1.Y]);
            var vec2 = new Vector3(point2, map[point2.X, point2.Y]);
            var vec3 = new Vector3(point3, map[point3.X, point3.Y]);

            plane.Init(vec1, vec2, vec3);
        }
コード例 #2
0
ファイル: Subdivision.cs プロジェクト: NecroSharper/WCell
        protected void InitMesh(Vector2 av, Vector2 bv, Vector2 cv, Vector2 dv)
        {
            var a = new Vector2(av.X, av.Y);
            var b = new Vector2(bv.X, bv.Y);
            var c = new Vector2(cv.X, cv.Y);
            var d = new Vector2(dv.X, dv.Y);


            var edgeA = MakeEdge();

            edgeA.SetEndPoints(a, b);

            var edgeB = MakeEdge();

            Edge.Splice(edgeA.Sym, edgeB);
            edgeB.SetEndPoints(b, c);

            var edgeC = MakeEdge();

            Edge.Splice(edgeB.Sym, edgeC);
            edgeC.SetEndPoints(c, d);

            var edgeD = MakeEdge();

            Edge.Splice(edgeC.Sym, edgeD);
            edgeD.SetEndPoints(d, a);
            Edge.Splice(edgeD.Sym, edgeA);

            var diag = MakeEdge();

            Edge.Splice(edgeD.Sym, diag);
            Edge.Splice(edgeB.Sym, diag.Sym);
            diag.SetEndPoints(a, c);

            startingEdge = edgeA;
            firstFace    = null;

            MakeFace(edgeA.Sym).Update(this);
            MakeFace(edgeC.Sym).Update(this);
        }
コード例 #3
0
ファイル: Subdivision.cs プロジェクト: NecroSharper/WCell
        public Edge Spoke(Vector2 point, Edge edge)
        {
            var newFaces = new LinkedListTriangle[4];
            var faceIdx  = 0;

            // Note e is the edge returned by Locate(point)

            if ((point == edge.Orig) || (point == edge.Dest))
            {
                Console.WriteLine("WARNING: Tried to re-insert point: {0}", point);
                Console.WriteLine("         orig: {0}", edge.Orig);
                Console.WriteLine("         dest: {0}", edge.Dest);
                return(null);
            }

            Edge boundaryEdge = null;

            var lFace = edge.LFace;

            lFace.DontAnchor(edge);
            newFaces[faceIdx++] = lFace;

            if (OnEdge(point, edge))
            {
                if (CCWBoundary(edge))
                {
                    // edge is on the boundary
                    // defer deletion until after new edges are added
                    boundaryEdge = edge;
                }
                else
                {
                    var symLFace = edge.Sym.LFace;
                    newFaces[faceIdx++] = symLFace;
                    symLFace.DontAnchor(edge.Sym);

                    edge = edge.OPrev;
                    DeleteEdge(edge.ONext);
                }
            }

            var baseEdge = MakeEdge(edge.Orig, new Vector2(point.X, point.Y));

            Edge.Splice(baseEdge, edge);

            startingEdge = baseEdge;
            do
            {
                baseEdge = Connect(edge, baseEdge.Sym);
                edge     = baseEdge.OPrev;
            } while (edge.LNext != startingEdge);

            if (boundaryEdge != null)
            {
                DeleteEdge(boundaryEdge);
            }

            baseEdge = (boundaryEdge != null) ? startingEdge.RPrev : startingEdge.Sym;
            do
            {
                if (faceIdx != 0)
                {
                    newFaces[--faceIdx].Reshape(baseEdge);
                }
                else
                {
                    MakeFace(baseEdge);
                }

                baseEdge = baseEdge.ONext;
            } while (baseEdge != startingEdge.Sym);

            return(startingEdge);
        }
コード例 #4
0
ファイル: Subdivision.cs プロジェクト: NecroSharper/WCell
        public Edge Insert(float x, float y, LinkedListTriangle tri)
        {
            var newVec = new Vector2(x, y);

            return(Insert(newVec, tri));
        }