Polyhedral-net Splines
Loading...
Searching...
No Matches
C++ Library

C++ Library to facilitate building interactive applications utilizing PnS.

Public API reference

Warning
The Public API is uses PIMPL Idiom for binary compatibility. Use of any classes or functions outide the public library from pre-compiled binaries may face issues with binary compatibility.

Header files

#include "PolyhedralSplines/PnSpline.hpp"
#include "PolyhedralSplines/PnSPatch.hpp"

Creating a PnSpline Object

PnSpline object represent a Polyhedral-net-Spline surface. It is represented as peicewise polynomial patches in Bernstein–Bézier form. A PnSpline object can be created using the control-net data.

Create the data for the control net.

std::vector< std::array< double, 3 > > cubeVertices = {
{-1, -1, 1},
{ 1, -1, 1},
{ 1, 1, 1},
{-1, 1, 1},
{-1, -1, -1},
{ 1, -1, -1},
{ 1, 1, -1},
{-1, 1, -1}
};
std::vector< std::vector< uint32_t > > cubeFaces = {
{0, 1, 2, 3},
{7, 6, 5, 4},
{1, 0, 4, 5},
{2, 1, 5, 6},
{3, 2, 6, 7},
{0, 3, 7, 4}
};

Create a PnSpline object

PnSpline surface = PnSpline(cubeVertices, cubeFaces);
Represents a PnSpline(Polyhedral net Spline) composed of piecwise polynomial patches PnSPatch.
Definition PnSpline.hpp:35

Accessing the Piecwise Patches

PnSPatch reresents a single peicewise polynomial patch in Bernstein–Bézier form.

A patch can be retireved using an index. The value for each dimention for each coefficient can then be accessed.

for(uint32_t p = 0; p < surface.numPatches(); p++){
PnSPatch patch = surface.getPatch(p);
for(uint32_t u = 0; u < patch.getDegreeU() + 1; u++){
for(uint32_t v= 0; v < patch.getDegreeV() + 1; v++){
double x = patch(u, v, 0);
double y = patch(u, v, 1);
double z = patch(u, v, 2);
}
}
}
Represents a polynomial patch in Bernstein–Bézier form.
Definition PnSPatch.hpp:20
uint32_t getDegreeV() const
Get the polynomial degree in the v-direction.
Definition PnSPatch.hpp:161
uint32_t getDegreeU() const
Get the polynomial degree in the u-direction.
Definition PnSPatch.hpp:157
uint32_t numPatches() const
Get the number of patches in this PnSpline.
Definition PnSpline.hpp:207
PnSPatch getPatch(uint32_t index) const
Access an individual patch by index.
Definition PnSpline.hpp:211

Updating the Control Net

The control net for a PnSpline can be efficiently updated using the updateControlMesh function. This will only regenerate the required patches. Making it a lot faster than creating a new PnSpline from scratch, especially for large control nets.

std::vector<std::array<double,3>> updatedVertices = {
{-2, -1, 1},
{ 2, -1, 1}
};
std::vector<uint32_t> updateIndices = {0, 1};
std::vector<uint32_t> upadatedPatchesIndices = surface.updateControlMesh(updatedVertices, updateIndices);
std::vector< uint32_t > updateControlMesh(std::vector< std::array< double, 3 > > &updatedControlPoints, std::vector< uint32_t > &updateIndices)
Update part of the control mesh.
Definition PnSpline.hpp:185

Each element in upadatedPatchesIndices represents the index to a patch that has been modified. The remaining patches remain unchanged.

Note
Modifying the topology/connectivity of the control net requires a new PnSpline to be created.