Solids functions

FV = cube(r=1.0; radius=1.0, origin=(0.0, 0.0, 0.0))

Create a cube mesh with radius r.

  • radius: the keyword radius is an alternative to the positional argument r.

  • origin: A tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

FV = cylinder(r, h; base=0.0, center=(0.0, 0.0, 0.0), geog=false, unit="m", np=36) -> GMTfv

Create a cylinder with radius r and height h.

Args

  • r: The radius of the cylinder. For geographical cylinders, the default is meters. But see unit below.

  • h: The height of the cylinder. It should be in the same unit as r.

Kwargs

  • base: The base height of the cylinder. Default is 0.

  • center: A 3-element array or tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

  • closed: If true (the default), close the cylinder at top and bottom.

  • geog: If true, create a cylinder in geographical coordinates.

  • unit: For geographical cylinders only.If radius is not in meters use one of unit=:km, or unit=:Nautical or unit=:Miles

  • np: The number of vertices in the circle. Default is 36.

Return a Faces-Vertices dataset.

Example

	FV = cylinder(50, 100)
	viz(FV)
FV = dodecahedron(r=1.0; radius=1.0, origin=(0.0, 0.0, 0.0))

Create an dodecahedron mesh with radius r.

  • radius: the keyword radius is an alternative to the positional argument r.

  • origin: A tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

FV = extrude(shape::Matrix{<:AbstractFloat}, h; base=0.0, closed=true) -> GMTfv

Create an extruded 2D/3D shape.

Args

  • shape: The shape to extrude. It can be a 2D polygon or a 3D polygon defined by a Mx2 or Mx3 matrix or a GMTdataset

  • h: The height of the extrusion. Same units as in shape.

Kwargs

  • base: The base height of the 2D shape to extrude. Default is 0. Ignored if the shape is a 3D polygon.

  • closed: If true (the default), close the shapre at top and bottom.

FV = fv2fv(F, V; proj="", proj4="", wkt="", epsg=0) -> GMTfv

Create a FacesVerices object from a matrix of faces indices and another matrix of vertices (a Mx3 matrix).

  • F: A matrix of faces indices or a vector of matrices when defining more than one body.

  • V: A Mx3 matrix of vertices.

  • proj or proj4: A proj4 string for setting the Coordinate Referencing System

  • wkt: A WKT SRS.

  • epsg: Same as proj but using an EPSG code

When using Meshing.jl we can use the output of the $isosurface$ function, "verts, faces" as input to this function.

  • F: A vector of Tuple{Int, Int, Int} with the body faces indices

  • V: A vector of Tuple{Float64, Float64, Float64} with the body vertices

Example

gyroid(v) = cos(v[1])*sin(v[2])+cos(v[2])*sin(v[3])+cos(v[3])*sin(v[1]);
gyroid_shell(v) = max(gyroid(v)-0.4,-gyroid(v)-0.4);
xr,yr,zr = ntuple(_ -> LinRange(0,pi*4,50), 3);
A = [gyroid_shell((x,y,z)) for x in xr, y in yr, z in zr];
A[1,:,:] .= 1e10; A[:,1,:] .= 1e10; A[:,:,1] .= 1e10; A[end,:,:] .= 1e10; A[:,end,:] .= 1e10; A[:,:,end] .= 1e10;
vts, fcs = isosurface(A, MarchingCubes());
FV = fv2fv(fcs, vts)
viz(FV, cmap=makecpt(T="0/1", cmap="darkgreen,lightgreen"))
D = grid2tri(G, G2=nothing; bottom=false, downsample=0, level=false, ratio=0.01,
             thickness=0.0, wall_only=false, top_only=false, geog=false)

Triangulates the surface defined by the grid G, and optionally the bottom surface G2, plus the vertical wall between them, or between G and constant level or a constant thickness. Optionally computes only the vertical wall or the full closed bodie (that is, including the bottom surface).

The output of this function can be used in $plot3d$ to create 3D views of volume layer.

NOTE: The G grid should have a out-skirt of NaNs, otherwise just use $grdview$ with the $N$ option.

Parameters

  • G: A GMTgrid object or a grid file name representing the surface to be triangulated.

  • G2: An optional second grid (or file name) representing the bottom surface of the layer. Using this option makes the thickness option be ignored.

Keywords

  • bottom: If true, fully close the body with the bottom surface. By default we don't do this because that surface is often not visible whem elevation view angle is positive. But we may want this if later we want to save this mesh in STL for importing in a 3D viewer software.

  • layer: If true, we interpret thickness option as meaning a contant level value. That is, the vertical wall is computed from the sides of G and a constant level provided via the thickness option.

  • downsample: If the grid is of too high resolution, files here get big and operations slow down with this and later figures may not benefit much. In those cases it is a good idea to downsample the grid. The downsample option accepts an integer reduction factor. downsample=2 will shrink the grid by a factor two in each dimention, downsample=3 will shrink it by a factor three etc.

  • geog: If the G grid has no referencing information but you know that it is in geographical coordinates set geog=true. This information will be added to the triangulation output and is usefull for plotting purposes.

  • ratio: A slightly tricky parameter that determines how close the computed concave hull is to the true concave hull. A value smaller to 0.005 seems to do it but we normally don't want that close because the vertical wall obtained from this will be too jagged. The default value of 0.01 seems to work well to get a smoother concave hull but one that still fits the objective of getting a nice vertical wall. May need tweaking for specific cases.

  • thickness: A scalar representing the layer thickness in the same units as those of the input grid. NOTE: this option is ignored when two grids are passed in input.

  • top_only: If true, only the triangulation of Gis returned.

  • wall_only: If true, only the vertical wall between G and G2, or G + thickness is computed and returned.

Returns

A vector of GMTdataset with the triangulated surface and vertical wall, or just the wall or the full closed body.

FV = icosahedron(r=1.0; radius=1.0, origin=(0.0, 0.0, 0.0))

Create an icosahedron mesh with radius r.

  • radius: the keyword radius is an alternative to the positional argument r.

  • origin: A tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

FV = octahedron(r=1.0; radius=1.0, origin=(0.0, 0.0, 0.0))

Create an octahedron mesh with radius r.

  • radius: the keyword radius is an alternative to the positional argument r.

  • origin: A tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

replicant(FV, kwargs...) -> Vector{GMTdataset}

Take a Faces-Vertices dataset describing a 3D body and replicate it N number of times with the option of assigning different colors and scales to each copy. The end result is a single Vector{GMTdataset} with the replicated body.

Parameters

  • FV: A Faces-Vertices dataset describing a 3D body.

  • kwargs:

    • replicate: A NamedTuple with one or more of the following fields: centers, a Mx3 Matrix with the centers of the copies; zcolor, a vector of length $size(centers, 1)$, specifying a variable that will be used together with the cmap option to assign a color of each copy (default is the $1:size(centers, 1)$); cmap, a GMTcpt object; scales, a scalar or a vector of $size(centers, 1)$, specifying the scale factor of each copy.

    • replicate: A Mx3 Matrix with the centers of the each copy.

    • replicate: A Tuple with a Matrix and a scalar or a vector. The first element is the centers Mx3 matrix and the second is the scale factor (or vector of factors).

    • view or perspective: Set the view angle for the replication. The default is 217.5/30. Surface elements that are not visible from this persective are eliminated.

Returns

A Vector{GMTdataset} with the replicated body. Normally, a triangulated surface.

Examples

FV = sphere();
D  = replicant(FV, replicate=(centers=rand(10,3), scales=0.1));

or, to plot them

viz(FV, replicate=(centers=rand(10,3)*10, scales=0.1))
FV = sphere(r=1; radius=1.0, n=1, center=(0.0, 0.0, 0.0))

Create a triangulated geodesic sphere.

Generates a geodesic sphere triangulation based on the number of refinement iterations n and the radius r. Geodesic spheres (aka Buckminster-Fuller spheres) are triangulations of a sphere that have near uniform edge lenghts. The algorithm starts with a regular icosahedron. Next this icosahedron is refined n times, while nodes are pushed to a sphere surface with radius r at each iteration.

  • radius: the keyword radius is an alternative to the positional argument r.

  • n: is the number of iterations used to obtain the sphere from the icosahedron.

  • center: A tuple of three numbers defining the center of the sphere.

Returns

A two elements vector of GMTdataset where first contains the vertices and the second the indices that define the faces.

FV = tetrahedron(r=1.0; radius=1.0, origin=(0.0, 0.0, 0.0))

Create a tetrahedron mesh with radius r.

  • radius: the keyword radius is an alternative to the positional argument r.

  • origin: A tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

FV = torus(; r=2.0, R=5.0, center=(0.0, 0.0, 0.0), nx=100, ny=50) -> GMTfv

Create a torus mesh with radius r.

  • r: the inner radius of the torus.

  • R: the outer radius of the torus.

  • center: A 3-element array or tuple of three numbers defining the origin of the body. Default is (0.0, 0.0, 0.0).

  • nx: the number of vertices in the xx direction.

  • ny: the number of vertices in the yy direction.

FV = surf2fv(X::Matrix{T}, Y::Matrix{T}, Z::Matrix{T}; proj="", proj4="", wkt="", epsg=0) -> GMTfv

Create a creates a three-dimensional FacesVerices object suitable for 3D plotting either of closed bodies or 3D surfaces. The values in matrix Z represent the heights above a grid in the x-y plane defined by X and Y

  • X,Y,Z: Three matrices of the same size and type float.

  • proj or proj4: A proj4 string for setting the Coordinate Referencing System

  • wkt: A WKT SRS.

  • epsg: Same as proj but using an EPSG code.

Example

X,Y = meshgrid(1:0.5:10,1.:20);
Z = sin.(X) .+ cos.(Y);
FV = surf2fv(X, Y, Z);
viz(FV)