/*! Push \a srcTrans into \a dstGeo
 */
void TransformPushGraphOp::pushToGeometry(
    const Transform *srcTrans, Geometry *dstGeo)
{
    typedef Vec4f  VecType;
    typedef Pnt3f  PntType;
    
    Matrix mat    = srcTrans->getMatrix();
    Matrix invMat = mat;

    invMat[3][0] = invMat[3][1] = invMat[3][2] = 0.f;

    invMat.invert   ();
    invMat.transpose();

    const Geometry::SFLengthsType     *sfLen  = dstGeo->getSFLengths     ();
          Geometry::MFPropertiesType  *mfProp = dstGeo->editMFProperties ();
          Geometry::MFPropIndicesType *mfInd  = dstGeo->editMFPropIndices();
    
    Geometry::MFPropertiesType::const_iterator  propIt  = mfProp->begin();
    Geometry::MFPropertiesType::const_iterator  propEnd = mfProp->end  ();
    
    Geometry::MFPropIndicesType::const_iterator indIt   = mfInd ->begin();
    Geometry::MFPropIndicesType::const_iterator indEnd  = mfInd ->end  ();
    
    UInt32 propUsed = 0;
    for(UInt32 i = 0; i < sfLen->getValue()->size(); ++i)
        propUsed += sfLen->getValue()->getValue<UInt32>(i);
    
    for(; propIt != propEnd && indIt != indEnd; ++propIt, ++indIt)
    {
              GeoVectorProperty   *prop = *propIt;
        const GeoIntegralProperty *ind  = *indIt;
        
        if(prop == NULL)
            continue;
        
        if(ind == NULL)
        {
            // unindexed
            if((prop->getUsage() & GeoProperty::UsageObjectSpace) != 0x0000)
            {
                // transform with mat
                for(UInt32 i = 0; i < propUsed; ++i)
                {
                    PntType pnt = prop->getValue<PntType>(i);
                    mat.multFull(pnt, pnt);
                    prop->setValue(pnt, i);
                }
            }
            else if((prop->getUsage() & GeoProperty::UsageTangentSpace) != 0x0000)
            {
                // transform with invMat
                for(UInt32 i = 0; i < propUsed; ++i)
                {
                    VecType vec = prop->getValue<VecType>(i);
                    invMat.mult(vec, vec);
                    prop->setValue(vec, i);
                }
            }
        }
        else
        {
            std::set<UInt32> transInd;
            
            if((prop->getUsage() & GeoProperty::UsageObjectSpace) != 0x0000)
            {
                // transform with mat
                for(UInt32 i = 0; i < propUsed; ++i)
                {
                    UInt32 j = ind->getValue(i);
                    
                    if(transInd.find(j) == transInd.end())
                    {
                        PntType pnt = prop->getValue<PntType>(j);
                        mat.multFull(pnt, pnt);
                        prop->setValue(pnt, j);
                        
                        transInd.insert(j);
                    }
                }
            }
            else if((prop->getUsage() & GeoProperty::UsageTangentSpace) != 0x0000)
            {
                // transform with invMat
                for(UInt32 i = 0; i < propUsed; ++i)
                {
                    UInt32 j = ind->getValue(i);
                    
                    if(transInd.find(j) == transInd.end())
                    {
                        VecType vec = prop->getValue<VecType>(j);
                        invMat.mult(vec, vec);
                        prop->setValue(vec, j);
                        
                        transInd.insert(j);
                    }
                }
            }
        }
    }
}