Click or drag to resize

GeometryHandler Class

GeometryHandler is a class that is used for extracting geometry from a DWG file. It consists of a series of methods that are called for each shape type in the as well as for changes in color and line style.

Nearly all of the OnBegin... methods return an enumerated value. This is to indicate to Distill whether or not the user GeometryHandler wants the geometry to be reduced further or not. The GeometryHandler base class implements all OnBegin... methods for shapes such that they return DwgReduction.Reduce. The GeometryHandler base class therefore causes a model to be fully reduced to primitives. Client code should subclass GeomtryHandler and override the methods they wish to intercept.

For example, an application that wishes to extract text from a DWG file would only need to override OnBeginText.

OnBeginPage should return true if the client wishes to process the page.

OnBeginDocument does not have a return value.

OnPolygon and OnPolyline represent primitives for which there is no further reduction.

All the OnBeginShape and OnEndShape methods take a shape ID parameter. This is unique ID that is assigned to every shape. This is to make it easier to identify when all reduction is done for a particular shape.

Many of the routines take arrays of double precision floating point numbers. These represent 3D coordinates of the shapes in the order X, Y, Z. The length of each array will always be a multiple of 3. At present, the Z coordinate is ignored since the shapes are projected onto a 2D sheet.

Inheritance Hierarchy
SystemObject
  Atalasoft.Imaging.Codec.CadCamGeometryHandler

Namespace:  Atalasoft.Imaging.Codec.CadCam
Assembly:  Atalasoft.dotImage.Dwg (in Atalasoft.dotImage.Dwg.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public class GeometryHandler

The GeometryHandler type exposes the following members.

Constructors
  NameDescription
Public methodGeometryHandler
Initializes a new instance of the GeometryHandler class
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodOnBeginCircle
This method is called when a circle has been encountered.
Public methodOnBeginCircularArc3Point
Describes a circular using three points.
Public methodOnBeginCircularArcCenterRadius
Describes a circular arc via a circle's center, radius and sweep angle.
Public methodCode exampleOnBeginDocument
Constructs a new default GeometryHandler.
Public methodOnBeginEllipticalArc
Describes an elliptical arc
Public methodCode exampleOnBeginPage
Called when page processing starts.
Public methodOnBeginPolygon
Describes a closed polygon
Public methodOnBeginRay
Describes an infinite mathematical ray.
Public methodOnBeginSimplePolyline
Describes an open polygon to be drawn.
Public methodOnBeginText
Describes text presented on the page
Public methodOnBeginXLine
Describes a mathematical infinite line
Public methodOnEndCircle
Describes completion of a circle
Public methodOnEndCircularArc3Point
Describes completion of a circular arc
Public methodOnEndCircularArcCenterRadius
Describes completion of a circular arc
Public methodOnEndDocument
Describes completion of the document
Public methodOnEndEllipticalArc
Describes completion of an elliptical arc
Public methodOnEndPage
Describes completion of a page
Public methodOnEndPolygon
Describes completion of a polygon
Public methodOnEndRay
Public methodOnEndSimplePolyline
Describes completion of a simple polyline
Public methodOnEndText
Describes completion of text
Public methodOnEndXLine
Describes completion of a line
Public methodOnPolygon
Describes a request to render a primitive closed polygon
Public methodOnPolyline
Describes a request to render a primitive open polygon
Public methodOnSetColor
Represents a request to change the color of subsequent objects
Public methodOnSetFillMode
Represents a request to set the fill mode of subsequent filled shapes
Public methodOnSetLineWidth
Represents a request to set the line characteristics of subsequent shapes
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
Extracting Fonts (C#)
public class FontExtractorHandler : GeometryHandler {
    private List<Font> _fonts = new List<Font>();
    public override DwgReduction OnBeginText(int shapeId, double[] position,
        double[] direction, double[] up, string text, bool raw,
        DwgTextStyle textStyle, double[] extrusion)
    {
        if (textStyle.Font != null) {
            _fonts.Add(textStyle.Font);
        }
        return DwgReduction.DontReduce;
    }
    public List<Font> Fonts { get { return _fonts; } }
}
See Also