MCPcopy Create free account
hub / github.com/Kitware/VTK / Add1DSphericalCoordinates

Method Add1DSphericalCoordinates

IO/NetCDF/vtkNetCDFCFReader.cxx:1411–1488  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1409
1410//------------------------------------------------------------------------------
1411void 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]);

Callers 1

RequestDataMethod · 0.95

Calls 14

GetDimensionInfoMethod · 0.95
AddStructuredCellsMethod · 0.95
minFunction · 0.50
cosFunction · 0.50
sinFunction · 0.50
AllocateMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetValueMethod · 0.45
GetBoundsMethod · 0.45
GetRangeMethod · 0.45
InsertNextPointMethod · 0.45

Tested by

no test coverage detected