示例#1
0
std::vector<Vendor> VendorDAOMySQL::findVendorByName(const std::string &name)
{
    MySQLManager::ConnectionHolder ch(MySQLManager::getInstance());
    std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(FIND_VENDOR_BY_NAME));

    ps->setString(1, "%" + name + "%");

    std::unique_ptr<sql::ResultSet> res(ps->executeQuery());

    std::vector<Vendor> vendors;
    while(res->next())
    {
        vendors.push_back(Vendor(res->getInt(1), res->getString(2)));
    }

    return vendors;
}
示例#2
0
 void w_validate_buffer(window* pw, int view_w, int view_h)
 {
   if(pw->dirty_area.is_valid())
   {
     WINDOW_ON_PAINT_PARAMS p;
     paint_graphics ps(pw->buffer, pw->dirty_area.x1, pw->dirty_area.y1, pw->dirty_area.x2, pw->dirty_area.y2 );
     p.clip_x = pw->dirty_area.x1;
     p.clip_y = pw->dirty_area.y1;
     p.clip_w = pw->dirty_area.x2 - pw->dirty_area.x1;
     p.clip_h = pw->dirty_area.y2 - pw->dirty_area.y1;
     p.view_w = view_w;
     p.view_h = view_h;
     p.surface = &ps; 
     pw->notify(WINDOW_ON_PAINT, &p);
     pw->dirty_area = agg::rect_i(1,1,0,0);
   }
 }
示例#3
0
void Network::handlePluckerMessage(const osc::ReceivedMessage& m,
                                   const IpEndpointName& remoteEndpoint)
{
  // Utility data structures
  char buffer[1024];
  osc::OutboundPacketStream ps(buffer, 1024);

  // Parse OSC message
  osc::Symbol uuid;
  m.ArgumentStream() >> uuid >> osc::EndMessage;
  std::cerr << uuid << std::endl;

  WidgetMap* widgets = Widget::getAll();
  WidgetMap::iterator wit = widgets->find(std::string(uuid));
  if (wit != widgets->end() && dynamic_cast<Track*>(wit->second))
    ((Track*)wit->second)->addPlucker();
}
示例#4
0
void Function::Compile( sqlite3_context* ctx )
{
	Parser ps( mVM, mText );	

	if( ps.mErr.size() )
	{
		mCompiled = false;
		
		vector<char> buf;
		ConvertToUTF8( ps.mErr, buf );
		sqlite3_result_error( ctx, &buf[ 0 ], buf.size() - 1 );
	}
	else
	{
		mCompiled = true;
	}
}
示例#5
0
void Network::handleObjectPadTextMessage(const osc::ReceivedMessage& m,
                                         const IpEndpointName& remoteEndpoint)
{
  // Utility data structures
  char buffer[1024];
  osc::OutboundPacketStream ps(buffer, 1024);

  // Parse OSC message
  osc::Symbol uuid, text;
  m.ArgumentStream() >> uuid >> text >> osc::EndMessage;
  std::cerr << uuid << ", " << text << std::endl;

  WidgetMap* widgets = Widget::getAll();
  WidgetMap::iterator wit = widgets->find(std::string(uuid));
  if (wit != widgets->end() && dynamic_cast<RoundPad*>(wit->second))
    ((RoundPad*)wit->second)->setCommentText(std::string(text));
}
示例#6
0
std::vector<Inventory> InventoryDAOMySQL::searchInventoryByGtin(const int &userId, const std::string &gtin)
{
    MySQLManager::ConnectionHolder ch(MySQLManager::getInstance());
    std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(INVENTORIES_SEARCH_GTIN));

    ps->setInt(1, userId);
    ps->setString(2, "%" + gtin + "%");

    std::unique_ptr<sql::ResultSet> res(ps->executeQuery());

    std::vector<Inventory> inventories;
    while(res->next())
    {
        inventories.push_back(Inventory(res->getInt(1), res->getInt(2), res->getInt(3), res->getString(4)));
    }
    return inventories;
}
示例#7
0
void MergeGraphOp::setParams(const std::string params)
{
    ParamSet ps(params);   

    ps("color_is_vector", _color_is_vector);
    ps("secondary_color_is_vector", _secondary_color_is_vector);
    ps("texcoord_is_vector", _texcoord0_is_vector);
    ps("texcoord0_is_vector", _texcoord0_is_vector);
    ps("texcoord1_is_vector", _texcoord1_is_vector);
    ps("texcoord2_is_vector", _texcoord2_is_vector);
    ps("texcoord3_is_vector", _texcoord3_is_vector);

    std::string out = ps.getUnusedParams();
    if(out.length())
    {
        FWARNING(("MergeGraphOp doesn't have parameters '%s'.\n",
                out.c_str()));
    }
}
示例#8
0
HRESULT CFGFilterLAV::PropertyPageCallback(IBaseFilter* pBF)
{
    CheckPointer(pBF, E_POINTER);

    CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), AfxGetMyApp()->GetMainWnd());

    // Find out which internal filter we are opening the property page for
    CFGFilterLAV::LAVFILTER_TYPE LAVFilterType = CFGFilterLAV::INVALID;
    if (!CFGFilterLAV::IsInternalInstance(pBF, &LAVFilterType)) {
        return E_UNEXPECTED;
    }

    HRESULT hr = E_FAIL;
    if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
        ps.AddPages(pSPP, (LAVFilterType != CFGFilterLAV::AUDIO_DECODER) ? 1 : 2);
    }

    CComPtr<IPropertyPage> pPP = DEBUG_NEW CInternalPropertyPageTempl<CPinInfoWnd>(nullptr, &hr);
    ps.AddPage(pPP, pBF);

    if (ps.GetPageCount() > 1) {
        ps.DoModal();

        if (CComQIPtr<ILAVFSettings> pLAVFSettings = pBF) {
            CFGFilterLAVSplitterBase::Settings settings;
            if (settings.GetSettings(pLAVFSettings)) { // Get current settings from LAVSplitter
                settings.SaveSettings(); // Save them to the registry/ini
            }
        } else if (CComQIPtr<ILAVVideoSettings> pLAVVideoSettings = pBF) {
            CFGFilterLAVVideo::Settings settings;
            if (settings.GetSettings(pLAVVideoSettings)) { // Get current settings from LAVVideo
                settings.SaveSettings(); // Save them to the registry/ini
            }
        } else if (CComQIPtr<ILAVAudioSettings> pLAVAudioSettings = pBF) {
            CFGFilterLAVAudio::Settings settings;
            if (settings.GetSettings(pLAVAudioSettings)) { // Get current settings from LAVAudio
                settings.SaveSettings(); // Save them to the registry/ini
            }
        }

        hr = S_OK;
    }

    return hr;
}
示例#9
0
void CXGraphBitmap::Draw(CDCEx *pDC)
{
    if (!m_bVisible)
        return;

    CDCEx  dc;
    BITMAP bmp;
    CRect  bmpRect = m_clRect;

    if (m_bBorder)
    {
        CPenSelector ps(0, 1, pDC);
        pDC->Rectangle(m_clRect);
        bmpRect.DeflateRect (1,1,1,1);
    }

    if (pDC->m_bPrinting)
        pDC->AdjustRatio (bmpRect);

    m_pBitmap->GetBitmap(&bmp);

    dc.CreateCompatibleDC (pDC);

    CGdiObject* pOldObject = dc.SelectObject (m_pBitmap);

    pDC->StretchBlt(bmpRect.left, bmpRect.top, bmpRect.Width(), bmpRect.Height(), &dc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);

    dc.SelectObject (pOldObject);

    if (m_bSizing)
    {
        if (pDC->m_bPrinting)
        {
            CRect rect = m_Tracker.m_rect;
            pDC->AdjustRatio (m_Tracker.m_rect);
            m_Tracker.Draw (pDC);
            m_Tracker.m_rect = rect;
        }
        else
            m_Tracker.Draw (pDC);
    }



}
int main(int argc,char* argv[])
	{
	LidarProcessOctree lpo(argv[1],512*1024*1024);
	
	#if 1
	Misc::Timer t;
	{
	// BinaryPointSaver bps(argv[2]);
	PointCounter pc;
	lpo.processPoints(pc);
	std::cout<<pc.getNumPoints()<<std::endl;
	}
	t.elapse();
	std::cout<<"Done in "<<t.getTime()*1000.0<<" ms"<<std::endl;
	#elif 0
	PointSaver ps(argv[2]);
	Box box=Box::full;
	for(int i=0;i<2;++i)
		{
		box.min[i]=atof(argv[3+i]);
		box.max[i]=atof(argv[5+i]);
		}
	lpo.processPointsInBox(box,ps);
	#else
	PointCounter pc;
	Scalar radius=Scalar(0.1);
	PointDensityCalculator pdc(lpo,radius,4);
	#if 0
	Box box;
	box.min=Point(930,530,0);
	box.max=Point(970,570,100);
	lpo.processPointsInBox(box,pdc);
	#else
	// lpo.processPoints(pdc);
	lpo.processNodesPostfix(pdc);
	#endif
	
	std::cout<<"Number of processed points: "<<pdc.numPoints<<std::endl;
	std::cout<<"Total number of found neighbors: "<<pdc.totalNumNeighbors<<std::endl;
	std::cout<<"Total number of loaded octree nodes: "<<lpo.getNumSubdivideCalls()<<", "<<lpo.getNumLoadedNodes()<<std::endl;
	std::cout<<"Average point density in 1/m^3: "<<pdc.totalNumNeighbors/(pdc.numPoints*4.0/3.0*3.141592654*radius*radius*radius)<<std::endl;
	#endif
	
	return 0;
	}
示例#11
0
Eigen::MatrixXf
powerspectrum::from_pcm(const Eigen::VectorXf& pcm_samples)
{
    MINILOG(logTRACE) << "Powerspectrum computation. input samples="
            << pcm_samples.size();
    // check if inputs are sane
    if ((pcm_samples.size() < win_size) || (hop_size > win_size)) {
        return Eigen::MatrixXf(0, 0);
    }
    size_t frames = (pcm_samples.size() - (win_size-hop_size)) / hop_size;
    size_t freq_bins = win_size/2 + 1;

    // initialize power spectrum
    Eigen::MatrixXf ps(freq_bins, frames);

    // peak normalization value
    float pcm_scale = std::max(fabs(pcm_samples.minCoeff()),
            fabs(pcm_samples.maxCoeff()));

    // scale signal to 96db (16bit)
    pcm_scale =  std::pow(10.0f, 96.0f/20.0f) / pcm_scale;

    // compute the power spectrum
    for (size_t i = 0; i < frames; i++) {

        // fill pcm
        for (int j = 0; j < win_size; j++) {
            kiss_pcm[j] = pcm_samples(i*hop_size+j) * pcm_scale * win_funct(j);
        }

        // fft
        kiss_fftr(kiss_status, kiss_pcm, kiss_freq);

        // save powerspectrum frame
        Eigen::MatrixXf::ColXpr psc(ps.col(i));
        for (int j = 0; j < win_size/2+1; j++) {
            psc(j) =
                    std::pow(kiss_freq[j].r, 2) + std::pow(kiss_freq[j].i, 2);
        }
    }

    MINILOG(logTRACE) << "Powerspectrum finished. size=" << ps.rows() << "x"
            << ps.cols();
    return ps;
}
示例#12
0
void MapgenV7P::generateCaves(s16 max_stone_y, s16 large_cave_depth)
{
	if (max_stone_y < node_min.Y)
		return;

	PseudoRandom ps(blockseed + 21343);
	PseudoRandom ps2(blockseed + 1032);

	u32 large_caves_count = (node_max.Y <= large_cave_depth) ? ps.range(0, 2) : 0;

	for (u32 i = 0; i < small_caves_count + large_caves_count; i++) {
		CavesV6 cave(ndef, &gennotify, water_level, c_water_source, c_lava_source);

		bool large_cave = (i >= small_caves_count);
		cave.makeCave(vm, node_min, node_max, &ps, &ps2,
			large_cave, max_stone_y, heightmap);
	}
}
示例#13
0
文件: test.cpp 项目: wxwidget/cluster
using namespace cluster

int main(int argc, char* argv[])
{
  ClusterId num_clusters = 30;
  PointId num_points = 3000;
  Dimensions num_dimensions = 10;

  PointsSpace ps(num_points, num_dimensions);
  //std::cout << "PointSpace" << ps;

  Clusters clusters(num_clusters, ps);

  clusters.k_means();
  
  std::cout << clusters;

}
示例#14
0
void plLayerAnimation::Read(hsStream* s, hsResMgr* mgr)
{
    plLayerAnimationBase::Read(s, mgr);

    fTimeConvert.Read(s, mgr);  
    if (!(fTimeConvert.IsStopped()))
    {   
        plSynchEnabler ps(true);    // enable dirty tracking so that we send state about
                                    // the anim resetting to start now.
        fTimeConvert.SetCurrentAnimTime(0, true);
    }
    Eval(hsTimer::GetSysSeconds(),0,0);

    // add sdl modifier
    delete fLayerSDLMod;
    fLayerSDLMod = new plLayerSDLModifier;
    fLayerSDLMod->SetLayerAnimation(this);
}
示例#15
0
bool BuildAstTreeDepGraph ::
ProcessStmt( AstInterface &fa, const AstNodePtr& s)
{
   GraphAccessInterface::Node *n = graph->CreateNodeImpl(s, GetStmtDomain(s));
   StmtNodeInfo info(n,s);
   stmtNodes.PushFirst(info);
   for (StmtStackType::Iterator ps(stmtNodes); !ps.ReachEnd(); ++ps) {
        ComputeStmtDep((*ps), info, DEPTYPE_DATA | DEPTYPE_IO);
   }
   for ( StmtStackType::Iterator p(ctrlNodes); !p.ReachEnd(); ++p) {
      ComputeCtrlDep((*p), info);
   }
   for (StmtStackType::Iterator pg(gotoNodes); !pg.ReachEnd(); ++pg) {
        ComputeCtrlDep((*pg), info);
   }

   return ProcessAstTree::ProcessStmt(fa, s);
}
int test_file(const std::string & test_data_filepath,
        const std::string & label_prefix) {
    int fails = 0;
    std::vector<pstrudel::TreeShape>  trees;
    pstrudel::treeio::read_from_filepath(trees, test_data_filepath, "nexus");
    unsigned long tree_idx = 0;
    for (auto & tree : trees) {
        std::string label = label_prefix + ":" + std::to_string(tree_idx + 1);
        pstrudel::LineageThroughTimeProfileCalculator ltt_calc(tree);
        auto profiles = ltt_calc.build_lineage_splitting_time_profile();
        auto lst_profile = profiles.first;
        auto scaled_lst_profile = profiles.second;
        std::ostringstream o;
        TREE_WRITER.write(o, tree);
        o << "\n";
        assert(lst_profile.data_size() == scaled_lst_profile.data_size());
        auto rds = lst_profile.data_size();
        for (unsigned long idx = 0; idx < rds; ++idx) {
            o << std::fixed << std::setprecision(22) << lst_profile.raw_data(idx);
            o << "\t" << std::fixed << std::setprecision(22) << scaled_lst_profile.raw_data(idx);
            o << "\n";
        }
        colugo::Subprocess ps({"python", CHECK_SCRIPT, "-f", "newick", "-l", label});
        try {
            auto result = ps.communicate(o.str());
            if (ps.returncode() != 0) {
                std::cerr << "(test '" << label << "' returned error: " << ps.returncode() << ")\n";
                // TREE_WRITER.write(std::cerr, tree);
                // std::cerr << std::endl;
                std::cerr << result.first;
                std::cerr << result.second;
                fails += 1;
            // } else {
            //     std::cerr << result.second;
            }
        } catch (const colugo::SubprocessTimeOutException & e) {
            std::cerr << "(test '" << label << "' timed out)\n";
            exit(1);
        }
        ++tree_idx;
    }
    return fails;
}
示例#17
0
static void
path_cleanup( struct aa_rx_mp *mp, ompl::geometric::PathGeometric &path )
{
    amino::sgSpaceInformation::Ptr &si = mp->space_information;

    if( mp->simplify ) {
        ompl::geometric::PathSimplifier ps(si);
        int n = (int)path.getStateCount();
        path.interpolate(n*10);

        for( int i = 0; i < 10; i ++ ) {
            ps.reduceVertices(path);
            ps.collapseCloseVertices(path);
            ps.shortcutPath(path);
        }

        ps.smoothBSpline(path, 3, path.length()/100.0);
    }
}
示例#18
0
int main(int argc, char* argv[]) {

	if (argc != 2) {
		std::cout << "Invalid input fromt the command line argument.\n";
		return -1;
	}
	else {
		ProcessScheduler ps(argv[1]);
		
		if (!fileExists(ps.filename.c_str())) {
			std::cout << "File not found" << std::endl;
			return -1;
		}
		ps.readFile();
		ps.run();
	}

    return 0;
}
示例#19
0
int main(int argc, char **argv)
{

	symbol_table_t st;

	// add symbols to st;

	PRE_IN_FIX(st, "+", 130, 110);
	PRE_IN_FIX(st, "-", 130, 110);

	INFIX(st, "*", 120);
	INFIX(st, "/", 120);
	INFIX(st, "%", 120);

	INFIX(st, "|", 70);
	INFIX(st, "^", 80);
	INFIX(st, "&", 90);

	INFIX(st, "<<", 100);
	INFIX(st, ">>", 100);

	PREFIX(st, "~", 130);

	INFIX_R(st, "**", 140);

//	SYMBOL(st, "(", 150);
	// usage
	{
		//char line[500];
		if (argc != 2)
			return 1;
		char *line = argv[1];
		//while (fgets(line, sizeof(line), stdin)) {
			parse_state_t ps(st);
			symbol_base_t *root = ps.parse(line, strlen(line));
			printf ("%d\n", calc(root));

			delete root;
		//}
	}

	return 0;
}
示例#20
0
/*
 *  wr_string() writes a string to the operation screen at the location
 *  specified by col and row.  F_color is the color of the string
 *  and B_color is the color of the background. blinking should be BLINK
 *  if the string is to blink, and !BLINK if not. The last parameter is
 *  a pointer to the null-terminated string. wr_string goes to the next
 *  line if the current line is filled.
 *
 *  wr_string() was modified to support writing to graphics screen
 *  as well as text screen.  If graphics has not been initialized,
 *  writes messages to text screen.  Necessary in order to see any
 *  smx error messages that occur during initialization (these are
 *  usually insufficient resource errors -- for example, failure to
 *  create task due to lack of tcb's.
 */
void _cdecl wr_string(int col, int row, int F_color, int B_color,
                                         int blinking, const char *in_string)
{
#if (DEVICE_CONSOLE_OUT)

 #if (USES_UART)
   int   was_unlocked;
 #endif

   if (!crt_is_init) return;

 #if (USES_UART)
  #if (USE_COLOR == 0)
   F_color = WHITE;
   B_color = BLACK;
  #endif
   was_unlocked = !IS_LOCKED(self);
   LOCK(self);
   ANSI_GotoXY(row,col);
   ANSI_SetGMode(F_color+30);
   ANSI_SetGMode(B_color+40);
   if (blinking)
      ANSI_SetGMode(BLINK);
   ps(in_string);
   ANSI_ClrEndOfLine();
   if (was_unlocked) unlockx(self);
 #endif

 #if defined(PEG) && SMXPEG_CONSOLE_WINDOW
   //TODO:
 #endif

#else
   /* Avoid compiler warning about unused pars. */
   (void) col;
   (void) row;
   (void) F_color;
   (void) B_color;
   (void) blinking;
   (void) in_string;

#endif
}
void computeDB(const robot_model::RobotModelPtr &robot_model,
           unsigned int ns, unsigned int ne)
{
  planning_scene::PlanningScenePtr ps(new planning_scene::PlanningScene(robot_model));
  ompl_interface::OMPLInterface ompl_interface(robot_model);
  moveit_msgs::Constraints c = getConstraints();
  ompl_interface::ConstraintApproximationConstructionOptions opt;
  opt.state_space_parameterization = "PoseModel";
  opt.samples = ns;
  opt.edges_per_sample = ne;
  opt.explicit_motions = true;
  opt.max_edge_length = 0.2;
  opt.explicit_points_resolution = 0.05;
  opt.max_explicit_points = 10;

  ompl_interface.getConstraintsLibrary().addConstraintApproximation(c, "right_arm", ps, opt);
  ompl_interface.getConstraintsLibrary().saveConstraintApproximations("~/constraints_approximation_database");
  ROS_INFO("Done");
}
PropertyRecordPtr XmlPropertyReader::getPropertiesAsRecord(DOMElement *parent)
{
    PropertyRecordPtr ps(new PropertyRecord());

    DOMNodeList* propertyDefChildren = parent->getChildNodes();
    for (XMLSize_t childIdx = 0; childIdx < propertyDefChildren->getLength(); childIdx++)
    {
        DOMNode* curChild = propertyDefChildren->item(childIdx);
        if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
        {
            PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
            if (entry.first != "")
            {
                ps->setProperty(entry.first, entry.second);
            }
        }
    }
    return ps;
}
示例#23
0
LDAPExpr::LDAPExpr( const std::string &filter ) : d()
{
  ParseState ps(filter);
  try
  {
    LDAPExpr expr = ParseExpr(ps);

    if (!Trim(ps.rest()).empty())
    {
      ps.error(GARBAGE + " '" + ps.rest() + "'");
    }

    d = expr.d;
  }
  catch (const std::out_of_range&)
  {
    ps.error(EOS);
  }
}
示例#24
0
文件: ps.c 项目: 99years/plan9
void
main(int argc, char *argv[])
{
	int fd, i, tot, none = 1;
	Dir *dir, **mem;


	ARGBEGIN {
	case 'a':
		aflag++;
		break;
	case 'p':
		pflag++;
		break;
	case 'r':
		rflag++;
		break;
	} ARGEND;
	Binit(&bout, 1, OWRITE);
	if(chdir("/proc")==-1)
		error("/proc");
	fd=open(".", OREAD);
	if(fd<0)
		error("/proc");
	tot = dirreadall(fd, &dir);
	if(tot <= 0){
		fprint(2, "ps: empty directory /proc\n");
		exits("empty");
	}
	mem = malloc(tot*sizeof(Dir*));
	for(i=0; i<tot; i++)
		mem[i] = dir++;

	qsort(mem, tot, sizeof(Dir*), cmp);
	for(i=0; i<tot; i++){
		ps(mem[i]->name);
		none = 0;
	}

	if(none)
		error("no processes; bad #p");
	exits(0);
}
示例#25
0
void sMouseButton(GLFWwindow*, int32 button, int32 action, int32 mods)
{
	double xd, yd;
	glfwGetCursorPos(mainWindow, &xd, &yd);
	b2Vec2 ps((float32)xd, (float32)yd);

	// Use the mouse to move things around.
	if (button == GLFW_MOUSE_BUTTON_1)
	{
        //<##>
        //ps.Set(0, 0);
		b2Vec2 pw = g_camera.ConvertScreenToWorld(ps);
		if (action == GLFW_PRESS)
		{
			if (mods == GLFW_MOD_SHIFT)
			{
				test->ShiftMouseDown(pw);
			}
			else
			{
				test->MouseDown(pw);
			}
		}
		
		if (action == GLFW_RELEASE)
		{
			test->MouseUp(pw);
		}
	}
	else if (button == GLFW_MOUSE_BUTTON_2)
	{
		if (action == GLFW_PRESS)
		{	
			lastp = g_camera.ConvertScreenToWorld(ps);
			rightMouseDown = true;
		}

		if (action == GLFW_RELEASE)
		{
			rightMouseDown = false;
		}
	}
}
示例#26
0
void main( int argc, char ** argv )
{
   Environment env(argc, argv);
   WALBERLA_UNUSED(env);
   walberla::mpi::MPIManager::instance()->useWorldComm();

   //init domain partitioning
   auto forest = blockforest::createBlockForest( AABB(0,0,0,20,20,20), // simulation domain
                                                 Vector3<uint_t>(2,2,2), // blocks in each direction
                                                 Vector3<bool>(false, false, false) // periodicity
                                                 );
   domain::BlockForestDomain domain(forest);

   //init data structures
   data::ParticleStorage ps(100);

   //initialize particle
   auto uid = createSphere(ps, domain);
   WALBERLA_LOG_DEVEL_ON_ROOT("uid: " << uid);

   //init kernels
   mpi::ReduceProperty    RP;
   mpi::SyncNextNeighbors SNN;

   //sync
   SNN(ps, domain);

   auto pIt = ps.find(uid);
   if (pIt != ps.end())
   {
      pIt->getForceRef() += Vec3(real_c(walberla::mpi::MPIManager::instance()->rank()));
   }

   RP.operator()<ForceTorqueNotification>(ps);

   if (walberla::mpi::MPIManager::instance()->rank() == 0)
   {
      WALBERLA_CHECK_FLOAT_EQUAL( pIt->getForce(), Vec3(real_t(28)) );
   } else
   {
      WALBERLA_CHECK_FLOAT_EQUAL( pIt->getForce(), Vec3(real_t(walberla::mpi::MPIManager::instance()->rank())) );
   }
}
示例#27
0
int main(int argc, char* argv[])
{
    if (argc != 4) {
        std::cerr << "usage: remote_thr <connect-to> <message-size> "
                  << "<message-count>\n";
        return 1;
    }

    std::string const ep = argv[1];
    int message_size = std::atoi(argv[2]);
    int message_count = std::atoi(argv[3]);

    asio::io_service ios;
    asio::zmq::context ctx;

    asio::zmq::test::perf::pusher ps(ios, ctx, message_count, message_size, ep);

    ios.run();
}
bool move_group::MoveGroupPickPlaceAction::planUsingPickPlacePlace(const moveit_msgs::PlaceGoal& goal,
                                                                   moveit_msgs::PlaceResult* action_res,
                                                                   plan_execution::ExecutableMotionPlan& plan)
{
  setPlaceState(PLANNING);

  planning_scene_monitor::LockedPlanningSceneRO ps(plan.planning_scene_monitor_);

  pick_place::PlacePlanPtr place_plan;
  try
  {
    place_plan = pick_place_->planPlace(plan.planning_scene_, goal);
  }
  catch (std::exception& ex)
  {
    ROS_ERROR_NAMED("manipulation", "Pick&place threw an exception: %s", ex.what());
  }

  if (place_plan)
  {
    const std::vector<pick_place::ManipulationPlanPtr>& success = place_plan->getSuccessfulManipulationPlans();
    if (success.empty())
    {
      plan.error_code_ = place_plan->getErrorCode();
    }
    else
    {
      const pick_place::ManipulationPlanPtr& result = success.back();
      plan.plan_components_ = result->trajectories_;
      if (result->id_ < goal.place_locations.size())
        action_res->place_location = goal.place_locations[result->id_];
      plan.error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
      action_res->planning_time = place_plan->getLastPlanTime();
    }
  }
  else
  {
    plan.error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
  }

  return plan.error_code_.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
}
示例#29
0
void
pcl::gpu::PseudoConvexHull3D::reconstruct (const Cloud &cloud, DeviceArray2D<int>& vertexes)
{
    const device::Cloud& c = (const device::Cloud&)cloud;

    device::FacetStream& fs = impl_->fs;
    device::PointStream ps(c);

    ps.computeInitalSimplex();

    device::InitalSimplex simplex = ps.simplex;

    fs.setInitialFacets(ps.simplex);
    ps.initalClassify();

    for(;;)
    {
        //new external points number
        ps.cloud_size = ps.searchFacetHeads(fs.facet_count, fs.head_points);
        if (ps.cloud_size == 0)
            break;

        fs.compactFacets();
        ps.classify(fs);

        if (!fs.canSplit())
            throw PCLException("Can't split facets, please enlarge default buffer", __FILE__, "", __LINE__);

        fs.splitFacets();
    }

    int ecount;
    int fcount = fs.facet_count;
    fs.empty_count.download(&ecount);

    vertexes.create(3, fcount + ecount);
    DeviceArray2D<int> subf(3, fcount, vertexes.ptr(),        vertexes.step());
    DeviceArray2D<int> sube(3, ecount, vertexes.ptr()+fcount, vertexes.step());

    DeviceArray2D<int>(3, fcount, fs.verts_inds.ptr(), fs.verts_inds.step()).copyTo(subf);
    DeviceArray2D<int>(3, ecount, fs.empty_facets.ptr(), fs.empty_facets.step()).copyTo(sube);
}
示例#30
0
文件: u1.c 项目: thomdabeast/CS460-1
main(int argc, char *argv[])
{ 
  char name[64]; int pid, cmd, segment, i;
  pid = getpid();
  color = 0x000B + (pid % 5);  // avoid black on black baground

  printf("enter main() : argc = %d\n", argc);
  for (i=0; i<argc; i++)
    printf("argv[%d] = %s\n", i, argv[i]);
 
  while(1){
       pid = getpid();
       color = 0x000B + (pid % 5);
       segment = (pid+1)*0x1000;   
       printf("==============================================\n");
       printf("I am proc %din U mode: segment=%x\n", pid, segment);
       show_menu();
       printf("Command ? ");
       gets(name); 
       if (name[0]==0) 
           continue;

       cmd = find_cmd(name);

       switch(cmd){
           case 0 : getpid();   break;
           case 1 : ps();       break;
           case 2 : chname();   break;
           case 3 : kmode();    break;
           case 4 : kswitch();  break;
           case 5 : wait();     break;

           case 6 : exit();     break;
           case 7 : fork();     break;
           case 8 : exec();     break;

           case 9:  chcolor(); break;

           default: invalid(name); break;
       } 
  }
}