public CylPosition Transform(Transform3D transf) { return(new CylPosition( transf.transform(_vPosition), HalfAxis.ToHalfAxis(transf.transformRot(HalfAxis.ToVector3D(_axis))) )); }
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 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 static CylPosition Transform(CylPosition cylPosition, Transform3D transform) { return(new CylPosition( transform.transform(cylPosition._vPosition), HalfAxis.ToHalfAxis( transform.transformRot(HalfAxis.ToVector3D(cylPosition._axis)) ) )); }
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 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> /// 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 BoxLayer 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 BoxLayer layer = new BoxLayer(zLow + (hasInterlayer ? interlayerThickness : 0.0), _layer.PatternName); 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 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; } }
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 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)); }
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 override bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis) { return (orthoAxis == HalfAxis.HAxis.AXIS_Z_N) || (orthoAxis == HalfAxis.HAxis.AXIS_Z_P); }
public static HAxis Transform(HAxis axis, Transform3D transform) { return(HalfAxis.ToHalfAxis(transform.transformRot(HalfAxis.ToVector3D(axis)))); }
public void SetPosition(Vector3D position, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { _position = position; _lengthAxis = lengthAxis; _widthAxis = widthAxis; }
// static methods public static 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; }
/// <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> /// 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 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; }
private void FillBitmapControl(HalfAxis.HAxis iFace) { List<Texture> listTexture = new List<Texture>(); foreach (Pair<HalfAxis.HAxis, Texture> p in _textures) if (p.first == iFace) listTexture.Add(p.second); listBoxTextures.SetTextureList(listTexture); }
public Orientation(HalfAxis.HAxis dir0, HalfAxis.HAxis dir1) { _dir0 = dir0; _dir1 = dir1; }
public override Color GetColor(HalfAxis.HAxis axis) { return _color; }
public override Color GetColor(HalfAxis.HAxis axis) { return _colors[(int)axis]; }
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 void SetAllowedOrthoAxis(HalfAxis.HAxis axis, bool allowed) { _allowedOrthoAxis[(int)axis] = allowed; }
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; }
public abstract bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis);
public CylPosition(Vector3D vPosition, HalfAxis.HAxis axis) { _vPosition = vPosition; _axis = axis; }
public override bool AllowOrthoAxis(HalfAxis.HAxis orthoAxis) { return _allowedOrthoAxis[(int)orthoAxis]; }
public Position(int index, Vector3D xyz, HalfAxis.HAxis axis1, HalfAxis.HAxis axis2) { _index = index; _xyz = xyz; _axis1 = axis1; _axis2 = axis2; }
public override string ToString() { return(string.Format("{0} | ({1},{2})", _vPosition, HalfAxis.ToString(_axisLength), HalfAxis.ToString(_axisWidth))); }
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 BoxPosition(Vector3D vPosition, HalfAxis.HAxis dirLength, HalfAxis.HAxis dirWidth) { _vPosition = vPosition; _axisLength = dirLength; _axisWidth = dirWidth; }
public void SetFaceTextures(HalfAxis.HAxis iFace, List<Texture> textures) { _textureLists[(int)iFace] = textures; }