Hello Pablo,

Pablo Carneiro Elias wrote:
> I'm trying to use the OSG::createSingleIndex function at  
> <OpenSG/OSGGeoFunctions.h> but it only prints "nyi" (not yet 
> implemented). Is there any other way of doing what that function does?

hm, no I don't think so. The beginning of an implementation would 
probably look like the below (completely untested).
The missing (and a bit tedious) part is now rewriting all the properties 
so that they can actually be indexed by the newly written index.

Int32 createSingleIndex(Geometry *geo)
{
     // creates a single index for the geometry by reordering/duplicating
     // values in properties.
     // - determine unique 'index tuples' (unique 'property value tuples'
     //   would be exact, but harder and slower to compute)
     // - write a new index by numbering the unique 'index tuples'
     //   and referring to them in the order they are used by the geo
     // - reorder the property values in such a way that the new index
     //   can refer directly to them instead of the 'index tuples'

     GeoUInt32PropertyUnrecPtr  newI = GeoUInt32Property::create();
     GeoIntegralProperty       *lens = geo->getLengths       ();
     Geometry::IndexBag         ibag = geo->getUniqueIndexBag();

     UInt32               idx = 0;
     IndexDic             indexDic;
     IndexDic::Int32Tuple indexTuple(ibag.size());

     // find all unique index tuples of the geometry and write new index

     for(UInt32 i = 0; i < lens->size(); ++i)
     {
         for(UInt32 j = 0; j < lens->getValue(i); ++j, ++idx)
         {
             for(UInt32 k = 0; k < ibag.size(); ++k)
             {
                 indexTuple[k] = ibag[k].first->getValue(idx);
             }

             // write new index
             newI->push_back(indexDic.entry(indexTuple));
         }
     }

     for(UInt32 i = 0; i < indexDic.entryCount(); ++i)
     {
         // write new properties such that
         // indexTuple = indexDic.entry(i);
         //
         // p_new[k][i] = p_old[k][ indexTuple[k] ]
         // where k distinguishes between the different properties
     }
}

Sorry, I'm not sure when I'll be able to finish this, so I'm posting it 
in case anybody wants to pick it up...

        Cheers,
                Carsten

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to