10#include "PnSPatch.hpp"
11#include "PnSpline_impl.hpp"
55 PnSpline(std::vector<std::array<double,3>>& controlPoints,
56 std::vector<std::vector<uint32_t>>& controlIndices,
102 std::vector<std::array<double,3>>& updatedControlPoints,
103 std::vector<uint32_t>& updateIndices);
136 std::vector<std::vector<uint32_t>>& controlIndices,
138 std::vector<double> flatPts;
139 flatPts.reserve(controlPoints.size() * 3);
140 for (
auto& p : controlPoints) {
141 flatPts.insert(flatPts.end(), {p[0], p[1], p[2]});
144 std::vector<uint32_t> flatIndices;
145 std::vector<uint64_t> faceSizes;
146 for (
auto& face : controlIndices) {
147 faceSizes.push_back(face.size());
148 flatIndices.insert(flatIndices.end(), face.begin(), face.end());
151 impl = PnSpline_create_from_points(flatPts.data(), controlPoints.size(),
152 flatIndices.data(), faceSizes.data(), controlIndices.size(),
157 :
impl(PnSpline_clone(other.
impl)) {}
160 if (
this != &other) {
168 other.impl =
nullptr;
172 if (
this != &other) {
175 other.impl =
nullptr;
186 std::vector<std::array<double,3>>& updatedControlPoints,
187 std::vector<uint32_t>& updateIndices) {
189 std::vector<double> flatPts;
190 flatPts.reserve(updatedControlPoints.size() * 3);
191 for (
auto& p : updatedControlPoints) {
192 flatPts.insert(flatPts.end(), {p[0], p[1], p[2]});
195 std::vector<uint32_t> outPatchIds(PnSpline_getNumPatches(
impl));
196 uint64_t numUpdated = PnSpline_updateControlMesh(
197 impl, flatPts.data(), updatedControlPoints.size(),
198 updateIndices.data(), updateIndices.size(),
199 outPatchIds.data(), outPatchIds.size());
201 outPatchIds.resize(numUpdated);
208 return PnSpline_getNumPatches(
impl);
Represents a polynomial patch in Bernstein–Bézier form.
Definition PnSPatch.hpp:20
uint32_t numPatches() const
Get the number of patches in this PnSpline.
Definition PnSpline.hpp:207
PnSpline & operator=(const PnSpline &other)
Copy assignment operator.
Definition PnSpline.hpp:159
void degRaise()
Degree raise all patches upto degree 3 for each paramter. Degree greater than 3 will remain unchanged...
Definition PnSpline.hpp:205
PnSPatch getPatch(uint32_t index) const
Access an individual patch by index.
Definition PnSpline.hpp:211
~PnSpline()
Destructor.
Definition PnSpline.hpp:180
PnSplineImpl * impl
Opaque pointer to implementation (PIMPL idiom). This is to ensure binary compatibility.
Definition PnSpline.hpp:128
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
PnSpline()
Construct an empty PnSpline.
Definition PnSpline.hpp:133
A class representing a Bézier patch.
Definition Patch.hpp:20
Definition PnSpline_impl.cpp:17