catmull_spline & catmull_spline_fld

Synopsis

catmull_spline generates a Catmull-Rom spline from a series of 2D or 3D coordinates.

catmull_spline_fld generates a Catmull-Rom spline from a 2D or 3D input field.

Input Ports

catmull_spline
Name Type Description

in float array coordinates of nodes to be used to generate the spline

catmull_spline_fld
Name Type Description

in_fld mesh+data input_field to be used to generate the spline

Parameters

The following lists all of the parameters found in the parameter block CatmullParams, which are accessed by the modules CatmullSplineCore and CatmullSplineFldCore, and the UI Macros CatmullUI and CatmullFldUI.

Name Type Description UI Control

line_type enum specifies if the spline is closed or open. Radio Buttons
spline_type enum specifies which spline to use. none
points_added int numbers of points added between two original points. Slider
smoothness float 'Smoothness' of generated spline. Slider

Output Ports

Name Type Description

out_data float array coordinates of spline nodes
out_mesh mesh spline represented as a polyline mesh
out_obj DataObject Default Renderable Object

Description

catmull_spline is a user module that takes a series of either 2D or 3D floating point coordinates and generates a spline that passes through all the points with C1 (continuous first parametric derivative) and G1 (slopes equal at joints) continuity. The spline is then output as a similar series of coordinates, a polyline mesh and a directly renderable DataObject. Parameters are provided so that the number of points output and the smoothness of the spline can be altered. A user interface is provided so that these parameters can be easily altered.

Input Ports

&in

Reference to an array of floating point coordinates which are to be used as the nodes that the spline curve connects. Coordinates can be either 2 or 3 dimensional and should be represented by arrays of the form [n][2] and [n][3] respectively, where n is the number of nodes. A spline curve is then generated that connects the nodes together in the order given.

Parameters

line_type

A member of the CatmullParams parameter block group, this enumeration is used to specify whether the spline curve should be a complete closed curve or whether the curve should be left open. The enumeration is of the form shown below:

   enum line_type { choices => {"closed","open"}; } = "closed";

spline_type

A member of the CatmullParams parameter block group, this enumeration is used to specify which type of spline algorithm should be used to generate the spline curve. Currently the module only supports the use of the Catmull-Rom spline. However in future the module maybe enhanced to support other splines. The enumeration is of the form shown below:

   enum spline_type { choices => {"CatmullRom"}; };

points_added

A member of the CatmullParams parameter block group, this int value is used to specify the number of points that should be added between each pair of original points to create the spline curve. Increasing this value will result in a more accurate representation of the generated spline.

smoothness

A member of the CatmullParams parameter block group, this float value is used to specify the 'smoothness' of the generated spline curve. In this case the smoothness of a spline curve is defined as now closely it matches the original data. Normally this parameter should have a value between 0 and 1. As the smoothness approaches 0 the generated spline matches the original line more closely. If smoothness is given a value outside of the range 0 to 1, the resulting line will tend to be baroque.

Output Ports

out_data

The most primitive output field of the catmull_spline macro. This output contains the generated spline represented as a floating point array of coordinates. The resultant array is of the same form as the input array. Therefore for a 3D spline the resultant array would have the following dimensions [out_size][3] where out_size is the number of coordinate points generated by the spline calculation.

out_mesh

The spline curve represented as a polyline mesh.

out_obj

The directly renderable output field of the catmull macro. This contains a DataObject object that can be rendered by the standard data viewers. The Data Object is generated within the same module as the polyline mesh output.

Utility Macros

The low-level CatmullSplineCore module is used in this Functional Macro CatmullSplineFunc. This macro is used by the catmull_spline user macro. The user macro also uses the User Interface macro CatmullUI.

Example

Four example applications are provided. The CatmullSpline2DEg application takes an array of 8 2D coordinates and smoothes the polyline between them by calculating a Catmull-Rom spline curve. Similarly the CatmullSpline3DEg application takes 8 3D coordinates the smoothes the line between them. CatmullSplineFldEg takes a 3D field (Mesh+Node_Data) and smoothes the line between the field coordinates interpolating the node data values.

The PathSmoothingEg application reads the hydrogen data-set, generates a surface and then allows the user to setup a 3D path through that data-set. The camera can then by moved along the path, hence allowing the user to 'fly' through the data. To improve the sense of movement the camera path is smoothed by the CatmullSplineFunc macro.

The PathSmoothingEg application should be used by first resetting, normalizing and centering the Top object. After doing this the user should see a surface with a path marked along it. Pressing the 'Play Frames' button will start the camera moving along the path. It will stop after one circuit. To return to a overview the camera and object views both have to be reset. The user interface allows the smoothness, number of points added and visibility of both the path and the key points to be altered. The application also allows the a new path to created. First the user should press the 'Reset All' button to clear all existing key points. Next adding control points should be enabled by setting the Collect Points toggle. Once this is done control points can be added by CTRL-clicking on the surface. The CatmullSplineFunc macro will add extra points in between control points to smooth the new path.

Files

iac_proj/catmull/ctmlmods.v contains the CatmullParams group and the CatmullSplineCore module V definitions.

iac_proj/catmull/ctmlmacs.v contains the V definitions of the catmull_spline User Macro, the CatmullSplineFunc Functional Macro and the CatmullUI UI Macro.

iac_proj/catmull/ctmlapps.v contains the V definitions of the example applications CatmullSpline2DEg, CatmullSpline3DEg and PathSmoothingEg.

Other Notes

The CatmullMacs library inherits its process. As this library contains no procedural code, the process is not important. The low-level CatmullSplineCore module, executes under the process specified in its library, not the process defined in the high-level library.

Author

Mario Valle

Modifications

Andrew Dodd
Paul G. Lever
Dr Federico Gamba

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL

See Also

CatmullParams, CatmullUI, CatmullSplineFunc and CatmullSplineCore & CatmullSplineFldCore.