public void Recombine() { Tris = new List <Tri>(Simplexs.Count); Quads = new List <Quad>(); foreach (ISimplex item in Simplexs) { Tris.Add((Tri)item); //triangles.Add(Tris.Last().ToTriangle(nodes)); //triangles.Last().Id = Tris.Last().Id; } List <Tri> selTrias = (from t in Tris orderby Math.Abs(t.ToTriangle(Nodes).MaxAngleDeg - 90) select t).ToList(); foreach (Tri item in selTrias) { if (!Tris.Contains(item)) { continue; } Quad q = QuadMinA(item, out Tri del); if (q != null) { Quads.Add(q); Simplexs.Remove(item); Simplexs.Remove(del); Simplexs.Add(Quads.Last()); Tris.Remove(item); Tris.Remove(del); } } }
public void Generate(IList <VERTEX> input, bool assignIds = true, bool checkInput = false) { Clear(); Buffer = new ObjectBuffer <VERTEX>(Dimension); int inputCount = input.Count; if (inputCount < Dimension + 1) { return; } Buffer.AddInput(input, assignIds, checkInput); InitConvexHull(); // Expand the convex hull and faces. while (Buffer.UnprocessedFaces.First != null) { SimplexWrap <VERTEX> currentFace = Buffer.UnprocessedFaces.First; Buffer.CurrentVertex = currentFace.FurthestVertex; UpdateCenter(); // The affected faces get tagged TagAffectedFaces(currentFace); // Create the cone from the currentVertex and the affected faces horizon. if (!Buffer.SingularVertices.Contains(Buffer.CurrentVertex) && CreateCone()) { CommitCone(); } else { HandleSingular(); } // Need to reset the tags int count = Buffer.AffectedFaceBuffer.Count; for (int i = 0; i < count; i++) { Buffer.AffectedFaceBuffer[i].Tag = 0; } } for (int i = 0; i < Buffer.ConvexSimplexs.Count; i++) { SimplexWrap <VERTEX> wrap = Buffer.ConvexSimplexs[i]; wrap.Tag = i; Simplexs.Add(new Simplex <VERTEX>(Dimension)); } for (int i = 0; i < Buffer.ConvexSimplexs.Count; i++) { SimplexWrap <VERTEX> wrap = Buffer.ConvexSimplexs[i]; Simplex <VERTEX> simplex = Simplexs[i]; simplex.IsNormalFlipped = wrap.IsNormalFlipped; simplex.Offset = wrap.Offset; for (int j = 0; j < Dimension; j++) { simplex.Normal[j] = wrap.Normal[j]; simplex.Vertices[j] = wrap.Vertices[j]; if (wrap.AdjacentFaces[j] != null) { simplex.Adjacent[j] = Simplexs[wrap.AdjacentFaces[j].Tag]; } else { simplex.Adjacent[j] = null; } } simplex.CalculateCentroid(); } Buffer.Clear(); Buffer = null; }