コード例 #1
0
 public static void Draw(BProperties boxProperties, HalfAxis.HAxis axis, PictureBox pictureBox)
 {
     // get horizontal angle
     double angle = 45;
     // instantiate graphics
     Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size);
     graphics.CameraPosition = new Vector3D(
         Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
         , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
         , 10000.0);
     graphics.Target = Vector3D.Zero;
     graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
     // draw
     Box box = new Box(0, boxProperties);
     // set axes
     HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P;
     HalfAxis.HAxis widthAxis = HalfAxis.HAxis.AXIS_Y_P;
     switch (axis)
     {
         case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break;
         case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break;
         case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break;
         default: break;
     }
     box.LengthAxis = TreeDim.StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis);
     box.WidthAxis = TreeDim.StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis);
     // draw box
     graphics.AddBox(box);
     graphics.Flush();
     // set to picture box
     pictureBox.Image = graphics.Bitmap;
 }
コード例 #2
0
        /// <summary>
        /// Compute layer bouding box
        /// </summary>
        /// <param name="bProperties">Case properties</param>
        /// <returns>bounding box</returns>
        public BBox3D BoundingBox(BProperties bProperties)
        {
            BBox3D bbox = new BBox3D();

            foreach (BoxPosition bpos in this)
            {
                Vector3D[] pts = new Vector3D[8];
                Vector3D   vI  = HalfAxis.ToVector3D(bpos.DirectionLength);
                Vector3D   vJ  = HalfAxis.ToVector3D(bpos.DirectionWidth);
                Vector3D   vK  = Vector3D.CrossProduct(vI, vJ);
                pts[0] = bpos.Position;
                pts[1] = bpos.Position + bProperties.Length * vI;
                pts[2] = bpos.Position + bProperties.Width * vJ;
                pts[3] = bpos.Position + bProperties.Length * vI + bProperties.Width * vJ;
                pts[4] = bpos.Position + bProperties.Height * vK;
                pts[5] = bpos.Position + bProperties.Width * vJ + bProperties.Height * vK;;
                pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width;
                pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * bProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width;

                foreach (Vector3D pt in pts)
                {
                    bbox.Extend(pt);
                }
            }

            return(bbox);
        }
コード例 #3
0
 public CasePalletAnalysis(
     BProperties boxProperties,
     PalletProperties palletProperties,
     InterlayerProperties interlayerProperties,
     InterlayerProperties interlayerPropertiesAntiSlip,
     PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm,
     PalletConstraintSet constraintSet)
     : base(boxProperties.ParentDocument)
 {
     // sanity checks
     if (palletProperties.ParentDocument != ParentDocument ||
         (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument))
     {
         throw new Exception("box, pallet, interlayer do not belong to the same document");
     }
     if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) ||
         (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet))
     {
         throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox");
     }
     // has interlayer ?
     constraintSet.HasInterlayer = null != interlayerProperties;
     // setting members
     this.BProperties                  = boxProperties;
     this.PalletProperties             = palletProperties;
     this.InterlayerProperties         = interlayerProperties;
     this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     this.PalletCornerProperties       = palletCorners;
     this.PalletCapProperties          = palletCap;
     this.PalletFilmProperties         = palletFilm;
     this.ConstraintSet                = constraintSet;
 }
コード例 #4
0
 public CasePalletAnalysis(
     BProperties boxProperties,
     PalletProperties palletProperties,
     InterlayerProperties interlayerProperties,
     InterlayerProperties interlayerPropertiesAntiSlip,
     PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm,
     PalletConstraintSet constraintSet)
     : base(boxProperties.ParentDocument)
 {
     // sanity checks
     if (palletProperties.ParentDocument != ParentDocument
         || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument))
         throw new Exception("box, pallet, interlayer do not belong to the same document");
     if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet)
         || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet))
         throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox");
     // has interlayer ?
     constraintSet.HasInterlayer = null != interlayerProperties;
     // setting members
     this.BProperties = boxProperties;
     this.PalletProperties = palletProperties;
     this.InterlayerProperties = interlayerProperties;
     this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     this.PalletCornerProperties = palletCorners;
     this.PalletCapProperties = palletCap;
     this.PalletFilmProperties = palletFilm;
     this.ConstraintSet = constraintSet;
 }
コード例 #5
0
 public CaseOptimAnalysis(
     BProperties boxProperties
     , PalletProperties palletProperties
     , PalletConstraintSet palletConstraintSet
     , CaseOptimConstraintSet caseOptimConstraintSet)
     : base(boxProperties.ParentDocument)
 {
 }
コード例 #6
0
 public CaseOptimAnalysis(
     BProperties boxProperties
     , PalletProperties palletProperties
     , PalletConstraintSet palletConstraintSet
     , CaseOptimConstraintSet caseOptimConstraintSet)
     : base(boxProperties.ParentDocument)
 {
 }
コード例 #7
0
 public double Thickness(BProperties bProperties)
 {
     if (Count == 0) return 0.0;
     BoxPosition bPos = this[0];
     Vector3D diagonale = bProperties.Length * HalfAxis.ToVector3D(bPos.DirectionLength)
                         + bProperties.Width * HalfAxis.ToVector3D(bPos.DirectionWidth)
                         + bProperties.Height * Vector3D.CrossProduct(HalfAxis.ToVector3D(bPos.DirectionLength), HalfAxis.ToVector3D(bPos.DirectionWidth));
     return Math.Abs(diagonale.Z);
 }
コード例 #8
0
 public BoxCaseAnalysis(BProperties bProperties, BoxProperties caseProperties, BCaseConstraintSet constraintSet)
     : base(bProperties.ParentDocument)
 {
     if (!constraintSet.IsValid)
         throw new Exception("Using invalid box/case constraintset -> Can not instantiate box/case analysis!");
     this.BProperties = bProperties;
     this.CaseProperties = caseProperties;
     _constraintSet = constraintSet;
 }
コード例 #9
0
 public BoxCaseAnalysis(BProperties bProperties, BoxProperties caseProperties, BCaseConstraintSet constraintSet)
     : base(bProperties.ParentDocument)
 {
     if (!constraintSet.IsValid)
     {
         throw new Exception("Using invalid box/case constraintset -> Can not instantiate box/case analysis!");
     }
     this.BProperties    = bProperties;
     this.CaseProperties = caseProperties;
     _constraintSet      = constraintSet;
 }
コード例 #10
0
        public void ProcessAnalysis(BoxCaseAnalysis analysis)
        {
            _bProperties = analysis.BProperties;
            _caseProperties = analysis.CaseProperties;
            _constraintSet = analysis.ConstraintSet;

            if (!_constraintSet.IsValid)
                throw new EngineException("Constraint set is invalid!");

            analysis.Solutions = GenerateSolutions();
        }
コード例 #11
0
 /// <summary>
 /// Creates a new analysis without generating solutions
 /// </summary>
 /// <param name="name">Name of analysis</param>
 /// <param name="description">Description</param>
 /// <param name="box">Case</param>
 /// <param name="pallet">Pallet</param>
 /// <param name="interlayer">Interlayer</param>
 /// <param name="constraintSet">PalletConstraintSet</param>
 /// <param name="solutions">Solutions</param>
 /// <returns>CasePalletAnalysis generated using input parameters</returns>
 public CasePalletAnalysis CreateNewCasePalletAnalysis(
     string name, string description
     , BProperties box, PalletProperties pallet
     , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip
     , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm
     , PalletConstraintSet constraintSet
     , List<CasePalletSolution> solutions)
 {
     CasePalletAnalysis analysis = new CasePalletAnalysis(
         box, pallet,
         interlayer, interlayerAntiSlip,
         palletCorners, palletCap, palletFilm,
         constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _casePalletAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewCasePalletAnalysisCreated(analysis);
     // set solution selected if it is unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
コード例 #12
0
 /// <summary>
 /// Creates a new analysis in this document + compute solutions
 /// </summary>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="box"></param>
 /// <param name="pallet"></param>
 /// <param name="interlayer"></param>
 /// <param name="constraintSet"></param>
 /// <param name="solver">Node : analysis creation requires a solver</param>
 /// <returns>An analysis</returns>
 public CasePalletAnalysis CreateNewCasePalletAnalysis(
     string name, string description
     , BProperties box, PalletProperties pallet
     , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip
     , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm
     , PalletConstraintSet constraintSet
     , ICasePalletAnalysisSolver solver)
 {
     CasePalletAnalysis analysis = new CasePalletAnalysis(
         box, pallet,
         interlayer, interlayerAntiSlip,
         palletCorners, palletCap, palletFilm,
         constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _casePalletAnalyses.Add(analysis);
     // compute analysis
     solver.ProcessAnalysis(analysis);
     if (analysis.Solutions.Count < 1)
     {	// remove analysis from list if it has no valid solution
         _casePalletAnalyses.Remove(analysis);
         return null;
     }
     // notify listeners
     NotifyOnNewCasePalletAnalysisCreated(analysis);
     Modify();
     return analysis;
 }
コード例 #13
0
 public BoxCaseAnalysis CreateNewBoxCaseAnalysis(
     string name, string description
     , BProperties boxProperties, BoxProperties caseProperties
     , BCaseConstraintSet constraintSet
     , IBoxCaseAnalysisSolver solver)
 {
     BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _boxCaseAnalyses.Add(analysis);
     // compute analysis
     if (null != solver)
     {
         solver.ProcessAnalysis(analysis);
         if (analysis.Solutions.Count < 1)
         {	// remove analysis from list if it has no valid solution
             _boxCaseAnalyses.Remove(analysis);
             return null;
         }
     }
     // notify listeners
     NotifyOnNewBoxCaseAnalysis(analysis);
     Modify();
     return analysis;
 }
コード例 #14
0
 public BoxCaseAnalysis CreateNewBoxCaseAnalysis(
     string name, string description
     , BProperties boxProperties, BoxProperties caseProperties
     , BCaseConstraintSet constraintSet
     , List<BoxCaseSolution> solutions)
 {
     BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _boxCaseAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewBoxCaseAnalysis(analysis);
     // set solution selected if it is unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
コード例 #15
0
 public List<CasePalletSolution> Process(
     BoxProperties boxProperties, PalletProperties palletProperties,
     InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip,
     PalletConstraintSet constraintSet)
 {
     _bProperties = boxProperties;
     _palletProperties = palletProperties;
     _interlayerProperties = interlayerProperties;
     _interlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     _constraintSet = constraintSet;
     // check constraint set validity
     if (!_constraintSet.IsValid)
         throw new EngineException("Constraint set is invalid!");
     // generate solutions
     return GenerateSolutions();
 }
コード例 #16
0
ファイル: Box.cs プロジェクト: frozenflame83/StackBuilder
        public Box(uint pickId, BProperties bProperties, BoxPosition bPosition)
        {
            if (!bPosition.IsValid)
                throw new GraphicsException("Invalid BoxPosition: can not create box");
            _pickId = pickId;
            _dim[0] = bProperties.Length;
            _dim[1] = bProperties.Width;
            _dim[2] = bProperties.Height;

            _colors = bProperties.Colors;

            BoxProperties boxProperties = bProperties as BoxProperties;
            if (null != boxProperties)
            {
                List<Pair<HalfAxis.HAxis, Texture>> textures = boxProperties.TextureList;
                foreach (Pair<HalfAxis.HAxis, Texture> tex in textures)
                {
                    int iIndex = (int)tex.first;
                    if (null == _textureLists[iIndex])
                        _textureLists[iIndex] = new List<Texture>();
                    _textureLists[iIndex].Add(tex.second);
                }
                _showTape = boxProperties.ShowTape;
                _tapeWidth = boxProperties.TapeWidth;
                _tapeColor = boxProperties.TapeColor;
            }

            // set position
            Position = bPosition.Position;
            // set direction length
            LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength);
            // set direction width
            WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth);
            // IsBundle ?
            _isBundle = bProperties.IsBundle;
            if (bProperties.IsBundle)
            {
                BundleProperties bundleProp = bProperties as BundleProperties;
                if (null != bundleProp)
                    _noFlats = bundleProp.NoFlats;
            }
        }
コード例 #17
0
        private Layer GenerateBestLayer(
            BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties,
            PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis)
        {
            Layer bestLayer = null;
            // loop through all patterns
            foreach (LayerPattern pattern in _patterns)
            {
                // is pattern allowed
                if (!_constraintSet.AllowPattern(pattern.Name)) continue;

                // direction 1
                Layer layer1 = new Layer(bProperties, palletProperties, cornerProperties,
                    constraintSet, hAxis);
                double actualLength = 0.0, actualWidth = 0.0;
                pattern.GetLayerDimensionsChecked(layer1, out actualLength, out actualWidth);
                pattern.GenerateLayer(layer1, actualLength, actualWidth);
                // save as best pattern
                if (null == bestLayer || bestLayer.Count < layer1.Count)
                    bestLayer = layer1;
                // direction 2 (opposite)
                Layer layer2 = new Layer(bProperties, palletProperties, cornerProperties,
                    constraintSet, HalfAxis.Opposite(hAxis));
                actualLength = 0.0; actualWidth = 0.0;
                pattern.GetLayerDimensionsChecked(layer2, out actualLength, out actualWidth);
                pattern.GenerateLayer(layer2, actualLength, actualWidth);
                // save as best pattern
                if (null == bestLayer || bestLayer.Count < layer2.Count)
                    bestLayer = layer2;
            }
            return bestLayer;
        }
コード例 #18
0
ファイル: Box.cs プロジェクト: frozenflame83/StackBuilder
        public Box(uint pickId, BProperties bProperties)
        {
            _pickId = pickId;
            _dim[0] = bProperties.Length;
            _dim[1] = bProperties.Width;
            _dim[2] = bProperties.Height;

            _colors = bProperties.Colors;

            // IsBundle ?
            _isBundle = bProperties.IsBundle;

            // textures
            BoxProperties boxProperties = bProperties as BoxProperties;
            if (null != boxProperties)
            {
                List<Pair<HalfAxis.HAxis, Texture>> textures = boxProperties.TextureList;
                foreach (Pair<HalfAxis.HAxis, Texture> tex in textures)
                {
                    int iIndex = (int)tex.first;
                    if (null == _textureLists[iIndex])
                        _textureLists[iIndex] = new List<Texture>();
                    _textureLists[iIndex].Add(tex.second);

                }
                // tape
                _showTape = boxProperties.ShowTape;
                _tapeWidth = boxProperties.TapeWidth;
                _tapeColor = boxProperties.TapeColor;
            }
        }
コード例 #19
0
 public BoxItem(BProperties boxProperties)
 {
     _boxProperties = boxProperties;
 }
コード例 #20
0
 /// <summary>
 /// Process case/pallet analysis
 /// </summary>
 /// <param name="analysis">Pallet analysis to process</param>
 public void ProcessAnalysis(CasePalletAnalysis analysis)
 {
     _bProperties = analysis.BProperties;
     _palletProperties = analysis.PalletProperties;
     _interlayerProperties = analysis.InterlayerProperties;
     _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip;
     _cornerProperties = analysis.PalletCornerProperties;
     _capProperties = analysis.PalletCapProperties;
     _constraintSet = analysis.ConstraintSet;
     // check contraint set validity
     if (!_constraintSet.IsValid)
         throw new EngineException("Constraint set is invalid!");
     // generate solutions
     analysis.Solutions = GenerateSolutions();
 }