Hello Carsten,

thank you for the quick answer. I realized that comparing a special 
string with the full name of a node does not do what I want at the end. 
So I have fixed it now by giving the method a second input. Know 
"generateJointList" compares a substring at the beginning of each name 
with a given string. And only the matches are inserted in the list. For 
this the idea with casting was great :)
But at the end I have jet an error message :( :

Unbehandelte Ausnahme bei 0x7c3417fb (msvcr71.dll) in 01hello.exe: 
0xC0000005: Zugriffsverletzung-Leseposition 0x00000000.

I know for certain that the matter is my generateJointList method but 
why. For me it seems correct now. Any hints where to change something?


By the way here is the customized method:

void GenerateJointList::generateJointList(NodePtr scene, string subStr) {
        UInt32 children = scene->getNChildren();
        // Returns an iterator referring to the first element in the map
         container
        mIter = mJointList.begin();

        // check if it is one of the joints we are looking for
        
         if(subStr.compare(string(getName(scene)).substr(0,
         subStr.length())) == 0) {

             // Insert joint to list!
            mJointList.insert(mIter, pair<string,
             NodePtr>(string(getName(scene)), scene));
        }
        
        // check all children
        for (int i = 0; i < children; i++) {
                generateJointList(scene->getChild(i), subStr);
        }
}

greets,
Sadi

Carsten Neumann schrieb:
>       Hello Sadi,
> 
> Sadi Tanis wrote:
>> I have written a class with two methods to save nodes in a map and to 
>> print this map. The nodes in this case are joints of a loaded model. 
>> Once executed the map remains empty.
>> I think it is because somewhere I need to declare a pointer to the root 
>> node that the saving function receives a filled node-tree. But I don't 
>> know where and how exactly.
>>
>> This is the class definition and the methods of it:
>>
>> #include <map>
>> #include <string>
>> #include <OpenSG/OSGNodePtr.h>
>>
>> // defining a map with string key and a NodePtr
>> typedef std::map<std::string, OSG::NodePtr> jointlist;
>> typedef std::map<std::string, OSG::NodePtr>::iterator it;
>>
>>
>> class GenerateJointList {
>>          private:
>>              
>>              // member variables
>>              jointlist mJointList, mResultList;
>>              it mIter;
>>      
>>      public:
>>
>>              // generates list
>>              void generateJointList(OSG::NodePtr scene);
>>
>>              // prints list
>>              void printList();
>> };
>>
>> void GenerateJointList::generateJointList(NodePtr scene) {
>>      UInt32 children = scene->getNChildren();
>>
>>      // Returns an iterator referring to the first element
>>          // in the map container
>>      mIter = mJointList.begin();
>>
>>      // check if it is one of the joints we are looking for
>>          // all joint node names begin with "Gelenk"
>>      if(getName(scene) == "Gelenk") {
>                       ^^^^^^^^^
> 
> I think this is where the problem is: the prototype of getName is
> const Char8 *getName(AttachmentContainerPtrConstArg  container);
> It returns a C string, i.e. a pointer to a character array, which you 
> can not compare with ==. You either need to use the strcmp function or 
> create a temporary std::string like this:
> 
> if(std::string(getName(scene)) == "Gelenk")



> 
>       Hope it helps,
>               Carsten
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users


-- 
Sadi Tanis
University of Koblenz/Landau
Student of Computer Vision
Simmerner Straße 134
56075 Koblenz Germany
Tel. +49.261.208.98.73
E-mail [EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to