/// <summary> /// Private ctor /// </summary> /// <param name="stylusPoints"></param> /// <param name="operations"></param> /// <param name="usePressure"></param> internal StrokeNodeIterator(StylusPointCollection stylusPoints, StrokeNodeOperations operations, bool usePressure) { //Note, StylusPointCollection can be null _stylusPoints = stylusPoints; if (operations == null) { throw new ArgumentNullException("operations"); } _operations = operations; _usePressure = usePressure; }
/// <summary> /// Creates a default enumerator for a given stroke /// If using the strokes drawing attributes, pass stroke.DrawingAttributes for the second /// argument. If using an overridden DA, use that instance. /// </summary> internal static StrokeNodeIterator GetIterator(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes) { if (stylusPoints == null) { throw new System.ArgumentNullException("stylusPoints"); } if (drawingAttributes == null) { throw new System.ArgumentNullException("drawingAttributes"); } StrokeNodeOperations operations = StrokeNodeOperations.CreateInstance(drawingAttributes.StylusShape); bool usePressure = !drawingAttributes.IgnorePressure; return(new StrokeNodeIterator(stylusPoints, operations, usePressure)); }
/// <summary> /// Constructor. /// </summary> /// <param name="operations">StrokeNodeOperations object created for particular rendering</param> /// <param name="index">Index of the node on the stroke spine</param> /// <param name="nodeData">StrokeNodeData for this node</param> /// <param name="lastNodeData">StrokeNodeData for the precedeng node</param> /// <param name="isLastNode">Whether the current node is the last node</param> internal StrokeNode( StrokeNodeOperations operations, int index, StrokeNodeData nodeData, StrokeNodeData lastNodeData, bool isLastNode) { System.Diagnostics.Debug.Assert(operations != null); System.Diagnostics.Debug.Assert((nodeData.IsEmpty == false) && (index >= 0)); _operations = operations; _index = index; _thisNode = nodeData; _lastNode = lastNodeData; _isQuadCached = lastNodeData.IsEmpty; _connectingQuad = Quad.Empty; _isLastNode = isLastNode; }
/// <summary> /// Constructor for an incremental node enumerator that builds nodes /// from array(s) of points and a given stylus shape. /// </summary> /// <param name="nodeShape">a shape that defines the stroke contour</param> internal StrokeNodeIterator(StylusShape nodeShape) : this(null, //stylusPoints StrokeNodeOperations.CreateInstance(nodeShape), false) //usePressure) { }
/// <summary> /// Constructor for an incremental node enumerator that builds nodes /// from StylusPointCollections /// called by the IncrementalRenderer /// </summary> /// <param name="drawingAttributes">drawing attributes</param> internal StrokeNodeIterator(DrawingAttributes drawingAttributes) : this(null, //stylusPoints StrokeNodeOperations.CreateInstance((drawingAttributes == null ? null : drawingAttributes.StylusShape)), (drawingAttributes == null ? false : !drawingAttributes.IgnorePressure)) //usePressure { }
private Point[] FilterPoints(Point[] path) { System.Diagnostics.Debug.Assert(path.Length > 1); Point back2, back1; int i; List <Point> newPath = new List <Point>(); if (_nodeIterator.Count == 0) { newPath.Add(path[0]); newPath.Add(path[1]); back2 = path[0]; back1 = path[1]; i = 2; } else { newPath.Add(path[0]); back2 = _nodeIterator[_nodeIterator.Count - 1].Position; back1 = path[0]; i = 1; } while (i < path.Length) { if (DoubleUtil.AreClose(back1, path[i])) { // Filter out duplicate points i++; continue; } Vector begin = back2 - back1; Vector end = path[i] - back1; //On a line defined by begin & end, finds the findex of the point nearest to the origin (0,0). double findex = StrokeNodeOperations.GetProjectionFIndex(begin, end); if (DoubleUtil.IsBetweenZeroAndOne(findex)) { Vector v = (begin + (end - begin) * findex); if (v.LengthSquared < CollinearTolerance) { // The point back1 can be considered as on the line from back2 to the toTest StrokeNode. // Modify the previous point. newPath[newPath.Count - 1] = path[i]; back1 = path[i]; i++; #if POINTS_FILTER_TRACE _collinearPointsScreened++; #endif continue; } } // Add the surviving point into the list. newPath.Add(path[i]); back2 = back1; back1 = path[i]; i++; } #if POINTS_FILTER_TRACE _totalPointsScreened += path.Length - newPath.Count; #endif return(newPath.ToArray()); }
/// <summary> /// Constructor. /// </summary> /// <param name="operations">StrokeNodeOperations object created for particular rendering</param> /// <param name="index">Index of the node on the stroke spine</param> /// <param name="nodeData">StrokeNodeData for this node</param> /// <param name="lastNodeData">StrokeNodeData for the precedeng node</param> /// <param name="isLastNode">Whether the current node is the last node</param> internal StrokeNode( StrokeNodeOperations operations, int index, in StrokeNodeData nodeData,