VertEq() public static method

public static VertEq ( LibTessDotNet.MeshUtils.Vertex lhs, LibTessDotNet.MeshUtils.Vertex rhs ) : bool
lhs LibTessDotNet.MeshUtils.Vertex
rhs LibTessDotNet.MeshUtils.Vertex
return bool
示例#1
0
 protected void ComputeInterior()
 {
     RemoveDegenerateEdges();
     InitPriorityQ();
     RemoveDegenerateFaces();
     InitEdgeDict();
     MeshUtils.Vertex vertex;
     while ((vertex = _pq.ExtractMin()) != null)
     {
         while (true)
         {
             MeshUtils.Vertex vertex2 = _pq.Minimum();
             if (vertex2 == null || !Geom.VertEq(vertex2, vertex))
             {
                 break;
             }
             vertex2 = _pq.ExtractMin();
             SpliceMergeVertices(vertex._anEdge, vertex2._anEdge);
         }
         SweepEvent(vertex);
     }
     DoneEdgeDict();
     DonePriorityQ();
     RemoveDegenerateFaces();
 }
示例#2
0
 private void RemoveDegenerateEdges()
 {
     MeshUtils.Edge eHead = _mesh._eHead;
     MeshUtils.Edge next;
     for (MeshUtils.Edge edge = eHead._next; edge != eHead; edge = next)
     {
         next = edge._next;
         MeshUtils.Edge lnext = edge._Lnext;
         if (Geom.VertEq(edge._Org, edge._Dst) && edge._Lnext._Lnext != edge)
         {
             SpliceMergeVertices(lnext, edge);
             _mesh.Delete(edge);
             edge  = lnext;
             lnext = edge._Lnext;
         }
         if (lnext._Lnext == edge)
         {
             if (lnext != edge)
             {
                 if (lnext == next || lnext == next._Sym)
                 {
                     next = next._next;
                 }
                 _mesh.Delete(lnext);
             }
             if (edge == next || edge == next._Sym)
             {
                 next = next._next;
             }
             _mesh.Delete(edge);
         }
     }
 }
示例#3
0
        private void ConnectRightVertex(ActiveRegion regUp, MeshUtils.Edge eBottomLeft)
        {
            MeshUtils.Edge edge         = eBottomLeft._Onext;
            ActiveRegion   activeRegion = RegionBelow(regUp);

            MeshUtils.Edge eUp  = regUp._eUp;
            MeshUtils.Edge eUp2 = activeRegion._eUp;
            bool           flag = false;

            if (eUp._Dst != eUp2._Dst)
            {
                CheckForIntersect(regUp);
            }
            if (Geom.VertEq(eUp._Org, _event))
            {
                _mesh.Splice(edge._Oprev, eUp);
                regUp = TopLeftRegion(regUp);
                edge  = RegionBelow(regUp)._eUp;
                FinishLeftRegions(RegionBelow(regUp), activeRegion);
                flag = true;
            }
            if (Geom.VertEq(eUp2._Org, _event))
            {
                _mesh.Splice(eBottomLeft, eUp2._Oprev);
                eBottomLeft = FinishLeftRegions(activeRegion, null);
                flag        = true;
            }
            if (flag)
            {
                ActiveRegion   regUp2 = regUp;
                MeshUtils.Edge onext  = eBottomLeft._Onext;
                MeshUtils.Edge edge2  = edge;
                AddRightEdges(regUp2, onext, edge2, edge2, true);
            }
            else
            {
                MeshUtils.Edge eDst = (!Geom.VertLeq(eUp2._Org, eUp._Org)) ? eUp : eUp2._Oprev;
                eDst = _mesh.Connect(eBottomLeft._Lprev, eDst);
                ActiveRegion   regUp3 = regUp;
                MeshUtils.Edge edge3  = eDst;
                AddRightEdges(regUp3, edge3, edge3._Onext, eDst._Onext, false);
                eDst._Sym._activeRegion._fixUpperEdge = true;
                WalkDirtyRegions(regUp);
            }
        }
示例#4
0
 private void ConnectLeftDegenerate(ActiveRegion regUp, MeshUtils.Vertex vEvent)
 {
     MeshUtils.Edge eUp = regUp._eUp;
     if (Geom.VertEq(eUp._Org, vEvent))
     {
         throw new InvalidOperationException("Vertices should have been merged before");
     }
     if (!Geom.VertEq(eUp._Dst, vEvent))
     {
         _mesh.SplitEdge(eUp._Sym);
         if (regUp._fixUpperEdge)
         {
             _mesh.Delete(eUp._Onext);
             regUp._fixUpperEdge = false;
         }
         _mesh.Splice(vEvent._anEdge, eUp);
         SweepEvent(vEvent);
         return;
     }
     throw new InvalidOperationException("Vertices should have been merged before");
 }
示例#5
0
        private bool CheckForRightSplice(ActiveRegion regUp)
        {
            ActiveRegion activeRegion = RegionBelow(regUp);

            MeshUtils.Edge eUp  = regUp._eUp;
            MeshUtils.Edge eUp2 = activeRegion._eUp;
            if (Geom.VertLeq(eUp._Org, eUp2._Org))
            {
                if (Geom.EdgeSign(eUp2._Dst, eUp._Org, eUp2._Org) > 0f)
                {
                    return(false);
                }
                if (!Geom.VertEq(eUp._Org, eUp2._Org))
                {
                    _mesh.SplitEdge(eUp2._Sym);
                    _mesh.Splice(eUp, eUp2._Oprev);
                    regUp._dirty = (activeRegion._dirty = true);
                }
                else if (eUp._Org != eUp2._Org)
                {
                    _pq.Remove(eUp._Org._pqHandle);
                    SpliceMergeVertices(eUp2._Oprev, eUp);
                }
            }
            else
            {
                if (Geom.EdgeSign(eUp._Dst, eUp2._Org, eUp._Org) < 0f)
                {
                    return(false);
                }
                RegionAbove(regUp)._dirty = (regUp._dirty = true);
                _mesh.SplitEdge(eUp._Sym);
                _mesh.Splice(eUp2._Oprev, eUp);
            }
            return(true);
        }
示例#6
0
        private bool CheckForIntersect(ActiveRegion regUp)
        {
            ActiveRegion activeRegion = RegionBelow(regUp);

            MeshUtils.Edge   eUp  = regUp._eUp;
            MeshUtils.Edge   eUp2 = activeRegion._eUp;
            MeshUtils.Vertex org  = eUp._Org;
            MeshUtils.Vertex org2 = eUp2._Org;
            MeshUtils.Vertex dst  = eUp._Dst;
            MeshUtils.Vertex dst2 = eUp2._Dst;
            if (org == org2)
            {
                return(false);
            }
            float num  = Math.Min(org._t, dst._t);
            float num2 = Math.Max(org2._t, dst2._t);

            if (num > num2)
            {
                return(false);
            }
            if (Geom.VertLeq(org, org2))
            {
                if (Geom.EdgeSign(dst2, org, org2) > 0f)
                {
                    return(false);
                }
            }
            else if (Geom.EdgeSign(dst, org2, org) < 0f)
            {
                return(false);
            }
            MeshUtils.Vertex vertex = MeshUtils.Pooled <MeshUtils.Vertex> .Create();

            Geom.EdgeIntersect(dst, org, dst2, org2, vertex);
            if (Geom.VertLeq(vertex, _event))
            {
                vertex._s = _event._s;
                vertex._t = _event._t;
            }
            MeshUtils.Vertex vertex2 = Geom.VertLeq(org, org2) ? org : org2;
            if (Geom.VertLeq(vertex2, vertex))
            {
                vertex._s = vertex2._s;
                vertex._t = vertex2._t;
            }
            if (Geom.VertEq(vertex, org) || Geom.VertEq(vertex, org2))
            {
                CheckForRightSplice(regUp);
                return(false);
            }
            if ((!Geom.VertEq(dst, _event) && Geom.EdgeSign(dst, _event, vertex) >= 0f) || (!Geom.VertEq(dst2, _event) && Geom.EdgeSign(dst2, _event, vertex) <= 0f))
            {
                if (dst2 == _event)
                {
                    _mesh.SplitEdge(eUp._Sym);
                    _mesh.Splice(eUp2._Sym, eUp);
                    regUp = TopLeftRegion(regUp);
                    eUp   = RegionBelow(regUp)._eUp;
                    FinishLeftRegions(RegionBelow(regUp), activeRegion);
                    ActiveRegion   regUp2 = regUp;
                    MeshUtils.Edge oprev  = eUp._Oprev;
                    MeshUtils.Edge edge   = eUp;
                    AddRightEdges(regUp2, oprev, edge, edge, true);
                    return(true);
                }
                if (dst == _event)
                {
                    _mesh.SplitEdge(eUp2._Sym);
                    _mesh.Splice(eUp._Lnext, eUp2._Oprev);
                    activeRegion = regUp;
                    regUp        = TopRightRegion(regUp);
                    MeshUtils.Edge rprev = RegionBelow(regUp)._eUp._Rprev;
                    activeRegion._eUp = eUp2._Oprev;
                    eUp2 = FinishLeftRegions(activeRegion, null);
                    AddRightEdges(regUp, eUp2._Onext, eUp._Rprev, rprev, true);
                    return(true);
                }
                if (Geom.EdgeSign(dst, _event, vertex) >= 0f)
                {
                    RegionAbove(regUp)._dirty = (regUp._dirty = true);
                    _mesh.SplitEdge(eUp._Sym);
                    eUp._Org._s = _event._s;
                    eUp._Org._t = _event._t;
                }
                if (Geom.EdgeSign(dst2, _event, vertex) <= 0f)
                {
                    regUp._dirty = (activeRegion._dirty = true);
                    _mesh.SplitEdge(eUp2._Sym);
                    eUp2._Org._s = _event._s;
                    eUp2._Org._t = _event._t;
                }
                return(false);
            }
            _mesh.SplitEdge(eUp._Sym);
            _mesh.SplitEdge(eUp2._Sym);
            _mesh.Splice(eUp2._Oprev, eUp);
            eUp._Org._s        = vertex._s;
            eUp._Org._t        = vertex._t;
            eUp._Org._pqHandle = _pq.Insert(eUp._Org);
            if (eUp._Org._pqHandle._handle == PQHandle.Invalid)
            {
                throw new InvalidOperationException("PQHandle should not be invalid");
            }
            GetIntersectData(eUp._Org, org, dst, org2, dst2);
            RegionAbove(regUp)._dirty = (regUp._dirty = (activeRegion._dirty = true));
            return(false);
        }