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.
Namespace: Atalasoft.Imaging.Codec.CadCam
The GeometryHandler type exposes the following members.
Name | Description | |
---|---|---|
GeometryHandler | Initializes a new instance of the GeometryHandler class |
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnBeginCircle | This method is called when a circle has been encountered. | |
OnBeginCircularArc3Point | Describes a circular using three points. | |
OnBeginCircularArcCenterRadius | Describes a circular arc via a circle's center, radius and sweep angle. | |
OnBeginDocument | Constructs a new default GeometryHandler. | |
OnBeginEllipticalArc | Describes an elliptical arc | |
OnBeginPage | Called when page processing starts. | |
OnBeginPolygon | Describes a closed polygon | |
OnBeginRay | Describes an infinite mathematical ray. | |
OnBeginSimplePolyline | Describes an open polygon to be drawn. | |
OnBeginText | Describes text presented on the page | |
OnBeginXLine | Describes a mathematical infinite line | |
OnEndCircle | Describes completion of a circle | |
OnEndCircularArc3Point | Describes completion of a circular arc | |
OnEndCircularArcCenterRadius | Describes completion of a circular arc | |
OnEndDocument | Describes completion of the document | |
OnEndEllipticalArc | Describes completion of an elliptical arc | |
OnEndPage | Describes completion of a page | |
OnEndPolygon | Describes completion of a polygon | |
OnEndRay | ||
OnEndSimplePolyline | Describes completion of a simple polyline | |
OnEndText | Describes completion of text | |
OnEndXLine | Describes completion of a line | |
OnPolygon | Describes a request to render a primitive closed polygon | |
OnPolyline | Describes a request to render a primitive open polygon | |
OnSetColor | Represents a request to change the color of subsequent objects | |
OnSetFillMode | Represents a request to set the fill mode of subsequent filled shapes | |
OnSetLineWidth | Represents a request to set the line characteristics of subsequent shapes | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
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; } } }