What's the best way to copy a node?
Under the Introduction to Some Simple Classes: General Copy Functions I read about the clone function. Is that the best way?
Cloning a node
-
- Site Admin
- Posts: 1419
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Cloning a node
Try this approach:
For historical reasons, the complete copy requires the "extra definiton" to be cloned along with node definition. This object contains diagnosis-specific data.
Code: Select all
DSL_node *origNode = net.GetNode(hOrig);
int hNew = net.AddNode(origNode->Definition()->GetType(), "ClonedNode");
const DSL_intArray &parents = net.GetParents(hOrig);
for (int i = 0; i < parents.NumItems(); i++)
{
net.AddArc(parents[i], hNew);
}
net.GetNode(hNew)->Definition()->Clone(*origNode->Definition());
net.GetNode(hNew)->ExtraDefinition()->Clone(*origNode->ExtraDefinition());
-
- Posts: 71
- Joined: Mon Aug 01, 2016 9:45 pm
Re: Cloning a node
This is very cool.
I actually wanted to copy a node without the arcs.
Thanks for the post.
I actually wanted to copy a node without the arcs.
Thanks for the post.