public Tabs(LineStrip boundary, float toolRadius, bool inside = false) { originalBoundary = new Slice(new LineStrip[] { boundary }, new Plane(Vector3.UnitZ, Vector3.Zero)); float offset = toolRadius; if (inside) { offset = -offset; } Slice slice = new Slice(originalBoundary); slice.Offset(offset); this.boundary = slice.GetLines(Slice.LineType.Outside).First(s => true); this.toolRadius = toolRadius; float length = this.boundary.Length(LineStrip.Type.Closed); int numTabs = (int)(length / desiredSpacing); if (numTabs < minTabs) { numTabs = 0; } float tabSpacing = length / numTabs; tabLocations = new List<Vector3>(); foreach (var point in this.boundary.PointsAlongLine(tabSpacing, tabSpacing / 2.0f)) { tabLocations.Add(point); } }
public void GenerateTabPaths(float toolRadius) { tabs.Clear(); try { Slice s = new Slice(this, new Plane(Vector3.UnitZ, new Vector3(0, 0, MinPoint.Z + 0.002f))); foreach (var line in s.GetLines(Slice.LineType.Outside)) { tabs.Add(new TabsGUI(line, toolRadius, false)); } foreach (var line in s.GetLines(Slice.LineType.Hole)) { tabs.Add(new TabsGUI(line, toolRadius, true)); } } catch (Exception) { } this.Offset = offset; // Force the offset update in the tabs }