コード例 #1
0
        private Bitmap GetBoxBitmapFromDesc(PalletSolutionDesc desc)
        {
            bool showDimensions = false;

            // load document
            Document document = new Document(desc.FullFilePath, null);

            if (document.Analyses.Count != 1)
            {
                throw new Exception("Failed to load analysis.");
            }
            // get analysis and solution
            CasePalletAnalysis analysis = document.Analyses[0];
            Graphics3DImage    graphics = new Graphics3DImage(new Size(50, 50));

            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target         = Vector3D.Zero;
            Box box = new Box(0, analysis.BProperties);

            graphics.AddBox(box);
            if (showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
            }
            graphics.Flush();
            return(graphics.Bitmap);
        }
コード例 #2
0
        private void Draw()
        {
            try
            {
                // get current descriptor
                PalletSolutionDesc desc = CurrentSolutionDesc;
                // sanity check
                if (null == desc ||
                    pictureBoxCase.Size.Width < 1 || pictureBoxCase.Size.Height < 1 ||
                    pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1)
                {
                    return;
                }

                // load document
                Document document = new Document(desc.FullFilePath, null);
                if (!document.AnalysesCasePallet.Any())
                {
                    return;
                }
                // get analysis and solution
                CasePalletAnalysis analysis = document.AnalysesCasePallet.First() as CasePalletAnalysis;
                {
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxCase.Size)
                    {
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    Box box = new Box(0, analysis.BProperties);
                    graphics.AddBox(box);
                    graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
                    graphics.Flush();
                    pictureBoxCase.Image = graphics.Bitmap;
                }

                {
                    // instantiate graphics
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size)
                    {
                        // set camera position
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    // instantiate solution viewer
                    CasePalletSolutionViewer sv = new CasePalletSolutionViewer(analysis.Solutions[0]);
                    sv.Draw(graphics);
                    graphics.Flush();
                    // show generated bitmap on picture box control
                    pictureBoxSolution.Image = graphics.Bitmap;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #3
0
        private void ProcessViewItem(viewItem vItem)
        {
            Graphics3DImage graphics = InitializeImageFromViewParameters(vItem.viewParameters);
            // load case
            BoxProperties bProperties = LoadCaseById(null, _root.data.items.library_cases, vItem.itemId);

            if (null != bProperties)
            {
                graphics.AddBox(new Box(0, bProperties));
                if (vItem.viewParameters.showDimensions)
                {
                    graphics.AddDimensions(new DimensionCube(bProperties.Length, bProperties.Width, bProperties.Height));
                }
            }
            // load pallet
            PalletProperties palletProperties = LoadPalletById(null, _root.data.items.library_pallets, vItem.itemId);

            if (null != palletProperties)
            {
                Pallet pallet = new Pallet(palletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
                if (vItem.viewParameters.showDimensions)
                {
                    graphics.AddDimensions(new DimensionCube(palletProperties.Length, palletProperties.Width, palletProperties.Height));
                }
            }
            // load interlayer
            InterlayerProperties interlayerProperties = LoadInterlayerById(null, _root.data.items.library_interlayers, vItem.itemId);

            if (null != interlayerProperties)
            {
                graphics.AddBox(new Box(0, interlayerProperties));
                if (vItem.viewParameters.showDimensions)
                {
                    graphics.AddDimensions(new DimensionCube(interlayerProperties.Length, interlayerProperties.Width, interlayerProperties.Thickness));
                }
            }
            // load bundle
            BundleProperties bundleProperties = LoadBundleById(null, _root.data.items.library_bundles, vItem.itemId);

            if (null != bundleProperties)
            {
                graphics.AddBox(new Box(0, bundleProperties));
                if (vItem.viewParameters.showDimensions)
                {
                    graphics.AddDimensions(new DimensionCube(bundleProperties.Length, bundleProperties.Width, bundleProperties.Height));
                }
            }
            // load truck
            TruckProperties truckProperties = null;

            if (null != truckProperties)
            {
                Truck truck = new Truck(truckProperties);
                truck.Draw(graphics);
                if (vItem.viewParameters.showDimensions)
                {
                    graphics.AddDimensions(new DimensionCube(truckProperties.Length, truckProperties.Width, truckProperties.Height));
                }
            }

            FinalizeImageFromViewParameters(vItem.viewParameters, graphics);
        }