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

Attribute Interface for merging attribute data between details. More...

#include <GA_AIFMerge.h>

Public Member Functions

 GA_AIFMerge ()
 
virtual ~GA_AIFMerge ()
 
virtual void destroyDestination (const GA_MergeMap &map, GA_Attribute *dattrib, const GA_Attribute &sattrib) const =0
 
virtual GA_AttributeaddDestination (const GA_MergeMap &map, GA_Attribute *dattrib, const GA_Attribute &sattrib) const =0
 
virtual void growArray (const GA_MergeMap &map, GA_Attribute &dattrib, const GA_Attribute *sattrib) const
 
virtual bool copyArray (const GA_MergeMap &map, GA_Attribute &dattrib, const GA_Attribute *sattrib) const =0
 

Static Public Member Functions

static bool destroyMismatchedType (const GA_MergeMap &map, GA_Attribute *dest)
 
static GA_AttributeaddMismatchedType (const GA_MergeMap &map, GA_Attribute *dest, const GA_Attribute &src)
 
static bool checkTupleStorage (const GA_MergeMap &map, GA_Attribute &dest, const GA_Attribute &src)
 
static bool checkTupleSize (const GA_MergeMap &map, GA_Attribute &dest, const GA_Attribute &src)
 

Detailed Description

Attribute Interface for merging attribute data between details.

This class provides an interface used to copy attribute data from one detail to another detail. The source detail is const and contains the geometry which will be merged into the destination detail.

Merging is done in stages:

  • Initially, the attributes on the source detail (the one being merged into the destination) are iterated over and if there's a matching "destination" attribute, the destroyDestination() method is called.
    This gives the merging interface a chance to destroy any attributes on the destination (depending on the options in the GA_MergeMap). The method will be called once for each attribute on the source detail.
    This provides the opportunity to delete attributes on the detail prior to the re-allocation of attribute arrays.
  • After the destination arrays have been resized to accommodate new elements, (or modify) attributes on the destination attribute, the addDestination() method will be called to create new attributes on the desintion detail. The method will be called for each attribute on the source detail.
  • The last stage of a merge is the copyArray() method. At this point, the attribute should have all the storage allocated and it should be as simple as using the source and destination iterators to copy the data. If optimizations are made in the growArray() method, you will most likely have to alter behaviour based on the map.getMergeStrategy().

Definition at line 56 of file GA_AIFMerge.h.

Constructor & Destructor Documentation

GA_AIFMerge::GA_AIFMerge ( )
virtual GA_AIFMerge::~GA_AIFMerge ( )
virtual

Member Function Documentation

virtual GA_Attribute* GA_AIFMerge::addDestination ( const GA_MergeMap map,
GA_Attribute dattrib,
const GA_Attribute sattrib 
) const
pure virtual

The addDestination() method is used to either create or modify attributes on the destination. For example, this method can be used to change storage, tuple size, etc. on an attribute, or to create an entirely new attribute. The dattrib parameter will be set to point to an existing attribute on the destination detail.

Parameters
mapThe merge options
dattribNULL or the existing destination attribute
sattribThe source attribute
static GA_Attribute* GA_AIFMerge::addMismatchedType ( const GA_MergeMap map,
GA_Attribute dest,
const GA_Attribute src 
)
static

The addMismatchedType() function is a convenience function to use the options in GA_MergeMap to handle attributes of different types. There are three possible types of return values:

  • The original mis-matched attribute. This will happen if the dest attribute passed in is a different type than the source attribute, but the merge options specify to keep the original attribute.
  • A new attribute of the same type as the source. This should only really happen if the dest parameter was NULL.
  • A NULL pointer. This will happen if it wasn't possible to call clone() on the source attribute.

The method should only be called if the dest and src attributes are different.

This should only be called from within addDestination()

ExampleMergeAIF::addDestination(GA_MergeMap &map, GA_Attribute *dest, const GA_Attribute &s) const {
Example *da = dynamic_cast<Example *>(dest);
if (!da)
{
dest = GA_AIFMerge::addMismatchedType(map, dest, s);
da = dynamic_cast<Example *>(dest);
return da;
}
return da;
}

Note: It's possible for dest to be NULL.

Parameters
mapThe merge options
destNULL or the existing destination attribute
srcThe source attribute
See Also
GA_MergeOptions
static bool GA_AIFMerge::checkTupleSize ( const GA_MergeMap map,
GA_Attribute dest,
const GA_Attribute src 
)
static

Convenience function to deal with changing tuple storage (based on merging strategy). The function returns true if the tuple sizes match, false if there's an irreconcilable difference. This should be called from within addDestination(). If the function returns false, then no attribute should be returned from addDestination() (indicating no merging).

Parameters
mapThe merge options
destThe existing destination attribute
srcThe source attribute
See Also
GA_MergeOptions
static bool GA_AIFMerge::checkTupleStorage ( const GA_MergeMap map,
GA_Attribute dest,
const GA_Attribute src 
)
static

Convenience function to deal with changing tuple sizes (based on merging strategy) The function returns true if the tuple storage match, false if there's an irreconcilable difference. This should be called from within addDestination(). If the function returns false, then no attribute should be returned from addDestination() (indicating no merging).

Parameters
mapThe merge options
destThe existing destination attribute
srcThe source attribute
See Also
GA_MergeOptions
virtual bool GA_AIFMerge::copyArray ( const GA_MergeMap map,
GA_Attribute dattrib,
const GA_Attribute sattrib 
) const
pure virtual

The copyArray() method is responsible for copying the data from the source to the destination attribute. The GA_MergeMap provides all the information necessary for mapping the source data to the destination.

Note: The destination attribute's AIFMerge is used, and it's possible that the source attribute is NULL (indicating that there's no data to copy).

bool
Example::mergeAppend(GA_MergeMap &map, const GA_Attribute *src)
{
if (src) {
// Copy data from the src array to my array
const GA_Range &di = map.getDestIterator(getOwner());
const GA_Range &si = map.getSourceIterator(getOwner());
copyArray(*this, di, src, si);
}
}
bool
ExampleMergeAIF::copyArray(GA_MergeMap &map, GA_Attribute &d, const GA_Attribute *s) const {
Example *da = dynamic_cast<Example *>(&d);
if (da)
da->mergeAppend(map, s);
}
Parameters
mapThe merge options
dattribNULL or the existing destination attribute
sattribThe source attribute
virtual void GA_AIFMerge::destroyDestination ( const GA_MergeMap map,
GA_Attribute dattrib,
const GA_Attribute sattrib 
) const
pure virtual

The destroyDestination() method is used to delete attributes on the destination (dattrib). These are attributes which will not survive the merge.

Parameters
mapThe merge options
dattribNULL or the existing destination attribute
sattribThe source attribute
static bool GA_AIFMerge::destroyMismatchedType ( const GA_MergeMap map,
GA_Attribute dest 
)
static

The destroyMismatchedType() function is a convenience function to use the options in GA_MergeMap to handle attributes of different types.

The method should only be called if the dest and src attributes are different.

This should only be called from within destroyDestination()

void
ExampleMergeAIF::destroyDestination(GA_MergeMap &map, GA_Attribute *dest, const GA_Attribute &s) const {
Example *da = dynamic_cast<Example *>(dest);
if (!da)
}

Note: It's possible for dest to be NULL.

Parameters
mapThe merge options
destNULL or the existing destination attribute
See Also
GA_MergeOptions
virtual void GA_AIFMerge::growArray ( const GA_MergeMap map,
GA_Attribute dattrib,
const GA_Attribute sattrib 
) const
virtual

The growArray() method is responsible for growing the array. The default behaviour is to call GA_Attribute::setArraySize(). This method is only called if the merge strategy is not set to GA_MergeOptions::MERGE_INTERLEAVE. It may be possible to perform optimizations depending on how data is stored.

Parameters
mapThe merge options
dattribNULL or the existing destination attribute
sattribThe source attribute

The default behaviour is to call:

dattrib.setArraySize( map.getDestCapacity(dattrib.getOwner()) );

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