------------------------------------------------------------------------------
| 1409 | |
| 1410 | //------------------------------------------------------------------------------ |
| 1411 | void vtkNetCDFCFReader::Add1DSphericalCoordinates(vtkPoints* points, const int extent[6]) |
| 1412 | { |
| 1413 | points->SetDataTypeToDouble(); |
| 1414 | points->Allocate( |
| 1415 | (extent[1] - extent[0] + 1) * (extent[3] - extent[2] + 1) * (extent[5] - extent[4] + 1)); |
| 1416 | |
| 1417 | vtkDoubleArray* coordArrays[3]; |
| 1418 | for (vtkIdType i = 0; i < this->LoadingDimensions->GetNumberOfTuples(); i++) |
| 1419 | { |
| 1420 | int dim = this->LoadingDimensions->GetValue(i); |
| 1421 | coordArrays[i] = this->GetDimensionInfo(dim)->GetBounds(); |
| 1422 | } |
| 1423 | |
| 1424 | int longitudeDim, latitudeDim, verticalDim; |
| 1425 | this->IdentifySphericalCoordinates( |
| 1426 | this->LoadingDimensions, longitudeDim, latitudeDim, verticalDim); |
| 1427 | |
| 1428 | if ((longitudeDim < 0) || (latitudeDim < 0)) |
| 1429 | { |
| 1430 | vtkErrorMacro(<< "Internal error: treating non spherical coordinates as if" |
| 1431 | << " they were spherical."); |
| 1432 | return; |
| 1433 | } |
| 1434 | |
| 1435 | // Check the height scale and bias. |
| 1436 | double vertScale = this->VerticalScale; |
| 1437 | double vertBias = this->VerticalBias; |
| 1438 | if (verticalDim >= 0) |
| 1439 | { |
| 1440 | double* verticalRange = coordArrays[verticalDim]->GetRange(); |
| 1441 | if ((verticalRange[0] * vertScale + vertBias < 0) || |
| 1442 | (verticalRange[1] * vertScale + vertBias < 0)) |
| 1443 | { |
| 1444 | vertBias = -std::min(verticalRange[0], verticalRange[1]) * vertScale; |
| 1445 | } |
| 1446 | } |
| 1447 | else |
| 1448 | { |
| 1449 | if (vertScale + vertBias <= 0) |
| 1450 | { |
| 1451 | vertScale = 1.0; |
| 1452 | vertBias = 0.0; |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | int ijk[3]; |
| 1457 | for (ijk[0] = extent[4]; ijk[0] <= extent[5]; ijk[0]++) |
| 1458 | { |
| 1459 | for (ijk[1] = extent[2]; ijk[1] <= extent[3]; ijk[1]++) |
| 1460 | { |
| 1461 | for (ijk[2] = extent[0]; ijk[2] <= extent[1]; ijk[2]++) |
| 1462 | { |
| 1463 | double lon, lat, h; |
| 1464 | if (verticalDim >= 0) |
| 1465 | { |
| 1466 | lon = coordArrays[longitudeDim]->GetValue(ijk[longitudeDim]); |
| 1467 | lat = coordArrays[latitudeDim]->GetValue(ijk[latitudeDim]); |
| 1468 | h = coordArrays[verticalDim]->GetValue(ijk[verticalDim]); |
no test coverage detected