public void Build(ToolpathSet toolpaths, Interval1d zrange, double cellSize = 2.0) { segments = new DVector <Segment2d>(); grid = new SegmentHashGrid2d <int>(cellSize, -1); Action <LinearToolpath3 <PrintVertex> > processPathF = (polyPath) => { if (polyPath.Type != ToolpathTypes.Deposition || polyPath.IsPlanar == false) { return; } if ((polyPath.TypeModifiers & FillTypeFlags.OutermostShell) == 0) { return; } Vector3d v0 = polyPath.Start.Position; Vector3d v1 = polyPath.End.Position; if (zrange.Contains(v0.z) == false || zrange.Contains(v1.z) == false) { return; } append_path(polyPath, cellSize); }; process_linear_paths(toolpaths, processPathF); }
public List <PolyLine2d> GetPolylinesForLayer(int layer) { ToolpathSet pathSetIn = Paths; SKColor extrudeColor = SkiaUtil.Color(0, 0, 0, 255); Interval1d layer_zrange = Layers.GetLayerZInterval(layer); List <PolyLine2d> polylines = new List <PolyLine2d>(); Action <LinearToolpath3 <PrintVertex> > drawPath3F = (polyPath) => { Vector3d v0 = polyPath.Start.Position; if (layer_zrange.Contains(v0.z) == false) { return; } if (polyPath.Type != ToolpathTypes.Deposition) { return; } PolyLine2d pline = new PolyLine2d(); for (int i = 0; i < polyPath.VertexCount; ++i) { pline.AppendVertex(polyPath[i].Position.xy); } polylines.Add(pline); }; ProcessLinearPaths(pathSetIn, drawPath3F); return(polylines); }
public override bool CheckVisibility(ref Frame3f curFrameW, ref Vector3d eyePosW) { Vector3d axis = curFrameW.GetAxis(nTranslationAxis); Vector3d eyevec = (eyePosW - curFrameW.Origin).Normalized; double dot = axis.Dot(eyevec); return(CosVisibilityRange.Contains(dot)); }
void compute_toolpath_polylines() { Func <Vector3d, byte> LayerFilterF = (v) => { return(255); }; Vector3d origin = BedOrigin; Interval1d zrange = ZInterval; double width = Settings.Machine.NozzleDiamMM; float extrude_width = (float)width / 2; float travel_width = (float)width / 3; Polylines.Clear(); // should already be empty, no? Action <LinearToolpath3 <PrintVertex> > drawPath3F = (polyPath) => { Vector3d v0 = polyPath.Start.Position; // LAYER FILTER if (zrange.Contains(v0.z) == false) { return; } byte layer_alpha = LayerFilterF(v0); if (layer_alpha == 0) { return; } bool is_below = (layer_alpha < 255); fMaterial mat = CCMaterials.PathMaterial_Default; float w = 0.1f; if (polyPath.Type == ToolpathTypes.Deposition) { if ((polyPath.TypeModifiers & FillTypeFlags.SupportMaterial) != 0) { mat = CCMaterials.PathMaterial_Support; } else { mat = CCMaterials.PathMaterial_Extrude; } w = extrude_width; } else if (polyPath.Type == ToolpathTypes.Travel) { mat = CCMaterials.PathMaterial_Travel; w = travel_width; } else if (polyPath.Type == ToolpathTypes.PlaneChange) { mat = CCMaterials.PathMaterial_PlaneChange; w = travel_width; } else { // } // todo layer alpha... //paint.Color = SkiaUtil.Color(paint.Color, layer_alpha); if (is_below) { w *= 6; } fPolylineGameObject path = make_path(polyPath, mat, w, origin); Polylines.Add(path); }; process_linear_paths(Toolpaths, drawPath3F); foreach (fPolylineGameObject go in Polylines) { AppendNewGO(go, parentGO, false); go.SetLayer(FPlatform.WidgetOverlayLayer); } }