Example Code

Example using De Boor's algorithm to plot a B-spline curve.

Code and Documents

Attachment

Overview

A B-Spline may be used by CAD software to represent a curve. With B-Spline, a curve is encoded by a set of

"Control-points", a set of "Knots" and the "Degree" of the spline. This method is currently

employed within .DXF files to represent a "SPLINE" "entity".  Using given Degree, Knots and Control-points, The

"De Boor's algorithm" converts a scaler value (within the range of Knots) to a point on the curve.

Description

At the heart of this example is a reentrant VI which implememnts the (recursive) De Boor's algorithm

- "Util.Math.BSpline.deBoors.Recursive.vi".  It can be used to translate any scaler/target (within

Knot domain) into a point on the curve.

Util.Math.BSpline.deBoors.vi calls the recursive VI multiple times - once for each element in an

array of targets - generating an array of points.

The top-level VI is actually a sub-VI from a larger application, but it can be run independently and

will plot a curve using the default input values.

Hardware and Software Requirements

LabVIEW 2013 or later.

Steps to Implement or Execute Code

1. Open top-level VI and click run-arrow.

Additional Information or References

This VI is a sub-VI from a larger application designed to convert several types of DXF entities into "polylines" (for another process).

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
TommyDunkz
NI Employee (retired)
on

Hi 550nm,

 

Thank you for taking the time to share this example code with the community! I've reviewed it and have some recommendations for it, so that it can meet the Community Example style guidelines. Most of these are minor stylistic changes that we ask for in order to keep the user experience consistent for Community Examples, and to ensure that the code can be implemented seamlessly into larger applications.

 

Once the following changes have been made, I'll go ahead and push the example live for all users of the community:

  • All files should be named with full words, and spaces between the words. Some examples:
  • The top-left corner of each example should have a free label formatted as follows:community_example_label.png
  • Notes about this label:
    • The Overview must be exactly one sentence long. Its intent is to be a quick description of the example.  For a more in-depth description of the example and its motivations, use the community download page.
    • Bold the section names (Overview, Requirements, Instructions).
    • Bold anything you want to stand out in the text. In the text above, Network Streams is bolded because it’s the name of the palette of functions being illustrated, and Simple Network Streams - Host.vi is bolded because it’s the name of another VI you have to run along with this example.
    • Use “or compatible” instead of “or later” in the requirements section to help “future-proof” the information.
  • KnotIndex.vi has some controls labelled with default names. These controls should have more descriptive names.
  • Front panel clusters should be set to 'Arrange Vertically'.
  • Use Linked Input Tunnels for state data that is passed through all the frames of Case/Event Structures. Search for “Wiring Tunnels Automatically” in the LabVIEW Help for more information about this feature. There is one nested case structure in StraightSpan.vi that should have a Linked Input Tunnel.
  • In general, the subVIs in this example could use some comments explaining the purpose of each one.
  • Use Subdiagram Labels to document the functionality of subdiagrams in your code.
  • SPLINE.vi's block diagram has a couple of long wires that would benefit from wire labels.
  • Remove Diagram Disable Structure at the right-hand side of SPLINE.vi's block diagram.
  • Include the LabVIEW version in the name of the download. An example might be named “My Custom Sorting Algorithm – LV2009.vi” or “My Custom Sorting Algorithm – LV2009.zip”.

 

Best regards,

 

Tom D.
Staff Software Engineer
NI
Contributors