Exemplo n.º 1
0
        public LRTriangleMesh ResolveTriangles(int[] vertexMapping)
        {
            this.vertexMapping = vertexMapping;
            lrCornerResolver = new LRCornerResolver(ref lrTriangleMesh, ref ctTriangleMesh, ref tMarked, ref vertexMapping);

            //Loop through all vertices
            for (int i = 0; i < vertexMapping.Length; i++)
            {
                int[] faces = ctTriangleMesh.VF(i);
                int[][] facesSharingRingEdge = LRUtils.GetFacesSharingRingEdge(faces, tMarked);

                if (vMarked[i]) //If vertex is marked then its not isolated and therefore has a ring edge (is start vertex of a ring edge)
                {
                    if (facesSharingRingEdge[0] != null && !tProcessed[facesSharingRingEdge[0][0]])
                    {
                        //Resolve "left" triangle
                        int c = ctTriangleMesh.GetSpecificCorner(facesSharingRingEdge[0][0], i); //Get the corner of the vertex, which is incident with the marked triangle of the ring edge, where the vertex is the start vertex
                        int pc = ctTriangleMesh.P(c); //Get the next corner around the triangle, which is the one facing the ring edge

                        lrTriangleMesh.LR[(2 * vertexMapping[ctTriangleMesh.V(c)])] = vertexMapping[ctTriangleMesh.V(pc)]; //Store the mapped vertex index (laced ring vertex index) in the LR table at the correct pos.
                    }

                    if (facesSharingRingEdge[0] != null && !tProcessed[facesSharingRingEdge[0][1]])
                    {
                        //Resolve "right" triangle
                        int c = ctTriangleMesh.GetSpecificCorner(facesSharingRingEdge[0][1], i); //Get the corner of the vertex, which is incident with the marked triangle of the ring edge, where the vertex is the start vertex
                        int nc = ctTriangleMesh.N(c); //Get the previous corner around the triangle, which is the one facing the ring edge

                        lrTriangleMesh.LR[(2 * vertexMapping[ctTriangleMesh.V(c)]) + 1] = vertexMapping[ctTriangleMesh.V(nc)]; //Store the mapped vertex index (laced ring vertex index) in the LR table at the correct pos.
                    }

                    T0LookUp(i, faces); //Look up if vertex is part of a T0 and handle accordingly
                }
                else //Isolated vertex
                {
                    CheckAndResolveIsolatedVertex(i); //Create entry for isolated vertex
                    T0LookUp(i, faces); //Look up if it is part of a T0 and handle accordingly
                }
            }

            //Store results in lr object
            lrTriangleMesh.T = t.ToArray();
            lrTriangleMesh.O = lrCornerResolver.O.ToArray();
            lrTriangleMesh.TS = ts.ToArray();
            lrTriangleMesh.OS = lrCornerResolver.OS.ToArray();
            lrTriangleMesh.C = lrCornerResolver.IsolatedCorners.ToArray();

            return lrTriangleMesh;
        }
Exemplo n.º 2
0
        public LRTriangleMesh ResolveTriangles(int[] vertexMapping)
        {
            this.vertexMapping = vertexMapping;
            lrCornerResolver   = new LRCornerResolver(ref lrTriangleMesh, ref ctTriangleMesh, ref tMarked, ref vertexMapping);

            //Loop through all vertices
            for (int i = 0; i < vertexMapping.Length; i++)
            {
                int[]   faces = ctTriangleMesh.VF(i);
                int[][] facesSharingRingEdge = LRUtils.GetFacesSharingRingEdge(faces, tMarked);

                if (vMarked[i]) //If vertex is marked then its not isolated and therefore has a ring edge (is start vertex of a ring edge)
                {
                    if (facesSharingRingEdge[0] != null && !tProcessed[facesSharingRingEdge[0][0]])
                    {
                        //Resolve "left" triangle
                        int c  = ctTriangleMesh.GetSpecificCorner(facesSharingRingEdge[0][0], i);                          //Get the corner of the vertex, which is incident with the marked triangle of the ring edge, where the vertex is the start vertex
                        int pc = ctTriangleMesh.P(c);                                                                      //Get the next corner around the triangle, which is the one facing the ring edge

                        lrTriangleMesh.LR[(2 * vertexMapping[ctTriangleMesh.V(c)])] = vertexMapping[ctTriangleMesh.V(pc)]; //Store the mapped vertex index (laced ring vertex index) in the LR table at the correct pos.
                    }

                    if (facesSharingRingEdge[0] != null && !tProcessed[facesSharingRingEdge[0][1]])
                    {
                        //Resolve "right" triangle
                        int c  = ctTriangleMesh.GetSpecificCorner(facesSharingRingEdge[0][1], i);                              //Get the corner of the vertex, which is incident with the marked triangle of the ring edge, where the vertex is the start vertex
                        int nc = ctTriangleMesh.N(c);                                                                          //Get the previous corner around the triangle, which is the one facing the ring edge

                        lrTriangleMesh.LR[(2 * vertexMapping[ctTriangleMesh.V(c)]) + 1] = vertexMapping[ctTriangleMesh.V(nc)]; //Store the mapped vertex index (laced ring vertex index) in the LR table at the correct pos.
                    }

                    T0LookUp(i, faces); //Look up if vertex is part of a T0 and handle accordingly
                }
                else //Isolated vertex
                {
                    CheckAndResolveIsolatedVertex(i); //Create entry for isolated vertex
                    T0LookUp(i, faces);               //Look up if it is part of a T0 and handle accordingly
                }
            }

            //Store results in lr object
            lrTriangleMesh.T  = t.ToArray();
            lrTriangleMesh.O  = lrCornerResolver.O.ToArray();
            lrTriangleMesh.TS = ts.ToArray();
            lrTriangleMesh.OS = lrCornerResolver.OS.ToArray();
            lrTriangleMesh.C  = lrCornerResolver.IsolatedCorners.ToArray();

            return(lrTriangleMesh);
        }