public void AddSample(Vector3 position, int index) { if (SamplesList.Count == 0) { SamplesList.Add(new BSPoint(position)); Sorted2Indices.Add(index); } if (SamplesList.Find((a) => { return(a.Position == position); }) == null) { SamplesList.Add(new BSPoint(position)); Sorted2Indices.Add(index); } }
void Sort() { List <BSIndexPoint> sortedPoints = new List <BSIndexPoint>(); for (int i = 0; i < SamplesList.Count; ++i) { sortedPoints.Add(new BSIndexPoint(SamplesList[i], Sorted2Indices[i])); } sortedPoints.Sort((A, B) => { if (A.Point.Position.X == B.Point.Position.X) // same, then compare Y { if (A.Point.Position.Y == B.Point.Position.Y) { return(A.Point.Position.Z < B.Point.Position.Z ? 1 : -1); } else { return(A.Point.Position.Y < B.Point.Position.Y ? 1 : -1); } } return(A.Point.Position.X < B.Point.Position.X ? 1 : -1); }); Sorted2Indices.Clear(); for (int i = 0; i < SamplesList.Count; ++i) { Sorted2Indices.Add(-1); } for (int sampleIndex = 0; sampleIndex < SamplesList.Count; ++sampleIndex) { SamplesList[sampleIndex] = sortedPoints[sampleIndex].Point; Sorted2Indices[sampleIndex] = sortedPoints[sampleIndex].OriginalIndex; } }
public void Reset() { ClearTriangles(); ClearSamples(); Sorted2Indices.Clear(); }