Patch Class Reference

#include <patch.h>

Class Description

See also
Class PatchMesh, Class TVPatch, Patches and Faces.

Description:
A PatchMesh is made up of a series of Patch objects derived from this class. This is similar to the way faces relate to a mesh. All methods of this class are implemented by the system.
Data Members:
int type;

The patch type. One of the following values:

PATCH_UNDEF

Undefined.

PATCH_TRI

Triangular patch.

PATCH_QUAD

Quadrilateral patch.

int v[4];

A patch can have three or four vertices based on the type. The corner vertices on a patch are referred to as a, b, c, (and if it's a quad patch d). These are ordered a, b, c, d going counter-clockwise around the patch.

int vec[8];

A patch can have six or eight vector points. The vectors are referred to as follows: ab is the vector coming out of vertex a towards b. ba is the one coming out of b towards a. bc is the vector coming out of b towards c. cb is the one coming out of c towards b, and so on.

int interior[4];

A patch can have three or four interior vertices.

Point3 aux[9];

This is used internally for triangular patches only (degree 4 control points).

int edge[4];

Pointers into the edge list. There can be three or four depending on the patch type.

DWORD smGroup;

The smoothing group. This defaults to 1. All patches are smoothed in a PatchMesh.

DWORD flags;

Patch Flags

The following value may be set.

PATCH_AUTO

Interior vertices are computed automatically if this flag is set (and normally it is set). An example of when this flag would not be set is if you were creating a primitive using patches that needed to make special interior control points to create the shape. In this case you'd clear this flag and then put whatever values you needed into the vec array.

PATCH_HIDDEN

The patch is hidden.

PATCH_LINEARMAPPING

This option is available in release 4.0 and later only.

The patch is using the old linear mapping scheme.

PATCH_USE_CRUVED_MAPPING_ON_VERTEX_COLOR

This option is available in release 4.0 and later only.

The patch is using the new curved mapping for vertex colors also.

int aux1;

This data member is available in release 3.0 and later only.

This is used to track topology changes during editing (Edit Patch).

int aux2;

This data member is available in release 3.0 and later only.

This is used to track topology changes during editing (PatchMesh).

+ Inheritance diagram for Patch:

Public Member Functions

CoreExport Patch ()
 
CoreExport Patch (int type)
 
CoreExport Patch (Patch &fromPatch)
 
CoreExport ~Patch ()
 
CoreExport void Init ()
 
CoreExport void setVerts (int *vrt)
 
void setVerts (int a, int b, int c)
 
void setVerts (int a, int b, int c, int d)
 
void setVecs (int ab, int ba, int bc, int cb, int ca, int ac)
 
void setVecs (int ab, int ba, int bc, int cb, int cd, int dc, int da, int ad)
 
void setInteriors (int a, int b, int c)
 
void setInteriors (int a, int b, int c, int d)
 
int getVert (int index)
 
intgetAllVerts (void)
 
MtlID getMatID ()
 
void setMatID (MtlID id)
 
Point3 getUVW (int index) const
 
Point2 getUV (int index) const
 
bool getVertUVW (int vert, Point3 &uvw) const
 
bool getVertUV (int vert, Point2 &uv) const
 
Point3 BicubicSurface (PatchMesh *pMesh, const float *uu, const float *vv)
 
CoreExport Point3 interp (PatchMesh *pMesh, float centerU, float centerV, float centerW)
 
CoreExport Point3 interp (PatchMesh *pMesh, float fU, float fV)
 
CoreExport Point3 WUTangent (PatchMesh *pMesh, float fU, float fV, float fW)
 
CoreExport Point3 UVTangent (PatchMesh *pMesh, float fU, float fV, float fW)
 
CoreExport Point3 VWTangent (PatchMesh *pMesh, float fU, float fV, float fW)
 
CoreExport Point3 UTangent (PatchMesh *pMesh, float fU, float fV)
 
CoreExport Point3 VTangent (PatchMesh *pMesh, float fU, float fV)
 
CoreExport Point3 Normal (PatchMesh *pMesh, float fU, float fV, float fW)
 
CoreExport Point3 Normal (PatchMesh *pMesh, float fU, float fV)
 
CoreExport void ComputeAux (PatchMesh *pMesh, int index)
 
CoreExport void ComputeAux (PatchMesh *pMesh)
 
CoreExport void computeInteriors (PatchMesh *pMesh)
 
CoreExport void SetType (int iType, BOOL init=FALSE)
 
CoreExport Patchoperator= (Patch &from)
 
CoreExport void SetAuto (BOOL sw=TRUE)
 
BOOL IsAuto ()
 
CoreExport void SetHidden (BOOL sw=TRUE)
 
BOOL IsHidden ()
 
int WhichEdge (int v1, int v2)
 
int WhichVert (int index)
 
CoreExport void Dump ()
 
CoreExport IOResult Save (ISave *isave)
 
CoreExport IOResult Load (ILoad *iload)
 
- Public Member Functions inherited from BaseInterfaceServer
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
virtual UtilExport int NumInterfaces () const
 
virtual UtilExport BaseInterfaceGetInterfaceAt (int i) const
 
virtual UtilExport ~BaseInterfaceServer ()
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 

Public Attributes

int type
 
int v [4]
 
int vec [8]
 
int interior [4]
 
Point3 aux [9]
 
int edge [4]
 
DWORD smGroup
 
DWORD flags
 
int aux1
 
int aux2
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 
- Protected Attributes inherited from BaseInterfaceServer
Tab< BaseInterface * > interfaces
 

Constructor & Destructor Documentation

Remarks
Constructor. The type is set to undefined, the smooth group is set to 1, and the flags indicate automatic interior points. Note: This constructor does not allocate arrays. Use SetType(type).
CoreExport Patch ( int  type)
CoreExport Patch ( Patch fromPatch)
Remarks
Constructor. The this pointer is set to the fromPatch.
Remarks
Destructor.

Member Function Documentation

CoreExport void Init ( )
Remarks
This method is used by the constructors internally. Developers should not call this method.
CoreExport void setVerts ( int vrt)
Remarks
The vertices are copied from the array passed. Based on the patch type either three or four vertices are copied.
Parameters:
int *vrt

The vertices are set to these values. These values are indices into the v array.
void setVerts ( int  a,
int  b,
int  c 
)
inline
Remarks
Sets the vertices for Tri Patch to those passed.
Parameters:
int a, int b, int c

The vertices to set. v[0]=a; v[1]=b; v[2]=c;These values are indices into the v array.
565 { assert(type == PATCH_TRI); v[0]=a; v[1]=b; v[2]=c; }
#define PATCH_TRI
Definition: PatchTypeConstants.h:13
int type
Definition: patch.h:523
int v[4]
Definition: patch.h:524
#define assert(expr)
Definition: assert1.h:71
void setVerts ( int  a,
int  b,
int  c,
int  d 
)
inline
Remarks
Sets the vertices for a Quad Patch to those passed.
Parameters:
int a, int b, int c, int d

The vertices to set. v[0]=a; v[1]=b; v[2]=c; v[3] = d; These values are indices into the v array.
571 { assert(type == PATCH_QUAD); v[0]=a; v[1]=b; v[2]=c; v[3]=d; }
#define PATCH_QUAD
int type
Definition: patch.h:523
int v[4]
Definition: patch.h:524
#define assert(expr)
Definition: assert1.h:71
void setVecs ( int  ab,
int  ba,
int  bc,
int  cb,
int  ca,
int  ac 
)
inline
Remarks
Sets the vectors for a Tri Patch to those passed.
Parameters:
int ab, int ba, int bc, int cb, int ca, int ac;

The vectors to set. vec[0]=ab; vec[1]=ba; vec[2]=bc;

vec[3]=cb; vec[4]=ca; vec[5]=ac;These values are indices into the vec array.
578  {
579  assert(type == PATCH_TRI);
580  vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=ca; vec[5]=ac;
581  }
int vec[8]
Definition: patch.h:525
#define PATCH_TRI
Definition: PatchTypeConstants.h:13
int type
Definition: patch.h:523
#define assert(expr)
Definition: assert1.h:71
void setVecs ( int  ab,
int  ba,
int  bc,
int  cb,
int  cd,
int  dc,
int  da,
int  ad 
)
inline
Remarks
Sets the vectors for a Quad patch to those passed.
Parameters:
int ab, int ba, int bc, int cb,

int cd, int dc, int da, int ad;

The vectors to set. vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb;

vec[4]=cd; vec[5]=dc; vec[6]=da, vec[7]=ad; These values are indices into the vec array.
590  {
591  assert(type == PATCH_QUAD);
592  vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=cd; vec[5]=dc; vec[6]=da, vec[7]=ad;
593  }
int vec[8]
Definition: patch.h:525
#define PATCH_QUAD
int type
Definition: patch.h:523
#define assert(expr)
Definition: assert1.h:71
void setInteriors ( int  a,
int  b,
int  c 
)
inline
Remarks
Sets the interior vertex values for a Tri Patch.
Parameters:
The interior values to set: interior[0]=a; interior[1]=b; interior[2]=c; These values are indices into the interior array.
599  {
600  assert(type == PATCH_TRI);
601  interior[0]=a; interior[1]=b; interior[2]=c;
602  }
#define PATCH_TRI
Definition: PatchTypeConstants.h:13
int type
Definition: patch.h:523
int interior[4]
Definition: patch.h:526
#define assert(expr)
Definition: assert1.h:71
void setInteriors ( int  a,
int  b,
int  c,
int  d 
)
inline
Remarks
Sets the interior vertex values for a Tri Patch.
Parameters:
int a, int b, int c, int d

The interior values to set: interior[0]=a; interior[1]=b; interior[2]=c; interior[3]=d; These values are indices into the interior array.
609  {
610  assert(type == PATCH_QUAD);
611  interior[0]=a; interior[1]=b; interior[2]=c; interior[3]=d;
612  }
#define PATCH_QUAD
int type
Definition: patch.h:523
int interior[4]
Definition: patch.h:526
#define assert(expr)
Definition: assert1.h:71
int getVert ( int  index)
inline
Remarks
Returns the vertex specified by the index.
Parameters:
int index

The vertex to retrieve. This value may be 0, 1, 2 (or 3 if it's a quad patch).
618 { return v[index]; }
int v[4]
Definition: patch.h:524
int* getAllVerts ( void  )
inline
Remarks
Returns a pointer to the vertex array.
620 { return v; }
int v[4]
Definition: patch.h:524
MtlID getMatID ( )
inline
621 {return (int)((flags>>FACE_MATID_SHIFT)&FACE_MATID_MASK);}
DWORD flags
Definition: patch.h:530
#define FACE_MATID_MASK
A mask used to access the material ID.
Definition: MeshFaceFlagConstants.h:55
#define FACE_MATID_SHIFT
The number of bits to shift the flags to access the material.
Definition: MeshFaceFlagConstants.h:54
void setMatID ( MtlID  id)
inline
622 {flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
DWORD flags
Definition: patch.h:530
#define FACE_MATID_SHIFT
The number of bits to shift the flags to access the material.
Definition: MeshFaceFlagConstants.h:54
Point3 getUVW ( int  index) const
Point2 getUV ( int  index) const
bool getVertUVW ( int  vert,
Point3 uvw 
) const
bool getVertUV ( int  vert,
Point2 uv 
) const
Point3 BicubicSurface ( PatchMesh pMesh,
const float *  uu,
const float *  vv 
)
CoreExport Point3 interp ( PatchMesh pMesh,
float  centerU,
float  centerV,
float  centerW 
)
Remarks
Triangle patch interpolator. This method returns a point on the surface of the patch based on the specified u, v and w values. The u, v, w values are barycentric coordinates. u+v+w = 1.0. If u is 1, and v and w are 0, the point is at the first vertex. If u is 0, v is 1, and w is 0, then the point is at the second vertex. If u and v are 0 and w is 1 then the point is at the third vertex. Varying positions between these values represent different positions on the patch.
Parameters:
PatchMesh *pMesh

Points to the PatchMesh to interpolate.

float centerU, float centerV, float centerW

The barycentric coordinates.
Returns
A point on the surface of the patch.
CoreExport Point3 interp ( PatchMesh pMesh,
float  fU,
float  fV 
)
Remarks
Quadrilateral patch interpolator. This method returns a point on the surface of the patch based on the specified u and v values.
Parameters:
PatchMesh *pMesh

Points to the PatchMesh to interpolate.

float fU

The fU value in the range 0.0 to 1.0. This defines the distance along one axis of the patch.

float fV

The fV value in the range 0.0 to 1.0. This defines the distance along the other axis of the patch.
Returns
A point on the surface of the patch.
CoreExport Point3 WUTangent ( PatchMesh pMesh,
float  fU,
float  fV,
float  fW 
)
CoreExport Point3 UVTangent ( PatchMesh pMesh,
float  fU,
float  fV,
float  fW 
)
CoreExport Point3 VWTangent ( PatchMesh pMesh,
float  fU,
float  fV,
float  fW 
)
CoreExport Point3 UTangent ( PatchMesh pMesh,
float  fU,
float  fV 
)
CoreExport Point3 VTangent ( PatchMesh pMesh,
float  fU,
float  fV 
)
CoreExport Point3 Normal ( PatchMesh pMesh,
float  fU,
float  fV,
float  fW 
)
CoreExport Point3 Normal ( PatchMesh pMesh,
float  fU,
float  fV 
)
CoreExport void ComputeAux ( PatchMesh pMesh,
int  index 
)
Remarks
This method is used internally. It compute the degree-4 alias control points.
CoreExport void ComputeAux ( PatchMesh pMesh)
CoreExport void computeInteriors ( PatchMesh pMesh)
Remarks
Whenever you are done working on a PatchMesh, this method should be called. If the interior vertices of the patch are automatic it will update them to correctly match the changes to the other vectors. This computes interior vertices considering this patch only.
Parameters:
PatchMesh* pMesh

Points to the PatchMesh to compute the interior vertices of.
CoreExport void SetType ( int  iType,
BOOL  init = FALSE 
)
Remarks
Sets the type of the patch to either Tri or Quad and optionally resets the arrays.
Parameters:
int iType

The patch type. One of the following values:

PATCH_TRI - Triangular Patch

PATCH_QUAD - Quadrilateral Patch

BOOL init = FALSE

If TRUE the arrays are reset to undefined; otherwise they are left unchanged. Normally this is set to FALSE.
CoreExport Patch& operator= ( Patch from)
Remarks
Assignment operator.
Parameters:
Patch& from

The patch to copy from.
CoreExport void SetAuto ( BOOL  sw = TRUE)
Remarks
Sets the flag controlling if interior vertices are computed automatically.
Parameters:
BOOL sw = TRUE

TRUE to set; FALSE to clear.
BOOL IsAuto ( )
inline
Remarks
Returns TRUE if the PATCH_AUTO flag is set; otherwise FALSE.
700 { return (flags & PATCH_AUTO) ? TRUE : FALSE; }
#define PATCH_AUTO
Definition: patch.h:442
DWORD flags
Definition: patch.h:530
CoreExport void SetHidden ( BOOL  sw = TRUE)
Remarks
This method is available in release 3.0 and later only.

Sets the hidden state of the patch.
Parameters:
BOOL sw = TRUE

TRUE to hide; FALSE to unhide.
BOOL IsHidden ( )
inline
Remarks
This method is available in release 3.0 and later only.

Returns TRUE if the patch is hidden; otherwise FALSE.
714 { return (flags & PATCH_HIDDEN) ? TRUE : FALSE; }
DWORD flags
Definition: patch.h:530
#define PATCH_HIDDEN
Definition: patch.h:446
int WhichEdge ( int  v1,
int  v2 
)
Remarks
This method is available in release 4.0 and later only.

This method provides an easy way to find out which edge of a patch uses two vertices. Simply supply the two vertices of the desired edge and call this method.
Parameters:
int v1, int v2

The index of the two vertices.
Returns
The index of the edge within the patch (0 - 2 for triangular patches, 0 - 3 for quad patches).

CAUTION: Be sure to check the return value before using it for an index
  • If the two vertices supplied are not used as an edge on this patch, -1 is returned.
int WhichVert ( int  index)
Remarks
This method is available in release 4.0 and later only.

This method provides an easy way to find out which corner of a patch uses a given vertex. Simply supply the vertex index and call this method.
Parameters:
int index

The index of the vertex.
Returns
The corner index of the given vertex within the patch (0 - 2 for triangular patches, 0 - 3 for quad patches).

CAUTION: Be sure to check the return value before using it for an index
  • If the vertex supplied is not used as a corner on this patch, -1 is returned.
CoreExport void Dump ( )
Remarks
This may be called to dump the patch mesh structure via DebugPrint(). See Troubleshooting.
Operators:
CoreExport IOResult Save ( ISave isave)
CoreExport IOResult Load ( ILoad iload)

Member Data Documentation

int type
int v[4]
int vec[8]
int interior[4]
Point3 aux[9]
int edge[4]
DWORD smGroup
DWORD flags
int aux1
int aux2