예제 #1
0
SbBool
SoUnknownNode::readInstance(SoInput *in, unsigned short flags)

//
////////////////////////////////////////////////////////////////////////
{
    int i;

    // This is mostly the normal SoGroup reading code, but we look for
    // an alternateRep field after reading and move our public
    // children onto the hidden children list:

    hasChildren = (!in->isBinary() || (flags & IS_GROUP));
    SbBool result;
    if (hasChildren) {
	result = SoGroup::readInstance(in, flags);

	// If read ASCII AND didn't read any children, set hasChildren
	// to FALSE:
	if (!in->isBinary() && getNumChildren() == 0) hasChildren = FALSE;

	// Add all kids to hiddenChildren, then remove them all from the
	// regular (SoGroup) list
	for (i = 0; i < getNumChildren(); i++) {
	    hiddenChildren.append(getChild(i));
	}
	removeAllChildren();
    }
    else {
	result = SoNode::readInstance(in, flags);
    }

    // Check to see if an alternate representation was read and
    // store a pointer to it if one is found.
    int num = instanceFieldData->getNumFields();
    SbBool haveAlternateRep = FALSE;
    for (i=0; i<num; i++) {
        if (instanceFieldData->getFieldName(i) == SbName("alternateRep")) {
	    SoField *f = instanceFieldData->getField(this, i);
	    if (f->isOfType(SoSFNode::getClassTypeId())) {
		haveAlternateRep = TRUE;
		SoSFNode *alternateRepField = (SoSFNode *)f;
		SoNode *n = alternateRepField->getValue();
		if (n != NULL)
		    addChild(n);
	    }
            break;
        }
    }

    // If no alternateRep was specified, look for a field named "isA"
    // of type MFString and try to automatically create an
    // alternateRep:
    if (!haveAlternateRep) for (i=0; i<num; i++) {
        if (instanceFieldData->getFieldName(i) == SbName("isA")) {
	    SoField *f = instanceFieldData->getField(this, i);
	    if (f->isOfType(SoMFString::getClassTypeId())) {
		createFromIsA((SoMFString *)f);
	    }
	}
    }

    return result;
}
예제 #2
0
파일: SoSFNode.cpp 프로젝트: Alexpux/Coin3D
// Compares to see if the \a field points to the same node as this
// field does, and returns \c TRUE if this is the case.
//
// Be aware that this method does \e not check for node/subgraph
// equality if the pointers are not the same, so \c FALSE is returned
// even though the contents of the node/subgraph are equal.
SbBool
SoSFNode::operator==(const SoSFNode & field) const
{
  return (this->getValue() == field.getValue());
}