8#ifndef OPENSUBDIV3_BFR_SURFACE_H
9#define OPENSUBDIV3_BFR_SURFACE_H
11#include "../version.h"
13#include "../bfr/surfaceData.h"
18namespace OPENSUBDIV_VERSION {
41template <
typename REAL>
69 bool IsValid()
const {
return _data.isValid(); }
72 void Clear() { _data.reinitialize(); }
95 bool IsRegular()
const {
return _data.isRegular(); }
98 bool IsLinear()
const {
return _data.isLinear(); }
134 template <
typename REAL_MESH>
137 REAL controlPoints[],
144 REAL maxExtent[])
const;
150 REAL maxExtent[])
const;
217 REAL P[], REAL Du[], REAL Dv[])
const;
222 REAL P[], REAL Du[], REAL Dv[],
223 REAL Duu[], REAL Duv[], REAL Dvv[])
const;
245 REAL sDu[], REAL sDv[])
const;
249 REAL sDu[], REAL sDv[],
250 REAL sDuu[], REAL sDuv[], REAL sDvv[])
const;
255 REAL result[])
const;
260 REAL result[])
const;
268 void evaluateDerivs(REAL
const uv[2], REAL
const patchPoints[],
270 void evalRegularDerivs(REAL
const uv[2], REAL
const patchPoints[],
272 void evalIrregularDerivs(REAL
const uv[2], REAL
const patchPoints[],
274 void evalMultiLinearDerivs(REAL
const uv[2], REAL
const patchPoints[],
277 void evalRegularBasis(REAL
const uv[2], REAL * wDeriv[])
const;
278 IndexArray evalIrregularBasis(REAL
const uv[2], REAL * wDeriv[])
const;
279 int evalMultiLinearBasis(REAL
const uv[2], REAL * wDeriv[])
const;
281 int evaluateStencils(REAL
const uv[2], REAL * sDeriv[])
const;
282 int evalRegularStencils(REAL
const uv[2], REAL * sDeriv[])
const;
283 int evalIrregularStencils(REAL
const uv[2], REAL * sDeriv[])
const;
284 int evalMultiLinearStencils(REAL
const uv[2], REAL * sDeriv[])
const;
287 void computeLinearPatchPoints(REAL p[],
PointDescriptor const &)
const;
288 void computeIrregularPatchPoints(REAL p[],
PointDescriptor const &)
const;
291 unsigned char getRegPatchType()
const {
return _data.getRegPatchType(); }
292 unsigned char getRegPatchMask()
const {
return _data.getRegPatchMask(); }
294 internal::IrregularPatchType
const & getIrregPatch()
const;
300 internal::SurfaceData & getSurfaceData() {
return _data; }
301 internal::SurfaceData
const & getSurfaceData()
const {
return _data; }
305 internal::SurfaceData _data;
312template <
typename REAL>
319 computeLinearPatchPoints(points, pointDesc);
321 computeIrregularPatchPoints(points, pointDesc);
326template <
typename REAL>
332 GatherControlPoints(meshPoints, meshPointDesc, patchPoints, patchPointDesc);
333 ComputePatchPoints(patchPoints, patchPointDesc);
339template <
typename REAL>
342 REAL
const patchPoints[],
343 PointDescriptor
const & pointDesc,
344 REAL * derivatives[])
const {
346 evalRegularDerivs(uv, patchPoints, pointDesc, derivatives);
347 }
else if (IsLinear()) {
348 evalMultiLinearDerivs(uv, patchPoints, pointDesc, derivatives);
350 evalIrregularDerivs(uv, patchPoints, pointDesc, derivatives);
353template <
typename REAL>
356 REAL
const patchPoints[],
360 REAL * derivatives[6] = { P, 0, 0, 0, 0, 0 };
361 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
363template <
typename REAL>
366 REAL
const patchPoints[],
368 REAL P[], REAL Du[], REAL Dv[])
const {
370 REAL * derivatives[6] = { P, Du, Dv, 0, 0, 0 };
371 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
373template <
typename REAL>
376 REAL
const patchPoints[],
378 REAL P[], REAL Du[], REAL Dv[],
379 REAL Duu[], REAL Duv[], REAL Dvv[])
const {
381 REAL * derivatives[6] = { P, Du, Dv, Duu, Duv, Dvv };
382 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
385template <
typename REAL>
390 return evalRegularStencils(uv, sDeriv);
391 }
else if (IsLinear()) {
392 return evalMultiLinearStencils(uv, sDeriv);
394 return evalIrregularStencils(uv, sDeriv);
397template <
typename REAL>
401 REAL * derivativeStencils[6] = { sP, 0, 0, 0, 0, 0 };
402 return evaluateStencils(uv, derivativeStencils);
404template <
typename REAL>
407 REAL sP[], REAL sDu[], REAL sDv[])
const {
409 REAL * derivativeStencils[6] = { sP, sDu, sDv, 0, 0, 0 };
410 return evaluateStencils(uv, derivativeStencils);
412template <
typename REAL>
415 REAL sP[], REAL sDu[], REAL sDv[],
416 REAL sDuu[], REAL sDuv[], REAL sDvv[])
const {
418 REAL * derivativeStencils[6] = { sP, sDu, sDv, sDuu, sDuv, sDvv };
419 return evaluateStencils(uv, derivativeStencils);
425using namespace OPENSUBDIV_VERSION;
Simple class defining the 2D parameterization of a face.
int GetFaceSize() const
Returns the size (number of vertices) of the corresponding face.
Encapsulates the limit surface for a face of a mesh.
int Index
Integer type representing a mesh index.
int GetNumControlPoints() const
Return the number of control points affecting the Surface.
void Evaluate(REAL const uv[2], REAL const patchPoints[], PointDescriptor const &pointDesc, REAL P[]) const
Evaluation of position.
int GetFaceSize() const
Return the size of the face.
bool IsRegular() const
Return if the Surface is a single regular patch.
void BoundControlPoints(REAL const controlPoints[], PointDescriptor const &controlPointDesc, REAL minExtent[], REAL maxExtent[]) const
Compute bounds of control points from a local array.
int GetControlPointIndices(Index meshPointIndices[]) const
Identify indices of control points in the mesh.
void ApplyStencil(REAL const stencil[], REAL const controlPoints[], PointDescriptor const &, REAL result[]) const
Apply a single stencil to control points from a local array.
Parameterization GetParameterization() const
Return the Parameterization.
Surface()
Default construction produces an invalid instance.
void ApplyStencilFromMesh(REAL const stencil[], REAL const meshPoints[], PointDescriptor const &, REAL result[]) const
Apply a single stencil to control points from the mesh data.
Surface & operator=(Surface const &src)=default
void BoundControlPointsFromMesh(REAL const meshPoints[], PointDescriptor const &meshPointDesc, REAL minExtent[], REAL maxExtent[]) const
Compute bounds of control points from the mesh data.
void Clear()
Clear a previously initialized Surface.
Surface(Surface const &src)=default
void PreparePatchPoints(REAL const meshPoints[], PointDescriptor const &meshPointDesc, REAL patchPoints[], PointDescriptor const &patchPointDesc) const
Prepare patch points in a local array for evaluation.
bool IsValid() const
Return true if successfully initialized.
void GatherControlPoints(REAL_MESH const meshPoints[], PointDescriptor const &meshPointDesc, REAL controlPoints[], PointDescriptor const &controlPointDesc) const
Gather control points in a local array.
void ComputePatchPoints(REAL patchPoints[], PointDescriptor const &patchPointDesc) const
Compute all patch points following the control points.
bool IsLinear() const
Return if the Surface is linear.
int GetNumPatchPoints() const
Return the number of patch points representing the Surface.
int EvaluateStencil(REAL const uv[2], REAL sP[]) const
Evaluation of the limit stencil for position.
Simple struct defining the size and stride of points in arrays.
PointDescriptor(int n, int m)
Base class providing initialization of a Surface for each face of a mesh.