Beispiel #1
0
bool VisualManagerPass::drawScene(VisualParams* vp)
{
    if(!multiPassEnabled)
        return false;

    if(renderToScreen.getValue())
    {
        glViewport(0,0,passWidth,passHeight);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glEnable(GL_DEPTH_BUFFER_BIT);

        //render opaque meshes
        vp->pass() = sofa::core::visual::VisualParams::Std;
        VisualDrawVisitor act ( vp );
        act.setTags(this->getTags());
        act.execute ( getContext() );

        //render transparent meshes
        vp->pass() = sofa::core::visual::VisualParams::Transparent;
        VisualDrawVisitor act2 ( vp );
        act2.setTags(this->getTags());
        act2.execute ( getContext() );

        return true;
    }
    else
        return false;
}
Beispiel #2
0
/*==============================================================================
 * FUNCTION:		RtlTest::testClone
 * OVERVIEW:		Test constructor from list of expressions; cloning of RTLs
 *============================================================================*/
void RtlTest::testClone () {
	Assign* a1 = new Assign(
			Location::regOf(8),
			new Binary(opPlus,
				Location::regOf(9),
				new Const(99)));
	Assign* a2 = new Assign(new IntegerType(16),
			new Location(opParam, new Const("x"), NULL),
			new Location(opParam, new Const("y"), NULL));
	std::list<Statement*> ls;
	ls.push_back(a1);
	ls.push_back(a2);
	RTL* r = new RTL(0x1234, &ls);
	RTL* r2 = r->clone();
	std::ostringstream o1, o2;
	r->print(o1);
	delete r;			// And r2 should still stand!
	r2->print(o2);
	delete r2;
	std::string expected("00001234    0 *v* r8 := r9 + 99\n"
						 "            0 *j16* x := y\n");

	std::string act1(o1.str());
	std::string act2(o2.str());
	CPPUNIT_ASSERT_EQUAL(expected, act1);
	CPPUNIT_ASSERT_EQUAL(expected, act2);
}
Beispiel #3
0
void VisualManagerPass::preDrawScene(VisualParams* vp)
{
    if(renderToScreen.getValue() || (!multiPassEnabled))
        return;

    //const VisualParams::Viewport& viewport = vp->viewport();
    fbo->setSize(passWidth, passHeight);
    fbo->start();

    glViewport(0,0,passWidth,passHeight);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glEnable(GL_DEPTH_BUFFER_BIT);

    //render opaque meshes
    vp->pass() = sofa::core::visual::VisualParams::Std;
    VisualDrawVisitor act ( vp );
    act.setTags(this->getTags());
    act.execute ( getContext() );
    //render transparent meshes
    vp->pass() = sofa::core::visual::VisualParams::Transparent;
    VisualDrawVisitor act2 ( vp );
    act2.setTags(this->getTags());
    act2.execute ( getContext() );

    fbo->stop();
    prerendered=true;
}
Beispiel #4
0
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos)
{
    Q_UNUSED(pos)

    QMenu menu;
    menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage()));
    menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
    menu.addAction(qIconProvider->fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager()));
    menu.addSeparator();
    QAction act(tr("Show Most &Visited"), this);
    act.setCheckable(true);
    act.setChecked(m_bookmarksModel->isShowingMostVisited());
    connect(&act, SIGNAL(triggered()), this, SLOT(showMostVisited()));
    menu.addAction(&act);
    QAction act2(tr("Show Only Icons"), this);
    act2.setCheckable(true);
    act2.setChecked(m_bookmarksModel->isShowingOnlyIconsInToolbar());
    connect(&act2, SIGNAL(triggered()), this, SLOT(toggleShowOnlyIcons()));
    menu.addAction(&act2);
    menu.addSeparator();
    menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel()));

    //Prevent choosing first option with double rightclick
    QPoint position = mapToGlobal(pos);
    QPoint p(position.x(), position.y() + 1);
    menu.exec(p);
}
void display()
{
	switch(num)
	{
		case 1:act1();break;
		case 2:act2();break;
		
	}

}
void DefaultVisualManagerLoop::drawStep(sofa::core::visual::VisualParams* vparams)
{
    if ( !gRoot ) return;
    if (gRoot->visualManager.empty())
    {
        vparams->pass() = sofa::core::visual::VisualParams::Std;
        VisualDrawVisitor act ( vparams );
        act.setTags(this->getTags());
        gRoot->execute ( &act );
        vparams->pass() = sofa::core::visual::VisualParams::Transparent;
        VisualDrawVisitor act2 ( vparams );
        act2.setTags(this->getTags());
        gRoot->execute ( &act2 );
    }
    else
    {
        Node::Sequence<core::visual::VisualManager>::iterator begin = gRoot->visualManager.begin(), end = gRoot->visualManager.end(), it;
        for (it = begin; it != end; ++it)
            (*it)->preDrawScene(vparams);
        bool rendered = false; // true if a manager did the rendering
        for (it = begin; it != end; ++it)
            if ((*it)->drawScene(vparams))
            {
                rendered = true;
                break;
            }
        if (!rendered) // do the rendering
        {
            vparams->pass() = sofa::core::visual::VisualParams::Std;

            VisualDrawVisitor act ( vparams );
            act.setTags(this->getTags());
            gRoot->execute ( &act );
            vparams->pass() = sofa::core::visual::VisualParams::Transparent;
            VisualDrawVisitor act2 ( vparams );
            act2.setTags(this->getTags());
            gRoot->execute ( &act2 );
        }
        Node::Sequence<core::visual::VisualManager>::reverse_iterator rbegin = gRoot->visualManager.rbegin(), rend = gRoot->visualManager.rend(), rit;
        for (rit = rbegin; rit != rend; ++rit)
            (*rit)->postDrawScene(vparams);
    }
}
Beispiel #7
0
int hpx_main()
{
    {
        tuple_type t(42, 3.14, "test");

        worker1_action act1;
        act1(hpx::find_here(), t);

        worker1_ref_action act2;
        act2(hpx::find_here(), t);
    }
    {
        tuple_base_type t(42, 3.14, "test");

        worker2_action act1;
        act1(hpx::find_here(), t);

        worker2_ref_action act2;
        act2(hpx::find_here(), t);
    }

    return hpx::finalize();
}
Beispiel #8
0
int main( int argc, char** argv ) {

  boost::cmt::thread* at = boost::cmt::thread::create( "actor_thread" );
  boost::reflect::any_ptr<calculator> ap( boost::make_shared<calculator>() );
  boost::cmt::actor<calculator> act( boost::make_shared<calculator>(), at );
  boost::cmt::actor<calculator> act2(ap, at );

  boost::cmt::thread* tt = boost::cmt::thread::create( "test_thread" );
  tt->async<void>( boost::bind(test, act) ).wait();
  tt->async<void>( boost::bind(test, act2) ).wait();
  at->async<void>( boost::bind(test, act2) ).wait();

  //test(act);
  test(act2);

  tt->quit();
  at->quit();

  return 0;
}
Beispiel #9
0
int main( int argc, char** argv ) {

  mace::cmt::thread* at = mace::cmt::thread::create( "actor_thread" );
  mace::stub::ptr<calculator> ap( std::make_shared<calculator>() );
  mace::cmt::actor<calculator> act( std::make_shared<calculator>(), at );
  mace::cmt::actor<calculator> act2(ap, at );

  mace::cmt::thread* tt = mace::cmt::thread::create( "test_thread" );
  tt->async( boost::bind(test, act) ).wait();
  tt->async( boost::bind(test, act2) ).wait();
  at->async( boost::bind(test, act2) ).wait();

  //test(act);
  test(act2);
  mace::cmt::usleep(100000);

  tt->quit();
  at->quit();

  return 0;
}
Beispiel #10
0
int main (int argc, char **argv) {
	ImageDataset d;
	d.loadImagesFromFile("train-images-idx3-ubyte");
	d.loadLabelsFromFile("train-labels-idx1-ubyte");
	std::shared_ptr<clneural::ActivationFunction> act(new clneural::SigmoidActivationFunction());
	std::shared_ptr<clneural::ActivationFunction> act2(new clneural::LinearActivationFunction());
	std::vector<std::list<unsigned int>> C1_connections(6, std::list<unsigned int>({0}));
	clneural::ConvolutionalLayer::Dimension C1_input;
	clneural::ConvolutionalLayer::Dimension C1_filter;
	float training_speed = 0.7f;
	C1_input.width = 32;
	C1_input.height = 32;
	C1_filter.width = 5;
	C1_filter.height = 5;
	std::shared_ptr<clneural::NeuralNetworkLayer> C1(new clneural::ConvolutionalLayer(C1_input, C1_filter, C1_connections, act, training_speed));
	clneural::SubsamplingLayer::Dimension S2_input;
	clneural::SubsamplingLayer::Dimension S2_filter;
	S2_input.width = 28;
	S2_input.height = 28;
	S2_filter.width = 2;
	S2_filter.height = 2;
	std::shared_ptr<clneural::NeuralNetworkLayer> S2(new clneural::SubsamplingLayer(S2_input, S2_filter, 6, act2, training_speed));
	std::vector<std::list<unsigned int>> C3_connections(16);
	C3_connections[0] = std::list<unsigned int>({0,1,2});
	C3_connections[1] = std::list<unsigned int>({1,2,3});
	C3_connections[2] = std::list<unsigned int>({2,3,4});
	C3_connections[3] = std::list<unsigned int>({3,4,5});
	C3_connections[4] = std::list<unsigned int>({4,5,0});
	C3_connections[5] = std::list<unsigned int>({5,0,1});
	C3_connections[6] = std::list<unsigned int>({0,1,2,3});
	C3_connections[7] = std::list<unsigned int>({1,2,3,4});
	C3_connections[8] = std::list<unsigned int>({2,3,4,5});
	C3_connections[9] = std::list<unsigned int>({3,4,5,0});
	C3_connections[10] = std::list<unsigned int>({4,5,0,1});
	C3_connections[11] = std::list<unsigned int>({5,0,1,2});
	C3_connections[12] = std::list<unsigned int>({0,1,3,4});
	C3_connections[13] = std::list<unsigned int>({1,2,4,5});
	C3_connections[14] = std::list<unsigned int>({0,2,3,5});
	C3_connections[15] = std::list<unsigned int>({0,1,2,3,4,5});
	clneural::ConvolutionalLayer::Dimension C3_input;
	clneural::ConvolutionalLayer::Dimension C3_filter;
	C3_input.width = 14;
	C3_input.height = 14;
	C3_filter.width = 5;
	C3_filter.height = 5;
	std::shared_ptr<clneural::NeuralNetworkLayer> C3(new clneural::ConvolutionalLayer(C3_input, C3_filter, C3_connections, act, training_speed));
	clneural::SubsamplingLayer::Dimension S4_input;
	clneural::SubsamplingLayer::Dimension S4_filter;
	S4_input.width = 10;
	S4_input.height = 10;
	S4_filter.width = 2;
	S4_filter.height = 2;
	std::shared_ptr<clneural::NeuralNetworkLayer> S4(new clneural::SubsamplingLayer(S4_input, S4_filter, 16, act2, training_speed));
	std::shared_ptr<clneural::NeuralNetworkLayer> N1(new clneural::FullFeedforwardLayer(400, 84, act, training_speed));
	std::shared_ptr<clneural::NeuralNetworkLayer> N2(new clneural::FullFeedforwardLayer(84, 10, act, training_speed));
	clneural::NeuralNetwork n;
	n.addLayer(C1);
	n.addLayer(S2);
	n.addLayer(C3);
	n.addLayer(S4);
	n.addLayer(N1);
	n.addLayer(N2);


	std::shared_ptr<OpenCLInterface> ocl = OpenCLInterface::getInstance();
	ocl->initialize(CL_DEVICE_TYPE_CPU);

	float dist = 0.0f;
	for (unsigned int i = 0; i < 60000; i++) {
		std::pair<std::vector<float>, uint8_t> trainelem = d.popRandomElementWithLabel();
		std::vector<float> desired(10, 0.0f);
		desired[trainelem.second] = 1.0f;
		dist += n.trainNetwork(trainelem.first, desired);
		std::vector<float> nout = n.getLastOutput();
		if ((i % 1000) == 0) {
			std::cout << "TIME: " << ((float) clock())/CLOCKS_PER_SEC << ", STEP:" << (i + 1) << ", MDIST: " << dist/1000.0f << ", OUT: (" << nout[0];
			for (unsigned int j = 1; j < nout.size(); j++) std::cout << "," << nout[j];
			std::cout << "), DESIRED: (" << desired[0];
			for (unsigned int j = 1; j < desired.size(); j++) std::cout << "," << desired[j];
			std::cout << ")" << std::endl;
			dist = 0.0f;
		}
	}
	n.saveToFile("conv_images1.net");
	verifyNetwork(n);
	return 0;
}
Beispiel #11
0
void do_scan(CHAR_DATA *ch, char *argument)
{
   extern char *const dir_name[];
   char arg1[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
   ROOM_INDEX_DATA *scan_room;
   EXIT_DATA *pExit;
   sh_int door, depth, outlet;

   argument = one_argument(argument, arg1);

    if (IS_AFFECTED(ch,AFF_BLIND))
    {
        send_to_char("Maybe it would help if you could see?\n\r",ch);
        return;
    }

   if (arg1[0] == '\0')
   {
      act2("$n looks all around.", ch, NULL, NULL, TO_ROOM, ACTION_MUST_SEE);
      send_to_char("Looking around you see:\n\r", ch);
                scan_list(ch->in_room, ch, 0, -1);

      for (door=0;door<6;door++)
      {
	 outlet = door;
	 if ( ( ch->alignment < 0 )
	 && (pExit = ch ->in_room->exit[door+6]) != NULL)
	     outlet += 6;
         if ((pExit = ch ->in_room->exit[outlet]) != NULL)
            scan_list(pExit->u1.to_room, ch, 1, outlet);
      }
      return;
   }
   else if (!str_cmp(arg1, "n") || !str_cmp(arg1, "north")) door = 0;
   else if (!str_cmp(arg1, "e") || !str_cmp(arg1, "east"))  door = 1;
   else if (!str_cmp(arg1, "s") || !str_cmp(arg1, "south")) door = 2;
   else if (!str_cmp(arg1, "w") || !str_cmp(arg1, "west"))  door = 3;
   else if (!str_cmp(arg1, "u") || !str_cmp(arg1, "up" ))   door = 4;
   else if (!str_cmp(arg1, "d") || !str_cmp(arg1, "down"))  door = 5;
   else { send_to_char("Which way do you want to scan?\n\r", ch); return; }

   act("You peer intently $T.", ch, NULL, dir_name[door], TO_CHAR);
   act("$n peers intently $T.", ch, NULL, dir_name[door], TO_ROOM);
   sprintf(buf, "Looking %s you see:\n\r", dir_name[door]);
                                                                                  
   scan_room = ch->in_room;

   for (depth = 1; depth < 4; depth++)
   {
      outlet = door;
      if (scan_room == NULL) return;
      if ( ( ch->alignment < 0 )
      && ((pExit = scan_room->exit[outlet+6]) != NULL))
      {
	scan_room = pExit->u1.to_room;
	scan_list(pExit->u1.to_room, ch, depth, outlet+6);
      }
      else if ((pExit = scan_room->exit[outlet]) != NULL)
      {
         scan_room = pExit->u1.to_room;
         scan_list(pExit->u1.to_room, ch, depth, outlet);
      }
   }
   return;
}