Layer2D BuildLayer(CasePalletSolution palletSolution, TruckProperties truckProperties, TruckConstraintSet constraintSet ,HalfAxis.HAxis axisOrtho, bool swapped) { return new Layer2D(new Vector3D(palletSolution.PalletLength, palletSolution.PalletWidth, palletSolution.PalletHeight) , new Vector2D(truckProperties.Length, truckProperties.Width) , axisOrtho, swapped); }
public bool IsOrientationAllowed(HalfAxis.HAxis axis) { if (HalfAxis.HAxis.AXIS_X_N == axis && HalfAxis.HAxis.AXIS_X_P == axis) return checkBoxX.Checked; else if (HalfAxis.HAxis.AXIS_Y_N == axis && HalfAxis.HAxis.AXIS_Y_P == axis) return checkBoxY.Checked; else if (HalfAxis.HAxis.AXIS_Z_N == axis && HalfAxis.HAxis.AXIS_Z_P == axis) return checkBoxZ.Checked; else return false; }
public static bool SaveListToXMLFile(List <BoxPosition> boxPositions, string filename) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Save(filename); var listElt = xmlDoc.CreateElement("BoxPositions"); xmlDoc.AppendChild(listElt); foreach (var bPos in boxPositions) { // BoxPosition XmlElement boxPositionElt = xmlDoc.CreateElement("BoxPosition"); listElt.AppendChild(boxPositionElt); // Position XmlAttribute positionAttribute = xmlDoc.CreateAttribute("Position"); positionAttribute.Value = bPos.Position.ToString(); boxPositionElt.Attributes.Append(positionAttribute); // AxisLength XmlAttribute axisLengthAttribute = xmlDoc.CreateAttribute("AxisLength"); axisLengthAttribute.Value = HalfAxis.ToString(bPos.DirectionLength); boxPositionElt.Attributes.Append(axisLengthAttribute); // AxisWidth XmlAttribute axisWidthAttribute = xmlDoc.CreateAttribute("AxisWidth"); axisWidthAttribute.Value = HalfAxis.ToString(bPos.DirectionWidth); boxPositionElt.Attributes.Append(axisWidthAttribute); } } catch (Exception /*ex*/) { return(false); } return(true); }
public void AddPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // build 4D matrix Vector3D vAxisLength = HalfAxis.ToVector3D(lengthAxis); Vector3D vAxisWidth = HalfAxis.ToVector3D(widthAxis); Vector3D vAxisHeight = Vector3D.CrossProduct(vAxisLength, vAxisWidth); Matrix4D mat = Matrix4D.Identity; mat.M11 = vAxisLength.X; mat.M12 = vAxisLength.Y; mat.M13 = vAxisLength.Z; mat.M21 = vAxisWidth.X; mat.M22 = vAxisWidth.Y; mat.M23 = vAxisWidth.Z; mat.M31 = vAxisHeight.X; mat.M32 = vAxisHeight.Y; mat.M33 = vAxisHeight.Z; mat.M41 = 0.0; mat.M42 = 0.0; mat.M43 = 0.0; mat.M44 = 1.0; Transform3D localTransf = new Transform3D(mat); Transform3D localTransfInv = localTransf.Inverse(); Transform3D originTranslation = Transform3D.Translation(localTransfInv.transform(VecTransf) - new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0)); var layerPos = new BoxPosition( originTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0) + 0.5 * ForcedSpace * vAxisLength + 0.5 * ForcedSpace * vAxisWidth) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(LengthAxis))) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(WidthAxis))) ); layerPos.Position += new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0); // add position Add(layerPos.Adjusted(DimBox)); }
public CylPosition Transform(Transform3D transf) { return(new CylPosition( transf.transform(_vPosition), HalfAxis.ToHalfAxis(transf.transformRot(HalfAxis.ToVector3D(_axis))) )); }
public BoxPosition RotateZ180(Vector3D dim) { Vector3D v = Position; v += dim.X * HalfAxis.ToVector3D(DirectionLength) + dim.Y * HalfAxis.ToVector3D(DirectionWidth); return(new BoxPosition(v, HalfAxis.Opposite(DirectionLength), HalfAxis.Opposite(DirectionWidth))); }
public static bool LoadListFromXMLFile(out List <BoxPosition> boxPositions, string filename) { boxPositions = new List <BoxPosition>(); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); XmlElement eltBoxPositions = xmlDoc.DocumentElement; foreach (XmlNode nodeBP in eltBoxPositions.ChildNodes) { if (nodeBP is XmlElement eltBoxPosition) { string sPosition = eltBoxPosition.Attributes["Position"].Value; string sAxisLength = eltBoxPosition.Attributes["AxisLength"].Value; string sAxisWidth = eltBoxPosition.Attributes["AxisWidth"].Value; boxPositions.Add(new BoxPosition(Vector3D.Parse(sPosition), HalfAxis.Parse(sAxisLength), HalfAxis.Parse(sAxisWidth))); } } } catch (Exception /*ex*/) { return(false); } return(true); }
public BoxPosition Translate(HalfAxis.HAxis axis, double value) { Vector3D v = Position; v += value * HalfAxis.ToVector3D(axis); return(new BoxPosition(v, DirectionLength, DirectionWidth)); }
public BoxPosition ToBoxPosition(BBox3D bbox) { Vector3D vOrig = Vector3D.Zero; HalfAxis.HAxis axis = HalfAxis.HAxis.AXIS_Y_P; switch (Side) { case HalfAxis.HAxis.AXIS_X_N: vOrig = new Vector3D(bbox.PtMin.X, bbox.PtMax.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_Y_N; break; case HalfAxis.HAxis.AXIS_Y_N: vOrig = new Vector3D(bbox.PtMin.X, bbox.PtMin.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_X_P; break; case HalfAxis.HAxis.AXIS_X_P: vOrig = new Vector3D(bbox.PtMax.X, bbox.PtMin.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_Y_P; break; case HalfAxis.HAxis.AXIS_Y_P: vOrig = new Vector3D(bbox.PtMax.X, bbox.PtMax.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_X_N; break; default: break; } return(new BoxPosition(vOrig + Position.X * HalfAxis.ToVector3D(axis) + Position.Y * Vector3D.ZAxis, axis, HalfAxis.HAxis.AXIS_Z_P)); }
public BBox3D BoundingBox(Packable packable) { BBox3D bbox = new BBox3D(); if (packable is PackableBrick packableBrick) { Vector3D dimensions = packableBrick.OuterDimensions; 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 + dimensions.X * vI; pts[2] = bpos.Position + dimensions.Y * vJ; pts[3] = bpos.Position + dimensions.X * vI + dimensions.Y * vJ; pts[4] = bpos.Position + dimensions.Z * vK; pts[5] = bpos.Position + dimensions.Y * vJ + dimensions.Z * vK; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * dimensions.Y; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * dimensions.X + HalfAxis.ToVector3D(bpos.DirectionWidth) * dimensions.Y; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } } return(bbox); }
private Layer2D GenerateBestLayer( BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties, PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis) { Layer2D bestLayer = null; // loop through all patterns foreach (LayerPattern pattern in LayerPattern.All) { // is pattern allowed if (!_constraintSet.AllowPattern(pattern.Name)) continue; // direction 1 Layer2D layer1 = BuildLayer(bProperties, palletProperties, cornerProperties, constraintSet, hAxis, false, false); 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) Layer2D layer2 = BuildLayer(bProperties, palletProperties, cornerProperties, constraintSet, HalfAxis.Opposite(hAxis), false, false); 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; }
public BBox3D BoundingBox(PackProperties packProperties) { 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 + packProperties.Length * vI; pts[2] = bpos.Position + packProperties.Width * vJ; pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ; pts[4] = bpos.Position + packProperties.Height * vK; pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK;; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } return(bbox); }
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; }
public Vector3D Center(Vector3D dimensions) { Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); return(Position + (0.5 * dimensions.X * vI) + (0.5 * dimensions.Y * vJ) + (0.5 * dimensions.Z * vK)); }
public Layer3DBoxIndexed Sort(Packable packable) { Vector3D dimensions = packable.OuterDimensions; Vector3D minPoint = BoundingBox(packable).PtMin; Dictionary <int, double> dictIndexDist = new Dictionary <int, double>(); foreach (var boxPos in this) { int index = boxPos.Index; double maxDist = boxPos.BPos.MaxDistance(dimensions, minPoint); if (dictIndexDist.ContainsKey(index)) { dictIndexDist[index] = Math.Max(dictIndexDist[index], maxDist); } else { dictIndexDist.Add(index, maxDist); } } // sort by ascending distance var sortedDict = from entry in dictIndexDist orderby entry.Value ascending select entry; // instantiate new layer Layer3DBoxIndexed sortedLayer = new Layer3DBoxIndexed(ZLow, LayerIndex); foreach (var elt in sortedDict) { int index = elt.Key; var boxPositions = FindAll(bp => bp.Index == index); Vector3D vAxisWidth = HalfAxis.ToVector3D(boxPositions[0].BPos.DirectionWidth); boxPositions.Sort( delegate(BoxPositionIndexed bp1, BoxPositionIndexed bp2) { double abscissa1 = Vector3D.DotProduct(bp1.BPos.Position, vAxisWidth); double abscissa2 = Vector3D.DotProduct(bp2.BPos.Position, vAxisWidth); if (abscissa1 > abscissa2) { return(1); } else if (abscissa2 < abscissa1) { return(-1); } else { return(0); } }); foreach (var bpos in boxPositions) { sortedLayer.Add(bpos); } } return(sortedLayer); }
public string Tooltip(double height) { return(string.Format("{0} * {1} = {2}\n {3} | {4}" , Count , NoLayers(height) , CountInHeight(height) , HalfAxis.ToString(AxisOrtho) , PatternName)); }
public static CylPosition Transform(CylPosition cylPosition, Transform3D transform) { return(new CylPosition( transform.transform(cylPosition.XYZ), HalfAxis.ToHalfAxis( transform.transformRot(HalfAxis.ToVector3D(cylPosition.Direction)) ) )); }
public void AddPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // build 4D matrix Vector3D vAxisLength = HalfAxis.ToVector3D(lengthAxis); Vector3D vAxisWidth = HalfAxis.ToVector3D(widthAxis); Vector3D vAxisHeight = Vector3D.CrossProduct(vAxisLength, vAxisWidth); Matrix4D mat = Matrix4D.Identity; mat.M11 = vAxisLength.X; mat.M12 = vAxisLength.Y; mat.M13 = vAxisLength.Z; mat.M21 = vAxisWidth.X; mat.M22 = vAxisWidth.Y; mat.M23 = vAxisWidth.Z; mat.M31 = vAxisHeight.X; mat.M32 = vAxisHeight.Y; mat.M33 = vAxisHeight.Z; mat.M41 = 0.0; mat.M42 = 0.0; mat.M43 = 0.0; mat.M44 = 1.0; Transform3D localTransf = new Transform3D(mat); Transform3D localTransfInv = localTransf.Inverse(); Transform3D originTranslation = Transform3D.Translation(localTransfInv.transform(VecTransf) - new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0)); var layerPos = new BoxPosition( originTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0) + 0.5 * ForcedSpace * vAxisLength + 0.5 * ForcedSpace * vAxisWidth) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(LengthAxis))) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(WidthAxis))) ); // spacing ? layerPos.Position += new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0); var bposAdj = layerPos.Adjusted(DimBoxTotal); // bulge ? Vector3D vecBulge = Vector3D.Zero; if (Bulge.X > 0) { vecBulge += 0.5 * Bulge.X * HalfAxis.ToVector3D(bposAdj.DirectionLength); } if (Bulge.Y > 0) { vecBulge += 0.5 * Bulge.Y * HalfAxis.ToVector3D(bposAdj.DirectionWidth); } if (Bulge.Z > 0) { vecBulge += 0.5 * Bulge.Z * HalfAxis.ToVector3D(bposAdj.DirectionHeight); } bposAdj.Position += vecBulge; // add position Add(bposAdj); }
public static BoxPosition Transform(BoxPosition boxPosition, Transform3D transform) { if (!boxPosition.IsValid) { throw new Exception("Invalid box position : can not transform"); } return(new BoxPosition( transform.transform(boxPosition.Position) , HalfAxis.Transform(boxPosition.DirectionLength, transform) , HalfAxis.Transform(boxPosition.DirectionWidth, transform) )); }
public static BoxPosition Parse(string s) { string[] sArray = s.Split('|'); var v = Vector3D.Parse(sArray[0]); string sOrientation = sArray[1]; sOrientation = sOrientation.Trim(); sOrientation = sOrientation.TrimStart('('); sOrientation = sOrientation.TrimEnd(')'); string[] vOrientation = sOrientation.Split(','); return(new BoxPosition(v, HalfAxis.Parse(vOrientation[0]), HalfAxis.Parse(vOrientation[1]))); }
public FilmRectangle( Vector3D origin, HalfAxis.HAxis axis1, HalfAxis.HAxis axis2, Vector2D dimensions, double dBorder) { _origin = origin; _axis1 = axis1; _axis2 = axis2; _dimensions = dimensions; _dBorder = dBorder; }
public void AddPosition(Layer layer, Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { Matrix4D matRot = Matrix4D.Identity; Vector3D vTranslation = Vector3D.Zero; if (_swapped && !layer.Inversed) { matRot = new Matrix4D( 0.0, -1.0, 0.0, 0.0 , 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0); } else if (!_swapped && layer.Inversed) { matRot = new Matrix4D( -1.0, 0.0, 0.0, 0.0 , 0.0, -1.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(layer.PalletLength, layer.PalletWidth, 0.0); } else if (_swapped && layer.Inversed) { matRot = new Matrix4D( 0.0, 1.0, 0.0, 0.0 , -1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(0.0, layer.PalletWidth, 0.0); } Transform3D transfRot = new Transform3D(matRot); HalfAxis.HAxis lengthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis))); HalfAxis.HAxis widthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis))); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; Transform3D transfRotTranslation = new Transform3D(matRot); Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0)); if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped)) { _log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Variant = {1}, Swapped = true", this.Name, _variantIndex)); return; } layer.AddPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped); }
/* * /// <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; * } * * public BBox3D BoundingBox(PackProperties packProperties) * { * 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 + packProperties.Length * vI; * pts[2] = bpos.Position + packProperties.Width * vJ; * pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ; * pts[4] = bpos.Position + packProperties.Height * vK; * pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK; ; * pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * * foreach (Vector3D pt in pts) * bbox.Extend(pt); * } * * return bbox; * } */ 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)); }
public Layer3DBox GetBoxLayer(int iLayerIndex, ref bool hasInterlayer, ref double zInterlayer) { if (null == _parentAnalysis) { throw new Exception("_parentAnalysis not set."); } double interlayerThickness = (null != _parentAnalysis.InterlayerProperties) ? _parentAnalysis.InterlayerProperties.Thickness : 0.0; double packHeight = _parentAnalysis.PackProperties.Height; double zLow = _parentAnalysis.PalletProperties.Height; int i = 0; while (i <= iLayerIndex - 1) { LayerDescriptor desc = _listLayers[i]; zLow += (desc.HasInterlayer ? interlayerThickness : 0.0) + packHeight; ++i; } zInterlayer = zLow; hasInterlayer = _listLayers[iLayerIndex].HasInterlayer; zLow += hasInterlayer ? interlayerThickness : 0.0; Transform3D swapTransform = Transform3D.Identity; if (_listLayers[iLayerIndex].Swapped) { Matrix4D matRot = new Matrix4D( -1.0, 0.0, 0.0, _parentAnalysis.PalletProperties.Length , 0.0, -1.0, 0.0, _parentAnalysis.PalletProperties.Width , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0); swapTransform = new Transform3D(matRot); } // build BoxLayer Layer3DBox layer = new Layer3DBox(zLow + (hasInterlayer ? interlayerThickness : 0.0), 0); foreach (BoxPosition b in _layer) { layer.Add( new BoxPosition( swapTransform.transform(b.Position + zLow * Vector3D.ZAxis) , HalfAxis.Transform(b.DirectionLength, swapTransform) , HalfAxis.Transform(b.DirectionWidth, swapTransform)) ); } return(layer); }
public bool IntersectWithContent(CylPosition cylPosition) { Vector3D cylDirection = HalfAxis.ToVector3D(cylPosition.Direction); foreach (CylPosition c in Positions) { Vector3D vDiff = c.XYZ - cylPosition.XYZ; double axisProj = Vector3D.DotProduct(cylDirection, vDiff); Vector3D vDiffProj = vDiff - axisProj * cylDirection; if (axisProj < CylLength && vDiffProj.GetLength() < CylRadius) { return(true); } } return(false); }
// static methods static public double EstimateWeight( BoxProperties boxProperties, PackArrangement arrangement, HalfAxis.HAxis orientation , int[] noWalls, double thickness, double surfacicMass) { double length = 0.0, width = 0.0, height = 0.0; PackProperties.GetDimensions(boxProperties, orientation, arrangement, ref length, ref width, ref height); Vector3D vDimensions = new Vector3D( length + noWalls[0] * thickness , width + noWalls[1] * thickness , height + noWalls[2] * thickness); double area = (noWalls[0] * vDimensions.Y * vDimensions.Z + noWalls[1] * vDimensions.X * vDimensions.Z + noWalls[2] * vDimensions.X * vDimensions.Y) * UnitsManager.FactorSquareLengthToArea; return area * surfacicMass; }
public static LayerDesc Parse(string value) { Regex r = new Regex(@"(?<name>|(?<axis>))", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { string patternName = m.Result("${name}"); HalfAxis.HAxis axis = HalfAxis.Parse(m.Result("${axis}")); return(new LayerDesc(patternName, axis)); } else { throw new Exception("Failed to parse LayerDesc"); } }
public double Dimension(HalfAxis.HAxis axis) { switch (axis) { case HalfAxis.HAxis.AXIS_X_N: case HalfAxis.HAxis.AXIS_X_P: return _length; case HalfAxis.HAxis.AXIS_Y_N: case HalfAxis.HAxis.AXIS_Y_P: return _width; case HalfAxis.HAxis.AXIS_Z_N: case HalfAxis.HAxis.AXIS_Z_P: return Height; default: return 0.0; } }
public static LayerDesc Parse(string value) { Regex r = new Regex(@"(?<name>.*)\|(?<axis>.*)\|(?<swap>.*)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { string patternName = m.Result("${name}"); HalfAxis.HAxis axis = HalfAxis.Parse(m.Result("${axis}")); bool swapped = string.Equals("t", m.Result("${swap}"), StringComparison.CurrentCultureIgnoreCase); return(new LayerDescBox(patternName, axis, swapped)); } else { throw new Exception("Failed to parse LayerDesc"); } }
public override bool AllowOrientation(HalfAxis.HAxis axisOrtho) { switch (axisOrtho) { case HalfAxis.HAxis.AXIS_X_N: case HalfAxis.HAxis.AXIS_X_P: return _axesAllowed[0]; case HalfAxis.HAxis.AXIS_Y_N: case HalfAxis.HAxis.AXIS_Y_P: return _axesAllowed[1]; case HalfAxis.HAxis.AXIS_Z_N: case HalfAxis.HAxis.AXIS_Z_P: return _axesAllowed[2]; default: throw new Exception("Invalid axis"); } }
public void MinMax(double boxLength, double boxWidth, out Vector2D vMin, out Vector2D vMax) { Vector3D[] pts = new Vector3D[4]; pts[0] = new Vector3D(_position.X, _position.Y, 0.0); pts[1] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength; pts[2] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_widthAxis) * boxWidth; pts[3] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength + HalfAxis.ToVector3D(_widthAxis) * boxWidth; vMin = new Vector2D(double.MaxValue, double.MaxValue); vMax = new Vector2D(double.MinValue, double.MinValue); foreach (Vector3D v in pts) { vMin.X = Math.Min(v.X, vMin.X); vMin.Y = Math.Min(v.Y, vMin.Y); vMax.X = Math.Max(v.X, vMax.X); vMax.Y = Math.Max(v.Y, vMax.Y); } }
private BBox3D ComputeLoadBBox3D() { double palletLength = ParentTruckAnalysis.ParentSolution.PalletLength; double palletWidth = ParentTruckAnalysis.ParentSolution.PalletWidth; double palletHeight = ParentTruckAnalysis.ParentSolution.PalletHeight; BBox3D bbox = new BBox3D(); int iLayer = 0; while (iLayer < NoLayers) { foreach (BoxPosition bPositionLayer in Layer) { // actual position in load BoxPosition bpos = new BoxPosition( new Vector3D( bPositionLayer.Position.X , bPositionLayer.Position.Y , bPositionLayer.Position.Z + palletHeight * iLayer) , bPositionLayer.DirectionLength , bPositionLayer.DirectionWidth); 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 + palletLength * vI; pts[2] = bpos.Position + palletWidth * vJ; pts[3] = bpos.Position + palletLength * vI + palletWidth * vJ; pts[4] = bpos.Position + palletHeight * vK; pts[5] = bpos.Position + palletWidth * vJ + palletHeight * vK;; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * palletWidth; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * palletLength + HalfAxis.ToVector3D(bpos.DirectionWidth) * palletWidth; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } ++iLayer; } return(bbox); }
public bool IsValidPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // check layerPos // get 4 points Vector3D[] pts = new Vector3D[4]; pts[0] = new Vector3D(vPosition.X, vPosition.Y, 0.0); pts[1] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(lengthAxis) * BoxLength; pts[2] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(widthAxis) * BoxWidth; pts[3] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(lengthAxis) * BoxLength + HalfAxis.ToVector3D(widthAxis) * BoxWidth; foreach (Vector3D pt in pts) { if (pt.X < (0.0 - _epsilon) || pt.X > (DimContainer.X + _epsilon) || pt.Y < (0.0 - _epsilon) || pt.Y > (DimContainer.Y + _epsilon)) { return(false); } } return(true); }
private LayerPosition ApplyReflection(LayerPosition layerPos, Matrix4D matRot, Vector3D vTranslation) { Vector3D dimensions = Analysis.ContentDimensions; Transform3D transfRot = new Transform3D(matRot); HalfAxis.HAxis axisLength = HalfAxis.ToHalfAxis(transfRot.transform(HalfAxis.ToVector3D(layerPos.LengthAxis))); HalfAxis.HAxis axisWidth = HalfAxis.ToHalfAxis(transfRot.transform(HalfAxis.ToVector3D(layerPos.WidthAxis))); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; Transform3D transfRotTranslation = new Transform3D(matRot); Vector3D transPos = transfRotTranslation.transform(new Vector3D(layerPos.Position.X, layerPos.Position.Y, layerPos.Position.Z)); return(new LayerPosition( new Vector3D(transPos.X, transPos.Y, transPos.Z) - dimensions.Z * Vector3D.CrossProduct(HalfAxis.ToVector3D(axisLength), HalfAxis.ToVector3D(axisWidth)) , axisLength , axisWidth)); }
private Vector3D[] Points(Vector3D dim) { Vector3D position = Position; Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); var points = new Vector3D[8]; points[0] = position; points[1] = position + dim[0] * vI; points[2] = position + dim[0] * vI + dim[1] * vJ; points[3] = position + dim[1] * vJ; points[4] = position + dim[2] * vK; points[5] = position + dim[2] * vK + dim[0] * vI; points[6] = position + dim[2] * vK + dim[0] * vI + dim[1] * vJ; points[7] = position + dim[2] * vK + dim[1] * vJ; return(points); }
public BBox3D BBox(Vector3D dimensions) { BBox3D bbox = new BBox3D(); Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); Vector3D[] pts = new Vector3D[8]; pts[0] = Position; pts[1] = Position + dimensions.X * vI; pts[2] = Position + dimensions.Y * vJ; pts[3] = Position + dimensions.X * vI + dimensions.Y * vJ; pts[4] = Position + dimensions.Z * vK; pts[5] = Position + dimensions.Y * vJ + dimensions.Z * vK; pts[6] = Position + HalfAxis.ToVector3D(DirectionWidth) * dimensions.Y; pts[7] = Position + HalfAxis.ToVector3D(DirectionLength) * dimensions.X + HalfAxis.ToVector3D(DirectionWidth) * dimensions.Y; foreach (Vector3D pt in pts) { bbox.Extend(pt); } return(bbox); }
public BBox3D(BoxPosition bPos, Vector3D dim) { Vector3D lengthAxis = HalfAxis.ToVector3D(bPos.DirectionLength); Vector3D widthAxis = HalfAxis.ToVector3D(bPos.DirectionWidth); Vector3D heightAxis = HalfAxis.ToVector3D(bPos.DirectionHeight); var points = new Vector3D[8]; points[0] = bPos.Position; points[1] = bPos.Position + dim[0] * lengthAxis; points[2] = bPos.Position + dim[0] * lengthAxis + dim[1] * widthAxis; points[3] = bPos.Position + dim[1] * widthAxis; points[4] = bPos.Position + dim[2] * heightAxis; points[5] = bPos.Position + dim[2] * heightAxis + dim[0] * lengthAxis; points[6] = bPos.Position + dim[2] * heightAxis + dim[0] * lengthAxis + dim[1] * widthAxis; points[7] = bPos.Position + dim[2] * heightAxis + dim[1] * widthAxis; foreach (var pt in points) { Extend(pt); } }
public void SetFaceColor(HalfAxis.HAxis iFace, Color color) { _colors[(int)iFace] = color; }
public void SetColor(HalfAxis.HAxis axis, Color color) { _colors[(int)axis] = color; Modify(); }
public TriangleIndices[] TrianglesByFace(HalfAxis.HAxis axis) { TriangleIndices[] tri = new TriangleIndices[2]; ulong n = (ulong)axis; switch (axis) { case HalfAxis.HAxis.AXIS_X_N: tri[0] = new TriangleIndices(0, 4, 3, n, n, n, 1, 2, 0); tri[1] = new TriangleIndices(3, 4, 7, n, n, n, 0, 2, 3); break; case HalfAxis.HAxis.AXIS_X_P: tri[0] = new TriangleIndices(1, 2, 5, n, n, n, 0, 1, 3); tri[1] = new TriangleIndices(5, 2, 6, n, n, n, 3, 1, 2); break; case HalfAxis.HAxis.AXIS_Y_N: tri[0] = new TriangleIndices(0, 1, 4, n, n, n, 0, 1, 3); tri[1] = new TriangleIndices(4, 1, 5, n, n, n, 3, 1, 2); break; case HalfAxis.HAxis.AXIS_Y_P: tri[0] = new TriangleIndices(7, 6, 2, n, n, n, 2, 3, 0); tri[1] = new TriangleIndices(7, 2, 3, n, n, n, 2, 0, 1); break; case HalfAxis.HAxis.AXIS_Z_N: tri[0] = new TriangleIndices(0, 3, 1, n, n, n, 2, 0, 3); tri[1] = new TriangleIndices(1, 3, 2, n, n, n, 3, 0, 1); break; case HalfAxis.HAxis.AXIS_Z_P: tri[0] = new TriangleIndices(4, 5, 7, n, n, n, 0, 1, 2); tri[1] = new TriangleIndices(7, 5, 6, n, n, n, 2, 1, 3); break; default: Debug.Assert(false); break; } return tri; }
public void SetFaceTextures(HalfAxis.HAxis iFace, List<Texture> textures) { _textureLists[(int)iFace] = textures; }
public override Color GetColor(HalfAxis.HAxis axis) { return _color; }
public static void GetDimensions( BoxProperties boxProperties , HalfAxis.HAxis boxOrientation , PackArrangement arrangement , ref double length, ref double width, ref double height) { if (null == boxProperties) return; length = arrangement._iLength * boxProperties.Dim(PackProperties.DimIndex0(boxOrientation)); width = arrangement._iWidth * boxProperties.Dim(PackProperties.DimIndex1(boxOrientation)); height = arrangement._iHeight * boxProperties.Dim(3 - PackProperties.DimIndex0(boxOrientation) - PackProperties.DimIndex1(boxOrientation)); }
private Layer2D BuildLayer(PackProperties packProperties, PalletProperties palletProperties, PackPalletConstraintSet constraintSet, HalfAxis.HAxis axisOrtho, bool swapped, bool inversed) { double forcedSpace = constraintSet.MinimumSpace.Value; return new Layer2D( new Vector3D(packProperties.Length + forcedSpace, packProperties.Width + forcedSpace, packProperties.Height) , new Vector2D( palletProperties.Length + constraintSet.OverhangX + forcedSpace , _palletProperties.Width + constraintSet.OverhangY + forcedSpace) , axisOrtho, swapped); }
public override bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis) { return (orthoAxis == HalfAxis.HAxis.AXIS_Z_N) || (orthoAxis == HalfAxis.HAxis.AXIS_Z_P); }
public override string ToString() => string.Format("{0}|{1}|{2}", PatternName, HalfAxis.ToString(AxisOrtho), Swapped ? "t" : "f");
abstract public bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis);
public override bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis) { return _allowedOrthoAxis[(int)orthoAxis]; }
Layer2D BuildLayer(BoxProperties boxP, BoxProperties caseP, HalfAxis.HAxis orthoAxis, bool swapped) { return new Layer2D(new Vector3D(boxP.Length, boxP.Width, boxP.Height) , new Vector2D(caseP.InsideLength, caseP.InsideWidth) , orthoAxis , swapped); }
public override Color GetColor(HalfAxis.HAxis axis) { return _colors[(int)axis]; }
/// <summary> /// Texture pair /// </summary> /// <param name="axis">Face normal axis</param> /// <param name="position">Position</param> /// <param name="size">Size</param> /// <param name="angle">Angle</param> /// <param name="bmp">Image used as texture</param> public void AddTexture(HalfAxis.HAxis axis, Vector2D position, Vector2D size, double angle, Bitmap bmp) { _textures.Add(new Pair<HalfAxis.HAxis, Texture>(axis, new Texture(bmp, position, size, angle))); Modify(); }
public void SetAllowedOrthoAxis(HalfAxis.HAxis axis, bool allowed) { _allowedOrthoAxis[(int)axis] = allowed; }
abstract public Color GetColor(HalfAxis.HAxis axis);
private static int DimIndex1(HalfAxis.HAxis axis) { switch (axis) { case HalfAxis.HAxis.AXIS_X_N: return 2; case HalfAxis.HAxis.AXIS_X_P: return 1; case HalfAxis.HAxis.AXIS_Y_N: return 2; case HalfAxis.HAxis.AXIS_Y_P: return 0; case HalfAxis.HAxis.AXIS_Z_N: return 0; case HalfAxis.HAxis.AXIS_Z_P: return 1; default: return 1; } }
public override string Tooltip(double height) => $"{Count} * {NoLayers(height)} = {CountInHeight(height)}\n {HalfAxis.ToString(AxisOrtho)} | {PatternName} | {SwappedString}";
/// <summary> /// Create a new pack /// </summary> /// <param name="name">Name</param> /// <param name="description">Description</param> /// <param name="box">Inner box</param> /// <param name="arrangement">Arrangement</param> /// <param name="axis">Axis</param> /// <param name="wrapper">Wrapper</param> /// <returns></returns> public PackProperties CreateNewPack( string name, string description , BoxProperties box , PackArrangement arrangement , HalfAxis.HAxis axis , PackWrapper wrapper) { // instantiate and initialize PackProperties packProperties = new PackProperties(this , box , arrangement , axis , wrapper); packProperties.Name = name; packProperties.Description = description; // insert in list _typeList.Add(packProperties); // notify listeners NotifyOnNewTypeCreated(packProperties); Modify(); return packProperties; }
/// <summary> /// constructor /// </summary> /// <param name="doc">Reference of parent <see cref="Document"/></param> /// <param name="box">Reference </param> public PackProperties(Document doc , BoxProperties box , PackArrangement arrangement , HalfAxis.HAxis orientation , PackWrapper wrapper) : base(doc) { _boxProperties = box; _boxProperties.AddDependancy(this); _arrangement = arrangement; _orientation = orientation; _wrapper = wrapper; }
public CylPosition(Vector3D vPosition, HalfAxis.HAxis axis) { _vPosition = vPosition; _axis = axis; }
public Orientation(HalfAxis.HAxis dir0, HalfAxis.HAxis dir1) { _dir0 = dir0; _dir1 = dir1; }
public Position(int index, Vector3D xyz, HalfAxis.HAxis axis1, HalfAxis.HAxis axis2) { _index = index; _xyz = xyz; _axis1 = axis1; _axis2 = axis2; }