StrokeCountMap Class

Data carrier interface for per-primitive stroke counts and distances used by PolyfaceBuilder.

  • For a simple primitive (line segment or arc) that is stroked with uniform fraction, the members are:

    • numStroke = total number of strokes
    • curveLength = length of this curve
    • a0 = external mapped coordinate for fraction 0 on this primitive or component
    • a1 = external mapped coordinate for fraction 1 on this primitive or component
  • For linestring and bspline curve, those numbers are totals for the overall curve, and breakdown within the components (line segments or bezier spans) is recorded on the optional array componentData[]

    • Members of the array are annotated with componentIndex within the linestring or bspline curve

Methods

Name Description
addToCountAndLength(numStroke: number, curveLength: number): void Apply stroke count and curve length from a component to a parent map.  
clone(): StrokeCountMap Clone all data from root.  
fractionToA(fraction: number): number Interpolate in the a0,a1 mapping.  
isCompatibleComponentStructure(other: StrokeCountMap, enforceCounts: boolean): boolean Return true if other has the same component structure as this  
createWithComponentIndex(componentIndex: number = 0, numStroke: number = 0, curveLength: number = 0, a0: number = 0, a1: number = 0): StrokeCountMap Static Create a StrokeCountMap with componentIndex (but no primitive or componentData array)  
createWithCurvePrimitive(primitive: CurvePrimitive, numStroke: number, curveLength: number, a0: number, a1: number, componentData?: StrokeCountMap[]): StrokeCountMap Static Create a StrokeCountMap with curve primitive and optional componentData array.  
createWithCurvePrimitiveAndOptionalParent(curvePrimitive: CurvePrimitive, parentMap?: StrokeCountMap, componentData?: StrokeCountMap[]): StrokeCountMap Static Create a StrokeCountMap, optionally  

Properties

Name Type Description
a0 number Start coordinate (in user-defined space) for fraction 0 on this primitive or component  
a1 number End coordinate (in user-defined space) for fraction 0 on this primitive or component  
componentData undefined | StrokeCountMap[] Further StrokeCountMap's within this interval (e.g.  
componentIndex undefined | number This curve's index within its parent.  
curveLength number Length of the curve interval.  
numStroke number Number of strokes expected in this interval.  
primitive undefined | CurvePrimitive The curve that this map represents  

Defined in

Last Updated: 15 March, 2024