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" 35 namespace OPENSUBDIV_VERSION {
58 template <
typename REAL>
86 bool IsValid()
const {
return _data.isValid(); }
89 void Clear() { _data.reinitialize(); }
151 template <
typename REAL_MESH>
153 PointDescriptor
const & meshPointDesc,
154 REAL controlPoints[],
155 PointDescriptor
const & controlPointDesc)
const;
159 PointDescriptor
const & controlPointDesc,
161 REAL maxExtent[])
const;
165 PointDescriptor
const & meshPointDesc,
167 REAL maxExtent[])
const;
200 PointDescriptor
const & meshPointDesc,
202 PointDescriptor
const & patchPointDesc)
const;
214 PointDescriptor
const & patchPointDesc)
const;
228 REAL
const patchPoints[], PointDescriptor
const & pointDesc,
233 REAL
const patchPoints[], PointDescriptor
const & pointDesc,
234 REAL P[], REAL Du[], REAL Dv[])
const;
238 REAL
const patchPoints[], PointDescriptor
const & pointDesc,
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;
271 REAL
const controlPoints[], PointDescriptor
const &,
272 REAL result[])
const;
276 REAL
const meshPoints[], PointDescriptor
const &,
277 REAL result[])
const;
285 void evaluateDerivs(REAL
const uv[2], REAL
const patchPoints[],
286 PointDescriptor
const &, REAL * derivs[])
const;
287 void evalRegularDerivs(REAL
const uv[2], REAL
const patchPoints[],
288 PointDescriptor
const &, REAL * derivs[])
const;
289 void evalIrregularDerivs(REAL
const uv[2], REAL
const patchPoints[],
290 PointDescriptor
const &, REAL * derivs[])
const;
291 void evalMultiLinearDerivs(REAL
const uv[2], REAL
const patchPoints[],
292 PointDescriptor
const &, REAL * derivs[])
const;
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;
329 template <
typename REAL>
336 computeLinearPatchPoints(points, pointDesc);
338 computeIrregularPatchPoints(points, pointDesc);
343 template <
typename REAL>
349 GatherControlPoints(meshPoints, meshPointDesc, patchPoints, patchPointDesc);
350 ComputePatchPoints(patchPoints, patchPointDesc);
356 template <
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);
370 template <
typename REAL>
373 REAL
const patchPoints[],
377 REAL * derivatives[6] = { P, 0, 0, 0, 0, 0 };
378 evaluateDerivs(uv, patchPoints, pointDesc, derivatives);
380 template <
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);
390 template <
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);
402 template <
typename REAL>
407 return evalRegularStencils(uv, sDeriv);
408 }
else if (IsLinear()) {
409 return evalMultiLinearStencils(uv, sDeriv);
411 return evalIrregularStencils(uv, sDeriv);
414 template <
typename REAL>
418 REAL * derivativeStencils[6] = { sP, 0, 0, 0, 0, 0 };
419 return evaluateStencils(uv, derivativeStencils);
421 template <
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);
429 template <
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);
442 using namespace OPENSUBDIV_VERSION;
void ApplyStencil(REAL const stencil[], REAL const controlPoints[], PointDescriptor const &, REAL result[]) const
Apply a single stencil to control points from a local array.
void Evaluate(REAL const uv[2], REAL const patchPoints[], PointDescriptor const &pointDesc, REAL P[]) const
Evaluation of position.
void GatherControlPoints(REAL_MESH const meshPoints[], PointDescriptor const &meshPointDesc, REAL controlPoints[], PointDescriptor const &controlPointDesc) const
Gather control points in a local array.
void Clear()
Clear a previously initialized Surface.
Simple class defining the 2D parameterization of a face.
void BoundControlPoints(REAL const controlPoints[], PointDescriptor const &controlPointDesc, REAL minExtent[], REAL maxExtent[]) const
Compute bounds of control points from a local array.
bool IsValid() const
Return true if successfully initialized.
void PreparePatchPoints(REAL const meshPoints[], PointDescriptor const &meshPointDesc, REAL patchPoints[], PointDescriptor const &patchPointDesc) const
Prepare patch points in a local array for evaluation.
int GetNumPatchPoints() const
Return the number of patch points representing the Surface.
void ApplyStencilFromMesh(REAL const stencil[], REAL const meshPoints[], PointDescriptor const &, REAL result[]) const
Apply a single stencil to control points from the mesh data.
Base class providing initialization of a Surface for each face of a mesh.
int GetFaceSize() const
Returns the size (number of vertices) of the corresponding face.
int GetNumControlPoints() const
Return the number of control points affecting the Surface.
PointDescriptor(int n, int m)
int EvaluateStencil(REAL const uv[2], REAL sP[]) const
Evaluation of the limit stencil for position.
int Index
Integer type representing a mesh index.
bool IsLinear() const
Return if the Surface is linear.
bool IsRegular() const
Return if the Surface is a single regular patch.
void ComputePatchPoints(REAL patchPoints[], PointDescriptor const &patchPointDesc) const
Compute all patch points following the control points.
void BoundControlPointsFromMesh(REAL const meshPoints[], PointDescriptor const &meshPointDesc, REAL minExtent[], REAL maxExtent[]) const
Compute bounds of control points from the mesh data.
Simple struct defining the size and stride of points in arrays.
Surface()
Default construction produces an invalid instance.
int GetFaceSize() const
Return the size of the face.
Encapsulates the limit surface for a face of a mesh.
Surface & operator=(Surface const &src)=default
int GetControlPointIndices(Index meshPointIndices[]) const
Identify indices of control points in the mesh.
Parameterization GetParameterization() const
Return the Parameterization.