Creating Splines with the ShapeSheet in Visio 2000

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

 

Susan Harney

February 2000

Summary: This article describes how to create a spline in the ShapeSheet® window by drawing with the line or freeform tool and then working with that shape's Geometry rows and adding degree and knot values to the appropriate cells. (7 printed pages.)

You don't need to know any of the technical details to draw and modify a spline with the mouse. You can create a spline on the drawing page using the freeform tool, and adjust the spline by dragging the handles that appear when you select the spline with the freeform or pencil tool.

However, if you want to create a spline based on a specific set of control points and knots, you may prefer to work in the ShapeSheet window. In Microsoft® Visio® 2000, freeform curves are represented internally as non-uniform rational B-splines (NURBS).

This article describes how to create a spline in the ShapeSheet window by drawing with the line or freeform tool, and then working with that shape's Geometry rows and adding degree and knot values to the appropriate cells.

**Note   **You can also create splines from a program. To do this you can do one of the following:

  • Invoke the DrawNURBS or DrawSpline method.
  • Work with the sections, rows, and cells in the spline's Geometry section, using the rows and cell formulas described in this article.

For details about adding rows and changing row types, along with constants and cell names to use when working with spline rows from a program, see "Developing Microsoft Visio Solutions" in the Visio section of Office Developer Documentation, a guide for creating custom graphic solutions using the Visio development platform.

Splines: The Basics

If you're unfamiliar with splines, you may want to consult a standard college textbook on curve and surface geometry or a comparable textbook on computer-aided design. Until you do, here's a brief introduction.

Think of a spline as a thin, flexible ruler with marks that may be unevenly spaced (hence the "non-uniform" part of the name). The marks are called knots and a knot may be repeated more than once. The multiplicity of a knot is the number of times it is repeated.

Figure 1. Knots on a spline

The spline's degree is a positive integer (between 1 and 9 in Visio) that is the degree of the polynomial equations used to calculate the pieces of the spline.

The control points of the spline influence its curvature. Each control point is located at some distance from the visible curve of the spline. Together, all of a spline's control points are sometimes called the spline's control polygon. Each control point has a domain of influence of degree+2 consecutive knots. For example, if a spline has a degree of 2, each control point has a domain of influence of four consecutive knots on the spline. The control point influences the part of the spline between the first and last knot of its domain.

Figure 2. Control points and their domains of influence on a spline with a degree of 2

The visible curve of the spline is "attracted" to each control point, exerting the strongest pull at about the middle of its domain of influence. A control point has no effect outside its domain of influence, but the domains of adjacent control points may overlap, so degree+2 control points affect every point on the curve.

Every control point has a weight associated with it. All weights must be positive and a larger weight causes the spline to move closer to its control point. The weights produced by the freeform tool are all equal to 1, but splines with unequal weights are sometimes used in CAD drawings. These splines are rational.

The degree of a spline, the number of knots it has, the locations of its control points relative to each other, and the relative size of its weights all influence the appearance of the spline on the drawing page.

About Periodic and Nonperiodic Splines

A spline can be periodic or nonperiodic. A nonperiodic spline has beginning and ending points and it can be open or closed (that is, its beginning and ending points can meet). A periodic spline is a closed, seamless shape that has no beginning or ending point.

Figure 3. A periodic spline (left), an open nonperiodic spline (center), and a closed nonperiodic spline (right)

By mathematical convention, a nonperiodic spline has degree+1 knots of the same multiplicity at the end of the spline as well as the beginning. In Visio, however, if a spline begins with degree+1 knots, the Visio program assumes that the spline is nonperiodic and that the multiple ending knots are implied.

For a periodic spline, the multiplicity of the first knot can be less than or equal to the degree of the spline. For example, if the spline has a degree of 3, the first one, two, or three knots can have the same value, but the fourth knot must be greater.

How Spline Data Is Organized in the ShapeSheet

There are two ways to represent splines in the Geometry section of the ShapeSheet.

  • A single NURBSTo row. This is the most compact representation, storing most of the spline's data in a single cell as a NURBS formula. However, control points, knots, and weights represented as arguments of the NURBS formula can only be constants, they cannot be formulas. The freeform tool creates a NURBSTo row.
  • A SplineStart row followed by one or more SplineKnot rows. This representation fully supports formulas, but it does not include weights, so it is only good for non-rational splines.

In either case, the first spline row must be preceded by another kind of row, such as a Start row, to indicate the first control point of the spline. The preceding row can be a LineTo, ArcTo, or EllipticalArcTo row if the spline follows a segment of that type.

The following table describes the values in a NURBSTo row. All coordinates are local. Spline knots are specified as described in Splines: The Basics earlier in this article.

NURBS Representation In the Geometry Section

Row Cell Value
The row that precedes NURBSTo X The x-coordinate of the spline's first control point
  Y The y-coordinate of the spline's first control point
NURBSTo X The x-coordinate of the spline's last control point
  Y The y-coordinate of the spline's last control point
  A The spline's second or last knot
  B The spline's second or last weight
  C The spline's first knot
  D The spline's first weight
  E The rest of the spline as a NURBS formula

The following table describes the values in SplineStart and SplineKnot row cells. All coordinates are local. Spline knots are specified as described in Splines: The Basics earlier in this article.

SplineStart Representation In the Geometry Section

Row Cell Value
The row that precedes SplineStart X The x-coordinate of the spline's first control point
  Y The y-coordinate of the spline's first control point
SplineStart X The x-coordinate of the spline's second control point
  Y The y-coordinate of the spline's second control point
  A The spline's second knot
  B The spline's first knot
  C The spline's last knot
  D The degree of the spline (an integer from 1 to 9)
SplineKnot X The x-coordinate of a control point
  Y The y-coordinate of a control point
  A The spline's third or greater knot

For a valid spline in either representation, the values of these cells must follow certain rules:

  • The knot values must not decrease from the first knot to the last.
  • The multiplicity of the first knot (the number of times the same knot value occurs) may not exceed the degree of the spline plus 1. For example, if the spline has a degree of 3, the first four knots can have the same value.
  • The multiplicity of all knots after the first must not exceed the degree of the spline.
  • If you're creating splines in Visio from a data set that has degree+1 ending knots, you need to create a SplineKnot row for only one ending knot, not degree+1 knots.
  • The degree of the spline must be an integer from 1 to 9. A value of 1 draws the spline as straight segments between control points (which is essentially identical to its control polygon). The higher the degree, the flatter the spline's curves will be.
  • Unless the degree of the spline is 1, a SplineStart row must be followed by at least one SplineKnot row.

If you delete a SplineKnot row of a nonperiodic spline or similarly change the knot of a NURBSTo so that it has fewer than degree+1 knots at the beginning, Visio assumes that you want a periodic spline and converts the spline.

If the spline definition becomes invalid, Visio draws the spline as if the last SplineKnot row is a LineTo row. All other SplineKnot rows are ignored.

Creating a Spline Using SplineStart and SplineKnot Rows: An Example

The following example shows how to create a spline in the ShapeSheet window. Suppose you want to create a spline based on the following definition:

Degree = 3
Control points = {3,3}, {3,5}, {5,5}, {5,3}, {7,3}
Knots = 0, 0, 0, 0, 1, 2

(Using conventional mathematical notation, the knots of the same spline would be specified as 0, 0, 0, 0, 1, 2, 2, 2, 2.)

To create the example spline in the ShapeSheet window:

  1. Use the line tool to draw the spline's control polygon as a series of line segments connecting its control points. In this example, the control polygon would look like this.

    Figure 4. A spline's control polygon drawn as a Visio shape

  2. In the ShapeSheet window, change the row type of the first LineTo row to SplineStart.

  3. Change the row type of all subsequent LineTo rows to SplineKnot.

  4. Set formulas as shown in the following table.

Row Cell Formula Meaning
SplineStart Geometry1.A2 =0 Second knot
Geometry1.B2 =0 First knot
Geometry1.C2 =2 Last knot
Geometry1.D2 =3 Degree of the spline
SplineKnot Geometry1.A3 =0 Third knot
SplineKnot Geometry1.A4 =0 Fourth knot
SplineKnot Geometry1.A5 =1 Fifth knot

The resulting spline looks like this.

Figure 5. The control polygon converted to a spline

Creating a Spline Using the NURBSTo Row: An Example

The following rational spline represents a hyperbola. Note that this is a truly rational spline, hence it could not be represented in Visio without using NURBS.

Degree = 2
Control points = {0,0}, {1,3}, {2,0}
Knots = 0, 0, 0, 1
Weights: 1, 4, 1

(Using conventional mathematical notation, the knots would be specified as 0, 0, 0, 1, 1, 1.)

  1. Use the freeform tool to draw any spline.
  2. Position the spline's endpoints 2" apart and resize its height to be 3".
  3. In the ShapeSheet window, replace the NURBS formula with NURBS(1,2,0,0,0.5,1,0,4).
  4. Change the value in Cell A of the NURBSTo row to 0.

The resulting spline looks like this.

Figure 6. A hyperbola as a NURBS curve

Try assigning other positive values to the second weight (the last argument in the NURBS formula) and notice the effect on the shape of the curve. In any case you'll get a conic section: it's a hyperbola if the weight is greater than 1, an elliptical arc if the weight is between 0 and 1, and a parabola if the weight is exactly 1.