Ejemplo n.º 1
0
        public void Draw(Graphics3D graphics)
        {
            if (null == _caseDefinition || null == _boxProperties)
                return;

            // get global transformation
            Transform3D transf = _globalOrientation.Transformation;

            // draw case (back faces)
            Case case_ = _caseProperties != null ? new Case(_caseProperties, transf) : null;
            if (null != case_)
            {
                // draw case (inside)
                case_.DrawInside(graphics);
            }
            // add boxes
            uint pickId = 0;
            for (int i=0; i<_caseDefinition.Arrangement._iLength; ++i)
                for (int j=0; j<_caseDefinition.Arrangement._iWidth; ++j)
                    for (int k = 0; k < _caseDefinition.Arrangement._iHeight; ++k)
                        graphics.AddBox( new Box(pickId++, _boxProperties, GetPosition(i, j, k, _caseDefinition.Dim0, _caseDefinition.Dim1) ) );
            if (_showDimentions)
            {
                // add external dimensions
                Vector3D outerDimensions = _caseDefinition.OuterDimensions(_boxProperties, _caseOptimConstraintSet);
                graphics.AddDimensions(DimensionCube.Transform(new DimensionCube(Vector3D.Zero, outerDimensions.X, outerDimensions.Y, outerDimensions.Z, Color.Black, true), transf));
                // add inner dimensions
                Vector3D innerOffset = _caseDefinition.InnerOffset(_caseOptimConstraintSet);
                Vector3D innerDimensions = _caseDefinition.InnerDimensions(_boxProperties);
                graphics.AddDimensions(DimensionCube.Transform(new DimensionCube(innerOffset, innerDimensions.X, innerDimensions.Y, innerDimensions.Z, Color.Red, false), transf));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draw layers
        /// Images are used during report generation
        /// </summary>
        public void DrawLayers(Graphics3D graphics, bool showPallet, int layerIndex)
        {
            if (null == _caseSolution)
            {
                throw new Exception("No solution defined!");
            }
            BoxCasePalletAnalysis caseAnalysis = _caseSolution.ParentCaseAnalysis;

            // draw solution
            uint pickId = 0;
            int  iLayer = 0, iLayerCount = 0;

            while (iLayerCount <= layerIndex && iLayer < _caseSolution.Count)
            {
                ILayer     layer  = _caseSolution[iLayer];
                Layer3DBox blayer = layer as Layer3DBox;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.AddBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                    }
                    ++iLayerCount;
                }
                ++iLayer;
            }
        }
Ejemplo n.º 3
0
 public override void Draw(Graphics3D graphics)
 {
     foreach (Face face in Faces)
     {
         graphics.AddFace(face);
     }
 }
Ejemplo n.º 4
0
        public override void DrawEnd(Graphics3D graphics)
        {
            Vector3D viewDir = graphics.ViewDirection;
            int[] seg0=null, seg1= null, seg2=null;

            if (viewDir.X < 0.0 && viewDir.Y >= 0.0)
            {
                seg0 = new int[2] { 4, 5 };
                seg1 = new int[2] { 5, 6 };
                seg2 = new int[2] { 1, 5 };
            }
            else if (viewDir.X < 0.0 && viewDir.Y < 0.0)
            {
                seg0 = new int[2] { 5, 6 };
                seg1 = new int[2] { 6, 7 };
                seg2 = new int[2] { 2, 6 };
            }
            else if (viewDir.X >= 0.0 && viewDir.Y < 0.0)
            {
                seg0 = new int[2] { 6, 7 };
                seg1 = new int[2] { 7, 4 };
                seg2 = new int[2] { 3, 7 };
            }
            else if (viewDir.X >= 0.0 && viewDir.Y >= 0.0)
            {
                seg0 = new int[2] { 7, 4 };
                seg1 = new int[2] { 4, 5 };
                seg2 = new int[2] { 0, 4 };
            }
            graphics.AddSegment(new Segment(Points[seg0[0]], Points[seg0[1]], _colorPath) );
            graphics.AddSegment(new Segment(Points[seg1[0]], Points[seg1[1]], _colorPath));
            graphics.AddSegment(new Segment(Points[seg2[0]], Points[seg2[1]], _colorPath));
        }
Ejemplo n.º 5
0
        public override void Draw(Graphics3D graphics)
        {
            var g       = graphics.Graphics;
            var viewDir = graphics.ViewDirection;

            Face[] faces = Faces;
            for (int i = 0; i < 4; ++i)
            {
                // visible ?
                if (!faces[i].IsVisible(viewDir))
                {
                    continue;
                }
                // color
                faces[i].ColorFill = ColorFill;
                // points
                Vector3D[] points3D = faces[i].Points;
                Point[]    pt       = graphics.TransformPoint(points3D);
                //  draw solid face
                Brush brush = new SolidBrush(faces[i].ColorGraph(graphics));
                g.FillPolygon(brush, pt);
                // draw path
                Brush brushPath    = new SolidBrush(faces[i].ColorPath);
                Pen   penPathThick = new Pen(brushPath, 1.5f);
                int   ptCount      = pt.Length;
                for (int j = 1; j < ptCount; ++j)
                {
                    g.DrawLine(penPathThick, pt[j - 1], pt[j]);
                }
                g.DrawLine(penPathThick, pt[ptCount - 1], pt[0]);
            }
        }
Ejemplo n.º 6
0
        public override void Draw(Graphics3D graphics, Transform3D transform)
        {
            AnalysisPalletsOnPallet analysis = Solution.Analysis;

            // ### draw pallet
            Pallet pallet = new Pallet(analysis.PalletProperties);
        }
Ejemplo n.º 7
0
        void OnButtonPressed(int iIndex)
        {
            Graphics3D.Reset();
            switch (iIndex)
            {
            case 0: AngleHoriz = 0.0; AngleVert = 0.0; break;

            case 1: AngleHoriz = 90.0; AngleVert = 0.0; break;

            case 2: AngleHoriz = 180.0; AngleVert = 0.0; break;

            case 3: AngleHoriz = 270.0; AngleVert = 0.0; break;

            case 4: AngleHoriz = 0.0; AngleVert = 90.0; break;

            case 5: AngleHoriz = 45.0 + 0.0; AngleVert = 45.0; break;

            case 6: AngleHoriz = 45.0 + 90.0; AngleVert = 45.0; break;

            case 7: AngleHoriz = 45.0 + 180.0; AngleVert = 45.0; break;

            case 8: AngleHoriz = 45.0 + 270.0; AngleVert = 45.0; break;

            case 9: ShowDimensions = !ShowDimensions; break;

            default: break;
            }
            Invalidate();
        }
Ejemplo n.º 8
0
        public override void DrawEnd(Graphics3D graphics)
        {
            // sanity check
            if (_height <= 1.0E-3)
            {
                return;
            }

            Face[] faces = Faces;
            if (Vector3D.DotProduct(faces[0].Normal, graphics.ViewDirection) <= 0.0)
            {
                for (int i = 0; i < 4; ++i)
                {
                    graphics.AddFace(faces[i]);
                }
            }
            if (Vector3D.DotProduct(faces[4].Normal, graphics.ViewDirection) <= 0.0)
            {
                for (int i = 4; i < 8; ++i)
                {
                    graphics.AddFace(faces[i]);
                }
            }
            if (Math.Abs(Vector3D.DotProduct(faces[0].Normal, graphics.ViewDirection)) < 1.0E-3)
            {
                graphics.AddFace(faces[3]);
            }

            if (Math.Abs(Vector3D.DotProduct(faces[4].Normal, graphics.ViewDirection)) < 1.0E-3)
            {
                graphics.AddFace(faces[7]);
            }
        }
Ejemplo n.º 9
0
 public override void DrawEnd(Graphics3D graphics)
 {
     Face[] faces = Faces;
     for (int i = 0; i < 4; ++i)
     {
         graphics.AddFace(Faces[i]);
     }
 }
Ejemplo n.º 10
0
        public void Draw(Graphics3D graphics)
        {
            ArrowPoints(graphics, out int[] arrow0, out int[] arrow1, out int[] arrow2);

            DrawArrow(arrow0, graphics);
            DrawArrow(arrow1, graphics);
            DrawArrow(arrow2, graphics);
        }
Ejemplo n.º 11
0
        public override void DrawEnd(Graphics3D graphics)
        {
            Vector3D viewDir = graphics.ViewDirection;

            int[] seg0 = null, seg1 = null, seg2 = null;

            if (viewDir.X < 0.0 && viewDir.Y >= 0.0)
            {
                seg0 = new int[2] {
                    4, 5
                };
                seg1 = new int[2] {
                    5, 6
                };
                seg2 = new int[2] {
                    1, 5
                };
            }
            else if (viewDir.X < 0.0 && viewDir.Y < 0.0)
            {
                seg0 = new int[2] {
                    5, 6
                };
                seg1 = new int[2] {
                    6, 7
                };
                seg2 = new int[2] {
                    2, 6
                };
            }
            else if (viewDir.X >= 0.0 && viewDir.Y < 0.0)
            {
                seg0 = new int[2] {
                    6, 7
                };
                seg1 = new int[2] {
                    7, 4
                };
                seg2 = new int[2] {
                    3, 7
                };
            }
            else if (viewDir.X >= 0.0 && viewDir.Y >= 0.0)
            {
                seg0 = new int[2] {
                    7, 4
                };
                seg1 = new int[2] {
                    4, 5
                };
                seg2 = new int[2] {
                    0, 4
                };
            }
            graphics.AddSegment(new Segment(Points[seg0[0]], Points[seg0[1]], ColorPath));
            graphics.AddSegment(new Segment(Points[seg1[0]], Points[seg1[1]], ColorPath));
            graphics.AddSegment(new Segment(Points[seg2[0]], Points[seg2[1]], ColorPath));
        }
Ejemplo n.º 12
0
        private void AddFace(Graphics3D graphics, Vector3D p0, Vector3D p1)
        {
            var pt0 = p0 + 0.5 * Width * Axis;
            var pt1 = p0 - 0.5 * Width * Axis;
            var pt2 = p1 - 0.5 * Width * Axis;
            var pt3 = p1 + 0.5 * Width * Axis;

            graphics.AddFace(new Face(0, new Vector3D[] { pt0, pt1, pt2, pt3 }, Color, Color.Black, "STRAPPER"));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Compute color from set color + angle with light
        /// </summary>
        public Color ColorGraph(Graphics3D graphics, Color color)
        {
            double cosA = Math.Abs(Vector3D.DotProduct(Normal, graphics.VLight));

            if (cosA < 0 || cosA > 1)
            {
                cosA = 1.0;
            }
            return(Color.FromArgb((int)(color.R * cosA), (int)(color.G * cosA), (int)(color.B * cosA)));
        }
Ejemplo n.º 14
0
        public override void Draw(Graphics3D graphics, Transform3D transform)
        {
            Pallet pallet = new Pallet(_palletProperties);

            pallet.Draw(graphics, transform);
            if (graphics.ShowDimensions)
            {
                graphics.AddDimensions(new DimensionCube(_palletProperties.Dimensions));
            }
        }
        /// <summary>
        /// Use this method when drawing a solution that belongs an analysis
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _solution)
            {
                return;
            }
            // initialize Graphics3D object
            if (!graphics.ShowBoxIds)
            {
                // draw pallet
                Pallet pallet = new Pallet(_analysis.PalletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
            }
            // draw solution
            uint pickId = 0;

            foreach (ILayer layer in _solution)
            {
                CylinderLayer cylLayer = layer as CylinderLayer;
                if (null != cylLayer)
                {
                    foreach (Vector3D pos in cylLayer)
                    {
                        graphics.AddCylinder(
                            new Cylinder(pickId++, _analysis.CylinderProperties, new CylPosition(pos, HalfAxis.HAxis.AXIS_Z_P))
                            );
                    }
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos)
                {
                    Box box = new Box(pickId++, _analysis.InterlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (_analysis.PalletProperties.Length - _analysis.InterlayerProperties.Length)
                        , 0.5 * (_analysis.PalletProperties.Width - _analysis.InterlayerProperties.Width)
                        , interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }
            if (_showDimensions)
            {
                if (_showDimensions)
                {
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                                          , Color.Black, false));
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                                          , Color.Red, true));
                }
            }
        }
Ejemplo n.º 16
0
        public void Draw(Graphics3D graphics)
        {
            int[] arrow0 = null;
            int[] arrow1 = null;
            int[] arrow2 = null;
            ArrowPoints(graphics, out arrow0, out arrow1, out arrow2);

            DrawArrow(arrow0, graphics);
            DrawArrow(arrow1, graphics);
            DrawArrow(arrow2, graphics);
        }
Ejemplo n.º 17
0
        public override void DrawEnd(Graphics3D graphics)
        {
            Vector3D ptPrev = HullPoints[0];

            for (int i = 1; i < HullPoints.Count; ++i)
            {
                AddFace(graphics, ptPrev, HullPoints[i]);
                ptPrev = HullPoints[i];
            }
            AddFace(graphics, ptPrev, HullPoints[0]);
        }
Ejemplo n.º 18
0
        public void Draw(Graphics3D graphics)
        {
            int[] arrow0 = null;
            int[] arrow1 = null;
            int[] arrow2 = null;
            ArrowPoints(graphics, out arrow0, out arrow1, out arrow2);

            DrawArrow(arrow0, graphics);
            DrawArrow(arrow1, graphics);
            DrawArrow(arrow2, graphics);
        }
Ejemplo n.º 19
0
 public void DrawInside(Graphics3D graphics)
 {
     Face[] faces = Faces;
     for (int i = 0; i < 6; ++i)
     {
         faces[i].IsSolid = false;
     }
     foreach (Face face in faces)
     {
         graphics.AddFace(face);
     }
 }
Ejemplo n.º 20
0
 public void DrawInside(Graphics3D graphics, Transform3D transform)
 {
     Face[] faces = InsideFaces;
     for (int i = 0; i < 6; ++i)
     {
         faces[i].IsSolid = false;
     }
     foreach (Face face in faces)
     {
         graphics.AddFace(face.Transform(transform));
     }
 }
Ejemplo n.º 21
0
        public override void Draw(Graphics3D graphics, Transform3D transform)
        {
            if (null == Solution)
            {
                return;
            }
            // draw pallet
            PalletProperties palletProperties = Solution.Analysis.Containers.First() as PalletProperties;
            Pallet           p = new Pallet(palletProperties);

            p.Draw(graphics, transform);

            // 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)
                {
                    Box b = new Box(pickId++, bProperties)
                    {
                        Position    = solElt.Position.Position,
                        HLengthAxis = solElt.Position.DirectionLength,
                        HWidthAxis  = solElt.Position.DirectionWidth
                    };
                    boxes.Add(b);
                }
            }
            // draw boxes as triangles using BSPTree
            BSPTree bspTree = new BSPTree();

            foreach (Box b in boxes)
            {
                bspTree.InsertBox(b);
            }
            bspTree.Draw(graphics);

            // ### dimensions
            if (graphics.ShowDimensions)
            {
                graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol1), Color.Black, false));
                graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol2), Color.Red, true));
            }
            // ###
        }
Ejemplo n.º 22
0
        public static void DrawILayer(Graphics3D graphics, ILayer layer, Packable packable, bool showDimensions)
        {
            bool show3D = Properties.Settings.Default.LayerView3D;

            graphics.CameraPosition = show3D ? Graphics3D.Corner_0 : Graphics3D.Top;

            uint   pickId = 0;
            BBox3D bbox   = new BBox3D();

            // ### layer of boxes ###
            if (layer is Layer3DBox layerBox)
            {
                foreach (BoxPosition bPosition in layerBox)
                {
                    Box b = null;
                    if (packable is PackProperties)
                    {
                        b = new Pack(pickId++, packable as PackProperties, bPosition);
                    }
                    else
                    {
                        b = new Box(pickId++, packable as PackableBrick, bPosition);
                    }
                    graphics.AddBox(b);
                    bbox.Extend(b.BBox);
                }
            }
            // ###
            // ### layer of cylinders ###
            if (layer is Layer3DCyl layerCyl)
            {
                foreach (Vector3D vPos in layerCyl)
                {
                    Cyl cyl = null;
                    if (packable is CylinderProperties cylinderProp)
                    {
                        cyl = new Cylinder(pickId++, cylinderProp, new CylPosition(vPos, HalfAxis.HAxis.AXIS_Z_P));
                    }
                    else if (packable is BottleProperties bottleProp)
                    {
                        cyl = new Bottle(pickId++, bottleProp, new CylPosition(vPos, HalfAxis.HAxis.AXIS_Z_P));
                    }
                    graphics.AddCylinder(cyl);
                    bbox.Extend(cyl.BBox);
                }
            }
            // ###
            if (showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(bbox, Color.Black, false));
            }
        }
        /// <summary>
        /// Use this method when drawing a solution that belongs an analysis
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _solution)
                return;
            // initialize Graphics3D object
            if (!graphics.ShowBoxIds)
            {
                // draw pallet
                Pallet pallet = new Pallet(_analysis.PalletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
            }
            // draw solution
            uint pickId = 0;
            foreach (ILayer layer in _solution)
            {
                CylinderLayer cylLayer = layer as CylinderLayer;
                if (null != cylLayer)
                {
                    foreach (Vector3D pos in cylLayer)
                        graphics.AddCylinder(
                            new Cylinder(pickId++, _analysis.CylinderProperties, new CylPosition(pos, HalfAxis.HAxis.AXIS_Z_P))
                            );
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos)
                {
                    Box box = new Box(pickId++, _analysis.InterlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (_analysis.PalletProperties.Length - _analysis.InterlayerProperties.Length)
                        , 0.5 * (_analysis.PalletProperties.Width - _analysis.InterlayerProperties.Width)
                        , interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }
            if (_showDimensions)
            {
                if (_showDimensions)
                {
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                        , Color.Black, false));
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                        , Color.Red, true));
                }
            }
        }
Ejemplo n.º 24
0
        public void Draw(Graphics3D g)
        {
            if (null == Root)
            {
                return;
            }
            List <Triangle> triangles = new List <Triangle>();

            Draw(Root, g.CameraPosition, ref triangles);
            foreach (var tr in triangles)
            {
                g.AddTriangle(tr);
            }
        }
Ejemplo n.º 25
0
        public void Draw(Graphics3D g)
        {
            if (null == Root)
            {
                return;
            }
            List <Face> faces = new List <Face>();

            Draw(Root, g.CameraPosition, ref faces);
            foreach (Face f in faces)
            {
                g.Draw(f, Graphics3D.FaceDir.FRONT);
            }
        }
Ejemplo n.º 26
0
        public void Draw(Graphics3D graphics)
        {
            // sanity check
            if (null == _solution)
            {
                return;
            }
            InterlayerProperties interlayerProperties = _analysis.InterlayerProperties;
            // draw pallet
            Pallet pallet = new Pallet(_analysis.PalletProperties);

            pallet.Draw(graphics, Transform3D.Identity);
            // draw solution
            uint pickid = 0;

            for (int iLayerIndex = 0; iLayerIndex < _solution.LayerCount; ++iLayerIndex)
            {
                bool     hasInterlayer = false;
                double   zInterlayer   = 0.0;
                BoxLayer blayer        = _solution.GetBoxLayer(iLayerIndex, ref hasInterlayer, ref zInterlayer);

                if (hasInterlayer && (null != interlayerProperties))
                {
                    // instantiate box
                    Box box = new Box(pickid++, interlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (_analysis.PalletProperties.Length - interlayerProperties.Length)
                        , 0.5 * (_analysis.PalletProperties.Width - interlayerProperties.Width)
                        , zInterlayer);
                    // draw
                    graphics.AddBox(box);
                }
                foreach (BoxPosition bPosition in blayer)
                {
                    graphics.AddBox(new Pack(pickid++, _analysis.PackProperties, bPosition));
                }

                if (_showDimensions)
                {
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                                          , Color.Black, false));
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                                          , Color.Red, true));
                }
            }
        }
Ejemplo n.º 27
0
 public void Draw(Graphics3D graphics, IEnumerable <Box> boxes, bool selected, bool annotate)
 {
     graphics.BackgroundColor = selected ? Color.LightBlue : Color.White;
     graphics.CameraPosition  = Graphics3D.Corner_0;
     // draw boxes
     foreach (var box in boxes)
     {
         graphics.AddBox(box);
     }
     graphics.Flush();
     if (annotate)
     {
         Annotate(graphics.Graphics, graphics.Size);
     }
 }
Ejemplo n.º 28
0
        public Vector3D[] DrawingPoints(Graphics3D graphics)
        {
            ArrowPoints(graphics, out int[] arrow0, out int[] arrow1, out int[] arrow2);

            const double exageration = 1.2;

            Vector3D[] pts = new Vector3D[6];
            pts[0] = _pts[arrow0[0]] + (_pts[arrow0[0]] - _pts[arrow0[2]]) * offsetPerc * exageration;
            pts[1] = _pts[arrow0[1]] + (_pts[arrow0[1]] - _pts[arrow0[3]]) * offsetPerc * exageration;
            pts[2] = _pts[arrow1[0]] + (_pts[arrow1[0]] - _pts[arrow1[2]]) * offsetPerc * exageration;
            pts[3] = _pts[arrow1[1]] + (_pts[arrow1[1]] - _pts[arrow1[3]]) * offsetPerc * exageration;
            pts[4] = _pts[arrow2[0]] + (_pts[arrow2[0]] - _pts[arrow2[2]]) * offsetPerc * exageration;
            pts[5] = _pts[arrow2[1]] + (_pts[arrow2[1]] - _pts[arrow2[3]]) * offsetPerc * exageration;
            return(pts);
        }
Ejemplo n.º 29
0
        public override void Draw(Graphics3D graphics)
        {
            System.Drawing.Graphics g = graphics.Graphics;
            Vector3D viewDir          = graphics.ViewDirection;

            // build pen path
            Brush brushPath = new SolidBrush(ColorPath);
            Pen   penPath   = new Pen(brushPath, 1.7f);

            // bottom, top
            Point[] ptsBottom = graphics.TransformPoint(GetBottomPoints());
            Point[] ptsTop    = graphics.TransformPoint(GetTopPoints());

            // outer wall
            Face[] facesWalls = GetFaceWalls();
            foreach (Face face in facesWalls)
            {
                try
                {
                    var normal = face.Normal;
                    // visible ?
                    if (!face.IsVisible(viewDir))
                    {
                        continue;
                    }
                    // draw polygon
                    Point[] ptsFace = graphics.TransformPoint(face.Points);
                    g.FillPolygon(new SolidBrush(face.ColorGraph(graphics)), ptsFace);
                }
                catch (Exception /*ex*/)
                {
                }
            }
            // top
            double cosTop     = Math.Abs(Vector3D.DotProduct(HalfAxis.ToVector3D(Position.Direction), graphics.VLight));
            Color  colorTop   = Color.FromArgb((int)(Color.R * cosTop), (int)(Color.G * cosTop), (int)(Color.B * cosTop));
            Brush  brushTop   = new SolidBrush(colorTop);
            bool   topVisible = Vector3D.DotProduct(HalfAxis.ToVector3D(Position.Direction), viewDir) < 0;

            if (topVisible)
            {
                g.FillPolygon(brushTop, ptsTop);
            }
            else
            {
                g.FillPolygon(brushTop, ptsBottom);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _boxCaseSolution)
            {
                throw new Exception("No box/case solution defined!");
            }

            BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
            // retrieve case properties
            BProperties boxProperties = boxCaseAnalysis.BProperties;

            if (null == boxProperties)
            {
                return;
            }
            BoxProperties caseProperties = boxCaseAnalysis.CaseProperties;
            // draw case (inside)
            Case case_ = new Case(caseProperties);

            case_.DrawInside(graphics, Transform3D.Identity);
            // draw solution
            uint pickId = 0;

            foreach (ILayer layer in _boxCaseSolution)
            {
                Layer3DBox blayer = layer as Layer3DBox;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                    }
                }
            }
            // get case analysis
            if (_showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(
                                           Vector3D.Zero
                                           , caseProperties.Length, caseProperties.Width, caseProperties.Height
                                           , System.Drawing.Color.Black
                                           , true));
                graphics.AddDimensions(new DimensionCube(
                                           _boxCaseSolution.LoadBoundingBox
                                           , System.Drawing.Color.Red
                                           , false));
            }
        }
        /// <summary>
        /// Draw case solution
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _caseSolution)
                throw new Exception("No case solution defined!");

            // load pallet solution
            BoxProperties caseProperties;

            CasePalletSolution palletSolution = _caseSolution.PalletSolutionDesc.LoadPalletSolution();
            if (null == palletSolution)
                caseProperties = new BoxProperties(null, _caseSolution.CaseLength, _caseSolution.CaseWidth, _caseSolution.CaseHeight);
            else
            {
                CasePalletAnalysis palletAnalysis = palletSolution.Analysis;
                // retrieve case properties 
                caseProperties = palletAnalysis.BProperties as BoxProperties;
            }
            if (null == caseProperties) return;
            // draw case (inside)
            Case case_ = new Case(caseProperties);
            case_.DrawInside(graphics);
            // get case analysis
            BoxCasePalletAnalysis caseAnalysis = _caseSolution.ParentCaseAnalysis;
            // draw solution
            uint pickId = 0;
            foreach (ILayer layer in _caseSolution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                        graphics.AddBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos)
                {
                    Box box = new Box(pickId++, caseAnalysis.InterlayerProperties);
                    // set position
                    box.Position = new Vector3D(0.0, 0.0, interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }
            // get case analysis
            if (_showDimensions)
                graphics.AddDimensions(new DimensionCube(_caseSolution.CaseLength, _caseSolution.CaseWidth, _caseSolution.CaseHeight));
        }
Ejemplo n.º 32
0
        public void Draw(Graphics3D graphics, Packable packable, double height, bool selected, bool annotate)
        {
            graphics.BackgroundColor = selected ? Color.LightBlue : Color.White;
            graphics.CameraPosition  = Graphics3D.Corner_0;

            // draw layer (brick)
            if (_layer is Layer2DBrick layer2D)
            {
                uint pickId = 0;
                foreach (var bPosition in layer2D.Positions)
                {
                    if (packable is PackProperties)
                    {
                        graphics.AddBox(new Pack(pickId++, packable as PackProperties, bPosition));
                    }
                    else if (packable is PackableBrick)
                    {
                        graphics.AddBox(new Box(pickId++, packable as PackableBrick, bPosition));
                    }
                }
            }
            // draw layer (cylinder)
            else if (_layer is Layer2DCylImp)
            {
                Layer2DCylImp layer2DCyl = _layer as Layer2DCylImp;
                uint          pickId     = 0;
                foreach (Vector2D pos in layer2DCyl)
                {
                    Cyl cyl = null;
                    if (packable is CylinderProperties cylProperties)
                    {
                        cyl = new Cylinder(pickId++, cylProperties, new CylPosition(new Vector3D(pos.X, pos.Y, 0.0), HalfAxis.HAxis.AXIS_Z_P));
                    }
                    else if (packable is BottleProperties bottleProperties)
                    {
                        cyl = new Bottle(pickId++, bottleProperties, new CylPosition(new Vector3D(pos.X, pos.Y, 0.0), HalfAxis.HAxis.AXIS_Z_P));
                    }
                    graphics.AddCylinder(cyl);
                }
            }
            graphics.Flush();
            // annotate thumbnail
            if (annotate)
            {
                Annotate(graphics.Graphics, graphics.Size, height);
            }
        }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (ctrl == graphCtrlPallet)
     {
         PalletProperties pp = CurrentPallet;
         Pallet pallet = new Pallet(pp);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f };
         graphics.AddDimensions(dc); 
     }
     else if (ctrl == graphCtrlSolution)
     {
         if (null == CurrentSolution) return;
         CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution);
         sv.Draw(graphics);
     }
 }
Ejemplo n.º 34
0
 public override void DrawBegin(Graphics3D graph)
 {
     foreach (FilmRectangle rectangle in _rectangles)
     {
         if (Vector3D.DotProduct(rectangle.Normal, graph.ViewDirection) > 0)
         {
             // hatching
             if (HasHatching)
             {
                 Segment[] segments = rectangle.Segments;
                 foreach (Segment s in segments)
                 {
                     graph.AddSegmentBackgound(s);
                 }
             }
         }
     }
 }
Ejemplo n.º 35
0
 public override void DrawEnd(Graphics3D graphics)
 {
     Face[] faces = Faces;
     if (Vector3D.DotProduct(faces[0].Normal, graphics.ViewDirection) <= 0.0)
     {
         for (int i = 0; i < 4; ++i)
         {
             graphics.AddFace(faces[i]);
         }
     }
     if (Vector3D.DotProduct(faces[4].Normal, graphics.ViewDirection) <= 0.0)
     {
         for (int i = 4; i < 8; ++i)
         {
             graphics.AddFace(faces[i]);
         }
     }
 }
Ejemplo n.º 36
0
        public void Draw(Graphics3D graphics, CylinderProperties cylProperties, double height, bool selected, bool annotate)
        {
            graphics.BackgroundColor = selected ? Color.LightBlue : Color.White;
            graphics.CameraPosition  = Graphics3D.Corner_0;

            uint pickId = 0;

            foreach (var cp in Layout.Positions)
            {
                graphics.AddCylinder(new Cylinder(pickId++, cylProperties, cp));
            }
            graphics.Flush();

            if (annotate)
            {
                Annotate(graphics.Graphics, graphics.Size, height);
            }
        }
        public void Draw(Graphics3D graphics)
        {
            // sanity check
            if (null == _solution) return;
            InterlayerProperties interlayerProperties = _analysis.InterlayerProperties;
            // draw pallet
            Pallet pallet = new Pallet(_analysis.PalletProperties);
            pallet.Draw(graphics, Transform3D.Identity);
            // draw solution
            uint pickid = 0;
            for (int iLayerIndex = 0; iLayerIndex < _solution.LayerCount; ++iLayerIndex)
            {
                bool hasInterlayer = false;
                double zInterlayer = 0.0;
                BoxLayer blayer = _solution.GetBoxLayer(iLayerIndex, ref hasInterlayer, ref zInterlayer);

                if (hasInterlayer && (null != interlayerProperties))
                {
                    // instantiate box
                    Box box = new Box(pickid++, interlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (_analysis.PalletProperties.Length - interlayerProperties.Length)
                        , 0.5 * (_analysis.PalletProperties.Width - interlayerProperties.Width)
                        , zInterlayer);
                    // draw
                    graphics.AddBox(box);
                }
                foreach (BoxPosition bPosition in blayer)
                    graphics.AddBox(new Pack(pickid++, _analysis.PackProperties, bPosition));

                if (_showDimensions)
                {
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                        , Color.Black, false));
                    graphics.AddDimensions(
                        new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                        , Color.Red, true));
                }
            }
        }
Ejemplo n.º 38
0
 public override void Draw(Graphics3D graphics)
 {
     // draw tray back faces
     if (_packProperties.Wrap.Type == PackWrapper.WType.WT_TRAY)
     {}
     // draw inner boxes
     if (_packProperties.Wrap.Type == PackWrapper.WType.WT_POLYETHILENE
         || _packProperties.Wrap.Type == PackWrapper.WType.WT_TRAY
         || _forceTransparency)
     {
         List<Box> boxes = InnerBoxes;
         boxes.Sort( new BoxComparerSimplifiedPainterAlgo(graphics.GetWorldToEyeTransformation()) );
         foreach (Box b in boxes)
             graphics.Draw(b);
     }
     if (_packProperties.Wrap.Type != PackWrapper.WType.WT_TRAY)
     {
         // draw front faces
         foreach (Face f in Faces)
         {
             graphics.Draw(
                 f
                 , Graphics3D.FaceDir.FRONT
                 , _packProperties.Wrap.Color
                 , _packProperties.Wrap.Transparent || _forceTransparency);
         }
     }
     else
     {
         // draw tray front faces
         foreach (Face f in TrayFaces)
         {
             graphics.Draw(
                 f
                 , Graphics3D.FaceDir.FRONT
                 , _packProperties.Wrap.Color
                 , _packProperties.Wrap.Transparent);
         }
     }
 }
Ejemplo n.º 39
0
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _boxCaseSolution)
                throw new Exception("No box/case solution defined!");

            BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
            // retrieve case properties 
            BProperties boxProperties = boxCaseAnalysis.BProperties;
            if (null == boxProperties) return;
            BoxProperties caseProperties = boxCaseAnalysis.CaseProperties;
            // draw case (inside)
            Case case_ = new Case(caseProperties);
            case_.DrawInside(graphics);
            // draw solution
            uint pickId = 0;
            foreach (ILayer layer in _boxCaseSolution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                }
            }
            // get case analysis
            if (_showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(
                    Vector3D.Zero
                    , caseProperties.Length, caseProperties.Width, caseProperties.Height
                    , System.Drawing.Color.Black
                    , true));
                graphics.AddDimensions(new DimensionCube(
                    _boxCaseSolution.LoadBoundingBox
                    , System.Drawing.Color.Red
                    , false));
            }
        }
        /// <summary>
        /// Draw layers
        /// Images are used during report generation
        /// </summary>
        public void DrawLayers(Graphics3D graphics, bool showPallet, int layerIndex)
        {
             if (null == _solution)
                throw new Exception("No solution defined!");

             if (!graphics.ShowBoxIds) // -> if box ids are drawn, we do not draw pallet
             {
                 // draw pallet
                 Pallet pallet = new Pallet(_analysis.PalletProperties);
                 pallet.Draw(graphics, Transform3D.Identity);
             }
            // draw solution
            uint pickId = 0;
            int iLayer = 0, iLayerCount = 0;
            while (iLayerCount <= layerIndex && iLayer < _solution.Count)
            {
                ILayer layer = _solution[iLayer];
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                        graphics.AddBox(new Box(pickId++, _analysis.BProperties, bPosition));
                    ++iLayerCount;
                }
                ++iLayer;
            }
            // flush
            graphics.Flush();
        }
Ejemplo n.º 41
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     // build pack
     PackProperties packProperties = new PackProperties(null, SelectedBox, Arrangement, BoxOrientation, Wrapper);
     if (uCtrlOuterDimensions.Checked)
         packProperties.ForceOuterDimensions(
             new Vector3D(uCtrlOuterDimensions.X, uCtrlOuterDimensions.Y, uCtrlOuterDimensions.Z) );
     Pack pack = new Pack(0, packProperties);
     pack.ForceTransparency = true;
     graphics.AddBox(pack);
     graphics.AddDimensions(new DimensionCube(Vector3D.Zero, pack.Length, pack.Width, pack.Height, Color.Black, true));
     if (packProperties.Wrap.Transparent)
         graphics.AddDimensions(
             new DimensionCube(
                 packProperties.InnerOffset
                 , packProperties.InnerLength, packProperties.InnerWidth, packProperties.InnerHeight
                 , Color.Red, false));
 }
        /// <summary>
        /// Use this method when drawing a solution that belongs an analysis
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _solution)
                return;
            // initialize Graphics3D object
            if (!graphics.ShowBoxIds)
            {
                // draw pallet
                Pallet pallet = new Pallet(_analysis.PalletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
            }
            // load bounding box
            BBox3D loadBBox = _solution.LoadBoundingBox; 
            BBox3D loadBBoxWDeco = _solution.LoadBoundingBoxWDeco;

            #region Pallet film : begin
            // draw film
            Film film = null;
            if (_solution.Analysis.HasPalletFilm)
            {
                PalletFilmProperties palletFilmProperties = _solution.Analysis.PalletFilmProperties;
                film = new Film(
                    palletFilmProperties.Color,
                    palletFilmProperties.UseTransparency,
                    palletFilmProperties.UseHatching,
                    palletFilmProperties.HatchSpacing,
                    palletFilmProperties.HatchAngle);
                film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin,
                    HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0));
                film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis,
                    HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0));
                film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis + loadBBoxWDeco.Width * Vector3D.YAxis,
                    HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0));
                film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Width * Vector3D.YAxis,
                    HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0));
                film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Height * Vector3D.ZAxis,
                    HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Width),
                    UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1)));
                film.DrawBegin(graphics);
            }
            #endregion

            #region Pallet corners
            // *** pallet corners 
            // positions
            Vector3D[] cornerPositions =
            {
                loadBBox.PtMin
                , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMin.Y, loadBBox.PtMin.Z)
                , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z)
                , new Vector3D(loadBBox.PtMin.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z)
            };
            // length axes
            HalfAxis.HAxis[] lAxes =
            {
                HalfAxis.HAxis.AXIS_X_P,
                HalfAxis.HAxis.AXIS_Y_P,
                HalfAxis.HAxis.AXIS_X_N,
                HalfAxis.HAxis.AXIS_Y_N
            };
            // width axes
            HalfAxis.HAxis[] wAxes =
            {
                HalfAxis.HAxis.AXIS_Y_P,
                HalfAxis.HAxis.AXIS_X_N,
                HalfAxis.HAxis.AXIS_Y_N,
                HalfAxis.HAxis.AXIS_X_P
            };
            // corners
            Corner[] corners = new Corner[4];
            if (_solution.Analysis.HasPalletCorners)
            {
                for (int i = 0; i < 4; ++i)
                {
                    corners[i] = new Corner(0, _solution.Analysis.PalletCornerProperties);
                    corners[i].Height = Math.Min(_solution.Analysis.PalletCornerProperties.Length, loadBBox.Height);
                    corners[i].SetPosition(cornerPositions[i], lAxes[i], wAxes[i]);
                    corners[i].DrawBegin(graphics);
                }
            }
            // *** pallet corners : end
            #endregion

            // draw solution
            uint pickId = 0;
            foreach (ILayer layer in _solution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                        graphics.AddBox(new Box(pickId++, _analysis.BProperties, bPosition));
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos)
                {
                    InterlayerProperties currInterlayerProperties = (0 == interlayerPos.TypeId)
                        ? _analysis.InterlayerProperties : _analysis.InterlayerPropertiesAntiSlip;
                    Box box = new Box(pickId++, currInterlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (_analysis.PalletProperties.Length - currInterlayerProperties.Length)
                        , 0.5 * (_analysis.PalletProperties.Width - currInterlayerProperties.Width)
                        , interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }

            if (_showDimensions)
            {
                graphics.AddDimensions(
                    new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                    , Color.Black, false));
                graphics.AddDimensions(
                    new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                    , Color.Red, true));
            }

            // pallet corners
            if (_solution.Analysis.HasPalletCorners)
            {
                for (int i = 0; i < 4; ++i)
                    corners[i].DrawEnd(graphics);
            }
            // pallet cap
            if (_solution.HasPalletCap)
            {
                PalletCapProperties capProperties = _solution.Analysis.PalletCapProperties;
                Vector3D pos = new Vector3D(
                    0.5 * (_analysis.PalletProperties.Length - capProperties.Length),
                    0.5 * (_analysis.PalletProperties.Width - capProperties.Width),
                    loadBBox.PtMax.Z - capProperties.InsideHeight);
                PalletCap cap = new PalletCap(0, capProperties, pos);
                cap.DrawEnd(graphics);
            }
            // pallet film
            if (_solution.Analysis.HasPalletFilm)
            {
                film.DrawEnd(graphics);
            }
            graphics.EnableFaceSorting = false;
        }
Ejemplo n.º 43
0
        private void ArrowPoints(Graphics3D graphics, out int[] arrow0, out int[] arrow1, out int[] arrow2)
        {
            Vector3D viewDir = graphics.ViewDirection;
            arrow0 = null;
            arrow1 = null;
            arrow2 = null;

            if (!_above)
            {
                if (viewDir.X < 0.0 && viewDir.Y >= 0.0)
                {
                    arrow0 = new int[4] { 0, 4, 1, 5 };
                    arrow1 = new int[4] { 0, 1, 3, 2 };
                    arrow2 = new int[4] { 1, 2, 0, 3 };
                }
                else if (viewDir.X < 0.0 && viewDir.Y < 0.0)
                {
                    arrow0 = new int[4] { 1, 5, 2, 6 };
                    arrow1 = new int[4] { 1, 2, 0, 3 };
                    arrow2 = new int[4] { 2, 3, 1, 0 };
                }
                else if (viewDir.X >= 0.0 && viewDir.Y < 0.0)
                {
                    arrow0 = new int[4] { 2, 6, 3, 7 };
                    arrow1 = new int[4] { 2, 3, 1, 0 };
                    arrow2 = new int[4] { 3, 0, 2, 1 };
                }
                else if (viewDir.X >= 0.0 && viewDir.Y >= 0.0)
                {
                    arrow0 = new int[4] { 3, 7, 0, 4 };
                    arrow1 = new int[4] { 3, 0, 2, 1 };
                    arrow2 = new int[4] { 0, 1, 3, 2 };
                }
            }
            else
            {
                if (viewDir.X < 0.0 && viewDir.Y >= 0.0)
                {
                    arrow0 = new int[4] { 2, 6, 3, 7 };
                    arrow1 = new int[4] { 7, 6, 4, 5 };
                    arrow2 = new int[4] { 4, 7, 5, 6 };
                }
                else if (viewDir.X < 0.0 && viewDir.Y < 0.0)
                {
                    arrow0 = new int[4] { 3, 7, 0, 4 };
                    arrow1 = new int[4] { 4, 7, 5, 6 };
                    arrow2 = new int[4] { 4, 5, 7, 6 };
                }
                else if (viewDir.X >= 0.0 && viewDir.Y < 0.0)
                {
                    arrow0 = new int[4] { 4, 0, 5, 1 };
                    arrow1 = new int[4] { 4, 5, 7, 6 };
                    arrow2 = new int[4] { 6, 5, 7, 4 };
                }
                else if (viewDir.X >= 0.0 && viewDir.Y >= 0.0)
                {
                    arrow0 = new int[4] { 1, 5, 2, 6 };
                    arrow1 = new int[4] { 5, 6, 4, 7 };
                    arrow2 = new int[4] { 7, 6, 4, 5 };
                }
            }
        }
Ejemplo n.º 44
0
 public abstract void Draw(Graphics3D graphics);
        public void DrawLayer(Graphics3D graphics, int layerIndex)
        {
            // sanity check
            if (null == _solution) return;

            if (_showDimensions)
            {
                BoxLayer layer = layerIndex %2 == 0 ? _solution.Layer : _solution.LayerSwapped;
                uint pickId = 0;
                foreach (BoxPosition bPosition in layer)
                    graphics.AddBox(new Pack(pickId++, _solution.Analysis.PackProperties, bPosition));
                graphics.AddDimensions(
                    new DimensionCube(layer.BoundingBox(_solution.Analysis.PackProperties)
                        , Color.Black, false));
            }
        }
Ejemplo n.º 46
0
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            if (CornerLength > 0 && CornerWidth > 0 && CornerThickness > 0
                && CornerThickness < CornerWidth)
            {
                // draw
                PalletCornerProperties palletCornerProperties = new PalletCornerProperties(
                    null, ItemName, ItemDescription, CornerLength, CornerWidth, CornerThickness,
                    CornerWeight, CornerColor);

                Corner palletCap = new Corner(0, palletCornerProperties);
                palletCap.Draw(graphics);
                graphics.AddDimensions(new DimensionCube(CornerWidth, CornerWidth, CornerLength));
            }
        }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     // ### draw pallet
     if (graphCtrlPallet == ctrl)
     {
         PalletProperties pp = SelectedPallet;
         Pallet pallet = new Pallet(pp);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f };
         graphics.AddDimensions(dc);
     }
     // ### draw case definition
     else if (ctrl == graphCtrlBoxesLayout)
     {
         // ### draw case definition
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             if (null == solution) return;
             // instantiate case definition viewer
             CaseDefinitionViewer cdv = new CaseDefinitionViewer(SelectedSolution.CaseDefinition, SelectedBox, BuildCaseOptimConstraintSet());
             cdv.Orientation = SelectedSolution.PalletSolution.FirstCaseOrientation;
             cdv.Draw(graphics);
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
     // ### draw associated pallet solution
     else if (ctrl == graphCtrlPalletLayout)
     {
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             // get selected box
             BoxProperties boxProperties = SelectedBox;
             // get selected pallet
             PalletProperties palletProperties = SelectedPallet;
             if (null != solution && null != boxProperties && null != palletProperties)
             {
                 Vector3D outerDim = solution.CaseDefinition.OuterDimensions(boxProperties, BuildCaseOptimConstraintSet());
                 BoxProperties caseProperties = new BoxProperties(null, outerDim.X, outerDim.Y, outerDim.Z);
                 caseProperties.SetColor(Color.Chocolate);
                 CasePalletSolutionViewer.Draw(graphics, solution.PalletSolution, caseProperties, null, palletProperties);
             }
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
 }
Ejemplo n.º 48
0
 public virtual void DrawEnd(Graphics3D graphics) { }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (null == CurrentSolution) return;
     BoxCaseSolutionViewer sv = new BoxCaseSolutionViewer(CurrentSolution);
     sv.Draw(graphics);
 }
Ejemplo n.º 50
0
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            if (null == _dt)
                return;
            DataCase dtCase = _dt as DataCase;
            if (null != dtCase)
            {
                Box b = new Box(0, ToCase(dtCase));
                graphics.AddBox(b);
                graphics.AddDimensions(new DimensionCube(dtCase.OuterDimensions));
            }
            DataBox dtBox = _dt as DataBox;
            if (null != dtBox)
            {
                Box b = new Box(0, ToBox(dtBox));
                graphics.AddBox(b);
                graphics.AddDimensions(new DimensionCube(dtBox.Dimensions));
            }
            DataPallet dtPallet = _dt as DataPallet;
            if (null != dtPallet)
            {
                Pallet pallet = new Pallet(ToPallet(dtPallet));
                pallet.Draw(graphics, Sharp3D.Math.Core.Transform3D.Identity);
                graphics.AddDimensions(new DimensionCube(dtPallet.Dimensions));
            }
            DataInterlayer dtInterlayer = _dt as DataInterlayer;
            if (null != dtInterlayer)
            {
                graphics.AddBox(new Box(0, ToInterlayer(dtInterlayer)));
                graphics.AddDimensions(new DimensionCube(dtInterlayer.Dimensions));
            }

            DataPalletCap dtPalletCap = _dt as DataPalletCap;
            if (null != dtPalletCap)
            {
                PalletCap palletCap = new PalletCap(0, ToPalletCap(dtPalletCap), Sharp3D.Math.Core.Vector3D.Zero);
                palletCap.Draw(graphics);
                graphics.AddDimensions(new DimensionCube(dtPalletCap.Dimensions));
            }

            DataCylinder dtCylinder = _dt as DataCylinder;
            if (null != dtCylinder)
            {
                Cylinder cyl = new Cylinder(0, ToCylinder(dtCylinder));
                graphics.AddCylinder(cyl);
            }
        }
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public static void Draw(Graphics3D graphics
            , CasePalletSolution solution
            , BoxProperties boxProperties, InterlayerProperties interlayerProperties, PalletProperties palletProperties)
        {
            // draw pallet
            Pallet pallet = new Pallet(palletProperties);
            pallet.Draw(graphics, Transform3D.Identity);
            // draw solution
            uint pickId = 0;
            foreach (ILayer layer in solution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos && null != interlayerProperties)
                {
                    Box box = new Box(pickId++, interlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (palletProperties.Length - interlayerProperties.Length)
                        , 0.5 * (palletProperties.Width - interlayerProperties.Width)
                        , interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }
 
            // always show dimensions
            BoxLayer bLayer = solution[solution.Count - 1] as BoxLayer;
            double palletHeight = solution[solution.Count - 1].ZLow + (null != bLayer ? bLayer.Thickness(boxProperties) : 0.0);

            // show dimensions
            graphics.AddDimensions(new DimensionCube(solution.BoundingBox, Color.Black, false));
            graphics.AddDimensions(new DimensionCube(solution.LoadBoundingBox, Color.Red, true));
        }
        public void Draw(Graphics3D graphics)
        {
            if (null == _solution)
                return;
            // initialize Graphics3D object
            if (!graphics.ShowBoxIds)
            {
                // draw pallet
                Pallet pallet = new Pallet(_analysis.PalletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
            }
            // draw solution
            uint pickId = 0;
            foreach (CylPosition pos in _solution)
                graphics.AddCylinder(new Cylinder(pickId++, _analysis.CylinderProperties, pos));

            if (_showDimensions)
            {
                graphics.AddDimensions(
                    new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1)
                    , Color.Black, false));
                graphics.AddDimensions(
                    new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2)
                    , Color.Red, true));
            }
        }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 { 
     // instantiate solution viewer
     PackPalletSolutionViewer sv = new PackPalletSolutionViewer(GetCurrentSolution());
     sv.Draw(graphics);
 }
Ejemplo n.º 54
0
 public virtual void DrawBegin(Graphics3D graphics) { }
                /// <summary>
        /// Draw layers
        /// Images are used during report generation
        /// </summary>
        public void DrawLayers(Graphics3D graphics, bool showPallet, int layerIndex)
        {
            if (null == _solution)
                throw new Exception("No solution defined!");

            if (!graphics.ShowBoxIds) // -> if box ids are drawn, we do not draw pallet
            {
                // draw pallet
                Pallet pallet = new Pallet(_analysis.PalletProperties);
                pallet.Draw(graphics, Transform3D.Identity);
            }
            // draw solution
            uint pickId = 0;
            CylinderLayer cylLayer = _solution.CylinderLayerFirst;
            if (cylLayer != null)
            {
                foreach (Vector3D pos in cylLayer)
                    graphics.AddCylinder(new Cylinder(pickId++, _analysis.CylinderProperties, new CylPosition(pos, HalfAxis.HAxis.AXIS_Z_P)));
            }
            // flush
            graphics.Flush();
        }
Ejemplo n.º 56
0
 public void Draw(Graphics3D graphics, Vector3D dimensions, Color color, Transform3D t)
 {
     double coefX = dimensions.X / _defaultDimensions.X;
     double coefY = dimensions.Y / _defaultDimensions.Y;
     double coefZ = dimensions.Z / _defaultDimensions.Z;
     uint pickId = 0;
     foreach (Position pos in _positions)
     {
         double coef0 = coefX, coef1 = coefY, coef2 = coefZ;
         if (pos.Axis1 == HalfAxis.HAxis.AXIS_X_P && pos.Axis2 == HalfAxis.HAxis.AXIS_Y_P)
         { coef0 = coefX; coef1 = coefY; }
         else if (pos.Axis1 == HalfAxis.HAxis.AXIS_Y_P && pos.Axis2 == HalfAxis.HAxis.AXIS_X_N)
         { coef0 = coefY; coef1 = coefX; }
         Vector3D dim = _lumbers[pos.Index];
         Box box = new Box(pickId++, dim.X * coef0, dim.Y * coef1, dim.Z * coef2);
         box.SetAllFacesColor(color);
         box.Position = t.transform(new Vector3D(pos.XYZ.X * coefX, pos.XYZ.Y * coefY, pos.XYZ.Z * coefZ));
         box.LengthAxis = Basics.HalfAxis.ToVector3D(HalfAxis.Transform(pos.Axis1, t)); ;
         box.WidthAxis = Basics.HalfAxis.ToVector3D(HalfAxis.Transform(pos.Axis2, t)); ;
         graphics.AddBox(box);
     }
 }
Ejemplo n.º 57
0
        public void Draw(Graphics3D graphics, Transform3D t)
        {
            if (_length == 0.0 || _width == 0.0 || _height == 0.0)
                return;

            PalletData palletType = PalletData.GetByName(_typeName);
            if (null != palletType)
                palletType.Draw(graphics, new Vector3D(_length, _width, _height), _color, t);
        }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (graphCtrlCaseSolution == ctrl)
     {
         // instantiate solution viewer
         BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(GetCurrentSolution());
         sv.Draw(graphics);
     }
     else if (graphCtrlPalletSolution == ctrl)
     {
             CasePalletSolution sol = GetCurrentSolution().PalletSolutionDesc.LoadPalletSolution();
             // instantial solution viewer
             CasePalletSolutionViewer svPallet = new CasePalletSolutionViewer(sol);
             svPallet.Draw(graphics);
     }
 }
Ejemplo n.º 59
0
        public Vector3D[] DrawingPoints(Graphics3D graphics)
        {
            int[] arrow0 = null;
            int[] arrow1 = null;
            int[] arrow2 = null;
            ArrowPoints(graphics, out arrow0, out arrow1, out arrow2);

            const double exageration = 1.2;

            Vector3D[] pts = new Vector3D[6];
            pts[0] = _pts[arrow0[0]] + (_pts[arrow0[0]] - _pts[arrow0[2]]) * offsetPerc * exageration;
            pts[1] = _pts[arrow0[1]] + (_pts[arrow0[1]] - _pts[arrow0[3]]) * offsetPerc * exageration;
            pts[2] = _pts[arrow1[0]] + (_pts[arrow1[0]] - _pts[arrow1[2]]) * offsetPerc * exageration;
            pts[3] = _pts[arrow1[1]] + (_pts[arrow1[1]] - _pts[arrow1[3]]) * offsetPerc * exageration;
            pts[4] = _pts[arrow2[0]] + (_pts[arrow2[0]] - _pts[arrow2[2]]) * offsetPerc * exageration;
            pts[5] = _pts[arrow2[1]] + (_pts[arrow2[1]] - _pts[arrow2[3]]) * offsetPerc * exageration;
            return pts;
        }
Ejemplo n.º 60
0
        private void DrawArrow(int[] arrow, Graphics3D graphics)
        {
            Vector3D pt0 = _pts[arrow[0]];
            Vector3D pt0_ = pt0 + (pt0 - _pts[arrow[2]]) * offsetPerc;
            Vector3D pt00_ = pt0 + (pt0 - _pts[arrow[2]]) * offsetPerc * 1.1;

            Vector3D pt1 = _pts[arrow[1]];
            Vector3D pt1_ = pt1 + (pt1 - _pts[arrow[3]]) * offsetPerc;
            Vector3D pt11_ = pt1 + (pt1 - _pts[arrow[3]]) * offsetPerc * 1.1;

            if ((pt1 - pt0).GetLengthSquared() < 1.0E-03)
                return;

            string text = string.Format("{0:0.0}", (pt1-pt0).GetLength());
            graphics.Draw(text, 0.5 * (pt1_ + pt0_), _color, _fontSize);
            graphics.Draw(new Segment(pt0_, pt0_ + (pt1 - pt0) * (2.0 / 5.0), _color));
            graphics.Draw(new Segment(pt0_ + (pt1 - pt0) * (3.0 / 5.0), pt1_, _color));
            graphics.Draw(new Segment(pt0, pt00_, _color));
            graphics.Draw(new Segment(pt1, pt11_, _color));
        }