Ejemplo n.º 1
0
 protected override void Initialize()
 {
     base.Initialize();
     this.ClipBoundaryDefinitionPoints = new ListNonNull <DxfPoint>();
     this.ClipBoundaryNormal           = DxfVector.ZAxis;
     this.ClipBoundaryOrigin           = DxfPoint.Origin;
     this.IsClipBoundaryEnabled        = false;
     this.IsFrontClippingPlane         = true;
     this.FrontClippingPlaneDistance   = 0;
     this.IsBackClippingPlane          = false;
     this.BackClippingPlaneDistance    = 0;
     this.InverseTransformationMatrix  = DxfTransformationMatrix.Identity;
     this.TransformationMatrix         = DxfTransformationMatrix.Identity;
 }
Ejemplo n.º 2
0
 protected override DxfObject PostParse()
 {
     DiffuseMapTransformMatrix    = new DxfTransformationMatrix(_diffuseMapTransformMatrixValues.ToArray());
     SpecularMapTransformMatrix   = new DxfTransformationMatrix(_specularMapTransformMatrixValues.ToArray());
     ReflectionMapTransformMatrix = new DxfTransformationMatrix(_reflectionMapTransformMatrixValues.ToArray());
     OpacityMapTransformMatrix    = new DxfTransformationMatrix(_opacityMapTransformMatrixValues.ToArray());
     BumpMapTransformMatrix       = new DxfTransformationMatrix(_bumpMapTransformMatrixValues.ToArray());
     RefractionMapTransformMatrix = new DxfTransformationMatrix(_refractionMapTransformMatrixValues.ToArray());
     NormalMapTransformMatrix     = new DxfTransformationMatrix(_normalMapTransformMatrixValues.ToArray());
     _diffuseMapTransformMatrixValues.Clear();
     _specularMapTransformMatrixValues.Clear();
     _reflectionMapTransformMatrixValues.Clear();
     _opacityMapTransformMatrixValues.Clear();
     _bumpMapTransformMatrixValues.Clear();
     _refractionMapTransformMatrixValues.Clear();
     _normalMapTransformMatrixValues.Clear();
     return(this);
 }
Ejemplo n.º 3
0
        internal override DxfObject PopulateFromBuffer(DxfCodePairBufferReader buffer)
        {
            var hasReadFrontClippingPlane = false;
            var hasSetInverseMatrix       = false;
            var matrixList = new List <double>();

            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == 0)
                {
                    break;
                }

                while (this.TrySetExtensionData(pair, buffer))
                {
                    pair = buffer.Peek();
                }

                switch (pair.Code)
                {
                case 70:
                    var boundaryPointCount = pair.ShortValue;
                    break;

                case 10:
                    // code 10 always starts a new point
                    ClipBoundaryDefinitionPoints.Add(new DxfPoint());
                    ClipBoundaryDefinitionPoints.Last().X = pair.DoubleValue;
                    break;

                case 20:
                    ClipBoundaryDefinitionPoints.Last().Y = pair.DoubleValue;
                    break;

                case 30:
                    ClipBoundaryDefinitionPoints.Last().Z = pair.DoubleValue;
                    break;

                case 11:
                    ClipBoundaryOrigin.X = pair.DoubleValue;
                    break;

                case 12:
                    ClipBoundaryOrigin.Y = pair.DoubleValue;
                    break;

                case 13:
                    ClipBoundaryOrigin.Z = pair.DoubleValue;
                    break;

                case 40:
                    if (!hasReadFrontClippingPlane)
                    {
                        FrontClippingPlaneDistance = pair.DoubleValue;
                        hasReadFrontClippingPlane  = true;
                    }
                    else
                    {
                        matrixList.Add(pair.DoubleValue);
                        if (matrixList.Count == 12)
                        {
                            var m11    = matrixList[0];
                            var m21    = matrixList[1];
                            var m31    = matrixList[2];
                            var m41    = 0.0;
                            var m12    = matrixList[0];
                            var m22    = matrixList[1];
                            var m32    = matrixList[2];
                            var m42    = 0.0;
                            var m13    = matrixList[0];
                            var m23    = matrixList[1];
                            var m33    = matrixList[2];
                            var m43    = 0.0;
                            var m14    = matrixList[0];
                            var m24    = matrixList[1];
                            var m34    = matrixList[2];
                            var m44    = 0.0;
                            var matrix = new DxfTransformationMatrix(
                                m11, m12, m13, m14,
                                m21, m22, m23, m24,
                                m31, m32, m33, m34,
                                m41, m42, m43, m44);
                            if (!hasSetInverseMatrix)
                            {
                                InverseTransformationMatrix = matrix;
                                hasSetInverseMatrix         = true;
                            }
                            else
                            {
                                TransformationMatrix = matrix;
                            }

                            matrixList.Clear();
                        }
                    }
                    break;

                case 41:
                    BackClippingPlaneDistance = pair.DoubleValue;
                    break;

                case 71:
                    IsClipBoundaryEnabled = BoolShort(pair.ShortValue);
                    break;

                case 72:
                    IsFrontClippingPlane = BoolShort(pair.ShortValue);
                    break;

                case 73:
                    IsBackClippingPlane = BoolShort(pair.ShortValue);
                    break;

                case 210:
                    ClipBoundaryNormal.X = pair.DoubleValue;
                    break;

                case 220:
                    ClipBoundaryNormal.Y = pair.DoubleValue;
                    break;

                case 230:
                    ClipBoundaryNormal.Z = pair.DoubleValue;
                    break;

                default:
                    if (!TrySetPair(pair))
                    {
                        ExcessCodePairs.Add(pair);
                    }
                    break;
                }

                buffer.Advance();
            }

            Debug.Assert(matrixList.Count == 0);
            return(PostParse());
        }
Ejemplo n.º 4
0
        internal override DxfObject PopulateFromBuffer(DxfCodePairBufferReader buffer)
        {
            var hasReadFrontClippingPlane = false;
            var hasSetInverseMatrix = false;
            var matrixList = new List<double>();
            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == 0)
                {
                    break;
                }

                while (this.TrySetExtensionData(pair, buffer))
                {
                    pair = buffer.Peek();
                }

                switch (pair.Code)
                {
                    case 70:
                        var boundaryPointCount = pair.ShortValue;
                        break;
                    case 10:
                        // code 10 always starts a new point
                        ClipBoundaryDefinitionPoints.Add(new DxfPoint());
                        ClipBoundaryDefinitionPoints.Last().X = pair.DoubleValue;
                        break;
                    case 20:
                        ClipBoundaryDefinitionPoints.Last().Y = pair.DoubleValue;
                        break;
                    case 30:
                        ClipBoundaryDefinitionPoints.Last().Z = pair.DoubleValue;
                        break;
                    case 11:
                        ClipBoundaryOrigin.X = pair.DoubleValue;
                        break;
                    case 12:
                        ClipBoundaryOrigin.Y = pair.DoubleValue;
                        break;
                    case 13:
                        ClipBoundaryOrigin.Z = pair.DoubleValue;
                        break;
                    case 40:
                        if (!hasReadFrontClippingPlane)
                        {
                            FrontClippingPlaneDistance = pair.DoubleValue;
                            hasReadFrontClippingPlane = true;
                        }
                        else
                        {
                            matrixList.Add(pair.DoubleValue);
                            if (matrixList.Count == 12)
                            {
                                var m11 = matrixList[0];
                                var m21 = matrixList[1];
                                var m31 = matrixList[2];
                                var m41 = 0.0;
                                var m12 = matrixList[0];
                                var m22 = matrixList[1];
                                var m32 = matrixList[2];
                                var m42 = 0.0;
                                var m13 = matrixList[0];
                                var m23 = matrixList[1];
                                var m33 = matrixList[2];
                                var m43 = 0.0;
                                var m14 = matrixList[0];
                                var m24 = matrixList[1];
                                var m34 = matrixList[2];
                                var m44 = 0.0;
                                var matrix = new DxfTransformationMatrix(
                                        m11, m12, m13, m14,
                                        m21, m22, m23, m24,
                                        m31, m32, m33, m34,
                                        m41, m42, m43, m44);
                                if (!hasSetInverseMatrix)
                                {
                                    InverseTransformationMatrix = matrix;
                                    hasSetInverseMatrix = true;
                                }
                                else
                                {
                                    TransformationMatrix = matrix;
                                }

                                matrixList.Clear();
                            }
                        }
                        break;
                    case 41:
                        BackClippingPlaneDistance = pair.DoubleValue;
                        break;
                    case 71:
                        IsClipBoundaryEnabled = BoolShort(pair.ShortValue);
                        break;
                    case 72:
                        IsFrontClippingPlane = BoolShort(pair.ShortValue);
                        break;
                    case 73:
                        IsBackClippingPlane = BoolShort(pair.ShortValue);
                        break;
                    case 210:
                        ClipBoundaryNormal.X = pair.DoubleValue;
                        break;
                    case 220:
                        ClipBoundaryNormal.Y = pair.DoubleValue;
                        break;
                    case 230:
                        ClipBoundaryNormal.Z = pair.DoubleValue;
                        break;
                    default:
                        if (!TrySetPair(pair))
                        {
                            ExcessCodePairs.Add(pair);
                        }
                        break;
                }

                buffer.Advance();
            }

            Debug.Assert(matrixList.Count == 0);
            return PostParse();
        }