Topology Class Reference

This reference page is linked to from the following overview topics: Mesh and Topology.



Detailed Description

Represents the topology data of a mesh, providing information about the structure of a surface, e.g. how faces are layed down.

The class Mesh is inherited from this class, and provides information about the vertices. Since only full triangle or quad meshes are allowed in Mudbox, an instance of this class is basically an array of triangles and quads. When a mixed triangle-quad or n-sided mesh is imported into mudbox, then the mesh is converted to a full triangle topology, see the member functions IsFakeTriangle and SetFakeTriangle. The Topology class can hold different type of data for the polygons, like position indices, adjacency, texture coordinate indices etc. These are called face components. To save memory not every buffer is allocated at the beginning. You can control which buffers will be allocated by calling the AddFaceComponent() and RemoveFaceComponent() functions.

Definition at line 45 of file topology.h.

#include <topology.h>

Inheritance diagram for Topology:
Inheritance graph
[legend]

List of all members.

Public Types

enum   FaceState {
  fsSelected = 0x01, fsVisible = 0x02, fsFake = 0x04, fsActive = 0x08,
  fsMapped = 0x10
}
enum   FaceComponent {
  fcIndex = 1, fcAdjacency = 2, fcTCIndex = 4, fcNormal = 8,
  fcID = 16, fcOctree = 32, fcFreeze = 64, fcState = 128
}
enum   FaceType { typeTriangular, typeQuadric }

Public Member Functions

void  MoveTo (Topology *pDestination)
  Move the content of this object to another one. This is a fast function.
void  CopyTo (Topology *pDestination) const
  Copy the content of this object to another one, while keeps the content of the current object.
void  Serialize (Stream &s)
  serializes the content of the object into/from a stream.
FaceType  Type (void) const
  Returns the type of the topology. Can be full triangular or full quadric.
void  SetType (FaceType eType)
  Sets the type of the object. This call also clears all the content of the object.
int  SideCount (void) const
  Returns the number of sides in the faces. This is three if the topology is triangle based, and four if its quad based.
unsigned int  FaceCount (void) const
  Returns the number of faces in the topology.
virtual Vector  FaceNormal (unsigned int iFaceIndex) const
  Returns the normal vector for a face in the topology.
void  SetFaceID (unsigned int iFaceIndex, unsigned int iID)
  This function is used only internally.
unsigned int  FaceID (unsigned int iFaceIndex) const
  This function is used only internally.
virtual void  SetFakeTriangleCount (unsigned int iFakeTriangleCount)
  Call this method to indicate how many fake triangles are in the topology.
unsigned int  QuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex position index of a corner of a quad.
void  SetQuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex position index of a corner of a quad.
unsigned int  QuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex texture coordinate index of a corner of a quad.
void  SetQuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex texture coordinate index of a corner of a quad.
virtual unsigned int  QuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns the vertex adjacency information index of a side of a quad.
unsigned int  QuadAdjacency_ForcedInline (unsigned int iFaceIndex, unsigned int iSideIndex) const
virtual void  SetQuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue)
  Sets the adjacency info for a side of a quad. See QuadAdjacency for details.
bool  HasAdjacentQuad (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns true if the given edge of a quad has an adjacent quad on the other side.
unsigned int  TriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex position index of a corner of a triangle.
void  SetTriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex position index of a corner of a triangle.
unsigned int  TriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const
  Returns the vertex texture coordinate index of a corner of a triangle.
void  SetTriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue)
  Sets the vertex texture coordinate index of a corner of a triangle.
virtual unsigned int  TriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns the vertex adjacency information index of a side of a triangle.
virtual void  SetTriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue)
  Sets the adjacency info for a side of a triangle. See TriangleAdjacency for details.
bool  HasAdjacentTriangle (unsigned int iFaceIndex, unsigned int iSideIndex) const
  Returns true if the given edge of a triangle has an adjacent triangle on the other side.
unsigned char &  FaceState (unsigned int iFaceIndex)
  Returns the state of a face. See FaceState.
unsigned char  FaceState (unsigned int iFaceIndex) const
  Sets the state of a face.
bool  IsFaceSelected (unsigned int iFaceIndex) const
  Returns true if the given face is selected.
virtual void  SetFaceSelected (unsigned int iFaceIndex, bool bSelected=true, bool bUpdateVertexSelection=false, bool bBatchSelection=false)
  Sets selection state for a face.
virtual unsigned int  SelectedFaceCount () const
  Returns the number of selected faces.
bool  IsFaceVisible (unsigned int iFaceIndex) const
  Returns true if the given face is visible.
void  SetFaceVisible (unsigned int iFaceIndex, bool bSelected=true)
  Sets the visibility of a given face.
bool  IsFaceActive (unsigned int iFaceIndex) const
void  SetFaceActive (unsigned int iFaceIndex, bool bSelected=true)
bool  IsFaceMapped (unsigned int iFaceIndex) const
  Used only internally.
void  SetFaceMapped (unsigned int iFaceIndex, bool bSelected=true)
  Used only internally.
bool  IsFakeTriangle (unsigned int iTriangleIndex) const
  This function can only be used for triangular meshes.
void  SetFakeTriangle (unsigned int iTriangleIndex, bool b)
bool  IsFaceTemp (unsigned int iFaceIndex) const
void  SetFaceTemp (unsigned int iFaceIndex, bool bSelected=true)
void  ClearFaceTempStates ()
virtual void  AddFaceComponent (FaceComponent eComponentToAdd)
  Adds new face component(s) to the object.
virtual void  RemoveFaceComponent (FaceComponent eComponentToRemove)
  Removes face component(s) from the object. This might delete some data from the memory.
unsigned int  FaceComponents (void) const
  Returns the current face components for the object.
void  SetFaceCount (unsigned int iFaceCount)
  Sets the number of faces in the object. Existing face data will be kept.
virtual bool  SetAdjacencyCount (unsigned int iCount, bool bKeepContent=true, bool bForced=false)
  Sets the size of the adjacency array.
unsigned int  AdjacencyCount (void) const
  Returns the size of the adjacency matrix.
virtual bool  HasTShape () const
  Return true if these is edge shared by more than two faces.
virtual void  SetHasTShape (bool bHasTShape)

Public Attributes

Store< unsigned int >  m_pIndices

Protected Member Functions

  Topology (void)
  Do not use constructors directly. Use CreateInstances() instead.
  Topology (FaceType eType)
  Constructs the object with zero faces.

Friends

class  ::XMesh

Member Enumeration Documentation

enum FaceState
Enumerator:
fsSelected 
fsVisible 
fsFake 
fsActive 
fsMapped 

Definition at line 48 of file topology.h.

    {
        fsSelected = 0x01,
        fsVisible = 0x02,
        fsFake = 0x04,
        fsActive = 0x08,
        fsMapped = 0x10,
        // fsTemp = 0x20    // for performance reasons, the temp state is split into a seperate vector
    };
enum FaceType
Enumerator:
typeTriangular 
typeQuadric 

Definition at line 69 of file topology.h.


Constructor & Destructor Documentation

Topology ( void  ) [protected]

Do not use constructors directly. Use CreateInstances() instead.

Topology ( FaceType  eType ) [protected]

Constructs the object with zero faces.


Member Function Documentation

void MoveTo ( Topology pDestination )

Move the content of this object to another one. This is a fast function.

This object will loose all data and become an empty topology.

void CopyTo ( Topology pDestination ) const

Copy the content of this object to another one, while keeps the content of the current object.

This function is similar to MoveTo, but since it is copying all the data, it is slower. You can use this function when you want to do some temporary change to a mesh (like you want to change the vertex ordering inside faces) but then you want to restore the original state. In that case you can simply create a copy of the mesh, do the modifications, and when you don't need it any longer, just delete it.

void Serialize ( Stream s ) [virtual]

serializes the content of the object into/from a stream.

Reimplemented from TreeNode.

FaceType Type ( void  ) const [inline]

Returns the type of the topology. Can be full triangular or full quadric.

Definition at line 112 of file topology.h.

{ return m_eType; };
void SetType ( FaceType  eType )

Sets the type of the object. This call also clears all the content of the object.

int SideCount ( void  ) const [inline]

Returns the number of sides in the faces. This is three if the topology is triangle based, and four if its quad based.

Definition at line 116 of file topology.h.

{ return Type() == typeTriangular ? 3 : 4; };
unsigned int FaceCount ( void  ) const [inline]

Returns the number of faces in the topology.

Definition at line 120 of file topology.h.

{ return m_iFaceCount; };
virtual Vector FaceNormal ( unsigned int  iFaceIndex ) const [virtual]

Returns the normal vector for a face in the topology.

void SetFaceID ( unsigned int  iFaceIndex,
unsigned int  iID 
) [inline]

This function is used only internally.

Definition at line 124 of file topology.h.

{ m_pFaceIDs[iFaceIndex] = iID; };
unsigned int FaceID ( unsigned int  iFaceIndex ) const [inline]

This function is used only internally.

Definition at line 126 of file topology.h.

{ return m_pFaceIDs[iFaceIndex]; };
virtual void SetFakeTriangleCount ( unsigned int  iFakeTriangleCount ) [virtual]

Call this method to indicate how many fake triangles are in the topology.

Call SetFaceCount before calling this method. Note this has no effect on quadric meshes.

unsigned int QuadIndex ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex 
) const [inline]

Returns the vertex position index of a corner of a quad.

The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh.

Definition at line 134 of file topology.h.

{ return m_pIndices[iFaceIndex*4+iCornerIndex]; };
void SetQuadIndex ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue 
) [inline]

Sets the vertex position index of a corner of a quad.

The value returned by this call can be used as parameter for the VertexTC() function in class Mesh.

Definition at line 137 of file topology.h.

{ m_pIndices[iFaceIndex*4+iCornerIndex] = iValue; };
unsigned int QuadTCI ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex 
) const [inline]

Returns the vertex texture coordinate index of a corner of a quad.

Definition at line 139 of file topology.h.

{ return m_pTCI[iFaceIndex*4+iCornerIndex]; }
void SetQuadTCI ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue 
) [inline]

Sets the vertex texture coordinate index of a corner of a quad.

Definition at line 141 of file topology.h.

{ m_pTCI[iFaceIndex*4+iCornerIndex] = iValue; }
virtual unsigned int QuadAdjacency ( unsigned int  iFaceIndex,
unsigned int  iSideIndex 
) const [inline, virtual]

Returns the vertex adjacency information index of a side of a quad.

If the returned value is x, then x/4 is the index of the adjacent quad, while x4 is the side in the adjacent quad which is common with the given one.

Definition at line 145 of file topology.h.

{ return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
unsigned int QuadAdjacency_ForcedInline ( unsigned int  iFaceIndex,
unsigned int  iSideIndex 
) const [inline]

Definition at line 146 of file topology.h.

{ return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
virtual void SetQuadAdjacency ( unsigned int  iFaceIndex,
unsigned int  iSideIndex,
unsigned int  iValue 
) [inline, virtual]

Sets the adjacency info for a side of a quad. See QuadAdjacency for details.

Definition at line 148 of file topology.h.

        { m_pAdjacency[iFaceIndex*4+iSideIndex] = iValue; }
bool HasAdjacentQuad ( unsigned int  iFaceIndex,
unsigned int  iSideIndex 
) const [inline]

Returns true if the given edge of a quad has an adjacent quad on the other side.

Definition at line 151 of file topology.h.

{ return QuadAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; };
unsigned int TriangleIndex ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex 
) const [inline]

Returns the vertex position index of a corner of a triangle.

The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh.

Definition at line 156 of file topology.h.

{ return m_pIndices[iFaceIndex*3+iCornerIndex]; };
void SetTriangleIndex ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue 
) [inline]

Sets the vertex position index of a corner of a triangle.

Definition at line 158 of file topology.h.

{ m_pIndices[iFaceIndex*3+iCornerIndex] = iValue; };
unsigned int TriangleTCI ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex 
) const [inline]

Returns the vertex texture coordinate index of a corner of a triangle.

Definition at line 160 of file topology.h.

{ return m_pTCI[iFaceIndex*3+iCornerIndex]; }
void SetTriangleTCI ( unsigned int  iFaceIndex,
unsigned int  iCornerIndex,
unsigned int  iValue 
) [inline]

Sets the vertex texture coordinate index of a corner of a triangle.

The value returned by this call can be used as parameter for the VertexTC() function in class Mesh.

Definition at line 163 of file topology.h.

{ m_pTCI[iFaceIndex*3+iCornerIndex] = iValue; }
virtual unsigned int TriangleAdjacency ( unsigned int  iFaceIndex,
unsigned int  iSideIndex 
) const [inline, virtual]

Returns the vertex adjacency information index of a side of a triangle.

If the returned value is x, then x/3 is the index of the adjacent triangle, while x3 is the side in the adjacent triangle which is common with the given one.

Definition at line 167 of file topology.h.

{ return m_pAdjacency[iFaceIndex*3+iSideIndex]; }
virtual void SetTriangleAdjacency ( unsigned int  iFaceIndex,
unsigned int  iSideIndex,
unsigned int  iValue 
) [inline, virtual]

Sets the adjacency info for a side of a triangle. See TriangleAdjacency for details.

Definition at line 169 of file topology.h.

        { m_pAdjacency[iFaceIndex*3+iSideIndex] = iValue; }
bool HasAdjacentTriangle ( unsigned int  iFaceIndex,
unsigned int  iSideIndex 
) const [inline]

Returns true if the given edge of a triangle has an adjacent triangle on the other side.

Definition at line 172 of file topology.h.

        { return TriangleAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; };
unsigned char& FaceState ( unsigned int  iFaceIndex ) [inline]

Returns the state of a face. See FaceState.

Definition at line 176 of file topology.h.

{ return m_pFaceState[iFaceIndex]; };
unsigned char FaceState ( unsigned int  iFaceIndex ) const [inline]

Sets the state of a face.

Definition at line 178 of file topology.h.

{ return m_pFaceState[iFaceIndex]; };
bool IsFaceSelected ( unsigned int  iFaceIndex ) const [inline]

Returns true if the given face is selected.

Definition at line 181 of file topology.h.

{ return (FaceState( iFaceIndex ) & fsSelected) != 0; };
virtual void SetFaceSelected ( unsigned int  iFaceIndex,
bool  bSelected = true,
bool  bUpdateVertexSelection = false,
bool  bBatchSelection = false 
) [virtual]

Sets selection state for a face.

The parameter bUpdateVertexSelection controls if the internal buffers should be updated or not. Passing true as this parameter makes the function slow, so do that only if you want to change the selection status for a few faces only. Otherwise use false, and after you changed all the vertices, update the buffers once only. [HOW? OPEN QUESTION]

virtual unsigned int SelectedFaceCount ( ) const [virtual]

Returns the number of selected faces.

bool IsFaceVisible ( unsigned int  iFaceIndex ) const [inline]

Returns true if the given face is visible.

Definition at line 192 of file topology.h.

{ return (FaceState( iFaceIndex ) & fsVisible) != 0; };
void SetFaceVisible ( unsigned int  iFaceIndex,
bool  bSelected = true 
) [inline]

Sets the visibility of a given face.

Definition at line 194 of file topology.h.

        { if ( bSelected ) FaceState( iFaceIndex ) |= fsVisible; else FaceState( iFaceIndex ) &= 0xff-fsVisible; };
bool IsFaceActive ( unsigned int  iFaceIndex ) const [inline]

Definition at line 196 of file topology.h.

{ return (FaceState( iFaceIndex ) & fsActive) != 0; };
void SetFaceActive ( unsigned int  iFaceIndex,
bool  bSelected = true 
) [inline]

Definition at line 197 of file topology.h.

        { if ( bSelected ) FaceState( iFaceIndex ) |= fsActive; else FaceState( iFaceIndex ) &= 0xff-fsActive; };
bool IsFaceMapped ( unsigned int  iFaceIndex ) const [inline]

Used only internally.

Definition at line 200 of file topology.h.

{ return (FaceState( iFaceIndex ) & fsMapped) != 0; };
void SetFaceMapped ( unsigned int  iFaceIndex,
bool  bSelected = true 
) [inline]

Used only internally.

Definition at line 202 of file topology.h.

        { if ( bSelected ) FaceState( iFaceIndex ) |= fsMapped; else FaceState( iFaceIndex ) &= 0xff-fsMapped; };
bool IsFakeTriangle ( unsigned int  iTriangleIndex ) const [inline]

This function can only be used for triangular meshes.

If the mesh only contains triangles, then this function always return false. When the original mesh was a mixed tri-quad or n-sided one, then during import it gets converted into a triangular mesh. Each polygon which has more than three sides are converted into N-2 triangles where N is the number of sides in the polygon. The first triangle is marked as real, but the other ones are marked as fake by this function. So this function makes it possible to restore the original polygon structure of the mesh.

Definition at line 210 of file topology.h.

        { return iTriangleIndex < FaceCount() && (FaceState( iTriangleIndex ) & fsFake); };
void SetFakeTriangle ( unsigned int  iTriangleIndex,
bool  b 
) [inline]

Definition at line 212 of file topology.h.

        { if( iTriangleIndex < FaceCount() ) { 
            if ( b ) FaceState( iTriangleIndex ) |= fsFake; 
            else     FaceState( iTriangleIndex ) &= 0xff-fsFake; 
          }; 
        };
bool IsFaceTemp ( unsigned int  iFaceIndex ) const [inline]

Definition at line 219 of file topology.h.

{ return m_pFaceTemp[iFaceIndex]; };
void SetFaceTemp ( unsigned int  iFaceIndex,
bool  bSelected = true 
) [inline]

Definition at line 220 of file topology.h.

        { m_pFaceTemp[iFaceIndex] = bSelected; }
void ClearFaceTempStates ( ) [inline]

Definition at line 224 of file topology.h.

    {
        MB_ASSERT(m_iFaceCount <= m_pFaceTemp.ItemCount()); 
        memset(&m_pFaceTemp[0], 0, m_iFaceCount);  // memset is the fastest way to clear the array.
    }
virtual void AddFaceComponent ( FaceComponent  eComponentToAdd ) [virtual]

Adds new face component(s) to the object.

If the specified components did not exist yet, memory will be allocated for them.

virtual void RemoveFaceComponent ( FaceComponent  eComponentToRemove ) [virtual]

Removes face component(s) from the object. This might delete some data from the memory.

unsigned int FaceComponents ( void  ) const [inline]

Returns the current face components for the object.

Definition at line 237 of file topology.h.

{ return m_eFaceComponents; };
void SetFaceCount ( unsigned int  iFaceCount )

Sets the number of faces in the object. Existing face data will be kept.

virtual bool SetAdjacencyCount ( unsigned int  iCount,
bool  bKeepContent = true,
bool  bForced = false 
) [virtual]

Sets the size of the adjacency array.

unsigned int AdjacencyCount ( void  ) const [inline]

Returns the size of the adjacency matrix.

Definition at line 243 of file topology.h.

{ return m_pAdjacency.ItemCount(); };
virtual bool HasTShape ( ) const [virtual]

Return true if these is edge shared by more than two faces.

virtual void SetHasTShape ( bool  bHasTShape ) [virtual]

Friends And Related Function Documentation

friend class ::XMesh [friend]

Definition at line 251 of file topology.h.


Member Data Documentation

Store<unsigned int> m_pIndices

Definition at line 79 of file topology.h.


The documentation for this class was generated from the following file:

Topology Topology Topology Topology Topology Topology Topology Topology Topology Topology
Topology Topology Topology Topology Topology Topology Topology Topology Topology Topology