Hello Sajjadul,

Sajjadul Islam wrote:
Hello Francesco,


Thanks for the hint, I checked the documentation but did not get much out of 
that .

the SplitGraphOp split up the graph into several parts that contains a pre specified number of polygons.


After the split operation i am trying to retrieve the geometry which i have to do to set the material to it. And there is where probably the problem arises. There may be multiple nodes containing the separated geometry core with the pre-specified number of polygons.

yes.

How to access them?

your graph probably changes from
        
          |
        node[geo]

to something like

          |
        node[group]
          |
          +---------------+     ...
          |               |
        node[geo]       node[geo]

(the group might be something different, maybe a MaterialGroup).
The SplitGraphOp will probably drop the name(s) if you had any assigned to the Node and/or Geometry (where should the they be placed?). This all boils down to: Examine the graph before and after the GraphOp is applied, then you should be able to figure out where the new (split) Geometries are placed.

        Hope it helps,
                Carsten

PS: The attached class may be useful to examine the scenegraph (for small scenes). It is not very sophisticated, but it might be a starting point.

#include <SceneGraphPrinter.h>

// OpenSG includes
#include <OpenSG/OSGSimpleAttachments.h>

    SceneGraphPrinter::SceneGraphPrinter(OSG::NodePtr root)
    
    : _pRoot  (root),
      _pStream(NULL),
      _indent (0)
{
    // nothing to do
}

void
    SceneGraphPrinter::print(std::ostream &os)
{
    _pStream = &os;
    _indent  = 0;
    
    OSG::traverse(
        _pRoot,
        OSG::osgTypedMethodFunctor1ObjPtrCPtrRef<
            OSG::Action::ResultE,
            SceneGraphPrinter,
            OSG::NodePtr         >(this, &Self::traverseEnter),
        OSG::osgTypedMethodFunctor2ObjPtrCPtrRef<
            OSG::Action::ResultE,
            SceneGraphPrinter,
            OSG::NodePtr,
            OSG::Action::ResultE >(this, &Self::traverseLeave));
}

OSG::Action::ResultE
    SceneGraphPrinter::traverseEnter(OSG::NodePtr &node)
{
    if(node == OSG::NullFC)
        return OSG::Action::Continue;
    
    std::ostream &os = *_pStream;
    incIndent();
    
    indentStream(os)
        <<   "[" << node.getCPtr()
        << "] [" << (OSG::getName(node) ? OSG::getName(node) : "<unnamed>")
        << "]";
    
    OSG::NodeCorePtr pCore = node->getCore();
    
    if(pCore == OSG::NullFC)
    {
        os << "\n";
        return OSG::Action::Continue;
    }
    
    os << " -- [" << pCore.getCPtr() << "]"
       <<    " [" << pCore->getType().getCName() << "]";
    
    os << " [" << (OSG::getName(pCore) ? OSG::getName(pCore) : "<unnamed>")
       << "]";
    
    OSG::MFNodePtr::const_iterator pIt  = pCore->getParents().begin();
    OSG::MFNodePtr::const_iterator pEnd = pCore->getParents().end  ();
    
    os << " --";
    
    for(; pIt != pEnd; ++pIt)
    {
        os << " ["  << node.getCPtr()
           << "] [" << (OSG::getName(node) ? OSG::getName(node) : "<unnamed>")
           << "]";
    }
    
    os << "\n";
    return OSG::Action::Continue;
}

OSG::Action::ResultE
    SceneGraphPrinter::traverseLeave(OSG::NodePtr &node, OSG::Action::ResultE 
res)
{
    if(node == OSG::NullFC)
        return OSG::Action::Continue;
    
    decIndent();
    
    return OSG::Action::Continue;
}

#ifndef _SCENEGRPAHPRINTER_H_
#define _SCENEGRPAHPRINTER_H_

// OpenSG includes
#include <OpenSG/OSGAction.h>
#include <OpenSG/OSGNode.h>

// std library includes
#include <iosfwd>

class SceneGraphPrinter
{
  public:
    typedef SceneGraphPrinter Self;
      
    SceneGraphPrinter(OSG::NodePtr root);
    
    void print(std::ostream &os);
  
  private:
    OSG::NodePtr  _pRoot;
    std::ostream *_pStream;
    OSG::UInt32   _indent;
    
    OSG::Action::ResultE traverseEnter(OSG::NodePtr         &node );
    OSG::Action::ResultE traverseLeave(OSG::NodePtr         &node,
                                       OSG::Action::ResultE  res  );
    
    void          incIndent   (void            );
    void          decIndent   (void            );
    std::ostream &indentStream(std::ostream &os);
};

inline void
    SceneGraphPrinter::incIndent(void)
{
    _indent += 2;
}

inline void
    SceneGraphPrinter::decIndent(void)
{
    _indent -= 2;
}

inline std::ostream &
    SceneGraphPrinter::indentStream(std::ostream &os)
{
    for(OSG::UInt32 i = 0; i < _indent; ++i)
        os << " ";
    
    return os;
}

#endif //_SCENEGRPAHPRINTER_H_
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to