Esempio n. 1
0
 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 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);
        }