Esempio n. 1
0
void StyleBuilder::addFeature(const Feature& _feat, const DrawRule& _rule) {

    if (!checkRule(_rule)) { return; }

    switch (_feat.geometryType) {
        case GeometryType::points:
            for (auto& point : _feat.points) {
                addPoint(point, _feat.props, _rule);
            }
            break;
        case GeometryType::lines:
            for (auto& line : _feat.lines) {
                addLine(line, _feat.props, _rule);
            }
            break;
        case GeometryType::polygons:
            for (auto& polygon : _feat.polygons) {
                addPolygon(polygon, _feat.props, _rule);
            }
            break;
        default:
            break;
    }

}
Esempio n. 2
0
void iteration(struct GOL *gol)
{
	struct Cell *cell;
	unsigned int i;
	unsigned int count;
	unsigned int threadNum;
	double ccTime, wupTime, thTime;

	// TODO: it can be multithread?
	reviveCells(&gol->toRevive[0], gol->world);
	killCells(&gol->toKill[0], gol->world);

	ccTime = startMeasurement();
	#pragma omp parallel shared(gol) private(cell, count, threadNum, thTime)
	{
		thTime = startMeasurement();

		threadNum = omp_get_thread_num();

		for (cell = wit_first_split(&count, threadNum, gol->world);
		     wit_done_split(count, gol->world);
		     cell = wit_next_split(cell, &count, gol->numThreads))
		{
			switch (checkRule(cell, gol->rule)) {
			case GOL_REVIVE:
				addToList(cell, &gol->toRevive[threadNum]);
				break;
			case GOL_KILL:
				addToList(cell, &gol->toKill[threadNum]);
				break;
			case GOL_SURVIVE:
			case GOL_KEEP_DEAD:
			default:
				break;
			}
		}

		endMeasurement(thTime, threads[threadNum], gol->stats);
	}
	endMeasurement(ccTime, cellChecking, gol->stats);

	wupTime = startMeasurement();
	// Add lists
	for (i = 0; i < gol->numThreads; ++i) {
		reviveCells(&gol->toRevive[i], gol->world);
		freeList(&gol->toRevive[i]);
	}

	// Free lists
	for (i = 0; i < gol->numThreads; ++i) {
		killCells(&gol->toKill[i], gol->world);
		freeList(&gol->toKill[i]);
	}
	endMeasurement(wupTime, worldUpdate, gol->stats);
}
Esempio n. 3
0
void TypeRuleEngine::checkRules(int from)
{
    operationStarted();
    _rulesChecked = 0;

    // Full or partial check?
    if (from <= 0) {
        from = 0;
        _hits.fill(0, _rules.size());
        _rulesPerType.clear();
        for (int i = 0; i < _activeRules.size(); ++i)
            delete _activeRules[i];
        _activeRules.clear();
        _rulesToCheck = _rules.size();
    }
    else {
        _hits.resize(_rules.size());
        _rulesToCheck = _rules.size() - from;
    }

    if (!_symbols->factory().symbolsAvailable() || _rules.isEmpty())
        return;

    forceOperationProgress();
    OsSpecs specs(&_symbols->memSpecs());

    // Checking the rules from last to first assures that rules in the
    // _activeRules hash are processes first to last. That way, if multiple
    // rules match the same instance, the first rule takes precedence.
    for (int i = _rules.size() - 1; !interrupted() && i >= from; --i) {
        ++_rulesChecked;
        checkOperationProgress();

        checkRule(_rules[i], i, &specs);
    }

    operationStopped();
    operationProgress();
    shellEndl();
}
void PolylineStyleBuilder<V>::addFeature(const Feature& _feat, const DrawRule& _rule) {

    if (_feat.geometryType == GeometryType::points) { return; }
    if (!checkRule(_rule)) { return; }

    Parameters params = parseRule(_rule, _feat.props);

    if (params.fill.width[0] <= 0.0f && params.fill.width[1] <= 0.0f ) { return; }

    if (_feat.geometryType == GeometryType::lines) {
        // Line geometries are never clipped to tiles, so keep all segments
        params.keepTileEdges = true;

        for (auto& line : _feat.lines) {
            addMesh(line, params);
        }
    } else {
        for (auto& polygon : _feat.polygons) {
            for (const auto& line : polygon) {
                addMesh(line, params);
            }
        }
    }
}
Esempio n. 5
0
void Style::buildFeature(Tile& _tile, const Feature& _feat, const DrawRule& _rule) const {

    if (!checkRule(_rule)) { return; }

    bool visible;
    if (_rule.get(StyleParamKey::visible, visible) && !visible) {
        return;
    }

    auto& mesh = _tile.getMesh(*this);

    if (!mesh) {
        mesh.reset(newMesh());
    }

    switch (_feat.geometryType) {
        case GeometryType::points:
            for (auto& point : _feat.points) {
                buildPoint(point, _rule, _feat.props, *mesh, _tile);
            }
            break;
        case GeometryType::lines:
            for (auto& line : _feat.lines) {
                buildLine(line, _rule, _feat.props, *mesh, _tile);
            }
            break;
        case GeometryType::polygons:
            for (auto& polygon : _feat.polygons) {
                buildPolygon(polygon, _rule, _feat.props, *mesh, _tile);
            }
            break;
        default:
            break;
    }

}