25#ifndef OPENSUBDIV3_BFR_SURFACE_H
26#define OPENSUBDIV3_BFR_SURFACE_H
28#include "../version.h"
30#include "../bfr/surfaceData.h"
31#include "../bfr/parameterization.h"
32#include "../vtr/array.h"
35namespace OPENSUBDIV_VERSION {
58template <
typename REAL>
86 bool IsValid()
const {
return _data.isValid(); }
89 void Clear() { _data.reinitialize(); }
151 template <
typename REAL_MESH>
154 REAL controlPoints[],
161 REAL maxExtent[])
const;
167 REAL maxExtent[])
const;
234 REAL P[], REAL Du[], REAL Dv[])
const;
239 REAL P[], REAL Du[], REAL Dv[],
240 REAL Duu[], REAL Duv[], REAL Dvv[])
const;
262 REAL sDu[], REAL sDv[])
const;
266 REAL sDu[], REAL sDv[],
267 REAL sDuu[], REAL sDuv[], REAL sDvv[])
const;
272 REAL result[])
const;
277 REAL result[])
const;
285 void evaluateDerivs(REAL
const uv[2], REAL
const patchPoints[],
287 void evalRegularDerivs(REAL
const uv[2], REAL
const patchPoints[],
289 void evalIrregularDerivs(REAL
const uv[2], REAL
const patchPoints[],
291 void evalMultiLinearDerivs(REAL
const uv[2], REAL
const patchPoints[],
294 void evalRegularBasis(REAL
const uv[2], REAL * wDeriv[])
const;
295 IndexArray evalIrregularBasis(REAL
const uv[2], REAL * wDeriv[])
const;
296 int evalMultiLinearBasis(REAL
const uv[2], REAL * wDeriv[])
const;
298 int evaluateStencils(REAL
const uv[2], REAL * sDeriv[])
const;
299 int evalRegularStencils(REAL
const uv[2], REAL * sDeriv[])
const;
300 int evalIrregularStencils(REAL
const uv[2], REAL * sDeriv[])
const;
301 int evalMultiLinearStencils(REAL
const uv[2], REAL * sDeriv[])
const;
304 void computeLinearPatchPoints(REAL p[],
PointDescriptor const &)
const;
305 void computeIrregularPatchPoints(REAL p[],
PointDescriptor const &)
const;
308 unsigned char getRegPatchType()
const {
return _data.getRegPatchType(); }
309 unsigned char getRegPatchMask()
const {
return _data.getRegPatchMask(); }
311 internal::IrregularPatchType
const & getIrregPatch()
const;
317 internal::SurfaceData & getSurfaceData() {
return _data; }
318 internal::SurfaceData
const & getSurfaceData()
const {
return _data; }
322 internal::SurfaceData _data;
329template <
typename REAL>
336 computeLinearPatchPoints(points, pointDesc);
338 computeIrregularPatchPoints(points, pointDesc);
343template <
typename REAL>
349 GatherControlPoints(meshPoints, meshPointDesc, patchPoints, patchPointDesc);
350 ComputePatchPoints(patchPoints, patchPointDesc);
356template <
typename REAL>
359 REAL
const patchPoints[],
360 PointDescriptor
const & pointDesc,
361 REAL * derivatives[])
const {
363 evalRegularDerivs(uv, patchPoints, pointDesc, derivatives);
364 }
else if (IsLinear()) {
365 evalMultiLinearDerivs(uv, patchPoints, pointDesc, derivatives);
367 evalIrregularDerivs(uv, patchPoints, pointDesc, derivatives);
370template <
typename REAL>
373 REAL
const patchPoints[],
377 REAL * derivatives[6] = { P, 0, 0, 0, 0, 0 };
378 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
380template <
typename REAL>
383 REAL
const patchPoints[],
385 REAL P[], REAL Du[], REAL Dv[])
const {
387 REAL * derivatives[6] = { P, Du, Dv, 0, 0, 0 };
388 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
390template <
typename REAL>
393 REAL
const patchPoints[],
395 REAL P[], REAL Du[], REAL Dv[],
396 REAL Duu[], REAL Duv[], REAL Dvv[])
const {
398 REAL * derivatives[6] = { P, Du, Dv, Duu, Duv, Dvv };
399 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
402template <
typename REAL>
407 return evalRegularStencils(uv, sDeriv);
408 }
else if (IsLinear()) {
409 return evalMultiLinearStencils(uv, sDeriv);
411 return evalIrregularStencils(uv, sDeriv);
414template <
typename REAL>
418 REAL * derivativeStencils[6] = { sP, 0, 0, 0, 0, 0 };
419 return evaluateStencils(uv, derivativeStencils);
421template <
typename REAL>
424 REAL sP[], REAL sDu[], REAL sDv[])
const {
426 REAL * derivativeStencils[6] = { sP, sDu, sDv, 0, 0, 0 };
427 return evaluateStencils(uv, derivativeStencils);
429template <
typename REAL>
432 REAL sP[], REAL sDu[], REAL sDv[],
433 REAL sDuu[], REAL sDuv[], REAL sDvv[])
const {
435 REAL * derivativeStencils[6] = { sP, sDu, sDv, sDuu, sDuv, sDvv };
436 return evaluateStencils(uv, derivativeStencils);
442using 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 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.
int Index
Integer type representing a mesh index.
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.