StrokeOptions Class
Tolerance blob for various stroking methods.
- Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength
- Chord error is an distance measured from a curve or facet to its approximating stroke or facet.
- angle is the angle between two contiguous strokes or across a facet edge.
- maxEdgeLength is the length of a stroke or a edge of a facet.
- It is rare for all three to be active at once.
- Nearly all stroke and facet use cases will apply an angle tolerance.
- For curves, 15 degrees is typical
- For facets, 22.5 degrees is typical.
- Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.
- The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.
- When creating output for devices such as 3D printing will want a chord tolerance.
- For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.
- Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.
- Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.
- Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.
- If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.
Methods
Name | Description | |
---|---|---|
constructor(): StrokeOptions | ||
applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number | Return stroke count which is the larger of the existing count or count needed for angle condition for given | |
applyChordTol(minCount: number, radius: number, sweepRadians: number): number | Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. | |
applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number | Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given | |
applyMaxEdgeLength(minCount: number, totalLength: number): number | Return stroke count which is the larger of the minCount or count needed for edge length condition. | |
applyMinStrokesPerPrimitive(minCount: number): number | Return stroke count which is the larger of existing count or this.minStrokesPerPrimitive |
|
applyTolerancesToArc(radius: number, sweepRadians: number...): number | Determine a stroke count for a (partial) circular arc of given radius. | |
clone(): StrokeOptions | Return a deep clone | |
applyAngleTol(options: StrokeOptions, minCount: number, sweepRadians: number, defaultStepRadians?: number): number Static | Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance | |
applyMaxEdgeLength(options: StrokeOptions, minCount: number, edgeLength: number): number Static | Return the number of strokes needed for given edgeLength curve. | |
createForCurves(): StrokeOptions Static | Create StrokeOptions with defaults appropriate for curves. |
|
createForFacets(): StrokeOptions Static | Create StrokeOptions with defaults appropriate for surfaces facets |
Properties
Name | Type | Description | |
---|---|---|---|
angleTol | Angle | undefined | Turning angle between strokes. | |
chordTol | number | undefined | Distance from stroke to actual geometry | |
defaultCircleStrokes | number | Default number of strokes for a circle. | |
hasAngleTol Accessor ReadOnly | boolean | Ask if angleTol is specified | |
hasChordTol Accessor ReadOnly | boolean | Ask if chordTol is specified | |
hasMaxEdgeLength Accessor ReadOnly | boolean | Ask if maxEdgeLength is specified | |
maxEdgeLength | number | undefined | Maximum length of a single stroke. | |
maximizeConvexFacets Accessor | boolean | Whether to post-process a planar triangulation by removing edges to maximize the size of convex facets. | |
minStrokesPerPrimitive | number | undefined | Minimum strokes on a primitive | |
needColors | boolean | undefined | Optional color request flag | |
needConvexFacets | boolean | undefined | Caller expects convex facets. | Deprecated |
needNormals Accessor | boolean | Whether normals are requested | |
needParams Accessor | boolean | Whether params are requested. | |
needTwoSided Accessor | boolean | Whether twoSided is requested. | |
shouldTriangulate | boolean | Whether or not to triangulate each added facet |
Defined in
- curve/StrokeOptions.ts Line 34
Last Updated: 14 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.