7 #include <Inventor/C/errors/debugerror.h>
8 #include <Inventor/nodes/SoSeparator.h>
9 #include <Inventor/nodes/SoMaterial.h>
28 std::map<SoMaterial*,std::pair<SoSeparator*,VP1ExtraSepLayerHelper*> >
mat2sepandhelper;
34 : m_d(
new Imp(topsep,numberOfNodesPerExtraSep))
44 delete it->second.second;
45 it->second.first->unref();
59 VP1Msg::message(
"VP1ExtraSepLayerHelper::addNode ERROR: Node already added!");
63 SoSeparator *
sep =
new SoSeparator;
65 sep->setName(
"SepHelperInternalSep");
66 sep->renderCaching.setValue(SoSeparator::ON);
67 sep->boundingBoxCaching.setValue(SoSeparator::ON);
75 assert(
m_d->
topsep->getChild(
m_d->
topsep->getNumChildren()-1)->getTypeId().isDerivedFrom(SoSeparator::getClassTypeId()));
76 SoSeparator * lastsep =
static_cast<SoSeparator*
>(
m_d->
topsep->getChild(
m_d->
topsep->getNumChildren()-1));
78 lastsep->addChild(
node);
84 SoSeparator *
sep =
new SoSeparator;
86 sep->setName(
"SepHelperInternalSep");
87 sep->renderCaching.setValue(SoSeparator::ON);
88 sep->boundingBoxCaching.setValue(SoSeparator::ON);
100 VP1Msg::message(
"VP1ExtraSepLayerHelper::removeNode ERROR: Node not added previously!");
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);
112 extrasep->removeChild(
node);
117 if (lastsep!=extrasep&&lastsep->getNumChildren()>0) {
118 SoNode * othernode = lastsep->getChild(lastsep->getNumChildren()-1);
120 lastsep->removeChild(othernode);
121 extrasep->addChild(othernode);
127 if (lastsep->getNumChildren()==0) {
146 for (
int i = 0;
i <
n; ++
i)
147 m_d->
topsep->getChild(
i)->enableNotify(
false);
151 it->second.second->largeChangesBegin();
165 it->second.second->largeChangesEnd();
168 for (
int i = 0;
i <
n; ++
i) {
197 SoSeparator * matsep =
new SoSeparator;
199 matsep->setName(
"SepHelperInternalSep_MatSep");
201 matsep->addChild(
mat);
202 SoSeparator *
sep =
new SoSeparator;
204 sep->setName(
"SepHelperInternalSep_InternalSepHelperTop");
205 matsep->addChild(
sep);
211 it->second.second->addNode(
node);
221 it->second.second->removeNode(
node);
222 if (
it->second.second->topSeparator()->getNumChildren()==0) {
225 it->second.first->unref();