File I/O

Two means are provided to read data from files either via the function load or via file specific functions.

Note

To use the unifying function load, the package FileIO is needed.

Step files

To read .step and .stp files containing B-spline surfaces and/or NURBS surfaces the load function and the readStep function is provided.

Note

So far only reading B-spline surfaces (called B_SPLINE_SURFACE_WITH_KNOTS in .step and .stp) and NURBS surfaces (as a BOUNDED_SURFACE() in .step and .stp) is supported. However, reading curves should not be too dificult to implement.

using NURBS, FileIO
Patches = load("assets/torus.stp")

using PlotlyJS
plotPatches(Patches, plotControlPoints=false, resolution=0.25)

Multipatch Files

To read multipatch files as defined and provided by the nurbs Octave implementation and BEMBEL the load function and the readMultipatch function is provided.

Note

Apart from these files the implementation in this package is done independendly from the Octave package. Similarities are accidentally (as it is also based on [1]). Also note, that the Octave package so far provides more functionality.

using NURBS, FileIO
Patches = load("assets/sphere.dat")

using PlotlyJS
plotPatches(Patches, plotControlPoints=true, resolution=0.1)

VTK Files (ParaView)

To display surfaces in ParaView the function saveVtk is provided. It converts the surface to an unstructured grid and exports a .vtu file which can be opened by ParaView.

using NURBS, FileIO
Patches = load("assets/torus.stp")

saveVtk("filename", Patches; resolution=0.01) # filename without extension

To add color information the function vtk can be used together with the WriteVKT.jl package. To this end, the color values at the four corner points of each cell have to be provided in a Vector.

using NURBS, FileIO, WriteVTK
Patches = load("assets/torus.stp")

cellV, x, y, z = NURBS.vtk(Patches, 0.01)

vtk_grid("filename", x, y, z, cellV) do vtk
    vtk["dataName"] = 2 * x + y
end