Home › Forum › SOFA › Building SOFA › [SOLVED] NewOmniDriver: GNode cannot access protected member
Tagged: 32_bits, SOFA_other, VS2012, Windows_7
- This topic has 12 replies, 5 voices, and was last updated 8 years, 8 months ago by Korcan.
-
AuthorPosts
-
15 January 2016 at 15:16 #5324ceceyangBlocked
Hello everyone,
I am building the latest version of SOFA on Win32 with Visual studio 2012.
Everything went well except NewOmniDriver. In NewOmniDriver.cpp there is :sofa::simulation::tree::GNode *parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(this->getContext());
if (parentRoot->parent())
parentRoot = parentRoot->parent();And VisualStudio show me the error:
error C2248: ‘sofa::simulation::tree::GNode::parent’ : cannot access protected member declared in class ‘sofa::simulation::tree::GNode’Anyone can help me with it?
Thanks! 🙂
Cece
18 January 2016 at 21:38 #5327HugoKeymasterHi Cece,
I do not have my own computer with me, so it’s not very easy to answer you.
However, I looked within the GNode.h (located in modules/component/sofa/simulation/tree) and it appears that the function parent() is now protected. You can however use the function getParents() returning all potential parent nodes. From here, you should be able to get the parent node you need.
I will see if some other developers have more information.Hope this helps already.
Cheers,Hugo
19 January 2016 at 00:07 #5332remibessardBlockedHello,
Indeed you can use getParents(), or getFirstParent() as it has been used to replace the same parent() method in ExportDotVisitor.cpp(344).
Also do not forget to cast the returned value :
if (parentRoot->getFirstParent())
parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(parentRoot->getFirstParent());Regards,
– Remi
19 January 2016 at 17:30 #5338ceceyangBlockedHello guys,
I am a beginner programmer, so .. Do you guys means I can change
GNode* getroot();
void setroot(GNode* root);to:
GNode* getParent(); (Parents? or Parent)
void setParent(GNode* root);in NewOmniDriver.h
Cece
19 January 2016 at 17:32 #5339ceceyangBlockedBTW, what I did was added:
GNode* getroot();
void setroot(GNode* root);
in NewOmniDriver.halso in NewOmniDriver.cpp:
template <class DataTypes>
void
NewOmniDriver<DataTypes>::setRoot(GNode* root){
Parentroot = root;
}
template <class DataTypes>
GNode* NewOmniDriver<DataTypes>::getRoot(){
return Parentroot;
}Do you guys think this is necessary or not?
19 January 2016 at 17:33 #5340ceceyangBlockedSeems I should click reply to you.
19 January 2016 at 19:01 #5342ceceyangBlockedFor the question parents/parent. I found answer. Thx
19 January 2016 at 19:21 #5343HugoKeymasterHi Cece,
Could you explain a bit more what was your issue and the fix you applied ?
Do you need any further help ?
Thank you for your feedback.Hugo
21 January 2016 at 17:06 #5360ceceyangBlockedHello Hugo,
I followed you and Remi’s advices, made this change in NewOmniDriver.cpp:
if (parentRoot->getParents())
parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(parentRoot->getParents());And this in .h:
GNode* getParents();
void setParents(GNode* parentRoot);Fortunately, the GNode protected problem disappeared, but I got new errors, and two of them I have no idea of how to solve:
error C2681: ‘sofa::core::objectmodel::BaseNode::Parents’ : invalid expression type for dynamic_cast
error C2451: conditional expression of type ‘sofa::core::objectmodel::BaseNode::Parents’ is illegalSo, do you have any idea?
Thank you guys sooo much for your time spent on my questions!Cece
21 January 2016 at 19:26 #5361ceceyangBlockedAbout this error:
conditional expression of type ‘sofa::core::objectmodel::BaseNode::Parents’ is illegal[if (parentRoot->getParents())
parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(parentRoot->getParents())]should it be like:
if (parentRoot->getParents())
parentRoot = parentRoot->getParents();
?I change it into above, then got an new error…
error C2440: ‘=’ : cannot convert from ‘sofa::core::objectmodel::BaseNode::Parents’ to ‘sofa::simulation::tree::GNode *’21 January 2016 at 22:19 #5362MichelBlockedI will look at this on Cece’s computer tomorrow or next Monday and report back. Hold off for now until I have more to write. This should be fixable.
Michel
22 January 2016 at 14:11 #5368ceceyangBlockedThank you guys so much.
And thanks again Remi, by replacing return with:
if (parentRoot->getParent()[0])
parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(parentRoot->getParent()[0]);the error was fixed. 🙂
1 March 2016 at 19:57 #6009KorcanBlockedHi Cece,
I changed NewOmniDriver.cpp like
if (parentRoot->getFirstParent()) parentRoot = dynamic_cast<sofa::simulation::tree::GNode*>(parentRoot->getFirstParent());
But still it crashing. Can you tell us which steps you made from start to end ?
Best Wishes,
Korcan -
AuthorPosts
- You must be logged in to reply to this topic.