HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_Primitive Class Referenceabstract

The base class for all GT primitive types. More...

#include <GT_Primitive.h>

+ Inheritance diagram for GT_Primitive:

Classes

class  jsonWriter
 

Public Member Functions

 GT_Primitive ()
 
 GT_Primitive (const GT_Primitive &src)
 
virtual ~GT_Primitive ()
 
virtual const char * className () const =0
 
virtual int getPrimitiveType () const
 
virtual bool getUniqueID (int64 &id) const
 
virtual void enlargeBounds (UT_BoundingBox boxes[], int nsegments) const =0
 
virtual void enlargeRenderBounds (UT_BoundingBox boxes[], int nsegments) const
 
virtual void getVelocityRange (UT_Vector3 &min, UT_Vector3 &max, const char *attribute_name="v") const
 
virtual bool refine (GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
 
virtual int getMotionSegments () const =0
 
virtual int64 getMemoryUsage () const =0
 
const GT_TransformHandlegetPrimitiveTransform () const
 
void setPrimitiveTransform (const GT_TransformHandle &x)
 Set the transform for a the primitive. More...
 
GT_PrimitiveHandle clone () const
 
virtual bool hasDataArray (const char *name, GT_Owner owner_scope[], int num_owners, GT_Storage *storage=NULL, GT_Size *tuple_size=NULL) const
 
virtual bool updateGeoPrim (const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
 update any cached data for geometry and its attributes More...
 
void setStaticGeometry (bool static_geo)
 Return true if the primitive represents geometry at frame 'fr'. More...
 
bool isStaticGeometry () const
 
bool isFrameInfoAvailable () const
 
bool getDataIdHash (int64 &hash, int segment=0, bool cache_data_id=false) const
 
virtual bool getTopologyVersion (int64 &version) const
 Returns the topology version for the primitive. More...
 
GT_DataArrayHandle findAttribute (const char *name, GT_Owner &owner, int segment) const
 
void dumpAttributeLists (const char *label, bool data_too) const
 print out all attribute lists More...
 
void dumpPrimitive () const
 
bool saveAttributeLists (UT_JSONWriter &w) const
 
virtual bool save (UT_JSONWriter &w) const
 
virtual const
GT_ViewportRefineOptions
viewportRefineOptions () const
 
GT_PrimitiveHandle harden () const
 
GT_PrimitiveHandle copyTransformed (const GT_TransformHandle &x, bool force=false) const
 
void refineCopyTransformFrom (const GT_Primitive &src)
 
GT_PrimitiveHandle attributeMerge (const GT_Primitive &src, const UT_StringMMPattern *vertex_pattern, const UT_StringMMPattern *point_pattern, const UT_StringMMPattern *uniform_pattern, const UT_StringMMPattern *detail_pattern) const
 
virtual GT_PrimitiveHandle doHarden () const
 
virtual GT_PrimitiveHandle doSoftCopy () const =0
 
virtual GT_PrimitiveHandle doAttributeMerge (const GT_Primitive &src, const UT_StringMMPattern *vertex, const UT_StringMMPattern *point, const UT_StringMMPattern *uniform, const UT_StringMMPattern *detail) const
 The virtual implementation of attribute merging. More...
 
bool enlargeWidth (UT_BoundingBox boxes[], int nsegments, fpreal defwidth=-1) const
 
virtual const
GT_AttributeListHandle
getPointAttributes () const
 
virtual const
GT_AttributeListHandle
getVertexAttributes () const
 
virtual const
GT_AttributeListHandle
getUniformAttributes () const
 
virtual const
GT_AttributeListHandle
getDetailAttributes () const
 
const GT_AttributeListHandlegetAttributeList (GT_Owner owner) const
 
virtual const GT_DataArrayHandlegetVertexList () const
 
virtual GT_DataArrayHandle createPointNormals (int segment=0, const char *P="P", bool normalize=true, const fpreal32 *pntdata=NULL, GT_Storage store=GT_STORE_REAL32) const
 
virtual fpreal computePerimeter (int seg=0) const
 
virtual fpreal computeSurfaceArea (int seg=0) const
 
virtual fpreal computeVolume (const UT_Vector3 &ref_P, int seg=0) const
 
- Public Member Functions inherited from UT_IntrusiveRefCounter< GT_Primitive >
SYS_FORCE_INLINE UT_IntrusiveRefCounter ()
 Default constructor: Sets counter to 0. More...
 
SYS_FORCE_INLINE UT_IntrusiveRefCounter (const UT_IntrusiveRefCounter &)
 Copy constructor: Sets counter to 0. More...
 
UT_IntrusiveRefCounteroperator= (const UT_IntrusiveRefCounter &)
 Assignment operator: Does not modify counter. More...
 
SYS_FORCE_INLINE uint32 use_count () const
 Return current counter. More...
 

Static Public Member Functions

static int createPrimitiveTypeId ()
 
static GT_AttributeListHandle mergeAttributeLists (bool &changed, const GT_AttributeListHandle &src, const GT_AttributeListHandle &merge, const UT_StringMMPattern *pattern, const UT_StringMMPattern *alternate=NULL)
 
static bool computeVelocityRange (UT_Vector3 &vmin, UT_Vector3 &vmax, const GT_DataArrayHandle &v)
 
static GT_PrimitiveHandle refineDetail (const GU_ConstDetailHandle &detail, const GT_RefineParms *parms)
 
static GT_PrimitiveHandle refinePrimitive (const GT_PrimitiveHandle &primh, const GT_RefineParms *parms)
 
static voidoperator new (size_t size)
 
static voidoperator new (size_t size, void *p)
 
static void operator delete (void *p, size_t size)
 

Protected Member Functions

void enlargeP (UT_BoundingBox &box, const GT_AttributeListHandle &list, int segment) const
 
void enlargeP (UT_BoundingBox &B, const GT_DataArrayHandle &P) const
 Convenience method to enlarge a bounding box given a position attribute. More...
 
void enlargePw (UT_BoundingBox &B, const GT_DataArrayHandle &P) const
 
- Protected Member Functions inherited from UT_IntrusiveRefCounter< GT_Primitive >
SYS_FORCE_INLINE ~UT_IntrusiveRefCounter ()
 Destructor: Only derived classes can destruct this. More...
 

Detailed Description

The base class for all GT primitive types.

Primitives represent geometric entities like spheres and polygons. There is a list of well-known primitives defined in GT_PrimitiveTypes.h. These are returned by the getPrimitiveType() method.

Each primitive must be able to compute a bounding box. Since a primitive may be part of a sequence of primitives, the primitive must be able to compute the bounding boxes for each segment.

Definition at line 41 of file GT_Primitive.h.

Constructor & Destructor Documentation

GT_Primitive::GT_Primitive ( )
GT_Primitive::GT_Primitive ( const GT_Primitive src)
virtual GT_Primitive::~GT_Primitive ( )
virtual

Member Function Documentation

GT_PrimitiveHandle GT_Primitive::attributeMerge ( const GT_Primitive src,
const UT_StringMMPattern vertex_pattern,
const UT_StringMMPattern point_pattern,
const UT_StringMMPattern uniform_pattern,
const UT_StringMMPattern detail_pattern 
) const
inline

The attributeMerge method will return a new primitive, but with the given attributes merged in from the source primitive. If the method isn't implementd on the sub-class, or if the primitive types don't match, or if there are other errors, the method will return the original primitive (i.e. this).

Definition at line 250 of file GT_Primitive.h.

GT_PrimitiveHandle GT_Primitive::clone ( ) const
inline

Create a clone of this primitive, the clone may share references to the same data.

Definition at line 116 of file GT_Primitive.h.

virtual fpreal GT_Primitive::computePerimeter ( int  seg = 0) const
virtual

Methods for GEO/GU support.

The default methods for these simply refine until a primitive can handle the method.

Reimplemented in GT_PrimPolygonMesh, GT_PrimCurveMesh, GT_PrimPolygon, GT_PrimCurve, GT_PrimFragments, and GT_PrimInstance.

virtual fpreal GT_Primitive::computeSurfaceArea ( int  seg = 0) const
virtual

Methods for GEO/GU support.

The default methods for these simply refine until a primitive can handle the method.

Reimplemented in GT_PrimPolygonMesh, GT_PrimPolygon, GT_PrimFragments, and GT_PrimInstance.

static bool GT_Primitive::computeVelocityRange ( UT_Vector3 vmin,
UT_Vector3 vmax,
const GT_DataArrayHandle v 
)
static

Convenience method to compute the velocity bounds given a data array Returns false if the data array handle wasn't valid. If invalid, vmin and vmax will be set to 0.

virtual fpreal GT_Primitive::computeVolume ( const UT_Vector3 ref_P,
int  seg = 0 
) const
virtual

Methods for GEO/GU support.

The default methods for these simply refine until a primitive can handle the method.

Reimplemented in GT_PrimPolygonMesh, GT_PrimPolygon, GT_PrimFragments, and GT_PrimInstance.

GT_PrimitiveHandle GT_Primitive::copyTransformed ( const GT_TransformHandle x,
bool  force = false 
) const

Create a transformed copy. This will transform a clone() of the primitive by the given transform. It's possible this primitive might be returned if the clone doesn't need to be transformed. The force parameter will force a clone to be created.

virtual GT_DataArrayHandle GT_Primitive::createPointNormals ( int  segment = 0,
const char *  P = "P",
bool  normalize = true,
const fpreal32 pntdata = NULL,
GT_Storage  store = GT_STORE_REAL32 
) const
virtual

Methods defined on GT_Primitive which are a short-cut to avoid a static/dynamic cast of the primitive when we know that the primitive is a polygon mesh. These are not part of the interface of GT_Primitive per se.

Reimplemented in GT_PrimPolygonMesh.

static int GT_Primitive::createPrimitiveTypeId ( )
static

The GT library has pre-defined primitive types (see GT_PrimitiveType) Custom primitives may ask for an identifier which is guaranteed to be unique. These integers are created at run time and may have different values from run to run. They will always be greater or equal to GT_MAX_PRIM_TYPES.

virtual GT_PrimitiveHandle GT_Primitive::doAttributeMerge ( const GT_Primitive src,
const UT_StringMMPattern vertex,
const UT_StringMMPattern point,
const UT_StringMMPattern uniform,
const UT_StringMMPattern detail 
) const
virtual
void GT_Primitive::dumpAttributeLists ( const char *  label,
bool  data_too 
) const

print out all attribute lists

void GT_Primitive::dumpPrimitive ( ) const

Dump the primitive. If the primitive's save() method isn't implemented (i.e. returns false), the attributes will be dumped.

void GT_Primitive::enlargeP ( UT_BoundingBox box,
const GT_AttributeListHandle list,
int  segment 
) const
protected

Convenience function to compute the point bounding box given an attribute list. This tests whether "P" is in homogeneous coordinates or not.

void GT_Primitive::enlargeP ( UT_BoundingBox B,
const GT_DataArrayHandle P 
) const
protected

Convenience method to enlarge a bounding box given a position attribute.

void GT_Primitive::enlargePw ( UT_BoundingBox B,
const GT_DataArrayHandle P 
) const
protected

Convenience method to enlarge a bounding box given P in homogeneous coordinates.

virtual void GT_Primitive::enlargeRenderBounds ( UT_BoundingBox  boxes[],
int  nsegments 
) const
virtual

This is used when computing bounds for rendering (not just geometric bounds). This normally just calls enlargeBounds(), but for some primitives, their bounds can be influenced by attribute values (i.e. the "width" in point mesh primitives). This allows proper bounds to be passed to mantra. Users may want to call enlargeWidth()

Reimplemented in GT_PrimAgentShape, GT_PrimCurveMesh, GT_PrimPointMesh, GT_GEOPrimPacked, GT_PrimFragments, GT_PrimInstance, GT_PrimCollect, GT_PrimCurve, GT_GEOPrimList, and GT_PrimMultiSegment.

bool GT_Primitive::enlargeWidth ( UT_BoundingBox  boxes[],
int  nsegments,
fpreal  defwidth = -1 
) const

Search attributes for a "width" or "pscale" attribute. If one is found, enlarge the bounding boxes by the maximum value of the attribute. If no attributes are found, use the defwidth. Returns true if an attribute was found

Note
If the defwidth is less than 0, the "mantra" default width will be used. Pass in 0 to leave the boxes unchanged.
GT_DataArrayHandle GT_Primitive::findAttribute ( const char *  name,
GT_Owner owner,
int  segment 
) const

Find an attribute of a given name. The search order is:

const GT_AttributeListHandle& GT_Primitive::getAttributeList ( GT_Owner  owner) const

Virtual methods to access the attribute data for primitives Some primitives may not implement these methods, in which case, the returned value will be an empty list.

bool GT_Primitive::getDataIdHash ( int64 hash,
int  segment = 0,
bool  cache_data_id = false 
) const

Return the data ID hash derived from attribute lists. If cache_data_id is true, cache the result for future calls. This should only be done if the primitive and its attributes will not change (such as packed primitive contents).

virtual const GT_AttributeListHandle& GT_Primitive::getDetailAttributes ( ) const
virtual

Virtual methods to access the attribute data for primitives Some primitives may not implement these methods, in which case, the returned value will be an empty list.

Reimplemented in GT_PrimCurveMesh, GT_PrimPolygonMesh, GT_PackedAlembic, GT_PrimPatch, GT_PrimPatchMesh, GT_PrimNURBSCurveMesh, GT_PrimNuPatch, GT_PrimTube, GT_PrimQuadricMesh, GT_PrimQuadric, GT_PrimPointMesh, GT_GEOPrimTPSurf, GT_PrimInstance, and GT_PrimTetMesh.

virtual const GT_AttributeListHandle& GT_Primitive::getPointAttributes ( ) const
virtual

Virtual methods to access the attribute data for primitives Some primitives may not implement these methods, in which case, the returned value will be an empty list.

Reimplemented in GT_PrimPolygonMesh, GT_GEOPrimMetaBall, GT_GEOPrimTPSurf, GT_PrimPointMesh, GT_GEOPrimPacked, and GT_PrimTetMesh.

const GT_TransformHandle& GT_Primitive::getPrimitiveTransform ( ) const
inline

Return a transform applied to the entire primitive. By default, this returns an identity transform.

Definition at line 108 of file GT_Primitive.h.

virtual bool GT_Primitive::getTopologyVersion ( int64 version) const
virtual

Returns the topology version for the primitive.

Reimplemented in GT_PrimAgentShape.

virtual const GT_AttributeListHandle& GT_Primitive::getUniformAttributes ( ) const
virtual

Virtual methods to access the attribute data for primitives Some primitives may not implement these methods, in which case, the returned value will be an empty list.

Reimplemented in GT_PrimCurveMesh, GT_PrimPolygonMesh, GT_PrimPatch, GT_PrimPatchMesh, GT_PrimNURBSCurveMesh, GT_PrimVolume, GT_PrimVDB, GT_PrimPolygon, GT_GEOPrimMetaBall, GT_GEOPrimTPSurf, GT_PrimCurve, GT_PrimFragments, GT_PrimInstance, and GT_PrimTetMesh.

virtual bool GT_Primitive::getUniqueID ( int64 id) const
virtual

Return a unique primitive ID and true, if an ID can be generated (false otherwise).

Reimplemented in GT_PackedAlembicMesh, and GT_PackedAlembic.

virtual void GT_Primitive::getVelocityRange ( UT_Vector3 min,
UT_Vector3 max,
const char *  attribute_name = "v" 
) const
virtual

This method is used to find the minimum/maximum velocity bounds. By default, the shared/vertex attributes are scanned for the attribute and its range is used. Only the first segment is queried.

If unable to compute the velocity range, the min and max should be set to 0.

Reimplemented in GT_GEOPrimPacked, GT_PrimFragments, GT_PrimInstance, GT_GEODetail, GT_PrimCollect, and GT_GEOPrimList.

virtual const GT_AttributeListHandle& GT_Primitive::getVertexAttributes ( ) const
virtual

Virtual methods to access the attribute data for primitives Some primitives may not implement these methods, in which case, the returned value will be an empty list.

Reimplemented in GT_PrimCurveMesh, GT_PrimPolygonMesh, GT_PrimPatch, GT_PrimPatchMesh, GT_PrimNURBSCurveMesh, GT_PrimNuPatch, GT_PrimQuadricMesh, GT_PrimPolygon, GT_PrimCurve, and GT_PrimTetMesh.

virtual const GT_DataArrayHandle& GT_Primitive::getVertexList ( ) const
virtual

Methods defined on GT_Primitive which are a short-cut to avoid a static/dynamic cast of the primitive when we know that the primitive is a polygon mesh. These are not part of the interface of GT_Primitive per se.

Reimplemented in GT_PrimPolygonMesh, and GT_PrimTetMesh.

GT_PrimitiveHandle GT_Primitive::harden ( ) const
inline

The harden method will return a NULL pointer if hardening isn't implemented for the primitive in question. Otherwise, any references will be hardened into local data for the primitive.

Definition at line 230 of file GT_Primitive.h.

virtual bool GT_Primitive::hasDataArray ( const char *  name,
GT_Owner  owner_scope[],
int  num_owners,
GT_Storage storage = NULL,
GT_Size tuple_size = NULL 
) const
virtual

Returns true if a data array with 'name' is found in 'owner_scope', and optionally its storage and tuple_size.

Reimplemented in GT_GEOPackedAgent.

bool GT_Primitive::isFrameInfoAvailable ( ) const
inline

Definition at line 146 of file GT_Primitive.h.

bool GT_Primitive::isStaticGeometry ( ) const
inline

Definition at line 145 of file GT_Primitive.h.

static GT_AttributeListHandle GT_Primitive::mergeAttributeLists ( bool &  changed,
const GT_AttributeListHandle src,
const GT_AttributeListHandle merge,
const UT_StringMMPattern pattern,
const UT_StringMMPattern alternate = NULL 
)
static

This method will "merge" two attribute lists given The changed variable will be set to true if there are modifications, otherwise, it will remain unchanged.

static void GT_Primitive::operator delete ( void p,
size_t  size 
)
static

For memory tracking, we override the new/delete operators

static void* GT_Primitive::operator new ( size_t  size)
static

For memory tracking, we override the new/delete operators

static void* GT_Primitive::operator new ( size_t  size,
void p 
)
static

For memory tracking, we override the new/delete operators

virtual bool GT_Primitive::refine ( GT_Refine refiner,
const GT_RefineParms parms = NULL 
) const
virtual
void GT_Primitive::refineCopyTransformFrom ( const GT_Primitive src)

Copy the transform from the source primitive for transforming. This is only required when you're not using a copy c-tor on the primitive (which automatically copies the transform).

static GT_PrimitiveHandle GT_Primitive::refineDetail ( const GU_ConstDetailHandle detail,
const GT_RefineParms parms 
)
static

Refine a detail or primitive. The refine parms may be NULL. If the refinement fails, the returned handle will be NULL.

static GT_PrimitiveHandle GT_Primitive::refinePrimitive ( const GT_PrimitiveHandle primh,
const GT_RefineParms parms 
)
static

Refine a detail or primitive. The refine parms may be NULL. If the refinement fails, the returned handle will be NULL.

bool GT_Primitive::saveAttributeLists ( UT_JSONWriter w) const

Save all attribute lists to a JSON stream. The attribute lists are saved as a dictionary/map, keyed on the class name.

void GT_Primitive::setPrimitiveTransform ( const GT_TransformHandle x)
inline

Set the transform for a the primitive.

Definition at line 111 of file GT_Primitive.h.

void GT_Primitive::setStaticGeometry ( bool  static_geo)
inline

Return true if the primitive represents geometry at frame 'fr'.

Definition at line 143 of file GT_Primitive.h.

virtual const GT_ViewportRefineOptions& GT_Primitive::viewportRefineOptions ( ) const
virtual

This method is used to pass information about refinement to the Houdini viewport. This returns a default GT_ViewportRefineOptions.

Reimplemented in GT_PrimCurveMesh, GT_PrimQuadric, GT_PrimNURBSCurveMesh, GT_PrimFragments, GT_GEOPrimPacked, GT_PrimInstance, GT_PrimVDB, GT_GEOPrimMetaBall, GT_GEOPrimCurve, and GT_GEOPrimTPSurf.


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