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); }
public LRTriangleMesh ResolveVertices(out int[] vertexMapping) { //init vertex-map with -1 vertexMapping = new int[ctTriangleMesh.Points.Length]; for (int i = 0; i < vertexMapping.Length; i++) { vertexMapping[i] = -1; } lrTriangleMesh.V = new Point3D[ctTriangleMesh.Points.Length]; //Get vertex which is on the ring (any) int startCtVertex = 0; while (true) {//Find first marked vertex -> startvertex if (vMarked[startCtVertex] == true) { break; } startCtVertex++; } lrTriangleMesh.V[0] = ctTriangleMesh.Points[startCtVertex]; //Save start vertex vertexMapping[startCtVertex] = 0; //Create entry in map -> index = pos of vertex in corner table, value = pos of vertex in lr int index = 1; for (int currCtVertex = startCtVertex; ; index++) { int[] faces = ctTriangleMesh.VF(currCtVertex); //Get faces incident with vertex int[][] facesSharingRingEdge = LRUtils.GetFacesSharingRingEdge(faces, tMarked); currCtVertex = GetNextRingVertex(currCtVertex, facesSharingRingEdge); //Get next ring-vertex left to the current one if (currCtVertex == startCtVertex) { break; //Back at the start of the ring } lrTriangleMesh.V[index] = ctTriangleMesh.Points[currCtVertex]; //Save that vertex vertexMapping[currCtVertex] = index; } lrTriangleMesh.MR = index; return(lrTriangleMesh); }