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

Method AddUnstructuredSphericalCoordinates

IO/NetCDF/vtkNetCDFCFReader.cxx:1745–1774  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1743
1744//------------------------------------------------------------------------------
1745void vtkNetCDFCFReader::AddUnstructuredSphericalCoordinates(
1746 vtkUnstructuredGrid* unstructuredOutput, const int extent[6])
1747{
1748 // First load the data as rectilinear coordinates, and then convert them
1749 // to spherical coordinates. Not only does this reuse code, but it also
1750 // probably makes the locator more efficient this way.
1751 this->AddUnstructuredRectilinearCoordinates(unstructuredOutput, extent);
1752
1753 double height = 1.0 * this->VerticalScale + this->VerticalBias;
1754 if (height <= 0.0)
1755 {
1756 height = 1.0;
1757 }
1758
1759 vtkPoints* points = unstructuredOutput->GetPoints();
1760 vtkIdType numPoints = points->GetNumberOfPoints();
1761 for (vtkIdType pointId = 0; pointId < numPoints; pointId++)
1762 {
1763 double lonLat[3];
1764 points->GetPoint(pointId, lonLat);
1765 double lon = vtkMath::RadiansFromDegrees(lonLat[0]);
1766 double lat = vtkMath::RadiansFromDegrees(lonLat[1]);
1767
1768 double cartesianCoord[3];
1769 cartesianCoord[0] = height * cos(lon) * cos(lat);
1770 cartesianCoord[1] = height * sin(lon) * cos(lat);
1771 cartesianCoord[2] = height * sin(lat);
1772 points->SetPoint(pointId, cartesianCoord);
1773 }
1774}
1775
1776//------------------------------------------------------------------------------
1777int vtkNetCDFCFReader::ReadMetaData(int ncFD)

Callers 1

RequestDataMethod · 0.95

Calls 7

cosFunction · 0.50
sinFunction · 0.50
GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
SetPointMethod · 0.45

Tested by

no test coverage detected