PiecewiseFunction
Introduction
vtkPiecewiseFunction Defines a piecewise function mapping. This mapping allows the addition of control points, and allows the user to control the function between the control points. A piecewise hermite curve is used between control points, based on the sharpness and midpoint parameters. A sharpness of 0 yields a piecewise linear function and a sharpness of 1 yields a piecewise constant function. The midpoint is the normalized distance between control points at which the curve reaches the median Y value.
The midpoint and sharpness values specified when adding a node are used to control the transition to the next node (the last node's values are ignored) Outside the range of nodes, the values are 0 if Clamping is off, or the nearest node point if Clamping is on. Using the legacy methods for adding points (which do not have Sharpness and Midpoint parameters) will default to Midpoint = 0.5 (halfway between the control points) and Sharpness = 0.0 (linear).
Usage
const ofun = vtkPiecewiseFunction.newInstance();
ofun.addPoint(200.0, 0.0);
ofun.addPoint(1200.0, 0.2);
ofun.addPoint(4000.0, 0.4);See Also
Methods
addPoint
Add points to the function.
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The x coordinate. |
y | Number | Yes | The y coordinate. |
addPointLong
Add points to the function.
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The x coordinate. |
y | Number | Yes | The y coordinate. |
midpoint | Number | Yes | |
sharpness | Number | Yes |
addSegment
Add a line segment to the function.
| Argument | Type | Required | Description |
|---|---|---|---|
x1 | Number | Yes | The first point x coordinate. |
y1 | Number | Yes | The first point y coordinate. |
x2 | Number | Yes | The second point x coordinate. |
y2 | Number | Yes | The second point y coordinate. |
adjustRange
Remove all points out of the new range, and make sure there is a point at each end of that range.
| Argument | Type | Required | Description |
|---|---|---|---|
range | Range | Yes |
estimateMinNumberOfSamples
Estimates the minimum size of a table such that it would correctly sample this function.
extend
Method used to decorate a given object (publicAPI+model) with vtkPiecewiseFunction characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IPiecewiseFunctionInitialValues | No | (default: {}) |
findMinimumXDistance
Traverses the nodes to find the minimum distance.
getAllowDuplicateScalars
Toggle whether to allow duplicate scalar values in the piecewise function (off by default).
getClamping
When zero range clamping is Off, GetValue() returns 0.0 when a value is requested outside of the points specified.
When zero range clamping is On, GetValue() returns the value at the value at the lowest point for a request below all points specified and returns the value at the highest point for a request above all points specified. On is the default.
getDataPointer
Returns a pointer to the data stored in the table.
getFirstNonZeroValue
Returns the first point location which precedes a non-zero segment of the function.
getNodeValue
For the node specified by index, set/get the location (X), value (Y), midpoint, and sharpness values at the node.
| Argument | Type | Required | Description |
|---|---|---|---|
index | Number | Yes | |
val | Yes |
getRange
Returns the min and max node locations of the function.
getRangeByReference
Returns the min and max node locations of the function.
getSize
Get the number of points used to specify the function.
getTable
Fills in an array of function values evaluated at regular intervals.
| Argument | Type | Required | Description |
|---|---|---|---|
xStart | Number | Yes | |
xEnd | Number | Yes | |
size | Number | Yes | |
table | Yes | ||
stride | Number | No |
getType
Return the type of function: Function Types:
- 0 : Constant (No change in slope between end points)
- 1 : NonDecreasing (Always increasing or zero slope)
- 2 : NonIncreasing (Always decreasing or zero slope)
- 3 : Varied (Contains both decreasing and increasing slopes)
getValue
Returns the value of the function at the specified location using the specified interpolation.
newInstance
Method used to create a new instance of vtkPiecewiseFunction.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IPiecewiseFunctionInitialValues | No | for pre-setting some of its content |
removeAllPoints
Removes all points from the function.
removePoint
Remove the first point found at the given x location Return the index of the remove point if any, -1 otherwise.
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes |
setAllowDuplicateScalars
| Argument | Type | Required | Description |
|---|---|---|---|
allowDuplicateScalars | Boolean | Yes |
setClamping
When zero range clamping is Off, GetValue() returns 0.0 when a value is requested outside of the points specified.
When zero range clamping is On, GetValue() returns the value at the value at the lowest point for a request below all points specified and returns the value at the highest point for a request above all points specified. On is the default.
| Argument | Type | Required | Description |
|---|---|---|---|
clamping | Boolean | Yes |
setNodeValue
| Argument | Type | Required | Description |
|---|---|---|---|
index | Number | Yes | |
val | Yes |
setNodes
| Argument | Type | Required | Description |
|---|---|---|---|
nodes | Yes |
setRange
| Argument | Type | Required | Description |
|---|---|---|---|
min | Number | Yes | |
max | Number | Yes |
setRange
| Argument | Type | Required | Description |
|---|---|---|---|
range | Range | Yes |
setRangeFrom
| Argument | Type | Required | Description |
|---|---|---|---|
range | Range | Yes |
sortAndUpdateRange
Internal method to sort the vector and update the Range whenever a node is added, edited or removed.
updateRange
Returns true if the range has been updated and Modified() has been called.