Beispiel #1
0
//arg1: number of nodes to add; arg2: 9 digit seed for RNG
int main(int argc, char **argv)
{
	nodes = atoi(argv[1]);
	seed = atof(argv[2]);
	eligible = (int *)malloc(nodes*sizeof(int));
	memset(eligible, 0, nodes*sizeof(int));

	init();

	//determine how many additional connections each node needs
	for(int i = 0; i < nodes; i++)
		eligible[i] = (int) round(power_rng(&seed, alpha, min, max));

	//add those connections as necessary
	for(int i = 0; i < nodes; i++)
	{
		if(eligible[i] > 0)
			addConnections(i, eligible[i]);
	}

	writeOutput();

	cleanup();

	return EXIT_SUCCESS;
}
void ShadingNetworkExporter::createEntity()
{
    MString name = appleseedName() + MString("_shader_group");
    m_shaderGroup = asr::ShaderGroupFactory::create(name.asChar());

    m_shadersExported.clear();
    createShader(node());

    m_shadersExported.clear();
    addConnections(node());
}
Beispiel #3
0
// Create a new empty graph (for a map)
// #Vertices always same as NUM_PLACES
Map newMap()
{
   int i;
   Map g = malloc(sizeof(struct MapRep));
   assert(g != NULL);
   g->nV = NUM_MAP_LOCATIONS;
   for (i = 0; i < g->nV; i++){
      g->connections[i] = NULL;
   }
   g->nE = 0;
   addConnections(g);
   return g;
}
Beispiel #4
0
NeuralNet* Dummy::neuralNet(ParametersMap* parametersMap, Interface* input)
{
    BufferType bufferType = (BufferType) (parametersMap->getNumber(Enumerations::enumTypeToString(ET_BUFFER)));
    ImplementationType implementationType = (ImplementationType) (parametersMap->getNumber(
            Enumerations::enumTypeToString(ET_IMPLEMENTATION)));
    FunctionType functionType = (FunctionType) (parametersMap->getNumber(
            Enumerations::enumTypeToString(ET_FUNCTION)));

    unsigned size = (unsigned) (parametersMap->getNumber(Dummy::SIZE));
    unsigned numInputs = (unsigned) (parametersMap->getNumber(Dummy::NUM_INPUTS));
    unsigned numLayers = parametersMap->getNumber(Dummy::NUM_LAYERS);

    NeuralNet* net = new NeuralNet(implementationType);

    addConnections(net, input, numInputs, numLayers, size, bufferType, functionType);

    return net;
}
Beispiel #5
0
Individual* Dummy::individual(ParametersMap* parametersMap, Interface* input)
{
    BufferType bufferType = (BufferType) (parametersMap->getNumber(Enumerations::enumTypeToString(ET_BUFFER)));
    ImplementationType implementationType = (ImplementationType) (parametersMap->getNumber(
            Enumerations::enumTypeToString(ET_IMPLEMENTATION)));
    FunctionType functionType = (FunctionType) (parametersMap->getNumber(
            Enumerations::enumTypeToString(ET_FUNCTION)));

    unsigned size = (unsigned) (parametersMap->getNumber(Dummy::SIZE));
    unsigned numInputs = (unsigned) (parametersMap->getNumber(Dummy::NUM_INPUTS));
    unsigned numLayers = parametersMap->getNumber(Dummy::NUM_LAYERS);

    Individual* individual = new Individual(implementationType);
    individual->setFitness(1);

    addConnections(individual, input, numInputs, numLayers, size, bufferType, functionType);

    return individual;
}
void ShadingNetworkExporter::addConnections(const MObject& node)
{
    MStatus status;
    MFnDependencyNode depNodeFn(node);

    const OSLShaderInfo *shaderInfo =
        ShadingNodeRegistry::getShaderInfo(depNodeFn.typeName());

    if(!shaderInfo)
    {
        std::cout << "Skipping unsupported shader: " << depNodeFn.typeName() << "\n";
        return;
    }

    if(m_shadersExported.count(depNodeFn.name()) != 0)
    {
        std::cout << "Skipping already exported shader: " << depNodeFn.name() << "\n";
        return;
    }

    m_shadersExported.insert(depNodeFn.name());

    for(int i = 0, e = shaderInfo->paramInfo.size(); i < e; ++i)
    {
        const OSLParamInfo& paramInfo = shaderInfo->paramInfo[i];

        // Skip output attributes.
        if(paramInfo.isOutput)
            continue;

        MPlug plug = depNodeFn.findPlug(paramInfo.mayaAttributeName, &status);
        if(!status)
        {
            std::cout << "Skipping unknown attribute: "
                        << paramInfo.mayaAttributeName << std::endl;
            continue;
        }

        if(plug.isConnected())
        {
            MPlug srcPlug;
            if(AttributeUtils::getPlugConnectedTo(plug, srcPlug))
            {
                MFnDependencyNode srcDepNodeFn(srcPlug.node());

                const OSLShaderInfo *srcShaderInfo =
                    ShadingNodeRegistry::getShaderInfo(srcDepNodeFn.typeName());

                if(!srcShaderInfo)
                    continue;

                if(const OSLParamInfo *srcParamInfo = srcShaderInfo->findParam(srcPlug.name()))
                {
                    m_shaderGroup->add_connection(
                        srcDepNodeFn.name().asChar(),
                        srcParamInfo->paramName.asChar(),
                        depNodeFn.name().asChar(),
                        paramInfo.paramName.asChar());
                }

                addConnections(srcPlug.node());
            }
        }

        if(plug.isCompound() && plug.numConnectedChildren() != 0)
        {
            // ???
        }

        if(plug.isArray() && plug.numConnectedElements() != 0)
        {
            // ???
        }
    }
}
Beispiel #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    debug("Entering MainWindow constructor", __FILE__, __LINE__);

    m_pInstance = this;

    QTextCodec *utf8Codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForTr(utf8Codec);
    QTextCodec::setCodecForCStrings(utf8Codec);
    QTextCodec::setCodecForLocale(utf8Codec);

    ui->setupUi(this);

    // Check single instance

    // Show splash screen

    // Load program settings
    loadSettings();
    debug("Program settings loaded.", __FILE__, __LINE__);

    if (m_settingsInterfaceName.length() <= 0)
    {
        debug("Can't read settings. I'll try to use virtual interface", __FILE__, __LINE__);
        m_settingsInterfaceName = "virtual";
    }

    // Check serial key

    // Check for updates

    // Add menu and toolbar connections
    addConnections();

    // Create a new empty document by default
    // m_pDoc = new Document(this);
    m_pDoc = new Document();
    debug("New empty document created.", __FILE__, __LINE__);

    // Create lok tab bar (where all lokos are shown)

    m_pLokoTabBar = new LokoTabBar(this);
    debug("New Loko Tab Bar created.", __FILE__, __LINE__);

    // QMessageBox::information(this, "Error", "Could not load the plugin");

    // this->setCentralWidget(ui->graphicsView);

    m_pView = ui->graphicsView;

    m_printer = new QPrinter( QPrinter::HighResolution );

    // doc->setModified();

    showEditToolbars(false);

    // Use virtual plugin
    useInterface(m_settingsInterfaceName);

    if (g_interface == NULL)
    {
        // can't load m_settingsInterfaceName... try just loading virtual interface
        useInterface("virtual");
    }

    debug("Starting feedback modules thread", __FILE__, __LINE__);
    startReadingFeedbackModules();

    // create some testing lokos
    createTestLokos();
    debug("Test lokos created.", __FILE__, __LINE__);

    debug("MainWindow::MainWindow() finished", __FILE__, __LINE__);

}