public override void Draw(Graphics3D graphics, Transform3D transform) { if (null == Solution) { return; } // draw pallet if (Solution.Analysis.Containers.First() is PalletProperties palletProperties) { Pallet p = new Pallet(palletProperties); p.Draw(graphics, transform); } TruckProperties truckProperties = Solution.Analysis.Containers.First() as TruckProperties; if (null != truckProperties) { Truck t = new Truck(truckProperties); t.DrawBegin(graphics); } // check validity if (!(SolItemIndex < Solution.SolItemCount)) { return; } // get list of boxes List <Box> boxes = new List <Box>(); HSolItem solItem = Solution.SolItem(SolItemIndex); uint pickId = 0; foreach (HSolElement solElt in solItem.ContainedElements) { if (Analysis.ContentTypeByIndex(solElt.ContentType) is BoxProperties bProperties) { boxes.Add(new Box(pickId++, bProperties, solElt.Position)); } } // draw boxes as triangles using BSPTree BSPTree bspTree = new BSPTree(); foreach (Box b in boxes) { bspTree.InsertBox(b); } bspTree.Draw(graphics); // draw truck end if (null != truckProperties) { Truck t = new Truck(truckProperties); t.DrawEnd(graphics); } // ### dimensions if (graphics.ShowDimensions) { graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol1), Color.Black, false)); graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol2), Color.Red, true)); } // ### }
public void Draw(Graphics3D graphics, IEnumerable <BoxExplicitDir> boxes, bool selected, bool showOuterDimensions) { graphics.BackgroundColor = selected ? Color.LightBlue : Color.White; graphics.CameraPosition = Graphics3D.Corner_0; // draw case (inside) Case crate = new Case(0, Dimensions, Dimensions, CrateColor); crate.DrawInside(graphics, Transform3D.Identity); var tree = new BSPTree(); foreach (var box in boxes) { tree.InsertBox(box); } tree.Draw(graphics); crate.DrawEnd(graphics); if (showOuterDimensions) { graphics.AddDimensions(new DimensionCube(Dimensions)); } graphics.Flush(); }