const VrmlField *VrmlNodeMultiTouchSensor::getField(const char *fieldName) const
{
    if (strcmp(fieldName, "trackObjects") == 0)
        return &d_trackObjects;
    if (strcmp(fieldName, "freeze") == 0)
        return &d_freeze;
    else if (strcmp(fieldName, "enabled") == 0)
        return &d_enabled;
    else if (strcmp(fieldName, "currentCamera") == 0)
        return &d_currentCamera;
    else if (strcmp(fieldName, "size") == 0)
        return &d_size;
    else if (strcmp(fieldName, "minPosition") == 0)
        return &d_minPosition;
    else if (strcmp(fieldName, "markerPosition") == 0)
        return &d_markerPosition;
    else if (strcmp(fieldName, "markerRotation") == 0)
        return &d_markerRotation;
    else if (strcmp(fieldName, "positionThreshold") == 0)
        return &d_positionThreshold;
    else if (strcmp(fieldName, "orientationThreshold") == 0)
        return &d_orientationThreshold;
    else if (strcmp(fieldName, "orientation") == 0)
        return &d_orientation;
    else if (strcmp(fieldName, "invisiblePosition") == 0)
        return &d_invisiblePosition;
    else if (strcmp(fieldName, "markerName") == 0)
        return &d_markerName;
    else
        cerr << "Node does not have this eventOut or exposed field " << nodeType()->getName() << "::" << name() << "." << fieldName << endl;
    return 0;
}
void AudioNode::ref(RefType refType)
{
    switch (refType) {
    case RefTypeNormal:
        atomicIncrement(&m_normalRefCount);
        break;
    case RefTypeConnection:
        atomicIncrement(&m_connectionRefCount);
        break;
    case RefTypeDisabled:
        atomicIncrement(&m_disabledRefCount);
        break;
    default:
        ASSERT_NOT_REACHED();
    }

#if DEBUG_AUDIONODE_REFERENCES
    printf("%p: %d: AudioNode::ref(%d) %d %d %d\n", this, nodeType(), refType, m_normalRefCount, m_connectionRefCount, m_disabledRefCount);
#endif

    // See the disabling code in finishDeref() below. This handles the case where a node
    // is being re-connected after being used at least once and disconnected.
    // In this case, we need to re-enable.
    if (m_isDisabled && m_connectionRefCount > 0 && refType == RefTypeConnection) {
        ASSERT(isMainThread());
        AudioContext::AutoLocker locker(context());

        m_isDisabled = false;
        for (unsigned i = 0; i < m_outputs.size(); ++i)
            output(i)->enable();
    }
}
Exemple #3
0
GeoDataCoordinates GeoDataAbstractView::coordinates() const
{
    if ( nodeType() == GeoDataTypes::GeoDataLookAtType) {
        const GeoDataLookAt *lookAt = static_cast<const GeoDataLookAt*>( this );
        if( lookAt ){
            return lookAt->coordinates();
        }
    }
    else if( nodeType() == GeoDataTypes::GeoDataCameraType ){
        const GeoDataCamera *camera = static_cast<const GeoDataCamera*>( this );
        if ( camera ){
            return camera->coordinates();
        }
    }
    return GeoDataCoordinates();
}
Exemple #4
0
void AudioNode::ref(RefType refType)
{
#if ENABLE(OILPAN)
    ASSERT(m_keepAlive);
#endif
    switch (refType) {
    case RefTypeNormal:
        atomicIncrement(&m_normalRefCount);
        break;
    case RefTypeConnection:
        atomicIncrement(&m_connectionRefCount);
        break;
    default:
        ASSERT_NOT_REACHED();
    }

#if DEBUG_AUDIONODE_REFERENCES
    fprintf(stderr, "%p: %d: AudioNode::ref(%d) %d %d\n", this, nodeType(), refType, m_normalRefCount, m_connectionRefCount);
#endif

    // See the disabling code in finishDeref() below. This handles the case where a node
    // is being re-connected after being used at least once and disconnected.
    // In this case, we need to re-enable.
    if (refType == RefTypeConnection)
        enableOutputsIfNecessary();
}
Exemple #5
0
bool XmlReader::readReal(const char* tag, qreal* val)
      {
      if (isTag(name(), tag)) {
            if (read()) {
                  if (nodeType() == XML_READER_TYPE_TEXT) {
                        *val = (qreal)matof((const char*)value());
                        skipElement((const xmlChar*)tag);
                        return true;
                        }
                  else if (nodeType() == XML_READER_TYPE_END_ELEMENT)
                        return false;
                  else
                        printf("?readInt: node type %d <%s>\n", nodeType(), name());
                  }
            }
      return false;
      }
QVariant QVariantTree::getItemContainer(const QVariant& key,
                                        const QVariant& defaultValue) const
{
    Q_ASSERT(nodeIsContainer());
    QVariantTreeElementContainer* containerType = containerOf(nodeType());
    Q_ASSERT_X(containerType != 0, "QVariantTree", "cannot find container of type");
    return containerType->item(nodeValue(), key, defaultValue);
}
void BytecodeGenerator::visitPrintNode(PrintNode* node) {
    Bytecode* bc = _state.currentBcToFill();
    for(size_t i = 0; i != node->operands(); ++i) {
        node->operandAt(i)->visit(this);
        VarType argType = nodeType(node->operandAt(i));
        Instruction bcPrint = typedInsn(argType, BC_IPRINT, BC_DPRINT, BC_SPRINT);
        bc->addInsn(bcPrint);
    }
}
Exemple #8
0
void XmlReader::skipElement(const xmlChar* e)
      {
      //      printf("skip <%s>\n", e);
      while (read()) {
            // printf("  name<%s>\n", name());
            if ((nodeType() == XML_READER_TYPE_END_ELEMENT) && xmlStrEqual(name(), e))
                  break;
            }
      }
void QVariantTree::delItemContainer(const QVariant& key)
{
    Q_ASSERT(nodeIsContainer());
    QVariantTreeElementContainer* containerType = containerOf(nodeType());
    Q_ASSERT_X(containerType != 0, "QVariantTree", "cannot find container of type");

    QVariantList collItemAddress = _address;
    collItemAddress << QVariant(key);
    _root = internalDelTreeValue(_root, collItemAddress);
}
Exemple #10
0
bool XmlReader::readString(const char* tag, QString* val)
      {
      if (isTag(name(), tag)) {
            while (read()) {
                  if (nodeType() == XML_READER_TYPE_TEXT) {
                        *val = QString::fromUtf8((const char*)value());
                        skipElement((const xmlChar*)tag);
                        return true;
                        }
                  else if ((nodeType() == XML_READER_TYPE_END_ELEMENT) && isTag(name(), tag)) {
                        *val = QString();
                        return true;
                        }
                  else
                        printf("?readInt: node type %d <%s>\n", nodeType(), name());
                  }
            }
      return false;
      }
Exemple #11
0
int 
Swig_require(const char *ns, Node *n, ...) {
  va_list ap;
  char *name;
  DOH *obj;
  char   temp[512];

  va_start(ap, n);
  name = va_arg(ap, char *);
  while (name) {
    int newref = 0;
    int opt = 0;
    if (*name == '*') {
      newref = 1;
      name++;
    } else if (*name == '?') {
      newref = 1;
      opt = 1;
      name++;
    }
    obj = Getattr(n,name);
    if (!opt && !obj) {
      Printf(stderr,"%s:%d. Fatal error (Swig_require).  Missing attribute '%s' in node '%s'.\n", 
	     Getfile(n), Getline(n), name, nodeType(n));
      assert(obj);
    }
    if (!obj) obj = DohNone;
    if (newref) {
      /* Save a copy of the attribute */
      strcpy(temp,ns);
      strcat(temp,":");
      strcat(temp,name);
      Setattr(n,temp,obj);
    } 
    name = va_arg(ap, char *);
  }
  va_end(ap);

  /* Save the view */
  {
    String *view = Getattr(n,"view");
    if (view) {
      if (Strcmp(view,ns) != 0) {
	strcpy(temp,ns);
	strcat(temp,":view");
	Setattr(n,temp,view);
	Setattr(n,"view",ns);
      }
    } else {
      Setattr(n,"view",ns);
    }
  }

  return 1;
}
Exemple #12
0
bool GeoDataAbstractView::operator==(const GeoDataAbstractView &other) const
{
    if (nodeType() != other.nodeType()) {
        return false;
    }

    if (nodeType() == GeoDataTypes::GeoDataCameraType) {
        const GeoDataCamera &thisCam = static_cast<const GeoDataCamera &>(*this);
        const GeoDataCamera &otherCam = static_cast<const GeoDataCamera &>(other);

        return thisCam == otherCam;
    } else if (nodeType() == GeoDataTypes::GeoDataLookAtType) {
        const GeoDataLookAt &thisLookAt = static_cast<const GeoDataLookAt &>(*this);
        const GeoDataLookAt &otherLookAt = static_cast<const GeoDataLookAt &>(other);

        return thisLookAt == otherLookAt;
    }

    return false;
}
Exemple #13
0
void 
Swig_print_tags(DOH *obj, DOH *root) {
  DOH *croot, *newroot;
  DOH *cobj;

  if (!root) croot = NewString("");
  else croot = root;

  while (obj) {
    Printf(stdout,"%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
    cobj = firstChild(obj);
    if (cobj) {
      newroot = NewStringf("%s . %s",croot,nodeType(obj));
      Swig_print_tags(cobj,newroot);
      Delete(newroot);
    }
    obj = nextSibling(obj);
  }
  if (!root)
    Delete(croot);
}
Exemple #14
0
NodeView::NodeView( const QPointF& position, kiwi::core::Node * n)
: kiwi::view::NodeView( n )
{
    assert( n );
    n->setView( this );
    setFlags(QGraphicsItem::ItemIsMovable);
    setPos( position );
    float nodeHeight = (nodeType()->inputs().size() + nodeType()->outputs().size()) * portsSpacing() + headerHeight();
    _rect = QRectF( 0, 0, 150.0, nodeHeight );

    int i = 0;
    for( auto it = nodeType()->inputs().begin(); it != nodeType()->inputs().end(); ++it )
    {
        _inputs.push_back( new PortView(PortView::INPUT, this, i) );
        _inputs[i]->setPos( QPointF( leftX(), inputsY() + i * portsSpacing() ) );
        ++i;
    }
    i = 0;
    for( auto it = nodeType()->outputs().begin(); it != nodeType()->outputs().end(); ++it )
    {
        _outputs.push_back( new PortView(PortView::OUTPUT, this, i) );
        _outputs[i]->setPos( QPointF( rightX(), outputsY() + i * portsSpacing() ) );
        ++i;
    }

    _dropShadow.setBlurRadius( 16 );
    _dropShadow.setXOffset( 0.0 );
    _dropShadow.setYOffset( 5.0 );
    setGraphicsEffect( &_dropShadow );

}
Exemple #15
0
void Swig_extend_merge(Node *cls, Node *am) {
  Node *n;
  Node *csym;

  n = firstChild(am);
  while (n) {
    String *symname;
    if (Strcmp(nodeType(n),"constructor") == 0) {
      symname = Getattr(n,"sym:name");
      if (symname) {
	if (Strcmp(symname,Getattr(n,"name")) == 0) {
	  /* If the name and the sym:name of a constructor are the same,
             then it hasn't been renamed.  However---the name of the class
             itself might have been renamed so we need to do a consistency
             check here */
	  if (Getattr(cls,"sym:name")) {
	    Setattr(n,"sym:name", Getattr(cls,"sym:name"));
	  }
	}
      } 
    }

    symname = Getattr(n,"sym:name");
    DohIncref(symname);
    if ((symname) && (!Getattr(n,"error"))) {
      /* Remove node from its symbol table */
      Swig_symbol_remove(n);
      csym = Swig_symbol_add(symname,n);
      if (csym != n) {
	/* Conflict with previous definition.  Nuke previous definition */
	String *e = NewStringEmpty();
	String *en = NewStringEmpty();
	String *ec = NewStringEmpty();
	Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
	Printf(en,"%%extend definition of '%s'.",symname);
	SWIG_WARN_NODE_BEGIN(n);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
	SWIG_WARN_NODE_END(n);
	Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, 
	       Getfile(n),Getline(n),en);
	Setattr(csym,"error",e);
	Delete(e);
	Delete(en);
	Delete(ec);
	Swig_symbol_remove(csym);              /* Remove class definition */
	Swig_symbol_add(symname,n);            /* Insert extend definition */
      }
    }
    n = nextSibling(n);
  }
}
Exemple #16
0
void Swig_print_tags(DOH *obj, DOH *root) {
  DOH *croot, *newroot;
  DOH *cobj;

  if (!root)
    croot = NewStringEmpty();
  else
    croot = root;

  while (obj) {
    Swig_diagnostic(Getfile(obj), Getline(obj), "%s . %s\n", croot, nodeType(obj));
    cobj = firstChild(obj);
    if (cobj) {
      newroot = NewStringf("%s . %s", croot, nodeType(obj));
      Swig_print_tags(cobj, newroot);
      Delete(newroot);
    }
    obj = nextSibling(obj);
  }
  if (!root)
    Delete(croot);
}
Exemple #17
0
void BytecodeGenerator::visitReturnNode(ReturnNode* node) {
    Bytecode* bc = _state.currentBcToFill();
    if(node->returnExpr() != 0) {
        node->returnExpr()->visit(this);
        VarType expectedRetType = _state.currentBcFun()->returnType();
        VarType actualRetType = nodeType(node->returnExpr());
        if(actualRetType != expectedRetType) {
            Instruction castInsn = actualRetType == VT_INT ? BC_I2D : BC_D2I;
            bc->addInsn(castInsn);
        }
    }
    bc->addInsn(BC_RETURN);
}
Exemple #18
0
const VrmlField *VrmlNodeTimesteps::getField(const char *fieldName) const
{
    if (strcmp(fieldName, "numTimesteps") == 0)
        return &d_numTimesteps;
    if (strcmp(fieldName, "enabled") == 0)
        return &d_enabled;
    else if (strcmp(fieldName, "loop") == 0)
        return &d_loop;
    else if (strcmp(fieldName, "fraction_changed") == 0)
        return &d_fraction_changed;
    else
        cerr << "Node does not have this eventOut or exposed field " << nodeType()->getName() << "::" << name() << "." << fieldName << endl;
    return 0;
}
Exemple #19
0
std::shared_ptr<cainteoir::document_reader>
cainteoir::createMimeInHtmlReader(std::shared_ptr<cainteoir::buffer> &aData,
                                  const rdf::uri &aSubject,
                                  rdf::graph &aPrimaryMetadata,
                                  const std::string &aTitle,
                                  const char *aDefaultEncoding)
{
	auto reader = cainteoir::createXmlReader(aData, aDefaultEncoding);
	reader->set_predefined_entities(xml::html_entities);

	const char *first = nullptr;
	const char *last  = nullptr;
	bool processing   = true;
	do switch (reader->nodeType())
	{
	case xml::reader::beginTagNode:
		if (!reader->nodeName().comparei("pre"))
			first = reader->current() + 1;
		break;
	case xml::reader::endTagNode:
		if (first && reader->nodeName().comparei("pre"))
			processing = false;
		break;
	case xml::reader::attribute:
	case xml::reader::commentNode:
		break;
	case xml::reader::textNode:
	case xml::reader::error: // email address as tag -- Joseph <*****@*****.**>
		last = reader->current();
		break;
	default:
		return std::shared_ptr<cainteoir::document_reader>();
	} while (processing && reader->read());

	if (!first || !last || last < first)
		return std::shared_ptr<cainteoir::document_reader>();

	uint32_t ch = 0;
	const char *next = first;
	while ((next = utf8::read(first, ch)) && ucd::isspace(ch))
		first = next;

	auto text = std::make_shared<buffer>(first, last);

	if (!mime::email.match(text) && !mime::mime.match(text))
		return std::shared_ptr<cainteoir::document_reader>();

	auto data = cainteoir::copy(*text, 0);
	return createMimeReader(data, aSubject, aPrimaryMetadata, aTitle);
}
Exemple #20
0
void Swig_extend_append_previous(Node *cls, Node *am) {
  Node *n, *ne;
  Node *pe = 0;
  Node *ae = 0;

  if (!am) return;
  
  n = firstChild(am);
  while (n) {
    ne = nextSibling(n);
    set_nextSibling(n,0);
    /* typemaps and fragments need to be prepended */
    if (((Cmp(nodeType(n),"typemap") == 0) || (Cmp(nodeType(n),"fragment") == 0)))  {
      if (!pe) pe = Swig_cparse_new_node("extend");
      appendChild(pe, n);
    } else {
      if (!ae) ae = Swig_cparse_new_node("extend");
      appendChild(ae, n);
    }    
    n = ne;
  }
  if (pe) prependChild(cls,pe);
  if (ae) appendChild(cls,ae);
}
Exemple #21
0
// unfortunately we get back all groups double wrapped, seems
// apple was preparing for something that never came, if that
// day does come this might need to go
void flatPackArray(lua_State* L, plist_t node, int depth)
{
  int i;
  if (nodeType(node) == PLIST_ARRAY)
  {
    for (i=0;i<groupSize(node);i++) 
    {
      flatPackArray(L, arrayElem(node, i), depth);
    }      
  }
  else
  {
    parseNode(L, node, depth);
  }
}
String *Swig_name_fulldecl(Node *n) {
  String *decl = Swig_name_decl(n);
  String *type = Getattr(n, "type");
  String *nodetype = nodeType(n);
  String *fulldecl;
  /* add on the return type */
  if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) {
    fulldecl = decl;
  } else {
    String *t = SwigType_str(type, 0);
    fulldecl = NewStringf("%s %s", t, decl);
    Delete(decl);
    Delete(t);
  }
  return fulldecl;
}
Exemple #23
0
char *getStringVal(plist_t dict, const char* key) 
{
  char* charVal = "";
  plist_t plistItem = dictEntry(dict, key);
  switch (nodeType(plistItem)) 
  {
    case PLIST_STRING:
      stringVal(plistItem,&charVal);
      break;
    default: // fall through to empty val.
    case PLIST_NONE:
      charVal = NULL;
      break;
  }
  return charVal;
}
Exemple #24
0
void BytecodeGenerator::visitCallNode(CallNode* node) {
    BytecodeFunction* funToCall = _state.bcFunByName(node->name());
    assert(funToCall);
    Bytecode* bc = _state.currentBcToFill();
    for(size_t i = node->parametersNumber(); i > 0; --i) {
        node->parameterAt(i - 1)->visit(this);
        VarType expectedArgType = funToCall->parameterType(i - 1);
        VarType actualArgType = nodeType(node->parameterAt(i - 1));
        if(actualArgType != expectedArgType) {
            Instruction castInsn = actualArgType == VT_INT ? BC_I2D : BC_D2I;
            bc->addInsn(castInsn);
        }
    }
    bc->addInsn(BC_CALL);
    bc->addInt16(funToCall->id());
}
Exemple #25
0
const VrmlField *VrmlNodeClippingPlane::getField(const char *fieldName) const
{
    if (strcmp(fieldName, "enabled") == 0)
        return &d_enabled;
    else if (strcmp(fieldName, "global") == 0)
        return &d_global;
    else if (strcmp(fieldName, "position") == 0)
        return &d_position;
    else if (strcmp(fieldName, "orientation") == 0)
        return &d_orientation;
    else if (strcmp(fieldName, "number") == 0)
        return &d_number;
    else
        cerr << "Node does not have this eventOut or exposed field " << nodeType()->getName() << "::" << name() << "." << fieldName << endl;
    return 0;
}
Exemple #26
0
void BytecodeGenerator::visitUnaryOpNode(UnaryOpNode* node) {
    node->operand()->visit(this);
    Bytecode* bc = _state.currentBcToFill();
    TokenKind unOp = node->kind();
    VarType operandType = nodeType(node->operand());
    if(unOp == tSUB) {
        Instruction bcNeg = operandType == VT_INT ? BC_INEG : BC_DNEG;
        bc->addInsn(bcNeg);
    } else if (unOp == tNOT) {
        genNotBc(bc);
    } else if (unOp == tADD) {
        // unary '+' has no effect
    } else {
        throw ExceptionWithPos(invalidUnaryOperatorMsg(unOp), node->position());
    }
}
Exemple #27
0
void
Swig_print_node(Node *obj) {
  Iterator ki;
  Node   *cobj;
  
  print_indent(0);
  Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj));
  ki = First(obj);
  while (ki.key) {
    String *k = ki.key;
    if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
	(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
	(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
      /* Do nothing */
    } else if (Cmp(k,"parms") == 0) {
      print_indent(2);
      Printf(stdout,"%-12s - %s\n", k, ParmList_protostr(Getattr(obj,k)));
    } else {
      DOH *o;
      char *trunc = "";
      print_indent(2);
      if (DohIsString(Getattr(obj,k))) {
	o = Str(Getattr(obj,k));
	if (Len(o) > 40) {
	  trunc = "...";
	}
	Printf(stdout,"%-12s - \"%(escape)-0.40s%s\"\n", k, o, trunc);
	Delete(o);
      } else {
	Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k));
      }
    }
    ki = Next(ki);
  }
  cobj = firstChild(obj);
  if (cobj) {
    indent_level += 6;
    Printf(stdout,"\n");
    Swig_print_tree(cobj);
    indent_level -= 6;
  } else {
    print_indent(1);
    Printf(stdout,"\n");
  }
}
Exemple #28
0
void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcStyleBehavior)
{
    String oldData = m_data;
    m_data = newData;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalcStyleBehavior);

    if (nodeType() == PROCESSING_INSTRUCTION_NODE)
        toProcessingInstruction(this)->checkStyleSheet();

    if (document().frame())
        document().frame()->selection().didUpdateCharacterData(this, offsetOfReplacedData, oldLength, newLength);

    document().incDOMTreeVersion();
    didModifyData(oldData);
}
MStatus uninitializePlugin( MObject obj)
//
//	Description:
//		this method is called when the plug-in is unloaded from Maya. It
//		deregisters all of the services that it was providing.
//
//	Arguments:
//		obj - a handle to the plug-in object (use MFnPlugin to access it)
//
{
	MStatus   status;
	MFnPlugin plugin( obj );

	// Deregister our node types.
	//
	CHECK_MSTATUS( plugin.deregisterCommand( "dx11Shader" ) );
	CHECK_MSTATUS( plugin.deregisterNode( dx11ShaderNode::typeId() ));
    CHECK_MSTATUS( plugin.deregisterNode( dx11ConeAngleToHotspotConverter::typeId() ));

	// Deregister the shader override
	//
	CHECK_MSTATUS(
		MHWRender::MDrawRegistry::deregisterShaderOverrideCreator(
			"drawdb/shader/surface/dx11Shader",
			sDX11ShaderRegistrantId));

	// Deregister the vertex mutators
	//
	CHECK_MSTATUS(MHWRender::MDrawRegistry::deregisterIndexBufferMutator("PNAEN18"));
	CHECK_MSTATUS(MHWRender::MDrawRegistry::deregisterIndexBufferMutator("PNAEN9"));

	// Remove user pref UI:
	MGlobal::executeCommandOnIdle("dx11ShaderDeleteUI");
	
	// Deregister dx11Shader from filePathEditor
	status = MGlobal::executeCommand("filePathEditor -deregisterType \"dx11Shader.shader\" -temporary");
    if (!status) {
		MString nodeType("dx11Shader.shader");
		MString errorString = dx11ShaderStrings::getString( dx11ShaderStrings::kErrorDeregisterNodeType, nodeType );
		MGlobal::displayWarning( errorString );
    }

	return MStatus::kSuccess;
}
Exemple #30
0
CMNet* myCreateDiscreteMNet()
{
    const int numOfNds = 4;
    const int numOfNodeTypes = 1;
    const int numOfClqs = 4;

    intVector clqSizes( numOfClqs, 2 );

    int clq0[] = { 0, 1 };
    int clq1[] = { 1, 2 };
    int clq2[] = { 2, 3 };
    int clq3[] = { 3, 0 };

    const int *clqs[] = { clq0, clq1, clq2, clq3 };

    CNodeType nodeType( 1, 2 );

    intVector nodeAssociation( numOfNds, 0 );

    CMNet *pMNet = CMNet::Create( numOfNds, numOfNodeTypes, &nodeType,
	&nodeAssociation.front(), numOfClqs, &clqSizes.front(), clqs );

    pMNet->AllocFactors();

    float data0[]  = { 0.79f, 0.21f, 0.65f, 0.35f };
    float data1[]  = { 0.91f, 0.09f, 0.22f, 0.78f };
    float data2[]  = { 0.45f, 0.55f, 0.24f, 0.76f };
    float data3[]  = { 0.51f, 0.49f, 0.29f, 0.71f };

    float *data[] = { data0, data1, data2, data3 };

    int i = 0;

    for( ; i < numOfClqs; ++i )
    {
	pMNet->AllocFactor(i);

	pMNet->GetFactor(i)->AllocMatrix( data[i], matTable );
    }

    return pMNet;
}