Beispiel #1
0
            public void Execute(VVert v0, VVert v1, Op op)
            {
                if (op == Op.Restart)
                {
                    m_Selection.Clear();
                    op = Op.Add;
                }

                if (op == Op.Add)
                {
                    m_Selection.AddVVert(v0);
                    m_Selection.AddVVert(v1);
                }
                else
                {
                    m_Selection.DelVVert(v0);
                    m_Selection.DelVVert(v1);
                }

                m_EdgeSet.Add(v0.GetVEdge(v1));
                _WalkSelect(v0, v1, op);
                _WalkSelect(v1, v0, op);
                m_EdgeSet.Clear();
            }
Beispiel #2
0
            // "VEdge cont init"


            /// <summary>
            /// [BE WARNED: the degraded triangle case, the triangle might degrade into an edge or a point]
            ///
            ///
            /// </summary>
            private void _InitVEdgeTable()
            {
                int[] rvIdxs = m_RealMesh.triangles;
                int   triCnt = rvIdxs.Length / 3;

                //Dbg.Log("triCnt = {0}", triCnt);
                //ETimeProf prof = new ETimeProf();

                // loop over all real-tris, and generate VEdges
                for (int triIdx = 0; triIdx < triCnt; triIdx++)
                {
                    //prof.SecStart(0);
                    int rv0 = rvIdxs[triIdx * 3];
                    int rv1 = rvIdxs[triIdx * 3 + 1];
                    int rv2 = rvIdxs[triIdx * 3 + 2];

                    VVert vv0 = GetVV(rv0);
                    VVert vv1 = GetVV(rv1);
                    VVert vv2 = GetVV(rv2);

                    bool bDegradedTri = (vv0 == vv1) || (vv1 == vv2) || (vv0 == vv2);
                    if (bDegradedTri)
                    {
                        m_DegRTriCont.Add(triIdx); //record the degraded real-tri
                    }
                    //prof.SecEnd(0);

                    if (vv0 != vv1)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(1);
                        if ((vedge = vv0.GetVEdge(vv1)) == null)
                        {
                            vedge = _CreateNewVEdge(vv0, vv1);
                        }
                        Dbg.Assert(vedge != null, "VMesh._InitVEdgeTable: vedge is null");

                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(1);
                    }

                    if (vv1 != vv2)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(2);
                        if ((vedge = vv1.GetVEdge(vv2)) == null)
                        {
                            vedge = _CreateNewVEdge(vv1, vv2);
                        }
                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(2);
                    }

                    if (vv0 != vv2)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(3);
                        if ((vedge = vv2.GetVEdge(vv0)) == null)
                        {
                            vedge = _CreateNewVEdge(vv2, vv0);
                        }
                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(3);
                    }
                } // end of for

                m_VEdgeArr = m_VEdgeCont.ToArray();
                //prof.SecShowAll();
            }
Beispiel #3
0
            // private method

            /// <summary>
            /// try to process v2 if possible (under given op)
            /// [v0 ==> v1 == v2] in this order
            /// </summary>
            private void _WalkSelect(VVert v0, VVert v1, Op op)
            {
                //////////////////////////////////////////////////
                // 1. if v1 doesn't have exactly 4 vedges, return;
                // 2. take the vedge E that doesn't share VFace with vedge(v0,v1)
                // 3. select the other vvert v2 of E;
                // 4. iterate as _WalkSelect(v1, v2, op)
                //////////////////////////////////////////////////

                VEdge thisEdge = v0.GetVEdge(v1);

                thisEdge.GetVFaces(m_tmpVFaces1);

                while (true)
                {
                    // step 1
                    VELst veLst = v1.GetActiveVEdges();
                    if (veLst.Count != GOOD_EDGE_CNT)
                    {
                        //Dbg.Log("_WalkSelect: {0}=>{1}, veLst.Count not 4, is {2}", v0, v1, veLst.Count);
                        break; //END
                    }

                    // step 2
                    VEdge thatEdge = null;
                    for (int i = 0; i < GOOD_EDGE_CNT; ++i)
                    {
                        VEdge rhs = veLst[i];
                        if (rhs == thisEdge)
                        {
                            continue;
                        }

                        rhs.GetVFaces(m_tmpVFaces2);
                        if (!_HasIntersect(m_tmpVFaces1, m_tmpVFaces2))
                        {
                            thatEdge = rhs;
                            break; //just out of edge loop
                        }
                    }

                    // step 3
                    VVert v2 = null;
                    if (thatEdge != null)
                    {
                        v2 = thatEdge.GetVVert(0);
                        if (v2 == v1)
                        {
                            v2 = thatEdge.GetVVert(1);
                        }

                        // check for inf loop
                        VEdge newEdge = v1.GetVEdge(v2);
                        if (m_EdgeSet.Contains(newEdge))
                        {
                            break; //END
                        }
                        m_EdgeSet.Add(newEdge);

                        // modify selection
                        if (op == Op.Add)
                        {
                            m_Selection.AddVVert(v2);
                        }
                        else
                        {
                            m_Selection.DelVVert(v2);
                        }

                        // step 4
                        v0       = v1;
                        v1       = v2;
                        thisEdge = thatEdge;
                        Misc.Swap(ref m_tmpVFaces1, ref m_tmpVFaces2);
                    }
                    else
                    {
                        //Dbg.Log("_WalkSelect: {0}=>{1}, not found thatEdge", v0, v1);
                        break; //END
                    }
                } // end of while(true)
            }