Yair Kurzion (yair++at++polygon.engr.sgi.com)
Thu, 21 Jan 1999 14:34:10 -0800 (PST)
Suppose you want to realloc the COORD attribute on a Fluxed GeoSet. Here is
what you should do (similar to the routine change_prim_count in
pguide/libpf/C++/fluxed_gset.C):
1. Get a writable copy of the Fluxed GeoSet. (pfFlux::getWritableData)
This will return a copy of the multi-buffered GeoSet. You can modify its
attributes as you please because no other process can see this copy
until you writeComplete it.
2. Get COORD Attr from the GeoSet you just received. (pfGeoSet::getAttrLists)
Grab the old Attribute lists. Note that each copy of the Fluxed GeoSet
should point to a different set of Attribute arrays (see below).
3. Realloc this Attr array to the new size (pfRealloc)
pfMalloc new attributes if they are NULL or pfRealloc if not NULL.
4. SetAttr on the GeoSet (pfGeoSet::setAttr)
Store the new attributes on the GeoSet.
5. WriteComplete. (pfFlux::writeComplete)
Tell Flux that you are done modifying the GeoSet and that it may let other
processes use it.
When you create a new Fluxed GeoSet as in
fluxed_gset = new pfFlux(make_fluxed_gset, PFFLUX_DEFAULT_NUM_BUFFERS);
you should write an init routine make_fluxed_gset that allocates new
attribute arrays every time it is invoked. This way the different copies of
the fluxed GeoSet will have different attribute arrays and the above
manipulation will be MP-safe. The sample code in pguide/libpf/C++/fluxed_gset.C
does exactly that.
One more note:
If your GeoSet has an attribute that NEVER needs modification or realloc, you
can use the same array for setting this attribute every time your init routine
is invoked. e.g. If your vertex normals change but the vertices themselves
never change, you can allocate the COORD attribute array only once and use the
same memory for all COORD attributes.
-yair
--
\_________ \_____ \__ \__ \_____ Yair Kurzion
\_________ \_____ \__ \__ \_____ yair++at++sgi.com
\__ \__ \____\__ \__ http://reality.sgi.com/yair
\__ \__ \__ Work: (650) 933-6502
\__ \__ \__ Home: (408) 226-9771
\__ \__ \__
This archive was generated by hypermail 2.0b2 on Thu Jan 21 1999 - 14:34:17 PST