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


C++ vtkSmartPointer::GetArray方法代码示例

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


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

示例1: addPointData

void DataAggregator::addPointData(int pointIndex, PointCoordinates coordinates, int currentTimeStep,
                                  vtkSmartPointer<vtkPointData> pointData) {
	this->lastTimeIndex = currentTimeStep;

	switch (this->dataType) {
	case Data::PRECIPITATION: {
		vtkSmartPointer<vtkDataArray> abstractPrecipitationRateArray =
		    pointData->GetArray("precipitationRates");
		vtkSmartPointer<vtkFloatArray> precipitationRateArray = vtkFloatArray::SafeDownCast(
		            abstractPrecipitationRateArray);

		if (!precipitationRateArray) {
			return;
		}

		double currentPrecipitationRate = precipitationRateArray->GetValue(pointIndex);

		if (this->aggregatedData.contains(coordinates)) {
			// The point has already been looked at before
			PrecipitationAggregationValue* currentValue = static_cast<PrecipitationAggregationValue*>
			        (this->aggregatedData.value(coordinates));

			// Accumulate the precipitation rates over time, therefore getting the total amount of precipitation.
			// To do this, two assumptions are made:
			// 1. The precipitation amount at the beginning of the accumulation is zero.
			// 2. A data point constantly emits precipitation with its precipitation rate until new precipitation rate data is available.
			currentValue->setAccumulatedPrecipitation(currentValue->getAccumulatedPrecipitation() + ((1.0 *
			        (currentTimeStep - currentValue->getTimeIndex()) * this->timeResolution) *
			        currentValue->getLastPrecipitationRate()));
			currentValue->setTimeIndex(currentTimeStep);
			currentValue->setLastPrecipitationRate(currentPrecipitationRate);
		} else {
			// This is the first time a point with these coordinates shows up
			PrecipitationAggregationValue* newValue = new PrecipitationAggregationValue();
			newValue->setLastPrecipitationRate(currentPrecipitationRate);
			newValue->setTimeIndex(currentTimeStep);
			this->aggregatedData.insert(coordinates, newValue);
		}
		break;
	}
	case Data::TEMPERATURE: {
		vtkSmartPointer<vtkDataArray> abstractTemperatureArray = pointData->GetArray("temperatures");
		vtkSmartPointer<vtkFloatArray> temperatureArray = vtkFloatArray::SafeDownCast(
		            abstractTemperatureArray);

		if (!temperatureArray) {
			return;
		}

		double currentTemperature = temperatureArray->GetValue(pointIndex);

		if (this->aggregatedData.contains(coordinates)) {
			// The point has already been looked at before
			TemperatureAggregationValue* currentValue = static_cast<TemperatureAggregationValue*>
			        (this->aggregatedData.value(coordinates));

			// Calculate the arithmetric mean with the cumulative moving average method.
			// This is a bit more costly than the naive way to calculate the average but prevents huge numbers from showing up while summing up all values.
			currentValue->setAverageTemperature((currentTemperature + (currentValue->getTimeIndex() *
			                                     currentValue->getAverageTemperature())) / (currentValue->getTimeIndex() * 1.0 + 1));
			currentValue->setTimeIndex(currentValue->getTimeIndex() + 1);
		} else {
			// This is the first time a point with these coordinates shows up
			TemperatureAggregationValue* newValue = new TemperatureAggregationValue();
			newValue->setAverageTemperature(currentTemperature);
			newValue->setTimeIndex(1);
			this->aggregatedData.insert(coordinates, newValue);
		}
		break;
	}
	case Data::WIND: {
		vtkSmartPointer<vtkDataArray> abstractVelocitiesArray = pointData->GetArray("speeds");
		vtkSmartPointer<vtkFloatArray> velocitiesArray = vtkFloatArray::SafeDownCast(
		            abstractVelocitiesArray);
		vtkSmartPointer<vtkDataArray> abstractBearingsArray = pointData->GetArray("directions");
		vtkSmartPointer<vtkFloatArray> bearingsArray = vtkFloatArray::SafeDownCast(
		            abstractBearingsArray);

		if (!velocitiesArray || !bearingsArray) {
			return;
		}

		double currentVelocity = velocitiesArray->GetValue(pointIndex);
		double currentBearing = bearingsArray->GetValue(pointIndex);

		if (this->aggregatedData.contains(coordinates)) {
			// The point has already been looked at before
			WindAggregationValue* currentValue = static_cast<WindAggregationValue*>(this->aggregatedData.value(
			        coordinates));

			// Calculate the arithmetric mean with the cumulative moving average method.
			// This is a bit more costly than the naive way to calculate the average but prevents huge numbers from showing up while summing up all values.
			currentValue->setAverageVelocity((currentVelocity + (currentValue->getTimeIndex() *
			                                  currentValue->getAverageVelocity())) / (currentValue->getTimeIndex() * 1.0 + 1));
			currentValue->setAverageBearing((currentBearing + (currentValue->getTimeIndex() *
			                                 currentValue->getAverageBearing())) / (currentValue->getTimeIndex() * 1.0 + 1));
			currentValue->setTimeIndex(currentValue->getTimeIndex() + 1);
		} else {
			// This is the first time a point with these coordinates shows up
			WindAggregationValue* newValue = new WindAggregationValue();
//.........这里部分代码省略.........
开发者ID:Nuos,项目名称:STUPRO,代码行数:101,代码来源:DataAggregator.cpp


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