Exemplo n.º 1
0
    public bool RefinementTestLoop(int halfedge1, int halfedge2)
    {
        if (!ValidateFaceLoop(halfedge1, halfedge2))
        {
            return(false);
        }
        ExtrudableMesh _extrudableMesh = modellingObject.GetComponentInChildren <ExtrudableMesh>();
        Manifold       manifold        = _extrudableMesh._manifold;

        int h          = halfedge1;
        int initital_f = manifold.GetIncidentFace(halfedge1);
        int f          = initital_f;

        List <int> faceloop = new List <int>();
        List <int> edgeloop = new List <int>();

        while (true)
        {
            if (manifold.IsFaceInUse(f))
            {
                if (manifold.IsHalfedgeInUse(h))
                {
                    int h2 = manifold.GetNextHalfEdge(h);
                    h2 = manifold.GetNextHalfEdge(h2);
                    if (manifold.IsHalfedgeInUse(h2))
                    {
                        int w = manifold.SplitEdge(h);
                        edgeloop.Add(w);
                        faceloop.Add(f);

                        h = manifold.GetOppHalfEdge(h2);
                        f = manifold.GetIncidentFace(h);
                        if (f == initital_f)
                        {
                            int[] farray = faceloop.ToArray();
                            int[] earray = edgeloop.ToArray();
                            for (int i = 0; i < farray.Length; i++)
                            {
                                if (i == farray.Length - 1)
                                {
                                    int output = manifold.SplitFaceByEdges(farray[i], earray[i], earray[0]); // earray[1]);
                                }
                                else
                                {
                                    int output = manifold.SplitFaceByEdges(farray[i], earray[i], earray[i + 1]);
                                }
                            }
                            _extrudableMesh.UpdateMesh();
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
    }