Click or drag to resize

VectorGraphicOptimizer Class

This class is used to optimize paths and layers. I. e. paths and layers can be simplified by removing superfluous elements or replacing commands by other ones more suitable for marking. (In the RAYGUIDE GUI these operations are available in the context menu "Vector optimizations" of a vector graphic object in the object tree.)
Inheritance Hierarchy
SystemObject
  RAYLASE.Marker.VectorGraphicElementVectorGraphicOptimizer

Namespace: RAYLASE.Marker.VectorGraphicElement
Assembly: RAYLASE.Marker.VectorGraphicElement (in RAYLASE.Marker.VectorGraphicElement.dll) Version: 2.19.0
Syntax
C#
public class VectorGraphicOptimizer

The VectorGraphicOptimizer type exposes the following members.

Constructors
 NameDescription
Public methodVectorGraphicOptimizerInitializes a new instance of the VectorGraphicOptimizer class
Top
Methods
 NameDescription
Public methodCloseGaps Closes gaps between open paths if the gaps are not larger than LocationDistance.
Public methodClosePaths Closes the contour of all open paths by adding a line from the end position to the start position.
Public methodDoublePointsInPolylines(VectorGraphicLayer) Loops through all paths and inserts in each polyline an additional point between each two points.
Public methodDoublePointsInPolylines(VectorGraphicPath) Loops through all commands of the given path and inserts an additional point between each two points of polylines.
Public methodJoinLayers Joins layers. All paths will be appended to the first matching layer.
Public methodJoinPolylines(VectorGraphicLayer) Loops through all paths and joines in each path adjacent polylines.
Public methodJoinPolylines(VectorGraphicPath) Loops through all commands in the given path and joines adjacent polylines.
Public methodJoinSimilarArcs(VectorGraphicLayer, Double) Loops through all paths and concatenates in each path adjacent arcs if they are "similar", i. e. they must have the same center and the first arc's end point is the same as the second arc's start point.
Public methodJoinSimilarArcs(VectorGraphicPath, ListArcToMetafileCommand, Double) Loops through all commands in the given path and checks, if each two adjacent commands are arcs and if it is possible to replace them by a single arc. If yes, the arcs are merged.
Public methodJoinStraightLines(VectorGraphicLayer, Double) Loops through all paths and concatenates in each path adjacent lines if they are collinear.
Public methodJoinStraightLines(VectorGraphicPath, Double) Loops through all commands in the given path and searches for polylines. Adjacent polylines are concatenated then if the second (poly)line is collinear with the first one.
Public methodJoinStraightLines(VectorGraphicPath, ListBaseMetafileCommand, Double) Loops through all commands in the given path and searches for polylines. Adjacent polylines are concatenated then if the second (poly)line is collinear with the first one and if it is in the given list of commands to join.
Public methodJoinTouchingPaths Loops through all paths of the given layer and joins adjacent paths if the predecessor's end point is nearer than LocationDistance to the successor's start point.
Public methodOptimizeOrientationFilling 
Public methodOptimizeVectors(IListVectorGraphicLayer, OptimizationSettings, dmat4, Double, Int32, NullableCancellationToken) Optimizes all objects for filling. For best filling Results, the vectors have to be in order, the objects have to closed and objects contained in another object must be of opposite orientation.
Public methodOptimizeVectors(IListVectorGraphicLayer, OptimizationSettings, dmat4, Double, Int32, PenSet, NullableCancellationToken) 
Public methodRemoveDrills(VectorGraphicLayer) Loops through all paths and removes all drills.
Public methodRemoveDrills(VectorGraphicPath) Loops through all commands of the given path and deletes all drills.
Public methodRemoveDuplicates(VectorGraphicLayer, Double) Removes duplicate paths in the path list, adjacent duplicate points in polylines and adjacent duplicate loops in polylines.
Public methodRemoveDuplicates(VectorGraphicPath, Double) Loops through all commands of the given path, searches for polylines and removes all duplicated points and all loops found in all the polylines.
Public methodRemoveEmptyPaths Loops through all paths and removes empty ones.
Public methodRemoveStraightPoints(VectorGraphicLayer, Double) Loops through all paths and checks all polylines for adjacent points building a line. If found, the points between the line's borders are removed.
Public methodRemoveStraightPoints(VectorGraphicPath, Double) Loops through all commands in the given path, checks all PolyLineMetafileCommands and tries to remove all "linear" points from them.
Public methodReplaceAllByDrills Converts the vectors to a list of drills./>
Public methodReplaceAllCommandsByPolylines(VectorGraphicLayer, Int32, Double) Loops through all paths and replaces all commands by polylines. See CreatePolyline(Int32, Double) for details.
Public methodReplaceAllCommandsByPolylines(VectorGraphicPath, Int32, Double) Loops through all commands in the given path and replaces each one by a polyline if possible, consisting out of NumberOfPoints. See CreatePolyline(Int32, Double) for details.
Public methodReplaceArcByDrill If the given path contains only an arc or an ellipse it is replaced by a drill if its radius is less than or equal than the given one. In case of an ellipse the criterion is its arc length instead, to avoid replacing ellipses with a big axes ratio.
Public methodReplaceArcsByDrills Loops through all paths and replaces all arcs with a radius less than the given one by drills.
Public methodReplaceCircularArcsByCubicCurves(VectorGraphicLayer) Loops through all paths and replaces all circular arcs by approximating cubic curves.
Public methodReplaceCircularArcsByCubicCurves(VectorGraphicPath) Loops through all commands of the given path and converts all circular arcs to approximating cubic curves.
Public methodReplaceCircularArcsByEllipticalArcs(VectorGraphicLayer) Loops through all paths and replaces all circular arcs by elliptical arcs.
Public methodReplaceCircularArcsByEllipticalArcs(VectorGraphicPath) Loops through all commands of the given path and converts all circular arcs to elliptical arcs with both semi axes having the old arc's radius.
Public methodReplaceCircularArcsByLines(VectorGraphicLayer) Loops through all paths and replaces each arc by a single line.
Public methodReplaceCircularArcsByLines(VectorGraphicPath) Loops through all commands of the given path and replaces each arc by a single line.
Public methodReplaceCircularArcsByPolylines(VectorGraphicLayer, Int32, Double) Loops through all paths and replaces all circular arcs by approximating polylines.
Public methodReplaceCircularArcsByPolylines(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all circular arcs to polylines.
Public methodReplaceCircularArcsByQuadraticCurves(VectorGraphicLayer) Loops through all paths and replaces all circular arcs by approximating quadratic curves.
Public methodReplaceCircularArcsByQuadraticCurves(VectorGraphicPath) Loops through all commands of the given path and converts all circular arcs to quadratic curves.
Public methodReplaceCommandsByPaths Replaces all commands in the given layer whose indices are given in Dictionary pathDic by a path containing only that command.
Public methodReplaceCubicCurvesByArcs(VectorGraphicLayer, Int32, Double) Loops through all paths and replaces all cubic curves by arcs.
Public methodReplaceCubicCurvesByArcs(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all cubic curves to arcs.
Public methodReplaceCubicCurvesByLines(VectorGraphicLayer) Loops through all paths and replaces each curve by a single line.
Public methodReplaceCubicCurvesByLines(VectorGraphicPath) Loops through all commands of the given path and replaces each curve by a single line.
Public methodReplaceCubicCurvesByPolylines(VectorGraphicLayer, Int32, Double) Loops through all commands of the given layer and converts all cubic curves to polylines.
Public methodReplaceCubicCurvesByPolylines(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all cubic curves to polylines.
Public methodReplaceCubicCurvesByQuadraticCurves(VectorGraphicLayer) Loops through all paths and replaces each cubic curve by a quadratic curve.
Public methodReplaceCubicCurvesByQuadraticCurves(VectorGraphicPath) Loops through all commands of the given path and replaces each cubic curve by a quadratic curve.
Public methodReplaceDrillByCircle If the given path contains only a drill it is replaced by a circle with the given radius.
Public methodReplaceDrillsByCircles Loops through all paths and replaces all drills by circles with the given radius.
Public methodReplaceEllipticalArcsByCircularArcs(VectorGraphicLayer) Loops through all paths and replaces all elliptical arcs by circular arcs.
Public methodReplaceEllipticalArcsByCircularArcs(VectorGraphicPath) Loops through all commands of the given path and converts all elliptical arcs to circular arcs.
Public methodReplaceEllipticalArcsByCubicCurves(VectorGraphicLayer) Loops through all paths and replaces all elliptical arcs by approximating cubic curves.
Public methodReplaceEllipticalArcsByCubicCurves(VectorGraphicPath) Loops through all commands of the given path and converts all elliptical arcs to approximating cubic curves.
Public methodReplaceEllipticalArcsByLines(VectorGraphicLayer) Loops through all paths and replaces each arc by a single line.
Public methodReplaceEllipticalArcsByLines(VectorGraphicPath) Loops through all commands of the given path and replaces each arc by a single line.
Public methodReplaceEllipticalArcsByPolylines(VectorGraphicLayer, Int32, Double) Loops through all paths and replaces all elliptical arcs by approximating polylines.
Public methodReplaceEllipticalArcsByPolylines(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all elliptical arcs to polylines.
Public methodReplaceEllipticalArcsByQuadraticCurves(VectorGraphicLayer) Loops through all paths and replaces all elliptical arcs by approximating quadratic curves.
Public methodReplaceEllipticalArcsByQuadraticCurves(VectorGraphicPath) Loops through all commands of the given path and converts all elliptical arcs to quadratic curves.
Public methodReplacePolylinesByArcs(VectorGraphicLayer) Loops through all paths and replaces all polylines by approximating arcs.
Public methodReplacePolylinesByArcs(VectorGraphicPath) Loops through all commands of the given path and converts all polylines to arcs.
Public methodReplacePolylinesByCubicCurves(VectorGraphicLayer) Loops through all paths and replaces each polyline by a set of cubic curves.
Public methodReplacePolylinesByCubicCurves(VectorGraphicPath) Loops through all commands of the given path and converts each polyline into a set of cubic curves.
Public methodReplacePolylinesByQuadraticCurves(VectorGraphicLayer) Loops through all paths and replaces each polyline by a set of quadratic curves.
Public methodReplacePolylinesByQuadraticCurves(VectorGraphicPath) Loops through all commands of the given path and converts each polyline to a set of quadratic curves.
Public methodReplacePolylineSectionsByArcs(VectorGraphicLayer, Double) Loops through all paths and replaces all polyline sections by approximating arcs if possible.
Public methodReplacePolylineSectionsByArcs(VectorGraphicPath, Double) Loops through all commands of the given path and converts all fitting polyline sections into arcs.
Public methodReplaceQuadraticCurvesByArcs(VectorGraphicLayer, Int32, Double) Loops through all paths and replaces all quadratic curves by arcs.
Public methodReplaceQuadraticCurvesByArcs(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all quadratic curves to arcs.
Public methodReplaceQuadraticCurvesByCubicCurves(VectorGraphicLayer) Loops through all paths and replaces each quadratic curve by a cubic curve.
Public methodReplaceQuadraticCurvesByCubicCurves(VectorGraphicPath) Loops through all commands of the given path and and replaces each quadratic curve by a cubic curve.
Public methodReplaceQuadraticCurvesByLines(VectorGraphicLayer) Loops through all paths and replaces each curve by a single line.
Public methodReplaceQuadraticCurvesByLines(VectorGraphicPath) Loops through all commands of the given path and and replaces each curve by a single line.
Public methodReplaceQuadraticCurvesByPolylines(VectorGraphicLayer, Int32, Double) Loops through all commands of the given layer and converts all quadratic curves to polylines.
Public methodReplaceQuadraticCurvesByPolylines(VectorGraphicPath, Int32, Double) Loops through all commands of the given path and converts all quadratic curves to polylines.
Public methodReplaceStraightCurvesByLines(VectorGraphicLayer, Double) Checks if the control point(s) of a cubic or quadratic curve are laying on the line defined by the curve's start and end point. If yes, the curve is replaced by a line.
Public methodReplaceStraightCurvesByLines(VectorGraphicPath, Double) Loops through all commands in the given path, checks all QuadraticCurveToMetafileCommands and CubicCurveToMetafileCommands and replaces them by lines if all control points are laying on the line defined by the curve's start and end point.
Public methodSegment 
Public methodSegmentByTime 
Public methodSetZCoordsToZero(VectorGraphicLayer) Loops through all paths and sets all z-coordinates to zero.
Public methodSetZCoordsToZero(VectorGraphicPath) Loops through all commands of the given path and sets all z-coordinates to zero.
Public methodSortVectorsByDirection 
Public methodSortVectorsMinJump Sorts all the vectors in the given layer to minimize jumps and jump distance.
Public methodSplitIntoTwo(VectorGraphicLayer) Loops through all paths and splits all commands into two (Drill and SetPen commands are ignored).
Public methodSplitIntoTwo(VectorGraphicPath) Loops through all commands of the given path and splits all commands into two; Drills and SetPen commands remain unchanged.
Public methodSplitPaths Splits all paths given in the dictionary pathDic into two paths at the command index which is the value of each entry in pathDic.
Top
Remarks
For optimization there are three important tolerance values available here as properties: - LocationDistance: The locations of two points are considered as equal if their distance is less than this value, measured in micrometers. - CollinearityDistance: A point is considered to be laying on the line defined by two other points if its perpendicular distance from the line is less than this value, measured in micrometers. - NumberOfPoints: When replacing a metafile command by a polyline the resulting polyline will consist out of this number of points; some commands will reduce this amount of points in an additional step by removing all points which are inert the CollinearityDistance. Example: Say, you want to remove duplicates in the polylines of a path, and a point should be considered as the same as another point if their distance is less than 300 micrometers. This can be done in this way:
VectorGraphicPath path = GetYourPathFromSomewhere();
VectorGraphicOptimizer vgo = new VectorGraphicOptimizer();
vgo.LocationDistance = 300;
vgo.RemoveDuplicates(path);
See a full example in the sample folder.
See Also