//tries to subtract the other slice from this slice //returns null if this subtraction can be integrated into this slice //returns another slice if the subtraction would break this slice in two public Slice Subtract(Slice other) { if (other.Contains(GetVector(extent)) && other.Contains(GetVector(-extent))) { //our slice is entirely within the other slice, delete us! extent = 0; return(null); } if (Contains(other.GetVector(other.extent)) && Contains(-other.GetVector(other.extent))) { //we entirely contain the other slice, so we're getting cut in half! } }
public void TestContainsReturnsFalseWhenEqualItemNotInSlice() { var list = new[] { 0, 1, 2, 3, 4 }; var slice = new Slice <int>(list, 2, 2); var actual = slice.Contains(0); Assert.IsFalse(actual); }
private void AddRoutPoint(Slice currentPolygon, Vector3 newPoint, bool check = true) { if (routs.Count == 0) { routs.Add(new LineStrip()); } LineStrip currentRout = routs[routs.Count - 1]; if (check) { if (currentRout.Vertices.Count > 0) { Slice larger = new Slice(currentPolygon); larger.Offset(toolRadius * 1.05f); Vector3 lastPoint = currentRout.Vertices[currentRout.Vertices.Count - 1]; LineStrip path = new LineStrip(); path.Append(lastPoint); path.Append(newPoint); Slice test = new Slice(path, toolRadius * 2.0f, currentPolygon.Plane); if (!larger.Contains(test)) { // Can't move at this level - need to go to the save Z move height. currentRout = new LineStrip(); routs.Add(currentRout); //DrawSlice(Color.Black, Color.Red, test); } else { //DrawSlice(Color.Black, Color.Green, test); } //larger.Subtract(test); //GL.Translate(0, 0, 100); } } // If the Z height changed, move to the new position and and drop, or rise and then move. if (currentRout.Vertices.Count > 0) { var lastPoint = currentRout.Vertices[currentRout.Vertices.Count - 1]; if (newPoint.Z < lastPoint.Z) { currentRout.Vertices.Add(new Vector3(newPoint.X, newPoint.Y, lastPoint.Z)); } else if (newPoint.Z > lastPoint.Z) { currentRout.Vertices.Add(new Vector3(lastPoint.X, lastPoint.Y, newPoint.Z)); } } currentRout.Vertices.Add(newPoint); }
public bool Contains(Slice p) { return(topPolygon.Contains(p)); }