WIPEOUT

1 2    next >
archana_saini
2/19/2015 6:13 AM

Hi

I am not able to understand the working of WIPEOUT.
How to use it ?
Can you provide some example of it as others?

Thanks
Archana

Wout
2/23/2015 8:01 PM

Hi,

I've added some example code for creating the WIPEOUT entity, which uses a helper method that I've just added: SetWipeoutPolygon(). So you'll have to use the newest CadLib 4.0 version to use this example.

C# Code:
using System;
using WW.Cad.IO;
using WW.Cad.Model;
using WW.Cad.Model.Entities;
using WW.Cad.Model.Objects;
using WW.Math;

namespace WW.Cad.Test.Examples {
    public class WipeoutExample {
        public void Demonstrate() {
            DxfModel model = new DxfModel();
            
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, 5), new Point2D(10, -5)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, -5), new Point2D(10, 5)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, 0), new Point2D(10, 0)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(5, 5), new Point2D(5, -5)));

            // Use the wipeout entity to erase a part of the lines.
            // The wipeout entity fills the polygon defined by the BoundaryVertices using the background color.
            DxfWipeout wipeout = new DxfWipeout();
            wipeout.SetWipeoutPolygon(new [] {
                new Point2D(4d, 1d), 
                new Point2D(4d, -1d), 
                new Point2D(6d, -1d), 
                new Point2D(6d, 1d) 
            });
            model.Entities.Add(wipeout);

            // Do not display wipeout frames.
            DxfWipeoutVariables wipeoutVariables =
                model.DictionaryRoot.Entries.GetFirstValue("ACAD_WIPEOUT_VARS") as DxfWipeoutVariables;
            if (wipeoutVariables == null) {
                wipeoutVariables = new DxfWipeoutVariables();
                model.DictionaryRoot.Entries.Add(new DxfDictionaryEntry("ACAD_WIPEOUT_VARS", wipeoutVariables));
            }
            wipeoutVariables.DisplayFrame = false;


            DxfWriter.Write("WipeoutExample.dxf", model);
        }
    }
}

If you want to keep using your existing CadLib version you can use the following code:

C# Code:
using System;
using WW.Cad.IO;
using WW.Cad.Model;
using WW.Cad.Model.Entities;
using WW.Cad.Model.Objects;
using WW.Math;

namespace WW.Cad.Test.Examples {
    public class WipeoutExample {
        public void Demonstrate() {
            DxfModel model = new DxfModel();
            
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, 5), new Point2D(10, -5)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, -5), new Point2D(10, 5)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(0, 0), new Point2D(10, 0)));
            model.Entities.Add(new DxfLine(EntityColors.Red, new Point2D(5, 5), new Point2D(5, -5)));

            // Use the wipeout entity to erase a part of the lines.
            // The wipeout entity fills the polygon defined by the BoundaryVertices using the background color.
            DxfWipeout wipeout = new DxfWipeout();
            wipeout.Size = new Size2D(1d, 1d);
            wipeout.ImageDisplayFlags = ImageDisplayFlags.ShowImage | ImageDisplayFlags.ShowUnalignedImage | ImageDisplayFlags.UseClippingBoundary;
            wipeout.ClippingEnabled = true;
            SetWipeoutPolygon(wipeout, new [] {
                new Point2D(4d, 1d), 
                new Point2D(4d, -1d), 
                new Point2D(6d, -1d), 
                new Point2D(6d, 1d) 
            });
            model.Entities.Add(wipeout);

            // Do not display wipeout frames.
            DxfWipeoutVariables wipeoutVariables =
                model.DictionaryRoot.Entries.GetFirstValue("ACAD_WIPEOUT_VARS") as DxfWipeoutVariables;
            if (wipeoutVariables == null) {
                wipeoutVariables = new DxfWipeoutVariables();
                model.DictionaryRoot.Entries.Add(new DxfDictionaryEntry("ACAD_WIPEOUT_VARS", wipeoutVariables));
            }
            wipeoutVariables.DisplayFrame = false;


            DxfWriter.Write("WipeoutExample.dxf", model);
        }

        public void SetWipeoutPolygon(DxfWipeout wipeout, IList<Point2D> polygon) {
            Bounds2D bounds = new Bounds2D();
            bounds.Update(polygon);
            wipeout.InsertionPoint = (Point3D) bounds.Min;
            wipeout.XAxis = new Vector3D(bounds.Delta.X, 0d, 0d);
            wipeout.YAxis = new Vector3D(0d, bounds.Delta.Y, 0d);
            // Transform the polygon to the image coordinate system.
            Matrix3D transform =
                Transformation3D.Scaling(1d / XAxis.X, 1d / YAxis.Y, 1d) *
                Transformation3D.Translation(Point2D.Zero - bounds.Center);
            wipeout.BoundaryVertices.Clear();
            foreach (Point2D p in polygon) {
                wipeout.BoundaryVertices.Add(transform.Transform(p));
            }
            // The last point has to be the same as the first point,
            // otherwise the wipeout is not drawn.
            if (wipeout.BoundaryVertices.Count > 2 && wipeout.BoundaryVertices[0] != wipeout.BoundaryVertices[wipeout.BoundaryVertices.Count - 1]) {
                wipeout.BoundaryVertices.Add(wipeout.BoundaryVertices[0]);
            }
        }
    }
}


- Wout

archana_saini
2/24/2015 1:03 PM

Hi

Thanks a ton !! :D

archana_saini
2/25/2015 5:37 AM

Hi,
Thanks...
This is working great. but the only problem is that for the first time, it is showing the black borders of the polygon.

??

Thanks
Archana

Wout
2/25/2015 9:16 AM

That shouldn't happen, the code below

C# Code:
// Do not display wipeout frames.

should turn the wipeout frames off.

Can you send the DXF file you created so I can investigate it?

- Wout

archana_saini
2/26/2015 7:37 AM

Hi

It is done Wout.
Thanks A lot !

Regards
Archana

archana_saini
2/26/2015 9:07 AM

Hi

There is an issue in this.
Whenever the DWG file is saved and opened again, it does not show the wiped out area but yes the wipeout entity do exists.

Please find the attachment of the Sample DWG file created herewith.

Thanks & Regards
Archana

archana_saini
2/26/2015 9:14 AM

Hi

Sorry, I am asking too many questions.
How to fill White Color. because whenever I take White Color in hatch, it fills the entity with black color.


Thanks
Archana

archana_saini
2/26/2015 9:58 AM

Hi


I am attaching the Image and the DWG file for the model I am creating.
The code is same as you sent.


Thanks
Archana

Wout
2/26/2015 9:35 PM

Hi,

You say "saved and opened again", with what application is this done?

Also I would need your original file that you created before this saving and opening, because the files you uploaded don't contain the WIPEOUT entity anymore.

I need to be able to reproduce how the problem is happening.

About your question about filling with white color, the WIPEOUT entity is meant for erasing, so you can't specify a specific erase color. It always uses the background color. If you need filling an area, you will need to use e.g. the HATCH entity for this (class DxfHatch).

- Wout

1 2    next >