Beispiel #1
0
        public LayerPosition Adjusted(Vector3D dimensions)
        {
            LayerPosition layerPosTemp = new LayerPosition(this);

            // reverse if oriented to Z- (AXIS_Z_N)
            if (HeightAxis == HalfAxis.HAxis.AXIS_Z_N)
            {
                if (LengthAxis == HalfAxis.HAxis.AXIS_X_P)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_Y_P;
                    layerPosTemp.Position += new Vector3D(0.0, -dimensions.Y, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_Y_P)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_N;
                    layerPosTemp.Position += new Vector3D(dimensions.Y, 0.0, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_X_N)
                {
                    layerPosTemp.LengthAxis = HalfAxis.HAxis.AXIS_X_P;
                    layerPosTemp.Position  += new Vector3D(-dimensions.X, 0.0, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_Y_N)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_P;
                    layerPosTemp.Position += new Vector3D(-dimensions.Y, 0.0, -dimensions.Z);
                }
            }

            return(layerPosTemp);
        }
Beispiel #2
0
        /// <summary>
        /// returns 3D layer. This is only used in LayerSummary
        /// </summary>
        internal ILayer GetILayer(int layerIndex, bool symX, bool symY)
        {
            ILayer2D currentLayer = _layerTypes[layerIndex];

            if (currentLayer is Layer2D)
            {
                Layer2D    layer2DBox = currentLayer as Layer2D;
                Layer3DBox boxLayer   = new Layer3DBox(0.0, layerIndex);
                foreach (LayerPosition layerPos in layer2DBox)
                {
                    LayerPosition layerPosTemp = AdjustLayerPosition(layerPos, symX, symY);
                    boxLayer.Add(new BoxPosition(
                                     layerPosTemp.Position + Analysis.Offset
                                     , layerPosTemp.LengthAxis
                                     , layerPosTemp.WidthAxis
                                     ));
                }
                return(boxLayer);
            }

            if (currentLayer is Layer2DCyl)
            {
                Layer2DCyl layer2DCyl = currentLayer as Layer2DCyl;
                Layer3DCyl cylLayer   = new Layer3DCyl(0.0);
                foreach (Vector2D vPos in layer2DCyl)
                {
                    cylLayer.Add(
                        AdjustPosition(new Vector3D(vPos.X, vPos.Y, 0.0), symX, symY)
                        + Analysis.Offset);
                }
                return(cylLayer);
            }
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// if box bottom oriented to Z+, reverse box
        /// </summary>
        private LayerPosition AdjustLayerPosition(LayerPosition layerPos, bool reflectionX, bool reflectionY)
        {
            Vector3D dimensions    = Analysis.ContentDimensions;
            Vector2D containerDims = Analysis.ContainerDimensions;

            // implement change
            LayerPosition layerPosTemp = new LayerPosition(layerPos);

            // apply symetry in X
            if (reflectionX)
            {
                Matrix4D 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
                    );
                Vector3D vTranslation = new Vector3D(0.0, containerDims.Y, 0.0);
                layerPosTemp = ApplyReflection(layerPosTemp, matRot, vTranslation);
            }
            // apply symetry in Y
            if (reflectionY)
            {
                Matrix4D 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
                    );
                Vector3D vTranslation = new Vector3D(containerDims.X, 0.0, 0.0);
                layerPosTemp = ApplyReflection(layerPosTemp, matRot, vTranslation);
            }
            return(layerPosTemp.Adjusted(dimensions));
        }
 /// <summary>
 /// if box bottom oriented to Z+, reverse box
 /// </summary>
 private LayerPosition AdjustLayerPosition(LayerPosition layerPos)
 {
     LayerPosition layerPosTemp = layerPos;
     if (layerPosTemp.HeightAxis == HalfAxis.HAxis.AXIS_Z_N)
     {
         if (layerPosTemp.LengthAxis == HalfAxis.HAxis.AXIS_X_P)
         {
             layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_Y_P;
             layerPosTemp.Position += new Vector3D(0.0, -_packProperties.Width, -_packProperties.Height);
         }
         else if (layerPos.LengthAxis == HalfAxis.HAxis.AXIS_Y_P)
         {
             layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_N;
             layerPosTemp.Position += new Vector3D(_packProperties.Width, 0.0, -_packProperties.Height);
         }
         else if (layerPos.LengthAxis == HalfAxis.HAxis.AXIS_X_N)
         {
             layerPosTemp.LengthAxis = HalfAxis.HAxis.AXIS_X_P;
             layerPosTemp.Position += new Vector3D(-_packProperties.Length, 0.0, -_packProperties.Height);
         }
         else if (layerPos.LengthAxis == HalfAxis.HAxis.AXIS_Y_N)
         {
             layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_P;
             layerPosTemp.Position += new Vector3D(-_packProperties.Width, 0.0, -_packProperties.Height);
         }
     }
     return layerPosTemp;
 }
Beispiel #5
0
        public static bool Intersect(LayerPosition p1, LayerPosition p2, double boxLength, double boxWidth)
        {
            Vector2D v1Min, v1Max, v2Min, v2Max;
            p1.MinMax(boxLength, boxWidth, out v1Min, out v1Max);
            p2.MinMax(boxLength, boxWidth, out v2Min, out v2Max);

            if (v1Max.X <= v2Min.X || v2Max.X <= v1Min.X || v1Max.Y <= v2Min.Y || v2Max.Y <= v1Min.Y)
                return false;
            return true;
        }
Beispiel #6
0
        public static bool Intersect(LayerPosition p1, LayerPosition p2, double boxLength, double boxWidth)
        {
            Vector2D v1Min, v1Max, v2Min, v2Max;

            p1.MinMax(boxLength, boxWidth, out v1Min, out v1Max);
            p2.MinMax(boxLength, boxWidth, out v2Min, out v2Max);

            if (v1Max.X <= v2Min.X || v2Max.X <= v1Min.X || v1Max.Y <= v2Min.Y || v2Max.Y <= v1Min.Y)
            {
                return(false);
            }
            return(true);
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
 public LayerPosition(LayerPosition pos)
 {
     _position   = pos._position;
     _lengthAxis = pos._lengthAxis;
     _widthAxis  = pos._widthAxis;
 }
Beispiel #9
0
        public Box(uint pickId, BProperties bProperties, LayerPosition 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.LengthAxis);
            // set direction width
            WidthAxis = HalfAxis.ToVector3D(bPosition.WidthAxis);
            // IsBundle ?
            _isBundle = bProperties.IsBundle;
            if (bProperties.IsBundle)
            {
                BundleProperties bundleProp = bProperties as BundleProperties;
                if (null != bundleProp)
                    _noFlats = bundleProp.NoFlats;
            }
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        /// <summary>
        /// if box bottom oriented to Z+, reverse box
        /// </summary>
        private LayerPosition AdjustLayerPosition(LayerPosition layerPos, bool reflectionX, bool reflectionY)
        {
            
            Vector3D dimensions = Analysis.ContentDimensions;
            Vector2D containerDims = Analysis.ContainerDimensions;

            // implement change
            LayerPosition layerPosTemp = new LayerPosition(layerPos);

            // apply symetry in X
            if (reflectionX)
            {
                Matrix4D 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
                  );
                Vector3D vTranslation = new Vector3D(0.0, containerDims.Y, 0.0);
                layerPosTemp = ApplyReflection(layerPosTemp, matRot, vTranslation);
            }
            // apply symetry in Y
            if (reflectionY)
            {
                Matrix4D 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
                    );
                Vector3D vTranslation = new Vector3D(containerDims.X, 0.0, 0.0);
                layerPosTemp = ApplyReflection(layerPosTemp, matRot, vTranslation);
            }
            return layerPosTemp.Adjusted(dimensions);
        }
Beispiel #12
0
        public LayerPosition Adjusted(Vector3D dimensions)
        {
            LayerPosition layerPosTemp = new LayerPosition(this);

            // reverse if oriented to Z- (AXIS_Z_N)
            if (HeightAxis == HalfAxis.HAxis.AXIS_Z_N)
            {
                if (LengthAxis == HalfAxis.HAxis.AXIS_X_P)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_Y_P;
                    layerPosTemp.Position += new Vector3D(0.0, -dimensions.Y, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_Y_P)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_N;
                    layerPosTemp.Position += new Vector3D(dimensions.Y, 0.0, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_X_N)
                {
                    layerPosTemp.LengthAxis = HalfAxis.HAxis.AXIS_X_P;
                    layerPosTemp.Position += new Vector3D(-dimensions.X, 0.0, -dimensions.Z);
                }
                else if (LengthAxis == HalfAxis.HAxis.AXIS_Y_N)
                {
                    layerPosTemp.WidthAxis = HalfAxis.HAxis.AXIS_X_P;
                    layerPosTemp.Position += new Vector3D(-dimensions.Y, 0.0, -dimensions.Z);
                }
            }

            return layerPosTemp;
        }
Beispiel #13
0
 public LayerPosition(LayerPosition pos)
 {
     _position = pos._position;
     _lengthAxis = pos._lengthAxis;
     _widthAxis = pos._widthAxis;
 }