Splice() публичный Метод

Splice is the basic operation for changing the mesh connectivity and topology. It changes the mesh so that eOrg->Onext = OLD( eDst->Onext ) eDst->Onext = OLD( eOrg->Onext ) where OLD(...) means the value before the meshSplice operation. This can have two effects on the vertex structure: - if eOrg->Org != eDst->Org, the two vertices are merged together - if eOrg->Org == eDst->Org, the origin is split into two vertices In both cases, eDst->Org is changed and eOrg->Org is untouched. Similarly (and independently) for the face structure, - if eOrg->Lface == eDst->Lface, one loop is split into two - if eOrg->Lface != eDst->Lface, two distinct loops are joined into one In both cases, eDst->Lface is changed and eOrg->Lface is unaffected. Some special cases: If eDst == eOrg, the operation has no effect. If eDst == eOrg->Lnext, the new face will have a single edge. If eDst == eOrg->Lprev, the old face will have a single edge. If eDst == eOrg->Onext, the new vertex will have a single edge. If eDst == eOrg->Oprev, the old vertex will have a single edge.
public Splice ( LibTessDotNet.MeshUtils.Edge eOrg, LibTessDotNet.MeshUtils.Edge eDst ) : void
eOrg LibTessDotNet.MeshUtils.Edge
eDst LibTessDotNet.MeshUtils.Edge
Результат void
Пример #1
0
        public void AddContour(ContourVertex[] vertices, ContourOrientation forceOrientation)
        {
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            bool flag = false;

            if (forceOrientation != 0)
            {
                float num = SignedArea(vertices);
                flag = ((forceOrientation == ContourOrientation.Clockwise && num < 0f) || (forceOrientation == ContourOrientation.CounterClockwise && num > 0f));
            }
            MeshUtils.Edge edge = null;
            for (int i = 0; i < vertices.Length; i++)
            {
                if (edge == null)
                {
                    edge = _mesh.MakeEdge();
                    Mesh           mesh  = _mesh;
                    MeshUtils.Edge edge2 = edge;
                    mesh.Splice(edge2, edge2._Sym);
                }
                else
                {
                    _mesh.SplitEdge(edge);
                    edge = edge._Lnext;
                }
                int num2 = flag ? (vertices.Length - 1 - i) : i;
                edge._Org._coords  = vertices[num2].Position;
                edge._Org._data    = vertices[num2].Data;
                edge._winding      = 1;
                edge._Sym._winding = -1;
            }
        }
Пример #2
0
        private void AddContourInternal(IList <ContourVertex> vertices, ContourOrientation forceOrientation)
        {
            if (_mesh == null)
            {
                _mesh = _pool.Get <Mesh>();
            }

            bool reverse = false;

            if (forceOrientation != ContourOrientation.Original)
            {
                var area = SignedArea(vertices);
                reverse = (forceOrientation == ContourOrientation.Clockwise && area < new DeterministicFloat(0)) || (forceOrientation == ContourOrientation.CounterClockwise && area > new DeterministicFloat(0));
            }

            MeshUtils.Edge e = null;
            for (int i = 0; i < vertices.Count; ++i)
            {
                if (e == null)
                {
                    e = _mesh.MakeEdge(_pool);
                    _mesh.Splice(_pool, e, e._Sym);
                }
                else
                {
                    // Create a new vertex and edge which immediately follow e
                    // in the ordering around the left face.
                    _mesh.SplitEdge(_pool, e);
                    e = e._Lnext;
                }

                int index = reverse ? vertices.Count - 1 - i : i;
                // The new vertex is now e._Org.
                e._Org._coords = vertices[index].Position;
                e._Org._data   = vertices[index].Data;

                // The winding of an edge says how the winding number changes as we
                // cross from the edge's right face to its left face.  We add the
                // vertices in such an order that a CCW contour will add +1 to
                // the winding number of the region inside the contour.
                e._winding      = 1;
                e._Sym._winding = -1;
            }
        }
Пример #3
0
        public void AddContour(ContourVertex[] vertices, int count, ContourOrientation forceOrientation)
        {
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }

            bool reverse = false;

            if (forceOrientation != ContourOrientation.Original)
            {
                float area = SignedArea(vertices, count);
                reverse = (forceOrientation == ContourOrientation.Clockwise && area < 0.0f) || (forceOrientation == ContourOrientation.CounterClockwise && area > 0.0f);
            }

            MeshUtils.Edge e = null;
            for (int i = 0; i < count; ++i)
            {
                if (e == null)
                {
                    e = _mesh.MakeEdge();
                    _mesh.Splice(e, e._Sym);
                }
                else
                {
                    // Create a new vertex and edge which immediately follow e
                    // in the ordering around the left face.
                    _mesh.SplitEdge(e);
                    e = e._Lnext;
                }

                int index = reverse ? count - 1 - i : i;
                // The new vertex is now e._Org.
                e._Org._coords = vertices[index].Position;
                e._Org._data   = vertices[index].Data;

                // The winding of an edge says how the winding number changes as we
                // cross from the edge's right face to its left face.  We add the
                // vertices in such an order that a CCW contour will add +1 to
                // the winding number of the region inside the contour.
                e._winding      = 1;
                e._Sym._winding = -1;
            }
        }
Пример #4
0
        private MeshUtils.Edge FinishLeftRegions(ActiveRegion regFirst, ActiveRegion regLast)
        {
            ActiveRegion activeRegion = regFirst;

            MeshUtils.Edge eUp = regFirst._eUp;
            while (activeRegion != regLast)
            {
                activeRegion._fixUpperEdge = false;
                ActiveRegion   activeRegion2 = RegionBelow(activeRegion);
                MeshUtils.Edge edge          = activeRegion2._eUp;
                if (edge._Org != eUp._Org)
                {
                    if (!activeRegion2._fixUpperEdge)
                    {
                        FinishRegion(activeRegion);
                        break;
                    }
                    edge = _mesh.Connect(eUp._Lprev, edge._Sym);
                    FixUpperEdge(activeRegion2, edge);
                }
                if (eUp._Onext != edge)
                {
                    _mesh.Splice(edge._Oprev, edge);
                    _mesh.Splice(eUp, edge);
                }
                FinishRegion(activeRegion);
                eUp          = activeRegion2._eUp;
                activeRegion = activeRegion2;
            }
            return(eUp);
        }