HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_Topology Class Reference

#include <GA_Topology.h>

Classes

class  ga_StorageSwitch
 

Public Types

enum  TopologyCE {
  TOPO_CE_PRIMPOINTS, TOPO_CE_PRIMVERTICES, TOPO_CE_PRIMVERTEXCOUNT, TOPO_CE_POINTPRIMS,
  TOPO_CE_POINTVERTICES, TOPO_CE_POINTNEIGHBOURS, TOPO_CE_VERTEXPOINT, TOPO_CE_VERTEXPRIM,
  TOPO_CE_VERTEXPRIMINDEX, NUM_TOPO_CE
}
 

Public Member Functions

 GA_Topology (GA_Detail &detail)
 
 ~GA_Topology ()
 
GA_DataId getDataId () const
 Return the data ID for the topology attributes. More...
 
bool isFull () const
 Test whether all required attributes built. More...
 
void makeFull ()
 
void rebuildTopology (bool rebuild_topology=true, bool support_hedge=false)
 
void makeMinimal ()
 
bool checkStorageChange ()
 
void addVertex (GA_Offset vtx)
 Functions to maintain topological information. More...
 
void addPoint (GA_Offset pt)
 
void addVertexBlock (GA_Offset vtx, GA_Size nvertices)
 
void addPointBlock (GA_Offset pt, GA_Size npoints)
 
void delPoint (GA_Offset pt)
 
void delVertex (GA_Offset vtx)
 
void wireVertexPoint (GA_Offset vtx, GA_Offset pt)
 
void wireVertexPointAndRelinkHedges (GA_Offset vtx, GA_Offset pt, GA_Offset prev_into_src_vtx, GA_Offset next_into_src_vtx)
 
void wireVertexPointAndIgnoreHedges (GA_Offset vtx, GA_Offset pt)
 
void wireVertexPrimitive (GA_Offset vtx, GA_Offset prim)
 
bool isPointUsed (GA_Offset pt) const
 Test to see whether a point is used. More...
 
bool isPointShared (GA_Offset pt) const
 Test to see whether a point is used by more than one vertex. More...
 
void makePointRef ()
 Make the attribute to store vertex->point reference (mandatory) More...
 
void makePrimitiveRef ()
 Make the attribute to store vertex->primitive reference (optional) More...
 
void makeVertexRef ()
 
SYS_FORCE_INLINE const
GA_ATITopology
getPointRef () const
 
SYS_FORCE_INLINE const
GA_ATITopology
getPrimitiveRef () const
 
SYS_FORCE_INLINE const
GA_ATITopology
getVertexRef () const
 
SYS_FORCE_INLINE const
GA_ATITopology
getVertexPrevRef () const
 
SYS_FORCE_INLINE const
GA_ATITopology
getVertexNextRef () const
 
SYS_FORCE_INLINE GA_ATITopologygetPointRef ()
 
SYS_FORCE_INLINE GA_ATITopologygetPrimitiveRef ()
 
SYS_FORCE_INLINE GA_ATITopologygetVertexRef ()
 
SYS_FORCE_INLINE GA_ATITopologygetVertexPrevRef ()
 
SYS_FORCE_INLINE GA_ATITopologygetVertexNextRef ()
 
bool jsonSavePointRef (UT_JSONWriter &w, const GA_SaveMap &s) const
 
bool jsonLoadPointRef (UT_JSONParser &p, const GA_LoadMap &s)
 
void mergeRebuild (const GA_MergeMap &map)
 
void mergeGrowCheckStorageChange (GA_Size sz, bool cloned_data_id)
 
bool validate () const
 
void getAdjacentBoundaryVertices (GA_Offset vtx, GA_Offset &prev_vtx, GA_Offset &next_vtx) const
 
bool isHedgeFull () const
 
void makeHedgeFull ()
 
void makeHedgeRef ()
 
void createHedgeTopologyLinks ()
 Creates hedge topology attributes and computes them for the existing detail. More...
 
void destroyHedgeTopologyLinks ()
 Destroys the hedge topology attributes. More...
 
bool isValidHedge (GA_Offset src_vtx) const
 
bool isPrimaryHedge (GA_Offset src_vtx) const
 
GA_Offset hedgeToPrevHedge (GA_Offset src_vtx) const
 
GA_Offset hedgeToNextHedge (GA_Offset src_vtx) const
 
GA_Offset hedgeToPrimaryHedge (GA_Offset vtx)
 returns the primary hedge in the equivalence class of a given hedge More...
 
void relinkHedge (GA_Offset src_vtx, GA_Offset dst_vtx, GA_Offset into_src_vtx=GA_INVALID_OFFSET)
 
void relinkVertexHedges (GA_Offset vtx)
 
void relinkVertexHedges (GA_Offset vtx, GA_Offset prev_into_src_vtx, GA_Offset next_into_src_vtx)
 
void rebuildHedgeTopologyLinks ()
 
void countMemory (UT_MemoryCounter &counter, bool inclusive) const
 
int getStorageLevel () const
 
void cloneDataId (const GA_Topology &src, bool allow_clear=false)
 Call GA_Attribute::cloneDataId on all the attributes we hold. More...
 
void defragmentElements (const GA_Defragment &defrag)
 
void defragmentLinks (const GA_Defragment &defrag)
 
GA_CEAttributequeryCEAttribute (TopologyCE topotype, GA_StorageClass storage, GA_Precision precision, int &tuplesize, bool isarray, bool read, bool write)
 
void setCEAttribute (UT_UniquePtr< GA_CEAttribute > &&ceattrib, TopologyCE topotype, bool leave_on_gpu=false)
 
void flushCEWriteCaches (bool clearwriteback=true)
 
bool hasPendingCEWriteBack () const
 
void flushCECaches ()
 Remove all CE Caches, copying back any marked as written to. More...
 
void stealCEAttributes (const GA_Topology &src)
 

Static Public Member Functions

static int computeStorageDownShift (int storage_level, GA_Size size)
 
static int computeStorageUpShift (int storage_level, GA_Size size)
 
static GA_Storage getStorage (int level)
 
static TopologyCE nameToTopologyCE (const char *name)
 
static const char * topologyCEToName (TopologyCE topotype)
 

Detailed Description

Definition at line 31 of file GA_Topology.h.

Member Enumeration Documentation

Enumerator
TOPO_CE_PRIMPOINTS 
TOPO_CE_PRIMVERTICES 
TOPO_CE_PRIMVERTEXCOUNT 
TOPO_CE_POINTPRIMS 
TOPO_CE_POINTVERTICES 
TOPO_CE_POINTNEIGHBOURS 
TOPO_CE_VERTEXPOINT 
TOPO_CE_VERTEXPRIM 
TOPO_CE_VERTEXPRIMINDEX 
NUM_TOPO_CE 

Definition at line 391 of file GA_Topology.h.

Constructor & Destructor Documentation

GA_Topology::GA_Topology ( GA_Detail detail)
GA_Topology::~GA_Topology ( )

Member Function Documentation

void GA_Topology::addPoint ( GA_Offset  pt)
inline

Definition at line 160 of file GA_Topology.h.

void GA_Topology::addPointBlock ( GA_Offset  pt,
GA_Size  npoints 
)
void GA_Topology::addVertex ( GA_Offset  vtx)
inline

Functions to maintain topological information.

Definition at line 158 of file GA_Topology.h.

void GA_Topology::addVertexBlock ( GA_Offset  vtx,
GA_Size  nvertices 
)
bool GA_Topology::checkStorageChange ( )

The topology attributes try to store minimal amounts of information. That is, if there are only 4 points in the geometry, we won't store the indices as 64-bit integers. This method will change the storage attributes if needed.

void GA_Topology::cloneDataId ( const GA_Topology src,
bool  allow_clear = false 
)

Call GA_Attribute::cloneDataId on all the attributes we hold.

static int GA_Topology::computeStorageDownShift ( int  storage_level,
GA_Size  size 
)
inlinestatic

Definition at line 72 of file GA_Topology.h.

static int GA_Topology::computeStorageUpShift ( int  storage_level,
GA_Size  size 
)
inlinestatic

Definition at line 86 of file GA_Topology.h.

void GA_Topology::countMemory ( UT_MemoryCounter counter,
bool  inclusive 
) const

This counts memory using the given UT_MemoryCounter. NOTE: GA_Topology doesn't own any of the memory it points to, so there's not much to count.

void GA_Topology::createHedgeTopologyLinks ( )

Creates hedge topology attributes and computes them for the existing detail.

void GA_Topology::defragmentElements ( const GA_Defragment defrag)

Called by GA_Detail::defragment when defragmenting offset lists

NOTE: defragmentLinks will bump the data ID of myPointRef, myVertexRef, or myPrimitiveRef if any of those are modified, because they are modified when defragmenting an index map that is different from their owner, i.e. their link owner's index map. defragmentElements does NOT bump any data IDs.

void GA_Topology::defragmentLinks ( const GA_Defragment defrag)

Called by GA_Detail::defragment when defragmenting offset lists

NOTE: defragmentLinks will bump the data ID of myPointRef, myVertexRef, or myPrimitiveRef if any of those are modified, because they are modified when defragmenting an index map that is different from their owner, i.e. their link owner's index map. defragmentElements does NOT bump any data IDs.

void GA_Topology::delPoint ( GA_Offset  pt)
void GA_Topology::delVertex ( GA_Offset  vtx)
void GA_Topology::destroyHedgeTopologyLinks ( )

Destroys the hedge topology attributes.

void GA_Topology::flushCECaches ( )

Remove all CE Caches, copying back any marked as written to.

void GA_Topology::flushCEWriteCaches ( bool  clearwriteback = true)

Any CE cache which was marked as written to will be copied back to the CPU. It will be left on the GPU, however.

void GA_Topology::getAdjacentBoundaryVertices ( GA_Offset  vtx,
GA_Offset prev_vtx,
GA_Offset next_vtx 
) const

Returns the next and previous boundary vertices of a given vertex in its primitive.

Parameters
vtxinput vertex
prev_vtxreference into which previous boundary vertex of vtx will be written
next_vtxreference into which next boundary vertex of vtx will be written
GA_DataId GA_Topology::getDataId ( ) const

Return the data ID for the topology attributes.

SYS_FORCE_INLINE const GA_ATITopology* GA_Topology::getPointRef ( ) const
inline
Examples:
tetprim/GEO_PrimTetra.C.

Definition at line 221 of file GA_Topology.h.

SYS_FORCE_INLINE GA_ATITopology* GA_Topology::getPointRef ( )
inline

Definition at line 231 of file GA_Topology.h.

SYS_FORCE_INLINE const GA_ATITopology* GA_Topology::getPrimitiveRef ( ) const
inline
Examples:
tetprim/GEO_PrimTetra.C.

Definition at line 223 of file GA_Topology.h.

SYS_FORCE_INLINE GA_ATITopology* GA_Topology::getPrimitiveRef ( )
inline

Definition at line 233 of file GA_Topology.h.

static GA_Storage GA_Topology::getStorage ( int  level)
inlinestatic

Definition at line 100 of file GA_Topology.h.

int GA_Topology::getStorageLevel ( ) const
inline

Returns the current storage level as an int. Call GA_Topology::getStorage(topology.getStorageLevel()) to get the GA_Storage.

Definition at line 385 of file GA_Topology.h.

SYS_FORCE_INLINE const GA_ATITopology* GA_Topology::getVertexNextRef ( ) const
inline
Examples:
tetprim/GEO_PrimTetra.C.

Definition at line 229 of file GA_Topology.h.

SYS_FORCE_INLINE GA_ATITopology* GA_Topology::getVertexNextRef ( )
inline

Definition at line 239 of file GA_Topology.h.

SYS_FORCE_INLINE const GA_ATITopology* GA_Topology::getVertexPrevRef ( ) const
inline
Examples:
tetprim/GEO_PrimTetra.C.

Definition at line 227 of file GA_Topology.h.

SYS_FORCE_INLINE GA_ATITopology* GA_Topology::getVertexPrevRef ( )
inline

Definition at line 237 of file GA_Topology.h.

SYS_FORCE_INLINE const GA_ATITopology* GA_Topology::getVertexRef ( ) const
inline
Examples:
tetprim/GEO_PrimTetra.C.

Definition at line 225 of file GA_Topology.h.

SYS_FORCE_INLINE GA_ATITopology* GA_Topology::getVertexRef ( )
inline

Definition at line 235 of file GA_Topology.h.

bool GA_Topology::hasPendingCEWriteBack ( ) const

The topology data may be on the GPU. This also includes some meta-topology info such as prim->points. Note topology is in index space on the GPU, not offset, so we always have a non tirival mapping.

Currently writing isn't supported. Gets a named topology attribute, verifying it was cached with a matching data id. If not, flushes any cache and returns null.

GA_Offset GA_Topology::hedgeToNextHedge ( GA_Offset  src_vtx) const
inline

Returns the next hedge in the equivalence class of the given hedge.

See Also
hedgeToPrevHedge

Definition at line 348 of file GA_Topology.h.

GA_Offset GA_Topology::hedgeToPrevHedge ( GA_Offset  src_vtx) const
inline

Returns the previous hedge in the equivalence class of the given hedge.

The equivalence class of a hedge consists of all hedges whose two endpoints coincide with those of the hedge in question (although they may be reversely paired). By endpoints of a hedge we mean the two points into which the tail and head vertex of a hedge are respectively wired.

Note
Starting with any valid hedge, repeated calls to hedgeToPrevHedge or hedgeToNextHedge traverses all hedges to the original one and ultimately wraps around.

Definition at line 343 of file GA_Topology.h.

GA_Offset GA_Topology::hedgeToPrimaryHedge ( GA_Offset  vtx)

returns the primary hedge in the equivalence class of a given hedge

bool GA_Topology::isFull ( ) const

Test whether all required attributes built.

bool GA_Topology::isHedgeFull ( ) const
inline

Returns true if hedge topology is maintained

A hedge (short for half-edge) embodies the notion of an edge localised to a primitive incident to it. An edge incident to k primitives therefore leads to k distinct hedges, one belonging to each of the primitives. Unlike edges, hedges are oriented and therefore have distinct tail and head vertices. The points wired to the tail and head vertices of a hedge are respectively called its tail and head points and together make up the endpoints of the given hedge. Two hedges are called equivalent if and only if their endpoints (as sets) coincide, i.e. if and only if either they both have the same tail point and the same head point, or the head point of one is the same as the tail point of another and vice versa. Equivalence of hedges puts them into equivalence classes.

Definition at line 279 of file GA_Topology.h.

bool GA_Topology::isPointShared ( GA_Offset  pt) const

Test to see whether a point is used by more than one vertex.

bool GA_Topology::isPointUsed ( GA_Offset  pt) const

Test to see whether a point is used.

bool GA_Topology::isPrimaryHedge ( GA_Offset  src_vtx) const
inline

Returns true if the input hedge is a primary hedge.

Note
This method doesn't check for validity of the hedge. It returns true as long as the vertex is not marked as being secondary to another hedge.

Each equivalence class of hedges (linked into a circular linked list using myHedgePrevRef and myHedgeNextRef) must have exactly one primary hedge. All other hedges in the class are marked secondary by being added to the group mySecondaryHedges. This is an invariant maintained at all times.

Note
The primary hedge of a class is elected arbitrarily. It stays primary until it is unlinked from the class, at which time another hedge becomes the primary hedge in that class. A singleton hedge is the primary of its own class.

Definition at line 330 of file GA_Topology.h.

bool GA_Topology::isValidHedge ( GA_Offset  src_vtx) const

Return true if the argument is the tail vertex of a "valid" hedge.

A hedge is valid if and only if (1) it belongs to a primitive that supports hedges and (2) the primitive returns a non-negative vertex offset for its next boundary vertex. A valid hedge is singleton if it is not linked up with any other hedges into an equivalence class. NOTE 1: The validity of a hedge has nothing to do with its vertices being wired to points. NOTE 2: All valid hedges with unwired vertices are singletons. The next and previous hedge references of an invalid hedge must be GA_INVALID_OFFSET and those of a singleton hedge must be the hedge itself. This will be how we distinguish valid hedges from invalid ones.

bool GA_Topology::jsonLoadPointRef ( UT_JSONParser p,
const GA_LoadMap s 
)
bool GA_Topology::jsonSavePointRef ( UT_JSONWriter w,
const GA_SaveMap s 
) const
void GA_Topology::makeFull ( )
inline

This method constructs the topology attributes for the detail. It should only be called by GA_Detail. Please use rebuildTopology() from other code.

Definition at line 115 of file GA_Topology.h.

void GA_Topology::makeHedgeFull ( )
inline

Creates hedge topology attributes if they don't already exist

See Also
createHedgeTopologyLinks
rebuildHedgeTopologyLinks

Definition at line 285 of file GA_Topology.h.

void GA_Topology::makeHedgeRef ( )

Creates the hedge topology attributes

Note
This method will create 2 vertex topology attributes and 1 vertex group
void GA_Topology::makeMinimal ( )

makeMinimal() deletes the non-essential topology attributes. All optional attributes (the options which allow reverse lookup of elements) are deleted. The attribute to map vertex to point (myPointRef) remains untouched.

void GA_Topology::makePointRef ( )

Make the attribute to store vertex->point reference (mandatory)

void GA_Topology::makePrimitiveRef ( )

Make the attribute to store vertex->primitive reference (optional)

void GA_Topology::makeVertexRef ( )

Make the attributes to store point->vertex references (optional) Note: This method will create 3 attributes

void GA_Topology::mergeGrowCheckStorageChange ( GA_Size  sz,
bool  cloned_data_id 
)
void GA_Topology::mergeRebuild ( const GA_MergeMap map)

Make any changes to the topology attributes to accommodate the new data (i.e. change their sizes if need be). This method is called before the merge begins.

static TopologyCE GA_Topology::nameToTopologyCE ( const char *  name)
static
GA_CEAttribute* GA_Topology::queryCEAttribute ( TopologyCE  topotype,
GA_StorageClass  storage,
GA_Precision  precision,
int tuplesize,
bool  isarray,
bool  read,
bool  write 
)

The topology data may be on the GPU. This also includes some meta-topology info such as prim->points. Note topology is in index space on the GPU, not offset, so we always have a non tirival mapping.

Currently writing isn't supported. Gets a named topology attribute, verifying it was cached with a matching data id. If not, flushes any cache and returns null.

void GA_Topology::rebuildHedgeTopologyLinks ( )

Tosses out existing topology links and rebuilds the whole thing from scratch.

See Also
createHedgeTopologyLinks
void GA_Topology::rebuildTopology ( bool  rebuild_topology = true,
bool  support_hedge = false 
)

Re-create the topology links. This method will re-create all the topological information. If the rebuild_topology option is true, then any missing attributes will be created. If support_hedge is true, then half-edge topology attributes are constructed.

void GA_Topology::relinkHedge ( GA_Offset  src_vtx,
GA_Offset  dst_vtx,
GA_Offset  into_src_vtx = GA_INVALID_OFFSET 
)

Same as linkHedge, but first unlinks hedge before calling linkHedge.

See Also
linkHedge
void GA_Topology::relinkVertexHedges ( GA_Offset  vtx)

This is equivalent to calling relinkHedge on both of the hedges that are incident to a vtx.

void GA_Topology::relinkVertexHedges ( GA_Offset  vtx,
GA_Offset  prev_into_src_vtx,
GA_Offset  next_into_src_vtx 
)

This is equivalent to calling relinkHedge on both of the hedges that are incident to a vtx. Instead of searching for equivalent hedges to link into, it respectively links the the hedges whose head and tail vertices are vtx into prev_into_src_vtx and next_into_src_vtx.

void GA_Topology::setCEAttribute ( UT_UniquePtr< GA_CEAttribute > &&  ceattrib,
TopologyCE  topotype,
bool  leave_on_gpu = false 
)

Stores this as the canonical CE attribute for this topoid, marking current data id as the valid version.

void GA_Topology::stealCEAttributes ( const GA_Topology src)

Steal the CE attribute from the source topology, leaving the src with a null CE attribute.

static const char* GA_Topology::topologyCEToName ( TopologyCE  topotype)
static
bool GA_Topology::validate ( ) const

Verify that the topologies are constructed correctly This is just for debugging purposes, and so may call printf

void GA_Topology::wireVertexPoint ( GA_Offset  vtx,
GA_Offset  pt 
)
Note
When hedge attributes are present wireVertexPoint has to try to fix the changes to hedge equivalence classes that take place when a vertex is wired to a new point, namely, the two hedges incident to the given vertex must be unlinked from their previous equivalence classes and must be linked into respective new ones. This means that a search on the incident primitives of the new point must be carried out to determine the new associations. This is where having hedges costs the most. If the caller has access to the classes to other hedges from the classes into which the affected hedges must be linked, it must call wireVertexPointAndLinkHedges which runs in constant time. Alternatively, if the caller knows that no hedge information needs to be changed, wireVertexPointAndIgnoreHedges can be called.
See Also
wireVertexPointAndRelinkHedges
wireVertexPointAndIgnoreHedges
void GA_Topology::wireVertexPointAndIgnoreHedges ( GA_Offset  vtx,
GA_Offset  pt 
)

Wires vertex to the point and completely ignores the affected hedges.

This is equivalent to wireVertexPoint before hedges were introduced, or when hedge attributes do not exist. Note that if hedge attributes are present, this should be called at the risk of violating hedge invariants. It is useful, for example, if all the vertices wired to a point are being wired to another point and therefore there is no need to update hedge attributes.

void GA_Topology::wireVertexPointAndRelinkHedges ( GA_Offset  vtx,
GA_Offset  pt,
GA_Offset  prev_into_src_vtx,
GA_Offset  next_into_src_vtx 
)

Wires vertex to the point and links the the hedges whose head and tail vertices are vtx into prev_into_src_vtx and next_into_src_vtx respectively.

Note
This method is used to avoid the search that is performed by the standard wireVertexPoint to find hedges equivalent to those incident to vtx. It's useful when these hedges are known in advance.
void GA_Topology::wireVertexPrimitive ( GA_Offset  vtx,
GA_Offset  prim 
)

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