void
GeoPositionNodeAutoScaler::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
    GeoPositionNode* geo = static_cast<GeoPositionNode*>(node);
    osgUtil::CullVisitor* cs = static_cast<osgUtil::CullVisitor*>(nv);
    double size = 1.0/cs->pixelSize( node->getBound().center(), 0.5f );
    geo->getPositionAttitudeTransform()->setScale( osg::componentMultiply(_baseScale, osg::Vec3d(size,size,size)) );
    traverse(node, nv);
}
    void addBuoyancyTest(osg::Node* model)
    {
        //labels = new AnnotationLayer();
        //map->addLayer(labels);

        normals = new AnnotationLayer();
        map->addLayer(normals);

        // geometry for a unit normal vector
        normalDrawable = new LineDrawable(GL_LINES);
        normalDrawable->setColor(osg::Vec4(1,1,0,1));
        normalDrawable->pushVertex(osg::Vec3(0,0,0));
        normalDrawable->pushVertex(osg::Vec3(0,0,10));
        normalDrawable->pushVertex(osg::Vec3(-2,0,0.5));
        normalDrawable->pushVertex(osg::Vec3(2,0,0.5));
        normalDrawable->pushVertex(osg::Vec3(0,-2,0.5));
        normalDrawable->pushVertex(osg::Vec3(0,2,0.5));
        normalDrawable->finish();

        // a single shared anchor point for the intersection set:
        isect->setAnchor(anchor);

        // generate a bunch of local points around the anchor:
        for(int x=-50; x<=50; x+=25)
        {
            for(int y=-50; y<=50; y+=25)
            {
                isect->addLocalPoint(osg::Vec3d(x, y, 0));

                // a label communicating the wave height:
                //PlaceNode* label = new PlaceNode();
                //label->setDynamic(true);
                //label->setPosition(anchor);
                //label->setIconImage(image);
                //label->setText("-");
                //labels->getGroup()->addChild(label);

                // a normal vector and optional model:
                GeoPositionNode* normal = new GeoPositionNode();
                normal->setDynamic(true);
                normal->getPositionAttitudeTransform()->addChild(normalDrawable);
                if (model)
                    normal->getPositionAttitudeTransform()->addChild(model);
                normal->setPosition(anchor);
                normals->getGroup()->addChild(normal);
            }
        }

        //ScreenSpaceLayout::setDeclutteringEnabled(false);
    }
    void updateBuoyancyTest()
    {
        for(unsigned i=0; i<isect->getHeights().size(); ++i)
        {
            osg::Vec3d local = isect->getInput()[i];
            local.z() = isect->getHeights()[i];

            //PlaceNode* label = dynamic_cast<PlaceNode*>(labels->getGroup()->getChild(i));
            //label->getPositionAttitudeTransform()->setPosition(local);
            //label->setText(Stringify()<<std::setprecision(2)<<local.z());

            GeoPositionNode* normalNode = dynamic_cast<GeoPositionNode*>(normals->getGroup()->getChild(i));
            normalNode->getPositionAttitudeTransform()->setPosition(local);
            osg::Quat q;
            q.makeRotate(osg::Vec3d(0,0,1), isect->getNormals()[i]);
            normalNode->getPositionAttitudeTransform()->setAttitude(q);
        }
    }