pub fn make_surface(surf: &Surface3D) -> Box<Surface<Decimal, Decimal, Decimal>>Expand description
Creates a 3D surface representation wrapped in a Box, based on the input Surface3D structure.
This function converts the input Surface3D data into a Surface object, which includes the x, y, and z
coordinate mappings. If any of the x, y, or z coordinate vectors in the input are empty, it creates a
default 2x2 surface with all z values initialized to zero and x/y spanning the range [0, 1].
§Parameters
surf: A reference to aSurface3Dobject, which contains x, y, and z coordinate vectors and an optional name for the surface.
§Returns
- A
Boxcontaining aSurface<Decimal, Decimal, Decimal>object, where:xandyaxes are unique and sorted.zvalues are represented in a 2D matrix where rows correspond toyvalues and columns correspond toxvalues.
§Logic Details
-
Edge Case Handling: If any of
surf.x,surf.y, orsurf.zis empty, create a default 2x2 surface:- All z values are initialized to
Decimal::ZERO. - x and y coordinates are
[0, 1]. - The surface name remains as provided in the
surf.name.
- All z values are initialized to
-
Unique and Sorted Axes:
- Extract unique and sorted x and y coordinates using a
BTreeSet. - These unique x and y coordinates are then stored in vectors (
x_uniqueandy_unique).
- Extract unique and sorted x and y coordinates using a
-
Mapping Coordinates:
- Create mappings (
x_to_colandy_to_row) to translate x and y coordinates into column and row indices of thez_matrix. Each coordinate is mapped to its respective index in the
- Create mappings (