96{
97 assert(
m_d->nodes2extrasep.find(node)!=
m_d->nodes2extrasep.end());
99 if (
m_d->nodes2extrasep.find(node)==
m_d->nodes2extrasep.end())
100 VP1Msg::message(
"VP1ExtraSepLayerHelper::removeNode ERROR: Node not added previously!");
101 }
102
103
104 SoSeparator * extrasep =
m_d->nodes2extrasep[
node];
105 assert(extrasep->findChild(node)>-1);
106 assert(
m_d->topsep->getChild(
m_d->topsep->getNumChildren()-1)->getTypeId()==SoSeparator::getClassTypeId());
107 SoSeparator * lastsep =
static_cast<SoSeparator*
>(
m_d->topsep->getChild(
m_d->topsep->getNumChildren()-1));
108 assert(lastsep->getNumChildren()>0);
109
110
112 extrasep->removeChild(node);
114 m_d->nodes2extrasep.erase(
m_d->nodes2extrasep.find(node));
115
116
117 if (lastsep!=extrasep&&lastsep->getNumChildren()>0) {
118 SoNode * othernode = lastsep->getChild(lastsep->getNumChildren()-1);
119 othernode->ref();
120 lastsep->removeChild(othernode);
121 extrasep->addChild(othernode);
122 othernode->unref();
123 m_d->nodes2extrasep[othernode] = extrasep;
124 }
125
126
127 if (lastsep->getNumChildren()==0) {
128 lastsep->ref();
129 m_d->topsep->removeChild(lastsep);
130 lastsep->unref();
131 }
132}