Beispiel #1
0
    public bool RefineMentTest(int halfedge)
    {
        ExtrudableMesh _extrudableMesh = modellingObject.GetComponentInChildren <ExtrudableMesh>();
        Manifold       manifold        = _extrudableMesh._manifold;

        if (manifold.IsHalfedgeInUse(halfedge))
        {
            int h2 = manifold.GetNextHalfEdge(halfedge);
            h2 = manifold.GetNextHalfEdge(h2);

            if (manifold.IsHalfedgeInUse(h2))
            {
                int v1     = _extrudableMesh._manifold.SplitEdge(halfedge);
                int v2     = _extrudableMesh._manifold.SplitEdge(h2);
                int output = _extrudableMesh._manifold.SplitFaceByEdges(manifold.GetIncidentFace(halfedge), v1, v2);
                _extrudableMesh.UpdateMesh();

                ControlsManager man = modellingObject.GetComponentInChildren <Controls.ControlsManager>();
                man.UpdateControls();

                return(true);
            }
        }

        return(false);
    }
Beispiel #2
0
        private void ShowRefinement(int vertexid1, int vertexid2)
        {
            if (activeControllers.Count == 2)
            {
                //splitManifold = Extrudable._manifold.Copy();

                //int edge = adjacentVertices[activeControllers[1].AssociatedVertexID];

                /*
                 * Debug.Log("vertexid2: " + vertexid2);
                 *
                 * string text = "";
                 *
                 * foreach (KeyValuePair<int, int> kvp in adjacentVertices)
                 * {
                 *  //textBox3.Text += ("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 *  text += string.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 * }
                 * Debug.Log(text);
                 */
                int edge = adjacentVertices[vertexid2];

                splitManifold = Extrudable._manifold.Copy();

                int edge2 = splitManifold.GetNextHalfEdge(edge);

                edge2 = splitManifold.GetNextHalfEdge(edge2);

                splitManifold.RefineFaceloop(edge, edge2);

                //Extrudable._manifold.RefineFaceloop(edge, edge2);
                splitManifold.StitchMesh(1e-10);
                var newMesh = new Mesh();
                newMesh.vertices     = mesh.vertices;
                newMesh.normals      = mesh.normals;
                newMesh.subMeshCount = 2;
                newMesh.SetIndices(mesh.triangles, MeshTopology.Triangles, 0);
                //newMesh.SetIndices(new int[0], MeshTopology.Lines, 1);
                mesh = newMesh;
                mesh.UploadMeshData(false);
                GameObject refinePreview = GameObject.FindGameObjectWithTag("RefinePreview");
                refinePreview.GetComponent <MeshFilter>().mesh      = CreatePreviewMesh();
                refinePreview.GetComponent <MeshRenderer>().enabled = true;
            }
        }
Beispiel #3
0
    public bool ValidateFaceLoop(int halfedgeId1, int halfedgeId2)
    {
        Manifold manifold = _extrudableMesh._manifold;

        //if (manifold.GetIncidentFace(halfedgeId1) == manifold.GetIncidentFace(halfedgeId2))
        //{
        //    return false;
        //}

        if (!manifold.IsHalfedgeInUse(halfedgeId1) || !manifold.IsHalfedgeInUse(halfedgeId2))
        {
            return(false);
        }

        int f = manifold.GetIncidentFace(halfedgeId1);
        int h = halfedgeId1;

        while (true)
        {
            int h2 = manifold.GetNextHalfEdge(h);
            h2 = manifold.GetNextHalfEdge(h2);
            int h3 = manifold.GetOppHalfEdge(h2);


            if (h2 == halfedgeId2 || h3 == halfedgeId2)
            {
                return(true);
            }

            else if (manifold.GetIncidentFace(h3) == f)
            {
                return(false);
            }
            h = h3;
        }
    }
Beispiel #4
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);
            }
        }
    }