示例#1
0
        /// <summary>
        /// Creates a new Wipeout that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Wipeout that is a copy of this instance.</returns>
        public override object Clone()
        {
            Wipeout entity = new Wipeout((ClippingBoundary)this.ClippingBoundary.Clone())
            {
                //EntityObject properties
                Layer         = (Layer)this.layer.Clone(),
                LineType      = (LineType)this.lineType.Clone(),
                Color         = (AciColor)this.color.Clone(),
                Lineweight    = (Lineweight)this.lineweight.Clone(),
                Transparency  = (Transparency)this.transparency.Clone(),
                LineTypeScale = this.lineTypeScale,
                Normal        = this.normal,
                //Wipeout properties
                //Brightness = this.brightness,
                //Contrast = this.contrast,
                //Fade = this.fade,
                Elevation = this.elevation
            };

            foreach (XData data in this.xData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
示例#2
0
        /// <summary>
        /// Creates a new Wipeout that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Wipeout that is a copy of this instance.</returns>
        public override object Clone()
        {
            Wipeout entity = new Wipeout((ClippingBoundary)this.ClippingBoundary.Clone())
            {
                //EntityObject properties
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsVisible     = this.IsVisible,
                //Wipeout properties
                Elevation = this.elevation
            };

            foreach (XData data in this.XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
        private void WriteWipeout(Wipeout wipeout)
        {
            this.chunk.Write(100, SubclassMarker.Wipeout);

            BoundingRectangle br = new BoundingRectangle(wipeout.ClippingBoundary.Vertexes);
            
            Vector3 ocsInsPoint = new Vector3(br.Min.X, br.Min.Y, wipeout.Elevation);
            double w = br.Width;
            double h = br.Height;
            double max = w >= h ? w : h;
            Vector3 ocsUx = new Vector3(max, 0.0, 0.0);
            Vector3 ocsUy = new Vector3(0.0, max, 0.0);

            IList<Vector3> wcsPoints = MathHelper.Transform(new List<Vector3>{ocsInsPoint, ocsUx, ocsUy}, wipeout.Normal, CoordinateSystem.Object, CoordinateSystem.World);

            // Insertion point in WCS
            this.chunk.Write(10, wcsPoints[0].X);
            this.chunk.Write(20, wcsPoints[0].Y);
            this.chunk.Write(30, wcsPoints[0].Z);

            // U vector in WCS
            this.chunk.Write(11, wcsPoints[1].X);
            this.chunk.Write(21, wcsPoints[1].Y);
            this.chunk.Write(31, wcsPoints[1].Z);

            // V vector in WCS
            this.chunk.Write(12, wcsPoints[2].X);
            this.chunk.Write(22, wcsPoints[2].Y);
            this.chunk.Write(32, wcsPoints[2].Z);

            this.chunk.Write(13, 1.0);
            this.chunk.Write(23, 1.0);

            //this.chunk.Write(280, wipeout.ShowClippingFrame ? (short) 1 : (short) 0);
            this.chunk.Write(280, (short)1);
            this.chunk.Write(281, (short)50);
            this.chunk.Write(282, (short)50);
            this.chunk.Write(283, (short)0);

            this.chunk.Write(71, (short)wipeout.ClippingBoundary.Type);

            if (wipeout.ClippingBoundary.Type == ClippingBoundaryType.Polygonal)
                this.chunk.Write(91, wipeout.ClippingBoundary.Vertexes.Count + 1);
            else
                this.chunk.Write(91, wipeout.ClippingBoundary.Vertexes.Count);

            foreach (Vector2 vertex in wipeout.ClippingBoundary.Vertexes)
            {
                double x = (vertex.X - ocsInsPoint.X)/max - 0.5;
                double y = -((vertex.Y - ocsInsPoint.Y) / max - 0.5);
                this.chunk.Write(14, x);
                this.chunk.Write(24, y);
            }

            // for unknown reasons the wipeout with a polygonal clipping boundary requires to repeat the first vertex
            if (wipeout.ClippingBoundary.Type == ClippingBoundaryType.Polygonal)
            {
                this.chunk.Write(14, (wipeout.ClippingBoundary.Vertexes[0].X - ocsInsPoint.X) / max - 0.5);
                this.chunk.Write(24, -((wipeout.ClippingBoundary.Vertexes[0].Y - ocsInsPoint.Y) / max - 0.5));
            }

            this.WriteXData(wipeout.XData);
        }
示例#4
0
        private Wipeout ReadWipeout()
        {
            Vector3 position = Vector3.Zero;
            Vector3 u = Vector3.UnitX;
            Vector3 v = Vector3.UnitY;
            ClippingBoundaryType boundaryType = ClippingBoundaryType.Rectangular;
            double x = 0.0;
            List<Vector2> vertexes = new List<Vector2>();
            List<XData> xData = new List<XData>();

            this.chunk.Next();
            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 10:
                        position.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 20:
                        position.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 30:
                        position.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 11:
                        u.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 21:
                        u.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 31:
                        u.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 12:
                        v.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 22:
                        v.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 32:
                        v.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 71:
                        boundaryType = (ClippingBoundaryType) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 91:
                        // we cannot rely in this information it might or might not appear
                        this.chunk.Next();
                        break;
                    case 14:
                        x = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 24:
                        vertexes.Add(new Vector2(x, this.chunk.ReadDouble()));
                        this.chunk.Next();
                        break;
                    case 1001:
                        string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        XData data = this.ReadXDataRecord(this.GetApplicationRegistry(appId));
                        xData.Add(data);
                        break;
                    default:
                        if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071)
                            throw new Exception("The extended data of an entity must start with the application registry code.");

                        this.chunk.Next();
                        break;
                }
            }

            // for polygonal boundaries the last vertex is equal to the first, we will remove it
            if (boundaryType == ClippingBoundaryType.Polygonal)
                vertexes.RemoveAt(vertexes.Count - 1);

            Vector3 normal = Vector3.Normalize(Vector3.CrossProduct(u, v));
            IList<Vector3> ocsPoints = MathHelper.Transform(new List<Vector3> {position, u, v}, normal, CoordinateSystem.World, CoordinateSystem.Object);
            double bx = ocsPoints[0].X;
            double by = ocsPoints[0].Y;
            double elevation = ocsPoints[0].Z;
            double max = ocsPoints[1].X;

            for (int i = 0; i < vertexes.Count; i++)
            {
                double vx = bx + max*(vertexes[i].X + 0.5);
                double vy = by + max*(0.5 - vertexes[i].Y);
                vertexes[i] = new Vector2(vx, vy);
            }

            ClippingBoundary clippingBoundary = boundaryType == ClippingBoundaryType.Rectangular ? new ClippingBoundary(vertexes[0], vertexes[1]) : new ClippingBoundary(vertexes);
            Wipeout entity = new Wipeout(clippingBoundary)
            {
                Normal = normal,
                Elevation = elevation
            };

            entity.XData.AddRange(xData);

            return entity;
        }
示例#5
0
        /// <summary>
        /// Creates a new Wipeout that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Wipeout that is a copy of this instance.</returns>
        public override object Clone()
        {
            Wipeout entity = new Wipeout((ClippingBoundary)this.ClippingBoundary.Clone())
            {
                //EntityObject properties
                Layer = (Layer)this.layer.Clone(),
                LineType = (LineType)this.lineType.Clone(),
                Color = (AciColor)this.color.Clone(),
                Lineweight = (Lineweight)this.lineweight.Clone(),
                Transparency = (Transparency)this.transparency.Clone(),
                LineTypeScale = this.lineTypeScale,
                Normal = this.normal,
                //Wipeout properties
                //Brightness = this.brightness,
                //Contrast = this.contrast,
                //Fade = this.fade,
                Elevation = this.elevation
            };

            foreach (XData data in this.xData.Values)
                entity.XData.Add((XData)data.Clone());

            return entity;
        }
示例#6
0
        private static void WipeoutEntity()
        {
            Line line1 = new Line(new Vector2(-1, -1), new Vector2(1, 1));
            Line line2 = new Line(new Vector2(-1, 1), new Vector2(1, -1));
            Circle circle = new Circle(Vector2.Zero, 0.5);

            Wipeout wipeout1 = new Wipeout(new Vector2(-1.5, -0.25), new Vector2(1.5, 0.25)); // a rectangular wipeout defined from two opposite corners
            //Wipeout wipeout1 = new Wipeout(-1.5, -0.25, 3.0, 0.5); // a rectangular wipeout defined by its bottom-left corner and its width and height
            //Wipeout wipeout1 = new Wipeout(new List<Vector2>{new Vector2(-1.5, 0.25), new Vector2(1.5, 0.25), new Vector2(1.5, -0.25), new Vector2(-1.5, -0.25)}); // a polygonal wipeout

            List<Vector2> vertexes = new List<Vector2>
            {
                new Vector2(-30, 30),
                new Vector2(-20, 60),
                new Vector2(-10, 40),
                new Vector2(10, 70),
                new Vector2(30, 20)
            };

            Wipeout wipeout2 = new Wipeout(vertexes);
            // optionally you can set the normal and elevation
            //wipeout1.Normal = new Vector3(1.0);
            //wipeout1.Elevation = 10;
            DxfDocument doc = new DxfDocument();
            doc.AddEntity(line1);
            doc.AddEntity(line2);
            doc.AddEntity(circle);
            doc.AddEntity(wipeout1);
            doc.AddEntity(wipeout2);

            doc.Save("wipeout.dxf");

            DxfDocument test = DxfDocument.Load("wipeout.dxf");
            test.Save("test.dxf");

        }