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

Method AllocProjectedGeometry

IO/NetCDF/vtkMPASReader.cxx:1718–1817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716//------------------------------------------------------------------------------
1717
1718int vtkMPASReader::AllocProjectedGeometry()
1719{
1720 constexpr float BLOATFACTOR = .5;
1721 this->ModNumPoints = (int)floor(this->NumberOfPoints * (1.0 + BLOATFACTOR));
1722 this->ModNumCells = (int)floor(this->NumberOfCells * (1.0 + BLOATFACTOR)) + 1;
1723
1724 int varid;
1725 CHECK_VAR("lonCell", varid);
1726 this->PointX = new double[this->ModNumPoints];
1727 if (!this->Internals->ValidateDimensions(varid, false, 1, "nCells"))
1728 {
1729 return 0;
1730 }
1731 size_t start_pt[] = { 0 };
1732 size_t count_pt[] = { this->NumberOfPoints };
1733 if (this->Internals->nc_err(nc_get_vara_double(
1734 this->Internals->ncFile, varid, start_pt, count_pt, this->PointX + this->PointOffset)))
1735 {
1736 return 0;
1737 }
1738 // point 0 is 0.0
1739 this->PointX[0] = 0.0;
1740
1741 CHECK_VAR("latCell", varid);
1742 this->PointY = new double[this->ModNumPoints];
1743 if (!this->Internals->ValidateDimensions(varid, false, 1, "nCells"))
1744 {
1745 return 0;
1746 }
1747 if (this->Internals->nc_err(nc_get_vara_double(
1748 this->Internals->ncFile, varid, start_pt, count_pt, this->PointY + this->PointOffset)))
1749 {
1750 return 0;
1751 }
1752 // point 0 is 0.0
1753 this->PointY[0] = 0.0;
1754
1755 CHECK_VAR("cellsOnVertex", varid);
1756 this->OrigConnections = new int[this->NumberOfCells * this->PointsPerCell];
1757 // TODO Spec says dims should be '3', 'nVertices', but my example files
1758 // use nVertices, vertexDegree...
1759 if (!this->Internals->ValidateDimensions(varid, false, 2, "nVertices", "vertexDegree"))
1760 {
1761 return 0;
1762 }
1763 size_t start_conn[] = { 0, 0 };
1764 size_t count_conn[] = { this->NumberOfCells, this->PointsPerCell };
1765 if (this->Internals->nc_err(nc_get_vara_int(
1766 this->Internals->ncFile, varid, start_conn, count_conn, this->OrigConnections)))
1767 {
1768 return 0;
1769 }
1770
1771 // create my own list to include modified origConnections (due to
1772 // eliminating wraparound in the lat/lon projection) plus additional
1773 // cells added when mirroring cells that had previously wrapped around
1774
1775 this->ModConnections = new int[this->ModNumCells * this->PointsPerCell];

Callers 1

ReadAndOutputGridMethod · 0.95

Calls 6

nc_get_vara_doubleFunction · 0.85
nc_get_vara_intFunction · 0.85
ValidateDimensionsMethod · 0.80
nc_var_idMethod · 0.80
floorFunction · 0.50
nc_errMethod · 0.45

Tested by

no test coverage detected