当前位置: 首页>>代码示例>>C++>>正文


C++ DataItem::bool_value方法代码示例

本文整理汇总了C++中DataItem::bool_value方法的典型用法代码示例。如果您正苦于以下问题:C++ DataItem::bool_value方法的具体用法?C++ DataItem::bool_value怎么用?C++ DataItem::bool_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataItem的用法示例。


在下文中一共展示了DataItem::bool_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

void PointsDataSeparator::run()
{
	// This shambles of a section retrieves all the various inputs.
	DataItem *pointsInput = get_dataitem("PointsInputComplete", true, DATAITEM_POINTSVECTORS_CPU_VECTOR);

	std::vector<std::vector<Hamtrans::Point> *> *points = (std::vector<std::vector<Hamtrans::Point> *> *) pointsInput->get_data();

	DataItem *parametersInput = get_dataitem("ParametersInput");
	DataItem *refreshedPoints = get_dataitem("PointsInput");

	Hamtrans::SeparationParameters *params;

	std::vector<std::vector<Hamtrans::Point> *> *outputPoints;

	// Handles the parameters (see if they're pre-existing).
	if(parametersInput->get_initialised()) {
		params = (Hamtrans::SeparationParameters *) parametersInput->get_data();
		outputPoints = (std::vector<std::vector<Hamtrans::Point> *> *) params->dataPointer;
	} else {
		params = new Hamtrans::SeparationParameters();
		outputPoints = new std::vector<std::vector<Hamtrans::Point> *>();
		params->dataPointer = outputPoints;
	}

	size_t perSet = 0 ;

	DataItem *maxPointsPerIteration = get_dataitem_optional("MaxPointsPerIteration");
	if(maxPointsPerIteration != NULL) {
		perSet = maxPointsPerIteration->integer_value();
	} else {
		perSet = PointsDataSeperatorLimits();
	}

	std::cerr << perSet << " points per iteration" << std::endl;

	std::vector<std::vector<Hamtrans::Point> *> *thisSubsetOut = new std::vector<std::vector<Hamtrans::Point> *>();

	// The next section handles the merging back in of new/modified points:
	if(parametersInput->get_initialised() && refreshedPoints->get_initialised())
	{
		std::vector<std::vector<Hamtrans::Point> *> *thisSubsetIn = (std::vector<std::vector<Hamtrans::Point> *> *) refreshedPoints->get_data();
		for(size_t i = 0; i < thisSubsetIn->size(); i++) {
			std::vector<Hamtrans::Point> *subVector = (*thisSubsetIn)[i];
			outputPoints->push_back(subVector);
		}
		delete thisSubsetIn;
		refreshedPoints->uninitialise();
		
	}
	
	// This section handles what happens when the original set has been exhausted.
	if(points->size() == 0)	{
		DataItem *infiniteLoop = get_dataitem_optional("InfiniteLoop");
		if(infiniteLoop != NULL && infiniteLoop->bool_value()) {
			std::cerr << "INF LOOP" << std::endl;
			delete params;
			params = new Hamtrans::SeparationParameters;

			std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>OUTPUT POINTS HAS " << outputPoints->size() << " sub vectors" << std::endl;

			points = outputPoints;
			outputPoints = new std::vector<std::vector<Hamtrans::Point> *>();
			params->dataPointer = outputPoints;

			pointsInput->set_data(points);

		} else {
			std::cerr << "Separate and merge complete." << std::endl;
			delete params;
			parametersInput->uninitialise();

			delete points;
			pointsInput->set_data(outputPoints);

			switch_destination_set();
			return ;
		}
	}
	
	// This section dispatches subsets of the original set for the Pipeline.
	size_t cummulative = 0;
	size_t numVectors = points->size();
	std::cout << "Separator has " << points->size() << " vectors." << std::endl;
	for(size_t i = 0; i < numVectors; i++)
	{
		std::cerr << (*points)[0]->size() << " points in the top vector " << i << std::endl;

		while((*points)[0]->size() == 0)
		{
			points->erase(points->begin());
			if(points->size() == 0)
				break;
		}

		if(points->size() == 0)
			break;

		size_t amount = std::min((*points)[0]->size(), perSet);
		amount = std::min(amount, perSet - cummulative);
		if(amount > 0) {
//.........这里部分代码省略.........
开发者ID:Trannosaur,项目名称:all-trannosaurs-code,代码行数:101,代码来源:PointsDataSeparator.cpp


注:本文中的DataItem::bool_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。